@tern-secure/types 1.1.0-canary.v20251003171521 → 1.1.0-canary.v20251008165428
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/dist/esm/index.js +0 -6
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +218 -282
- package/dist/index.d.ts +218 -282
- package/dist/index.js +0 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -136,11 +136,14 @@ interface CookieStore {
|
|
|
136
136
|
delete(name: string): Promise<void>;
|
|
137
137
|
}
|
|
138
138
|
interface CookieOptions {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
139
|
+
httpOnly?: boolean | undefined;
|
|
140
|
+
path?: string | undefined;
|
|
141
|
+
partitioned?: boolean | undefined;
|
|
142
|
+
maxAge?: number | undefined;
|
|
143
|
+
expires?: Date | undefined;
|
|
144
|
+
priority?: 'low' | 'medium' | 'high' | undefined;
|
|
145
|
+
sameSite?: 'strict' | 'lax' | 'none' | undefined;
|
|
146
|
+
secure?: boolean | undefined;
|
|
144
147
|
}
|
|
145
148
|
|
|
146
149
|
type AuthErrorCode = keyof typeof ERRORS;
|
|
@@ -191,22 +194,25 @@ interface CorsOptions {
|
|
|
191
194
|
skipSameOrigin?: boolean;
|
|
192
195
|
}
|
|
193
196
|
interface SessionCookieConfig {
|
|
194
|
-
domain?: string;
|
|
195
197
|
path?: string;
|
|
196
198
|
httpOnly?: boolean;
|
|
197
199
|
sameSite?: 'strict' | 'lax' | 'none';
|
|
200
|
+
partitioned?: boolean;
|
|
198
201
|
maxAge?: number;
|
|
202
|
+
priority?: 'low' | 'medium' | 'high';
|
|
199
203
|
}
|
|
200
204
|
interface TokenCookieConfig {
|
|
201
|
-
domain?: string;
|
|
202
205
|
path: string;
|
|
203
206
|
httpOnly: boolean;
|
|
204
207
|
sameSite: 'strict' | 'lax' | 'none';
|
|
208
|
+
partitioned?: boolean;
|
|
205
209
|
maxAge: number;
|
|
210
|
+
expires?: Date;
|
|
211
|
+
priority?: 'low' | 'medium' | 'high';
|
|
206
212
|
}
|
|
207
213
|
interface CookieOpts extends CookieOptions {
|
|
208
|
-
namePrefix?: string;
|
|
209
214
|
domain?: string;
|
|
215
|
+
namePrefix?: string;
|
|
210
216
|
session?: SessionCookieConfig;
|
|
211
217
|
}
|
|
212
218
|
interface RateLimitOptions {
|
|
@@ -253,259 +259,6 @@ interface TernSecureHandlerOptions {
|
|
|
253
259
|
basePath?: string;
|
|
254
260
|
}
|
|
255
261
|
|
|
256
|
-
/**
|
|
257
|
-
* Defines the basic structure for color theming.
|
|
258
|
-
*/
|
|
259
|
-
interface ThemeColors {
|
|
260
|
-
primary?: string;
|
|
261
|
-
secondary?: string;
|
|
262
|
-
accent?: string;
|
|
263
|
-
background?: string;
|
|
264
|
-
text?: string;
|
|
265
|
-
error?: string;
|
|
266
|
-
success?: string;
|
|
267
|
-
}
|
|
268
|
-
/**
|
|
269
|
-
* Defines the basic structure for font theming.
|
|
270
|
-
*/
|
|
271
|
-
interface ThemeFonts {
|
|
272
|
-
primary?: string;
|
|
273
|
-
secondary?: string;
|
|
274
|
-
}
|
|
275
|
-
/**
|
|
276
|
-
* Defines the basic structure for spacing and layout theming.
|
|
277
|
-
*/
|
|
278
|
-
interface ThemeSpacing {
|
|
279
|
-
small?: string | number;
|
|
280
|
-
medium?: string | number;
|
|
281
|
-
large?: string | number;
|
|
282
|
-
}
|
|
283
|
-
/**
|
|
284
|
-
* Defines the basic structure for border radius theming.
|
|
285
|
-
*/
|
|
286
|
-
interface ThemeBorderRadius {
|
|
287
|
-
small?: string | number;
|
|
288
|
-
medium?: string | number;
|
|
289
|
-
large?: string | number;
|
|
290
|
-
}
|
|
291
|
-
/**
|
|
292
|
-
* Allows for overriding styles of specific UI components.
|
|
293
|
-
* Properties can be CSS-in-JS objects or class names, depending on implementation.
|
|
294
|
-
*/
|
|
295
|
-
interface ThemeComponentStyles {
|
|
296
|
-
button?: Record<string, any> | string;
|
|
297
|
-
input?: Record<string, any> | string;
|
|
298
|
-
card?: Record<string, any> | string;
|
|
299
|
-
label?: Record<string, any> | string;
|
|
300
|
-
}
|
|
301
|
-
/**
|
|
302
|
-
* Defines the overall appearance/theme configuration.
|
|
303
|
-
* This allows for broad customization of the UI components.
|
|
304
|
-
*/
|
|
305
|
-
interface Appearance {
|
|
306
|
-
colors?: ThemeColors;
|
|
307
|
-
fonts?: ThemeFonts;
|
|
308
|
-
spacing?: ThemeSpacing;
|
|
309
|
-
borderRadius?: ThemeBorderRadius;
|
|
310
|
-
componentStyles?: ThemeComponentStyles;
|
|
311
|
-
variables?: Record<string, string | number>;
|
|
312
|
-
}
|
|
313
|
-
/**
|
|
314
|
-
* Base UI configuration shared between SignIn and SignUp
|
|
315
|
-
*/
|
|
316
|
-
interface BaseAuthUIConfig {
|
|
317
|
-
/** Visual appearance configuration */
|
|
318
|
-
appearance?: Appearance;
|
|
319
|
-
/** Application logo URL or SVG string */
|
|
320
|
-
logo?: string;
|
|
321
|
-
/** Application name for display */
|
|
322
|
-
appName?: string;
|
|
323
|
-
/** Render mode for cross-platform support */
|
|
324
|
-
renderMode?: 'modal' | 'page' | 'embedded';
|
|
325
|
-
/** Layout direction */
|
|
326
|
-
layout?: 'vertical' | 'horizontal';
|
|
327
|
-
/** Custom loading message */
|
|
328
|
-
loadingMessage?: string;
|
|
329
|
-
/** Loading spinner variant */
|
|
330
|
-
loadingSpinnerVariant?: 'circular' | 'linear' | 'dots';
|
|
331
|
-
/** Accessibility configuration */
|
|
332
|
-
a11y?: {
|
|
333
|
-
/** ARIA labels and descriptions */
|
|
334
|
-
labels?: Record<string, string>;
|
|
335
|
-
/** Element to receive initial focus */
|
|
336
|
-
initialFocus?: string;
|
|
337
|
-
/** Whether to trap focus within the auth UI */
|
|
338
|
-
trapFocus?: boolean;
|
|
339
|
-
};
|
|
340
|
-
}
|
|
341
|
-
/**
|
|
342
|
-
* Sign-in specific UI configuration
|
|
343
|
-
*/
|
|
344
|
-
interface SignInUIConfig extends BaseAuthUIConfig {
|
|
345
|
-
/** Social sign-in buttons configuration */
|
|
346
|
-
socialButtons?: {
|
|
347
|
-
google?: boolean;
|
|
348
|
-
microsoft?: boolean;
|
|
349
|
-
github?: boolean;
|
|
350
|
-
facebook?: boolean;
|
|
351
|
-
twitter?: boolean;
|
|
352
|
-
apple?: boolean;
|
|
353
|
-
linkedin?: boolean;
|
|
354
|
-
layout?: 'vertical' | 'horizontal';
|
|
355
|
-
size?: 'small' | 'medium' | 'large';
|
|
356
|
-
};
|
|
357
|
-
/** "Remember me" checkbox configuration */
|
|
358
|
-
rememberMe?: {
|
|
359
|
-
enabled?: boolean;
|
|
360
|
-
defaultChecked?: boolean;
|
|
361
|
-
};
|
|
362
|
-
/** Sign-up link configuration */
|
|
363
|
-
signUpLink?: {
|
|
364
|
-
enabled?: boolean;
|
|
365
|
-
text?: string;
|
|
366
|
-
href?: string;
|
|
367
|
-
};
|
|
368
|
-
}
|
|
369
|
-
/**
|
|
370
|
-
* Sign-up specific UI configuration
|
|
371
|
-
*/
|
|
372
|
-
interface SignUpUIConfig extends BaseAuthUIConfig {
|
|
373
|
-
/** Password requirements display configuration */
|
|
374
|
-
passwordRequirements?: {
|
|
375
|
-
show?: boolean;
|
|
376
|
-
rules?: Array<{
|
|
377
|
-
rule: string;
|
|
378
|
-
description: string;
|
|
379
|
-
}>;
|
|
380
|
-
};
|
|
381
|
-
/** Terms and conditions configuration */
|
|
382
|
-
terms?: {
|
|
383
|
-
enabled?: boolean;
|
|
384
|
-
text?: string;
|
|
385
|
-
link?: string;
|
|
386
|
-
};
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
interface TernSecureSession {
|
|
390
|
-
token: string | null;
|
|
391
|
-
expiresAt?: number;
|
|
392
|
-
}
|
|
393
|
-
type SignInFormValues = {
|
|
394
|
-
email: string;
|
|
395
|
-
password: string;
|
|
396
|
-
phoneNumber?: string;
|
|
397
|
-
};
|
|
398
|
-
type SignInInitialValue = Partial<SignInFormValues>;
|
|
399
|
-
type SignUpFormValues = {
|
|
400
|
-
email: string;
|
|
401
|
-
password: string;
|
|
402
|
-
confirmPassword?: string;
|
|
403
|
-
displayName?: string;
|
|
404
|
-
};
|
|
405
|
-
type SignUpInitialValue = Partial<SignUpFormValues>;
|
|
406
|
-
interface SignInResponse {
|
|
407
|
-
success: boolean;
|
|
408
|
-
message?: string;
|
|
409
|
-
error?: any | undefined;
|
|
410
|
-
user?: any;
|
|
411
|
-
}
|
|
412
|
-
interface AuthError extends Error {
|
|
413
|
-
code?: any | string;
|
|
414
|
-
message: string;
|
|
415
|
-
response?: SignInResponse;
|
|
416
|
-
}
|
|
417
|
-
declare function isSignInResponse(value: any): value is SignInResponse;
|
|
418
|
-
interface AuthActions {
|
|
419
|
-
signInWithEmail: (email: string, password: string) => Promise<SignInResponse>;
|
|
420
|
-
signInWithGoogle: () => Promise<void>;
|
|
421
|
-
signInWithMicrosoft: () => Promise<void>;
|
|
422
|
-
signOut: () => Promise<void>;
|
|
423
|
-
getRedirectResult: () => Promise<any>;
|
|
424
|
-
getIdToken: () => Promise<string | null>;
|
|
425
|
-
createUserWithEmailAndPassword?: (email: string, password: string) => Promise<SignInResponse>;
|
|
426
|
-
sendEmailVerification?: (user: TernSecureUser) => Promise<void>;
|
|
427
|
-
}
|
|
428
|
-
interface RedirectConfig {
|
|
429
|
-
redirectUrl?: string;
|
|
430
|
-
isReturn?: boolean;
|
|
431
|
-
priority?: number;
|
|
432
|
-
}
|
|
433
|
-
interface SignInProps extends RedirectConfig {
|
|
434
|
-
initialValue?: SignInInitialValue;
|
|
435
|
-
logo?: string;
|
|
436
|
-
appName?: string;
|
|
437
|
-
appearance?: Appearance;
|
|
438
|
-
onError?: (error: AuthError) => void;
|
|
439
|
-
onSuccess?: (user: TernSecureUser | null) => void;
|
|
440
|
-
}
|
|
441
|
-
/**
|
|
442
|
-
* SignUpProps interface defines the properties for the sign-up component.
|
|
443
|
-
* It extends RedirectConfig to include redirect-related properties.
|
|
444
|
-
*/
|
|
445
|
-
interface SignUpProps extends RedirectConfig {
|
|
446
|
-
initialValue?: SignUpInitialValue;
|
|
447
|
-
logo?: string;
|
|
448
|
-
appName?: string;
|
|
449
|
-
appearance?: Appearance;
|
|
450
|
-
onError?: (error: AuthError) => void;
|
|
451
|
-
onSuccess?: (user: TernSecureUser | null) => void;
|
|
452
|
-
}
|
|
453
|
-
/**
|
|
454
|
-
* Defines the contract for a TernSecure instance.
|
|
455
|
-
* This instance provides authentication state, user information, and methods
|
|
456
|
-
* for managing the authentication lifecycle. It is designed to be used by
|
|
457
|
-
* UI packages like tern-ui, which act as "dumb" renderers.
|
|
458
|
-
*/
|
|
459
|
-
interface TernSecureInstanceOld {
|
|
460
|
-
/** Indicates if the user is currently signed in. */
|
|
461
|
-
isSignedIn: () => boolean;
|
|
462
|
-
/** The current authenticated user object, or null if not signed in. */
|
|
463
|
-
user: TernSecureUser | null;
|
|
464
|
-
/** The current user session information, or null if not signed in. */
|
|
465
|
-
session: TernSecureSession | null;
|
|
466
|
-
/** Initiates the sign-out process for the current user. */
|
|
467
|
-
signOut: () => Promise<void>;
|
|
468
|
-
/**
|
|
469
|
-
* Prepares or signals to mount the sign-in interface.
|
|
470
|
-
* @param options Optional configuration or initial state for the sign-in UI, conforming to SignInProps.
|
|
471
|
-
*/
|
|
472
|
-
mountSignIn: (options?: SignInProps) => void;
|
|
473
|
-
/** Cleans up or signals to unmount the sign-in interface. */
|
|
474
|
-
unmountSignIn: () => void;
|
|
475
|
-
/**
|
|
476
|
-
* Prepares or signals to mount the sign-up interface.
|
|
477
|
-
* @param options Optional configuration or initial state for the sign-up UI, conforming to SignUpProps.
|
|
478
|
-
*/
|
|
479
|
-
mountSignUp: (options?: SignUpProps) => void;
|
|
480
|
-
/** Cleans up or signals to unmount the sign-up interface. */
|
|
481
|
-
unmountSignUp: () => void;
|
|
482
|
-
/**
|
|
483
|
-
* Determines if a redirect is necessary based on the current authentication
|
|
484
|
-
* state and the given path.
|
|
485
|
-
* @param currentPath The current URL path.
|
|
486
|
-
* @returns True if a redirect is needed, false otherwise, or a string path to redirect to.
|
|
487
|
-
*/
|
|
488
|
-
shouldRedirect: (currentPath: string) => boolean | string;
|
|
489
|
-
/**
|
|
490
|
-
* Constructs a URL, appending necessary redirect parameters.
|
|
491
|
-
* Useful for redirecting back to the original page after authentication.
|
|
492
|
-
* @param baseUrl The base URL to which redirect parameters should be added.
|
|
493
|
-
* @returns The new URL string with redirect parameters.
|
|
494
|
-
*/
|
|
495
|
-
constructUrlWithRedirect: (baseUrl: string) => string;
|
|
496
|
-
/**
|
|
497
|
-
* Redirects the user to the configured login page.
|
|
498
|
-
* @param redirectUrl Optional URL to redirect to after successful login.
|
|
499
|
-
*/
|
|
500
|
-
redirectToLogin: (redirectUrl?: string) => void;
|
|
501
|
-
/** Indicates if an authentication operation is currently in progress. */
|
|
502
|
-
isLoading: boolean;
|
|
503
|
-
/** Holds any error that occurred during an authentication operation, or null otherwise. */
|
|
504
|
-
error: Error | null;
|
|
505
|
-
/** Indicates if the user has verified their email address. */
|
|
506
|
-
sendVerificationEmail: () => Promise<void>;
|
|
507
|
-
}
|
|
508
|
-
|
|
509
262
|
type SessionStatus = 'active' | 'expired' | 'revoked' | 'pending';
|
|
510
263
|
/**
|
|
511
264
|
* parsed can be replaced with
|
|
@@ -596,7 +349,7 @@ interface SessionResult {
|
|
|
596
349
|
}
|
|
597
350
|
|
|
598
351
|
type SignInStatus = 'idle' | 'pending_email_password' | 'pending_social' | 'pending_mfa' | 'redirecting' | 'success' | 'error';
|
|
599
|
-
type
|
|
352
|
+
type SignInFormValues = {
|
|
600
353
|
email: string;
|
|
601
354
|
password: string;
|
|
602
355
|
phoneNumber?: string;
|
|
@@ -611,17 +364,17 @@ interface AuthErrorTree extends Error {
|
|
|
611
364
|
message: string;
|
|
612
365
|
response?: any | string;
|
|
613
366
|
}
|
|
614
|
-
interface
|
|
367
|
+
interface SignInResponse {
|
|
615
368
|
success: boolean;
|
|
616
369
|
message?: string;
|
|
617
370
|
error?: any | undefined;
|
|
618
371
|
user?: any;
|
|
619
372
|
}
|
|
620
|
-
type
|
|
621
|
-
interface ResendEmailVerification extends
|
|
373
|
+
type SignInInitialValue = Partial<SignInFormValues>;
|
|
374
|
+
interface ResendEmailVerification extends SignInResponse {
|
|
622
375
|
isVerified?: boolean;
|
|
623
376
|
}
|
|
624
|
-
declare function isSignInResponseTree(value: any): value is
|
|
377
|
+
declare function isSignInResponseTree(value: any): value is SignInResponse;
|
|
625
378
|
interface SignInResource {
|
|
626
379
|
/**
|
|
627
380
|
* The current status of the sign-in process.
|
|
@@ -632,7 +385,7 @@ interface SignInResource {
|
|
|
632
385
|
* @param params - The sign-in form values.
|
|
633
386
|
* @returns A promise that resolves with the sign-in response.
|
|
634
387
|
*/
|
|
635
|
-
withEmailAndPassword: (params:
|
|
388
|
+
withEmailAndPassword: (params: SignInFormValues) => Promise<SignInResponse>;
|
|
636
389
|
/**
|
|
637
390
|
* @param provider - The identifier of the social provider (e.g., 'google', 'microsoft', 'github').
|
|
638
391
|
* @param options - Optional configuration for the social sign-in flow.
|
|
@@ -640,14 +393,14 @@ interface SignInResource {
|
|
|
640
393
|
*/
|
|
641
394
|
withSocialProvider: (provider: string, options?: {
|
|
642
395
|
mode?: 'popup' | 'redirect';
|
|
643
|
-
}) => Promise<
|
|
396
|
+
}) => Promise<SignInResponse | void>;
|
|
644
397
|
/**
|
|
645
398
|
* Completes an MFA (Multi-Factor Authentication) step after a primary authentication attempt.
|
|
646
399
|
* @param mfaToken - The MFA token or code submitted by the user.
|
|
647
400
|
* @param mfaContext - Optional context or session data from the MFA initiation step.
|
|
648
401
|
* @returns A promise that resolves with the sign-in response upon successful MFA verification.
|
|
649
402
|
*/
|
|
650
|
-
completeMfaSignIn: (mfaToken: string, mfaContext?: any) => Promise<
|
|
403
|
+
completeMfaSignIn: (mfaToken: string, mfaContext?: any) => Promise<SignInResponse>;
|
|
651
404
|
/**
|
|
652
405
|
* Sends a password reset email to the given email address.
|
|
653
406
|
* @param email - The user's email address.
|
|
@@ -663,7 +416,7 @@ interface SignInResource {
|
|
|
663
416
|
* Checks the result of a redirect-based sign-in flow, typically used in OAuth or SSO scenarios.
|
|
664
417
|
* @returns A promise that resolves with the sign-in response or null if no result is available.
|
|
665
418
|
*/
|
|
666
|
-
checkRedirectResult: () => Promise<
|
|
419
|
+
checkRedirectResult: () => Promise<SignInResponse | null>;
|
|
667
420
|
}
|
|
668
421
|
|
|
669
422
|
interface SignUpResource {
|
|
@@ -681,7 +434,7 @@ interface SignUpResource {
|
|
|
681
434
|
*/
|
|
682
435
|
withSocialProvider: (provider: string, options?: {
|
|
683
436
|
mode?: 'popup' | 'redirect';
|
|
684
|
-
}) => Promise<
|
|
437
|
+
}) => Promise<SignInResponse | void>;
|
|
685
438
|
}
|
|
686
439
|
type SignUpStatus = 'missing_requirements' | 'complete' | 'abandoned';
|
|
687
440
|
|
|
@@ -776,10 +529,10 @@ interface TernSecureState {
|
|
|
776
529
|
isAuthenticated: boolean;
|
|
777
530
|
token: any | null;
|
|
778
531
|
email: string | null;
|
|
779
|
-
status:
|
|
532
|
+
status: 'loading' | 'authenticated' | 'unauthenticated' | 'unverified';
|
|
780
533
|
user?: TernSecureUser | null;
|
|
781
534
|
}
|
|
782
|
-
type AuthProviderStatus =
|
|
535
|
+
type AuthProviderStatus = 'idle' | 'pending' | 'error' | 'success';
|
|
783
536
|
declare const DEFAULT_TERN_SECURE_STATE: TernSecureState;
|
|
784
537
|
interface TernSecureAuthProvider {
|
|
785
538
|
/** Current auth state */
|
|
@@ -799,8 +552,8 @@ interface TernSecureAuthProvider {
|
|
|
799
552
|
/** Sign out the current user */
|
|
800
553
|
signOut(): Promise<void>;
|
|
801
554
|
}
|
|
802
|
-
type Persistence =
|
|
803
|
-
type Mode$1 =
|
|
555
|
+
type Persistence = 'local' | 'session' | 'browserCookie' | 'none';
|
|
556
|
+
type Mode$1 = 'browser' | 'server';
|
|
804
557
|
type TernAuthSDK = {
|
|
805
558
|
/** SDK package name (e.g., @tern-secure/auth) */
|
|
806
559
|
name: string;
|
|
@@ -852,7 +605,7 @@ type EventHandler<Events extends TernSecureEvent> = (payload: TernAuthEventPaylo
|
|
|
852
605
|
type TernAuthEventPayload = {
|
|
853
606
|
status: TernSecureAuthStatus;
|
|
854
607
|
};
|
|
855
|
-
type TernSecureAuthStatus =
|
|
608
|
+
type TernSecureAuthStatus = 'error' | 'loading' | 'ready';
|
|
856
609
|
type onEventListener = <E extends TernSecureEvent>(event: E, handler: EventHandler<E>, opt?: {
|
|
857
610
|
notify?: boolean;
|
|
858
611
|
}) => void;
|
|
@@ -891,6 +644,14 @@ interface TernSecureAuth {
|
|
|
891
644
|
requiresVerification: boolean;
|
|
892
645
|
/** Initialize TernSecureAuth */
|
|
893
646
|
initialize(options?: TernSecureAuthOptions): Promise<void>;
|
|
647
|
+
/**
|
|
648
|
+
* @internal
|
|
649
|
+
*/
|
|
650
|
+
_internal_getOption<K extends keyof TernSecureAuthOptions>(key: K): TernSecureAuthOptions[K];
|
|
651
|
+
/**
|
|
652
|
+
* @internal
|
|
653
|
+
*/
|
|
654
|
+
_internal_getAllOptions(): Readonly<TernSecureAuthOptions>;
|
|
894
655
|
/** Current user*/
|
|
895
656
|
user: TernSecureUser | null | undefined;
|
|
896
657
|
/** Current session */
|
|
@@ -910,7 +671,22 @@ interface TernSecureAuth {
|
|
|
910
671
|
/** Remove event listener */
|
|
911
672
|
off: OffEventListener;
|
|
912
673
|
addListener: (callback: ListenerCallback) => UnsubscribeCallback;
|
|
674
|
+
/** Get redirect result from OAuth flows */
|
|
675
|
+
getRedirectResult: () => Promise<any>;
|
|
676
|
+
/** Navigate to SignIn page */
|
|
677
|
+
redirectToSignIn(options?: SignInRedirectOptions): Promise<unknown>;
|
|
678
|
+
/** Navigate to SignUp page */
|
|
679
|
+
redirectToSignUp(options?: SignUpRedirectOptions): Promise<unknown>;
|
|
680
|
+
redirectAfterSignIn: () => void;
|
|
681
|
+
redirectAfterSignUp: () => void;
|
|
913
682
|
}
|
|
683
|
+
type SignUpFormValues = {
|
|
684
|
+
email: string;
|
|
685
|
+
password: string;
|
|
686
|
+
confirmPassword?: string;
|
|
687
|
+
displayName?: string;
|
|
688
|
+
};
|
|
689
|
+
type SignUpInitialValue = Partial<SignUpFormValues>;
|
|
914
690
|
interface TernSecureAuthFactory {
|
|
915
691
|
create(options?: TernSecureAuthOptions): TernSecureAuth;
|
|
916
692
|
}
|
|
@@ -932,6 +708,166 @@ type TernVerificationResult = (DecodedIdToken & {
|
|
|
932
708
|
valid: false;
|
|
933
709
|
error: AuthErrorResponse;
|
|
934
710
|
};
|
|
711
|
+
/**
|
|
712
|
+
* Props for SignIn component focusing on UI concerns
|
|
713
|
+
*/
|
|
714
|
+
type SignInProps = {
|
|
715
|
+
/** Routing Path */
|
|
716
|
+
path?: string;
|
|
717
|
+
/** URL to navigate to after successfully sign-in */
|
|
718
|
+
forceRedirectUrl?: string | null;
|
|
719
|
+
/** Initial form values */
|
|
720
|
+
initialValue?: SignInInitialValue;
|
|
721
|
+
/** Callbacks */
|
|
722
|
+
onSuccess?: (user: TernSecureUser | null) => void;
|
|
723
|
+
} & SignUpRedirectUrl;
|
|
724
|
+
/**
|
|
725
|
+
* Props for SignUp component focusing on UI concerns
|
|
726
|
+
*/
|
|
727
|
+
type SignUpProps = {
|
|
728
|
+
/** URL to navigate to after successfully sign-up */
|
|
729
|
+
forceRedirectUrl?: string | null;
|
|
730
|
+
/** Initial form values */
|
|
731
|
+
initialValue?: SignUpInitialValue;
|
|
732
|
+
/** Callbacks */
|
|
733
|
+
onSubmit?: (values: SignUpFormValues) => Promise<void>;
|
|
734
|
+
onSuccess?: (user: TernSecureUser | null) => void;
|
|
735
|
+
} & SignInRedirectUrl;
|
|
736
|
+
type SignInRedirectOptions = RedirectOptions;
|
|
737
|
+
type SignUpRedirectOptions = RedirectOptions;
|
|
738
|
+
|
|
739
|
+
/**
|
|
740
|
+
* Defines the basic structure for color theming.
|
|
741
|
+
*/
|
|
742
|
+
interface ThemeColors {
|
|
743
|
+
primary?: string;
|
|
744
|
+
secondary?: string;
|
|
745
|
+
accent?: string;
|
|
746
|
+
background?: string;
|
|
747
|
+
text?: string;
|
|
748
|
+
error?: string;
|
|
749
|
+
success?: string;
|
|
750
|
+
}
|
|
751
|
+
/**
|
|
752
|
+
* Defines the basic structure for font theming.
|
|
753
|
+
*/
|
|
754
|
+
interface ThemeFonts {
|
|
755
|
+
primary?: string;
|
|
756
|
+
secondary?: string;
|
|
757
|
+
}
|
|
758
|
+
/**
|
|
759
|
+
* Defines the basic structure for spacing and layout theming.
|
|
760
|
+
*/
|
|
761
|
+
interface ThemeSpacing {
|
|
762
|
+
small?: string | number;
|
|
763
|
+
medium?: string | number;
|
|
764
|
+
large?: string | number;
|
|
765
|
+
}
|
|
766
|
+
/**
|
|
767
|
+
* Defines the basic structure for border radius theming.
|
|
768
|
+
*/
|
|
769
|
+
interface ThemeBorderRadius {
|
|
770
|
+
small?: string | number;
|
|
771
|
+
medium?: string | number;
|
|
772
|
+
large?: string | number;
|
|
773
|
+
}
|
|
774
|
+
/**
|
|
775
|
+
* Allows for overriding styles of specific UI components.
|
|
776
|
+
* Properties can be CSS-in-JS objects or class names, depending on implementation.
|
|
777
|
+
*/
|
|
778
|
+
interface ThemeComponentStyles {
|
|
779
|
+
button?: Record<string, any> | string;
|
|
780
|
+
input?: Record<string, any> | string;
|
|
781
|
+
card?: Record<string, any> | string;
|
|
782
|
+
label?: Record<string, any> | string;
|
|
783
|
+
}
|
|
784
|
+
/**
|
|
785
|
+
* Defines the overall appearance/theme configuration.
|
|
786
|
+
* This allows for broad customization of the UI components.
|
|
787
|
+
*/
|
|
788
|
+
interface Appearance {
|
|
789
|
+
colors?: ThemeColors;
|
|
790
|
+
fonts?: ThemeFonts;
|
|
791
|
+
spacing?: ThemeSpacing;
|
|
792
|
+
borderRadius?: ThemeBorderRadius;
|
|
793
|
+
componentStyles?: ThemeComponentStyles;
|
|
794
|
+
variables?: Record<string, string | number>;
|
|
795
|
+
}
|
|
796
|
+
/**
|
|
797
|
+
* Base UI configuration shared between SignIn and SignUp
|
|
798
|
+
*/
|
|
799
|
+
interface BaseAuthUIConfig {
|
|
800
|
+
/** Visual appearance configuration */
|
|
801
|
+
appearance?: Appearance;
|
|
802
|
+
/** Application logo URL or SVG string */
|
|
803
|
+
logo?: string;
|
|
804
|
+
/** Application name for display */
|
|
805
|
+
appName?: string;
|
|
806
|
+
/** Render mode for cross-platform support */
|
|
807
|
+
renderMode?: 'modal' | 'page' | 'embedded';
|
|
808
|
+
/** Layout direction */
|
|
809
|
+
layout?: 'vertical' | 'horizontal';
|
|
810
|
+
/** Custom loading message */
|
|
811
|
+
loadingMessage?: string;
|
|
812
|
+
/** Loading spinner variant */
|
|
813
|
+
loadingSpinnerVariant?: 'circular' | 'linear' | 'dots';
|
|
814
|
+
/** Accessibility configuration */
|
|
815
|
+
a11y?: {
|
|
816
|
+
/** ARIA labels and descriptions */
|
|
817
|
+
labels?: Record<string, string>;
|
|
818
|
+
/** Element to receive initial focus */
|
|
819
|
+
initialFocus?: string;
|
|
820
|
+
/** Whether to trap focus within the auth UI */
|
|
821
|
+
trapFocus?: boolean;
|
|
822
|
+
};
|
|
823
|
+
}
|
|
824
|
+
/**
|
|
825
|
+
* Sign-in specific UI configuration
|
|
826
|
+
*/
|
|
827
|
+
interface SignInUIConfig extends BaseAuthUIConfig {
|
|
828
|
+
/** Social sign-in buttons configuration */
|
|
829
|
+
socialButtons?: {
|
|
830
|
+
google?: boolean;
|
|
831
|
+
microsoft?: boolean;
|
|
832
|
+
github?: boolean;
|
|
833
|
+
facebook?: boolean;
|
|
834
|
+
twitter?: boolean;
|
|
835
|
+
apple?: boolean;
|
|
836
|
+
linkedin?: boolean;
|
|
837
|
+
layout?: 'vertical' | 'horizontal';
|
|
838
|
+
size?: 'small' | 'medium' | 'large';
|
|
839
|
+
};
|
|
840
|
+
/** "Remember me" checkbox configuration */
|
|
841
|
+
rememberMe?: {
|
|
842
|
+
enabled?: boolean;
|
|
843
|
+
defaultChecked?: boolean;
|
|
844
|
+
};
|
|
845
|
+
/** Sign-up link configuration */
|
|
846
|
+
signUpLink?: {
|
|
847
|
+
enabled?: boolean;
|
|
848
|
+
text?: string;
|
|
849
|
+
href?: string;
|
|
850
|
+
};
|
|
851
|
+
}
|
|
852
|
+
/**
|
|
853
|
+
* Sign-up specific UI configuration
|
|
854
|
+
*/
|
|
855
|
+
interface SignUpUIConfig extends BaseAuthUIConfig {
|
|
856
|
+
/** Password requirements display configuration */
|
|
857
|
+
passwordRequirements?: {
|
|
858
|
+
show?: boolean;
|
|
859
|
+
rules?: Array<{
|
|
860
|
+
rule: string;
|
|
861
|
+
description: string;
|
|
862
|
+
}>;
|
|
863
|
+
};
|
|
864
|
+
/** Terms and conditions configuration */
|
|
865
|
+
terms?: {
|
|
866
|
+
enabled?: boolean;
|
|
867
|
+
text?: string;
|
|
868
|
+
link?: string;
|
|
869
|
+
};
|
|
870
|
+
}
|
|
935
871
|
|
|
936
872
|
type Mode = 'browser' | 'server';
|
|
937
873
|
type TernSecureSDK = {
|
|
@@ -1019,9 +955,9 @@ interface TernSecureInstanceTree {
|
|
|
1019
955
|
/** Construct URL with redirect parameters */
|
|
1020
956
|
constructUrlWithAuthRedirect: (to: string) => string;
|
|
1021
957
|
/** Navigate to SignIn page */
|
|
1022
|
-
redirectToSignIn(options?:
|
|
958
|
+
redirectToSignIn(options?: SignInRedirectOptionss): Promise<unknown>;
|
|
1023
959
|
/** Navigate to SignUp page */
|
|
1024
|
-
redirectToSignUp(options?:
|
|
960
|
+
redirectToSignUp(options?: SignUpRedirectOptionss): Promise<unknown>;
|
|
1025
961
|
redirectAfterSignIn: () => void;
|
|
1026
962
|
redirectAfterSignUp: () => void;
|
|
1027
963
|
/** Error and Event Handling */
|
|
@@ -1067,7 +1003,7 @@ type SignInPropsTree = {
|
|
|
1067
1003
|
/** URL to navigate to after successfully sign-in */
|
|
1068
1004
|
forceRedirectUrl?: string | null;
|
|
1069
1005
|
/** Initial form values */
|
|
1070
|
-
initialValue?:
|
|
1006
|
+
initialValue?: SignInInitialValue;
|
|
1071
1007
|
/** UI configuration */
|
|
1072
1008
|
ui?: SignInUIConfig;
|
|
1073
1009
|
/** Callbacks */
|
|
@@ -1089,8 +1025,8 @@ type SignUpPropsTree = {
|
|
|
1089
1025
|
onError?: (error: AuthErrorTree) => void;
|
|
1090
1026
|
onSuccess?: (user: TernSecureUser | null) => void;
|
|
1091
1027
|
} & SignInRedirectUrl;
|
|
1092
|
-
type
|
|
1093
|
-
type
|
|
1028
|
+
type SignInRedirectOptionss = RedirectOptions;
|
|
1029
|
+
type SignUpRedirectOptionss = RedirectOptions;
|
|
1094
1030
|
|
|
1095
1031
|
interface TernSecureApiErrorJSON {
|
|
1096
1032
|
code: string;
|
|
@@ -1136,4 +1072,4 @@ type DomainOrProxyUrl = {
|
|
|
1136
1072
|
*/
|
|
1137
1073
|
type Autocomplete<U extends T, T = string> = U | (T & Record<never, never>);
|
|
1138
1074
|
|
|
1139
|
-
export { type ActiveSession, type AdminConfigValidationResult, type AfterSignOutUrl, type Appearance, type
|
|
1075
|
+
export { type ActiveSession, type AdminConfigValidationResult, type AfterSignOutUrl, type Appearance, type AuthEndpoint, type AuthErrorCode, type AuthErrorResponse, type AuthErrorTree, type AuthProviderStatus, type Autocomplete, type BaseAuthUIConfig, type CheckAuthorizationFromSessionClaims, type CheckCustomClaims, type ConfigValidationResult, type CookieOptions, type CookieOpts, type CookieStore, type CorsOptions, DEFAULT_TERN_SECURE_STATE, type DecodedIdToken, type DomainOrProxyUrl, ERRORS, type EndpointConfig, type ErrorCode, type ExpiredSession, type FirebaseClaims, type FirebaseState, type IdTokenResult, type InitialState, type InstanceType, type JWTPayload, type JWTProtectedHeader, type Jwt, type ListenerCallback, type ParsedToken, type PendingSession, type Persistence, type RateLimitOptions, type RedirectOptions, type ResendEmailVerification, type SecurityOptions, type ServerConfigValidationResult, type SessionCookieConfig, type SessionEndpointConfig, type SessionParams, type SessionResult, type SessionStatus, type SessionSubEndpoint, type SharedSignInAuthObjectProperties, type SignInFormValues, type SignInInitialValue, type SignInProps, type SignInPropsTree, type SignInRedirectOptions, type SignInRedirectOptionss, type SignInRedirectUrl, type SignInResource, type SignInResponse, type SignInStatus, type SignInUIConfig, type SignOut, type SignOutOptions, type SignOutOptionsTree, type SignUpFormValues, type SignUpFormValuesTree, type SignUpInitialValue, type SignUpInitialValueTree, type SignUpProps, type SignUpPropsTree, type SignUpRedirectOptions, type SignUpRedirectOptionss, type SignUpRedirectUrl, type SignUpResource, type SignUpStatus, type SignUpUIConfig, type SignedInSession, type TernAuthEventPayload, type TernAuthListenerEvent, type TernAuthListenerEventPayload, type TernAuthSDK, type TernSecureAPIError, type TernSecureAdminConfig, type TernSecureApiErrorJSON, type TernSecureAuth, type TernSecureAuthFactory, type TernSecureAuthOptions, type TernSecureAuthProvider, type TernSecureAuthStatus, type TernSecureConfig, type TernSecureFireRestError, type TernSecureFireRestErrorJSON, type TernSecureHandlerOptions, type TernSecureInstance, type TernSecureInstanceTree, type TernSecureInstanceTreeOptions, type TernSecureInstanceTreeStatus, type TernSecureOptions, type TernSecureResources, type TernSecureSDK, type TernSecureServerConfig, type TernSecureSessionTree, type TernSecureState, type TernSecureUser, type TernSecureUserData, type TernVerificationResult, type ThemeBorderRadius, type ThemeColors, type ThemeComponentStyles, type ThemeFonts, type ThemeSpacing, type TokenCookieConfig, type UnsubscribeCallback, type UseAuthReturn, type UseSignInReturn, type UserInfo, type VerifiedTokens, isSignInResponseTree };
|
package/dist/index.js
CHANGED
|
@@ -22,7 +22,6 @@ var src_exports = {};
|
|
|
22
22
|
__export(src_exports, {
|
|
23
23
|
DEFAULT_TERN_SECURE_STATE: () => DEFAULT_TERN_SECURE_STATE,
|
|
24
24
|
ERRORS: () => ERRORS,
|
|
25
|
-
isSignInResponse: () => isSignInResponse,
|
|
26
25
|
isSignInResponseTree: () => isSignInResponseTree
|
|
27
26
|
});
|
|
28
27
|
module.exports = __toCommonJS(src_exports);
|
|
@@ -63,11 +62,6 @@ var ERRORS = {
|
|
|
63
62
|
REDIRECT_LOOP: "Redirect loop detected."
|
|
64
63
|
};
|
|
65
64
|
|
|
66
|
-
// src/ternsecure.ts
|
|
67
|
-
function isSignInResponse(value) {
|
|
68
|
-
return typeof value === "object" && "success" in value && typeof value.success === "boolean";
|
|
69
|
-
}
|
|
70
|
-
|
|
71
65
|
// src/auth.ts
|
|
72
66
|
var DEFAULT_TERN_SECURE_STATE = {
|
|
73
67
|
userId: null,
|
|
@@ -90,7 +84,6 @@ function isSignInResponseTree(value) {
|
|
|
90
84
|
0 && (module.exports = {
|
|
91
85
|
DEFAULT_TERN_SECURE_STATE,
|
|
92
86
|
ERRORS,
|
|
93
|
-
isSignInResponse,
|
|
94
87
|
isSignInResponseTree
|
|
95
88
|
});
|
|
96
89
|
//# sourceMappingURL=index.js.map
|