import { ContextService } from "./ContextService.mjs"; import { OpenBadgesKeyBindingRecord } from "../repository/OpenBadgesKeyBindingRecord.mjs"; import { OpenBadgesKeyBindingRepository } from "../repository/OpenBadgesKeyBindingRepository.mjs"; import { AgentContext } from "@credo-ts/core"; //#region src/services/KeyService.d.ts /** * Local key type enum (replaces credo-ts 0.5 KeyType) */ declare enum KeyType { Ed25519 = "ed25519", P256 = "p256", P384 = "p384", } /** * Lightweight reference to a public key used internally (replaces 0.5 Key class) */ interface OpenBadgesKey { publicKey: Uint8Array; keyType: KeyType; kmsKeyId?: string; } /** * Supported DID methods for key binding */ type SupportedDidMethod = 'did:web' | 'did:key' | 'did:jwk'; /** * Options for ensuring a key binding */ interface EnsureBindingOptions { controller: string; vmId: string; keyType?: KeyType; didMethod?: SupportedDidMethod; } declare class KeyService { private readonly bindings; private readonly contexts; constructor(bindings: OpenBadgesKeyBindingRepository, contexts: ContextService); private bindingId; /** * Get the multicodec prefix for a key type */ private getMulticodecPrefix; /** * Get the verification method type for a key type */ private getVerificationMethodType; /** * Generate a did:key DID from public key material */ generateDidKey(publicKey: Buffer, keyType: KeyType): { did: string; vmId: string; }; /** * Generate a did:jwk DID from public key material */ generateDidJwk(publicKey: Buffer, keyType: KeyType): { did: string; vmId: string; }; /** * Parse a did:key to extract public key bytes and determine key type */ parseDidKey(did: string): { publicKey: Buffer; keyType: KeyType; } | null; /** * Parse a did:jwk to extract the JWK and determine key type */ parseDidJwk(did: string): { jwk: any; keyType: KeyType; } | null; /** * Ensure a KMS-backed key exists and is bound to a verificationMethod id * Supports Ed25519, P-256, and P-384 key types * Supports did:web, did:key, and did:jwk DID methods */ ensureBinding(agentContext: AgentContext, opts: EnsureBindingOptions): Promise; getBindingByVm(agentContext: AgentContext, vmId: string): Promise; getPublicJwkByVm(agentContext: AgentContext, vmId: string): Promise<{ kty: string; crv: string; x: string; y?: undefined; } | { kty: string; crv: string; x: string; y: string; } | null>; getKeyForVm(agentContext: AgentContext, vmId: string): Promise; private seedVerificationMethodDocument; /** * Create a new key binding with a did:key DID * Returns the generated DID and verification method ID */ createDidKeyBinding(agentContext: AgentContext, keyType?: KeyType): Promise<{ did: string; vmId: string; publicKeyMultibase: string; }>; /** * Create a new key binding with a did:jwk DID * Returns the generated DID and verification method ID */ createDidJwkBinding(agentContext: AgentContext, keyType?: KeyType): Promise<{ did: string; vmId: string; publicKeyMultibase: string; }>; /** * Get a JWK for a did:key or did:jwk DID */ getJwkForDid(did: string): any | null; } //#endregion export { EnsureBindingOptions, KeyService, KeyType, OpenBadgesKey, SupportedDidMethod }; //# sourceMappingURL=KeyService.d.mts.map