Skip to content
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

Update IPFS codec registration example #20

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

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
@@ -166,7 +163,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: '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
Member

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
Member

@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
@@ -166,7 +163,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: 'dag-jose', hashAlg: 'sha2-256' })
Copy link
Member

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
@@ -206,7 +203,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: 'dag-jose', hashAlg: 'sha2-256' })
Copy link
Member

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
@@ -246,7 +243,7 @@ const cleartext = prepareCleartext({ my: 'secret message' })

// 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
Member

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