@xylex-group/athena 2.1.2 → 2.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.
Files changed (42) hide show
  1. package/README.md +287 -116
  2. package/dist/browser.cjs +1628 -156
  3. package/dist/browser.cjs.map +1 -1
  4. package/dist/browser.d.cts +14 -14
  5. package/dist/browser.d.ts +14 -14
  6. package/dist/browser.js +1625 -156
  7. package/dist/browser.js.map +1 -1
  8. package/dist/cli/index.cjs +1532 -145
  9. package/dist/cli/index.cjs.map +1 -1
  10. package/dist/cli/index.d.cts +3 -3
  11. package/dist/cli/index.d.ts +3 -3
  12. package/dist/cli/index.js +1533 -146
  13. package/dist/cli/index.js.map +1 -1
  14. package/dist/index.cjs +1658 -167
  15. package/dist/index.cjs.map +1 -1
  16. package/dist/index.d.cts +7 -7
  17. package/dist/index.d.ts +7 -7
  18. package/dist/index.js +1656 -168
  19. package/dist/index.js.map +1 -1
  20. package/dist/{model-form-2hqmoOUX.d.ts → model-form-BpDXlbxb.d.ts} +97 -2
  21. package/dist/{model-form-Cy-zaO0u.d.cts → model-form-hoE2jHIi.d.cts} +97 -2
  22. package/dist/{pipeline-BOPszLsL.d.ts → pipeline-BNIw8pDQ.d.ts} +1 -1
  23. package/dist/{pipeline-E3FDbs4W.d.cts → pipeline-DNIpEsN8.d.cts} +1 -1
  24. package/dist/{client-dpAp-NZK.d.cts → react-email-BvyCZnfW.d.cts} +349 -174
  25. package/dist/{client-BX0NQqOn.d.ts → react-email-qPA1wjFV.d.ts} +349 -174
  26. package/dist/react.cjs +30 -9
  27. package/dist/react.cjs.map +1 -1
  28. package/dist/react.d.cts +4 -4
  29. package/dist/react.d.ts +4 -4
  30. package/dist/react.js +30 -9
  31. package/dist/react.js.map +1 -1
  32. package/dist/{types-BaBzjwXr.d.cts → types-A5e97acl.d.cts} +2 -1
  33. package/dist/{types-BaBzjwXr.d.ts → types-A5e97acl.d.ts} +2 -1
  34. package/dist/{types-CeBPrnGj.d.ts → types-BnD22-vb.d.ts} +1 -1
  35. package/dist/{types-CpqL-pZx.d.cts → types-bDlr4u7p.d.cts} +1 -1
  36. package/dist/utils.cjs +153 -0
  37. package/dist/utils.cjs.map +1 -0
  38. package/dist/utils.d.cts +23 -0
  39. package/dist/utils.d.ts +23 -0
  40. package/dist/utils.js +146 -0
  41. package/dist/utils.js.map +1 -0
  42. package/package.json +75 -17
