@xylex-group/athena 2.12.0 → 2.13.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 +21 -21
- package/README.md +1190 -1184
- package/bin/athena-js.js +104 -76
- package/dist/admin.cjs +45 -0
- package/dist/admin.cjs.map +1 -0
- package/dist/admin.d.cts +64 -0
- package/dist/admin.d.ts +64 -0
- package/dist/admin.js +41 -0
- package/dist/admin.js.map +1 -0
- package/dist/athena-auth-url-oLux_57a.d.cts +377 -0
- package/dist/athena-auth-url-oLux_57a.d.ts +377 -0
- package/dist/browser.cjs +33 -46
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.d.cts +12 -10
- package/dist/browser.d.ts +12 -10
- package/dist/browser.js +33 -46
- package/dist/browser.js.map +1 -1
- package/dist/cli/index.cjs +150 -48
- package/dist/cli/index.cjs.map +1 -1
- package/dist/cli/index.d.cts +14 -5
- package/dist/cli/index.d.ts +14 -5
- package/dist/cli/index.js +150 -49
- package/dist/cli/index.js.map +1 -1
- package/dist/{client-QUbAs7E8.d.ts → client-BJjUwDSg.d.cts} +109 -1448
- package/dist/{client-C3x75Zgn.d.cts → client-DVOKSYDI.d.ts} +109 -1448
- package/dist/cookies.cjs +18 -0
- package/dist/cookies.cjs.map +1 -1
- package/dist/cookies.d.cts +2 -1
- package/dist/cookies.d.ts +2 -1
- package/dist/cookies.js +17 -1
- package/dist/cookies.js.map +1 -1
- package/dist/{index-CVcQCGyG.d.ts → index-CFL9xbFR.d.cts} +2 -0
- package/dist/{index-CVcQCGyG.d.cts → index-UKJpunc6.d.ts} +2 -0
- package/dist/index.cjs +101 -46
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -10
- package/dist/index.d.ts +13 -10
- package/dist/index.js +101 -47
- package/dist/index.js.map +1 -1
- package/dist/{model-form-CD1uhWSh.d.cts → model-form-Dw4zEL5a.d.cts} +2 -2
- package/dist/{model-form-Dm69I-oO.d.ts → model-form-yRg71q3H.d.ts} +2 -2
- package/dist/{module-CW3tWJ10.d.ts → module-DBteUIob.d.ts} +12 -9
- package/dist/{module-Cxcurfes.d.cts → module-yoX49uQC.d.cts} +12 -9
- package/dist/next/client.cjs +452 -46
- package/dist/next/client.cjs.map +1 -1
- package/dist/next/client.d.cts +7 -4
- package/dist/next/client.d.ts +7 -4
- package/dist/next/client.js +430 -47
- package/dist/next/client.js.map +1 -1
- package/dist/next/server.cjs +292 -46
- package/dist/next/server.cjs.map +1 -1
- package/dist/next/server.d.cts +81 -5
- package/dist/next/server.d.ts +81 -5
- package/dist/next/server.js +280 -47
- package/dist/next/server.js.map +1 -1
- package/dist/organization.cjs +72 -0
- package/dist/organization.cjs.map +1 -0
- package/dist/organization.d.cts +43 -0
- package/dist/organization.d.ts +43 -0
- package/dist/organization.js +70 -0
- package/dist/organization.js.map +1 -0
- package/dist/payload-BzVbUgY_.d.cts +219 -0
- package/dist/payload-DEOWN_oo.d.ts +219 -0
- package/dist/{pipeline-BAwb6Vzm.d.ts → pipeline-Bj6RWt1A.d.ts} +1 -1
- package/dist/{pipeline-B14jVK7J.d.cts → pipeline-Dwck-wZO.d.cts} +1 -1
- package/dist/react.cjs +2 -10
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +26 -7
- package/dist/react.d.ts +26 -7
- package/dist/react.js +2 -10
- package/dist/react.js.map +1 -1
- package/dist/session-cookie-detection-BqOp9mO6.d.cts +46 -0
- package/dist/session-cookie-detection-BqOp9mO6.d.ts +46 -0
- package/dist/social-providers.cjs +4189 -0
- package/dist/social-providers.cjs.map +1 -0
- package/dist/social-providers.d.cts +4948 -0
- package/dist/social-providers.d.ts +4948 -0
- package/dist/social-providers.js +4117 -0
- package/dist/social-providers.js.map +1 -0
- package/dist/{types-Cq4-NoB4.d.ts → types-BRP7sfSF.d.ts} +50 -2
- package/dist/{types-Dr849HD6.d.cts → types-BU8uJH_b.d.cts} +50 -2
- package/dist/{types-CwJCPpLD.d.ts → types-CH78O90i.d.cts} +2 -2
- package/dist/{types-CwJCPpLD.d.cts → types-CH78O90i.d.ts} +2 -2
- package/dist/{types-DMOoYnPS.d.cts → types-CjC9_5ZQ.d.cts} +3 -3
- package/dist/{types-BcVmPBP-.d.ts → types-DPgejxYC.d.ts} +3 -3
- package/dist/types-eAKAh71s.d.cts +1476 -0
- package/dist/types-eAKAh71s.d.ts +1476 -0
- package/dist/utils.cjs +438 -12
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +76 -11
- package/dist/utils.d.ts +76 -11
- package/dist/utils.js +390 -13
- package/dist/utils.js.map +1 -1
- package/package.json +49 -22
- package/dist/shared-0Kdc74lu.d.ts +0 -35
- package/dist/shared-C0wVICRv.d.cts +0 -35
package/dist/next/server.d.cts
CHANGED
|
@@ -1,7 +1,83 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import '../
|
|
4
|
-
|
|
1
|
+
import { al as AthenaClientSessionLike, aX as AthenaSdkClientWithStorage, aW as AthenaSdkClientWithAuth } from '../client-BJjUwDSg.cjs';
|
|
2
|
+
import { ae as AthenaAuthSessionResponse } from '../types-eAKAh71s.cjs';
|
|
3
|
+
import { i as AthenaAuthSessionBridgeOptions, j as AthenaAuthSessionBridgePathOptions, A as AthenaAdapterBaseOptions, k as AthenaServerRequestOptions, a as AthenaAdapterExperimentalOptions } from '../payload-BzVbUgY_.cjs';
|
|
4
|
+
export { b as ATHENA_AUTH_SESSION_BRIDGE_ROUTE, c as ATHENA_AUTH_SESSION_COOKIE_NAME, d as ATHENA_AUTH_SESSION_COOKIE_NAMES, e as AthenaAuthSessionBridgeClientOptions, f as AthenaAuthSessionBridgePayload, g as AthenaAuthSessionBridgeSource, h as clearAthenaAuthSessionOnAppHost, p as persistAthenaAuthSessionOnAppHost, r as resolveSessionBridgePayload } from '../payload-BzVbUgY_.cjs';
|
|
5
|
+
export { S as SESSION_COOKIE_PATTERNS, h as hasAuthSessionCookie } from '../session-cookie-detection-BqOp9mO6.cjs';
|
|
6
|
+
import '../types-CH78O90i.cjs';
|
|
7
|
+
import '../types-BU8uJH_b.cjs';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Handle bridge `POST` — set an httpOnly session cookie from JSON body.
|
|
11
|
+
*
|
|
12
|
+
* Expected body: `{ "token": string, "expiresAt"?: string }`.
|
|
13
|
+
*
|
|
14
|
+
* @param request - Incoming request (JSON body)
|
|
15
|
+
* @param options - Cookie / route configuration
|
|
16
|
+
* @returns `200` on success, `400` when token is missing
|
|
17
|
+
*/
|
|
18
|
+
declare function handleAthenaAuthSessionBridgePost(request: Request, options?: AthenaAuthSessionBridgeOptions): Promise<Response>;
|
|
19
|
+
/**
|
|
20
|
+
* Handle bridge `DELETE` — clear bridged session cookie name variants.
|
|
21
|
+
*
|
|
22
|
+
* @param request - Incoming request (used for Secure detection)
|
|
23
|
+
* @param options - Cookie / route configuration
|
|
24
|
+
* @returns `200` with clear `Set-Cookie` headers
|
|
25
|
+
*/
|
|
26
|
+
declare function handleAthenaAuthSessionBridgeDelete(request: Request, options?: AthenaAuthSessionBridgeOptions): Response;
|
|
27
|
+
/**
|
|
28
|
+
* Create dedicated App Router handlers for the session bridge.
|
|
29
|
+
*
|
|
30
|
+
* Drop into a route file with no additional wiring:
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```ts
|
|
34
|
+
* // app/api/athena-auth/session/route.ts
|
|
35
|
+
* import { createAthenaAuthSessionBridgeHandlers } from '@xylex-group/athena/next/server'
|
|
36
|
+
*
|
|
37
|
+
* export const { POST, DELETE } = createAthenaAuthSessionBridgeHandlers()
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* @param options - Optional cookie name, path, SameSite, Secure overrides
|
|
41
|
+
* @returns Object with `POST` and `DELETE` route handlers
|
|
42
|
+
*/
|
|
43
|
+
declare function createAthenaAuthSessionBridgeHandlers(options?: AthenaAuthSessionBridgeOptions): {
|
|
44
|
+
POST: (request: Request) => Promise<Response>;
|
|
45
|
+
DELETE: (request: Request) => Response;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Whether this request should be handled as a session bridge call.
|
|
49
|
+
*
|
|
50
|
+
* Returns true when:
|
|
51
|
+
* - the pathname equals the configured `route`, or
|
|
52
|
+
* - the final path segment is listed in `matchPaths` (default `session`)
|
|
53
|
+
*
|
|
54
|
+
* @param request - Incoming request
|
|
55
|
+
* @param options - Route + matchPaths configuration
|
|
56
|
+
*/
|
|
57
|
+
declare function isAthenaAuthSessionBridgePath(request: Request, options?: AthenaAuthSessionBridgePathOptions): boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Create catch-all / `[path]` handlers that only service session-bridge paths.
|
|
60
|
+
*
|
|
61
|
+
* Non-matching paths return `404` with `{ error: 'Not found' }` so you can
|
|
62
|
+
* mount under `/api/auth/[...path]` without implementing a full auth proxy.
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```ts
|
|
66
|
+
* // app/api/auth/[...path]/route.ts
|
|
67
|
+
* import { createAthenaAuthSessionBridgePathHandlers } from '@xylex-group/athena/next/server'
|
|
68
|
+
*
|
|
69
|
+
* export const { POST, DELETE } = createAthenaAuthSessionBridgePathHandlers({
|
|
70
|
+
* route: '/api/auth/session',
|
|
71
|
+
* })
|
|
72
|
+
* ```
|
|
73
|
+
*
|
|
74
|
+
* @param options - Bridge options plus `matchPaths`
|
|
75
|
+
* @returns Object with `POST` and `DELETE` route handlers
|
|
76
|
+
*/
|
|
77
|
+
declare function createAthenaAuthSessionBridgePathHandlers(options?: AthenaAuthSessionBridgePathOptions): {
|
|
78
|
+
POST: (request: Request) => Promise<Response>;
|
|
79
|
+
DELETE: (request: Request) => Response;
|
|
80
|
+
};
|
|
5
81
|
|
|
6
82
|
interface AthenaServerClientOptions extends AthenaAdapterBaseOptions, AthenaServerRequestOptions {
|
|
7
83
|
session?: AthenaClientSessionLike | AthenaAuthSessionResponse | null;
|
|
@@ -50,4 +126,4 @@ declare function resolveAthenaServerContext(options: AthenaServerContextOptionsW
|
|
|
50
126
|
declare function resolveAthenaServerContext(options: AthenaServerContextOptionsWithTypecheckedColumns): Promise<AthenaResolvedServerContext<AthenaSdkClientWithAuth<true>>>;
|
|
51
127
|
declare function resolveAthenaServerContext(options?: AthenaServerContextOptions): Promise<AthenaResolvedServerContext<AthenaSdkClientWithAuth<false>>>;
|
|
52
128
|
|
|
53
|
-
export { type AthenaResolvedServerContext, type AthenaServerClientOptions, type AthenaServerContextOptions, createAthenaServerClient, resolveAthenaServerContext };
|
|
129
|
+
export { AthenaAuthSessionBridgeOptions, AthenaAuthSessionBridgePathOptions, type AthenaResolvedServerContext, type AthenaServerClientOptions, type AthenaServerContextOptions, createAthenaAuthSessionBridgeHandlers, createAthenaAuthSessionBridgePathHandlers, createAthenaServerClient, handleAthenaAuthSessionBridgeDelete, handleAthenaAuthSessionBridgePost, isAthenaAuthSessionBridgePath, resolveAthenaServerContext };
|
package/dist/next/server.d.ts
CHANGED
|
@@ -1,7 +1,83 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import '../
|
|
4
|
-
|
|
1
|
+
import { al as AthenaClientSessionLike, aX as AthenaSdkClientWithStorage, aW as AthenaSdkClientWithAuth } from '../client-DVOKSYDI.js';
|
|
2
|
+
import { ae as AthenaAuthSessionResponse } from '../types-eAKAh71s.js';
|
|
3
|
+
import { i as AthenaAuthSessionBridgeOptions, j as AthenaAuthSessionBridgePathOptions, A as AthenaAdapterBaseOptions, k as AthenaServerRequestOptions, a as AthenaAdapterExperimentalOptions } from '../payload-DEOWN_oo.js';
|
|
4
|
+
export { b as ATHENA_AUTH_SESSION_BRIDGE_ROUTE, c as ATHENA_AUTH_SESSION_COOKIE_NAME, d as ATHENA_AUTH_SESSION_COOKIE_NAMES, e as AthenaAuthSessionBridgeClientOptions, f as AthenaAuthSessionBridgePayload, g as AthenaAuthSessionBridgeSource, h as clearAthenaAuthSessionOnAppHost, p as persistAthenaAuthSessionOnAppHost, r as resolveSessionBridgePayload } from '../payload-DEOWN_oo.js';
|
|
5
|
+
export { S as SESSION_COOKIE_PATTERNS, h as hasAuthSessionCookie } from '../session-cookie-detection-BqOp9mO6.js';
|
|
6
|
+
import '../types-CH78O90i.js';
|
|
7
|
+
import '../types-BRP7sfSF.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Handle bridge `POST` — set an httpOnly session cookie from JSON body.
|
|
11
|
+
*
|
|
12
|
+
* Expected body: `{ "token": string, "expiresAt"?: string }`.
|
|
13
|
+
*
|
|
14
|
+
* @param request - Incoming request (JSON body)
|
|
15
|
+
* @param options - Cookie / route configuration
|
|
16
|
+
* @returns `200` on success, `400` when token is missing
|
|
17
|
+
*/
|
|
18
|
+
declare function handleAthenaAuthSessionBridgePost(request: Request, options?: AthenaAuthSessionBridgeOptions): Promise<Response>;
|
|
19
|
+
/**
|
|
20
|
+
* Handle bridge `DELETE` — clear bridged session cookie name variants.
|
|
21
|
+
*
|
|
22
|
+
* @param request - Incoming request (used for Secure detection)
|
|
23
|
+
* @param options - Cookie / route configuration
|
|
24
|
+
* @returns `200` with clear `Set-Cookie` headers
|
|
25
|
+
*/
|
|
26
|
+
declare function handleAthenaAuthSessionBridgeDelete(request: Request, options?: AthenaAuthSessionBridgeOptions): Response;
|
|
27
|
+
/**
|
|
28
|
+
* Create dedicated App Router handlers for the session bridge.
|
|
29
|
+
*
|
|
30
|
+
* Drop into a route file with no additional wiring:
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```ts
|
|
34
|
+
* // app/api/athena-auth/session/route.ts
|
|
35
|
+
* import { createAthenaAuthSessionBridgeHandlers } from '@xylex-group/athena/next/server'
|
|
36
|
+
*
|
|
37
|
+
* export const { POST, DELETE } = createAthenaAuthSessionBridgeHandlers()
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* @param options - Optional cookie name, path, SameSite, Secure overrides
|
|
41
|
+
* @returns Object with `POST` and `DELETE` route handlers
|
|
42
|
+
*/
|
|
43
|
+
declare function createAthenaAuthSessionBridgeHandlers(options?: AthenaAuthSessionBridgeOptions): {
|
|
44
|
+
POST: (request: Request) => Promise<Response>;
|
|
45
|
+
DELETE: (request: Request) => Response;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Whether this request should be handled as a session bridge call.
|
|
49
|
+
*
|
|
50
|
+
* Returns true when:
|
|
51
|
+
* - the pathname equals the configured `route`, or
|
|
52
|
+
* - the final path segment is listed in `matchPaths` (default `session`)
|
|
53
|
+
*
|
|
54
|
+
* @param request - Incoming request
|
|
55
|
+
* @param options - Route + matchPaths configuration
|
|
56
|
+
*/
|
|
57
|
+
declare function isAthenaAuthSessionBridgePath(request: Request, options?: AthenaAuthSessionBridgePathOptions): boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Create catch-all / `[path]` handlers that only service session-bridge paths.
|
|
60
|
+
*
|
|
61
|
+
* Non-matching paths return `404` with `{ error: 'Not found' }` so you can
|
|
62
|
+
* mount under `/api/auth/[...path]` without implementing a full auth proxy.
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```ts
|
|
66
|
+
* // app/api/auth/[...path]/route.ts
|
|
67
|
+
* import { createAthenaAuthSessionBridgePathHandlers } from '@xylex-group/athena/next/server'
|
|
68
|
+
*
|
|
69
|
+
* export const { POST, DELETE } = createAthenaAuthSessionBridgePathHandlers({
|
|
70
|
+
* route: '/api/auth/session',
|
|
71
|
+
* })
|
|
72
|
+
* ```
|
|
73
|
+
*
|
|
74
|
+
* @param options - Bridge options plus `matchPaths`
|
|
75
|
+
* @returns Object with `POST` and `DELETE` route handlers
|
|
76
|
+
*/
|
|
77
|
+
declare function createAthenaAuthSessionBridgePathHandlers(options?: AthenaAuthSessionBridgePathOptions): {
|
|
78
|
+
POST: (request: Request) => Promise<Response>;
|
|
79
|
+
DELETE: (request: Request) => Response;
|
|
80
|
+
};
|
|
5
81
|
|
|
6
82
|
interface AthenaServerClientOptions extends AthenaAdapterBaseOptions, AthenaServerRequestOptions {
|
|
7
83
|
session?: AthenaClientSessionLike | AthenaAuthSessionResponse | null;
|
|
@@ -50,4 +126,4 @@ declare function resolveAthenaServerContext(options: AthenaServerContextOptionsW
|
|
|
50
126
|
declare function resolveAthenaServerContext(options: AthenaServerContextOptionsWithTypecheckedColumns): Promise<AthenaResolvedServerContext<AthenaSdkClientWithAuth<true>>>;
|
|
51
127
|
declare function resolveAthenaServerContext(options?: AthenaServerContextOptions): Promise<AthenaResolvedServerContext<AthenaSdkClientWithAuth<false>>>;
|
|
52
128
|
|
|
53
|
-
export { type AthenaResolvedServerContext, type AthenaServerClientOptions, type AthenaServerContextOptions, createAthenaServerClient, resolveAthenaServerContext };
|
|
129
|
+
export { AthenaAuthSessionBridgeOptions, AthenaAuthSessionBridgePathOptions, type AthenaResolvedServerContext, type AthenaServerClientOptions, type AthenaServerContextOptions, createAthenaAuthSessionBridgeHandlers, createAthenaAuthSessionBridgePathHandlers, createAthenaServerClient, handleAthenaAuthSessionBridgeDelete, handleAthenaAuthSessionBridgePost, isAthenaAuthSessionBridgePath, resolveAthenaServerContext };
|
package/dist/next/server.js
CHANGED
|
@@ -136,6 +136,22 @@ function parseCookies(cookieHeader) {
|
|
|
136
136
|
});
|
|
137
137
|
return cookieMap;
|
|
138
138
|
}
|
|
139
|
+
|
|
140
|
+
// src/cookies/session-cookie-detection.ts
|
|
141
|
+
var SESSION_COOKIE_PATTERNS = [
|
|
142
|
+
/(?:^|;\s*)(?:__Secure-)?better-auth\.session_token=/,
|
|
143
|
+
/(?:^|;\s*)(?:__Secure-)?better-auth-session_token=/,
|
|
144
|
+
/(?:^|;\s*)(?:__Secure-)?athena-auth\.session-token=/,
|
|
145
|
+
/(?:^|;\s*)(?:__Secure-)?athena-auth-session-token=/,
|
|
146
|
+
/(?:^|;\s*)(?:__Secure-)?athena-auth\.session_token=/,
|
|
147
|
+
/(?:^|;\s*)(?:__Secure-)?athena-auth-session_token=/
|
|
148
|
+
];
|
|
149
|
+
function hasAuthSessionCookie(cookieHeader) {
|
|
150
|
+
if (!cookieHeader) {
|
|
151
|
+
return false;
|
|
152
|
+
}
|
|
153
|
+
return SESSION_COOKIE_PATTERNS.some((pattern) => pattern.test(cookieHeader));
|
|
154
|
+
}
|
|
139
155
|
var getSessionCookie = (request2, config) => {
|
|
140
156
|
const cookies = (request2 instanceof Headers || !("headers" in request2) ? request2 : request2.headers).get("cookie");
|
|
141
157
|
if (!cookies) {
|
|
@@ -160,7 +176,7 @@ var getSessionCookie = (request2, config) => {
|
|
|
160
176
|
|
|
161
177
|
// src/utils/athena-request-headers.ts
|
|
162
178
|
var NO_CACHE_HEADER_VALUE = "no-cache";
|
|
163
|
-
var API_KEY_HEADER_CANDIDATES = ["x-api-key", "apikey"];
|
|
179
|
+
var API_KEY_HEADER_CANDIDATES = ["X-Athena-Key", "x-athena-key", "X-Api-Key", "x-api-key", "apikey"];
|
|
164
180
|
var ATHENA_KEY_HEADER_CANDIDATES = ["X-Athena-Key", "x-athena-key"];
|
|
165
181
|
var SESSION_TOKEN_HEADER_CANDIDATES = ["X-Athena-Auth-Session-Token"];
|
|
166
182
|
var BEARER_MIRROR_HEADER_CANDIDATES = ["X-Athena-Auth-Bearer-Token"];
|
|
@@ -262,14 +278,6 @@ function buildServiceRequestHeaders(profile, sdkHeaderValue, config, options, ex
|
|
|
262
278
|
});
|
|
263
279
|
}
|
|
264
280
|
function applyAthenaApiKeyHeaders(headers, apiKey, athenaKey) {
|
|
265
|
-
if (apiKey) {
|
|
266
|
-
if (!hasHeaderIgnoreCase(headers, "apikey")) {
|
|
267
|
-
headers.apikey = apiKey;
|
|
268
|
-
}
|
|
269
|
-
if (!hasHeaderIgnoreCase(headers, "x-api-key")) {
|
|
270
|
-
headers["x-api-key"] = apiKey;
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
281
|
const resolvedAthenaKey = normalizeHeaderValue(athenaKey) ?? normalizeHeaderValue(apiKey);
|
|
274
282
|
if (resolvedAthenaKey && !hasHeaderIgnoreCase(headers, "X-Athena-Key")) {
|
|
275
283
|
headers["X-Athena-Key"] = resolvedAthenaKey;
|
|
@@ -395,7 +403,7 @@ function buildAthenaRequestHeaders(input) {
|
|
|
395
403
|
|
|
396
404
|
// package.json
|
|
397
405
|
var package_default = {
|
|
398
|
-
version: "2.
|
|
406
|
+
version: "2.13.0"
|
|
399
407
|
};
|
|
400
408
|
|
|
401
409
|
// src/sdk-version.ts
|
|
@@ -2824,38 +2832,6 @@ async function withRetry(config, fn) {
|
|
|
2824
2832
|
throw new Error("withRetry reached an unexpected state");
|
|
2825
2833
|
}
|
|
2826
2834
|
|
|
2827
|
-
// src/db/module.ts
|
|
2828
|
-
function createDbModule(input) {
|
|
2829
|
-
const db = {
|
|
2830
|
-
from: input.from,
|
|
2831
|
-
select(table, first, second) {
|
|
2832
|
-
if (first && typeof first === "object" && !Array.isArray(first)) {
|
|
2833
|
-
return input.from(table).select(void 0, first);
|
|
2834
|
-
}
|
|
2835
|
-
return input.from(table).select(first, second);
|
|
2836
|
-
},
|
|
2837
|
-
insert(table, values, options) {
|
|
2838
|
-
return Array.isArray(values) ? input.from(table).insert(values, options) : input.from(table).insert(values, options);
|
|
2839
|
-
},
|
|
2840
|
-
upsert(table, values, options) {
|
|
2841
|
-
return Array.isArray(values) ? input.from(table).upsert(values, options) : input.from(table).upsert(values, options);
|
|
2842
|
-
},
|
|
2843
|
-
update(table, values, options) {
|
|
2844
|
-
return input.from(table).update(values, options);
|
|
2845
|
-
},
|
|
2846
|
-
delete(table, options) {
|
|
2847
|
-
return input.from(table).delete(options);
|
|
2848
|
-
},
|
|
2849
|
-
rpc(fn, args, options) {
|
|
2850
|
-
return input.rpc(fn, args, options);
|
|
2851
|
-
},
|
|
2852
|
-
query(query, options) {
|
|
2853
|
-
return input.query(query, options);
|
|
2854
|
-
}
|
|
2855
|
-
};
|
|
2856
|
-
return db;
|
|
2857
|
-
}
|
|
2858
|
-
|
|
2859
2835
|
// src/storage/file.ts
|
|
2860
2836
|
function createStorageFileModule(base, config = {}) {
|
|
2861
2837
|
const upload = async (input, options) => {
|
|
@@ -8434,7 +8410,30 @@ function createClientFromConfig(config, sourceConfig) {
|
|
|
8434
8410
|
config.experimental,
|
|
8435
8411
|
queryTracer
|
|
8436
8412
|
);
|
|
8437
|
-
const
|
|
8413
|
+
const untypedDbFrom = from;
|
|
8414
|
+
const db = {
|
|
8415
|
+
from,
|
|
8416
|
+
select(table, first, second) {
|
|
8417
|
+
if (first && typeof first === "object" && !Array.isArray(first)) {
|
|
8418
|
+
return untypedDbFrom(table).select(void 0, first);
|
|
8419
|
+
}
|
|
8420
|
+
return untypedDbFrom(table).select(first, second);
|
|
8421
|
+
},
|
|
8422
|
+
insert(table, values, options) {
|
|
8423
|
+
return Array.isArray(values) ? untypedDbFrom(table).insert(values, options) : untypedDbFrom(table).insert(values, options);
|
|
8424
|
+
},
|
|
8425
|
+
upsert(table, values, options) {
|
|
8426
|
+
return Array.isArray(values) ? untypedDbFrom(table).upsert(values, options) : untypedDbFrom(table).upsert(values, options);
|
|
8427
|
+
},
|
|
8428
|
+
update(table, values, options) {
|
|
8429
|
+
return untypedDbFrom(table).update(values, options);
|
|
8430
|
+
},
|
|
8431
|
+
delete(table, options) {
|
|
8432
|
+
return untypedDbFrom(table).delete(options);
|
|
8433
|
+
},
|
|
8434
|
+
rpc,
|
|
8435
|
+
query
|
|
8436
|
+
};
|
|
8438
8437
|
const chat = createChatModule({
|
|
8439
8438
|
baseUrl: config.chatUrl,
|
|
8440
8439
|
apiKey: config.apiKey,
|
|
@@ -8585,7 +8584,9 @@ function createClientFromConfig(config, sourceConfig) {
|
|
|
8585
8584
|
var AthenaClient = class {
|
|
8586
8585
|
/** Create a fluent builder for a strongly-typed Athena SDK client. */
|
|
8587
8586
|
static builder() {
|
|
8588
|
-
return createAthenaClientBuilder(
|
|
8587
|
+
return createAthenaClientBuilder(
|
|
8588
|
+
(config) => createClientFromInput(config)
|
|
8589
|
+
);
|
|
8589
8590
|
}
|
|
8590
8591
|
static fromEnvironment(options = {}) {
|
|
8591
8592
|
const env = options.env ?? process.env;
|
|
@@ -8616,11 +8617,12 @@ var AthenaClient = class {
|
|
|
8616
8617
|
});
|
|
8617
8618
|
}
|
|
8618
8619
|
};
|
|
8619
|
-
function createClient(
|
|
8620
|
+
function createClient(...args) {
|
|
8621
|
+
const [configOrUrl, apiKey, options] = args;
|
|
8620
8622
|
if (typeof configOrUrl === "string" || configOrUrl === null || configOrUrl === void 0) {
|
|
8621
8623
|
return createClientFromInput({
|
|
8622
8624
|
url: configOrUrl,
|
|
8623
|
-
key: "",
|
|
8625
|
+
key: apiKey ?? "",
|
|
8624
8626
|
...options
|
|
8625
8627
|
});
|
|
8626
8628
|
}
|
|
@@ -8756,6 +8758,237 @@ function buildSessionClientOptions(context, options) {
|
|
|
8756
8758
|
};
|
|
8757
8759
|
}
|
|
8758
8760
|
|
|
8761
|
+
// src/next/session-bridge/constants.ts
|
|
8762
|
+
var ATHENA_AUTH_SESSION_BRIDGE_ROUTE = "/api/athena-auth/session";
|
|
8763
|
+
var ATHENA_AUTH_SESSION_COOKIE_NAME = "athena-auth.session-token";
|
|
8764
|
+
var ATHENA_AUTH_SESSION_COOKIE_NAMES = [
|
|
8765
|
+
ATHENA_AUTH_SESSION_COOKIE_NAME,
|
|
8766
|
+
"athena-auth.session_token"
|
|
8767
|
+
];
|
|
8768
|
+
|
|
8769
|
+
// src/next/session-bridge/client.ts
|
|
8770
|
+
var JSON_CONTENT_TYPE = "application/json";
|
|
8771
|
+
function isBrowserRuntime() {
|
|
8772
|
+
return typeof globalThis !== "undefined" && "window" in globalThis;
|
|
8773
|
+
}
|
|
8774
|
+
async function persistAthenaAuthSessionOnAppHost(payload, options) {
|
|
8775
|
+
if (!(payload && isBrowserRuntime())) {
|
|
8776
|
+
return;
|
|
8777
|
+
}
|
|
8778
|
+
const route = options?.route ?? ATHENA_AUTH_SESSION_BRIDGE_ROUTE;
|
|
8779
|
+
const fetchImpl = options?.fetch ?? fetch;
|
|
8780
|
+
const response = await fetchImpl(route, {
|
|
8781
|
+
body: JSON.stringify(payload),
|
|
8782
|
+
credentials: "same-origin",
|
|
8783
|
+
headers: {
|
|
8784
|
+
"Content-Type": JSON_CONTENT_TYPE
|
|
8785
|
+
},
|
|
8786
|
+
method: "POST"
|
|
8787
|
+
});
|
|
8788
|
+
if (!response.ok) {
|
|
8789
|
+
throw new Error("Failed to persist the Athena Auth session on the app host");
|
|
8790
|
+
}
|
|
8791
|
+
}
|
|
8792
|
+
async function clearAthenaAuthSessionOnAppHost(options) {
|
|
8793
|
+
if (!isBrowserRuntime()) {
|
|
8794
|
+
return;
|
|
8795
|
+
}
|
|
8796
|
+
const route = options?.route ?? ATHENA_AUTH_SESSION_BRIDGE_ROUTE;
|
|
8797
|
+
const fetchImpl = options?.fetch ?? fetch;
|
|
8798
|
+
const response = await fetchImpl(route, {
|
|
8799
|
+
credentials: "same-origin",
|
|
8800
|
+
method: "DELETE"
|
|
8801
|
+
});
|
|
8802
|
+
if (!response.ok) {
|
|
8803
|
+
throw new Error("Failed to clear the Athena Auth session on the app host");
|
|
8804
|
+
}
|
|
8805
|
+
}
|
|
8806
|
+
|
|
8807
|
+
// src/next/session-bridge/payload.ts
|
|
8808
|
+
function resolveSessionBridgePayload(payload) {
|
|
8809
|
+
const token = payload?.session?.token ?? payload?.token;
|
|
8810
|
+
if (typeof token !== "string") {
|
|
8811
|
+
return null;
|
|
8812
|
+
}
|
|
8813
|
+
const normalizedToken = token.trim();
|
|
8814
|
+
if (!normalizedToken) {
|
|
8815
|
+
return null;
|
|
8816
|
+
}
|
|
8817
|
+
return {
|
|
8818
|
+
token: normalizedToken,
|
|
8819
|
+
expiresAt: typeof payload?.session?.expiresAt === "string" ? payload.session.expiresAt : void 0
|
|
8820
|
+
};
|
|
8821
|
+
}
|
|
8822
|
+
|
|
8823
|
+
// src/next/session-bridge/cookie.ts
|
|
8824
|
+
var EXPIRED_AT = /* @__PURE__ */ new Date(0);
|
|
8825
|
+
function resolveRequestIsSecure(request2) {
|
|
8826
|
+
const forwardedProto = request2.headers.get("x-forwarded-proto")?.trim();
|
|
8827
|
+
if (forwardedProto) {
|
|
8828
|
+
const first = forwardedProto.split(",")[0]?.trim().toLowerCase();
|
|
8829
|
+
if (first === "https") return true;
|
|
8830
|
+
if (first === "http") return false;
|
|
8831
|
+
}
|
|
8832
|
+
return new URL(request2.url).protocol === "https:";
|
|
8833
|
+
}
|
|
8834
|
+
function resolveSessionCookieExpiresAt(value) {
|
|
8835
|
+
if (typeof value !== "string") {
|
|
8836
|
+
return void 0;
|
|
8837
|
+
}
|
|
8838
|
+
const expiresAt = new Date(value);
|
|
8839
|
+
return Number.isNaN(expiresAt.getTime()) ? void 0 : expiresAt;
|
|
8840
|
+
}
|
|
8841
|
+
function serializeCookie(name, value, options) {
|
|
8842
|
+
const parts = [
|
|
8843
|
+
`${encodeURIComponent(name)}=${encodeURIComponent(value)}`,
|
|
8844
|
+
`Path=${options.path}`,
|
|
8845
|
+
"HttpOnly",
|
|
8846
|
+
`SameSite=${options.sameSite === "none" ? "None" : options.sameSite === "strict" ? "Strict" : "Lax"}`
|
|
8847
|
+
];
|
|
8848
|
+
if (options.secure) {
|
|
8849
|
+
parts.push("Secure");
|
|
8850
|
+
}
|
|
8851
|
+
if (options.expires) {
|
|
8852
|
+
parts.push(`Expires=${options.expires.toUTCString()}`);
|
|
8853
|
+
}
|
|
8854
|
+
return parts.join("; ");
|
|
8855
|
+
}
|
|
8856
|
+
function resolveBridgeCookieConfig(options) {
|
|
8857
|
+
return {
|
|
8858
|
+
cookieName: options?.cookieName ?? ATHENA_AUTH_SESSION_COOKIE_NAME,
|
|
8859
|
+
cookieNames: options?.cookieNames ?? ATHENA_AUTH_SESSION_COOKIE_NAMES,
|
|
8860
|
+
cookiePath: options?.cookiePath ?? "/",
|
|
8861
|
+
sameSite: options?.sameSite ?? "lax"
|
|
8862
|
+
};
|
|
8863
|
+
}
|
|
8864
|
+
function appendSessionCookie(headers, request2, token, expiresAt, options) {
|
|
8865
|
+
const config = resolveBridgeCookieConfig(options);
|
|
8866
|
+
const secure = options?.secure ?? resolveRequestIsSecure(request2);
|
|
8867
|
+
headers.append(
|
|
8868
|
+
"set-cookie",
|
|
8869
|
+
serializeCookie(config.cookieName, token, {
|
|
8870
|
+
path: config.cookiePath,
|
|
8871
|
+
sameSite: config.sameSite,
|
|
8872
|
+
secure,
|
|
8873
|
+
expires: expiresAt
|
|
8874
|
+
})
|
|
8875
|
+
);
|
|
8876
|
+
}
|
|
8877
|
+
function appendClearSessionCookies(headers, request2, options) {
|
|
8878
|
+
const config = resolveBridgeCookieConfig(options);
|
|
8879
|
+
const secure = options?.secure ?? resolveRequestIsSecure(request2);
|
|
8880
|
+
const names = /* @__PURE__ */ new Set([config.cookieName, ...config.cookieNames]);
|
|
8881
|
+
for (const name of names) {
|
|
8882
|
+
headers.append(
|
|
8883
|
+
"set-cookie",
|
|
8884
|
+
serializeCookie(name, "", {
|
|
8885
|
+
path: config.cookiePath,
|
|
8886
|
+
sameSite: config.sameSite,
|
|
8887
|
+
secure,
|
|
8888
|
+
expires: EXPIRED_AT
|
|
8889
|
+
})
|
|
8890
|
+
);
|
|
8891
|
+
}
|
|
8892
|
+
}
|
|
8893
|
+
|
|
8894
|
+
// src/next/session-bridge/handlers.ts
|
|
8895
|
+
function json(body, init) {
|
|
8896
|
+
const headers = init?.headers ?? new Headers();
|
|
8897
|
+
if (!headers.has("content-type")) {
|
|
8898
|
+
headers.set("content-type", "application/json; charset=utf-8");
|
|
8899
|
+
}
|
|
8900
|
+
return new Response(JSON.stringify(body), {
|
|
8901
|
+
status: init?.status ?? 200,
|
|
8902
|
+
headers
|
|
8903
|
+
});
|
|
8904
|
+
}
|
|
8905
|
+
function resolveRoute(options) {
|
|
8906
|
+
return options?.route ?? ATHENA_AUTH_SESSION_BRIDGE_ROUTE;
|
|
8907
|
+
}
|
|
8908
|
+
async function handleAthenaAuthSessionBridgePost(request2, options) {
|
|
8909
|
+
const payload = await request2.json().catch(() => null);
|
|
8910
|
+
const token = typeof payload?.token === "string" ? payload.token.trim() : "";
|
|
8911
|
+
if (!token) {
|
|
8912
|
+
return json(
|
|
8913
|
+
{
|
|
8914
|
+
error: "Missing Athena Auth session token"
|
|
8915
|
+
},
|
|
8916
|
+
{ status: 400 }
|
|
8917
|
+
);
|
|
8918
|
+
}
|
|
8919
|
+
const headers = new Headers();
|
|
8920
|
+
appendSessionCookie(
|
|
8921
|
+
headers,
|
|
8922
|
+
request2,
|
|
8923
|
+
token,
|
|
8924
|
+
resolveSessionCookieExpiresAt(payload?.expiresAt),
|
|
8925
|
+
options
|
|
8926
|
+
);
|
|
8927
|
+
return json(
|
|
8928
|
+
{
|
|
8929
|
+
ok: true,
|
|
8930
|
+
route: resolveRoute(options)
|
|
8931
|
+
},
|
|
8932
|
+
{ headers }
|
|
8933
|
+
);
|
|
8934
|
+
}
|
|
8935
|
+
function handleAthenaAuthSessionBridgeDelete(request2, options) {
|
|
8936
|
+
const headers = new Headers();
|
|
8937
|
+
appendClearSessionCookies(headers, request2, options);
|
|
8938
|
+
return json(
|
|
8939
|
+
{
|
|
8940
|
+
ok: true,
|
|
8941
|
+
route: resolveRoute(options)
|
|
8942
|
+
},
|
|
8943
|
+
{ headers }
|
|
8944
|
+
);
|
|
8945
|
+
}
|
|
8946
|
+
function createAthenaAuthSessionBridgeHandlers(options) {
|
|
8947
|
+
return {
|
|
8948
|
+
POST: (request2) => handleAthenaAuthSessionBridgePost(request2, options),
|
|
8949
|
+
DELETE: (request2) => handleAthenaAuthSessionBridgeDelete(request2, options)
|
|
8950
|
+
};
|
|
8951
|
+
}
|
|
8952
|
+
function normalizePathname(pathname) {
|
|
8953
|
+
if (pathname.length > 1 && pathname.endsWith("/")) {
|
|
8954
|
+
return pathname.slice(0, -1);
|
|
8955
|
+
}
|
|
8956
|
+
return pathname || "/";
|
|
8957
|
+
}
|
|
8958
|
+
function isAthenaAuthSessionBridgePath(request2, options) {
|
|
8959
|
+
const pathname = normalizePathname(new URL(request2.url).pathname);
|
|
8960
|
+
const route = normalizePathname(resolveRoute(options));
|
|
8961
|
+
if (pathname === route) {
|
|
8962
|
+
return true;
|
|
8963
|
+
}
|
|
8964
|
+
const matchPaths = options?.matchPaths ?? ["session"];
|
|
8965
|
+
const segments = pathname.split("/").filter(Boolean);
|
|
8966
|
+
const tail = segments[segments.length - 1];
|
|
8967
|
+
return typeof tail === "string" && matchPaths.includes(tail);
|
|
8968
|
+
}
|
|
8969
|
+
function createAthenaAuthSessionBridgePathHandlers(options) {
|
|
8970
|
+
const notFound = () => json(
|
|
8971
|
+
{
|
|
8972
|
+
error: "Not found"
|
|
8973
|
+
},
|
|
8974
|
+
{ status: 404 }
|
|
8975
|
+
);
|
|
8976
|
+
return {
|
|
8977
|
+
POST: async (request2) => {
|
|
8978
|
+
if (!isAthenaAuthSessionBridgePath(request2, options)) {
|
|
8979
|
+
return notFound();
|
|
8980
|
+
}
|
|
8981
|
+
return handleAthenaAuthSessionBridgePost(request2, options);
|
|
8982
|
+
},
|
|
8983
|
+
DELETE: (request2) => {
|
|
8984
|
+
if (!isAthenaAuthSessionBridgePath(request2, options)) {
|
|
8985
|
+
return notFound();
|
|
8986
|
+
}
|
|
8987
|
+
return handleAthenaAuthSessionBridgeDelete(request2, options);
|
|
8988
|
+
}
|
|
8989
|
+
};
|
|
8990
|
+
}
|
|
8991
|
+
|
|
8759
8992
|
// src/next/server.ts
|
|
8760
8993
|
function resolveUserId(session) {
|
|
8761
8994
|
return session?.user?.id ?? null;
|
|
@@ -8794,6 +9027,6 @@ async function resolveAthenaServerContext(options) {
|
|
|
8794
9027
|
};
|
|
8795
9028
|
}
|
|
8796
9029
|
|
|
8797
|
-
export { createAthenaServerClient, resolveAthenaServerContext };
|
|
9030
|
+
export { ATHENA_AUTH_SESSION_BRIDGE_ROUTE, ATHENA_AUTH_SESSION_COOKIE_NAME, ATHENA_AUTH_SESSION_COOKIE_NAMES, SESSION_COOKIE_PATTERNS, clearAthenaAuthSessionOnAppHost, createAthenaAuthSessionBridgeHandlers, createAthenaAuthSessionBridgePathHandlers, createAthenaServerClient, handleAthenaAuthSessionBridgeDelete, handleAthenaAuthSessionBridgePost, hasAuthSessionCookie, isAthenaAuthSessionBridgePath, persistAthenaAuthSessionOnAppHost, resolveAthenaServerContext, resolveSessionBridgePayload };
|
|
8798
9031
|
//# sourceMappingURL=server.js.map
|
|
8799
9032
|
//# sourceMappingURL=server.js.map
|