DID Resolution
DID resolution is the process of taking a DID string and producing the corresponding DID Document — the public record that contains verification keys, authentication methods, and service endpoints.
Resolution Flow
- Parse DID — extract the method name (e.g.,
sns,pki,web,key) - Route to handler — select the method-specific resolver
- Fetch DID Document — the handler queries the appropriate source (on-chain, HTTP, certificate store)
- Extract public key — the relying party reads verification methods from the document
DID Document Structure
JSON
{ "@context": ["https://www.w3.org/ns/did/v1"], "id": "did:sns:attestto.sol", "verificationMethod": [{ "id": "did:sns:attestto.sol#key-1", "type": "Ed25519VerificationKey2020", "controller": "did:sns:attestto.sol", "publicKeyMultibase": "z6Mkf5rGMoatrSj1f..." }], "authentication": ["did:sns:attestto.sol#key-1"], "assertionMethod": ["did:sns:attestto.sol#key-1"] }
| Field | Description |
|---|---|
id | The DID itself |
verificationMethod | Array of public keys and their types |
authentication | Keys authorized for authentication (login) |
assertionMethod | Keys authorized for signing claims (credential issuance) |
Universal Resolver Pattern
Rather than hard-coding each DID method, a universal resolver dispatches
to the correct handler based on the method prefix. Attestto's resolver
supports did:sns, did:pki, did:web,
did:key, and did:sol.
The wallet-identity-resolver Package
bash
npm install @attestto/wallet-identity-resolver
Code Example
TypeScript
import { resolve } from '@attestto/wallet-identity-resolver' // Resolve a DID to its DID Document const doc = await resolve('did:sns:attestto.sol') // Extract the first public key const key = doc.verificationMethod[0] console.log('Key type:', key.type) console.log('Public key:', key.publicKeyMultibase) // Check if a specific key is authorized for authentication const canAuth = doc.authentication.includes(key.id) console.log('Authorized for auth:', canAuth)
The resolver can run in both browser and Node.js environments. For production use, point it at your own resolver endpoint to control caching and availability.