Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ node_modules
/dist
/docs
/coverage
*.lcov
*.lcov.forge/

Copy link
Copy Markdown
Contributor

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. *.lcov had no trailing newline, so the edit produced *.lcov.forge/ and now neither *.lcov nor .forge/ is ignored, which means coverage output can get committed by accident.

Should be *.lcov on 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.

2 changes: 1 addition & 1 deletion .version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v6.3.0
v6.3.0
88 changes: 76 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This link 404s. node-auth0 has no packages/ directory and its default branch is master. The package lives at github.com/auth0/auth0-auth-js, so this should be https://github.com/auth0/auth0-auth-js/tree/main/packages/auth0-auth-js.

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.
Expand Down Expand Up @@ -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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getUserInfo does not exist in @auth0/auth0-auth-js. I grepped auth0-auth-js, auth0-server-js and auth0-api-js at 1.12.1 and there is no such method on AuthClient or anywhere else, only userinfo_endpoint in test fixtures. So this snippet throws TypeError: auth.getUserInfo is not a function.

The migration doc lists the UserInfo endpoint as a known gap and it is still open. Either land getUserInfo in auth0-auth-js before this merges, or change this section to say it is not available yet and show a direct call to /userinfo. Right now UserInfoClient is the one removed client with no migration path at all, and the docs claim there is one.


## 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:
Expand All @@ -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

Expand Down Expand Up @@ -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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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 auth0-auth-js:

  • oauth.authorizationCodeGrantWithPKCE
  • oauth.pushedAuthorization
  • oauth.tokenForConnection maps to getTokenForConnection
  • backchannel.authorize and backchannel.backchannelGrant map to initiateBackchannelAuthentication and backchannelAuthenticationGrant
  • tokenExchange.exchangeToken maps to exchangeToken
  • the four passwordless.* methods, collapsed into one row today

IDTokenValidator.validate has no public equivalent that I can find, so it is better to say that outright than to leave it out.

Also, the repo convention is a top level migration file. v5_MIGRATION_GUIDE.md exists and the Documentation list links a v6_MIGRATION_GUIDE.md, but this whole section lives only in the README and is not linked from that list.


| 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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two rows here do not match the real API. In auth0-auth-js these live on a sub client: AuthClient.database is a DatabaseClient, so it should be authClient.database.signUp(...) and authClient.database.changePassword(...). authClient.signUp does not exist.

The getUserInfo row has the same problem as the section above, that method is not there at all.

Worth a footnote that getTokenByCode takes a URL and not a code, so it is not a drop in replacement for authorizationCodeGrant. The other five rows check out.


### mTLS configuration

If you use mTLS, you must now provide an explicit `customFetch` option:
Comment on lines +389 to +391

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This section documents useMtls and customFetch on AuthClient in auth0-auth-js, but the mTLS breaking changes in this PR are on ManagementClient and the option names are different.

Nothing here tells a ManagementClient({ useMTLS: true }) user that they now have to pass a fetch option, or that useMTLS together with clientAssertionSigningKey throws at construction. Those are the customers most likely to break, and right now the thrown error message is the only clue they get.

Can we add a short "ManagementClient breaking changes" block with a working ManagementClient mTLS snippet?


```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:
Expand Down Expand Up @@ -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

Expand Down
1 change: 0 additions & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@ export default [
"*.config.mjs",
"scripts/",
"tests/data/",
"tests/auth/fixtures/",
"**/*.d.ts",
"**/*.d.mts",
// Generated API files - these are auto-generated and should not be linted
Expand Down
6 changes: 3 additions & 3 deletions jest.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ export default {
displayName: "unit",
preset: "ts-jest",
testEnvironment: "node",
roots: ["<rootDir>/src/management/tests"],
testPathIgnorePatterns: ["/tests/wire/"],
moduleNameMapper: {
"^(\.{1,2}/.*)\.js$": "$1",
},
roots: ["<rootDir>/src/management/tests"],
testPathIgnorePatterns: ["/tests/wire/"],
setupFilesAfterEnv: ["<rootDir>/src/management/tests/setup.ts"],
transform: {
"^.+\\.tsx?$": [
Expand Down Expand Up @@ -88,4 +88,4 @@ export default {
],
workerThreads: false,
passWithNoTests: true,
};
};
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1710,7 +1710,6 @@
"validate": "yarn lint:check && yarn format --check && yarn build && yarn test && yarn lint:package"
},
"dependencies": {
"uuid": "^11.1.1",
"jose": "^5.0.0",
"auth0-legacy": "npm:auth0@^4.37.1"
},
Expand Down
Loading
Loading