@xylex-group/athena 3.1.0 → 3.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/admin.cjs +55 -1
- package/dist/admin.cjs.map +1 -1
- package/dist/admin.d.cts +32 -8
- package/dist/admin.d.ts +32 -8
- package/dist/admin.js +54 -2
- package/dist/admin.js.map +1 -1
- package/dist/athena-auth-url-C1FbVmN6.d.cts +200 -0
- package/dist/athena-auth-url-C1FbVmN6.d.ts +200 -0
- package/dist/{athena-request-headers-C7Jy-c_D.d.ts → athena-request-headers-DzimbvOA.d.ts} +48 -200
- package/dist/{athena-request-headers-DujFFyMU.d.cts → athena-request-headers-Lr_m8xCV.d.cts} +48 -200
- package/dist/billing.cjs +1 -1
- package/dist/billing.cjs.map +1 -1
- package/dist/billing.js +1 -1
- package/dist/billing.js.map +1 -1
- package/dist/browser.cjs +602 -16
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.d.cts +8 -7
- package/dist/browser.d.ts +8 -7
- package/dist/browser.js +593 -17
- package/dist/browser.js.map +1 -1
- package/dist/cli/index.cjs +141 -6
- package/dist/cli/index.cjs.map +1 -1
- package/dist/cli/index.d.cts +2 -2
- package/dist/cli/index.d.ts +2 -2
- package/dist/cli/index.js +141 -6
- package/dist/cli/index.js.map +1 -1
- package/dist/env.cjs +130 -0
- package/dist/env.cjs.map +1 -0
- package/dist/env.d.cts +70 -0
- package/dist/env.d.ts +70 -0
- package/dist/env.js +122 -0
- package/dist/env.js.map +1 -0
- package/dist/index.cjs +624 -19
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -7
- package/dist/index.d.ts +8 -7
- package/dist/index.js +615 -20
- package/dist/index.js.map +1 -1
- package/dist/{model-form-BhWWsA-7.d.cts → model-form-3Gr8rkdT.d.cts} +24 -2
- package/dist/{model-form-BbdzJ9Uh.d.ts → model-form-CotpEL7z.d.ts} +24 -2
- package/dist/{module-xFd7_Igv.d.cts → module-CQmOaDzP.d.cts} +4 -4
- package/dist/{module-DKkJKOuJ.d.ts → module-CWkUTcUc.d.ts} +4 -4
- package/dist/next/client.cjs +123 -7
- package/dist/next/client.cjs.map +1 -1
- package/dist/next/client.d.cts +4 -3
- package/dist/next/client.d.ts +4 -3
- package/dist/next/client.js +123 -7
- package/dist/next/client.js.map +1 -1
- package/dist/next/server.cjs +1130 -364
- package/dist/next/server.cjs.map +1 -1
- package/dist/next/server.d.cts +121 -8
- package/dist/next/server.d.ts +121 -8
- package/dist/next/server.js +1120 -365
- package/dist/next/server.js.map +1 -1
- package/dist/{pipeline-DuKzYGia.d.cts → pipeline-BnRKO_Pd.d.cts} +1 -1
- package/dist/{pipeline-wer2G9xW.d.ts → pipeline-sWCmlFqu.d.ts} +1 -1
- package/dist/{proxy-request-headers-m4D2Tduy.d.ts → proxy-request-headers-CttlcuRb.d.ts} +1 -1
- package/dist/{proxy-request-headers-DGxdoyA0.d.cts → proxy-request-headers-pIBSn1Fw.d.cts} +1 -1
- package/dist/react.cjs +290 -31
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +59 -9
- package/dist/react.d.ts +59 -9
- package/dist/react.js +290 -32
- package/dist/react.js.map +1 -1
- package/dist/schema-handlers-BtT_IQFi.d.cts +138 -0
- package/dist/schema-handlers-VjFDhIMw.d.ts +138 -0
- package/dist/social-providers.d.cts +1 -1
- package/dist/social-providers.d.ts +1 -1
- package/dist/{types-CccOiXPo.d.ts → types-BDX8zS7w.d.ts} +12 -0
- package/dist/{types-AOY-GLu8.d.cts → types-BVKpQmfY.d.cts} +11 -0
- package/dist/{types-AOY-GLu8.d.ts → types-BVKpQmfY.d.ts} +11 -0
- package/dist/{types-1ztXDgPa.d.cts → types-D-Am7YSd.d.cts} +12 -0
- package/dist/utils.cjs +30 -0
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +3 -2
- package/dist/utils.d.ts +3 -2
- package/dist/utils.js +30 -1
- package/dist/utils.js.map +1 -1
- package/dist/{v3-client-CWfZHcKL.d.cts → v3-client-G1SLeHRa.d.cts} +23 -1
- package/dist/{v3-client-DZp2NEhK.d.ts → v3-client-ao8BWQ8v.d.ts} +23 -1
- package/package.json +16 -2
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolve Athena Auth base / upstream URLs from env or explicit config.
|
|
3
|
+
*
|
|
4
|
+
* Mirrors the Athena Auth UI base-url contract so apps and the SDK share one
|
|
5
|
+
* precedence order for `ATHENA_AUTH_*` environment variables.
|
|
6
|
+
*/
|
|
7
|
+
/** Default browser/proxy path for same-origin auth routing. */
|
|
8
|
+
declare const ATHENA_AUTH_PATH = "/api/auth";
|
|
9
|
+
/** Fallback origin when no absolute upstream is configured (server-side). */
|
|
10
|
+
declare const LOCAL_DEV_ORIGIN = "http://localhost:3000";
|
|
11
|
+
/**
|
|
12
|
+
* Hosted Athena Auth origin used when no upstream override is supplied.
|
|
13
|
+
* Origin only — no `/api/auth` suffix.
|
|
14
|
+
*/
|
|
15
|
+
declare const DEFAULT_ATHENA_AUTH_ORIGIN = "https://auth.athena-auth.com";
|
|
16
|
+
/**
|
|
17
|
+
* @deprecated Prefer {@link DEFAULT_ATHENA_AUTH_ORIGIN}.
|
|
18
|
+
* Kept for callers that used the older name.
|
|
19
|
+
*/
|
|
20
|
+
declare const DEFAULT_ATHENA_AUTH_UPSTREAM_URL = "https://auth.athena-auth.com";
|
|
21
|
+
/**
|
|
22
|
+
* Environment keys checked (in order) for the Athena Auth upstream URL.
|
|
23
|
+
*
|
|
24
|
+
* Prefer server-only keys first so private upstream hosts are not forced to
|
|
25
|
+
* rely on `NEXT_PUBLIC_*` values.
|
|
26
|
+
*/
|
|
27
|
+
declare const ATHENA_AUTH_UPSTREAM_ENV_KEYS: readonly ["ATHENA_AUTH_UPSTREAM_URL", "ATHENA_AUTH_URL", "NEXT_PUBLIC_ATHENA_AUTH_UPSTREAM_URL", "NEXT_PUBLIC_ATHENA_AUTH_URL"];
|
|
28
|
+
/**
|
|
29
|
+
* Auth UI naming parity (`base-url.ts`).
|
|
30
|
+
* Same ordered list as {@link ATHENA_AUTH_UPSTREAM_ENV_KEYS}.
|
|
31
|
+
*/
|
|
32
|
+
declare const ATHENA_AUTH_UPSTREAM_URL_ENV_NAMES: readonly ["ATHENA_AUTH_UPSTREAM_URL", "ATHENA_AUTH_URL", "NEXT_PUBLIC_ATHENA_AUTH_UPSTREAM_URL", "NEXT_PUBLIC_ATHENA_AUTH_URL"];
|
|
33
|
+
type AthenaAuthUpstreamEnvKey = (typeof ATHENA_AUTH_UPSTREAM_ENV_KEYS)[number];
|
|
34
|
+
/** Loose env map (Node `process.env` or a test fixture). */
|
|
35
|
+
type EnvLike = Record<string, string | undefined>;
|
|
36
|
+
type AthenaAuthUpstreamEnv = Partial<Record<AthenaAuthUpstreamEnvKey, string | undefined>> & EnvLike;
|
|
37
|
+
interface AthenaAuthClientBaseUrlOptions {
|
|
38
|
+
/**
|
|
39
|
+
* When `true` (default), ensure the client base ends with `/api/auth`.
|
|
40
|
+
* Set `false` when the auth server is mounted at a custom path or root.
|
|
41
|
+
*/
|
|
42
|
+
appendAuthPath?: boolean;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Returns `true` when the value is an absolute `http://` or `https://` URL.
|
|
46
|
+
*/
|
|
47
|
+
declare function isAbsoluteUrl(value: string): boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Read the first non-empty Athena Auth upstream URL from an env-like map.
|
|
50
|
+
*
|
|
51
|
+
* @returns Trimmed URL string, or `undefined` when none of the keys are set
|
|
52
|
+
*/
|
|
53
|
+
declare function readAthenaAuthUpstreamUrlFromEnv(env: EnvLike): string | undefined;
|
|
54
|
+
/**
|
|
55
|
+
* Normalize a consumer-supplied auth base URL so it targets `/api/auth`
|
|
56
|
+
* (unless the path already ends with that segment).
|
|
57
|
+
*
|
|
58
|
+
* Absolute URLs keep origin and rewrite pathname; relative paths are ensured
|
|
59
|
+
* to end with `/api/auth`.
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```ts
|
|
63
|
+
* normalizeAthenaAuthBaseUrl('https://auth.example.com')
|
|
64
|
+
* // => 'https://auth.example.com/api/auth'
|
|
65
|
+
*
|
|
66
|
+
* normalizeAthenaAuthBaseUrl('/api/auth')
|
|
67
|
+
* // => '/api/auth'
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
declare function normalizeAthenaAuthBaseUrl(urlOrPath: string): string;
|
|
71
|
+
/**
|
|
72
|
+
* Resolve the **server-side** Athena Auth upstream origin (no `/api/auth` suffix).
|
|
73
|
+
*
|
|
74
|
+
* Used when proxying or calling the auth host directly from Node / edge.
|
|
75
|
+
*
|
|
76
|
+
* @param rawUpstreamUrl - Explicit URL, env map, or omit to read `process.env`
|
|
77
|
+
* @returns Origin like `https://auth.example.com` (no trailing slash)
|
|
78
|
+
*/
|
|
79
|
+
declare function resolveAthenaAuthUpstreamUrl(rawUpstreamUrl?: string | AthenaAuthUpstreamEnv): string;
|
|
80
|
+
/**
|
|
81
|
+
* Resolve the **browser-facing** auth client base URL.
|
|
82
|
+
*
|
|
83
|
+
* Default behavior appends `/api/auth` for same-origin proxying. Pass
|
|
84
|
+
* `{ appendAuthPath: false }` to keep a custom path or root mount.
|
|
85
|
+
*
|
|
86
|
+
* Overloads match common call styles from Athena Auth UI and app code:
|
|
87
|
+
* - `resolveAthenaAuthClientBaseUrl("https://auth.example.com")`
|
|
88
|
+
* - `resolveAthenaAuthClientBaseUrl(process.env)`
|
|
89
|
+
* - `resolveAthenaAuthClientBaseUrl(undefined)` → env + defaults
|
|
90
|
+
* - `resolveAthenaAuthClientBaseUrl(path, upstream, { appendAuthPath: false })`
|
|
91
|
+
*/
|
|
92
|
+
declare function resolveAthenaAuthClientBaseUrl(configuredAuthBaseUrl?: string | EnvLike, rawUpstreamUrl?: string | AthenaAuthUpstreamEnv, options?: AthenaAuthClientBaseUrlOptions): string;
|
|
93
|
+
declare function resolveAthenaAuthClientBaseUrl(configuredAuthBaseUrl: string, rawUpstreamUrl?: string | AthenaAuthUpstreamEnv, options?: AthenaAuthClientBaseUrlOptions): string;
|
|
94
|
+
/**
|
|
95
|
+
* Build an absolute Athena Auth request URL for a path under the client base.
|
|
96
|
+
*
|
|
97
|
+
* Resolves at **call time** (reads env when `rawBaseUrl` is omitted) so module
|
|
98
|
+
* load order does not freeze a stale URL.
|
|
99
|
+
*
|
|
100
|
+
* @param path - Path relative to the auth base (leading slashes stripped)
|
|
101
|
+
* @param rawBaseUrl - Optional base string or env map
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
* ```ts
|
|
105
|
+
* resolveAthenaAuthRequestUrl('get-session', 'https://auth.example.com')
|
|
106
|
+
* // => 'https://auth.example.com/api/auth/get-session'
|
|
107
|
+
* ```
|
|
108
|
+
*/
|
|
109
|
+
declare function resolveAthenaAuthRequestUrl(path: string, rawBaseUrl?: string | EnvLike): string;
|
|
110
|
+
/** Relative auth path for email verification (`GET /verify-email`). */
|
|
111
|
+
declare const ATHENA_AUTH_VERIFY_EMAIL_PATH = "verify-email";
|
|
112
|
+
/**
|
|
113
|
+
* Relative segment for session lookup (`GET /get-session`).
|
|
114
|
+
* Prefer with {@link resolveAthenaAuthRequestUrl} when `base` already ends in `/api/auth`.
|
|
115
|
+
*/
|
|
116
|
+
declare const ATHENA_AUTH_GET_SESSION_PATH = "get-session";
|
|
117
|
+
/**
|
|
118
|
+
* Absolute app/proxy path for session lookup.
|
|
119
|
+
* Use with `new URL(ATHENA_AUTH_GET_SESSION_ABSOLUTE_PATH, appOrigin)` when
|
|
120
|
+
* `baseUrl` is the **app origin** (e.g. `https://app.example.com`), not the auth client base.
|
|
121
|
+
*/
|
|
122
|
+
declare const ATHENA_AUTH_GET_SESSION_ABSOLUTE_PATH = "/api/auth/get-session";
|
|
123
|
+
/**
|
|
124
|
+
* @deprecated Alias of {@link ATHENA_AUTH_GET_SESSION_ABSOLUTE_PATH} for drop-in
|
|
125
|
+
* replacement of app-local `AUTH_SESSION_PATH` constants. Prefer the `ATHENA_` name.
|
|
126
|
+
*/
|
|
127
|
+
declare const AUTH_SESSION_PATH = "/api/auth/get-session";
|
|
128
|
+
/**
|
|
129
|
+
* Query param that forces Athena Auth / Better Auth style session handlers to
|
|
130
|
+
* skip cookie cache and re-read the live session cookie.
|
|
131
|
+
*/
|
|
132
|
+
declare const ATHENA_AUTH_DISABLE_COOKIE_CACHE_QUERY_PARAM = "disableCookieCache";
|
|
133
|
+
/**
|
|
134
|
+
* @deprecated Alias of {@link ATHENA_AUTH_DISABLE_COOKIE_CACHE_QUERY_PARAM}.
|
|
135
|
+
*/
|
|
136
|
+
declare const DISABLE_COOKIE_CACHE_QUERY_PARAM = "disableCookieCache";
|
|
137
|
+
/** Value paired with {@link ATHENA_AUTH_DISABLE_COOKIE_CACHE_QUERY_PARAM}. */
|
|
138
|
+
declare const ATHENA_AUTH_DISABLE_COOKIE_CACHE_QUERY_VALUE = "true";
|
|
139
|
+
/**
|
|
140
|
+
* @deprecated Alias of {@link ATHENA_AUTH_DISABLE_COOKIE_CACHE_QUERY_VALUE}.
|
|
141
|
+
*/
|
|
142
|
+
declare const DISABLE_COOKIE_CACHE_QUERY_VALUE = "true";
|
|
143
|
+
/**
|
|
144
|
+
* Optional request/response header some apps use to pass serialized session
|
|
145
|
+
* payload between edge middleware and the app (not set by the SDK itself).
|
|
146
|
+
*/
|
|
147
|
+
declare const ATHENA_SESSION_DATA_HEADER = "x-session-data";
|
|
148
|
+
/**
|
|
149
|
+
* @deprecated Alias of {@link ATHENA_SESSION_DATA_HEADER}.
|
|
150
|
+
*/
|
|
151
|
+
declare const SESSION_DATA_HEADER = "x-session-data";
|
|
152
|
+
/**
|
|
153
|
+
* Absolute callback URL for email verification.
|
|
154
|
+
*
|
|
155
|
+
* Equivalent to `resolveAthenaAuthRequestUrl("verify-email")` — use this in
|
|
156
|
+
* sign-up / send-verification payloads as `callbackURL` instead of a local
|
|
157
|
+
* wrapper around Auth UI `base-url` helpers.
|
|
158
|
+
*
|
|
159
|
+
* @param rawBaseUrl - Optional base string or env map (defaults to process env)
|
|
160
|
+
* @returns e.g. `https://auth.example.com/api/auth/verify-email`
|
|
161
|
+
*
|
|
162
|
+
* @example
|
|
163
|
+
* ```ts
|
|
164
|
+
* import { resolveEmailVerificationCallbackUrl } from "@xylex-group/athena/utils"
|
|
165
|
+
*
|
|
166
|
+
* await client.auth.signUp.email({
|
|
167
|
+
* email,
|
|
168
|
+
* password,
|
|
169
|
+
* name,
|
|
170
|
+
* callbackURL: resolveEmailVerificationCallbackUrl(),
|
|
171
|
+
* })
|
|
172
|
+
* ```
|
|
173
|
+
*/
|
|
174
|
+
declare function resolveEmailVerificationCallbackUrl(rawBaseUrl?: string | EnvLike): string;
|
|
175
|
+
/**
|
|
176
|
+
* Build a same-origin (or absolute) **fresh** get-session URL.
|
|
177
|
+
*
|
|
178
|
+
* Appends `disableCookieCache=true` so middleware / RSC session probes do not
|
|
179
|
+
* reuse a stale cookie-cache entry.
|
|
180
|
+
*
|
|
181
|
+
* @param baseUrl - App origin (`https://app.example.com`) or any base accepted by
|
|
182
|
+
* the `URL` constructor. Resolves {@link ATHENA_AUTH_GET_SESSION_ABSOLUTE_PATH}
|
|
183
|
+
* (`/api/auth/get-session`) against that base.
|
|
184
|
+
* @returns URL such as `https://app.example.com/api/auth/get-session?disableCookieCache=true`
|
|
185
|
+
*
|
|
186
|
+
* @example
|
|
187
|
+
* ```ts
|
|
188
|
+
* import { createFreshSessionLookupUrl } from "@xylex-group/athena/utils"
|
|
189
|
+
*
|
|
190
|
+
* const url = createFreshSessionLookupUrl("https://app.example.com")
|
|
191
|
+
* await fetch(url, { headers: { cookie: requestHeaders.get("cookie") ?? "" } })
|
|
192
|
+
* ```
|
|
193
|
+
*
|
|
194
|
+
* For auth-client base URLs that already include `/api/auth`, prefer:
|
|
195
|
+
* `resolveAthenaAuthRequestUrl("get-session", authBase) + "?disableCookieCache=true"`
|
|
196
|
+
* or pass the **app** origin into this helper when you proxy `/api/auth/*` locally.
|
|
197
|
+
*/
|
|
198
|
+
declare function createFreshSessionLookupUrl(baseUrl: string | URL): URL;
|
|
199
|
+
|
|
200
|
+
export { ATHENA_AUTH_DISABLE_COOKIE_CACHE_QUERY_PARAM as A, DEFAULT_ATHENA_AUTH_ORIGIN as D, type EnvLike as E, LOCAL_DEV_ORIGIN as L, SESSION_DATA_HEADER as S, ATHENA_AUTH_DISABLE_COOKIE_CACHE_QUERY_VALUE as a, ATHENA_AUTH_GET_SESSION_ABSOLUTE_PATH as b, ATHENA_AUTH_GET_SESSION_PATH as c, ATHENA_AUTH_PATH as d, ATHENA_AUTH_UPSTREAM_ENV_KEYS as e, ATHENA_AUTH_UPSTREAM_URL_ENV_NAMES as f, ATHENA_AUTH_VERIFY_EMAIL_PATH as g, ATHENA_SESSION_DATA_HEADER as h, AUTH_SESSION_PATH as i, type AthenaAuthClientBaseUrlOptions as j, type AthenaAuthUpstreamEnv as k, type AthenaAuthUpstreamEnvKey as l, DEFAULT_ATHENA_AUTH_UPSTREAM_URL as m, DISABLE_COOKIE_CACHE_QUERY_PARAM as n, DISABLE_COOKIE_CACHE_QUERY_VALUE as o, createFreshSessionLookupUrl as p, isAbsoluteUrl as q, normalizeAthenaAuthBaseUrl as r, readAthenaAuthUpstreamUrlFromEnv as s, resolveAthenaAuthClientBaseUrl as t, resolveAthenaAuthRequestUrl as u, resolveAthenaAuthUpstreamUrl as v, resolveEmailVerificationCallbackUrl as w };
|
|
@@ -77,6 +77,53 @@ interface ClearAuthCookiesOptions {
|
|
|
77
77
|
* }
|
|
78
78
|
* ```
|
|
79
79
|
*/
|
|
80
|
+
interface SignOutAndClearAthenaSessionOptions {
|
|
81
|
+
/**
|
|
82
|
+
* Call the auth client's sign-out (or equivalent). Failures are swallowed so
|
|
83
|
+
* cookies still clear; rethrow by setting `throwOnSignOutError`.
|
|
84
|
+
*/
|
|
85
|
+
signOut: () => Promise<unknown> | unknown;
|
|
86
|
+
/**
|
|
87
|
+
* Optional app-host session bridge clear
|
|
88
|
+
* (`clearAthenaAuthSessionOnAppHost` from `@xylex-group/athena/next/client`).
|
|
89
|
+
*/
|
|
90
|
+
clearBridge?: () => Promise<unknown> | unknown;
|
|
91
|
+
/**
|
|
92
|
+
* When set and running in a browser, hard-redirect after clearing cookies.
|
|
93
|
+
* Pass `null` / omit to skip navigation (caller uses soft navigate).
|
|
94
|
+
*/
|
|
95
|
+
redirectTo?: string | null;
|
|
96
|
+
/**
|
|
97
|
+
* When false, skip `window.location` even if `redirectTo` is set.
|
|
98
|
+
* @default true when `redirectTo` is a non-empty string
|
|
99
|
+
*/
|
|
100
|
+
hardRedirect?: boolean;
|
|
101
|
+
clearCookieOptions?: ClearAuthCookiesOptions;
|
|
102
|
+
throwOnSignOutError?: boolean;
|
|
103
|
+
}
|
|
104
|
+
interface SignOutAndClearAthenaSessionResult {
|
|
105
|
+
clearedCookies: string[];
|
|
106
|
+
signOutError: unknown | null;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Sign out, clear Athena/Better Auth cookies, optionally clear the app-host
|
|
110
|
+
* session bridge cookie, then optionally hard-redirect.
|
|
111
|
+
*
|
|
112
|
+
* Prefer this over per-app `try/finally` copy-paste of clear + redirect.
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* ```ts
|
|
116
|
+
* import { signOutAndClearAthenaSession } from "@xylex-group/athena/utils"
|
|
117
|
+
* import { clearAthenaAuthSessionOnAppHost } from "@xylex-group/athena/next/client"
|
|
118
|
+
*
|
|
119
|
+
* await signOutAndClearAthenaSession({
|
|
120
|
+
* signOut: () => authClient.signOut({ fetchOptions: { throw: true } }),
|
|
121
|
+
* clearBridge: () => clearAthenaAuthSessionOnAppHost(),
|
|
122
|
+
* redirectTo: "/sign-in",
|
|
123
|
+
* })
|
|
124
|
+
* ```
|
|
125
|
+
*/
|
|
126
|
+
declare function signOutAndClearAthenaSession(options: SignOutAndClearAthenaSessionOptions): Promise<SignOutAndClearAthenaSessionResult>;
|
|
80
127
|
declare function clearAuthCookies(options?: ClearAuthCookiesOptions): string[];
|
|
81
128
|
|
|
82
129
|
/**
|
|
@@ -177,205 +224,6 @@ declare function shouldRedirectAuthenticatedAuthMode(mode: AuthMode): boolean;
|
|
|
177
224
|
*/
|
|
178
225
|
declare function resolveAuthModeRedirect(mode: string | undefined, redirects?: AuthModeRedirects): string | null;
|
|
179
226
|
|
|
180
|
-
/**
|
|
181
|
-
* Resolve Athena Auth base / upstream URLs from env or explicit config.
|
|
182
|
-
*
|
|
183
|
-
* Mirrors the Athena Auth UI base-url contract so apps and the SDK share one
|
|
184
|
-
* precedence order for `ATHENA_AUTH_*` environment variables.
|
|
185
|
-
*/
|
|
186
|
-
/** Default browser/proxy path for same-origin auth routing. */
|
|
187
|
-
declare const ATHENA_AUTH_PATH = "/api/auth";
|
|
188
|
-
/** Fallback origin when no absolute upstream is configured (server-side). */
|
|
189
|
-
declare const LOCAL_DEV_ORIGIN = "http://localhost:3000";
|
|
190
|
-
/**
|
|
191
|
-
* Hosted Athena Auth origin used when no upstream override is supplied.
|
|
192
|
-
* Origin only — no `/api/auth` suffix.
|
|
193
|
-
*/
|
|
194
|
-
declare const DEFAULT_ATHENA_AUTH_ORIGIN = "https://auth.athena-auth.com";
|
|
195
|
-
/**
|
|
196
|
-
* @deprecated Prefer {@link DEFAULT_ATHENA_AUTH_ORIGIN}.
|
|
197
|
-
* Kept for callers that used the older name.
|
|
198
|
-
*/
|
|
199
|
-
declare const DEFAULT_ATHENA_AUTH_UPSTREAM_URL = "https://auth.athena-auth.com";
|
|
200
|
-
/**
|
|
201
|
-
* Environment keys checked (in order) for the Athena Auth upstream URL.
|
|
202
|
-
*
|
|
203
|
-
* Prefer server-only keys first so private upstream hosts are not forced to
|
|
204
|
-
* rely on `NEXT_PUBLIC_*` values.
|
|
205
|
-
*/
|
|
206
|
-
declare const ATHENA_AUTH_UPSTREAM_ENV_KEYS: readonly ["ATHENA_AUTH_UPSTREAM_URL", "ATHENA_AUTH_URL", "NEXT_PUBLIC_ATHENA_AUTH_UPSTREAM_URL", "NEXT_PUBLIC_ATHENA_AUTH_URL"];
|
|
207
|
-
/**
|
|
208
|
-
* Auth UI naming parity (`base-url.ts`).
|
|
209
|
-
* Same ordered list as {@link ATHENA_AUTH_UPSTREAM_ENV_KEYS}.
|
|
210
|
-
*/
|
|
211
|
-
declare const ATHENA_AUTH_UPSTREAM_URL_ENV_NAMES: readonly ["ATHENA_AUTH_UPSTREAM_URL", "ATHENA_AUTH_URL", "NEXT_PUBLIC_ATHENA_AUTH_UPSTREAM_URL", "NEXT_PUBLIC_ATHENA_AUTH_URL"];
|
|
212
|
-
type AthenaAuthUpstreamEnvKey = (typeof ATHENA_AUTH_UPSTREAM_ENV_KEYS)[number];
|
|
213
|
-
/** Loose env map (Node `process.env` or a test fixture). */
|
|
214
|
-
type EnvLike = Record<string, string | undefined>;
|
|
215
|
-
type AthenaAuthUpstreamEnv = Partial<Record<AthenaAuthUpstreamEnvKey, string | undefined>> & EnvLike;
|
|
216
|
-
interface AthenaAuthClientBaseUrlOptions {
|
|
217
|
-
/**
|
|
218
|
-
* When `true` (default), ensure the client base ends with `/api/auth`.
|
|
219
|
-
* Set `false` when the auth server is mounted at a custom path or root.
|
|
220
|
-
*/
|
|
221
|
-
appendAuthPath?: boolean;
|
|
222
|
-
}
|
|
223
|
-
/**
|
|
224
|
-
* Returns `true` when the value is an absolute `http://` or `https://` URL.
|
|
225
|
-
*/
|
|
226
|
-
declare function isAbsoluteUrl(value: string): boolean;
|
|
227
|
-
/**
|
|
228
|
-
* Read the first non-empty Athena Auth upstream URL from an env-like map.
|
|
229
|
-
*
|
|
230
|
-
* @returns Trimmed URL string, or `undefined` when none of the keys are set
|
|
231
|
-
*/
|
|
232
|
-
declare function readAthenaAuthUpstreamUrlFromEnv(env: EnvLike): string | undefined;
|
|
233
|
-
/**
|
|
234
|
-
* Normalize a consumer-supplied auth base URL so it targets `/api/auth`
|
|
235
|
-
* (unless the path already ends with that segment).
|
|
236
|
-
*
|
|
237
|
-
* Absolute URLs keep origin and rewrite pathname; relative paths are ensured
|
|
238
|
-
* to end with `/api/auth`.
|
|
239
|
-
*
|
|
240
|
-
* @example
|
|
241
|
-
* ```ts
|
|
242
|
-
* normalizeAthenaAuthBaseUrl('https://auth.example.com')
|
|
243
|
-
* // => 'https://auth.example.com/api/auth'
|
|
244
|
-
*
|
|
245
|
-
* normalizeAthenaAuthBaseUrl('/api/auth')
|
|
246
|
-
* // => '/api/auth'
|
|
247
|
-
* ```
|
|
248
|
-
*/
|
|
249
|
-
declare function normalizeAthenaAuthBaseUrl(urlOrPath: string): string;
|
|
250
|
-
/**
|
|
251
|
-
* Resolve the **server-side** Athena Auth upstream origin (no `/api/auth` suffix).
|
|
252
|
-
*
|
|
253
|
-
* Used when proxying or calling the auth host directly from Node / edge.
|
|
254
|
-
*
|
|
255
|
-
* @param rawUpstreamUrl - Explicit URL, env map, or omit to read `process.env`
|
|
256
|
-
* @returns Origin like `https://auth.example.com` (no trailing slash)
|
|
257
|
-
*/
|
|
258
|
-
declare function resolveAthenaAuthUpstreamUrl(rawUpstreamUrl?: string | AthenaAuthUpstreamEnv): string;
|
|
259
|
-
/**
|
|
260
|
-
* Resolve the **browser-facing** auth client base URL.
|
|
261
|
-
*
|
|
262
|
-
* Default behavior appends `/api/auth` for same-origin proxying. Pass
|
|
263
|
-
* `{ appendAuthPath: false }` to keep a custom path or root mount.
|
|
264
|
-
*
|
|
265
|
-
* Overloads match common call styles from Athena Auth UI and app code:
|
|
266
|
-
* - `resolveAthenaAuthClientBaseUrl("https://auth.example.com")`
|
|
267
|
-
* - `resolveAthenaAuthClientBaseUrl(process.env)`
|
|
268
|
-
* - `resolveAthenaAuthClientBaseUrl(undefined)` → env + defaults
|
|
269
|
-
* - `resolveAthenaAuthClientBaseUrl(path, upstream, { appendAuthPath: false })`
|
|
270
|
-
*/
|
|
271
|
-
declare function resolveAthenaAuthClientBaseUrl(configuredAuthBaseUrl?: string | EnvLike, rawUpstreamUrl?: string | AthenaAuthUpstreamEnv, options?: AthenaAuthClientBaseUrlOptions): string;
|
|
272
|
-
declare function resolveAthenaAuthClientBaseUrl(configuredAuthBaseUrl: string, rawUpstreamUrl?: string | AthenaAuthUpstreamEnv, options?: AthenaAuthClientBaseUrlOptions): string;
|
|
273
|
-
/**
|
|
274
|
-
* Build an absolute Athena Auth request URL for a path under the client base.
|
|
275
|
-
*
|
|
276
|
-
* Resolves at **call time** (reads env when `rawBaseUrl` is omitted) so module
|
|
277
|
-
* load order does not freeze a stale URL.
|
|
278
|
-
*
|
|
279
|
-
* @param path - Path relative to the auth base (leading slashes stripped)
|
|
280
|
-
* @param rawBaseUrl - Optional base string or env map
|
|
281
|
-
*
|
|
282
|
-
* @example
|
|
283
|
-
* ```ts
|
|
284
|
-
* resolveAthenaAuthRequestUrl('get-session', 'https://auth.example.com')
|
|
285
|
-
* // => 'https://auth.example.com/api/auth/get-session'
|
|
286
|
-
* ```
|
|
287
|
-
*/
|
|
288
|
-
declare function resolveAthenaAuthRequestUrl(path: string, rawBaseUrl?: string | EnvLike): string;
|
|
289
|
-
/** Relative auth path for email verification (`GET /verify-email`). */
|
|
290
|
-
declare const ATHENA_AUTH_VERIFY_EMAIL_PATH = "verify-email";
|
|
291
|
-
/**
|
|
292
|
-
* Relative segment for session lookup (`GET /get-session`).
|
|
293
|
-
* Prefer with {@link resolveAthenaAuthRequestUrl} when `base` already ends in `/api/auth`.
|
|
294
|
-
*/
|
|
295
|
-
declare const ATHENA_AUTH_GET_SESSION_PATH = "get-session";
|
|
296
|
-
/**
|
|
297
|
-
* Absolute app/proxy path for session lookup.
|
|
298
|
-
* Use with `new URL(ATHENA_AUTH_GET_SESSION_ABSOLUTE_PATH, appOrigin)` when
|
|
299
|
-
* `baseUrl` is the **app origin** (e.g. `https://app.example.com`), not the auth client base.
|
|
300
|
-
*/
|
|
301
|
-
declare const ATHENA_AUTH_GET_SESSION_ABSOLUTE_PATH = "/api/auth/get-session";
|
|
302
|
-
/**
|
|
303
|
-
* @deprecated Alias of {@link ATHENA_AUTH_GET_SESSION_ABSOLUTE_PATH} for drop-in
|
|
304
|
-
* replacement of app-local `AUTH_SESSION_PATH` constants. Prefer the `ATHENA_` name.
|
|
305
|
-
*/
|
|
306
|
-
declare const AUTH_SESSION_PATH = "/api/auth/get-session";
|
|
307
|
-
/**
|
|
308
|
-
* Query param that forces Athena Auth / Better Auth style session handlers to
|
|
309
|
-
* skip cookie cache and re-read the live session cookie.
|
|
310
|
-
*/
|
|
311
|
-
declare const ATHENA_AUTH_DISABLE_COOKIE_CACHE_QUERY_PARAM = "disableCookieCache";
|
|
312
|
-
/**
|
|
313
|
-
* @deprecated Alias of {@link ATHENA_AUTH_DISABLE_COOKIE_CACHE_QUERY_PARAM}.
|
|
314
|
-
*/
|
|
315
|
-
declare const DISABLE_COOKIE_CACHE_QUERY_PARAM = "disableCookieCache";
|
|
316
|
-
/** Value paired with {@link ATHENA_AUTH_DISABLE_COOKIE_CACHE_QUERY_PARAM}. */
|
|
317
|
-
declare const ATHENA_AUTH_DISABLE_COOKIE_CACHE_QUERY_VALUE = "true";
|
|
318
|
-
/**
|
|
319
|
-
* @deprecated Alias of {@link ATHENA_AUTH_DISABLE_COOKIE_CACHE_QUERY_VALUE}.
|
|
320
|
-
*/
|
|
321
|
-
declare const DISABLE_COOKIE_CACHE_QUERY_VALUE = "true";
|
|
322
|
-
/**
|
|
323
|
-
* Optional request/response header some apps use to pass serialized session
|
|
324
|
-
* payload between edge middleware and the app (not set by the SDK itself).
|
|
325
|
-
*/
|
|
326
|
-
declare const ATHENA_SESSION_DATA_HEADER = "x-session-data";
|
|
327
|
-
/**
|
|
328
|
-
* @deprecated Alias of {@link ATHENA_SESSION_DATA_HEADER}.
|
|
329
|
-
*/
|
|
330
|
-
declare const SESSION_DATA_HEADER = "x-session-data";
|
|
331
|
-
/**
|
|
332
|
-
* Absolute callback URL for email verification.
|
|
333
|
-
*
|
|
334
|
-
* Equivalent to `resolveAthenaAuthRequestUrl("verify-email")` — use this in
|
|
335
|
-
* sign-up / send-verification payloads as `callbackURL` instead of a local
|
|
336
|
-
* wrapper around Auth UI `base-url` helpers.
|
|
337
|
-
*
|
|
338
|
-
* @param rawBaseUrl - Optional base string or env map (defaults to process env)
|
|
339
|
-
* @returns e.g. `https://auth.example.com/api/auth/verify-email`
|
|
340
|
-
*
|
|
341
|
-
* @example
|
|
342
|
-
* ```ts
|
|
343
|
-
* import { resolveEmailVerificationCallbackUrl } from "@xylex-group/athena/utils"
|
|
344
|
-
*
|
|
345
|
-
* await client.auth.signUp.email({
|
|
346
|
-
* email,
|
|
347
|
-
* password,
|
|
348
|
-
* name,
|
|
349
|
-
* callbackURL: resolveEmailVerificationCallbackUrl(),
|
|
350
|
-
* })
|
|
351
|
-
* ```
|
|
352
|
-
*/
|
|
353
|
-
declare function resolveEmailVerificationCallbackUrl(rawBaseUrl?: string | EnvLike): string;
|
|
354
|
-
/**
|
|
355
|
-
* Build a same-origin (or absolute) **fresh** get-session URL.
|
|
356
|
-
*
|
|
357
|
-
* Appends `disableCookieCache=true` so middleware / RSC session probes do not
|
|
358
|
-
* reuse a stale cookie-cache entry.
|
|
359
|
-
*
|
|
360
|
-
* @param baseUrl - App origin (`https://app.example.com`) or any base accepted by
|
|
361
|
-
* the `URL` constructor. Resolves {@link ATHENA_AUTH_GET_SESSION_ABSOLUTE_PATH}
|
|
362
|
-
* (`/api/auth/get-session`) against that base.
|
|
363
|
-
* @returns URL such as `https://app.example.com/api/auth/get-session?disableCookieCache=true`
|
|
364
|
-
*
|
|
365
|
-
* @example
|
|
366
|
-
* ```ts
|
|
367
|
-
* import { createFreshSessionLookupUrl } from "@xylex-group/athena/utils"
|
|
368
|
-
*
|
|
369
|
-
* const url = createFreshSessionLookupUrl("https://app.example.com")
|
|
370
|
-
* await fetch(url, { headers: { cookie: requestHeaders.get("cookie") ?? "" } })
|
|
371
|
-
* ```
|
|
372
|
-
*
|
|
373
|
-
* For auth-client base URLs that already include `/api/auth`, prefer:
|
|
374
|
-
* `resolveAthenaAuthRequestUrl("get-session", authBase) + "?disableCookieCache=true"`
|
|
375
|
-
* or pass the **app** origin into this helper when you proxy `/api/auth/*` locally.
|
|
376
|
-
*/
|
|
377
|
-
declare function createFreshSessionLookupUrl(baseUrl: string | URL): URL;
|
|
378
|
-
|
|
379
227
|
declare function asString(value: unknown): string | null;
|
|
380
228
|
declare function asBoolean(value: unknown): boolean;
|
|
381
229
|
declare function asBooleanOrNull(value: unknown): boolean | null;
|
|
@@ -458,4 +306,4 @@ declare function buildAthenaGatewayHeaders(input: {
|
|
|
458
306
|
}): Record<string, string>;
|
|
459
307
|
declare function buildAthenaRequestHeaders(input: BuildAthenaRequestHeadersInput): Record<string, string>;
|
|
460
308
|
|
|
461
|
-
export {
|
|
309
|
+
export { ATHENA_AUTH_COOKIE_PREFIXES as A, type BuildAthenaRequestHeadersInput as B, type ClearAuthCookiesOptions as C, shouldRedirectAuthenticatedAuthView as D, applyAthenaApiKeyHeaders as E, applyAthenaAuthContextHeaders as F, applyAthenaPgUriHeaders as G, buildServiceRequestHeaders as H, hasHeaderIgnoreCase as I, resolveHeaderValue as J, resolveRequestHeaderOverrides as K, DEFAULT_AUTH_COOKIE_PREFIXES as L, type SignOutAndClearAthenaSessionResult as M, asBoolean as N, asBooleanOrNull as O, asIdentifier as P, asNumber as Q, type ResolvedRequestHeaderOverrides as R, type SignOutAndClearAthenaSessionOptions as S, asRecord as T, asStringArray as U, firstString as V, signOutAndClearAthenaSession as W, AUTHENTICATED_REDIRECT_MODE_SET as a, AUTHENTICATED_REDIRECT_VIEW_SET as b, AUTH_DEFAULT_VIEW as c, AUTH_MODE_REDIRECTS as d, AUTH_MODE_SET as e, AUTH_ROUTES as f, AUTH_TWO_FACTOR_SEGMENT as g, AUTH_VIEW_BY_SEGMENT as h, type AthenaRequestHeaderOverrideFields as i, type AthenaRequestHeaderProfile as j, type AuthMode as k, type AuthModeRedirects as l, type AuthRoutes as m, type AuthView as n, asNonEmptyString as o, asString as p, buildAthenaGatewayHeaders as q, buildAthenaRequestHeaders as r, clearAuthCookies as s, createAuthModeRedirects as t, createAuthRoutes as u, isAuthMode as v, readTrimmedString as w, resolveAuthModeRedirect as x, resolveAuthViewFromSegment as y, shouldRedirectAuthenticatedAuthMode as z };
|