Skip to content

Update IPFS codec registration example#20

Open
jbouwman wants to merge 3 commits intoceramicnetwork:mainfrom
jbouwman:ipfs-codec-doc-update
Open

Update IPFS codec registration example#20
jbouwman wants to merge 3 commits intoceramicnetwork:mainfrom
jbouwman:ipfs-codec-doc-update

Conversation

@jbouwman
Copy link

@jbouwman jbouwman commented Sep 7, 2021

Update documentation to reflect that versions of js-IPFS greater than 0.40 support direct usage of multiformats codecs.

Update documentation to reflect that versions of js-IPFS greater than 0.40 support direct usage of multiformats codecs.
README.md Outdated
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: 'dag-jose', hashAlg: 'sha2-256' })
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

best to use use dagJose.name since that's the internal matching that's going to happen in js-ipfs and the user can avoid one magic string

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const cid = await ipfs.dag.put(jwe, { format: 'dag-jose', hashAlg: 'sha2-256' })
const cid = await ipfs.dag.put(jwe, { format: dagJose.name, hashAlg: 'sha2-256' })

Copy link
Contributor

@rvagg rvagg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👌 nice
lgtm aside from the use of 'dag-jose' over dagJose.name as mentioned inline

@jbouwman
Copy link
Author

jbouwman commented Sep 8, 2021

ok_hand nice
lgtm aside from the use of 'dag-jose' over dagJose.name as mentioned inline

Done -- thank you for the review. I arrived here after stepping through https://blog.ceramic.network/how-to-store-signed-and-encrypted-data-on-ipfs/ which refers to the legacy codec wrapper. I wonder if there's a way to attach a note there mentioning the change.

@rvagg
Copy link
Contributor

rvagg commented Sep 8, 2021

@oed will know. There's been a lot of change in the entire IPLD (and therefore js-ipfs) stack this year but it should have stabilised now so this pattern should be good for the time being.

Copy link
Collaborator

@oed oed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this update!
Just a small change needed as already mentioned by @rvagg.

Regarding the blog post. I made a note to update it once we update to the latest js-ipfs in the js-ceramic code base.

README.md Outdated
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: 'dag-jose', hashAlg: 'sha2-256' })
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const cid = await ipfs.dag.put(jwe, { format: 'dag-jose', hashAlg: 'sha2-256' })
const cid = await ipfs.dag.put(jwe, { format: dagJose.name, hashAlg: 'sha2-256' })

README.md Outdated
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: 'dag-jose', hashAlg: 'sha2-256' })
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const cid = await ipfs.dag.put(jwe, { format: 'dag-jose', hashAlg: 'sha2-256' })
const cid = await ipfs.dag.put(jwe, { format: dagJose.name, hashAlg: 'sha2-256' })

README.md Outdated
// encrypt and put into ipfs
const jwe = jose.JWE.encrypt.flattened(cleartext, jwk, { alg: 'dir', enc: 'A128CBC-HS256' })
const cid = await ipfs.dag.put(jwe, { format: format.codec, hashAlg: 'sha2-256' })
const cid = await ipfs.dag.put(jwe, { format: 'dag-jose', hashAlg: 'sha2-256' })
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const cid = await ipfs.dag.put(jwe, { format: 'dag-jose', hashAlg: 'sha2-256' })
const cid = await ipfs.dag.put(jwe, { format: dagJose.name, hashAlg: 'sha2-256' })

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants