@synet/did
Version:
Secure, minimal, standards-compliant DID library for production environments. Supports did:key and did:web methods with strict validation and cryptographic security.
72 lines (71 loc) • 2.38 kB
TypeScript
/**
*
* @synet/did - Production DID Library
*
* Secure, minimal, standards-compliant DID creation for production environments.
* Supports only did:key and did:web methods following W3C DID Core specification.
* Stable, maintained and robust.
*
* Security Features:
* - No cryptographic fallbacks to weak sources
* - Strict input validation and sanitization
* - Minimal attack surface
* - Standards-compliant multicodec encoding
*
*/
import type { DIDCreateOptions, DIDDocument, VerificationMethod, Service } from "./types";
/**
* Official multicodec codes from https://github.com/multiformats/multicodec
*/
declare const MULTICODEC_CODES: {
readonly "ed25519-pub": 237;
readonly "secp256k1-pub": 231;
readonly "x25519-pub": 236;
};
/**
* Supported key types
*/
export type KeyType = keyof typeof MULTICODEC_CODES;
/**
* Create a did:key DID from a public key
*
* @param publicKeyHex - Public key in hexadecimal format
* @param keyType - Type of cryptographic key (legacy names supported)
* @returns Standards-compliant did:key DID
*/
export declare function createDIDKey(publicKeyHex: string, keyType?: KeyType | "Ed25519" | "secp256k1" | "X25519"): string;
/**
* Create a did:web DID
*
* @param domain - Domain name for the DID
* @param path - Optional path component
* @returns Standards-compliant did:web DID
*/
export declare function createDIDWeb(domain: string, path?: string): string;
/**
* Create a DID using the specified method
*
* @param options - DID creation options
* @returns DID string
*/
export declare function createDID(options: DIDCreateOptions): string;
/**
* Create a basic DID document for a given DID
*
* @param did - DID string
* @param options - Optional document options
* @returns DID document
*/
export declare function createDIDDocument(did: string, options?: {
"@context"?: string | string[];
controller?: string;
verificationMethod?: VerificationMethod | VerificationMethod[];
authentication?: (string | VerificationMethod)[];
assertionMethod?: (string | VerificationMethod)[];
keyAgreement?: (string | VerificationMethod)[];
capabilityInvocation?: (string | VerificationMethod)[];
capabilityDelegation?: (string | VerificationMethod)[];
service?: Service[];
mediaType?: "application/did+json" | "application/did+ld+json";
}): DIDDocument;
export {};