@expressots/core 2.0.0 → 2.1.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/lib/CHANGELOG.md +18 -1
- package/lib/cjs/middleware/interfaces/cookie-parser.interface.js +2 -0
- package/lib/cjs/middleware/interfaces/cookie-session/cookie-session.interface.js +2 -0
- package/lib/cjs/middleware/interfaces/cookie-session/keygrip.interface.js +2 -0
- package/lib/cjs/middleware/middleware-resolver.js +4 -2
- package/lib/cjs/middleware/middleware-service.js +25 -0
- package/lib/cjs/types/middleware/index.d.ts +3 -0
- package/lib/cjs/types/middleware/index.d.ts.map +1 -1
- package/lib/cjs/types/middleware/interfaces/cookie-parser.interface.d.ts +10 -0
- package/lib/cjs/types/middleware/interfaces/cookie-parser.interface.d.ts.map +1 -0
- package/lib/cjs/types/middleware/interfaces/cookie-session/cookie-session.interface.d.ts +58 -0
- package/lib/cjs/types/middleware/interfaces/cookie-session/cookie-session.interface.d.ts.map +1 -0
- package/lib/cjs/types/middleware/interfaces/cookie-session/keygrip.interface.d.ts +28 -0
- package/lib/cjs/types/middleware/interfaces/cookie-session/keygrip.interface.d.ts.map +1 -0
- package/lib/cjs/types/middleware/middleware-resolver.d.ts.map +1 -1
- package/lib/cjs/types/middleware/middleware-service.d.ts +28 -0
- package/lib/cjs/types/middleware/middleware-service.d.ts.map +1 -1
- package/lib/esm/middleware/interfaces/cookie-parser.interface.js +2 -0
- package/lib/esm/middleware/interfaces/cookie-session/cookie-session.interface.js +2 -0
- package/lib/esm/middleware/interfaces/cookie-session/keygrip.interface.js +2 -0
- package/lib/esm/middleware/middleware-resolver.js +4 -2
- package/lib/esm/middleware/middleware-service.js +25 -0
- package/lib/esm/types/middleware/index.d.ts +3 -0
- package/lib/esm/types/middleware/index.d.ts.map +1 -1
- package/lib/esm/types/middleware/interfaces/cookie-parser.interface.d.ts +10 -0
- package/lib/esm/types/middleware/interfaces/cookie-parser.interface.d.ts.map +1 -0
- package/lib/esm/types/middleware/interfaces/cookie-session/cookie-session.interface.d.ts +58 -0
- package/lib/esm/types/middleware/interfaces/cookie-session/cookie-session.interface.d.ts.map +1 -0
- package/lib/esm/types/middleware/interfaces/cookie-session/keygrip.interface.d.ts +28 -0
- package/lib/esm/types/middleware/interfaces/cookie-session/keygrip.interface.d.ts.map +1 -0
- package/lib/esm/types/middleware/middleware-resolver.d.ts.map +1 -1
- package/lib/esm/types/middleware/middleware-service.d.ts +28 -0
- package/lib/esm/types/middleware/middleware-service.d.ts.map +1 -1
- package/lib/package.json +1 -1
- package/package.json +1 -1
package/lib/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,20 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
## [2.1.0](https://github.com/expressots/expressots/compare/2.0.0...2.1.0) (2023-09-16)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* add cookie-parser middleware ([2fe9377](https://github.com/expressots/expressots/commit/2fe93776423355503211a0d96f2b1952e3bc6320))
|
|
9
|
+
* add cookie-parser middleware ([a53a0c2](https://github.com/expressots/expressots/commit/a53a0c2e23dafc188286cd0ff5a6145cf3416ad0))
|
|
10
|
+
* add cookie-session middleware ([323c2d3](https://github.com/expressots/expressots/commit/323c2d32c5e4a9c78f19fe47807f323139fb306a))
|
|
11
|
+
* add cookie-session middleware ([60ac1fa](https://github.com/expressots/expressots/commit/60ac1fa36b2a8388983be0ab8f2d8a1696089d78))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Bug Fixes
|
|
15
|
+
|
|
16
|
+
* create folder for interface and print pck name instead of curated name ([2a47508](https://github.com/expressots/expressots/commit/2a47508f5170950ddd8b471fffc8d43a8fb57e32))
|
|
17
|
+
|
|
1
18
|
## [2.0.0](https://github.com/expressots/expressots/compare/1.9.1...2.0.0) (2023-09-14)
|
|
2
19
|
|
|
3
20
|
### Features
|
|
@@ -298,4 +315,4 @@
|
|
|
298
315
|
|
|
299
316
|
### Bug Fixes
|
|
300
317
|
|
|
301
|
-
- fix pipeline for tag name ([b9ec52d](https://github.com/expressots/expressots/commit/b9ec52dc065763185f69364d8f083b1a95fa37e0))
|
|
318
|
+
- fix pipeline for tag name ([b9ec52d](https://github.com/expressots/expressots/commit/b9ec52dc065763185f69364d8f083b1a95fa37e0))
|
|
@@ -17,6 +17,8 @@ class MiddlewareResolver {
|
|
|
17
17
|
this.middlewareRegistry = {
|
|
18
18
|
cors: "cors",
|
|
19
19
|
compression: "compression",
|
|
20
|
+
cookieParser: "cookie-parser",
|
|
21
|
+
cookieSession: "cookie-session",
|
|
20
22
|
// Add other middlewares
|
|
21
23
|
};
|
|
22
24
|
this.logger = new logger_service_1.Logger();
|
|
@@ -31,7 +33,7 @@ class MiddlewareResolver {
|
|
|
31
33
|
getMiddleware(middlewareName, ...options) {
|
|
32
34
|
const packageName = this.middlewareRegistry[middlewareName];
|
|
33
35
|
if (!packageName) {
|
|
34
|
-
|
|
36
|
+
this.logger.error(`Middleware ${packageName} not found`, "middleware-resolver");
|
|
35
37
|
return null;
|
|
36
38
|
}
|
|
37
39
|
let hasMiddleware = "";
|
|
@@ -39,7 +41,7 @@ class MiddlewareResolver {
|
|
|
39
41
|
hasMiddleware = require.resolve(packageName, { paths: [process.cwd()] });
|
|
40
42
|
}
|
|
41
43
|
catch (error) {
|
|
42
|
-
this.logger.warn(`Middleware [${
|
|
44
|
+
this.logger.warn(`Middleware [${packageName}] not installed. Please install it using your package manager.`, "middleware-resolver");
|
|
43
45
|
}
|
|
44
46
|
if (hasMiddleware) {
|
|
45
47
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
@@ -78,6 +78,31 @@ let Middleware = Middleware_1 = class Middleware {
|
|
|
78
78
|
this.middlewares.push(middleware);
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
|
+
/**
|
|
82
|
+
* Adds Cookie Parser middleware to parse the cookie header and populate req.cookies with an object keyed by the cookie names.
|
|
83
|
+
*
|
|
84
|
+
* @param secret - A string or array used for signing cookies. This is optional and if not specified, the cookie-parser will not parse signed cookies.
|
|
85
|
+
* @param options - Optional configuration options for Cookie Parser.
|
|
86
|
+
*/
|
|
87
|
+
addCookieParser(secret, options) {
|
|
88
|
+
const middleware = (0, middleware_resolver_1.middlewareResolver)("cookieParser", secret, options);
|
|
89
|
+
const middlewareExist = this.middlewareExists("cookieParser");
|
|
90
|
+
if (middleware && !middlewareExist) {
|
|
91
|
+
this.middlewares.push(middleware);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Adds Cookie Session middleware to enable cookie-based sessions.
|
|
96
|
+
*
|
|
97
|
+
* @param options - Optional configuration options for Cookie Session. Defines the behavior of cookie sessions like the name of the cookie, keys to sign the cookie, etc.
|
|
98
|
+
*/
|
|
99
|
+
addCookieSession(options) {
|
|
100
|
+
const middleware = (0, middleware_resolver_1.middlewareResolver)("cookieSession", options);
|
|
101
|
+
const middlewareExist = this.middlewareExists("cookieSession");
|
|
102
|
+
if (middleware && !middlewareExist) {
|
|
103
|
+
this.middlewares.push(middleware);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
81
106
|
/**
|
|
82
107
|
* Configures the error handling middleware for the application.
|
|
83
108
|
*
|
|
@@ -2,4 +2,7 @@ export { IMiddleware, Middleware } from "./middleware-service";
|
|
|
2
2
|
export { OptionsJson } from "./interfaces/body-parser.interface";
|
|
3
3
|
export { CorsOptions } from "./interfaces/cors.interface";
|
|
4
4
|
export { CompressionOptions } from "./interfaces/compression.interface";
|
|
5
|
+
export { CookieSessionOptions } from "./interfaces/cookie-session/cookie-session.interface";
|
|
6
|
+
export { Keygrip } from "./interfaces/cookie-session/keygrip.interface";
|
|
7
|
+
export { CookieParserOptions } from "./interfaces/cookie-parser.interface";
|
|
5
8
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../packages/core/src/middleware/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../packages/core/src/middleware/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AACxE,OAAO,EAAE,oBAAoB,EAAE,MAAM,sDAAsD,CAAC;AAC5F,OAAO,EAAE,OAAO,EAAE,MAAM,+CAA+C,CAAC;AACxE,OAAO,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
interface CookieParserOptions {
|
|
2
|
+
/**
|
|
3
|
+
* A function used for decoding cookies.
|
|
4
|
+
* By default, `decodeURIComponent` is used.
|
|
5
|
+
* You can provide a custom decoding function here.
|
|
6
|
+
*/
|
|
7
|
+
decode?(val: string): string;
|
|
8
|
+
}
|
|
9
|
+
export { CookieParserOptions };
|
|
10
|
+
//# sourceMappingURL=cookie-parser.interface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cookie-parser.interface.d.ts","sourceRoot":"","sources":["../../../../../packages/core/src/middleware/interfaces/cookie-parser.interface.ts"],"names":[],"mappings":"AAAA,UAAU,mBAAmB;IAC3B;;;;OAIG;IACH,MAAM,CAAC,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;CAC9B;AAED,OAAO,EAAE,mBAAmB,EAAE,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { Keygrip } from "./keygrip.interface";
|
|
2
|
+
interface CookieSessionOptions {
|
|
3
|
+
/**
|
|
4
|
+
* The name of the cookie to set, defaults to session.
|
|
5
|
+
*/
|
|
6
|
+
name?: string | undefined;
|
|
7
|
+
/**
|
|
8
|
+
* The list of keys to use to sign & verify cookie values. Set cookies are always signed with keys[0], while the other keys are valid for verification, allowing for key rotation.
|
|
9
|
+
*/
|
|
10
|
+
keys: Array<string> | Keygrip;
|
|
11
|
+
/**
|
|
12
|
+
* A string which will be used as single key if keys is not provided.
|
|
13
|
+
*/
|
|
14
|
+
secret?: string | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* a number representing the milliseconds from Date.now() for expiry.
|
|
17
|
+
*/
|
|
18
|
+
maxAge?: number | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* a Date object indicating the cookie's expiration date (expires at the end of session by default).
|
|
21
|
+
*/
|
|
22
|
+
expires?: Date | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* a string indicating the path of the cookie (/ by default).
|
|
25
|
+
*/
|
|
26
|
+
path?: string | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* a string indicating the domain of the cookie (no default).
|
|
29
|
+
*/
|
|
30
|
+
domain?: string | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* a boolean or string indicating whether the cookie is a "same site" cookie (false by default). This can be set to 'strict', 'lax', 'none', or true (which maps to 'strict').
|
|
33
|
+
*/
|
|
34
|
+
sameSite?: "strict" | "lax" | "none" | boolean | undefined;
|
|
35
|
+
/**
|
|
36
|
+
* a boolean indicating whether the cookie is only to be sent over HTTPS (false by default for HTTP, true by default for HTTPS).
|
|
37
|
+
*/
|
|
38
|
+
secure?: boolean | undefined;
|
|
39
|
+
/**
|
|
40
|
+
* a boolean indicating whether the cookie is only to be sent over HTTPS (use this if you handle SSL not in your node process).
|
|
41
|
+
*/
|
|
42
|
+
secureProxy?: boolean | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* a boolean indicating whether the cookie is only to be sent over HTTP(S), and not made available to client JavaScript (true by default).
|
|
45
|
+
*/
|
|
46
|
+
httpOnly?: boolean | undefined;
|
|
47
|
+
/**
|
|
48
|
+
* a boolean indicating whether the cookie is to be signed (true by default). If this is true, another cookie of the same name with the .sig suffix appended will also be sent, with a 27-byte url-safe base64 SHA1 value representing the hash of cookie-name=cookie-value against the
|
|
49
|
+
* first Keygrip key. This signature key is used to detect tampering the next time a cookie is received.
|
|
50
|
+
*/
|
|
51
|
+
signed?: boolean | undefined;
|
|
52
|
+
/**
|
|
53
|
+
* a boolean indicating whether to overwrite previously set cookies of the same name (true by default). If this is true, all cookies set during the same request with the same name (regardless of path or domain) are filtered out of the Set-Cookie header when setting this cookie.
|
|
54
|
+
*/
|
|
55
|
+
overwrite?: boolean | undefined;
|
|
56
|
+
}
|
|
57
|
+
export { CookieSessionOptions };
|
|
58
|
+
//# sourceMappingURL=cookie-session.interface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cookie-session.interface.d.ts","sourceRoot":"","sources":["../../../../../../packages/core/src/middleware/interfaces/cookie-session/cookie-session.interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAE9C,UAAU,oBAAoB;IAC5B;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAE1B;;OAEG;IACH,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC;IAE9B;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAE5B;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAE5B;;OAEG;IACH,OAAO,CAAC,EAAE,IAAI,GAAG,SAAS,CAAC;IAE3B;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAE1B;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAE5B;;OAEG;IACH,QAAQ,CAAC,EAAE,QAAQ,GAAG,KAAK,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC;IAE3D;;OAEG;IACH,MAAM,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAE7B;;OAEG;IACH,WAAW,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAElC;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAE/B;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAE7B;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CACjC;AAED,OAAO,EAAE,oBAAoB,EAAE,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
interface Keygrip {
|
|
2
|
+
/**
|
|
3
|
+
* Signs the provided data and returns the signature as a string.
|
|
4
|
+
* @param data Data to be signed.
|
|
5
|
+
* @returns Signature string.
|
|
6
|
+
*/
|
|
7
|
+
sign(data: any): string;
|
|
8
|
+
/**
|
|
9
|
+
* Verifies the provided data against a given digest (signature).
|
|
10
|
+
* @param data Data to be verified.
|
|
11
|
+
* @param digest Signature to verify against.
|
|
12
|
+
* @returns True if the verification is successful, otherwise false.
|
|
13
|
+
*/
|
|
14
|
+
verify(data: any, digest: string): boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Retrieves the index of the provided data in relation to a given digest (signature).
|
|
17
|
+
* @param data Data to find the index for.
|
|
18
|
+
* @param digest Signature to search for.
|
|
19
|
+
* @returns Index of the data, or -1 if not found.
|
|
20
|
+
*/
|
|
21
|
+
index(data: any, digest: string): number;
|
|
22
|
+
}
|
|
23
|
+
interface KeygripFunction {
|
|
24
|
+
new (keys: ReadonlyArray<string>, algorithm?: string, encoding?: string): Keygrip;
|
|
25
|
+
(keys: ReadonlyArray<string>, algorithm?: string, encoding?: string): Keygrip;
|
|
26
|
+
}
|
|
27
|
+
export { KeygripFunction as Keygrip };
|
|
28
|
+
//# sourceMappingURL=keygrip.interface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keygrip.interface.d.ts","sourceRoot":"","sources":["../../../../../../packages/core/src/middleware/interfaces/cookie-session/keygrip.interface.ts"],"names":[],"mappings":"AACA,UAAU,OAAO;IACf;;;;OAIG;IAEH,IAAI,CAAC,IAAI,EAAE,GAAG,GAAG,MAAM,CAAC;IAExB;;;;;OAKG;IAEH,MAAM,CAAC,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC;IAE3C;;;;;OAKG;IAEH,KAAK,CAAC,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC;CAC1C;AAGD,UAAU,eAAe;IACvB,KACE,IAAI,EAAE,aAAa,CAAC,MAAM,CAAC,EAC3B,SAAS,CAAC,EAAE,MAAM,EAClB,QAAQ,CAAC,EAAE,MAAM,GAChB,OAAO,CAAC;IACX,CAAC,IAAI,EAAE,aAAa,CAAC,MAAM,CAAC,EAAE,SAAS,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CAC/E;AAGD,OAAO,EAAE,eAAe,IAAI,OAAO,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"middleware-resolver.d.ts","sourceRoot":"","sources":["../../../../packages/core/src/middleware/middleware-resolver.ts"],"names":[],"mappings":"AACA,OAAO,OAAO,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"middleware-resolver.d.ts","sourceRoot":"","sources":["../../../../packages/core/src/middleware/middleware-resolver.ts"],"names":[],"mappings":"AACA,OAAO,OAAO,MAAM,SAAS,CAAC;AAqE9B;;;;;;;GAOG;AACH,iBAAS,kBAAkB,CACzB,UAAU,EAAE,MAAM,EAClB,GAAG,OAAO,EAAE,GAAG,GACd,OAAO,CAAC,cAAc,GAAG,IAAI,CAG/B;AAED,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
|
|
@@ -2,7 +2,9 @@ import express from "express";
|
|
|
2
2
|
import { OptionsJson } from "./interfaces/body-parser.interface";
|
|
3
3
|
import { CompressionOptions } from "./interfaces/compression.interface";
|
|
4
4
|
import { CorsOptions } from "./interfaces/cors.interface";
|
|
5
|
+
import { CookieParserOptions } from "./interfaces/cookie-parser.interface";
|
|
5
6
|
import { ServeStaticOptions } from "./interfaces/serve-static.interface";
|
|
7
|
+
import { CookieSessionOptions } from "./interfaces/cookie-session/cookie-session.interface";
|
|
6
8
|
type ExpressHandler = express.ErrorRequestHandler | express.RequestParamHandler | express.RequestHandler | undefined;
|
|
7
9
|
/**
|
|
8
10
|
* Interface for configuring and managing middlewares in the application.
|
|
@@ -28,6 +30,19 @@ interface IMiddleware {
|
|
|
28
30
|
* @param options - Optional configuration options for Compression. Allows fine-tuning the compression behavior, such as setting the compression level, threshold, and filter functions to determine which requests should be compressed.
|
|
29
31
|
*/
|
|
30
32
|
addCompression(options?: CompressionOptions): void;
|
|
33
|
+
/**
|
|
34
|
+
* Adds Cookie Parser middleware to parse the cookie header and populate req.cookies with an object keyed by the cookie names.
|
|
35
|
+
*
|
|
36
|
+
* @param secret - A string or array used for signing cookies. This is optional and if not specified, the cookie-parser will not parse signed cookies.
|
|
37
|
+
* @param options - Optional configuration options for Cookie Parser.
|
|
38
|
+
*/
|
|
39
|
+
addCookieParser(secret?: string | Array<string> | undefined, options?: CookieParserOptions): void;
|
|
40
|
+
/**
|
|
41
|
+
* Adds Cookie Session middleware to enable cookie-based sessions.
|
|
42
|
+
*
|
|
43
|
+
* @param options - Optional configuration options for Cookie Session. Defines the behavior of cookie sessions like the name of the cookie, keys to sign the cookie, etc.
|
|
44
|
+
*/
|
|
45
|
+
addCookieSession(options: CookieSessionOptions): void;
|
|
31
46
|
/**
|
|
32
47
|
* Configures the error handling middleware for the application.
|
|
33
48
|
*
|
|
@@ -99,6 +114,19 @@ declare class Middleware implements IMiddleware {
|
|
|
99
114
|
* @param options - Optional configuration options for Compression. Allows fine-tuning the compression behavior, such as setting the compression level, threshold, and filter functions to determine which requests should be compressed.
|
|
100
115
|
*/
|
|
101
116
|
addCompression(options?: CompressionOptions): void;
|
|
117
|
+
/**
|
|
118
|
+
* Adds Cookie Parser middleware to parse the cookie header and populate req.cookies with an object keyed by the cookie names.
|
|
119
|
+
*
|
|
120
|
+
* @param secret - A string or array used for signing cookies. This is optional and if not specified, the cookie-parser will not parse signed cookies.
|
|
121
|
+
* @param options - Optional configuration options for Cookie Parser.
|
|
122
|
+
*/
|
|
123
|
+
addCookieParser(secret?: string | Array<string> | undefined, options?: CookieParserOptions | undefined): void;
|
|
124
|
+
/**
|
|
125
|
+
* Adds Cookie Session middleware to enable cookie-based sessions.
|
|
126
|
+
*
|
|
127
|
+
* @param options - Optional configuration options for Cookie Session. Defines the behavior of cookie sessions like the name of the cookie, keys to sign the cookie, etc.
|
|
128
|
+
*/
|
|
129
|
+
addCookieSession(options: CookieSessionOptions): void;
|
|
102
130
|
/**
|
|
103
131
|
* Configures the error handling middleware for the application.
|
|
104
132
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"middleware-service.d.ts","sourceRoot":"","sources":["../../../../packages/core/src/middleware/middleware-service.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS,CAAC;AAI9B,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AACxE,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;
|
|
1
|
+
{"version":3,"file":"middleware-service.d.ts","sourceRoot":"","sources":["../../../../packages/core/src/middleware/middleware-service.ts"],"names":[],"mappings":"AAAA,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ression: "compression",
|
|
23
|
+
cookieParser: "cookie-parser",
|
|
24
|
+
cookieSession: "cookie-session",
|
|
23
25
|
// Add other middlewares
|
|
24
26
|
};
|
|
25
27
|
/**
|
|
@@ -32,7 +34,7 @@ class MiddlewareResolver {
|
|
|
32
34
|
getMiddleware(middlewareName, ...options) {
|
|
33
35
|
const packageName = this.middlewareRegistry[middlewareName];
|
|
34
36
|
if (!packageName) {
|
|
35
|
-
|
|
37
|
+
this.logger.error(`Middleware ${packageName} not found`, "middleware-resolver");
|
|
36
38
|
return null;
|
|
37
39
|
}
|
|
38
40
|
let hasMiddleware = "";
|
|
@@ -40,7 +42,7 @@ class MiddlewareResolver {
|
|
|
40
42
|
hasMiddleware = require.resolve(packageName, { paths: [process.cwd()] });
|
|
41
43
|
}
|
|
42
44
|
catch (error) {
|
|
43
|
-
this.logger.warn(`Middleware [${
|
|
45
|
+
this.logger.warn(`Middleware [${packageName}] not installed. Please install it using your package manager.`, "middleware-resolver");
|
|
44
46
|
}
|
|
45
47
|
if (hasMiddleware) {
|
|
46
48
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
@@ -77,6 +77,31 @@ let Middleware = Middleware_1 = class Middleware {
|
|
|
77
77
|
this.middlewares.push(middleware);
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
|
+
/**
|
|
81
|
+
* Adds Cookie Parser middleware to parse the cookie header and populate req.cookies with an object keyed by the cookie names.
|
|
82
|
+
*
|
|
83
|
+
* @param secret - A string or array used for signing cookies. This is optional and if not specified, the cookie-parser will not parse signed cookies.
|
|
84
|
+
* @param options - Optional configuration options for Cookie Parser.
|
|
85
|
+
*/
|
|
86
|
+
addCookieParser(secret, options) {
|
|
87
|
+
const middleware = (0, middleware_resolver_1.middlewareResolver)("cookieParser", secret, options);
|
|
88
|
+
const middlewareExist = this.middlewareExists("cookieParser");
|
|
89
|
+
if (middleware && !middlewareExist) {
|
|
90
|
+
this.middlewares.push(middleware);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Adds Cookie Session middleware to enable cookie-based sessions.
|
|
95
|
+
*
|
|
96
|
+
* @param options - Optional configuration options for Cookie Session. Defines the behavior of cookie sessions like the name of the cookie, keys to sign the cookie, etc.
|
|
97
|
+
*/
|
|
98
|
+
addCookieSession(options) {
|
|
99
|
+
const middleware = (0, middleware_resolver_1.middlewareResolver)("cookieSession", options);
|
|
100
|
+
const middlewareExist = this.middlewareExists("cookieSession");
|
|
101
|
+
if (middleware && !middlewareExist) {
|
|
102
|
+
this.middlewares.push(middleware);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
80
105
|
/**
|
|
81
106
|
* Configures the error handling middleware for the application.
|
|
82
107
|
*
|
|
@@ -2,4 +2,7 @@ export { IMiddleware, Middleware } from "./middleware-service";
|
|
|
2
2
|
export { OptionsJson } from "./interfaces/body-parser.interface";
|
|
3
3
|
export { CorsOptions } from "./interfaces/cors.interface";
|
|
4
4
|
export { CompressionOptions } from "./interfaces/compression.interface";
|
|
5
|
+
export { CookieSessionOptions } from "./interfaces/cookie-session/cookie-session.interface";
|
|
6
|
+
export { Keygrip } from "./interfaces/cookie-session/keygrip.interface";
|
|
7
|
+
export { CookieParserOptions } from "./interfaces/cookie-parser.interface";
|
|
5
8
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../packages/core/src/middleware/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../packages/core/src/middleware/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AACxE,OAAO,EAAE,oBAAoB,EAAE,MAAM,sDAAsD,CAAC;AAC5F,OAAO,EAAE,OAAO,EAAE,MAAM,+CAA+C,CAAC;AACxE,OAAO,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
interface CookieParserOptions {
|
|
2
|
+
/**
|
|
3
|
+
* A function used for decoding cookies.
|
|
4
|
+
* By default, `decodeURIComponent` is used.
|
|
5
|
+
* You can provide a custom decoding function here.
|
|
6
|
+
*/
|
|
7
|
+
decode?(val: string): string;
|
|
8
|
+
}
|
|
9
|
+
export { CookieParserOptions };
|
|
10
|
+
//# sourceMappingURL=cookie-parser.interface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cookie-parser.interface.d.ts","sourceRoot":"","sources":["../../../../../packages/core/src/middleware/interfaces/cookie-parser.interface.ts"],"names":[],"mappings":"AAAA,UAAU,mBAAmB;IAC3B;;;;OAIG;IACH,MAAM,CAAC,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;CAC9B;AAED,OAAO,EAAE,mBAAmB,EAAE,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { Keygrip } from "./keygrip.interface";
|
|
2
|
+
interface CookieSessionOptions {
|
|
3
|
+
/**
|
|
4
|
+
* The name of the cookie to set, defaults to session.
|
|
5
|
+
*/
|
|
6
|
+
name?: string | undefined;
|
|
7
|
+
/**
|
|
8
|
+
* The list of keys to use to sign & verify cookie values. Set cookies are always signed with keys[0], while the other keys are valid for verification, allowing for key rotation.
|
|
9
|
+
*/
|
|
10
|
+
keys: Array<string> | Keygrip;
|
|
11
|
+
/**
|
|
12
|
+
* A string which will be used as single key if keys is not provided.
|
|
13
|
+
*/
|
|
14
|
+
secret?: string | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* a number representing the milliseconds from Date.now() for expiry.
|
|
17
|
+
*/
|
|
18
|
+
maxAge?: number | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* a Date object indicating the cookie's expiration date (expires at the end of session by default).
|
|
21
|
+
*/
|
|
22
|
+
expires?: Date | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* a string indicating the path of the cookie (/ by default).
|
|
25
|
+
*/
|
|
26
|
+
path?: string | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* a string indicating the domain of the cookie (no default).
|
|
29
|
+
*/
|
|
30
|
+
domain?: string | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* a boolean or string indicating whether the cookie is a "same site" cookie (false by default). This can be set to 'strict', 'lax', 'none', or true (which maps to 'strict').
|
|
33
|
+
*/
|
|
34
|
+
sameSite?: "strict" | "lax" | "none" | boolean | undefined;
|
|
35
|
+
/**
|
|
36
|
+
* a boolean indicating whether the cookie is only to be sent over HTTPS (false by default for HTTP, true by default for HTTPS).
|
|
37
|
+
*/
|
|
38
|
+
secure?: boolean | undefined;
|
|
39
|
+
/**
|
|
40
|
+
* a boolean indicating whether the cookie is only to be sent over HTTPS (use this if you handle SSL not in your node process).
|
|
41
|
+
*/
|
|
42
|
+
secureProxy?: boolean | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* a boolean indicating whether the cookie is only to be sent over HTTP(S), and not made available to client JavaScript (true by default).
|
|
45
|
+
*/
|
|
46
|
+
httpOnly?: boolean | undefined;
|
|
47
|
+
/**
|
|
48
|
+
* a boolean indicating whether the cookie is to be signed (true by default). If this is true, another cookie of the same name with the .sig suffix appended will also be sent, with a 27-byte url-safe base64 SHA1 value representing the hash of cookie-name=cookie-value against the
|
|
49
|
+
* first Keygrip key. This signature key is used to detect tampering the next time a cookie is received.
|
|
50
|
+
*/
|
|
51
|
+
signed?: boolean | undefined;
|
|
52
|
+
/**
|
|
53
|
+
* a boolean indicating whether to overwrite previously set cookies of the same name (true by default). If this is true, all cookies set during the same request with the same name (regardless of path or domain) are filtered out of the Set-Cookie header when setting this cookie.
|
|
54
|
+
*/
|
|
55
|
+
overwrite?: boolean | undefined;
|
|
56
|
+
}
|
|
57
|
+
export { CookieSessionOptions };
|
|
58
|
+
//# sourceMappingURL=cookie-session.interface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cookie-session.interface.d.ts","sourceRoot":"","sources":["../../../../../../packages/core/src/middleware/interfaces/cookie-session/cookie-session.interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAE9C,UAAU,oBAAoB;IAC5B;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAE1B;;OAEG;IACH,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC;IAE9B;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAE5B;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAE5B;;OAEG;IACH,OAAO,CAAC,EAAE,IAAI,GAAG,SAAS,CAAC;IAE3B;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAE1B;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAE5B;;OAEG;IACH,QAAQ,CAAC,EAAE,QAAQ,GAAG,KAAK,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC;IAE3D;;OAEG;IACH,MAAM,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAE7B;;OAEG;IACH,WAAW,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAElC;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAE/B;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAE7B;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CACjC;AAED,OAAO,EAAE,oBAAoB,EAAE,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
interface Keygrip {
|
|
2
|
+
/**
|
|
3
|
+
* Signs the provided data and returns the signature as a string.
|
|
4
|
+
* @param data Data to be signed.
|
|
5
|
+
* @returns Signature string.
|
|
6
|
+
*/
|
|
7
|
+
sign(data: any): string;
|
|
8
|
+
/**
|
|
9
|
+
* Verifies the provided data against a given digest (signature).
|
|
10
|
+
* @param data Data to be verified.
|
|
11
|
+
* @param digest Signature to verify against.
|
|
12
|
+
* @returns True if the verification is successful, otherwise false.
|
|
13
|
+
*/
|
|
14
|
+
verify(data: any, digest: string): boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Retrieves the index of the provided data in relation to a given digest (signature).
|
|
17
|
+
* @param data Data to find the index for.
|
|
18
|
+
* @param digest Signature to search for.
|
|
19
|
+
* @returns Index of the data, or -1 if not found.
|
|
20
|
+
*/
|
|
21
|
+
index(data: any, digest: string): number;
|
|
22
|
+
}
|
|
23
|
+
interface KeygripFunction {
|
|
24
|
+
new (keys: ReadonlyArray<string>, algorithm?: string, encoding?: string): Keygrip;
|
|
25
|
+
(keys: ReadonlyArray<string>, algorithm?: string, encoding?: string): Keygrip;
|
|
26
|
+
}
|
|
27
|
+
export { KeygripFunction as Keygrip };
|
|
28
|
+
//# sourceMappingURL=keygrip.interface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keygrip.interface.d.ts","sourceRoot":"","sources":["../../../../../../packages/core/src/middleware/interfaces/cookie-session/keygrip.interface.ts"],"names":[],"mappings":"AACA,UAAU,OAAO;IACf;;;;OAIG;IAEH,IAAI,CAAC,IAAI,EAAE,GAAG,GAAG,MAAM,CAAC;IAExB;;;;;OAKG;IAEH,MAAM,CAAC,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC;IAE3C;;;;;OAKG;IAEH,KAAK,CAAC,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC;CAC1C;AAGD,UAAU,eAAe;IACvB,KACE,IAAI,EAAE,aAAa,CAAC,MAAM,CAAC,EAC3B,SAAS,CAAC,EAAE,MAAM,EAClB,QAAQ,CAAC,EAAE,MAAM,GAChB,OAAO,CAAC;IACX,CAAC,IAAI,EAAE,aAAa,CAAC,MAAM,CAAC,EAAE,SAAS,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CAC/E;AAGD,OAAO,EAAE,eAAe,IAAI,OAAO,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"middleware-resolver.d.ts","sourceRoot":"","sources":["../../../../packages/core/src/middleware/middleware-resolver.ts"],"names":[],"mappings":"AACA,OAAO,OAAO,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"middleware-resolver.d.ts","sourceRoot":"","sources":["../../../../packages/core/src/middleware/middleware-resolver.ts"],"names":[],"mappings":"AACA,OAAO,OAAO,MAAM,SAAS,CAAC;AAqE9B;;;;;;;GAOG;AACH,iBAAS,kBAAkB,CACzB,UAAU,EAAE,MAAM,EAClB,GAAG,OAAO,EAAE,GAAG,GACd,OAAO,CAAC,cAAc,GAAG,IAAI,CAG/B;AAED,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
|
|
@@ -2,7 +2,9 @@ import express from "express";
|
|
|
2
2
|
import { OptionsJson } from "./interfaces/body-parser.interface";
|
|
3
3
|
import { CompressionOptions } from "./interfaces/compression.interface";
|
|
4
4
|
import { CorsOptions } from "./interfaces/cors.interface";
|
|
5
|
+
import { CookieParserOptions } from "./interfaces/cookie-parser.interface";
|
|
5
6
|
import { ServeStaticOptions } from "./interfaces/serve-static.interface";
|
|
7
|
+
import { CookieSessionOptions } from "./interfaces/cookie-session/cookie-session.interface";
|
|
6
8
|
type ExpressHandler = express.ErrorRequestHandler | express.RequestParamHandler | express.RequestHandler | undefined;
|
|
7
9
|
/**
|
|
8
10
|
* Interface for configuring and managing middlewares in the application.
|
|
@@ -28,6 +30,19 @@ interface IMiddleware {
|
|
|
28
30
|
* @param options - Optional configuration options for Compression. Allows fine-tuning the compression behavior, such as setting the compression level, threshold, and filter functions to determine which requests should be compressed.
|
|
29
31
|
*/
|
|
30
32
|
addCompression(options?: CompressionOptions): void;
|
|
33
|
+
/**
|
|
34
|
+
* Adds Cookie Parser middleware to parse the cookie header and populate req.cookies with an object keyed by the cookie names.
|
|
35
|
+
*
|
|
36
|
+
* @param secret - A string or array used for signing cookies. This is optional and if not specified, the cookie-parser will not parse signed cookies.
|
|
37
|
+
* @param options - Optional configuration options for Cookie Parser.
|
|
38
|
+
*/
|
|
39
|
+
addCookieParser(secret?: string | Array<string> | undefined, options?: CookieParserOptions): void;
|
|
40
|
+
/**
|
|
41
|
+
* Adds Cookie Session middleware to enable cookie-based sessions.
|
|
42
|
+
*
|
|
43
|
+
* @param options - Optional configuration options for Cookie Session. Defines the behavior of cookie sessions like the name of the cookie, keys to sign the cookie, etc.
|
|
44
|
+
*/
|
|
45
|
+
addCookieSession(options: CookieSessionOptions): void;
|
|
31
46
|
/**
|
|
32
47
|
* Configures the error handling middleware for the application.
|
|
33
48
|
*
|
|
@@ -99,6 +114,19 @@ declare class Middleware implements IMiddleware {
|
|
|
99
114
|
* @param options - Optional configuration options for Compression. Allows fine-tuning the compression behavior, such as setting the compression level, threshold, and filter functions to determine which requests should be compressed.
|
|
100
115
|
*/
|
|
101
116
|
addCompression(options?: CompressionOptions): void;
|
|
117
|
+
/**
|
|
118
|
+
* Adds Cookie Parser middleware to parse the cookie header and populate req.cookies with an object keyed by the cookie names.
|
|
119
|
+
*
|
|
120
|
+
* @param secret - A string or array used for signing cookies. This is optional and if not specified, the cookie-parser will not parse signed cookies.
|
|
121
|
+
* @param options - Optional configuration options for Cookie Parser.
|
|
122
|
+
*/
|
|
123
|
+
addCookieParser(secret?: string | Array<string> | undefined, options?: CookieParserOptions | undefined): void;
|
|
124
|
+
/**
|
|
125
|
+
* Adds Cookie Session middleware to enable cookie-based sessions.
|
|
126
|
+
*
|
|
127
|
+
* @param options - Optional configuration options for Cookie Session. Defines the behavior of cookie sessions like the name of the cookie, keys to sign the cookie, etc.
|
|
128
|
+
*/
|
|
129
|
+
addCookieSession(options: CookieSessionOptions): void;
|
|
102
130
|
/**
|
|
103
131
|
* Configures the error handling middleware for the application.
|
|
104
132
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"middleware-service.d.ts","sourceRoot":"","sources":["../../../../packages/core/src/middleware/middleware-service.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS,CAAC;AAI9B,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AACxE,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;
|
|
1
|
+
{"version":3,"file":"middleware-service.d.ts","sourceRoot":"","sources":["../../../../packages/core/src/middleware/middleware-service.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS,CAAC;AAI9B,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AACxE,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAC3E,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AAEzE,OAAO,EAAE,oBAAoB,EAAE,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