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

Missing IPLD format "dag-jose" #30

Closed
olnrt opened this issue May 22, 2021 · 1 comment
Closed

Missing IPLD format "dag-jose" #30

olnrt opened this issue May 22, 2021 · 1 comment

Comments

@olnrt
Copy link

olnrt commented May 22, 2021

Hello,

By following the README code, and this tutorial, I am faced with the dag-jose codec missing error.

import Ipfs from 'ipfs-core'
import dagJose from 'dag-jose'
import { convert } from 'blockcodec-to-ipld-format'
import { DID } from 'dids'
import { Ed25519Provider } from 'key-did-provider-ed25519'
import KeyResolver from 'key-did-resolver'

const dagJoseFormat = convert(dagJose)
ipfs = await Ipfs.create({ ipld: { formats: [dagJoseFormat] } })

const seed = fromString(SEED, 'base16')
const provider = new Ed25519Provider(seed)
const  did = new DID({ provider, resolver: KeyResolver.default.getResolver() })
await did.authenticate()

const { jws, linkedBlock } = await did.createDagJWS('test')
const jwsCid = await ipfs.dag.put(jws, { format: 'dag-jose', hashAlg: 'sha2-256' })

the dagJoseFormat looks like :

{
  codec: undefined,
  defaultHashAlg: 18,
  util: {
    serialize: [Function: serialize],
    deserialize: [Function: deserialize],
    cid: [AsyncFunction: cid]
  },
  resolver: { resolve: [Function (anonymous)], tree: [GeneratorFunction: tree] }
}

(I am surprised the dagJoseFormat.codec is undefined, and I've tried to 'force' it to 'dag-jose' with no success)

This throws the error :

Error: Missing IPLD format "dag-jose"
    at IPLDResolver.loadFormat (/dids/node_modules/ipfs-core/src/runtime/ipld.js:46:17)

With the following libs

    "blockcodec-to-ipld-format": "^1.0.0",
    "dag-jose": "^0.3.0",
    "dids": "^2.1.0",
    "ipfs-core": "^0.6.1",
    "key-did-provider-ed25519": "^1.1.0",
    "key-did-resolver": "^1.2.0",
    "uint8arrays": "^2.1.5"

I've found other issues telling this may happen, but with older dependencies, and I am surprised it can happen again with the ceramic blog tutorial and up to date code.

Last thing, I wonder why ipfs is directly used with dag+block, whereas I thought ceramic was the storage used with js-did. Is it possible to sign and encrypt documents directly in ceramic or is it planed ?
thanks.

@olnrt
Copy link
Author

olnrt commented Jun 1, 2021

this issue can be closed, as it is similar to ceramicnetwork/js-ceramic#1429 (comment)
Here, the import dagJose from 'dag-jose' embeds it in a default member. It implies to use const dagJoseFormat = convert(dagJose.default) to make everything work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant