@@ -150,14 +150,15 @@ export class Clerk implements ClerkInterface {
150
150
public telemetry : TelemetryCollector | undefined ;
151
151
152
152
protected internal_last_error : ClerkAPIError | null = null ;
153
+ // converted to protected environment to support `updateEnvironment` type assertion
154
+ protected environment ?: EnvironmentResource | null ;
153
155
154
156
#publishableKey: string = '' ;
155
157
#domain: DomainOrProxyUrl [ 'domain' ] ;
156
158
#proxyUrl: DomainOrProxyUrl [ 'proxyUrl' ] ;
157
159
#authService: SessionCookieService | null = null ;
158
160
#broadcastChannel: LocalStorageBroadcastChannel < ClerkCoreBroadcastChannelEvent > | null = null ;
159
161
#componentControls?: ReturnType < MountComponentRenderer > | null ;
160
- #environment?: EnvironmentResource | null ;
161
162
//@ts -expect-error with being undefined even though it's not possible - related to issue with ts and error thrower
162
163
#fapiClient: FapiClient ;
163
164
#instanceType?: InstanceType ;
@@ -328,7 +329,7 @@ export class Clerk implements ClerkInterface {
328
329
329
330
public openSignIn = ( props ?: SignInProps ) : void => {
330
331
this . assertComponentsReady ( this . #componentControls) ;
331
- if ( sessionExistsAndSingleSessionModeEnabled ( this , this . # environment) ) {
332
+ if ( sessionExistsAndSingleSessionModeEnabled ( this , this . environment ) ) {
332
333
if ( this . #instanceType === 'development' ) {
333
334
throw new ClerkRuntimeError ( warnings . cannotOpenSignInOrSignUp , {
334
335
code : 'cannot_render_single_session_enabled' ,
@@ -348,7 +349,7 @@ export class Clerk implements ClerkInterface {
348
349
349
350
public openSignUp = ( props ?: SignUpProps ) : void => {
350
351
this . assertComponentsReady ( this . #componentControls) ;
351
- if ( sessionExistsAndSingleSessionModeEnabled ( this , this . # environment) ) {
352
+ if ( sessionExistsAndSingleSessionModeEnabled ( this , this . environment ) ) {
352
353
if ( this . #instanceType === 'development' ) {
353
354
throw new ClerkRuntimeError ( warnings . cannotOpenSignInOrSignUp , {
354
355
code : 'cannot_render_single_session_enabled' ,
@@ -388,7 +389,7 @@ export class Clerk implements ClerkInterface {
388
389
389
390
public openOrganizationProfile = ( props ?: OrganizationProfileProps ) : void => {
390
391
this . assertComponentsReady ( this . #componentControls) ;
391
- if ( disabledOrganizationsFeature ( this , this . # environment) ) {
392
+ if ( disabledOrganizationsFeature ( this , this . environment ) ) {
392
393
if ( this . #instanceType === 'development' ) {
393
394
throw new ClerkRuntimeError ( warnings . cannotRenderAnyOrganizationComponent ( 'OrganizationProfile' ) , {
394
395
code : 'cannot_render_organizations_disabled' ,
@@ -416,7 +417,7 @@ export class Clerk implements ClerkInterface {
416
417
417
418
public openCreateOrganization = ( props ?: CreateOrganizationProps ) : void => {
418
419
this . assertComponentsReady ( this . #componentControls) ;
419
- if ( disabledOrganizationsFeature ( this , this . # environment) ) {
420
+ if ( disabledOrganizationsFeature ( this , this . environment ) ) {
420
421
if ( this . #instanceType === 'development' ) {
421
422
throw new ClerkRuntimeError ( warnings . cannotRenderAnyOrganizationComponent ( 'CreateOrganization' ) , {
422
423
code : 'cannot_render_organizations_disabled' ,
@@ -535,7 +536,7 @@ export class Clerk implements ClerkInterface {
535
536
536
537
public mountOrganizationProfile = ( node : HTMLDivElement , props ?: OrganizationProfileProps ) => {
537
538
this . assertComponentsReady ( this . #componentControls) ;
538
- if ( disabledOrganizationsFeature ( this , this . # environment) ) {
539
+ if ( disabledOrganizationsFeature ( this , this . environment ) ) {
539
540
if ( this . #instanceType === 'development' ) {
540
541
throw new ClerkRuntimeError ( warnings . cannotRenderAnyOrganizationComponent ( 'OrganizationProfile' ) , {
541
542
code : 'cannot_render_organizations_disabled' ,
@@ -575,7 +576,7 @@ export class Clerk implements ClerkInterface {
575
576
576
577
public mountCreateOrganization = ( node : HTMLDivElement , props ?: CreateOrganizationProps ) => {
577
578
this . assertComponentsReady ( this . #componentControls) ;
578
- if ( disabledOrganizationsFeature ( this , this . # environment) ) {
579
+ if ( disabledOrganizationsFeature ( this , this . environment ) ) {
579
580
if ( this . #instanceType === 'development' ) {
580
581
throw new ClerkRuntimeError ( warnings . cannotRenderAnyOrganizationComponent ( 'CreateOrganization' ) , {
581
582
code : 'cannot_render_organizations_disabled' ,
@@ -606,7 +607,7 @@ export class Clerk implements ClerkInterface {
606
607
607
608
public mountOrganizationSwitcher = ( node : HTMLDivElement , props ?: OrganizationSwitcherProps ) => {
608
609
this . assertComponentsReady ( this . #componentControls) ;
609
- if ( disabledOrganizationsFeature ( this , this . # environment) ) {
610
+ if ( disabledOrganizationsFeature ( this , this . environment ) ) {
610
611
if ( this . #instanceType === 'development' ) {
611
612
throw new ClerkRuntimeError ( warnings . cannotRenderAnyOrganizationComponent ( 'OrganizationSwitcher' ) , {
612
613
code : 'cannot_render_organizations_disabled' ,
@@ -633,7 +634,7 @@ export class Clerk implements ClerkInterface {
633
634
634
635
public mountOrganizationList = ( node : HTMLDivElement , props ?: OrganizationListProps ) => {
635
636
this . assertComponentsReady ( this . #componentControls) ;
636
- if ( disabledOrganizationsFeature ( this , this . # environment) ) {
637
+ if ( disabledOrganizationsFeature ( this , this . environment ) ) {
637
638
if ( this . #instanceType === 'development' ) {
638
639
throw new ClerkRuntimeError ( warnings . cannotRenderAnyOrganizationComponent ( 'OrganizationList' ) , {
639
640
code : 'cannot_render_organizations_disabled' ,
@@ -842,17 +843,17 @@ export class Clerk implements ClerkInterface {
842
843
}
843
844
844
845
public buildUserProfileUrl ( ) : string {
845
- if ( ! this . # environment || ! this . # environment. displayConfig ) {
846
+ if ( ! this . environment || ! this . environment . displayConfig ) {
846
847
return '' ;
847
848
}
848
- return this . buildUrlWithAuth ( this . # environment. displayConfig . userProfileUrl ) ;
849
+ return this . buildUrlWithAuth ( this . environment . displayConfig . userProfileUrl ) ;
849
850
}
850
851
851
852
public buildHomeUrl ( ) : string {
852
- if ( ! this . # environment || ! this . # environment. displayConfig ) {
853
+ if ( ! this . environment || ! this . environment . displayConfig ) {
853
854
return '' ;
854
855
}
855
- return this . buildUrlWithAuth ( this . # environment. displayConfig . homeUrl ) ;
856
+ return this . buildUrlWithAuth ( this . environment . displayConfig . homeUrl ) ;
856
857
}
857
858
858
859
public buildAfterSignInUrl ( ) : string {
@@ -872,17 +873,17 @@ export class Clerk implements ClerkInterface {
872
873
}
873
874
874
875
public buildCreateOrganizationUrl ( ) : string {
875
- if ( ! this . # environment || ! this . # environment. displayConfig ) {
876
+ if ( ! this . environment || ! this . environment . displayConfig ) {
876
877
return '' ;
877
878
}
878
- return this . buildUrlWithAuth ( this . # environment. displayConfig . createOrganizationUrl ) ;
879
+ return this . buildUrlWithAuth ( this . environment . displayConfig . createOrganizationUrl ) ;
879
880
}
880
881
881
882
public buildOrganizationProfileUrl ( ) : string {
882
- if ( ! this . # environment || ! this . # environment. displayConfig ) {
883
+ if ( ! this . environment || ! this . environment . displayConfig ) {
883
884
return '' ;
884
885
}
885
- return this . buildUrlWithAuth ( this . # environment. displayConfig . organizationProfileUrl ) ;
886
+ return this . buildUrlWithAuth ( this . environment . displayConfig . organizationProfileUrl ) ;
886
887
}
887
888
888
889
#redirectToSatellite = async ( ) : Promise < unknown > => {
@@ -1015,11 +1016,11 @@ export class Clerk implements ClerkInterface {
1015
1016
params : HandleOAuthCallbackParams = { } ,
1016
1017
customNavigate ?: ( to : string ) => Promise < unknown > ,
1017
1018
) : Promise < unknown > => {
1018
- if ( ! this . loaded || ! this . # environment || ! this . client ) {
1019
+ if ( ! this . loaded || ! this . environment || ! this . client ) {
1019
1020
return ;
1020
1021
}
1021
1022
const { signIn, signUp } = this . client ;
1022
- const { displayConfig } = this . # environment;
1023
+ const { displayConfig } = this . environment ;
1023
1024
const { firstFactorVerification } = signIn ;
1024
1025
const { externalAccount } = signUp . verifications ;
1025
1026
const su = {
@@ -1205,7 +1206,7 @@ export class Clerk implements ClerkInterface {
1205
1206
customNavigate,
1206
1207
unsafeMetadata,
1207
1208
} : AuthenticateWithMetamaskParams = { } ) : Promise < void > => {
1208
- if ( ! this . client || ! this . # environment) {
1209
+ if ( ! this . client || ! this . environment ) {
1209
1210
return ;
1210
1211
}
1211
1212
@@ -1252,7 +1253,7 @@ export class Clerk implements ClerkInterface {
1252
1253
Organization . get ( organizationId ) ;
1253
1254
1254
1255
public updateEnvironment ( environment : EnvironmentResource ) : asserts this is { environment : EnvironmentResource } {
1255
- this . # environment = environment ;
1256
+ this . environment = environment ;
1256
1257
this . #authService?. setEnvironment ( environment ) ;
1257
1258
}
1258
1259
@@ -1292,16 +1293,16 @@ export class Clerk implements ClerkInterface {
1292
1293
} ;
1293
1294
1294
1295
get __unstable__environment ( ) : EnvironmentResource | null | undefined {
1295
- return this . # environment;
1296
+ return this . environment ;
1296
1297
}
1297
1298
1298
1299
// TODO: Fix this properly
1299
1300
// eslint-disable-next-line @typescript-eslint/require-await
1300
1301
__unstable__setEnvironment = async ( env : EnvironmentJSON ) => {
1301
- this . # environment = new Environment ( env ) ;
1302
+ this . environment = new Environment ( env ) ;
1302
1303
1303
1304
if ( Clerk . mountComponentRenderer ) {
1304
- this . #componentControls = Clerk . mountComponentRenderer ( this , this . # environment, this . #options) ;
1305
+ this . #componentControls = Clerk . mountComponentRenderer ( this , this . environment , this . #options) ;
1305
1306
}
1306
1307
} ;
1307
1308
@@ -1485,7 +1486,7 @@ export class Clerk implements ClerkInterface {
1485
1486
}
1486
1487
1487
1488
if ( Clerk . mountComponentRenderer ) {
1488
- this . #componentControls = Clerk . mountComponentRenderer ( this , this . # environment as Environment , this . #options) ;
1489
+ this . #componentControls = Clerk . mountComponentRenderer ( this , this . environment as Environment , this . #options) ;
1489
1490
}
1490
1491
1491
1492
break ;
@@ -1523,7 +1524,7 @@ export class Clerk implements ClerkInterface {
1523
1524
// TODO: Add an auth service also for non standard browsers that will poll for the __session JWT but won't use cookies
1524
1525
1525
1526
if ( Clerk . mountComponentRenderer ) {
1526
- this . #componentControls = Clerk . mountComponentRenderer ( this , this . # environment, this . #options) ;
1527
+ this . #componentControls = Clerk . mountComponentRenderer ( this , this . environment , this . #options) ;
1527
1528
}
1528
1529
1529
1530
return true ;
@@ -1632,10 +1633,10 @@ export class Clerk implements ClerkInterface {
1632
1633
} ;
1633
1634
1634
1635
#buildUrl = ( key : 'signInUrl' | 'signUpUrl' , params ?: Record < string , string > ) : string => {
1635
- if ( ! key || ! this . loaded || ! this . # environment || ! this . # environment. displayConfig ) {
1636
+ if ( ! key || ! this . loaded || ! this . environment || ! this . environment . displayConfig ) {
1636
1637
return '' ;
1637
1638
}
1638
- const signInOrUpUrl = this . #options[ key ] || this . # environment. displayConfig [ key ] ;
1639
+ const signInOrUpUrl = this . #options[ key ] || this . environment . displayConfig [ key ] ;
1639
1640
const redirectUrls = new RedirectUrls ( this . #options, params ) ;
1640
1641
return this . buildUrlWithAuth ( redirectUrls . appendPreservedPropsToUrl ( signInOrUpUrl , params ) ) ;
1641
1642
} ;
@@ -1659,9 +1660,9 @@ export class Clerk implements ClerkInterface {
1659
1660
}
1660
1661
1661
1662
const userSignedIn = this . session ;
1662
- const signInUrl = this . #options. signInUrl || this . # environment?. displayConfig . signInUrl ;
1663
+ const signInUrl = this . #options. signInUrl || this . environment ?. displayConfig . signInUrl ;
1663
1664
const referrerIsSignInUrl = signInUrl && window . location . href . startsWith ( signInUrl ) ;
1664
- const signUpUrl = this . #options. signUpUrl || this . # environment?. displayConfig . signUpUrl ;
1665
+ const signUpUrl = this . #options. signUpUrl || this . environment ?. displayConfig . signUpUrl ;
1665
1666
const referrerIsSignUpUrl = signUpUrl && window . location . href . startsWith ( signUpUrl ) ;
1666
1667
1667
1668
// don't redirect if user is not signed in and referrer is sign in/up url
0 commit comments