-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
small updates to README to get demo to work #21
Open
DougAnderson444
wants to merge
2
commits into
ceramicnetwork:main
Choose a base branch
from
DougAnderson444:patch-1
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -55,7 +55,7 @@ Create a signed envelope block: | |||
```js | ||||
const signer = ES256KSigner(privkey) | ||||
// arbitrary data to DAG-CBOR encode, we get a: | ||||
// { cid:CID, linkedBlock: Uint8Array } | ||||
// { cid: CID, linkedBlock: Uint8Array } | ||||
const payloadBlock = await encodePayload(payload) | ||||
// sign the CID as a JWS using our signer | ||||
const jws = await createJWS(toJWSPayload(payloadBlock), signer) | ||||
|
@@ -105,7 +105,7 @@ const payloadBlock = await Block.create({ bytes: payloadBytes, cid: payloadCid, | |||
|
||||
## JWE Encryption Usage | ||||
|
||||
When using DAG-JOSE (for JWE or JWS) with js-IPFS, you will need to convert it from a raw multiformats style codec to a legacy IPLD codec using [blockcodec-to-ipld-format](https://github.com/ipld/js-blockcodec-to-ipld-format). | ||||
When using DAG-JOSE (for JWE or JWS) with js-IPFS, you will need to convert it from a raw multiformats style codec to a legacy IPLD codec using [ipld-format-to-blockcodec](https://github.com/ipld/js-ipld-format-to-blockcodec). | ||||
|
||||
_The following example is available in complete form in [example-ipfs.mjs](./example-ipfs.mjs)._ | ||||
|
||||
|
@@ -114,7 +114,7 @@ _A plain IPLD (without IPFS, for cases where you are managing the block store) v | |||
```js | ||||
// IPLD & IPFS | ||||
import { create as createIpfs } from 'ipfs' | ||||
import { convert as toLegacyIpld } from 'blockcodec-to-ipld-format' | ||||
import { convert } from 'ipld-format-to-blockcodec'; | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||
|
||||
import * as dagJose from 'dag-jose' | ||||
``` | ||||
|
@@ -144,13 +144,11 @@ import { generateKeyPairFromSeed } from '@stablelib/x25519' | |||
Set up js-IPFS: | ||||
|
||||
```js | ||||
const dagJoseIpldFormat = toLegacyIpld(dagJose) | ||||
|
||||
// Async setup tasks | ||||
async function setup () { | ||||
console.log('Starting IPFS ...') | ||||
// Instantiate an IPFS node, that knows how to deal with DAG-JOSE blocks | ||||
ipfs = await createIpfs({ ipld: { formats: [dagJoseIpldFormat] } }) | ||||
ipfs = await createIpfs(); | ||||
} | ||||
``` | ||||
|
||||
|
@@ -166,7 +164,7 @@ const storeEncrypted = async (payload, key) => { | |||
// encrypt into JWE container layout using secret key | ||||
const jwe = await createJWE(cleartext, [dirEncrypter]) | ||||
// let IPFS store the bytes using the DAG-JOSE codec and return a CID | ||||
const cid = await ipfs.dag.put(jwe, { format: dagJoseIpldFormat.codec, hashAlg: 'sha2-256' }) | ||||
const cid = await ipfs.dag.put(jwe, { format: dagJose.codec, hashAlg: 'sha2-256' }) | ||||
console.log(`Encrypted block CID: \u001b[32m${cid}\u001b[39m`) | ||||
return cid | ||||
} | ||||
|
@@ -206,7 +204,7 @@ const storeEncrypted = async (payload, pubkey) => { | |||
// encrypt into JWE container layout using public key | ||||
const jwe = await createJWE(cleartext, [asymEncrypter]) | ||||
// let IPFS store the bytes using the DAG-JOSE codec and return a CID | ||||
const cid = await ipfs.dag.put(jwe, { format: dagJoseIpldFormat.codec, hashAlg: 'sha2-256' }) | ||||
const cid = await ipfs.dag.put(jwe, { format: dagJose.codec, hashAlg: 'sha2-256' }) | ||||
console.log(`Encrypted block CID: \u001b[32m${cid}\u001b[39m`) | ||||
return cid | ||||
} | ||||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.