3.0.2 • Published 3 days ago

@verida/vda-did v3.0.2

Weekly downloads
-
License
ISC
Repository
github
Last release
3 days ago

VDA DID

Provides a client side library for creating, updating and deleting Verida DID's that match the Verida DID specification.

You may consider using @verida/did-client.

Installation

yarn add @verida/vda-did @verida/did-document ethers

Usage

Create a DID

import { DIDDocument } from '@verida/did-document'
import { VdaDid } from '@verida/vda-did'
import { ethers } from 'ethers'

const wallet = ethers.Wallet.createRandom()
const DID_PRIVATE_KEY = wallet.privateKey
const DID_ADDRESS = wallet.address
const DID = `did:vda:testnet:${DID_ADDRESS}`
const DID_PK = wallet.publicKey

// Choose at least three endpoints from the Acacia testnet
// https://developers.verida.network/docs/infrastructure/networks
// (This will soon be decentralized and made available on-chain)
const ENDPOINTS = [
    `https://node1-euw6.gcp.devnet.verida.tech/did/${DID}`,
    `https://node2-euw6.gcp.devnet.verida.tech/did/${DID}`,
    `https://node3-euw6.gcp.devnet.verida.tech/did/${DID}`
]

const VDA_DID_CONFIG = {
    identifier: DID,
    signKey: DID_PRIVATE_KEY,
    callType: 'web3',
    web3Options: {

    }
}

const veridaApi = new VdaDid(VDA_DID_CONFIG)

const doc = new DIDDocument(DID, DID_PK)
doc.signProof(wallet.privateKey)

const publishedEndpoints = await veridaApi.create(doc, ENDPOINTS)
console.log(publishedEndpoints)

Update a DID

veridaApi.update(didDocument, controllerPrivateKey)

Note: controllerPrivateKey is optional and only needs to be specified if the DID Document controller is being changed.

Delete a DID

Deletes the DID configured in the constructor of this VdaDid instance.

veridaApi.delete()

Configuration

const veridaApi = new VdaDid(config: VdaDidConfigurationOptions) supports the following configuration:

export interface VdaDidConfigurationOptions {
    // DID (ie: did:vda:testnet:0x...)
    identifier: string;
    // Private key of the controller
    signKey: string;
    chainNameOrId?: 'testnet' | 'mainnet';
    callType: 'gasless' | 'web3';
    web3Options: VeridaWeb3ConfigurationOptions;
}

Where:

export interface Web3SelfTransactionConfig extends Web3GasConfiguration {
    // Blockchain (Polygon) private key for writing DID references
    privateKey?: string;
    // Blockchain RPC_URL (defaults to a common Polygon RPC_URL)
    rpcUrl?: string;
}
3.0.3

3 days ago

4.0.0-alpha.0

16 days ago

3.0.2

2 months ago

3.0.2-alpha.0

4 months ago

3.0.1

4 months ago

3.0.0

5 months ago

2.4.0-rc5

5 months ago

2.4.0-rc3

5 months ago

2.4.0-rc2

5 months ago

2.3.6

8 months ago

2.3.5

8 months ago

2.4.0-rc1

5 months ago

2.3.4-rc1

1 year ago

2.3.4-rc2

1 year ago

2.3.0

1 year ago

2.2.1

1 year ago

2.2.0

1 year ago

2.3.1

1 year ago

2.1.3

1 year ago

2.3.4

1 year ago

2.3.3

1 year ago

2.3.0-rc1

1 year ago

2.3.0-rc2

1 year ago

2.3.0-rc3

1 year ago

2.3.5-rc1

1 year ago

2.3.3-rc1

1 year ago

2.3.3-rc2

1 year ago

2.1.1

1 year ago

2.0.2

1 year ago

2.0.5

1 year ago

2.0.4

1 year ago

2.1.0

1 year ago

2.0.0

1 year ago

2.0.0-rc6

1 year ago

2.0.0-rc5

1 year ago

2.0.0-rc4

1 year ago

2.0.0-rc3

2 years ago

2.0.0-rc2

2 years ago

2.0.0-rc1

2 years ago