Skip to content

Commit

Permalink
Enable dag-jose decoder (#380)
Browse files Browse the repository at this point in the history
Enable dag-jose decoder

Co-authored-by: Russell Dempsey <1173416+SgtPooki@users.noreply.github.com>
  • Loading branch information
m0ar and SgtPooki authored Aug 31, 2023
1 parent 2caac4a commit 612d2b0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/lib/codec-importer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ export default async function codecImporter<T extends CodecDataTypes = CodecData
return import('multiformats/codecs/json')
case 'dag-json':
return import('@ipld/dag-json')
case 'dag-jose':
return {
decode: (await import('dag-jose')).decode as unknown as
((bytes: Uint8Array) => Promise<unknown>)
}
default:
throw new Error(`unsupported codec: ${codecCode}=${getCodecNameFromCode(codecCode)}`)
}
Expand Down
2 changes: 2 additions & 0 deletions src/lib/get-codec-name-from-code.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ export default function getCodecNameFromCode (code: number): string {
return 'json'
case multicodecs.DAG_JSON:
return 'dag-json'
case multicodecs.DAG_JOSE:
return 'dag-jose'
default:
// TODO: Remove dependency on multicodecs
return multicodecs.codeToName[code as multicodecs.CodecCode]
Expand Down

0 comments on commit 612d2b0

Please sign in to comment.