@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/dist/client.js DELETED
@@ -1,629 +0,0 @@
1
- import { GenesisPayConfigError, GenesisPayNetworkSafetyError, GenesisPayValidationError, throwForErrorResponse, } from "./errors.js";
2
- import { createMandatesResource } from "./mandates.js";
3
- import { createCustomersResource } from "./customers.js";
4
- import { createInvoicesResource } from "./invoices.js";
5
- import { createPaymentGate } from "./payment-gate.js";
6
- import { DEFAULT_FACILITATOR_BASE_URL, genesisPaySettlement } from "./genesispay-settlement.js";
7
- import { createPlansResource } from "./plans.js";
8
- import { createProductsResource } from "./products.js";
9
- import { createEntitlementsResource } from "./entitlements.js";
10
- import { resolvePaymentGateNetwork } from "./networks.js";
11
- import { parseUsdcAmountToMinorUnits } from "./usdc-amount.js";
12
- import { asRecord, oneOf, optionalMetadata, optionalString, requiredString, toCount, } from "./resource.js";
13
- import { constructEvent } from "./webhooks.js";
14
- import { isPayerRedirectUrl } from "./checkout-return.js";
15
- // The error classes live in ./errors.js (shared with every future resource:
16
- // plans, mandates, …) and are re-exported here so existing imports from
17
- // "./client.js" keep working.
18
- export { GenesisPayConfigError, GenesisPayNetworkSafetyError, GenesisPayNotFoundError, GenesisPayRateLimitError, GenesisPayValidationError, } from "./errors.js";
19
- /**
20
- * Production GenesisPay facilitator. Hardcoded so a live key always resolves to
21
- * our facilitator with zero config, mirroring the test default.
22
- *
23
- * This is the custom domain, deliberately, not the Railway-generated hostname.
24
- * The generated form is derived from the service name, so it breaks the moment
25
- * the service is renamed — and `peerpay-app-production.up.railway.app`, which
26
- * this used to point at, never existed at all: production has exactly one
27
- * domain, `genesispay.finance`. Every zero-config live key resolved to a dead
28
- * host until this line was fixed. Point it at a domain we own, not at one
29
- * Railway generates for us.
30
- */
31
- const PRODUCTION_FACILITATOR_BASE_URL = "https://genesispay.finance";
32
- // Both facilitator URLs are hardcoded so the key mode alone routes to the right
33
- // GenesisPay facilitator; an explicit `baseUrl` still overrides for self-host/staging.
34
- const MODE_BASE_URLS = {
35
- test: DEFAULT_FACILITATOR_BASE_URL,
36
- live: PRODUCTION_FACILITATOR_BASE_URL,
37
- };
38
- /**
39
- * Appended to the error when simulate-payment answers 403. The server sends its
40
- * own explanation in the body, but a proxy or a future rewording must not be
41
- * able to leave the caller without the one fact that matters: the endpoint is
42
- * gated on the *key mode*, and a live key can never mint a payment.
43
- */
44
- const SIMULATE_PAYMENT_LIVE_KEY_HINT = "simulate-payment only works with a test-mode key (gp_sk_test_…); this client " +
45
- "is using a live key, and live keys can only record real, on-chain payments.";
46
- /** Which networks each key mode may legitimately resolve to (fail-closed guard). */
47
- const MODE_NETWORKS = {
48
- test: ["base-sepolia"],
49
- live: ["base"],
50
- };
51
- function parseKeyMode(apiKey) {
52
- if (apiKey.startsWith("gp_sk_live_"))
53
- return "live";
54
- if (apiKey.startsWith("gp_sk_"))
55
- return "test"; // gp_sk_test_… and legacy gp_sk_<32>
56
- throw new GenesisPayConfigError("apiKey must be a GenesisPay seller key (gp_sk_test_… or gp_sk_live_…).");
57
- }
58
- function normalizeBaseUrl(url) {
59
- const trimmed = url.trim().replace(/\/+$/, "");
60
- const isHttps = /^https:\/\//i.test(trimmed);
61
- const isLocalHttp = /^http:\/\/(localhost|127\.0\.0\.1)(:\d+)?(\/|$)/i.test(trimmed);
62
- if (!isHttps && !isLocalHttp) {
63
- throw new GenesisPayConfigError(`baseUrl must be https (got "${trimmed}").`);
64
- }
65
- return trimmed;
66
- }
67
- function describeError(error) {
68
- return error instanceof Error ? error.message : "unknown error";
69
- }
70
- function toCheckoutLink(raw) {
71
- // A backend older than 0.6.0 reports the amount only as `amountUsdc`; both
72
- // names carry the same decimal string, so either one populates both fields.
73
- // The check is on "is a string" rather than "is present", so a backend that
74
- // sends a non-string `amount` still falls back instead of yielding "".
75
- const amount = requiredString(typeof raw.amount === "string" ? raw.amount : raw.amountUsdc);
76
- return {
77
- publicId: requiredString(raw.publicId),
78
- payUrl: requiredString(raw.payUrl),
79
- amount,
80
- amountUsdc: amount,
81
- asset: oneOf(raw.asset, ["USDC", "EURC"], "USDC"),
82
- title: requiredString(raw.title),
83
- metadata: optionalMetadata(raw.metadata),
84
- clientReferenceId: optionalString(raw.clientReferenceId),
85
- returnUrl: optionalString(raw.returnUrl),
86
- cancelUrl: optionalString(raw.cancelUrl),
87
- };
88
- }
89
- /**
90
- * Maps the server's attempt views tolerantly: a non-array (or missing) field
91
- * yields `[]`, an entry without a usable `id` is skipped, and every optional
92
- * field degrades to `null` — an older backend must never crash a poll loop.
93
- */
94
- function toCheckoutAttempts(value) {
95
- if (!Array.isArray(value))
96
- return [];
97
- const attempts = [];
98
- for (const entry of value) {
99
- if (!entry || typeof entry !== "object" || Array.isArray(entry))
100
- continue;
101
- const raw = entry;
102
- const id = optionalString(raw.id);
103
- if (!id)
104
- continue;
105
- attempts.push({
106
- id,
107
- status: oneOf(raw.status, ["pending", "submitted", "confirmed", "failed", "expired"], "pending"),
108
- txHash: optionalString(raw.txHash),
109
- payerWallet: optionalString(raw.payerWallet),
110
- createdAt: requiredString(raw.createdAt),
111
- confirmedAt: optionalString(raw.confirmedAt),
112
- failureReason: optionalString(raw.failureReason),
113
- // Only an explicit `true` counts: an older backend omits the field, and
114
- // treating anything truthy as simulated would misreport real payments.
115
- simulated: raw.simulated === true,
116
- });
117
- }
118
- return attempts;
119
- }
120
- function toCheckoutSession(raw) {
121
- const confirmedPaymentCount = toCount(raw.confirmedPaymentCount);
122
- return {
123
- ...toCheckoutLink(raw),
124
- description: optionalString(raw.description),
125
- linkType: oneOf(raw.linkType, ["single", "reusable"], "single"),
126
- status: oneOf(raw.status, ["active", "paid", "archived"], "active"),
127
- destinationWallet: requiredString(raw.destinationWallet),
128
- chainId: toCount(raw.chainId),
129
- // Derived, not sent by the server: one confirmed payment is what "paid" means
130
- // for a reusable link too, so this is the single value worth polling on.
131
- paid: confirmedPaymentCount > 0,
132
- confirmedPaymentCount,
133
- createdAt: requiredString(raw.createdAt),
134
- attempts: toCheckoutAttempts(raw.attempts),
135
- };
136
- }
137
- /**
138
- * Folds the `{ attempt, link }` that `simulate-payment` answers with into one
139
- * `CheckoutSession`, so the method returns the same shape `checkout.retrieve`
140
- * does and a test can go straight from simulating to asserting on `paid`.
141
- *
142
- * The merge is necessary rather than cosmetic: the simulate route's `link` is a
143
- * plain link view with no `confirmedPaymentCount` and no `attempts`, so mapping
144
- * it alone would report `paid: false` immediately after minting a confirmed
145
- * payment. The confirmed attempt from the same response supplies both.
146
- *
147
- * The one thing this cannot know is how many payments a *reusable* link already
148
- * had — `confirmedPaymentCount` is therefore "at least this one". Call
149
- * `checkout.retrieve()` when the exact total matters.
150
- */
151
- function toSimulatedCheckoutSession(rawLink, attempt) {
152
- const session = toCheckoutSession(rawLink);
153
- const confirmedPaymentCount = session.confirmedPaymentCount + (attempt.status === "confirmed" ? 1 : 0);
154
- return {
155
- ...session,
156
- attempts: [attempt, ...session.attempts],
157
- confirmedPaymentCount,
158
- paid: confirmedPaymentCount > 0,
159
- };
160
- }
161
- /**
162
- * True when two amount strings mean different money. `"5.0"` and `"5.00"` are
163
- * the same amount, so the comparison is on parsed minor units rather than on
164
- * the strings; a value the parser cannot read at all is left to the server,
165
- * which owns amount validation, and only counts as a disagreement if the other
166
- * string differs from it.
167
- */
168
- function amountsDisagree(a, b) {
169
- if (a.trim() === b.trim())
170
- return false;
171
- const minorUnits = (value) => {
172
- try {
173
- return parseUsdcAmountToMinorUnits(value);
174
- }
175
- catch {
176
- return null;
177
- }
178
- };
179
- const [minorA, minorB] = [minorUnits(a), minorUnits(b)];
180
- if (minorA === null || minorB === null)
181
- return true;
182
- return minorA !== minorB;
183
- }
184
- /**
185
- * Resolves `amount` and the deprecated `amountUsdc` down to the single value
186
- * the request carries.
187
- *
188
- * The disagreement case is stopped here rather than on the server because a
189
- * create call that names two different prices has no correct interpretation —
190
- * picking either one would create a link for money the caller did not mean.
191
- */
192
- function resolveCheckoutAmount(input) {
193
- const { amount, amountUsdc } = input;
194
- if (amount === undefined && amountUsdc === undefined) {
195
- throw new GenesisPayValidationError('checkout.create requires `amount` — a decimal string in the link\'s asset, e.g. "5.00".', [{ path: "amount", message: "amount is required." }]);
196
- }
197
- if (amount !== undefined && amountUsdc !== undefined && amountsDisagree(amount, amountUsdc)) {
198
- throw new GenesisPayValidationError(`checkout.create got amount "${amount}" and the deprecated amountUsdc "${amountUsdc}", ` +
199
- "which are different amounts. Set `amount` on its own.", [{ path: "amount", message: "amount and amountUsdc disagree." }]);
200
- }
201
- return (amount ?? amountUsdc);
202
- }
203
- const MAX_REDIRECT_URL_LENGTH = 2_048;
204
- /**
205
- * Local validation for the two payer-facing redirect fields, mirroring the
206
- * server's `payerRedirectUrlSchema`. The point of doing it here rather than
207
- * waiting for a 422 is that a `javascript:`/`data:` value would otherwise be
208
- * serialised and sent to the API once before anyone notices — and the checkout
209
- * markup that later renders it as a link is exactly where an unsafe URL hurts.
210
- * The server stays the authoritative backstop for raw HTTP clients.
211
- *
212
- * Trims each field, drops empty-after-trim values (the server stores them as
213
- * `null`), and rejects anything over 2048 characters or outside the scheme
214
- * allowlist. A supplied non-string (a JavaScript caller passing `null` or a
215
- * number past the TypeScript boundary) is reported as a validation issue
216
- * rather than crashing on `.trim()`. A rejected call throws
217
- * `GenesisPayValidationError` with one issue per offending field, before any
218
- * network request.
219
- */
220
- function validateRedirectFields(input) {
221
- const issues = [];
222
- const normalize = (field, raw) => {
223
- if (raw === undefined)
224
- return undefined;
225
- if (typeof raw !== "string") {
226
- issues.push({ path: field, message: `${field} must be a string` });
227
- return undefined;
228
- }
229
- const trimmed = raw.trim();
230
- if (!trimmed)
231
- return undefined;
232
- if (trimmed.length > MAX_REDIRECT_URL_LENGTH) {
233
- issues.push({
234
- path: field,
235
- message: `${field} must be ${MAX_REDIRECT_URL_LENGTH} characters or less`,
236
- });
237
- return undefined;
238
- }
239
- if (!isPayerRedirectUrl(trimmed)) {
240
- issues.push({
241
- path: field,
242
- message: `${field} must be an https URL (http is allowed for localhost only)`,
243
- });
244
- return undefined;
245
- }
246
- return trimmed;
247
- };
248
- const returnUrl = normalize("returnUrl", input.returnUrl);
249
- const cancelUrl = normalize("cancelUrl", input.cancelUrl);
250
- if (issues.length > 0) {
251
- throw new GenesisPayValidationError("checkout.create rejected one or more redirect URLs.", issues);
252
- }
253
- return { returnUrl, cancelUrl };
254
- }
255
- function paymentNotConfiguredResponse() {
256
- return Response.json({
257
- error: "payment_not_configured",
258
- message: "This seller has no receiving wallet configured yet.",
259
- }, { status: 402 });
260
- }
261
- function paymentUnavailableResponse(error) {
262
- return Response.json({
263
- error: "payment_unavailable",
264
- message: `Payment is temporarily unavailable: ${describeError(error)}`,
265
- }, { status: 503 });
266
- }
267
- export class GenesisPay {
268
- mode;
269
- baseUrl;
270
- checkout;
271
- /** Subscription plans and their hosted `checkoutUrl` — see ./plans.ts. */
272
- plans;
273
- /** The merchant's catalogue and its canonical payment links — see ./products.ts. */
274
- products;
275
- /** Seller-scoped redirect-entitlement verification. */
276
- entitlements;
277
- /** Reusable billing contacts for one-off invoices. */
278
- customers;
279
- /** Draft, finalize, deliver, and collect one-off invoices. */
280
- invoices;
281
- /**
282
- * Payment mandates: bounded, revocable spending approvals a payer signs once.
283
- *
284
- * There is no `mandates.activate` on purpose — activation carries the
285
- * *payer's* signature, is authorized by their wallet rather than by this API
286
- * key, and therefore belongs in the payer-facing frontend. See the module
287
- * comment in ./mandates.ts.
288
- */
289
- mandates;
290
- /**
291
- * Webhook signature verification. Also exported as the free function
292
- * `constructEvent` — a webhook route rarely has a client instance in scope,
293
- * and verification needs the endpoint secret rather than the API key.
294
- */
295
- webhooks;
296
- apiKey;
297
- fetchFn;
298
- configTtlMs;
299
- expectedPayTo;
300
- cache;
301
- inflight;
302
- /**
303
- * The single authenticated-JSON seam every resource goes through. Bound as a
304
- * field so it can be handed to `./plans.ts` / `./mandates.ts` without leaking
305
- * the key, the base URL or `fetch` into them.
306
- */
307
- request = (options) => this.performRequest(options);
308
- constructor(options) {
309
- const apiKey = options.apiKey?.trim();
310
- if (!apiKey) {
311
- throw new GenesisPayConfigError("apiKey (gp_sk_test_… / gp_sk_live_…) is required.");
312
- }
313
- this.apiKey = apiKey;
314
- this.mode = parseKeyMode(apiKey);
315
- const chosen = options.baseUrl?.trim() || MODE_BASE_URLS[this.mode];
316
- if (!chosen) {
317
- throw new GenesisPayConfigError(`GenesisPay ${this.mode} base URL is not configured yet; pass baseUrl explicitly.`);
318
- }
319
- this.baseUrl = normalizeBaseUrl(chosen);
320
- this.fetchFn = options.fetchFn ?? fetch;
321
- this.configTtlMs = options.configTtlMs ?? 300_000;
322
- this.expectedPayTo = options.expectedPayTo?.trim().toLowerCase() || undefined;
323
- this.checkout = {
324
- create: (input) => this.createCheckout(input),
325
- retrieve: (publicId) => this.retrieveCheckout(publicId),
326
- simulatePayment: (publicId, opts) => this.simulateCheckoutPayment(publicId, opts),
327
- };
328
- // Both resources get the same bound request seam, so their errors go
329
- // through the one shared mapper in ./errors.ts like checkout's do.
330
- this.plans = createPlansResource(this.request, (wallet, what) => this.assertPinnedDestination(wallet, what));
331
- // Shares the client's own link mapper so the minted link's shape cannot
332
- // drift from `checkout.create`'s.
333
- this.products = createProductsResource(this.request, (wallet, what) => this.assertPinnedDestination(wallet, what), (raw) => toCheckoutLink(raw), this.baseUrl, (publicId, body) => this.performProductGateRequest(publicId, body));
334
- this.entitlements = createEntitlementsResource(this.request);
335
- this.mandates = createMandatesResource(this.request);
336
- this.customers = createCustomersResource(this.request);
337
- this.invoices = createInvoicesResource(this.request);
338
- // Stateless pass-through: verification depends only on the endpoint secret,
339
- // never on this client's key, mode or base URL.
340
- this.webhooks = {
341
- constructEvent: (rawBody, signatureHeader, secret, opts) => constructEvent(rawBody, signatureHeader, secret, opts),
342
- };
343
- }
344
- /** Raw on purpose: product-gate negotiation must preserve 402 protocol headers. */
345
- async performProductGateRequest(publicId, body) {
346
- return this.fetchFn(`${this.baseUrl}/api/v1/products/${encodeURIComponent(publicId)}/x402`, {
347
- method: "POST",
348
- headers: {
349
- authorization: `Bearer ${this.apiKey}`,
350
- "content-type": "application/json",
351
- accept: "application/json",
352
- },
353
- body: JSON.stringify(body),
354
- cache: "no-store",
355
- });
356
- }
357
- /**
358
- * Resolve (and cache) the seller config from the key. Single-flight so a
359
- * cold-start burst shares one request; failures are never cached (the memo is
360
- * cleared on rejection so the next call retries).
361
- */
362
- async retrieveSeller(opts) {
363
- const now = Date.now();
364
- if (!opts?.forceRefresh && this.cache && now - this.cache.fetchedAt < this.configTtlMs) {
365
- return this.cache.config;
366
- }
367
- if (!this.inflight) {
368
- this.inflight = this.fetchSeller()
369
- .then((config) => {
370
- this.cache = { config, fetchedAt: Date.now() };
371
- return config;
372
- })
373
- .finally(() => {
374
- this.inflight = undefined;
375
- });
376
- }
377
- return this.inflight;
378
- }
379
- gate(config) {
380
- const innerGates = new Map();
381
- const defaultSettle = genesisPaySettlement({
382
- facilitatorBaseUrl: this.baseUrl,
383
- apiKey: this.apiKey,
384
- fetchFn: this.fetchFn,
385
- });
386
- const buildInner = (seller) => {
387
- // Key by (payTo, chainId): a wallet rotation after TTL builds a fresh gate,
388
- // while any single gate stays internally consistent across challenge/replay.
389
- const cacheKey = `${seller.payTo}:${seller.network.chainId}`;
390
- let inner = innerGates.get(cacheKey);
391
- if (!inner) {
392
- inner = createPaymentGate({
393
- amountUsdc: config.amountUsdc,
394
- payTo: seller.payTo,
395
- network: seller.network.networkName,
396
- description: config.description,
397
- resource: config.resource,
398
- mimeType: config.mimeType,
399
- maxTimeoutSeconds: config.maxTimeoutSeconds,
400
- });
401
- innerGates.set(cacheKey, inner);
402
- }
403
- return inner;
404
- };
405
- const resolveSeller = () => this.retrieveSeller();
406
- return {
407
- prime: async () => {
408
- await resolveSeller();
409
- },
410
- wrap: (handler, opts) => {
411
- const verifySettlement = opts?.verifySettlement ?? defaultSettle;
412
- return async (request, ...args) => {
413
- let seller;
414
- try {
415
- seller = await resolveSeller();
416
- }
417
- catch (error) {
418
- // Fail closed: never run the paid handler when config can't be resolved.
419
- return paymentUnavailableResponse(error);
420
- }
421
- if (!seller.hasPayTo || !seller.payTo) {
422
- return paymentNotConfiguredResponse();
423
- }
424
- return buildInner(seller).wrap(handler, { verifySettlement })(request, ...args);
425
- };
426
- },
427
- };
428
- }
429
- async fetchSeller() {
430
- let response;
431
- try {
432
- response = await this.fetchFn(`${this.baseUrl}/api/v1/seller`, {
433
- headers: { authorization: `Bearer ${this.apiKey}` },
434
- });
435
- }
436
- catch (error) {
437
- throw new GenesisPayConfigError(`Failed to reach GenesisPay to resolve the seller: ${describeError(error)}`);
438
- }
439
- if (!response.ok) {
440
- // 401/403/500 land on GenesisPayConfigError with the key/base-URL hint; a
441
- // 429 on the seller lookup is a rate limit like any other, not a broken key.
442
- await throwForErrorResponse(response, {
443
- operation: "GET /api/v1/seller",
444
- hint: "Could not resolve the seller — check the API key and base URL.",
445
- });
446
- }
447
- const config = (await response.json());
448
- this.assertSafe(config);
449
- return config;
450
- }
451
- assertSafe(config) {
452
- const net = config.network;
453
- // (1) Mode consistency: the mode encoded in the key prefix and the mode the
454
- // server resolved from its stored column must agree. For keys minted by this
455
- // system they always do (both come from the deployment network at creation);
456
- // a disagreement means key/DB corruption or a spoofed response — fail closed.
457
- if (config.mode !== this.mode) {
458
- throw new GenesisPayNetworkSafetyError(`Key mode "${this.mode}" does not match the server-resolved mode "${config.mode}".`);
459
- }
460
- // (2) Mode↔network: a live key must never resolve to a testnet, and vice
461
- // versa. Checked before the asset table so an unknown/foreign network name
462
- // surfaces as a typed safety error instead of a generic lookup throw.
463
- if (!MODE_NETWORKS[this.mode].includes(net.networkName)) {
464
- throw new GenesisPayNetworkSafetyError(`A ${this.mode} key must not resolve to network "${net.networkName}".`);
465
- }
466
- // (3) Asset integrity: the backend-reported USDC/chainId must match the
467
- // SDK's own native-USDC table for that (now-known) network.
468
- const known = resolvePaymentGateNetwork(net.networkName);
469
- if (known.chainId !== net.chainId ||
470
- known.usdcAddress.toLowerCase() !== String(net.usdcAddress).toLowerCase()) {
471
- throw new GenesisPayNetworkSafetyError(`Backend network is inconsistent for "${net.networkName}" (chainId ${net.chainId}, usdc ${net.usdcAddress}).`);
472
- }
473
- // (4) Optional local pin on the payout wallet.
474
- if (this.expectedPayTo && config.payTo && config.payTo.toLowerCase() !== this.expectedPayTo) {
475
- throw new GenesisPayNetworkSafetyError(`Resolved payTo does not match expectedPayTo.`);
476
- }
477
- }
478
- /**
479
- * Applies the `expectedPayTo` pin to a destination the server just froze onto
480
- * a newly created object.
481
- *
482
- * Checking it in `assertSafe` alone was not enough: that only covers the
483
- * `/api/v1/seller` config lookup, while a checkout link and a subscription
484
- * plan each record their own `destinationWallet` at creation. Those are the
485
- * addresses money actually moves to — a pin that does not cover them is not
486
- * the guarantee the option advertises.
487
- */
488
- assertPinnedDestination(wallet, what) {
489
- if (!this.expectedPayTo)
490
- return;
491
- if (typeof wallet !== "string" || !wallet) {
492
- // Fail CLOSED. A response that omits the destination is exactly the
493
- // response the pin cannot vouch for — an intermediary that strips the
494
- // field must not read as "matches". Silently returning here made the
495
- // guarantee bypassable by omission.
496
- throw new GenesisPayNetworkSafetyError(`The ${what} response carried no destinationWallet to check against expectedPayTo.`);
497
- }
498
- if (wallet.toLowerCase() !== this.expectedPayTo) {
499
- throw new GenesisPayNetworkSafetyError(`The ${what} was created with a destinationWallet that does not match expectedPayTo.`);
500
- }
501
- }
502
- /**
503
- * One authenticated JSON round-trip, with the error mapping every method
504
- * shares. A transport failure (no response at all) is the only case handled
505
- * here rather than in `throwForErrorResponse`, because there is no status to
506
- * map — it is always a config/connectivity problem.
507
- */
508
- async performRequest(options) {
509
- const hasBody = options.body !== undefined;
510
- let response;
511
- try {
512
- response = await this.fetchFn(`${this.baseUrl}${options.path}`, {
513
- method: options.method ?? "GET",
514
- headers: {
515
- authorization: `Bearer ${this.apiKey}`,
516
- ...(hasBody ? { "content-type": "application/json" } : {}),
517
- ...options.headers,
518
- },
519
- ...(hasBody ? { body: JSON.stringify(options.body) } : {}),
520
- });
521
- }
522
- catch (error) {
523
- throw new GenesisPayConfigError(`Failed to reach GenesisPay to ${options.action}: ${describeError(error)}`);
524
- }
525
- if (!response.ok) {
526
- // Shared mapping: 422 → GenesisPayValidationError (with the field issues),
527
- // 429 → GenesisPayRateLimitError (with Retry-After), 404 → NotFound, rest → Config.
528
- await throwForErrorResponse(response, {
529
- operation: options.operation,
530
- notFoundMessage: options.notFoundMessage,
531
- hint: typeof options.hint === "function" ? options.hint(response.status) : options.hint,
532
- });
533
- }
534
- // An OK response with an unparseable body yields null; each caller decides
535
- // what a missing object means, and says so in its own error message.
536
- return (await response.json().catch(() => null));
537
- }
538
- async createCheckout(input) {
539
- const amount = resolveCheckoutAmount(input);
540
- const { returnUrl, cancelUrl } = validateRedirectFields(input);
541
- const body = await this.request({
542
- method: "POST",
543
- path: "/api/v1/links",
544
- operation: "POST /api/v1/links",
545
- action: "create a checkout link",
546
- body: {
547
- title: input.title,
548
- description: input.description,
549
- amount,
550
- // Both names, one value: a backend older than 0.6.0 only knows
551
- // `amountUsdc`, and a newer one accepts the pair precisely because they
552
- // agree. Nothing here can disagree — it is the same string twice.
553
- amountUsdc: amount,
554
- linkType: input.linkType ?? "single",
555
- ...(input.destinationWallet ? { destinationWallet: input.destinationWallet } : {}),
556
- ...(input.asset ? { asset: input.asset } : {}),
557
- ...(input.metadata ? { metadata: input.metadata } : {}),
558
- ...(input.clientReferenceId ? { clientReferenceId: input.clientReferenceId } : {}),
559
- ...(returnUrl ? { returnUrl } : {}),
560
- ...(cancelUrl ? { cancelUrl } : {}),
561
- },
562
- });
563
- const link = asRecord(body)?.link;
564
- if (!link || typeof link.payUrl !== "string" || !link.payUrl) {
565
- throw new GenesisPayConfigError(`GenesisPay link created but no payUrl in response: ${JSON.stringify(body)}`);
566
- }
567
- this.assertPinnedDestination(link.destinationWallet, "checkout link");
568
- return toCheckoutLink(link);
569
- }
570
- /**
571
- * Fetch the current state of a checkout link. `paid` is the field to poll on;
572
- * an unknown publicId raises `GenesisPayNotFoundError`, never a config error.
573
- */
574
- async retrieveCheckout(publicId) {
575
- const id = publicId?.trim();
576
- if (!id) {
577
- throw new GenesisPayConfigError("checkout.retrieve(publicId) requires the publicId returned by checkout.create().");
578
- }
579
- const body = await this.request({
580
- path: `/api/v1/links/${encodeURIComponent(id)}`,
581
- operation: `GET /api/v1/links/${id}`,
582
- action: `retrieve checkout "${id}"`,
583
- notFoundMessage: `No GenesisPay checkout with publicId "${id}". Check the id and that it belongs to the account this API key authenticates.`,
584
- });
585
- const link = asRecord(body)?.link;
586
- if (!link || typeof link.publicId !== "string" || !link.publicId) {
587
- throw new GenesisPayConfigError(`GenesisPay returned no link for publicId "${id}": ${JSON.stringify(body)}`);
588
- }
589
- return toCheckoutSession(link);
590
- }
591
- /** Test-mode only — see the doc on `checkout.simulatePayment`. */
592
- async simulateCheckoutPayment(publicId, opts) {
593
- const id = publicId?.trim();
594
- if (!id) {
595
- throw new GenesisPayConfigError("checkout.simulatePayment(publicId) requires the publicId returned by checkout.create().");
596
- }
597
- const body = await this.request({
598
- method: "POST",
599
- path: `/api/v1/links/${encodeURIComponent(id)}/simulate-payment`,
600
- operation: `POST /api/v1/links/${id}/simulate-payment`,
601
- action: `simulate a payment on checkout "${id}"`,
602
- body: opts?.payerWallet ? { payerWallet: opts.payerWallet } : {},
603
- // A 404 here has two very different causes and the server cannot tell you
604
- // which — by design, since a mainnet deployment must not even confirm the
605
- // endpoint exists. Naming both stops the "the id is definitely right, why
606
- // is it 404" hunt at the wrong end.
607
- notFoundMessage: `GenesisPay simulate-payment returned 404 for checkout "${id}". Either no such ` +
608
- `checkout exists for the account this API key authenticates, or this GenesisPay ` +
609
- `deployment runs on mainnet, where the endpoint does not exist at all. ` +
610
- `Check the publicId first, then the deployment's network.`,
611
- hint: (status) => status === 403 ? SIMULATE_PAYMENT_LIVE_KEY_HINT : undefined,
612
- });
613
- const record = asRecord(body);
614
- const link = record?.link;
615
- if (!link || typeof link.publicId !== "string" || !link.publicId) {
616
- throw new GenesisPayConfigError(`GenesisPay simulated a payment on "${id}" but returned no link: ${JSON.stringify(body)}`);
617
- }
618
- // The attempt is not an optional detail here the way an unknown field would
619
- // be: without it the merged session would report `paid: false` right after
620
- // a payment was minted. A 201 that omits it is a broken contract, not an
621
- // older backend — the endpoint and the field shipped together.
622
- const [attempt] = toCheckoutAttempts([record?.attempt]);
623
- if (!attempt) {
624
- throw new GenesisPayConfigError(`GenesisPay simulated a payment on "${id}" but returned no attempt: ${JSON.stringify(body)}`);
625
- }
626
- return toSimulatedCheckoutSession(link, attempt);
627
- }
628
- }
629
- //# sourceMappingURL=client.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"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