Utility functions for the dag-jose ipld codec
npm install dag-jose-utilsThis library provides utilities for using the DAG-JOSE IPLD codec. It uses DAG-CBOR to encode payloads and cleartexts to CIDs.
$ npm i --save dag-jose-utils
`Importing
`ts
import {
encodePayload,
prepareCleartext,
decodeCleartext,
encodeIdentityCID,
decodeIdentityCID,
toJWSPayload,
toJWSStrings
} from 'dag-jose-utils'
`API
$3
`ts
interface EncodedPayload {
cid: CID
linkedBlock: Uint8Array
}
`$3
Prepares a payload to be signed in a JWS. Note that you will need to encode the encodePayload.cid.bytes as base64url before signing.$3
Prepares a cleartext object to be encrypted in a JWE. By default the blockSize for padding is 24.$3
Decode a decrypted cleartext to an ipld object.$3
Encode an ipld object as a CID that uses the identity hash.$3
Decode an ipld object from a CID that uses the identity hash.$3
Transform an EncodedPayload (from encodePayload()) or a CID into a JWS string for use with createJWS() in did-jwt. The string form is simply the Base64url encoded form of the CID's byte representation.$3
Transform a DagJWS object from ipld-dag-jose into an array of strings for each signature in the object. The strings can then be verified using verifyJWS()` in did-jwt.