Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
this.name,
this.address
);
await defaultLock.acquire(this._context.namespace.cbsSession.cbsLock, () => {
return this._context.namespace.cbsSession.init();
});
let tokenObject: AccessToken;
let tokenType: TokenType;
if (this._context.namespace.tokenCredential instanceof SharedKeyCredential) {
tokenObject = this._context.namespace.tokenCredential.getToken(this.audience);
tokenType = TokenType.CbsTokenTypeSas;
// renew sas token in every 45 minutess
this._tokenTimeout = (3600 - 900) * 1000;
} else {
const aadToken = await this._context.namespace.tokenCredential.getToken(Constants.aadServiceBusScope);
if (!aadToken) {
throw new Error(`Failed to get token from the provided "TokenCredential" object`);
}
tokenObject = aadToken;
tokenType = TokenType.CbsTokenTypeJwt;
this._tokenTimeout = tokenObject.expiresOnTimestamp - Date.now() - 2 * 60 * 1000;
}
log.link(
"[%s] %s: calling negotiateClaim for audience '%s'.",
this._context.namespace.connectionId,
this._type,
this.audience
);
// Acquire the lock to negotiate the CBS claim.
log.link(