UNPKG

@x402-hpke/node

Version:

Provider-agnostic HPKE envelope library for x402 (Node) — cross-language interop with Python

84 lines (83 loc) 3.42 kB
import { createHpke } from "./index.js"; import { OkpJwk } from "./keys.js"; import { X402Extension } from "./extensions.js"; /** * A helper to create a 402 Payment Required response. * @param hpke The configured hpke instance. * @param args The arguments for the payment required response. * @param isPublic If true, the entire response data is exposed in the public sidecar. * @returns The sealed envelope and an optional publicJsonBody. */ export declare function createPaymentRequired(hpke: ReturnType<typeof createHpke>, args: { paymentRequiredData: Record<string, any>; recipientPublicJwk: OkpJwk; kid: string; }, isPublic?: boolean): Promise<{ envelope: import("./envelope.js").Envelope; publicJsonBody: any; }>; /** * A helper to create a client-side X-Payment request. * @param hpke The configured hpke instance. * @param args The arguments for the payment request. * @param isPublic If true, exposes the payment data in a public X-Payment header. * @returns The sealed envelope and an optional publicHeaders sidecar. */ export declare function createPayment(hpke: ReturnType<typeof createHpke>, args: { paymentData: Record<string, any>; recipientPublicJwk: OkpJwk; kid: string; extensions?: X402Extension[]; }, isPublic?: boolean): Promise<{ envelope: import("./envelope.js").Envelope; publicHeaders: Record<string, string> | undefined; }>; /** * A helper to create a server-side X-Payment-Response. * @param hpke The configured hpke instance. * @param args The arguments for the payment response. * @param isPublic If true, exposes the settlement data in a public X-Payment-Response header. * @returns The sealed envelope and an optional publicHeaders sidecar. */ export declare function createPaymentResponse(hpke: ReturnType<typeof createHpke>, args: { settlementData: Record<string, any>; recipientPublicJwk: OkpJwk; kid: string; extensions?: X402Extension[]; }, isPublic?: boolean): Promise<{ envelope: import("./envelope.js").Envelope; publicHeaders: Record<string, string> | undefined; }>; /** * A helper to create a general-purpose request envelope. * @param hpke The configured hpke instance. * @param args The arguments for the request. * @param isPublic If true, exposes the request data in a public header. * @returns The sealed envelope and an optional publicHeaders sidecar. */ export declare function createRequest(hpke: ReturnType<typeof createHpke>, args: { requestData: Record<string, any>; recipientPublicJwk: OkpJwk; kid: string; extensions?: X402Extension[]; }, isPublic?: boolean): Promise<{ envelope: import("./envelope.js").Envelope; publicHeaders: Record<string, string> | undefined; }>; /** * A helper to create a general-purpose response envelope. * @param hpke The configured hpke instance. * @param args The arguments for the response. * @param isPublic If true, exposes the response data in a public header. * @returns The sealed envelope and an optional publicHeaders sidecar. */ export declare function createResponse(hpke: ReturnType<typeof createHpke>, args: { responseData: Record<string, any>; recipientPublicJwk: OkpJwk; httpResponseCode: number; kid: string; extensions?: X402Extension[]; }, isPublic?: boolean): Promise<{ envelope: import("./envelope.js").Envelope; publicHeaders: Record<string, string> | undefined; }>;