@@ -46,6 +46,7 @@ export class BDAccount {
4646 private bdStsToken : string | undefined ;
4747 private bdTapToken : string | undefined ;
4848 private bdTapMasterSecret : string | undefined ;
49+ private bdTapMasterSecretApplication : string | undefined ;
4950 private sharedTokens : IDecodedSession [ ] ;
5051 private selectedToken : string | undefined ;
5152 private decodedToken ! : jwt . JwtPayload | null ;
@@ -335,11 +336,15 @@ export class BDAccount {
335336 throw new Error ( `Failed to get fresh TAP token from BD API` ) ;
336337 }
337338
338- public async getTapMasterSecret ( ) : Promise < { bdTapMasterSecret : string ; cached : boolean } > {
339- if ( this . bdTapMasterSecret ) return { bdTapMasterSecret : this . bdTapMasterSecret , cached : true } ;
339+ public async getTapMasterSecret (
340+ application = "default" ,
341+ ) : Promise < { bdTapMasterSecret : string ; cached : boolean ; application : string } > {
342+ if ( this . bdTapMasterSecret && this . bdTapMasterSecretApplication === application ) {
343+ return { bdTapMasterSecret : this . bdTapMasterSecret , cached : true , application } ;
344+ }
340345 const headers = await getReqHeaders ( this . cognitoIdToken ) ; // , { tokenLifetime, vendingSchedule, shareId });
341346 const method = "POST" ;
342- const body = JSON . stringify ( { } ) ;
347+ const body = JSON . stringify ( { application } ) ;
343348 this . logger . debug ( { method, tapMasterSecretUrl, headers, body } ) ;
344349 const res = await fetch ( tapMasterSecretUrl , { method, headers, body } ) ;
345350 const resBody = await res . json ( ) ;
@@ -355,7 +360,12 @@ export class BDAccount {
355360 throw new Error ( "Missing bdTapMasterSecret in BD API Response" ) ;
356361 }
357362 this . bdTapMasterSecret = resBody . bdTapMasterSecret ;
358- return { bdTapMasterSecret : resBody . bdTapMasterSecret , cached : false } ;
363+ this . bdTapMasterSecretApplication = resBody ?. application ?? "default" ;
364+ return {
365+ bdTapMasterSecret : resBody . bdTapMasterSecret ,
366+ cached : false ,
367+ application : resBody ?. application ?? "default" ,
368+ } ;
359369 }
360370
361371 public async getStsToken ( tokenLifetime : string , shareId ?: string ) : Promise < { bdStsToken : string ; cached : boolean } > {
0 commit comments