@usethrottle/auth 0.11.0 → 0.12.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 (68) hide show
  1. package/README.md +52 -0
  2. package/dist/AccountDashboard-V63ghvjY.d.ts +90 -0
  3. package/dist/AccountModal-KA54WUFW.js +13 -0
  4. package/dist/AccountModal-KA54WUFW.js.map +1 -0
  5. package/dist/AccountModal-pIMgledL.d.ts +141 -0
  6. package/dist/AuthModal-T2GYI6ZF.js +13 -0
  7. package/dist/AuthModal-T2GYI6ZF.js.map +1 -0
  8. package/dist/SignUpPage-BJcMUb2V.d.ts +160 -0
  9. package/dist/chunk-3B4DNX5T.js +2 -0
  10. package/dist/chunk-3B4DNX5T.js.map +1 -0
  11. package/dist/chunk-5EUZYJJL.js +29 -0
  12. package/dist/chunk-5EUZYJJL.js.map +1 -0
  13. package/dist/chunk-6WN3J5MM.js +2075 -0
  14. package/dist/chunk-6WN3J5MM.js.map +1 -0
  15. package/dist/chunk-CUNMJ2PH.js +1320 -0
  16. package/dist/chunk-CUNMJ2PH.js.map +1 -0
  17. package/dist/chunk-ETYOOYYV.js +2 -0
  18. package/dist/chunk-ETYOOYYV.js.map +1 -0
  19. package/dist/chunk-JSDZMPCV.js +520 -0
  20. package/dist/chunk-JSDZMPCV.js.map +1 -0
  21. package/dist/chunk-QPVS6JXP.js +39 -0
  22. package/dist/chunk-QPVS6JXP.js.map +1 -0
  23. package/dist/chunk-RCNUWITB.js +747 -0
  24. package/dist/chunk-RCNUWITB.js.map +1 -0
  25. package/dist/{chunk-YY6YATXT.js → chunk-TDQC3LMQ.js} +17 -3
  26. package/dist/chunk-TDQC3LMQ.js.map +1 -0
  27. package/dist/{chunk-EFMKBOTL.js → chunk-UFGW76AZ.js} +2 -2
  28. package/dist/chunk-VDK23T6L.js +230 -0
  29. package/dist/chunk-VDK23T6L.js.map +1 -0
  30. package/dist/chunk-X6D35EAX.js +19 -0
  31. package/dist/chunk-X6D35EAX.js.map +1 -0
  32. package/dist/client-7LVKfuXO.d.ts +319 -0
  33. package/dist/hooks-DkpLrEiC.d.ts +148 -0
  34. package/dist/index.cjs +16 -2
  35. package/dist/index.cjs.map +1 -1
  36. package/dist/index.d.cts +34 -3
  37. package/dist/index.d.ts +34 -3
  38. package/dist/index.js +16 -2
  39. package/dist/index.js.map +1 -1
  40. package/dist/localization-SnIAZXJn.d.ts +389 -0
  41. package/dist/react/components/account/index.d.ts +37 -0
  42. package/dist/react/components/account/index.js +44 -0
  43. package/dist/react/components/account/index.js.map +1 -0
  44. package/dist/react/components/auth/index.d.ts +17 -0
  45. package/dist/react/components/auth/index.js +40 -0
  46. package/dist/react/components/auth/index.js.map +1 -0
  47. package/dist/react/components/guards.d.ts +21 -0
  48. package/dist/react/components/guards.js +13 -0
  49. package/dist/react/components/guards.js.map +1 -0
  50. package/dist/react/components/index.cjs +3561 -2805
  51. package/dist/react/components/index.cjs.map +1 -1
  52. package/dist/react/components/index.d.cts +14 -2
  53. package/dist/react/components/index.d.ts +14 -821
  54. package/dist/react/components/index.js +90 -4680
  55. package/dist/react/components/index.js.map +1 -1
  56. package/dist/react/components/provider.d.ts +79 -0
  57. package/dist/react/components/provider.js +18 -0
  58. package/dist/react/components/provider.js.map +1 -0
  59. package/dist/react/forms/index.js +1 -1
  60. package/dist/react/index.cjs +16 -2
  61. package/dist/react/index.cjs.map +1 -1
  62. package/dist/react/index.d.cts +34 -3
  63. package/dist/react/index.d.ts +5 -433
  64. package/dist/react/index.js +3 -2
  65. package/dist/styles.css +7 -4
  66. package/package.json +4 -1
  67. package/dist/chunk-YY6YATXT.js.map +0 -1
  68. /package/dist/{chunk-EFMKBOTL.js.map → chunk-UFGW76AZ.js.map} +0 -0
