8000 GitHub - fossabot/js-did: A simple interface to interact with DIDs that conform to the DID-provider interface.
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

A simple interface to interact with DIDs that conform to the DID-provider interface.

Notifications You must be signed in to change notification settings

fossabot/js-did

 
 

Repository files navigation

DID

FOSSA Status

This library a simple interface to interact with DIDs that conform to the DID-provider interface.

Installation

npm install dids

Example usage

import { DID } from 'dids'
import IdentityWallet from 'identity-wallet'

// See https://github.com/3box/identity-wallet-js
const wallet = new IdentityWallet(async () => true, {})
const alice = new DID(wallet.getDidProvider())

// Authenticate with the provider
await alice.authenticate()

// Read the DID string - this will throw an error if the DID instance is not authenticated
const aliceDID = alice.DID

// Create a JWS - this will throw an error if the DID instance is not authenticated
// CIDs and Buffers will be encoded to string
const jws = await alice.createJWS({ hello: 'world', link: new CID(...), data: Buffer.from('12ed', 'hex') })

Interfaces and types

CreateJWSOptions

interface CreateJWSOptions {
  protected?: Record<string, any>
  pubKeyId?: string
}

API

DID class

did.authenticated

Returns boolean

did.DID

Accessing this property will throw an error if the instance is not authenticated

Returns string

did.authenticate()

Returns Promise<string>

did.createJWS()

The instance needs to be authenticated before calling this method

Arguments

  1. payload: Record<string, any>
  2. options?: CreateJWSOptions to specify the protected header and/or pubKeyId to use for signing

Returns Promise<string>

License

FOSSA Status

About

A simple interface to interact with DIDs that conform to the DID-provider interface.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 95.5%
  • JavaScript 4.5%
0