@atlasauth/nextjs 0.3.0 → 0.5.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.d.ts +16 -0
- package/dist/access-token.js +46 -0
- package/dist/access-token.js.map +1 -0
- package/dist/compat.d.ts +220 -0
- package/dist/compat.js +352 -0
- package/dist/compat.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.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.5.0 — 2026-10-24
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- `@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.
|
|
8
|
+
- `withAccessToken` sets the `DPoP-Nonce` response header (on success and refusal) when the verifier is given `dpopNonces`.
|
|
9
|
+
|
|
10
|
+
## 0.4.0 — 2026-10-23
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- `withAccessToken(options, handler)`: wrap an App Router route handler so it runs only for a request with an Atlas-issued OAuth access token for your API (audience, scopes, DPoP); anything else gets 401/403 with the `WWW-Authenticate` challenge. Re-exports `createAccessTokenVerifier`, `protectedResourceMetadata`, `protectedResourceMetadataPath`.
|
|
15
|
+
|
|
3
16
|
## 0.3.0
|
|
4
17
|
### Added
|
|
5
18
|
- **`getAtlasInitialState(options?)`** in `@atlasauth/nextjs/server` → `Promise<AtlasInitialState>`: the instance's
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type AccessTokenClaims, type AccessTokenVerifierOptions } from '@atlasauth/backend';
|
|
2
|
+
export { createAccessTokenVerifier, protectedResourceMetadata, protectedResourceMetadataPath, type AccessTokenClaims, type AccessTokenResult, type AccessTokenVerifierOptions, } from '@atlasauth/backend';
|
|
3
|
+
/** The verified token handed to a {@link withAccessToken} route handler. */
|
|
4
|
+
export interface VerifiedAccessToken {
|
|
5
|
+
claims: AccessTokenClaims;
|
|
6
|
+
subject: string;
|
|
7
|
+
clientId: string | null;
|
|
8
|
+
scopes: string[];
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Wrap a Next.js route handler (App Router, any runtime) so it only runs for a
|
|
12
|
+
* request carrying an Atlas-issued OAuth access token for YOUR API (audience,
|
|
13
|
+
* scopes, DPoP when bound). Anything else gets 401/403 with the RFC 6750 /
|
|
14
|
+
* RFC 9728 `WWW-Authenticate` challenge — what an MCP client needs to sign in.
|
|
15
|
+
*/
|
|
16
|
+
export declare function withAccessToken<Ctx = unknown>(options: AccessTokenVerifierOptions, handler: (request: Request, token: VerifiedAccessToken, ctx: Ctx) => Response | Promise<Response>): (request: Request, ctx: Ctx) => Promise<Response>;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.protectedResourceMetadataPath = exports.protectedResourceMetadata = exports.createAccessTokenVerifier = void 0;
|
|
4
|
+
exports.withAccessToken = withAccessToken;
|
|
5
|
+
const backend_1 = require("@atlasauth/backend");
|
|
6
|
+
var backend_2 = require("@atlasauth/backend");
|
|
7
|
+
Object.defineProperty(exports, "createAccessTokenVerifier", { enumerable: true, get: function () { return backend_2.createAccessTokenVerifier; } });
|
|
8
|
+
Object.defineProperty(exports, "protectedResourceMetadata", { enumerable: true, get: function () { return backend_2.protectedResourceMetadata; } });
|
|
9
|
+
Object.defineProperty(exports, "protectedResourceMetadataPath", { enumerable: true, get: function () { return backend_2.protectedResourceMetadataPath; } });
|
|
10
|
+
/**
|
|
11
|
+
* Wrap a Next.js route handler (App Router, any runtime) so it only runs for a
|
|
12
|
+
* request carrying an Atlas-issued OAuth access token for YOUR API (audience,
|
|
13
|
+
* scopes, DPoP when bound). Anything else gets 401/403 with the RFC 6750 /
|
|
14
|
+
* RFC 9728 `WWW-Authenticate` challenge — what an MCP client needs to sign in.
|
|
15
|
+
*/
|
|
16
|
+
function withAccessToken(options, handler) {
|
|
17
|
+
const verify = (0, backend_1.createAccessTokenVerifier)(options);
|
|
18
|
+
return async (request, ctx) => {
|
|
19
|
+
const result = await verify({ method: request.method, url: request.url, headers: request.headers });
|
|
20
|
+
if (!result.ok) {
|
|
21
|
+
return new Response(JSON.stringify(result.error ? { error: result.error, error_description: result.description } : { error: 'unauthorized' }), {
|
|
22
|
+
status: result.status,
|
|
23
|
+
headers: {
|
|
24
|
+
'content-type': 'application/json',
|
|
25
|
+
'www-authenticate': result.wwwAuthenticate,
|
|
26
|
+
...(result.dpopNonce ? { 'dpop-nonce': result.dpopNonce } : {}),
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
}
|
|
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
|
+
}
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=access-token.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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,wHAAA,6BAA6B,OAAA;AAc/B;;;;;GAKG;AACH,SAAgB,eAAe,CAC7B,OAAmC,EACnC,OAAiG;IAEjG,MAAM,MAAM,GAAG,IAAA,mCAAyB,EAAC,OAAO,CAAC,CAAC;IAClD,OAAO,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,EAAE;QAC5B,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;QACpG,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC;YACf,OAAO,IAAI,QAAQ,CACjB,IAAI,CAAC,SAAS,CACZ,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,iBAAiB,EAAE,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,cAAc,EAAE,CAC1G,EACD;gBACE,MAAM,EAAE,MAAM,CAAC,MAAM;gBACrB,OAAO,EAAE;oBACP,cAAc,EAAE,kBAAkB;oBAClC,kBAAkB,EAAE,MAAM,CAAC,eAAe;oBAC1C,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;iBAChE;aACF,CACF,CAAC;QACJ,CAAC;QACD,MAAM,QAAQ,GAAG,MAAM,OAAO,CAC5B,OAAO,EACP,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,EACpG,GAAG,CACJ,CAAC;QACF,IAAI,CAAC,MAAM,CAAC,SAAS;YAAE,OAAO,QAAQ,CAAC;QACvC,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;AAMD,wDAGC;AAGD,oDAKC;AAGD,sDAKC;AAoBD,wCAUC;AAqBD,4CAUC;AAGD,sDAGC;AAQD,8DAWC;AAMD,gEAUC;AAGD,4CAEC;AAGD,4EAEC;AA2CD,wDAWC;AAGD,sDAEC;AAGD,4DAcC;AAGD,sDAGC;AASD,kEAqBC;AAQD,oEAgBC;AAGD,sDAGC;AAQD,wDAEC;AAlYD;;;;;;;;;;;GAWG;AACH,6CAAiI;AACjI,uCAAgD;AAChD,qCAA0F;AAE1F,gFAAgF;AACnE,QAAA,oBAAoB,GAAsB,CAAC,cAAc,EAAE,cAAc,CAAC,CAAC;AAIxF;;;;;;GAMG;AACH,SAAgB,qBAAqB,CACnC,UAA2C,EAAE;IAE7C,IAAI,UAA0D,CAAC;IAC/D,OAAO,KAAK,EAAE,OAAO,EAAE,EAAE;QACvB,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,MAAM,YAAY,GAAG,CAAC,GAAG,4BAAoB,EAAE,GAAG,CAAC,OAAO,CAAC,YAAY,IAAI,EAAE,CAAC,CAAC,CAAC;YAChF,UAAU,GAAG,IAAA,4BAAe,EAAC,EAAE,GAAG,IAAA,sBAAa,GAAE,EAAE,GAAG,OAAO,EAAE,YAAY,EAAE,CAAC,CAAC;QACjF,CAAC;QACD,MAAM,EAAE,YAAY,EAAE,GAAG,wDAAa,aAAa,GAAC,CAAC;QACrD,OAAO,UAAU,CAAC,OAAO,EAAE,YAAqB,CAAC,CAAC;IACpD,CAAC,CAAC;AAC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CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;YAClD,CAAC;YACD,KAAK,CAAC,OAAO,CAAC,MAA8B;gBAC1C,MAAM,mBAAmB,EAAE,CAAC;gBAC5B,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;YAC3B,CAAC;SACF;QACD,OAAO,EAAE,eAAe,CAAC,aAAa,CAAC;KACxC,CAAC;AACJ,CAAC;AAED,yFAAyF;AACzF,SAAgB,qBAAqB,CAAC,GAAG,QAAmB;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/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -17,4 +17,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
__exportStar(require("./matcher"), exports);
|
|
18
18
|
__exportStar(require("./middleware"), exports);
|
|
19
19
|
__exportStar(require("./proxy"), exports);
|
|
20
|
+
__exportStar(require("./access-token"), exports);
|
|
20
21
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAA0B;AAC1B,+CAA6B;AAC7B,0CAAwB"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAA0B;AAC1B,+CAA6B;AAC7B,0CAAwB;AACxB,iDAA+B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlasauth/nextjs",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.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.16.0"
|
|
19
23
|
},
|
|
20
24
|
"peerDependencies": {
|
|
21
25
|
"next": ">=13.4"
|