@exwave-nexus/auth-nextjs 0.0.0-stage → 0.3.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Exwave
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,107 @@
1
- # Temporary Holding Version
1
+ # @exwave-nexus/auth-nextjs
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Exwave Auth for the Next.js App Router. The session lives in a sealed
4
+ httpOnly cookie: Server Components, Server Functions and Route Handlers read
5
+ the user, and pages render signed in from the first byte. Built on
6
+ [`@exwave-nexus/auth`](https://www.npmjs.com/package/@exwave-nexus/auth) and
7
+ [`@exwave-nexus/auth-react`](https://www.npmjs.com/package/@exwave-nexus/auth-react).
8
+
9
+ Full guide: <https://www.exwave.net/docs/auth/nextjs/>
10
+
11
+ ```bash
12
+ npm install @exwave-nexus/auth @exwave-nexus/auth-react @exwave-nexus/auth-nextjs
13
+ ```
14
+
15
+ Starting from scratch? `npm create exwave@latest -- --template next` makes an
16
+ app with all of this, and every screen, already in place.
17
+
18
+ ## Set it up
19
+
20
+ ```bash
21
+ # .env.local
22
+ NEXT_PUBLIC_EXWAVE_PUBLISHABLE_KEY=exw_pk_... # Nexus → Auth
23
+ EXWAVE_COOKIE_SECRET=... # openssl rand -base64 32
24
+ ```
25
+
26
+ ```ts
27
+ // lib/exwave.ts
28
+ import { createExwaveNext } from "@exwave-nexus/auth-nextjs";
29
+
30
+ export const exwave = createExwaveNext();
31
+ ```
32
+
33
+ ```ts
34
+ // app/api/exwave/[...action]/route.ts: the routes the hooks call
35
+ import { exwave } from "@/lib/exwave";
36
+
37
+ export const { GET, POST } = exwave.routeHandlers();
38
+ ```
39
+
40
+ ```ts
41
+ // proxy.ts: keeps sessions fresh before pages render
42
+ import type { NextRequest } from "next/server";
43
+ import { exwave } from "@/lib/exwave";
44
+
45
+ export function proxy(request: NextRequest) {
46
+ return exwave.proxy(request);
47
+ }
48
+
49
+ export const config = {
50
+ matcher: ["/((?!api/exwave|_next/static|_next/image|favicon.ico).*)"],
51
+ };
52
+ ```
53
+
54
+ ```tsx
55
+ // app/layout.tsx
56
+ import { ExwaveProvider } from "@exwave-nexus/auth-nextjs/client";
57
+ import { exwave } from "@/lib/exwave";
58
+
59
+ export default async function RootLayout({ children }) {
60
+ return (
61
+ <html lang="en">
62
+ <body>
63
+ <ExwaveProvider initialState={await exwave.getAuthState()}>
64
+ {children}
65
+ </ExwaveProvider>
66
+ </body>
67
+ </html>
68
+ );
69
+ }
70
+ ```
71
+
72
+ `ExwaveProvider` from `./client` is `@exwave-nexus/auth-react`'s, wired to the
73
+ router: it navigates with `router.push` and refreshes Server Components when
74
+ someone signs in or out. Every hook from `@exwave-nexus/auth-react` works
75
+ under it.
76
+
77
+ ## On the server
78
+
79
+ ```ts
80
+ const user = await exwave.getUser(); // null when signed out
81
+ ```
82
+
83
+ | Method | Does |
84
+ | --- | --- |
85
+ | `getUser()` | The signed-in user, or `null`. Safe in Server Components |
86
+ | `getAuthState()` | The session as the browser may see it, for the provider |
87
+ | `getSession()` | The user and a player access token |
88
+ | `getPlayerAccessToken()` | A PAT with at least 60 s left, for a game |
89
+ | `getSignOutReason()` | Why the last session in this browser ended |
90
+ | `getConfig()` | The platform's settings, cached for 60 s |
91
+ | `signIn()`, `verifyEmail()`, `confirmPasswordReset()`, `signOut()` | The same, from Server Functions |
92
+ | `routeHandlers()`, `proxy(request)` | The wiring above |
93
+
94
+ `createExwaveNext(options)` takes `publishableKey` and `cookieSecret` to read
95
+ them from elsewhere, `appUrl` when email links should name another origin
96
+ than the request's, and `paths` for the pages they land on.
97
+
98
+ ## Ready-made screens
99
+
100
+ The sign-in, sign-up, verification and password reset pages, with the files
101
+ above, as shadcn/ui components:
102
+
103
+ ```bash
104
+ npx shadcn@latest add https://www.exwave.net/r/auth-nextjs.json
105
+ ```
106
+
107
+ Next.js 16 or later and React 19 or later are peer dependencies.
@@ -0,0 +1,19 @@
1
+ import type { AuthState } from "@exwave-nexus/auth";
2
+ import { type ExwaveProviderSettings } from "@exwave-nexus/auth-react";
3
+ export interface ExwaveNextProviderProps extends Omit<ExwaveProviderSettings, "navigate" | "onAuthChange"> {
4
+ /** Where `routeHandlers()` is mounted. Default `/api/exwave`. */
5
+ api?: string;
6
+ /** `await exwave.getAuthState()`, from the layout, on every server render. */
7
+ initialState?: AuthState;
8
+ }
9
+ /**
10
+ * `<ExwaveProvider>` for the Next.js App Router: it talks to your
11
+ * `/api/exwave` routes, moves between pages with the router, and refreshes
12
+ * Server Components when someone signs in or out.
13
+ *
14
+ * ```tsx
15
+ * // app/layout.tsx
16
+ * <ExwaveProvider initialState={await exwave.getAuthState()}>{children}</ExwaveProvider>
17
+ * ```
18
+ */
19
+ export declare function ExwaveProvider({ api, ...props }: ExwaveNextProviderProps): import("react").JSX.Element;
package/dist/client.js ADDED
@@ -0,0 +1,25 @@
1
+ "use client";
2
+ // src/client.tsx
3
+ import {
4
+ ExwaveProvider as Provider
5
+ } from "@exwave-nexus/auth-react";
6
+ import { useRouter } from "next/navigation";
7
+ import { jsx } from "react/jsx-runtime";
8
+ function ExwaveProvider({
9
+ api = "/api/exwave",
10
+ ...props
11
+ }) {
12
+ const router = useRouter();
13
+ return /* @__PURE__ */ jsx(Provider, {
14
+ ...props,
15
+ api,
16
+ navigate: (to, options) => options?.replace ? router.replace(to) : router.push(to),
17
+ onAuthChange: () => router.refresh()
18
+ });
19
+ }
20
+ export {
21
+ ExwaveProvider
22
+ };
23
+
24
+ //# debugId=E37EDBD9FD7D36C564756E2164756E21
25
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/client.tsx"],"sourcesContent":["\"use client\";\n\nimport type { AuthState } from \"@exwave-nexus/auth\";\nimport {\n type ExwaveProviderSettings,\n ExwaveProvider as Provider,\n} from \"@exwave-nexus/auth-react\";\nimport { useRouter } from \"next/navigation\";\n\nexport interface ExwaveNextProviderProps\n extends Omit<ExwaveProviderSettings, \"navigate\" | \"onAuthChange\"> {\n /** Where `routeHandlers()` is mounted. Default `/api/exwave`. */\n api?: string;\n /** `await exwave.getAuthState()`, from the layout, on every server render. */\n initialState?: AuthState;\n}\n\n/**\n * `<ExwaveProvider>` for the Next.js App Router: it talks to your\n * `/api/exwave` routes, moves between pages with the router, and refreshes\n * Server Components when someone signs in or out.\n *\n * ```tsx\n * // app/layout.tsx\n * <ExwaveProvider initialState={await exwave.getAuthState()}>{children}</ExwaveProvider>\n * ```\n */\nexport function ExwaveProvider({\n api = \"/api/exwave\",\n ...props\n}: ExwaveNextProviderProps) {\n const router = useRouter();\n return (\n <Provider\n {...props}\n api={api}\n navigate={(to, options) =>\n options?.replace ? router.replace(to) : router.push(to)\n }\n onAuthChange={() => router.refresh()}\n />\n );\n}\n"],"mappings":";;AAGA;AAAA,oBAEE;AAAA;AAEF;AAAA;AAPA;AA2BO,SAAS,cAAc;AAAA,EAC5B,MAAM;AAAA,KACH;AAAA,GACuB;AAAA,EAC1B,MAAM,SAAS,UAAU;AAAA,EACzB,uBACE,IAAC,UAAD;AAAA,OACM;AAAA,IACJ;AAAA,IACA,UAAU,CAAC,IAAI,YACb,SAAS,UAAU,OAAO,QAAQ,EAAE,IAAI,OAAO,KAAK,EAAE;AAAA,IAExD,cAAc,MAAM,OAAO,QAAQ;AAAA,GACrC;AAAA;","debugId":"E37EDBD9FD7D36C564756E2164756E21","names":[]}
@@ -0,0 +1,129 @@
1
+ import type { AuthState, CodeInput, EmailInput, PasswordResetConfirmInput, PlatformConfig, SignInInput, SignUpInput, SignUpResult, User } from "@exwave-nexus/auth";
2
+ import { type SignOutReason } from "@exwave-nexus/auth";
3
+ import { type ExwaveServerAuthOptions, isSecureRequest, type RefreshResult, type ServerSession } from "@exwave-nexus/auth/server";
4
+ import { type NextRequest, NextResponse } from "next/server";
5
+ export type { SignOutReason } from "@exwave-nexus/auth";
6
+ export { ExwaveAuthError, isExwaveAuthError } from "@exwave-nexus/auth";
7
+ export interface ExwaveNextOptions extends Partial<ExwaveServerAuthOptions> {
8
+ /** Pages the email links land on, relative to the app. */
9
+ paths?: {
10
+ verifyEmail?: string;
11
+ resetPassword?: string;
12
+ };
13
+ /** The app's public origin for email links. Default: the request's `Host`. */
14
+ appUrl?: string;
15
+ }
16
+ /** What server code may see. The refresh token stays in the cookie. */
17
+ export interface NextSession {
18
+ user: User;
19
+ accessToken: string;
20
+ expiresAt: number;
21
+ }
22
+ /**
23
+ * Managed auth for the Next.js App Router. With no options it reads
24
+ * `NEXT_PUBLIC_EXWAVE_PUBLISHABLE_KEY` and `EXWAVE_COOKIE_SECRET`, lazily, so
25
+ * builds don't need them.
26
+ */
27
+ export declare function createExwaveNext(options?: ExwaveNextOptions): {
28
+ readonly server: {
29
+ authOrigin: string;
30
+ platformId: string;
31
+ cookieName: string;
32
+ reasonCookieName: string;
33
+ signUp: (input: import("@exwave-nexus/auth").SignUpInput) => Promise<import("@exwave-nexus/auth").SignUpResult>;
34
+ resendVerification: (input: import("@exwave-nexus/auth").EmailInput) => Promise<void>;
35
+ resetPassword: (input: import("@exwave-nexus/auth").EmailInput) => Promise<void>;
36
+ getConfig(): Promise<PlatformConfig>;
37
+ getUser: (accessToken: string) => Promise<import("@exwave-nexus/auth").User>;
38
+ signIn(input: SignInInput): Promise<ServerSession>;
39
+ verifyEmail(input: CodeInput): Promise<ServerSession>;
40
+ confirmPasswordReset(input: PasswordResetConfirmInput): Promise<ServerSession>;
41
+ signOut(session: ServerSession, { everywhere }?: {
42
+ everywhere?: boolean | undefined;
43
+ }): Promise<void>;
44
+ refreshSession(session: ServerSession, { force }?: {
45
+ force?: boolean | undefined;
46
+ }): Promise<RefreshResult>;
47
+ seal: (session: ServerSession) => Promise<string>;
48
+ unseal: (value: string | null | undefined) => Promise<ServerSession | null>;
49
+ readCookie(request: Request): Promise<ServerSession | null>;
50
+ readSignOutReason(request: Request): SignOutReason | null;
51
+ sessionCookie(session: ServerSession, secure: boolean): Promise<string>;
52
+ clearCookie(secure: boolean): string;
53
+ signOutReasonCookie(reason: SignOutReason, secure: boolean): string;
54
+ clearSignOutReasonCookie(secure: boolean): string;
55
+ isSecureRequest: typeof isSecureRequest;
56
+ verifyPlayerAccessToken: (token: string) => Promise<import("@exwave-nexus/auth/server").VerifiedPlayer>;
57
+ now: () => number;
58
+ };
59
+ /** `export const { GET, POST } = exwave.routeHandlers()` in `app/api/exwave/[...action]/route.ts`. */
60
+ routeHandlers(): {
61
+ GET: (request: Request, context: {
62
+ params: Promise<{
63
+ action?: string[];
64
+ }>;
65
+ }) => Promise<Response>;
66
+ POST: (request: Request, context: {
67
+ params: Promise<{
68
+ action?: string[];
69
+ }>;
70
+ }) => Promise<Response>;
71
+ };
72
+ /**
73
+ * The session as the browser may see it, for `<ExwaveProvider
74
+ * initialState>` from `@exwave-nexus/auth-nextjs/client`: the user, the
75
+ * PAT's expiry and why the last session ended. No tokens, and no refresh,
76
+ * so it is safe in Server Components.
77
+ */
78
+ getAuthState(): Promise<AuthState>;
79
+ /** The signed-in user from the cookie, or `null`. Safe in Server Components. */
80
+ getUser(): Promise<User | null>;
81
+ /**
82
+ * Why the last session in this browser ended, for the sign-in page:
83
+ * `account_locked`, `invalid_refresh_token` (ended elsewhere or expired),
84
+ * `signed_out_everywhere` or `signed_out`. `null` after 5 minutes or a new
85
+ * sign-in. Safe in Server Components.
86
+ */
87
+ getSignOutReason(): Promise<SignOutReason | null>;
88
+ /** The platform's config, such as `passwordPolicy` for sign-up forms. Cached for 60 s. */
89
+ getConfig(): Promise<PlatformConfig>;
90
+ getSession(): Promise<NextSession | null>;
91
+ /**
92
+ * A player access token (PAT) with at least 60 s left, to hand to a game.
93
+ * Server Functions and Route Handlers
94
+ * refresh and store the rotated cookie. Server Components cannot set
95
+ * cookies, so they never refresh (a lost rotation would end the session):
96
+ * they rely on `proxy` and get `null` once the PAT has expired.
97
+ */
98
+ getPlayerAccessToken(): Promise<string | null>;
99
+ signUp: (input: SignUpInput) => Promise<SignUpResult>;
100
+ resendVerification: (input: EmailInput) => Promise<void>;
101
+ resetPassword: (input: EmailInput) => Promise<void>;
102
+ signIn(input: SignInInput): Promise<User>;
103
+ verifyEmail(input: CodeInput): Promise<User>;
104
+ confirmPasswordReset(input: PasswordResetConfirmInput): Promise<User>;
105
+ signOut({ everywhere }?: {
106
+ everywhere?: boolean | undefined;
107
+ }): Promise<void>;
108
+ /**
109
+ * For `proxy.ts`: refreshes a session whose PAT has under 60 s left, so
110
+ * pages render with a fresh PAT and the browser gets the rotated cookie.
111
+ * A session that ended (locked, signed out elsewhere, expired) loses its
112
+ * cookie and leaves the reason for `getSignOutReason()`.
113
+ */
114
+ proxy(request: NextRequest): Promise<NextResponse>;
115
+ };
116
+ export type ExwaveNext = ReturnType<typeof createExwaveNext>;
117
+ /** Shorthand: `export const { GET, POST } = exwaveRouteHandlers()`. */
118
+ export declare function exwaveRouteHandlers(options?: ExwaveNextOptions): {
119
+ GET: (request: Request, context: {
120
+ params: Promise<{
121
+ action?: string[];
122
+ }>;
123
+ }) => Promise<Response>;
124
+ POST: (request: Request, context: {
125
+ params: Promise<{
126
+ action?: string[];
127
+ }>;
128
+ }) => Promise<Response>;
129
+ };
package/dist/index.js ADDED
@@ -0,0 +1,244 @@
1
+ // src/index.ts
2
+ import { REFRESH_MARGIN_MS } from "@exwave-nexus/auth";
3
+ import {
4
+ COOKIE_MAX_AGE_SECONDS,
5
+ createExwaveServerAuth,
6
+ handleAuthRequest,
7
+ isSecureRequest,
8
+ isSignOutReason,
9
+ SIGN_OUT_REASON_MAX_AGE_SECONDS
10
+ } from "@exwave-nexus/auth/server";
11
+ import { cookies, headers } from "next/headers";
12
+ import { NextResponse } from "next/server";
13
+ import { ExwaveAuthError, isExwaveAuthError } from "@exwave-nexus/auth";
14
+ function createExwaveNext(options = {}) {
15
+ let instance;
16
+ const server = () => {
17
+ instance ??= createExwaveServerAuth({
18
+ ...options,
19
+ publishableKey: options.publishableKey ?? process.env.NEXT_PUBLIC_EXWAVE_PUBLISHABLE_KEY ?? process.env.EXWAVE_PUBLISHABLE_KEY ?? "",
20
+ cookieSecret: options.cookieSecret ?? process.env.EXWAVE_COOKIE_SECRET ?? ""
21
+ });
22
+ return instance;
23
+ };
24
+ const paths = {
25
+ verifyEmail: "/verify",
26
+ resetPassword: "/reset-password",
27
+ ...options.paths
28
+ };
29
+ async function appOrigin() {
30
+ if (options.appUrl)
31
+ return new URL(options.appUrl).origin;
32
+ const h = await headers();
33
+ const host = h.get("host") ?? "localhost";
34
+ const local = /^(localhost|127\.0\.0\.1|\[::1\])(:\d+)?$/.test(host);
35
+ const proto = h.get("x-forwarded-proto") ?? (local ? "http" : "https");
36
+ return `${proto}://${host}`;
37
+ }
38
+ async function cookieOptions() {
39
+ return {
40
+ httpOnly: true,
41
+ sameSite: "lax",
42
+ secure: isSecureRequest(await appOrigin()),
43
+ path: "/",
44
+ maxAge: COOKIE_MAX_AGE_SECONDS
45
+ };
46
+ }
47
+ async function readSession(store) {
48
+ const jar = store ?? await cookies();
49
+ return server().unseal(jar.get(server().cookieName)?.value);
50
+ }
51
+ async function persist(session, reason) {
52
+ const jar = await cookies();
53
+ const { cookieName, reasonCookieName } = server();
54
+ const options2 = await cookieOptions();
55
+ if (session) {
56
+ jar.set(cookieName, await server().seal(session), options2);
57
+ if (jar.has(reasonCookieName))
58
+ jar.delete(reasonCookieName);
59
+ return;
60
+ }
61
+ jar.delete(cookieName);
62
+ if (reason)
63
+ jar.set(reasonCookieName, reason, {
64
+ ...options2,
65
+ maxAge: SIGN_OUT_REASON_MAX_AGE_SECONDS
66
+ });
67
+ }
68
+ async function canWrite(jar, value) {
69
+ try {
70
+ jar.set(server().cookieName, value, await cookieOptions());
71
+ return true;
72
+ } catch {
73
+ return false;
74
+ }
75
+ }
76
+ const link = async (redirectTo, path) => redirectTo ?? new URL(path, await appOrigin()).href;
77
+ return {
78
+ get server() {
79
+ return server();
80
+ },
81
+ routeHandlers() {
82
+ const handler = async (request, context) => {
83
+ const { action = [] } = await context.params;
84
+ return handleAuthRequest(server(), request, action.join("/"), {
85
+ links: paths,
86
+ appUrl: options.appUrl
87
+ });
88
+ };
89
+ return { GET: handler, POST: handler };
90
+ },
91
+ async getAuthState() {
92
+ const jar = await cookies();
93
+ const session = await readSession(jar);
94
+ const reason = jar.get(server().reasonCookieName)?.value;
95
+ return {
96
+ user: session?.user ?? null,
97
+ expiresAt: session?.expiresAt ?? null,
98
+ signOutReason: !session && isSignOutReason(reason) ? reason : null
99
+ };
100
+ },
101
+ async getUser() {
102
+ return (await readSession())?.user ?? null;
103
+ },
104
+ async getSignOutReason() {
105
+ const value = (await cookies()).get(server().reasonCookieName)?.value;
106
+ return isSignOutReason(value) ? value : null;
107
+ },
108
+ async getConfig() {
109
+ return server().getConfig();
110
+ },
111
+ async getSession() {
112
+ const session = await readSession();
113
+ if (!session)
114
+ return null;
115
+ const { user, accessToken, expiresAt } = session;
116
+ return { user, accessToken, expiresAt };
117
+ },
118
+ async getPlayerAccessToken() {
119
+ const jar = await cookies();
120
+ const raw = jar.get(server().cookieName)?.value;
121
+ const session = await readSession(jar);
122
+ if (!session || !raw)
123
+ return null;
124
+ const now = server().now();
125
+ if (session.expiresAt - now > REFRESH_MARGIN_MS)
126
+ return session.accessToken;
127
+ if (!await canWrite(jar, raw))
128
+ return session.expiresAt > now ? session.accessToken : null;
129
+ let result;
130
+ try {
131
+ result = await server().refreshSession(session);
132
+ } catch {
133
+ return session.expiresAt > now ? session.accessToken : null;
134
+ }
135
+ if (result.cookie === "write")
136
+ await persist(result.session);
137
+ if (result.cookie === "clear")
138
+ await persist(null, result.reason);
139
+ return result.session?.accessToken ?? null;
140
+ },
141
+ signUp: async (input) => server().signUp({
142
+ ...input,
143
+ redirectTo: await link(input.redirectTo, paths.verifyEmail)
144
+ }),
145
+ resendVerification: async (input) => server().resendVerification({
146
+ ...input,
147
+ redirectTo: await link(input.redirectTo, paths.verifyEmail)
148
+ }),
149
+ resetPassword: async (input) => server().resetPassword({
150
+ ...input,
151
+ redirectTo: await link(input.redirectTo, paths.resetPassword)
152
+ }),
153
+ async signIn(input) {
154
+ const session = await server().signIn(input);
155
+ await persist(session);
156
+ return session.user;
157
+ },
158
+ async verifyEmail(input) {
159
+ const session = await server().verifyEmail(input);
160
+ await persist(session);
161
+ return session.user;
162
+ },
163
+ async confirmPasswordReset(input) {
164
+ const session = await server().confirmPasswordReset(input);
165
+ await persist(session);
166
+ return session.user;
167
+ },
168
+ async signOut({ everywhere = false } = {}) {
169
+ const session = await readSession();
170
+ let reason = "signed_out";
171
+ try {
172
+ if (session) {
173
+ await server().signOut(session, { everywhere });
174
+ if (everywhere)
175
+ reason = "signed_out_everywhere";
176
+ }
177
+ } catch (error) {
178
+ if (everywhere)
179
+ throw error;
180
+ } finally {
181
+ await persist(null, reason);
182
+ }
183
+ },
184
+ async proxy(request) {
185
+ const { cookieName: name, reasonCookieName } = server();
186
+ const value = request.cookies.get(name)?.value;
187
+ if (!value)
188
+ return NextResponse.next();
189
+ const session = await server().unseal(value);
190
+ let result = null;
191
+ if (session) {
192
+ try {
193
+ result = await server().refreshSession(session);
194
+ } catch {
195
+ return NextResponse.next();
196
+ }
197
+ if (result.cookie === "keep")
198
+ return NextResponse.next();
199
+ }
200
+ const sealed = result?.session ? await server().seal(result.session) : null;
201
+ const reason = result?.cookie === "clear" ? result.reason : null;
202
+ if (sealed)
203
+ request.cookies.set(name, sealed);
204
+ else
205
+ request.cookies.delete(name);
206
+ if (reason)
207
+ request.cookies.set(reasonCookieName, reason);
208
+ const response = NextResponse.next({
209
+ request: { headers: request.headers }
210
+ });
211
+ const options2 = {
212
+ httpOnly: true,
213
+ sameSite: "lax",
214
+ secure: isSecureRequest(request.url),
215
+ path: "/"
216
+ };
217
+ if (sealed && result?.cookie === "write")
218
+ response.cookies.set(name, sealed, {
219
+ ...options2,
220
+ maxAge: COOKIE_MAX_AGE_SECONDS
221
+ });
222
+ else if (!sealed)
223
+ response.cookies.delete(name);
224
+ if (reason)
225
+ response.cookies.set(reasonCookieName, reason, {
226
+ ...options2,
227
+ maxAge: SIGN_OUT_REASON_MAX_AGE_SECONDS
228
+ });
229
+ return response;
230
+ }
231
+ };
232
+ }
233
+ function exwaveRouteHandlers(options) {
234
+ return createExwaveNext(options).routeHandlers();
235
+ }
236
+ export {
237
+ isExwaveAuthError,
238
+ exwaveRouteHandlers,
239
+ createExwaveNext,
240
+ ExwaveAuthError
241
+ };
242
+
243
+ //# debugId=2C7AB3DA48E9893264756E2164756E21
244
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/index.ts"],
4
+ "sourcesContent": [
5
+ "import type {\n AuthState,\n CodeInput,\n EmailInput,\n PasswordResetConfirmInput,\n PlatformConfig,\n SignInInput,\n SignUpInput,\n SignUpResult,\n User,\n} from \"@exwave-nexus/auth\";\nimport { REFRESH_MARGIN_MS, type SignOutReason } from \"@exwave-nexus/auth\";\nimport {\n COOKIE_MAX_AGE_SECONDS,\n createExwaveServerAuth,\n type ExwaveServerAuth,\n type ExwaveServerAuthOptions,\n handleAuthRequest,\n isSecureRequest,\n isSignOutReason,\n type RefreshResult,\n type ServerSession,\n SIGN_OUT_REASON_MAX_AGE_SECONDS,\n} from \"@exwave-nexus/auth/server\";\nimport { cookies, headers } from \"next/headers\";\nimport { type NextRequest, NextResponse } from \"next/server\";\n\nexport type { SignOutReason } from \"@exwave-nexus/auth\";\nexport { ExwaveAuthError, isExwaveAuthError } from \"@exwave-nexus/auth\";\n\nexport interface ExwaveNextOptions extends Partial<ExwaveServerAuthOptions> {\n /** Pages the email links land on, relative to the app. */\n paths?: { verifyEmail?: string; resetPassword?: string };\n /** The app's public origin for email links. Default: the request's `Host`. */\n appUrl?: string;\n}\n\n/** What server code may see. The refresh token stays in the cookie. */\nexport interface NextSession {\n user: User;\n accessToken: string;\n expiresAt: number;\n}\n\ntype CookieStore = Awaited<ReturnType<typeof cookies>>;\n\n/**\n * Managed auth for the Next.js App Router. With no options it reads\n * `NEXT_PUBLIC_EXWAVE_PUBLISHABLE_KEY` and `EXWAVE_COOKIE_SECRET`, lazily, so\n * builds don't need them.\n */\nexport function createExwaveNext(options: ExwaveNextOptions = {}) {\n let instance: ExwaveServerAuth | undefined;\n const server = () => {\n instance ??= createExwaveServerAuth({\n ...options,\n publishableKey:\n options.publishableKey ??\n process.env.NEXT_PUBLIC_EXWAVE_PUBLISHABLE_KEY ??\n process.env.EXWAVE_PUBLISHABLE_KEY ??\n \"\",\n cookieSecret:\n options.cookieSecret ?? process.env.EXWAVE_COOKIE_SECRET ?? \"\",\n });\n return instance;\n };\n const paths = {\n verifyEmail: \"/verify\",\n resetPassword: \"/reset-password\",\n ...options.paths,\n };\n\n async function appOrigin(): Promise<string> {\n if (options.appUrl) return new URL(options.appUrl).origin;\n const h = await headers();\n const host = h.get(\"host\") ?? \"localhost\";\n const local = /^(localhost|127\\.0\\.0\\.1|\\[::1\\])(:\\d+)?$/.test(host);\n const proto = h.get(\"x-forwarded-proto\") ?? (local ? \"http\" : \"https\");\n return `${proto}://${host}`;\n }\n\n async function cookieOptions() {\n return {\n httpOnly: true,\n sameSite: \"lax\" as const,\n secure: isSecureRequest(await appOrigin()),\n path: \"/\",\n maxAge: COOKIE_MAX_AGE_SECONDS,\n };\n }\n\n async function readSession(\n store?: CookieStore,\n ): Promise<ServerSession | null> {\n const jar = store ?? (await cookies());\n return server().unseal(jar.get(server().cookieName)?.value);\n }\n\n // Only Server Functions and Route Handlers can set cookies. An ended\n // session leaves its reason for the sign-in page; a new one clears it.\n async function persist(\n session: ServerSession | null,\n reason?: SignOutReason,\n ) {\n const jar = await cookies();\n const { cookieName, reasonCookieName } = server();\n const options = await cookieOptions();\n if (session) {\n jar.set(cookieName, await server().seal(session), options);\n if (jar.has(reasonCookieName)) jar.delete(reasonCookieName);\n return;\n }\n jar.delete(cookieName);\n if (reason)\n jar.set(reasonCookieName, reason, {\n ...options,\n maxAge: SIGN_OUT_REASON_MAX_AGE_SECONDS,\n });\n }\n\n async function canWrite(jar: CookieStore, value: string): Promise<boolean> {\n try {\n jar.set(server().cookieName, value, await cookieOptions());\n return true;\n } catch {\n return false;\n }\n }\n\n const link = async (redirectTo: string | undefined, path: string) =>\n redirectTo ?? new URL(path, await appOrigin()).href;\n\n return {\n get server() {\n return server();\n },\n\n /** `export const { GET, POST } = exwave.routeHandlers()` in `app/api/exwave/[...action]/route.ts`. */\n routeHandlers() {\n const handler = async (\n request: Request,\n context: { params: Promise<{ action?: string[] }> },\n ) => {\n const { action = [] } = await context.params;\n return handleAuthRequest(server(), request, action.join(\"/\"), {\n links: paths,\n appUrl: options.appUrl,\n });\n };\n return { GET: handler, POST: handler };\n },\n\n /**\n * The session as the browser may see it, for `<ExwaveProvider\n * initialState>` from `@exwave-nexus/auth-nextjs/client`: the user, the\n * PAT's expiry and why the last session ended. No tokens, and no refresh,\n * so it is safe in Server Components.\n */\n async getAuthState(): Promise<AuthState> {\n const jar = await cookies();\n const session = await readSession(jar);\n const reason = jar.get(server().reasonCookieName)?.value;\n return {\n user: session?.user ?? null,\n expiresAt: session?.expiresAt ?? null,\n signOutReason: !session && isSignOutReason(reason) ? reason : null,\n };\n },\n\n /** The signed-in user from the cookie, or `null`. Safe in Server Components. */\n async getUser(): Promise<User | null> {\n return (await readSession())?.user ?? null;\n },\n\n /**\n * Why the last session in this browser ended, for the sign-in page:\n * `account_locked`, `invalid_refresh_token` (ended elsewhere or expired),\n * `signed_out_everywhere` or `signed_out`. `null` after 5 minutes or a new\n * sign-in. Safe in Server Components.\n */\n async getSignOutReason(): Promise<SignOutReason | null> {\n const value = (await cookies()).get(server().reasonCookieName)?.value;\n return isSignOutReason(value) ? value : null;\n },\n\n /** The platform's config, such as `passwordPolicy` for sign-up forms. Cached for 60 s. */\n async getConfig(): Promise<PlatformConfig> {\n return server().getConfig();\n },\n\n async getSession(): Promise<NextSession | null> {\n const session = await readSession();\n if (!session) return null;\n const { user, accessToken, expiresAt } = session;\n return { user, accessToken, expiresAt };\n },\n\n /**\n * A player access token (PAT) with at least 60 s left, to hand to a game.\n * Server Functions and Route Handlers\n * refresh and store the rotated cookie. Server Components cannot set\n * cookies, so they never refresh (a lost rotation would end the session):\n * they rely on `proxy` and get `null` once the PAT has expired.\n */\n async getPlayerAccessToken(): Promise<string | null> {\n const jar = await cookies();\n const raw = jar.get(server().cookieName)?.value;\n const session = await readSession(jar);\n if (!session || !raw) return null;\n const now = server().now();\n if (session.expiresAt - now > REFRESH_MARGIN_MS)\n return session.accessToken;\n if (!(await canWrite(jar, raw)))\n return session.expiresAt > now ? session.accessToken : null;\n let result: RefreshResult;\n try {\n result = await server().refreshSession(session);\n } catch {\n return session.expiresAt > now ? session.accessToken : null;\n }\n if (result.cookie === \"write\") await persist(result.session);\n if (result.cookie === \"clear\") await persist(null, result.reason);\n return result.session?.accessToken ?? null;\n },\n\n signUp: async (input: SignUpInput): Promise<SignUpResult> =>\n server().signUp({\n ...input,\n redirectTo: await link(input.redirectTo, paths.verifyEmail),\n }),\n resendVerification: async (input: EmailInput) =>\n server().resendVerification({\n ...input,\n redirectTo: await link(input.redirectTo, paths.verifyEmail),\n }),\n resetPassword: async (input: EmailInput) =>\n server().resetPassword({\n ...input,\n redirectTo: await link(input.redirectTo, paths.resetPassword),\n }),\n async signIn(input: SignInInput): Promise<User> {\n const session = await server().signIn(input);\n await persist(session);\n return session.user;\n },\n async verifyEmail(input: CodeInput): Promise<User> {\n const session = await server().verifyEmail(input);\n await persist(session);\n return session.user;\n },\n async confirmPasswordReset(\n input: PasswordResetConfirmInput,\n ): Promise<User> {\n const session = await server().confirmPasswordReset(input);\n await persist(session);\n return session.user;\n },\n async signOut({ everywhere = false } = {}) {\n const session = await readSession();\n let reason: SignOutReason = \"signed_out\";\n try {\n if (session) {\n await server().signOut(session, { everywhere });\n if (everywhere) reason = \"signed_out_everywhere\";\n }\n } catch (error) {\n if (everywhere) throw error;\n } finally {\n await persist(null, reason);\n }\n },\n\n /**\n * For `proxy.ts`: refreshes a session whose PAT has under 60 s left, so\n * pages render with a fresh PAT and the browser gets the rotated cookie.\n * A session that ended (locked, signed out elsewhere, expired) loses its\n * cookie and leaves the reason for `getSignOutReason()`.\n */\n async proxy(request: NextRequest): Promise<NextResponse> {\n const { cookieName: name, reasonCookieName } = server();\n const value = request.cookies.get(name)?.value;\n if (!value) return NextResponse.next();\n const session = await server().unseal(value);\n let result: RefreshResult | null = null;\n if (session) {\n try {\n result = await server().refreshSession(session);\n } catch {\n // Auth unreachable: keep the cookie and let the page decide.\n return NextResponse.next();\n }\n if (result.cookie === \"keep\") return NextResponse.next();\n }\n const sealed = result?.session\n ? await server().seal(result.session)\n : null;\n const reason = result?.cookie === \"clear\" ? result.reason : null;\n // Hand the fresh session (or the reason) to this render through the request cookies.\n if (sealed) request.cookies.set(name, sealed);\n else request.cookies.delete(name);\n if (reason) request.cookies.set(reasonCookieName, reason);\n const response = NextResponse.next({\n request: { headers: request.headers },\n });\n const options = {\n httpOnly: true,\n sameSite: \"lax\",\n secure: isSecureRequest(request.url),\n path: \"/\",\n } as const;\n if (sealed && result?.cookie === \"write\")\n response.cookies.set(name, sealed, {\n ...options,\n maxAge: COOKIE_MAX_AGE_SECONDS,\n });\n else if (!sealed) response.cookies.delete(name);\n if (reason)\n response.cookies.set(reasonCookieName, reason, {\n ...options,\n maxAge: SIGN_OUT_REASON_MAX_AGE_SECONDS,\n });\n return response;\n },\n };\n}\n\nexport type ExwaveNext = ReturnType<typeof createExwaveNext>;\n\n/** Shorthand: `export const { GET, POST } = exwaveRouteHandlers()`. */\nexport function exwaveRouteHandlers(options?: ExwaveNextOptions) {\n return createExwaveNext(options).routeHandlers();\n}\n"
6
+ ],
7
+ "mappings": ";AAWA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAYA;AACA;AAGA;AAuBO,SAAS,gBAAgB,CAAC,UAA6B,CAAC,GAAG;AAAA,EAChE,IAAI;AAAA,EACJ,MAAM,SAAS,MAAM;AAAA,IACnB,aAAa,uBAAuB;AAAA,SAC/B;AAAA,MACH,gBACE,QAAQ,kBACR,QAAQ,IAAI,sCACZ,QAAQ,IAAI,0BACZ;AAAA,MACF,cACE,QAAQ,gBAAgB,QAAQ,IAAI,wBAAwB;AAAA,IAChE,CAAC;AAAA,IACD,OAAO;AAAA;AAAA,EAET,MAAM,QAAQ;AAAA,IACZ,aAAa;AAAA,IACb,eAAe;AAAA,OACZ,QAAQ;AAAA,EACb;AAAA,EAEA,eAAe,SAAS,GAAoB;AAAA,IAC1C,IAAI,QAAQ;AAAA,MAAQ,OAAO,IAAI,IAAI,QAAQ,MAAM,EAAE;AAAA,IACnD,MAAM,IAAI,MAAM,QAAQ;AAAA,IACxB,MAAM,OAAO,EAAE,IAAI,MAAM,KAAK;AAAA,IAC9B,MAAM,QAA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,MAAM,SAAS,QAAQ,UACnB,MAAM,OAAO,EAAE,KAAK,OAAO,OAAO,IAClC;AAAA,MACJ,MAAM,SAAS,QAAQ,WAAW,UAAU,OAAO,SAAS;AAAA,MAE5D,IAAI;AAAA,QAAQ,QAAQ,QAAQ,IAAI,MAAM,MAAM;AAAA,MACvC;AAAA,gBAAQ,QAAQ,OAAO,IAAI;AAAA,MAChC,IAAI;AAAA,QAAQ,QAAQ,QAAQ,IAAI,kBAAkB,MAAM;AAAA,MACxD,MAAM,WAAW,aAAa,KAAK;AAAA,QACjC,SAAS,EAAE,SAAS,QAAQ,QAAQ;AAAA,MACtC,CAAC;AAAA,MACD,MAAM,WAAU;AAAA,QACd,UAAU;AAAA,QACV,UAAU;AAAA,QACV,QAAQ,gBAAgB,QAAQ,GAAG;AAAA,QACnC,MAAM;AAAA,MACR;AAAA,MACA,IAAI,UAAU,QAAQ,WAAW;AAAA,QAC/B,SAAS,QAAQ,IAAI,MAAM,QAAQ;AAAA,aAC9B;AAAA,UACH,QAAQ;AAAA,QACV,CAAC;AAAA,MACE,SAAI,CAAC;AAAA,QAAQ,SAAS,QAAQ,OAAO,IAAI;AAAA,MAC9C,IAAI;AAAA,QACF,SAAS,QAAQ,IAAI,kBAAkB,QAAQ;AAAA,aAC1C;AAAA,UACH,QAAQ;AAAA,QACV,CAAC;AAAA,MACH,OAAO;AAAA;AAAA,EAEX;AAAA;AAMK,SAAS,mBAAmB,CAAC,SAA6B;AAAA,EAC/D,OAAO,iBAAiB,OAAO,EAAE,cAAc;AAAA;",
8
+ "debugId": "2C7AB3DA48E9893264756E2164756E21",
9
+ "names": []
10
+ }
package/package.json CHANGED
@@ -1,6 +1,35 @@
1
1
  {
2
2
  "name": "@exwave-nexus/auth-nextjs",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.3.0",
4
+ "description": "Exwave Auth for the Next.js App Router: the session in an httpOnly cookie, read in Server Components, with route handlers, a proxy and the provider.",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/exwave-nexus/exwave-auth-js.git",
9
+ "directory": "packages/auth-nextjs"
10
+ },
11
+ "type": "module",
12
+ "sideEffects": false,
13
+ "exports": {
14
+ ".": {
15
+ "types": "./dist/index.d.ts",
16
+ "default": "./dist/index.js"
17
+ },
18
+ "./client": {
19
+ "types": "./dist/client.d.ts",
20
+ "default": "./dist/client.js"
21
+ }
22
+ },
23
+ "dependencies": {
24
+ "@exwave-nexus/auth": "0.3.0",
25
+ "@exwave-nexus/auth-react": "0.3.0"
26
+ },
27
+ "peerDependencies": {
28
+ "next": ">=16.0.0",
29
+ "react": ">=19.0.0"
30
+ },
31
+ "publishConfig": {
32
+ "registry": "https://registry.npmjs.org",
33
+ "access": "public"
34
+ }
35
+ }