Update IPFS codec registration example#20
Update IPFS codec registration example#20jbouwman wants to merge 3 commits intoceramicnetwork:mainfrom
Conversation
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' }) |
There was a problem hiding this comment.
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.
| 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' }) |
rvagg
left a comment
There was a problem hiding this comment.
👌 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. |
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' }) |
There was a problem hiding this comment.
| 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' }) |
There was a problem hiding this comment.
| 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' }) |
There was a problem hiding this comment.
| 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.