@x402-hpke/node
Version:
Provider-agnostic HPKE envelope library for x402 (Node) — cross-language interop with Python
58 lines (57 loc) • 2.17 kB
TypeScript
export type Algorithms = {
kem: "X25519";
kdf: "HKDF-SHA256";
aead: "CHACHA20-POLY1305";
};
export type CreateHpkeOptions = {
publicEntities?: "all" | "*" | string[];
namespace: string;
kem?: Algorithms["kem"];
kdf?: Algorithms["kdf"];
aead?: Algorithms["aead"];
jwksUrl?: string;
};
import { open } from "./envelope.js";
import { generateKeyPair, selectJwkFromJwks, setJwks, type Jwks, generatePublicJwk } from "./keys.js";
export { canonicalAad, buildCanonicalAad, validateX402Core } from "./aad.js";
export { generateKeyPair, selectJwkFromJwks, generatePublicJwk, generateJwks, generateSingleJwks } from "./keys.js";
export * from "./payment.js";
export * from "./extensions.js";
export * from "./helpers.js";
export { sealChunkXChaCha, openChunkXChaCha } from "./streaming.js";
export * as X402Errors from "./errors.js";
export { CanonicalHeaders, type HeaderEntry, type TransportType } from "./constants.js";
export { x402SecureTransport } from "./x402SecureTransport.js";
export declare const X402_HPKE_VERSION: "v1";
export declare const X402_HPKE_SUITE: "X25519-HKDF-SHA256-CHACHA20POLY1305";
export declare function createHpke(opts: CreateHpkeOptions): {
namespace: string;
kem: "X25519";
kdf: "HKDF-SHA256";
aead: "CHACHA20-POLY1305";
version: "v1";
suite: "X25519-HKDF-SHA256-CHACHA20POLY1305";
seal: (args: any) => Promise<{
envelope: import("./envelope.js").Envelope;
publicHeaders?: Record<string, string>;
publicBody?: Record<string, any>;
}>;
open: (args: Parameters<typeof open>[0]) => Promise<{
plaintext: Uint8Array;
body?: Record<string, any>;
headers?: Array<{
header: string;
value: any;
[k: string]: any;
}>;
}>;
canonicalAad: (x402: any, app?: any) => Uint8Array<ArrayBufferLike>;
generateKeyPair: typeof generateKeyPair;
generatePublicJwk: typeof generatePublicJwk;
selectJwkFromJwks: typeof selectJwkFromJwks;
fetchJwks(url?: string, ttl?: {
minTtlMs?: number;
maxTtlMs?: number;
}): Promise<Jwks>;
setJwks: typeof setJwks;
};