@genesis-tech/genesispay-seller 0.13.0 → 0.13.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/package.json +1 -1
  2. package/dist/checkout-return.d.ts +0 -41
  3. package/dist/checkout-return.d.ts.map +0 -1
  4. package/dist/checkout-return.js +0 -67
  5. package/dist/checkout-return.js.map +0 -1
  6. package/dist/client.d.ts +0 -283
  7. package/dist/client.d.ts.map +0 -1
  8. package/dist/client.js +0 -629
  9. package/dist/client.js.map +0 -1
  10. package/dist/customers.d.ts +0 -41
  11. package/dist/customers.d.ts.map +0 -1
  12. package/dist/customers.js +0 -76
  13. package/dist/customers.js.map +0 -1
  14. package/dist/entitlements.d.ts +0 -19
  15. package/dist/entitlements.d.ts.map +0 -1
  16. package/dist/entitlements.js +0 -30
  17. package/dist/entitlements.js.map +0 -1
  18. package/dist/errors.d.ts +0 -63
  19. package/dist/errors.d.ts.map +0 -1
  20. package/dist/errors.js +0 -162
  21. package/dist/errors.js.map +0 -1
  22. package/dist/genesispay-settlement.d.ts +0 -30
  23. package/dist/genesispay-settlement.d.ts.map +0 -1
  24. package/dist/genesispay-settlement.js +0 -103
  25. package/dist/genesispay-settlement.js.map +0 -1
  26. package/dist/index.d.ts +0 -16
  27. package/dist/index.d.ts.map +0 -1
  28. package/dist/index.js +0 -18
  29. package/dist/index.js.map +0 -1
  30. package/dist/invoices.d.ts +0 -80
  31. package/dist/invoices.d.ts.map +0 -1
  32. package/dist/invoices.js +0 -133
  33. package/dist/invoices.js.map +0 -1
  34. package/dist/mandate-gate.d.ts +0 -49
  35. package/dist/mandate-gate.d.ts.map +0 -1
  36. package/dist/mandate-gate.js +0 -109
  37. package/dist/mandate-gate.js.map +0 -1
  38. package/dist/mandates.d.ts +0 -172
  39. package/dist/mandates.d.ts.map +0 -1
  40. package/dist/mandates.js +0 -213
  41. package/dist/mandates.js.map +0 -1
  42. package/dist/networks.d.ts +0 -10
  43. package/dist/networks.d.ts.map +0 -1
  44. package/dist/networks.js +0 -22
  45. package/dist/networks.js.map +0 -1
  46. package/dist/payment-gate.d.ts +0 -67
  47. package/dist/payment-gate.d.ts.map +0 -1
  48. package/dist/payment-gate.js +0 -106
  49. package/dist/payment-gate.js.map +0 -1
  50. package/dist/peerpay-settlement.d.ts +0 -27
  51. package/dist/peerpay-settlement.d.ts.map +0 -1
  52. package/dist/peerpay-settlement.js +0 -100
  53. package/dist/peerpay-settlement.js.map +0 -1
  54. package/dist/plans.d.ts +0 -68
  55. package/dist/plans.d.ts.map +0 -1
  56. package/dist/plans.js +0 -127
  57. package/dist/plans.js.map +0 -1
  58. package/dist/products.d.ts +0 -146
  59. package/dist/products.d.ts.map +0 -1
  60. package/dist/products.js +0 -295
  61. package/dist/products.js.map +0 -1
  62. package/dist/resource.d.ts +0 -47
  63. package/dist/resource.d.ts.map +0 -1
  64. package/dist/resource.js +0 -71
  65. package/dist/resource.js.map +0 -1
  66. package/dist/usdc-amount.d.ts +0 -7
  67. package/dist/usdc-amount.d.ts.map +0 -1
  68. package/dist/usdc-amount.js +0 -21
  69. package/dist/usdc-amount.js.map +0 -1
  70. package/dist/webhooks.d.ts +0 -277
  71. package/dist/webhooks.d.ts.map +0 -1
  72. package/dist/webhooks.js +0 -224
  73. package/dist/webhooks.js.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@genesis-tech/genesispay-seller",
3
- "version": "0.13.0",
3
+ "version": "0.13.1",
4
4
  "description": "Framework-agnostic x402 payment gate for sellers, powered by GenesisPay.",