package/README.md CHANGED
@@ -149,6 +149,44 @@ headless core, or anywhere you want the call without the hook.
149
149
  | `pauseSubscription(id): Promise<Subscription>` | `POST /me/subscriptions/:id/pause` | Requires step-up. |
150
150
  | `resumeSubscription(id): Promise<Subscription>` | `POST /me/subscriptions/:id/resume` | Requires step-up. |
151
151
  | `claimCart(cartId): Promise<{ cartId: string; customerId: string }>` | `POST /me/carts/:cartId/claim` | Attaches a guest cart to the signed-in buyer. Throws `cart_already_claimed` if it belongs to someone else. |
152
+ | `getOpenCart({ currency }): Promise<OpenCart \| null>` | `GET /me/cart?currency=` | The buyer's newest open or idle-abandoned cart in that currency (see `status`). `null` for none or an older API (404). A currency that is not 3 letters throws `TypeError`. |
153
+
154
+ `auth.whenClaimSettled()` resolves once a sign-in or registration's cart claim has finished
155
+ (succeeded or failed). `ThrottleProvider` marks it pending from the moment `signIn`/`register`
156
+ is called; a bare `createThrottleAuth` client resolves at once. Both it and `getOpenCart` are
157
+ optional on the `ThrottleAuth`/`ThrottleAccount` interfaces (and `OrderLineItem.referenceId` is
158
+ optional in the type), so 0.11-shaped implementations still compile. Values from
159
+ `createThrottleAuth`/`createAccount` always have them; through `useAuth()` they are optional, so
160
+ call them as `auth.whenClaimSettled?.()` and `account.getOpenCart?.(...)`.
161
+
162
+ For reorder, `onReorder` targets carry `sku` (the line's `referenceId`, never rendered) and
163
+ `subscriptionId` per line, and `reorderOnPaid` on `AccountDashboard`, `OrdersPanel` and
164
+ `OrderDetail` also offers "Order again" on `captured`/`paid` orders (default `false`).
165
+
166
+ ```ts
167
+ // Resume the buyer's open cart once the sign-in claim has finished.
168
+ await auth.signIn(email, password);
169
+ await auth.whenClaimSettled();
170
+ const cart = await account.getOpenCart({ currency: 'USD' }); // OpenCart | null
171
+ if (cart) console.log(cart.cartId, cart.status);
172
+
173
+ // Order lines carry referenceId (the merchant SKU); it is data, not UI.
174
+ const order = await account.getOrder(orderId);
175
+ const skus = order.lineItems.map((line) => line.referenceId);
176
+ ```
177
+
178
+ ```tsx
179
+ // Reorder targets carry sku and subscriptionId per line. reorderOnPaid also
180
+ // offers "Order again" on captured/paid orders.
181
+ <AccountDashboard
182
+ reorderOnPaid
183
+ onReorder={(target) => {
184
+ for (const line of target.lineItems) {
185
+ if (line.sku) addToCart(line.sku, line.quantity, line.subscriptionId);
186
+ }
187
+ }}
188
+ />
189
+ ```
152
190
 
153
191
  Paging is `{ cursor?: string; limit?: number }`; `limit` is 1-100 and defaults to
154
192
  25. A list returns rows only — carry the last row's `id` as the next `cursor`.
@@ -429,6 +467,20 @@ export default function RootLayout({ children }: { children: React.ReactNode })
429
467
  }
