@cproto/did-plc-lib
TypeScript icon, indicating that this package has built-in type declarations

0.0.6 • Public • Published

@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.

Package Sidebar

Install

npm i @cproto/did-plc-lib

Weekly Downloads

18

Version

0.0.6

License

MIT

Unpacked Size

4.27 MB

Total Files

32

Last publish

Collaborators

  • aeroxander