Complete TypeScript SDK API reference with types, interfaces, and function signatures.
function validateDeveloperCredential( input: unknown ): ValidationResult<DeveloperCredential>
function validateAgentCredential( input: unknown ): ValidationResult<AgentCredential>
function isDeveloperCredential( credential: unknown ): credential is DeveloperCredential
function isAgentCredential( credential: unknown ): credential is AgentCredential
function isValidationSuccess<T>( result: ValidationResult<T> ): result is { ok: true; value: T; warnings: ValidationWarning[] }
async function signCredential( credential: DeveloperCredential | AgentCredential, privateKey: CryptoKey, options: SignOptions ): Promise<string>
async function generateKeyPair( algorithm: 'EdDSA' | 'ES256' ): Promise<{ privateKey: CryptoKey; publicKey: CryptoKey }>
async function exportPublicKey( key: CryptoKey ): Promise<JsonWebKey>
async function importPublicKey( jwk: JsonWebKey, algorithm: 'EdDSA' | 'ES256' ): Promise<CryptoKey>
async function importPrivateKey( jwk: JsonWebKey, algorithm: 'EdDSA' | 'ES256' ): Promise<CryptoKey>
async function importKeyFromPEM( pem: string, algorithm: 'EdDSA' | 'ES256', options?: ImportKeyFromPEMOptions ): Promise<CryptoKey>
async function exportPrivateKeyToPEM( key: CryptoKey, options?: ExportKeyToPEMOptions ): Promise<string>
async function exportPublicKeyToPEM( key: CryptoKey, options?: ExportKeyToPEMOptions ): Promise<string>
async function verifyCredential( token: string, options: VerifyOptions ): Promise<VerifiedCredential>
function decodeToken(token: string): { header: JWSHeader; payload: JWTPayload; signature: string; }
function getCredentialType( token: string ): 'developer' | 'agent' | null
async function verifyAgentTrustChain( agentToken: string, options: TrustChainOptions ): Promise<TrustChainResult>
function decodeStatusList(encodedList: string): Uint8Array
function isBitSet(bitstring: Uint8Array, index: number): boolean
async function checkStatusList2021( statusListUrl: string, statusListIndex: number ): Promise<CredentialStatus>
function parseStatusEntry( credentialStatus: unknown ): StatusList2021Entry | null
class StatusListCache { constructor(ttl: number); fetch(url: string): Promise<Uint8Array>; clear(): void; }
const defaultStatusListCache: StatusListCache
async function signHttpRequest( request: HttpRequestInfo, options: HttpSignOptions ): Promise<HttpSignatureHeaders>
async function createSignedRequest( request: HttpRequestInfo, options: HttpSignOptions ): Promise<{ url: string; method: string; headers: Record<string, string>; body?: string }>
function computeJwkThumbprint(jwk: JsonWebKey): string
function computeContentDigest(body: Uint8Array | string): string
function generateNonce(): string
async function verifyHttpSignature( request: IncomingHttpRequest, options: HttpVerifyOptions ): Promise<HttpVerificationResult>
async function fetchKeyDirectory(url: string): Promise<KeyDirectory>
function findKeyByThumbprint( directory: KeyDirectory, thumbprint: string ): JsonWebKey | undefined
function createDefaultKeyResolver(): ( signatureAgent: string, keyId: string ) => Promise<CryptoKey>
function verifyContentDigest( body: Uint8Array | string, header: string ): boolean
function clearKeyDirectoryCache(): void
function generateKeyDirectory( options: GenerateDirectoryOptions ): KeyDirectory
async function signDirectoryResponse( directory: KeyDirectory, options: SignDirectoryOptions ): Promise<SignedDirectoryResponse>
async function generateWebBotAuthSetup( baseUrl?: string ): Promise<{ privateKey: CryptoKey; publicKey: CryptoKey; thumbprint: string; directory: KeyDirectory; keyDirectoryUrl: string; }>
function isValidKeyDirectoryUrl(url: string): boolean
class ReplayProtection { constructor(store: JtiStore); check(jti: string, exp: number): Promise<void>; }
function createReplayMiddleware( store: JtiStore ): RequestHandler
function withReplayProtection<T>( store: JtiStore, verifyFn: (token: string) => Promise<T> ): (token: string) => Promise<T>
class InMemoryJtiStore implements JtiStore { constructor(ttlSeconds?: number); has(jti: string): Promise<boolean>; add(jti: string, exp: number): Promise<void>; cleanup(): Promise<void>; }
async function checkReplay( store: JtiStore, jti: string, exp: number ): Promise<void>
function computeContentHash( content: Uint8Array, algorithm?: ContentHashAlgorithm ): Uint8Array
function computeContentHashB64( content: Uint8Array, algorithm?: ContentHashAlgorithm ): string
function verifyContentHash( content: Uint8Array, hash: Uint8Array, algorithm?: ContentHashAlgorithm ): boolean
function createHashClaim( content: Uint8Array, algorithm?: ContentHashAlgorithm ): HashClaim
function verifyHashClaim( content: Uint8Array, claim: HashClaim ): boolean
function computeCredentialBindingHash( credential: object ): string
function verifyCredentialBinding( credential: object, expectedHash: string ): boolean
class CredentialChain { add(credential: object, token: string): ChainEntry; getProof(): ChainProof; verify(): boolean; get length(): number; }
function computeChainHash( credentialHash: Uint8Array, previousHash: Uint8Array | null ): Uint8Array
function verifyChainLink( entry: ChainEntry, previousEntry: ChainEntry | null ): boolean
function verifyChainIntegrity(entries: ChainEntry[]): boolean
function serializeChainEntry(entry: ChainEntry): SerializedChainEntry
function deserializeChainEntry( serialized: SerializedChainEntry ): ChainEntry
class MultiSigCredential { constructor(credential: object); addSignature( privateKey: CryptoKey, signerId: string, options: SignOptions ): Promise<void>; getSignatures(): SignatureEntry[]; verifyAll( keyResolver: MultiSigKeyResolver ): Promise<MultiSigVerificationResult>; }
async function addSignature( credential: MultiSigCredential, privateKey: CryptoKey, signerId: string, options: SignOptions ): Promise<void>
async function verifyMultiSignatures( credential: MultiSigCredential, keyResolver: MultiSigKeyResolver ): Promise<MultiSigVerificationResult>
class AuditLogger { addHandler(handler: AuditHandler): void; log(event: AuditEvent): void; }
function getAuditLogger(): AuditLogger | undefined
function setAuditLogger(logger: AuditLogger): void
class ConsoleAuditHandler implements AuditHandler { handle(event: AuditEvent): void; }
class InMemoryAuditHandler implements AuditHandler { readonly events: AuditEvent[]; handle(event: AuditEvent): void; clear(): void; }
function serializeAuditEvent(event: AuditEvent): SerializedAuditEvent
function deserializeAuditEvent( serialized: SerializedAuditEvent ): AuditEvent
function eventToJson(event: AuditEvent): string
class LocalSigner implements CloudSigner { constructor(privateKey: CryptoKey, algorithm: 'EdDSA' | 'ES256'); sign(data: Uint8Array): Promise<Uint8Array>; getInfo(): SignerInfo; }
function createLocalSigner( privateKey: CryptoKey, algorithm: 'EdDSA' | 'ES256' ): LocalSigner
async function signWithSigner( signer: CloudSigner, data: Uint8Array ): Promise<Uint8Array>
class AwsKmsSigner implements CloudSigner { constructor(options: AwsKmsSignerOptions); sign(data: Uint8Array): Promise<Uint8Array>; getInfo(): SignerInfo; }
async function createSdJwt( credential: object, privateKey: CryptoKey, options: CreateSdJwtOptions ): Promise<SDJwt>
function createPresentation( sdJwt: SDJwt, disclosedPaths: string[], options?: CreatePresentationOptions ): string
async function verifySdJwt( presentation: string, options: VerifySdJwtOptions ): Promise<SdJwtVerificationResult>
function createDisclosure( salt: string, claimName: string, claimValue: unknown ): Disclosure
function decodeDisclosure(encoded: string): Disclosure
function compactSdJwt(sdJwt: SDJwt): string
function canonicalize(obj: unknown): Uint8Array
function canonicalizeToString(obj: unknown): string
function computeCanonicalHash( obj: unknown, algorithm?: ContentHashAlgorithm ): Uint8Array
function computeCanonicalHashB64( obj: unknown, algorithm?: ContentHashAlgorithm ): string
function verifyCanonicalHash( obj: unknown, hash: Uint8Array, algorithm?: ContentHashAlgorithm ): boolean
function sanitizeMessage(message: string): string
function sanitizeDetails(details: unknown): unknown
function getPublicMessage(error: Error): string
function createSanitizedError(error: Error): SanitizedError
function sanitizeException(error: unknown): SanitizedError
function validateTokenInput(token: string): void
function validateDid(did: string): void
function validateKid(kid: string): void
function validateUrl(url: string): void
function validateCredentialStructure( credential: unknown, options?: ValidateCredentialStructureOptions ): void
function validateAlgorithm(algorithm: string): void
function validateBase64url(value: string): void
class BelticError extends Error { code: string; }
class ValidationError extends BelticError { issues: ValidationErrorDetail[]; byPath(): Map<string, ValidationErrorDetail[]>; format(): string; }
class SignatureError extends BelticError { step: SignatureErrorStep; code: string; }
class TrustChainError extends BelticError { step: TrustChainErrorStep; agentCredential?: Partial<AgentCredential>; developerCredential?: Partial<DeveloperCredential>; }
class PolicyViolationError extends BelticError { violations: PolicyViolation[]; hasType(type: string): boolean; }
class ReplayDetectedError extends BelticError { jti: string; firstSeen: Date; }
class InputValidationError extends BelticError { field: string; }
class CanonicalizationError extends BelticError {}
class ContentIntegrityError extends BelticError {}
class ChainIntegrityError extends BelticError {}
class MultiSigError extends BelticError {}
class CloudSignerError extends BelticError {}
class SDJwtError extends BelticError {}
interface SignOptions { alg: 'EdDSA' | 'ES256'; issuerDid: string; subjectDid: string; keyId?: string; audience?: string; }
interface VerifyOptions { keyResolver: KeyResolver; expectedIssuer?: string; expectedAudience?: string; allowedAlgorithms?: ('EdDSA' | 'ES256')[]; }
interface TrustChainOptions { keyResolver: KeyResolver; fetchDeveloperCredential: (id: string) => Promise<string>; checkStatus?: StatusChecker; policy?: TrustPolicy; }
interface TrustPolicy { minKybTier?: 'tier_1' | 'tier_2' | 'tier_3'; minPromptInjectionScore?: number; minPiiLeakageScore?: number; minToolAbuseScore?: number; minHarmRefusalScore?: number; minVerificationLevel?: 'self_attested' | 'beltic_verified' | 'third_party_verified'; prohibitedDataCategories?: string[]; }
interface HttpRequestInfo { method: string; url: string; headers?: Record<string, string>; body?: Uint8Array | string; }
interface HttpSignOptions { privateKey: CryptoKey; keyId: string; keyDirectoryUrl: string; components?: SignableComponent[]; expiresIn?: number; }
interface AuditEvent { type: AuditEventType; timestamp: Date; credentialId?: string; action: string; actor?: string; details: Record<string, unknown>; }
const ALLOWED_ALGORITHMS: readonly ['EdDSA', 'ES256']
const PROHIBITED_ALGORITHMS: readonly ['none', 'HS256', 'HS384', 'HS512']
const MAX_CLOCK_SKEW_SECONDS: 300
const MAX_TOKEN_LENGTH: 1_000_000
const DID_PATTERN: RegExp const KID_PATTERN: RegExp const URL_PATTERN: RegExp const BASE64URL_PATTERN: RegExp const CREDENTIAL_ID_PATTERN: RegExp
Was this page helpful?
Suggestions