auth0 2.43.0 → 2.44.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 CHANGED
@@ -1,5 +1,21 @@
1
1
  # Change Log
2
2
 
3
+ ## [v2.44.1](https://github.com/auth0/node-auth0/tree/v2.44.1) (2022-12-09)
4
+
5
+ [Full Changelog](https://github.com/auth0/node-auth0/compare/v2.44.0...v2.44.1)
6
+
7
+ **Fixed**
8
+
9
+ - Prevent calling the callback more than once [\#759](https://github.com/auth0/node-auth0/pull/759) ([snocorp](https://github.com/snocorp))
10
+
11
+ ## [v2.44.0](https://github.com/auth0/node-auth0/tree/v2.44.0) (2022-10-11)
12
+
13
+ [Full Changelog](https://github.com/auth0/node-auth0/compare/v2.43.0...v2.44.0)
14
+
15
+ **Added**
16
+
17
+ - [SDK-3653] Add proxy support to Management Client [\#747](https://github.com/auth0/node-auth0/pull/747) ([adamjmcgrath](https://github.com/adamjmcgrath))
18
+
3
19
  ## [v2.43.0](https://github.com/auth0/node-auth0/tree/v2.43.0) (2022-10-10)
4
20
 
5
21
  [Full Changelog](https://github.com/auth0/node-auth0/compare/v2.42.0...v2.43.0)
package/README.md CHANGED
@@ -1,31 +1,37 @@
1
- # node-auth0
1
+ ![Node.js client library for Auth0](https://cdn.auth0.com/website/sdks/banner/node-auth0-banner.png)
2
2
 
3
- [![Build Status][circleci-image]][circleci-url]
4
- [![NPM version][npm-image]][npm-url]
5
- [![Coverage][codecov-image]][codecov-url]
6
- [![License][license-image]][license-url]
7
- [![Downloads][downloads-image]][downloads-url]
8
- [![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fauth0%2Fnode-auth0.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Fauth0%2Fnode-auth0?ref=badge_shield)
3
+ ![Release](https://img.shields.io/npm/v/auth0)
4
+ [![Codecov](https://img.shields.io/codecov/c/github/auth0/node-auth0)](https://codecov.io/gh/auth0/node-auth0)
5
+ ![Downloads](https://img.shields.io/npm/dw/auth0)
6
+ [![License](https://img.shields.io/:license-mit-blue.svg?style=flat)](https://opensource.org/licenses/MIT)
7
+ ![CircleCI](https://img.shields.io/circleci/build/github/auth0/node-auth0)
9
8
 
10
- Node.js client library for the [Auth0](https://auth0.com) platform.
9
+ 📚 [Documentation](#documentation) - 🚀 [Getting Started](#getting-started) - 💻 [API Reference](#api-reference) - 💬 [Feedback](#feedback)
11
10
 
12
- ## Installation
11
+ ## Documentation
13
12
 
14
- ```bash
15
- npm install auth0
16
- ```
13
+ - [FAQs](https://github.com/auth0/node-auth0/blob/master/FAQ.md) - frequently asked questions about node-auth0.
14
+ - [Docs Site](https://auth0.com/docs) - explore our docs site and learn more about Auth0
17
15
 
18
- ## Documentation
16
+ ## Getting Started
19
17
 
20
- You can find this library documentation in this [page](https://auth0.github.io/node-auth0/).
18
+ ### Requirements
21
19
 
22
- For more information about [auth0](https://auth0.com) check our [documentation page](https://auth0.com/docs).
20
+ This library supports the following tooling versions:
23
21
 
24
- ## Node version support
22
+ - Node.js: `>=8.3.0`
25
23
 
26
- This SDK is tested on the latest Node versions 8, 10, 12 and 14.
24
+ ### Installation
27
25
 
28
- ## Authentication API Client
26
+ Using [npm](https://npmjs.org) in your project directory run the following command:
27
+
28
+ ```bash
29
+ npm install auth0
30
+ ```
31
+
32
+ ### Configure the SDK
33
+
34
+ #### Authentication API Client
29
35
 
30
36
  This client must be used to access Auth0's [Authentication API](https://auth0.com/docs/api/authentication).
31
37
 
@@ -40,7 +46,9 @@ var auth0 = new AuthenticationClient({
40
46
  });
41
47
  ```
42
48
 
43
- ## Management API Client
49
+ #### Management API Client
50
+
51
+ > Note: When using the ManagementClient in a browser you should set `telemetry: false`.
44
52
 
45
53
  The Auth0 Management API is meant to be used by back-end servers or trusted parties performing administrative tasks. Generally speaking, anything that can be done through the Auth0 dashboard (and more) can also be done through this API.
46
54
 
@@ -55,134 +63,42 @@ var management = new ManagementClient({
55
63
  });
56
64
  ```
57
65
 
58
- > Note: When using at browser you should use `telemetry: false`.
59
-
60
- To obtain **automatically** a Management API token via the ManagementClient, you can specify the parameters `clientId`, `clientSecret` (use a Non Interactive Client) and optionally `scope`.
61
- Behind the scenes the Client Credentials Grant is used to obtain the `access_token` and is by default cached for the duration of the returned `expires_in` value.
62
-
63
- ```js
64
- var ManagementClient = require('auth0').ManagementClient;
65
- var auth0 = new ManagementClient({
66
- domain: '{YOUR_ACCOUNT}.auth0.com',
67
- clientId: '{YOUR_NON_INTERACTIVE_CLIENT_ID}',
68
- clientSecret: '{YOUR_NON_INTERACTIVE_CLIENT_SECRET}',
69
- scope: 'read:users update:users',
70
- });
71
- ```
72
-
73
- > Make sure your ClientId is allowed to request tokens from Management API in [Auth0 Dashboard](https://manage.auth0.com/#/apis)
74
-
75
- To obtain a Management API token from your node backend, you can use Client Credentials Grant using your registered Auth0 Non Interactive Clients
76
-
77
- ```js
78
- var AuthenticationClient = require('auth0').AuthenticationClient;
79
-
80
- var auth0 = new AuthenticationClient({
81
- domain: '{YOUR_ACCOUNT}.auth0.com',
82
- clientId: '{CLIENT_ID}',
83
- clientSecret: '{CLIENT_SECRET}',
84
- });
85
-
86
- auth0.clientCredentialsGrant(
87
- {
88
- audience: 'https://{YOUR_ACCOUNT}.auth0.com/api/v2/',
89
- scope: '{MANAGEMENT_API_SCOPES}',
90
- },
91
- function (err, response) {
92
- if (err) {
93
- // Handle error.
94
- }
95
- console.log(response.access_token);
96
- }
97
- );
98
- ```
99
-
100
- Also you can request a token when the user authenticates using any of our client side SDKs, e.g. [auth0.js](https://github.com/auth0/auth0.js).
66
+ For other examples see the [EXAMPLES.md](https://github.com/auth0/node-auth0/blob/master/EXAMPLES.md) document.
101
67
 
102
- ## Promises and callbacks
68
+ ## API Reference
103
69
 
104
- Be aware that all methods can be used with promises or callbacks. However, when a callback is provided no promise will be returned.
70
+ - [AuthenticationClient](https://auth0.github.io/node-auth0/AuthenticationClient.html)
71
+ - [ManagementClient](https://auth0.github.io/node-auth0/ManagementClient.html)
105
72
 
106
- ```js
107
- // Using callbacks.
108
- management.getUsers(function (err, users) {
109
- if (err) {
110
- // handle error.
111
- }
112
- console.log(users);
113
- });
114
-
115
- // Using promises.
116
- management
117
- .getUsers()
118
- .then(function (users) {
119
- console.log(users);
120
- })
121
- .catch(function (err) {
122
- // Handle error.
123
- });
124
- ```
73
+ ## Feedback
125
74
 
126
- ## Typescript
75
+ ### Contributing
127
76
 
128
- The types for this library are currently maintained by the community at [Definitely Typed](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/auth0). The team is planning taking ownership of this library as discussed in https://github.com/auth0/node-auth0/issues/572. After the team has taken ownership we will remove this net from the Readme.
77
+ We appreciate feedback and contribution to this repo! Before you get started, please see the following:
129
78
 
130
- ## Troubleshooting
79
+ - [Auth0's general contribution guidelines](https://github.com/auth0/open-source-template/blob/master/GENERAL-CONTRIBUTING.md)
80
+ - [Auth0's code of conduct guidelines](https://github.com/auth0/open-source-template/blob/master/CODE-OF-CONDUCT.md)
131
81
 
132
- ### Getting `Error: Can't resolve 'superagent-proxy'` when bundling with Webpack
82
+ ### Raise an issue
133
83
 
134
- We have a dependency on `rest-facade` which `require`s but doesn't include `superagent-proxy`. This SDK doesn't support proxies, so this dependency is not required. To workaround this you can add the following to your `webpack.config.js`:
135
-
136
- ```
137
- resolve: {
138
- alias: {
139
- 'superagent-proxy': false
140
- }
141
- }
142
- ```
84
+ To provide feedback or report a bug, please [raise an issue on our issue tracker](https://github.com/auth0/node-auth0/issues).
143
85
 
144
- Or install `superagent-proxy` yourself.
86
+ ### Vulnerability Reporting
145
87
 
88
+ Please do not report security vulnerabilities on the public GitHub issue tracker. The [Responsible Disclosure Program](https://auth0.com/whitehat) details the procedure for disclosing security issues.
146
89
 
147
90
  ## What is Auth0?
148
91
 
149
- Auth0 helps you to:
150
-
151
- - Add authentication with [multiple authentication sources](https://docs.auth0.com/identityproviders), either social like **Google, Facebook, Microsoft Account, LinkedIn, GitHub, Twitter, Box, Salesforce, amont others**, or enterprise identity systems like **Windows Azure AD, Google Apps, Active Directory, ADFS or any SAML Identity Provider**.
152
- - Add authentication through more traditional **[username/password databases](https://docs.auth0.com/mysql-connection-tutorial)**.
153
- - Add support for **[linking different user accounts](https://docs.auth0.com/link-accounts)** with the same user.
154
- - Support for generating signed [Json Web Tokens](https://docs.auth0.com/jwt) to call your APIs and **flow the user identity** securely.
155
- - Analytics of how, when and where users are logging in.
156
- - Pull data from other sources and add it to the user profile, through [JavaScript rules](https://docs.auth0.com/rules).
157
-
158
- ## Create a free Auth0 Account
159
-
160
- 1. Go to [Auth0](https://auth0.com) and click "Try Auth0 for Free".
161
- 2. Use Google, GitHub or Microsoft Account to login.
162
-
163
- ## Issue Reporting
164
-
165
- If you have found a bug or if you have a feature request, please report them at this repository issues section. Please do not report security vulnerabilities on the public GitHub issue tracker. The [Responsible Disclosure Program](https://auth0.com/whitehat) details the procedure for disclosing security issues.
166
-
167
- ## Author
168
-
169
- [Auth0](https://auth0.com)
170
-
171
- ## License
172
-
173
- This project is licensed under the MIT license. See the [LICENSE](LICENSE) file for more info.
174
-
175
- <!-- Vaaaaarrrrsss -->
176
-
177
- [npm-image]: https://img.shields.io/npm/v/auth0.svg?style=flat-square
178
- [npm-url]: https://npmjs.org/package/auth0
179
- [circleci-image]: https://img.shields.io/circleci/project/github/auth0/node-auth0.svg?branch=master&style=flat-square
180
- [circleci-url]: https://circleci.com/gh/auth0/node-auth0
181
- [codecov-image]: https://img.shields.io/codecov/c/github/auth0/node-auth0.svg?style=flat-square
182
- [codecov-url]: https://codecov.io/github/auth0/node-auth0?branch=master
183
- [license-image]: https://img.shields.io/npm/l/auth0.svg?style=flat-square
184
- [license-url]: #license
185
- [downloads-image]: https://img.shields.io/npm/dm/auth0.svg?style=flat-square
186
- [downloads-url]: https://npmjs.org/package/auth0
187
-
188
- [![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fauth0%2Fnode-auth0.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2Fauth0%2Fnode-auth0?ref=badge_large)
92
+ <p align="center">
93
+ <picture>
94
+ <source media="(prefers-color-scheme: dark)" srcset="https://cdn.auth0.com/website/sdks/logos/auth0_dark_mode.png" width="150">
95
+ <source media="(prefers-color-scheme: light)" srcset="https://cdn.auth0.com/website/sdks/logos/auth0_light_mode.png" width="150">
96
+ <img alt="Auth0 Logo" src="https://cdn.auth0.com/website/sdks/logos/auth0_light_mode.png" width="150">
97
+ </picture>
98
+ </p>
99
+ <p align="center">
100
+ Auth0 is an easy to implement, adaptable authentication and authorization platform. To learn more checkout <a href="https://auth0.com/why-auth0">Why Auth0?</a>
101
+ </p>
102
+ <p align="center">
103
+ This project is licensed under the MIT license. See the <a href="https://github.com/auth0/node-auth0/blob/master/LICENSE"> LICENSE</a> file for more info.
104
+ </p>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "auth0",
3
- "version": "2.43.0",
3
+ "version": "2.44.1",
4
4
  "description": "SDK for Auth0 API v2",
5
5
  "main": "src/index.js",
6
6
  "sideEffects": false,
@@ -65,6 +65,7 @@
65
65
  "proxyquire": "^2.1.3",
66
66
  "sinon": "^14.0.0",
67
67
  "string-replace-webpack-plugin": "0.1.3",
68
+ "superagent-proxy": "^3.0.0",
68
69
  "webpack": "^4.36.1"
69
70
  }
70
71
  }
@@ -73,9 +73,12 @@ class Auth0RestClient {
73
73
  this.restClient[method](...args, (err, data, headers) => {
74
74
  const payload = { data, headers };
75
75
  if (err) {
76
- (callback && callback(err)) || reject(err);
76
+ if (callback) callback(err);
77
+ else reject(err);
78
+ return;
77
79
  }
78
- (callback && callback(null, payload)) || resolve(payload);
80
+ if (callback) callback(null, payload);
81
+ else resolve(payload);
79
82
  });
80
83
  });
81
84
  }
@@ -24,6 +24,7 @@ class BaseManager {
24
24
  const clientOptions = {
25
25
  errorFormatter: { message: 'message', name: 'error' },
26
26
  headers: options.headers,
27
+ proxy: options.proxy,
27
28
  query: { repeatParams: false },
28
29
  includeResponseHeaders: options.includeResponseHeaders,
29
30
  };
@@ -97,6 +97,8 @@ class ClientsManager extends BaseManager {
97
97
  * });
98
98
  * @param {object} params Client parameters.
99
99
  * @param {string} params.client_id Application client ID.
100
+ * @param {string} params.fields Comma-separated list of fields to include or exclude (based on value provided for include_fields).
101
+ * @param {string} params.include_fields Whether specified fields are to be included (true) or excluded (false).
100
102
  * @param {Function} [cb] Callback function.
101
103
  * @returns {Promise|undefined}
102
104
  */
@@ -90,7 +90,8 @@ class ManagementClient {
90
90
  * @param {boolean} [options.retry.enabled=true] Enabled or Disable Retry Policy functionality.
91
91
  * @param {number} [options.retry.maxRetries=10] Retry failed requests X times.
92
92
  * @param {object} [options.headers] Additional headers that will be added to the outgoing requests.
93
- * @param {object} [options.includeResponseHeaders] Include the response headers in the payload in the format `{ data, headers }`.
93
+ * @param {string} [options.proxy] Add the `superagent-proxy` dependency and specify a proxy url eg 'https://myproxy.com:1234'
94
+ * @param {boolean} [options.includeResponseHeaders] Include the response headers in the payload in the format `{ data, headers }`.
94
95
  */
95
96
  constructor(options) {
96
97
  if (!options || typeof options !== 'object') {
@@ -149,6 +150,7 @@ class ManagementClient {
149
150
 
150
151
  managerOptions.retry = options.retry;
151
152
  managerOptions.includeResponseHeaders = options.includeResponseHeaders;
153
+ managerOptions.proxy = options.proxy;
152
154
 
153
155
  /**
154
156
  * Simple abstraction for performing CRUD operations on the
@@ -525,6 +527,8 @@ class ManagementClient {
525
527
  * });
526
528
  * @param {object} params Client parameters.
527
529
  * @param {string} params.client_id Application client ID.
530
+ * @param {string} params.fields Comma-separated list of fields to include or exclude (based on value provided for include_fields).
531
+ * @param {string} params.include_fields Whether specified fields are to be included (true) or excluded (false).
528
532
  * @param {Function} [cb] Callback function.
529
533
  * @returns {Promise|undefined}
530
534
  */