Skip to navigation

SDK — DID Operations

View as Markdown

Source: packages/sdk/src/did.ts.

Method matrix

SDK methodEndpointNotes
createDID(options?)POST /api/v1/didsAuto-maps keyType: 'ed25519' → Ed25519
resolveDID(did)GET /api/v1/dids/{did}Auth required
resolveAny(did)GET /api/v1/dids/resolve/{did}Public, multi-method
updateDID(did, document)PUT /api/v1/dids/{did}Partial document
deactivateDID(did)DELETE /api/v1/dids/{did}Irreversible
rotateKey(did, keyType?, currentKeyProof?)POST /api/v1/dids/{did}/rotate-keykeyType defaults Ed25519
addDelegate(did, params)POST /api/v1/dids/{did}/delegatesERC-1056 inspired
listDelegates(did)GET /api/v1/dids/{did}/delegates
revokeDelegate(did, params)DELETE /api/v1/dids/{did}/delegatesBody in DELETE
setAttribute(did, params)POST /api/v1/dids/{did}/attributes
revokeAttribute(did, params)DELETE /api/v1/dids/{did}/attributes

Example: create + resolve + rotate

import { IDAClient } from '@infinia/ida-sdk';
const client = new IDAClient({ apiUrl: 'https://adid.dev', apiKey: jwt });
// Create
const created = await client.createDID({
keyType: 'ed25519',
services: [{
id: '#didcomm-1',
type: 'DIDCommMessaging',
serviceEndpoint: 'https://adid.dev/api/v1/didcomm/receive',
}],
});
console.log('Created:', created.did);
// Resolve (chain-cached)
const doc = await client.resolveDID(created.did);
console.log('Doc:', JSON.stringify(doc, null, 2));
// Universal resolve (works for did:key, did:web, did:ethr too)
const { didDocument } = await client.resolveAny(created.did);
// Rotate key (proof must be a base64url signature over server-issued nonce)
await client.rotateKey(created.did, 'Ed25519', currentKeyProofBase64);

Example: delegate management

const delegate = await client.addDelegate(created.did, {
delegateType: 'sigAuth',
delegate: '0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1',
validity: 86_400, // 24 h in seconds
});
const list = await client.listDelegates(created.did);
await client.revokeDelegate(created.did, {
delegateType: 'sigAuth',
delegate: '0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1',
});