-
Notifications
You must be signed in to change notification settings - Fork 9
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
base: main
Are you sure you want to change the base?
Conversation
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' }) |
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.
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
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.
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' }) |
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.
👌 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. |
@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. |
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.
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' }) |
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.
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' }) |
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.
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' }) |
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.
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' }) |
Update documentation to reflect that versions of js-IPFS greater than 0.40 support direct usage of multiformats codecs.