@peac/adapter-did 0.12.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/resolver.ts","../src/errors.ts","../src/multicodec.ts","../src/did-key.ts","../src/did-web.ts","../src/extract-key.ts","../src/cache.ts"],"names":[],"mappings":";AAuCO,SAAS,wBAAwB,SAAA,EAAuC;AAC7E,EAAA,OAAO;AAAA,IACL,OAAA,EAAS,UAAU,OAAA,CAAQ,CAAC,MAAM,CAAC,GAAG,CAAA,CAAE,OAAO,CAAC,CAAA;AAAA,IAEhD,MAAM,QAAQ,GAAA,EAA2C;AACvD,MAAA,MAAM,MAAA,GAAS,cAAc,GAAG,CAAA;AAChC,MAAA,IAAI,CAAC,MAAA,EAAQ;AACX,QAAA,OAAO;AAAA,UACL,WAAA,EAAa,IAAA;AAAA,UACb,qBAAA,EAAuB,EAAE,KAAA,EAAO,YAAA,EAAa;AAAA,UAC7C,qBAAqB;AAAC,SACxB;AAAA,MACF;AAEA,MAAA,KAAA,MAAW,YAAY,SAAA,EAAW;AAChC,QAAA,IAAI,QAAA,CAAS,OAAA,CAAQ,QAAA,CAAS,MAAM,CAAA,EAAG;AACrC,UAAA,OAAO,QAAA,CAAS,QAAQ,GAAG,CAAA;AAAA,QAC7B;AAAA,MACF;AAEA,MAAA,OAAO;AAAA,QACL,WAAA,EAAa,IAAA;AAAA,QACb,qBAAA,EAAuB,EAAE,KAAA,EAAO,oBAAA,EAAqB;AAAA,QACrD,qBAAqB;AAAC,OACxB;AAAA,IACF;AAAA,GACF;AACF;AAKA,SAAS,cAAc,GAAA,EAA4B;AACjD,EAAA,IAAI,CAAC,GAAA,CAAI,UAAA,CAAW,MAAM,GAAG,OAAO,IAAA;AACpC,EAAA,MAAM,KAAA,GAAQ,GAAA,CAAI,KAAA,CAAM,GAAG,CAAA;AAC3B,EAAA,IAAI,KAAA,CAAM,MAAA,GAAS,CAAA,EA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AAW,GAAA,EAAmB;AAC5B,IAAA,IAAA,CAAK,KAAA,CAAM,OAAO,GAAG,CAAA;AAAA,EACvB;AAAA;AAAA,EAGA,KAAA,GAAc;AACZ,IAAA,IAAA,CAAK,MAAM,KAAA,EAAM;AAAA,EACnB;AAAA;AAAA,EAGA,IAAI,IAAA,GAAe;AACjB,IAAA,OAAO,KAAK,KAAA,CAAM,IAAA;AAAA,EACpB;AACF;AAUA,SAAS,gBAAgB,MAAA,EAAkD;AACzE,EAAA,OAAO,gBAAgB,MAAM,CAAA;AAC/B","file":"index.mjs","sourcesContent":["/**\n * DID Resolver interface and composite resolver.\n *\n * Pluggable resolver architecture: callers instantiate and configure\n * resolvers explicitly (DD-52: no ambient key discovery).\n */\n\nimport type { DIDResolutionResult } from './types.js';\n\n// ---------------------------------------------------------------------------\n// Interface\n// ---------------------------------------------------------------------------\n\n/**\n * Interface for DID resolvers.\n *\n * Each resolver handles one or more DID methods (e.g., ['key'], ['web']).\n * Resolution returns a W3C DID Resolution Result.\n */\nexport interface DIDResolver {\n /** DID methods this resolver handles (e.g., ['key'] for did:key) */\n readonly methods: readonly string[];\n /** Resolve a DID to its DID Document */\n resolve(did: string): Promise<DIDResolutionResult>;\n}\n\n// ---------------------------------------------------------------------------\n// Composite Resolver\n// ---------------------------------------------------------------------------\n\n/**\n * Create a composite resolver that delegates to method-specific resolvers.\n *\n * Tries resolvers in order by method match. The first resolver whose\n * `methods` array includes the DID's method handles the resolution.\n *\n * @param resolvers - Array of method-specific resolvers\n * @returns A composite resolver that delegates by method\n */\nexport function createCompositeResolver(resolvers: DIDResolver[]): DIDResolver {\n return {\n methods: resolvers.flatMap((r) => [...r.methods]),\n\n async resolve(did: string): Promise<DIDResolutionResult> {\n const method = extractMethod(did);\n if (!method) {\n return {\n didDocument: null,\n didResolutionMetadata: { error: 'invalidDid' },\n didDocumentMetadata: {},\n };\n }\n\n for (const resolver of resolvers) {\n if (resolver.methods.includes(method)) {\n return resolver.resolve(did);\n }\n }\n\n return {\n didDocument: null,\n didResolutionMetadata: { error: 'methodNotSupported' },\n didDocumentMetadata: {},\n };\n },\n };\n}\n\n/**\n * Extract the method from a DID string (e.g., \"key\" from \"did:key:z6Mk...\").\n */\nfunction extractMethod(did: string): string | null {\n if (!did.startsWith('did:')) return null;\n const parts = did.split(':');\n if (parts.length < 3) return null;\n return parts[1];\n}\n","/**\n * DID adapter error types.\n *\n * Uses error codes registered in specs/kernel/errors.json (PR3 #571).\n */\n\n/** DID-specific error codes (registered in kernel) */\nexport type DIDErrorCode =\n | 'E_DID_RESOLUTION_FAILED'\n | 'E_DID_DOCUMENT_INVALID'\n | 'E_DID_KEY_NOT_FOUND'\n | 'E_DID_UNSUPPORTED_METHOD'\n | 'E_DID_DEACTIVATED'\n | 'E_DID_KEY_AMBIGUOUS';\n\n/**\n * Error thrown by DID adapter operations.\n */\nexport class DIDError extends Error {\n readonly code: DIDErrorCode;\n\n constructor(code: DIDErrorCode, message: string) {\n super(message);\n this.name = 'DIDError';\n this.code = code;\n }\n}\n","/**\n * Ed25519 multicodec prefix parsing.\n *\n * Supports both multibase forms allowed by the did:key spec (CCG v0.9):\n * - 'z' prefix: base58btc encoding\n * - 'u' prefix: base64url encoding\n *\n * The Ed25519 multicodec prefix is 0xed01 as a varint (2 bytes).\n * After stripping the 2-byte prefix, the remaining 32 bytes are\n * the raw Ed25519 public key.\n */\n\nimport { DIDError } from './errors.js';\n\n// ---------------------------------------------------------------------------\n// Constants\n// ---------------------------------------------------------------------------\n\n/** Ed25519 multicodec prefix as varint: [0xed, 0x01] */\nconst ED25519_MULTICODEC_PREFIX = new Uint8Array([0xed, 0x01]);\n\n/** Expected Ed25519 public key length in bytes */\nconst ED25519_KEY_LENGTH = 32;\n\n/** Total expected length: 2 byte prefix + 32 byte key */\nconst ED25519_MULTICODEC_LENGTH = ED25519_MULTICODEC_PREFIX.length + ED25519_KEY_LENGTH;\n\n// ---------------------------------------------------------------------------\n// Base58btc decoder (minimal, for 'z' prefix multibase)\n// ---------------------------------------------------------------------------\n\nconst BASE58_ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';\nconst BASE58_MAP = new Map<string, number>();\nfor (let i = 0; i < BASE58_ALPHABET.length; i++) {\n BASE58_MAP.set(BASE58_ALPHABET[i], i);\n}\n\nfunction base58btcDecode(input: string): Uint8Array {\n if (input.length === 0) return new Uint8Array(0);\n\n // Count leading '1's (zero bytes)\n let zeros = 0;\n while (zeros < input.length && input[zeros] === '1') {\n zeros++;\n }\n\n // Decode\n const size = Math.ceil((input.length * 733) / 1000) + 1;\n const b256 = new Uint8Array(size);\n let length = 0;\n\n for (let i = zeros; i < input.length; i++) {\n const value = BASE58_MAP.get(input[i]);\n if (value === undefined) {\n throw new DIDError('E_DID_DOCUMENT_INVALID', `Invalid base58btc character: ${input[i]}`);\n }\n let carry = value;\n for (let j = 0; j < length || carry > 0; j++) {\n carry += 58 * (b256[j] || 0);\n b256[j] = carry % 256;\n carry = Math.floor(carry / 256);\n if (j >= length) length = j + 1;\n }\n }\n\n // Build result with leading zeros\n const result = new Uint8Array(zeros + length);\n for (let i = 0; i < length; i++) {\n result[zeros + length - 1 - i] = b256[i];\n }\n return result;\n}\n\n// ---------------------------------------------------------------------------\n// Base64url decoder (for 'u' prefix multibase)\n// ---------------------------------------------------------------------------\n\nfunction base64urlDecode(input: string): Uint8Array {\n return new Uint8Array(Buffer.from(input, 'base64url'));\n}\n\n// ---------------------------------------------------------------------------\n// Public API\n// ---------------------------------------------------------------------------\n\n/**\n * Extract an Ed25519 public key from a multibase-encoded multicodec value.\n *\n * Supports both multibase prefixes:\n * - 'z': base58btc (e.g., did:key:z6Mk...)\n * - 'u': base64url\n *\n * @param multibaseValue - The multibase-encoded value (including prefix character)\n * @returns 32-byte Ed25519 public key\n * @throws DIDError if not Ed25519 or malformed\n */\nexport function extractEd25519FromMultibase(multibaseValue: string): Uint8Array {\n if (multibaseValue.length < 2) {\n throw new DIDError('E_DID_DOCUMENT_INVALID', 'Multibase value too short');\n }\n\n const prefix = multibaseValue[0];\n const encoded = multibaseValue.slice(1);\n let decoded: Uint8Array;\n\n if (prefix === 'z') {\n decoded = base58btcDecode(encoded);\n } else if (prefix === 'u') {\n decoded = base64urlDecode(encoded);\n } else {\n throw new DIDError(\n 'E_DID_DOCUMENT_INVALID',\n `Unsupported multibase prefix: '${prefix}'. Expected 'z' (base58btc) or 'u' (base64url).`\n );\n }\n\n // Check total length\n if (decoded.length !== ED25519_MULTICODEC_LENGTH) {\n throw new DIDError(\n 'E_DID_KEY_NOT_FOUND',\n `Expected ${ED25519_MULTICODEC_LENGTH} bytes (2 prefix + 32 key), got ${decoded.length}`\n );\n }\n\n // Verify Ed25519 multicodec prefix (0xed, 0x01)\n if (decoded[0] !== ED25519_MULTICODEC_PREFIX[0] || decoded[1] !== ED25519_MULTICODEC_PREFIX[1]) {\n // Non-Ed25519 key type: do NOT throw an oracle-revealing error about\n // what type it is. Just say Ed25519 not found.\n throw new DIDError('E_DID_KEY_NOT_FOUND', 'Multicodec prefix does not indicate Ed25519');\n }\n\n return decoded.slice(2);\n}\n","/**\n * did:key resolver (Ed25519, zero network I/O).\n *\n * Implements the did:key method spec (W3C CCG v0.9).\n * Parses the multicodec-encoded Ed25519 public key directly from\n * the DID string. No network requests, no ambient discovery.\n *\n * Only Ed25519 keys (multicodec 0xed01) are supported.\n * Non-Ed25519 did:key DIDs produce an error without revealing\n * the actual key type (no oracle).\n */\n\nimport type { DIDDocument, VerificationMethod } from './types.js';\nimport type { DIDResolutionResult } from './types.js';\nimport type { DIDResolver } from './resolver.js';\nimport { extractEd25519FromMultibase } from './multicodec.js';\nimport { DIDError } from './errors.js';\n\n// ---------------------------------------------------------------------------\n// did:key Resolver\n// ---------------------------------------------------------------------------\n\n/**\n * Resolver for the did:key method.\n *\n * did:key encodes the public key directly in the DID string.\n * Resolution is pure computation with zero network I/O.\n *\n * @example\n * ```typescript\n * const resolver = new DidKeyResolver();\n * const result = await resolver.resolve('did:key:z6MkhaXgBZDvotDkL...');\n * const key = extractVerificationKey(result.didDocument!);\n * ```\n */\nexport class DidKeyResolver implements DIDResolver {\n readonly methods = ['key'] as const;\n\n async resolve(did: string): Promise<DIDResolutionResult> {\n // Validate DID format\n if (!did.startsWith('did:key:')) {\n return {\n didDocument: null,\n didResolutionMetadata: { error: 'invalidDid' },\n didDocumentMetadata: {},\n };\n }\n\n const multibaseValue = did.slice('did:key:'.length);\n if (!multibaseValue) {\n return {\n didDocument: null,\n didResolutionMetadata: { error: 'invalidDid' },\n didDocumentMetadata: {},\n };\n }\n\n // Extract Ed25519 public key (validates multicodec prefix).\n // Validate the multibase value contains a valid Ed25519 key.\n // Error boundary: DIDError.code is PEAC-internal (E_DID_*).\n // didResolutionMetadata.error uses DID-resolution-style values\n // for the public adapter contract.\n try {\n extractEd25519FromMultibase(multibaseValue);\n } catch (e) {\n if (e instanceof DIDError) {\n return {\n didDocument: null,\n didResolutionMetadata: { error: e.code },\n didDocumentMetadata: {},\n };\n }\n return {\n didDocument: null,\n didResolutionMetadata: { error: 'invalidDid' },\n didDocumentMetadata: {},\n };\n }\n\n // Build DID Document with the extracted key\n const keyId = `${did}#${multibaseValue}`;\n\n const verificationMethod: VerificationMethod = {\n id: keyId,\n type: 'Ed25519VerificationKey2020',\n controller: did,\n publicKeyMultibase: multibaseValue,\n };\n\n const document: DIDDocument = {\n '@context': [\n 'https://www.w3.org/ns/did/v1',\n 'https://w3id.org/security/suites/ed25519-2020/v1',\n ],\n id: did,\n verificationMethod: [verificationMethod],\n authentication: [keyId],\n assertionMethod: [keyId],\n };\n\n return {\n didDocument: document,\n didResolutionMetadata: { contentType: 'application/did+json' },\n didDocumentMetadata: {},\n };\n }\n}\n","/**\n * did:web resolver using a caller-provided SSRF-hardened fetch.\n *\n * Implements the did:web method spec (W3C CCG draft).\n * Resolves did:web DIDs to DID Documents via HTTPS fetch.\n *\n * Callers MUST provide a hardened fetch function (e.g., safeFetchJson\n * from @peac/net-node) that enforces:\n * - HTTPS only\n * - No redirects\n * - Private-IP / DNS-rebinding protections\n * - Timeout\n * - Response size limit\n *\n * This resolver adds:\n * - did:web authority/path validation (no userinfo, no query/fragment,\n * no empty segments, no IP literals)\n * - Content-type enforcement (application/did+json or application/json)\n * - Exact DID Document id match (DD-203)\n * - Domain allowlist (optional)\n *\n * URL transformation rules:\n * - did:web:example.com -> https://example.com/.well-known/did.json\n * - did:web:example.com:path:to -> https://example.com/path/to/did.json\n * - did:web:example.com%3A8443 -> https://example.com:8443/.well-known/did.json\n */\n\nimport type { DIDDocument } from './types.js';\nimport type { DIDResolutionResult } from './types.js';\nimport type { DIDResolver } from './resolver.js';\n\n// ---------------------------------------------------------------------------\n// Fetch Contract\n// ---------------------------------------------------------------------------\n\n/**\n * Result shape for the caller-provided hardened fetch function.\n *\n * Callers should use safeFetchJson from @peac/net-node, which returns\n * this shape. The resolver uses contentType and finalUrl for additional\n * validation beyond what the fetch function itself enforces.\n */\nexport interface HardenedFetchResult<T = unknown> {\n ok: boolean;\n data?: T;\n code?: string;\n error?: string;\n /** Content-Type of the response (for validation) */\n contentType?: string;\n /** Final URL after any processing (for redirect detection) */\n finalUrl?: string;\n}\n\nexport type HardenedFetchFn = <T = unknown>(\n url: string,\n options?: { timeoutMs?: number; maxResponseBytes?: number; maxRedirects?: number }\n) => Promise<HardenedFetchResult<T>>;\n\n// ---------------------------------------------------------------------------\n// Options\n// ---------------------------------------------------------------------------\n\nexport interface DidWebResolverOptions {\n /** Request timeout in milliseconds (default: 5000) */\n timeoutMs?: number;\n /**\n * Optional domain allowlist (lowercase). If set, only these domains\n * are permitted. Comparison is case-insensitive.\n */\n allowedDomains?: string[];\n /**\n * SSRF-hardened fetch function. Required.\n * Use safeFetchJson from @peac/net-node for production.\n */\n fetchFn: HardenedFetchFn;\n}\n\n// ---------------------------------------------------------------------------\n// Constants\n// ---------------------------------------------------------------------------\n\nconst MAX_DOCUMENT_BYTES = 256 * 1024;\nconst DEFAULT_TIMEOUT_MS = 5000;\n\n/** Acceptable content types for DID Documents */\nconst ACCEPTABLE_CONTENT_TYPES = new Set(['application/did+json', 'application/json']);\n\n// ---------------------------------------------------------------------------\n// did:web Resolver\n// ---------------------------------------------------------------------------\n\nexport class DidWebResolver implements DIDResolver {\n readonly methods = ['web'] as const;\n\n private readonly timeoutMs: number;\n private readonly allowedDomains: string[] | undefined;\n private readonly fetchFn: HardenedFetchFn;\n\n constructor(options: DidWebResolverOptions) {\n this.timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;\n this.allowedDomains = options.allowedDomains?.map(normalizeHostname);\n this.fetchFn = options.fetchFn;\n }\n\n async resolve(did: string): Promise<DIDResolutionResult> {\n // 1. Validate DID format\n if (!did.startsWith('did:web:')) {\n return errorResult('invalidDid');\n }\n\n const methodSpecificId = did.slice('did:web:'.length);\n if (!methodSpecificId) {\n return errorResult('invalidDid');\n }\n\n // 2. Validate and transform to URL\n const urlResult = validateAndTransform(methodSpecificId);\n if (!urlResult.ok) {\n return errorResult('invalidDid');\n }\n const url = urlResult.url;\n\n // 3. Domain allowlist check (case-insensitive, trailing-dot-normalized)\n const hostname = normalizeHostname(urlResult.hostname);\n if (this.allowedDomains && !this.allowedDomains.includes(hostname)) {\n return errorResult('invalidDid');\n }\n\n // 4. Fetch DID Document\n let fetchResult: HardenedFetchResult;\n try {\n fetchResult = await this.fetchFn<unknown>(url, {\n timeoutMs: this.timeoutMs,\n maxResponseBytes: MAX_DOCUMENT_BYTES,\n maxRedirects: 0,\n });\n } catch {\n return errorResult('notFound');\n }\n\n if (!fetchResult.ok || !fetchResult.data) {\n return errorResult('notFound');\n }\n\n // 5. Redirect detection: if finalUrl is provided, it must match the\n // requested URL exactly. The fetch contract uses maxRedirects: 0, so\n // any discrepancy indicates the fetcher did not enforce no-redirect.\n if (fetchResult.finalUrl && fetchResult.finalUrl !== url) {\n return errorResult('invalidDid');\n }\n\n // 6. Content-type enforcement (application/did+json or application/json)\n if (fetchResult.contentType) {\n const baseType = fetchResult.contentType.split(';')[0].trim().toLowerCase();\n if (!ACCEPTABLE_CONTENT_TYPES.has(baseType)) {\n return errorResult('invalidDid');\n }\n }\n\n // 7. Validate response is a JSON object with `id` field\n const raw = fetchResult.data;\n if (typeof raw !== 'object' || raw === null || Array.isArray(raw)) {\n return errorResult('invalidDid');\n }\n\n const doc = raw as DIDDocument;\n\n if (typeof doc.id !== 'string') {\n return errorResult('invalidDid');\n }\n\n // 8. Exact `id` match (DD-203)\n if (doc.id !== did) {\n return errorResult('invalidDid');\n }\n\n return {\n didDocument: doc,\n didResolutionMetadata: { contentType: 'application/did+json' },\n didDocumentMetadata: {},\n };\n }\n}\n\n// ---------------------------------------------------------------------------\n// Authority + Path Validation (Fix 2: strict validation)\n// ---------------------------------------------------------------------------\n\ninterface ValidationResult {\n ok: boolean;\n url: string;\n hostname: string;\n}\n\n/**\n * Validate and transform a did:web method-specific identifier to an HTTPS URL.\n *\n * Rejects:\n * - IP literals (IPv4, IPv6)\n * - Userinfo in authority\n * - Query or fragment components\n * - Empty path segments\n * - Malformed percent encoding\n * - Empty host\n */\nfunction validateAndTransform(methodSpecificId: string): ValidationResult {\n const fail: ValidationResult = { ok: false, url: '', hostname: '' };\n\n // Split on ':' for domain + optional path segments\n const parts = methodSpecificId.split(':');\n if (parts.length === 0 || !parts[0]) {\n return fail;\n }\n\n // Decode authority (handles %3A for port)\n let authority: string;\n try {\n authority = decodeURIComponent(parts[0]);\n } catch {\n return fail; // Malformed percent encoding\n }\n\n // Reject empty authority\n if (!authority) {\n return fail;\n }\n\n // Reject userinfo (@ in authority)\n if (authority.includes('@')) {\n return fail;\n }\n\n // Reject query/fragment in authority\n if (authority.includes('?') || authority.includes('#')) {\n return fail;\n }\n\n // Reject encoded slashes in authority (path traversal attempt)\n if (authority.includes('/')) {\n return fail;\n }\n\n // Parse hostname (with possible port)\n let hostname: string;\n try {\n const testUrl = new URL(`https://${authority}`);\n hostname = testUrl.hostname;\n\n // Reject if URL constructor added unexpected components\n if (testUrl.username || testUrl.password) {\n return fail;\n }\n } catch {\n return fail; // Invalid authority\n }\n\n // Reject IP literals\n if (isIPLiteral(hostname)) {\n return fail;\n }\n\n // Reject empty hostname\n if (!hostname) {\n return fail;\n }\n\n // Decode and validate path segments\n if (parts.length > 1) {\n const pathParts = parts.slice(1);\n\n for (const segment of pathParts) {\n // Reject empty path segments\n if (!segment) {\n return fail;\n }\n\n // Decode and reject slashes/query/fragment in segments\n let decoded: string;\n try {\n decoded = decodeURIComponent(segment);\n } catch {\n return fail;\n }\n\n if (decoded.includes('/') || decoded.includes('?') || decoded.includes('#')) {\n return fail;\n }\n }\n\n const decodedSegments = pathParts.map(decodeURIComponent);\n return {\n ok: true,\n url: `https://${authority}/${decodedSegments.join('/')}/did.json`,\n hostname,\n };\n }\n\n return {\n ok: true,\n url: `https://${authority}/.well-known/did.json`,\n hostname,\n };\n}\n\n/**\n * Check if a hostname is an IP literal (IPv4 or IPv6).\n */\nfunction isIPLiteral(hostname: string): boolean {\n if (hostname.startsWith('[')) return true;\n const parts = hostname.split('.');\n if (parts.length === 4 && parts.every((p) => /^\\d+$/.test(p))) return true;\n return false;\n}\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\n/**\n * Normalize a hostname for consistent comparison.\n * Lowercases and strips trailing dot (DNS root).\n */\nfunction normalizeHostname(host: string): string {\n return host.toLowerCase().replace(/\\.$/, '');\n}\n\nfunction errorResult(error: string): DIDResolutionResult {\n return {\n didDocument: null,\n didResolutionMetadata: { error },\n didDocumentMetadata: {},\n };\n}\n","/**\n * Verification key extraction from DID Documents.\n *\n * Implements DD-202 (DID Verification Method Selection Policy):\n * 1. Prefer methods referenced in authentication/assertionMethod\n * 2. If multiple eligible Ed25519 methods remain, require caller keyId\n * or fail with E_DID_KEY_AMBIGUOUS\n * 3. Only Ed25519 keys extracted; other types silently skipped\n * 4. Iterates ALL methods regardless of match (no early-return oracle)\n */\n\nimport type { DIDDocument, VerificationMethod } from './types.js';\nimport { extractEd25519FromMultibase } from './multicodec.js';\nimport { DIDError } from './errors.js';\n\n// ---------------------------------------------------------------------------\n// Options\n// ---------------------------------------------------------------------------\n\nexport interface ExtractKeyOptions {\n /**\n * Explicit key ID to select.\n * If provided, only methods with this ID are considered.\n */\n keyId?: string;\n /**\n * Which verification relationship to prefer.\n * Default: 'authentication'\n */\n relationship?: 'authentication' | 'assertionMethod';\n}\n\n// ---------------------------------------------------------------------------\n// Implementation\n// ---------------------------------------------------------------------------\n\n/**\n * Extract an Ed25519 public key from a DID Document.\n *\n * Selection policy (DD-202):\n * 1. Collect all verification methods from the document\n * 2. Filter by keyId if provided\n * 3. Filter by relationship references (authentication/assertionMethod)\n * 4. Try to extract Ed25519 key from each eligible method\n * 5. If exactly one Ed25519 key found: return it\n * 6. If zero found: return null\n * 7. If multiple found without keyId: throw E_DID_KEY_AMBIGUOUS\n *\n * All methods are iterated regardless of match to prevent key-type oracle.\n *\n * @param document - The resolved DID Document\n * @param options - Key selection options\n * @returns 32-byte Ed25519 public key, or null if no suitable key found\n * @throws DIDError with E_DID_KEY_AMBIGUOUS if multiple eligible keys\n */\nexport function extractVerificationKey(\n document: DIDDocument,\n options?: ExtractKeyOptions\n): Uint8Array | null {\n const methods = document.verificationMethod ?? [];\n const relationship = options?.relationship ?? 'authentication';\n const keyId = options?.keyId;\n\n // Get relationship-referenced method IDs\n const relationshipRefs = getRelationshipRefs(document, relationship);\n\n // Collect all eligible Ed25519 keys (iterate ALL methods, no early return)\n const candidates: Uint8Array[] = [];\n\n for (const method of methods) {\n // Filter by keyId if specified\n if (keyId && method.id !== keyId) {\n continue;\n }\n\n // Prefer relationship-referenced methods if refs exist\n if (relationshipRefs.length > 0 && !relationshipRefs.includes(method.id)) {\n continue;\n }\n\n // Try to extract Ed25519 key (silently skip non-Ed25519)\n const key = tryExtractEd25519(method);\n if (key) {\n candidates.push(key);\n }\n }\n\n // If no relationship-referenced methods found, fall back to all methods\n if (candidates.length === 0 && relationshipRefs.length > 0) {\n for (const method of methods) {\n if (keyId && method.id !== keyId) continue;\n const key = tryExtractEd25519(method);\n if (key) candidates.push(key);\n }\n }\n\n if (candidates.length === 0) {\n return null;\n }\n\n if (candidates.length === 1) {\n return candidates[0];\n }\n\n // Multiple Ed25519 keys without explicit keyId selection\n throw new DIDError(\n 'E_DID_KEY_AMBIGUOUS',\n `Found ${candidates.length} eligible Ed25519 keys. Provide keyId to select.`\n );\n}\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\n/**\n * Get verification method IDs referenced by a relationship.\n */\nfunction getRelationshipRefs(\n document: DIDDocument,\n relationship: 'authentication' | 'assertionMethod'\n): string[] {\n const refs = document[relationship];\n if (!refs) return [];\n\n return refs\n .map((ref) => (typeof ref === 'string' ? ref : ref.id))\n .filter((id): id is string => typeof id === 'string');\n}\n\n/**\n * Try to extract an Ed25519 key from a verification method.\n * Returns null for non-Ed25519 methods (no oracle).\n */\nfunction tryExtractEd25519(method: VerificationMethod): Uint8Array | null {\n // Try publicKeyMultibase (Multikey / Ed25519VerificationKey2020)\n if (method.publicKeyMultibase) {\n try {\n return extractEd25519FromMultibase(method.publicKeyMultibase);\n } catch {\n return null;\n }\n }\n\n // Try publicKeyJwk (JsonWebKey2020, OKP/Ed25519)\n if (method.publicKeyJwk) {\n const jwk = method.publicKeyJwk;\n if (jwk.kty === 'OKP' && jwk.crv === 'Ed25519' && typeof jwk.x === 'string') {\n try {\n // JWK x value is base64url-encoded raw key\n const bytes = new Uint8Array(Buffer.from(jwk.x, 'base64url'));\n if (bytes.length === 32) return bytes;\n } catch {\n return null;\n }\n }\n return null;\n }\n\n return null;\n}\n","/**\n * Caching resolver wrapper.\n *\n * Wraps any DIDResolver with TTL-based in-memory caching.\n * Cache entries expire after configurable TTL and are evicted\n * when maxEntries is reached (oldest-first).\n *\n * The cache key is the full DID string.\n */\n\nimport type { DIDResolutionResult } from './types.js';\nimport type { DIDResolver } from './resolver.js';\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\nexport interface CachingResolverOptions {\n /** Time-to-live in milliseconds (default: 300000 = 5 minutes) */\n ttlMs?: number;\n /** Maximum number of cached entries (default: 1000) */\n maxEntries?: number;\n}\n\ninterface CacheEntry {\n result: DIDResolutionResult;\n expiresAt: number;\n}\n\n// ---------------------------------------------------------------------------\n// Constants\n// ---------------------------------------------------------------------------\n\nconst DEFAULT_TTL_MS = 5 * 60 * 1000; // 5 minutes\nconst DEFAULT_MAX_ENTRIES = 1000;\n\n// ---------------------------------------------------------------------------\n// CachingResolver\n// ---------------------------------------------------------------------------\n\n/**\n * Caching wrapper for any DIDResolver.\n *\n * - TTL-based expiry: entries older than ttlMs are evicted on access\n * - Max entries: oldest entries evicted when capacity is reached\n * - Only successful resolutions are cached (didDocument !== null)\n * - Failed resolutions are NOT cached (each attempt is fresh)\n *\n * @example\n * ```typescript\n * const inner = new DidKeyResolver();\n * const cached = new CachingResolver(inner, { ttlMs: 60000 });\n * const result = await cached.resolve('did:key:z6Mk...');\n * ```\n */\nexport class CachingResolver implements DIDResolver {\n readonly methods: readonly string[];\n\n private readonly inner: DIDResolver;\n private readonly ttlMs: number;\n private readonly maxEntries: number;\n private readonly cache = new Map<string, CacheEntry>();\n\n constructor(inner: DIDResolver, options?: CachingResolverOptions) {\n this.inner = inner;\n this.methods = inner.methods;\n this.ttlMs = options?.ttlMs ?? DEFAULT_TTL_MS;\n this.maxEntries = options?.maxEntries ?? DEFAULT_MAX_ENTRIES;\n }\n\n async resolve(did: string): Promise<DIDResolutionResult> {\n const now = Date.now();\n\n // Check cache (return deep clone to prevent caller mutation of cached data)\n const cached = this.cache.get(did);\n if (cached && cached.expiresAt > now) {\n return deepCloneResult(cached.result);\n }\n\n // Evict expired entry if present\n if (cached) {\n this.cache.delete(did);\n }\n\n // Resolve from inner\n const result = await this.inner.resolve(did);\n\n // Only cache successful resolutions (deep clone on store to isolate)\n if (result.didDocument !== null) {\n // Evict oldest if at capacity\n if (this.cache.size >= this.maxEntries) {\n const oldestKey = this.cache.keys().next().value;\n if (oldestKey !== undefined) {\n this.cache.delete(oldestKey);\n }\n }\n\n this.cache.set(did, {\n result: deepCloneResult(result),\n expiresAt: now + this.ttlMs,\n });\n }\n\n return result;\n }\n\n /** Invalidate a specific cached entry */\n invalidate(did: string): void {\n this.cache.delete(did);\n }\n\n /** Clear the entire cache */\n clear(): void {\n this.cache.clear();\n }\n\n /** Current number of cached entries */\n get size(): number {\n return this.cache.size;\n }\n}\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\n/**\n * Deep clone a DIDResolutionResult to prevent caller mutation of cached data.\n * Uses structuredClone (available since Node 17) for correctness.\n */\nfunction deepCloneResult(result: DIDResolutionResult): DIDResolutionResult {\n return structuredClone(result);\n}\n"]}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Ed25519 multicodec prefix parsing.
3
+ *
4
+ * Supports both multibase forms allowed by the did:key spec (CCG v0.9):
5
+ * - 'z' prefix: base58btc encoding
6
+ * - 'u' prefix: base64url encoding
7
+ *
8
+ * The Ed25519 multicodec prefix is 0xed01 as a varint (2 bytes).
9
+ * After stripping the 2-byte prefix, the remaining 32 bytes are
10
+ * the raw Ed25519 public key.
11
+ */
12
+ /**
13
+ * Extract an Ed25519 public key from a multibase-encoded multicodec value.
14
+ *
15
+ * Supports both multibase prefixes:
16
+ * - 'z': base58btc (e.g., did:key:z6Mk...)
17
+ * - 'u': base64url
18
+ *
19
+ * @param multibaseValue - The multibase-encoded value (including prefix character)
20
+ * @returns 32-byte Ed25519 public key
21
+ * @throws DIDError if not Ed25519 or malformed
22
+ */
23
+ export declare function extractEd25519FromMultibase(multibaseValue: string): Uint8Array;
24
+ //# sourceMappingURL=multicodec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"multicodec.d.ts","sourceRoot":"","sources":["../src/multicodec.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AA2EH;;;;;;;;;;GAUG;AACH,wBAAgB,2BAA2B,CAAC,cAAc,EAAE,MAAM,GAAG,UAAU,CAoC9E"}
@@ -0,0 +1,121 @@
1
+ "use strict";
2
+ /**
3
+ * Ed25519 multicodec prefix parsing.
4
+ *
5
+ * Supports both multibase forms allowed by the did:key spec (CCG v0.9):
6
+ * - 'z' prefix: base58btc encoding
7
+ * - 'u' prefix: base64url encoding
8
+ *
9
+ * The Ed25519 multicodec prefix is 0xed01 as a varint (2 bytes).
10
+ * After stripping the 2-byte prefix, the remaining 32 bytes are
11
+ * the raw Ed25519 public key.
12
+ */
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.extractEd25519FromMultibase = extractEd25519FromMultibase;
15
+ const errors_js_1 = require("./errors.js");
16
+ // ---------------------------------------------------------------------------
17
+ // Constants
18
+ // ---------------------------------------------------------------------------
19
+ /** Ed25519 multicodec prefix as varint: [0xed, 0x01] */
20
+ const ED25519_MULTICODEC_PREFIX = new Uint8Array([0xed, 0x01]);
21
+ /** Expected Ed25519 public key length in bytes */
22
+ const ED25519_KEY_LENGTH = 32;
23
+ /** Total expected length: 2 byte prefix + 32 byte key */
24
+ const ED25519_MULTICODEC_LENGTH = ED25519_MULTICODEC_PREFIX.length + ED25519_KEY_LENGTH;
25
+ // ---------------------------------------------------------------------------
26
+ // Base58btc decoder (minimal, for 'z' prefix multibase)
27
+ // ---------------------------------------------------------------------------
28
+ const BASE58_ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
29
+ const BASE58_MAP = new Map();
30
+ for (let i = 0; i < BASE58_ALPHABET.length; i++) {
31
+ BASE58_MAP.set(BASE58_ALPHABET[i], i);
32
+ }
33
+ function base58btcDecode(input) {
34
+ if (input.length === 0)
35
+ return new Uint8Array(0);
36
+ // Count leading '1's (zero bytes)
37
+ let zeros = 0;
38
+ while (zeros < input.length && input[zeros] === '1') {
39
+ zeros++;
40
+ }
41
+ // Decode
42
+ const size = Math.ceil(input.length * 733 / 1000) + 1;
43
+ const b256 = new Uint8Array(size);
44
+ let length = 0;
45
+ for (let i = zeros; i < input.length; i++) {
46
+ const value = BASE58_MAP.get(input[i]);
47
+ if (value === undefined) {
48
+ throw new errors_js_1.DIDError('E_DID_DOCUMENT_INVALID', `Invalid base58btc character: ${input[i]}`);
49
+ }
50
+ let carry = value;
51
+ for (let j = 0; j < length || carry > 0; j++) {
52
+ carry += 58 * (b256[j] || 0);
53
+ b256[j] = carry % 256;
54
+ carry = Math.floor(carry / 256);
55
+ if (j >= length)
56
+ length = j + 1;
57
+ }
58
+ }
59
+ // Build result with leading zeros
60
+ const result = new Uint8Array(zeros + length);
61
+ for (let i = 0; i < length; i++) {
62
+ result[zeros + length - 1 - i] = b256[i];
63
+ }
64
+ return result;
65
+ }
66
+ // ---------------------------------------------------------------------------
67
+ // Base64url decoder (for 'u' prefix multibase)
68
+ // ---------------------------------------------------------------------------
69
+ function base64urlDecode(input) {
70
+ // Pad to multiple of 4
71
+ const padded = input + '='.repeat((4 - (input.length % 4)) % 4);
72
+ const binary = atob(padded.replace(/-/g, '+').replace(/_/g, '/'));
73
+ const bytes = new Uint8Array(binary.length);
74
+ for (let i = 0; i < binary.length; i++) {
75
+ bytes[i] = binary.charCodeAt(i);
76
+ }
77
+ return bytes;
78
+ }
79
+ // ---------------------------------------------------------------------------
80
+ // Public API
81
+ // ---------------------------------------------------------------------------
82
+ /**
83
+ * Extract an Ed25519 public key from a multibase-encoded multicodec value.
84
+ *
85
+ * Supports both multibase prefixes:
86
+ * - 'z': base58btc (e.g., did:key:z6Mk...)
87
+ * - 'u': base64url
88
+ *
89
+ * @param multibaseValue - The multibase-encoded value (including prefix character)
90
+ * @returns 32-byte Ed25519 public key
91
+ * @throws DIDError if not Ed25519 or malformed
92
+ */
93
+ function extractEd25519FromMultibase(multibaseValue) {
94
+ if (multibaseValue.length < 2) {
95
+ throw new errors_js_1.DIDError('E_DID_DOCUMENT_INVALID', 'Multibase value too short');
96
+ }
97
+ const prefix = multibaseValue[0];
98
+ const encoded = multibaseValue.slice(1);
99
+ let decoded;
100
+ if (prefix === 'z') {
101
+ decoded = base58btcDecode(encoded);
102
+ }
103
+ else if (prefix === 'u') {
104
+ decoded = base64urlDecode(encoded);
105
+ }
106
+ else {
107
+ throw new errors_js_1.DIDError('E_DID_DOCUMENT_INVALID', `Unsupported multibase prefix: '${prefix}'. Expected 'z' (base58btc) or 'u' (base64url).`);
108
+ }
109
+ // Check total length
110
+ if (decoded.length !== ED25519_MULTICODEC_LENGTH) {
111
+ throw new errors_js_1.DIDError('E_DID_KEY_NOT_FOUND', `Expected ${ED25519_MULTICODEC_LENGTH} bytes (2 prefix + 32 key), got ${decoded.length}`);
112
+ }
113
+ // Verify Ed25519 multicodec prefix (0xed, 0x01)
114
+ if (decoded[0] !== ED25519_MULTICODEC_PREFIX[0] || decoded[1] !== ED25519_MULTICODEC_PREFIX[1]) {
115
+ // Non-Ed25519 key type: do NOT throw an oracle-revealing error about
116
+ // what type it is. Just say Ed25519 not found.
117
+ throw new errors_js_1.DIDError('E_DID_KEY_NOT_FOUND', 'Multicodec prefix does not indicate Ed25519');
118
+ }
119
+ return decoded.slice(2);
120
+ }
121
+ //# sourceMappingURL=multicodec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"multicodec.js","sourceRoot":"","sources":["../src/multicodec.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;AA6FH,kEAuCC;AAlID,2CAAuC;AAEvC,8EAA8E;AAC9E,YAAY;AACZ,8EAA8E;AAE9E,wDAAwD;AACxD,MAAM,yBAAyB,GAAG,IAAI,UAAU,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;AAE/D,kDAAkD;AAClD,MAAM,kBAAkB,GAAG,EAAE,CAAC;AAE9B,yDAAyD;AACzD,MAAM,yBAAyB,GAAG,yBAAyB,CAAC,MAAM,GAAG,kBAAkB,CAAC;AAExF,8EAA8E;AAC9E,wDAAwD;AACxD,8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M,IAAI,oBAAQ,CAChB,qBAAqB,EACrB,6CAA6C,CAC9C,CAAC;IACJ,CAAC;IAED,OAAO,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAC1B,CAAC"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * DID Resolver interface and composite resolver.
3
+ *
4
+ * Pluggable resolver architecture: callers instantiate and configure
5
+ * resolvers explicitly (DD-52: no ambient key discovery).
6
+ */
7
+ import type { DIDResolutionResult } from './types.js';
8
+ /**
9
+ * Interface for DID resolvers.
10
+ *
11
+ * Each resolver handles one or more DID methods (e.g., ['key'], ['web']).
12
+ * Resolution returns a W3C DID Resolution Result.
13
+ */
14
+ export interface DIDResolver {
15
+ /** DID methods this resolver handles (e.g., ['key'] for did:key) */
16
+ readonly methods: readonly string[];
17
+ /** Resolve a DID to its DID Document */
18
+ resolve(did: string): Promise<DIDResolutionResult>;
19
+ }
20
+ /**
21
+ * Create a composite resolver that delegates to method-specific resolvers.
22
+ *
23
+ * Tries resolvers in order by method match. The first resolver whose
24
+ * `methods` array includes the DID's method handles the resolution.
25
+ *
26
+ * @param resolvers - Array of method-specific resolvers
27
+ * @returns A composite resolver that delegates by method
28
+ */
29
+ export declare function createCompositeResolver(resolvers: DIDResolver[]): DIDResolver;
30
+ //# sourceMappingURL=resolver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolver.d.ts","sourceRoot":"","sources":["../src/resolver.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAMtD;;;;;GAKG;AACH,MAAM,WAAW,WAAW;IAC1B,oEAAoE;IACpE,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,wCAAwC;IACxC,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;CACpD;AAMD;;;;;;;;GAQG;AACH,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,WAAW,EAAE,GAAG,WAAW,CA2B7E"}
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ /**
3
+ * DID Resolver interface and composite resolver.
4
+ *
5
+ * Pluggable resolver architecture: callers instantiate and configure
6
+ * resolvers explicitly (DD-52: no ambient key discovery).
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.createCompositeResolver = createCompositeResolver;
10
+ // ---------------------------------------------------------------------------
11
+ // Composite Resolver
12
+ // ---------------------------------------------------------------------------
13
+ /**
14
+ * Create a composite resolver that delegates to method-specific resolvers.
15
+ *
16
+ * Tries resolvers in order by method match. The first resolver whose
17
+ * `methods` array includes the DID's method handles the resolution.
18
+ *
19
+ * @param resolvers - Array of method-specific resolvers
20
+ * @returns A composite resolver that delegates by method
21
+ */
22
+ function createCompositeResolver(resolvers) {
23
+ return {
24
+ methods: resolvers.flatMap((r) => [...r.methods]),
25
+ async resolve(did) {
26
+ const method = extractMethod(did);
27
+ if (!method) {
28
+ return {
29
+ didDocument: null,
30
+ didResolutionMetadata: { error: 'invalidDid' },
31
+ didDocumentMetadata: {},
32
+ };
33
+ }
34
+ for (const resolver of resolvers) {
35
+ if (resolver.methods.includes(method)) {
36
+ return resolver.resolve(did);
37
+ }
38
+ }
39
+ return {
40
+ didDocument: null,
41
+ didResolutionMetadata: { error: 'methodNotSupported' },
42
+ didDocumentMetadata: {},
43
+ };
44
+ },
45
+ };
46
+ }
47
+ /**
48
+ * Extract the method from a DID string (e.g., "key" from "did:key:z6Mk...").
49
+ */
50
+ function extractMethod(did) {
51
+ if (!did.startsWith('did:'))
52
+ return null;
53
+ const parts = did.split(':');
54
+ if (parts.length < 3)
55
+ return null;
56
+ return parts[1];
57
+ }
58
+ //# sourceMappingURL=resolver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolver.js","sourceRoot":"","sources":["../src/resolver.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAkCH,0DA2BC;AAxCD,8EA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+ *
4
+ * These types model the subset of W3C DID Core v1.0 (Recommendation 2022)
5
+ * needed for Ed25519 key extraction. This is an interoperability adapter
6
+ * layer, not a normative W3C dependency. did:key and did:web are CCG
7
+ * drafts with no formal W3C Recommendation standing.
8
+ *
9
+ * @see https://www.w3.org/TR/did-core/
10
+ */
11
+ /**
12
+ * A verification method entry in a DID Document.
13
+ *
14
+ * PEAC only extracts Ed25519 keys; other key types are silently skipped
15
+ * (no oracle for key-type presence).
16
+ */
17
+ export interface VerificationMethod {
18
+ /** Verification method identifier (e.g., "did:key:z6Mk...#z6Mk...") */
19
+ id: string;
20
+ /**
21
+ * Key type. PEAC recognizes:
22
+ * - 'Ed25519VerificationKey2020'
23
+ * - 'Multikey'
24
+ * - 'JsonWebKey2020'
25
+ */
26
+ type: string;
27
+ /** Controller DID */
28
+ controller: string;
29
+ /** Multibase-encoded public key (base58btc 'z' prefix or base64url 'u' prefix) */
30
+ publicKeyMultibase?: string;
31
+ /** JWK representation of the public key */
32
+ publicKeyJwk?: JsonWebKey;
33
+ }
34
+ /**
35
+ * Minimal JsonWebKey for Ed25519 (OKP curve).
36
+ */
37
+ export interface JsonWebKey {
38
+ kty: string;
39
+ crv?: string;
40
+ x?: string;
41
+ [key: string]: unknown;
42
+ }
43
+ /**
44
+ * A W3C DID Document (subset relevant to PEAC key extraction).
45
+ */
46
+ export interface DIDDocument {
47
+ /** JSON-LD context */
48
+ '@context': string | string[];
49
+ /** The DID this document describes */
50
+ id: string;
51
+ /** Verification methods (key material) */
52
+ verificationMethod?: VerificationMethod[];
53
+ /** Authentication relationship references */
54
+ authentication?: (string | VerificationMethod)[];
55
+ /** Assertion method relationship references */
56
+ assertionMethod?: (string | VerificationMethod)[];
57
+ /** Controller DID(s) */
58
+ controller?: string | string[];
59
+ }
60
+ /** Metadata about the resolution process itself */
61
+ export interface DIDResolutionMetadata {
62
+ /** Error code if resolution failed */
63
+ error?: string;
64
+ /** Content type of the DID Document */
65
+ contentType?: string;
66
+ }
67
+ /** Metadata about the DID Document */
68
+ export interface DIDDocumentMetadata {
69
+ /** When the DID Document was created */
70
+ created?: string;
71
+ /** When the DID Document was last updated */
72
+ updated?: string;
73
+ /** Whether the DID has been deactivated */
74
+ deactivated?: boolean;
75
+ }
76
+ /** Complete DID resolution result */
77
+ export interface DIDResolutionResult {
78
+ didDocument: DIDDocument | null;
79
+ didResolutionMetadata: DIDResolutionMetadata;
80
+ didDocumentMetadata: DIDDocumentMetadata;
81
+ }
82
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAMH;;;;;GAKG;AACH,MAAM,WAAW,kBAAkB;IACjC,uEAAuE;IACvE,EAAE,EAAE,MAAM,CAAC;IACX;;;;;OAKG;IACH,IAAI,EAAE,MAAM,CAAC;IACb,qBAAqB;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,kFAAkF;IAClF,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,2CAA2C;IAC3C,YAAY,CAAC,EAAE,UAAU,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAMD;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,sBAAsB;IACtB,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC9B,sCAAsC;IACtC,EAAE,EAAE,MAAM,CAAC;IACX,0CAA0C;IAC1C,kBAAkB,CAAC,EAAE,kBAAkB,EAAE,CAAC;IAC1C,6CAA6C;IAC7C,cAAc,CAAC,EAAE,CAAC,MAAM,GAAG,kBAAkB,CAAC,EAAE,CAAC;IACjD,+CAA+C;IAC/C,eAAe,CAAC,EAAE,CAAC,MAAM,GAAG,kBAAkB,CAAC,EAAE,CAAC;IAClD,wBAAwB;IACxB,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CAChC;AAMD,mDAAmD;AACnD,MAAM,WAAW,qBAAqB;IACpC,sCAAsC;IACtC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,uCAAuC;IACvC,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,sCAAsC;AACtC,MAAM,WAAW,mBAAmB;IAClC,wCAAwC;IACxC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,6CAA6C;IAC7C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,2CAA2C;IAC3C,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,qCAAqC;AACrC,MAAM,WAAW,mBAAmB;IAClC,WAAW,EAAE,WAAW,GAAG,IAAI,CAAC;IAChC,qBAAqB,EAAE,qBAAqB,CAAC;IAC7C,mBAAmB,EAAE,mBAAmB,CAAC;CAC1C"}
package/dist/types.js ADDED
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ /**
3
+ * W3C DID Core v1.0 types for PEAC adapter-did.
4
+ *
5
+ * These types model the subset of W3C DID Core v1.0 (Recommendation 2022)
6
+ * needed for Ed25519 key extraction. This is an interoperability adapter
7
+ * layer, not a normative W3C dependency. did:key and did:web are CCG
8
+ * drafts with no formal W3C Recommendation standing.
9
+ *
10
+ * @see https://www.w3.org/TR/did-core/
11
+ */
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG"}
package/package.json ADDED
@@ -0,0 +1,68 @@
1
+ {
2
+ "name": "@peac/adapter-did",
3
+ "version": "0.12.6",
4
+ "description": "DID document resolution for PEAC receipt verification (did:key, did:web)",
5
+ "main": "dist/index.cjs",
6
+ "types": "dist/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/index.d.ts",
10
+ "import": "./dist/index.mjs",
11
+ "require": "./dist/index.cjs",
12
+ "default": "./dist/index.mjs"
13
+ },
14
+ "./package.json": "./package.json"
15
+ },
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "git+https://github.com/peacprotocol/peac.git",
19
+ "directory": "packages/adapters/did"
20
+ },
21
+ "author": "PEAC Protocol Contributors",
22
+ "license": "Apache-2.0",
23
+ "files": [
24
+ "dist",
25
+ "README.md"
26
+ ],
27
+ "publishConfig": {
28
+ "access": "public"
29
+ },
30
+ "dependencies": {
31
+ "@peac/kernel": "0.12.6",
32
+ "@peac/schema": "0.12.6"
33
+ },
34
+ "devDependencies": {
35
+ "@types/node": "^22.19.11",
36
+ "tsup": "^8.0.0",
37
+ "typescript": "^5.3.3",
38
+ "vitest": "^4.0.0"
39
+ },
40
+ "bugs": {
41
+ "url": "https://github.com/peacprotocol/peac/issues"
42
+ },
43
+ "homepage": "https://github.com/peacprotocol/peac#readme",
44
+ "keywords": [
45
+ "peac",
46
+ "peacprotocol",
47
+ "interaction-records",
48
+ "signed-records",
49
+ "receipts",
50
+ "originary",
51
+ "adapter-did",
52
+ "did",
53
+ "did-key",
54
+ "did-web",
55
+ "decentralized-identity",
56
+ "w3c-did-core",
57
+ "ed25519",
58
+ "verification"
59
+ ],
60
+ "scripts": {
61
+ "build:js": "tsup",
62
+ "build:types": "tsc --emitDeclarationOnly --declaration",
63
+ "build": "pnpm build:js && pnpm build:types",
64
+ "test": "vitest run",
65
+ "test:watch": "vitest",
66
+ "clean": "rm -rf dist"
67
+ }
68
+ }