auth0 3.3.0 → 3.4.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,17 @@
1
1
  # Change Log
2
2
 
3
+ ## [v3.4.0](https://github.com/auth0/node-auth0/tree/v3.4.0) (2023-05-05)
4
+
5
+ [Full Changelog](https://github.com/auth0/node-auth0/compare/v3.3.0...v3.4.0)
6
+
7
+ **Added**
8
+
9
+ - feat: allow to pass a method as token [\#793](https://github.com/auth0/node-auth0/pull/793) ([KillianHmyd](https://github.com/KillianHmyd))
10
+
11
+ **Fixed**
12
+
13
+ - Fix ESM [\#828](https://github.com/auth0/node-auth0/pull/828) ([adamjmcgrath](https://github.com/adamjmcgrath))
14
+
3
15
  ## [v3.3.0](https://github.com/auth0/node-auth0/tree/v3.3.0) (2023-03-14)
4
16
 
5
17
  [Full Changelog](https://github.com/auth0/node-auth0/compare/v3.2.0...v3.3.0)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "auth0",
3
- "version": "3.3.0",
3
+ "version": "3.4.0",
4
4
  "description": "SDK for Auth0 API v2",
5
5
  "main": "src/index.js",
6
6
  "module": "src/index.mjs",
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;