@@ -32,7 +32,6 @@ function removeTrailingSlash(str) {
3232 return str ;
3333}
3434
35- const asyncKeys = [ 'publicServerURL' ] ;
3635export class Config {
3736 static get ( applicationId : string , mount : string ) {
3837 const cacheInfo = AppCache . get ( applicationId ) ;
@@ -57,33 +56,16 @@ export class Config {
5756 return config ;
5857 }
5958
60- async loadKeys ( ) {
61- const asyncKeys = [ 'publicServerURL' ] ;
62-
63- await Promise . all (
64- asyncKeys . map ( async key => {
65- if ( typeof this [ `_${ key } ` ] === 'function' ) {
66- this [ key ] = await this [ `_${ key } ` ] ( ) ;
67- }
68- } )
69- ) ;
70-
71- AppCache . put ( this . appId , this ) ;
72- }
73-
74- static transformConfiguration ( serverConfiguration ) {
75- for ( const key of Object . keys ( serverConfiguration ) ) {
76- if ( asyncKeys . includes ( key ) && typeof serverConfiguration [ key ] === 'function' ) {
77- serverConfiguration [ `_${ key } ` ] = serverConfiguration [ key ] ;
78- delete serverConfiguration [ key ] ;
79- }
59+ async getPublicServerURL ( ) {
60+ if ( typeof this . publicServerURL === 'function' ) {
61+ return await this . publicServerURL ( ) ;
8062 }
63+ return this . publicServerURL ;
8164 }
8265
8366 static put ( serverConfiguration ) {
8467 Config . validateOptions ( serverConfiguration ) ;
8568 Config . validateControllers ( serverConfiguration ) ;
86- Config . transformConfiguration ( serverConfiguration ) ;
8769 AppCache . put ( serverConfiguration . appId , serverConfiguration ) ;
8870 Config . setupPasswordValidator ( serverConfiguration . passwordPolicy ) ;
8971 return serverConfiguration ;
@@ -474,7 +456,7 @@ export class Config {
474456 if ( typeof appName !== 'string' ) {
475457 throw 'An app name is required for e-mail verification and password resets.' ;
476458 }
477- if ( typeof publicServerURL !== 'string' ) {
459+ if ( ! publicServerURL || ( typeof publicServerURL !== 'string' && typeof publicServerURL !== 'function' ) ) {
478460 throw 'A public server url is required for e-mail verification and password resets.' ;
479461 }
480462 if ( emailVerifyTokenValidityDuration ) {
@@ -546,11 +528,7 @@ export class Config {
546528 }
547529
548530 get mount ( ) {
549- var mount = this . _mount ;
550- if ( this . publicServerURL ) {
551- mount = this . publicServerURL ;
552- }
553- return mount ;
531+ return this . _mount ;
554532 }
555533
556534 set mount ( newValue ) {
@@ -714,55 +692,64 @@ export class Config {
714692 }
715693 }
716694
717- get invalidLinkURL ( ) {
718- return this . customPages . invalidLink || `${ this . publicServerURL } /apps/invalid_link.html` ;
695+ async invalidLinkURL ( ) {
696+ const publicServerURL = await this . getPublicServerURL ( ) ;
697+ return this . customPages . invalidLink || `${ publicServerURL } /apps/invalid_link.html` ;
719698 }
720699
721- get invalidVerificationLinkURL ( ) {
700+ async invalidVerificationLinkURL ( ) {
701+ const publicServerURL = await this . getPublicServerURL ( ) ;
722702 return (
723703 this . customPages . invalidVerificationLink ||
724- `${ this . publicServerURL } /apps/invalid_verification_link.html`
704+ `${ publicServerURL } /apps/invalid_verification_link.html`
725705 ) ;
726706 }
727707
728- get linkSendSuccessURL ( ) {
708+ async linkSendSuccessURL ( ) {
709+ const publicServerURL = await this . getPublicServerURL ( ) ;
729710 return (
730- this . customPages . linkSendSuccess || `${ this . publicServerURL } /apps/link_send_success.html`
711+ this . customPages . linkSendSuccess || `${ publicServerURL } /apps/link_send_success.html`
731712 ) ;
732713 }
733714
734- get linkSendFailURL ( ) {
735- return this . customPages . linkSendFail || `${ this . publicServerURL } /apps/link_send_fail.html` ;
715+ async linkSendFailURL ( ) {
716+ const publicServerURL = await this . getPublicServerURL ( ) ;
717+ return this . customPages . linkSendFail || `${ publicServerURL } /apps/link_send_fail.html` ;
736718 }
737719
738- get verifyEmailSuccessURL ( ) {
720+ async verifyEmailSuccessURL ( ) {
721+ const publicServerURL = await this . getPublicServerURL ( ) ;
739722 return (
740723 this . customPages . verifyEmailSuccess ||
741- `${ this . publicServerURL } /apps/verify_email_success.html`
724+ `${ publicServerURL } /apps/verify_email_success.html`
742725 ) ;
743726 }
744727
745- get choosePasswordURL ( ) {
746- return this . customPages . choosePassword || `${ this . publicServerURL } /apps/choose_password` ;
728+ async choosePasswordURL ( ) {
729+ const publicServerURL = await this . getPublicServerURL ( ) ;
730+ return this . customPages . choosePassword || `${ publicServerURL } /apps/choose_password` ;
747731 }
748732
749- get requestResetPasswordURL ( ) {
750- return `${ this . publicServerURL } /${ this . pagesEndpoint } /${ this . applicationId } /request_password_reset` ;
733+ async requestResetPasswordURL ( ) {
734+ const publicServerURL = await this . getPublicServerURL ( ) ;
735+ return `${ publicServerURL } /${ this . pagesEndpoint } /${ this . applicationId } /request_password_reset` ;
751736 }
752737
753- get passwordResetSuccessURL ( ) {
738+ async passwordResetSuccessURL ( ) {
739+ const publicServerURL = await this . getPublicServerURL ( ) ;
754740 return (
755741 this . customPages . passwordResetSuccess ||
756- `${ this . publicServerURL } /apps/password_reset_success.html`
742+ `${ publicServerURL } /apps/password_reset_success.html`
757743 ) ;
758744 }
759745
760746 get parseFrameURL ( ) {
761747 return this . customPages . parseFrameURL ;
762748 }
763749
764- get verifyEmailURL ( ) {
765- return `${ this . publicServerURL } /${ this . pagesEndpoint } /${ this . applicationId } /verify_email` ;
750+ async verifyEmailURL ( ) {
751+ const publicServerURL = await this . getPublicServerURL ( ) ;
752+ return `${ publicServerURL } /${ this . pagesEndpoint } /${ this . applicationId } /verify_email` ;
766753 }
767754
768755 async loadMasterKey ( ) {
0 commit comments