auth0 3.3.0 → 4.0.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/README.md +19 -15
  2. package/package.json +47 -33
  3. package/CHANGELOG.md +0 -673
  4. package/src/Auth0RestClient.js +0 -123
  5. package/src/RetryRestClient.js +0 -105
  6. package/src/auth/DatabaseAuthenticator.js +0 -282
  7. package/src/auth/OAUthWithIDTokenValidation.js +0 -124
  8. package/src/auth/OAuthAuthenticator.js +0 -405
  9. package/src/auth/PasswordlessAuthenticator.js +0 -303
  10. package/src/auth/TokensManager.js +0 -254
  11. package/src/auth/UsersManager.js +0 -161
  12. package/src/auth/clientAuthentication.js +0 -86
  13. package/src/auth/idToken.js +0 -167
  14. package/src/auth/index.js +0 -573
  15. package/src/errors.js +0 -60
  16. package/src/index.js +0 -11
  17. package/src/index.mjs +0 -11
  18. package/src/management/ActionsManager.js +0 -526
  19. package/src/management/AttackProtectionManager.js +0 -158
  20. package/src/management/BaseManager.js +0 -41
  21. package/src/management/BlacklistedTokensManager.js +0 -67
  22. package/src/management/BrandingManager.js +0 -250
  23. package/src/management/ClientCredentialsManager.js +0 -112
  24. package/src/management/ClientGrantsManager.js +0 -124
  25. package/src/management/ClientsManager.js +0 -184
  26. package/src/management/ConnectionsManager.js +0 -213
  27. package/src/management/CustomDomainsManager.js +0 -141
  28. package/src/management/DeviceCredentialsManager.js +0 -91
  29. package/src/management/EmailProviderManager.js +0 -101
  30. package/src/management/EmailTemplatesManager.js +0 -90
  31. package/src/management/GrantsManager.js +0 -84
  32. package/src/management/GuardianManager.js +0 -361
  33. package/src/management/HooksManager.js +0 -295
  34. package/src/management/JobsManager.js +0 -324
  35. package/src/management/LogStreamsManager.js +0 -136
  36. package/src/management/LogsManager.js +0 -82
  37. package/src/management/ManagementTokenProvider.js +0 -144
  38. package/src/management/MigrationsManager.js +0 -76
  39. package/src/management/OrganizationsManager.js +0 -721
  40. package/src/management/PromptsManager.js +0 -162
  41. package/src/management/ResourceServersManager.js +0 -143
  42. package/src/management/RolesManager.js +0 -329
  43. package/src/management/RulesConfigsManager.js +0 -86
  44. package/src/management/RulesManager.js +0 -148
  45. package/src/management/StatsManager.js +0 -84
  46. package/src/management/TenantManager.js +0 -76
  47. package/src/management/TicketsManager.js +0 -104
  48. package/src/management/UserBlocksManager.js +0 -121
  49. package/src/management/UsersManager.js +0 -882
  50. package/src/management/index.js +0 -3405
  51. package/src/utils.js +0 -60
