Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('should require an options object', function() {
expect(Authenticator).to.throw(ArgumentError, 'Missing authenticator options');
expect(Authenticator.bind(null, 1)).to.throw(
ArgumentError,
'The authenticator options must be an object'
);
expect(Authenticator.bind(null, validOptions)).to.not.throw(ArgumentError);
});
});
it('should error when no options are provided', function() {
expect(StatsManager).to.throw(ArgumentError, 'Must provide manager options');
});
TokensManager.prototype.getDelegationToken = function(data, cb) {
var body = extend({ client_id: this.clientId }, data);
var headers = this.headers;
if (!data) {
throw new ArgumentError('Missing token data object');
}
var hasIdToken = typeof data.id_token === 'string' && data.id_token.trim().length !== 0;
var hasRefreshToken =
typeof data.refresh_token === 'string' && data.refresh_token.trim().length !== 0;
if (!hasIdToken && !hasRefreshToken) {
throw new ArgumentError('one of id_token or refresh_token is required');
}
if (hasIdToken && hasRefreshToken) {
throw new ArgumentError('id_token and refresh_token fields cannot be specified simulatenously');
}
if (typeof data.target !== 'string' || data.target.trim().length === 0) {
var RolesManager = function(options) {
if (options === null || typeof options !== 'object') {
throw new ArgumentError('Must provide manager options');
}
if (options.baseUrl === null || options.baseUrl === undefined) {
throw new ArgumentError('Must provide a base URL for the API');
}
if ('string' !== typeof options.baseUrl || options.baseUrl.length === 0) {
throw new ArgumentError('The provided base URL is invalid');
}
/**
* Options object for the Rest Client instance.
*
* @type {Object}
*/
var clientOptions = {
headers: options.headers,
query: { repeatParams: false }
};
/**
* Provides an abstraction layer for performing CRUD operations on
* {@link https://auth0.com/docs/api/v2#!/RolesManager Auth0 RolesManagers}.
*
UserBlocksManager.prototype.getByIdentifier = function(params) {
if (typeof params !== 'object' || typeof params.identifier !== 'string') {
throw new ArgumentError('You must provide an user identifier for the getByIdentifier method');
}
return this.userBlocksByIdentifier.get.apply(this.userBlocksByIdentifier, arguments);
};
var ConnectionsManager = function(options) {
if (options === null || typeof options !== 'object') {
throw new ArgumentError('Must provide client options');
}
if (options.baseUrl === null || options.baseUrl === undefined) {
throw new ArgumentError('Must provide a base URL for the API');
}
if ('string' !== typeof options.baseUrl || options.baseUrl.length === 0) {
throw new ArgumentError('The provided base URL is invalid');
}
/**
* Options object for the Rest Client instance.
*
* @type {Object}
*/
var clientOptions = {
var EmailTemplatesManager = function(options) {
if (!options || 'object' !== typeof options) {
throw new ArgumentError('Must provide manager options');
}
if (!options.baseUrl || 'string' !== typeof options.baseUrl) {
throw new ArgumentError('Must provide a valid string as base URL for the API');
}
/**
* Options object for the Rest Client instance.
*
* @type {Object}
*/
var clientOptions = {
headers: options.headers,
query: { repeatParams: false }
};
var TokensManager = function(options) {
if (typeof options !== 'object') {
throw new ArgumentError('Missing tokens manager options');
}
if (typeof options.baseUrl !== 'string') {
throw new ArgumentError('baseUrl field is required');
}
this.baseUrl = options.baseUrl;
this.headers = options.headers || {};
this.clientId = options.clientId || '';
};
var BlacklistedTokensManager = function(options) {
if (options === null || typeof options !== 'object') {
throw new ArgumentError('Must provide client options');
}
if (options.baseUrl === null || options.baseUrl === undefined) {
throw new ArgumentError('Must provide a base URL for the API');
}
if ('string' !== typeof options.baseUrl || options.baseUrl.length === 0) {
throw new ArgumentError('The provided base URL is invalid');
}
/**
* Options object for the Rest Client instace.
*
* @type {Object}
*/
var clientOptions = {
errorFormatter: { message: 'message', name: 'error' },
headers: options.headers,
query: { repeatParams: false }
};
/**
* Provides an abstraction layer for consuming the
* [Auth0 Blacklisted Tokens endpoint]{@link https://auth0.com/docs/api/v2#!/Clients}.
var TenantManager = function(options) {
if (options === null || typeof options !== 'object') {
throw new ArgumentError('Must provide manager options');
}
if (options.baseUrl === null || options.baseUrl === undefined) {
throw new ArgumentError('Must provide a base URL for the API');
}
if ('string' !== typeof options.baseUrl || options.baseUrl.length === 0) {
throw new ArgumentError('The provided base URL is invalid');
}
var clientOptions = {
errorFormatter: { message: 'message', name: 'error' },
headers: options.headers,
query: { repeatParams: false }
};
/**
* Provides an abstraction layer for consuming the
* {@link https://auth0.com/docs/api/v2#!/Stats Stats endpoint}.
*
* @type {external:RestClient}
*/
var auth0RestClient = new Auth0RestClient(
options.baseUrl + '/tenants/settings',