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,86 +0,0 @@
1
- const BaseManager = require('./BaseManager');
2
-
3
- /**
4
- * The rules configs manager class provides a simple abstraction for performing CRUD operations
5
- * on Auth0 RulesConfigsManager.
6
- */
7
- class RulesConfigsManager 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/v2#!/RulesConfigsManager Auth0 RulesConfigsManager}.
20
- *
21
- * @type {external:RestClient}
22
- */
23
- this.resource = this._getRestClient('/rules-configs/:key');
24
- }
25
-
26
- /**
27
- * Set a new rules config.
28
- *
29
- * @example
30
- * var params = { key: RULE_CONFIG_KEY };
31
- * var data = { value: RULES_CONFIG_VALUE };
32
- *
33
- * management.rulesConfigs.set(params, data, function (err, rulesConfig) {
34
- * if (err) {
35
- * // Handle error.
36
- * }
37
- *
38
- * // Rules Config set.
39
- * });
40
- * @param {object} params Rule Config parameters.
41
- * @param {string} params.key Rule Config key.
42
- * @param {object} data Rule Config Data parameters.
43
- * @param {string} data.value Rule Config Data value.
44
- * @param {Function} [cb] Callback function.
45
- * @returns {Promise|undefined}
46
- */
47
- set(...args) {
48
- return this.resource.update(...args);
49
- }
50
-
51
- /**
52
- * Get all rules configs.
53
- *
54
- * @example
55
- * management.rulesConfigs.getAll(function (err, rulesConfig) {
56
- * console.log(rulesConfig.length);
57
- * });
58
- * @param {Function} [cb] Callback function.
59
- * @returns {Promise|undefined}
60
- */
61
- getAll(...args) {
62
- return this.resource.getAll(...args);
63
- }
64
-
65
- /**
66
- * Delete an existing rules config.
67
- *
68
- * @example
69
- * management.rulesConfigs.delete({ key: RULE_CONFIG_KEY }, function (err) {
70
- * if (err) {
71
- * // Handle error.
72
- * }
73
- *
74
- * // Rules Config deleted.
75
- * });
76
- * @param {object} params Rule Configs parameters.
77
- * @param {string} params.key Rule Configs key.
78
- * @param {Function} [cb] Callback function.
79
- * @returns {Promise|undefined}
80
- */
81
- delete(...args) {
82
- return this.resource.delete(...args);
83
- }
84
- }
85
-
86
- module.exports = RulesConfigsManager;
@@ -1,148 +0,0 @@
1
- const BaseManager = require('./BaseManager');
2
-
3
- /**
4
- * The rule class provides a simple abstraction for performing CRUD operations
5
- * on Auth0 RulesManagers.
6
- */
7
- class RulesManager 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/v2#!/RulesManagers Auth0 RulesManagers}.
20
- *
21
- * @type {external:RestClient}
22
- */
23
- this.resource = this._getRestClient('/rules/:id');
24
- }
25
-
26
- /**
27
- * Create a new rule.
28
- *
29
- * @example
30
- * management.rules.create(data, function (err) {
31
- * if (err) {
32
- * // Handle error.
33
- * }
34
- *
35
- * // Rule created.
36
- * });
37
- * @param {object} data Rule data object.
38
- * @param {Function} [cb] Callback function.
39
- * @returns {Promise|undefined}
40
- */
41
- create(...args) {
42
- return this.resource.create(...args);
43
- }
44
-
45
- /**
46
- * Get all rules.
47
- *
48
- * @example <caption>
49
- * This method takes an optional object as first argument that may be used to
50
- * specify pagination settings. If pagination options are not present,
51
- * the first page of a limited number of results will be returned.
52
- * </caption>
53
- *
54
- * // Pagination settings.
55
- * var params = {
56
- * per_page: 10,
57
- * page: 0
58
- * };
59
- *
60
- * management.rules.getAll(params, function (err, rules) {
61
- * console.log(rules.length);
62
- * });
63
- * @param {object} [params] Rules parameters.
64
- * @param {number} [params.per_page] Number of results per page.
65
- * @param {number} [params.page] Page number, zero indexed.
66
- * @param {Function} [cb] Callback function.
67
- * @returns {Promise|undefined}
68
- */
69
- getAll(...args) {
70
- return this.resource.getAll(...args);
71
- }
72
-
73
- /**
74
- * Get an Auth0 rule.
75
- *
76
- * @example
77
- * management.rules.get({ id: RULE_ID }, function (err, rule) {
78
- * if (err) {
79
- * // Handle error.
80
- * }
81
- *
82
- * console.log(rule);
83
- * });
84
- * @param {object} params Rule parameters.
85
- * @param {string} params.id Rule ID.
86
- * @param {Function} [cb] Callback function.
87
- * @returns {Promise|undefined}
88
- */
89
- get(...args) {
90
- return this.resource.get(...args);
91
- }
92
-
93
- /**
94
- * Update an existing rule.
95
- *
96
- * @example
97
- * var data = { name: 'New name' };
98
- * var params = { id: RULE_ID };
99
- *
100
- * // Using auth0 instance.
101
- * management.updateRule(params, data, function (err, rule) {
102
- * if (err) {
103
- * // Handle error.
104
- * }
105
- *
106
- * console.log(rule.name); // 'New name'
107
- * });
108
- *
109
- * // Using the rules manager directly.
110
- * management.rules.update(params, data, function (err, rule) {
111
- * if (err) {
112
- * // Handle error.
113
- * }
114
- *
115
- * console.log(rule.name); // 'New name'
116
- * });
117
- * @param {object} params Rule parameters.
118
- * @param {string} params.id Rule ID.
119
- * @param {object} data Updated rule data.
120
- * @param {Function} [cb] Callback function.
121
- * @returns {Promise|undefined}
122
- */
123
- update(...args) {
124
- return this.resource.patch(...args);
125
- }
126
-
127
- /**
128
- * Delete an existing rule.
129
- *
130
- * @example
131
- * management.rules.delete({ id: RULE_ID }, function (err) {
132
- * if (err) {
133
- * // Handle error.
134
- * }
135
- *
136
- * // Rule deleted.
137
- * });
138
- * @param {object} params Rule parameters.
139
- * @param {string} params.id Rule ID.
140
- * @param {Function} [cb] Callback function.
141
- * @returns {Promise|undefined}
142
- */
143
- delete(...args) {
144
- return this.resource.delete(...args);
145
- }
146
- }
147
-
148
- module.exports = RulesManager;
@@ -1,84 +0,0 @@
1
- const BaseManager = require('./BaseManager');
2
-
3
- /**
4
- * Abstracts interaction with the stats endpoint.
5
- */
6
- class StatsManager 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
18
- * {@link https://auth0.com/docs/api/v2#!/Stats Stats endpoint}.
19
- *
20
- * @type {external:RestClient}
21
- */
22
- this.resource = this._getRestClient('/stats/:type');
23
- }
24
-
25
- /**
26
- * Get the daily stats.
27
- *
28
- * @example
29
- * var params = {
30
- * from: '{YYYYMMDD}', // First day included in the stats.
31
- * to: '{YYYYMMDD}' // Last day included in the stats.
32
- * };
33
- *
34
- * management.stats.getDaily(params, function (err, stats) {
35
- * if (err) {
36
- * // Handle error.
37
- * }
38
- *
39
- * console.log(stats);
40
- * });
41
- * @param {object} params Stats parameters.
42
- * @param {string} params.from The first day in YYYYMMDD format.
43
- * @param {string} params.to The last day in YYYYMMDD format.
44
- * @param {Function} [cb] Callback function.
45
- * @returns {Promise|undefined}
46
- */
47
- getDaily(params, cb) {
48
- params = params || {};
49
- params.type = 'daily';
50
-
51
- if (cb && cb instanceof Function) {
52
- return this.resource.get(params, cb);
53
- }
54
-
55
- return this.resource.get(params);
56
- }
57
-
58
- /**
59
- * Get a the active users count.
60
- *
61
- * @example
62
- * management.stats.getActiveUsersCount(function (err, usersCount) {
63
- * if (err) {
64
- * // Handle error.
65
- * }
66
- *
67
- * console.log(usersCount);
68
- * });
69
- * @param {Function} [cb] Callback function.
70
- * @returns {Promise|undefined}
71
- */
72
- getActiveUsersCount(cb) {
73
- const options = { type: 'active-users' };
74
-
75
- if (cb && cb instanceof Function) {
76
- return this.resource.get(options, cb);
77
- }
78
-
79
- // Return a promise.
80
- return this.resource.get(options);
81
- }
82
- }
83
-
84
- module.exports = StatsManager;
@@ -1,76 +0,0 @@
1
- const BaseManager = require('./BaseManager');
2
-
3
- /**
4
- * Abstracts interaction with the tenant endpoint.
5
- */
6
- class TenantManager 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
18
- * {@link https://auth0.com/docs/api/v2#!/Stats Stats endpoint}.
19
- *
20
- * @type {external:RestClient}
21
- */
22
- this.resource = this._getRestClient('/tenants/settings');
23
- }
24
-
25
- /**
26
- * Update the tenant settings.
27
- *
28
- * @example
29
- * management.tenant.updateSettings(data, function (err) {
30
- * if (err) {
31
- * // Handle error.
32
- * }
33
- * });
34
- * @param {object} data The new tenant settings.
35
- * @param {Function} [cb] Callback function.
36
- * @returns {Promise|undefined}
37
- */
38
- updateSettings(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 settings..
49
- *
50
- * @example
51
- * management.tenant.getSettings({ include_fields: true, fields: 'friendly_name' }, function (err, settings) {
52
- * if (err) {
53
- * // Handle error.
54
- * }
55
- *
56
- * console.log(settings);
57
- * });
58
- * @param {object} [data] Request parameters
59
- * @param {Function} [cb] Callback function.
60
- * @returns {Promise|undefined}
61
- */
62
- getSettings(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 = TenantManager;
@@ -1,104 +0,0 @@
1
- const BaseManager = require('./BaseManager');
2
-
3
- /**
4
- * Abstracts interaction with the tickets endpoint.
5
- */
6
- class TicketsManager 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
18
- * {@link https://auth0.com/docs/api/v2#!/Tickets Tickets endpoint}.
19
- *
20
- * @type {external:RestClient}
21
- */
22
- this.resource = this._getRestClient('/tickets/:type');
23
- }
24
-
25
- /**
26
- * Create a new password change ticket.
27
- *
28
- * @example
29
- * var params = {
30
- * result_url: '{REDIRECT_URL}', // Redirect after using the ticket.
31
- * user_id: '{USER_ID}', // Optional.
32
- * email: '{USER_EMAIL}', // Optional.
33
- * new_password: '{PASSWORD}'
34
- * };
35
- *
36
- * management.tickets.changePassword(params, function (err) {
37
- * if (err) {
38
- * // Handle error.
39
- * }
40
- * });
41
- * @param {object} data
42
- * @param {string} [data.result_url] URL the user will be redirected to once ticket is used.
43
- * @param {string} [data.user_id] user_id for whom the ticket should be created. (Conflicts with: connection_id, email)
44
- * @param {string} [data.client_id] ID of the client.
45
- * @param {string} [data.organization_id] ID of the organization.
46
- * @param {string} [data.connection_id] ID of the connection.
47
- * @param {Integer} [data.ttl_sec] Number of seconds for which the ticket is valid before expiration.
48
- * @param {string} [data.email] Email of the user. (Requires: connection_id)
49
- * @param {boolean} [data.mark_email_as_verified] Whether to set the email_verified attribute to true (true) or whether it should not be updated (false).
50
- * @param {boolean} [data.includeEmailInRedirect] Whether to include the email address as part of the returnUrl in the reset_email (true), or not (false).
51
- * @param {Function} [cb] Callback function.
52
- * @returns {Promise}
53
- */
54
- changePassword(data, cb) {
55
- const params = { type: 'password-change' };
56
-
57
- if (cb && cb instanceof Function) {
58
- return this.resource.create(params, data, cb);
59
- }
60
-
61
- // Return a promise.
62
- return this.resource.create(params, data);
63
- }
64
-
65
- /**
66
- * Create an email verification ticket.
67
- *
68
- * @example
69
- * var data = {
70
- * user_id: '{USER_ID}',
71
- * result_url: '{REDIRECT_URL}' // Optional redirect after the ticket is used.
72
- * };
73
- *
74
- * management.tickets.verifyEmail(data, function (err) {
75
- * if (err) {
76
- * // Handle error.
77
- * }
78
- * });
79
- * @param {object} data
80
- * @param {string} [data.result_url] URL the user will be redirected to once ticket is used.
81
- * @param {string} data.user_id user_id for whom the ticket should be created.
82
- * @param {Integer} [data.ttl_sec] Number of seconds for which the ticket is valid before expiration.
83
- * @param {boolean} [data.includeEmailInRedirect] Whether to include the email address as part of the result_url (true), or not (false).
84
- * @param {object} [data.identity] Used to verify secondary, federated, and passwordless-email identities.
85
- * @param {string} data.identity.user_id user_id of the identity.
86
- * @param {string} data.identity.provider provider of the identity.
87
- * @param {string} [data.client_id] client ID.
88
- * @param {string} [data.organization_id] organization ID.
89
- * @param {Function} [cb] Callback function.
90
- * @returns {Promise}
91
- */
92
- verifyEmail(data, cb) {
93
- const params = { type: 'email-verification' };
94
-
95
- if (cb && cb instanceof Function) {
96
- return this.resource.create(params, data, cb);
97
- }
98
-
99
- // Return a promise.
100
- return this.resource.create(params, data);
101
- }
102
- }
103
-
104
- module.exports = TicketsManager;
@@ -1,121 +0,0 @@
1
- const { ArgumentError } = require('rest-facade');
2
- const BaseManager = require('./BaseManager');
3
-
4
- /**
5
- * Abstracts interaction with the user-blocks endpoint.
6
- */
7
- class UserBlocksManager 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
- this.userBlocksById = this._getRestClient('/user-blocks/:id');
18
-
19
- this.userBlocksByIdentifier = this._getRestClient('/user-blocks');
20
- }
21
-
22
- /**
23
- * Get user blocks by id.
24
- *
25
- * @example
26
- * management.userBlocks.get({ id: USER_ID }, function (err, blocks) {
27
- * if (err) {
28
- * // Handle error.
29
- * }
30
- *
31
- * console.log(blocks);
32
- * });
33
- * @param {object} params The user data object..
34
- * @param {string} params.id The user id.
35
- * @param {Function} [cb] Callback function
36
- * @returns {Promise|undefined}
37
- */
38
- get(params, ...restOfArgs) {
39
- if (typeof params !== 'object' || typeof params.id !== 'string') {
40
- throw new ArgumentError('You must provide an user id for the get method');
41
- }
42
-
43
- return this.userBlocksById.get(params, ...restOfArgs);
44
- }
45
-
46
- /**
47
- * Unblock an user by its id.
48
- *
49
- * @example
50
- * management.userBlocks.delete({ id: USER_ID }, function (err) {
51
- * if (err) {
52
- * // Handle error.
53
- * }
54
- *
55
- * // User unblocked.
56
- * });
57
- * @param {object} params The user data object..
58
- * @param {string} params.id The user id.
59
- * @param {Function} [cb] Callback function
60
- * @returns {Promise|undefined}
61
- */
62
- delete(params, ...restOfArgs) {
63
- if (typeof params !== 'object' || typeof params.id !== 'string') {
64
- throw new ArgumentError('You must provide an user id for the delete method');
65
- }
66
-
67
- return this.userBlocksById.delete(params, ...restOfArgs);
68
- }
69
-
70
- /**
71
- * Get user blocks by identifier.
72
- *
73
- * @example
74
- * management.userBlocks.getByIdentifier({ identifier: USER_ID }, function (err, blocks) {
75
- * if (err) {
76
- * // Handle error.
77
- * }
78
- *
79
- * console.log(blocks);
80
- * });
81
- * @param {object} params The user data object..
82
- * @param {string} params.identifier The user identifier, any of: username, phone_number, email.
83
- * @param {Function} [cb] Callback function
84
- * @returns {Promise|undefined}
85
- */
86
- getByIdentifier(params, ...restOfArgs) {
87
- if (typeof params !== 'object' || typeof params.identifier !== 'string') {
88
- throw new ArgumentError('You must provide an user identifier for the getByIdentifier method');
89
- }
90
-
91
- return this.userBlocksByIdentifier.get(params, ...restOfArgs);
92
- }
93
-
94
- /**
95
- * Unblock an user by identifier.
96
- *
97
- * @example
98
- * management.userBlocks.deleteByIdentifier({ identifier: USER_ID }, function (err) {
99
- * if (err) {
100
- * // Handle error.
101
- * }
102
- *
103
- * // User unblocked.
104
- * });
105
- * @param {object} params The user data object..
106
- * @param {string} params.identifier The user identifier, any of: username, phone_number, email.
107
- * @param {Function} [cb] Callback function
108
- * @returns {Promise|undefined}
109
- */
110
- deleteByIdentifier(params, ...restOfArgs) {
111
- if (typeof params !== 'object' || typeof params.identifier !== 'string') {
112
- throw new ArgumentError(
113
- 'You must provide an user identifier for the deleteByIdentifier method'
114
- );
115
- }
116
-
117
- return this.userBlocksByIdentifier.delete(params, ...restOfArgs);
118
- }
119
- }
120
-
121
- module.exports = UserBlocksManager;