@openrails/billing-ui 0.236.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.
- package/CHANGELOG.md +87 -9
- package/README.md +78 -83
- package/dist/account/account-billing.d.ts +1 -1
- package/dist/account/payment-methods-panel.d.ts +2 -2
- package/dist/authenticate.d.ts +5 -4
- package/dist/buy-button.d.ts +17 -10
- package/dist/client/client.d.ts +52 -23
- package/dist/client/generated/error-codes.d.ts +1 -1
- package/dist/client/generated/routes.d.ts +24 -218
- package/dist/client/generated/wire.d.ts +39 -200
- package/dist/client/index.d.ts +2 -1
- package/dist/client/token-source.d.ts +60 -0
- package/dist/client/types.d.ts +108 -199
- package/dist/client-Bi_lP_M0.js +932 -0
- package/dist/client-Bi_lP_M0.js.map +1 -0
- package/dist/client.js +2 -2
- package/dist/components/eyebrow.d.ts +5 -0
- package/dist/embedded-checkout.d.ts +22 -0
- package/dist/{hooks-2d-XjpuI.js → hooks-Bk80rNv8.js} +99 -90
- package/dist/hooks-Bk80rNv8.js.map +1 -0
- package/dist/index.d.ts +5 -8
- package/dist/index.js +1149 -2163
- package/dist/index.js.map +1 -1
- package/dist/modal.d.ts +3 -9
- package/dist/offers.d.ts +10 -9
- package/dist/psp.d.ts +0 -8
- package/dist/react/config.d.ts +17 -12
- package/dist/react/context.d.ts +3 -1
- package/dist/react/hooks.d.ts +5 -5
- package/dist/react/index.d.ts +1 -1
- package/dist/react.js +2 -2
- package/dist/styles.css +1 -1
- package/dist/tokenized-card-form.d.ts +5 -1
- package/dist/types.d.ts +12 -250
- package/docs/payment-form-contract.md +31 -74
- package/package.json +1 -2
- package/dist/checkout-frame.d.ts +0 -17
- package/dist/checkout-page.d.ts +0 -21
- package/dist/checkout.d.ts +0 -22
- package/dist/client/checkout.d.ts +0 -28
- package/dist/client-BuvolBPT.js +0 -1092
- package/dist/client-BuvolBPT.js.map +0 -1
- package/dist/components/ccbill-fields.d.ts +0 -8
- package/dist/components/methods.d.ts +0 -13
- package/dist/components/summary.d.ts +0 -12
- package/dist/fixtures.d.ts +0 -9
- package/dist/frame.d.ts +0 -47
- package/dist/hooks-2d-XjpuI.js.map +0 -1
- package/dist/lib/rail-meta.d.ts +0 -15
- package/dist/lib/redirect.d.ts +0 -2
- package/dist/source.d.ts +0 -5
|
@@ -8,8 +8,12 @@ export type Balance = {
|
|
|
8
8
|
billing_mode: "arrears" | "prepaid";
|
|
9
9
|
balance_amount: string;
|
|
10
10
|
held_amount: string;
|
|
11
|
+
accrued_amount: string;
|
|
11
12
|
available_amount: string;
|
|
12
13
|
owed_amount: string;
|
|
14
|
+
accrual_rate_per_hour: string;
|
|
15
|
+
as_of: string;
|
|
16
|
+
depletes_at: string | null;
|
|
13
17
|
};
|
|
14
18
|
export type BalanceTransaction = {
|
|
15
19
|
id: string;
|
|
@@ -49,13 +53,6 @@ export type CaptchaConfig = {
|
|
|
49
53
|
action: string;
|
|
50
54
|
token_header: string;
|
|
51
55
|
};
|
|
52
|
-
export type CaptchaStatus = {
|
|
53
|
-
enabled: boolean;
|
|
54
|
-
required: boolean;
|
|
55
|
-
provider: string | null;
|
|
56
|
-
token_header: string;
|
|
57
|
-
client_script_url: string;
|
|
58
|
-
};
|
|
59
56
|
export type CardDetails = {
|
|
60
57
|
brand: string | null;
|
|
61
58
|
last4: string | null;
|
|
@@ -76,71 +73,6 @@ export type Cart = {
|
|
|
76
73
|
last_changed_at: string | null;
|
|
77
74
|
expires_at: string | null;
|
|
78
75
|
};
|
|
79
|
-
export type CheckoutSession = {
|
|
80
|
-
id: string;
|
|
81
|
-
status: string;
|
|
82
|
-
merchant: CheckoutSessionMerchant;
|
|
83
|
-
plan: CheckoutSessionPlan;
|
|
84
|
-
line_items: CheckoutSessionLineItem[];
|
|
85
|
-
tax: string | null;
|
|
86
|
-
due_today: string | null;
|
|
87
|
-
options: CheckoutSessionOption[];
|
|
88
|
-
saved_methods: CheckoutSessionSavedMethod[];
|
|
89
|
-
next_action: NextAction | null;
|
|
90
|
-
operation: PaymentOperation | null;
|
|
91
|
-
payment_id: string | null;
|
|
92
|
-
subscription_id: string | null;
|
|
93
|
-
failure_message: string | null;
|
|
94
|
-
failure: PaymentFailure | null;
|
|
95
|
-
success_url: string | null;
|
|
96
|
-
embed_origin: string | null;
|
|
97
|
-
expires_at: string;
|
|
98
|
-
};
|
|
99
|
-
export type CheckoutSessionLineItem = {
|
|
100
|
-
label: string;
|
|
101
|
-
sublabel: string | null;
|
|
102
|
-
amount: string;
|
|
103
|
-
};
|
|
104
|
-
export type CheckoutSessionLink = {
|
|
105
|
-
id: string;
|
|
106
|
-
url: string | null;
|
|
107
|
-
expires_at: string;
|
|
108
|
-
};
|
|
109
|
-
export type CheckoutSessionMerchant = {
|
|
110
|
-
display_name: string;
|
|
111
|
-
};
|
|
112
|
-
export type CheckoutSessionOption = {
|
|
113
|
-
id: string;
|
|
114
|
-
psp_id: string;
|
|
115
|
-
rail: string;
|
|
116
|
-
mode: string;
|
|
117
|
-
driver: string;
|
|
118
|
-
public_config: Record<string, string> | null;
|
|
119
|
-
};
|
|
120
|
-
export type CheckoutSessionPayResult = {
|
|
121
|
-
status: string;
|
|
122
|
-
next_action: NextAction | null;
|
|
123
|
-
operation: PaymentOperation | null;
|
|
124
|
-
payment_id: string | null;
|
|
125
|
-
subscription_id: string | null;
|
|
126
|
-
failure_message: string | null;
|
|
127
|
-
failure: PaymentFailure | null;
|
|
128
|
-
};
|
|
129
|
-
export type CheckoutSessionPlan = {
|
|
130
|
-
auto_renew: boolean;
|
|
131
|
-
display_name: string;
|
|
132
|
-
unit_amount: string;
|
|
133
|
-
currency: string;
|
|
134
|
-
unit_decimals: number;
|
|
135
|
-
billing_interval_hours: number | null;
|
|
136
|
-
access_duration_hours: number | null;
|
|
137
|
-
};
|
|
138
|
-
export type CheckoutSessionSavedMethod = {
|
|
139
|
-
id: string;
|
|
140
|
-
option_id: string;
|
|
141
|
-
rail: string;
|
|
142
|
-
card: CardDetails | null;
|
|
143
|
-
};
|
|
144
76
|
export type CreateMyOrderParams = {
|
|
145
77
|
lines?: OrderLineParams[];
|
|
146
78
|
cart?: boolean;
|
|
@@ -188,6 +120,10 @@ export type CustomerChangeSubscriptionParams = {
|
|
|
188
120
|
quantity?: number | null;
|
|
189
121
|
signature?: string;
|
|
190
122
|
};
|
|
123
|
+
export type CustomerConfig = {
|
|
124
|
+
payment: PaymentConfig;
|
|
125
|
+
merchant: PublicMerchant;
|
|
126
|
+
};
|
|
191
127
|
export type CustomerEntitlement = {
|
|
192
128
|
customer_id: string;
|
|
193
129
|
entitlement: string;
|
|
@@ -219,62 +155,10 @@ export type DriftField = {
|
|
|
219
155
|
export type Health = {
|
|
220
156
|
status: "ok" | "ready";
|
|
221
157
|
};
|
|
222
|
-
export type Invoice = {
|
|
223
|
-
id: string;
|
|
224
|
-
customer_id: string;
|
|
225
|
-
currency: string;
|
|
226
|
-
invoice_number: string | null;
|
|
227
|
-
period_starts_at: string;
|
|
228
|
-
period_ends_at: string;
|
|
229
|
-
usage_total: string;
|
|
230
|
-
deposits_total: string;
|
|
231
|
-
owed_accrued: string;
|
|
232
|
-
owed_paid: string;
|
|
233
|
-
closing_balance: string;
|
|
234
|
-
subtotal_amount: string;
|
|
235
|
-
total_amount: string;
|
|
236
|
-
amount_paid: string;
|
|
237
|
-
amount_due: string;
|
|
238
|
-
line_items: InvoiceLineItem[];
|
|
239
|
-
money_movements: Record<string, string> | null;
|
|
240
|
-
po_number: string | null;
|
|
241
|
-
tax: Record<string, unknown> | null;
|
|
242
|
-
billing_contacts: InvoiceContact[];
|
|
243
|
-
memo: string | null;
|
|
244
|
-
status: "draft" | "open" | "paid" | "uncollectible" | "voided";
|
|
245
|
-
collection_method: "charge_automatically" | "send_invoice";
|
|
246
|
-
issued_at: string | null;
|
|
247
|
-
due_at: string | null;
|
|
248
|
-
delinquent: boolean;
|
|
249
|
-
paid_at: string | null;
|
|
250
|
-
voided_at: string | null;
|
|
251
|
-
uncollectible_at: string | null;
|
|
252
|
-
finalized_at: string | null;
|
|
253
|
-
external_invoice_id: string | null;
|
|
254
|
-
collection_failure_count: number;
|
|
255
|
-
collection_failed_at: string | null;
|
|
256
|
-
next_collection_attempt_at: string | null;
|
|
257
|
-
last_collection_failure_code: string | null;
|
|
258
|
-
recovery: PaymentRecovery | null;
|
|
259
|
-
available_actions: ("mark_uncollectible" | "record_payment" | "retry_collection" | "void")[];
|
|
260
|
-
created_at: string;
|
|
261
|
-
};
|
|
262
158
|
export type InvoiceContact = {
|
|
263
159
|
name: string;
|
|
264
160
|
email: string;
|
|
265
161
|
};
|
|
266
|
-
export type InvoiceLineItem = {
|
|
267
|
-
event_type: string;
|
|
268
|
-
amount: string;
|
|
269
|
-
count: number;
|
|
270
|
-
dimensions: Record<string, number> | null;
|
|
271
|
-
};
|
|
272
|
-
export type InvoicePayNow = {
|
|
273
|
-
invoice: Invoice;
|
|
274
|
-
payment_id: string | null;
|
|
275
|
-
operation: PaymentOperation;
|
|
276
|
-
replayed: boolean;
|
|
277
|
-
};
|
|
278
162
|
export type Mandate = {
|
|
279
163
|
id: string;
|
|
280
164
|
customer_id: string;
|
|
@@ -298,14 +182,6 @@ export type MarkNotificationsReadParams = {
|
|
|
298
182
|
notification_ids?: string[];
|
|
299
183
|
all?: boolean;
|
|
300
184
|
};
|
|
301
|
-
export type MintCheckoutSessionParams = {
|
|
302
|
-
price_id?: string;
|
|
303
|
-
price_key?: string;
|
|
304
|
-
product_key?: string;
|
|
305
|
-
amount?: string;
|
|
306
|
-
auto_renew?: boolean;
|
|
307
|
-
success_url?: string;
|
|
308
|
-
};
|
|
309
185
|
export type NetworkLinkChallenge = {
|
|
310
186
|
id: string;
|
|
311
187
|
nonce: string;
|
|
@@ -346,12 +222,10 @@ export type NotificationData = {
|
|
|
346
222
|
downgrade_applied?: boolean;
|
|
347
223
|
new_product?: string;
|
|
348
224
|
overdue_amount?: string;
|
|
349
|
-
|
|
225
|
+
overdue_orders?: number;
|
|
350
226
|
overdue_started_at?: string;
|
|
351
227
|
from_state?: string;
|
|
352
228
|
to_state?: string;
|
|
353
|
-
invoice_id?: string;
|
|
354
|
-
invoice_number?: string;
|
|
355
229
|
amount_due?: string;
|
|
356
230
|
due_at?: string;
|
|
357
231
|
failure_code?: string;
|
|
@@ -373,8 +247,8 @@ export type NotificationData = {
|
|
|
373
247
|
export type Order = {
|
|
374
248
|
id: string;
|
|
375
249
|
customer_id: string;
|
|
376
|
-
origin: "customer" | "merchant" | "subscription";
|
|
377
|
-
status: "canceled" | "complete" | "expired" | "open" | "processing" | "void";
|
|
250
|
+
origin: "customer" | "merchant" | "subscription" | "usage";
|
|
251
|
+
status: "canceled" | "complete" | "expired" | "open" | "processing" | "uncollectible" | "void";
|
|
378
252
|
number: string | null;
|
|
379
253
|
currency: string;
|
|
380
254
|
total: string;
|
|
@@ -383,15 +257,18 @@ export type Order = {
|
|
|
383
257
|
payment_options: OrderPaymentOption[];
|
|
384
258
|
checkout: OrderCheckout | null;
|
|
385
259
|
renewal: OrderRenewal | null;
|
|
260
|
+
usage: OrderUsage | null;
|
|
386
261
|
expires_at: string | null;
|
|
387
262
|
completed_at: string | null;
|
|
388
263
|
canceled_at: string | null;
|
|
389
264
|
expired_at: string | null;
|
|
390
265
|
voided_at: string | null;
|
|
266
|
+
uncollectible_at: string | null;
|
|
391
267
|
created_at: string;
|
|
392
268
|
};
|
|
393
269
|
export type OrderCheckout = {
|
|
394
270
|
url: string | null;
|
|
271
|
+
ui_mode: "embedded" | "hosted";
|
|
395
272
|
expires_at: string;
|
|
396
273
|
success_url: string;
|
|
397
274
|
cancel_url: string | null;
|
|
@@ -399,13 +276,14 @@ export type OrderCheckout = {
|
|
|
399
276
|
};
|
|
400
277
|
export type OrderLine = {
|
|
401
278
|
id: string;
|
|
402
|
-
price_id: string;
|
|
403
|
-
product_id: string;
|
|
279
|
+
price_id: string | null;
|
|
280
|
+
product_id: string | null;
|
|
281
|
+
source: string | null;
|
|
404
282
|
description: string;
|
|
405
283
|
quantity: number | null;
|
|
406
284
|
unit_amount: string;
|
|
407
285
|
amount: string;
|
|
408
|
-
ownership: "consumable" | "extend" | "unique";
|
|
286
|
+
ownership: "consumable" | "extend" | "unique" | null;
|
|
409
287
|
billing_interval_hours: number | null;
|
|
410
288
|
access_duration_hours: number | null;
|
|
411
289
|
subscription_id: string | null;
|
|
@@ -466,6 +344,20 @@ export type OrderRenewal = {
|
|
|
466
344
|
period_ends_at: string;
|
|
467
345
|
due_at: string;
|
|
468
346
|
};
|
|
347
|
+
export type OrderUsage = {
|
|
348
|
+
period_starts_at: string;
|
|
349
|
+
period_ends_at: string;
|
|
350
|
+
due_at: string;
|
|
351
|
+
amount_paid: string;
|
|
352
|
+
amount_due: string;
|
|
353
|
+
collection_method: "charge_automatically" | "send_invoice";
|
|
354
|
+
next_collection_attempt_at: string | null;
|
|
355
|
+
po_number: string | null;
|
|
356
|
+
memo: string | null;
|
|
357
|
+
tax: Record<string, unknown> | null;
|
|
358
|
+
billing_contacts: InvoiceContact[];
|
|
359
|
+
delinquent: boolean;
|
|
360
|
+
};
|
|
469
361
|
export type PSPLinkState = {
|
|
470
362
|
status: "error" | "linked" | "pending_manual_link" | "sync_disabled";
|
|
471
363
|
ids: Record<string, string> | null;
|
|
@@ -486,17 +378,6 @@ export type PSPPaymentConfig = {
|
|
|
486
378
|
status?: string;
|
|
487
379
|
retry_after?: number;
|
|
488
380
|
};
|
|
489
|
-
export type PayCheckoutSessionParams = {
|
|
490
|
-
option_id?: string;
|
|
491
|
-
payment_method_id?: string;
|
|
492
|
-
payment_token?: string;
|
|
493
|
-
card?: CardEntry;
|
|
494
|
-
billing_details?: BillingDetails;
|
|
495
|
-
token_symbol?: string;
|
|
496
|
-
};
|
|
497
|
-
export type PayInvoiceParams = {
|
|
498
|
-
payment_method_id?: string;
|
|
499
|
-
};
|
|
500
381
|
export type PayOrderParams = {
|
|
501
382
|
payment?: OrderPaymentParams;
|
|
502
383
|
expected_total?: string;
|
|
@@ -512,7 +393,6 @@ export type Payment = {
|
|
|
512
393
|
customer_id: string;
|
|
513
394
|
subscription_id: string | null;
|
|
514
395
|
order_id: string | null;
|
|
515
|
-
invoice_id: string | null;
|
|
516
396
|
quantity: number | null;
|
|
517
397
|
price_id: string | null;
|
|
518
398
|
price: Price | null;
|
|
@@ -566,15 +446,10 @@ export type PaymentMethodSubscription = {
|
|
|
566
446
|
display_name: string;
|
|
567
447
|
created_at: string;
|
|
568
448
|
};
|
|
569
|
-
export type PaymentOperation = {
|
|
570
|
-
id: string;
|
|
571
|
-
status: string;
|
|
572
|
-
};
|
|
573
449
|
export type PaymentRecovery = {
|
|
574
450
|
last_failure_reason?: string;
|
|
575
451
|
retryable: boolean;
|
|
576
452
|
blocked_reason?: string;
|
|
577
|
-
operation?: PaymentOperation;
|
|
578
453
|
order_id?: string;
|
|
579
454
|
};
|
|
580
455
|
export type PendingAction = {
|
|
@@ -640,14 +515,18 @@ export type PublicConfig = {
|
|
|
640
515
|
capabilities: Capabilities;
|
|
641
516
|
currencies: CurrencyUnits[];
|
|
642
517
|
rails: RailDefinition[];
|
|
643
|
-
payment: PaymentConfig | null;
|
|
644
|
-
merchant: PublicMerchant | null;
|
|
645
518
|
captcha: CaptchaConfig | null;
|
|
519
|
+
network: PublicNetwork | null;
|
|
646
520
|
};
|
|
647
521
|
export type PublicMerchant = {
|
|
648
522
|
display_name: string;
|
|
649
523
|
logo_url: string | null;
|
|
650
524
|
support_url: string | null;
|
|
525
|
+
embed_origins: string[];
|
|
526
|
+
};
|
|
527
|
+
export type PublicNetwork = {
|
|
528
|
+
issuer: string;
|
|
529
|
+
client_id: string;
|
|
651
530
|
};
|
|
652
531
|
export type Quantity = {
|
|
653
532
|
min: number;
|
|
@@ -659,11 +538,6 @@ export type RailDefinition = {
|
|
|
659
538
|
credential_keys: string[];
|
|
660
539
|
setting_keys: string[];
|
|
661
540
|
};
|
|
662
|
-
export type ReplacePaymentMethodCardParams = {
|
|
663
|
-
payment_token?: string;
|
|
664
|
-
card?: CardEntry;
|
|
665
|
-
billing_details?: BillingDetails;
|
|
666
|
-
};
|
|
667
541
|
export type RetrySubscriptionNowParams = {
|
|
668
542
|
payment_method_id?: string;
|
|
669
543
|
};
|
|
@@ -712,12 +586,6 @@ export type SolanaPaymentToken = {
|
|
|
712
586
|
preferred: boolean;
|
|
713
587
|
recurring_eligible: boolean;
|
|
714
588
|
};
|
|
715
|
-
export type StripeEngineAuthentication = {
|
|
716
|
-
operation: PaymentOperation;
|
|
717
|
-
payment_intent_id?: string;
|
|
718
|
-
client_secret?: string;
|
|
719
|
-
provider_payment_method_id?: string;
|
|
720
|
-
};
|
|
721
589
|
export type StripePortalSession = {
|
|
722
590
|
url: string;
|
|
723
591
|
};
|
|
@@ -782,7 +650,6 @@ export type SubscriptionChange = {
|
|
|
782
650
|
amount_due_now: string;
|
|
783
651
|
next_charge_amount: string;
|
|
784
652
|
next_charge_date?: string;
|
|
785
|
-
operation_id?: string;
|
|
786
653
|
};
|
|
787
654
|
export type SubscriptionChangePreview = {
|
|
788
655
|
effective: string;
|
|
@@ -806,37 +673,9 @@ export type SubscriptionDunning = {
|
|
|
806
673
|
};
|
|
807
674
|
export type SubscriptionRetryNowResult = {
|
|
808
675
|
subscription: Subscription;
|
|
809
|
-
|
|
676
|
+
status: string;
|
|
810
677
|
replayed: boolean;
|
|
811
678
|
};
|
|
812
|
-
export type SupportedTokensResponse = {
|
|
813
|
-
tokens: TokenInfo[];
|
|
814
|
-
};
|
|
815
|
-
export type TokenBalance = {
|
|
816
|
-
amount: string;
|
|
817
|
-
units: string;
|
|
818
|
-
sufficient: boolean;
|
|
819
|
-
};
|
|
820
|
-
export type TokenInfo = {
|
|
821
|
-
symbol: string;
|
|
822
|
-
name: string;
|
|
823
|
-
mint: string;
|
|
824
|
-
decimals: number;
|
|
825
|
-
price?: string;
|
|
826
|
-
preferred: boolean;
|
|
827
|
-
recurring_eligible: boolean;
|
|
828
|
-
quote?: TokenQuote;
|
|
829
|
-
balance?: TokenBalance;
|
|
830
|
-
};
|
|
831
|
-
export type TokenQuote = {
|
|
832
|
-
amount: string;
|
|
833
|
-
units: string;
|
|
834
|
-
token_price_usd: string;
|
|
835
|
-
fx_rate: string;
|
|
836
|
-
fx_currency: string;
|
|
837
|
-
quoted_at: string;
|
|
838
|
-
expires_at: string;
|
|
839
|
-
};
|
|
840
679
|
export type UpdatePaymentMethodParams = {
|
|
841
680
|
exp_month?: number;
|
|
842
681
|
exp_year?: number;
|
package/dist/client/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { CANCEL_REASON_MAX, CANCEL_REASON_MIN, createBillingClient, isWalletAction, isWalletRejection, RETRY_BUDGET_MS, signWalletAction, WalletRejectedError, type BillingClient, type BillingClientOptions, type ListOptions, type OrderResult, type ProductListOptions, type SendSolanaTransaction, type SubscriptionChangeInput, } from './client';
|
|
2
|
+
export { redeemAssertion, tokenSource, type RedeemAssertionOptions, type TokenResponse, type TokenSource, type TokenSourceOptions, } from './token-source';
|
|
2
3
|
export { BillingError, isBillingError, isServerError, readBillingError, toBillingError, type BillingErrorBody, } from './errors';
|
|
3
|
-
export type { Account, Balance, CaptchaConfig, CardSummary, Cart, Currency, CurrencyScales, PaymentConfig, PaymentFailure, PublicConfig, PublicMerchant,
|
|
4
|
+
export type { Account, Balance, CaptchaConfig, CardSummary, Cart, Currency, CurrencyScales, CustomerConfig, CustomerLink, PaymentConfig, PaymentFailure, PublicConfig, PublicMerchant, ListPage, NetworkLinkChallenge, NewCard, NextAction, Order, OrderLine, OrderLineRefusal, OrderPaymentInput, OrderPreviewLine, Page, Payment, PaymentMethod, PaymentRecovery, Price, Product, Subscription, SubscriptionDunning, SubscriptionProduct, SubscriptionStatus, SubscriptionChange, SubscriptionChangePreview, } from './types';
|
|
4
5
|
export { amountToDecimal, decimalToAmount, formatAmount, type Amount, } from '../lib/money';
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/** A token endpoint's answer (RFC 6749 §5.1). */
|
|
2
|
+
export interface TokenResponse {
|
|
3
|
+
access_token: string;
|
|
4
|
+
/** Seconds until the token expires. */
|
|
5
|
+
expires_in: number;
|
|
6
|
+
}
|
|
7
|
+
export interface TokenSourceOptions {
|
|
8
|
+
/**
|
|
9
|
+
* Asks the host for the customer's access token: one bound to the
|
|
10
|
+
* merchant, from the host's own backend or `redeemAssertion`.
|
|
11
|
+
*/
|
|
12
|
+
fetchToken: () => Promise<TokenResponse>;
|
|
13
|
+
/** Seconds before its expiry at which a token is replaced. Default 60. */
|
|
14
|
+
skew?: number;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* A `getToken` for `createBillingClient`: the current token, fetched when
|
|
18
|
+
* there is none or the cached one is about to expire.
|
|
19
|
+
*/
|
|
20
|
+
export interface TokenSource {
|
|
21
|
+
(): Promise<string>;
|
|
22
|
+
/**
|
|
23
|
+
* Drops the cached token, so the next call fetches a new one. With
|
|
24
|
+
* `token`, only when that is the one cached.
|
|
25
|
+
*/
|
|
26
|
+
invalidate(token?: string): void;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Keeps the customer's access token for a billing client: it caches the
|
|
30
|
+
* token until `skew` seconds before it expires and fetches the next one with
|
|
31
|
+
* a single request, however many calls are waiting. A failed fetch is not
|
|
32
|
+
* cached. Tokens stay in memory, never in browser storage, so a reload
|
|
33
|
+
* fetches again. The client retries a call answered 401 `credential_expired`
|
|
34
|
+
* once with a new token.
|
|
35
|
+
*/
|
|
36
|
+
export declare function tokenSource({ fetchToken, skew, }: TokenSourceOptions): TokenSource;
|
|
37
|
+
/** Whether `getToken` is a `tokenSource`, whose token the client can replace. */
|
|
38
|
+
export declare const isTokenSource: (getToken: unknown) => getToken is TokenSource;
|
|
39
|
+
export interface RedeemAssertionOptions {
|
|
40
|
+
/** The authorization server's token endpoint, such as `https://billing.example/oauth2/token`. */
|
|
41
|
+
tokenEndpoint: string;
|
|
42
|
+
/**
|
|
43
|
+
* The assertion the merchant's backend signed for this customer (RFC
|
|
44
|
+
* 7523): single use and minutes long, so redeem each one once.
|
|
45
|
+
*/
|
|
46
|
+
assertion: string;
|
|
47
|
+
/**
|
|
48
|
+
* Transport. Pass a fetch that adds a DPoP proof (auth-ui's `dpopFetch`)
|
|
49
|
+
* to bind the token to the browser's key.
|
|
50
|
+
*/
|
|
51
|
+
fetch?: (input: string, init: RequestInit) => Promise<Response>;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Redeems a customer assertion for an access token to OpenRails
|
|
55
|
+
* (`scope=openrails:self`): a `fetchToken` for `tokenSource`, after the
|
|
56
|
+
* host's backend signed the assertion.
|
|
57
|
+
*/
|
|
58
|
+
export declare function redeemAssertion(options: RedeemAssertionOptions): Promise<TokenResponse & {
|
|
59
|
+
token_type: string;
|
|
60
|
+
}>;
|