@@ -29,6 +29,7 @@ import {
2929 OIDCEndpoints ,
3030 TokenResponse ,
3131 extractPkceStorageKeyFromState ,
32+ Config ,
3233} from '@asgardeo/javascript' ;
3334import { SPAHelper } from './spa-helper' ;
3435import {
@@ -103,26 +104,26 @@ export class AuthenticationHelper<T extends MainThreadClientConfig | WebWorkerCl
103104 config : SPACustomGrantConfig ,
104105 enableRetrievingSignOutURLFromSession ?: ( config : SPACustomGrantConfig ) => void ,
105106 ) : Promise < User | Response > {
107+ const _config : Config = ( await this . _storageManager . getConfigData ( ) ) as Config ;
106108 let useDefaultEndpoint = true ;
107109 let matches = false ;
108110
109111 // If the config does not contains a token endpoint, default token endpoint will be used.
110112 if ( config ?. tokenEndpoint ) {
111113 useDefaultEndpoint = false ;
112114
113- for ( const baseUrl of [
114- ...( ( await this . _storageManager . getConfigData ( ) ) ?. resourceServerURLs ?? [ ] ) ,
115- ( config as any ) . baseUrl ,
116- ] ) {
115+ for ( const baseUrl of [ ...( _config ?. allowedExternalUrls ?? [ ] ) , ( config as any ) . baseUrl ] ) {
117116 if ( baseUrl && config . tokenEndpoint ?. startsWith ( baseUrl ) ) {
118117 matches = true ;
119118 break ;
120119 }
121120 }
122121 }
122+
123123 if ( config . shouldReplayAfterRefresh ) {
124124 this . _storageManager . setTemporaryDataParameter ( CUSTOM_GRANT_CONFIG , JSON . stringify ( config ) ) ;
125125 }
126+
126127 if ( useDefaultEndpoint || matches ) {
127128 return this . _authenticationClient
128129 . exchangeToken ( config )
@@ -147,9 +148,9 @@ export class AuthenticationHelper<T extends MainThreadClientConfig | WebWorkerCl
147148 new AsgardeoAuthException (
148149 'SPA-MAIN_THREAD_CLIENT-RCG-IV01' ,
149150 'Request to the provided endpoint is prohibited.' ,
150- 'Requests can only be sent to resource servers specified by the `resourceServerURLs `' +
151+ 'Requests can only be sent to resource servers specified by the `allowedExternalUrls `' +
151152 ' attribute while initializing the SDK. The specified token endpoint in this request ' +
152- 'cannot be found among the `resourceServerURLs `' ,
153+ 'cannot be found among the `allowedExternalUrls `' ,
153154 ) ,
154155 ) ;
155156 }
@@ -224,9 +225,9 @@ export class AuthenticationHelper<T extends MainThreadClientConfig | WebWorkerCl
224225 enableRetrievingSignOutURLFromSession ?: ( config : SPACustomGrantConfig ) => void ,
225226 ) : Promise < HttpResponse > {
226227 let matches = false ;
227- const config = await this . _storageManager . getConfigData ( ) ;
228+ const config : Config = ( await this . _storageManager . getConfigData ( ) ) as Config ;
228229
229- for ( const baseUrl of [ ...( ( await config ?. resourceServerURLs ) ?? [ ] ) , ( config as any ) . baseUrl ] ) {
230+ for ( const baseUrl of [ ...( config ?. allowedExternalUrls ?? [ ] ) , ( config as any ) . baseUrl ] ) {
230231 if ( baseUrl && requestConfig ?. url ?. startsWith ( baseUrl ) ) {
231232 matches = true ;
232233
@@ -319,9 +320,9 @@ export class AuthenticationHelper<T extends MainThreadClientConfig | WebWorkerCl
319320 new AsgardeoAuthException (
320321 'SPA-AUTH_HELPER-HR-IV02' ,
321322 'Request to the provided endpoint is prohibited.' ,
322- 'Requests can only be sent to resource servers specified by the `resourceServerURLs `' +
323+ 'Requests can only be sent to resource servers specified by the `allowedExternalUrls `' +
323324 ' attribute while initializing the SDK. The specified endpoint in this request ' +
324- 'cannot be found among the `resourceServerURLs `' ,
325+ 'cannot be found among the `allowedExternalUrls `' ,
325326 ) ,
326327 ) ;
327328 }
@@ -335,12 +336,12 @@ export class AuthenticationHelper<T extends MainThreadClientConfig | WebWorkerCl
335336 httpFinishCallback ?: ( ) => void ,
336337 ) : Promise < HttpResponse [ ] | undefined > {
337338 let matches = true ;
338- const config = await this . _storageManager . getConfigData ( ) ;
339+ const config : Config = ( await this . _storageManager . getConfigData ( ) ) as Config ;
339340
340341 for ( const requestConfig of requestConfigs ) {
341342 let urlMatches = false ;
342343
343- for ( const baseUrl of [ ...( ( await config ) ?. resourceServerURLs ?? [ ] ) , ( config as any ) . baseUrl ] ) {
344+ for ( const baseUrl of [ ...( config ?. allowedExternalUrls ?? [ ] ) , ( config as any ) . baseUrl ] ) {
344345 if ( baseUrl && requestConfig . url ?. startsWith ( baseUrl ) ) {
345346 urlMatches = true ;
346347
@@ -436,9 +437,9 @@ export class AuthenticationHelper<T extends MainThreadClientConfig | WebWorkerCl
436437 throw new AsgardeoAuthException (
437438 'SPA-AUTH_HELPER-HRA-IV02' ,
438439 'Request to the provided endpoint is prohibited.' ,
439- 'Requests can only be sent to resource servers specified by the `resourceServerURLs `' +
440+ 'Requests can only be sent to resource servers specified by the `allowedExternalUrls `' +
440441 ' attribute while initializing the SDK. The specified endpoint in this request ' +
441- 'cannot be found among the `resourceServerURLs `' ,
442+ 'cannot be found among the `allowedExternalUrls `' ,
442443 ) ;
443444 }
444445 }
0 commit comments