430
468
  ```
431
469
 
470
+ ### Lazy modals
471
+
472
+ `ThrottleProvider` loads the sign-in and account modals on their first open. The
473
+ first open fetches one chunk (once); a failed fetch renders nothing, logs one
474
+ warning and is retried on the next open. In the ESM build, pages that use only the
475
+ provider and guards ship none of the modal code; the CJS build is one bundle per
476
+ entry and inlines the modals. Import paths are unchanged.
477
+
478
+ ```tsx
479
+ const { openSignIn } = useThrottle();
480
+ // The first call fetches the sign-in chunk, then shows the modal; later calls are instant.
481
+ <button onClick={() => openSignIn()}>Sign in</button>
482
+ ```
483
+
432
484
  ### Known limits
433
485
 
434
486
  - **No add-card control.** There is no buyer-plane route for creating a saved
@@ -0,0 +1,90 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { a as ThrottleAppearance, c as ThrottleLocalization } from './localization-SnIAZXJn.js';
3
+
4
+ /**
5
+ * Composition of the list of records a panel renders. `'boxed'` is today's
6
+ * shipped look (each item its own bordered box, outlined action buttons) and
7
+ * must stay byte-for-byte identical to it. `'rows'` separates items with a
8
+ * hairline instead, and renders actions as plain text — the motivation is
9
+ * that the account dashboard is itself a bordered card, so a panel built from
10
+ * bordered boxes is a card inside a card with nothing establishing hierarchy.
11
+ * `'table'` is a real `<table>` with column headers, for merchants who want
12
+ * their buyer's records (especially money) in aligned tabular columns.
13
+ */
14
+ type AccountPanelVariant = 'rows' | 'boxed' | 'table';
15
+ declare function AddressesPanel(props: {
16
+ appearance?: ThrottleAppearance;
17
+ localization?: ThrottleLocalization;
18
+ variant?: AccountPanelVariant;
19
+ }): react_jsx_runtime.JSX.Element;
20
+
21
+ /**
22
+ * The order the buyer is acting on, including its line items — so "order
23
+ * again" can rebuild a cart without fetching the order a second time.
24
+ */
25
+ interface OrderActionTarget {
26
+ id: string;
27
+ orderNumber: string;
28
+ currency: string;
29
+ lineItems: Array<{
30
+ name: string;
31
+ unitPrice: number;
32
+ quantity: number;
33
+ /** The catalog SKU (the line's `referenceId`), for re-adding it. Never display it. */
34
+ sku: string | null;
35
+ subscriptionId: string | null;
36
+ }>;
37
+ }
38
+ interface OrderActionHandlers {
39
+ onPayNow?(order: OrderActionTarget): void;
40
+ onReorder?(order: OrderActionTarget): void;
41
+ onTrackShipment?(order: OrderActionTarget): void;
42
+ }
43
+ declare function OrdersPanel(props: OrderActionHandlers & {
44
+ appearance?: ThrottleAppearance;
45
+ localization?: ThrottleLocalization;
46
+ variant?: AccountPanelVariant;
47
+ onViewSubscription?(id: string): void;
48
+ /** Forwarded to `OrderDetail`, where both default to on. */
49
+ allowCancel?: boolean;
50
+ allowReturn?: boolean;
51
+ /** Forwarded to `OrderDetail`: also offer "Order again" on orders whose payment is captured or paid. */
52
+ reorderOnPaid?: boolean;
53
+ /** Opens straight to this order. Set by the dashboard on cross-panel navigation. */
54
+ initialOpenId?: string | null;
55
+ }): react_jsx_runtime.JSX.Element;
56
+
57
+ type AccountTab = 'profile' | 'addresses' | 'paymentMethods' | 'orders' | 'invoices' | 'subscriptions' | 'security';
58
+ declare const ACCOUNT_TABS: readonly AccountTab[];
59
+ interface AccountDashboardProps extends OrderActionHandlers {
60
+ /** Which panels to show, in order. Defaults to all seven. */
61
+ tabs?: AccountTab[];
62
+ tab?: AccountTab;
63
+ onTabChange?(tab: AccountTab): void;
64
+ routing?: 'virtual' | 'hash';
65
+ /**
66
+ * `'sidebar'` (default) puts the seven panels in a vertical rail beside the
67
+ * content; `'tabs'` is the original horizontal strip above it. Seven is a lot
68
+ * for a strip — at narrow widths most of them sit off-screen behind a scroll
69
+ * with nothing signalling they exist — so the rail is the default. The strip
70
+ * remains for merchants whose surrounding page already has a side nav and
71
+ * would end up with two.
72
+ */
73
+ layout?: 'sidebar' | 'tabs';
74
+ /**
75
+ * Default composition for every panel rendered here. A panel's own
76
+ * `variant` prop cannot be set through the dashboard (it does not expose
77
+ * per-tab overrides), so in practice this is the only source of `variant`
78
+ * each panel receives when rendered through `AccountDashboard` — a panel
79
+ * rendered directly, outside the dashboard, keeps deciding its own default
80
+ * from its own `variant` prop rather than this one.
81
+ */
82
+ panelVariant?: AccountPanelVariant;
83
+ /** Also offer "Order again" on orders whose payment is captured or paid. Default false. */
84
+ reorderOnPaid?: boolean;
85
+ appearance?: ThrottleAppearance;
86
+ localization?: ThrottleLocalization;
87
+ }
88
+ declare function AccountDashboard(props: AccountDashboardProps): react_jsx_runtime.JSX.Element | null;
89
+
90
+ export { ACCOUNT_TABS as A, type OrderActionTarget as O, AccountDashboard as a, type AccountDashboardProps as b, type AccountPanelVariant as c, type AccountTab as d, AddressesPanel as e, OrdersPanel as f };
@@ -0,0 +1,13 @@
1
+ "use client";
2
+ import {
3
+ AccountModal
4
+ } from "./chunk-6WN3J5MM.js";
5
+ import "./chunk-UFGW76AZ.js";
6
+ import "./chunk-QPVS6JXP.js";
7
+ import "./chunk-CUNMJ2PH.js";
8
+ import "./chunk-K7RCWADI.js";
9
+ import "./chunk-TDQC3LMQ.js";
10
+ export {
11
+ AccountModal
12
+ };
13
+ //# sourceMappingURL=AccountModal-KA54WUFW.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,141 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { a as ThrottleAppearance, c as ThrottleLocalization } from './localization-SnIAZXJn.js';
3
+ import { c as AccountPanelVariant, O as OrderActionTarget, d as AccountTab } from './AccountDashboard-V63ghvjY.js';
4
+
5
+ declare function VerifyEmailBanner(props: {
6
+ appearance?: ThrottleAppearance;
7
+ localization?: ThrottleLocalization;
8
+ }): react_jsx_runtime.JSX.Element | null;
9
+
10
+ declare function ProfilePanel(props: {
11
+ appearance?: ThrottleAppearance;
12
+ localization?: ThrottleLocalization;
13
+ }): react_jsx_runtime.JSX.Element | null;
14
+
15
+ /**
16
+ * Add, set-default and remove. The card form is hosted by the processor and
17
+ * shown in an iframe by AddCardDialog, so a card number never reaches this
18
+ * component. Adding is verified-only, like listing: what it hands out is the
19
+ * ability to attach a payment instrument to the account.
20
+ */
21
+ declare function PaymentMethodsPanel(props: {
22
+ appearance?: ThrottleAppearance;
23
+ localization?: ThrottleLocalization;
24
+ variant?: AccountPanelVariant;
25
+ }): react_jsx_runtime.JSX.Element;
26
+
27
+ /**
28
+ * The card form itself is hosted by the processor and shown in an iframe, so a
29
+ * card number never touches this SDK, the merchant's page, or our API. When the
30
+ * card is vaulted the frame posts `throttle.completed`, and the transaction id
31
+ * on that message is what we hand back to record the card.
32
+ */
33
+ declare function AddCardDialog(props: {
34
+ open: boolean;
35
+ onClose(): void;
36
+ onAdded(): void;
37
+ localization?: ThrottleLocalization;
38
+ }): react_jsx_runtime.JSX.Element | null;
39
+
40
+ declare function OrderDetail(props: {
41
+ orderId: string;
42
+ onBack?(): void;
43
+ onViewSubscription?(id: string): void;
44
+ onViewInvoice?(id: string): void;
45
+ /**
46
+ * Status-dependent actions the MERCHANT owns. Each renders only when its
47
+ * handler is supplied, because the buyer plane cannot perform them: a
48
+ * built-in Pay or Track button would be a control that always fails.
49
+ */
50
+ onPayNow?(order: OrderActionTarget): void;
51
+ onReorder?(order: OrderActionTarget): void;
52
+ onTrackShipment?(order: OrderActionTarget): void;
53
+ /**
54
+ * Cancel and return, by contrast, ARE buyer-plane capabilities, so they are
55
+ * wired in here and need no handler. Opt out with `false` for a storefront
56
+ * that handles them elsewhere.
57
+ */
58
+ allowCancel?: boolean;
59
+ allowReturn?: boolean;
60
+ /**
61
+ * Also offer "Order again" on an order whose payment is captured or paid,
62
+ * whatever its status. Default false.
63
+ */
64
+ reorderOnPaid?: boolean;
65
+ appearance?: ThrottleAppearance;
66
+ localization?: ThrottleLocalization;
67
+ }): react_jsx_runtime.JSX.Element;
68
+
69
+ declare function InvoicesPanel(props: {
70
+ appearance?: ThrottleAppearance;
71
+ localization?: ThrottleLocalization;
72
+ variant?: AccountPanelVariant;
73
+ /** Navigation out of an invoice, forwarded to `InvoiceDetail`. */
74
+ onViewOrder?(orderId: string): void;
75
+ onViewSubscription?(subscriptionId: string): void;
76
+ onPay?(invoice: {
77
+ id: string;
78
+ number: string;
79
+ total: number;
80
+ currency: string;
81
+ }): void;
82
+ /** Opens straight to this invoice. Set by the dashboard on cross-panel navigation. */
83
+ initialOpenId?: string | null;
84
+ }): react_jsx_runtime.JSX.Element;
85
+
86
+ declare function InvoiceDetail(props: {
87
+ invoiceId: string;
88
+ onBack?(): void;
89
+ /**
90
+ * Navigation out of the invoice. An invoice is a record OF something — an
91
+ * order or a subscription — and without these it was a dead end: the buyer
92
+ * could read what they were charged but not reach the thing that charged
93
+ * them. Each link renders only when the handler is supplied AND the server
94
+ * resolved the id.
95
+ */
96
+ onViewOrder?(orderId: string): void;
97
+ onViewSubscription?(subscriptionId: string): void;
98
+ /** Settle an open invoice. Merchant-owned, like the order's Pay now. */
99
+ onPay?(invoice: {
100
+ id: string;
101
+ number: string;
102
+ total: number;
103
+ currency: string;
104
+ }): void;
105
+ appearance?: ThrottleAppearance;
106
+ localization?: ThrottleLocalization;
107
+ }): react_jsx_runtime.JSX.Element;
108
+
109
+ declare function SubscriptionsPanel(props: {
110
+ appearance?: ThrottleAppearance;
111
+ localization?: ThrottleLocalization;
112
+ variant?: AccountPanelVariant;
113
+ }): react_jsx_runtime.JSX.Element;
114
+
115
+ declare function SecurityPanel(props: {
116
+ appearance?: ThrottleAppearance;
117
+ localization?: ThrottleLocalization;
118
+ variant?: AccountPanelVariant;
119
+ }): react_jsx_runtime.JSX.Element;
120
+
121
+ interface AccountModalProps {
122
+ open: boolean;
123
+ onClose(): void;
124
+ tabs?: AccountTab[];
125
+ appearance?: ThrottleAppearance;
126
+ localization?: ThrottleLocalization;
127
+ /** Where focus returns on close. See `Modal`'s own doc for why a caller
128
+ * sometimes has to name this rather than let the modal capture it. */
129
+ restoreFocusTo?: Element | null;
130
+ }
131
+ /**
132
+ * The account dashboard, reachable without going through `UserButton`'s
133
+ * menu — a merchant can wire this to a "Settings" control anywhere. Mirrors
134
+ * `AuthModal`'s shape (a `Modal` hosting the existing card/dashboard), so a
135
+ * merchant who wants to own the open/close state themselves has the same
136
+ * kind of component available for the account surface that they already
137
+ * have for sign-in.
138
+ */
139
+ declare function AccountModal(props: AccountModalProps): react_jsx_runtime.JSX.Element;
140
+
141
+ export { AccountModal as A, InvoiceDetail as I, OrderDetail as O, PaymentMethodsPanel as P, SecurityPanel as S, VerifyEmailBanner as V, type AccountModalProps as a, AddCardDialog as b, InvoicesPanel as c, ProfilePanel as d, SubscriptionsPanel as e };
@@ -0,0 +1,13 @@
1
+ "use client";
2
+ import {
3
+ AuthModal
4
+ } from "./chunk-JSDZMPCV.js";
5
+ import "./chunk-X6D35EAX.js";
6
+ import "./chunk-QPVS6JXP.js";
7
+ import "./chunk-CUNMJ2PH.js";
8
+ import "./chunk-K7RCWADI.js";
9
+ import "./chunk-TDQC3LMQ.js";
10
+ export {
11
+ AuthModal
12
+ };
13
+ //# sourceMappingURL=AuthModal-T2GYI6ZF.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,160 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { ReactNode } from 'react';
3
+ import { a as ThrottleAppearance, c as ThrottleLocalization } from './localization-SnIAZXJn.js';
4
+
5
+ type AuthCardVariant = 'quiet' | 'grouped' | 'branded';
6
+ interface SignInProps {
7
+ appearance?: ThrottleAppearance;
8
+ localization?: ThrottleLocalization;
9
+ /** Composition of the card. Default `'quiet'`. */
10
+ variant?: AuthCardVariant;
11
+ /** Rendered above the title in the `branded` variant. Falls back to `ThrottleProvider`'s `logo`. */
12
+ logo?: ReactNode;
13
+ onSuccess?(): void;
14
+ onForgotPassword?(): void;
15
+ onSignUp?(): void;
16
+ }
17
+ declare function SignIn(props: SignInProps): react_jsx_runtime.JSX.Element;
18
+
19
+ interface SignUpProps {
20
+ appearance?: ThrottleAppearance;
21
+ localization?: ThrottleLocalization;
22
+ /** Composition of the card. Default `'quiet'`. */
23
+ variant?: AuthCardVariant;
24
+ /** Rendered above the title in the `branded` variant. Falls back to `ThrottleProvider`'s `logo`. */
25
+ logo?: ReactNode;
26
+ onSuccess?(): void;
27
+ onSignIn?(): void;
28
+ }
29
+ declare function SignUp(props: SignUpProps): react_jsx_runtime.JSX.Element;
30
+
31
+ interface ForgotPasswordProps {
32
+ appearance?: ThrottleAppearance;
33
+ localization?: ThrottleLocalization;
34
+ /** Composition of the card. Default `'quiet'`. A single input, so `'grouped'` renders the same as `'quiet'`. */
35
+ variant?: AuthCardVariant;
36
+ /** Rendered above the title in the `branded` variant. Falls back to `ThrottleProvider`'s `logo`. */
37
+ logo?: ReactNode;
38
+ onBack?(): void;
39
+ }
40
+ declare function ForgotPassword(props: ForgotPasswordProps): react_jsx_runtime.JSX.Element;
41
+
42
+ interface ResetPasswordProps {
43
+ token?: string;
44
+ appearance?: ThrottleAppearance;
45
+ localization?: ThrottleLocalization;
46
+ /** Composition of the card. Default `'quiet'`. A single input, so `'grouped'` renders the same as `'quiet'`. */
47
+ variant?: AuthCardVariant;
48
+ /** Rendered above the title in the `branded` variant. Falls back to `ThrottleProvider`'s `logo`. */
49
+ logo?: ReactNode;
50
+ onSuccess?(): void;
51
+ }
52
+ declare function ResetPassword(props: ResetPasswordProps): react_jsx_runtime.JSX.Element;
53
+
54
+ interface VerifyEmailProps {
55
+ token?: string;
56
+ appearance?: ThrottleAppearance;
57
+ localization?: ThrottleLocalization;
58
+ /** Composition of the card. Default `'quiet'`. This card has no inputs, so `'grouped'` renders the same as `'quiet'`. */
59
+ variant?: AuthCardVariant;
60
+ /** Rendered above the title in the `branded` variant. Falls back to `ThrottleProvider`'s `logo`. */
61
+ logo?: ReactNode;
62
+ onSuccess?(): void;
63
+ }
64
+ declare function VerifyEmail(props: VerifyEmailProps): react_jsx_runtime.JSX.Element;
65
+
66
+ type AuthView = 'signIn' | 'signUp' | 'forgotPassword' | 'resetPassword' | 'verifyEmail';
67
+ interface AuthFlowProps {
68
+ initialView?: AuthView;
69
+ /** Controlled mode: pass both to own the value yourself. */
70
+ view?: AuthView;
71
+ onViewChange?(view: AuthView): void;
72
+ /** Wins over the token in the URL. */
73
+ token?: string;
74
+ routing?: 'virtual' | 'hash';
75
+ afterSignIn?(): void;
76
+ afterSignUp?(): void;
77
+ appearance?: ThrottleAppearance;
78
+ localization?: ThrottleLocalization;
79
+ }
80
+ declare function AuthFlow(props: AuthFlowProps): react_jsx_runtime.JSX.Element;
81
+
82
+ interface AuthModalProps {
83
+ open: boolean;
84
+ onClose(): void;
85
+ initialView?: AuthView;
86
+ afterSignIn?(): void;
87
+ afterSignUp?(): void;
88
+ appearance?: ThrottleAppearance;
89
+ localization?: ThrottleLocalization;
90
+ }
91
+ declare function AuthModal(props: AuthModalProps): react_jsx_runtime.JSX.Element;
92
+
93
+ interface SignInButtonProps {
94
+ mode?: 'modal' | 'redirect';
95
+ /** Required when mode is "redirect". */
96
+ url?: string;
97
+ initialView?: AuthView;
98
+ asChild?: boolean;
99
+ children?: ReactNode;
100
+ appearance?: ThrottleAppearance;
101
+ localization?: ThrottleLocalization;
102
+ afterSignIn?(): void;
103
+ }
104
+ declare function SignInButton(props: SignInButtonProps): react_jsx_runtime.JSX.Element;
105
+
106
+ /** The twin of `SignInButton`, opening the same flow on the sign-up view. */
107
+ interface SignUpButtonProps {
108
+ mode?: 'modal' | 'redirect';
109
+ /** Required when mode is "redirect". */
110
+ url?: string;
111
+ initialView?: AuthView;
112
+ asChild?: boolean;
113
+ children?: ReactNode;
114
+ appearance?: ThrottleAppearance;
115
+ localization?: ThrottleLocalization;
116
+ afterSignUp?(): void;
117
+ }
118
+ declare function SignUpButton(props: SignUpButtonProps): react_jsx_runtime.JSX.Element;
119
+
120
+ interface SignOutButtonProps {
121
+ /** Revokes every session, not just this device. May raise a step-up prompt. */
122
+ everywhere?: boolean;
123
+ children?: ReactNode;
124
+ localization?: ThrottleLocalization;
125
+ onSignedOut?(): void;
126
+ }
127
+ declare function SignOutButton(props: SignOutButtonProps): react_jsx_runtime.JSX.Element;
128
+
129
+ interface SignInPageProps {
130
+ /** Rendered above the card. Absent by default. */
131
+ logo?: ReactNode;
132
+ /** Rendered below the card. Absent by default. */
133
+ footer?: ReactNode;
134
+ appearance?: ThrottleAppearance;
135
+ localization?: ThrottleLocalization;
136
+ onSuccess?(): void;
137
+ onForgotPassword?(): void;
138
+ onSignUp?(): void;
139
+ }
140
+ /**
141
+ * A full-viewport, centred shell around `<SignIn/>` for merchants who drop it
142
+ * directly on a route (e.g. `/sign-in`) and would otherwise get a card stuck
143
+ * at the top of a bare page. `100dvh`, not `100vh` — see styles.ts.
144
+ */
145
+ declare function SignInPage(props: SignInPageProps): react_jsx_runtime.JSX.Element;
146
+
147
+ interface SignUpPageProps {
148
+ /** Rendered above the card. Absent by default. */
149
+ logo?: ReactNode;
150
+ /** Rendered below the card. Absent by default. */
151
+ footer?: ReactNode;
152
+ appearance?: ThrottleAppearance;
153
+ localization?: ThrottleLocalization;
154
+ onSuccess?(): void;
155
+ onSignIn?(): void;
156
+ }
157
+ /** The `<SignUp/>` twin of `SignInPage`. */
158
+ declare function SignUpPage(props: SignUpPageProps): react_jsx_runtime.JSX.Element;
159
+
160
+ export { type AuthCardVariant as A, ForgotPassword as F, ResetPassword as R, SignIn as S, VerifyEmail as V, AuthFlow as a, type AuthFlowProps as b, AuthModal as c, type AuthModalProps as d, type AuthView as e, type ForgotPasswordProps as f, type ResetPasswordProps as g, SignInButton as h, type SignInButtonProps as i, SignInPage as j, type SignInPageProps as k, type SignInProps as l, SignOutButton as m, type SignOutButtonProps as n, SignUp as o, SignUpButton as p, type SignUpButtonProps as q, SignUpPage as r, type SignUpPageProps as s, type SignUpProps as t, type VerifyEmailProps as u };
@@ -0,0 +1,2 @@
1
+ "use client";
2
+ //# sourceMappingURL=chunk-3B4DNX5T.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,29 @@
1
+ "use client";
2
+ import {
3
+ useAuth
4
+ } from "./chunk-TDQC3LMQ.js";
5
+
6
+ // src/react/components/guards.tsx
7
+ import { Fragment, jsx } from "react/jsx-runtime";
8
+ function SignedIn(props) {
9
+ const { status } = useAuth();
10
+ return status === "authenticated" ? /* @__PURE__ */ jsx(Fragment, { children: props.children }) : null;
11
+ }
12
+ function SignedOut(props) {
13
+ const { status } = useAuth();
14
+ return status === "unauthenticated" ? /* @__PURE__ */ jsx(Fragment, { children: props.children }) : null;
15
+ }
16
+ function Protect(props) {
17
+ const { status, emailVerified } = useAuth();
18
+ if (status === "loading") return null;
19
+ if (status !== "authenticated") return /* @__PURE__ */ jsx(Fragment, { children: props.fallback ?? null });
20
+ if (props.requireVerified && !emailVerified) return /* @__PURE__ */ jsx(Fragment, { children: props.fallback ?? null });
21
+ return /* @__PURE__ */ jsx(Fragment, { children: props.children });
22
+ }
23
+
24
+ export {
25
+ SignedIn,
26
+ SignedOut,
27
+ Protect
28
+ };
29
+ //# sourceMappingURL=chunk-5EUZYJJL.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/react/components/guards.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\nimport { useAuth } from '../context';\n\n/**\n * All three render nothing while `status === 'loading'`. A guard that treated\n * loading as signed-out would flash a \"Sign in\" button at a buyer whose\n * session is a few milliseconds from being restored.\n */\nexport function SignedIn(props: { children: ReactNode }) {\n const { status } = useAuth();\n return status === 'authenticated' ? <>{props.children}</> : null;\n}\n\nexport function SignedOut(props: { children: ReactNode }) {\n const { status } = useAuth();\n return status === 'unauthenticated' ? <>{props.children}</> : null;\n}\n\nexport function Protect(props: { requireVerified?: boolean; fallback?: ReactNode; children: ReactNode }) {\n const { status, emailVerified } = useAuth();\n if (status === 'loading') return null;\n if (status !== 'authenticated') return <>{props.fallback ?? null}</>;\n if (props.requireVerified && !emailVerified) return <>{props.fallback ?? null}</>;\n return <>{props.children}</>;\n}\n"],"mappings":";;;;;;AAUsC;AAF/B,SAAS,SAAS,OAAgC;AACvD,QAAM,EAAE,OAAO,IAAI,QAAQ;AAC3B,SAAO,WAAW,kBAAkB,gCAAG,gBAAM,UAAS,IAAM;AAC9D;AAEO,SAAS,UAAU,OAAgC;AACxD,QAAM,EAAE,OAAO,IAAI,QAAQ;AAC3B,SAAO,WAAW,oBAAoB,gCAAG,gBAAM,UAAS,IAAM;AAChE;AAEO,SAAS,QAAQ,OAAiF;AACvG,QAAM,EAAE,QAAQ,cAAc,IAAI,QAAQ;AAC1C,MAAI,WAAW,UAAW,QAAO;AACjC,MAAI,WAAW,gBAAiB,QAAO,gCAAG,gBAAM,YAAY,MAAK;AACjE,MAAI,MAAM,mBAAmB,CAAC,cAAe,QAAO,gCAAG,gBAAM,YAAY,MAAK;AAC9E,SAAO,gCAAG,gBAAM,UAAS;AAC3B;","names":[]}