SDK — DID Operations
SDK — DID Operations
Source: packages/sdk/src/did.ts.
Method matrix
| SDK method | Endpoint | Notes |
|---|---|---|
createDID(options?) | POST /api/v1/dids | Auto-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-key | keyType defaults Ed25519 |
addDelegate(did, params) | POST /api/v1/dids/{did}/delegates | ERC-1056 inspired |
listDelegates(did) | GET /api/v1/dids/{did}/delegates | |
revokeDelegate(did, params) | DELETE /api/v1/dids/{did}/delegates | Body in DELETE |
setAttribute(did, params) | POST /api/v1/dids/{did}/attributes | |
revokeAttribute(did, params) | DELETE /api/v1/dids/{did}/attributes |
Example: create + resolve + rotate
1 import { IDAClient } from '@infinia/ida-sdk'; 2 3 const client = new IDAClient({ apiUrl: 'https://adid.dev', apiKey: jwt }); 4 5 // Create 6 const created = await client.createDID({ 7 keyType: 'ed25519', 8 services: [{ 9 id: '#didcomm-1', 10 type: 'DIDCommMessaging', 11 serviceEndpoint: 'https://adid.dev/api/v1/didcomm/receive', 12 }], 13 }); 14 console.log('Created:', created.did); 15 16 // Resolve (chain-cached) 17 const doc = await client.resolveDID(created.did); 18 console.log('Doc:', JSON.stringify(doc, null, 2)); 19 20 // Universal resolve (works for did:key, did:web, did:ethr too) 21 const { didDocument } = await client.resolveAny(created.did); 22 23 // Rotate key (proof must be a base64url signature over server-issued nonce) 24 await client.rotateKey(created.did, 'Ed25519', currentKeyProofBase64);
Example: delegate management
1 const delegate = await client.addDelegate(created.did, { 2 delegateType: 'sigAuth', 3 delegate: '0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1', 4 validity: 86_400, // 24 h in seconds 5 }); 6 7 const list = await client.listDelegates(created.did); 8 9 await client.revokeDelegate(created.did, { 10 delegateType: 'sigAuth', 11 delegate: '0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1', 12 });