@@ -153,14 +153,15 @@ export class Clerk implements ClerkInterface {
153
153
public telemetry : TelemetryCollector | undefined ;
154
154
155
155
protected internal_last_error : ClerkAPIError | null = null ;
156
+ // converted to protected environment to support `updateEnvironment` type assertion
157
+ protected environment ?: EnvironmentResource | null ;
156
158
157
159
#publishableKey: string = '' ;
158
160
#domain: DomainOrProxyUrl [ 'domain' ] ;
159
161
#proxyUrl: DomainOrProxyUrl [ 'proxyUrl' ] ;
160
162
#authService: SessionCookieService | null = null ;
161
163
#broadcastChannel: LocalStorageBroadcastChannel < ClerkCoreBroadcastChannelEvent > | null = null ;
162
164
#componentControls?: ReturnType < MountComponentRenderer > | null ;
163
- #environment?: EnvironmentResource | null ;
164
165
//@ts -expect-error with being undefined even though it's not possible - related to issue with ts and error thrower
165
166
#fapiClient: FapiClient ;
166
167
#instanceType?: InstanceType ;
@@ -331,7 +332,7 @@ export class Clerk implements ClerkInterface {
331
332
332
333
public openSignIn = ( props ?: SignInProps ) : void => {
333
334
this . assertComponentsReady ( this . #componentControls) ;
334
- if ( sessionExistsAndSingleSessionModeEnabled ( this , this . # environment) ) {
335
+ if ( sessionExistsAndSingleSessionModeEnabled ( this , this . environment ) ) {
335
336
if ( this . #instanceType === 'development' ) {
336
337
throw new ClerkRuntimeError ( warnings . cannotOpenSignInOrSignUp , {
337
338
code : 'cannot_render_single_session_enabled' ,
@@ -351,7 +352,7 @@ export class Clerk implements ClerkInterface {
351
352
352
353
public openSignUp = ( props ?: SignUpProps ) : void => {
353
354
this . assertComponentsReady ( this . #componentControls) ;
354
- if ( sessionExistsAndSingleSessionModeEnabled ( this , this . # environment) ) {
355
+ if ( sessionExistsAndSingleSessionModeEnabled ( this , this . environment ) ) {
355
356
if ( this . #instanceType === 'development' ) {
356
357
throw new ClerkRuntimeError ( warnings . cannotOpenSignInOrSignUp , {
357
358
code : 'cannot_render_single_session_enabled' ,
@@ -391,7 +392,7 @@ export class Clerk implements ClerkInterface {
391
392
392
393
public openOrganizationProfile = ( props ?: OrganizationProfileProps ) : void => {
393
394
this . assertComponentsReady ( this . #componentControls) ;
394
- if ( disabledOrganizationsFeature ( this , this . # environment) ) {
395
+ if ( disabledOrganizationsFeature ( this , this . environment ) ) {
395
396
if ( this . #instanceType === 'development' ) {
396
397
throw new ClerkRuntimeError ( warnings . cannotRenderAnyOrganizationComponent ( 'OrganizationProfile' ) , {
397
398
code : 'cannot_render_organizations_disabled' ,
@@ -419,7 +420,7 @@ export class Clerk implements ClerkInterface {
419
420
420
421
public openCreateOrganization = ( props ?: CreateOrganizationProps ) : void => {
421
422
this . assertComponentsReady ( this . #componentControls) ;
422
- if ( disabledOrganizationsFeature ( this , this . # environment) ) {
423
+ if ( disabledOrganizationsFeature ( this , this . environment ) ) {
423
424
if ( this . #instanceType === 'development' ) {
424
425
throw new ClerkRuntimeError ( warnings . cannotRenderAnyOrganizationComponent ( 'CreateOrganization' ) , {
425
426
code : 'cannot_render_organizations_disabled' ,
@@ -538,7 +539,7 @@ export class Clerk implements ClerkInterface {
538
539
539
540
public mountOrganizationProfile = ( node : HTMLDivElement , props ?: OrganizationProfileProps ) => {
540
541
this . assertComponentsReady ( this . #componentControls) ;
541
- if ( disabledOrganizationsFeature ( this , this . # environment) ) {
542
+ if ( disabledOrganizationsFeature ( this , this . environment ) ) {
542
543
if ( this . #instanceType === 'development' ) {
543
544
throw new ClerkRuntimeError ( warnings . cannotRenderAnyOrganizationComponent ( 'OrganizationProfile' ) , {
544
545
code : 'cannot_render_organizations_disabled' ,
@@ -578,7 +579,7 @@ export class Clerk implements ClerkInterface {
578
579
579
580
public mountCreateOrganization = ( node : HTMLDivElement , props ?: CreateOrganizationProps ) => {
580
581
this . assertComponentsReady ( this . #componentControls) ;
581
- if ( disabledOrganizationsFeature ( this , this . # environment) ) {
582
+ if ( disabledOrganizationsFeature ( this , this . environment ) ) {
582
583
if ( this . #instanceType === 'development' ) {
583
584
throw new ClerkRuntimeError ( warnings . cannotRenderAnyOrganizationComponent ( 'CreateOrganization' ) , {
584
585
code : 'cannot_render_organizations_disabled' ,
@@ -609,7 +610,7 @@ export class Clerk implements ClerkInterface {
609
610
610
611
public mountOrganizationSwitcher = ( node : HTMLDivElement , props ?: OrganizationSwitcherProps ) => {
611
612
this . assertComponentsReady ( this . #componentControls) ;
612
- if ( disabledOrganizationsFeature ( this , this . # environment) ) {
613
+ if ( disabledOrganizationsFeature ( this , this . environment ) ) {
613
614
if ( this . #instanceType === 'development' ) {
614
615
throw new ClerkRuntimeError ( warnings . cannotRenderAnyOrganizationComponent ( 'OrganizationSwitcher' ) , {
615
616
code : 'cannot_render_organizations_disabled' ,
@@ -636,7 +637,7 @@ export class Clerk implements ClerkInterface {
636
637
637
638
public mountOrganizationList = ( node : HTMLDivElement , props ?: OrganizationListProps ) => {
638
639
this . assertComponentsReady ( this . #componentControls) ;
639
- if ( disabledOrganizationsFeature ( this , this . # environment) ) {
640
+ if ( disabledOrganizationsFeature ( this , this . environment ) ) {
640
641
if ( this . #instanceType === 'development' ) {
641
642
throw new ClerkRuntimeError ( warnings . cannotRenderAnyOrganizationComponent ( 'OrganizationList' ) , {
642
643
code : 'cannot_render_organizations_disabled' ,
@@ -846,17 +847,17 @@ export class Clerk implements ClerkInterface {
846
847
}
847
848
848
849
public buildUserProfileUrl ( ) : string {
849
- if ( ! this . # environment || ! this . # environment. displayConfig ) {
850
+ if ( ! this . environment || ! this . environment . displayConfig ) {
850
851
return '' ;
851
852
}
852
- return this . buildUrlWithAuth ( this . # environment. displayConfig . userProfileUrl ) ;
853
+ return this . buildUrlWithAuth ( this . environment . displayConfig . userProfileUrl ) ;
853
854
}
854
855
855
856
public buildHomeUrl ( ) : string {
856
- if ( ! this . # environment || ! this . # environment. displayConfig ) {
857
+ if ( ! this . environment || ! this . environment . displayConfig ) {
857
858
return '' ;
858
859
}
859
- return this . buildUrlWithAuth ( this . # environment. displayConfig . homeUrl ) ;
860
+ return this . buildUrlWithAuth ( this . environment . displayConfig . homeUrl ) ;
860
861
}
861
862
862
863
public buildAfterSignInUrl ( ) : string {
@@ -876,17 +877,17 @@ export class Clerk implements ClerkInterface {
876
877
}
877
878
878
879
public buildCreateOrganizationUrl ( ) : string {
879
- if ( ! this . # environment || ! this . # environment. displayConfig ) {
880
+ if ( ! this . environment || ! this . environment . displayConfig ) {
880
881
return '' ;
881
882
}
882
- return this . buildUrlWithAuth ( this . # environment. displayConfig . createOrganizationUrl ) ;
883
+ return this . buildUrlWithAuth ( this . environment . displayConfig . createOrganizationUrl ) ;
883
884
}
884
885
885
886
public buildOrganizationProfileUrl ( ) : string {
886
- if ( ! this . # environment || ! this . # environment. displayConfig ) {
887
+ if ( ! this . environment || ! this . environment . displayConfig ) {
887
888
return '' ;
888
889
}
889
- return this . buildUrlWithAuth ( this . # environment. displayConfig . organizationProfileUrl ) ;
890
+ return this . buildUrlWithAuth ( this . environment . displayConfig . organizationProfileUrl ) ;
890
891
}
891
892
892
893
#redirectToSatellite = async ( ) : Promise < unknown > => {
@@ -1022,7 +1023,7 @@ export class Clerk implements ClerkInterface {
1022
1023
params : HandleOAuthCallbackParams ,
1023
1024
customNavigate ?: ( to : string ) => Promise < unknown > ,
1024
1025
) : Promise < unknown > => {
1025
- if ( ! this . loaded || ! this . # environment || ! this . client ) {
1026
+ if ( ! this . loaded || ! this . environment || ! this . client ) {
1026
1027
return ;
1027
1028
}
1028
1029
const { signIn : _signIn , signUp : _signUp } = this . client ;
@@ -1054,11 +1055,11 @@ export class Clerk implements ClerkInterface {
1054
1055
navigate : ( to : string ) => Promise < unknown > ;
1055
1056
} ,
1056
1057
) : Promise < unknown > => {
1057
- if ( ! this . loaded || ! this . # environment || ! this . client ) {
1058
+ if ( ! this . loaded || ! this . environment || ! this . client ) {
1058
1059
return ;
1059
1060
}
1060
1061
1061
- const { displayConfig } = this . # environment;
1062
+ const { displayConfig } = this . environment ;
1062
1063
const { firstFactorVerification } = signIn ;
1063
1064
const { externalAccount } = signUp . verifications ;
1064
1065
const su = {
@@ -1247,7 +1248,7 @@ export class Clerk implements ClerkInterface {
1247
1248
params : HandleOAuthCallbackParams = { } ,
1248
1249
customNavigate ?: ( to : string ) => Promise < unknown > ,
1249
1250
) : Promise < unknown > => {
1250
- if ( ! this . loaded || ! this . # environment || ! this . client ) {
1251
+ if ( ! this . loaded || ! this . environment || ! this . client ) {
1251
1252
return ;
1252
1253
}
1253
1254
const { signIn, signUp } = this . client ;
@@ -1306,7 +1307,7 @@ export class Clerk implements ClerkInterface {
1306
1307
customNavigate,
1307
1308
unsafeMetadata,
1308
1309
} : AuthenticateWithMetamaskParams = { } ) : Promise < void > => {
1309
- if ( ! this . client || ! this . # environment) {
1310
+ if ( ! this . client || ! this . environment ) {
1310
1311
return ;
1311
1312
}
1312
1313
@@ -1353,7 +1354,7 @@ export class Clerk implements ClerkInterface {
1353
1354
Organization . get ( organizationId ) ;
1354
1355
1355
1356
public updateEnvironment ( environment : EnvironmentResource ) : asserts this is { environment : EnvironmentResource } {
1356
- this . # environment = environment ;
1357
+ this . environment = environment ;
1357
1358
this . #authService?. setEnvironment ( environment ) ;
1358
1359
}
1359
1360
@@ -1393,16 +1394,16 @@ export class Clerk implements ClerkInterface {
1393
1394
} ;
1394
1395
1395
1396
get __unstable__environment ( ) : EnvironmentResource | null | undefined {
1396
- return this . # environment;
1397
+ return this . environment ;
1397
1398
}
1398
1399
1399
1400
// TODO: Fix this properly
1400
1401
// eslint-disable-next-line @typescript-eslint/require-await
1401
1402
__unstable__setEnvironment = async ( env : EnvironmentJSON ) => {
1402
- this . # environment = new Environment ( env ) ;
1403
+ this . environment = new Environment ( env ) ;
1403
1404
1404
1405
if ( Clerk . mountComponentRenderer ) {
1405
- this . #componentControls = Clerk . mountComponentRenderer ( this , this . # environment, this . #options) ;
1406
+ this . #componentControls = Clerk . mountComponentRenderer ( this , this . environment , this . #options) ;
1406
1407
}
1407
1408
} ;
1408
1409
@@ -1586,7 +1587,7 @@ export class Clerk implements ClerkInterface {
1586
1587
}
1587
1588
1588
1589
if ( Clerk . mountComponentRenderer ) {
1589
- this . #componentControls = Clerk . mountComponentRenderer ( this , this . # environment as Environment , this . #options) ;
1590
+ this . #componentControls = Clerk . mountComponentRenderer ( this , this . environment as Environment , this . #options) ;
1590
1591
}
1591
1592
1592
1593
break ;
@@ -1624,7 +1625,7 @@ export class Clerk implements ClerkInterface {
1624
1625
// TODO: Add an auth service also for non standard browsers that will poll for the __session JWT but won't use cookies
1625
1626
1626
1627
if ( Clerk . mountComponentRenderer ) {
1627
- this . #componentControls = Clerk . mountComponentRenderer ( this , this . # environment, this . #options) ;
1628
+ this . #componentControls = Clerk . mountComponentRenderer ( this , this . environment , this . #options) ;
1628
1629
}
1629
1630
1630
1631
return true ;
@@ -1737,10 +1738,10 @@ export class Clerk implements ClerkInterface {
1737
1738
options : RedirectOptions ,
1738
1739
_initValues ?: Record < string , string > ,
1739
1740
) : string => {
1740
- if ( ! key || ! this . loaded || ! this . # environment || ! this . # environment. displayConfig ) {
1741
+ if ( ! key || ! this . loaded || ! this . environment || ! this . environment . displayConfig ) {
1741
1742
return '' ;
1742
1743
}
1743
- const signInOrUpUrl = this . #options[ key ] || this . # environment. displayConfig [ key ] ;
1744
+ const signInOrUpUrl = this . #options[ key ] || this . environment . displayConfig [ key ] ;
1744
1745
const redirectUrls = new RedirectUrls ( this . #options, options ) . toSearchParams ( ) ;
1745
1746
const initValues = new URLSearchParams ( _initValues || { } ) ;
1746
1747
const url = buildURL ( { base : signInOrUpUrl , hashSearchParams : [ initValues , redirectUrls ] } , { stringify : true } ) ;
@@ -1766,9 +1767,9 @@ export class Clerk implements ClerkInterface {
1766
1767
}
1767
1768
1768
1769
const userSignedIn = this . session ;
1769
- const signInUrl = this . #options. signInUrl || this . # environment?. displayConfig . signInUrl ;
1770
+ const signInUrl = this . #options. signInUrl || this . environment ?. displayConfig . signInUrl ;
1770
1771
const referrerIsSignInUrl = signInUrl && window . location . href . startsWith ( signInUrl ) ;
1771
- const signUpUrl = this . #options. signUpUrl || this . # environment?. displayConfig . signUpUrl ;
1772
+ const signUpUrl = this . #options. signUpUrl || this . environment ?. displayConfig . signUpUrl ;
1772
1773
const referrerIsSignUpUrl = signUpUrl && window . location . href . startsWith ( signUpUrl ) ;
1773
1774
1774
1775
// don't redirect if user is not signed in and referrer is sign in/up url
0 commit comments