azirid-react 0.6.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/README.md +1311 -0
- package/dist/index.cjs +3333 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1570 -0
- package/dist/index.d.ts +1570 -0
- package/dist/index.js +3275 -0
- package/dist/index.js.map +1 -0
- package/dist/next.cjs +189 -0
- package/dist/next.cjs.map +1 -0
- package/dist/next.d.cts +180 -0
- package/dist/next.d.ts +180 -0
- package/dist/next.js +175 -0
- package/dist/next.js.map +1 -0
- package/dist/server.cjs +58 -0
- package/dist/server.cjs.map +1 -0
- package/dist/server.d.cts +102 -0
- package/dist/server.d.ts +102 -0
- package/dist/server.js +55 -0
- package/dist/server.js.map +1 -0
- package/dist/styles.css +2 -0
- package/package.json +114 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,1570 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ReactNode, CSSProperties, FormEvent } from 'react';
|
|
3
|
+
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
4
|
+
import { UseMutationResult, UseQueryResult } from '@tanstack/react-query';
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
7
|
+
import { ClassValue } from 'clsx';
|
|
8
|
+
|
|
9
|
+
interface AuthUser {
|
|
10
|
+
id: string;
|
|
11
|
+
email: string;
|
|
12
|
+
firstName?: string;
|
|
13
|
+
lastName?: string;
|
|
14
|
+
emailVerified: boolean;
|
|
15
|
+
mfaEnabled?: boolean;
|
|
16
|
+
appId?: string;
|
|
17
|
+
tenantId?: string;
|
|
18
|
+
workspaceId?: string;
|
|
19
|
+
environment?: 'development' | 'production';
|
|
20
|
+
mustChangePassword?: boolean;
|
|
21
|
+
publicMetadata?: Record<string, unknown> | null;
|
|
22
|
+
unsafeMetadata?: Record<string, unknown> | null;
|
|
23
|
+
[key: string]: unknown;
|
|
24
|
+
}
|
|
25
|
+
interface AuthSuccessResponse {
|
|
26
|
+
accessToken: string;
|
|
27
|
+
user: AuthUser;
|
|
28
|
+
}
|
|
29
|
+
interface AuthState {
|
|
30
|
+
user: AuthUser | null;
|
|
31
|
+
accessToken: string | null;
|
|
32
|
+
isAuthenticated: boolean;
|
|
33
|
+
isLoading: boolean;
|
|
34
|
+
error: string | null;
|
|
35
|
+
}
|
|
36
|
+
interface SignupData {
|
|
37
|
+
email: string;
|
|
38
|
+
password: string;
|
|
39
|
+
acceptedTosVersion?: string;
|
|
40
|
+
acceptedPrivacyVersion?: string;
|
|
41
|
+
unsafeMetadata?: Record<string, unknown>;
|
|
42
|
+
referralCode?: string;
|
|
43
|
+
}
|
|
44
|
+
interface SocialLoginData {
|
|
45
|
+
provider: 'google' | 'github';
|
|
46
|
+
providerAccountId: string;
|
|
47
|
+
email: string;
|
|
48
|
+
emailVerified?: boolean;
|
|
49
|
+
firstName?: string;
|
|
50
|
+
lastName?: string;
|
|
51
|
+
createUserIfNotExists?: boolean;
|
|
52
|
+
turnstileToken?: string;
|
|
53
|
+
acceptedTosVersion?: string;
|
|
54
|
+
acceptedPrivacyVersion?: string;
|
|
55
|
+
}
|
|
56
|
+
interface ChangePasswordData {
|
|
57
|
+
currentPassword: string;
|
|
58
|
+
newPassword: string;
|
|
59
|
+
}
|
|
60
|
+
interface AppBranding {
|
|
61
|
+
displayName?: string | null;
|
|
62
|
+
logoUrl?: string | null;
|
|
63
|
+
faviconUrl?: string | null;
|
|
64
|
+
primaryColor?: string | null;
|
|
65
|
+
accentColor?: string | null;
|
|
66
|
+
removeBranding?: boolean;
|
|
67
|
+
}
|
|
68
|
+
type SupportedLocale = 'es' | 'en';
|
|
69
|
+
interface AccessMessages {
|
|
70
|
+
login: {
|
|
71
|
+
title: string;
|
|
72
|
+
description: string;
|
|
73
|
+
submit: string;
|
|
74
|
+
emailLabel: string;
|
|
75
|
+
emailPlaceholder: string;
|
|
76
|
+
passwordLabel: string;
|
|
77
|
+
passwordPlaceholder: string;
|
|
78
|
+
};
|
|
79
|
+
signup: {
|
|
80
|
+
title: string;
|
|
81
|
+
description: string;
|
|
82
|
+
submit: string;
|
|
83
|
+
emailLabel: string;
|
|
84
|
+
emailPlaceholder: string;
|
|
85
|
+
passwordLabel: string;
|
|
86
|
+
passwordPlaceholder: string;
|
|
87
|
+
confirmPasswordLabel: string;
|
|
88
|
+
confirmPasswordPlaceholder: string;
|
|
89
|
+
};
|
|
90
|
+
forgotPassword: {
|
|
91
|
+
title: string;
|
|
92
|
+
description: string;
|
|
93
|
+
submit: string;
|
|
94
|
+
emailLabel: string;
|
|
95
|
+
emailPlaceholder: string;
|
|
96
|
+
successMessage: string;
|
|
97
|
+
};
|
|
98
|
+
resetPassword: {
|
|
99
|
+
title: string;
|
|
100
|
+
description: string;
|
|
101
|
+
submit: string;
|
|
102
|
+
newPasswordLabel: string;
|
|
103
|
+
newPasswordPlaceholder: string;
|
|
104
|
+
confirmPasswordLabel: string;
|
|
105
|
+
confirmPasswordPlaceholder: string;
|
|
106
|
+
};
|
|
107
|
+
social: {
|
|
108
|
+
google: string;
|
|
109
|
+
apple: string;
|
|
110
|
+
separator: string;
|
|
111
|
+
comingSoon: string;
|
|
112
|
+
};
|
|
113
|
+
passwordToggle: {
|
|
114
|
+
show: string;
|
|
115
|
+
hide: string;
|
|
116
|
+
};
|
|
117
|
+
securedBy: string;
|
|
118
|
+
billing: {
|
|
119
|
+
pay: string;
|
|
120
|
+
selectPaymentMethod: string;
|
|
121
|
+
creditCard: string;
|
|
122
|
+
paypal: string;
|
|
123
|
+
payphone: string;
|
|
124
|
+
bankTransfer: string;
|
|
125
|
+
cancel: string;
|
|
126
|
+
processing: string;
|
|
127
|
+
};
|
|
128
|
+
validation: {
|
|
129
|
+
emailRequired: string;
|
|
130
|
+
emailInvalid: string;
|
|
131
|
+
passwordRequired: string;
|
|
132
|
+
passwordMinLength: string;
|
|
133
|
+
confirmPasswordRequired: string;
|
|
134
|
+
passwordsMismatch: string;
|
|
135
|
+
tokenRequired: string;
|
|
136
|
+
newPasswordRequired: string;
|
|
137
|
+
currentPasswordRequired: string;
|
|
138
|
+
mfaCodeRequired: string;
|
|
139
|
+
mfaCodeLength: string;
|
|
140
|
+
providerRequired: string;
|
|
141
|
+
providerIdRequired: string;
|
|
142
|
+
urlInvalid: string;
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
type BootstrapResponse = {
|
|
146
|
+
authenticated: true;
|
|
147
|
+
accessToken: string;
|
|
148
|
+
user: AuthUser;
|
|
149
|
+
branding?: AppBranding;
|
|
150
|
+
} | {
|
|
151
|
+
authenticated: false;
|
|
152
|
+
branding?: AppBranding;
|
|
153
|
+
};
|
|
154
|
+
interface PasskeyItem {
|
|
155
|
+
id: string;
|
|
156
|
+
deviceName?: string;
|
|
157
|
+
credentialId: string;
|
|
158
|
+
createdAt: string;
|
|
159
|
+
lastUsedAt?: string;
|
|
160
|
+
}
|
|
161
|
+
interface PasskeyRegisterStartData {
|
|
162
|
+
deviceName?: string;
|
|
163
|
+
}
|
|
164
|
+
interface PasskeyRegisterStartResponse {
|
|
165
|
+
challengeId: string;
|
|
166
|
+
options: unknown;
|
|
167
|
+
}
|
|
168
|
+
interface PasskeyRegisterVerifyData {
|
|
169
|
+
challengeId: string;
|
|
170
|
+
credential: unknown;
|
|
171
|
+
}
|
|
172
|
+
interface PasskeyLoginStartData {
|
|
173
|
+
tenantId?: string;
|
|
174
|
+
}
|
|
175
|
+
interface PasskeyLoginStartResponse {
|
|
176
|
+
challengeId: string;
|
|
177
|
+
options: unknown;
|
|
178
|
+
}
|
|
179
|
+
interface PasskeyLoginVerifyData {
|
|
180
|
+
challengeId: string;
|
|
181
|
+
credential: unknown;
|
|
182
|
+
tenantId?: string;
|
|
183
|
+
}
|
|
184
|
+
interface PasskeyLoginData {
|
|
185
|
+
credentialId: string;
|
|
186
|
+
tenantId?: string;
|
|
187
|
+
}
|
|
188
|
+
interface RegisterPasskeyData {
|
|
189
|
+
credentialId: string;
|
|
190
|
+
publicKey: string;
|
|
191
|
+
deviceName?: string;
|
|
192
|
+
}
|
|
193
|
+
interface AziridProviderProps {
|
|
194
|
+
children: ReactNode;
|
|
195
|
+
/**
|
|
196
|
+
* Azirid API URL for **direct mode** (requests go straight to the API).
|
|
197
|
+
*
|
|
198
|
+
* - **Omitted** → proxy mode (recommended for Next.js). Requests go to
|
|
199
|
+
* your app's `/api/auth/*` route handler which proxies them securely.
|
|
200
|
+
* Cookies are first-party. No CORS needed.
|
|
201
|
+
*
|
|
202
|
+
* - **Set** → direct mode. Requests go directly to this URL.
|
|
203
|
+
* Requires CORS configured on the API.
|
|
204
|
+
*
|
|
205
|
+
* @example Direct mode (React SPA / Vite)
|
|
206
|
+
* ```tsx
|
|
207
|
+
* <AziridProvider apiUrl="https://api.azirid.com" publishableKey="pk_live_...">
|
|
208
|
+
* ```
|
|
209
|
+
*
|
|
210
|
+
* @example Proxy mode (Next.js — recommended)
|
|
211
|
+
* ```tsx
|
|
212
|
+
* <AziridProvider publishableKey="pk_live_...">
|
|
213
|
+
* ```
|
|
214
|
+
*/
|
|
215
|
+
apiUrl?: string;
|
|
216
|
+
/** Extra headers to send with every request */
|
|
217
|
+
fetchOptions?: Record<string, string>;
|
|
218
|
+
/** Callback after successful login */
|
|
219
|
+
onLoginSuccess?: (response: AuthSuccessResponse) => void;
|
|
220
|
+
/** Callback after successful signup */
|
|
221
|
+
onSignupSuccess?: (response: AuthSuccessResponse) => void;
|
|
222
|
+
/** Callback after logout */
|
|
223
|
+
onLogoutSuccess?: () => void;
|
|
224
|
+
/** Callback on any auth error */
|
|
225
|
+
onError?: (error: string) => void;
|
|
226
|
+
/** Callback when session expires and refresh fails */
|
|
227
|
+
onSessionExpired?: () => void;
|
|
228
|
+
/** Auto-bootstrap session on mount (default: true) */
|
|
229
|
+
autoBootstrap?: boolean;
|
|
230
|
+
/** Interval in ms for proactive token refresh (default: 50000 = 50 seconds). Set to 0 to disable. */
|
|
231
|
+
refreshInterval?: number;
|
|
232
|
+
/**
|
|
233
|
+
* URL of a local API route to sync the session cookie (for server actions).
|
|
234
|
+
* - In dev mode (pk_dev_*): auto-activates with "/api/auth/session"
|
|
235
|
+
* - In prod mode (pk_live_*): disabled by default
|
|
236
|
+
* - Pass a string to force a custom URL, or false to force disable
|
|
237
|
+
*/
|
|
238
|
+
sessionSyncUrl?: string | false;
|
|
239
|
+
/** Publishable key for the app (e.g. pk_development_a1b2c3...) */
|
|
240
|
+
publishableKey?: string;
|
|
241
|
+
/** Tenant ID for multi-tenant apps */
|
|
242
|
+
tenantId?: string;
|
|
243
|
+
/** Locale for built-in form strings (default: "es") */
|
|
244
|
+
locale?: SupportedLocale;
|
|
245
|
+
/** Override specific message strings */
|
|
246
|
+
messages?: Partial<AccessMessages>;
|
|
247
|
+
}
|
|
248
|
+
interface AziridContextValue extends AuthState {
|
|
249
|
+
/** Shortcut: calls loginMutation.mutate(data) */
|
|
250
|
+
login: (data: {
|
|
251
|
+
email: string;
|
|
252
|
+
password: string;
|
|
253
|
+
}) => void;
|
|
254
|
+
/** Shortcut: calls signupMutation.mutate(data) */
|
|
255
|
+
signup: (data: SignupData) => void;
|
|
256
|
+
/** Shortcut: calls logoutMutation.mutate() */
|
|
257
|
+
logout: () => void;
|
|
258
|
+
clearError: () => void;
|
|
259
|
+
/** Refresh the access token manually */
|
|
260
|
+
refresh: () => Promise<void>;
|
|
261
|
+
/** Update local user state after profile changes */
|
|
262
|
+
setUser: (user: AuthUser | null) => void;
|
|
263
|
+
/** TanStack mutation states */
|
|
264
|
+
isLoginPending: boolean;
|
|
265
|
+
isSignupPending: boolean;
|
|
266
|
+
isBootstrapping: boolean;
|
|
267
|
+
/** Full login mutation — same instance used by LoginForm and useLogin() */
|
|
268
|
+
loginMutation: UseMutationResult<AuthSuccessResponse, Error, {
|
|
269
|
+
email: string;
|
|
270
|
+
password: string;
|
|
271
|
+
}>;
|
|
272
|
+
/** Full signup mutation — same instance used by SignupForm and useSignup() */
|
|
273
|
+
signupMutation: UseMutationResult<AuthSuccessResponse, Error, SignupData>;
|
|
274
|
+
/** Full logout mutation — same instance used by useLogout() */
|
|
275
|
+
logoutMutation: UseMutationResult<unknown, Error, void>;
|
|
276
|
+
}
|
|
277
|
+
interface LoginFormProps {
|
|
278
|
+
/** Override the default onSubmit (uses context login by default) */
|
|
279
|
+
onSubmit?: (data: {
|
|
280
|
+
email: string;
|
|
281
|
+
password: string;
|
|
282
|
+
}) => void | Promise<void>;
|
|
283
|
+
/** Custom Zod schema for validation (overrides default loginSchema) */
|
|
284
|
+
schema?: z.ZodType;
|
|
285
|
+
/** Show a loading spinner / disable the form */
|
|
286
|
+
isLoading?: boolean;
|
|
287
|
+
/** Error message to display */
|
|
288
|
+
error?: string | null;
|
|
289
|
+
/** Custom class name for the root element */
|
|
290
|
+
className?: string;
|
|
291
|
+
/** Inline styles for the root element */
|
|
292
|
+
style?: CSSProperties;
|
|
293
|
+
/** Title displayed above the form */
|
|
294
|
+
title?: string;
|
|
295
|
+
/** Subtitle / description below the title */
|
|
296
|
+
description?: string;
|
|
297
|
+
/** Logo or branding element rendered above the card */
|
|
298
|
+
logo?: ReactNode;
|
|
299
|
+
/** Text for the submit button */
|
|
300
|
+
submitText?: string;
|
|
301
|
+
/** Render a footer below the form */
|
|
302
|
+
footer?: ReactNode;
|
|
303
|
+
/** Render a "forgot password?" link next to the password label */
|
|
304
|
+
forgotPassword?: ReactNode;
|
|
305
|
+
/** Hide the password visibility toggle */
|
|
306
|
+
hidePasswordToggle?: boolean;
|
|
307
|
+
/** Show SSO buttons (Google, Apple) above the form (default: true) */
|
|
308
|
+
showSocialButtons?: boolean;
|
|
309
|
+
/** Labels for i18n */
|
|
310
|
+
labels?: {
|
|
311
|
+
email?: string;
|
|
312
|
+
password?: string;
|
|
313
|
+
emailPlaceholder?: string;
|
|
314
|
+
passwordPlaceholder?: string;
|
|
315
|
+
};
|
|
316
|
+
/** Pre-fill the form fields */
|
|
317
|
+
defaultValues?: {
|
|
318
|
+
email?: string;
|
|
319
|
+
password?: string;
|
|
320
|
+
};
|
|
321
|
+
}
|
|
322
|
+
interface SignupFormProps {
|
|
323
|
+
/** Override the default onSubmit (uses context signup by default) */
|
|
324
|
+
onSubmit?: (data: SignupData) => void | Promise<void>;
|
|
325
|
+
/** Custom Zod schema for validation (overrides default signupSchema) */
|
|
326
|
+
schema?: z.ZodType;
|
|
327
|
+
/** Show a loading spinner / disable the form */
|
|
328
|
+
isLoading?: boolean;
|
|
329
|
+
/** Error message to display */
|
|
330
|
+
error?: string | null;
|
|
331
|
+
/** Custom class name for the root element */
|
|
332
|
+
className?: string;
|
|
333
|
+
/** Inline styles for the root element */
|
|
334
|
+
style?: CSSProperties;
|
|
335
|
+
/** Title displayed above the form */
|
|
336
|
+
title?: string;
|
|
337
|
+
/** Subtitle / description below the title */
|
|
338
|
+
description?: string;
|
|
339
|
+
/** Logo or branding element rendered above the card */
|
|
340
|
+
logo?: ReactNode;
|
|
341
|
+
/** Text for the submit button */
|
|
342
|
+
submitText?: string;
|
|
343
|
+
/** Render a footer below the form */
|
|
344
|
+
footer?: ReactNode;
|
|
345
|
+
/** Hide the password visibility toggle */
|
|
346
|
+
hidePasswordToggle?: boolean;
|
|
347
|
+
/** Show SSO buttons (Google, Apple) above the form (default: true) */
|
|
348
|
+
showSocialButtons?: boolean;
|
|
349
|
+
/** Labels for i18n */
|
|
350
|
+
labels?: {
|
|
351
|
+
email?: string;
|
|
352
|
+
password?: string;
|
|
353
|
+
confirmPassword?: string;
|
|
354
|
+
emailPlaceholder?: string;
|
|
355
|
+
passwordPlaceholder?: string;
|
|
356
|
+
confirmPasswordPlaceholder?: string;
|
|
357
|
+
};
|
|
358
|
+
}
|
|
359
|
+
interface FieldError {
|
|
360
|
+
field: string;
|
|
361
|
+
message: string;
|
|
362
|
+
}
|
|
363
|
+
interface UseFormReturn<T> {
|
|
364
|
+
values: T;
|
|
365
|
+
errors: FieldError[];
|
|
366
|
+
isSubmitting: boolean;
|
|
367
|
+
handleChange: (field: keyof T) => (e: React.ChangeEvent<HTMLInputElement>) => void;
|
|
368
|
+
handleSubmit: (e: FormEvent) => void;
|
|
369
|
+
setFieldValue: (field: keyof T, value: string) => void;
|
|
370
|
+
reset: () => void;
|
|
371
|
+
}
|
|
372
|
+
interface ReferralInfo {
|
|
373
|
+
referralCode: string;
|
|
374
|
+
referralUrl: string;
|
|
375
|
+
totalReferred: number;
|
|
376
|
+
completedReferrals: number;
|
|
377
|
+
pendingReferrals: number;
|
|
378
|
+
}
|
|
379
|
+
interface ReferralStatsData {
|
|
380
|
+
totalReferred: number;
|
|
381
|
+
completedReferrals: number;
|
|
382
|
+
pendingReferrals: number;
|
|
383
|
+
totalRewards: number;
|
|
384
|
+
referrals: ReferralItem[];
|
|
385
|
+
}
|
|
386
|
+
interface ReferralItem {
|
|
387
|
+
id: string;
|
|
388
|
+
referredEmail: string;
|
|
389
|
+
status: 'PENDING' | 'COMPLETED' | 'EXPIRED';
|
|
390
|
+
rewardStatus: 'PENDING' | 'GRANTED' | 'EXPIRED' | 'FAILED';
|
|
391
|
+
rewardAmount?: number;
|
|
392
|
+
createdAt: string;
|
|
393
|
+
completedAt?: string;
|
|
394
|
+
}
|
|
395
|
+
type PaymentProviderType = 'STRIPE' | 'PAYPAL' | 'PAYPHONE' | 'NUVEI' | 'MANUAL_TRANSFER';
|
|
396
|
+
interface AvailableProvider {
|
|
397
|
+
provider: PaymentProviderType;
|
|
398
|
+
checkout: boolean;
|
|
399
|
+
subscriptions: boolean;
|
|
400
|
+
}
|
|
401
|
+
interface PaymentIntent {
|
|
402
|
+
id: string;
|
|
403
|
+
amount: number;
|
|
404
|
+
currency: string;
|
|
405
|
+
description?: string;
|
|
406
|
+
status: 'PENDING' | 'PROCESSING' | 'COMPLETED' | 'EXPIRED' | 'CANCELED';
|
|
407
|
+
expiresAt?: string;
|
|
408
|
+
metadata?: Record<string, unknown>;
|
|
409
|
+
}
|
|
410
|
+
interface BillingPlan {
|
|
411
|
+
id: string;
|
|
412
|
+
name: string;
|
|
413
|
+
slug: string;
|
|
414
|
+
description?: string;
|
|
415
|
+
amount: number;
|
|
416
|
+
currency: string;
|
|
417
|
+
interval: 'MONTHLY' | 'YEARLY' | 'ONE_TIME';
|
|
418
|
+
features?: string[];
|
|
419
|
+
metadata?: Record<string, unknown>;
|
|
420
|
+
sortOrder: number;
|
|
421
|
+
}
|
|
422
|
+
interface UserSubscription {
|
|
423
|
+
id: string;
|
|
424
|
+
planId: string;
|
|
425
|
+
plan: BillingPlan;
|
|
426
|
+
status: 'ACTIVE' | 'TRIALING' | 'PAST_DUE' | 'CANCELED' | 'UNPAID' | 'INCOMPLETE';
|
|
427
|
+
currentPeriodStart?: string;
|
|
428
|
+
currentPeriodEnd?: string;
|
|
429
|
+
cancelAtPeriodEnd: boolean;
|
|
430
|
+
canceledAt?: string;
|
|
431
|
+
trialEnd?: string;
|
|
432
|
+
}
|
|
433
|
+
interface PayphoneWidgetConfig {
|
|
434
|
+
token: string;
|
|
435
|
+
storeId: string;
|
|
436
|
+
clientTransactionId: string;
|
|
437
|
+
amount: number;
|
|
438
|
+
amountWithoutTax: number;
|
|
439
|
+
currency: string;
|
|
440
|
+
reference: string;
|
|
441
|
+
}
|
|
442
|
+
interface CheckoutResponse {
|
|
443
|
+
/** Redirect URL (card providers like Stripe/PayPal) */
|
|
444
|
+
url?: string;
|
|
445
|
+
sessionId?: string;
|
|
446
|
+
/** Set when the response identifies the provider */
|
|
447
|
+
provider?: PaymentProviderType;
|
|
448
|
+
/** Plan details (for MANUAL_TRANSFER and PAYPHONE) */
|
|
449
|
+
plan?: {
|
|
450
|
+
id: string;
|
|
451
|
+
name: string;
|
|
452
|
+
slug: string;
|
|
453
|
+
amount: number;
|
|
454
|
+
currency: string;
|
|
455
|
+
interval: string;
|
|
456
|
+
};
|
|
457
|
+
/** Intent details (for MANUAL_TRANSFER and PAYPHONE) */
|
|
458
|
+
intent?: {
|
|
459
|
+
id: string;
|
|
460
|
+
amount: number;
|
|
461
|
+
currency: string;
|
|
462
|
+
description?: string | null;
|
|
463
|
+
};
|
|
464
|
+
/** Payphone widget configuration (only for PAYPHONE) */
|
|
465
|
+
widgetConfig?: PayphoneWidgetConfig;
|
|
466
|
+
/** Bank account details (only for MANUAL_TRANSFER) */
|
|
467
|
+
bankDetails?: Record<string, unknown> | null;
|
|
468
|
+
/** Instructions for the user (only for MANUAL_TRANSFER) */
|
|
469
|
+
transferInstructions?: string | null;
|
|
470
|
+
}
|
|
471
|
+
interface BillingInvoice {
|
|
472
|
+
id: string;
|
|
473
|
+
amount: number;
|
|
474
|
+
currency: string;
|
|
475
|
+
status: 'PENDING' | 'PAID' | 'FAILED' | 'REFUNDED';
|
|
476
|
+
paidAt?: string;
|
|
477
|
+
invoiceUrl?: string;
|
|
478
|
+
createdAt: string;
|
|
479
|
+
}
|
|
480
|
+
interface SubmitTransferProofData {
|
|
481
|
+
planId: string;
|
|
482
|
+
fileUrl: string;
|
|
483
|
+
fileName?: string;
|
|
484
|
+
fileType?: string;
|
|
485
|
+
amount: number;
|
|
486
|
+
currency?: string;
|
|
487
|
+
notes?: string;
|
|
488
|
+
}
|
|
489
|
+
interface TransferProof {
|
|
490
|
+
id: string;
|
|
491
|
+
planId: string;
|
|
492
|
+
plan?: BillingPlan;
|
|
493
|
+
fileUrl: string;
|
|
494
|
+
fileName?: string;
|
|
495
|
+
fileType?: string;
|
|
496
|
+
amount: number;
|
|
497
|
+
currency: string;
|
|
498
|
+
status: 'PENDING_REVIEW' | 'APPROVED' | 'REJECTED';
|
|
499
|
+
reviewedAt?: string;
|
|
500
|
+
rejectionReason?: string;
|
|
501
|
+
notes?: string;
|
|
502
|
+
createdAt: string;
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
declare const LoginForm: react.ForwardRefExoticComponent<LoginFormProps & react.RefAttributes<HTMLFormElement>>;
|
|
506
|
+
|
|
507
|
+
declare const SignupForm: react.ForwardRefExoticComponent<SignupFormProps & react.RefAttributes<HTMLFormElement>>;
|
|
508
|
+
|
|
509
|
+
interface ReferralCardProps {
|
|
510
|
+
className?: string;
|
|
511
|
+
style?: CSSProperties;
|
|
512
|
+
title?: string;
|
|
513
|
+
description?: string;
|
|
514
|
+
}
|
|
515
|
+
declare function ReferralCard({ className, style, title, description, }: ReferralCardProps): react_jsx_runtime.JSX.Element;
|
|
516
|
+
declare namespace ReferralCard {
|
|
517
|
+
var displayName: string;
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
interface ReferralStatsProps {
|
|
521
|
+
className?: string;
|
|
522
|
+
style?: CSSProperties;
|
|
523
|
+
}
|
|
524
|
+
declare function ReferralStats({ className, style }: ReferralStatsProps): react_jsx_runtime.JSX.Element;
|
|
525
|
+
declare namespace ReferralStats {
|
|
526
|
+
var displayName: string;
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
interface PricingTableProps {
|
|
530
|
+
className?: string;
|
|
531
|
+
style?: CSSProperties;
|
|
532
|
+
successUrl: string;
|
|
533
|
+
cancelUrl: string;
|
|
534
|
+
columns?: number;
|
|
535
|
+
onPlanSelect?: (plan: BillingPlan) => void;
|
|
536
|
+
}
|
|
537
|
+
declare function PricingTable({ className, style, successUrl, cancelUrl, columns, onPlanSelect, }: PricingTableProps): react_jsx_runtime.JSX.Element;
|
|
538
|
+
declare namespace PricingTable {
|
|
539
|
+
var displayName: string;
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
interface CheckoutButtonProps {
|
|
543
|
+
planId: string;
|
|
544
|
+
successUrl: string;
|
|
545
|
+
cancelUrl: string;
|
|
546
|
+
className?: string;
|
|
547
|
+
style?: CSSProperties;
|
|
548
|
+
children?: ReactNode;
|
|
549
|
+
}
|
|
550
|
+
declare function CheckoutButton({ planId, successUrl, cancelUrl, className, style, children, }: CheckoutButtonProps): react_jsx_runtime.JSX.Element;
|
|
551
|
+
declare namespace CheckoutButton {
|
|
552
|
+
var displayName: string;
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
interface PayButtonProps {
|
|
556
|
+
planId?: string;
|
|
557
|
+
intentId?: string;
|
|
558
|
+
successUrl: string;
|
|
559
|
+
cancelUrl: string;
|
|
560
|
+
className?: string;
|
|
561
|
+
style?: CSSProperties;
|
|
562
|
+
children?: ReactNode;
|
|
563
|
+
disabled?: boolean;
|
|
564
|
+
onSuccess?: (data: CheckoutResponse) => void;
|
|
565
|
+
onError?: (error: Error) => void;
|
|
566
|
+
onProviderSelect?: (provider: PaymentProviderType) => void;
|
|
567
|
+
}
|
|
568
|
+
declare function PayButton({ planId, intentId, successUrl, cancelUrl, className, style, children, disabled, onSuccess, onError, onProviderSelect, }: PayButtonProps): react_jsx_runtime.JSX.Element;
|
|
569
|
+
|
|
570
|
+
interface PayphoneCallbackProps {
|
|
571
|
+
onSuccess?: (data: {
|
|
572
|
+
status: string;
|
|
573
|
+
intentId: string;
|
|
574
|
+
}) => void;
|
|
575
|
+
onError?: (error: Error) => void;
|
|
576
|
+
className?: string;
|
|
577
|
+
style?: CSSProperties;
|
|
578
|
+
}
|
|
579
|
+
declare function PayphoneCallback({ onSuccess, onError, className, style, }: PayphoneCallbackProps): react_jsx_runtime.JSX.Element;
|
|
580
|
+
|
|
581
|
+
interface SubscriptionBadgeProps {
|
|
582
|
+
className?: string;
|
|
583
|
+
style?: CSSProperties;
|
|
584
|
+
}
|
|
585
|
+
declare function SubscriptionBadge({ className, style }: SubscriptionBadgeProps): react_jsx_runtime.JSX.Element;
|
|
586
|
+
declare namespace SubscriptionBadge {
|
|
587
|
+
var displayName: string;
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
interface InvoiceListProps {
|
|
591
|
+
className?: string;
|
|
592
|
+
style?: CSSProperties;
|
|
593
|
+
}
|
|
594
|
+
declare function InvoiceList({ className, style }: InvoiceListProps): react_jsx_runtime.JSX.Element;
|
|
595
|
+
declare namespace InvoiceList {
|
|
596
|
+
var displayName: string;
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
/** Error thrown by the API client — carries the HTTP status code. */
|
|
600
|
+
interface ApiError extends Error {
|
|
601
|
+
status: number;
|
|
602
|
+
}
|
|
603
|
+
/** Check if an error is an API auth error (401/403). */
|
|
604
|
+
declare function isAuthError(err: unknown): boolean;
|
|
605
|
+
declare const SUFFIXES: {
|
|
606
|
+
readonly login: "login";
|
|
607
|
+
readonly signup: "signup";
|
|
608
|
+
readonly logout: "logout";
|
|
609
|
+
readonly me: "me";
|
|
610
|
+
readonly refresh: "refresh";
|
|
611
|
+
readonly bootstrap: "session/bootstrap";
|
|
612
|
+
readonly magicLinkRequest: "magic-link/request";
|
|
613
|
+
readonly magicLinkVerify: "magic-link/verify";
|
|
614
|
+
readonly socialLogin: "social/login";
|
|
615
|
+
readonly changePassword: "password/change";
|
|
616
|
+
readonly passkeyLogin: "passkeys/login";
|
|
617
|
+
readonly passkeyLoginStart: "passkeys/login/start";
|
|
618
|
+
readonly passkeyLoginVerify: "passkeys/login/verify";
|
|
619
|
+
readonly passkeyRegisterStart: "passkeys/register/start";
|
|
620
|
+
readonly passkeyRegisterVerify: "passkeys/register/verify";
|
|
621
|
+
readonly passkeys: "passkeys";
|
|
622
|
+
readonly providers: "billing/providers";
|
|
623
|
+
readonly plans: "billing/plans";
|
|
624
|
+
readonly subscription: "billing/subscription";
|
|
625
|
+
readonly checkout: "billing/checkout";
|
|
626
|
+
readonly billingPortal: "billing/portal";
|
|
627
|
+
readonly invoices: "billing/invoices";
|
|
628
|
+
readonly submitTransferProof: "billing/transfer-proof";
|
|
629
|
+
readonly transferProofs: "billing/transfer-proofs";
|
|
630
|
+
readonly payphoneConfirm: "billing/payphone/confirm";
|
|
631
|
+
readonly referralMe: "referrals/me";
|
|
632
|
+
readonly referralStats: "referrals/stats";
|
|
633
|
+
};
|
|
634
|
+
/** Base paths for each mode */
|
|
635
|
+
declare const BASE_PATHS: {
|
|
636
|
+
/** Proxy mode (Next.js): requests go to the same origin via route handler */
|
|
637
|
+
readonly proxy: "/api/auth";
|
|
638
|
+
/** Direct mode: requests go straight to the Azirid API */
|
|
639
|
+
readonly direct: "/v1/users/auth";
|
|
640
|
+
};
|
|
641
|
+
/** Build full path map from a basePath */
|
|
642
|
+
declare function buildPaths(basePath: string): AuthPaths;
|
|
643
|
+
/** Default paths (direct mode — backward compatible) */
|
|
644
|
+
declare const PATHS: AuthPaths;
|
|
645
|
+
type AuthPaths = {
|
|
646
|
+
[K in keyof typeof SUFFIXES]: string;
|
|
647
|
+
};
|
|
648
|
+
interface AccessClientConfig {
|
|
649
|
+
/** Base URL of the Azirid API (empty string for proxy mode) */
|
|
650
|
+
baseUrl: string;
|
|
651
|
+
/**
|
|
652
|
+
* Base path for auth endpoints.
|
|
653
|
+
* - Proxy mode: '/api/auth' (matches Next.js route handler)
|
|
654
|
+
* - Direct mode: '/v1/users/auth' (matches API routes)
|
|
655
|
+
* @default '/v1/users/auth'
|
|
656
|
+
*/
|
|
657
|
+
basePath?: string;
|
|
658
|
+
/** Extra headers (e.g. Authorization) */
|
|
659
|
+
headers?: Record<string, string>;
|
|
660
|
+
}
|
|
661
|
+
interface AccessClient {
|
|
662
|
+
/** HTTP methods */
|
|
663
|
+
post: <T = unknown>(path: string, body?: unknown) => Promise<T>;
|
|
664
|
+
get: <T = unknown>(path: string) => Promise<T>;
|
|
665
|
+
patch: <T = unknown>(path: string, body?: unknown) => Promise<T>;
|
|
666
|
+
del: <T = unknown>(path: string) => Promise<T>;
|
|
667
|
+
/** Resolved paths */
|
|
668
|
+
paths: AuthPaths;
|
|
669
|
+
/** Base URL */
|
|
670
|
+
baseUrl: string;
|
|
671
|
+
/** App context */
|
|
672
|
+
appContext?: {
|
|
673
|
+
publishableKey: string;
|
|
674
|
+
tenantId?: string;
|
|
675
|
+
};
|
|
676
|
+
/** Manually set the access token (used by refresh/bootstrap) */
|
|
677
|
+
setAccessToken: (token: string | null) => void;
|
|
678
|
+
/** Get the current access token */
|
|
679
|
+
getAccessToken: () => string | null;
|
|
680
|
+
/** Store refresh token received from the API body (cross-origin support) */
|
|
681
|
+
setRefreshToken: (token: string | null) => void;
|
|
682
|
+
/** Get the current in-memory refresh token */
|
|
683
|
+
getRefreshToken: () => string | null;
|
|
684
|
+
/** Store CSRF token received from the API body (cross-origin support) */
|
|
685
|
+
setCsrfToken: (token: string | null) => void;
|
|
686
|
+
/** Get the current CSRF token (from memory or cookie) */
|
|
687
|
+
getCsrfToken: () => string | null;
|
|
688
|
+
/** Deduplicated refresh — safe to call from multiple places concurrently */
|
|
689
|
+
refreshSession: () => Promise<void>;
|
|
690
|
+
}
|
|
691
|
+
declare function createAccessClient(config: AccessClientConfig, appContext?: AccessClient['appContext']): AccessClient;
|
|
692
|
+
|
|
693
|
+
/** Access the raw API client for custom calls */
|
|
694
|
+
declare function useAccessClient(): AccessClient;
|
|
695
|
+
/**
|
|
696
|
+
* Get the current app branding from bootstrap.
|
|
697
|
+
* Returns null when no branding is configured.
|
|
698
|
+
*/
|
|
699
|
+
declare function useBranding(): AppBranding | null;
|
|
700
|
+
/**
|
|
701
|
+
* Get resolved i18n messages for the current locale.
|
|
702
|
+
* Falls back to Spanish (es) if no provider is found.
|
|
703
|
+
*/
|
|
704
|
+
declare function useMessages(): AccessMessages;
|
|
705
|
+
declare function AziridProvider(props: AziridProviderProps): react_jsx_runtime.JSX.Element;
|
|
706
|
+
declare function useAzirid(): AziridContextValue;
|
|
707
|
+
|
|
708
|
+
declare const es: AccessMessages;
|
|
709
|
+
|
|
710
|
+
declare const en: AccessMessages;
|
|
711
|
+
|
|
712
|
+
/**
|
|
713
|
+
* Resolve the messages dictionary for a given locale.
|
|
714
|
+
* Optional overrides are shallow-merged per section.
|
|
715
|
+
*/
|
|
716
|
+
declare function resolveMessages(locale?: SupportedLocale, overrides?: Partial<AccessMessages>): AccessMessages;
|
|
717
|
+
|
|
718
|
+
interface LoginData {
|
|
719
|
+
email: string;
|
|
720
|
+
password: string;
|
|
721
|
+
}
|
|
722
|
+
interface UseLoginOptions {
|
|
723
|
+
/** Callback after successful login */
|
|
724
|
+
onSuccess?: (response: AuthSuccessResponse) => void;
|
|
725
|
+
/** Callback on login error */
|
|
726
|
+
onError?: (error: Error) => void;
|
|
727
|
+
}
|
|
728
|
+
type UseLoginReturn = UseMutationResult<AuthSuccessResponse, Error, LoginData> & {
|
|
729
|
+
/** Convenience: call mutate() with consumer callbacks */
|
|
730
|
+
login: (data: LoginData) => void;
|
|
731
|
+
};
|
|
732
|
+
/**
|
|
733
|
+
* Hook for login. Uses the **same mutation** as `<LoginForm>` and
|
|
734
|
+
* `useAzirid().login()`, so the provider state (user, tokens, callbacks)
|
|
735
|
+
* is always in sync.
|
|
736
|
+
*
|
|
737
|
+
* @example
|
|
738
|
+
* ```tsx
|
|
739
|
+
* const { login, isPending, error } = useLogin({
|
|
740
|
+
* onSuccess: (res) => router.push("/dashboard"),
|
|
741
|
+
* onError: (err) => toast.error(err.message),
|
|
742
|
+
* });
|
|
743
|
+
*
|
|
744
|
+
* login({ email: "user@test.com", password: "secret" });
|
|
745
|
+
* ```
|
|
746
|
+
*/
|
|
747
|
+
declare function useLogin(options?: UseLoginOptions): UseLoginReturn;
|
|
748
|
+
|
|
749
|
+
interface UseSignupOptions {
|
|
750
|
+
/** Callback after successful signup */
|
|
751
|
+
onSuccess?: (response: AuthSuccessResponse) => void;
|
|
752
|
+
/** Callback on signup error */
|
|
753
|
+
onError?: (error: Error) => void;
|
|
754
|
+
}
|
|
755
|
+
type UseSignupReturn = UseMutationResult<AuthSuccessResponse, Error, SignupData> & {
|
|
756
|
+
/** Convenience: call mutate() with consumer callbacks */
|
|
757
|
+
signup: (data: SignupData) => void;
|
|
758
|
+
};
|
|
759
|
+
/**
|
|
760
|
+
* Hook for signup. Uses the **same mutation** as `<SignupForm>` and
|
|
761
|
+
* `useAzirid().signup()`, so the provider state (user, tokens, callbacks)
|
|
762
|
+
* is always in sync.
|
|
763
|
+
*
|
|
764
|
+
* @example
|
|
765
|
+
* ```tsx
|
|
766
|
+
* const { signup, isPending, error } = useSignup({
|
|
767
|
+
* onSuccess: (res) => router.push("/welcome"),
|
|
768
|
+
* });
|
|
769
|
+
*
|
|
770
|
+
* signup({ email: "new@user.com", password: "SecurePass10" });
|
|
771
|
+
* ```
|
|
772
|
+
*/
|
|
773
|
+
declare function useSignup(options?: UseSignupOptions): UseSignupReturn;
|
|
774
|
+
|
|
775
|
+
interface UseLogoutOptions {
|
|
776
|
+
/** Callback after successful logout */
|
|
777
|
+
onSuccess?: () => void;
|
|
778
|
+
/** Callback on logout error */
|
|
779
|
+
onError?: (error: Error) => void;
|
|
780
|
+
}
|
|
781
|
+
type UseLogoutReturn = UseMutationResult<unknown, Error, void> & {
|
|
782
|
+
/** Convenience: call mutate() with consumer callbacks */
|
|
783
|
+
logout: () => void;
|
|
784
|
+
};
|
|
785
|
+
/**
|
|
786
|
+
* Hook for logout. Uses the **same mutation** as `useAzirid().logout()`,
|
|
787
|
+
* so the provider state is always in sync.
|
|
788
|
+
*
|
|
789
|
+
* @example
|
|
790
|
+
* ```tsx
|
|
791
|
+
* const { logout, isPending } = useLogout({
|
|
792
|
+
* onSuccess: () => router.push("/login"),
|
|
793
|
+
* });
|
|
794
|
+
*
|
|
795
|
+
* <button onClick={logout}>Cerrar sesión</button>
|
|
796
|
+
* ```
|
|
797
|
+
*/
|
|
798
|
+
declare function useLogout(options?: UseLogoutOptions): UseLogoutReturn;
|
|
799
|
+
|
|
800
|
+
interface UseSessionOptions {
|
|
801
|
+
/** Enable/disable auto-fetching (default: true) */
|
|
802
|
+
enabled?: boolean;
|
|
803
|
+
/** Refetch interval in ms (default: disabled) */
|
|
804
|
+
refetchInterval?: number;
|
|
805
|
+
/** Refetch when window gets focus (default: false) */
|
|
806
|
+
refetchOnWindowFocus?: boolean;
|
|
807
|
+
}
|
|
808
|
+
type UseSessionReturn = UseQueryResult<AuthUser, Error> & {
|
|
809
|
+
/** Shorthand: is the user authenticated? */
|
|
810
|
+
isAuthenticated: boolean;
|
|
811
|
+
};
|
|
812
|
+
/**
|
|
813
|
+
* Standalone hook to fetch the current session (GET /me).
|
|
814
|
+
* Requires `<AziridProvider>`.
|
|
815
|
+
*
|
|
816
|
+
* Useful for:
|
|
817
|
+
* - Checking if the user is still logged in on mount
|
|
818
|
+
* - Getting fresh user data from the server
|
|
819
|
+
* - Bootstrapping auth state on page load
|
|
820
|
+
*
|
|
821
|
+
* @example
|
|
822
|
+
* ```tsx
|
|
823
|
+
* const session = useSession();
|
|
824
|
+
*
|
|
825
|
+
* if (session.isLoading) return <Spinner />;
|
|
826
|
+
* if (!session.isAuthenticated) return <Redirect to="/login" />;
|
|
827
|
+
*
|
|
828
|
+
* return <p>Hola, {session.data?.firstName}</p>;
|
|
829
|
+
* ```
|
|
830
|
+
*/
|
|
831
|
+
declare function useSession(options?: UseSessionOptions): UseSessionReturn;
|
|
832
|
+
|
|
833
|
+
interface MagicLinkRequestData {
|
|
834
|
+
email: string;
|
|
835
|
+
}
|
|
836
|
+
interface MagicLinkVerifyData {
|
|
837
|
+
token: string;
|
|
838
|
+
}
|
|
839
|
+
interface UseMagicLinkOptions {
|
|
840
|
+
/** Callback after magic link email sent */
|
|
841
|
+
onRequestSuccess?: () => void;
|
|
842
|
+
/** Callback after magic link verified (user logged in) */
|
|
843
|
+
onVerifySuccess?: (response: AuthSuccessResponse) => void;
|
|
844
|
+
/** Callback on error */
|
|
845
|
+
onError?: (error: Error) => void;
|
|
846
|
+
}
|
|
847
|
+
interface UseMagicLinkReturn {
|
|
848
|
+
/** Request a magic link email */
|
|
849
|
+
request: UseMutationResult<unknown, Error, MagicLinkRequestData>;
|
|
850
|
+
/** Verify the magic link token */
|
|
851
|
+
verify: UseMutationResult<AuthSuccessResponse, Error, MagicLinkVerifyData>;
|
|
852
|
+
}
|
|
853
|
+
/**
|
|
854
|
+
* Standalone hook for magic link auth flow. Requires `<AziridProvider>`.
|
|
855
|
+
*
|
|
856
|
+
* @example
|
|
857
|
+
* ```tsx
|
|
858
|
+
* const magicLink = useMagicLink({
|
|
859
|
+
* onRequestSuccess: () => toast.success("Revisa tu correo"),
|
|
860
|
+
* onVerifySuccess: (res) => router.push("/dashboard"),
|
|
861
|
+
* });
|
|
862
|
+
*
|
|
863
|
+
* // Step 1: request magic link
|
|
864
|
+
* magicLink.request.mutate({ email: "user@test.com" });
|
|
865
|
+
*
|
|
866
|
+
* // Step 2: verify token (from URL params)
|
|
867
|
+
* magicLink.verify.mutate({ token: searchParams.get("token")! });
|
|
868
|
+
* ```
|
|
869
|
+
*/
|
|
870
|
+
declare function useMagicLink(options?: UseMagicLinkOptions): UseMagicLinkReturn;
|
|
871
|
+
|
|
872
|
+
interface UseSocialLoginOptions {
|
|
873
|
+
/** Callback after successful social login */
|
|
874
|
+
onSuccess?: (response: AuthSuccessResponse) => void;
|
|
875
|
+
/** Callback on error */
|
|
876
|
+
onError?: (error: Error) => void;
|
|
877
|
+
}
|
|
878
|
+
type UseSocialLoginReturn = UseMutationResult<AuthSuccessResponse, Error, SocialLoginData>;
|
|
879
|
+
/**
|
|
880
|
+
* Standalone hook for social login (Google, GitHub). Requires `<AziridProvider>`.
|
|
881
|
+
*
|
|
882
|
+
* @example
|
|
883
|
+
* ```tsx
|
|
884
|
+
* const socialLogin = useSocialLogin({
|
|
885
|
+
* onSuccess: (res) => router.push("/dashboard"),
|
|
886
|
+
* });
|
|
887
|
+
*
|
|
888
|
+
* socialLogin.mutate({
|
|
889
|
+
* provider: "google",
|
|
890
|
+
* providerAccountId: googleUser.id,
|
|
891
|
+
* email: googleUser.email,
|
|
892
|
+
* });
|
|
893
|
+
* ```
|
|
894
|
+
*/
|
|
895
|
+
declare function useSocialLogin(options?: UseSocialLoginOptions): UseSocialLoginReturn;
|
|
896
|
+
|
|
897
|
+
interface UseChangePasswordOptions {
|
|
898
|
+
/** Callback after password changed */
|
|
899
|
+
onSuccess?: (response: {
|
|
900
|
+
updated: boolean;
|
|
901
|
+
}) => void;
|
|
902
|
+
/** Callback on error */
|
|
903
|
+
onError?: (error: Error) => void;
|
|
904
|
+
}
|
|
905
|
+
type UseChangePasswordReturn = UseMutationResult<{
|
|
906
|
+
updated: boolean;
|
|
907
|
+
}, Error, ChangePasswordData>;
|
|
908
|
+
/**
|
|
909
|
+
* Standalone hook for changing password. Requires `<AziridProvider>`.
|
|
910
|
+
*
|
|
911
|
+
* @example
|
|
912
|
+
* ```tsx
|
|
913
|
+
* const changePassword = useChangePassword({
|
|
914
|
+
* onSuccess: () => toast.success("Contraseña actualizada"),
|
|
915
|
+
* });
|
|
916
|
+
*
|
|
917
|
+
* changePassword.mutate({
|
|
918
|
+
* currentPassword: "OldPass123!",
|
|
919
|
+
* newPassword: "NewSecure10!",
|
|
920
|
+
* });
|
|
921
|
+
* ```
|
|
922
|
+
*/
|
|
923
|
+
declare function useChangePassword(options?: UseChangePasswordOptions): UseChangePasswordReturn;
|
|
924
|
+
|
|
925
|
+
interface UseRefreshOptions {
|
|
926
|
+
/** Callback after tokens refreshed */
|
|
927
|
+
onSuccess?: (response: AuthSuccessResponse) => void;
|
|
928
|
+
/** Callback on error (e.g. session expired) */
|
|
929
|
+
onError?: (error: Error) => void;
|
|
930
|
+
}
|
|
931
|
+
type UseRefreshReturn = UseMutationResult<AuthSuccessResponse, Error, void>;
|
|
932
|
+
/**
|
|
933
|
+
* Standalone hook for manually refreshing the access token.
|
|
934
|
+
* Requires `<AziridProvider>`. Uses the refresh token cookie.
|
|
935
|
+
*
|
|
936
|
+
* Note: The AccessClient automatically handles 401 responses with token refresh.
|
|
937
|
+
* This hook is for cases where you want to proactively refresh.
|
|
938
|
+
*
|
|
939
|
+
* @example
|
|
940
|
+
* ```tsx
|
|
941
|
+
* const refresh = useRefresh({
|
|
942
|
+
* onSuccess: (res) => console.log("Token renovado"),
|
|
943
|
+
* onError: () => router.push("/login"),
|
|
944
|
+
* });
|
|
945
|
+
*
|
|
946
|
+
* refresh.mutate();
|
|
947
|
+
* ```
|
|
948
|
+
*/
|
|
949
|
+
declare function useRefresh(options?: UseRefreshOptions): UseRefreshReturn;
|
|
950
|
+
|
|
951
|
+
interface UseBootstrapOptions {
|
|
952
|
+
/** Enable auto-fetching on mount (default: true) */
|
|
953
|
+
enabled?: boolean;
|
|
954
|
+
/** Callback after bootstrap succeeds with an authenticated session */
|
|
955
|
+
onAuthenticated?: (response: Extract<BootstrapResponse, {
|
|
956
|
+
authenticated: true;
|
|
957
|
+
}>) => void;
|
|
958
|
+
/** Callback when no valid session exists */
|
|
959
|
+
onUnauthenticated?: () => void;
|
|
960
|
+
}
|
|
961
|
+
type UseBootstrapReturn = UseQueryResult<BootstrapResponse, Error> & {
|
|
962
|
+
/** Whether the bootstrap resolved to an authenticated session */
|
|
963
|
+
isAuthenticated: boolean;
|
|
964
|
+
};
|
|
965
|
+
/**
|
|
966
|
+
* Standalone hook for silent session bootstrap using refresh token cookie.
|
|
967
|
+
* Requires `<AziridProvider>`. Posts to the bootstrap endpoint on mount.
|
|
968
|
+
*
|
|
969
|
+
* @example
|
|
970
|
+
* ```tsx
|
|
971
|
+
* const bootstrap = useBootstrap({
|
|
972
|
+
* onAuthenticated: (res) => console.log("Sesión restaurada:", res.user.email),
|
|
973
|
+
* onUnauthenticated: () => router.push("/login"),
|
|
974
|
+
* });
|
|
975
|
+
*
|
|
976
|
+
* if (bootstrap.isLoading) return <Spinner />;
|
|
977
|
+
* if (!bootstrap.isAuthenticated) return <LoginPage />;
|
|
978
|
+
* ```
|
|
979
|
+
*/
|
|
980
|
+
declare function useBootstrap(options?: UseBootstrapOptions): UseBootstrapReturn;
|
|
981
|
+
|
|
982
|
+
interface UsePasskeysOptions {
|
|
983
|
+
/** Enable auto-fetching of passkey list (default: false) */
|
|
984
|
+
listEnabled?: boolean;
|
|
985
|
+
/** Callback after passkey registered */
|
|
986
|
+
onRegisterSuccess?: () => void;
|
|
987
|
+
/** Callback after passkey revoked */
|
|
988
|
+
onRevokeSuccess?: (data: {
|
|
989
|
+
revoked: boolean;
|
|
990
|
+
passkeyId: string;
|
|
991
|
+
}) => void;
|
|
992
|
+
/** Callback after passkey login */
|
|
993
|
+
onLoginSuccess?: (response: AuthSuccessResponse) => void;
|
|
994
|
+
/** Callback on error */
|
|
995
|
+
onError?: (error: Error) => void;
|
|
996
|
+
}
|
|
997
|
+
interface UsePasskeysReturn {
|
|
998
|
+
/** List registered passkeys (authenticated) */
|
|
999
|
+
list: UseQueryResult<PasskeyItem[], Error>;
|
|
1000
|
+
/** Start passkey registration challenge (authenticated) */
|
|
1001
|
+
registerStart: UseMutationResult<PasskeyRegisterStartResponse, Error, PasskeyRegisterStartData>;
|
|
1002
|
+
/** Verify passkey registration (authenticated) */
|
|
1003
|
+
registerVerify: UseMutationResult<{
|
|
1004
|
+
message: string;
|
|
1005
|
+
}, Error, PasskeyRegisterVerifyData>;
|
|
1006
|
+
/** Register a passkey directly (authenticated) */
|
|
1007
|
+
register: UseMutationResult<{
|
|
1008
|
+
message: string;
|
|
1009
|
+
}, Error, RegisterPasskeyData>;
|
|
1010
|
+
/** Revoke a passkey (authenticated) */
|
|
1011
|
+
revoke: UseMutationResult<{
|
|
1012
|
+
revoked: boolean;
|
|
1013
|
+
passkeyId: string;
|
|
1014
|
+
}, Error, string>;
|
|
1015
|
+
/** Simple passkey login by credentialId (public) */
|
|
1016
|
+
login: UseMutationResult<AuthSuccessResponse, Error, PasskeyLoginData>;
|
|
1017
|
+
/** Start passkey login challenge (public) */
|
|
1018
|
+
loginStart: UseMutationResult<PasskeyLoginStartResponse, Error, PasskeyLoginStartData | void>;
|
|
1019
|
+
/** Verify passkey login (public) */
|
|
1020
|
+
loginVerify: UseMutationResult<AuthSuccessResponse, Error, PasskeyLoginVerifyData>;
|
|
1021
|
+
}
|
|
1022
|
+
/**
|
|
1023
|
+
* Standalone hook for passkey (WebAuthn) management. Requires `<AziridProvider>`.
|
|
1024
|
+
*
|
|
1025
|
+
* @example
|
|
1026
|
+
* ```tsx
|
|
1027
|
+
* const passkeys = usePasskeys({
|
|
1028
|
+
* listEnabled: true,
|
|
1029
|
+
* onLoginSuccess: (res) => router.push("/dashboard"),
|
|
1030
|
+
* onRegisterSuccess: () => toast.success("Passkey registrada"),
|
|
1031
|
+
* });
|
|
1032
|
+
*
|
|
1033
|
+
* // List passkeys
|
|
1034
|
+
* const { data: passkeyList } = passkeys.list;
|
|
1035
|
+
*
|
|
1036
|
+
* // Start registration flow
|
|
1037
|
+
* const challenge = await passkeys.registerStart.mutateAsync({ deviceName: "Mi Mac" });
|
|
1038
|
+
* // ... get credential from navigator.credentials.create() ...
|
|
1039
|
+
* await passkeys.registerVerify.mutateAsync({ challengeId: challenge.challengeId, credential });
|
|
1040
|
+
*
|
|
1041
|
+
* // Login with passkey
|
|
1042
|
+
* const loginChallenge = await passkeys.loginStart.mutateAsync();
|
|
1043
|
+
* // ... get assertion from navigator.credentials.get() ...
|
|
1044
|
+
* await passkeys.loginVerify.mutateAsync({ challengeId: loginChallenge.challengeId, credential: assertion });
|
|
1045
|
+
* ```
|
|
1046
|
+
*/
|
|
1047
|
+
declare function usePasskeys(options?: UsePasskeysOptions): UsePasskeysReturn;
|
|
1048
|
+
|
|
1049
|
+
declare function useReferral(): {
|
|
1050
|
+
copyToClipboard: () => Promise<boolean>;
|
|
1051
|
+
data: ReferralInfo;
|
|
1052
|
+
error: Error;
|
|
1053
|
+
isError: true;
|
|
1054
|
+
isPending: false;
|
|
1055
|
+
isLoading: false;
|
|
1056
|
+
isLoadingError: false;
|
|
1057
|
+
isRefetchError: true;
|
|
1058
|
+
isSuccess: false;
|
|
1059
|
+
isPlaceholderData: false;
|
|
1060
|
+
status: "error";
|
|
1061
|
+
dataUpdatedAt: number;
|
|
1062
|
+
errorUpdatedAt: number;
|
|
1063
|
+
failureCount: number;
|
|
1064
|
+
failureReason: Error | null;
|
|
1065
|
+
errorUpdateCount: number;
|
|
1066
|
+
isFetched: boolean;
|
|
1067
|
+
isFetchedAfterMount: boolean;
|
|
1068
|
+
isFetching: boolean;
|
|
1069
|
+
isInitialLoading: boolean;
|
|
1070
|
+
isPaused: boolean;
|
|
1071
|
+
isRefetching: boolean;
|
|
1072
|
+
isStale: boolean;
|
|
1073
|
+
isEnabled: boolean;
|
|
1074
|
+
refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<ReferralInfo, Error>>;
|
|
1075
|
+
fetchStatus: _tanstack_react_query.FetchStatus;
|
|
1076
|
+
promise: Promise<ReferralInfo>;
|
|
1077
|
+
} | {
|
|
1078
|
+
copyToClipboard: () => Promise<boolean>;
|
|
1079
|
+
data: ReferralInfo;
|
|
1080
|
+
error: null;
|
|
1081
|
+
isError: false;
|
|
1082
|
+
isPending: false;
|
|
1083
|
+
isLoading: false;
|
|
1084
|
+
isLoadingError: false;
|
|
1085
|
+
isRefetchError: false;
|
|
1086
|
+
isSuccess: true;
|
|
1087
|
+
isPlaceholderData: false;
|
|
1088
|
+
status: "success";
|
|
1089
|
+
dataUpdatedAt: number;
|
|
1090
|
+
errorUpdatedAt: number;
|
|
1091
|
+
failureCount: number;
|
|
1092
|
+
failureReason: Error | null;
|
|
1093
|
+
errorUpdateCount: number;
|
|
1094
|
+
isFetched: boolean;
|
|
1095
|
+
isFetchedAfterMount: boolean;
|
|
1096
|
+
isFetching: boolean;
|
|
1097
|
+
isInitialLoading: boolean;
|
|
1098
|
+
isPaused: boolean;
|
|
1099
|
+
isRefetching: boolean;
|
|
1100
|
+
isStale: boolean;
|
|
1101
|
+
isEnabled: boolean;
|
|
1102
|
+
refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<ReferralInfo, Error>>;
|
|
1103
|
+
fetchStatus: _tanstack_react_query.FetchStatus;
|
|
1104
|
+
promise: Promise<ReferralInfo>;
|
|
1105
|
+
} | {
|
|
1106
|
+
copyToClipboard: () => Promise<boolean>;
|
|
1107
|
+
data: undefined;
|
|
1108
|
+
error: Error;
|
|
1109
|
+
isError: true;
|
|
1110
|
+
isPending: false;
|
|
1111
|
+
isLoading: false;
|
|
1112
|
+
isLoadingError: true;
|
|
1113
|
+
isRefetchError: false;
|
|
1114
|
+
isSuccess: false;
|
|
1115
|
+
isPlaceholderData: false;
|
|
1116
|
+
status: "error";
|
|
1117
|
+
dataUpdatedAt: number;
|
|
1118
|
+
errorUpdatedAt: number;
|
|
1119
|
+
failureCount: number;
|
|
1120
|
+
failureReason: Error | null;
|
|
1121
|
+
errorUpdateCount: number;
|
|
1122
|
+
isFetched: boolean;
|
|
1123
|
+
isFetchedAfterMount: boolean;
|
|
1124
|
+
isFetching: boolean;
|
|
1125
|
+
isInitialLoading: boolean;
|
|
1126
|
+
isPaused: boolean;
|
|
1127
|
+
isRefetching: boolean;
|
|
1128
|
+
isStale: boolean;
|
|
1129
|
+
isEnabled: boolean;
|
|
1130
|
+
refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<ReferralInfo, Error>>;
|
|
1131
|
+
fetchStatus: _tanstack_react_query.FetchStatus;
|
|
1132
|
+
promise: Promise<ReferralInfo>;
|
|
1133
|
+
} | {
|
|
1134
|
+
copyToClipboard: () => Promise<boolean>;
|
|
1135
|
+
data: undefined;
|
|
1136
|
+
error: null;
|
|
1137
|
+
isError: false;
|
|
1138
|
+
isPending: true;
|
|
1139
|
+
isLoading: true;
|
|
1140
|
+
isLoadingError: false;
|
|
1141
|
+
isRefetchError: false;
|
|
1142
|
+
isSuccess: false;
|
|
1143
|
+
isPlaceholderData: false;
|
|
1144
|
+
status: "pending";
|
|
1145
|
+
dataUpdatedAt: number;
|
|
1146
|
+
errorUpdatedAt: number;
|
|
1147
|
+
failureCount: number;
|
|
1148
|
+
failureReason: Error | null;
|
|
1149
|
+
errorUpdateCount: number;
|
|
1150
|
+
isFetched: boolean;
|
|
1151
|
+
isFetchedAfterMount: boolean;
|
|
1152
|
+
isFetching: boolean;
|
|
1153
|
+
isInitialLoading: boolean;
|
|
1154
|
+
isPaused: boolean;
|
|
1155
|
+
isRefetching: boolean;
|
|
1156
|
+
isStale: boolean;
|
|
1157
|
+
isEnabled: boolean;
|
|
1158
|
+
refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<ReferralInfo, Error>>;
|
|
1159
|
+
fetchStatus: _tanstack_react_query.FetchStatus;
|
|
1160
|
+
promise: Promise<ReferralInfo>;
|
|
1161
|
+
} | {
|
|
1162
|
+
copyToClipboard: () => Promise<boolean>;
|
|
1163
|
+
data: undefined;
|
|
1164
|
+
error: null;
|
|
1165
|
+
isError: false;
|
|
1166
|
+
isPending: true;
|
|
1167
|
+
isLoadingError: false;
|
|
1168
|
+
isRefetchError: false;
|
|
1169
|
+
isSuccess: false;
|
|
1170
|
+
isPlaceholderData: false;
|
|
1171
|
+
status: "pending";
|
|
1172
|
+
dataUpdatedAt: number;
|
|
1173
|
+
errorUpdatedAt: number;
|
|
1174
|
+
failureCount: number;
|
|
1175
|
+
failureReason: Error | null;
|
|
1176
|
+
errorUpdateCount: number;
|
|
1177
|
+
isFetched: boolean;
|
|
1178
|
+
isFetchedAfterMount: boolean;
|
|
1179
|
+
isFetching: boolean;
|
|
1180
|
+
isLoading: boolean;
|
|
1181
|
+
isInitialLoading: boolean;
|
|
1182
|
+
isPaused: boolean;
|
|
1183
|
+
isRefetching: boolean;
|
|
1184
|
+
isStale: boolean;
|
|
1185
|
+
isEnabled: boolean;
|
|
1186
|
+
refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<ReferralInfo, Error>>;
|
|
1187
|
+
fetchStatus: _tanstack_react_query.FetchStatus;
|
|
1188
|
+
promise: Promise<ReferralInfo>;
|
|
1189
|
+
} | {
|
|
1190
|
+
copyToClipboard: () => Promise<boolean>;
|
|
1191
|
+
data: ReferralInfo;
|
|
1192
|
+
isError: false;
|
|
1193
|
+
error: null;
|
|
1194
|
+
isPending: false;
|
|
1195
|
+
isLoading: false;
|
|
1196
|
+
isLoadingError: false;
|
|
1197
|
+
isRefetchError: false;
|
|
1198
|
+
isSuccess: true;
|
|
1199
|
+
isPlaceholderData: true;
|
|
1200
|
+
status: "success";
|
|
1201
|
+
dataUpdatedAt: number;
|
|
1202
|
+
errorUpdatedAt: number;
|
|
1203
|
+
failureCount: number;
|
|
1204
|
+
failureReason: Error | null;
|
|
1205
|
+
errorUpdateCount: number;
|
|
1206
|
+
isFetched: boolean;
|
|
1207
|
+
isFetchedAfterMount: boolean;
|
|
1208
|
+
isFetching: boolean;
|
|
1209
|
+
isInitialLoading: boolean;
|
|
1210
|
+
isPaused: boolean;
|
|
1211
|
+
isRefetching: boolean;
|
|
1212
|
+
isStale: boolean;
|
|
1213
|
+
isEnabled: boolean;
|
|
1214
|
+
refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<ReferralInfo, Error>>;
|
|
1215
|
+
fetchStatus: _tanstack_react_query.FetchStatus;
|
|
1216
|
+
promise: Promise<ReferralInfo>;
|
|
1217
|
+
};
|
|
1218
|
+
|
|
1219
|
+
declare function useReferralStats(): _tanstack_react_query.UseQueryResult<ReferralStatsData, Error>;
|
|
1220
|
+
|
|
1221
|
+
declare function usePlans(): _tanstack_react_query.UseQueryResult<BillingPlan[], Error>;
|
|
1222
|
+
|
|
1223
|
+
declare function useSubscription(): _tanstack_react_query.UseQueryResult<UserSubscription, Error>;
|
|
1224
|
+
|
|
1225
|
+
interface CheckoutParams {
|
|
1226
|
+
planId?: string;
|
|
1227
|
+
intentId?: string;
|
|
1228
|
+
successUrl: string;
|
|
1229
|
+
cancelUrl: string;
|
|
1230
|
+
provider?: PaymentProviderType;
|
|
1231
|
+
}
|
|
1232
|
+
interface UseCheckoutOptions {
|
|
1233
|
+
onSuccess?: (data: CheckoutResponse) => void;
|
|
1234
|
+
onError?: (error: Error) => void;
|
|
1235
|
+
redirectOnSuccess?: boolean;
|
|
1236
|
+
}
|
|
1237
|
+
declare function useCheckout(options?: UseCheckoutOptions): {
|
|
1238
|
+
checkout: (params: CheckoutParams) => void;
|
|
1239
|
+
data: undefined;
|
|
1240
|
+
variables: undefined;
|
|
1241
|
+
error: null;
|
|
1242
|
+
isError: false;
|
|
1243
|
+
isIdle: true;
|
|
1244
|
+
isPending: false;
|
|
1245
|
+
isSuccess: false;
|
|
1246
|
+
status: "idle";
|
|
1247
|
+
mutate: _tanstack_react_query.UseMutateFunction<CheckoutResponse, Error, CheckoutParams, unknown>;
|
|
1248
|
+
reset: () => void;
|
|
1249
|
+
context: unknown;
|
|
1250
|
+
failureCount: number;
|
|
1251
|
+
failureReason: Error | null;
|
|
1252
|
+
isPaused: boolean;
|
|
1253
|
+
submittedAt: number;
|
|
1254
|
+
mutateAsync: _tanstack_react_query.UseMutateAsyncFunction<CheckoutResponse, Error, CheckoutParams, unknown>;
|
|
1255
|
+
} | {
|
|
1256
|
+
checkout: (params: CheckoutParams) => void;
|
|
1257
|
+
data: undefined;
|
|
1258
|
+
variables: CheckoutParams;
|
|
1259
|
+
error: null;
|
|
1260
|
+
isError: false;
|
|
1261
|
+
isIdle: false;
|
|
1262
|
+
isPending: true;
|
|
1263
|
+
isSuccess: false;
|
|
1264
|
+
status: "pending";
|
|
1265
|
+
mutate: _tanstack_react_query.UseMutateFunction<CheckoutResponse, Error, CheckoutParams, unknown>;
|
|
1266
|
+
reset: () => void;
|
|
1267
|
+
context: unknown;
|
|
1268
|
+
failureCount: number;
|
|
1269
|
+
failureReason: Error | null;
|
|
1270
|
+
isPaused: boolean;
|
|
1271
|
+
submittedAt: number;
|
|
1272
|
+
mutateAsync: _tanstack_react_query.UseMutateAsyncFunction<CheckoutResponse, Error, CheckoutParams, unknown>;
|
|
1273
|
+
} | {
|
|
1274
|
+
checkout: (params: CheckoutParams) => void;
|
|
1275
|
+
data: undefined;
|
|
1276
|
+
error: Error;
|
|
1277
|
+
variables: CheckoutParams;
|
|
1278
|
+
isError: true;
|
|
1279
|
+
isIdle: false;
|
|
1280
|
+
isPending: false;
|
|
1281
|
+
isSuccess: false;
|
|
1282
|
+
status: "error";
|
|
1283
|
+
mutate: _tanstack_react_query.UseMutateFunction<CheckoutResponse, Error, CheckoutParams, unknown>;
|
|
1284
|
+
reset: () => void;
|
|
1285
|
+
context: unknown;
|
|
1286
|
+
failureCount: number;
|
|
1287
|
+
failureReason: Error | null;
|
|
1288
|
+
isPaused: boolean;
|
|
1289
|
+
submittedAt: number;
|
|
1290
|
+
mutateAsync: _tanstack_react_query.UseMutateAsyncFunction<CheckoutResponse, Error, CheckoutParams, unknown>;
|
|
1291
|
+
} | {
|
|
1292
|
+
checkout: (params: CheckoutParams) => void;
|
|
1293
|
+
data: CheckoutResponse;
|
|
1294
|
+
error: null;
|
|
1295
|
+
variables: CheckoutParams;
|
|
1296
|
+
isError: false;
|
|
1297
|
+
isIdle: false;
|
|
1298
|
+
isPending: false;
|
|
1299
|
+
isSuccess: true;
|
|
1300
|
+
status: "success";
|
|
1301
|
+
mutate: _tanstack_react_query.UseMutateFunction<CheckoutResponse, Error, CheckoutParams, unknown>;
|
|
1302
|
+
reset: () => void;
|
|
1303
|
+
context: unknown;
|
|
1304
|
+
failureCount: number;
|
|
1305
|
+
failureReason: Error | null;
|
|
1306
|
+
isPaused: boolean;
|
|
1307
|
+
submittedAt: number;
|
|
1308
|
+
mutateAsync: _tanstack_react_query.UseMutateAsyncFunction<CheckoutResponse, Error, CheckoutParams, unknown>;
|
|
1309
|
+
};
|
|
1310
|
+
|
|
1311
|
+
declare function useInvoices(): _tanstack_react_query.UseQueryResult<BillingInvoice[], Error>;
|
|
1312
|
+
|
|
1313
|
+
interface UseTransferProofOptions {
|
|
1314
|
+
onSuccess?: (data: TransferProof) => void;
|
|
1315
|
+
onError?: (error: Error) => void;
|
|
1316
|
+
}
|
|
1317
|
+
declare function useSubmitTransferProof(options?: UseTransferProofOptions): {
|
|
1318
|
+
submit: (data: SubmitTransferProofData) => void;
|
|
1319
|
+
data: undefined;
|
|
1320
|
+
variables: undefined;
|
|
1321
|
+
error: null;
|
|
1322
|
+
isError: false;
|
|
1323
|
+
isIdle: true;
|
|
1324
|
+
isPending: false;
|
|
1325
|
+
isSuccess: false;
|
|
1326
|
+
status: "idle";
|
|
1327
|
+
mutate: _tanstack_react_query.UseMutateFunction<TransferProof, Error, SubmitTransferProofData, unknown>;
|
|
1328
|
+
reset: () => void;
|
|
1329
|
+
context: unknown;
|
|
1330
|
+
failureCount: number;
|
|
1331
|
+
failureReason: Error | null;
|
|
1332
|
+
isPaused: boolean;
|
|
1333
|
+
submittedAt: number;
|
|
1334
|
+
mutateAsync: _tanstack_react_query.UseMutateAsyncFunction<TransferProof, Error, SubmitTransferProofData, unknown>;
|
|
1335
|
+
} | {
|
|
1336
|
+
submit: (data: SubmitTransferProofData) => void;
|
|
1337
|
+
data: undefined;
|
|
1338
|
+
variables: SubmitTransferProofData;
|
|
1339
|
+
error: null;
|
|
1340
|
+
isError: false;
|
|
1341
|
+
isIdle: false;
|
|
1342
|
+
isPending: true;
|
|
1343
|
+
isSuccess: false;
|
|
1344
|
+
status: "pending";
|
|
1345
|
+
mutate: _tanstack_react_query.UseMutateFunction<TransferProof, Error, SubmitTransferProofData, unknown>;
|
|
1346
|
+
reset: () => void;
|
|
1347
|
+
context: unknown;
|
|
1348
|
+
failureCount: number;
|
|
1349
|
+
failureReason: Error | null;
|
|
1350
|
+
isPaused: boolean;
|
|
1351
|
+
submittedAt: number;
|
|
1352
|
+
mutateAsync: _tanstack_react_query.UseMutateAsyncFunction<TransferProof, Error, SubmitTransferProofData, unknown>;
|
|
1353
|
+
} | {
|
|
1354
|
+
submit: (data: SubmitTransferProofData) => void;
|
|
1355
|
+
data: undefined;
|
|
1356
|
+
error: Error;
|
|
1357
|
+
variables: SubmitTransferProofData;
|
|
1358
|
+
isError: true;
|
|
1359
|
+
isIdle: false;
|
|
1360
|
+
isPending: false;
|
|
1361
|
+
isSuccess: false;
|
|
1362
|
+
status: "error";
|
|
1363
|
+
mutate: _tanstack_react_query.UseMutateFunction<TransferProof, Error, SubmitTransferProofData, unknown>;
|
|
1364
|
+
reset: () => void;
|
|
1365
|
+
context: unknown;
|
|
1366
|
+
failureCount: number;
|
|
1367
|
+
failureReason: Error | null;
|
|
1368
|
+
isPaused: boolean;
|
|
1369
|
+
submittedAt: number;
|
|
1370
|
+
mutateAsync: _tanstack_react_query.UseMutateAsyncFunction<TransferProof, Error, SubmitTransferProofData, unknown>;
|
|
1371
|
+
} | {
|
|
1372
|
+
submit: (data: SubmitTransferProofData) => void;
|
|
1373
|
+
data: TransferProof;
|
|
1374
|
+
error: null;
|
|
1375
|
+
variables: SubmitTransferProofData;
|
|
1376
|
+
isError: false;
|
|
1377
|
+
isIdle: false;
|
|
1378
|
+
isPending: false;
|
|
1379
|
+
isSuccess: true;
|
|
1380
|
+
status: "success";
|
|
1381
|
+
mutate: _tanstack_react_query.UseMutateFunction<TransferProof, Error, SubmitTransferProofData, unknown>;
|
|
1382
|
+
reset: () => void;
|
|
1383
|
+
context: unknown;
|
|
1384
|
+
failureCount: number;
|
|
1385
|
+
failureReason: Error | null;
|
|
1386
|
+
isPaused: boolean;
|
|
1387
|
+
submittedAt: number;
|
|
1388
|
+
mutateAsync: _tanstack_react_query.UseMutateAsyncFunction<TransferProof, Error, SubmitTransferProofData, unknown>;
|
|
1389
|
+
};
|
|
1390
|
+
declare function useTransferProofs(): _tanstack_react_query.UseQueryResult<TransferProof[], Error>;
|
|
1391
|
+
|
|
1392
|
+
declare function usePaymentProviders(): _tanstack_react_query.UseQueryResult<AvailableProvider[], Error>;
|
|
1393
|
+
|
|
1394
|
+
interface PayphoneConfirmParams {
|
|
1395
|
+
id: number;
|
|
1396
|
+
clientTransactionId: string;
|
|
1397
|
+
}
|
|
1398
|
+
interface PayphoneConfirmResult {
|
|
1399
|
+
status: 'confirmed' | 'cancelled' | 'already_confirmed';
|
|
1400
|
+
intentId: string;
|
|
1401
|
+
}
|
|
1402
|
+
interface UsePayphoneConfirmOptions {
|
|
1403
|
+
onSuccess?: (data: PayphoneConfirmResult) => void;
|
|
1404
|
+
onError?: (error: Error) => void;
|
|
1405
|
+
}
|
|
1406
|
+
declare function usePayphoneConfirm(options?: UsePayphoneConfirmOptions): _tanstack_react_query.UseMutationResult<PayphoneConfirmResult, Error, PayphoneConfirmParams, unknown>;
|
|
1407
|
+
|
|
1408
|
+
declare function useFormState<T extends Record<string, unknown>>(initialValues: T, schema: z.ZodType<unknown, z.ZodTypeDef, unknown>, onSubmit: (values: T) => void | Promise<void>): UseFormReturn<T>;
|
|
1409
|
+
|
|
1410
|
+
declare function usePasswordToggle(): {
|
|
1411
|
+
visible: boolean;
|
|
1412
|
+
toggle: () => void;
|
|
1413
|
+
type: "password" | "text";
|
|
1414
|
+
};
|
|
1415
|
+
|
|
1416
|
+
declare function createLoginSchema(v: AccessMessages['validation']): z.ZodObject<{
|
|
1417
|
+
email: z.ZodString;
|
|
1418
|
+
password: z.ZodString;
|
|
1419
|
+
}, "strip", z.ZodTypeAny, {
|
|
1420
|
+
email: string;
|
|
1421
|
+
password: string;
|
|
1422
|
+
}, {
|
|
1423
|
+
email: string;
|
|
1424
|
+
password: string;
|
|
1425
|
+
}>;
|
|
1426
|
+
declare function createSignupSchema(v: AccessMessages['validation']): z.ZodObject<{
|
|
1427
|
+
email: z.ZodString;
|
|
1428
|
+
password: z.ZodString;
|
|
1429
|
+
acceptedTosVersion: z.ZodOptional<z.ZodString>;
|
|
1430
|
+
acceptedPrivacyVersion: z.ZodOptional<z.ZodString>;
|
|
1431
|
+
}, "strip", z.ZodTypeAny, {
|
|
1432
|
+
email: string;
|
|
1433
|
+
password: string;
|
|
1434
|
+
acceptedTosVersion?: string | undefined;
|
|
1435
|
+
acceptedPrivacyVersion?: string | undefined;
|
|
1436
|
+
}, {
|
|
1437
|
+
email: string;
|
|
1438
|
+
password: string;
|
|
1439
|
+
acceptedTosVersion?: string | undefined;
|
|
1440
|
+
acceptedPrivacyVersion?: string | undefined;
|
|
1441
|
+
}>;
|
|
1442
|
+
declare const loginSchema: z.ZodObject<{
|
|
1443
|
+
email: z.ZodString;
|
|
1444
|
+
password: z.ZodString;
|
|
1445
|
+
}, "strip", z.ZodTypeAny, {
|
|
1446
|
+
email: string;
|
|
1447
|
+
password: string;
|
|
1448
|
+
}, {
|
|
1449
|
+
email: string;
|
|
1450
|
+
password: string;
|
|
1451
|
+
}>;
|
|
1452
|
+
type LoginInput = z.infer<typeof loginSchema>;
|
|
1453
|
+
declare const signupSchema: z.ZodObject<{
|
|
1454
|
+
email: z.ZodString;
|
|
1455
|
+
password: z.ZodString;
|
|
1456
|
+
acceptedTosVersion: z.ZodOptional<z.ZodString>;
|
|
1457
|
+
acceptedPrivacyVersion: z.ZodOptional<z.ZodString>;
|
|
1458
|
+
}, "strip", z.ZodTypeAny, {
|
|
1459
|
+
email: string;
|
|
1460
|
+
password: string;
|
|
1461
|
+
acceptedTosVersion?: string | undefined;
|
|
1462
|
+
acceptedPrivacyVersion?: string | undefined;
|
|
1463
|
+
}, {
|
|
1464
|
+
email: string;
|
|
1465
|
+
password: string;
|
|
1466
|
+
acceptedTosVersion?: string | undefined;
|
|
1467
|
+
acceptedPrivacyVersion?: string | undefined;
|
|
1468
|
+
}>;
|
|
1469
|
+
type SignupInput = z.infer<typeof signupSchema>;
|
|
1470
|
+
declare const changePasswordSchema: z.ZodObject<{
|
|
1471
|
+
currentPassword: z.ZodString;
|
|
1472
|
+
newPassword: z.ZodString;
|
|
1473
|
+
}, "strip", z.ZodTypeAny, {
|
|
1474
|
+
currentPassword: string;
|
|
1475
|
+
newPassword: string;
|
|
1476
|
+
}, {
|
|
1477
|
+
currentPassword: string;
|
|
1478
|
+
newPassword: string;
|
|
1479
|
+
}>;
|
|
1480
|
+
type ChangePasswordInput = z.infer<typeof changePasswordSchema>;
|
|
1481
|
+
declare const magicLinkRequestSchema: z.ZodObject<{
|
|
1482
|
+
email: z.ZodString;
|
|
1483
|
+
}, "strip", z.ZodTypeAny, {
|
|
1484
|
+
email: string;
|
|
1485
|
+
}, {
|
|
1486
|
+
email: string;
|
|
1487
|
+
}>;
|
|
1488
|
+
type MagicLinkRequestInput = z.infer<typeof magicLinkRequestSchema>;
|
|
1489
|
+
declare const magicLinkVerifySchema: z.ZodObject<{
|
|
1490
|
+
token: z.ZodString;
|
|
1491
|
+
}, "strip", z.ZodTypeAny, {
|
|
1492
|
+
token: string;
|
|
1493
|
+
}, {
|
|
1494
|
+
token: string;
|
|
1495
|
+
}>;
|
|
1496
|
+
type MagicLinkVerifyInput = z.infer<typeof magicLinkVerifySchema>;
|
|
1497
|
+
declare const socialLoginSchema: z.ZodObject<{
|
|
1498
|
+
provider: z.ZodEnum<["google", "github"]>;
|
|
1499
|
+
providerAccountId: z.ZodString;
|
|
1500
|
+
email: z.ZodString;
|
|
1501
|
+
emailVerified: z.ZodOptional<z.ZodBoolean>;
|
|
1502
|
+
firstName: z.ZodOptional<z.ZodString>;
|
|
1503
|
+
lastName: z.ZodOptional<z.ZodString>;
|
|
1504
|
+
createUserIfNotExists: z.ZodOptional<z.ZodBoolean>;
|
|
1505
|
+
turnstileToken: z.ZodOptional<z.ZodString>;
|
|
1506
|
+
acceptedTosVersion: z.ZodOptional<z.ZodString>;
|
|
1507
|
+
acceptedPrivacyVersion: z.ZodOptional<z.ZodString>;
|
|
1508
|
+
}, "strip", z.ZodTypeAny, {
|
|
1509
|
+
email: string;
|
|
1510
|
+
provider: "google" | "github";
|
|
1511
|
+
providerAccountId: string;
|
|
1512
|
+
firstName?: string | undefined;
|
|
1513
|
+
lastName?: string | undefined;
|
|
1514
|
+
emailVerified?: boolean | undefined;
|
|
1515
|
+
acceptedTosVersion?: string | undefined;
|
|
1516
|
+
acceptedPrivacyVersion?: string | undefined;
|
|
1517
|
+
createUserIfNotExists?: boolean | undefined;
|
|
1518
|
+
turnstileToken?: string | undefined;
|
|
1519
|
+
}, {
|
|
1520
|
+
email: string;
|
|
1521
|
+
provider: "google" | "github";
|
|
1522
|
+
providerAccountId: string;
|
|
1523
|
+
firstName?: string | undefined;
|
|
1524
|
+
lastName?: string | undefined;
|
|
1525
|
+
emailVerified?: boolean | undefined;
|
|
1526
|
+
acceptedTosVersion?: string | undefined;
|
|
1527
|
+
acceptedPrivacyVersion?: string | undefined;
|
|
1528
|
+
createUserIfNotExists?: boolean | undefined;
|
|
1529
|
+
turnstileToken?: string | undefined;
|
|
1530
|
+
}>;
|
|
1531
|
+
type SocialLoginInput = z.infer<typeof socialLoginSchema>;
|
|
1532
|
+
declare const passkeyRegisterStartSchema: z.ZodObject<{
|
|
1533
|
+
deviceName: z.ZodOptional<z.ZodString>;
|
|
1534
|
+
}, "strip", z.ZodTypeAny, {
|
|
1535
|
+
deviceName?: string | undefined;
|
|
1536
|
+
}, {
|
|
1537
|
+
deviceName?: string | undefined;
|
|
1538
|
+
}>;
|
|
1539
|
+
type PasskeyRegisterStartInput = z.infer<typeof passkeyRegisterStartSchema>;
|
|
1540
|
+
|
|
1541
|
+
declare function cn(...inputs: ClassValue[]): string;
|
|
1542
|
+
|
|
1543
|
+
/** Remove injected styles from the DOM (useful when embedding in host apps). */
|
|
1544
|
+
declare function removeStyles(): void;
|
|
1545
|
+
|
|
1546
|
+
declare global {
|
|
1547
|
+
interface Window {
|
|
1548
|
+
PPaymentButtonBox: new (config: Record<string, unknown>) => {
|
|
1549
|
+
render: (containerId: string) => void;
|
|
1550
|
+
};
|
|
1551
|
+
}
|
|
1552
|
+
}
|
|
1553
|
+
interface PayphoneModalProps {
|
|
1554
|
+
config: PayphoneWidgetConfig;
|
|
1555
|
+
successUrl: string;
|
|
1556
|
+
onClose: () => void;
|
|
1557
|
+
}
|
|
1558
|
+
|
|
1559
|
+
interface SessionSyncOptions {
|
|
1560
|
+
/** Cookie name (default: "__session") */
|
|
1561
|
+
cookieName?: string;
|
|
1562
|
+
/** Set Secure flag on cookie (default: false) */
|
|
1563
|
+
secure?: boolean;
|
|
1564
|
+
/** Cookie max age in seconds (default: 3600 = 1h) */
|
|
1565
|
+
maxAge?: number;
|
|
1566
|
+
}
|
|
1567
|
+
|
|
1568
|
+
declare const SDK_VERSION: string;
|
|
1569
|
+
|
|
1570
|
+
export { type AccessClient, type AccessClientConfig, type AccessMessages, type ApiError, type AppBranding, type AuthPaths, type AuthState, type AuthSuccessResponse, type AuthUser, type AvailableProvider, type AziridContextValue, AziridProvider, type AziridProviderProps, BASE_PATHS, type BillingInvoice, type BillingPlan, type BootstrapResponse, type ChangePasswordData, type ChangePasswordInput, CheckoutButton, type CheckoutButtonProps, type CheckoutParams, type CheckoutResponse, type FieldError, InvoiceList, type InvoiceListProps, type LoginData, LoginForm, type LoginFormProps, type LoginInput, type MagicLinkRequestData, type MagicLinkRequestInput, type MagicLinkVerifyData, type MagicLinkVerifyInput, PATHS, type PasskeyItem, type PasskeyLoginData, type PasskeyLoginStartData, type PasskeyLoginStartResponse, type PasskeyLoginVerifyData, type PasskeyRegisterStartData, type PasskeyRegisterStartInput, type PasskeyRegisterStartResponse, type PasskeyRegisterVerifyData, PayButton, type PayButtonProps, type PaymentIntent, type PaymentProviderType, PayphoneCallback, type PayphoneCallbackProps, type PayphoneConfirmParams, type PayphoneConfirmResult, type PayphoneModalProps, type PayphoneWidgetConfig, PricingTable, type PricingTableProps, ReferralCard, type ReferralCardProps, type ReferralInfo, type ReferralItem, ReferralStats, type ReferralStatsData, type ReferralStatsProps, type RegisterPasskeyData, SDK_VERSION, type SessionSyncOptions, type SignupData, SignupForm, type SignupFormProps, type SignupInput, type SocialLoginData, type SocialLoginInput, type SubmitTransferProofData, SubscriptionBadge, type SubscriptionBadgeProps, type SupportedLocale, type TransferProof, type UseBootstrapOptions, type UseBootstrapReturn, type UseChangePasswordOptions, type UseChangePasswordReturn, type UseCheckoutOptions, type UseFormReturn, type UseLoginOptions, type UseLoginReturn, type UseLogoutOptions, type UseLogoutReturn, type UseMagicLinkOptions, type UseMagicLinkReturn, type UsePasskeysOptions, type UsePasskeysReturn, type UsePayphoneConfirmOptions, type UseRefreshOptions, type UseRefreshReturn, type UseSessionOptions, type UseSessionReturn, type UseSignupOptions, type UseSignupReturn, type UseSocialLoginOptions, type UseSocialLoginReturn, type UserSubscription, buildPaths, changePasswordSchema, cn, createAccessClient, createLoginSchema, createSignupSchema, en, es, isAuthError, loginSchema, magicLinkRequestSchema, magicLinkVerifySchema, passkeyRegisterStartSchema, removeStyles, resolveMessages, signupSchema, socialLoginSchema, useAccessClient, useAzirid, useBootstrap, useBranding, useChangePassword, useCheckout, useFormState, useInvoices, useLogin, useLogout, useMagicLink, useMessages, usePasskeys, usePasswordToggle, usePaymentProviders, usePayphoneConfirm, usePlans, useReferral, useReferralStats, useRefresh, useSession, useSignup, useSocialLogin, useSubmitTransferProof, useSubscription, useTransferProofs };
|