@openrails/billing-ui 0.237.0 → 0.238.0

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.
@@ -88,7 +88,49 @@ var s = {
88
88
  USDG: 6,
89
89
  USDT: 6,
90
90
  ZAR: 6
91
- }, c = e.object({
91
+ };
92
+ //#endregion
93
+ //#region src/client/token-source.ts
94
+ function c({ fetchToken: e, skew: t = 60 }) {
95
+ let n, r, a = () => n && Date.now() < n.staleAt ? Promise.resolve(n.token) : (r ??= e().then((e) => {
96
+ if (typeof e?.access_token != "string" || !e.access_token || !Number.isFinite(e.expires_in)) throw i("invalid_response", "fetchToken answered no access_token and expires_in");
97
+ return n = {
98
+ token: e.access_token,
99
+ staleAt: Date.now() + (e.expires_in - t) * 1e3
100
+ }, e.access_token;
101
+ }).finally(() => {
102
+ r = void 0;
103
+ }), r);
104
+ return a.invalidate = (e) => {
105
+ (e === void 0 || n?.token === e) && (n = void 0);
106
+ }, a;
107
+ }
108
+ var ee = (e) => typeof e == "function" && typeof e.invalidate == "function";
109
+ async function l(e) {
110
+ let t = await (e.fetch ?? ((e, t) => fetch(e, t)))(e.tokenEndpoint, {
111
+ method: "POST",
112
+ headers: {
113
+ Accept: "application/json",
114
+ "Content-Type": "application/x-www-form-urlencoded"
115
+ },
116
+ body: new URLSearchParams({
117
+ grant_type: "urn:ietf:params:oauth:grant-type:jwt-bearer",
118
+ assertion: e.assertion,
119
+ scope: "openrails:self"
120
+ }).toString()
121
+ });
122
+ if (!t.ok) throw await a(t);
123
+ let n = await t.json().catch(() => null);
124
+ if (typeof n?.access_token != "string" || typeof n.expires_in != "number") throw i("invalid_response", "the token endpoint answered no access_token and expires_in");
125
+ return {
126
+ access_token: n.access_token,
127
+ expires_in: n.expires_in,
128
+ token_type: typeof n.token_type == "string" ? n.token_type : "Bearer"
129
+ };
130
+ }
131
+ //#endregion
132
+ //#region src/psp.ts
133
+ var u = e.object({
92
134
  psp_id: e.string().min(1),
93
135
  key: e.string().min(1),
94
136
  rail: e.string(),
@@ -99,77 +141,77 @@ var s = {
99
141
  checkout: e.boolean().nullish(),
100
142
  status: e.string().nullish(),
101
143
  retry_after: e.number().int().nullish()
102
- }), l = (e) => e.filter((e) => e.checkout !== !1), u = /* @__PURE__ */ new Set([
144
+ }), d = (e) => e.filter((e) => e.checkout !== !1), f = /* @__PURE__ */ new Set([
103
145
  "tokenize",
104
146
  "card",
105
147
  "elements"
106
148
  ]);
107
- function d(e) {
108
- let t = e.filter((e) => !!e.status && e.custodian === "psp" && u.has(e.flow)).map((e) => e.retry_after ?? 30);
149
+ function p(e) {
150
+ let t = e.filter((e) => !!e.status && e.custodian === "psp" && f.has(e.flow)).map((e) => e.retry_after ?? 30);
109
151
  return t.length > 0 ? Math.min(...t) : null;
110
152
  }
111
- var f = (e) => !!e && !e.startsWith("preview_"), p = (e) => e.rail === "stripe" && !!e.config?.publishable_key?.startsWith("pk_");
112
- function m(e) {
113
- return e.custodian !== "psp" || e.status ? null : e.flow === "card" && e.rail === "nmi" ? "card" : e.flow === "tokenize" && f(e.config?.tokenization_key) && e.config?.tokenization_url ? "collect_js" : p(e) ? "stripe_elements" : null;
153
+ var m = (e) => !!e && !e.startsWith("preview_"), h = (e) => e.rail === "stripe" && !!e.config?.publishable_key?.startsWith("pk_");
154
+ function g(e) {
155
+ return e.custodian !== "psp" || e.status ? null : e.flow === "card" && e.rail === "nmi" ? "card" : e.flow === "tokenize" && m(e.config?.tokenization_key) && e.config?.tokenization_url ? "collect_js" : h(e) ? "stripe_elements" : null;
114
156
  }
115
- var h = (e) => m(e) !== null, g = (e) => m(e) === "stripe_elements", _ = -(1n << 63n), v = (1n << 63n) - 1n;
116
- function y(e) {
157
+ var _ = (e) => g(e) !== null, v = (e) => g(e) === "stripe_elements", y = -(1n << 63n), b = (1n << 63n) - 1n;
158
+ function x(e) {
117
159
  if (typeof e != "string" || !/^-?\d{1,19}$/.test(e)) return null;
118
160
  let t = BigInt(e);
119
- return t < _ || t > v ? null : t;
161
+ return t < y || t > b ? null : t;
120
162
  }
121
- function b(e) {
122
- return y(e) !== null;
163
+ function S(e) {
164
+ return x(e) !== null;
123
165
  }
124
- function x(e) {
166
+ function C(e) {
125
167
  return typeof e == "number" && Number.isInteger(e) && e >= 0 && e <= 18;
126
168
  }
127
- function S(...e) {
169
+ function w(...e) {
128
170
  let t = 0n;
129
171
  for (let n of e) {
130
- let e = y(n);
172
+ let e = x(n);
131
173
  if (e === null) return null;
132
174
  t += e;
133
175
  }
134
- return t < _ || t > v ? null : t.toString();
176
+ return t < y || t > b ? null : t.toString();
135
177
  }
136
- var C = (() => {
178
+ var te = (() => {
137
179
  try {
138
180
  return new Intl.NumberFormat("en", { useGrouping: !1 }).format("9007199254740993") === "9007199254740993";
139
181
  } catch {
140
182
  return !1;
141
183
  }
142
- })(), w = 10n ** 15n;
143
- function T(e, t) {
184
+ })(), T = 10n ** 15n;
185
+ function E(e, t) {
144
186
  let n = e < 0n ? -e : e, r = 10n ** BigInt(t), i = (n % r).toString().padStart(t, "0").replace(/0+$/, "");
145
187
  return `${e < 0n ? "-" : ""}${n / r}${i ? `.${i}` : ""}`;
146
188
  }
147
- function E(e, t) {
148
- let n = y(e);
149
- return n === null || !x(t) ? null : T(n, t);
189
+ function ne(e, t) {
190
+ let n = x(e);
191
+ return n === null || !C(t) ? null : E(n, t);
150
192
  }
151
- function ee(e, t, n) {
152
- let r = y(e);
153
- if (r === null || !x(t) || !x(n) || n > t) return null;
193
+ function re(e, t, n) {
194
+ let r = x(e);
195
+ if (r === null || !C(t) || !C(n) || n > t) return null;
154
196
  let i = 10n ** BigInt(t - n);
155
197
  if (r % i !== 0n) return null;
156
198
  let a = r / i;
157
199
  return a > BigInt(2 ** 53 - 1) || a < -BigInt(2 ** 53 - 1) ? null : Number(a);
158
200
  }
159
- function te(e, t) {
160
- if (!x(t) || e.length > 40) return null;
201
+ function D(e, t) {
202
+ if (!C(t) || e.length > 40) return null;
161
203
  let n = /^(-?)(\d+)(?:\.(\d+))?$/.exec(e);
162
204
  if (!n) return null;
163
205
  let r = n[3] ?? "";
164
206
  if (r.length > t) return null;
165
207
  let i = BigInt(n[2]) * 10n ** BigInt(t) + BigInt(r.padEnd(t, "0") || "0"), a = n[1] ? -i : i;
166
- return a < _ || a > v ? null : a.toString();
208
+ return a < y || a > b ? null : a.toString();
167
209
  }
168
- function ne(e, t, n, r) {
169
- let i = t.trim().toUpperCase(), a = y(e);
170
- if (a === null || !x(n)) return `${i} amount exceeds the exact display range`;
171
- if (!C && (a >= w || a <= -w)) return `${i} amount exceeds this browser's exact display range`;
172
- let o = T(a, n);
210
+ function ie(e, t, n, r) {
211
+ let i = t.trim().toUpperCase(), a = x(e);
212
+ if (a === null || !C(n)) return `${i} amount exceeds the exact display range`;
213
+ if (!te && (a >= T || a <= -T)) return `${i} amount exceeds this browser's exact display range`;
214
+ let o = E(a, n);
173
215
  try {
174
216
  return new Intl.NumberFormat(r, {
175
217
  style: "currency",
@@ -182,7 +224,7 @@ function ne(e, t, n, r) {
182
224
  }
183
225
  //#endregion
184
226
  //#region src/client/types.ts
185
- var D = e.string().refine(b, "amount must be an int64 string"), O = e.string(), k = (t) => e.object({
227
+ var O = e.string().refine(S, "amount must be an int64 string"), k = e.string(), ae = (t) => e.object({
186
228
  data: e.array(t).nullish().transform((e) => e ?? []),
187
229
  total: e.number().nullish(),
188
230
  limit: e.number().nullish(),
@@ -192,31 +234,31 @@ var D = e.string().refine(b, "amount must be an int64 string"), O = e.string(),
192
234
  }), A = (t) => e.object({
193
235
  data: e.array(t).nullish().transform((e) => e ?? []),
194
236
  next_cursor: e.string().nullish().transform((e) => e ?? null)
195
- }), j = e.string(), re = e.object({
237
+ }), j = e.string(), M = e.object({
196
238
  status: e.string(),
197
239
  ids: e.record(e.string(), e.string()).nullish(),
198
240
  sync_status: e.string().nullish()
199
- }), M = e.object({
241
+ }), N = e.object({
200
242
  id: e.string(),
201
243
  key: e.string(),
202
244
  revision: e.number().int().nonnegative().optional(),
203
245
  version: e.number().int().nonnegative().optional(),
204
246
  product_id: e.string(),
205
247
  archived: e.boolean(),
206
- unit_amount: D,
248
+ unit_amount: O,
207
249
  customer_amount: e.object({
208
- min_amount: D,
209
- max_amount: D
250
+ min_amount: O,
251
+ max_amount: O
210
252
  }).nullish(),
211
253
  currency: e.string(),
212
254
  access_duration_hours: e.number().nullable(),
213
255
  billing_interval_hours: e.number().nullable(),
214
- trial_unit_amount: D.nullable(),
256
+ trial_unit_amount: O.nullable(),
215
257
  trial_duration_hours: e.number().nullable(),
216
- psps: e.record(e.string(), re).nullish(),
217
- created_at: O,
218
- updated_at: O
219
- }), N = e.object({
258
+ psps: e.record(e.string(), M).nullish(),
259
+ created_at: k,
260
+ updated_at: k
261
+ }), P = e.object({
220
262
  id: e.string(),
221
263
  key: e.string().nullish(),
222
264
  revision: e.number().int().nonnegative().optional(),
@@ -224,32 +266,30 @@ var D = e.string().refine(b, "amount must be an int64 string"), O = e.string(),
224
266
  description: e.string().nullish(),
225
267
  tier_group: e.string().nullish(),
226
268
  tier_rank: e.number().nullish()
227
- }), P = e.object({
269
+ }), F = e.object({
228
270
  brand: e.string().nullish(),
229
271
  last4: e.string().nullish(),
230
272
  exp_month: e.number().nullish(),
231
273
  exp_year: e.number().nullish()
232
- }), ie = e.object({
233
- id: e.string(),
234
- status: e.string()
235
- }), ae = e.object({
274
+ }), oe = e.object({
236
275
  last_failure_reason: e.string().nullish(),
237
276
  retryable: e.boolean(),
238
277
  blocked_reason: e.string().nullish(),
239
- operation: ie.nullish(),
240
278
  order_id: e.string().nullish()
241
- }), F = e.object({
242
- type: e.string(),
243
- redirect_to_url: e.object({ url: e.string().nullish() }).nullish(),
244
- transactions: e.array(e.string()).nullish()
245
279
  }), I = e.object({
280
+ type: e.string(),
281
+ url: e.string().nullish(),
282
+ psp_id: e.string().nullish(),
283
+ transactions: e.array(e.string()).nullish(),
284
+ payload: e.record(e.string(), e.string()).nullish()
285
+ }), L = e.object({
246
286
  attempts: e.number(),
247
287
  retries_left: e.number().nullish(),
248
- next_retry_at: O.nullish(),
249
- final_retry_at: O.nullish(),
288
+ next_retry_at: k.nullish(),
289
+ final_retry_at: k.nullish(),
250
290
  waiting_for_new_card: e.boolean(),
251
291
  last_failure_reason: e.string().nullish()
252
- }), L = e.object({
292
+ }), R = e.object({
253
293
  id: e.string(),
254
294
  status: j,
255
295
  rail: e.string().nullish(),
@@ -259,37 +299,37 @@ var D = e.string().refine(b, "amount must be an int64 string"), O = e.string(),
259
299
  psp_id: e.string().nullish(),
260
300
  collection_policy: e.string().nullish(),
261
301
  payment_method_id: e.string().nullish(),
262
- started_at: O.nullish(),
263
- ended_at: O.nullish(),
264
- current_period_starts_at: O.nullish(),
265
- current_period_ends_at: O.nullish(),
266
- canceled_at: O.nullish(),
302
+ started_at: k.nullish(),
303
+ ended_at: k.nullish(),
304
+ current_period_starts_at: k.nullish(),
305
+ current_period_ends_at: k.nullish(),
306
+ canceled_at: k.nullish(),
267
307
  cancel_type: e.string().nullish(),
268
308
  resumable: e.boolean().nullish(),
269
309
  cancel_scheduled: e.boolean().nullish(),
270
310
  cancel_mode: e.string().nullish(),
271
311
  cancel_portal_url: e.string().nullish(),
272
312
  access: e.object({
273
- starts_at: O,
274
- ends_at: O.nullish()
313
+ starts_at: k,
314
+ ends_at: k.nullish()
275
315
  }).nullish(),
276
- dunning: I.nullish(),
277
- price: M.nullish(),
278
- product: N.nullish(),
316
+ dunning: L.nullish(),
317
+ price: N.nullish(),
318
+ product: P.nullish(),
279
319
  scheduled_change: e.object({
280
320
  price_id: e.string(),
281
321
  quantity: e.number().nullish(),
282
- effective_at: O,
322
+ effective_at: k,
283
323
  source: e.string(),
284
- price: M.nullish(),
285
- product: N.nullish()
324
+ price: N.nullish(),
325
+ product: P.nullish()
286
326
  }).nullish(),
287
- card: P.nullish(),
288
- recovery: ae.nullish(),
289
- next_action: F.nullish(),
290
- created_at: O.nullish(),
291
- updated_at: O.nullish()
292
- }), R = e.object({
327
+ card: F.nullish(),
328
+ recovery: oe.nullish(),
329
+ next_action: I.nullish(),
330
+ created_at: k.nullish(),
331
+ updated_at: k.nullish()
332
+ }), z = e.object({
293
333
  name: e.string().nullish(),
294
334
  email: e.string().nullish(),
295
335
  phone: e.string().nullish(),
@@ -301,7 +341,7 @@ var D = e.string().refine(b, "amount must be an int64 string"), O = e.string(),
301
341
  postal_code: e.string().nullish(),
302
342
  country: e.string().nullish()
303
343
  }).nullish()
304
- }), z = e.object({
344
+ }), B = e.object({
305
345
  id: e.string(),
306
346
  status: e.string().nullish(),
307
347
  next_action: e.object({
@@ -311,12 +351,12 @@ var D = e.string().refine(b, "amount must be an int64 string"), O = e.string(),
311
351
  }).nullish(),
312
352
  rail: e.string().nullish(),
313
353
  psp_id: e.string().nullish(),
314
- card: P.nullish(),
315
- billing_details: R.nullish(),
354
+ card: F.nullish(),
355
+ billing_details: z.nullish(),
316
356
  reusable: e.boolean().nullish(),
317
357
  health: e.object({
318
358
  expiry_status: e.string().nullish(),
319
- last_charged_at: O.nullish(),
359
+ last_charged_at: k.nullish(),
320
360
  last_charge_outcome: e.string().nullish(),
321
361
  active: e.boolean().nullish()
322
362
  }).nullish(),
@@ -325,17 +365,11 @@ var D = e.string().refine(b, "amount must be an int64 string"), O = e.string(),
325
365
  display_name: e.string().nullish()
326
366
  })).nullish(),
327
367
  default_currencies: e.array(e.string()).nullish(),
328
- created_at: O.nullish()
329
- }), B = e.object({
368
+ created_at: k.nullish()
369
+ }), V = e.object({
330
370
  reason: e.string(),
331
371
  message: e.string(),
332
372
  field: e.string().nullish()
333
- }), V = e.object({
334
- type: e.string(),
335
- url: e.string().nullish(),
336
- psp_id: e.string().nullish(),
337
- transactions: e.array(e.string()).nullish(),
338
- payload: e.record(e.string(), e.string()).nullish()
339
373
  }), H = e.object({
340
374
  id: e.string(),
341
375
  price_id: e.string().nullish(),
@@ -343,8 +377,8 @@ var D = e.string().refine(b, "amount must be an int64 string"), O = e.string(),
343
377
  source: e.string().nullish(),
344
378
  description: e.string(),
345
379
  quantity: e.number().nullish(),
346
- unit_amount: D,
347
- amount: D,
380
+ unit_amount: O,
381
+ amount: O,
348
382
  billing_interval_hours: e.number().nullish(),
349
383
  access_duration_hours: e.number().nullish(),
350
384
  subscription_id: e.string().nullish(),
@@ -356,12 +390,12 @@ var D = e.string().refine(b, "amount must be an int64 string"), O = e.string(),
356
390
  status: e.string(),
357
391
  number: e.string().nullish(),
358
392
  currency: e.string(),
359
- total: D,
393
+ total: O,
360
394
  lines: e.array(H),
361
395
  payment: e.object({
362
396
  status: e.string(),
363
- next_action: V.nullish(),
364
- last_payment_error: B.nullish(),
397
+ next_action: I.nullish(),
398
+ last_payment_error: V.nullish(),
365
399
  payment_method_id: e.string().nullish(),
366
400
  payment_id: e.string().nullish()
367
401
  }),
@@ -373,36 +407,36 @@ var D = e.string().refine(b, "amount must be an int64 string"), O = e.string(),
373
407
  checkout: e.object({
374
408
  url: e.string().nullish(),
375
409
  ui_mode: e.enum(["hosted", "embedded"]).catch("hosted"),
376
- expires_at: O,
410
+ expires_at: k,
377
411
  success_url: e.string(),
378
412
  cancel_url: e.string().nullish(),
379
413
  saved_payment_methods: e.boolean()
380
414
  }).nullish(),
381
415
  renewal: e.object({
382
416
  subscription_id: e.string(),
383
- period_starts_at: O,
384
- period_ends_at: O,
385
- due_at: O
417
+ period_starts_at: k,
418
+ period_ends_at: k,
419
+ due_at: k
386
420
  }).nullish(),
387
421
  usage: e.object({
388
- period_starts_at: O,
389
- period_ends_at: O,
390
- due_at: O,
391
- amount_paid: D,
392
- amount_due: D,
422
+ period_starts_at: k,
423
+ period_ends_at: k,
424
+ due_at: k,
425
+ amount_paid: O,
426
+ amount_due: O,
393
427
  collection_method: e.string(),
394
- next_collection_attempt_at: O.nullish(),
428
+ next_collection_attempt_at: k.nullish(),
395
429
  po_number: e.string().nullish(),
396
430
  memo: e.string().nullish(),
397
431
  delinquent: e.boolean()
398
432
  }).nullish(),
399
- expires_at: O.nullish(),
400
- completed_at: O.nullish(),
401
- canceled_at: O.nullish(),
402
- expired_at: O.nullish(),
403
- voided_at: O.nullish(),
404
- uncollectible_at: O.nullish(),
405
- created_at: O
433
+ expires_at: k.nullish(),
434
+ completed_at: k.nullish(),
435
+ canceled_at: k.nullish(),
436
+ expired_at: k.nullish(),
437
+ voided_at: k.nullish(),
438
+ uncollectible_at: k.nullish(),
439
+ created_at: k
406
440
  }), W = e.object({
407
441
  code: e.string(),
408
442
  message: e.string(),
@@ -413,19 +447,19 @@ var D = e.string().refine(b, "amount must be an int64 string"), O = e.string(),
413
447
  product_id: e.string(),
414
448
  description: e.string(),
415
449
  quantity: e.number().nullish(),
416
- unit_amount: D,
417
- amount: D,
450
+ unit_amount: O,
451
+ amount: O,
418
452
  ownership: e.string(),
419
453
  billing_interval_hours: e.number().nullish(),
420
454
  access_duration_hours: e.number().nullish(),
421
455
  refusal: W.nullish()
422
456
  }), K = e.object({
423
457
  currency: e.string(),
424
- total: D,
458
+ total: O,
425
459
  lines: e.array(G),
426
460
  payment_options: U.shape.payment_options,
427
- last_changed_at: O.nullish(),
428
- expires_at: O.nullish()
461
+ last_changed_at: k.nullish(),
462
+ expires_at: k.nullish()
429
463
  }), q = e.object({
430
464
  id: e.string(),
431
465
  key: e.string(),
@@ -435,86 +469,85 @@ var D = e.string().refine(b, "amount must be an int64 string"), O = e.string(),
435
469
  entitlements: e.array(e.string()),
436
470
  credit_grant: e.object({
437
471
  currency: e.string(),
438
- amount: D.nullish(),
472
+ amount: O.nullish(),
439
473
  from_payment: e.boolean().optional(),
440
474
  expires_after_days: e.number().int().positive().nullish()
441
475
  }).nullish(),
442
476
  tier_group: e.string().nullable(),
443
477
  tier_rank: e.number(),
444
478
  archived: e.boolean(),
445
- prices: e.array(M).nullish().transform((e) => e ?? []),
446
- created_at: O,
447
- updated_at: O
448
- }), J = e.object({
479
+ prices: e.array(N).nullish().transform((e) => e ?? []),
480
+ created_at: k,
481
+ updated_at: k
482
+ }), se = e.object({
449
483
  id: e.string(),
450
484
  kind: e.string(),
451
485
  status: e.string(),
452
- amount: D,
453
- amount_refunded: D.nullish(),
486
+ amount: O,
487
+ amount_refunded: O.nullish(),
454
488
  currency: e.string(),
455
489
  subscription_id: e.string().nullish(),
456
490
  price_id: e.string().nullish(),
457
491
  channel: e.string().nullish(),
458
492
  rail: e.string().nullish(),
459
- created_at: O,
460
- price: M.nullish(),
461
- product: N.nullish(),
462
- card: P.nullish(),
493
+ created_at: k,
494
+ price: N.nullish(),
495
+ product: P.nullish(),
496
+ card: F.nullish(),
463
497
  failure: e.object({
464
498
  reason: e.string(),
465
499
  message: e.string(),
466
500
  field: e.string().nullish()
467
501
  }).nullish()
468
- }), oe = e.object({
502
+ }), J = e.object({
469
503
  currency: e.string(),
470
504
  billing_mode: e.string(),
471
- balance_amount: D,
472
- held_amount: D,
473
- accrued_amount: D,
474
- available_amount: D,
475
- owed_amount: D,
476
- accrual_rate_per_hour: D,
505
+ balance_amount: O,
506
+ held_amount: O,
507
+ accrued_amount: O,
508
+ available_amount: O,
509
+ owed_amount: O,
510
+ accrual_rate_per_hour: O,
477
511
  as_of: e.string(),
478
512
  depletes_at: e.string().nullable()
479
- }), se = e.object({
513
+ }), ce = e.object({
480
514
  id: e.string(),
481
- balances: e.array(oe),
515
+ balances: e.array(J),
482
516
  default_payment_methods: e.array(e.object({
483
517
  currency: e.string(),
484
518
  payment_method_id: e.string()
485
519
  })),
486
520
  unread_notifications: e.number()
487
- }), ce = e.object({
521
+ }), le = e.object({
488
522
  code: e.string(),
489
523
  decimals: e.number(),
490
524
  minor_decimals: e.number().nullish()
491
- }), le = e.object({
525
+ }), ue = e.object({
492
526
  price_id: e.string(),
493
527
  quantity: e.number().nullish(),
494
528
  rail: e.string().nullish(),
495
529
  currency: e.string(),
496
- amount_due_now: D,
497
- next_charge_amount: D,
498
- next_charge_date: O.nullish(),
530
+ amount_due_now: O,
531
+ next_charge_amount: O,
532
+ next_charge_date: k.nullish(),
499
533
  effective: e.string(),
500
534
  is_estimate: e.boolean().nullish(),
501
535
  message: e.string().nullish()
502
- }), ue = e.object({
536
+ }), Y = e.object({
503
537
  status: e.string(),
504
538
  effective: e.string().nullish(),
505
539
  price_id: e.string().nullish(),
506
540
  quantity: e.number().nullish(),
507
541
  subscription_id: e.string().nullish(),
508
- next_action: F.nullish(),
509
- delayed_start: O.nullish(),
542
+ next_action: I.nullish(),
543
+ delayed_start: k.nullish(),
510
544
  currency: e.string().nullish(),
511
- amount_due_now: D.nullish(),
512
- next_charge_amount: D.nullish(),
513
- next_charge_date: O.nullish(),
514
- message: e.string().nullish(),
515
- operation_id: e.string().nullish()
545
+ amount_due_now: O.nullish(),
546
+ next_charge_amount: O.nullish(),
547
+ next_charge_date: k.nullish(),
548
+ message: e.string().nullish()
516
549
  }), de = e.object({
517
- psps: e.array(c).nullish().transform((e) => e ?? []),
550
+ psps: e.array(u).nullish().transform((e) => e ?? []),
518
551
  solana: e.object({
519
552
  network: e.string(),
520
553
  chain: e.string(),
@@ -544,29 +577,30 @@ var D = e.string().refine(b, "amount must be an int64 string"), O = e.string(),
544
577
  route_groups: e.record(e.string(), e.boolean()),
545
578
  features: e.record(e.string(), e.boolean())
546
579
  }),
547
- currencies: e.array(ce).nullish().transform((e) => e ?? []),
548
- payment: de.nullish(),
549
- merchant: pe.nullish(),
580
+ currencies: e.array(le).nullish().transform((e) => e ?? []),
550
581
  captcha: fe.nullish(),
551
582
  network: e.object({
552
583
  issuer: e.string(),
553
584
  client_id: e.string()
554
585
  }).nullish()
555
586
  }), he = e.object({
587
+ payment: de,
588
+ merchant: pe
589
+ }), ge = e.object({
556
590
  id: e.string(),
557
591
  nonce: e.string(),
558
- expires_at: O
559
- }), ge = e.object({
592
+ expires_at: k
593
+ }), _e = e.object({
560
594
  id: e.string(),
561
595
  merchant_id: e.string(),
562
596
  customer_id: e.string(),
563
597
  account_id: e.string(),
564
598
  method: e.string(),
565
599
  status: e.string(),
566
- linked_at: O,
567
- revoked_at: O.nullish(),
600
+ linked_at: k,
601
+ revoked_at: k.nullish(),
568
602
  revoked_by: e.string().nullish()
569
- }), _e = e.object({ client_secret: e.string().nullish() }), Y = class extends Error {
603
+ }), X = class extends Error {
570
604
  constructor(e = "The wallet request was declined.") {
571
605
  super(e), this.name = "WalletRejectedError";
572
606
  }
@@ -584,18 +618,18 @@ async function xe(e, t) {
584
618
  if (!n) throw i("wallet_no_signature", "The wallet returned no signature.");
585
619
  return n;
586
620
  }
587
- var Se = 2e3, X = 300;
588
- function Z(e) {
589
- let t = Ce(e.headers.get("Retry-After"));
621
+ var Se = 2e3, Z = 300;
622
+ function Ce(e) {
623
+ let t = we(e.headers.get("Retry-After"));
590
624
  switch (e.status) {
591
625
  case 429: return t;
592
- case 503: return t ?? X;
626
+ case 503: return t ?? Z;
593
627
  case 502:
594
- case 504: return X;
628
+ case 504: return Z;
595
629
  default: return null;
596
630
  }
597
631
  }
598
- function Ce(e) {
632
+ function we(e) {
599
633
  if (!e) return null;
600
634
  if (/^\d+$/.test(e.trim())) return Number(e.trim()) * 1e3;
601
635
  let t = Date.parse(e);
@@ -612,8 +646,8 @@ function Q(e, t) {
612
646
  t?.addEventListener("abort", a, { once: !0 });
613
647
  });
614
648
  }
615
- function we(e = {}) {
616
- let t = (e.baseUrl ?? "/billing/v1").replace(/\/+$/, ""), r = e.fetch ?? ((e, t) => fetch(e, t)), o = Te({
649
+ function Te(e = {}) {
650
+ let t = (e.baseUrl ?? "/billing/v1").replace(/\/+$/, ""), r = e.fetch ?? ((e, t) => fetch(e, t)), o = Ee({
617
651
  ...s,
618
652
  ...e.currencies
619
653
  });
@@ -630,7 +664,7 @@ function we(e = {}) {
630
664
  ...n.headers
631
665
  });
632
666
  n.body !== void 0 && i.set("Content-Type", "application/json");
633
- let o = n.anonymous ? void 0 : await e.getToken?.();
667
+ let o = n.public ? void 0 : await e.getToken?.();
634
668
  o && i.set("Authorization", `Bearer ${o}`);
635
669
  let s = e.language?.();
636
670
  s && i.set("Accept-Language", s);
@@ -639,21 +673,27 @@ function we(e = {}) {
639
673
  headers: i,
640
674
  body: n.body === void 0 ? void 0 : JSON.stringify(n.body),
641
675
  signal: n.signal
642
- }, d = +(l === "GET"), f = 0;
643
- for (let e = 0;; e++) {
644
- let i;
676
+ }, d = +(l === "GET"), f = 0, p = !1;
677
+ for (let s = 0;; s++) {
678
+ let l;
645
679
  try {
646
- i = await r(c(t, n.query), u);
647
- } catch (t) {
648
- let r = X;
649
- if (e >= d || n.signal?.aborted || !(t instanceof TypeError) || f + r > 2e3) throw t;
650
- f += await Q(r, n.signal);
680
+ l = await r(c(t, n.query), u);
681
+ } catch (e) {
682
+ let t = Z;
683
+ if (s >= d || n.signal?.aborted || !(e instanceof TypeError) || f + t > 2e3) throw e;
684
+ f += await Q(t, n.signal);
685
+ continue;
686
+ }
687
+ if (l.ok) return l;
688
+ if (l.status === 401 && o && !p && ee(e.getToken)) {
689
+ let t = await a(l);
690
+ if (t.code !== "credential_expired") throw t;
691
+ e.getToken.invalidate(o), o = await e.getToken(), i.set("Authorization", `Bearer ${o}`), p = !0, s--;
651
692
  continue;
652
693
  }
653
- if (i.ok) return i;
654
- let o = Z(i);
655
- if (e >= d || o === null || f + o > 2e3) throw await a(i);
656
- await i.body?.cancel().catch(() => void 0), f += await Q(o, n.signal);
694
+ let m = Ce(l);
695
+ if (s >= d || m === null || f + m > 2e3) throw await a(l);
696
+ await l.body?.cancel().catch(() => void 0), f += await Q(m, n.signal);
657
697
  }
658
698
  }
659
699
  async function u(e, t, n) {
@@ -667,10 +707,10 @@ function we(e = {}) {
667
707
  if (!o.success) throw i("invalid_response", `${t}: ${o.error.issues[0]?.path.join(".")} ${o.error.issues[0]?.message}`);
668
708
  return o.data;
669
709
  }
670
- let d = (e) => encodeURIComponent(e), f = A(L), p = A(z), m = A(J), h = A(U), g = (e, t) => ({
710
+ let d = (e) => encodeURIComponent(e), f = A(R), p = A(B), m = A(se), h = A(U), g = (e, t) => ({
671
711
  limit: e.limit ?? t,
672
712
  cursor: e.cursor ?? void 0
673
- }), _ = k(q);
713
+ }), _ = ae(q);
674
714
  async function v(e, t) {
675
715
  try {
676
716
  return { order: await u(U, e, t) };
@@ -697,10 +737,10 @@ function we(e = {}) {
697
737
  });
698
738
  },
699
739
  getSubscription(e, t) {
700
- return u(L, `/me/subscriptions/${d(e)}`, { signal: t });
740
+ return u(R, `/me/subscriptions/${d(e)}`, { signal: t });
701
741
  },
702
742
  cancelSubscription(e, t) {
703
- return u(L, `/me/subscriptions/${d(e)}/cancel`, {
743
+ return u(R, `/me/subscriptions/${d(e)}/cancel`, {
704
744
  method: "POST",
705
745
  body: {
706
746
  reason: t.reason.trim(),
@@ -709,19 +749,19 @@ function we(e = {}) {
709
749
  });
710
750
  },
711
751
  resumeSubscription(e) {
712
- return u(L, `/me/subscriptions/${d(e)}/resume`, {
752
+ return u(R, `/me/subscriptions/${d(e)}/resume`, {
713
753
  method: "POST",
714
754
  body: {}
715
755
  });
716
756
  },
717
757
  setSubscriptionPaymentMethod(e, t) {
718
- return u(L, `/me/subscriptions/${d(e)}/payment-method`, {
758
+ return u(R, `/me/subscriptions/${d(e)}/payment-method`, {
719
759
  method: "PUT",
720
760
  body: { payment_method_id: t }
721
761
  });
722
762
  },
723
763
  previewSubscriptionChange(e, t, n) {
724
- return u(le, `/me/subscriptions/${d(e)}/change/preview`, {
764
+ return u(ue, `/me/subscriptions/${d(e)}/change/preview`, {
725
765
  method: "POST",
726
766
  body: {
727
767
  price_id: t.priceId,
@@ -730,8 +770,14 @@ function we(e = {}) {
730
770
  signal: n
731
771
  });
732
772
  },
773
+ confirmSubscriptionChange(e) {
774
+ return u(Y, `/me/subscriptions/${d(e)}/confirm`, {
775
+ method: "POST",
776
+ body: {}
777
+ });
778
+ },
733
779
  changeSubscription(e, t) {
734
- return u(ue, `/me/subscriptions/${d(e)}/change`, {
780
+ return u(Y, `/me/subscriptions/${d(e)}/change`, {
735
781
  method: "POST",
736
782
  body: {
737
783
  price_id: t.priceId,
@@ -748,7 +794,7 @@ function we(e = {}) {
748
794
  });
749
795
  },
750
796
  addPaymentMethod(e) {
751
- return u(z, "/me/payment-methods", {
797
+ return u(B, "/me/payment-methods", {
752
798
  method: "POST",
753
799
  body: e
754
800
  });
@@ -810,16 +856,7 @@ function we(e = {}) {
810
856
  });
811
857
  },
812
858
  confirmPaymentMethod(e) {
813
- return u(z, `/me/payment-methods/${d(e)}/confirm`, {
814
- method: "POST",
815
- body: {}
816
- });
817
- },
818
- getPaymentAuthentication(e) {
819
- return u(_e, `/me/payment-operations/${d(e)}/authentication`);
820
- },
821
- async confirmPaymentAuthentication(e) {
822
- await l(`/me/payment-operations/${d(e)}/authentication/confirm`, {
859
+ return u(B, `/me/payment-methods/${d(e)}/confirm`, {
823
860
  method: "POST",
824
861
  body: {}
825
862
  });
@@ -843,25 +880,29 @@ function we(e = {}) {
843
880
  });
844
881
  },
845
882
  getAccount(e) {
846
- return u(se, "/me", { signal: e });
883
+ return u(ce, "/me", { signal: e });
847
884
  },
848
885
  async listProducts(e) {
849
886
  return e.keys.length === 0 ? {
850
887
  data: [],
851
888
  next_cursor: null
852
889
  } : u(_, "/catalog/products", {
853
- query: { keys: e.keys },
854
- signal: e.signal
890
+ query: {
891
+ merchant: e.merchant,
892
+ keys: e.keys
893
+ },
894
+ signal: e.signal,
895
+ public: !0
855
896
  });
856
897
  },
857
898
  createNetworkLinkChallenge() {
858
- return u(he, "/me/network-link/challenges", {
899
+ return u(ge, "/me/network-link/challenges", {
859
900
  method: "POST",
860
901
  body: {}
861
902
  });
862
903
  },
863
904
  createNetworkLink(e) {
864
- return u(ge, "/me/network-link", {
905
+ return u(_e, "/me/network-link", {
865
906
  method: "POST",
866
907
  body: {
867
908
  challenge_id: e.challengeId,
@@ -872,17 +913,20 @@ function we(e = {}) {
872
913
  getConfig(e) {
873
914
  return u(me, "/config", {
874
915
  signal: e,
875
- anonymous: !0
916
+ public: !0
876
917
  });
877
918
  },
919
+ getCustomerConfig(e) {
920
+ return u(he, "/me/config", { signal: e });
921
+ },
878
922
  currencies: o
879
923
  };
880
924
  }
881
- function Te(e) {
925
+ function Ee(e) {
882
926
  return Object.fromEntries(Object.entries(e).map(([e, t]) => [e.toUpperCase(), t]));
883
927
  }
884
- var $ = (e) => e instanceof Y || e instanceof Error && e.name === "WalletRejectedError" || e instanceof t && e.code === "wallet_rejected";
928
+ var $ = (e) => e instanceof X || e instanceof Error && e.name === "WalletRejectedError" || e instanceof t && e.code === "wallet_rejected";
885
929
  //#endregion
886
- export { r as C, o as E, n as S, a as T, d as _, we as a, c as b, xe as c, ee as d, te as f, h as g, g as h, Y as i, S as l, b as m, ve as n, be as o, ne as p, Se as r, $ as s, ye as t, E as u, m as v, i as w, t as x, l as y };
930
+ export { t as C, a as D, i as E, o as O, c as S, r as T, p as _, Te as a, u as b, xe as c, re as d, D as f, _ as g, v as h, X as i, w as l, S as m, ve as n, be as o, ie as p, Se as r, $ as s, ye as t, ne as u, g as v, n as w, l as x, d as y };
887
931
 
888
- //# sourceMappingURL=client-D9G1Tgox.js.map
932
+ //# sourceMappingURL=client-Bi_lP_M0.js.map