@usethrottle/auth 0.1.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/CLAUDE.md +52 -0
- package/README.md +230 -0
- package/dist/chunk-NQU7HM23.js +378 -0
- package/dist/chunk-NQU7HM23.js.map +1 -0
- package/dist/chunk-YHIGTY64.js +49 -0
- package/dist/chunk-YHIGTY64.js.map +1 -0
- package/dist/chunk-ZMNCURDE.js +1 -0
- package/dist/chunk-ZMNCURDE.js.map +1 -0
- package/dist/index.cjs +408 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +245 -0
- package/dist/index.d.ts +245 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/dist/react/forms/index.cjs +402 -0
- package/dist/react/forms/index.cjs.map +1 -0
- package/dist/react/forms/index.d.cts +77 -0
- package/dist/react/forms/index.d.ts +77 -0
- package/dist/react/forms/index.js +354 -0
- package/dist/react/forms/index.js.map +1 -0
- package/dist/react/index.cjs +581 -0
- package/dist/react/index.cjs.map +1 -0
- package/dist/react/index.d.cts +54 -0
- package/dist/react/index.d.ts +54 -0
- package/dist/react/index.js +145 -0
- package/dist/react/index.js.map +1 -0
- package/package.json +36 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
interface Customer {
|
|
2
|
+
id: string;
|
|
3
|
+
email: string;
|
|
4
|
+
emailVerified: boolean;
|
|
5
|
+
firstName?: string | null;
|
|
6
|
+
lastName?: string | null;
|
|
7
|
+
phone?: string | null;
|
|
8
|
+
company?: string | null;
|
|
9
|
+
acceptsMarketing?: boolean;
|
|
10
|
+
}
|
|
11
|
+
interface Session {
|
|
12
|
+
accessToken: string;
|
|
13
|
+
expiresAt: string;
|
|
14
|
+
refreshToken: string;
|
|
15
|
+
customer: Customer;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Defined here rather than in `storage.ts` so `ThrottleAuthConfig` can name it
|
|
19
|
+
* without importing a module that does not exist until Task 2. `storage.ts`
|
|
20
|
+
* imports and re-exports it.
|
|
21
|
+
*/
|
|
22
|
+
interface AuthStorage {
|
|
23
|
+
get(key: string): string | null | Promise<string | null>;
|
|
24
|
+
set(key: string, value: string): void | Promise<void>;
|
|
25
|
+
remove(key: string): void | Promise<void>;
|
|
26
|
+
}
|
|
27
|
+
interface ThrottleAuthConfig {
|
|
28
|
+
publishableKey: string;
|
|
29
|
+
baseUrl?: string;
|
|
30
|
+
storage?: AuthStorage;
|
|
31
|
+
/** Called when a route needs a step-up proof. Return the buyer's password, or null to cancel. */
|
|
32
|
+
onStepUpRequired?: () => Promise<string | null>;
|
|
33
|
+
}
|
|
34
|
+
interface ProfilePatch {
|
|
35
|
+
firstName?: string;
|
|
36
|
+
lastName?: string;
|
|
37
|
+
phone?: string;
|
|
38
|
+
company?: string | null;
|
|
39
|
+
acceptsMarketing?: boolean;
|
|
40
|
+
}
|
|
41
|
+
interface AddressInput {
|
|
42
|
+
label?: string;
|
|
43
|
+
firstName?: string;
|
|
44
|
+
lastName?: string;
|
|
45
|
+
company?: string;
|
|
46
|
+
addressLine1: string;
|
|
47
|
+
addressLine2?: string;
|
|
48
|
+
city: string;
|
|
49
|
+
stateProvince?: string;
|
|
50
|
+
postalCode?: string;
|
|
51
|
+
countryCode: string;
|
|
52
|
+
phone?: string;
|
|
53
|
+
isDefault?: boolean;
|
|
54
|
+
}
|
|
55
|
+
interface Address {
|
|
56
|
+
id: string;
|
|
57
|
+
label: string | null;
|
|
58
|
+
firstName: string | null;
|
|
59
|
+
lastName: string | null;
|
|
60
|
+
company: string | null;
|
|
61
|
+
addressLine1: string;
|
|
62
|
+
addressLine2: string | null;
|
|
63
|
+
city: string;
|
|
64
|
+
stateProvince: string | null;
|
|
65
|
+
postalCode: string | null;
|
|
66
|
+
countryCode: string;
|
|
67
|
+
phone: string | null;
|
|
68
|
+
isDefault: boolean;
|
|
69
|
+
createdAt: string;
|
|
70
|
+
updatedAt: string;
|
|
71
|
+
}
|
|
72
|
+
interface PaymentMethod {
|
|
73
|
+
id: string;
|
|
74
|
+
methodType: string;
|
|
75
|
+
cardBrand: string | null;
|
|
76
|
+
cardLastFour: string | null;
|
|
77
|
+
cardExpMonth: number | null;
|
|
78
|
+
cardExpYear: number | null;
|
|
79
|
+
isDefault: boolean;
|
|
80
|
+
createdAt: string;
|
|
81
|
+
}
|
|
82
|
+
interface Order {
|
|
83
|
+
id: string;
|
|
84
|
+
orderNumber: string;
|
|
85
|
+
status: string;
|
|
86
|
+
type: string;
|
|
87
|
+
paymentStatus: string;
|
|
88
|
+
currency: string;
|
|
89
|
+
subtotal: number;
|
|
90
|
+
taxTotal: number;
|
|
91
|
+
discountTotal: number;
|
|
92
|
+
shippingTotal: number;
|
|
93
|
+
total: number;
|
|
94
|
+
buyerVatNumber: string | null;
|
|
95
|
+
taxReverseCharge: boolean;
|
|
96
|
+
billingAddress: unknown | null;
|
|
97
|
+
shippingAddress: unknown | null;
|
|
98
|
+
discountCode: string | null;
|
|
99
|
+
subscriptionId: string | null;
|
|
100
|
+
cancelledAt: string | null;
|
|
101
|
+
completedAt: string | null;
|
|
102
|
+
closedAt: string | null;
|
|
103
|
+
createdAt: string;
|
|
104
|
+
updatedAt: string;
|
|
105
|
+
}
|
|
106
|
+
interface Invoice {
|
|
107
|
+
id: string;
|
|
108
|
+
number: string;
|
|
109
|
+
status: string;
|
|
110
|
+
currency: string;
|
|
111
|
+
subtotal: number;
|
|
112
|
+
taxTotal: number;
|
|
113
|
+
shippingTotal: number;
|
|
114
|
+
discountTotal: number;
|
|
115
|
+
total: number;
|
|
116
|
+
amountRefunded: number;
|
|
117
|
+
issuedAt: string;
|
|
118
|
+
dueAt: string | null;
|
|
119
|
+
periodStart: string | null;
|
|
120
|
+
periodEnd: string | null;
|
|
121
|
+
createdAt: string;
|
|
122
|
+
updatedAt: string;
|
|
123
|
+
}
|
|
124
|
+
interface Subscription {
|
|
125
|
+
id: string;
|
|
126
|
+
status: string;
|
|
127
|
+
planReference: string;
|
|
128
|
+
planName: string | null;
|
|
129
|
+
interval: string;
|
|
130
|
+
amount: number;
|
|
131
|
+
quantity: number;
|
|
132
|
+
currency: string;
|
|
133
|
+
currentPeriodStart: string;
|
|
134
|
+
currentPeriodEnd: string;
|
|
135
|
+
trialEnd: string | null;
|
|
136
|
+
cancelledAt: string | null;
|
|
137
|
+
cancelAtPeriodEnd: boolean;
|
|
138
|
+
pendingPlanReference: string | null;
|
|
139
|
+
pendingPlanName: string | null;
|
|
140
|
+
pendingInterval: string | null;
|
|
141
|
+
pendingQuantity: number | null;
|
|
142
|
+
pausedAt: string | null;
|
|
143
|
+
lastPaymentAt: string | null;
|
|
144
|
+
createdAt: string;
|
|
145
|
+
updatedAt: string;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
type AuthStatus = 'loading' | 'authenticated' | 'unauthenticated';
|
|
149
|
+
interface AuthSnapshot {
|
|
150
|
+
status: AuthStatus;
|
|
151
|
+
customer: Customer | null;
|
|
152
|
+
/**
|
|
153
|
+
* False here does NOT only mean "we emailed them and they have not clicked".
|
|
154
|
+
* While it is false the API may also be withholding pre-existing account
|
|
155
|
+
* data behind the claim cutoff — empty order lists and a 403 on `PATCH /me`
|
|
156
|
+
* are expected, not broken. See the plan header.
|
|
157
|
+
*/
|
|
158
|
+
emailVerified: boolean;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
interface DeviceSession {
|
|
162
|
+
id: string;
|
|
163
|
+
userAgent: string | null;
|
|
164
|
+
ipPrefix: string | null;
|
|
165
|
+
createdAt: string;
|
|
166
|
+
lastUsedAt: string;
|
|
167
|
+
current: boolean;
|
|
168
|
+
}
|
|
169
|
+
interface ThrottleAuth {
|
|
170
|
+
register(email: string, password: string): Promise<{
|
|
171
|
+
status: 'active' | 'pending';
|
|
172
|
+
}>;
|
|
173
|
+
signIn(email: string, password: string): Promise<void>;
|
|
174
|
+
signOut(): Promise<void>;
|
|
175
|
+
signOutEverywhere(): Promise<void>;
|
|
176
|
+
restore(): Promise<void>;
|
|
177
|
+
getSnapshot(): AuthSnapshot;
|
|
178
|
+
subscribe(fn: (s: AuthSnapshot) => void): () => void;
|
|
179
|
+
stepUp(password: string): Promise<void>;
|
|
180
|
+
call<T = any>(method: string, path: string, body?: unknown): Promise<T>;
|
|
181
|
+
verifyEmail(token: string): Promise<void>;
|
|
182
|
+
resendVerification(): Promise<void>;
|
|
183
|
+
forgotPassword(email: string): Promise<void>;
|
|
184
|
+
resetPassword(token: string, password: string): Promise<void>;
|
|
185
|
+
changePassword(password: string): Promise<void>;
|
|
186
|
+
listSessions(): Promise<DeviceSession[]>;
|
|
187
|
+
revokeSession(id: string): Promise<void>;
|
|
188
|
+
}
|
|
189
|
+
declare function createThrottleAuth(config: ThrottleAuthConfig): ThrottleAuth;
|
|
190
|
+
|
|
191
|
+
declare class ThrottleAuthError extends Error {
|
|
192
|
+
readonly code: string;
|
|
193
|
+
readonly statusCode: number;
|
|
194
|
+
readonly retryAfter?: number;
|
|
195
|
+
readonly details?: unknown;
|
|
196
|
+
constructor(args: {
|
|
197
|
+
code: string;
|
|
198
|
+
message: string;
|
|
199
|
+
statusCode: number;
|
|
200
|
+
retryAfter?: number;
|
|
201
|
+
details?: unknown;
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
declare function memoryStorage(): AuthStorage;
|
|
206
|
+
/**
|
|
207
|
+
* localStorage when it works, memory when it does not. Safari private mode,
|
|
208
|
+
* hardened browser settings and server-side rendering all make localStorage
|
|
209
|
+
* either absent or throwing; none of them may take the storefront down.
|
|
210
|
+
*/
|
|
211
|
+
declare function localStorageAdapter(): AuthStorage;
|
|
212
|
+
|
|
213
|
+
interface Page {
|
|
214
|
+
cursor?: string;
|
|
215
|
+
limit?: number;
|
|
216
|
+
}
|
|
217
|
+
interface ThrottleAccount {
|
|
218
|
+
getProfile(): Promise<Customer>;
|
|
219
|
+
updateProfile(patch: ProfilePatch): Promise<Customer>;
|
|
220
|
+
listAddresses(): Promise<Address[]>;
|
|
221
|
+
createAddress(input: AddressInput): Promise<Address>;
|
|
222
|
+
updateAddress(id: string, patch: Partial<AddressInput>): Promise<Address>;
|
|
223
|
+
deleteAddress(id: string): Promise<void>;
|
|
224
|
+
listPaymentMethods(): Promise<PaymentMethod[]>;
|
|
225
|
+
setDefaultPaymentMethod(id: string): Promise<PaymentMethod>;
|
|
226
|
+
deletePaymentMethod(id: string): Promise<void>;
|
|
227
|
+
listOrders(page?: Page): Promise<Order[]>;
|
|
228
|
+
getOrder(id: string): Promise<Order>;
|
|
229
|
+
listInvoices(page?: Page): Promise<Invoice[]>;
|
|
230
|
+
getInvoice(id: string): Promise<Invoice>;
|
|
231
|
+
listSubscriptions(page?: Page): Promise<Subscription[]>;
|
|
232
|
+
getSubscription(id: string): Promise<Subscription>;
|
|
233
|
+
cancelSubscription(id: string, opts?: {
|
|
234
|
+
atPeriodEnd?: boolean;
|
|
235
|
+
}): Promise<Subscription>;
|
|
236
|
+
pauseSubscription(id: string): Promise<Subscription>;
|
|
237
|
+
resumeSubscription(id: string): Promise<Subscription>;
|
|
238
|
+
claimCart(cartId: string): Promise<{
|
|
239
|
+
cartId: string;
|
|
240
|
+
customerId: string;
|
|
241
|
+
}>;
|
|
242
|
+
}
|
|
243
|
+
declare function createAccount(auth: ThrottleAuth): ThrottleAccount;
|
|
244
|
+
|
|
245
|
+
export { type Address, type AddressInput, type AuthSnapshot, type AuthStatus, type AuthStorage, type Customer, type DeviceSession, type Invoice, type Order, type Page, type PaymentMethod, type ProfilePatch, type Session, type Subscription, type ThrottleAccount, type ThrottleAuth, type ThrottleAuthConfig, ThrottleAuthError, createAccount, createThrottleAuth, localStorageAdapter, memoryStorage };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
interface Customer {
|
|
2
|
+
id: string;
|
|
3
|
+
email: string;
|
|
4
|
+
emailVerified: boolean;
|
|
5
|
+
firstName?: string | null;
|
|
6
|
+
lastName?: string | null;
|
|
7
|
+
phone?: string | null;
|
|
8
|
+
company?: string | null;
|
|
9
|
+
acceptsMarketing?: boolean;
|
|
10
|
+
}
|
|
11
|
+
interface Session {
|
|
12
|
+
accessToken: string;
|
|
13
|
+
expiresAt: string;
|
|
14
|
+
refreshToken: string;
|
|
15
|
+
customer: Customer;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Defined here rather than in `storage.ts` so `ThrottleAuthConfig` can name it
|
|
19
|
+
* without importing a module that does not exist until Task 2. `storage.ts`
|
|
20
|
+
* imports and re-exports it.
|
|
21
|
+
*/
|
|
22
|
+
interface AuthStorage {
|
|
23
|
+
get(key: string): string | null | Promise<string | null>;
|
|
24
|
+
set(key: string, value: string): void | Promise<void>;
|
|
25
|
+
remove(key: string): void | Promise<void>;
|
|
26
|
+
}
|
|
27
|
+
interface ThrottleAuthConfig {
|
|
28
|
+
publishableKey: string;
|
|
29
|
+
baseUrl?: string;
|
|
30
|
+
storage?: AuthStorage;
|
|
31
|
+
/** Called when a route needs a step-up proof. Return the buyer's password, or null to cancel. */
|
|
32
|
+
onStepUpRequired?: () => Promise<string | null>;
|
|
33
|
+
}
|
|
34
|
+
interface ProfilePatch {
|
|
35
|
+
firstName?: string;
|
|
36
|
+
lastName?: string;
|
|
37
|
+
phone?: string;
|
|
38
|
+
company?: string | null;
|
|
39
|
+
acceptsMarketing?: boolean;
|
|
40
|
+
}
|
|
41
|
+
interface AddressInput {
|
|
42
|
+
label?: string;
|
|
43
|
+
firstName?: string;
|
|
44
|
+
lastName?: string;
|
|
45
|
+
company?: string;
|
|
46
|
+
addressLine1: string;
|
|
47
|
+
addressLine2?: string;
|
|
48
|
+
city: string;
|
|
49
|
+
stateProvince?: string;
|
|
50
|
+
postalCode?: string;
|
|
51
|
+
countryCode: string;
|
|
52
|
+
phone?: string;
|
|
53
|
+
isDefault?: boolean;
|
|
54
|
+
}
|
|
55
|
+
interface Address {
|
|
56
|
+
id: string;
|
|
57
|
+
label: string | null;
|
|
58
|
+
firstName: string | null;
|
|
59
|
+
lastName: string | null;
|
|
60
|
+
company: string | null;
|
|
61
|
+
addressLine1: string;
|
|
62
|
+
addressLine2: string | null;
|
|
63
|
+
city: string;
|
|
64
|
+
stateProvince: string | null;
|
|
65
|
+
postalCode: string | null;
|
|
66
|
+
countryCode: string;
|
|
67
|
+
phone: string | null;
|
|
68
|
+
isDefault: boolean;
|
|
69
|
+
createdAt: string;
|
|
70
|
+
updatedAt: string;
|
|
71
|
+
}
|
|
72
|
+
interface PaymentMethod {
|
|
73
|
+
id: string;
|
|
74
|
+
methodType: string;
|
|
75
|
+
cardBrand: string | null;
|
|
76
|
+
cardLastFour: string | null;
|
|
77
|
+
cardExpMonth: number | null;
|
|
78
|
+
cardExpYear: number | null;
|
|
79
|
+
isDefault: boolean;
|
|
80
|
+
createdAt: string;
|
|
81
|
+
}
|
|
82
|
+
interface Order {
|
|
83
|
+
id: string;
|
|
84
|
+
orderNumber: string;
|
|
85
|
+
status: string;
|
|
86
|
+
type: string;
|
|
87
|
+
paymentStatus: string;
|
|
88
|
+
currency: string;
|
|
89
|
+
subtotal: number;
|
|
90
|
+
taxTotal: number;
|
|
91
|
+
discountTotal: number;
|
|
92
|
+
shippingTotal: number;
|
|
93
|
+
total: number;
|
|
94
|
+
buyerVatNumber: string | null;
|
|
95
|
+
taxReverseCharge: boolean;
|
|
96
|
+
billingAddress: unknown | null;
|
|
97
|
+
shippingAddress: unknown | null;
|
|
98
|
+
discountCode: string | null;
|
|
99
|
+
subscriptionId: string | null;
|
|
100
|
+
cancelledAt: string | null;
|
|
101
|
+
completedAt: string | null;
|
|
102
|
+
closedAt: string | null;
|
|
103
|
+
createdAt: string;
|
|
104
|
+
updatedAt: string;
|
|
105
|
+
}
|
|
106
|
+
interface Invoice {
|
|
107
|
+
id: string;
|
|
108
|
+
number: string;
|
|
109
|
+
status: string;
|
|
110
|
+
currency: string;
|
|
111
|
+
subtotal: number;
|
|
112
|
+
taxTotal: number;
|
|
113
|
+
shippingTotal: number;
|
|
114
|
+
discountTotal: number;
|
|
115
|
+
total: number;
|
|
116
|
+
amountRefunded: number;
|
|
117
|
+
issuedAt: string;
|
|
118
|
+
dueAt: string | null;
|
|
119
|
+
periodStart: string | null;
|
|
120
|
+
periodEnd: string | null;
|
|
121
|
+
createdAt: string;
|
|
122
|
+
updatedAt: string;
|
|
123
|
+
}
|
|
124
|
+
interface Subscription {
|
|
125
|
+
id: string;
|
|
126
|
+
status: string;
|
|
127
|
+
planReference: string;
|
|
128
|
+
planName: string | null;
|
|
129
|
+
interval: string;
|
|
130
|
+
amount: number;
|
|
131
|
+
quantity: number;
|
|
132
|
+
currency: string;
|
|
133
|
+
currentPeriodStart: string;
|
|
134
|
+
currentPeriodEnd: string;
|
|
135
|
+
trialEnd: string | null;
|
|
136
|
+
cancelledAt: string | null;
|
|
137
|
+
cancelAtPeriodEnd: boolean;
|
|
138
|
+
pendingPlanReference: string | null;
|
|
139
|
+
pendingPlanName: string | null;
|
|
140
|
+
pendingInterval: string | null;
|
|
141
|
+
pendingQuantity: number | null;
|
|
142
|
+
pausedAt: string | null;
|
|
143
|
+
lastPaymentAt: string | null;
|
|
144
|
+
createdAt: string;
|
|
145
|
+
updatedAt: string;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
type AuthStatus = 'loading' | 'authenticated' | 'unauthenticated';
|
|
149
|
+
interface AuthSnapshot {
|
|
150
|
+
status: AuthStatus;
|
|
151
|
+
customer: Customer | null;
|
|
152
|
+
/**
|
|
153
|
+
* False here does NOT only mean "we emailed them and they have not clicked".
|
|
154
|
+
* While it is false the API may also be withholding pre-existing account
|
|
155
|
+
* data behind the claim cutoff — empty order lists and a 403 on `PATCH /me`
|
|
156
|
+
* are expected, not broken. See the plan header.
|
|
157
|
+
*/
|
|
158
|
+
emailVerified: boolean;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
interface DeviceSession {
|
|
162
|
+
id: string;
|
|
163
|
+
userAgent: string | null;
|
|
164
|
+
ipPrefix: string | null;
|
|
165
|
+
createdAt: string;
|
|
166
|
+
lastUsedAt: string;
|
|
167
|
+
current: boolean;
|
|
168
|
+
}
|
|
169
|
+
interface ThrottleAuth {
|
|
170
|
+
register(email: string, password: string): Promise<{
|
|
171
|
+
status: 'active' | 'pending';
|
|
172
|
+
}>;
|
|
173
|
+
signIn(email: string, password: string): Promise<void>;
|
|
174
|
+
signOut(): Promise<void>;
|
|
175
|
+
signOutEverywhere(): Promise<void>;
|
|
176
|
+
restore(): Promise<void>;
|
|
177
|
+
getSnapshot(): AuthSnapshot;
|
|
178
|
+
subscribe(fn: (s: AuthSnapshot) => void): () => void;
|
|
179
|
+
stepUp(password: string): Promise<void>;
|
|
180
|
+
call<T = any>(method: string, path: string, body?: unknown): Promise<T>;
|
|
181
|
+
verifyEmail(token: string): Promise<void>;
|
|
182
|
+
resendVerification(): Promise<void>;
|
|
183
|
+
forgotPassword(email: string): Promise<void>;
|
|
184
|
+
resetPassword(token: string, password: string): Promise<void>;
|
|
185
|
+
changePassword(password: string): Promise<void>;
|
|
186
|
+
listSessions(): Promise<DeviceSession[]>;
|
|
187
|
+
revokeSession(id: string): Promise<void>;
|
|
188
|
+
}
|
|
189
|
+
declare function createThrottleAuth(config: ThrottleAuthConfig): ThrottleAuth;
|
|
190
|
+
|
|
191
|
+
declare class ThrottleAuthError extends Error {
|
|
192
|
+
readonly code: string;
|
|
193
|
+
readonly statusCode: number;
|
|
194
|
+
readonly retryAfter?: number;
|
|
195
|
+
readonly details?: unknown;
|
|
196
|
+
constructor(args: {
|
|
197
|
+
code: string;
|
|
198
|
+
message: string;
|
|
199
|
+
statusCode: number;
|
|
200
|
+
retryAfter?: number;
|
|
201
|
+
details?: unknown;
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
declare function memoryStorage(): AuthStorage;
|
|
206
|
+
/**
|
|
207
|
+
* localStorage when it works, memory when it does not. Safari private mode,
|
|
208
|
+
* hardened browser settings and server-side rendering all make localStorage
|
|
209
|
+
* either absent or throwing; none of them may take the storefront down.
|
|
210
|
+
*/
|
|
211
|
+
declare function localStorageAdapter(): AuthStorage;
|
|
212
|
+
|
|
213
|
+
interface Page {
|
|
214
|
+
cursor?: string;
|
|
215
|
+
limit?: number;
|
|
216
|
+
}
|
|
217
|
+
interface ThrottleAccount {
|
|
218
|
+
getProfile(): Promise<Customer>;
|
|
219
|
+
updateProfile(patch: ProfilePatch): Promise<Customer>;
|
|
220
|
+
listAddresses(): Promise<Address[]>;
|
|
221
|
+
createAddress(input: AddressInput): Promise<Address>;
|
|
222
|
+
updateAddress(id: string, patch: Partial<AddressInput>): Promise<Address>;
|
|
223
|
+
deleteAddress(id: string): Promise<void>;
|
|
224
|
+
listPaymentMethods(): Promise<PaymentMethod[]>;
|
|
225
|
+
setDefaultPaymentMethod(id: string): Promise<PaymentMethod>;
|
|
226
|
+
deletePaymentMethod(id: string): Promise<void>;
|
|
227
|
+
listOrders(page?: Page): Promise<Order[]>;
|
|
228
|
+
getOrder(id: string): Promise<Order>;
|
|
229
|
+
listInvoices(page?: Page): Promise<Invoice[]>;
|
|
230
|
+
getInvoice(id: string): Promise<Invoice>;
|
|
231
|
+
listSubscriptions(page?: Page): Promise<Subscription[]>;
|
|
232
|
+
getSubscription(id: string): Promise<Subscription>;
|
|
233
|
+
cancelSubscription(id: string, opts?: {
|
|
234
|
+
atPeriodEnd?: boolean;
|
|
235
|
+
}): Promise<Subscription>;
|
|
236
|
+
pauseSubscription(id: string): Promise<Subscription>;
|
|
237
|
+
resumeSubscription(id: string): Promise<Subscription>;
|
|
238
|
+
claimCart(cartId: string): Promise<{
|
|
239
|
+
cartId: string;
|
|
240
|
+
customerId: string;
|
|
241
|
+
}>;
|
|
242
|
+
}
|
|
243
|
+
declare function createAccount(auth: ThrottleAuth): ThrottleAccount;
|
|
244
|
+
|
|
245
|
+
export { type Address, type AddressInput, type AuthSnapshot, type AuthStatus, type AuthStorage, type Customer, type DeviceSession, type Invoice, type Order, type Page, type PaymentMethod, type ProfilePatch, type Session, type Subscription, type ThrottleAccount, type ThrottleAuth, type ThrottleAuthConfig, ThrottleAuthError, createAccount, createThrottleAuth, localStorageAdapter, memoryStorage };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import "./chunk-ZMNCURDE.js";
|
|
2
|
+
import {
|
|
3
|
+
ThrottleAuthError,
|
|
4
|
+
createAccount,
|
|
5
|
+
createThrottleAuth,
|
|
6
|
+
localStorageAdapter,
|
|
7
|
+
memoryStorage
|
|
8
|
+
} from "./chunk-NQU7HM23.js";
|
|
9
|
+
export {
|
|
10
|
+
ThrottleAuthError,
|
|
11
|
+
createAccount,
|
|
12
|
+
createThrottleAuth,
|
|
13
|
+
localStorageAdapter,
|
|
14
|
+
memoryStorage
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|