Socket
Socket
Sign inDemoInstall

dag-jose-utils

Package Overview
Dependencies
18
Maintainers
9
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    dag-jose-utils

Utility functions for the dag-jose ipld codec


Version published
Weekly downloads
8.9K
decreased by-2.33%
Maintainers
9
Created
Weekly downloads
 

Readme

Source

dag-jose-utils

This library provides utilities for using the DAG-JOSE IPLD codec. It uses DAG-CBOR to encode payloads and cleartexts to CIDs.

Installation

First install the package

$ npm i --save dag-jose-utils

Importing

import {
  encodePayload,
  prepareCleartext,
  decodeCleartext,
  encodeIdentityCID,
  decodeIdentityCID,
  toJWSPayload,
  toJWSStrings
} from 'dag-jose-utils'

API

EncodedPayload

interface EncodedPayload {
  cid: CID
  linkedBlock: Uint8Array
}

encodePayload(payload: Record<string, any>): Promise

Prepares a payload to be signed in a JWS. Note that you will need to encode the encodePayload.cid.bytes as base64url before signing.

prepareCleartext(cleartext: Record<string, any>, blockSize?: number): Uint8Array

Prepares a cleartext object to be encrypted in a JWE. By default the blockSize for padding is 24.

decodeCleartext(b: Uint8Array): Record<string, any>

Decode a decrypted cleartext to an ipld object.

encodeIdentityCID(obj: Record<string, any>): CID

Encode an ipld object as a CID that uses the identity hash.

decodeIdentityCID(cid: CID): Record<string, any>

Decode an ipld object from a CID that uses the identity hash.

toJWSPayload(payload: EncodedPayload | CID): string

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.

toJWSStrings(jose: any): string[]

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.

Maintainer

Joel Thorstensson

License

MIT or APACHE

Keywords

FAQs

Last updated on 03 Jan 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc