-
Notifications
You must be signed in to change notification settings - Fork 318
[BREAKING] feat!: remove Authentication layer #1390
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
c9af50a
0a5c146
69f24ff
5b5be26
20afc0b
7f28dbe
53d0879
e6f3d8e
2553796
64e8eac
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,4 +3,4 @@ node_modules | |
| /dist | ||
| /docs | ||
| /coverage | ||
| *.lcov | ||
| *.lcov.forge/ | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| v6.3.0 | ||
| v6.3.0 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,20 +34,22 @@ npm install auth0 | |
|
|
||
| ### Configure the SDK | ||
|
|
||
| #### Authentication API Client | ||
| #### Authentication | ||
|
|
||
| This client can be used to access Auth0's [Authentication API](https://auth0.com/docs/api/authentication). | ||
| For authentication operations (OAuth flows, token management, user sign-up), use [`@auth0/auth0-auth-js`](https://github.com/auth0/node-auth0/tree/main/packages/auth0-auth-js). As of v7, node-auth0 no longer ships `AuthenticationClient` in its main entrypoint. The authentication layer has been separated into a dedicated package. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This link 404s. The same URL is used on lines 51, 357 and 412, so all four need fixing. This is the main call to action for the migration, so worth getting right. |
||
|
|
||
| ```js | ||
| import { AuthenticationClient } from "auth0"; | ||
| import { AuthClient } from "@auth0/auth0-auth-js"; | ||
|
|
||
| const auth0 = new AuthenticationClient({ | ||
| const auth = new AuthClient({ | ||
| domain: "{YOUR_TENANT_AND REGION}.auth0.com", | ||
| clientId: "{YOUR_CLIENT_ID}", | ||
| clientSecret: "{OPTIONAL_CLIENT_SECRET}", | ||
| }); | ||
| ``` | ||
|
|
||
| See the [auth0-auth-js documentation](https://github.com/auth0/node-auth0/tree/main/packages/auth0-auth-js) for full API reference. | ||
|
|
||
| #### Management API Client | ||
|
|
||
| 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. | ||
|
|
@@ -169,25 +171,30 @@ types from the root `auth0` entry adds nothing to your bundle and does not pull | |
| > through a bundler. A plain CommonJS `require()` cannot tree-shake and loads the full | ||
| > resource graph. | ||
|
|
||
| #### UserInfo API Client | ||
| #### User Profile Information | ||
|
|
||
| This client can be used to retrieve user profile information. | ||
| To retrieve user profile information, use the `getUserInfo` method from `@auth0/auth0-auth-js`: | ||
|
|
||
| ```js | ||
| import { UserInfoClient } from "auth0"; | ||
| import { AuthClient } from "@auth0/auth0-auth-js"; | ||
|
|
||
| const userInfo = new UserInfoClient({ | ||
| const auth = new AuthClient({ | ||
| domain: "{YOUR_TENANT_AND REGION}.auth0.com", | ||
| clientId: "{YOUR_CLIENT_ID}", | ||
| }); | ||
|
|
||
| // Get user info with an access token | ||
| const userProfile = await userInfo.getUserInfo(accessToken); | ||
| const userProfile = await auth.getUserInfo(accessToken); | ||
| ``` | ||
|
|
||
| As of v7, node-auth0 no longer ships `UserInfoClient`. Use `AuthClient.getUserInfo()` from `@auth0/auth0-auth-js` instead. | ||
|
Comment on lines
+176
to
+190
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The migration doc lists the UserInfo endpoint as a known gap and it is still open. Either land |
||
|
|
||
| ## Legacy Usage | ||
|
|
||
| If you are migrating from the legacy `node-auth0` package (v4.x) or need to maintain compatibility with legacy code, you can use the legacy export which provides the `node-auth0` v4.x API interface. | ||
|
|
||
| **Note:** The legacy entrypoint still includes `AuthenticationClient` from the v4.x API. This is separate from the v7 main entrypoint, which no longer ships authentication clients. | ||
|
|
||
| ### Installing Legacy Version | ||
|
|
||
| The legacy version (`node-auth0` v4.x) is available through the `/legacy` export path: | ||
|
|
@@ -202,7 +209,7 @@ const { ManagementClient, AuthenticationClient } = require("auth0/legacy"); | |
|
|
||
| ### Legacy Configuration | ||
|
|
||
| The legacy API uses the `node-auth0` v4.x configuration format and method signatures, which are different from the current v6 API: | ||
| The legacy API uses the `node-auth0` v4.x configuration format and method signatures, which are different from the current API: | ||
|
|
||
| #### Legacy Management Client | ||
|
|
||
|
|
@@ -345,6 +352,65 @@ try { | |
| } | ||
| ``` | ||
|
|
||
| ## Migrating from v6 to v7 | ||
|
|
||
| Version 7.0.0 removes authentication clients from the main entrypoint. The authentication layer has been separated into [`@auth0/auth0-auth-js`](https://github.com/auth0/node-auth0/tree/main/packages/auth0-auth-js). | ||
|
|
||
| ### Install the authentication package | ||
|
|
||
| ```bash | ||
| npm install @auth0/auth0-auth-js | ||
| ``` | ||
|
|
||
| ### Update imports | ||
|
|
||
| ```js | ||
| // v6 | ||
| import { AuthenticationClient, UserInfoClient } from "auth0"; | ||
|
|
||
| // v7 | ||
| import { AuthClient } from "@auth0/auth0-auth-js"; | ||
| ``` | ||
|
|
||
| ### Method mapping | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The table covers 9 of the roughly 19 public methods this PR removes. The ones missing that do have equivalents in
Also, the repo convention is a top level migration file. |
||
|
|
||
| | v6 (node-auth0) | v7 (@auth0/auth0-auth-js) | | ||
| | --------------------------------------------------- | --------------------------------------------- | | ||
| | `authenticationClient.authorizationCodeGrant(...)` | `authClient.getTokenByCode(...)` | | ||
| | `authenticationClient.clientCredentialsGrant(...)` | `authClient.getTokenByClientCredentials(...)` | | ||
| | `authenticationClient.refreshTokenGrant(...)` | `authClient.getTokenByRefreshToken(...)` | | ||
| | `authenticationClient.passwordGrant(...)` | `authClient.getTokenByPassword(...)` | | ||
| | `authenticationClient.revokeRefreshToken(...)` | `authClient.revokeToken(...)` | | ||
| | `authenticationClient.database.signUp(...)` | `authClient.signUp(...)` | | ||
| | `authenticationClient.database.changePassword(...)` | `authClient.changePassword(...)` | | ||
| | `authenticationClient.passwordless.*` | `authClient.passwordless.*` (sub-client) | | ||
| | `userInfoClient.getUserInfo(accessToken)` | `authClient.getUserInfo(accessToken)` | | ||
|
Comment on lines
+384
to
+387
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Two rows here do not match the real API. In The Worth a footnote that |
||
|
|
||
| ### mTLS configuration | ||
|
|
||
| If you use mTLS, you must now provide an explicit `customFetch` option: | ||
|
Comment on lines
+389
to
+391
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This section documents Nothing here tells a Can we add a short "ManagementClient breaking changes" block with a working |
||
|
|
||
| ```js | ||
| import { AuthClient } from "@auth0/auth0-auth-js"; | ||
| import https from "https"; | ||
| import fetch from "node-fetch"; | ||
|
|
||
| const agent = new https.Agent({ | ||
| cert: fs.readFileSync("client-cert.pem"), | ||
| key: fs.readFileSync("client-key.pem"), | ||
| }); | ||
|
|
||
| const auth = new AuthClient({ | ||
| domain: "your-tenant.auth0.com", | ||
| clientId: "YOUR_CLIENT_ID", | ||
| clientSecret: "YOUR_CLIENT_SECRET", | ||
| useMtls: true, | ||
| customFetch: (url, init) => fetch(url, { ...init, agent }), | ||
| }); | ||
| ``` | ||
|
|
||
| See the [auth0-auth-js documentation](https://github.com/auth0/node-auth0/tree/main/packages/auth0-auth-js) for complete API details. | ||
|
|
||
| ## Request and Response Types | ||
|
|
||
| The SDK exports all request and response types as TypeScript interfaces. You can import them directly: | ||
|
|
@@ -375,8 +441,6 @@ const actions = await client.actions.list(listParams); | |
| ### Key Classes | ||
|
|
||
| - **ManagementClient** - for Auth0 Management API operations | ||
| - **AuthenticationClient** - for Auth0 Authentication API operations | ||
| - **UserInfoClient** - for retrieving user profile information | ||
|
|
||
| ## Exception Handling | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This merged two patterns into one line.
*.lcovhad no trailing newline, so the edit produced*.lcov.forge/and now neither*.lcovnor.forge/is ignored, which means coverage output can get committed by accident.Should be
*.lcovon its own line with a newline, and.forge/on its own line if we want it ignored. It is also unrelated to the auth separation, so it may be cleaner as a separate commit.