Skip to content

TypeScript API Reference

This section documents the TypeScript API for Harbour Credentials.

Installation

npm install @reachhaven/harbour-credentials

Quick Import Reference

import {
  // Key management
  generateP256Keypair,
  generateEd25519Keypair,
  p256PublicKeyToDid,
  ed25519PublicKeyToDid,
  privateKeyToJwk,
  publicKeyToJwk,

  // Signing
  signJwt,
  signVp,

  // Verification
  verifyJwt,
  verifyVp,

  // SD-JWT
  issueSdJwt,
  verifySdJwt,

  // KB-JWT
  createKbJwt,
  verifyKbJwt,

  // SD-JWT VP
  issueSdJwtVp,
  verifySdJwtVp,

  // X.509
  generateSelfSignedCert,
  certToX5c,
  x5cToCert,

  // Passkey evidence (docs/specs/passkey-evidence.md)
  payloadDigest,
  buildBatch,
  buildWebAuthnEvidence,
  staticResolver,
  verifyEvidenceChain,
  verifyEvidenceForPayload,
  verifyInstructionEvidence,
} from '@reachhaven/harbour-credentials';

Type Definitions

interface Keypair {
  privateKey: CryptoKey;
  publicKey: CryptoKey;
}

interface VerifiableCredential {
  '@context': string[];
  type: string[];
  issuer: string;
  credentialSubject: Record<string, unknown>;
  [key: string]: unknown;
}

// issueSdJwtVc(claims, privateKey, options)
interface SdJwtIssueOptions {
  vct: string;
  /** Dot paths ("address.city") or segment lists (["harbour.gx:labelLevel"]). */
  disclosable?: (string | string[])[];
  cnf?: Record<string, unknown>;
  kid?: string;
  x5c?: string[];
  alg?: string;
}

interface KbJwtOptions {
  nonce: string;
  audience: string;
  issuedAt?: number;
}

interface SdJwtVpOptions {
  disclosedClaims?: string[];
  evidence?: Record<string, unknown>;
  nonce?: string;
  audience?: string;
}

Generated Documentation

Full TypeScript API documentation can be generated with TypeDoc by running yarn docs in the TypeScript package directory.