@atlasauth/nextjs 0.4.0 → 0.6.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/CHANGELOG.md +13 -0
- package/dist/access-token.js +19 -2
- package/dist/access-token.js.map +1 -1
- package/dist/compat.d.ts +220 -0
- package/dist/compat.js +352 -0
- package/dist/compat.js.map +1 -0
- package/dist/middleware.d.ts +35 -0
- package/dist/middleware.js +43 -0
- package/dist/middleware.js.map +1 -1
- package/dist/proxy.js +2 -0
- package/dist/proxy.js.map +1 -1
- package/package.json +6 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @atlasauth/nextjs changelog
|
|
2
2
|
|
|
3
|
+
## 0.6.0 — 2026-10-24
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- `betterAuthBridge` option: during a migration from Better Auth, turns each user's Better Auth session into an Atlas session on their next request (once), clears the old cookie, and sends users who still owe a second factor to sign-in. With `secretKey`, exchanges run server to server at a per-app limit suited to a bulk cutover.
|
|
8
|
+
|
|
9
|
+
## 0.5.0 — 2026-10-24
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- `@atlasauth/nextjs/compat`: server-side drop-in helpers for apps migrated from Auth.js (`getServerSessionCompat`, `nextAuthCompat`, server `signIn`/`signOut`), Auth0 (`getAuth0SessionCompat`, `withApiAuthRequiredCompat`, `withPageAuthRequiredCompat`, `handleAuthCompat`, `Auth0ClientCompat`), Supabase Auth (`getSupabaseUserCompat`, `getSupabaseSessionCompat`, `supabaseSignOutCompat`) and Better Auth (`createBetterAuthServerCompat`, `toNextJsHandlerCompat`, `getSessionCookieCompat`), and `createAtlasMiddleware()` built from the environment.
|
|
14
|
+
- `withAccessToken` sets the `DPoP-Nonce` response header (on success and refusal) when the verifier is given `dpopNonces`.
|
|
15
|
+
|
|
3
16
|
## 0.4.0 — 2026-10-23
|
|
4
17
|
|
|
5
18
|
### Added
|
package/dist/access-token.js
CHANGED
|
@@ -20,10 +20,27 @@ function withAccessToken(options, handler) {
|
|
|
20
20
|
if (!result.ok) {
|
|
21
21
|
return new Response(JSON.stringify(result.error ? { error: result.error, error_description: result.description } : { error: 'unauthorized' }), {
|
|
22
22
|
status: result.status,
|
|
23
|
-
headers: {
|
|
23
|
+
headers: {
|
|
24
|
+
'content-type': 'application/json',
|
|
25
|
+
'www-authenticate': result.wwwAuthenticate,
|
|
26
|
+
...(result.dpopNonce ? { 'dpop-nonce': result.dpopNonce } : {}),
|
|
27
|
+
},
|
|
24
28
|
});
|
|
25
29
|
}
|
|
26
|
-
|
|
30
|
+
const response = await handler(request, { claims: result.claims, subject: result.subject, clientId: result.clientId, scopes: result.scopes }, ctx);
|
|
31
|
+
if (!result.dpopNonce)
|
|
32
|
+
return response;
|
|
33
|
+
// RFC 9449 §8 — the server nonce on success too. Some responses (e.g. a
|
|
34
|
+
// fetched one) have immutable headers; those are re-wrapped.
|
|
35
|
+
try {
|
|
36
|
+
response.headers.set('dpop-nonce', result.dpopNonce);
|
|
37
|
+
return response;
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
const headers = new Headers(response.headers);
|
|
41
|
+
headers.set('dpop-nonce', result.dpopNonce);
|
|
42
|
+
return new Response(response.body, { status: response.status, statusText: response.statusText, headers });
|
|
43
|
+
}
|
|
27
44
|
};
|
|
28
45
|
}
|
|
29
46
|
//# sourceMappingURL=access-token.js.map
|
package/dist/access-token.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"access-token.js","sourceRoot":"","sources":["../src/access-token.ts"],"names":[],"mappings":";;;AA6BA,
|
|
1
|
+
{"version":3,"file":"access-token.js","sourceRoot":"","sources":["../src/access-token.ts"],"names":[],"mappings":";;;AA6BA,0CAuCC;AApED,gDAI4B;AAE5B,8CAO4B;AAN1B,oHAAA,yBAAyB,OAAA;AACzB,oHAAA,yBAAyB,OAAA;AACzB,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C,wEAAwE;QACxE,6DAA6D;QAC7D,IAAI,CAAC;YACH,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,YAAY,EAAE,MAAM,CAAC,SAAS,CAAC,CAAC;YACrD,OAAO,QAAQ,CAAC;QAClB,CAAC;QAAC,MAAM,CAAC;YACP,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;YAC9C,OAAO,CAAC,GAAG,CAAC,YAAY,EAAE,MAAM,CAAC,SAAS,CAAC,CAAC;YAC5C,OAAO,IAAI,QAAQ,CAAC,QAAQ,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,QAAQ,CAAC,MAAM,EAAE,UAAU,EAAE,QAAQ,CAAC,UAAU,EAAE,OAAO,EAAE,CAAC,CAAC;QAC5G,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
|
package/dist/compat.d.ts
ADDED
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@atlasauth/nextjs/compat` — server-side drop-in helpers for Next.js apps moving
|
|
3
|
+
* to Atlas from Auth.js (NextAuth), Auth0 (nextjs-auth0), Supabase Auth and Better
|
|
4
|
+
* Auth. `atlas migrate code --from <vendor>` rewrites imports onto these so the
|
|
5
|
+
* migrated code keeps the shapes it was written against and runs on day one; move
|
|
6
|
+
* call sites to `auth()` / `currentUser()` from `@atlasauth/nextjs/server` later.
|
|
7
|
+
*
|
|
8
|
+
* Everything here reads the verified Atlas session (cookies / Authorization
|
|
9
|
+
* header) exactly as `auth()` does. Profile fields beyond the id (email, name)
|
|
10
|
+
* come from the session claims, so they are present when the instance includes
|
|
11
|
+
* the profile claims in its session token.
|
|
12
|
+
*/
|
|
13
|
+
import { type AtlasMiddlewareOptions, type CurrentUser, type EdgeRequest } from './middleware';
|
|
14
|
+
import { type ServerAuth } from './server';
|
|
15
|
+
/** Routes the migrated middleware leaves public by default: the Atlas pages. */
|
|
16
|
+
export declare const COMPAT_PUBLIC_ROUTES: readonly string[];
|
|
17
|
+
type NextLikeRequest = EdgeRequest & {
|
|
18
|
+
url?: string;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* A ready-made Next.js `middleware` (14/15) built from the environment
|
|
22
|
+
* (`ATLAS_JWKS_URL`, `ATLAS_ISSUER`, `ATLAS_PUBLISHABLE_KEY`). Every route the
|
|
23
|
+
* middleware's `config.matcher` selects requires a session, except the Atlas
|
|
24
|
+
* sign-in and sign-up pages (and any `publicRoutes` you pass). The environment is
|
|
25
|
+
* read on the first request, not at import time.
|
|
26
|
+
*/
|
|
27
|
+
export declare function createAtlasMiddleware(options?: Partial<AtlasMiddlewareOptions>): (request: NextLikeRequest) => Promise<unknown>;
|
|
28
|
+
/** The session `getServerSession()` / v5 `auth()` resolve to. */
|
|
29
|
+
export interface NextAuthServerSession {
|
|
30
|
+
user: {
|
|
31
|
+
id: string;
|
|
32
|
+
name: string | null;
|
|
33
|
+
email: string | null;
|
|
34
|
+
image: string | null;
|
|
35
|
+
};
|
|
36
|
+
expires: string;
|
|
37
|
+
}
|
|
38
|
+
/** Pure projection, exported for tests and custom wiring. */
|
|
39
|
+
export declare function nextAuthServerSessionFrom(user: CurrentUser | null, state: Pick<ServerAuth, 'claims'>): NextAuthServerSession | null;
|
|
40
|
+
/**
|
|
41
|
+
* `getServerSession(authOptions)` (v4) and `auth()` (v5) on Atlas. Arguments are
|
|
42
|
+
* accepted and ignored, so existing call sites keep compiling.
|
|
43
|
+
*/
|
|
44
|
+
export declare function getServerSessionCompat(..._ignored: unknown[]): Promise<NextAuthServerSession | null>;
|
|
45
|
+
/** Server-side `signIn()` (a v5 server action): redirects to the Atlas sign-in page. */
|
|
46
|
+
export declare function nextAuthServerSignIn(_provider?: string, options?: {
|
|
47
|
+
redirectTo?: string;
|
|
48
|
+
callbackUrl?: string;
|
|
49
|
+
signInUrl?: string;
|
|
50
|
+
}): Promise<never>;
|
|
51
|
+
/** Server-side `signOut()` (a v5 server action): revokes the session, then redirects. */
|
|
52
|
+
export declare function nextAuthServerSignOut(options?: {
|
|
53
|
+
redirectTo?: string;
|
|
54
|
+
redirect?: boolean;
|
|
55
|
+
}): Promise<void>;
|
|
56
|
+
/** `handlers` from v5 `NextAuth()`: the old `/api/auth/*` route now answers 404. */
|
|
57
|
+
export declare const nextAuthHandlersCompat: {
|
|
58
|
+
GET: () => Promise<Response>;
|
|
59
|
+
POST: () => Promise<Response>;
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* `NextAuth(config)` on Atlas, for both shapes it is used in:
|
|
63
|
+
*
|
|
64
|
+
* - v5 `auth.ts`: `export const { handlers, auth, signIn, signOut } = NextAuth(config)`
|
|
65
|
+
* — the destructured members are the compat helpers above, so every
|
|
66
|
+
* `import { auth } from '@/auth'` keeps working;
|
|
67
|
+
* - v4 route: `const handler = NextAuth(authOptions); export { handler as GET, handler as POST }`
|
|
68
|
+
* — the returned function answers the old `/api/auth/*` route with 404.
|
|
69
|
+
*
|
|
70
|
+
* The config is accepted and ignored: configure providers in the Atlas dashboard
|
|
71
|
+
* and port `callbacks` to Atlas Actions, then delete it.
|
|
72
|
+
*/
|
|
73
|
+
export declare function nextAuthCompat(..._ignored: unknown[]): (() => Promise<Response>) & {
|
|
74
|
+
handlers: {
|
|
75
|
+
GET: () => Promise<Response>;
|
|
76
|
+
POST: () => Promise<Response>;
|
|
77
|
+
};
|
|
78
|
+
auth: typeof getServerSessionCompat;
|
|
79
|
+
signIn: typeof nextAuthServerSignIn;
|
|
80
|
+
signOut: typeof nextAuthServerSignOut;
|
|
81
|
+
/** v5 `unstable_update`: Atlas sessions pick up profile changes on their own refresh. */
|
|
82
|
+
unstable_update: (..._args: unknown[]) => Promise<NextAuthServerSession | null>;
|
|
83
|
+
};
|
|
84
|
+
/** The OIDC profile nextjs-auth0 puts on `session.user`. */
|
|
85
|
+
export interface Auth0ServerUser {
|
|
86
|
+
sub: string;
|
|
87
|
+
email?: string;
|
|
88
|
+
name?: string;
|
|
89
|
+
given_name?: string;
|
|
90
|
+
family_name?: string;
|
|
91
|
+
org_id?: string;
|
|
92
|
+
[claim: string]: unknown;
|
|
93
|
+
}
|
|
94
|
+
export interface Auth0ServerSession {
|
|
95
|
+
user: Auth0ServerUser;
|
|
96
|
+
/** Unix seconds the Atlas session token expires at. */
|
|
97
|
+
expiresAt?: number;
|
|
98
|
+
}
|
|
99
|
+
export declare function auth0SessionFrom(user: CurrentUser | null, state: Pick<ServerAuth, 'claims'>): Auth0ServerSession | null;
|
|
100
|
+
/** `getSession()` from nextjs-auth0 (v3, App Router) on Atlas. */
|
|
101
|
+
export declare function getAuth0SessionCompat(..._ignored: unknown[]): Promise<Auth0ServerSession | null>;
|
|
102
|
+
/**
|
|
103
|
+
* `withApiAuthRequired(handler)`: an App Router route handler (or a Pages API
|
|
104
|
+
* route, detected by its `res`) answers 401 unless a user is signed in.
|
|
105
|
+
*/
|
|
106
|
+
export declare function withApiAuthRequiredCompat<A extends unknown[], R>(handler: (...args: A) => R | Promise<R>): (...args: A) => Promise<R | Response | undefined>;
|
|
107
|
+
/**
|
|
108
|
+
* `withPageAuthRequired(Page, { returnTo })` for an App Router server component:
|
|
109
|
+
* renders the page for a signed-in user, else redirects to the sign-in page.
|
|
110
|
+
*/
|
|
111
|
+
export declare function withPageAuthRequiredCompat<P extends object, R>(page: (props: P) => R | Promise<R>, options?: {
|
|
112
|
+
returnTo?: string | ((props: P) => string | Promise<string>);
|
|
113
|
+
signInUrl?: string;
|
|
114
|
+
}): (props: P) => Promise<R>;
|
|
115
|
+
/** `handleAuth()` from nextjs-auth0 v3: the old `/api/auth/[auth0]` route now answers 404. */
|
|
116
|
+
export declare function handleAuthCompat(..._ignored: unknown[]): () => Promise<Response>;
|
|
117
|
+
/** `withMiddlewareAuthRequired()` from `@auth0/nextjs-auth0/edge`. */
|
|
118
|
+
export declare function withMiddlewareAuthRequiredCompat(..._ignored: unknown[]): (request: NextLikeRequest) => Promise<unknown>;
|
|
119
|
+
/**
|
|
120
|
+
* `new Auth0Client()` from `@auth0/nextjs-auth0/server` (v4) on Atlas:
|
|
121
|
+
* `getSession()`, `middleware(request)` and `getAccessToken()`.
|
|
122
|
+
*/
|
|
123
|
+
export declare class Auth0ClientCompat {
|
|
124
|
+
private readonly mw;
|
|
125
|
+
constructor(_options?: Record<string, unknown>);
|
|
126
|
+
getSession(..._ignored: unknown[]): Promise<Auth0ServerSession | null>;
|
|
127
|
+
middleware(request: NextLikeRequest): Promise<unknown>;
|
|
128
|
+
/**
|
|
129
|
+
* Atlas session tokens are verified by your own backend with the instance JWKS
|
|
130
|
+
* (`AtlasBackend` from `@atlasauth/backend`); there is no separate access token
|
|
131
|
+
* to fetch server-side. Read the session token from the request instead.
|
|
132
|
+
*/
|
|
133
|
+
getAccessToken(): Promise<never>;
|
|
134
|
+
}
|
|
135
|
+
/** The `User` object `supabase.auth.getUser()` resolves to (the fields apps read). */
|
|
136
|
+
export interface SupabaseServerUser {
|
|
137
|
+
id: string;
|
|
138
|
+
aud: 'authenticated';
|
|
139
|
+
role: 'authenticated';
|
|
140
|
+
email?: string;
|
|
141
|
+
user_metadata: Record<string, unknown>;
|
|
142
|
+
app_metadata: Record<string, unknown>;
|
|
143
|
+
}
|
|
144
|
+
export declare function supabaseServerUserFrom(user: CurrentUser | null): SupabaseServerUser | null;
|
|
145
|
+
/** `supabase.auth.getUser()` in a server component, route handler or server action. */
|
|
146
|
+
export declare function getSupabaseUserCompat(): Promise<{
|
|
147
|
+
data: {
|
|
148
|
+
user: SupabaseServerUser | null;
|
|
149
|
+
};
|
|
150
|
+
error: null;
|
|
151
|
+
}>;
|
|
152
|
+
/** `supabase.auth.getSession()` server-side. There is no raw token here; use getUser(). */
|
|
153
|
+
export declare function getSupabaseSessionCompat(): Promise<{
|
|
154
|
+
data: {
|
|
155
|
+
session: {
|
|
156
|
+
user: SupabaseServerUser;
|
|
157
|
+
expires_at?: number;
|
|
158
|
+
} | null;
|
|
159
|
+
};
|
|
160
|
+
error: null;
|
|
161
|
+
}>;
|
|
162
|
+
/** `supabase.auth.signOut()` server-side: revokes the active session. */
|
|
163
|
+
export declare function supabaseSignOutCompat(): Promise<{
|
|
164
|
+
error: null;
|
|
165
|
+
}>;
|
|
166
|
+
export interface BetterAuthServerSession {
|
|
167
|
+
user: {
|
|
168
|
+
id: string;
|
|
169
|
+
email: string | null;
|
|
170
|
+
name: string | null;
|
|
171
|
+
image: string | null;
|
|
172
|
+
emailVerified: boolean;
|
|
173
|
+
};
|
|
174
|
+
session: {
|
|
175
|
+
id: string;
|
|
176
|
+
userId: string;
|
|
177
|
+
expiresAt: Date;
|
|
178
|
+
activeOrganizationId: string | null;
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
export declare function betterAuthServerSessionFrom(user: CurrentUser | null, state: Pick<ServerAuth, 'claims' | 'sessionId'>): BetterAuthServerSession | null;
|
|
182
|
+
/**
|
|
183
|
+
* `betterAuth({...})` on Atlas: the returned object keeps `auth.api.getSession()`,
|
|
184
|
+
* `auth.api.signOut()` and `auth.handler`, so `lib/auth.ts` importers keep working.
|
|
185
|
+
* The options are accepted and ignored: configure sign-in methods, providers and
|
|
186
|
+
* plugins in the Atlas dashboard instead.
|
|
187
|
+
*/
|
|
188
|
+
export declare function createBetterAuthServerCompat(_options?: Record<string, unknown>): {
|
|
189
|
+
/** Type-only, like Better Auth's `typeof auth.$Infer.Session`. */
|
|
190
|
+
$Infer: {
|
|
191
|
+
Session: BetterAuthServerSession;
|
|
192
|
+
};
|
|
193
|
+
api: {
|
|
194
|
+
getSession(_input?: {
|
|
195
|
+
headers?: unknown;
|
|
196
|
+
}): Promise<BetterAuthServerSession | null>;
|
|
197
|
+
signOut(_input?: {
|
|
198
|
+
headers?: unknown;
|
|
199
|
+
}): Promise<{
|
|
200
|
+
success: boolean;
|
|
201
|
+
}>;
|
|
202
|
+
};
|
|
203
|
+
handler: () => Promise<Response>;
|
|
204
|
+
};
|
|
205
|
+
/** `toNextJsHandler(auth)` from `better-auth/next-js`: the old route now answers 404. */
|
|
206
|
+
export declare function toNextJsHandlerCompat(..._ignored: unknown[]): {
|
|
207
|
+
GET: () => Promise<Response>;
|
|
208
|
+
POST: () => Promise<Response>;
|
|
209
|
+
PATCH: () => Promise<Response>;
|
|
210
|
+
PUT: () => Promise<Response>;
|
|
211
|
+
DELETE: () => Promise<Response>;
|
|
212
|
+
};
|
|
213
|
+
/**
|
|
214
|
+
* `getSessionCookie(request)` from `better-auth/cookies`: a cheap, unverified
|
|
215
|
+
* "probably signed in" check for middleware. Returns a non-empty marker when the
|
|
216
|
+
* browser carries an Atlas session hint, else null. Never proof of identity; a
|
|
217
|
+
* page that needs the user calls `auth()`.
|
|
218
|
+
*/
|
|
219
|
+
export declare function getSessionCookieCompat(request: EdgeRequest, ..._ignored: unknown[]): string | null;
|
|
220
|
+
export {};
|
package/dist/compat.js
ADDED
|
@@ -0,0 +1,352 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.Auth0ClientCompat = exports.nextAuthHandlersCompat = exports.COMPAT_PUBLIC_ROUTES = void 0;
|
|
37
|
+
exports.createAtlasMiddleware = createAtlasMiddleware;
|
|
38
|
+
exports.nextAuthServerSessionFrom = nextAuthServerSessionFrom;
|
|
39
|
+
exports.getServerSessionCompat = getServerSessionCompat;
|
|
40
|
+
exports.nextAuthServerSignIn = nextAuthServerSignIn;
|
|
41
|
+
exports.nextAuthServerSignOut = nextAuthServerSignOut;
|
|
42
|
+
exports.nextAuthCompat = nextAuthCompat;
|
|
43
|
+
exports.auth0SessionFrom = auth0SessionFrom;
|
|
44
|
+
exports.getAuth0SessionCompat = getAuth0SessionCompat;
|
|
45
|
+
exports.withApiAuthRequiredCompat = withApiAuthRequiredCompat;
|
|
46
|
+
exports.withPageAuthRequiredCompat = withPageAuthRequiredCompat;
|
|
47
|
+
exports.handleAuthCompat = handleAuthCompat;
|
|
48
|
+
exports.withMiddlewareAuthRequiredCompat = withMiddlewareAuthRequiredCompat;
|
|
49
|
+
exports.supabaseServerUserFrom = supabaseServerUserFrom;
|
|
50
|
+
exports.getSupabaseUserCompat = getSupabaseUserCompat;
|
|
51
|
+
exports.getSupabaseSessionCompat = getSupabaseSessionCompat;
|
|
52
|
+
exports.supabaseSignOutCompat = supabaseSignOutCompat;
|
|
53
|
+
exports.betterAuthServerSessionFrom = betterAuthServerSessionFrom;
|
|
54
|
+
exports.createBetterAuthServerCompat = createBetterAuthServerCompat;
|
|
55
|
+
exports.toNextJsHandlerCompat = toNextJsHandlerCompat;
|
|
56
|
+
exports.getSessionCookieCompat = getSessionCookieCompat;
|
|
57
|
+
/**
|
|
58
|
+
* `@atlasauth/nextjs/compat` — server-side drop-in helpers for Next.js apps moving
|
|
59
|
+
* to Atlas from Auth.js (NextAuth), Auth0 (nextjs-auth0), Supabase Auth and Better
|
|
60
|
+
* Auth. `atlas migrate code --from <vendor>` rewrites imports onto these so the
|
|
61
|
+
* migrated code keeps the shapes it was written against and runs on day one; move
|
|
62
|
+
* call sites to `auth()` / `currentUser()` from `@atlasauth/nextjs/server` later.
|
|
63
|
+
*
|
|
64
|
+
* Everything here reads the verified Atlas session (cookies / Authorization
|
|
65
|
+
* header) exactly as `auth()` does. Profile fields beyond the id (email, name)
|
|
66
|
+
* come from the session claims, so they are present when the instance includes
|
|
67
|
+
* the profile claims in its session token.
|
|
68
|
+
*/
|
|
69
|
+
const middleware_1 = require("./middleware");
|
|
70
|
+
const matcher_1 = require("./matcher");
|
|
71
|
+
const server_1 = require("./server");
|
|
72
|
+
/** Routes the migrated middleware leaves public by default: the Atlas pages. */
|
|
73
|
+
exports.COMPAT_PUBLIC_ROUTES = ['/sign-in(.*)', '/sign-up(.*)'];
|
|
74
|
+
/**
|
|
75
|
+
* A ready-made Next.js `middleware` (14/15) built from the environment
|
|
76
|
+
* (`ATLAS_JWKS_URL`, `ATLAS_ISSUER`, `ATLAS_PUBLISHABLE_KEY`). Every route the
|
|
77
|
+
* middleware's `config.matcher` selects requires a session, except the Atlas
|
|
78
|
+
* sign-in and sign-up pages (and any `publicRoutes` you pass). The environment is
|
|
79
|
+
* read on the first request, not at import time.
|
|
80
|
+
*/
|
|
81
|
+
function createAtlasMiddleware(options = {}) {
|
|
82
|
+
let middleware;
|
|
83
|
+
return async (request) => {
|
|
84
|
+
if (!middleware) {
|
|
85
|
+
const publicRoutes = [...exports.COMPAT_PUBLIC_ROUTES, ...(options.publicRoutes ?? [])];
|
|
86
|
+
middleware = (0, middleware_1.atlasMiddleware)({ ...(0, server_1.configFromEnv)(), ...options, publicRoutes });
|
|
87
|
+
}
|
|
88
|
+
const { NextResponse } = await Promise.resolve().then(() => __importStar(require('next/server')));
|
|
89
|
+
return middleware(request, NextResponse);
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
function withRedirect(url, redirectUrl) {
|
|
93
|
+
if (!redirectUrl)
|
|
94
|
+
return url;
|
|
95
|
+
return `${url}${url.includes('?') ? '&' : '?'}redirect_url=${encodeURIComponent(redirectUrl)}`;
|
|
96
|
+
}
|
|
97
|
+
async function nextRedirect(url) {
|
|
98
|
+
const { redirect } = await Promise.resolve().then(() => __importStar(require('next/navigation')));
|
|
99
|
+
return redirect(url);
|
|
100
|
+
}
|
|
101
|
+
function expiresIso(state) {
|
|
102
|
+
const exp = typeof state.claims?.exp === 'number' ? state.claims.exp * 1000 : Date.now() + 60_000;
|
|
103
|
+
return new Date(exp).toISOString();
|
|
104
|
+
}
|
|
105
|
+
function fullName(user) {
|
|
106
|
+
return user.name ?? ([user.firstName, user.lastName].filter(Boolean).join(' ') || null);
|
|
107
|
+
}
|
|
108
|
+
/** Revoke the active session server-side (needs `ATLAS_SECRET_KEY`). */
|
|
109
|
+
async function revokeActiveSession() {
|
|
110
|
+
const state = await (0, server_1.auth)();
|
|
111
|
+
if (state.sessionId)
|
|
112
|
+
await (0, server_1.atlasClient)().sessions.revoke(state.sessionId);
|
|
113
|
+
}
|
|
114
|
+
function notFoundHandler(vendor) {
|
|
115
|
+
return async () => new Response(JSON.stringify({
|
|
116
|
+
errors: [
|
|
117
|
+
{
|
|
118
|
+
code: 'MIGRATED_TO_ATLAS',
|
|
119
|
+
message: `This ${vendor} auth route is no longer used: sign-in, sign-out and callbacks are handled by Atlas. Delete this route.`,
|
|
120
|
+
},
|
|
121
|
+
],
|
|
122
|
+
}), { status: 404, headers: { 'content-type': 'application/json' } });
|
|
123
|
+
}
|
|
124
|
+
/** Pure projection, exported for tests and custom wiring. */
|
|
125
|
+
function nextAuthServerSessionFrom(user, state) {
|
|
126
|
+
if (!user)
|
|
127
|
+
return null;
|
|
128
|
+
return { user: { id: user.id, name: fullName(user), email: user.email, image: null }, expires: expiresIso(state) };
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* `getServerSession(authOptions)` (v4) and `auth()` (v5) on Atlas. Arguments are
|
|
132
|
+
* accepted and ignored, so existing call sites keep compiling.
|
|
133
|
+
*/
|
|
134
|
+
async function getServerSessionCompat(..._ignored) {
|
|
135
|
+
const [user, state] = await Promise.all([(0, server_1.currentUser)(), (0, server_1.auth)()]);
|
|
136
|
+
return nextAuthServerSessionFrom(user, state);
|
|
137
|
+
}
|
|
138
|
+
/** Server-side `signIn()` (a v5 server action): redirects to the Atlas sign-in page. */
|
|
139
|
+
async function nextAuthServerSignIn(_provider, options = {}) {
|
|
140
|
+
return nextRedirect(withRedirect(options.signInUrl ?? matcher_1.DEFAULT_SIGN_IN_URL, options.redirectTo ?? options.callbackUrl));
|
|
141
|
+
}
|
|
142
|
+
/** Server-side `signOut()` (a v5 server action): revokes the session, then redirects. */
|
|
143
|
+
async function nextAuthServerSignOut(options = {}) {
|
|
144
|
+
await revokeActiveSession();
|
|
145
|
+
if (options.redirect !== false)
|
|
146
|
+
await nextRedirect(options.redirectTo ?? '/');
|
|
147
|
+
}
|
|
148
|
+
/** `handlers` from v5 `NextAuth()`: the old `/api/auth/*` route now answers 404. */
|
|
149
|
+
exports.nextAuthHandlersCompat = {
|
|
150
|
+
GET: notFoundHandler('Auth.js'),
|
|
151
|
+
POST: notFoundHandler('Auth.js'),
|
|
152
|
+
};
|
|
153
|
+
/**
|
|
154
|
+
* `NextAuth(config)` on Atlas, for both shapes it is used in:
|
|
155
|
+
*
|
|
156
|
+
* - v5 `auth.ts`: `export const { handlers, auth, signIn, signOut } = NextAuth(config)`
|
|
157
|
+
* — the destructured members are the compat helpers above, so every
|
|
158
|
+
* `import { auth } from '@/auth'` keeps working;
|
|
159
|
+
* - v4 route: `const handler = NextAuth(authOptions); export { handler as GET, handler as POST }`
|
|
160
|
+
* — the returned function answers the old `/api/auth/*` route with 404.
|
|
161
|
+
*
|
|
162
|
+
* The config is accepted and ignored: configure providers in the Atlas dashboard
|
|
163
|
+
* and port `callbacks` to Atlas Actions, then delete it.
|
|
164
|
+
*/
|
|
165
|
+
function nextAuthCompat(..._ignored) {
|
|
166
|
+
const handler = notFoundHandler('Auth.js');
|
|
167
|
+
return Object.assign(handler, {
|
|
168
|
+
handlers: exports.nextAuthHandlersCompat,
|
|
169
|
+
auth: getServerSessionCompat,
|
|
170
|
+
signIn: nextAuthServerSignIn,
|
|
171
|
+
signOut: nextAuthServerSignOut,
|
|
172
|
+
/** v5 `unstable_update`: Atlas sessions pick up profile changes on their own refresh. */
|
|
173
|
+
unstable_update: async (..._args) => getServerSessionCompat(),
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
function auth0SessionFrom(user, state) {
|
|
177
|
+
if (!user)
|
|
178
|
+
return null;
|
|
179
|
+
const out = { sub: user.id };
|
|
180
|
+
const name = fullName(user);
|
|
181
|
+
if (user.email)
|
|
182
|
+
out.email = user.email;
|
|
183
|
+
if (name)
|
|
184
|
+
out.name = name;
|
|
185
|
+
if (user.firstName)
|
|
186
|
+
out.given_name = user.firstName;
|
|
187
|
+
if (user.lastName)
|
|
188
|
+
out.family_name = user.lastName;
|
|
189
|
+
if (user.orgId)
|
|
190
|
+
out.org_id = user.orgId;
|
|
191
|
+
return { user: out, ...(typeof state.claims?.exp === 'number' ? { expiresAt: state.claims.exp } : {}) };
|
|
192
|
+
}
|
|
193
|
+
/** `getSession()` from nextjs-auth0 (v3, App Router) on Atlas. */
|
|
194
|
+
async function getAuth0SessionCompat(..._ignored) {
|
|
195
|
+
const [user, state] = await Promise.all([(0, server_1.currentUser)(), (0, server_1.auth)()]);
|
|
196
|
+
return auth0SessionFrom(user, state);
|
|
197
|
+
}
|
|
198
|
+
const UNAUTHORIZED = { error: 'not_authenticated', description: 'The user does not have an active session or is not authenticated' };
|
|
199
|
+
/**
|
|
200
|
+
* `withApiAuthRequired(handler)`: an App Router route handler (or a Pages API
|
|
201
|
+
* route, detected by its `res`) answers 401 unless a user is signed in.
|
|
202
|
+
*/
|
|
203
|
+
function withApiAuthRequiredCompat(handler) {
|
|
204
|
+
return async (...args) => {
|
|
205
|
+
const state = await (0, server_1.auth)();
|
|
206
|
+
if (state.userId)
|
|
207
|
+
return handler(...args);
|
|
208
|
+
const res = args[1];
|
|
209
|
+
if (res && typeof res.status === 'function') {
|
|
210
|
+
res.status(401).json(UNAUTHORIZED);
|
|
211
|
+
return undefined;
|
|
212
|
+
}
|
|
213
|
+
return new Response(JSON.stringify(UNAUTHORIZED), { status: 401, headers: { 'content-type': 'application/json' } });
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* `withPageAuthRequired(Page, { returnTo })` for an App Router server component:
|
|
218
|
+
* renders the page for a signed-in user, else redirects to the sign-in page.
|
|
219
|
+
*/
|
|
220
|
+
function withPageAuthRequiredCompat(page, options = {}) {
|
|
221
|
+
return async (props) => {
|
|
222
|
+
const state = await (0, server_1.auth)();
|
|
223
|
+
if (state.userId)
|
|
224
|
+
return page(props);
|
|
225
|
+
const returnTo = typeof options.returnTo === 'function' ? await options.returnTo(props) : options.returnTo;
|
|
226
|
+
return nextRedirect(withRedirect(options.signInUrl ?? matcher_1.DEFAULT_SIGN_IN_URL, returnTo));
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
/** `handleAuth()` from nextjs-auth0 v3: the old `/api/auth/[auth0]` route now answers 404. */
|
|
230
|
+
function handleAuthCompat(..._ignored) {
|
|
231
|
+
return notFoundHandler('Auth0');
|
|
232
|
+
}
|
|
233
|
+
/** `withMiddlewareAuthRequired()` from `@auth0/nextjs-auth0/edge`. */
|
|
234
|
+
function withMiddlewareAuthRequiredCompat(..._ignored) {
|
|
235
|
+
return createAtlasMiddleware();
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* `new Auth0Client()` from `@auth0/nextjs-auth0/server` (v4) on Atlas:
|
|
239
|
+
* `getSession()`, `middleware(request)` and `getAccessToken()`.
|
|
240
|
+
*/
|
|
241
|
+
class Auth0ClientCompat {
|
|
242
|
+
mw = createAtlasMiddleware();
|
|
243
|
+
constructor(_options = {}) { }
|
|
244
|
+
getSession(..._ignored) {
|
|
245
|
+
return getAuth0SessionCompat();
|
|
246
|
+
}
|
|
247
|
+
middleware(request) {
|
|
248
|
+
return this.mw(request);
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Atlas session tokens are verified by your own backend with the instance JWKS
|
|
252
|
+
* (`AtlasBackend` from `@atlasauth/backend`); there is no separate access token
|
|
253
|
+
* to fetch server-side. Read the session token from the request instead.
|
|
254
|
+
*/
|
|
255
|
+
async getAccessToken() {
|
|
256
|
+
throw new Error('Auth0ClientCompat.getAccessToken(): Atlas has no server-side access-token exchange. Send the session token (getToken() in the browser) to your API and verify it with @atlasauth/backend.');
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
exports.Auth0ClientCompat = Auth0ClientCompat;
|
|
260
|
+
function supabaseServerUserFrom(user) {
|
|
261
|
+
if (!user)
|
|
262
|
+
return null;
|
|
263
|
+
const name = fullName(user);
|
|
264
|
+
return {
|
|
265
|
+
id: user.id,
|
|
266
|
+
aud: 'authenticated',
|
|
267
|
+
role: 'authenticated',
|
|
268
|
+
...(user.email ? { email: user.email } : {}),
|
|
269
|
+
user_metadata: name ? { full_name: name, name } : {},
|
|
270
|
+
app_metadata: user.orgId ? { org_id: user.orgId, org_role: user.orgRole } : {},
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
/** `supabase.auth.getUser()` in a server component, route handler or server action. */
|
|
274
|
+
async function getSupabaseUserCompat() {
|
|
275
|
+
return { data: { user: supabaseServerUserFrom(await (0, server_1.currentUser)()) }, error: null };
|
|
276
|
+
}
|
|
277
|
+
/** `supabase.auth.getSession()` server-side. There is no raw token here; use getUser(). */
|
|
278
|
+
async function getSupabaseSessionCompat() {
|
|
279
|
+
const [user, state] = await Promise.all([(0, server_1.currentUser)(), (0, server_1.auth)()]);
|
|
280
|
+
const mapped = supabaseServerUserFrom(user);
|
|
281
|
+
return {
|
|
282
|
+
data: {
|
|
283
|
+
session: mapped
|
|
284
|
+
? { user: mapped, ...(typeof state.claims?.exp === 'number' ? { expires_at: state.claims.exp } : {}) }
|
|
285
|
+
: null,
|
|
286
|
+
},
|
|
287
|
+
error: null,
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
/** `supabase.auth.signOut()` server-side: revokes the active session. */
|
|
291
|
+
async function supabaseSignOutCompat() {
|
|
292
|
+
await revokeActiveSession();
|
|
293
|
+
return { error: null };
|
|
294
|
+
}
|
|
295
|
+
function betterAuthServerSessionFrom(user, state) {
|
|
296
|
+
if (!user)
|
|
297
|
+
return null;
|
|
298
|
+
return {
|
|
299
|
+
user: {
|
|
300
|
+
id: user.id,
|
|
301
|
+
email: user.email,
|
|
302
|
+
name: fullName(user),
|
|
303
|
+
image: null,
|
|
304
|
+
// Present when the instance includes `email_verified` in its session claims.
|
|
305
|
+
emailVerified: state.claims?.email_verified === true,
|
|
306
|
+
},
|
|
307
|
+
session: {
|
|
308
|
+
id: state.sessionId ?? '',
|
|
309
|
+
userId: user.id,
|
|
310
|
+
expiresAt: new Date(expiresIso(state)),
|
|
311
|
+
activeOrganizationId: user.orgId,
|
|
312
|
+
},
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* `betterAuth({...})` on Atlas: the returned object keeps `auth.api.getSession()`,
|
|
317
|
+
* `auth.api.signOut()` and `auth.handler`, so `lib/auth.ts` importers keep working.
|
|
318
|
+
* The options are accepted and ignored: configure sign-in methods, providers and
|
|
319
|
+
* plugins in the Atlas dashboard instead.
|
|
320
|
+
*/
|
|
321
|
+
function createBetterAuthServerCompat(_options = {}) {
|
|
322
|
+
return {
|
|
323
|
+
/** Type-only, like Better Auth's `typeof auth.$Infer.Session`. */
|
|
324
|
+
$Infer: {},
|
|
325
|
+
api: {
|
|
326
|
+
async getSession(_input) {
|
|
327
|
+
const [user, state] = await Promise.all([(0, server_1.currentUser)(), (0, server_1.auth)()]);
|
|
328
|
+
return betterAuthServerSessionFrom(user, state);
|
|
329
|
+
},
|
|
330
|
+
async signOut(_input) {
|
|
331
|
+
await revokeActiveSession();
|
|
332
|
+
return { success: true };
|
|
333
|
+
},
|
|
334
|
+
},
|
|
335
|
+
handler: notFoundHandler('Better Auth'),
|
|
336
|
+
};
|
|
337
|
+
}
|
|
338
|
+
/** `toNextJsHandler(auth)` from `better-auth/next-js`: the old route now answers 404. */
|
|
339
|
+
function toNextJsHandlerCompat(..._ignored) {
|
|
340
|
+
const handler = notFoundHandler('Better Auth');
|
|
341
|
+
return { GET: handler, POST: handler, PATCH: handler, PUT: handler, DELETE: handler };
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* `getSessionCookie(request)` from `better-auth/cookies`: a cheap, unverified
|
|
345
|
+
* "probably signed in" check for middleware. Returns a non-empty marker when the
|
|
346
|
+
* browser carries an Atlas session hint, else null. Never proof of identity; a
|
|
347
|
+
* page that needs the user calls `auth()`.
|
|
348
|
+
*/
|
|
349
|
+
function getSessionCookieCompat(request, ..._ignored) {
|
|
350
|
+
return (0, middleware_1.hasSignedInHint)(request) ? 'atlas' : null;
|
|
351
|
+
}
|
|
352
|
+
//# sourceMappingURL=compat.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compat.js","sourceRoot":"","sources":["../src/compat.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA,sDAYC;AAmDD,8DAMC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AAmB;IAC1D,MAAM,OAAO,GAAG,eAAe,CAAC,aAAa,CAAC,CAAC;IAC/C,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;AACxF,CAAC;AAED;;;;;GAKG;AACH,SAAgB,sBAAsB,CAAC,OAAoB,EAAE,GAAG,QAAmB;IACjF,OAAO,IAAA,4BAAe,EAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC;AACnD,CAAC"}
|
package/dist/middleware.d.ts
CHANGED
|
@@ -31,6 +31,38 @@ export interface AtlasMiddlewareOptions extends MiddlewareConfig {
|
|
|
31
31
|
/** Origin of the Atlas Frontend API (where `/v1/client/handshake` lives).
|
|
32
32
|
* Defaults to the origin of `jwksUrl`. */
|
|
33
33
|
fapiOrigin?: string;
|
|
34
|
+
/**
|
|
35
|
+
* Moving from Better Auth: a visitor who still carries a Better Auth session
|
|
36
|
+
* cookie (and no Atlas session) is exchanged ONCE for an Atlas session — read
|
|
37
|
+
* server-side (the cookie is HttpOnly), Atlas cookies set, Better Auth cookies
|
|
38
|
+
* cleared — so the switch signs nobody out. Runs on page navigations (GET /
|
|
39
|
+
* HEAD), which re-enter on the same URL with the new session. A user who still
|
|
40
|
+
* owes a second factor is sent to `signInUrl` (default: the same URL) carrying
|
|
41
|
+
* the sign-in attempt, which the Atlas components continue. Requires
|
|
42
|
+
* `publishableKey` and the bridge being enabled for the instance.
|
|
43
|
+
*/
|
|
44
|
+
betterAuthBridge?: boolean | BetterAuthBridgeConfig;
|
|
45
|
+
}
|
|
46
|
+
/** Options for {@link AtlasMiddlewareOptions.betterAuthBridge}. */
|
|
47
|
+
export interface BetterAuthBridgeConfig {
|
|
48
|
+
/** Better Auth's `advanced.cookiePrefix` (default `better-auth`). */
|
|
49
|
+
cookiePrefix?: string;
|
|
50
|
+
/** The session cookie's full name, when the old app overrode it. */
|
|
51
|
+
cookieName?: string;
|
|
52
|
+
/** The domain the Better Auth cookies were set on (its cross-subdomain domain), so they clear. */
|
|
53
|
+
cookieDomain?: string;
|
|
54
|
+
/** Where a user who still owes a second factor finishes signing in. Default: the requested URL. */
|
|
55
|
+
signInUrl?: string;
|
|
56
|
+
/**
|
|
57
|
+
* The instance secret key (e.g. `process.env.ATLAS_SECRET_KEY`). Recommended:
|
|
58
|
+
* the exchange then goes through the Backend API, limited per instance with a
|
|
59
|
+
* ceiling sized for a bulk cutover, instead of the per-IP Frontend API limit
|
|
60
|
+
* your server would share across every user. The user's IP (`x-forwarded-for`
|
|
61
|
+
* as your platform sets it) and user agent are forwarded.
|
|
62
|
+
*/
|
|
63
|
+
secretKey?: string;
|
|
64
|
+
/** Backend API origin for the secret-key path. Default `https://api.atlasauth.net`. */
|
|
65
|
+
bapiBaseUrl?: string;
|
|
34
66
|
}
|
|
35
67
|
/** Minimal shapes, so this package does not depend on Next.js at build time. */
|
|
36
68
|
export interface EdgeRequest {
|
|
@@ -38,6 +70,8 @@ export interface EdgeRequest {
|
|
|
38
70
|
pathname: string;
|
|
39
71
|
search?: string;
|
|
40
72
|
};
|
|
73
|
+
/** The HTTP method (NextRequest has it). Absent is treated as GET. */
|
|
74
|
+
method?: string;
|
|
41
75
|
headers: {
|
|
42
76
|
get(name: string): string | null;
|
|
43
77
|
};
|
|
@@ -101,6 +135,7 @@ export interface AtlasCookie {
|
|
|
101
135
|
value: string;
|
|
102
136
|
options: {
|
|
103
137
|
path?: string;
|
|
138
|
+
domain?: string;
|
|
104
139
|
httpOnly?: boolean;
|
|
105
140
|
sameSite?: 'lax' | 'strict' | 'none';
|
|
106
141
|
secure?: boolean;
|
package/dist/middleware.js
CHANGED
|
@@ -92,7 +92,50 @@ function createAtlasDecider(options) {
|
|
|
92
92
|
authorizedParties: options.authorizedParties,
|
|
93
93
|
fetchImpl: options.fetchImpl,
|
|
94
94
|
});
|
|
95
|
+
const bridgeConfig = options.betterAuthBridge
|
|
96
|
+
? options.betterAuthBridge === true
|
|
97
|
+
? {}
|
|
98
|
+
: options.betterAuthBridge
|
|
99
|
+
: null;
|
|
100
|
+
if (bridgeConfig && !options.publishableKey) {
|
|
101
|
+
throw new Error('atlasMiddleware: `betterAuthBridge` needs `publishableKey`.');
|
|
102
|
+
}
|
|
103
|
+
const betterAuthBridge = bridgeConfig
|
|
104
|
+
? (0, backend_1.createBetterAuthBridge)({
|
|
105
|
+
fapiOrigin: options.fapiOrigin ?? new URL(options.jwksUrl).origin,
|
|
106
|
+
publishableKey: options.publishableKey,
|
|
107
|
+
cookiePrefix: bridgeConfig.cookiePrefix,
|
|
108
|
+
cookieName: bridgeConfig.cookieName,
|
|
109
|
+
betterAuthCookieDomain: bridgeConfig.cookieDomain,
|
|
110
|
+
secretKey: bridgeConfig.secretKey,
|
|
111
|
+
bapiBaseUrl: bridgeConfig.bapiBaseUrl,
|
|
112
|
+
fetchImpl: options.fetchImpl,
|
|
113
|
+
})
|
|
114
|
+
: null;
|
|
95
115
|
return async function decide(request) {
|
|
116
|
+
/**
|
|
117
|
+
* Better Auth session bridge. Only on a page navigation: the exchange is a
|
|
118
|
+
* one-time server-to-server call, and re-entering on the same URL is what
|
|
119
|
+
* lets every downstream reader (auth(), server components) see the new
|
|
120
|
+
* session. A non-GET request is left alone — the next navigation exchanges.
|
|
121
|
+
* A Better Auth session Atlas will never accept (invalid, expired, already
|
|
122
|
+
* exchanged) has its cookies cleared; one Atlas could not judge (bridge off,
|
|
123
|
+
* rate limited, unreachable) is kept for a later attempt.
|
|
124
|
+
*/
|
|
125
|
+
const method = (request.method ?? 'GET').toUpperCase();
|
|
126
|
+
if (betterAuthBridge && request.url && (method === 'GET' || method === 'HEAD')) {
|
|
127
|
+
const outcome = await betterAuthBridge(request);
|
|
128
|
+
if (outcome.action === 'signed_in') {
|
|
129
|
+
return { kind: 'redirect', location: request.url, auth: exports.SIGNED_OUT, cookies: outcome.cookies };
|
|
130
|
+
}
|
|
131
|
+
if (outcome.action === 'needs_mfa') {
|
|
132
|
+
const target = bridgeConfig?.signInUrl ? new URL(bridgeConfig.signInUrl, request.url).toString() : request.url;
|
|
133
|
+
return { kind: 'redirect', location: outcome.continuationUrl(target), auth: exports.SIGNED_OUT, cookies: outcome.cookies };
|
|
134
|
+
}
|
|
135
|
+
if (outcome.action === 'refused' && outcome.cookies.length > 0) {
|
|
136
|
+
return { kind: 'redirect', location: request.url, auth: exports.SIGNED_OUT, cookies: outcome.cookies };
|
|
137
|
+
}
|
|
138
|
+
}
|
|
96
139
|
/**
|
|
97
140
|
* Cross-domain satellite RETURN: the handshake endpoint bounced the browser
|
|
98
141
|
* back with `?__atlas_hs=ok&__atlas_hu=<userId>&__atlas_hn=<nonce>`. Exchange
|
package/dist/middleware.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"middleware.js","sourceRoot":"","sources":["../src/middleware.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"middleware.js","sourceRoot":"","sources":["../src/middleware.ts"],"names":[],"mappings":";;;AAoJA,0CAMC;AAUD,kCAkBC;AAgCD,gDA4MC;AAKD,0CAmBC;AASD,4CAsCC;AA6BD,0DAqBC;AA3hBD,gDAU4B;AAC5B,uCAA6E;AAkhBpE,6FAlhBa,sBAAY,OAkhBb;AA7aR,QAAA,UAAU,GAAc;IACnC,MAAM,EAAE,IAAI;IACZ,SAAS,EAAE,IAAI;IACf,KAAK,EAAE,IAAI;IACX,OAAO,EAAE,IAAI;IACb,MAAM,EAAE,IAAI;CACb,CAAC;AAEF,SAAS,UAAU,CAAC,MAAqB,EAAE,IAAY;IACrD,IAAI,CAAC,MAAM;QAAE,OAAO,SAAS,CAAC;IAC9B,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;QACrC,MAAM,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,GAAG,IAAI,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ookie({ name, value, options }) {
|
|
|
50
50
|
const parts = [`${name}=${encodeURIComponent(value)}`];
|
|
51
51
|
if (options.path)
|
|
52
52
|
parts.push(`Path=${options.path}`);
|
|
53
|
+
if (options.domain)
|
|
54
|
+
parts.push(`Domain=${options.domain}`);
|
|
53
55
|
if (options.maxAge !== undefined)
|
|
54
56
|
parts.push(`Max-Age=${options.maxAge}`);
|
|
55
57
|
if (options.httpOnly)
|
package/dist/proxy.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proxy.js","sourceRoot":"","sources":["../src/proxy.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"proxy.js","sourceRoot":"","sources":["../src/proxy.ts"],"names":[],"mappings":";;;AAyFA,gCA0BC;AAOD,8BAEC;AA+BD,4CAyCC;AAiBD,4CAUC;AA/ND,6CAQsB;AAEtB;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH;iDACiD;AACpC,QAAA,kBAAkB,GAAG;IAChC,MAAM,EAAE,qBAAqB;IAC7B,MAAM,EAAE,iBAAiB;IACzB,SAAS,EAAE,oBAAoB;IAC/B,KAAK,EAAE,gBAAgB;IACvB,OAAO,EAAE,kBAAkB;CACnB,CAAC;AAEX,MAAM,mBAAmB,GAAG,UAAU,CAAC;AACvC,MAAM,aAAa,GAAG,+BAA+B,CAAC;AACtD,MAAM,eAAe,GAAG,uBAAuB,CAAC;AAmBhD;6EAC6E;AAC7E,MAAM,QAAQ,GAAG,IAAI,OAAO,EAAqB,CAAC;AAElD,SAAS,eAAe,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAe;IAC5D,yEAAyE;IACzE,MAAM,KAAK,GAAG,CAAC,GAAG,IAAI,IAAI,kBAAkB,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IACvD,IAAI,OAAO,CAAC,IAAI;QAAE,KAAK,CAAC,IAAI,CAAC,QAAQ,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;IACrD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Q,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,0BAAkB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI;KACnE,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlasauth/nextjs",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"exports": {
|
|
@@ -12,10 +12,14 @@
|
|
|
12
12
|
"types": "./dist/server.d.ts",
|
|
13
13
|
"default": "./dist/server.js"
|
|
14
14
|
},
|
|
15
|
+
"./compat": {
|
|
16
|
+
"types": "./dist/compat.d.ts",
|
|
17
|
+
"default": "./dist/compat.js"
|
|
18
|
+
},
|
|
15
19
|
"./package.json": "./package.json"
|
|
16
20
|
},
|
|
17
21
|
"dependencies": {
|
|
18
|
-
"@atlasauth/backend": "0.
|
|
22
|
+
"@atlasauth/backend": "0.17.0"
|
|
19
23
|
},
|
|
20
24
|
"peerDependencies": {
|
|
21
25
|
"next": ">=13.4"
|