Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
describe('instance', function() {
var client = new RetryRestClient(new RestClient(API_URL));
var methods = ['getAll', 'get', 'create', 'update', 'delete'];
methods.forEach(function(method) {
it('should have a ' + method + ' method', function() {
expect(client[method]).to.exist.to.be.an.instanceOf(Function);
});
});
});
before(function() {
this.restClient = new RestClient(API_URL);
});
var Auth0RestClient = function(resourceUrl, options, provider) {
if (resourceUrl === null || resourceUrl === undefined) {
throw new ArgumentError('Must provide a Resource Url');
}
if ('string' !== typeof resourceUrl || resourceUrl.length === 0) {
throw new ArgumentError('The provided Resource Url is invalid');
}
if (options === null || typeof options !== 'object') {
throw new ArgumentError('Must provide options');
}
this.options = options;
this.provider = provider;
this.restClient = new RestClient(resourceUrl, options);
this.wrappedProvider = function(method, args) {
if (!this.provider) {
return this.restClient[method].apply(this.restClient, args);
}
var callback;
if (args && args[args.length - 1] instanceof Function) {
callback = args[args.length - 1];
}
var self = this;
return this.provider
.getAccessToken()
.then(function(access_token) {
self.restClient.options.headers['Authorization'] = 'Bearer ' + access_token;
if (typeof options !== 'object') {
throw new ArgumentError('The authenticator options must be an object');
}
/**
* Options object for the Rest Client instace.
*
* @type {Object}
*/
var clientOptions = {
errorCustomizer: SanitizedError,
errorFormatter: { message: 'message', name: 'error' },
headers: options.headers
};
this.oauth = new RestClient(options.baseUrl + '/oauth/:type', clientOptions);
this.oauthWithIDTokenValidation = new OAUthWithIDTokenValidation(this.oauth, options);
this.clientId = options.clientId;
this.clientSecret = options.clientSecret;
};
if (typeof options !== 'object') {
throw new ArgumentError('The authenticator options must be an object');
}
/**
* Options object for the Rest Client instace.
*
* @type {Object}
*/
var clientOptions = {
errorFormatter: { message: 'message', name: 'error' },
headers: options.headers
};
this.oauth = oauth;
this.passwordless = new RestClient(options.baseUrl + '/passwordless/start', clientOptions);
this.clientId = options.clientId;
};
var SAMLAuthenticator = function (options) {
if (!options) {
throw new ArgumentError('Missing authenticator options');
}
if (typeof options !== 'object') {
throw new ArgumentError('The authenticator options must be an object');
}
var samlUrl = options.baseUrl + '/samlp/:type/:client_id';
this.saml = new RestClient(samlUrl);
this.clientId = options.clientId;
};
if (typeof options !== 'object') {
throw new ArgumentError('The authenticator options must be an object');
}
/**
* Options object for the Rest Client instace.
*
* @type {Object}
*/
var clientOptions = {
errorFormatter: { message: 'message', name: 'error' },
headers: options.headers
};
this.oauth = oauth;
this.dbConnections = new RestClient(options.baseUrl + '/dbconnections/:type', clientOptions);
this.clientId = options.clientId;
};