@@ -158,6 +158,7 @@ interface AthenaRpcCallOptions extends AthenaGatewayCallOptions {
158
158
  interface AthenaGatewayResponse<T = unknown> {
159
159
  ok: boolean;
160
160
  status: number;
161
+ statusText?: string | null;
161
162
  data: T | null;
162
163
  count?: number | null;
163
164
  error?: string;
@@ -377,4 +378,4 @@ interface SchemaIntrospectionProvider {
377
378
  inspect(options?: IntrospectionInspectOptions): Promise<IntrospectionSnapshot>;
378
379
  }
379
380
 
380
- export { type AthenaConditionCastType as A, Backend as B, type SchemaDef as C, type DatabaseDef as D, type TenantContextValue as E, type TenantKeyMap as F, type AthenaConditionValue as G, type AthenaConditionArrayValue as H, type IntrospectionSnapshot as I, type AthenaConditionOperator as J, type AnyModelDef as K, type AthenaGatewayHookConfig as L, type ModelAt as M, type AthenaGatewayHookResult as N, type AthenaDeletePayload as O, type AthenaFetchPayload as P, type AthenaGatewayResponse as Q, type RegistryDef as R, type SchemaIntrospectionProvider as S, type TenantContext as T, type UpdateOf as U, type AthenaInsertPayload as V, type AthenaUpdatePayload as W, type AthenaGatewayEndpointPath as X, type AthenaGatewayMethod as Y, type AthenaGatewayCallOptions as a, type AthenaGatewayErrorCode as b, type AthenaGatewayErrorDetails as c, type AthenaJsonArray as d, type AthenaJsonObject as e, type AthenaJsonPrimitive as f, type AthenaJsonValue as g, type AthenaRpcCallOptions as h, type AthenaRpcFilter as i, type AthenaRpcFilterOperator as j, type AthenaRpcOrder as k, type AthenaRpcPayload as l, type BackendConfig as m, type BackendType as n, type InsertOf as o, type IntrospectionColumn as p, type IntrospectionInspectOptions as q, type IntrospectionRelation as r, type IntrospectionSchema as s, type IntrospectionTable as t, type IntrospectionTypeKind as u, type ModelDef as v, type ModelMetadata as w, type ModelRelationKind as x, type ModelRelationMetadata as y, type RowOf as z };
381
+ export { type AthenaConditionCastType as A, Backend as B, type SchemaDef as C, type DatabaseDef as D, type TenantContextValue as E, type TenantKeyMap as F, type AthenaConditionValue as G, type AthenaConditionArrayValue as H, type IntrospectionSnapshot as I, type AnyModelDef as J, type AthenaConditionOperator as K, type AthenaGatewayHookConfig as L, type ModelAt as M, type AthenaGatewayHookResult as N, type AthenaDeletePayload as O, type AthenaFetchPayload as P, type AthenaGatewayResponse as Q, type RegistryDef as R, type SchemaIntrospectionProvider as S, type TenantContext as T, type UpdateOf as U, type AthenaInsertPayload as V, type AthenaUpdatePayload as W, type AthenaGatewayEndpointPath as X, type AthenaGatewayMethod as Y, type AthenaGatewayCallOptions as a, type AthenaGatewayErrorCode as b, type AthenaGatewayErrorDetails as c, type AthenaJsonArray as d, type AthenaJsonObject as e, type AthenaJsonPrimitive as f, type AthenaJsonValue as g, type AthenaRpcCallOptions as h, type AthenaRpcFilter as i, type AthenaRpcFilterOperator as j, type AthenaRpcOrder as k, type AthenaRpcPayload as l, type BackendConfig as m, type BackendType as n, type InsertOf as o, type IntrospectionColumn as p, type IntrospectionInspectOptions as q, type IntrospectionRelation as r, type IntrospectionSchema as s, type IntrospectionTable as t, type IntrospectionTypeKind as u, type ModelDef as v, type ModelMetadata as w, type ModelRelationKind as x, type ModelRelationMetadata as y, type RowOf as z };
@@ -158,6 +158,7 @@ interface AthenaRpcCallOptions extends AthenaGatewayCallOptions {
158
158
  interface AthenaGatewayResponse<T = unknown> {
159
159
  ok: boolean;
160
160
  status: number;
161
+ statusText?: string | null;
161
162
  data: T | null;
162
163
  count?: number | null;
163
164
  error?: string;
@@ -377,4 +378,4 @@ interface SchemaIntrospectionProvider {
377
378
  inspect(options?: IntrospectionInspectOptions): Promise<IntrospectionSnapshot>;
378
379
  }
379
380
 
380
- export { type AthenaConditionCastType as A, Backend as B, type SchemaDef as C, type DatabaseDef as D, type TenantContextValue as E, type TenantKeyMap as F, type AthenaConditionValue as G, type AthenaConditionArrayValue as H, type IntrospectionSnapshot as I, type AthenaConditionOperator as J, type AnyModelDef as K, type AthenaGatewayHookConfig as L, type ModelAt as M, type AthenaGatewayHookResult as N, type AthenaDeletePayload as O, type AthenaFetchPayload as P, type AthenaGatewayResponse as Q, type RegistryDef as R, type SchemaIntrospectionProvider as S, type TenantContext as T, type UpdateOf as U, type AthenaInsertPayload as V, type AthenaUpdatePayload as W, type AthenaGatewayEndpointPath as X, type AthenaGatewayMethod as Y, type AthenaGatewayCallOptions as a, type AthenaGatewayErrorCode as b, type AthenaGatewayErrorDetails as c, type AthenaJsonArray as d, type AthenaJsonObject as e, type AthenaJsonPrimitive as f, type AthenaJsonValue as g, type AthenaRpcCallOptions as h, type AthenaRpcFilter as i, type AthenaRpcFilterOperator as j, type AthenaRpcOrder as k, type AthenaRpcPayload as l, type BackendConfig as m, type BackendType as n, type InsertOf as o, type IntrospectionColumn as p, type IntrospectionInspectOptions as q, type IntrospectionRelation as r, type IntrospectionSchema as s, type IntrospectionTable as t, type IntrospectionTypeKind as u, type ModelDef as v, type ModelMetadata as w, type ModelRelationKind as x, type ModelRelationMetadata as y, type RowOf as z };
381
+ export { type AthenaConditionCastType as A, Backend as B, type SchemaDef as C, type DatabaseDef as D, type TenantContextValue as E, type TenantKeyMap as F, type AthenaConditionValue as G, type AthenaConditionArrayValue as H, type IntrospectionSnapshot as I, type AnyModelDef as J, type AthenaConditionOperator as K, type AthenaGatewayHookConfig as L, type ModelAt as M, type AthenaGatewayHookResult as N, type AthenaDeletePayload as O, type AthenaFetchPayload as P, type AthenaGatewayResponse as Q, type RegistryDef as R, type SchemaIntrospectionProvider as S, type TenantContext as T, type UpdateOf as U, type AthenaInsertPayload as V, type AthenaUpdatePayload as W, type AthenaGatewayEndpointPath as X, type AthenaGatewayMethod as Y, type AthenaGatewayCallOptions as a, type AthenaGatewayErrorCode as b, type AthenaGatewayErrorDetails as c, type AthenaJsonArray as d, type AthenaJsonObject as e, type AthenaJsonPrimitive as f, type AthenaJsonValue as g, type AthenaRpcCallOptions as h, type AthenaRpcFilter as i, type AthenaRpcFilterOperator as j, type AthenaRpcOrder as k, type AthenaRpcPayload as l, type BackendConfig as m, type BackendType as n, type InsertOf as o, type IntrospectionColumn as p, type IntrospectionInspectOptions as q, type IntrospectionRelation as r, type IntrospectionSchema as s, type IntrospectionTable as t, type IntrospectionTypeKind as u, type ModelDef as v, type ModelMetadata as w, type ModelRelationKind as x, type ModelRelationMetadata as y, type RowOf as z };
@@ -1,4 +1,4 @@
1
- import { n as BackendType, I as IntrospectionSnapshot, S as SchemaIntrospectionProvider } from './types-BaBzjwXr.js';
1
+ import { n as BackendType, I as IntrospectionSnapshot, S as SchemaIntrospectionProvider } from './types-A5e97acl.js';
2
2
 
3
3
  /**
4
4
  * Supported case transformations for generated symbols and path token variants.
@@ -1,4 +1,4 @@
1
- import { n as BackendType, I as IntrospectionSnapshot, S as SchemaIntrospectionProvider } from './types-BaBzjwXr.cjs';
1
+ import { n as BackendType, I as IntrospectionSnapshot, S as SchemaIntrospectionProvider } from './types-A5e97acl.cjs';
2
2
 
3
3
  /**
4
4
  * Supported case transformations for generated symbols and path token variants.
package/dist/utils.cjs ADDED
@@ -0,0 +1,153 @@
1
+ 'use strict';
2
+
3
+ // src/utils/slugify.ts
4
+ function slugify(input) {
5
+ return input.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 64);
6
+ }
7
+
8
+ // src/utils/trim-trailing-slashes.ts
9
+ function trimTrailingSlashes(value) {
10
+ return value.replace(/\/+$/, "");
11
+ }
12
+
13
+ // src/utils/parse-boolean-flag.ts
14
+ function parseBooleanFlag(rawValue, fallback) {
15
+ if (!rawValue) return fallback;
16
+ const normalized = rawValue.trim().toLowerCase();
17
+ if (normalized === "1" || normalized === "true" || normalized === "yes" || normalized === "on") {
18
+ return true;
19
+ }
20
+ if (normalized === "0" || normalized === "false" || normalized === "no" || normalized === "off") {
21
+ return false;
22
+ }
23
+ return fallback;
24
+ }
25
+
26
+ // src/utils/hostname.ts
27
+ var LOCAL_IPV4_PATTERN = /^127(?:\.\d{1,3}){3}$/;
28
+ function isLocalHostname(hostname) {
29
+ const normalized = hostname.trim().replace(/\.$/, "").toLowerCase();
30
+ if (!normalized) {
31
+ return false;
32
+ }
33
+ if (normalized === "localhost" || normalized.endsWith(".localhost")) {
34
+ return true;
35
+ }
36
+ if (normalized === "127.0.0.1" || LOCAL_IPV4_PATTERN.test(normalized) || normalized === "::1" || normalized === "[::1]" || normalized === "0:0:0:0:0:0:0:1") {
37
+ return true;
38
+ }
39
+ return false;
40
+ }
41
+
42
+ // src/utils/auth-cookies.ts
43
+ var DEFAULT_AUTH_COOKIE_PREFIXES = [
44
+ "athena-auth",
45
+ "__Secure-athena-auth",
46
+ "better-auth",
47
+ "__Secure-better-auth"
48
+ ];
49
+ function extractCookieNames(cookieHeader) {
50
+ const names = /* @__PURE__ */ new Set();
51
+ for (const rawCookie of cookieHeader.split(";")) {
52
+ const trimmed = rawCookie.trim();
53
+ if (!trimmed) continue;
54
+ const eqPos = trimmed.indexOf("=");
55
+ const name = (eqPos > -1 ? trimmed.slice(0, eqPos) : trimmed).trim();
56
+ if (name) {
57
+ names.add(name);
58
+ }
59
+ }
60
+ return Array.from(names);
61
+ }
62
+ function buildCookieDomainCandidates(hostname) {
63
+ const normalized = hostname.trim().replace(/\.$/, "").toLowerCase();
64
+ if (!normalized || isLocalHostname(normalized)) {
65
+ return [];
66
+ }
67
+ const labels = normalized.split(".").filter(Boolean);
68
+ if (labels.length < 2) {
69
+ return [normalized, `.${normalized}`];
70
+ }
71
+ const domains = /* @__PURE__ */ new Set();
72
+ for (let index = 0; index <= labels.length - 2; index += 1) {
73
+ const domain = labels.slice(index).join(".");
74
+ domains.add(domain);
75
+ domains.add(`.${domain}`);
76
+ }
77
+ return Array.from(domains);
78
+ }
79
+ function getCookieStore() {
80
+ const candidate = globalThis.document;
81
+ if (!candidate || typeof candidate.cookie !== "string") {
82
+ return null;
83
+ }
84
+ return candidate;
85
+ }
86
+ function getRuntimeHostname() {
87
+ const fromWindow = globalThis.window?.location?.hostname;
88
+ if (typeof fromWindow === "string") {
89
+ return fromWindow;
90
+ }
91
+ const fromLocation = globalThis.location?.hostname;
92
+ if (typeof fromLocation === "string") {
93
+ return fromLocation;
94
+ }
95
+ return "";
96
+ }
97
+ function writeExpiredCookie(cookieStore, name, path, domain) {
98
+ const domainClause = domain ? ` domain=${domain};` : "";
99
+ cookieStore.cookie = `${name}=; expires=Thu, 01 Jan 1970 00:00:00 GMT; Max-Age=0; path=${path};${domainClause}`;
100
+ }
101
+ function clearAuthCookies(options = {}) {
102
+ const cookieStore = getCookieStore();
103
+ if (!cookieStore) {
104
+ return [];
105
+ }
106
+ const cookieHeader = options.cookieHeader ?? cookieStore.cookie;
107
+ if (!cookieHeader?.trim()) {
108
+ return [];
109
+ }
110
+ const prefixes = options.prefixes?.length ? options.prefixes : [...DEFAULT_AUTH_COOKIE_PREFIXES];
111
+ const cookieNames = extractCookieNames(cookieHeader);
112
+ const namesToClear = cookieNames.filter((name) => prefixes.some((prefix) => name.startsWith(prefix)));
113
+ if (namesToClear.length === 0) {
114
+ return [];
115
+ }
116
+ const path = options.path?.trim() || "/";
117
+ const hostname = options.hostname ?? getRuntimeHostname();
118
+ const domainCandidates = buildCookieDomainCandidates(hostname);
119
+ for (const name of namesToClear) {
120
+ writeExpiredCookie(cookieStore, name, path);
121
+ for (const domain of domainCandidates) {
122
+ writeExpiredCookie(cookieStore, name, path, domain);
123
+ }
124
+ }
125
+ return namesToClear;
126
+ }
127
+
128
+ // src/utils/proxy-request-headers.ts
129
+ function proxyRequestHeaders(request) {
130
+ const headers = new Headers(request.headers);
131
+ const requestUrl = new URL(request.url);
132
+ const proto = requestUrl.protocol.replace(/:$/u, "") || "https";
133
+ headers.delete("host");
134
+ headers.set("x-forwarded-host", requestUrl.host);
135
+ headers.set("x-forwarded-proto", proto);
136
+ headers.set("x-forwarded-origin", requestUrl.origin);
137
+ headers.set("x-forwarded-uri", `${requestUrl.pathname}${requestUrl.search}`);
138
+ if (requestUrl.port) {
139
+ headers.set("x-forwarded-port", requestUrl.port);
140
+ } else {
141
+ headers.delete("x-forwarded-port");
142
+ }
143
+ return headers;
144
+ }
145
+
146
+ exports.clearAuthCookies = clearAuthCookies;
147
+ exports.isLocalHostname = isLocalHostname;
148
+ exports.parseBooleanFlag = parseBooleanFlag;
149
+ exports.proxyRequestHeaders = proxyRequestHeaders;
150
+ exports.slugify = slugify;
151
+ exports.trimTrailingSlashes = trimTrailingSlashes;
152
+ //# sourceMappingURL=utils.cjs.map
153
+ //# sourceMappingURL=utils.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/utils/slugify.ts","../src/utils/trim-trailing-slashes.ts","../src/utils/parse-boolean-flag.ts","../src/utils/hostname.ts","../src/utils/auth-cookies.ts","../src/utils/proxy-request-headers.ts"],"names":[],"mappings":";;;AAAO,SAAS,QAAQ,KAAA,EAAuB;AAC7C,EAAA,OAAO,KAAA,CACJ,WAAA,EAAY,CACZ,OAAA,CAAQ,aAAA,EAAe,GAAG,CAAA,CAC1B,OAAA,CAAQ,UAAA,EAAY,EAAE,CAAA,CACtB,KAAA,CAAM,GAAG,EAAE,CAAA;AAChB;;;ACNO,SAAS,oBAAoB,KAAA,EAAuB;AACzD,EAAA,OAAO,KAAA,CAAM,OAAA,CAAQ,MAAA,EAAQ,EAAE,CAAA;AACjC;;;ACFO,SAAS,gBAAA,CACd,UACA,QAAA,EACS;AACT,EAAA,IAAI,CAAC,UAAU,OAAO,QAAA;AAEtB,EAAA,MAAM,UAAA,GAAa,QAAA,CAAS,IAAA,EAAK,CAAE,WAAA,EAAY;AAE/C,EAAA,IACE,eAAe,GAAA,IACf,UAAA,KAAe,UACf,UAAA,KAAe,KAAA,IACf,eAAe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Q,GAAA,CAAI,mBAAmB,CAAA,EAAG,UAAA,CAAW,QAAQ,CAAA,EAAG,UAAA,CAAW,MAAM,CAAA,CAAE,CAAA;AAE3E,EAAA,IAAI,WAAW,IAAA,EAAM;AACnB,IAAA,OAAA,CAAQ,GAAA,CAAI,kBAAA,EAAoB,UAAA,CAAW,IAAI,CAAA;AAAA,EACjD,CAAA,MAAO;AACL,IAAA,OAAA,CAAQ,OAAO,kBAAkB,CAAA;AAAA,EACnC;AAEA,EAAA,OAAO,OAAA;AACT","file":"utils.cjs","sourcesContent":["export function slugify(input: string): string {\n return input\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, '-')\n .replace(/^-+|-+$/g, '')\n .slice(0, 64)\n}\n","export function trimTrailingSlashes(value: string): string {\n return value.replace(/\\/+$/, '')\n}\n","export function parseBooleanFlag(\n rawValue: string | undefined,\n fallback: boolean,\n): boolean {\n if (!rawValue) return fallback\n\n const normalized = rawValue.trim().toLowerCase()\n\n if (\n normalized === '1' ||\n normalized === 'true' ||\n normalized === 'yes' ||\n normalized === 'on'\n ) {\n return true\n }\n\n if (\n normalized === '0' ||\n normalized === 'false' ||\n normalized === 'no' ||\n normalized === 'off'\n ) {\n return false\n }\n\n return fallback\n}\n","const LOCAL_IPV4_PATTERN = /^127(?:\\.\\d{1,3}){3}$/\n\nexport function isLocalHostname(hostname: string): boolean {\n const normalized = hostname.trim().replace(/\\.$/, '').toLowerCase()\n if (!normalized) {\n return false\n }\n\n if (normalized === 'localhost' || normalized.endsWith('.localhost')) {\n return true\n }\n\n if (\n normalized === '127.0.0.1' ||\n LOCAL_IPV4_PATTERN.test(normalized) ||\n normalized === '::1' ||\n normalized === '[::1]' ||\n normalized === '0:0:0:0:0:0:0:1'\n ) {\n return true\n }\n\n return false\n}\n","import { isLocalHostname } from './hostname.ts'\n\nconst DEFAULT_AUTH_COOKIE_PREFIXES = [\n 'athena-auth',\n '__Secure-athena-auth',\n 'better-auth',\n '__Secure-better-auth',\n] as const\n\nexport interface ClearAuthCookiesOptions {\n prefixes?: string[]\n hostname?: string\n path?: string\n cookieHeader?: string\n}\n\ninterface BrowserCookieStore {\n cookie: string\n}\n\nfunction extractCookieNames(cookieHeader: string): string[] {\n const names = new Set<string>()\n for (const rawCookie of cookieHeader.split(';')) {\n const trimmed = rawCookie.trim()\n if (!trimmed) continue\n\n const eqPos = trimmed.indexOf('=')\n const name = (eqPos > -1 ? trimmed.slice(0, eqPos) : trimmed).trim()\n if (name) {\n names.add(name)\n }\n }\n return Array.from(names)\n}\n\nfunction buildCookieDomainCandidates(hostname: string): string[] {\n const normalized = hostname.trim().replace(/\\.$/, '').toLowerCase()\n if (!normalized || isLocalHostname(normalized)) {\n return []\n }\n\n const labels = normalized.split('.').filter(Boolean)\n if (labels.length < 2) {\n return [normalized, `.${normalized}`]\n }\n\n const domains = new Set<string>()\n for (let index = 0; index <= labels.length - 2; index += 1) {\n const domain = labels.slice(index).join('.')\n domains.add(domain)\n domains.add(`.${domain}`)\n }\n return Array.from(domains)\n}\n\nfunction getCookieStore(): BrowserCookieStore | null {\n const candidate = (globalThis as { document?: BrowserCookieStore }).document\n if (!candidate || typeof candidate.cookie !== 'string') {\n return null\n }\n return candidate\n}\n\nfunction getRuntimeHostname(): string {\n const fromWindow = (\n globalThis as { window?: { location?: { hostname?: string } } }\n ).window?.location?.hostname\n if (typeof fromWindow === 'string') {\n return fromWindow\n }\n\n const fromLocation = (\n globalThis as { location?: { hostname?: string } }\n ).location?.hostname\n if (typeof fromLocation === 'string') {\n return fromLocation\n }\n\n return ''\n}\n\nfunction writeExpiredCookie(\n cookieStore: BrowserCookieStore,\n name: string,\n path: string,\n domain?: string,\n) {\n const domainClause = domain ? ` domain=${domain};` : ''\n cookieStore.cookie =\n `${name}=; expires=Thu, 01 Jan 1970 00:00:00 GMT; Max-Age=0; path=${path};${domainClause}`\n}\n\n/**\n * Clears Athena/Better Auth browser cookies by prefix.\n * Returns the cookie names that matched and were targeted for deletion.\n */\nexport function clearAuthCookies(options: ClearAuthCookiesOptions = {}): string[] {\n const cookieStore = getCookieStore()\n if (!cookieStore) {\n return []\n }\n\n const cookieHeader = options.cookieHeader ?? cookieStore.cookie\n if (!cookieHeader?.trim()) {\n return []\n }\n\n const prefixes = options.prefixes?.length ? options.prefixes : [...DEFAULT_AUTH_COOKIE_PREFIXES]\n const cookieNames = extractCookieNames(cookieHeader)\n const namesToClear = cookieNames.filter(name => prefixes.some(prefix => name.startsWith(prefix)))\n if (namesToClear.length === 0) {\n return []\n }\n\n const path = options.path?.trim() || '/'\n const hostname = options.hostname ?? getRuntimeHostname()\n const domainCandidates = buildCookieDomainCandidates(hostname)\n\n for (const name of namesToClear) {\n writeExpiredCookie(cookieStore, name, path)\n for (const domain of domainCandidates) {\n writeExpiredCookie(cookieStore, name, path, domain)\n }\n }\n\n return namesToClear\n}\n","export function proxyRequestHeaders(request: Request): Headers {\n const headers = new Headers(request.headers)\n const requestUrl = new URL(request.url)\n const proto = requestUrl.protocol.replace(/:$/u, '') || 'https'\n\n // Let fetch set the upstream Host header, but keep the original public app\n // origin available for auth servers that need to validate or generate links\n // for Vercel preview domains behind this proxy.\n headers.delete('host')\n headers.set('x-forwarded-host', requestUrl.host)\n headers.set('x-forwarded-proto', proto)\n headers.set('x-forwarded-origin', requestUrl.origin)\n headers.set('x-forwarded-uri', `${requestUrl.pathname}${requestUrl.search}`)\n\n if (requestUrl.port) {\n headers.set('x-forwarded-port', requestUrl.port)\n } else {\n headers.delete('x-forwarded-port')\n }\n\n return headers\n}\n"]}
@@ -0,0 +1,23 @@
1
+ declare function slugify(input: string): string;
2
+
3
+ declare function trimTrailingSlashes(value: string): string;
4
+
5
+ declare function parseBooleanFlag(rawValue: string | undefined, fallback: boolean): boolean;
6
+
7
+ declare function isLocalHostname(hostname: string): boolean;
8
+
9
+ interface ClearAuthCookiesOptions {
10
+ prefixes?: string[];
11
+ hostname?: string;
12
+ path?: string;
13
+ cookieHeader?: string;
14
+ }
15
+ /**
16
+ * Clears Athena/Better Auth browser cookies by prefix.
17
+ * Returns the cookie names that matched and were targeted for deletion.
18
+ */
19
+ declare function clearAuthCookies(options?: ClearAuthCookiesOptions): string[];
20
+
21
+ declare function proxyRequestHeaders(request: Request): Headers;
22
+
23
+ export { type ClearAuthCookiesOptions, clearAuthCookies, isLocalHostname, parseBooleanFlag, proxyRequestHeaders, slugify, trimTrailingSlashes };
@@ -0,0 +1,23 @@
1
+ declare function slugify(input: string): string;
2
+
3
+ declare function trimTrailingSlashes(value: string): string;
4
+
5
+ declare function parseBooleanFlag(rawValue: string | undefined, fallback: boolean): boolean;
6
+
7
+ declare function isLocalHostname(hostname: string): boolean;
8
+
9
+ interface ClearAuthCookiesOptions {
10
+ prefixes?: string[];
11
+ hostname?: string;
12
+ path?: string;
13
+ cookieHeader?: string;
14
+ }
15
+ /**
16
+ * Clears Athena/Better Auth browser cookies by prefix.
17
+ * Returns the cookie names that matched and were targeted for deletion.
18
+ */
19
+ declare function clearAuthCookies(options?: ClearAuthCookiesOptions): string[];
20
+
21
+ declare function proxyRequestHeaders(request: Request): Headers;
22
+
23
+ export { type ClearAuthCookiesOptions, clearAuthCookies, isLocalHostname, parseBooleanFlag, proxyRequestHeaders, slugify, trimTrailingSlashes };
package/dist/utils.js ADDED
@@ -0,0 +1,146 @@
1
+ // src/utils/slugify.ts
2
+ function slugify(input) {
3
+ return input.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 64);
4
+ }
5
+
6
+ // src/utils/trim-trailing-slashes.ts
7
+ function trimTrailingSlashes(value) {
8
+ return value.replace(/\/+$/, "");
9
+ }
10
+
11
+ // src/utils/parse-boolean-flag.ts
12
+ function parseBooleanFlag(rawValue, fallback) {
13
+ if (!rawValue) return fallback;
14
+ const normalized = rawValue.trim().toLowerCase();
15
+ if (normalized === "1" || normalized === "true" || normalized === "yes" || normalized === "on") {
16
+ return true;
17
+ }
18
+ if (normalized === "0" || normalized === "false" || normalized === "no" || normalized === "off") {
19
+ return false;
20
+ }
21
+ return fallback;
22
+ }
23
+
24
+ // src/utils/hostname.ts
25
+ var LOCAL_IPV4_PATTERN = /^127(?:\.\d{1,3}){3}$/;
26
+ function isLocalHostname(hostname) {
27
+ const normalized = hostname.trim().replace(/\.$/, "").toLowerCase();
28
+ if (!normalized) {
29
+ return false;
30
+ }
31
+ if (normalized === "localhost" || normalized.endsWith(".localhost")) {
32
+ return true;
33
+ }
34
+ if (normalized === "127.0.0.1" || LOCAL_IPV4_PATTERN.test(normalized) || normalized === "::1" || normalized === "[::1]" || normalized === "0:0:0:0:0:0:0:1") {
35
+ return true;
36
+ }
37
+ return false;
38
+ }
39
+
40
+ // src/utils/auth-cookies.ts
41
+ var DEFAULT_AUTH_COOKIE_PREFIXES = [
42
+ "athena-auth",
43
+ "__Secure-athena-auth",
44
+ "better-auth",
45
+ "__Secure-better-auth"
46
+ ];
47
+ function extractCookieNames(cookieHeader) {
48
+ const names = /* @__PURE__ */ new Set();
49
+ for (const rawCookie of cookieHeader.split(";")) {
50
+ const trimmed = rawCookie.trim();
51
+ if (!trimmed) continue;
52
+ const eqPos = trimmed.indexOf("=");
53
+ const name = (eqPos > -1 ? trimmed.slice(0, eqPos) : trimmed).trim();
54
+ if (name) {
55
+ names.add(name);
56
+ }
57
+ }
58
+ return Array.from(names);
59
+ }
60
+ function buildCookieDomainCandidates(hostname) {
61
+ const normalized = hostname.trim().replace(/\.$/, "").toLowerCase();
62
+ if (!normalized || isLocalHostname(normalized)) {
63
+ return [];
64
+ }
65
+ const labels = normalized.split(".").filter(Boolean);
66
+ if (labels.length < 2) {
67
+ return [normalized, `.${normalized}`];
68
+ }
69
+ const domains = /* @__PURE__ */ new Set();
70
+ for (let index = 0; index <= labels.length - 2; index += 1) {
71
+ const domain = labels.slice(index).join(".");
72
+ domains.add(domain);
73
+ domains.add(`.${domain}`);
74
+ }
75
+ return Array.from(domains);
76
+ }
77
+ function getCookieStore() {
78
+ const candidate = globalThis.document;
79
+ if (!candidate || typeof candidate.cookie !== "string") {
80
+ return null;
81
+ }
82
+ return candidate;
83
+ }
84
+ function getRuntimeHostname() {
85
+ const fromWindow = globalThis.window?.location?.hostname;
86
+ if (typeof fromWindow === "string") {
87
+ return fromWindow;
88
+ }
89
+ const fromLocation = globalThis.location?.hostname;
90
+ if (typeof fromLocation === "string") {
91
+ return fromLocation;
92
+ }
93
+ return "";
94
+ }
95
+ function writeExpiredCookie(cookieStore, name, path, domain) {
96
+ const domainClause = domain ? ` domain=${domain};` : "";
97
+ cookieStore.cookie = `${name}=; expires=Thu, 01 Jan 1970 00:00:00 GMT; Max-Age=0; path=${path};${domainClause}`;
98
+ }
99
+ function clearAuthCookies(options = {}) {
100
+ const cookieStore = getCookieStore();
101
+ if (!cookieStore) {
102
+ return [];
103
+ }
104
+ const cookieHeader = options.cookieHeader ?? cookieStore.cookie;
105
+ if (!cookieHeader?.trim()) {
106
+ return [];
107
+ }
108
+ const prefixes = options.prefixes?.length ? options.prefixes : [...DEFAULT_AUTH_COOKIE_PREFIXES];
109
+ const cookieNames = extractCookieNames(cookieHeader);
110
+ const namesToClear = cookieNames.filter((name) => prefixes.some((prefix) => name.startsWith(prefix)));
111
+ if (namesToClear.length === 0) {
112
+ return [];
113
+ }
114
+ const path = options.path?.trim() || "/";
115
+ const hostname = options.hostname ?? getRuntimeHostname();
116
+ const domainCandidates = buildCookieDomainCandidates(hostname);
117
+ for (const name of namesToClear) {
118
+ writeExpiredCookie(cookieStore, name, path);
119
+ for (const domain of domainCandidates) {
120
+ writeExpiredCookie(cookieStore, name, path, domain);
121
+ }
122
+ }
123
+ return namesToClear;
124
+ }
125
+
126
+ // src/utils/proxy-request-headers.ts
127
+ function proxyRequestHeaders(request) {
128
+ const headers = new Headers(request.headers);
129
+ const requestUrl = new URL(request.url);
130
+ const proto = requestUrl.protocol.replace(/:$/u, "") || "https";
131
+ headers.delete("host");
132
+ headers.set("x-forwarded-host", requestUrl.host);
133
+ headers.set("x-forwarded-proto", proto);
134
+ headers.set("x-forwarded-origin", requestUrl.origin);
135
+ headers.set("x-forwarded-uri", `${requestUrl.pathname}${requestUrl.search}`);
136
+ if (requestUrl.port) {
137
+ headers.set("x-forwarded-port", requestUrl.port);
138
+ } else {
139
+ headers.delete("x-forwarded-port");
140
+ }
141
+ return headers;
142
+ }
143
+
144
+ export { clearAuthCookies, isLocalHostname, parseBooleanFlag, proxyRequestHeaders, slugify, trimTrailingSlashes };
145
+ //# sourceMappingURL=utils.js.map
146
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/utils/slugify.ts","../src/utils/trim-trailing-slashes.ts","../src/utils/parse-boolean-flag.ts","../src/utils/hostname.ts","../src/utils/auth-cookies.ts","../src/utils/proxy-request-headers.ts"],"names":[],"mappings":";AAAO,SAAS,QAAQ,KAAA,EAAuB;AAC7C,EAAA,OAAO,KAAA,CACJ,WAAA,EAAY,CACZ,OAAA,CAAQ,aAAA,EAAe,GAAG,CAAA,CAC1B,OAAA,CAAQ,UAAA,EAAY,EAAE,CAAA,CACtB,KAAA,CAAM,GAAG,EAAE,CAAA;AAChB;;;ACNO,SAAS,oBAAoB,KAAA,EAAuB;AACzD,EAAA,OAAO,KAAA,CAAM,OAAA,CAAQ,MAAA,EAAQ,EAAE,CAAA;AACjC;;;ACFO,SAAS,gBAAA,CACd,UACA,QAAA,EACS;AACT,EAAA,IAAI,CAAC,UAAU,OAAO,QAAA;AAEtB,EAAA,MAAM,UAAA,GAAa,QAAA,CAAS,IAAA,EAAK,CAAE,WAAA,EAAY;AAE/C,EAAA,IACE,eAAe,GAAA,IACf,UAAA,KAAe,UACf,UAAA,KAAe,KAAA,IACf,eAAe,IAAA,EACf;AACA,IAAA,OAAO,IAAA;AAAA,EACT;AAEA,EAAA,IACE,eAAe,GAAA,IACf,UAAA,KAAe,WACf,UAAA,KAAe,IAAA,IACf,eAAe,KAAA,EACf;AACA,IAAA,OAAO,KAAA;AAAA,EACT;AAEA,EAAA,OAAO,QAAA;A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AA,CAAW,IAAI,CAAA;AAAA,EACjD,CAAA,MAAO;AACL,IAAA,OAAA,CAAQ,OAAO,kBAAkB,CAAA;AAAA,EACnC;AAEA,EAAA,OAAO,OAAA;AACT","file":"utils.js","sourcesContent":["export function slugify(input: string): string {\n return input\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, '-')\n .replace(/^-+|-+$/g, '')\n .slice(0, 64)\n}\n","export function trimTrailingSlashes(value: string): string {\n return value.replace(/\\/+$/, '')\n}\n","export function parseBooleanFlag(\n rawValue: string | undefined,\n fallback: boolean,\n): boolean {\n if (!rawValue) return fallback\n\n const normalized = rawValue.trim().toLowerCase()\n\n if (\n normalized === '1' ||\n normalized === 'true' ||\n normalized === 'yes' ||\n normalized === 'on'\n ) {\n return true\n }\n\n if (\n normalized === '0' ||\n normalized === 'false' ||\n normalized === 'no' ||\n normalized === 'off'\n ) {\n return false\n }\n\n return fallback\n}\n","const LOCAL_IPV4_PATTERN = /^127(?:\\.\\d{1,3}){3}$/\n\nexport function isLocalHostname(hostname: string): boolean {\n const normalized = hostname.trim().replace(/\\.$/, '').toLowerCase()\n if (!normalized) {\n return false\n }\n\n if (normalized === 'localhost' || normalized.endsWith('.localhost')) {\n return true\n }\n\n if (\n normalized === '127.0.0.1' ||\n LOCAL_IPV4_PATTERN.test(normalized) ||\n normalized === '::1' ||\n normalized === '[::1]' ||\n normalized === '0:0:0:0:0:0:0:1'\n ) {\n return true\n }\n\n return false\n}\n","import { isLocalHostname } from './hostname.ts'\n\nconst DEFAULT_AUTH_COOKIE_PREFIXES = [\n 'athena-auth',\n '__Secure-athena-auth',\n 'better-auth',\n '__Secure-better-auth',\n] as const\n\nexport interface ClearAuthCookiesOptions {\n prefixes?: string[]\n hostname?: string\n path?: string\n cookieHeader?: string\n}\n\ninterface BrowserCookieStore {\n cookie: string\n}\n\nfunction extractCookieNames(cookieHeader: string): string[] {\n const names = new Set<string>()\n for (const rawCookie of cookieHeader.split(';')) {\n const trimmed = rawCookie.trim()\n if (!trimmed) continue\n\n const eqPos = trimmed.indexOf('=')\n const name = (eqPos > -1 ? trimmed.slice(0, eqPos) : trimmed).trim()\n if (name) {\n names.add(name)\n }\n }\n return Array.from(names)\n}\n\nfunction buildCookieDomainCandidates(hostname: string): string[] {\n const normalized = hostname.trim().replace(/\\.$/, '').toLowerCase()\n if (!normalized || isLocalHostname(normalized)) {\n return []\n }\n\n const labels = normalized.split('.').filter(Boolean)\n if (labels.length < 2) {\n return [normalized, `.${normalized}`]\n }\n\n const domains = new Set<string>()\n for (let index = 0; index <= labels.length - 2; index += 1) {\n const domain = labels.slice(index).join('.')\n domains.add(domain)\n domains.add(`.${domain}`)\n }\n return Array.from(domains)\n}\n\nfunction getCookieStore(): BrowserCookieStore | null {\n const candidate = (globalThis as { document?: BrowserCookieStore }).document\n if (!candidate || typeof candidate.cookie !== 'string') {\n return null\n }\n return candidate\n}\n\nfunction getRuntimeHostname(): string {\n const fromWindow = (\n globalThis as { window?: { location?: { hostname?: string } } }\n ).window?.location?.hostname\n if (typeof fromWindow === 'string') {\n return fromWindow\n }\n\n const fromLocation = (\n globalThis as { location?: { hostname?: string } }\n ).location?.hostname\n if (typeof fromLocation === 'string') {\n return fromLocation\n }\n\n return ''\n}\n\nfunction writeExpiredCookie(\n cookieStore: BrowserCookieStore,\n name: string,\n path: string,\n domain?: string,\n) {\n const domainClause = domain ? ` domain=${domain};` : ''\n cookieStore.cookie =\n `${name}=; expires=Thu, 01 Jan 1970 00:00:00 GMT; Max-Age=0; path=${path};${domainClause}`\n}\n\n/**\n * Clears Athena/Better Auth browser cookies by prefix.\n * Returns the cookie names that matched and were targeted for deletion.\n */\nexport function clearAuthCookies(options: ClearAuthCookiesOptions = {}): string[] {\n const cookieStore = getCookieStore()\n if (!cookieStore) {\n return []\n }\n\n const cookieHeader = options.cookieHeader ?? cookieStore.cookie\n if (!cookieHeader?.trim()) {\n return []\n }\n\n const prefixes = options.prefixes?.length ? options.prefixes : [...DEFAULT_AUTH_COOKIE_PREFIXES]\n const cookieNames = extractCookieNames(cookieHeader)\n const namesToClear = cookieNames.filter(name => prefixes.some(prefix => name.startsWith(prefix)))\n if (namesToClear.length === 0) {\n return []\n }\n\n const path = options.path?.trim() || '/'\n const hostname = options.hostname ?? getRuntimeHostname()\n const domainCandidates = buildCookieDomainCandidates(hostname)\n\n for (const name of namesToClear) {\n writeExpiredCookie(cookieStore, name, path)\n for (const domain of domainCandidates) {\n writeExpiredCookie(cookieStore, name, path, domain)\n }\n }\n\n return namesToClear\n}\n","export function proxyRequestHeaders(request: Request): Headers {\n const headers = new Headers(request.headers)\n const requestUrl = new URL(request.url)\n const proto = requestUrl.protocol.replace(/:$/u, '') || 'https'\n\n // Let fetch set the upstream Host header, but keep the original public app\n // origin available for auth servers that need to validate or generate links\n // for Vercel preview domains behind this proxy.\n headers.delete('host')\n headers.set('x-forwarded-host', requestUrl.host)\n headers.set('x-forwarded-proto', proto)\n headers.set('x-forwarded-origin', requestUrl.origin)\n headers.set('x-forwarded-uri', `${requestUrl.pathname}${requestUrl.search}`)\n\n if (requestUrl.port) {\n headers.set('x-forwarded-port', requestUrl.port)\n } else {\n headers.delete('x-forwarded-port')\n }\n\n return headers\n}\n"]}
package/package.json CHANGED
@@ -4,7 +4,6 @@
4
4
  "athena-js": "./bin/athena-js.js"
5
5
  },
6
6
  "dependencies": {
7
- "@xylex-group/athena": "^0.2.1",
8
7
  "blessed": "^0.1.81",
9
8
  "chalk": "^4.1.2",
10
9
  "cron-parser": "^4.9.0",
@@ -14,6 +13,8 @@
14
13
  },
15
14
  "description": "Athena JS SDK",
16
15
  "devDependencies": {
16
+ "@react-email/components": "^1.0.12",
17
+ "@react-email/render": "^2.0.8",
17
18
  "@types/blessed": "^0.1.25",
18
19
  "@types/node": "^20.10.5",
19
20
  "@types/pg": "^8.15.1",
@@ -25,6 +26,7 @@
25
26
  "eslint": "^8.57.1",
26
27
  "express": "^4.22.2",
27
28
  "react": "^18.3.1",
29
+ "react-dom": "^18.3.1",
28
30
  "react-test-renderer": "^18.3.1",
29
31
  "tsup": "^8.5.1",
30
32
  "tsx": "^4.7.0",
@@ -36,28 +38,71 @@
36
38
  "exports": {
37
39
  ".": {
38
40
  "browser": {
39
- "import": "./dist/browser.js",
40
- "require": "./dist/browser.cjs"
41
+ "import": {
42
+ "types": "./dist/browser.d.ts",
43
+ "default": "./dist/browser.js"
44
+ },
45
+ "require": {
46
+ "types": "./dist/browser.d.cts",
47
+ "default": "./dist/browser.cjs"
48
+ },
49
+ "default": "./dist/browser.js"
41
50
  },
42
- "import": "./dist/index.js",
43
- "require": "./dist/index.cjs",
44
- "types": "./dist/index.d.ts"
51
+ "import": {
52
+ "types": "./dist/index.d.ts",
53
+ "default": "./dist/index.js"
54
+ },
55
+ "require": {
56
+ "types": "./dist/index.d.cts",
57
+ "default": "./dist/index.cjs"
58
+ },
59
+ "default": "./dist/index.js"
45
60
  },
46
61
  "./browser": {
47
- "import": "./dist/browser.js",
48
- "require": "./dist/browser.cjs",
49
- "types": "./dist/browser.d.ts"
62
+ "import": {
63
+ "types": "./dist/browser.d.ts",
64
+ "default": "./dist/browser.js"
65
+ },
66
+ "require": {
67
+ "types": "./dist/browser.d.cts",
68
+ "default": "./dist/browser.cjs"
69
+ },
70
+ "default": "./dist/browser.js"
50
71
  },
51
72
  "./cookies": {
52
- "import": "./dist/cookies.js",
53
- "require": "./dist/cookies.cjs",
54
- "types": "./dist/cookies.d.ts"
73
+ "import": {
74
+ "types": "./dist/cookies.d.ts",
75
+ "default": "./dist/cookies.js"
76
+ },
77
+ "require": {
78
+ "types": "./dist/cookies.d.cts",
79
+ "default": "./dist/cookies.cjs"
80
+ },
81
+ "default": "./dist/cookies.js"
55
82
  },
56
83
  "./react": {
57
- "import": "./dist/react.js",
58
- "require": "./dist/react.cjs",
59
- "types": "./dist/react.d.ts"
60
- }
84
+ "import": {
85
+ "types": "./dist/react.d.ts",
86
+ "default": "./dist/react.js"
87
+ },
88
+ "require": {
89
+ "types": "./dist/react.d.cts",
90
+ "default": "./dist/react.cjs"
91
+ },
92
+ "default": "./dist/react.js"
93
+ },
94
+ "./utils": {
95
+ "import": {
96
+ "types": "./dist/utils.d.ts",
97
+ "default": "./dist/utils.js"
98
+ },
99
+ "require": {
100
+ "types": "./dist/utils.d.cts",
101
+ "default": "./dist/utils.cjs"
102
+ },
103
+ "default": "./dist/utils.js"
104
+ },
105
+ "./package.json": "./package.json"
61
106
  },
62
107
  "files": [
63
108
  "dist",
@@ -80,10 +125,19 @@
80
125
  "main": "./dist/index.cjs",
81
126
  "module": "./dist/index.js",
82
127
  "name": "@xylex-group/athena",
128
+ "sideEffects": false,
83
129
  "peerDependencies": {
130
+ "@react-email/components": ">=1.0.0",
131
+ "@react-email/render": ">=2.0.0",
84
132
  "react": ">=17.0.0"
85
133
  },
86
134
  "peerDependenciesMeta": {
135
+ "@react-email/components": {
136
+ "optional": true
137
+ },
138
+ "@react-email/render": {
139
+ "optional": true
140
+ },
87
141
  "react": {
88
142
  "optional": true
89
143
  }
@@ -108,14 +162,18 @@
108
162
  ],
109
163
  "react": [
110
164
  "dist/react.d.ts"
165
+ ],
166
+ "utils": [
167
+ "dist/utils.d.ts"
111
168
  ]
112
169
  }
113
170
  },
114
- "version": "2.1.2",
171
+ "version": "2.3.0",
115
172
  "scripts": {
116
173
  "build": "tsup",
117
174
  "check:all": "pnpm lint && pnpm typecheck && pnpm test && pnpm build",
118
175
  "dev": "tsup --watch",
176
+ "docs:methods": "node scripts/generate-sdk-method-reference.mjs",
119
177
  "example:api-call": "cd examples/api-call && bun run start",
120
178
  "example:email-resend": "cd examples/email-resend && bun run start",
121
179
  "example:express-api": "cd examples/express-api && bun run start",