0.0.6 • Published 3 months ago

@cproto/did-plc-lib v0.0.6

Weekly downloads
-
License
MIT
Repository
github
Last release
3 months ago

@did-plc/lib - DID PLC Typescript Client Library

NPM Github CI Status

This library provides both a simple client for the PLC directory, and an implementation of the PLC method itself (using a cryptographically signed operation log).

Client Usage

Fetching account data from directory:

import * as plc from '@did-plc/lib'

client = new plc.Client('https://plc.directory')

let exampleDid = 'did:plc:yk4dd2qkboz2yv6tpubpc6co'

// current account data, in terse object format
const data = await client.getDocumentData(exampleDid)

// or, the full DID Document
const didDoc = await client.getDocument(exampleDid)

Registering a new DID PLC:

import { Secp256k1Keypair } from '@atproto/crypto'
import * as plc from '@did-plc/lib'

// please test against a sandbox or local development server
client = new plc.Client('http://localhost:2582')

let signingKey = await Secp256k1Keypair.create()
let rotationKey = await Secp256k1Keypair.create()

did = await client.createDid({
    signingKey: signingKey.did(),
    handle: 'handle.example.com',
    pds: 'https://pds.example.com',
    rotationKeys: [rotationKey.did()],
    signer: rotationKey,
})

License

MIT / Apache 2.0 dual-licensed.