auth0 3.3.0 → 3.5.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # Change Log
2
2
 
3
+ ## [v3.5.0](https://github.com/auth0/node-auth0/tree/v3.5.0) (2023-06-26)
4
+
5
+ [Full Changelog](https://github.com/auth0/node-auth0/compare/v3.4.0...v3.5.0)
6
+
7
+ **Added**
8
+
9
+ - Add option to pass x-request-language header for passwordless [\#873](https://github.com/auth0/node-auth0/pull/873) ([adamjmcgrath](https://github.com/adamjmcgrath))
10
+
11
+ ## [v3.4.0](https://github.com/auth0/node-auth0/tree/v3.4.0) (2023-05-05)
12
+
13
+ [Full Changelog](https://github.com/auth0/node-auth0/compare/v3.3.0...v3.4.0)
14
+
15
+ **Added**
16
+
17
+ - feat: allow to pass a method as token [\#793](https://github.com/auth0/node-auth0/pull/793) ([KillianHmyd](https://github.com/KillianHmyd))
18
+
19
+ **Fixed**
20
+
21
+ - Fix ESM [\#828](https://github.com/auth0/node-auth0/pull/828) ([adamjmcgrath](https://github.com/adamjmcgrath))
22
+
3
23
  ## [v3.3.0](https://github.com/auth0/node-auth0/tree/v3.3.0) (2023-03-14)
4
24
 
5
25
  [Full Changelog](https://github.com/auth0/node-auth0/compare/v3.2.0...v3.3.0)
package/README.md CHANGED
@@ -63,6 +63,8 @@ var management = new ManagementClient({
63
63
  });
64
64
  ```
65
65
 
66
+ > Note: The domain should not include `https://` the ManagementClient will prepend that to the string.
67
+
66
68
  For other examples see the [EXAMPLES.md](https://github.com/auth0/node-auth0/blob/master/EXAMPLES.md) document.
67
69
 
68
70
  ## API Reference
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "auth0",
3
- "version": "3.3.0",
3
+ "version": "3.5.0",
4
4
  "description": "SDK for Auth0 API v2",
5
5
  "main": "src/index.js",
6
6
  "module": "src/index.mjs",
@@ -8,9 +8,10 @@ function getParamsFromOptions(options) {
8
8
  if (!options || typeof options !== 'object') {
9
9
  return params;
10
10
  }
11
- if (options.forwardedFor) {
11
+ if (options.forwardedFor || options.requestLanguage) {
12
12
  params._requestCustomizer = function (req) {
13
- req.set('auth0-forwarded-for', options.forwardedFor);
13
+ options.forwardedFor && req.set('auth0-forwarded-for', options.forwardedFor);
14
+ options.requestLanguage && req.set('x-request-language', options.requestLanguage);
14
15
  };
15
16
  }
16
17
  return params;
@@ -214,6 +215,7 @@ class PasswordlessAuthenticator {
214
215
  * @param {string} userData.send The type of email to be sent.
215
216
  * @param {object} [options] Additional options.
216
217
  * @param {string} [options.forwardedFor] Value to be used for auth0-forwarded-for header
218
+ * @param {string} [options.requestLanguage] Specify a language for the message area.
217
219
  * @param {Function} [cb] Method callback.
218
220
  * @returns {Promise|undefined}
219
221
  */
@@ -270,6 +272,7 @@ class PasswordlessAuthenticator {
270
272
  * @param {string} userData.phone_number User phone number.
271
273
  * @param {object} [options] Additional options.
272
274
  * @param {string} [options.forwardedFor] Value to be used for auth0-forwarded-for header
275
+ * @param {string} [options.requestLanguage] Specify a language for the message area.
273
276
  * @param {Function} [cb] Method callback.
274
277
  * @returns {Promise|undefined}
275
278
  */
package/src/index.mjs CHANGED
@@ -1,11 +1,4 @@
1
- import { createRequire } from 'module';
2
- const require = createRequire(import.meta.url);
3
- /**
4
- * Simple facade for consuming a REST API endpoint.
5
- *
6
- * @external RestClient
7
- * {@link https://github.com/ngonzalvez/rest-facade}
8
- */
9
- export const ManagementClient = require('./management');
10
- export const AuthenticationClient = require('./auth');
11
- export default { ManagementClient, AuthenticationClient }
1
+ import mod from './index.js';
2
+
3
+ export const { ManagementClient, AuthenticationClient } = mod;
4
+ export default { ManagementClient, AuthenticationClient };
@@ -95,7 +95,7 @@ class ManagementClient {
95
95
  * If no token is provided domain, clientId and clientSecret (or clientAssertionSigningKey)
96
96
  * are required.
97
97
  * @param {string} options.domain ManagementClient server domain.
98
- * @param {string} [options.token] API access token.
98
+ * @param {string|Function} [options.token] API access token.
99
99
  * @param {string} [options.clientId] Management API Non Interactive Client Id.
100
100
  * @param {string} [options.clientSecret] Management API Non Interactive Client Secret.
101
101
  * @param {string} [options.clientAssertionSigningKey] Private key used to sign the client assertion JWT.
@@ -144,15 +144,19 @@ class ManagementClient {
144
144
  }
145
145
 
146
146
  this.tokenProvider = new ManagementTokenProvider(config);
147
- } else if (typeof options.token !== 'string' || options.token.length === 0) {
147
+ } else if (
148
+ typeof options.token !== 'function' &&
149
+ (typeof options.token !== 'string' || options.token.length === 0)
150
+ ) {
148
151
  throw new ArgumentError('Must provide a token');
149
152
  } else {
150
153
  this.tokenProvider = {
151
154
  getAccessToken() {
152
- return Promise.resolve(options.token);
155
+ return typeof options.token === 'function'
156
+ ? options.token()
157
+ : Promise.resolve(options.token);
153
158
  },
154
159
  };
155
- managerOptions.headers['Authorization'] = `Bearer ${options.token}`;
156
160
  }
157
161
 
158
162
  managerOptions.tokenProvider = this.tokenProvider;