@@ -1,136 +0,0 @@
1
- const BaseManager = require('./BaseManager');
2
-
3
- /**
4
- * The logStreams class provides a simple abstraction for performing CRUD operations
5
- * on Auth0 Log Streams.
6
- */
7
- class LogStreamsManager extends BaseManager {
8
- /**
9
- * @param {object} options The client options.
10
- * @param {string} options.baseUrl The URL of the API.
11
- * @param {object} [options.headers] Headers to be included in all requests.
12
- * @param {object} [options.retry] Retry Policy Config
13
- */
14
- constructor(options) {
15
- super(options);
16
-
17
- /**
18
- * Provides an abstraction layer for performing CRUD operations on
19
- * {@link https://auth0.com/docs/api/management/v2#!/Log_Streams Auth0
20
- * Log Streams}.
21
- *
22
- * @type {external:RestClient}
23
- */
24
- this.resource = this._getRestClient('/log-streams/:id ');
25
- }
26
-
27
- /**
28
- * Get all Log Streams.
29
- *
30
- * @example
31
- *
32
- * management.logStreams.getAll(function (err, logStreams) {
33
- * console.log(logStreams.length);
34
- * });
35
- * @param {Function} [cb] Callback function.
36
- * @returns {Promise|undefined}
37
- */
38
- getAll(...args) {
39
- return this.resource.getAll(...args);
40
- }
41
-
42
- /**
43
- * Get an Auth0 Log Streams.
44
- *
45
- * @example
46
- * management.logStreams.get({ id: LOG_STREAM_ID }, function (err, logStream) {
47
- * if (err) {
48
- * // Handle error.
49
- * }
50
- *
51
- * console.log(logStream);
52
- * });
53
- * @param {object} params Log Stream parameters.
54
- * @param {string} params.id Log Stream ID.
55
- * @param {Function} [cb] Callback function.
56
- * @returns {Promise|undefined}
57
- */
58
- get(...args) {
59
- return this.resource.get(...args);
60
- }
61
-
62
- /**
63
- * Create an Auth0 Log Stream.
64
- *
65
- * @example
66
- * management.logStreams.create(data, function (err, log) {
67
- * if (err) {
68
- * // Handle error.
69
- * }
70
- *
71
- * console.log(log);
72
- * });
73
- * @param {object} data Log Stream data.
74
- * @param {Function} [cb] Callback function.
75
- * @returns {Promise|undefined}
76
- */
77
- create(...args) {
78
- return this.resource.create(...args);
79
- }
80
-
81
- /**
82
- * Update an Auth0 Log Streams.
83
- *
84
- * @example
85
- * var data = { name: 'New name' };
86
- * var params = { id: LOG_STREAM_ID };
87
- *
88
- * // Using auth0 instance.
89
- * management.updateLogStream(params, data, function (err, logStream) {
90
- * if (err) {
91
- * // Handle error.
92
- * }
93
- *
94
- * console.log(logStream.name); // 'New name'
95
- * });
96
- *
97
- * // Using the logStreams manager directly.
98
- * management.logStreams.update(params, data, function (err, logStream) {
99
- * if (err) {
100
- * // Handle error.
101
- * }
102
- *
103
- * console.log(logStream.name);
104
- * });
105
- * @param {object} params Log Stream parameters.
106
- * @param {string} params.id Log Stream ID.
107
- * @param {object} data Updated Log Stream data.
108
- * @param {Function} [cb] Callback function.
109
- * @returns {Promise|undefined}
110
- */
111
- update(...args) {
112
- return this.resource.patch(...args);
113
- }
114
-
115
- /**
116
- * Delete an Auth0 Log Streams.
117
- *
118
- * @example
119
- * management.logStreams.delete({ id: LOG_STREAM_ID }, function (err, log) {
120
- * if (err) {
121
- * // Handle error.
122
- * }
123
- *
124
- * console.log(log);
125
- * });
126
- * @param {object} params Log Stream parameters.
127
- * @param {string} params.id Log Stream ID.
128
- * @param {Function} [cb] Callback function.
129
- * @returns {Promise|undefined}
130
- */
131
- delete(...args) {
132
- return this.resource.delete(...args);
133
- }
134
- }
135
-
136
- module.exports = LogStreamsManager;
@@ -1,82 +0,0 @@
1
- const BaseManager = require('./BaseManager');
2
-
3
- /**
4
- * Represents the relationship between Auth0 and an Identity provider.
5
- */
6
- class LogsManager extends BaseManager {
7
- /**
8
- * @param {object} options The client options.
9
- * @param {string} options.baseUrl The URL of the API.
10
- * @param {object} [options.headers] Headers to be included in all requests.
11
- * @param {object} [options.retry] Retry Policy Config
12
- */
13
- constructor(options) {
14
- super(options);
15
-
16
- /**
17
- * Provides an abstraction layer for performing CRUD operations on
18
- * {@link https://auth0.com/docs/api/v2#!/LogsManagers Auth0
19
- * Logs}.
20
- *
21
- * @type {external:RestClient}
22
- */
23
- this.resource = this._getRestClient('/logs/:id');
24
- }
25
-
26
- /**
27
- * Get all logs.
28
- *
29
- * @example <caption>
30
- * This method takes an optional object as first argument that may be used to
31
- * specify pagination settings and the search query. If pagination options are
32
- * not present, the first page of a limited number of results will be returned.
33
- * </caption>
34
- *
35
- * // Pagination settings.
36
- * var params = {
37
- * per_page: 10,
38
- * page: 2
39
- * };
40
- *
41
- * management.logs.getAll(params, function (err, logs) {
42
- * console.log(logs.length);
43
- * });
44
- * @param {object} [params] Logs params.
45
- * @param {string} [params.q] Search Criteria using Query String Syntax
46
- * @param {number} [params.page] Page number. Zero based
47
- * @param {number} [params.per_page] The amount of entries per page
48
- * @param {string} [params.sort] The field to use for sorting.
49
- * @param {string} [params.fields] A comma separated list of fields to include or exclude
50
- * @param {boolean} [params.include_fields] true if the fields specified are to be included in the result, false otherwise.
51
- * @param {boolean} [params.include_totals] true if a query summary must be included in the result, false otherwise. Default false
52
- * @param {string} [params.from] For checkpoint pagination, log event Id from which to start selection from.
53
- * @param {number} [params.take] When using the `from` parameter, the number of entries to retrieve. Default 50, max 100.
54
- * @param {Function} [cb] Callback function.
55
- * @returns {Promise|undefined}
56
- */
57
- getAll(...args) {
58
- return this.resource.getAll(...args);
59
- }
60
-
61
- /**
62
- * Get an Auth0 log.
63
- *
64
- * @example
65
- * management.logs.get({ id: EVENT_ID }, function (err, log) {
66
- * if (err) {
67
- * // Handle error.
68
- * }
69
- *
70
- * console.log(log);
71
- * });
72
- * @param {object} params Log parameters.
73
- * @param {string} params.id Log ID.
74
- * @param {Function} [cb] Callback function.
75
- * @returns {Promise|undefined}
76
- */
77
- get(...args) {
78
- return this.resource.get(...args);
79
- }
80
- }
81
-
82
- module.exports = LogsManager;
@@ -1,144 +0,0 @@
1
- const { ArgumentError } = require('rest-facade');
2
- const AuthenticationClient = require('../auth');
3
- const memoizer = require('lru-memoizer');
4
- const util = require('util');
5
-
6
- /**
7
- * Auth0 Management API Token Provider.
8
- */
9
- class ManagementTokenProvider {
10
- /**
11
- * @param {object} options Options for the ManagementTokenProvider.
12
- * @param {string} options.domain ManagementClient server domain.
13
- * @param {string} options.clientId Non Interactive Client Id.
14
- * @param {string} options.clientSecret Non Interactive Client Secret.
15
- * @param {string} options.clientAssertionSigningKey Private key used to sign the client assertion JWT.
16
- * @param {string} options.clientAssertionSigningAlg Default 'RS256'.
17
- * @param {string} options.scope Non Interactive Client Scope.
18
- * @param {string} options.audience Audience of the Management API.
19
- * @param {boolean} [options.enableCache=true] Enabled or Disable Cache
20
- * @param {number} [options.cacheTTLInSeconds] By default the `expires_in` value will be used to determine the cached time of the token, this can be overridden.
21
- * @param {object} [options.headers] Additional headers that will be added to the outgoing requests.
22
- * @param {string} [options.proxy] Add the `superagent-proxy` dependency and specify a proxy url eg 'https://myproxy.com:1234'
23
- */
24
- constructor(options) {
25
- if (!options || typeof options !== 'object') {
26
- throw new ArgumentError('Options must be an object');
27
- }
28
-
29
- const params = { enableCache: true, ...options };
30
-
31
- if (!params.domain || params.domain.length === 0) {
32
- throw new ArgumentError('Must provide a domain');
33
- }
34
-
35
- if (!params.clientId || params.clientId.length === 0) {
36
- throw new ArgumentError('Must provide a clientId');
37
- }
38
-
39
- if (
40
- (!params.clientSecret || params.clientSecret.length === 0) &&
41
- (!params.clientAssertionSigningKey || params.clientAssertionSigningKey.length === 0)
42
- ) {
43
- throw new ArgumentError('Must provide a clientSecret or a clientAssertionSigningKey');
44
- }
45
-
46
- if (!params.audience || params.audience.length === 0) {
47
- throw new ArgumentError('Must provide a audience');
48
- }
49
-
50
- if (typeof params.enableCache !== 'boolean') {
51
- throw new ArgumentError('enableCache must be a boolean');
52
- }
53
-
54
- if (params.enableCache && params.cacheTTLInSeconds) {
55
- if (typeof params.cacheTTLInSeconds !== 'number') {
56
- throw new ArgumentError('cacheTTLInSeconds must be a number');
57
- }
58
-
59
- if (params.cacheTTLInSeconds <= 0) {
60
- throw new ArgumentError('cacheTTLInSeconds must be a greater than 0');
61
- }
62
- }
63
-
64
- if (params.scope && typeof params.scope !== 'string') {
65
- throw new ArgumentError('scope must be a string');
66
- }
67
-
68
- this.options = params;
69
- const authenticationClientOptions = {
70
- domain: this.options.domain,
71
- clientId: this.options.clientId,
72
- clientSecret: this.options.clientSecret,
73
- clientAssertionSigningKey: this.options.clientAssertionSigningKey,
74
- clientAssertionSigningAlg: this.options.clientAssertionSigningAlg,
75
- telemetry: this.options.telemetry,
76
- clientInfo: this.options.clientInfo,
77
- headers: this.options.headers,
78
- proxy: this.options.proxy,
79
- };
80
- this.authenticationClient = new AuthenticationClient(authenticationClientOptions);
81
-
82
- const self = this;
83
- this.getCachedAccessToken = util.promisify(
84
- memoizer({
85
- load(options, callback) {
86
- self
87
- .clientCredentialsGrant(options.domain, options.scope, options.audience)
88
- .then((data) => {
89
- callback(null, data);
90
- })
91
- .catch((err) => {
92
- callback(err);
93
- });
94
- },
95
- hash(options) {
96
- return `${options.domain}-${options.clientId}-${options.scope}`;
97
- },
98
- itemMaxAge(options, data) {
99
- if (options.cacheTTLInSeconds) {
100
- return options.cacheTTLInSeconds * 1000;
101
- }
102
-
103
- // if the expires_in is lower or equal to than 10 seconds, do not subtract 10 additional seconds.
104
- if (data.expires_in && data.expires_in <= 10 /* seconds */) {
105
- return data.expires_in * 1000;
106
- } else if (data.expires_in) {
107
- // Subtract 10 seconds from expires_in to fetch a new one, before it expires.
108
- return data.expires_in * 1000 - 10000 /* milliseconds */;
109
- }
110
- return 60 * 60 * 1000; //1h
111
- },
112
- max: 100,
113
- })
114
- );
115
- }
116
-
117
- /**
118
- * Returns the access_token.
119
- *
120
- * @returns {Promise} Promise returning an access_token.
121
- */
122
- async getAccessToken() {
123
- if (this.options.enableCache) {
124
- const data = await this.getCachedAccessToken(this.options);
125
- return data.access_token;
126
- } else {
127
- const data = await this.clientCredentialsGrant(
128
- this.options.domain,
129
- this.options.scope,
130
- this.options.audience
131
- );
132
- return data.access_token;
133
- }
134
- }
135
-
136
- clientCredentialsGrant(domain, scope, audience) {
137
- return this.authenticationClient.clientCredentialsGrant({
138
- audience,
139
- scope,
140
- });
141
- }
142
- }
143
-
144
- module.exports = ManagementTokenProvider;
@@ -1,76 +0,0 @@
1
- const BaseManager = require('./BaseManager');
2
-
3
- /**
4
- * Abstracts interaction with the migrations endpoint.
5
- */
6
- class MigrationsManager extends BaseManager {
7
- /**
8
- * @param {object} options The client options.
9
- * @param {string} options.baseUrl The URL of the API.
10
- * @param {object} [options.headers] Headers to be included in all requests.
11
- * @param {object} [options.retry] Retry Policy Config
12
- */
13
- constructor(options) {
14
- super(options);
15
-
16
- /**
17
- * Provides an abstraction layer for consuming the migrations endpoint
18
- *
19
- * @type {external:RestClient}
20
- */
21
- this.resource = this._getRestClient('/migrations');
22
- }
23
-
24
- /**
25
- * Update the tenant migrations.
26
- *
27
- * @example
28
- * management.migrations.updateMigrations(data, function (err) {
29
- * if (err) {
30
- * // Handle error.
31
- * }
32
- * });
33
- * @param {object} data The tenant migrations to be updated
34
- * @param {object} data.flags The tenant migrations flags to be updated
35
- * @param {Function} [cb] Callback function.
36
- * @returns {Promise|undefined}
37
- */
38
- updateMigrations(data, cb) {
39
- if (cb && cb instanceof Function) {
40
- return this.resource.patch({}, data, cb);
41
- }
42
-
43
- // Return a promise.
44
- return this.resource.patch({}, data);
45
- }
46
-
47
- /**
48
- * Get the tenant migrations.
49
- *
50
- * @example
51
- * management.migrations.getMigrations(function (err, migrations) {
52
- * if (err) {
53
- * // Handle error.
54
- * }
55
- *
56
- * console.log(migrations.flags);
57
- * });
58
- * @param data
59
- * @param {Function} [cb] Callback function.
60
- * @returns {Promise|undefined}
61
- */
62
- getMigrations(data, cb) {
63
- if (data instanceof Function && !cb) {
64
- cb = data;
65
- data = {};
66
- }
67
- if (cb && cb instanceof Function) {
68
- return this.resource.get(data, cb);
69
- }
70
-
71
- // Return a promise.
72
- return this.resource.get(data);
73
- }
74
- }
75
-
76
- module.exports = MigrationsManager;