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,
} 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;
}

interface SdJwtOptions {
  disclosableClaims?: string[];
  hashAlgorithm?: 'sha-256';
}

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.