5
5
  "license": "MIT",
6
6
  "author": "GenesisTech",
@@ -1,41 +0,0 @@
1
- /** The `returnUrl` query parameter carrying the checkout link's `publicId`. */
2
- export declare const CHECKOUT_RETURN_LINK_ID_PARAM = "genesispay_link_id";
3
- /** The `returnUrl` query parameter carrying the checkout status. */
4
- export declare const CHECKOUT_RETURN_STATUS_PARAM = "genesispay_status";
5
- /**
6
- * The result parameters GenesisPay appends to a merchant's `returnUrl`, as
7
- * read back by {@link parseCheckoutReturnHint}.
8
- *
9
- * **This is a UI hint, not proof of payment.** The values are unsigned and a
10
- * payer can open that URL without paying. Gate fulfilment on a verified
11
- * `payment.confirmed` webhook or on `checkout.retrieve(publicId).paid` — never
12
- * on these fields.
13
- */
14
- export type CheckoutReturnHint = {
15
- /** The checkout link's `publicId` — the value in `genesispay_link_id`. */
16
- linkId: string;
17
- /** Always `"paid"` — the parser returns nothing else. */
18
- status: "paid";
19
- };
20
- /**
21
- * Reads the return parameters off a `returnUrl`.
22
- *
23
- * Returns a hint only when the URL carries a non-empty `genesispay_link_id` and
24
- * an exact `genesispay_status=paid`. A missing id, any other status, or an
25
- * unparseable URL returns `null`. Accepts a string or an already-parsed `URL`.
26
- *
27
- * Performs **no verification**: it does not check that the link exists, that it
28
- * was paid, or that the parameters came from GenesisPay. Call
29
- * `checkout.retrieve(hint.linkId)` (authenticated with your seller key) before
30
- * acting on it.
31
- */
32
- export declare function parseCheckoutReturnHint(url: string | URL): CheckoutReturnHint | null;
33
- /**
34
- * The payer-facing redirect scheme allowlist for `returnUrl`/`cancelUrl`,
35
- * mirroring the server. `https` is always accepted; `http` is accepted only for
36
- * the exact loopback hostnames above — a `javascript:`/`data:` value, a remote
37
- * `http` host, or a deceptive `localhost.example` name is rejected, because
38
- * these values are rendered as links in the payer's browser.
39
- */
40
- export declare function isPayerRedirectUrl(rawUrl: string): boolean;
41
- //# sourceMappingURL=checkout-return.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"checkout-return.d.ts","sourceRoot":"","sources":["../src/checkout-return.ts"],"names":[],"mappings":"AAYA,+EAA+E;AAC/E,eAAO,MAAM,6BAA6B,uBAAuB,CAAC;AAElE,oEAAoE;AACpE,eAAO,MAAM,4BAA4B,sBAAsB,CAAC;AAQhE;;;;;;;;GAQG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B,0EAA0E;IAC1E,MAAM,EAAE,MAAM,CAAC;IACf,yDAAyD;IACzD,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,GAAG,kBAAkB,GAAG,IAAI,CAgBpF;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAa1D"}
@@ -1,67 +0,0 @@
1
- // The query parameters GenesisPay appends to a merchant's `returnUrl` after a
2
- // confirmed payment, and the helper that reads them back.
3
- //
4
- // These names are part of a cross-side contract: the server's hosted-checkout
5
- // URL builder (`src/features/payments/checkout-return-url.ts`) writes them and
6
- // this SDK reads them. A parity test lives on the server side (the only place
7
- // that can import both) and fails if either side renames one without the other.
8
- //
9
- // The parser below performs **no verification**. The parameters are unsigned —
10
- // anyone who knows a `publicId` can construct that URL without paying — so a
11
- // hint it returns is a UI convenience, never proof of payment.
12
- /** The `returnUrl` query parameter carrying the checkout link's `publicId`. */
13
- export const CHECKOUT_RETURN_LINK_ID_PARAM = "genesispay_link_id";
14
- /** The `returnUrl` query parameter carrying the checkout status. */
15
- export const CHECKOUT_RETURN_STATUS_PARAM = "genesispay_status";
16
- /** The only status the parser accepts — and the only status GenesisPay writes. */
17
- const PAID_STATUS = "paid";
18
- /** Hostnames for which `http` is accepted (local development only). */
19
- const LOCAL_REDIRECT_HOSTNAMES = new Set(["localhost", "127.0.0.1"]);
20
- /**
21
- * Reads the return parameters off a `returnUrl`.
22
- *
23
- * Returns a hint only when the URL carries a non-empty `genesispay_link_id` and
24
- * an exact `genesispay_status=paid`. A missing id, any other status, or an
25
- * unparseable URL returns `null`. Accepts a string or an already-parsed `URL`.
26
- *
27
- * Performs **no verification**: it does not check that the link exists, that it
28
- * was paid, or that the parameters came from GenesisPay. Call
29
- * `checkout.retrieve(hint.linkId)` (authenticated with your seller key) before
30
- * acting on it.
31
- */
32
- export function parseCheckoutReturnHint(url) {
33
- let parsed;
34
- try {
35
- parsed = typeof url === "string" ? new URL(url) : url;
36
- }
37
- catch {
38
- return null;
39
- }
40
- const linkId = parsed.searchParams.get(CHECKOUT_RETURN_LINK_ID_PARAM);
41
- const status = parsed.searchParams.get(CHECKOUT_RETURN_STATUS_PARAM);
42
- if (!linkId || status !== PAID_STATUS) {
43
- return null;
44
- }
45
- return { linkId, status: PAID_STATUS };
46
- }
47
- /**
48
- * The payer-facing redirect scheme allowlist for `returnUrl`/`cancelUrl`,
49
- * mirroring the server. `https` is always accepted; `http` is accepted only for
50
- * the exact loopback hostnames above — a `javascript:`/`data:` value, a remote
51
- * `http` host, or a deceptive `localhost.example` name is rejected, because
52
- * these values are rendered as links in the payer's browser.
53
- */
54
- export function isPayerRedirectUrl(rawUrl) {
55
- let parsed;
56
- try {
57
- parsed = new URL(rawUrl.trim());
58
- }
59
- catch {
60
- return false;
61
- }
62
- if (parsed.protocol === "https:") {
63
- return true;
64
- }
65
- return parsed.protocol === "http:" && LOCAL_REDIRECT_HOSTNAMES.has(parsed.hostname);
66
- }
67
- //# sourceMappingURL=checkout-return.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"checkout-return.js","sourceRoot":"","sources":["../src/checkout-return.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,0DAA0D;AAC1D,EAAE;AACF,8EAA8E;AAC9E,+EAA+E;AAC/E,8EAA8E;AAC9E,gFAAgF;AAChF,EAAE;AACF,+EAA+E;AAC/E,6EAA6E;AAC7E,+DAA+D;AAE/D,+EAA+E;AAC/E,MAAM,CAAC,MAAM,6BAA6B,GAAG,oBAAoB,CAAC;AAElE,oEAAoE;AACpE,MAAM,CAAC,MAAM,4BAA4B,GAAG,mBAAmB,CAAC;AAEhE,kFAAkF;AAClF,MAAM,WAAW,GAAG,MAAM,CAAC;AAE3B,uEAAuE;AACvE,MAAM,wBAAwB,GAAG,IAAI,GAAG,CAAC,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC,CAAC;AAkBrE;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,uBAAuB,CAAC,GAAiB;IACvD,IAAI,MAAW,CAAC;IAChB,IAAI,CAAC;QACH,MAAM,GAAG,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;IACxD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,MAAM,GAAG,MAAM,CAAC,YAAY,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAC;IACtE,MAAM,MAAM,GAAG,MAAM,CAAC,YAAY,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAC;IAErE,IAAI,CAAC,MAAM,IAAI,MAAM,KAAK,WAAW,EAAE,CAAC;QACtC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC;AACzC,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,kBAAkB,CAAC,MAAc;IAC/C,IAAI,MAAW,CAAC;IAChB,IAAI,CAAC;QACH,MAAM,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;IAClC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,MAAM,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;QACjC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,MAAM,CAAC,QAAQ,KAAK,OAAO,IAAI,wBAAwB,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;AACtF,CAAC"}
package/dist/client.d.ts DELETED
@@ -1,283 +0,0 @@
1
- import type { MandatesResource } from "./mandates.js";
2
- import type { CustomersResource } from "./customers.js";
3
- import type { InvoicesResource } from "./invoices.js";
4
- import type { VerifySettlement } from "./payment-gate.js";
5
- import type { PlansResource } from "./plans.js";
6
- import type { ProductsResource } from "./products.js";
7
- import type { EntitlementsResource } from "./entitlements.js";
8
- import type { PaymentGateNetwork } from "./networks.js";
9
- import type { ConstructEventOptions, GenesisPayEvent } from "./webhooks.js";
10
- /**
11
- * The legacy `GenesisPay` client — a Stripe-like entry point that owns the seller key and
12
- * resolves everything else (payout wallet, network, base URL) from it. The key
13
- * prefix decides the mode: `gp_sk_test_…` / legacy `gp_sk_…` → test,
14
- * `gp_sk_live_…` → live. See docs/archive/SELLER_SDK_DX_SPEC.md.
15
- */
16
- export type GenesisPayKeyMode = "test" | "live";
17
- export type GenesisPayClientOptions = {
18
- /** gp_sk_test_… | gp_sk_live_… | legacy gp_sk_… — the only required field. */
19
- apiKey: string;
20
- /** Overrides the mode→URL default (self-host / staging). Must be https (http only for localhost). */
21
- baseUrl?: string;
22
- /** Injectable fetch for tests. Defaults to the global fetch. */
23
- fetchFn?: typeof fetch;
24
- /** Seller-config cache TTL. Default 5 min. */
25
- configTtlMs?: number;
26
- /** Optional local pin on the resolved payout wallet; recommended for live keys. */
27
- expectedPayTo?: string;
28
- };
29
- export type SellerConfig = {
30
- id: string;
31
- mode: GenesisPayKeyMode;
32
- payTo: string | null;
33
- hasPayTo: boolean;
34
- network: {
35
- networkName: PaymentGateNetwork;
36
- chainId: number;
37
- usdcAddress: string;
38
- asset: "USDC";
39
- };
40
- };
41
- /**
42
- * The amount half of {@link CheckoutCreateInput}, as a union so that **one of
43
- * the two names is always required at compile time** — `amountUsdc` was a
44
- * required property before 0.6.0, and losing that to two optional fields would
45
- * have turned a type error into a runtime one.
46
- */
47
- export type CheckoutAmountInput = {
48
- /**
49
- * Decimal amount **in `asset`** — `"5.00"`, at most 6 decimals, always a
50
- * string (a float would lose minor units). Hosted checkout links settle
51
- * in USDC during the beta, so the amount is in dollars.
52
- *
53
- * Passing the deprecated `amountUsdc` alongside it is allowed only when
54
- * both are the same amount; two different values throw
55
- * `GenesisPayValidationError` before the request.
56
- */
57
- amount: string;
58
- /** @deprecated Use `amount` alone. */
59
- amountUsdc?: string;
60
- } | {
61
- amount?: string;
62
- /**
63
- * @deprecated Renamed to `amount` in 0.6.0. The name claimed a currency
64
- * the value did not always have. Still accepted, and still sent on the wire for backends older than
65
- * 0.6.0 — but new code should set `amount`.
66
- */
67
- amountUsdc: string;
68
- };
69
- export type CheckoutCreateInput = CheckoutAmountInput & {
70
- title: string;
71
- description?: string;
72
- linkType?: "single" | "reusable";
73
- destinationWallet?: string;
74
- /**
75
- * Hosted checkout links settle in USDC during the beta. Omit this field in
76
- * new integrations; it is kept only to make the invariant explicit in the
77
- * request type.
78
- */
79
- asset?: "USDC";
80
- /** Free-form correlation data; echoed back in webhooks and `checkout.retrieve()`. */
81
- metadata?: Record<string, string>;
82
- /** The merchant's own reference (Stripe: client_reference_id). */
83
- clientReferenceId?: string;
84
- /** Where the payer returns after a successful payment (https). */
85
- returnUrl?: string;
86
- /** Where the payer returns when they cancel (https). */
87
- cancelUrl?: string;
88
- };
89
- export type CheckoutLink = {
90
- publicId: string;
91
- payUrl: string;
92
- /** Decimal amount in `asset`, as the server normalized it (e.g. `"5.00"`). */
93
- amount: string;
94
- /** @deprecated Same value as {@link CheckoutLink.amount}; see the input field. */
95
- amountUsdc: string;
96
- /**
97
- * The currency `amount` is denominated in. Echoed back on create so a EURC
98
- * link can be confirmed as one without a second round-trip.
99
- */
100
- asset: "USDC" | "EURC";
101
- title: string;
102
- metadata: Record<string, string> | null;
103
- clientReferenceId: string | null;
104
- returnUrl: string | null;
105
- cancelUrl: string | null;
106
- };
107
- /** Lifecycle of a single payment attempt on a link, as the server reports it. */
108
- export type CheckoutAttemptStatus = "pending" | "submitted" | "confirmed" | "failed" | "expired";
109
- /**
110
- * One payment attempt against a checkout link — the receipt data (`txHash`,
111
- * `payerWallet`) that `paid === true` alone cannot give you.
112
- *
113
- * A `reusable` link accumulates attempts; the newest comes first. `txHash` is
114
- * null while an attempt is still pending, and stays null for attempts created
115
- * by the test-mode `simulate-payment` endpoint (no transaction exists).
116
- */
117
- export type CheckoutAttempt = {
118
- id: string;
119
- status: CheckoutAttemptStatus;
120
- txHash: string | null;
121
- payerWallet: string | null;
122
- createdAt: string;
123
- confirmedAt: string | null;
124
- failureReason: string | null;
125
- /**
126
- * True when no funds moved — an attempt created by
127
- * `checkout.simulatePayment`. Note that such an attempt also has
128
- * `txHash: null` — but so does a pending real one, which is why this flag
129
- * exists rather than inferring it.
130
- *
131
- * `false` for a real settlement, including on testnet and in provider
132
- * sandboxes: this is the fabricated-payment axis, not the environment axis.
133
- *
134
- * Defaults to `false` against a backend that does not report it.
135
- */
136
- simulated: boolean;
137
- };
138
- export type CheckoutSession = CheckoutLink & {
139
- description: string | null;
140
- linkType: "single" | "reusable";
141
- status: "active" | "paid" | "archived";
142
- destinationWallet: string;
143
- chainId: number;
144
- /**
145
- * true as soon as at least one payment is confirmed — the value to poll on.
146
- *
147
- * For a `reusable` link this answers "has this link ever been paid", not "has
148
- * this buyer paid": `confirmedPaymentCount` only grows, so `paid` stays true
149
- * from the first payment onward. Per-buyer fulfilment on a reusable link needs
150
- * a webhook, or `confirmedPaymentCount` tracked as a delta.
151
- */
152
- paid: boolean;
153
- confirmedPaymentCount: number;
154
- createdAt: string;
155
- /**
156
- * Payment attempts for this link, newest first — empty when the server does
157
- * not report them (older backend) or when nobody has tried to pay yet.
158
- */
159
- attempts: CheckoutAttempt[];
160
- };
161
- export type SimulatePaymentOptions = {
162
- /**
163
- * Payer address recorded on the simulated attempt. Defaults to a deliberately
164
- * synthetic server-side placeholder, so nobody mistakes a simulated payment
165
- * for a real payer in a dashboard or an export.
166
- */
167
- payerWallet?: string;
168
- };
169
- export type GateConfig = {
170
- amountUsdc: string;
171
- description?: string;
172
- resource?: string;
173
- mimeType?: string;
174
- maxTimeoutSeconds?: number;
175
- };
176
- type GateHandler<Args extends unknown[]> = (request: Request, ...args: Args) => Response | Promise<Response>;
177
- export interface ResolvingGate {
178
- wrap<Args extends unknown[]>(handler: GateHandler<Args>, opts?: {
179
- verifySettlement?: VerifySettlement;
180
- }): (request: Request, ...args: Args) => Promise<Response>;
181
- /** Warm the seller-config cache (and surface auth/wallet errors) before traffic. */
182
- prime(): Promise<void>;
183
- }
184
- export { GenesisPayConfigError, GenesisPayNetworkSafetyError, GenesisPayNotFoundError, GenesisPayRateLimitError, GenesisPayValidationError, type GenesisPayValidationIssue, } from "./errors.js";
185
- export declare class GenesisPay {
186
- readonly mode: GenesisPayKeyMode;
187
- readonly baseUrl: string;
188
- readonly checkout: {
189
- create(input: CheckoutCreateInput): Promise<CheckoutLink>;
190
- retrieve(publicId: string): Promise<CheckoutSession>;
191
- /**
192
- * Test mode only: records a confirmed payment on one of your links without
193
- * any money moving, and fires the real `payment.confirmed` (plus
194
- * `link.paid` for a single-use link) webhooks — the point being that you can
195
- * exercise your webhook handler end to end.
196
- *
197
- * The resulting attempt carries `simulated: true` and `txHash: null`; there
198
- * is no transaction, and a made-up hash would be a lie in a field other
199
- * systems point a block explorer at.
200
- */
201
- simulatePayment(publicId: string, opts?: SimulatePaymentOptions): Promise<CheckoutSession>;
202
- };
203
- /** Subscription plans and their hosted `checkoutUrl` — see ./plans.ts. */
204
- readonly plans: PlansResource;
205
- /** The merchant's catalogue and its canonical payment links — see ./products.ts. */
206
- readonly products: ProductsResource;
207
- /** Seller-scoped redirect-entitlement verification. */
208
- readonly entitlements: EntitlementsResource;
209
- /** Reusable billing contacts for one-off invoices. */
210
- readonly customers: CustomersResource;
211
- /** Draft, finalize, deliver, and collect one-off invoices. */
212
- readonly invoices: InvoicesResource;
213
- /**
214
- * Payment mandates: bounded, revocable spending approvals a payer signs once.
215
- *
216
- * There is no `mandates.activate` on purpose — activation carries the
217
- * *payer's* signature, is authorized by their wallet rather than by this API
218
- * key, and therefore belongs in the payer-facing frontend. See the module
219
- * comment in ./mandates.ts.
220
- */
221
- readonly mandates: MandatesResource;
222
- /**
223
- * Webhook signature verification. Also exported as the free function
224
- * `constructEvent` — a webhook route rarely has a client instance in scope,
225
- * and verification needs the endpoint secret rather than the API key.
226
- */
227
- readonly webhooks: {
228
- constructEvent(rawBody: string | Uint8Array, signatureHeader: string, secret: string, opts?: ConstructEventOptions): Promise<GenesisPayEvent>;
229
- };
230
- private readonly apiKey;
231
- private readonly fetchFn;
232
- private readonly configTtlMs;
233
- private readonly expectedPayTo?;
234
- private cache?;
235
- private inflight?;
236
- /**
237
- * The single authenticated-JSON seam every resource goes through. Bound as a
238
- * field so it can be handed to `./plans.ts` / `./mandates.ts` without leaking
239
- * the key, the base URL or `fetch` into them.
240
- */
241
- private readonly request;
242
- constructor(options: GenesisPayClientOptions);
243
- /** Raw on purpose: product-gate negotiation must preserve 402 protocol headers. */
244
- private performProductGateRequest;
245
- /**
246
- * Resolve (and cache) the seller config from the key. Single-flight so a
247
- * cold-start burst shares one request; failures are never cached (the memo is
248
- * cleared on rejection so the next call retries).
249
- */
250
- retrieveSeller(opts?: {
251
- forceRefresh?: boolean;
252
- }): Promise<SellerConfig>;
253
- gate(config: GateConfig): ResolvingGate;
254
- private fetchSeller;
255
- private assertSafe;
256
- /**
257
- * Applies the `expectedPayTo` pin to a destination the server just froze onto
258
- * a newly created object.
259
- *
260
- * Checking it in `assertSafe` alone was not enough: that only covers the
261
- * `/api/v1/seller` config lookup, while a checkout link and a subscription
262
- * plan each record their own `destinationWallet` at creation. Those are the
263
- * addresses money actually moves to — a pin that does not cover them is not
264
- * the guarantee the option advertises.
265
- */
266
- private assertPinnedDestination;
267
- /**
268
- * One authenticated JSON round-trip, with the error mapping every method
269
- * shares. A transport failure (no response at all) is the only case handled
270
- * here rather than in `throwForErrorResponse`, because there is no status to
271
- * map — it is always a config/connectivity problem.
272
- */
273
- private performRequest;
274
- private createCheckout;
275
- /**
276
- * Fetch the current state of a checkout link. `paid` is the field to poll on;
277
- * an unknown publicId raises `GenesisPayNotFoundError`, never a config error.
278
- */
279
- private retrieveCheckout;
280
- /** Test-mode only — see the doc on `checkout.simulatePayment`. */
281
- private simulateCheckoutPayment;
282
- }
283
- //# sour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