@caffeinebounce/identity 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.
@@ -0,0 +1,778 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { ComponentType, ReactNode, CSSProperties } from 'react';
3
+ import { SupabaseClient, AuthenticatorAssuranceLevels } from '@supabase/supabase-js';
4
+ export { AuthCallbackConfig, AuthCallbackErrorSource, AuthCallbackFlow, AuthCallbackHook, AuthCallbackHookContext, AuthCallbackHookErrorMode, AuthCallbackLinkingErrorContext, AuthCallbackLinkingErrorMessageResolver, AuthCallbackLinkingFlowContext, AuthCallbackLinkingFlowDetector, AuthCallbackRedirectTarget, AuthCallbackSuccessRedirectResolver, createAuthCallbackHandler } from './server.js';
5
+ export { DeviceFingerprint, GeolocationInfo, generateDeviceFingerprint, generateSecureToken, getClientIP, getGeolocationFromIP, hashString } from '@caffeinebounce/shared-utils';
6
+
7
+ /**
8
+ * Type for the createClient function that apps must provide.
9
+ * This abstracts over browser vs server client creation.
10
+ *
11
+ * Using `any` for all generic parameters avoids version mismatches
12
+ * between packages with different Supabase client versions.
13
+ */
14
+ type CreateClientFn = () => SupabaseClient<any, any, any, any, any>;
15
+ /**
16
+ * Configuration for OAuth providers
17
+ */
18
+ type OAuthProvider = "google" | "azure";
19
+ /**
20
+ * Logo configuration for auth pages
21
+ */
22
+ interface AuthLogo {
23
+ /** Logo image source (URL or path) */
24
+ src: string;
25
+ /** Alt text for the logo */
26
+ alt: string;
27
+ /** Logo width in pixels */
28
+ width?: number;
29
+ /** Logo height in pixels */
30
+ height?: number;
31
+ }
32
+ /**
33
+ * Common configuration for auth forms
34
+ */
35
+ interface AuthFormConfig {
36
+ /** App name displayed in headings */
37
+ appName?: string;
38
+ /** Logo configuration */
39
+ logo?: AuthLogo;
40
+ /** URL to terms of service page */
41
+ termsUrl?: string;
42
+ /** URL to privacy policy page */
43
+ privacyUrl?: string;
44
+ /** Supabase client factory */
45
+ createClient: CreateClientFn;
46
+ }
47
+ /**
48
+ * Link configuration for auth pages
49
+ */
50
+ interface AuthLinks {
51
+ /** Sign in page path */
52
+ signIn?: string;
53
+ /** Sign up page path */
54
+ signUp?: string;
55
+ /** Forgot password page path */
56
+ forgotPassword?: string;
57
+ /** Reset password page path */
58
+ resetPassword?: string;
59
+ /** Auth callback route for PKCE code exchange (e.g., /callback) */
60
+ callback?: string;
61
+ /** Home page path */
62
+ home?: string;
63
+ /** Default redirect after auth */
64
+ defaultRedirect?: string;
65
+ }
66
+ /**
67
+ * Default auth links
68
+ */
69
+ declare const defaultAuthLinks: Required<AuthLinks>;
70
+
71
+ /**
72
+ * Password reset event logging callbacks
73
+ */
74
+ interface PasswordResetEventCallbacks {
75
+ onPasswordResetRequested?: (email: string) => void;
76
+ }
77
+ interface ForgotPasswordFormProps extends AuthFormConfig {
78
+ /** Navigation links configuration */
79
+ links?: AuthLinks;
80
+ /** Image component to use (e.g., Next.js Image) */
81
+ ImageComponent?: ComponentType<{
82
+ src: string;
83
+ alt: string;
84
+ width: number;
85
+ height: number;
86
+ className?: string;
87
+ }>;
88
+ /** Link component to use (e.g., Next.js Link) */
89
+ LinkComponent?: ComponentType<{
90
+ href: string;
91
+ className?: string;
92
+ children: React.ReactNode;
93
+ }>;
94
+ /** Additional className for the form container */
95
+ className?: string;
96
+ /** Optional callbacks for logging password reset events */
97
+ onAuthEvent?: PasswordResetEventCallbacks;
98
+ }
99
+ /**
100
+ * ForgotPasswordForm - Password reset request form
101
+ */
102
+ declare function ForgotPasswordForm({ createClient, logo, links, ImageComponent, LinkComponent, className, onAuthEvent, }: ForgotPasswordFormProps): react_jsx_runtime.JSX.Element;
103
+
104
+ /**
105
+ * Password reset completion event logging callbacks
106
+ */
107
+ interface ResetPasswordEventCallbacks {
108
+ onPasswordResetCompleted?: (userId: string, email: string) => void;
109
+ onPasswordResetFailed?: (email: string, reason: string) => void;
110
+ }
111
+ interface ResetPasswordFormProps extends AuthFormConfig {
112
+ /** MFA Challenge component to render when MFA is required */
113
+ MFAChallengeComponent?: ComponentType<{
114
+ onSuccess: () => void;
115
+ onCancel: () => void;
116
+ }>;
117
+ /** Navigation links configuration */
118
+ links?: AuthLinks;
119
+ /** Image component to use (e.g., Next.js Image) */
120
+ ImageComponent?: ComponentType<{
121
+ src: string;
122
+ alt: string;
123
+ width: number;
124
+ height: number;
125
+ className?: string;
126
+ }>;
127
+ /** Link component to use (e.g., Next.js Link) */
128
+ LinkComponent?: ComponentType<{
129
+ href: string;
130
+ className?: string;
131
+ children: React.ReactNode;
132
+ }>;
133
+ /** Additional className for the form container */
134
+ className?: string;
135
+ /** Optional callbacks for logging password reset events */
136
+ onAuthEvent?: ResetPasswordEventCallbacks;
137
+ }
138
+ /**
139
+ * ResetPasswordForm - Set new password after reset link
140
+ */
141
+ declare function ResetPasswordForm({ createClient, logo, MFAChallengeComponent, links, ImageComponent, LinkComponent, className, onAuthEvent, }: ResetPasswordFormProps): react_jsx_runtime.JSX.Element;
142
+
143
+ /**
144
+ * Authentication event logging callbacks
145
+ */
146
+ interface AuthEventCallbacks {
147
+ onSignInAttempt?: (email: string, provider?: string) => void;
148
+ onSignInSuccess?: (userId: string, email: string, mfaUsed?: boolean) => void;
149
+ onSignInFailure?: (email: string, reason: string) => void;
150
+ onMFARequired?: (userId: string, email: string) => void;
151
+ }
152
+ interface SigninFormProps extends AuthFormConfig {
153
+ /** MFA Challenge component to render when MFA is required */
154
+ MFAChallengeComponent?: ComponentType<{
155
+ redirectTo: string;
156
+ onSuccess: () => void;
157
+ onCancel: () => void;
158
+ }>;
159
+ /** Navigation links configuration */
160
+ links?: AuthLinks;
161
+ /** Image component to use (e.g., Next.js Image) */
162
+ ImageComponent?: ComponentType<{
163
+ src: string;
164
+ alt: string;
165
+ width: number;
166
+ height: number;
167
+ className?: string;
168
+ }>;
169
+ /** Link component to use (e.g., Next.js Link) */
170
+ LinkComponent?: ComponentType<{
171
+ href: string;
172
+ className?: string;
173
+ children: React.ReactNode;
174
+ }>;
175
+ /** OAuth providers to show (default: ["azure"]) */
176
+ oauthProviders?: OAuthProvider[];
177
+ /** Show "Coming Soon" for Google OAuth */
178
+ googleComingSoon?: boolean;
179
+ /** Show "Coming Soon" for Microsoft OAuth */
180
+ azureComingSoon?: boolean;
181
+ /** When true, OAuth provider icons switch to monochrome (current text color) on hover */
182
+ oauthIconMonochromeOnHover?: boolean;
183
+ /** Additional className for the form container */
184
+ className?: string;
185
+ /** Optional callbacks for logging authentication events */
186
+ onAuthEvent?: AuthEventCallbacks;
187
+ /** Show hint about last used sign-in method. Default: true */
188
+ showLastSignInHint?: boolean;
189
+ /** Show the Home back-link on the auth form. Default: true */
190
+ showHomeLink?: boolean;
191
+ /** localStorage key for last sign-in data. Default: "last_signin" */
192
+ lastSignInStorageKey?: string;
193
+ /** Whether to show the logo inside the card. Default: true */
194
+ showLogo?: boolean;
195
+ }
196
+ /**
197
+ * SigninForm - Configurable sign-in form with email/password and OAuth support
198
+ *
199
+ * @example
200
+ * ```tsx
201
+ * <SigninForm
202
+ * createClient={createClient}
203
+ * logo={{ src: "/logo.png", alt: "My App" }}
204
+ * appName="My App"
205
+ * MFAChallengeComponent={MFAChallenge}
206
+ * LinkComponent={Link}
207
+ * ImageComponent={Image}
208
+ * />
209
+ * ```
210
+ */
211
+ declare function SigninForm({ createClient, logo, appName, termsUrl, privacyUrl, MFAChallengeComponent, links, ImageComponent, LinkComponent, oauthProviders, googleComingSoon, azureComingSoon, oauthIconMonochromeOnHover, className, onAuthEvent, showLastSignInHint, showHomeLink, lastSignInStorageKey, showLogo, }: SigninFormProps): react_jsx_runtime.JSX.Element;
212
+
213
+ /**
214
+ * Authentication event logging callbacks for sign-up
215
+ */
216
+ interface SignupEventCallbacks {
217
+ onSignUpAttempt?: (email: string, provider?: string) => void;
218
+ onSignUpSuccess?: (userId: string, email: string) => void;
219
+ onSignUpFailure?: (email: string, reason: string) => void;
220
+ onEmailVerificationSent?: (email: string) => void;
221
+ }
222
+ /**
223
+ * Configuration for a consent checkbox (program updates, marketing, etc.)
224
+ */
225
+ interface ConsentItem {
226
+ /** Unique identifier, used as the key in user metadata (e.g., "email_marketing") */
227
+ id: string;
228
+ /**
229
+ * Label content displayed next to the checkbox.
230
+ * Note: Do not include a required indicator (*) in the label text - the component
231
+ * will automatically append it when required: true.
232
+ */
233
+ label: React.ReactNode;
234
+ /** Optional description below the label (can include links) */
235
+ description?: React.ReactNode;
236
+ /** Whether this consent is required to submit the form */
237
+ required?: boolean;
238
+ /** Default checked state */
239
+ defaultChecked?: boolean;
240
+ /** Error message shown when required consent is not given */
241
+ errorMessage?: string;
242
+ }
243
+ interface SignupFormProps extends AuthFormConfig {
244
+ /** Navigation links configuration */
245
+ links?: AuthLinks;
246
+ /** Image component to use (e.g., Next.js Image) */
247
+ ImageComponent?: ComponentType<{
248
+ src: string;
249
+ alt: string;
250
+ width: number;
251
+ height: number;
252
+ className?: string;
253
+ }>;
254
+ /** Link component to use (e.g., Next.js Link) */
255
+ LinkComponent?: ComponentType<{
256
+ href: string;
257
+ className?: string;
258
+ children: React.ReactNode;
259
+ }>;
260
+ /** OAuth providers to show (default: ["azure"]) */
261
+ oauthProviders?: OAuthProvider[];
262
+ /** Show "Coming Soon" for Google OAuth */
263
+ googleComingSoon?: boolean;
264
+ /** Show "Coming Soon" for Microsoft OAuth */
265
+ azureComingSoon?: boolean;
266
+ /** When true, OAuth provider icons switch to monochrome (current text color) on hover */
267
+ oauthIconMonochromeOnHover?: boolean;
268
+ /** Additional className for the form container */
269
+ className?: string;
270
+ /** Optional callbacks for logging authentication events */
271
+ onAuthEvent?: SignupEventCallbacks;
272
+ /** Array of consent items to display (e.g., marketing opt-in, terms acceptance) */
273
+ consentItems?: ConsentItem[];
274
+ /** Position of consent checkboxes relative to submit button (default: "above") */
275
+ consentPosition?: "above" | "below";
276
+ /** Size of consent text - compact uses smaller text (default: "default") */
277
+ consentSize?: "default" | "compact";
278
+ /** Show the Home back-link on the auth form. Default: true */
279
+ showHomeLink?: boolean;
280
+ /** Whether to show the logo inside the card. Default: true */
281
+ showLogo?: boolean;
282
+ }
283
+ /**
284
+ * SignupForm - Configurable sign-up form with email/password and OAuth support
285
+ */
286
+ declare function SignupForm({ createClient, logo, appName, termsUrl, privacyUrl, links, ImageComponent, LinkComponent, oauthProviders, googleComingSoon, azureComingSoon, oauthIconMonochromeOnHover, className, onAuthEvent, consentItems, consentPosition, consentSize, showHomeLink, showLogo, }: SignupFormProps): react_jsx_runtime.JSX.Element;
287
+
288
+ /**
289
+ * MFA event logging callbacks
290
+ */
291
+ interface MFAEventCallbacks {
292
+ onMFASuccess?: (userId: string, email: string) => void;
293
+ onMFAFailure?: (userId: string, email: string, reason: string) => void;
294
+ }
295
+ interface MFAChallengeProps {
296
+ /** Supabase client factory */
297
+ createClient: CreateClientFn;
298
+ /** Callback when MFA verification succeeds */
299
+ onSuccess?: () => void;
300
+ /** Callback when user cancels MFA */
301
+ onCancel?: () => void;
302
+ /** Callback when user clicks recovery link */
303
+ onRecovery?: () => void;
304
+ /** Where to redirect after successful MFA (if onSuccess not provided) */
305
+ redirectTo?: string;
306
+ /** Sign-in URL to redirect to on cancel (if onCancel not provided) */
307
+ signInUrl?: string;
308
+ /** Recovery URL to redirect to on recovery (if onRecovery not provided) */
309
+ recoveryUrl?: string;
310
+ /** Optional callbacks for logging MFA events */
311
+ onAuthEvent?: MFAEventCallbacks;
312
+ }
313
+ /**
314
+ * MFAChallenge - Supabase MFA verification component
315
+ *
316
+ * Wraps the generic @caffeinebounce/ui MFAChallenge component with Supabase MFA API.
317
+ *
318
+ * @example
319
+ * ```tsx
320
+ * <MFAChallenge
321
+ * createClient={createClient}
322
+ * redirectTo="/dashboard"
323
+ * onCancel={() => router.push("/signin")}
324
+ * />
325
+ * ```
326
+ */
327
+ declare function MFAChallenge({ createClient, onSuccess, onCancel, onRecovery, redirectTo, signInUrl, recoveryUrl, onAuthEvent, }: MFAChallengeProps): react_jsx_runtime.JSX.Element;
328
+
329
+ interface MFAConfirmDialogProps {
330
+ /** Function to create a Supabase client */
331
+ createClient: CreateClientFn;
332
+ /** Whether the dialog is open */
333
+ open: boolean;
334
+ /** Callback when dialog open state changes */
335
+ onOpenChange: (open: boolean) => void;
336
+ /** Callback when MFA verification succeeds */
337
+ onConfirm: () => void | Promise<void>;
338
+ /** The factor ID to verify against */
339
+ factorId: string;
340
+ /** Factor type - determines if we need to send a code first */
341
+ factorType: "totp" | "phone";
342
+ /** Optional title override */
343
+ title?: string;
344
+ /** Optional description override */
345
+ description?: string;
346
+ /** Optional confirm button text */
347
+ confirmText?: string;
348
+ /** Whether the confirm action is in progress */
349
+ confirmLoading?: boolean;
350
+ }
351
+ /**
352
+ * MFAConfirmDialog - Reusable dialog for confirming sensitive actions with MFA
353
+ *
354
+ * Use this component anywhere you need to verify the user's identity before
355
+ * performing a sensitive action (e.g., removing MFA, changing email, etc.)
356
+ *
357
+ * @example
358
+ * ```tsx
359
+ * <MFAConfirmDialog
360
+ * createClient={createClient}
361
+ * open={showConfirm}
362
+ * onOpenChange={setShowConfirm}
363
+ * onConfirm={handleDelete}
364
+ * factorId={factor.id}
365
+ * factorType="totp"
366
+ * confirmText="Remove"
367
+ * />
368
+ * ```
369
+ */
370
+ declare function MFAConfirmDialog({ createClient, open, onOpenChange, onConfirm, factorId, factorType, title, description, confirmText, confirmLoading, }: MFAConfirmDialogProps): react_jsx_runtime.JSX.Element;
371
+
372
+ interface MFAContextType {
373
+ currentLevel: AuthenticatorAssuranceLevels | null;
374
+ nextLevel: AuthenticatorAssuranceLevels | null;
375
+ needsMFA: boolean;
376
+ loading: boolean;
377
+ refreshAAL: () => Promise<void>;
378
+ }
379
+ declare function useMFA(): MFAContextType;
380
+ interface MFAProviderProps {
381
+ /** Supabase client factory */
382
+ createClient: CreateClientFn;
383
+ /** Children to render */
384
+ children: ReactNode;
385
+ }
386
+ /**
387
+ * MFAProvider - Context provider for MFA state
388
+ *
389
+ * Tracks the current MFA assurance level and provides hooks for checking MFA status.
390
+ *
391
+ * @example
392
+ * ```tsx
393
+ * <MFAProvider createClient={createClient}>
394
+ * <App />
395
+ * </MFAProvider>
396
+ * ```
397
+ */
398
+ declare function MFAProvider({ createClient, children }: MFAProviderProps): react_jsx_runtime.JSX.Element;
399
+ /**
400
+ * useRequireMFA - Hook to check if MFA verification is required
401
+ *
402
+ * @example
403
+ * ```tsx
404
+ * const { needsMFA, loading, isVerified } = useRequireMFA();
405
+ *
406
+ * if (loading) return <Loading />;
407
+ * if (needsMFA) return <MFAChallenge />;
408
+ * if (!isVerified) return <AccessDenied />;
409
+ * ```
410
+ */
411
+ declare function useRequireMFA(): {
412
+ needsMFA: boolean;
413
+ loading: boolean;
414
+ isVerified: boolean;
415
+ };
416
+
417
+ interface MFARecoveryProps {
418
+ /** Supabase client factory */
419
+ createClient: CreateClientFn;
420
+ /** Callback when recovery succeeds */
421
+ onSuccess?: () => void;
422
+ /** Callback when user wants to go back to MFA challenge */
423
+ onBack?: () => void;
424
+ /** Callback when user cancels recovery */
425
+ onCancel?: () => void;
426
+ /** Where to redirect after successful recovery (if onSuccess not provided) */
427
+ redirectTo?: string;
428
+ /** MFA challenge URL to redirect back to (if onBack not provided) */
429
+ mfaChallengeUrl?: string;
430
+ /** Sign-in URL to redirect to on cancel (if onCancel not provided) */
431
+ signInUrl?: string;
432
+ }
433
+ /**
434
+ * MFARecovery - Supabase MFA recovery component
435
+ *
436
+ * Wraps the generic @caffeinebounce/ui MFARecovery component with Supabase recovery API.
437
+ *
438
+ * @example
439
+ * ```tsx
440
+ * <MFARecovery
441
+ * createClient={createClient}
442
+ * redirectTo="/profile#security"
443
+ * onBack={() => router.push("/mfa-challenge")}
444
+ * />
445
+ * ```
446
+ */
447
+ declare function MFARecovery({ createClient, onSuccess, onBack, onCancel, redirectTo, mfaChallengeUrl, signInUrl, }: MFARecoveryProps): react_jsx_runtime.JSX.Element;
448
+
449
+ interface TwoFactorSectionProps {
450
+ /** Function to create a Supabase client */
451
+ createClient: CreateClientFn;
452
+ }
453
+ declare function TwoFactorSection({ createClient }: TwoFactorSectionProps): react_jsx_runtime.JSX.Element;
454
+
455
+ interface DeleteAccountSectionProps {
456
+ /** Function to create a Supabase client */
457
+ createClient: CreateClientFn;
458
+ /** User's email address for confirmation */
459
+ email: string;
460
+ /** Optional retention days before permanent deletion (default: 30) */
461
+ retentionDays?: number;
462
+ }
463
+ /**
464
+ * DeleteAccountSection - Allow users to soft-delete their account
465
+ *
466
+ * This component provides a secure flow for account deletion with:
467
+ * - MFA verification if user has MFA enabled
468
+ * - Typed confirmation (user must type their email or "DELETE")
469
+ * - Clear explanation of consequences
470
+ *
471
+ * @example
472
+ * ```tsx
473
+ * <DeleteAccountSection
474
+ * createClient={createClient}
475
+ * email={user.email}
476
+ * retentionDays={30}
477
+ * />
478
+ * ```
479
+ */
480
+ declare function DeleteAccountSection({ createClient, email, retentionDays, }: DeleteAccountSectionProps): react_jsx_runtime.JSX.Element;
481
+
482
+ interface EmailSectionProps {
483
+ /** Function to create a Supabase client */
484
+ createClient: CreateClientFn;
485
+ /** User ID (reserved for future use) */
486
+ userId: string;
487
+ /** Current email address */
488
+ email: string;
489
+ /** Whether the email is verified */
490
+ isVerified: boolean;
491
+ /** Callback when email is changed */
492
+ onEmailChanged: (newEmail: string) => void;
493
+ }
494
+ declare function EmailSection({ createClient, userId: _userId, email, isVerified, onEmailChanged, }: EmailSectionProps): react_jsx_runtime.JSX.Element;
495
+
496
+ interface LinkedAccountsSectionProps {
497
+ /** Function to create a Supabase client */
498
+ createClient: CreateClientFn;
499
+ /** Callback when user needs to set a password before disconnecting */
500
+ onSetPasswordClick?: () => void;
501
+ /** Redirect URL after OAuth callback */
502
+ callbackRedirectUrl?: string;
503
+ /** External error message (e.g., from OAuth callback) */
504
+ linkError?: string | null;
505
+ }
506
+ declare function LinkedAccountsSection({ createClient, onSetPasswordClick, callbackRedirectUrl, linkError: externalLinkError, }: LinkedAccountsSectionProps): react_jsx_runtime.JSX.Element;
507
+
508
+ interface PasswordSectionProps {
509
+ /** Function to create a Supabase client */
510
+ createClient: CreateClientFn;
511
+ /** External control of dialog open state */
512
+ externalOpen?: boolean;
513
+ /** Callback when external open state changes */
514
+ onExternalOpenChange?: (open: boolean) => void;
515
+ }
516
+ declare function PasswordSection({ createClient, externalOpen, onExternalOpenChange, }: PasswordSectionProps): react_jsx_runtime.JSX.Element;
517
+
518
+ interface PhoneSectionProps {
519
+ /** Function to create a Supabase client */
520
+ createClient: CreateClientFn;
521
+ /** User ID (reserved for future use) */
522
+ userId: string;
523
+ /** Current phone number */
524
+ phone: string;
525
+ /** Whether the phone is verified */
526
+ isVerified: boolean;
527
+ /** Callback when phone is changed */
528
+ onPhoneChanged: (newPhone: string) => void;
529
+ /** API endpoint for phone verification (default: /api/phone/verify) */
530
+ verifyEndpoint?: string;
531
+ }
532
+ declare function PhoneSection({ createClient, userId: _userId, phone, isVerified, onPhoneChanged, verifyEndpoint, }: PhoneSectionProps): react_jsx_runtime.JSX.Element;
533
+
534
+ interface RecoverySectionProps {
535
+ /** Function to create a Supabase client */
536
+ createClient: CreateClientFn;
537
+ }
538
+ /**
539
+ * RecoverySection - Manage account recovery options
540
+ *
541
+ * Displays recovery methods like backup codes. Only shows backup codes
542
+ * if the user has MFA enabled.
543
+ */
544
+ declare function RecoverySection({ createClient }: RecoverySectionProps): react_jsx_runtime.JSX.Element;
545
+
546
+ interface AuthFormLayoutProps {
547
+ /** Form content (inside the card) */
548
+ children: ReactNode;
549
+ /** Footer content (outside the card, e.g., terms/privacy) */
550
+ footer?: ReactNode;
551
+ /** Home link URL */
552
+ homeUrl?: string;
553
+ /** Whether to show the home link */
554
+ showHomeLink?: boolean;
555
+ /** Link component to use (e.g., Next.js Link) */
556
+ LinkComponent?: ComponentType<{
557
+ href: string;
558
+ className?: string;
559
+ children: ReactNode;
560
+ }>;
561
+ /** Additional className for the card */
562
+ className?: string;
563
+ }
564
+ /**
565
+ * AuthFormLayout - Shared layout for auth form cards
566
+ *
567
+ * Provides consistent positioning, home link, and card styling for all auth forms.
568
+ */
569
+ declare function AuthFormLayout({ children, footer, homeUrl, showHomeLink, LinkComponent, className, }: AuthFormLayoutProps): react_jsx_runtime.JSX.Element;
570
+
571
+ interface AuthHeaderProps {
572
+ /** Logo configuration */
573
+ logo?: {
574
+ src: string;
575
+ alt: string;
576
+ width?: number;
577
+ height?: number;
578
+ };
579
+ /** Title text (e.g., "Sign in to {appName}") */
580
+ title: string;
581
+ /** Image component to use (e.g., Next.js Image) */
582
+ ImageComponent?: ComponentType<{
583
+ src: string;
584
+ alt: string;
585
+ width: number;
586
+ height: number;
587
+ className?: string;
588
+ }>;
589
+ /** Whether to show the logo inside the card. Default: true */
590
+ showLogo?: boolean;
591
+ /** Additional className */
592
+ className?: string;
593
+ }
594
+ /**
595
+ * AuthHeader - Shared header component for auth forms with logo and title
596
+ */
597
+ declare function AuthHeader({ logo, title, ImageComponent, className, }: AuthHeaderProps): react_jsx_runtime.JSX.Element;
598
+
599
+ type AuthPageVariant = "gradient" | "plain" | "ripple" | "rolling";
600
+ interface AuthColorScheme {
601
+ /** Page background color */
602
+ background?: string;
603
+ /** Secondary background for gradients */
604
+ backgroundAlt?: string;
605
+ /** Card background color */
606
+ cardBg?: string;
607
+ /** Card border color */
608
+ cardBorder?: string;
609
+ /** Primary accent color */
610
+ accent?: string;
611
+ /** Text on accent backgrounds */
612
+ accentForeground?: string;
613
+ /** Primary text color */
614
+ text?: string;
615
+ /** Muted text color */
616
+ textMuted?: string;
617
+ }
618
+ interface AuthPageLayoutProps {
619
+ /** Page content */
620
+ children: ReactNode;
621
+ /** Background variant. Default: "gradient" */
622
+ variant?: AuthPageVariant;
623
+ /** Color scheme override (merged with variant defaults) */
624
+ colorScheme?: Partial<AuthColorScheme>;
625
+ /** Logo to display above the sign-in card (external positioning) */
626
+ externalLogo?: {
627
+ src: string;
628
+ alt: string;
629
+ };
630
+ /** Size preset for the external logo. Default: "md" */
631
+ externalLogoSize?: "sm" | "md" | "lg" | "xl";
632
+ /** Image component for external logo rendering */
633
+ ExternalLogoImageComponent?: ComponentType<{
634
+ src: string;
635
+ alt: string;
636
+ width: number;
637
+ height: number;
638
+ className?: string;
639
+ style?: CSSProperties;
640
+ }>;
641
+ /** Logo element for rolling variant background watermark */
642
+ rollingLogo?: ReactNode;
643
+ /**
644
+ * Show the interactive ripple effect.
645
+ * @deprecated Use variant="ripple" instead.
646
+ */
647
+ showRippleEffect?: boolean;
648
+ }
649
+ /**
650
+ * AuthPageLayout - Full-page layout for auth pages with configurable background variant.
651
+ *
652
+ * @example Basic usage (gradient, backward compat)
653
+ * ```tsx
654
+ * <AuthPageLayout showRippleEffect>
655
+ * <SigninForm ... />
656
+ * </AuthPageLayout>
657
+ * ```
658
+ *
659
+ * @example Rolling variant
660
+ * ```tsx
661
+ * <AuthPageLayout variant="rolling" rollingLogo={<MyLogo />}>
662
+ * <SigninForm ... />
663
+ * </AuthPageLayout>
664
+ * ```
665
+ */
666
+ declare function AuthPageLayout({ children, variant: variantProp, colorScheme, showRippleEffect, externalLogo, externalLogoSize, ExternalLogoImageComponent, rollingLogo, }: AuthPageLayoutProps): react_jsx_runtime.JSX.Element;
667
+
668
+ /**
669
+ * Supported sign-in methods.
670
+ * NOTE: Keep in sync with OAuthProvider type in types.ts.
671
+ * Add new providers here only after they are fully wired into the sign-in flow.
672
+ */
673
+ type SignInMethod = "email" | "google" | "azure";
674
+ /** Stored last sign-in data */
675
+ interface LastSignInData {
676
+ /** The authentication method used */
677
+ method: SignInMethod;
678
+ /** The email address (will be masked when displayed) */
679
+ email: string;
680
+ /** ISO timestamp of when this sign-in occurred */
681
+ timestamp: string;
682
+ }
683
+ /** Options for the useLastSignIn hook */
684
+ interface UseLastSignInOptions {
685
+ /** localStorage key for storing data. Default: "last_signin" */
686
+ storageKey?: string;
687
+ }
688
+ /**
689
+ * Mask an email address for privacy display.
690
+ * Shows first character, asterisks, and domain.
691
+ * @example "user@example.com" -> "u***@example.com"
692
+ */
693
+ declare function maskEmail(email: string): string;
694
+ /**
695
+ * Hook to manage last sign-in method tracking.
696
+ *
697
+ * Stores and retrieves the user's last successful sign-in method
698
+ * in localStorage to help them remember how they signed up.
699
+ *
700
+ * @example
701
+ * ```tsx
702
+ * function SigninPage() {
703
+ * const { lastSignIn, recordSignIn, clearLastSignIn } = useLastSignIn();
704
+ *
705
+ * // Show hint if available
706
+ * if (lastSignIn) {
707
+ * return <LastSignInHint {...lastSignIn} onClear={clearLastSignIn} />;
708
+ * }
709
+ *
710
+ * // Record on successful sign-in
711
+ * const handleSuccess = (method, email) => {
712
+ * recordSignIn(method, email);
713
+ * };
714
+ * }
715
+ * ```
716
+ */
717
+ declare function useLastSignIn(options?: UseLastSignInOptions): {
718
+ /** The last sign-in data, or null if none stored */
719
+ lastSignIn: LastSignInData | null;
720
+ /** Whether the hook has finished loading from localStorage */
721
+ isLoaded: boolean;
722
+ /** Record a new sign-in */
723
+ recordSignIn: (method: SignInMethod, email: string) => void;
724
+ /** Clear stored sign-in data */
725
+ clearLastSignIn: () => void;
726
+ /** Mark an OAuth method as pending before redirecting to the provider */
727
+ markPendingOAuthSignIn: (method: Exclude<SignInMethod, "email">) => void;
728
+ /** Complete pending OAuth sign-in recording (call after OAuth callback) */
729
+ completePendingOAuthSignIn: (email: string) => void;
730
+ };
731
+
732
+ interface LastSignInHintProps {
733
+ /** The sign-in method that was last used */
734
+ method: SignInMethod;
735
+ /** The email address associated with the sign-in */
736
+ email: string;
737
+ /** Whether to mask the email for privacy. Default: true */
738
+ maskEmailAddress?: boolean;
739
+ /** Called when user clicks "Not you?" to clear the hint */
740
+ onClear?: () => void;
741
+ /** Additional className for the container */
742
+ className?: string;
743
+ }
744
+ /**
745
+ * LastSignInHint - Displays a helpful hint about the user's last sign-in method.
746
+ *
747
+ * Shows a subtle banner reminding users which authentication method they
748
+ * previously used, helping avoid confusion between email/password and OAuth.
749
+ *
750
+ * @example
751
+ * ```tsx
752
+ * <LastSignInHint
753
+ * method="google"
754
+ * email="user@example.com"
755
+ * onClear={() => clearLastSignIn()}
756
+ * />
757
+ * ```
758
+ */
759
+ declare function LastSignInHint({ method, email, maskEmailAddress, onClear, className, }: LastSignInHintProps): react_jsx_runtime.JSX.Element;
760
+
761
+ /**
762
+ * OAuth provider icons - Google and Microsoft
763
+ * These are inline SVGs for reliable rendering without external dependencies
764
+ */
765
+ interface IconProps {
766
+ className?: string;
767
+ monochrome?: boolean;
768
+ }
769
+ declare function GoogleIcon({ className, monochrome }: IconProps): react_jsx_runtime.JSX.Element;
770
+ declare function MicrosoftIcon({ className, monochrome }: IconProps): react_jsx_runtime.JSX.Element;
771
+
772
+ /**
773
+ * Generate cryptographically secure recovery codes
774
+ * Uses crypto.getRandomValues() for secure random number generation
775
+ */
776
+ declare function generateRecoveryCodes(count?: number): string[];
777
+
778
+ export { type AuthFormConfig, AuthFormLayout, type AuthFormLayoutProps, AuthHeader, type AuthHeaderProps, type AuthLinks, type AuthLogo, AuthPageLayout, type AuthPageLayoutProps, type ConsentItem, type CreateClientFn, DeleteAccountSection, type DeleteAccountSectionProps, EmailSection, type EmailSectionProps, ForgotPasswordForm, type ForgotPasswordFormProps, GoogleIcon, type LastSignInData, LastSignInHint, type LastSignInHintProps, LinkedAccountsSection, type LinkedAccountsSectionProps, MFAChallenge, type MFAChallengeProps, MFAConfirmDialog, type MFAConfirmDialogProps, MFAProvider, type MFAProviderProps, MFARecovery, type MFARecoveryProps, MicrosoftIcon, type OAuthProvider, PasswordSection, type PasswordSectionProps, PhoneSection, type PhoneSectionProps, RecoverySection, type RecoverySectionProps, ResetPasswordForm, type ResetPasswordFormProps, type SignInMethod, SigninForm, type SigninFormProps, SignupForm, type SignupFormProps, TwoFactorSection, type TwoFactorSectionProps, type UseLastSignInOptions, defaultAuthLinks, generateRecoveryCodes, maskEmail, useLastSignIn, useMFA, useRequireMFA };