@@ -33,7 +33,7 @@ export class NdiOidcHelper {
3333 private redirectUri : string ;
3434 private jweDecryptKey : Key ;
3535 private clientAssertionSignKey : Key ;
36- private oidcConfig : Promise < OidcConfig > ;
36+ private oidcConfig : OidcConfig ;
3737
3838 constructor ( props : NdiOidcHelperConstructor ) {
3939 this . oidcConfigUrl = props . oidcConfigUrl ;
@@ -46,8 +46,6 @@ export class NdiOidcHelper {
4646 timeout : 10000 ,
4747 proxy : props . proxyConfig ,
4848 } ) ;
49-
50- this . oidcConfig = this . axiosClient . get < OidcConfig > ( this . oidcConfigUrl ) . then ( ( res ) => res . data ) ;
5149 }
5250
5351 public constructAuthorizationUrl = async (
@@ -66,7 +64,7 @@ export class NdiOidcHelper {
6664 userInfoScope : string [ ] ,
6765 codeVerifier ?: string ,
6866 ) : Promise < string > => {
69- const { authorization_endpoint } = await this . oidcConfig ;
67+ const { authorization_endpoint } = await this . getOidcConfig ( ) ;
7068
7169 userInfoScope . unshift ( "openid" ) ;
7270
@@ -90,7 +88,7 @@ export class NdiOidcHelper {
9088 * Use getIdTokenPayload on returned Token Response to get the token payload
9189 */
9290 public getTokens = async ( authCode : string , codeVerifier ?: string ) : Promise < TokenResponse > => {
93- const { token_endpoint, issuer } = await this . oidcConfig ;
91+ const { token_endpoint, issuer } = await this . getOidcConfig ( ) ;
9492
9593 const params = {
9694 grant_type : "authorization_code" ,
@@ -149,8 +147,17 @@ export class NdiOidcHelper {
149147 }
150148 } ;
151149
150+ private getOidcConfig = async ( ) : Promise < OidcConfig > => {
151+ if ( ! this . oidcConfig ) {
152+ const response = await this . axiosClient . get < OidcConfig > ( this . oidcConfigUrl ) ;
153+ this . oidcConfig = response . data ;
154+ }
155+
156+ return this . oidcConfig ;
157+ } ;
158+
152159 private getKeys = async ( ) => {
153- const { jwks_uri } = await this . oidcConfig ;
160+ const { jwks_uri } = await this . getOidcConfig ( ) ;
154161 const {
155162 data : { keys } ,
156163 } = await this . axiosClient . get < { keys : object [ ] } > ( jwks_uri ) ;
0 commit comments