Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
this.tokenRenewalMarginInSeconds = 270;
/**
* @property {number} tokenValidTimeInSeconds - The number of seconds for which the
* token is valid. A constant set to 3599 seconds (~1 hour). Adal has a set valid time of
* 1 hour (3600 seconds) when it refreshes the access token.
*/
this.tokenValidTimeInSeconds = 3599;
if (!credentials ||
(credentials &&
!(credentials instanceof ms_rest_azure_1.ApplicationTokenCredentials ||
credentials instanceof ms_rest_azure_1.UserTokenCredentials ||
credentials instanceof ms_rest_azure_1.DeviceTokenCredentials ||
credentials instanceof ms_rest_azure_1.MSITokenCredentials))) {
throw new Error("'credentials' is a required parameter and must be an instance of ApplicationTokenCredentials | UserTokenCredentials | DeviceTokenCredentials | MSITokenCredentials.");
}
if (credentials instanceof ms_rest_azure_1.MSITokenCredentials) {
credentials.resource = Constants.aadEventHubsAudience;
}
this.credentials = credentials;
}
/**
static createFromAadTokenCredentials(host, entityPath, credentials) {
if (!host || (host && typeof host !== "string")) {
throw new Error("'host' is a required parameter and must be of type: 'string'.");
}
if (!entityPath || (entityPath && typeof entityPath !== "string")) {
throw new Error("'entityPath' is a required parameter and must be of type: 'string'.");
}
if (!credentials ||
!(credentials instanceof ms_rest_azure_1.ApplicationTokenCredentials ||
credentials instanceof ms_rest_azure_1.UserTokenCredentials ||
credentials instanceof ms_rest_azure_1.DeviceTokenCredentials ||
credentials instanceof ms_rest_azure_1.MSITokenCredentials)) {
throw new Error("'credentials' is a required parameter and must be an instance of ApplicationTokenCredentials | UserTokenCredentials | DeviceTokenCredentials | MSITokenCredentials.");
}
if (!host.endsWith("/"))
host += "/";
const connectionString = `Endpoint=sb://${host};SharedAccessKeyName=defaultKeyName;SharedAccessKey=defaultKeyValue`;
const tokenProvider = new aad_1.AadTokenProvider(credentials);
return EventHubClient.createFromConnectionString(connectionString, entityPath, tokenProvider);
}
}
static createFromAadTokenCredentials(host, entityPath, credentials) {
if (!host || (host && typeof host !== "string")) {
throw new Error("'host' is a required parameter and must be of type: 'string'.");
}
if (!entityPath || (entityPath && typeof entityPath !== "string")) {
throw new Error("'entityPath' is a required parameter and must be of type: 'string'.");
}
if (!credentials ||
!(credentials instanceof ms_rest_azure_1.ApplicationTokenCredentials ||
credentials instanceof ms_rest_azure_1.UserTokenCredentials ||
credentials instanceof ms_rest_azure_1.DeviceTokenCredentials ||
credentials instanceof ms_rest_azure_1.MSITokenCredentials)) {
throw new Error("'credentials' is a required parameter and must be an instance of ApplicationTokenCredentials | UserTokenCredentials | DeviceTokenCredentials | MSITokenCredentials.");
}
if (!host.endsWith("/"))
host += "/";
const connectionString = `Endpoint=sb://${host};SharedAccessKeyName=defaultKeyName;SharedAccessKey=defaultKeyValue`;
const tokenProvider = new aad_1.AadTokenProvider(credentials);
return EventHubClient.createFromConnectionString(connectionString, entityPath, tokenProvider);
}
}
* good to renew the token. A constant set to 270 seconds (4.5 minutes). Adal has a set window of 5 minutes
* when it refreshes the token from its token cache.
*/
this.tokenRenewalMarginInSeconds = 270;
/**
* @property {number} tokenValidTimeInSeconds - The number of seconds for which the
* token is valid. A constant set to 3599 seconds (~1 hour). Adal has a set valid time of
* 1 hour (3600 seconds) when it refreshes the access token.
*/
this.tokenValidTimeInSeconds = 3599;
if (!credentials ||
(credentials &&
!(credentials instanceof ms_rest_azure_1.ApplicationTokenCredentials ||
credentials instanceof ms_rest_azure_1.UserTokenCredentials ||
credentials instanceof ms_rest_azure_1.DeviceTokenCredentials ||
credentials instanceof ms_rest_azure_1.MSITokenCredentials))) {
throw new Error("'credentials' is a required parameter and must be an instance of ApplicationTokenCredentials | UserTokenCredentials | DeviceTokenCredentials | MSITokenCredentials.");
}
if (credentials instanceof ms_rest_azure_1.MSITokenCredentials) {
credentials.resource = Constants.aadEventHubsAudience;
}
this.credentials = credentials;
}
/**