@x402-hpke/node
Version:
Provider-agnostic HPKE envelope library for x402 (Node) — cross-language interop with Python
61 lines (60 loc) • 1.53 kB
TypeScript
import { OkpJwk } from "./keys.js";
export type Envelope = {
typ: "hpke-envelope";
ver: "1";
suite?: "X25519-HKDF-SHA256-CHACHA20POLY1305";
ns: string;
kid: string;
kem: "X25519";
kdf: "HKDF-SHA256";
aead: "CHACHA20-POLY1305";
enc: string;
aad: string;
ct: string;
};
export declare function seal(args: {
namespace: string;
kem: "X25519";
kdf: "HKDF-SHA256";
aead: "CHACHA20-POLY1305";
kid: string;
recipientPublicJwk: OkpJwk;
transport: {
getHeader(): {
header: string;
value: any;
} | undefined;
getBody(): Record<string, any>;
getExtensions(): Array<{
header: string;
value: any;
}>;
getHttpResponseCode(): number | undefined;
};
makeEntitiesPublic?: "all" | "*" | string[];
__testEphSeed32?: Uint8Array;
}): Promise<{
envelope: Envelope;
publicHeaders?: Record<string, string>;
publicBody?: Record<string, any>;
}>;
export declare function open(args: {
namespace: string;
kem: "X25519";
kdf: "HKDF-SHA256";
aead: "CHACHA20-POLY1305";
expectedKid?: string;
recipientPrivateJwk: OkpJwk;
envelope: Envelope;
publicHeaders?: Record<string, string>;
publicJson?: Record<string, string>;
publicBody?: Record<string, any>;
}): Promise<{
plaintext: Uint8Array;
body?: Record<string, any>;
headers?: Array<{
header: string;
value: any;
[k: string]: any;
}>;
}>;