@xylex-group/athena 2.4.1 → 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 +52 -1
- package/bin/athena-js.js +0 -0
- package/dist/browser.cjs +1912 -49
- 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 +1905 -50
- package/dist/browser.js.map +1 -1
- package/dist/cli/index.cjs +708 -22
- 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 +708 -22
- 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 +1912 -49
- 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 +1905 -50
- package/dist/index.js.map +1 -1
- package/dist/{model-form-4LPnOPAF.d.cts → model-form-BaHWi3gm.d.cts} +1 -1
- package/dist/{model-form-CO4-LmNC.d.ts → model-form-Dh6gWjL0.d.ts} +1 -1
- 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-Buhcpglm.d.ts → react-email-B8O1Jeff.d.cts} +596 -23
- package/dist/{react-email-6mOyxBo4.d.cts → react-email-CDEF0jij.d.ts} +596 -23
- package/dist/react.cjs +1 -1
- 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 +1 -1
- 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/package.json +193 -192
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
type AthenaCookieSameSite = 'strict' | 'lax' | 'none';
|
|
2
|
+
interface AthenaCookieOptions {
|
|
3
|
+
maxAge?: number;
|
|
4
|
+
expires?: Date;
|
|
5
|
+
domain?: string;
|
|
6
|
+
path?: string;
|
|
7
|
+
secure?: boolean;
|
|
8
|
+
httpOnly?: boolean;
|
|
9
|
+
partitioned?: boolean;
|
|
10
|
+
sameSite?: AthenaCookieSameSite;
|
|
11
|
+
[key: string]: unknown;
|
|
12
|
+
}
|
|
13
|
+
interface AthenaAuthCookie {
|
|
14
|
+
name: string;
|
|
15
|
+
attributes: AthenaCookieOptions;
|
|
16
|
+
}
|
|
17
|
+
interface AthenaAuthCookies {
|
|
18
|
+
sessionToken: AthenaAuthCookie;
|
|
19
|
+
sessionData: AthenaAuthCookie;
|
|
20
|
+
dontRememberToken: AthenaAuthCookie;
|
|
21
|
+
accountData: AthenaAuthCookie;
|
|
22
|
+
}
|
|
23
|
+
interface AthenaCookieDefinition {
|
|
24
|
+
name?: string;
|
|
25
|
+
attributes?: AthenaCookieOptions;
|
|
26
|
+
}
|
|
27
|
+
type AthenaCookieVersionResolver = string | ((session: Record<string, unknown>, user: Record<string, unknown>) => string | Promise<string>);
|
|
28
|
+
interface AthenaSessionCookieCacheConfig {
|
|
29
|
+
enabled?: boolean;
|
|
30
|
+
maxAge?: number;
|
|
31
|
+
strategy?: 'compact' | 'jwt' | 'jwe';
|
|
32
|
+
version?: AthenaCookieVersionResolver;
|
|
33
|
+
}
|
|
34
|
+
interface AthenaCookieAdvancedOptions {
|
|
35
|
+
cookiePrefix?: string;
|
|
36
|
+
useSecureCookies?: boolean;
|
|
37
|
+
defaultCookieAttributes?: AthenaCookieOptions;
|
|
38
|
+
cookies?: Record<string, AthenaCookieDefinition>;
|
|
39
|
+
crossSubDomainCookies?: {
|
|
40
|
+
enabled?: boolean;
|
|
41
|
+
domain?: string;
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
interface AthenaCookiesOptions {
|
|
45
|
+
baseURL?: string | {
|
|
46
|
+
protocol?: 'http' | 'https' | 'auto';
|
|
47
|
+
allowedHosts?: string[];
|
|
48
|
+
};
|
|
49
|
+
session?: {
|
|
50
|
+
expiresIn?: number;
|
|
51
|
+
cookieCache?: AthenaSessionCookieCacheConfig;
|
|
52
|
+
};
|
|
53
|
+
advanced?: AthenaCookieAdvancedOptions;
|
|
54
|
+
}
|
|
55
|
+
interface AthenaSessionPair<SessionShape extends Record<string, unknown> = Record<string, unknown>, UserShape extends Record<string, unknown> = Record<string, unknown>> {
|
|
56
|
+
session: SessionShape & {
|
|
57
|
+
token: string;
|
|
58
|
+
};
|
|
59
|
+
user: UserShape;
|
|
60
|
+
}
|
|
61
|
+
interface AthenaCookieContextRuntime {
|
|
62
|
+
headers?: Headers;
|
|
63
|
+
getCookie?: (name: string) => string | null | undefined;
|
|
64
|
+
setCookie: (name: string, value: string, attributes: AthenaCookieOptions) => void;
|
|
65
|
+
logger?: {
|
|
66
|
+
debug?: (event: string, payload?: unknown) => void;
|
|
67
|
+
};
|
|
68
|
+
setSignedCookie?: (name: string, value: string, secret: string, attributes: AthenaCookieOptions) => void | Promise<void>;
|
|
69
|
+
getSignedCookie?: (name: string, secret: string) => string | null | Promise<string | null>;
|
|
70
|
+
context: {
|
|
71
|
+
secret?: string;
|
|
72
|
+
authCookies: AthenaAuthCookies;
|
|
73
|
+
sessionConfig?: {
|
|
74
|
+
expiresIn?: number;
|
|
75
|
+
};
|
|
76
|
+
options?: {
|
|
77
|
+
session?: {
|
|
78
|
+
cookieCache?: AthenaSessionCookieCacheConfig;
|
|
79
|
+
};
|
|
80
|
+
account?: {
|
|
81
|
+
storeAccountCookie?: boolean;
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
setNewSession?: (session: AthenaSessionPair) => void;
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
interface AthenaGetCookieCacheConfig<SessionShape extends Record<string, unknown> = Record<string, unknown>, UserShape extends Record<string, unknown> = Record<string, unknown>> {
|
|
88
|
+
cookiePrefix?: string;
|
|
89
|
+
cookieName?: string;
|
|
90
|
+
isSecure?: boolean;
|
|
91
|
+
secret?: string;
|
|
92
|
+
strategy?: 'compact' | 'jwt' | 'jwe';
|
|
93
|
+
version?: string | ((session: SessionShape, user: UserShape) => string | Promise<string>);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
interface CookieAttributes {
|
|
97
|
+
value: string;
|
|
98
|
+
'max-age'?: number;
|
|
99
|
+
expires?: Date;
|
|
100
|
+
domain?: string;
|
|
101
|
+
path?: string;
|
|
102
|
+
secure?: boolean;
|
|
103
|
+
httponly?: boolean;
|
|
104
|
+
partitioned?: boolean;
|
|
105
|
+
samesite?: 'strict' | 'lax' | 'none';
|
|
106
|
+
[key: string]: unknown;
|
|
107
|
+
}
|
|
108
|
+
declare const SECURE_COOKIE_PREFIX = "__Secure-";
|
|
109
|
+
declare const HOST_COOKIE_PREFIX = "__Host-";
|
|
110
|
+
/**
|
|
111
|
+
* Remove __Secure- or __Host- prefix from cookie name.
|
|
112
|
+
*/
|
|
113
|
+
declare function stripSecureCookiePrefix(cookieName: string): string;
|
|
114
|
+
/**
|
|
115
|
+
* Split a comma-joined `Set-Cookie` header string into individual cookies.
|
|
116
|
+
*/
|
|
117
|
+
declare function splitSetCookieHeader(setCookie: string): string[];
|
|
118
|
+
declare function parseSetCookieHeader(setCookie: string): Map<string, CookieAttributes>;
|
|
119
|
+
declare function toCookieOptions(attributes: CookieAttributes): AthenaCookieOptions;
|
|
120
|
+
/**
|
|
121
|
+
* Parse a `Cookie` header into a key/value map.
|
|
122
|
+
*/
|
|
123
|
+
declare function parseCookies(cookieHeader: string): Map<string, string>;
|
|
124
|
+
/**
|
|
125
|
+
* Add or replace a cookie in the request `Cookie` header.
|
|
126
|
+
*/
|
|
127
|
+
declare function setRequestCookie(headers: Headers, name: string, value: string): void;
|
|
128
|
+
declare function setCookieToHeader(headers: Headers): (context: {
|
|
129
|
+
response: Response;
|
|
130
|
+
}) => void;
|
|
131
|
+
|
|
132
|
+
interface StoreCookie {
|
|
133
|
+
name: string;
|
|
134
|
+
value: string;
|
|
135
|
+
attributes: AthenaCookieOptions;
|
|
136
|
+
}
|
|
137
|
+
declare const createSessionStore: (cookieName: string, cookieOptions: AthenaCookieOptions, ctx: AthenaCookieContextRuntime) => {
|
|
138
|
+
getValue(): string;
|
|
139
|
+
hasChunks(): boolean;
|
|
140
|
+
chunk(value: string, options?: Partial<AthenaCookieOptions>): StoreCookie[];
|
|
141
|
+
clean(): StoreCookie[];
|
|
142
|
+
setCookies(cookies: StoreCookie[]): void;
|
|
143
|
+
};
|
|
144
|
+
declare function getChunkedCookie(ctx: AthenaCookieContextRuntime, cookieName: string): string | null;
|
|
145
|
+
/**
|
|
146
|
+
* SDK helper to read an account cookie value.
|
|
147
|
+
* - If plain JSON: returns parsed value.
|
|
148
|
+
* - If base64url-encoded JSON: returns parsed value.
|
|
149
|
+
* - Otherwise: returns the raw cookie string.
|
|
150
|
+
*/
|
|
151
|
+
declare function getAccountCookie(ctx: AthenaCookieContextRuntime, cookieName?: string): Promise<unknown | null>;
|
|
152
|
+
|
|
153
|
+
declare function createCookieGetter(options: AthenaCookiesOptions): (cookieName: string, overrideAttributes?: Partial<AthenaCookieOptions>) => AthenaAuthCookie;
|
|
154
|
+
declare function getCookies(options: AthenaCookiesOptions): AthenaAuthCookies;
|
|
155
|
+
declare function setCookieCache(ctx: AthenaCookieContextRuntime, session: AthenaSessionPair, dontRememberMe: boolean): Promise<void>;
|
|
156
|
+
declare function setSessionCookie(ctx: AthenaCookieContextRuntime, session: AthenaSessionPair, dontRememberMe?: boolean, overrides?: Partial<AthenaCookieOptions>): Promise<void>;
|
|
157
|
+
/**
|
|
158
|
+
* Expires a cookie by setting `maxAge: 0` while preserving attributes.
|
|
159
|
+
*/
|
|
160
|
+
declare function expireCookie(ctx: AthenaCookieContextRuntime, cookie: AthenaAuthCookie): void;
|
|
161
|
+
declare function deleteSessionCookie(ctx: AthenaCookieContextRuntime, skipDontRememberMe?: boolean): void;
|
|
162
|
+
declare const getSessionCookie: (request: Request | Headers, config?: {
|
|
163
|
+
cookiePrefix?: string;
|
|
164
|
+
cookieName?: string;
|
|
165
|
+
path?: string;
|
|
166
|
+
} | undefined) => string | null;
|
|
167
|
+
declare const getCookieCache: <SessionShape extends Record<string, unknown> = Record<string, unknown>, UserShape extends Record<string, unknown> = Record<string, unknown>>(request: Request | Headers, config?: AthenaGetCookieCacheConfig<SessionShape, UserShape>) => Promise<{
|
|
168
|
+
session: SessionShape;
|
|
169
|
+
user: UserShape;
|
|
170
|
+
updatedAt: number;
|
|
171
|
+
version?: string;
|
|
172
|
+
} | null>;
|
|
173
|
+
|
|
174
|
+
export { type AthenaCookiesOptions as A, HOST_COOKIE_PREFIX as H, SECURE_COOKIE_PREFIX as S, type AthenaSessionPair as a, type AthenaCookieOptions as b, type AthenaAuthCookies as c, getSessionCookie as d, type AthenaCookieContextRuntime as e, type AthenaAuthCookie as f, getCookieCache as g, type AthenaGetCookieCacheConfig as h, createCookieGetter as i, createSessionStore as j, deleteSessionCookie as k, expireCookie as l, getAccountCookie as m, getChunkedCookie as n, getCookies as o, parseCookies as p, parseSetCookieHeader as q, setCookieToHeader as r, setCookieCache as s, setRequestCookie as t, setSessionCookie as u, splitSetCookieHeader as v, stripSecureCookiePrefix as w, toCookieOptions as x };
|