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

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,103 @@
1
+ import { Lixa } from "./lixa";
2
+ import { type CookieOptions } from "./utils/cookies";
3
+ /**
4
+ * Duck-typed Express request interface for framework-agnostic typing.
5
+ * @public
6
+ */
7
+ export interface ExpressLikeRequest {
8
+ cookies?: Record<string, string>;
9
+ sessionInfo?: any;
10
+ sessionId?: string;
11
+ [key: string]: any;
12
+ }
13
+ /**
14
+ * Duck-typed Express response interface for framework-agnostic typing.
15
+ * @public
16
+ */
17
+ export interface ExpressLikeResponse {
18
+ cookie(name: string, value: string, options?: any): any;
19
+ status(code: number): this;
20
+ json(body: any): any;
21
+ redirect?(url: string): any;
22
+ [key: string]: any;
23
+ }
24
+ /**
25
+ * Express-compatible NextFunction type.
26
+ * @public
27
+ */
28
+ export type ExpressLikeNextFunction = (err?: any) => void;
29
+ /**
30
+ * Express-compatible RequestHandler type.
31
+ * @public
32
+ */
33
+ export type ExpressLikeRequestHandler = (req: ExpressLikeRequest, res: ExpressLikeResponse, next: ExpressLikeNextFunction) => any;
34
+ /**
35
+ * Options for Express authentication helpers.
36
+ * @public
37
+ */
38
+ export interface ExpressAuthHelperOptions {
39
+ sessionCookieName?: string;
40
+ sessionCookieOptions?: CookieOptions;
41
+ stateCookieOptions?: CookieOptions;
42
+ successRedirectUrl?: string;
43
+ errorRedirectUrl?: string;
44
+ }
45
+ /**
46
+ * Sets an RFC 6265bis compliant session cookie on an Express response.
47
+ *
48
+ * @param res - Express response object
49
+ * @param sessionId - Unique session ID
50
+ * @param options - Optional cookie attribute overrides
51
+ *
52
+ * @public
53
+ */
54
+ export declare function setSessionCookieOnResponse(res: ExpressLikeResponse, sessionId: string, options?: CookieOptions): void;
55
+ /**
56
+ * Clears the session cookie on an Express response.
57
+ *
58
+ * @param res - Express response object
59
+ * @param options - Optional cookie attribute overrides
60
+ *
61
+ * @public
62
+ */
63
+ export declare function clearSessionCookieOnResponse(res: ExpressLikeResponse, options?: CookieOptions): void;
64
+ /**
65
+ * Sets an OAuth CSRF state cookie on an Express response.
66
+ *
67
+ * @param res - Express response object
68
+ * @param state - OAuth state parameter
69
+ * @param options - Optional cookie attribute overrides
70
+ *
71
+ * @public
72
+ */
73
+ export declare function setStateCookieOnResponse(res: ExpressLikeResponse, state: string, options?: CookieOptions): void;
74
+ /**
75
+ * Clears the OAuth CSRF state cookie on an Express response.
76
+ *
77
+ * @param res - Express response object
78
+ * @param options - Optional cookie attribute overrides
79
+ *
80
+ * @public
81
+ */
82
+ export declare function clearStateCookieOnResponse(res: ExpressLikeResponse, options?: CookieOptions): void;
83
+ /**
84
+ * Creates an Express authentication middleware that verifies the session cookie and populates req.sessionInfo.
85
+ *
86
+ * @param lixa - Lixa instance
87
+ * @param options - Optional session cookie name and custom unauthorized handler
88
+ *
89
+ * @example
90
+ * ```typescript
91
+ * const requireAuth = createRequireAuthMiddleware(lixa);
92
+ * app.get('/protected', requireAuth, (req, res) => {
93
+ * res.json({ user: req.sessionInfo });
94
+ * });
95
+ * ```
96
+ *
97
+ * @public
98
+ */
99
+ export declare function createRequireAuthMiddleware(lixa: Lixa<any>, options?: {
100
+ sessionCookieName?: string;
101
+ unauthorizedHandler?: (req: ExpressLikeRequest, res: ExpressLikeResponse) => void;
102
+ }): ExpressLikeRequestHandler;
103
+ //# sourceMappingURL=express.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"express.d.ts","sourceRoot":"","sources":["../src/express.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAML,KAAK,aAAa,EACnB,MAAM,iBAAiB,CAAC;AAEzB;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,WAAW,CA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