@xylex-group/athena 3.1.0 → 3.5.1
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 +17 -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-BnFN2mbd.d.cts} +49 -201
- package/dist/{athena-request-headers-DujFFyMU.d.cts → athena-request-headers-Dwdkq2WR.d.ts} +49 -201
- 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 +3735 -248
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.d.cts +11 -10
- package/dist/browser.d.ts +11 -10
- package/dist/browser.js +3726 -249
- package/dist/browser.js.map +1 -1
- package/dist/cli/index.cjs +3232 -190
- package/dist/cli/index.cjs.map +1 -1
- package/dist/cli/index.d.cts +4 -4
- package/dist/cli/index.d.ts +4 -4
- package/dist/cli/index.js +3232 -190
- package/dist/cli/index.js.map +1 -1
- package/dist/cloudflare.cjs +12914 -0
- package/dist/cloudflare.cjs.map +1 -0
- package/dist/cloudflare.d.cts +368 -0
- package/dist/cloudflare.d.ts +368 -0
- package/dist/cloudflare.js +12885 -0
- package/dist/cloudflare.js.map +1 -0
- package/dist/cookies.cjs +4 -3
- package/dist/cookies.cjs.map +1 -1
- package/dist/cookies.js +4 -3
- package/dist/cookies.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 +3749 -241
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -10
- package/dist/index.d.ts +11 -10
- package/dist/index.js +3739 -242
- package/dist/index.js.map +1 -1
- package/dist/{model-form-BhWWsA-7.d.cts → model-form-D0ykVVOs.d.cts} +26 -4
- package/dist/{model-form-BbdzJ9Uh.d.ts → model-form-U8NVtfSA.d.ts} +26 -4
- package/dist/{module-xFd7_Igv.d.cts → module-CMWlJ1z3.d.cts} +5 -5
- package/dist/{module-DKkJKOuJ.d.ts → module-CZ-wPcf2.d.ts} +5 -5
- package/dist/next/client.cjs +3212 -196
- package/dist/next/client.cjs.map +1 -1
- package/dist/next/client.d.cts +6 -5
- package/dist/next/client.d.ts +6 -5
- package/dist/next/client.js +3212 -196
- package/dist/next/client.js.map +1 -1
- package/dist/next/server.cjs +4461 -781
- package/dist/next/server.cjs.map +1 -1
- package/dist/next/server.d.cts +139 -13
- package/dist/next/server.d.ts +139 -13
- package/dist/next/server.js +4451 -782
- package/dist/next/server.js.map +1 -1
- package/dist/{pipeline-DuKzYGia.d.cts → pipeline-BCpb4BX1.d.cts} +1 -1
- package/dist/{pipeline-wer2G9xW.d.ts → pipeline-CgmXwMeX.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 +62 -12
- package/dist/react.d.ts +62 -12
- package/dist/react.js +290 -32
- package/dist/react.js.map +1 -1
- package/dist/schema-handlers-CvWqF-dW.d.ts +138 -0
- package/dist/schema-handlers-Dr8h9Jg-.d.cts +138 -0
- package/dist/social-providers.cjs +1 -1
- package/dist/social-providers.cjs.map +1 -1
- package/dist/social-providers.d.cts +1 -1
- package/dist/social-providers.d.ts +1 -1
- package/dist/social-providers.js +1 -1
- package/dist/social-providers.js.map +1 -1
- package/dist/{types-Bltx6iL6.d.ts → types-B2RZPivM.d.cts} +8 -1
- package/dist/{types-Bltx6iL6.d.cts → types-B2RZPivM.d.ts} +8 -1
- package/dist/{types-1ztXDgPa.d.cts → types-BKklrX4J.d.ts} +14 -2
- 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-CgCv5o6R.d.cts → types-D5dj1v5Z.d.cts} +1 -1
- package/dist/{types-CccOiXPo.d.ts → types-DqBFwfhn.d.cts} +14 -2
- package/dist/{types-B75PdABb.d.ts → types-S-bTMPiM.d.ts} +1 -1
- package/dist/utils.cjs +30 -0
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +4 -3
- package/dist/utils.d.ts +4 -3
- package/dist/utils.js +30 -1
- package/dist/utils.js.map +1 -1
- package/dist/{v3-client-CWfZHcKL.d.cts → v3-client-DP-qg82X.d.cts} +323 -5
- package/dist/{v3-client-DZp2NEhK.d.ts → v3-client-OAai_JNs.d.ts} +323 -5
- package/package.json +25 -4
package/dist/next/server.d.cts
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
import { ad as AthenaAuthSessionResponse } from '../types-
|
|
2
|
-
import { r as AthenaClientModelsInput } from '../types-
|
|
3
|
-
import {
|
|
1
|
+
import { ad as AthenaAuthSessionResponse } from '../types-BVKpQmfY.cjs';
|
|
2
|
+
import { r as AthenaClientModelsInput } from '../types-D5dj1v5Z.cjs';
|
|
3
|
+
import { aA as AthenaRequestContext, ai as AthenaClientConfig, ag as AthenaClient } from '../v3-client-DP-qg82X.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 {
|
|
10
|
-
|
|
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-BnFN2mbd.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-Dr8h9Jg-.cjs';
|
|
13
|
+
import '../types-B2RZPivM.cjs';
|
|
11
14
|
import '../module-C_ab-MM1.cjs';
|
|
12
15
|
|
|
13
16
|
/**
|
|
@@ -102,18 +105,138 @@ 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
|
+
* Minimal session shape used to derive gateway identity headers.
|
|
200
|
+
* Accepts full {@link AthenaAuthSessionResponse} or a partial getSession payload.
|
|
201
|
+
*/
|
|
202
|
+
type AthenaServerSessionInput = {
|
|
203
|
+
user?: {
|
|
204
|
+
id?: string | null;
|
|
205
|
+
} | null;
|
|
206
|
+
session?: {
|
|
207
|
+
id?: string | null;
|
|
208
|
+
activeOrganizationId?: string | null;
|
|
209
|
+
} | null;
|
|
210
|
+
} | null;
|
|
211
|
+
/**
|
|
212
|
+
* Explicit gateway identity for request-scoped server clients.
|
|
213
|
+
*
|
|
214
|
+
* Maps to `X-User-Id` / `X-Organization-Id` via {@link AthenaRequestContext}.
|
|
215
|
+
* When both `session` and `scope` are provided, any field present on `scope`
|
|
216
|
+
* overrides the session-derived value (including explicit `null` to clear).
|
|
217
|
+
*/
|
|
218
|
+
interface AthenaServerScope {
|
|
219
|
+
userId?: string | null;
|
|
220
|
+
organizationId?: string | null;
|
|
221
|
+
}
|
|
105
222
|
interface AthenaServerContextOptions extends AthenaServerRequestOptions {
|
|
106
|
-
session?: AthenaAuthSessionResponse | null;
|
|
223
|
+
session?: AthenaAuthSessionResponse | AthenaServerSessionInput | null;
|
|
224
|
+
/**
|
|
225
|
+
* First-class identity scope. Prefer this over a second `withContext(...)`
|
|
226
|
+
* call when you already know user/org for the request.
|
|
227
|
+
*/
|
|
228
|
+
scope?: AthenaServerScope;
|
|
107
229
|
}
|
|
108
230
|
interface AthenaResolvedServerContext {
|
|
109
231
|
request: AthenaRequestContext;
|
|
110
|
-
session: AthenaAuthSessionResponse | null;
|
|
232
|
+
session: AthenaAuthSessionResponse | AthenaServerSessionInput | null;
|
|
111
233
|
userId: string | null;
|
|
112
234
|
organizationId: string | null;
|
|
113
235
|
}
|
|
114
236
|
declare function resolveAthenaServerContext(options?: AthenaServerContextOptions): Promise<AthenaResolvedServerContext>;
|
|
115
237
|
type AthenaBaseServerOptions = AthenaServerRequestOptions & {
|
|
116
|
-
session?: AthenaAuthSessionResponse | null;
|
|
238
|
+
session?: AthenaAuthSessionResponse | AthenaServerSessionInput | null;
|
|
239
|
+
scope?: AthenaServerScope;
|
|
117
240
|
};
|
|
118
241
|
/**
|
|
119
242
|
* Explicit server config: require url + key at the call site.
|
|
@@ -136,13 +259,16 @@ type AthenaServerClientConfig<TModels extends AthenaClientModelsInput | undefine
|
|
|
136
259
|
/**
|
|
137
260
|
* Request-scoped Next server façade over {@link createClient}.
|
|
138
261
|
*
|
|
139
|
-
* Resolves cookies, bearer tokens, optional session identity, and cache
|
|
140
|
-
* on every invocation, merges with any application-level context, then
|
|
262
|
+
* Resolves cookies, bearer tokens, optional session/`scope` identity, and cache
|
|
263
|
+
* policy on every invocation, merges with any application-level context, then
|
|
141
264
|
* materializes the client through the singular `createClient` primitive.
|
|
142
265
|
*
|
|
143
266
|
* Does not cache clients. Call once per Server Component / Server Action /
|
|
144
267
|
* Route Handler request (or pass explicit requestHeaders/requestCookies).
|
|
268
|
+
*
|
|
269
|
+
* Prefer `session` and/or `scope` for identity headers instead of a follow-up
|
|
270
|
+
* `withContext({})` that drops org/user fields.
|
|
145
271
|
*/
|
|
146
272
|
declare function createAthenaServerClient<const TModels extends AthenaClientModelsInput | undefined = undefined>(options: AthenaServerClientConfig<TModels>): Promise<AthenaClient<TModels>>;
|
|
147
273
|
|
|
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 };
|
|
274
|
+
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 AthenaServerSessionInput, 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,13 +1,16 @@
|
|
|
1
|
-
import { ad as AthenaAuthSessionResponse } from '../types-
|
|
2
|
-
import { r as AthenaClientModelsInput } from '../types-
|
|
3
|
-
import {
|
|
1
|
+
import { ad as AthenaAuthSessionResponse } from '../types-BVKpQmfY.js';
|
|
2
|
+
import { r as AthenaClientModelsInput } from '../types-S-bTMPiM.js';
|
|
3
|
+
import { aA as AthenaRequestContext, ai as AthenaClientConfig, ag as AthenaClient } from '../v3-client-OAai_JNs.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 {
|
|
10
|
-
|
|
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-Dwdkq2WR.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-CvWqF-dW.js';
|
|
13
|
+
import '../types-B2RZPivM.js';
|
|
11
14
|
import '../module-C_ab-MM1.js';
|
|
12
15
|
|
|
13
16
|
/**
|
|
@@ -102,18 +105,138 @@ 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
|
+
* Minimal session shape used to derive gateway identity headers.
|
|
200
|
+
* Accepts full {@link AthenaAuthSessionResponse} or a partial getSession payload.
|
|
201
|
+
*/
|
|
202
|
+
type AthenaServerSessionInput = {
|
|
203
|
+
user?: {
|
|
204
|
+
id?: string | null;
|
|
205
|
+
} | null;
|
|
206
|
+
session?: {
|
|
207
|
+
id?: string | null;
|
|
208
|
+
activeOrganizationId?: string | null;
|
|
209
|
+
} | null;
|
|
210
|
+
} | null;
|
|
211
|
+
/**
|
|
212
|
+
* Explicit gateway identity for request-scoped server clients.
|
|
213
|
+
*
|
|
214
|
+
* Maps to `X-User-Id` / `X-Organization-Id` via {@link AthenaRequestContext}.
|
|
215
|
+
* When both `session` and `scope` are provided, any field present on `scope`
|
|
216
|
+
* overrides the session-derived value (including explicit `null` to clear).
|
|
217
|
+
*/
|
|
218
|
+
interface AthenaServerScope {
|
|
219
|
+
userId?: string | null;
|
|
220
|
+
organizationId?: string | null;
|
|
221
|
+
}
|
|
105
222
|
interface AthenaServerContextOptions extends AthenaServerRequestOptions {
|
|
106
|
-
session?: AthenaAuthSessionResponse | null;
|
|
223
|
+
session?: AthenaAuthSessionResponse | AthenaServerSessionInput | null;
|
|
224
|
+
/**
|
|
225
|
+
* First-class identity scope. Prefer this over a second `withContext(...)`
|
|
226
|
+
* call when you already know user/org for the request.
|
|
227
|
+
*/
|
|
228
|
+
scope?: AthenaServerScope;
|
|
107
229
|
}
|
|
108
230
|
interface AthenaResolvedServerContext {
|
|
109
231
|
request: AthenaRequestContext;
|
|
110
|
-
session: AthenaAuthSessionResponse | null;
|
|
232
|
+
session: AthenaAuthSessionResponse | AthenaServerSessionInput | null;
|
|
111
233
|
userId: string | null;
|
|
112
234
|
organizationId: string | null;
|
|
113
235
|
}
|
|
114
236
|
declare function resolveAthenaServerContext(options?: AthenaServerContextOptions): Promise<AthenaResolvedServerContext>;
|
|
115
237
|
type AthenaBaseServerOptions = AthenaServerRequestOptions & {
|
|
116
|
-
session?: AthenaAuthSessionResponse | null;
|
|
238
|
+
session?: AthenaAuthSessionResponse | AthenaServerSessionInput | null;
|
|
239
|
+
scope?: AthenaServerScope;
|
|
117
240
|
};
|
|
118
241
|
/**
|
|
119
242
|
* Explicit server config: require url + key at the call site.
|
|
@@ -136,13 +259,16 @@ type AthenaServerClientConfig<TModels extends AthenaClientModelsInput | undefine
|
|
|
136
259
|
/**
|
|
137
260
|
* Request-scoped Next server façade over {@link createClient}.
|
|
138
261
|
*
|
|
139
|
-
* Resolves cookies, bearer tokens, optional session identity, and cache
|
|
140
|
-
* on every invocation, merges with any application-level context, then
|
|
262
|
+
* Resolves cookies, bearer tokens, optional session/`scope` identity, and cache
|
|
263
|
+
* policy on every invocation, merges with any application-level context, then
|
|
141
264
|
* materializes the client through the singular `createClient` primitive.
|
|
142
265
|
*
|
|
143
266
|
* Does not cache clients. Call once per Server Component / Server Action /
|
|
144
267
|
* Route Handler request (or pass explicit requestHeaders/requestCookies).
|
|
268
|
+
*
|
|
269
|
+
* Prefer `session` and/or `scope` for identity headers instead of a follow-up
|
|
270
|
+
* `withContext({})` that drops org/user fields.
|
|
145
271
|
*/
|
|
146
272
|
declare function createAthenaServerClient<const TModels extends AthenaClientModelsInput | undefined = undefined>(options: AthenaServerClientConfig<TModels>): Promise<AthenaClient<TModels>>;
|
|
147
273
|
|
|
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 };
|
|
274
|
+
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 AthenaServerSessionInput, type GetServerSessionEnsureActiveOptions, type GetServerSessionOptions, type GetServerSessionResult, OrganizationLike, type ResolveActiveOrganizationIdArgs, createAthenaAuthSessionBridgeHandlers, createAthenaAuthSessionBridgePathHandlers, createAthenaServerClient, getServerSession, handleAthenaAuthSessionBridgeDelete, handleAthenaAuthSessionBridgePost, isAthenaAuthSessionBridgePath, parseAthenaSessionDataHeader, resolveAthenaServerContext, resolveNextRequestContext };
|