auth0 2.36.1 → 2.38.1
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.
- package/CHANGELOG.md +557 -0
- package/README.md +33 -11
- package/package.json +22 -15
- package/src/Auth0RestClient.js +72 -71
- package/src/RetryRestClient.js +78 -81
- package/src/auth/DatabaseAuthenticator.js +242 -259
- package/src/auth/OAUthWithIDTokenValidation.js +99 -103
- package/src/auth/OAuthAuthenticator.js +325 -344
- package/src/auth/PasswordlessAuthenticator.js +238 -252
- package/src/auth/TokensManager.js +231 -246
- package/src/auth/UsersManager.js +149 -160
- package/src/auth/idToken.js +22 -19
- package/src/auth/index.js +510 -581
- package/src/errors.js +23 -23
- package/src/index.js +3 -2
- package/src/management/ActionsManager.js +503 -585
- package/src/management/BlacklistedTokensManager.js +77 -84
- package/src/management/BrandingManager.js +141 -163
- package/src/management/ClientGrantsManager.js +132 -145
- package/src/management/ClientsManager.js +145 -161
- package/src/management/ConnectionsManager.js +215 -204
- package/src/management/CustomDomainsManager.js +140 -157
- package/src/management/DeviceCredentialsManager.js +95 -111
- package/src/management/EmailProviderManager.js +110 -128
- package/src/management/EmailTemplatesManager.js +96 -112
- package/src/management/GrantsManager.js +94 -101
- package/src/management/GuardianManager.js +381 -455
- package/src/management/HooksManager.js +283 -325
- package/src/management/JobsManager.js +310 -343
- package/src/management/LogStreamsManager.js +142 -158
- package/src/management/LogsManager.js +92 -99
- package/src/management/ManagementTokenProvider.js +112 -120
- package/src/management/MigrationsManager.js +81 -90
- package/src/management/OrganizationsManager.js +686 -761
- package/src/management/PromptsManager.js +160 -182
- package/src/management/ResourceServersManager.js +143 -160
- package/src/management/RolesManager.js +323 -369
- package/src/management/RulesConfigsManager.js +94 -110
- package/src/management/RulesManager.js +154 -176
- package/src/management/StatsManager.js +87 -103
- package/src/management/TenantManager.js +81 -97
- package/src/management/TicketsManager.js +107 -115
- package/src/management/UserBlocksManager.js +135 -162
- package/src/management/UsersManager.js +729 -852
- package/src/management/index.js +3094 -3619
- package/src/utils.js +31 -60
|
@@ -1,123 +1,107 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
const { ArgumentError } = require('rest-facade');
|
|
2
|
+
const Auth0RestClient = require('../Auth0RestClient');
|
|
3
|
+
const RetryRestClient = require('../RetryRestClient');
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* Simple facade for consuming a REST API endpoint.
|
|
7
|
-
* @external RestClient
|
|
8
|
-
* @see https://github.com/ngonzalvez/rest-facade
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* @class
|
|
13
6
|
* Abstracts interaction with the stats endpoint.
|
|
14
|
-
* @constructor
|
|
15
|
-
* @memberOf module:management
|
|
16
|
-
*
|
|
17
|
-
* @param {Object} options The client options.
|
|
18
|
-
* @param {String} options.baseUrl The URL of the API.
|
|
19
|
-
* @param {Object} [options.headers] Headers to be included in all requests.
|
|
20
|
-
* @param {Object} [options.retry] Retry Policy Config
|
|
21
7
|
*/
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
8
|
+
class StatsManager {
|
|
9
|
+
/**
|
|
10
|
+
* @param {object} options The client options.
|
|
11
|
+
* @param {string} options.baseUrl The URL of the API.
|
|
12
|
+
* @param {object} [options.headers] Headers to be included in all requests.
|
|
13
|
+
* @param {object} [options.retry] Retry Policy Config
|
|
14
|
+
*/
|
|
15
|
+
constructor(options) {
|
|
16
|
+
if (options === null || typeof options !== 'object') {
|
|
17
|
+
throw new ArgumentError('Must provide manager options');
|
|
18
|
+
}
|
|
26
19
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
20
|
+
if (options.baseUrl === null || options.baseUrl === undefined) {
|
|
21
|
+
throw new ArgumentError('Must provide a base URL for the API');
|
|
22
|
+
}
|
|
30
23
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
24
|
+
if ('string' !== typeof options.baseUrl || options.baseUrl.length === 0) {
|
|
25
|
+
throw new ArgumentError('The provided base URL is invalid');
|
|
26
|
+
}
|
|
34
27
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
28
|
+
const clientOptions = {
|
|
29
|
+
errorFormatter: { message: 'message', name: 'error' },
|
|
30
|
+
headers: options.headers,
|
|
31
|
+
query: { repeatParams: false },
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Provides an abstraction layer for consuming the
|
|
36
|
+
* {@link https://auth0.com/docs/api/v2#!/Stats Stats endpoint}.
|
|
37
|
+
*
|
|
38
|
+
* @type {external:RestClient}
|
|
39
|
+
*/
|
|
40
|
+
const auth0RestClient = new Auth0RestClient(
|
|
41
|
+
`${options.baseUrl}/stats/:type`,
|
|
42
|
+
clientOptions,
|
|
43
|
+
options.tokenProvider
|
|
44
|
+
);
|
|
45
|
+
this.resource = new RetryRestClient(auth0RestClient, options.retry);
|
|
46
|
+
}
|
|
40
47
|
|
|
41
48
|
/**
|
|
42
|
-
*
|
|
43
|
-
*
|
|
49
|
+
* Get the daily stats.
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* var params = {
|
|
53
|
+
* from: '{YYYYMMDD}', // First day included in the stats.
|
|
54
|
+
* to: '{YYYYMMDD}' // Last day included in the stats.
|
|
55
|
+
* };
|
|
44
56
|
*
|
|
45
|
-
*
|
|
57
|
+
* management.stats.getDaily(params, function (err, stats) {
|
|
58
|
+
* if (err) {
|
|
59
|
+
* // Handle error.
|
|
60
|
+
* }
|
|
61
|
+
*
|
|
62
|
+
* console.log(stats);
|
|
63
|
+
* });
|
|
64
|
+
* @param {object} params Stats parameters.
|
|
65
|
+
* @param {string} params.from The first day in YYYYMMDD format.
|
|
66
|
+
* @param {string} params.to The last day in YYYYMMDD format.
|
|
67
|
+
* @param {Function} [cb] Callback function.
|
|
68
|
+
* @returns {Promise|undefined}
|
|
46
69
|
*/
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
options.tokenProvider
|
|
51
|
-
);
|
|
52
|
-
this.resource = new RetryRestClient(auth0RestClient, options.retry);
|
|
53
|
-
};
|
|
70
|
+
getDaily(params, cb) {
|
|
71
|
+
params = params || {};
|
|
72
|
+
params.type = 'daily';
|
|
54
73
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
* @method getDaily
|
|
59
|
-
* @memberOf module:management.StatsManager.prototype
|
|
60
|
-
*
|
|
61
|
-
* @example
|
|
62
|
-
* var params = {
|
|
63
|
-
* from: '{YYYYMMDD}', // First day included in the stats.
|
|
64
|
-
* to: '{YYYYMMDD}' // Last day included in the stats.
|
|
65
|
-
* };
|
|
66
|
-
*
|
|
67
|
-
* management.stats.getDaily(params, function (err, stats) {
|
|
68
|
-
* if (err) {
|
|
69
|
-
* // Handle error.
|
|
70
|
-
* }
|
|
71
|
-
*
|
|
72
|
-
* console.log(stats);
|
|
73
|
-
* });
|
|
74
|
-
*
|
|
75
|
-
* @param {Object} params Stats parameters.
|
|
76
|
-
* @param {String} params.from The first day in YYYYMMDD format.
|
|
77
|
-
* @param {String} params.to The last day in YYYYMMDD format.
|
|
78
|
-
* @param {Function} [cb] Callback function.
|
|
79
|
-
*
|
|
80
|
-
* @return {Promise|undefined}
|
|
81
|
-
*/
|
|
82
|
-
StatsManager.prototype.getDaily = function(params, cb) {
|
|
83
|
-
params = params || {};
|
|
84
|
-
params.type = 'daily';
|
|
74
|
+
if (cb && cb instanceof Function) {
|
|
75
|
+
return this.resource.get(params, cb);
|
|
76
|
+
}
|
|
85
77
|
|
|
86
|
-
|
|
87
|
-
return this.resource.get(params, cb);
|
|
78
|
+
return this.resource.get(params);
|
|
88
79
|
}
|
|
89
80
|
|
|
90
|
-
|
|
91
|
-
|
|
81
|
+
/**
|
|
82
|
+
* Get a the active users count.
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* management.stats.getActiveUsersCount(function (err, usersCount) {
|
|
86
|
+
* if (err) {
|
|
87
|
+
* // Handle error.
|
|
88
|
+
* }
|
|
89
|
+
*
|
|
90
|
+
* console.log(usersCount);
|
|
91
|
+
* });
|
|
92
|
+
* @param {Function} [cb] Callback function.
|
|
93
|
+
* @returns {Promise|undefined}
|
|
94
|
+
*/
|
|
95
|
+
getActiveUsersCount(cb) {
|
|
96
|
+
const options = { type: 'active-users' };
|
|
92
97
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
* @method getActiveUsersCount
|
|
97
|
-
* @memberOf module:management.StatsManager.prototype
|
|
98
|
-
*
|
|
99
|
-
* @example
|
|
100
|
-
* management.stats.getActiveUsersCount(function (err, usersCount) {
|
|
101
|
-
* if (err) {
|
|
102
|
-
* // Handle error.
|
|
103
|
-
* }
|
|
104
|
-
*
|
|
105
|
-
* console.log(usersCount);
|
|
106
|
-
* });
|
|
107
|
-
*
|
|
108
|
-
* @param {Function} [cb] Callback function.
|
|
109
|
-
*
|
|
110
|
-
* @return {Promise|undefined}
|
|
111
|
-
*/
|
|
112
|
-
StatsManager.prototype.getActiveUsersCount = function(cb) {
|
|
113
|
-
var options = { type: 'active-users' };
|
|
98
|
+
if (cb && cb instanceof Function) {
|
|
99
|
+
return this.resource.get(options, cb);
|
|
100
|
+
}
|
|
114
101
|
|
|
115
|
-
|
|
116
|
-
return this.resource.get(options
|
|
102
|
+
// Return a promise.
|
|
103
|
+
return this.resource.get(options);
|
|
117
104
|
}
|
|
118
|
-
|
|
119
|
-
// Return a promise.
|
|
120
|
-
return this.resource.get(options);
|
|
121
|
-
};
|
|
105
|
+
}
|
|
122
106
|
|
|
123
107
|
module.exports = StatsManager;
|
|
@@ -1,115 +1,99 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
const { ArgumentError } = require('rest-facade');
|
|
2
|
+
const Auth0RestClient = require('../Auth0RestClient');
|
|
3
|
+
const RetryRestClient = require('../RetryRestClient');
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* Simple facade for consuming a REST API endpoint.
|
|
7
|
-
* @external RestClient
|
|
8
|
-
* @see https://github.com/ngonzalvez/rest-facade
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* @class
|
|
13
6
|
* Abstracts interaction with the tenant endpoint.
|
|
14
|
-
* @constructor
|
|
15
|
-
* @memberOf module:management
|
|
16
|
-
*
|
|
17
|
-
* @param {Object} options The client options.
|
|
18
|
-
* @param {String} options.baseUrl The URL of the API.
|
|
19
|
-
* @param {Object} [options.headers] Headers to be included in all requests.
|
|
20
|
-
* @param {Object} [options.retry] Retry Policy Config
|
|
21
7
|
*/
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
8
|
+
class TenantManager {
|
|
9
|
+
/**
|
|
10
|
+
* @param {object} options The client options.
|
|
11
|
+
* @param {string} options.baseUrl The URL of the API.
|
|
12
|
+
* @param {object} [options.headers] Headers to be included in all requests.
|
|
13
|
+
* @param {object} [options.retry] Retry Policy Config
|
|
14
|
+
*/
|
|
15
|
+
constructor(options) {
|
|
16
|
+
if (options === null || typeof options !== 'object') {
|
|
17
|
+
throw new ArgumentError('Must provide manager options');
|
|
18
|
+
}
|
|
26
19
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
20
|
+
if (options.baseUrl === null || options.baseUrl === undefined) {
|
|
21
|
+
throw new ArgumentError('Must provide a base URL for the API');
|
|
22
|
+
}
|
|
30
23
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
24
|
+
if ('string' !== typeof options.baseUrl || options.baseUrl.length === 0) {
|
|
25
|
+
throw new ArgumentError('The provided base URL is invalid');
|
|
26
|
+
}
|
|
34
27
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
28
|
+
const clientOptions = {
|
|
29
|
+
errorFormatter: { message: 'message', name: 'error' },
|
|
30
|
+
headers: options.headers,
|
|
31
|
+
query: { repeatParams: false },
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Provides an abstraction layer for consuming the
|
|
36
|
+
* {@link https://auth0.com/docs/api/v2#!/Stats Stats endpoint}.
|
|
37
|
+
*
|
|
38
|
+
* @type {external:RestClient}
|
|
39
|
+
*/
|
|
40
|
+
const auth0RestClient = new Auth0RestClient(
|
|
41
|
+
`${options.baseUrl}/tenants/settings`,
|
|
42
|
+
clientOptions,
|
|
43
|
+
options.tokenProvider
|
|
44
|
+
);
|
|
45
|
+
this.resource = new RetryRestClient(auth0RestClient, options.retry);
|
|
46
|
+
}
|
|
40
47
|
|
|
41
48
|
/**
|
|
42
|
-
*
|
|
43
|
-
* {@link https://auth0.com/docs/api/v2#!/Stats Stats endpoint}.
|
|
49
|
+
* Update the tenant settings.
|
|
44
50
|
*
|
|
45
|
-
* @
|
|
51
|
+
* @example
|
|
52
|
+
* management.tenant.updateSettings(data, function (err) {
|
|
53
|
+
* if (err) {
|
|
54
|
+
* // Handle error.
|
|
55
|
+
* }
|
|
56
|
+
* });
|
|
57
|
+
* @param {object} data The new tenant settings.
|
|
58
|
+
* @param {Function} [cb] Callback function.
|
|
59
|
+
* @returns {Promise|undefined}
|
|
46
60
|
*/
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
);
|
|
52
|
-
this.resource = new RetryRestClient(auth0RestClient, options.retry);
|
|
53
|
-
};
|
|
61
|
+
updateSettings(data, cb) {
|
|
62
|
+
if (cb && cb instanceof Function) {
|
|
63
|
+
return this.resource.patch({}, data, cb);
|
|
64
|
+
}
|
|
54
65
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
*
|
|
58
|
-
* @method updateSettings
|
|
59
|
-
* @memberOf module:management.TenantManager.prototype
|
|
60
|
-
*
|
|
61
|
-
* @example
|
|
62
|
-
* management.tenant.updateSettings(data, function (err) {
|
|
63
|
-
* if (err) {
|
|
64
|
-
* // Handle error.
|
|
65
|
-
* }
|
|
66
|
-
* });
|
|
67
|
-
*
|
|
68
|
-
* @param {Object} data The new tenant settings.
|
|
69
|
-
* @param {Function} [cb] Callback function.
|
|
70
|
-
*
|
|
71
|
-
* @return {Promise|undefined}
|
|
72
|
-
*/
|
|
73
|
-
TenantManager.prototype.updateSettings = function(data, cb) {
|
|
74
|
-
if (cb && cb instanceof Function) {
|
|
75
|
-
return this.resource.patch({}, data, cb);
|
|
66
|
+
// Return a promise.
|
|
67
|
+
return this.resource.patch({}, data);
|
|
76
68
|
}
|
|
77
69
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
70
|
+
/**
|
|
71
|
+
* Get the tenant settings..
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* management.tenant.getSettings({ include_fields: true, fields: 'friendly_name' }, function (err, settings) {
|
|
75
|
+
* if (err) {
|
|
76
|
+
* // Handle error.
|
|
77
|
+
* }
|
|
78
|
+
*
|
|
79
|
+
* console.log(settings);
|
|
80
|
+
* });
|
|
81
|
+
* @param {object} [data] Request parameters
|
|
82
|
+
* @param {Function} [cb] Callback function.
|
|
83
|
+
* @returns {Promise|undefined}
|
|
84
|
+
*/
|
|
85
|
+
getSettings(data, cb) {
|
|
86
|
+
if (data instanceof Function && !cb) {
|
|
87
|
+
cb = data;
|
|
88
|
+
data = {};
|
|
89
|
+
}
|
|
90
|
+
if (cb && cb instanceof Function) {
|
|
91
|
+
return this.resource.get(data, cb);
|
|
92
|
+
}
|
|
81
93
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
*
|
|
85
|
-
* @method getSettings
|
|
86
|
-
* @memberOf module:management.TenantManager.prototype
|
|
87
|
-
*
|
|
88
|
-
* @example
|
|
89
|
-
* management.tenant.getSettings({ include_fields: true, fields: 'friendly_name' }, function (err, settings) {
|
|
90
|
-
* if (err) {
|
|
91
|
-
* // Handle error.
|
|
92
|
-
* }
|
|
93
|
-
*
|
|
94
|
-
* console.log(settings);
|
|
95
|
-
* });
|
|
96
|
-
*
|
|
97
|
-
* @param {Object} [data] Request parameters
|
|
98
|
-
* @param {Function} [cb] Callback function.
|
|
99
|
-
*
|
|
100
|
-
* @return {Promise|undefined}
|
|
101
|
-
*/
|
|
102
|
-
TenantManager.prototype.getSettings = function(data, cb) {
|
|
103
|
-
if (data instanceof Function && !cb) {
|
|
104
|
-
cb = data;
|
|
105
|
-
data = {};
|
|
94
|
+
// Return a promise.
|
|
95
|
+
return this.resource.get(data);
|
|
106
96
|
}
|
|
107
|
-
|
|
108
|
-
return this.resource.get(data, cb);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
// Return a promise.
|
|
112
|
-
return this.resource.get(data);
|
|
113
|
-
};
|
|
97
|
+
}
|
|
114
98
|
|
|
115
99
|
module.exports = TenantManager;
|
|
@@ -1,135 +1,127 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
const { ArgumentError } = require('rest-facade');
|
|
2
|
+
const Auth0RestClient = require('../Auth0RestClient');
|
|
3
|
+
const RetryRestClient = require('../RetryRestClient');
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* @class
|
|
7
6
|
* Abstracts interaction with the tickets endpoint.
|
|
8
|
-
* @constructor
|
|
9
|
-
* @memberOf module:management
|
|
10
|
-
*
|
|
11
|
-
* @param {Object} options The client options.
|
|
12
|
-
* @param {String} options.baseUrl The URL of the API.
|
|
13
|
-
* @param {Object} [options.headers] Headers to be included in all requests.
|
|
14
|
-
* @param {Object} [options.retry] Retry Policy Config
|
|
15
7
|
*/
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
8
|
+
class TicketsManager {
|
|
9
|
+
/**
|
|
10
|
+
* @param {object} options The client options.
|
|
11
|
+
* @param {string} options.baseUrl The URL of the API.
|
|
12
|
+
* @param {object} [options.headers] Headers to be included in all requests.
|
|
13
|
+
* @param {object} [options.retry] Retry Policy Config
|
|
14
|
+
*/
|
|
15
|
+
constructor(options) {
|
|
16
|
+
if (options === null || typeof options !== 'object') {
|
|
17
|
+
throw new ArgumentError('Must provide manager options');
|
|
18
|
+
}
|
|
20
19
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
if (options.baseUrl === null || options.baseUrl === undefined) {
|
|
21
|
+
throw new ArgumentError('Must provide a base URL for the API');
|
|
22
|
+
}
|
|
24
23
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
if ('string' !== typeof options.baseUrl || options.baseUrl.length === 0) {
|
|
25
|
+
throw new ArgumentError('The provided base URL is invalid');
|
|
26
|
+
}
|
|
28
27
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
28
|
+
const clientOptions = {
|
|
29
|
+
errorFormatter: { message: 'message', name: 'error' },
|
|
30
|
+
headers: options.headers,
|
|
31
|
+
query: { repeatParams: false },
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Provides an abstraction layer for consuming the
|
|
36
|
+
* {@link https://auth0.com/docs/api/v2#!/Tickets Tickets endpoint}.
|
|
37
|
+
*
|
|
38
|
+
* @type {external:RestClient}
|
|
39
|
+
*/
|
|
40
|
+
const auth0RestClient = new Auth0RestClient(
|
|
41
|
+
`${options.baseUrl}/tickets/:type`,
|
|
42
|
+
clientOptions,
|
|
43
|
+
options.tokenProvider
|
|
44
|
+
);
|
|
45
|
+
this.resource = new RetryRestClient(auth0RestClient, options.retry);
|
|
46
|
+
}
|
|
34
47
|
|
|
35
48
|
/**
|
|
36
|
-
*
|
|
37
|
-
* {@link https://auth0.com/docs/api/v2#!/Tickets Tickets endpoint}.
|
|
49
|
+
* Create a new password change ticket.
|
|
38
50
|
*
|
|
39
|
-
* @
|
|
51
|
+
* @example
|
|
52
|
+
* var params = {
|
|
53
|
+
* result_url: '{REDIRECT_URL}', // Redirect after using the ticket.
|
|
54
|
+
* user_id: '{USER_ID}', // Optional.
|
|
55
|
+
* email: '{USER_EMAIL}', // Optional.
|
|
56
|
+
* new_password: '{PASSWORD}'
|
|
57
|
+
* };
|
|
58
|
+
*
|
|
59
|
+
* management.tickets.changePassword(params, function (err) {
|
|
60
|
+
* if (err) {
|
|
61
|
+
* // Handle error.
|
|
62
|
+
* }
|
|
63
|
+
* });
|
|
64
|
+
* @param {object} data
|
|
65
|
+
* @param {string} [data.result_url] URL the user will be redirected to once ticket is used.
|
|
66
|
+
* @param {string} [data.user_id] user_id for whom the ticket should be created. (Conflicts with: connection_id, email)
|
|
67
|
+
* @param {string} [data.client_id] ID of the client.
|
|
68
|
+
* @param {string} [data.organization_id] ID of the organization.
|
|
69
|
+
* @param {string} [data.connection_id] ID of the connection.
|
|
70
|
+
* @param {Integer} [data.ttl_sec] Number of seconds for which the ticket is valid before expiration.
|
|
71
|
+
* @param {string} [data.email] Email of the user. (Requires: connection_id)
|
|
72
|
+
* @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).
|
|
73
|
+
* @param {boolean} [data.includeEmailInRedirect] Whether to include the email address as part of the returnUrl in the reset_email (true), or not (false).
|
|
74
|
+
* @param {Function} [cb] Callback function.
|
|
75
|
+
* @returns {Promise}
|
|
40
76
|
*/
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
clientOptions,
|
|
44
|
-
options.tokenProvider
|
|
45
|
-
);
|
|
46
|
-
this.resource = new RetryRestClient(auth0RestClient, options.retry);
|
|
47
|
-
};
|
|
77
|
+
changePassword(data, cb) {
|
|
78
|
+
const params = { type: 'password-change' };
|
|
48
79
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
* @method changePassword
|
|
53
|
-
* @memberOf module:management.TicketsManager.prototype
|
|
54
|
-
*
|
|
55
|
-
* @example
|
|
56
|
-
* var params = {
|
|
57
|
-
* result_url: '{REDIRECT_URL}', // Redirect after using the ticket.
|
|
58
|
-
* user_id: '{USER_ID}', // Optional.
|
|
59
|
-
* email: '{USER_EMAIL}', // Optional.
|
|
60
|
-
* new_password: '{PASSWORD}'
|
|
61
|
-
* };
|
|
62
|
-
*
|
|
63
|
-
* management.tickets.changePassword(params, function (err) {
|
|
64
|
-
* if (err) {
|
|
65
|
-
* // Handle error.
|
|
66
|
-
* }
|
|
67
|
-
* });
|
|
68
|
-
*
|
|
69
|
-
* @param {Object} data
|
|
70
|
-
* @param {String} [data.result_url] URL the user will be redirected to once ticket is used.
|
|
71
|
-
* @param {String} [data.user_id] user_id for whom the ticket should be created. (Conflicts with: connection_id, email)
|
|
72
|
-
* @param {String} [data.client_id] ID of the client.
|
|
73
|
-
* @param {String} [data.organization_id] ID of the organization.
|
|
74
|
-
* @param {String} [data.connection_id] ID of the connection.
|
|
75
|
-
* @param {Integer} [data.ttl_sec] Number of seconds for which the ticket is valid before expiration.
|
|
76
|
-
* @param {String} [data.email] Email of the user. (Requires: connection_id)
|
|
77
|
-
* @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).
|
|
78
|
-
* @param {Boolean} [data.includeEmailInRedirect] Whether to include the email address as part of the returnUrl in the reset_email (true), or not (false).
|
|
79
|
-
* @param {Function} [cb] Callback function.
|
|
80
|
-
* @return {Promise}
|
|
81
|
-
*/
|
|
82
|
-
TicketsManager.prototype.changePassword = function(data, cb) {
|
|
83
|
-
var params = { type: 'password-change' };
|
|
80
|
+
if (cb && cb instanceof Function) {
|
|
81
|
+
return this.resource.create(params, data, cb);
|
|
82
|
+
}
|
|
84
83
|
|
|
85
|
-
|
|
86
|
-
return this.resource.create(params, data
|
|
84
|
+
// Return a promise.
|
|
85
|
+
return this.resource.create(params, data);
|
|
87
86
|
}
|
|
88
87
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
88
|
+
/**
|
|
89
|
+
* Create an email verification ticket.
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* var data = {
|
|
93
|
+
* user_id: '{USER_ID}',
|
|
94
|
+
* result_url: '{REDIRECT_URL}' // Optional redirect after the ticket is used.
|
|
95
|
+
* };
|
|
96
|
+
*
|
|
97
|
+
* management.tickets.verifyEmail(data, function (err) {
|
|
98
|
+
* if (err) {
|
|
99
|
+
* // Handle error.
|
|
100
|
+
* }
|
|
101
|
+
* });
|
|
102
|
+
* @param {object} data
|
|
103
|
+
* @param {string} [data.result_url] URL the user will be redirected to once ticket is used.
|
|
104
|
+
* @param {string} data.user_id user_id for whom the ticket should be created.
|
|
105
|
+
* @param {Integer} [data.ttl_sec] Number of seconds for which the ticket is valid before expiration.
|
|
106
|
+
* @param {boolean} [data.includeEmailInRedirect] Whether to include the email address as part of the result_url (true), or not (false).
|
|
107
|
+
* @param {object} [data.identity] Used to verify secondary, federated, and passwordless-email identities.
|
|
108
|
+
* @param {string} data.identity.user_id user_id of the identity.
|
|
109
|
+
* @param {string} data.identity.provider provider of the identity.
|
|
110
|
+
* @param {string} [data.client_id] client ID.
|
|
111
|
+
* @param {string} [data.organization_id] organization ID.
|
|
112
|
+
* @param {Function} [cb] Callback function.
|
|
113
|
+
* @returns {Promise}
|
|
114
|
+
*/
|
|
115
|
+
verifyEmail(data, cb) {
|
|
116
|
+
const params = { type: 'email-verification' };
|
|
92
117
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
* @method verifyEmail
|
|
97
|
-
* @memberOf module:management.TicketsManager.prototype
|
|
98
|
-
*
|
|
99
|
-
* @example
|
|
100
|
-
* var data = {
|
|
101
|
-
* user_id: '{USER_ID}',
|
|
102
|
-
* result_url: '{REDIRECT_URL}' // Optional redirect after the ticket is used.
|
|
103
|
-
* };
|
|
104
|
-
*
|
|
105
|
-
* management.tickets.verifyEmail(data, function (err) {
|
|
106
|
-
* if (err) {
|
|
107
|
-
* // Handle error.
|
|
108
|
-
* }
|
|
109
|
-
* });
|
|
110
|
-
*
|
|
111
|
-
* @param {Object} data
|
|
112
|
-
* @param {String} [data.result_url] URL the user will be redirected to once ticket is used.
|
|
113
|
-
* @param {String} data.user_id user_id for whom the ticket should be created.
|
|
114
|
-
* @param {Integer} [data.ttl_sec] Number of seconds for which the ticket is valid before expiration.
|
|
115
|
-
* @param {Boolean} [data.includeEmailInRedirect] Whether to include the email address as part of the result_url (true), or not (false).
|
|
116
|
-
* @param {Object} [data.identity] Used to verify secondary, federated, and passwordless-email identities.
|
|
117
|
-
* @param {String} data.identity.user_id user_id of the identity.
|
|
118
|
-
* @param {String} data.identity.provider provider of the identity.
|
|
119
|
-
* @param {String} [data.client_id] client ID.
|
|
120
|
-
* @param {String} [data.organization_id] organization ID.
|
|
121
|
-
* @param {Function} [cb] Callback function.
|
|
122
|
-
* @return {Promise}
|
|
123
|
-
*/
|
|
124
|
-
TicketsManager.prototype.verifyEmail = function(data, cb) {
|
|
125
|
-
var params = { type: 'email-verification' };
|
|
118
|
+
if (cb && cb instanceof Function) {
|
|
119
|
+
return this.resource.create(params, data, cb);
|
|
120
|
+
}
|
|
126
121
|
|
|
127
|
-
|
|
128
|
-
return this.resource.create(params, data
|
|
122
|
+
// Return a promise.
|
|
123
|
+
return this.resource.create(params, data);
|
|
129
124
|
}
|
|
130
|
-
|
|
131
|
-
// Return a promise.
|
|
132
|
-
return this.resource.create(params, data);
|
|
133
|
-
};
|
|
125
|
+
}
|
|
134
126
|
|
|
135
127
|
module.exports = TicketsManager;
|