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