This library provides utilities for using the dag-jose ipld codec. It uses dag-cbor to encode payloads and cleartexts to CIDs.
First install the package
$ npm i --save dag-jose-utils
import {
encodePayload,
prepareCleartext,
decodeCleartext,
encodeIdentityCID,
decodeIdentityCID
} from 'dag-jose-utils'
interface EncodedPayload {
cid: CID
linkedBlock: Uint8Array
}
Prepares a payload to be signed in a JWS. Note that you will need to encode the encodePayload.cid.bytes
as base64url
before signing.
Prepares a cleartext object to be encrypted in a JWE. By default the blockSize for padding is 24.
Decode a decrypted cleartext to an ipld object.
Encode an ipld object as a CID that uses the identity hash.
Decode an ipld object from a CID that uses the identity hash.
MIT or APACHE