@xylex-group/athena 3.0.3 → 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 +912 -5
- 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 +881 -6
- package/dist/browser.js.map +1 -1
- package/dist/cli/index.cjs +7909 -7061
- package/dist/cli/index.cjs.map +1 -1
- package/dist/cli/index.d.cts +17 -10
- package/dist/cli/index.d.ts +17 -10
- package/dist/cli/index.js +7911 -7063
- 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 +1570 -98
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +31 -8
- package/dist/index.d.ts +31 -8
- package/dist/index.js +1532 -100
- package/dist/index.js.map +1 -1
- package/dist/model-form-3Gr8rkdT.d.cts +281 -0
- package/dist/model-form-CotpEL7z.d.ts +281 -0
- package/dist/{module-CPG3ULxQ.d.cts → module-CQmOaDzP.d.cts} +4 -4
- package/dist/{module-BruTcxe0.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-BnRKO_Pd.d.cts +93 -0
- package/dist/pipeline-sWCmlFqu.d.ts +93 -0
- 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 +672 -16
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +123 -8
- package/dist/react.d.ts +123 -8
- package/dist/react.js +671 -17
- 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-D6tZ9aoq.d.ts → types-BDX8zS7w.d.ts} +40 -1
- 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-DFr2cL1N.d.cts → types-D-Am7YSd.d.cts} +40 -1
- 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
- package/dist/model-form-Dh0sisdL.d.ts +0 -97
- package/dist/model-form-oOAJUVd4.d.cts +0 -97
- package/dist/pipeline-CIzV9f7b.d.cts +0 -8
- package/dist/pipeline-DNlc8Ayn.d.ts +0 -8
package/dist/next/server.d.cts
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
import { ad as AthenaAuthSessionResponse } from '../types-
|
|
1
|
+
import { ad as AthenaAuthSessionResponse } from '../types-BVKpQmfY.cjs';
|
|
2
2
|
import { r as AthenaClientModelsInput } from '../types-CgCv5o6R.cjs';
|
|
3
|
-
import { ax as AthenaRequestContext, ah as AthenaClientConfig, ag as AthenaClient } from '../v3-client-
|
|
3
|
+
import { ax as AthenaRequestContext, ah as AthenaClientConfig, ag as AthenaClient } from '../v3-client-G1SLeHRa.cjs';
|
|
4
|
+
import { OrganizationLike } from '../organization.cjs';
|
|
5
|
+
export { ActiveOrganizationSessionLike, EnsureActiveOrganizationOptions, EnsureActiveOrganizationResult, ensureActiveOrganization } from '../organization.cjs';
|
|
4
6
|
import { g as AthenaAuthSessionBridgeOptions, h as AthenaAuthSessionBridgePathOptions } from '../payload-DWI1rw-e.cjs';
|
|
5
7
|
export { A as ATHENA_AUTH_SESSION_BRIDGE_ROUTE, a as ATHENA_AUTH_SESSION_COOKIE_NAME, b as ATHENA_AUTH_SESSION_COOKIE_NAMES, c as AthenaAuthSessionBridgeClientOptions, d as AthenaAuthSessionBridgePayload, e as AthenaAuthSessionBridgeSource, f as clearAthenaAuthSessionOnAppHost, p as persistAthenaAuthSessionOnAppHost, r as resolveSessionBridgePayload } from '../payload-DWI1rw-e.cjs';
|
|
6
8
|
export { S as SESSION_COOKIE_PATTERNS, h as hasAuthSessionCookie } from '../session-cookie-detection-BqOp9mO6.cjs';
|
|
7
|
-
export { A as
|
|
8
|
-
export {
|
|
9
|
-
export {
|
|
9
|
+
export { A as ATHENA_AUTH_DISABLE_COOKIE_CACHE_QUERY_PARAM, a as ATHENA_AUTH_DISABLE_COOKIE_CACHE_QUERY_VALUE, b as ATHENA_AUTH_GET_SESSION_ABSOLUTE_PATH, c as ATHENA_AUTH_GET_SESSION_PATH, d as ATHENA_AUTH_PATH, e as ATHENA_AUTH_UPSTREAM_ENV_KEYS, f as ATHENA_AUTH_UPSTREAM_URL_ENV_NAMES, g as ATHENA_AUTH_VERIFY_EMAIL_PATH, h as ATHENA_SESSION_DATA_HEADER, i as AUTH_SESSION_PATH, j as AthenaAuthClientBaseUrlOptions, k as AthenaAuthUpstreamEnv, l as AthenaAuthUpstreamEnvKey, D as DEFAULT_ATHENA_AUTH_ORIGIN, m as DEFAULT_ATHENA_AUTH_UPSTREAM_URL, n as DISABLE_COOKIE_CACHE_QUERY_PARAM, o as DISABLE_COOKIE_CACHE_QUERY_VALUE, E as EnvLike, L as LOCAL_DEV_ORIGIN, S as SESSION_DATA_HEADER, p as createFreshSessionLookupUrl, q as isAbsoluteUrl, r as normalizeAthenaAuthBaseUrl, s as readAthenaAuthUpstreamUrlFromEnv, t as resolveAthenaAuthClientBaseUrl, u as resolveAthenaAuthRequestUrl, v as resolveAthenaAuthUpstreamUrl, w as resolveEmailVerificationCallbackUrl } from '../athena-auth-url-C1FbVmN6.cjs';
|
|
10
|
+
export { A as ATHENA_AUTH_COOKIE_PREFIXES, a as AUTHENTICATED_REDIRECT_MODE_SET, b as AUTHENTICATED_REDIRECT_VIEW_SET, c as AUTH_DEFAULT_VIEW, d as AUTH_MODE_REDIRECTS, e as AUTH_MODE_SET, f as AUTH_ROUTES, g as AUTH_TWO_FACTOR_SEGMENT, h as AUTH_VIEW_BY_SEGMENT, i as AthenaRequestHeaderOverrideFields, j as AthenaRequestHeaderProfile, k as AuthMode, l as AuthModeRedirects, m as AuthRoutes, n as AuthView, B as BuildAthenaRequestHeadersInput, C as ClearAuthCookiesOptions, R as ResolvedRequestHeaderOverrides, E as applyAthenaApiKeyHeaders, F as applyAthenaAuthContextHeaders, G as applyAthenaPgUriHeaders, o as asNonEmptyString, p as asString, q as buildAthenaGatewayHeaders, r as buildAthenaRequestHeaders, H as buildServiceRequestHeaders, s as clearAuthCookies, t as createAuthModeRedirects, u as createAuthRoutes, I as hasHeaderIgnoreCase, v as isAuthMode, w as readTrimmedString, x as resolveAuthModeRedirect, y as resolveAuthViewFromSegment, J as resolveHeaderValue, K as resolveRequestHeaderOverrides, z as shouldRedirectAuthenticatedAuthMode, D as shouldRedirectAuthenticatedAuthView } from '../athena-request-headers-Lr_m8xCV.cjs';
|
|
11
|
+
export { G as GetOriginFromHeadersOptions, g as getOriginFromHeaders, i as isDynamicServerUsageError, p as proxyRequestHeaders, r as readEnv, a as requireEnv } from '../proxy-request-headers-pIBSn1Fw.cjs';
|
|
12
|
+
export { A as ATHENA_TABLE_SCHEMA_ROUTE, a as AthenaTableCatalogColumn, b as AthenaTableCatalogQueryClient, c as AthenaTableCatalogRelation, d as AthenaTableCatalogResponse, e as AthenaTableCatalogTable, f as AthenaTableSchemaConfig, g as AthenaTableSchemaHandlerOptions, h as AthenaTableShowcaseConfig, F as FetchAthenaTableCatalogOptions, T as TableCatalogColumn, i as TableCatalogRelation, j as TableCatalogResponse, k as TableCatalogTable, l as buildAthenaTableCatalogQueries, m as createAthenaTableSchemaHandlers, n as fetchAthenaTableCatalog, o as fetchTableCatalog, p as handleAthenaTableSchemaPost, q as hasAthenaTableSchemaCredentials, r as isAthenaTableSchemaConfig, s as parseAthenaTableSchemaScope } from '../schema-handlers-BtT_IQFi.cjs';
|
|
10
13
|
import '../types-Bltx6iL6.cjs';
|
|
11
14
|
import '../module-C_ab-MM1.cjs';
|
|
12
15
|
|
|
@@ -102,8 +105,114 @@ interface AthenaServerRequestOptions {
|
|
|
102
105
|
}
|
|
103
106
|
declare function resolveNextRequestContext(options?: AthenaServerRequestOptions): Promise<AthenaRequestContext>;
|
|
104
107
|
|
|
108
|
+
interface ResolveActiveOrganizationIdArgs {
|
|
109
|
+
rawActiveOrganizationId: string | null;
|
|
110
|
+
session: AthenaAuthSessionResponse;
|
|
111
|
+
userId: string;
|
|
112
|
+
}
|
|
113
|
+
interface GetServerSessionEnsureActiveOptions<TOrganization extends OrganizationLike = OrganizationLike> {
|
|
114
|
+
listOrganizations: () => Promise<readonly TOrganization[]>;
|
|
115
|
+
onError?: (error: unknown) => void;
|
|
116
|
+
selectOrganizationId?: (organizations: readonly TOrganization[]) => string | null;
|
|
117
|
+
setActiveOrganization: (organizationId: string) => Promise<unknown>;
|
|
118
|
+
}
|
|
119
|
+
interface GetServerSessionOptions extends AthenaServerRequestOptions {
|
|
120
|
+
/**
|
|
121
|
+
* Absolute get-session URL. When omitted, built from `appOrigin` via
|
|
122
|
+
* {@link createFreshSessionLookupUrl}.
|
|
123
|
+
*/
|
|
124
|
+
authSessionUrl?: string | URL;
|
|
125
|
+
/**
|
|
126
|
+
* App origin used to build `/api/auth/get-session?disableCookieCache=true`
|
|
127
|
+
* when `authSessionUrl` is not set.
|
|
128
|
+
*/
|
|
129
|
+
appOrigin?: string | URL;
|
|
130
|
+
/**
|
|
131
|
+
* Raw middleware-forwarded session JSON (or omit to read
|
|
132
|
+
* {@link ATHENA_SESSION_DATA_HEADER} from `requestHeaders`).
|
|
133
|
+
*/
|
|
134
|
+
sessionDataHeader?: string | null;
|
|
135
|
+
/** Custom fetch (tests / edge). Defaults to `globalThis.fetch`. */
|
|
136
|
+
fetchImpl?: typeof fetch;
|
|
137
|
+
/**
|
|
138
|
+
* When true (default), skip the network get-session call if cookies and
|
|
139
|
+
* bearer token are both absent.
|
|
140
|
+
*/
|
|
141
|
+
skipFetchWithoutCredentials?: boolean;
|
|
142
|
+
/**
|
|
143
|
+
* Product org policy. Runs after the raw session is loaded and before
|
|
144
|
+
* optional ensure-active. Does not replace membership checks in the app.
|
|
145
|
+
*/
|
|
146
|
+
resolveActiveOrganizationId?: (args: ResolveActiveOrganizationIdArgs) => string | null | Promise<string | null>;
|
|
147
|
+
/**
|
|
148
|
+
* Optional bootstrap when the session has no active org. Inject list/set
|
|
149
|
+
* from your auth client; the package does not own org transport here.
|
|
150
|
+
*/
|
|
151
|
+
ensureActiveOrganization?: GetServerSessionEnsureActiveOptions;
|
|
152
|
+
}
|
|
153
|
+
interface GetServerSessionResult {
|
|
154
|
+
session: AthenaAuthSessionResponse | null;
|
|
155
|
+
userId: string | null;
|
|
156
|
+
/** Active org id from the auth session payload before product resolution. */
|
|
157
|
+
rawActiveOrganizationId: string | null;
|
|
158
|
+
/**
|
|
159
|
+
* Product-resolved organization id after `resolveActiveOrganizationId` and
|
|
160
|
+
* optional ensure-active. Prefer this for data client `scope.organizationId`.
|
|
161
|
+
*/
|
|
162
|
+
organizationId: string | null;
|
|
163
|
+
didEnsureActiveOrganization: boolean;
|
|
164
|
+
/** True when the session came from the middleware header without a fetch. */
|
|
165
|
+
fromSessionDataHeader: boolean;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Parse a middleware-forwarded session JSON string into a session response.
|
|
169
|
+
* Returns null for missing, invalid, or incomplete payloads.
|
|
170
|
+
*/
|
|
171
|
+
declare function parseAthenaSessionDataHeader(raw: string | null | undefined): AthenaAuthSessionResponse | null;
|
|
172
|
+
/**
|
|
173
|
+
* Load the current Athena Auth session for Next.js RSC / route handlers.
|
|
174
|
+
*
|
|
175
|
+
* Composition (not a full product policy module):
|
|
176
|
+
* 1. Optional middleware header (`x-session-data` / {@link ATHENA_SESSION_DATA_HEADER})
|
|
177
|
+
* 2. Else fetch get-session with request cookies/bearer
|
|
178
|
+
* 3. Optional product `resolveActiveOrganizationId`
|
|
179
|
+
* 4. Optional `ensureActiveOrganization` injectables
|
|
180
|
+
*
|
|
181
|
+
* Wrap with React `cache()` in the app if you need per-request dedupe:
|
|
182
|
+
*
|
|
183
|
+
* ```ts
|
|
184
|
+
* import { cache } from 'react'
|
|
185
|
+
* import { getServerSession } from '@xylex-group/athena/next/server'
|
|
186
|
+
*
|
|
187
|
+
* export const getSession = cache(() =>
|
|
188
|
+
* getServerSession({
|
|
189
|
+
* appOrigin: process.env.NEXT_PUBLIC_APP_URL!,
|
|
190
|
+
* resolveActiveOrganizationId: ({ userId, rawActiveOrganizationId }) =>
|
|
191
|
+
* resolveFormationsOrganizationId(userId, rawActiveOrganizationId),
|
|
192
|
+
* }),
|
|
193
|
+
* )
|
|
194
|
+
* ```
|
|
195
|
+
*/
|
|
196
|
+
declare function getServerSession(options?: GetServerSessionOptions): Promise<GetServerSessionResult>;
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Explicit gateway identity for request-scoped server clients.
|
|
200
|
+
*
|
|
201
|
+
* Maps to `X-User-Id` / `X-Organization-Id` via {@link AthenaRequestContext}.
|
|
202
|
+
* When both `session` and `scope` are provided, any field present on `scope`
|
|
203
|
+
* overrides the session-derived value (including explicit `null` to clear).
|
|
204
|
+
*/
|
|
205
|
+
interface AthenaServerScope {
|
|
206
|
+
userId?: string | null;
|
|
207
|
+
organizationId?: string | null;
|
|
208
|
+
}
|
|
105
209
|
interface AthenaServerContextOptions extends AthenaServerRequestOptions {
|
|
106
210
|
session?: AthenaAuthSessionResponse | null;
|
|
211
|
+
/**
|
|
212
|
+
* First-class identity scope. Prefer this over a second `withContext(...)`
|
|
213
|
+
* call when you already know user/org for the request.
|
|
214
|
+
*/
|
|
215
|
+
scope?: AthenaServerScope;
|
|
107
216
|
}
|
|
108
217
|
interface AthenaResolvedServerContext {
|
|
109
218
|
request: AthenaRequestContext;
|
|
@@ -114,6 +223,7 @@ interface AthenaResolvedServerContext {
|
|
|
114
223
|
declare function resolveAthenaServerContext(options?: AthenaServerContextOptions): Promise<AthenaResolvedServerContext>;
|
|
115
224
|
type AthenaBaseServerOptions = AthenaServerRequestOptions & {
|
|
116
225
|
session?: AthenaAuthSessionResponse | null;
|
|
226
|
+
scope?: AthenaServerScope;
|
|
117
227
|
};
|
|
118
228
|
/**
|
|
119
229
|
* Explicit server config: require url + key at the call site.
|
|
@@ -136,13 +246,16 @@ type AthenaServerClientConfig<TModels extends AthenaClientModelsInput | undefine
|
|
|
136
246
|
/**
|
|
137
247
|
* Request-scoped Next server façade over {@link createClient}.
|
|
138
248
|
*
|
|
139
|
-
* Resolves cookies, bearer tokens, optional session identity, and cache
|
|
140
|
-
* on every invocation, merges with any application-level context, then
|
|
249
|
+
* Resolves cookies, bearer tokens, optional session/`scope` identity, and cache
|
|
250
|
+
* policy on every invocation, merges with any application-level context, then
|
|
141
251
|
* materializes the client through the singular `createClient` primitive.
|
|
142
252
|
*
|
|
143
253
|
* Does not cache clients. Call once per Server Component / Server Action /
|
|
144
254
|
* Route Handler request (or pass explicit requestHeaders/requestCookies).
|
|
255
|
+
*
|
|
256
|
+
* Prefer `session` and/or `scope` for identity headers instead of a follow-up
|
|
257
|
+
* `withContext({})` that drops org/user fields.
|
|
145
258
|
*/
|
|
146
259
|
declare function createAthenaServerClient<const TModels extends AthenaClientModelsInput | undefined = undefined>(options: AthenaServerClientConfig<TModels>): Promise<AthenaClient<TModels>>;
|
|
147
260
|
|
|
148
|
-
export { AthenaAuthSessionBridgeOptions, AthenaAuthSessionBridgePathOptions, type AthenaEnvironmentServerConfig, type AthenaExplicitServerConfig, type AthenaRequestCookiesBag, type AthenaRequestCookiesInput, type AthenaRequestHeadersBag, type AthenaRequestHeadersInput, type AthenaResolvedServerContext, type AthenaServerClientConfig, type AthenaServerContextOptions, type AthenaServerRequestOptions, createAthenaAuthSessionBridgeHandlers, createAthenaAuthSessionBridgePathHandlers, createAthenaServerClient, handleAthenaAuthSessionBridgeDelete, handleAthenaAuthSessionBridgePost, isAthenaAuthSessionBridgePath, resolveAthenaServerContext, resolveNextRequestContext };
|
|
261
|
+
export { AthenaAuthSessionBridgeOptions, AthenaAuthSessionBridgePathOptions, type AthenaEnvironmentServerConfig, type AthenaExplicitServerConfig, type AthenaRequestCookiesBag, type AthenaRequestCookiesInput, type AthenaRequestHeadersBag, type AthenaRequestHeadersInput, type AthenaResolvedServerContext, type AthenaServerClientConfig, type AthenaServerContextOptions, type AthenaServerRequestOptions, type AthenaServerScope, type GetServerSessionEnsureActiveOptions, type GetServerSessionOptions, type GetServerSessionResult, OrganizationLike, type ResolveActiveOrganizationIdArgs, createAthenaAuthSessionBridgeHandlers, createAthenaAuthSessionBridgePathHandlers, createAthenaServerClient, getServerSession, handleAthenaAuthSessionBridgeDelete, handleAthenaAuthSessionBridgePost, isAthenaAuthSessionBridgePath, parseAthenaSessionDataHeader, resolveAthenaServerContext, resolveNextRequestContext };
|
package/dist/next/server.d.ts
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
import { ad as AthenaAuthSessionResponse } from '../types-
|
|
1
|
+
import { ad as AthenaAuthSessionResponse } from '../types-BVKpQmfY.js';
|
|
2
2
|
import { r as AthenaClientModelsInput } from '../types-B75PdABb.js';
|
|
3
|
-
import { ax as AthenaRequestContext, ah as AthenaClientConfig, ag as AthenaClient } from '../v3-client-
|
|
3
|
+
import { ax as AthenaRequestContext, ah as AthenaClientConfig, ag as AthenaClient } from '../v3-client-ao8BWQ8v.js';
|
|
4
|
+
import { OrganizationLike } from '../organization.js';
|
|
5
|
+
export { ActiveOrganizationSessionLike, EnsureActiveOrganizationOptions, EnsureActiveOrganizationResult, ensureActiveOrganization } from '../organization.js';
|
|
4
6
|
import { g as AthenaAuthSessionBridgeOptions, h as AthenaAuthSessionBridgePathOptions } from '../payload-DWI1rw-e.js';
|
|
5
7
|
export { A as ATHENA_AUTH_SESSION_BRIDGE_ROUTE, a as ATHENA_AUTH_SESSION_COOKIE_NAME, b as ATHENA_AUTH_SESSION_COOKIE_NAMES, c as AthenaAuthSessionBridgeClientOptions, d as AthenaAuthSessionBridgePayload, e as AthenaAuthSessionBridgeSource, f as clearAthenaAuthSessionOnAppHost, p as persistAthenaAuthSessionOnAppHost, r as resolveSessionBridgePayload } from '../payload-DWI1rw-e.js';
|
|
6
8
|
export { S as SESSION_COOKIE_PATTERNS, h as hasAuthSessionCookie } from '../session-cookie-detection-BqOp9mO6.js';
|
|
7
|
-
export { A as
|
|
8
|
-
export {
|
|
9
|
-
export {
|
|
9
|
+
export { A as ATHENA_AUTH_DISABLE_COOKIE_CACHE_QUERY_PARAM, a as ATHENA_AUTH_DISABLE_COOKIE_CACHE_QUERY_VALUE, b as ATHENA_AUTH_GET_SESSION_ABSOLUTE_PATH, c as ATHENA_AUTH_GET_SESSION_PATH, d as ATHENA_AUTH_PATH, e as ATHENA_AUTH_UPSTREAM_ENV_KEYS, f as ATHENA_AUTH_UPSTREAM_URL_ENV_NAMES, g as ATHENA_AUTH_VERIFY_EMAIL_PATH, h as ATHENA_SESSION_DATA_HEADER, i as AUTH_SESSION_PATH, j as AthenaAuthClientBaseUrlOptions, k as AthenaAuthUpstreamEnv, l as AthenaAuthUpstreamEnvKey, D as DEFAULT_ATHENA_AUTH_ORIGIN, m as DEFAULT_ATHENA_AUTH_UPSTREAM_URL, n as DISABLE_COOKIE_CACHE_QUERY_PARAM, o as DISABLE_COOKIE_CACHE_QUERY_VALUE, E as EnvLike, L as LOCAL_DEV_ORIGIN, S as SESSION_DATA_HEADER, p as createFreshSessionLookupUrl, q as isAbsoluteUrl, r as normalizeAthenaAuthBaseUrl, s as readAthenaAuthUpstreamUrlFromEnv, t as resolveAthenaAuthClientBaseUrl, u as resolveAthenaAuthRequestUrl, v as resolveAthenaAuthUpstreamUrl, w as resolveEmailVerificationCallbackUrl } from '../athena-auth-url-C1FbVmN6.js';
|
|
10
|
+
export { A as ATHENA_AUTH_COOKIE_PREFIXES, a as AUTHENTICATED_REDIRECT_MODE_SET, b as AUTHENTICATED_REDIRECT_VIEW_SET, c as AUTH_DEFAULT_VIEW, d as AUTH_MODE_REDIRECTS, e as AUTH_MODE_SET, f as AUTH_ROUTES, g as AUTH_TWO_FACTOR_SEGMENT, h as AUTH_VIEW_BY_SEGMENT, i as AthenaRequestHeaderOverrideFields, j as AthenaRequestHeaderProfile, k as AuthMode, l as AuthModeRedirects, m as AuthRoutes, n as AuthView, B as BuildAthenaRequestHeadersInput, C as ClearAuthCookiesOptions, R as ResolvedRequestHeaderOverrides, E as applyAthenaApiKeyHeaders, F as applyAthenaAuthContextHeaders, G as applyAthenaPgUriHeaders, o as asNonEmptyString, p as asString, q as buildAthenaGatewayHeaders, r as buildAthenaRequestHeaders, H as buildServiceRequestHeaders, s as clearAuthCookies, t as createAuthModeRedirects, u as createAuthRoutes, I as hasHeaderIgnoreCase, v as isAuthMode, w as readTrimmedString, x as resolveAuthModeRedirect, y as resolveAuthViewFromSegment, J as resolveHeaderValue, K as resolveRequestHeaderOverrides, z as shouldRedirectAuthenticatedAuthMode, D as shouldRedirectAuthenticatedAuthView } from '../athena-request-headers-DzimbvOA.js';
|
|
11
|
+
export { G as GetOriginFromHeadersOptions, g as getOriginFromHeaders, i as isDynamicServerUsageError, p as proxyRequestHeaders, r as readEnv, a as requireEnv } from '../proxy-request-headers-CttlcuRb.js';
|
|
12
|
+
export { A as ATHENA_TABLE_SCHEMA_ROUTE, a as AthenaTableCatalogColumn, b as AthenaTableCatalogQueryClient, c as AthenaTableCatalogRelation, d as AthenaTableCatalogResponse, e as AthenaTableCatalogTable, f as AthenaTableSchemaConfig, g as AthenaTableSchemaHandlerOptions, h as AthenaTableShowcaseConfig, F as FetchAthenaTableCatalogOptions, T as TableCatalogColumn, i as TableCatalogRelation, j as TableCatalogResponse, k as TableCatalogTable, l as buildAthenaTableCatalogQueries, m as createAthenaTableSchemaHandlers, n as fetchAthenaTableCatalog, o as fetchTableCatalog, p as handleAthenaTableSchemaPost, q as hasAthenaTableSchemaCredentials, r as isAthenaTableSchemaConfig, s as parseAthenaTableSchemaScope } from '../schema-handlers-VjFDhIMw.js';
|
|
10
13
|
import '../types-Bltx6iL6.js';
|
|
11
14
|
import '../module-C_ab-MM1.js';
|
|
12
15
|
|
|
@@ -102,8 +105,114 @@ interface AthenaServerRequestOptions {
|
|
|
102
105
|
}
|
|
103
106
|
declare function resolveNextRequestContext(options?: AthenaServerRequestOptions): Promise<AthenaRequestContext>;
|
|
104
107
|
|
|
108
|
+
interface ResolveActiveOrganizationIdArgs {
|
|
109
|
+
rawActiveOrganizationId: string | null;
|
|
110
|
+
session: AthenaAuthSessionResponse;
|
|
111
|
+
userId: string;
|
|
112
|
+
}
|
|
113
|
+
interface GetServerSessionEnsureActiveOptions<TOrganization extends OrganizationLike = OrganizationLike> {
|
|
114
|
+
listOrganizations: () => Promise<readonly TOrganization[]>;
|
|
115
|
+
onError?: (error: unknown) => void;
|
|
116
|
+
selectOrganizationId?: (organizations: readonly TOrganization[]) => string | null;
|
|
117
|
+
setActiveOrganization: (organizationId: string) => Promise<unknown>;
|
|
118
|
+
}
|
|
119
|
+
interface GetServerSessionOptions extends AthenaServerRequestOptions {
|
|
120
|
+
/**
|
|
121
|
+
* Absolute get-session URL. When omitted, built from `appOrigin` via
|
|
122
|
+
* {@link createFreshSessionLookupUrl}.
|
|
123
|
+
*/
|
|
124
|
+
authSessionUrl?: string | URL;
|
|
125
|
+
/**
|
|
126
|
+
* App origin used to build `/api/auth/get-session?disableCookieCache=true`
|
|
127
|
+
* when `authSessionUrl` is not set.
|
|
128
|
+
*/
|
|
129
|
+
appOrigin?: string | URL;
|
|
130
|
+
/**
|
|
131
|
+
* Raw middleware-forwarded session JSON (or omit to read
|
|
132
|
+
* {@link ATHENA_SESSION_DATA_HEADER} from `requestHeaders`).
|
|
133
|
+
*/
|
|
134
|
+
sessionDataHeader?: string | null;
|
|
135
|
+
/** Custom fetch (tests / edge). Defaults to `globalThis.fetch`. */
|
|
136
|
+
fetchImpl?: typeof fetch;
|
|
137
|
+
/**
|
|
138
|
+
* When true (default), skip the network get-session call if cookies and
|
|
139
|
+
* bearer token are both absent.
|
|
140
|
+
*/
|
|
141
|
+
skipFetchWithoutCredentials?: boolean;
|
|
142
|
+
/**
|
|
143
|
+
* Product org policy. Runs after the raw session is loaded and before
|
|
144
|
+
* optional ensure-active. Does not replace membership checks in the app.
|
|
145
|
+
*/
|
|
146
|
+
resolveActiveOrganizationId?: (args: ResolveActiveOrganizationIdArgs) => string | null | Promise<string | null>;
|
|
147
|
+
/**
|
|
148
|
+
* Optional bootstrap when the session has no active org. Inject list/set
|
|
149
|
+
* from your auth client; the package does not own org transport here.
|
|
150
|
+
*/
|
|
151
|
+
ensureActiveOrganization?: GetServerSessionEnsureActiveOptions;
|
|
152
|
+
}
|
|
153
|
+
interface GetServerSessionResult {
|
|
154
|
+
session: AthenaAuthSessionResponse | null;
|
|
155
|
+
userId: string | null;
|
|
156
|
+
/** Active org id from the auth session payload before product resolution. */
|
|
157
|
+
rawActiveOrganizationId: string | null;
|
|
158
|
+
/**
|
|
159
|
+
* Product-resolved organization id after `resolveActiveOrganizationId` and
|
|
160
|
+
* optional ensure-active. Prefer this for data client `scope.organizationId`.
|
|
161
|
+
*/
|
|
162
|
+
organizationId: string | null;
|
|
163
|
+
didEnsureActiveOrganization: boolean;
|
|
164
|
+
/** True when the session came from the middleware header without a fetch. */
|
|
165
|
+
fromSessionDataHeader: boolean;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Parse a middleware-forwarded session JSON string into a session response.
|
|
169
|
+
* Returns null for missing, invalid, or incomplete payloads.
|
|
170
|
+
*/
|
|
171
|
+
declare function parseAthenaSessionDataHeader(raw: string | null | undefined): AthenaAuthSessionResponse | null;
|
|
172
|
+
/**
|
|
173
|
+
* Load the current Athena Auth session for Next.js RSC / route handlers.
|
|
174
|
+
*
|
|
175
|
+
* Composition (not a full product policy module):
|
|
176
|
+
* 1. Optional middleware header (`x-session-data` / {@link ATHENA_SESSION_DATA_HEADER})
|
|
177
|
+
* 2. Else fetch get-session with request cookies/bearer
|
|
178
|
+
* 3. Optional product `resolveActiveOrganizationId`
|
|
179
|
+
* 4. Optional `ensureActiveOrganization` injectables
|
|
180
|
+
*
|
|
181
|
+
* Wrap with React `cache()` in the app if you need per-request dedupe:
|
|
182
|
+
*
|
|
183
|
+
* ```ts
|
|
184
|
+
* import { cache } from 'react'
|
|
185
|
+
* import { getServerSession } from '@xylex-group/athena/next/server'
|
|
186
|
+
*
|
|
187
|
+
* export const getSession = cache(() =>
|
|
188
|
+
* getServerSession({
|
|
189
|
+
* appOrigin: process.env.NEXT_PUBLIC_APP_URL!,
|
|
190
|
+
* resolveActiveOrganizationId: ({ userId, rawActiveOrganizationId }) =>
|
|
191
|
+
* resolveFormationsOrganizationId(userId, rawActiveOrganizationId),
|
|
192
|
+
* }),
|
|
193
|
+
* )
|
|
194
|
+
* ```
|
|
195
|
+
*/
|
|
196
|
+
declare function getServerSession(options?: GetServerSessionOptions): Promise<GetServerSessionResult>;
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Explicit gateway identity for request-scoped server clients.
|
|
200
|
+
*
|
|
201
|
+
* Maps to `X-User-Id` / `X-Organization-Id` via {@link AthenaRequestContext}.
|
|
202
|
+
* When both `session` and `scope` are provided, any field present on `scope`
|
|
203
|
+
* overrides the session-derived value (including explicit `null` to clear).
|
|
204
|
+
*/
|
|
205
|
+
interface AthenaServerScope {
|
|
206
|
+
userId?: string | null;
|
|
207
|
+
organizationId?: string | null;
|
|
208
|
+
}
|
|
105
209
|
interface AthenaServerContextOptions extends AthenaServerRequestOptions {
|
|
106
210
|
session?: AthenaAuthSessionResponse | null;
|
|
211
|
+
/**
|
|
212
|
+
* First-class identity scope. Prefer this over a second `withContext(...)`
|
|
213
|
+
* call when you already know user/org for the request.
|
|
214
|
+
*/
|
|
215
|
+
scope?: AthenaServerScope;
|
|
107
216
|
}
|
|
108
217
|
interface AthenaResolvedServerContext {
|
|
109
218
|
request: AthenaRequestContext;
|
|
@@ -114,6 +223,7 @@ interface AthenaResolvedServerContext {
|
|
|
114
223
|
declare function resolveAthenaServerContext(options?: AthenaServerContextOptions): Promise<AthenaResolvedServerContext>;
|
|
115
224
|
type AthenaBaseServerOptions = AthenaServerRequestOptions & {
|
|
116
225
|
session?: AthenaAuthSessionResponse | null;
|
|
226
|
+
scope?: AthenaServerScope;
|
|
117
227
|
};
|
|
118
228
|
/**
|
|
119
229
|
* Explicit server config: require url + key at the call site.
|
|
@@ -136,13 +246,16 @@ type AthenaServerClientConfig<TModels extends AthenaClientModelsInput | undefine
|
|
|
136
246
|
/**
|
|
137
247
|
* Request-scoped Next server façade over {@link createClient}.
|
|
138
248
|
*
|
|
139
|
-
* Resolves cookies, bearer tokens, optional session identity, and cache
|
|
140
|
-
* on every invocation, merges with any application-level context, then
|
|
249
|
+
* Resolves cookies, bearer tokens, optional session/`scope` identity, and cache
|
|
250
|
+
* policy on every invocation, merges with any application-level context, then
|
|
141
251
|
* materializes the client through the singular `createClient` primitive.
|
|
142
252
|
*
|
|
143
253
|
* Does not cache clients. Call once per Server Component / Server Action /
|
|
144
254
|
* Route Handler request (or pass explicit requestHeaders/requestCookies).
|
|
255
|
+
*
|
|
256
|
+
* Prefer `session` and/or `scope` for identity headers instead of a follow-up
|
|
257
|
+
* `withContext({})` that drops org/user fields.
|
|
145
258
|
*/
|
|
146
259
|
declare function createAthenaServerClient<const TModels extends AthenaClientModelsInput | undefined = undefined>(options: AthenaServerClientConfig<TModels>): Promise<AthenaClient<TModels>>;
|
|
147
260
|
|
|
148
|
-
export { AthenaAuthSessionBridgeOptions, AthenaAuthSessionBridgePathOptions, type AthenaEnvironmentServerConfig, type AthenaExplicitServerConfig, type AthenaRequestCookiesBag, type AthenaRequestCookiesInput, type AthenaRequestHeadersBag, type AthenaRequestHeadersInput, type AthenaResolvedServerContext, type AthenaServerClientConfig, type AthenaServerContextOptions, type AthenaServerRequestOptions, createAthenaAuthSessionBridgeHandlers, createAthenaAuthSessionBridgePathHandlers, createAthenaServerClient, handleAthenaAuthSessionBridgeDelete, handleAthenaAuthSessionBridgePost, isAthenaAuthSessionBridgePath, resolveAthenaServerContext, resolveNextRequestContext };
|
|
261
|
+
export { AthenaAuthSessionBridgeOptions, AthenaAuthSessionBridgePathOptions, type AthenaEnvironmentServerConfig, type AthenaExplicitServerConfig, type AthenaRequestCookiesBag, type AthenaRequestCookiesInput, type AthenaRequestHeadersBag, type AthenaRequestHeadersInput, type AthenaResolvedServerContext, type AthenaServerClientConfig, type AthenaServerContextOptions, type AthenaServerRequestOptions, type AthenaServerScope, type GetServerSessionEnsureActiveOptions, type GetServerSessionOptions, type GetServerSessionResult, OrganizationLike, type ResolveActiveOrganizationIdArgs, createAthenaAuthSessionBridgeHandlers, createAthenaAuthSessionBridgePathHandlers, createAthenaServerClient, getServerSession, handleAthenaAuthSessionBridgeDelete, handleAthenaAuthSessionBridgePost, isAthenaAuthSessionBridgePath, parseAthenaSessionDataHeader, resolveAthenaServerContext, resolveNextRequestContext };
|