-
Notifications
You must be signed in to change notification settings - Fork 338
/
Copy pathclerk.ts
1661 lines (1468 loc) · 54.2 KB
/
clerk.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import type {
Appearance,
CheckoutTheme,
CreateOrganizationTheme,
OrganizationListTheme,
OrganizationProfileTheme,
OrganizationSwitcherTheme,
PricingTableTheme,
SignInTheme,
SignUpTheme,
UserButtonTheme,
UserProfileTheme,
UserVerificationTheme,
WaitlistTheme,
} from './appearance';
import type { ClientResource } from './client';
import type { __experimental_CommerceNamespace, __experimental_CommerceSubscriptionPlanPeriod } from './commerce';
import type { CustomMenuItem } from './customMenuItems';
import type { CustomPage } from './customPages';
import type { InstanceType } from './instance';
import type { DisplayThemeJSON } from './json';
import type { LocalizationResource } from './localization';
import type { OAuthProvider, OAuthScope } from './oauth';
import type { OrganizationResource } from './organization';
import type { OrganizationCustomRoleKey } from './organizationMembership';
import type {
AfterMultiSessionSingleSignOutUrl,
AfterSignOutUrl,
LegacyRedirectProps,
RedirectOptions,
RedirectUrlProp,
SignInFallbackRedirectUrl,
SignInForceRedirectUrl,
SignUpFallbackRedirectUrl,
SignUpForceRedirectUrl,
} from './redirects';
import type { PendingSessionOptions, SignedInSessionResource } from './session';
import type { SessionVerificationLevel } from './sessionVerification';
import type { SignInResource } from './signIn';
import type { SignUpResource } from './signUp';
import type { ClientJSONSnapshot, EnvironmentJSONSnapshot } from './snapshots';
import type { Web3Strategy } from './strategies';
import type { TelemetryCollector } from './telemetry';
import type { UserResource } from './user';
import type { Autocomplete, DeepPartial, DeepSnakeToCamel } from './utils';
import type { WaitlistResource } from './waitlist';
/**
* @inline
*/
export type SDKMetadata = {
/**
* The npm package name of the SDK.
*/
name: string;
/**
* The npm package version of the SDK.
*/
version: string;
/**
* Typically this will be the `NODE_ENV` that the SDK is currently running in.
*/
environment?: string;
};
export type ListenerCallback = (emission: Resources) => void;
export type UnsubscribeCallback = () => void;
export type BeforeEmitCallback = (session?: SignedInSessionResource | null) => void | Promise<any>;
export type SignOutCallback = () => void | Promise<any>;
export type SignOutOptions = {
/**
* Specify a specific session to sign out. Useful for
* multi-session applications.
*/
sessionId?: string;
/**
* Specify a redirect URL to navigate to after sign out is complete.
*/
redirectUrl?: string;
};
/**
* @inline
*/
export interface SignOut {
(options?: SignOutOptions): Promise<void>;
(signOutCallback?: SignOutCallback, options?: SignOutOptions): Promise<void>;
}
/**
* Main Clerk SDK object.
*/
export interface Clerk {
/**
* Clerk SDK version number.
*/
version: string | undefined;
/**
* If present, contains information about the SDK that the host application is using.
* For example, if Clerk is loaded through `@clerk/nextjs`, this would be `{ name: '@clerk/nextjs', version: '1.0.0' }`
*/
sdkMetadata: SDKMetadata | undefined;
/**
* If true the bootstrapping of Clerk.load() has completed successfully.
*/
loaded: boolean;
/**
* @internal
*/
__internal_getOption<K extends keyof ClerkOptions>(key: K): ClerkOptions[K];
frontendApi: string;
/** Clerk Publishable Key string. */
publishableKey: string;
/** Clerk Proxy url string. */
proxyUrl: string | undefined;
/** Clerk Satellite Frontend API string. */
domain: string;
/** Clerk Flag for satellite apps. */
isSatellite: boolean;
/** Clerk Instance type is defined from the Publishable key */
instanceType: InstanceType | undefined;
/** Clerk flag for loading Clerk in a standard browser setup */
isStandardBrowser: boolean | undefined;
/**
* Indicates whether the current user has a valid signed-in client session
*/
isSignedIn: boolean;
/** Client handling most Clerk operations. */
client: ClientResource | undefined;
/** Current Session. */
session: SignedInSessionResource | null | undefined;
/** Active Organization */
organization: OrganizationResource | null | undefined;
/** Current User. */
user: UserResource | null | undefined;
/** Commerce Object */
__experimental_commerce: __experimental_CommerceNamespace;
telemetry: TelemetryCollector | undefined;
__internal_country?: string | null;
/**
* Signs out the current user on single-session instances, or all users on multi-session instances
* @param signOutCallback - Optional A callback that runs after sign out completes.
* @param options - Optional Configuration options, see {@link SignOutOptions}
* @returns A promise that resolves when the sign out process completes.
*/
signOut: SignOut;
/**
* Opens the Clerk SignIn component in a modal.
* @param props Optional sign in configuration parameters.
*/
openSignIn: (props?: SignInModalProps) => void;
/**
* Closes the Clerk SignIn modal.
*/
closeSignIn: () => void;
/**
* Opens the Clerk Checkout component in a drawer.
* @param props Optional checkout configuration parameters.
*/
__internal_openCheckout: (props?: __experimental_CheckoutProps) => void;
/**
* Closes the Clerk Checkout drawer.
*/
__internal_closeCheckout: () => void;
/**
* Opens the Clerk UserVerification component in a modal.
* @param props Optional user verification configuration parameters.
*/
__internal_openReverification: (props?: __internal_UserVerificationModalProps) => void;
/**
* Closes the Clerk user verification modal.
*/
__internal_closeReverification: () => void;
/**
* Opens the Google One Tap component.
* @param props Optional props that will be passed to the GoogleOneTap component.
*/
openGoogleOneTap: (props?: GoogleOneTapProps) => void;
/**
* Opens the Google One Tap component.
* If the component is not already open, results in a noop.
*/
closeGoogleOneTap: () => void;
/**
* Opens the Clerk SignUp component in a modal.
* @param props Optional props that will be passed to the SignUp component.
*/
openSignUp: (props?: SignUpModalProps) => void;
/**
* Closes the Clerk SignUp modal.
*/
closeSignUp: () => void;
/**
* Opens the Clerk UserProfile modal.
* @param props Optional props that will be passed to the UserProfile component.
*/
openUserProfile: (props?: UserProfileModalProps) => void;
/**
* Closes the Clerk UserProfile modal.
*/
closeUserProfile: () => void;
/**
* Opens the Clerk OrganizationProfile modal.
* @param props Optional props that will be passed to the OrganizationProfile component.
*/
openOrganizationProfile: (props?: OrganizationProfileModalProps) => void;
/**
* Closes the Clerk OrganizationProfile modal.
*/
closeOrganizationProfile: () => void;
/**
* Opens the Clerk CreateOrganization modal.
* @param props Optional props that will be passed to the CreateOrganization component.
*/
openCreateOrganization: (props?: CreateOrganizationModalProps) => void;
/**
* Closes the Clerk CreateOrganization modal.
*/
closeCreateOrganization: () => void;
/**
* Opens the Clerk Waitlist modal.
* @param props Optional props that will be passed to the Waitlist component.
*/
openWaitlist: (props?: WaitlistModalProps) => void;
/**
* Closes the Clerk Waitlist modal.
*/
closeWaitlist: () => void;
/**
* Mounts a sign in flow component at the target element.
* @param targetNode Target node to mount the SignIn component.
* @param signInProps sign in configuration parameters.
*/
mountSignIn: (targetNode: HTMLDivElement, signInProps?: SignInProps) => void;
/**
* Unmount a sign in flow component from the target element.
* If there is no component mounted at the target node, results in a noop.
*
* @param targetNode Target node to unmount the SignIn component from.
*/
unmountSignIn: (targetNode: HTMLDivElement) => void;
/**
* Mounts a sign up flow component at the target element.
*
* @param targetNode Target node to mount the SignUp component.
* @param signUpProps sign up configuration parameters.
*/
mountSignUp: (targetNode: HTMLDivElement, signUpProps?: SignUpProps) => void;
/**
* Unmount a sign up flow component from the target element.
* If there is no component mounted at the target node, results in a noop.
*
* @param targetNode Target node to unmount the SignUp component from.
*/
unmountSignUp: (targetNode: HTMLDivElement) => void;
/**
* Mount a user button component at the target element.
*
* @param targetNode Target node to mount the UserButton component.
* @param userButtonProps User button configuration parameters.
*/
mountUserButton: (targetNode: HTMLDivElement, userButtonProps?: UserButtonProps) => void;
/**
* Unmount a user button component at the target element.
* If there is no component mounted at the target node, results in a noop.
*
* @param targetNode Target node to unmount the UserButton component from.
*/
unmountUserButton: (targetNode: HTMLDivElement) => void;
/**
* Mount a user profile component at the target element.
*
* @param targetNode Target to mount the UserProfile component.
* @param userProfileProps User profile configuration parameters.
*/
mountUserProfile: (targetNode: HTMLDivElement, userProfileProps?: UserProfileProps) => void;
/**
* Unmount a user profile component at the target element.
* If there is no component mounted at the target node, results in a noop.
*
* @param targetNode Target node to unmount the UserProfile component from.
*/
unmountUserProfile: (targetNode: HTMLDivElement) => void;
/**
* Mount an organization profile component at the target element.
* @param targetNode Target to mount the OrganizationProfile component.
* @param props Configuration parameters.
*/
mountOrganizationProfile: (targetNode: HTMLDivElement, props?: OrganizationProfileProps) => void;
/**
* Unmount the organization profile component from the target node.
* @param targetNode Target node to unmount the OrganizationProfile component from.
*/
unmountOrganizationProfile: (targetNode: HTMLDivElement) => void;
/**
* Mount a CreateOrganization component at the target element.
* @param targetNode Target to mount the CreateOrganization component.
* @param props Configuration parameters.
*/
mountCreateOrganization: (targetNode: HTMLDivElement, props?: CreateOrganizationProps) => void;
/**
* Unmount the CreateOrganization component from the target node.
* @param targetNode Target node to unmount the CreateOrganization component from.
*/
unmountCreateOrganization: (targetNode: HTMLDivElement) => void;
/**
* Mount an organization switcher component at the target element.
* @param targetNode Target to mount the OrganizationSwitcher component.
* @param props Configuration parameters.
*/
mountOrganizationSwitcher: (targetNode: HTMLDivElement, props?: OrganizationSwitcherProps) => void;
/**
* Unmount the organization profile component from the target node.*
* @param targetNode Target node to unmount the OrganizationSwitcher component from.
*/
unmountOrganizationSwitcher: (targetNode: HTMLDivElement) => void;
/**
* Prefetches the data displayed by an organization switcher.
* It can be used when `mountOrganizationSwitcher({ asStandalone: true})`, to avoid unwanted loading states.
* This API is still under active development and may change at any moment.
* @experimental
* @param props Optional user verification configuration parameters.
*/
__experimental_prefetchOrganizationSwitcher: () => void;
/**
* Mount an organization list component at the target element.
* @param targetNode Target to mount the OrganizationList component.
* @param props Configuration parameters.
*/
mountOrganizationList: (targetNode: HTMLDivElement, props?: OrganizationListProps) => void;
/**
* Unmount the organization list component from the target node.*
* @param targetNode Target node to unmount the OrganizationList component from.
*/
unmountOrganizationList: (targetNode: HTMLDivElement) => void;
/**
* Mount a waitlist at the target element.
* @param targetNode Target to mount the Waitlist component.
* @param props Configuration parameters.
*/
mountWaitlist: (targetNode: HTMLDivElement, props?: WaitlistProps) => void;
/**
* Unmount the Waitlist component from the target node.
* @param targetNode Target node to unmount the Waitlist component from.
*/
unmountWaitlist: (targetNode: HTMLDivElement) => void;
/**
* Mounts a pricing table component at the target element.
* @param targetNode Target node to mount the PricingTable component.
* @param props configuration parameters.
*/
__experimental_mountPricingTable: (targetNode: HTMLDivElement, props?: __experimental_PricingTableProps) => void;
/**
* Unmount a pricing table component from the target element.
* If there is no component mounted at the target node, results in a noop.
*
* @param targetNode Target node to unmount the PricingTable component from.
*/
__experimental_unmountPricingTable: (targetNode: HTMLDivElement) => void;
/**
* Register a listener that triggers a callback each time important Clerk resources are changed.
* Allows to hook up at different steps in the sign up, sign in processes.
*
* Some important checkpoints:
* When there is an active session, user === session.user.
* When there is no active session, user and session will both be null.
* When a session is loading, user and session will be undefined.
*
* @param callback Callback function receiving the most updated Clerk resources after a change.
* @returns - Unsubscribe callback
*/
addListener: (callback: ListenerCallback) => UnsubscribeCallback;
/**
* Registers an internal listener that triggers a callback each time `Clerk.navigate` is called.
* Its purpose is to notify modal UI components when a navigation event occurs, allowing them to close if necessary.
* @internal
*/
__internal_addNavigationListener: (callback: () => void) => UnsubscribeCallback;
/**
* Registers the internal navigation context from UI components in order to
* be triggered from `Clerk` methods
* @internal
*/
__internal_setComponentNavigationContext: (context: __internal_ComponentNavigationContext) => () => void;
/**
* Set the active session and organization explicitly.
*
* If the session param is `null`, the active session is deleted.
* In a similar fashion, if the organization param is `null`, the current organization is removed as active.
*/
setActive: SetActive;
/**
* Function used to commit a navigation after certain steps in the Clerk processes.
*/
navigate: CustomNavigation;
/**
* Decorates the provided url with the auth token for development instances.
*
* @param {string} to
*/
buildUrlWithAuth(to: string): string;
/**
* Returns the configured url where <SignIn/> is mounted or a custom sign-in page is rendered.
*
* @param opts A {@link RedirectOptions} object
*/
buildSignInUrl(opts?: RedirectOptions): string;
/**
* Returns the configured url where <SignUp/> is mounted or a custom sign-up page is rendered.
*
* @param opts A {@link RedirectOptions} object
*/
buildSignUpUrl(opts?: RedirectOptions): string;
/**
* Returns the url where <UserProfile /> is mounted or a custom user-profile page is rendered.
*/
buildUserProfileUrl(): string;
/**
* Returns the configured url where <CreateOrganization /> is mounted or a custom create-organization page is rendered.
*/
buildCreateOrganizationUrl(): string;
/**
* Returns the configured url where <OrganizationProfile /> is mounted or a custom organization-profile page is rendered.
*/
buildOrganizationProfileUrl(): string;
/**
* Returns the configured afterSignInUrl of the instance.
*/
buildAfterSignInUrl({ params }?: { params?: URLSearchParams }): string;
/**
* Returns the configured afterSignInUrl of the instance.
*/
buildAfterSignUpUrl({ params }?: { params?: URLSearchParams }): string;
/**
* Returns the configured afterSignOutUrl of the instance.
*/
buildAfterSignOutUrl(): string;
/**
* Returns the configured afterMultiSessionSingleSignOutUrl of the instance.
*/
buildAfterMultiSessionSingleSignOutUrl(): string;
/**
* Returns the configured url where <Waitlist/> is mounted or a custom waitlist page is rendered.
*/
buildWaitlistUrl(opts?: { initialValues?: Record<string, string> }): string;
/**
*
* Redirects to the provided url after decorating it with the auth token for development instances.
*
* @param {string} to
*/
redirectWithAuth(to: string): Promise<unknown>;
/**
* Redirects to the configured URL where <SignIn/> is mounted.
*
* @param opts A {@link RedirectOptions} object
*/
redirectToSignIn(opts?: SignInRedirectOptions): Promise<unknown>;
/**
* Redirects to the configured URL where <SignUp/> is mounted.
*
* @param opts A {@link RedirectOptions} object
*/
redirectToSignUp(opts?: SignUpRedirectOptions): Promise<unknown>;
/**
* Redirects to the configured URL where <UserProfile/> is mounted.
*/
redirectToUserProfile: () => Promise<unknown>;
/**
* Redirects to the configured URL where <OrganizationProfile /> is mounted.
*/
redirectToOrganizationProfile: () => Promise<unknown>;
/**
* Redirects to the configured URL where <CreateOrganization /> is mounted.
*/
redirectToCreateOrganization: () => Promise<unknown>;
/**
* Redirects to the configured afterSignIn URL.
*/
redirectToAfterSignIn: () => void;
/**
* Redirects to the configured afterSignUp URL.
*/
redirectToAfterSignUp: () => void;
/**
* Redirects to the configured afterSignOut URL.
*/
redirectToAfterSignOut: () => void;
/**
* Redirects to the configured URL where <Waitlist/> is mounted.
*/
redirectToWaitlist: () => void;
/**
* Completes a Google One Tap redirection flow started by
* {@link Clerk.authenticateWithGoogleOneTap}
*/
handleGoogleOneTapCallback: (
signInOrUp: SignInResource | SignUpResource,
params: HandleOAuthCallbackParams,
customNavigate?: (to: string) => Promise<unknown>,
) => Promise<unknown>;
/**
* Completes an OAuth or SAML redirection flow started by
* {@link Clerk.client.signIn.authenticateWithRedirect} or {@link Clerk.client.signUp.authenticateWithRedirect}
*/
handleRedirectCallback: (
params: HandleOAuthCallbackParams | HandleSamlCallbackParams,
customNavigate?: (to: string) => Promise<unknown>,
) => Promise<unknown>;
/**
* Completes a Email Link flow started by {@link Clerk.client.signIn.createEmailLinkFlow} or {@link Clerk.client.signUp.createEmailLinkFlow}
*/
handleEmailLinkVerification: (
params: HandleEmailLinkVerificationParams,
customNavigate?: (to: string) => Promise<unknown>,
) => Promise<unknown>;
/**
* Authenticates user using their Metamask browser extension
*/
authenticateWithMetamask: (params?: AuthenticateWithMetamaskParams) => Promise<unknown>;
/**
* Authenticates user using their Coinbase Smart Wallet and browser extension
*/
authenticateWithCoinbaseWallet: (params?: AuthenticateWithCoinbaseWalletParams) => Promise<unknown>;
/**
* Authenticates user using their OKX Wallet browser extension
*/
authenticateWithOKXWallet: (params?: AuthenticateWithOKXWalletParams) => Promise<unknown>;
/**
* Authenticates user using their Web3 Wallet browser extension
*/
authenticateWithWeb3: (params: ClerkAuthenticateWithWeb3Params) => Promise<unknown>;
/**
* Authenticates user using a Google token generated from Google identity services.
*/
authenticateWithGoogleOneTap: (
params: AuthenticateWithGoogleOneTapParams,
) => Promise<SignInResource | SignUpResource>;
/**
* Creates an organization, adding the current user as admin.
*/
createOrganization: (params: CreateOrganizationParams) => Promise<OrganizationResource>;
/**
* Retrieves a single organization by id.
*/
getOrganization: (organizationId: string) => Promise<OrganizationResource>;
/**
* Handles a 401 response from Frontend API by refreshing the client and session object accordingly
*/
handleUnauthenticated: () => Promise<unknown>;
joinWaitlist: (params: JoinWaitlistParams) => Promise<WaitlistResource>;
/**
* Navigates to the next task or redirects to completion URL.
* If the current session has pending tasks, it navigates to the next task.
* If all tasks are complete, it navigates to the provided completion URL.
* @experimental
*/
__experimental_nextTask: (params?: NextTaskParams) => Promise<void>;
/**
* This is an optional function.
* This function is used to load cached Client and Environment resources if Clerk fails to load them from the Frontend API.
* @internal
*/
__internal_getCachedResources:
| (() => Promise<{ client: ClientJSONSnapshot | null; environment: EnvironmentJSONSnapshot | null }>)
| undefined;
/**
* This function is used to reload the initial resources (Environment/Client) from the Frontend API.
* @internal
*/
__internal_reloadInitialResources: () => Promise<void>;
/**
* Internal flag indicating whether a `setActive` call is in progress. Used to prevent navigations from being
* initiated outside of the Clerk class.
*/
__internal_setActiveInProgress: boolean;
}
export type HandleOAuthCallbackParams = TransferableOption &
SignInForceRedirectUrl &
SignInFallbackRedirectUrl &
SignUpForceRedirectUrl &
SignUpFallbackRedirectUrl &
LegacyRedirectProps & {
/**
* Full URL or path where the SignIn component is mounted.
*/
signInUrl?: string;
/**
* Full URL or path where the SignUp component is mounted.
*/
signUpUrl?: string;
/**
* Full URL or path to navigate to during sign in,
* if identifier verification is required.
*/
firstFactorUrl?: string;
/**
* Full URL or path to navigate to during sign in,
* if 2FA is enabled.
*/
secondFactorUrl?: string;
/**
* Full URL or path to navigate to during sign in,
* if the user is required to reset their password.
*/
resetPasswordUrl?: string;
/**
* Full URL or path to navigate to after an incomplete sign up.
*/
continueSignUpUrl?: string | null;
/**
* Full URL or path to navigate to after requesting email verification.
*/
verifyEmailAddressUrl?: string | null;
/**
* Full URL or path to navigate to after requesting phone verification.
*/
verifyPhoneNumberUrl?: string | null;
};
export type HandleSamlCallbackParams = HandleOAuthCallbackParams;
export type CustomNavigation = (to: string, options?: NavigateOptions) => Promise<unknown> | void;
export type ClerkThemeOptions = DeepSnakeToCamel<DeepPartial<DisplayThemeJSON>>;
/**
* Navigation options used to replace or push history changes.
* Both `routerPush` & `routerReplace` OR none options should be passed.
*/
type ClerkOptionsNavigation =
| {
/**
* A function which takes the destination path as an argument and performs a "push" navigation.
*/
routerPush?: never;
/**
* A function which takes the destination path as an argument and performs a "replace" navigation.
*/
routerReplace?: never;
routerDebug?: boolean;
}
| {
routerPush: RouterFn;
routerReplace: RouterFn;
routerDebug?: boolean;
};
export type ClerkOptions = PendingSessionOptions &
ClerkOptionsNavigation &
SignInForceRedirectUrl &
SignInFallbackRedirectUrl &
SignUpForceRedirectUrl &
SignUpFallbackRedirectUrl &
LegacyRedirectProps &
AfterSignOutUrl &
AfterMultiSessionSingleSignOutUrl & {
/**
* Optional object to style your components. Will only affect [Clerk Components](https://clerk.com/docs/components/overview) and not [Account Portal](https://clerk.com/docs/customization/account-portal/overview) pages.
*/
appearance?: Appearance;
/**
* Optional object to localize your components. Will only affect [Clerk Components](https://clerk.com/docs/components/overview) and not [Account Portal](https://clerk.com/docs/customization/account-portal/overview) pages.
*/
localization?: LocalizationResource;
polling?: boolean;
/**
* By default, the last signed-in session is used during client initialization. This option allows you to override that behavior, e.g. by selecting a specific session.
*/
selectInitialSession?: (client: ClientResource) => SignedInSessionResource | null;
/**
* By default, ClerkJS is loaded with the assumption that cookies can be set (browser setup). On native platforms this value must be set to `false`.
*/
standardBrowser?: boolean;
/**
* Optional support email for display in authentication screens. Will only affect [Clerk Components](https://clerk.com/docs/components/overview) and not [Account Portal](https://clerk.com/docs/customization/account-portal/overview) pages.
*/
supportEmail?: string;
/**
* By default, the [Clerk Frontend API `touch` endpoint](https://clerk.com/docs/reference/frontend-api/tag/Sessions#operation/touchSession) is called during page focus to keep the last active session alive. This option allows you to disable this behavior.
*/
touchSession?: boolean;
/**
* This URL will be used for any redirects that might happen and needs to point to your primary application on the client-side. This option is optional for production instances. **It is required to be set for a satellite application in a development instance**. It's recommended to use [the environment variable](https://clerk.com/docs/deployments/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
*/
signInUrl?: string;
/**
* This URL will be used for any redirects that might happen and needs to point to your primary application on the client-side. This option is optional for production instances but **must be set for a satellite application in a development instance**. It's recommended to use [the environment variable](https://clerk.com/docs/deployments/clerk-environment-variables#sign-in-and-sign-up-redirects) instead.
*/
signUpUrl?: string;
/**
* An optional array of domains to validate user-provided redirect URLs against. If no match is made, the redirect is considered unsafe and the default redirect will be used with a warning logged in the console.
*/
allowedRedirectOrigins?: Array<string | RegExp>;
/**
* An optional array of protocols to validate user-provided redirect URLs against. If no match is made, the redirect is considered unsafe and the default redirect will be used with a warning logged in the console.
*/
allowedRedirectProtocols?: Array<string>;
/**
* This option defines that the application is a satellite application.
*/
isSatellite?: boolean | ((url: URL) => boolean);
/**
* Controls whether or not Clerk will collect [telemetry data](https://clerk.com/docs/telemetry). If set to `debug`, telemetry events are only logged to the console and not sent to Clerk.
*/
telemetry?:
| false
| {
disabled?: boolean;
/**
* Telemetry events are only logged to the console and not sent to Clerk
*/
debug?: boolean;
};
/**
* Contains information about the SDK that the host application is using. You don't need to set this value yourself unless you're [developing an SDK](https://clerk.com/docs/references/sdk/overview).
*/
sdkMetadata?: SDKMetadata;
/**
* The full URL or path to the waitlist page. If `undefined`, will redirect to the [Account Portal waitlist page](https://clerk.com/docs/account-portal/overview#waitlist).
*/
waitlistUrl?: string;
/**
* Enable experimental flags to gain access to new features. These flags are not guaranteed to be stable and may change drastically in between patch or minor versions.
*/
experimental?: Autocomplete<
{
/**
* Persist the Clerk client to match the user's device with a client. Defaults to `true`.
*/
persistClient: boolean;
/**
* Clerk will rethrow network errors that occur while the user is offline.
*/
rethrowOfflineNetworkErrors: boolean;
commerce: boolean;
},
Record<string, any>
>;
/**
* The URL a developer should be redirected to in order to claim an instance created in Keyless mode.
* @internal
*/
__internal_keyless_claimKeylessApplicationUrl?: string;
/**
* After a developer has claimed their instance created by Keyless mode, they can use this URL to find their instance's keys
* @internal
*/
__internal_keyless_copyInstanceKeysUrl?: string;
/**
* Pass a function that will trigger the unmounting of the Keyless Prompt.
* It should cause the values of `__internal_claimKeylessApplicationUrl` and `__internal_copyInstanceKeysUrl` to become undefined.
* @internal
*/
__internal_keyless_dismissPrompt?: (() => Promise<void>) | null;
};
export interface NavigateOptions {
replace?: boolean;
metadata?: RouterMetadata;
}
export interface Resources {
client: ClientResource;
session?: SignedInSessionResource | null;
user?: UserResource | null;
organization?: OrganizationResource | null;
}
export type RoutingStrategy = 'path' | 'hash' | 'virtual';
/**
* Internal is a navigation type that affects the component
*
*/
type NavigationType =
/**
* Internal navigations affect the components and alter the
* part of the URL that comes after the `path` passed to the component.
* eg <SignIn path='sign-in'>
* going from /sign-in to /sign-in/factor-one is an internal navigation
*/
| 'internal'
/**
* Internal navigations affect the components and alter the
* part of the URL that comes before the `path` passed to the component.
* eg <SignIn path='sign-in'>
* going from /sign-in to / is an external navigation
*/
| 'external'
/**
* Window navigations are navigations towards a different origin
* and are not handled by the Clerk component or the host app router.
*/
| 'window';
type RouterMetadata = { routing?: RoutingStrategy; navigationType?: NavigationType };
/**
* @inline
*/
type RouterFn = (
/**
* The destination path
*/
to: string,
/**
* Optional metadata
*/
metadata?: {
/**
* @internal
*/
__internal_metadata?: RouterMetadata;
/**
* Provide a function to be used for navigation.
*/
windowNavigate: (to: URL | string) => void;
},
) => Promise<unknown> | unknown;
export type WithoutRouting<T> = Omit<T, 'path' | 'routing'>;
export type SignInInitialValues = {
emailAddress?: string;
phoneNumber?: string;
username?: string;
};
export type SignUpInitialValues = {
emailAddress?: string;
phoneNumber?: string;
firstName?: string;
lastName?: string;
username?: string;
};
export type SignInRedirectOptions = RedirectOptions &
RedirectUrlProp & {
/**
* Initial values that are used to prefill the sign in form.
*/
initialValues?: SignInInitialValues;
};
export type SignUpRedirectOptions = RedirectOptions &
RedirectUrlProp & {
/**
* Initial values that are used to prefill the sign up form.
*/
initialValues?: SignUpInitialValues;
};
/**
* The parameters for the `setActive()` method.
* @interface
*/
export type SetActiveParams = {
/**
* The session resource or session ID (string version) to be set as active. If `null`, the current session is deleted.
*/
session?: SignedInSessionResource | string | null;
/**
* The organization resource or organization ID/slug (string version) to be set as active in the current session. If `null`, the currently active organization is removed as active.
*/
organization?: OrganizationResource | string | null;
/**
* @deprecated in favor of `redirectUrl`.
*
* Callback run just before the active session and/or organization is set to the passed object. Can be used to set up for pre-navigation actions.
*/
beforeEmit?: BeforeEmitCallback;
/**
* The full URL or path to redirect to just before the active session and/or organization is set.
*/
redirectUrl?: string;
};
/**
* @inline
*/
export type SetActive = (setActiveParams: SetActiveParams) => Promise<void>;
export type RoutingOptions =
| { path: string | undefined; routing?: Extract<RoutingStrategy, 'path'> }
| { path?: never; routing?: Extract<RoutingStrategy, 'hash' | 'virtual'> };
export type SignInProps = RoutingOptions & {
/**