Skip to content

Commit 8e41333

Browse files
update branch to use esm properly, related to #2028
2 parents 6c7347e + 51deff0 commit 8e41333

31 files changed

+104
-100
lines changed

V4_MIGRATION_GUIDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ In v4, by default, the only claims that are persisted in the `user` object of se
230230
- `email_verified`
231231
- `org_id`
232232

233-
If you'd like to customize the `user` object to include additional custom claims from the ID token, you can use the `beforeSessionSaved` hook (see [beforeSessionSaved hook](https://github.com/guabu/nextjs-auth0/tree/main?tab=readme-ov-file#beforesessionsaved))
233+
If you'd like to customize the `user` object to include additional custom claims from the ID token, you can use the `beforeSessionSaved` hook (see [beforeSessionSaved hook](https://github.com/auth0/nextjs-auth0/blob/main/EXAMPLES.md#beforesessionsaved))
234234

235235
## Additional changes
236236

package.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"name": "@auth0/nextjs-auth0",
33
"version": "4.4.0",
44
"description": "Auth0 Next.js SDK",
5+
"type": "module",
56
"scripts": {
67
"build": "tsc",
78
"build:watch": "tsc -w",
@@ -60,19 +61,19 @@
6061
},
6162
"exports": {
6263
".": {
63-
"import": "./dist/client/index.js"
64+
"default": "./dist/client/index.js"
6465
},
6566
"./server": {
66-
"import": "./dist/server/index.js"
67+
"default": "./dist/server/index.js"
6768
},
6869
"./errors": {
69-
"import": "./dist/errors/index.js"
70+
"default": "./dist/errors/index.js"
7071
},
7172
"./types": {
72-
"import": "./dist/types/index.d.ts"
73+
"default": "./dist/types/index.d.ts"
7374
},
7475
"./testing": {
75-
"import": "./dist/testing/index.js"
76+
"default": "./dist/testing/index.js"
7677
}
7778
},
7879
"dependencies": {

src/client/helpers/get-access-token.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { AccessTokenError } from "../../errors";
1+
import { AccessTokenError } from "../../errors/index.js";
22

33
export async function getAccessToken() {
44
const tokenRes = await fetch(

src/client/hooks/use-user.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import useSWR from "swr";
44

5-
import type { User } from "../../types";
5+
import type { User } from "../../types/index.js";
66

77
export function useUser() {
88
const { data, error, isLoading } = useSWR<User, Error, string>(

src/client/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
export { useUser } from "./hooks/use-user";
2-
export { getAccessToken } from "./helpers/get-access-token";
3-
export { Auth0Provider } from "./providers/auth0-provider";
1+
export { useUser } from "./hooks/use-user.js";
2+
export { getAccessToken } from "./helpers/get-access-token.js";
3+
export { Auth0Provider } from "./providers/auth0-provider.js";

src/client/providers/auth0-provider.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import React from "react";
44
import { SWRConfig } from "swr";
55

6-
import { User } from "../../types";
6+
import { User } from "../../types/index.js";
77

88
export function Auth0Provider({
99
user,

src/server/auth-client.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
import { NextRequest, NextResponse } from "next/server";
1+
import { NextRequest, NextResponse } from "next/server.js";
22
import * as jose from "jose";
33
import * as oauth from "oauth4webapi";
44
import { describe, expect, it, vi } from "vitest";
55

6-
import { generateSecret } from "../test/utils";
7-
import { SessionData } from "../types";
8-
import { AuthClient } from "./auth-client";
9-
import { decrypt, encrypt } from "./cookies";
10-
import { StatefulSessionStore } from "./session/stateful-session-store";
11-
import { StatelessSessionStore } from "./session/stateless-session-store";
12-
import { TransactionState, TransactionStore } from "./transaction-store";
6+
import { generateSecret } from "../test/utils.js";
7+
import { SessionData } from "../types/index.js";
8+
import { AuthClient } from "./auth-client.js";
9+
import { decrypt, encrypt } from "./cookies.js";
10+
import { StatefulSessionStore } from "./session/stateful-session-store.js";
11+
import { StatelessSessionStore } from "./session/stateless-session-store.js";
12+
import { TransactionState, TransactionStore } from "./transaction-store.js";
1313

1414
describe("Authentication Client", async () => {
1515
const DEFAULT = {

src/server/auth-client.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { NextResponse, type NextRequest } from "next/server";
1+
import { NextResponse, type NextRequest } from "next/server.js";
22
import * as jose from "jose";
33
import * as oauth from "oauth4webapi";
44

5-
import packageJson from "../../package.json";
5+
import packageJson from "../../package.json" with { type: "json" };
66
import {
77
AccessTokenError,
88
AccessTokenErrorCode,
@@ -16,7 +16,7 @@ import {
1616
MissingStateError,
1717
OAuth2Error,
1818
SdkError
19-
} from "../errors";
19+
} from "../errors/index.js";
2020
import {
2121
AuthorizationParameters,
2222
ConnectionTokenSet,
@@ -25,16 +25,16 @@ import {
2525
SessionData,
2626
StartInteractiveLoginOptions,
2727
TokenSet
28-
} from "../types";
28+
} from "../types/index.js";
2929
import {
3030
ensureNoLeadingSlash,
3131
ensureTrailingSlash,
3232
removeTrailingSlash
33-
} from "../utils/pathUtils";
34-
import { toSafeRedirect } from "../utils/url-helpers";
35-
import { AbstractSessionStore } from "./session/abstract-session-store";
36-
import { TransactionState, TransactionStore } from "./transaction-store";
37-
import { filterClaims } from "./user";
33+
} from "../utils/pathUtils.js";
34+
import { toSafeRedirect } from "../utils/url-helpers.js";
35+
import { AbstractSessionStore } from "./session/abstract-session-store.js";
36+
import { TransactionState, TransactionStore } from "./transaction-store.js";
37+
import { filterClaims } from "./user.js";
3838

3939
export type BeforeSessionSavedHook = (
4040
session: SessionData,

src/server/chunked-cookies.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
RequestCookies,
88
ResponseCookies,
99
setChunkedCookie
10-
} from "./cookies";
10+
} from "./cookies.js";
1111

1212
// Create mock implementation for RequestCookies and ResponseCookies
1313
const createMocks = () => {

src/server/client.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
22

3-
import { ConfigurationError, ConfigurationErrorCode } from "../errors";
4-
import { Auth0Client } from "./client";
3+
import { ConfigurationError, ConfigurationErrorCode } from "../errors/index.js";
4+
import { Auth0Client } from "./client.js";
55

66
describe("Auth0Client", () => {
77
// Store original env vars

0 commit comments

Comments
 (0)