@xylex-group/athena 2.4.0 → 2.6.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 +124 -2
- package/bin/athena-js.js +0 -0
- package/dist/browser.cjs +2245 -151
- 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 +2238 -152
- package/dist/browser.js.map +1 -1
- package/dist/cli/index.cjs +1073 -102
- package/dist/cli/index.cjs.map +1 -1
- package/dist/cli/index.d.cts +3 -3
- package/dist/cli/index.d.ts +3 -3
- package/dist/cli/index.js +1073 -102
- package/dist/cli/index.js.map +1 -1
- package/dist/cookies.d.cts +1 -174
- package/dist/cookies.d.ts +1 -174
- package/dist/index-CVcQCGyG.d.cts +174 -0
- package/dist/index-CVcQCGyG.d.ts +174 -0
- package/dist/index.cjs +2246 -152
- 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 +2239 -153
- package/dist/index.js.map +1 -1
- package/dist/{model-form-GzTqhEzM.d.cts → model-form-BaHWi3gm.d.cts} +9 -5
- package/dist/{model-form-C0FAbOaf.d.ts → model-form-Dh6gWjL0.d.ts} +9 -5
- package/dist/{pipeline-CR4V15jF.d.ts → pipeline-Ce3pTw5h.d.ts} +1 -1
- package/dist/{pipeline-DZeExYMA.d.cts → pipeline-D1ZYeoH7.d.cts} +1 -1
- package/dist/{react-email-CQJq92zQ.d.cts → react-email-B8O1Jeff.d.cts} +637 -30
- package/dist/{react-email-BuApZuyG.d.ts → react-email-CDEF0jij.d.ts} +637 -30
- package/dist/react.cjs +84 -4
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +4 -4
- package/dist/react.d.ts +4 -4
- package/dist/react.js +84 -4
- package/dist/react.js.map +1 -1
- package/dist/{types-D1JvL21V.d.cts → types-CUuo4NDi.d.cts} +1 -1
- package/dist/{types-09Q4D86N.d.cts → types-DSX6AT5B.d.cts} +3 -3
- package/dist/{types-09Q4D86N.d.ts → types-DSX6AT5B.d.ts} +3 -3
- package/dist/{types-DU3gNdFv.d.ts → types-DapchQY5.d.ts} +1 -1
- package/dist/utils.cjs +131 -0
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +42 -1
- package/dist/utils.d.ts +42 -1
- package/dist/utils.js +117 -1
- package/dist/utils.js.map +1 -1
- package/package.json +193 -192
package/dist/react.cjs
CHANGED
|
@@ -132,12 +132,47 @@ function buildAthenaGatewayUrl(baseUrl, path) {
|
|
|
132
132
|
return `${baseUrl}${path}`;
|
|
133
133
|
}
|
|
134
134
|
|
|
135
|
+
// src/cookies/cookie-utils.ts
|
|
136
|
+
var SECURE_COOKIE_PREFIX = "__Secure-";
|
|
137
|
+
function parseCookies(cookieHeader) {
|
|
138
|
+
const cookies = cookieHeader.split("; ");
|
|
139
|
+
const cookieMap = /* @__PURE__ */ new Map();
|
|
140
|
+
cookies.forEach((cookie) => {
|
|
141
|
+
const [name, value] = cookie.split(/=(.*)/s);
|
|
142
|
+
cookieMap.set(name, value);
|
|
143
|
+
});
|
|
144
|
+
return cookieMap;
|
|
145
|
+
}
|
|
146
|
+
var getSessionCookie = (request, config) => {
|
|
147
|
+
const cookies = (request instanceof Headers || !("headers" in request) ? request : request.headers).get("cookie");
|
|
148
|
+
if (!cookies) {
|
|
149
|
+
return null;
|
|
150
|
+
}
|
|
151
|
+
const { cookieName = "session_token", cookiePrefix = "athena-auth" } = {};
|
|
152
|
+
const parsedCookie = parseCookies(cookies);
|
|
153
|
+
const getCookie = (name) => parsedCookie.get(name) || parsedCookie.get(`${SECURE_COOKIE_PREFIX}${name}`);
|
|
154
|
+
const sessionToken = getCookie(`${cookiePrefix}.${cookieName}`) || getCookie(`${cookiePrefix}-${cookieName}`);
|
|
155
|
+
if (sessionToken) {
|
|
156
|
+
return sessionToken;
|
|
157
|
+
}
|
|
158
|
+
return null;
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
// package.json
|
|
162
|
+
var package_default = {
|
|
163
|
+
version: "2.6.0"
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
// src/sdk-version.ts
|
|
167
|
+
var PACKAGE_VERSION = package_default.version;
|
|
168
|
+
function buildSdkHeaderValue(sdkName) {
|
|
169
|
+
return `${sdkName} ${PACKAGE_VERSION}`;
|
|
170
|
+
}
|
|
171
|
+
|
|
135
172
|
// src/gateway/client.ts
|
|
136
173
|
var DEFAULT_CLIENT = "railway_direct";
|
|
137
|
-
var FALLBACK_SDK_VERSION = "1.3.0";
|
|
138
174
|
var SDK_NAME = "xylex-group/athena";
|
|
139
|
-
var
|
|
140
|
-
var SDK_HEADER_VALUE = `${SDK_NAME} ${SDK_VERSION}`;
|
|
175
|
+
var SDK_HEADER_VALUE = buildSdkHeaderValue(SDK_NAME);
|
|
141
176
|
function parseResponseBody(rawText, contentType) {
|
|
142
177
|
if (!rawText) {
|
|
143
178
|
return { parsed: null, parseFailed: false };
|
|
@@ -156,6 +191,37 @@ function parseResponseBody(rawText, contentType) {
|
|
|
156
191
|
function normalizeHeaderValue(value) {
|
|
157
192
|
return value ? value : void 0;
|
|
158
193
|
}
|
|
194
|
+
function resolveHeaderValue(headers, candidates) {
|
|
195
|
+
for (const candidate of candidates) {
|
|
196
|
+
const direct = normalizeHeaderValue(headers[candidate]);
|
|
197
|
+
if (direct) return direct;
|
|
198
|
+
}
|
|
199
|
+
const loweredCandidates = new Set(candidates.map((candidate) => candidate.toLowerCase()));
|
|
200
|
+
for (const [key, value] of Object.entries(headers)) {
|
|
201
|
+
if (!loweredCandidates.has(key.toLowerCase())) {
|
|
202
|
+
continue;
|
|
203
|
+
}
|
|
204
|
+
const normalized = normalizeHeaderValue(value);
|
|
205
|
+
if (normalized) return normalized;
|
|
206
|
+
}
|
|
207
|
+
return void 0;
|
|
208
|
+
}
|
|
209
|
+
function resolveBearerTokenFromAuthorizationHeader(headers) {
|
|
210
|
+
const authorization = resolveHeaderValue(headers, ["Authorization"]);
|
|
211
|
+
if (!authorization) {
|
|
212
|
+
return void 0;
|
|
213
|
+
}
|
|
214
|
+
const match = authorization.match(/^Bearer\s+(.+)$/i);
|
|
215
|
+
const token = match?.[1]?.trim();
|
|
216
|
+
return token ? token : void 0;
|
|
217
|
+
}
|
|
218
|
+
function resolveSessionTokenFromCookieHeader(headers) {
|
|
219
|
+
const cookie = resolveHeaderValue(headers, ["Cookie"]);
|
|
220
|
+
if (!cookie) {
|
|
221
|
+
return void 0;
|
|
222
|
+
}
|
|
223
|
+
return getSessionCookie(new Headers({ cookie })) ?? void 0;
|
|
224
|
+
}
|
|
159
225
|
function isRecord(value) {
|
|
160
226
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
161
227
|
}
|
|
@@ -273,7 +339,7 @@ function buildRpcGetEndpoint(payload) {
|
|
|
273
339
|
status: 0
|
|
274
340
|
});
|
|
275
341
|
}
|
|
276
|
-
query.
|
|
342
|
+
query.append(filter.column, toRpcFilterQueryValue(filter));
|
|
277
343
|
}
|
|
278
344
|
}
|
|
279
345
|
const endpoint = `/rpc/${encodeURIComponent(functionName)}`;
|
|
@@ -319,6 +385,20 @@ function buildHeaders(config, options) {
|
|
|
319
385
|
headers["apikey"] = finalApiKey;
|
|
320
386
|
headers["x-api-key"] = headers["x-api-key"] ?? finalApiKey;
|
|
321
387
|
}
|
|
388
|
+
const explicitSessionToken = resolveHeaderValue(extraHeaders, [
|
|
389
|
+
"X-Athena-Auth-Session-Token"
|
|
390
|
+
]);
|
|
391
|
+
const derivedSessionToken = explicitSessionToken ?? resolveSessionTokenFromCookieHeader(extraHeaders);
|
|
392
|
+
if (derivedSessionToken) {
|
|
393
|
+
headers["X-Athena-Auth-Session-Token"] = derivedSessionToken;
|
|
394
|
+
}
|
|
395
|
+
const explicitBearerToken = resolveHeaderValue(extraHeaders, [
|
|
396
|
+
"X-Athena-Auth-Bearer-Token"
|
|
397
|
+
]);
|
|
398
|
+
const derivedBearerToken = explicitBearerToken ?? resolveBearerTokenFromAuthorizationHeader(extraHeaders);
|
|
399
|
+
if (derivedBearerToken) {
|
|
400
|
+
headers["X-Athena-Auth-Bearer-Token"] = derivedBearerToken;
|
|
401
|
+
}
|
|
322
402
|
const athenaClientKeys = ["x-athena-client", "X-Athena-Client"];
|
|
323
403
|
Object.entries(extraHeaders).forEach(([key, value]) => {
|
|
324
404
|
if (athenaClientKeys.includes(key)) return;
|