@vunexa/lixa 0.1.6-alpha.6 → 0.1.6-alpha.8

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.
@@ -0,0 +1,142 @@
1
+ /**
2
+ * Sensible default cookie configuration options.
3
+ * Follows RFC 6265bis and OAuth 2.0 security best practices.
4
+ *
5
+ * @public
6
+ */
7
+ export interface CookieOptions {
8
+ /**
9
+ * Cookie name.
10
+ * @default 'lixa_session'
11
+ */
12
+ name?: string | undefined;
13
+ /**
14
+ * Cookie path.
15
+ * @default '/'
16
+ */
17
+ path?: string | undefined;
18
+ /**
19
+ * Maximum age of the cookie in seconds.
20
+ */
21
+ maxAge?: number | undefined;
22
+ /**
23
+ * Prevents client-side scripts from accessing the cookie (XSS protection).
24
+ * @default true
25
+ */
26
+ httpOnly?: boolean | undefined;
27
+ /**
28
+ * Ensures the cookie is only transmitted over secure HTTPS connections.
29
+ * @default false in development, true in production
30
+ */
31
+ secure?: boolean | undefined;
32
+ /**
33
+ * Controls whether the cookie is sent with cross-site requests (CSRF protection).
34
+ * @default 'lax'
35
+ */
36
+ sameSite?: "lax" | "strict" | "none" | undefined;
37
+ /**
38
+ * Cookie domain.
39
+ */
40
+ domain?: string | undefined;
41
+ }
42
+ /**
43
+ * Cookie payload containing name, value, options, and formatted header.
44
+ *
45
+ * @public
46
+ */
47
+ export interface CookiePayload {
48
+ name: string;
49
+ value: string;
50
+ options: CookieOptions;
51
+ /**
52
+ * Formatted `Set-Cookie` header value string.
53
+ */
54
+ header: string;
55
+ }
56
+ /**
57
+ * Default session cookie name.
58
+ * @public
59
+ */
60
+ export declare const DEFAULT_SESSION_COOKIE_NAME = "lixa_session";
61
+ /**
62
+ * Default OAuth state cookie name.
63
+ * @public
64
+ */
65
+ export declare const DEFAULT_STATE_COOKIE_NAME = "lixa_oauth_state";
66
+ /**
67
+ * Default session max age in seconds (24 hours).
68
+ * @public
69
+ */
70
+ export declare const DEFAULT_SESSION_MAX_AGE_SECONDS: number;
71
+ /**
72
+ * Default OAuth state max age in seconds (10 minutes).
73
+ * @public
74
+ */
75
+ export declare const DEFAULT_STATE_MAX_AGE_SECONDS: number;
76
+ /**
77
+ * Checks if the runtime environment is production.
78
+ * @public
79
+ */
80
+ export declare function isProductionEnvironment(): boolean;
81
+ /**
82
+ * Serializes a cookie name, value, and options into a standard `Set-Cookie` header string.
83
+ *
84
+ * @param name - Cookie name
85
+ * @param value - Cookie value
86
+ * @param options - Cookie attributes
87
+ * @returns Formatted `Set-Cookie` string
88
+ *
89
+ * @public
90
+ */
91
+ export declare function serializeCookie(name: string, value: string, options?: CookieOptions): string;
92
+ /**
93
+ * Generates a session cookie payload with secure default options.
94
+ *
95
+ * @param sessionId - The session identifier string
96
+ * @param options - Optional overrides for cookie attributes
97
+ *
98
+ * @example
99
+ * ```typescript
100
+ * const cookie = createSessionCookie(sessionId);
101
+ * res.setHeader("Set-Cookie", cookie.header);
102
+ * // or with Express:
103
+ * res.cookie(cookie.name, cookie.value, cookie.options);
104
+ * ```
105
+ *
106
+ * @public
107
+ */
108
+ export declare function createSessionCookie(sessionId: string, options?: CookieOptions): CookiePayload;
109
+ /**
110
+ * Generates an expired session cookie payload to clear the session on logout.
111
+ *
112
+ * @param options - Optional overrides for cookie name or attributes
113
+ *
114
+ * @example
115
+ * ```typescript
116
+ * const cookie = clearSessionCookie();
117
+ * res.setHeader("Set-Cookie", cookie.header);
118
+ * // or with Express:
119
+ * res.clearCookie(cookie.name, cookie.options);
120
+ * ```
121
+ *
122
+ * @public
123
+ */
124
+ export declare function clearSessionCookie(options?: CookieOptions): CookiePayload;
125
+ /**
126
+ * Generates an OAuth CSRF state cookie payload for in-flight authorization flows.
127
+ *
128
+ * @param state - The random state string
129
+ * @param options - Optional overrides for cookie attributes
130
+ *
131
+ * @public
132
+ */
133
+ export declare function createStateCookie(state: string, options?: CookieOptions): CookiePayload;
134
+ /**
135
+ * Generates an expired OAuth state cookie payload to clean up the state cookie after callback.
136
+ *
137
+ * @param options - Optional overrides for cookie attributes
138
+ *
139
+ * @public
140
+ */
141
+ export declare function clearStateCookie(options?: CookieOptions): CookiePayload;
142
+ //# sourceMappingURL=cookies.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cookies.d.ts","sourceRoot":"","sources":["../../src/utils/cookies.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,WAAW,aAAa;IAC5B;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAE1B;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAE1B;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAE5B;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAE/B;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAE7B;;;OAGG;IACH,QAAQ,CAAC,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,SAAS,CAAC;IAEjD;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC7B;AAED;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,aAAa,CAAC;IACvB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;GAGG;AACH,eAAO,MAAM,2BAA2B,iBAAiB,CAAC;AAE1D;;;GAGG;AACH,eAAO,MAAM,yBAAyB,qBAAqB,CAAC;AAE5D;;;GAGG;AACH,eAAO,MAAM,+BAA+B,QAAe,CAAC;AAE5D;;;GAGG;AACH,eAAO,MAAM,6BAA6B,QAAU,CAAC;AAErD;;;GAGG;AACH,wBAAgB,uBAAuB,IAAI,OAAO,CAEjD;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,MAAM,CAsC5F;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,aAAa,CAqB7F;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,CAAC,EAAE,aAAa,GAAG,aAAa,CAqBzE;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,aAAa,CAqBvF;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,CAAC,EAAE,aAAa,GAAG,aAAa,CAqBvE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vunexa/lixa",
3
- "version": "0.1.6-alpha.6",
3
+ "version": "0.1.6-alpha.8",
4
4
  "description": "Lixa is a flexible, provider-agnostic OAuth and OpenID Connect (OIDC) client library that simplifies multi-provider authentication flows. It supports seamless integration with providers like Google and GitHub, offers extensible session management, and enables dynamic provider resolution based on callback URLs.",
5
5
  "keywords": [
6
6
  "oauth",