@arcis/node 1.3.0 → 1.4.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/dist/core/{index.d.mts → constants.d.ts} +21 -70
- package/dist/core/constants.d.ts.map +1 -0
- package/dist/core/errors.d.ts +53 -0
- package/dist/core/errors.d.ts.map +1 -0
- package/dist/core/index.d.ts +6 -168
- package/dist/core/index.d.ts.map +1 -0
- package/dist/{types-BOkx5YJc.d.mts → core/types.d.ts} +27 -30
- package/dist/core/types.d.ts.map +1 -0
- package/dist/index.d.ts +71 -166
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +57 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +56 -3
- package/dist/index.mjs.map +1 -1
- package/dist/logging/index.d.ts +4 -36
- package/dist/logging/index.d.ts.map +1 -0
- package/dist/logging/{index.d.mts → redactor.d.ts} +5 -9
- package/dist/logging/redactor.d.ts.map +1 -0
- package/dist/middleware/bot-detection.d.ts +86 -0
- package/dist/middleware/bot-detection.d.ts.map +1 -0
- package/dist/middleware/cookies.d.ts +48 -0
- package/dist/middleware/cookies.d.ts.map +1 -0
- package/dist/middleware/cors.d.ts +65 -0
- package/dist/middleware/cors.d.ts.map +1 -0
- package/dist/middleware/csrf.d.ts +109 -0
- package/dist/middleware/csrf.d.ts.map +1 -0
- package/dist/middleware/error-handler.d.ts +43 -0
- package/dist/middleware/error-handler.d.ts.map +1 -0
- package/dist/middleware/headers.d.ts +29 -0
- package/dist/middleware/headers.d.ts.map +1 -0
- package/dist/middleware/hpp.d.ts +56 -0
- package/dist/middleware/hpp.d.ts.map +1 -0
- package/dist/middleware/index.d.ts +16 -3
- package/dist/middleware/index.d.ts.map +1 -0
- package/dist/middleware/index.js +6 -1
- package/dist/middleware/index.js.map +1 -1
- package/dist/middleware/index.mjs +6 -1
- package/dist/middleware/index.mjs.map +1 -1
- package/dist/middleware/main.d.ts +40 -0
- package/dist/middleware/main.d.ts.map +1 -0
- package/dist/middleware/rate-limit-sliding.d.ts +46 -0
- package/dist/middleware/rate-limit-sliding.d.ts.map +1 -0
- package/dist/middleware/rate-limit-token.d.ts +51 -0
- package/dist/middleware/rate-limit-token.d.ts.map +1 -0
- package/dist/middleware/rate-limit.d.ts +34 -0
- package/dist/middleware/rate-limit.d.ts.map +1 -0
- package/dist/sanitizers/command.d.ts +28 -0
- package/dist/sanitizers/command.d.ts.map +1 -0
- package/dist/sanitizers/encode.d.ts +46 -0
- package/dist/sanitizers/encode.d.ts.map +1 -0
- package/dist/sanitizers/headers.d.ts +46 -0
- package/dist/sanitizers/headers.d.ts.map +1 -0
- package/dist/sanitizers/index.d.ts +17 -22
- package/dist/sanitizers/index.d.ts.map +1 -0
- package/dist/sanitizers/jsonp.d.ts +34 -0
- package/dist/sanitizers/jsonp.d.ts.map +1 -0
- package/dist/sanitizers/nosql.d.ts +31 -0
- package/dist/sanitizers/nosql.d.ts.map +1 -0
- package/dist/sanitizers/path.d.ts +28 -0
- package/dist/sanitizers/path.d.ts.map +1 -0
- package/dist/sanitizers/pii.d.ts +80 -0
- package/dist/sanitizers/pii.d.ts.map +1 -0
- package/dist/sanitizers/prototype.d.ts +34 -0
- package/dist/sanitizers/prototype.d.ts.map +1 -0
- package/dist/sanitizers/sanitize.d.ts +51 -0
- package/dist/sanitizers/sanitize.d.ts.map +1 -0
- package/dist/sanitizers/sql.d.ts +28 -0
- package/dist/sanitizers/sql.d.ts.map +1 -0
- package/dist/sanitizers/ssti.d.ts +20 -0
- package/dist/sanitizers/ssti.d.ts.map +1 -0
- package/dist/sanitizers/utils.d.ts +19 -0
- package/dist/sanitizers/utils.d.ts.map +1 -0
- package/dist/sanitizers/xss.d.ts +35 -0
- package/dist/sanitizers/xss.d.ts.map +1 -0
- package/dist/sanitizers/xxe.d.ts +20 -0
- package/dist/sanitizers/xxe.d.ts.map +1 -0
- package/dist/stores/index.d.ts +6 -104
- package/dist/stores/index.d.ts.map +1 -0
- package/dist/stores/memory.d.ts +35 -0
- package/dist/stores/memory.d.ts.map +1 -0
- package/dist/stores/{index.d.mts → redis.d.ts} +6 -45
- package/dist/stores/redis.d.ts.map +1 -0
- package/dist/utils/duration.d.ts +34 -0
- package/dist/utils/duration.d.ts.map +1 -0
- package/dist/utils/fingerprint.d.ts +64 -0
- package/dist/utils/fingerprint.d.ts.map +1 -0
- package/dist/utils/index.d.ts +10 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +188 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/index.mjs +182 -0
- package/dist/utils/index.mjs.map +1 -0
- package/dist/utils/ip.d.ts +70 -0
- package/dist/utils/ip.d.ts.map +1 -0
- package/dist/validation/email.d.ts +82 -0
- package/dist/validation/email.d.ts.map +1 -0
- package/dist/validation/file.d.ts +90 -0
- package/dist/validation/file.d.ts.map +1 -0
- package/dist/validation/index.d.ts +10 -3
- package/dist/validation/index.d.ts.map +1 -0
- package/dist/validation/redirect.d.ts +64 -0
- package/dist/validation/redirect.d.ts.map +1 -0
- package/dist/validation/schema.d.ts +36 -0
- package/dist/validation/schema.d.ts.map +1 -0
- package/dist/validation/url.d.ts +65 -0
- package/dist/validation/url.d.ts.map +1 -0
- package/package.json +8 -6
- package/dist/encode-CrQCGlBq.d.mts +0 -484
- package/dist/encode-jl9sOwmA.d.ts +0 -484
- package/dist/index-BAhgn9V2.d.ts +0 -532
- package/dist/index-BGNKspqH.d.ts +0 -340
- package/dist/index-Cd02z-0j.d.mts +0 -340
- package/dist/index-DgJtWMSj.d.mts +0 -532
- package/dist/index.d.mts +0 -175
- package/dist/middleware/index.d.mts +0 -3
- package/dist/sanitizers/index.d.mts +0 -24
- package/dist/types-BOkx5YJc.d.ts +0 -279
- package/dist/validation/index.d.mts +0 -3
|
@@ -1,69 +1,14 @@
|
|
|
1
|
-
export { A as ArcisFunction, a as ArcisMiddleware, b as ArcisOptions, E as ErrorHandlerOptions, F as FieldValidator, H as HeaderOptions, c as HstsOptions, d as HttpError, L as LogOptions, R as RateLimitEntry, e as RateLimitOptions, f as RateLimitResult, g as RateLimitStore, h as RateLimiterMiddleware, S as SafeLogger, i as SanitizeOptions, j as SanitizeResult, T as ThreatInfo, k as ThreatType, V as ValidationConfig, l as ValidationError, m as ValidationResult, n as ValidationSchema } from '../types-BOkx5YJc.mjs';
|
|
2
|
-
import 'express';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* @module @arcis/node/core/errors
|
|
6
|
-
* Custom error classes for Arcis
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* Base class for all Arcis errors
|
|
10
|
-
*/
|
|
11
|
-
declare class ArcisError extends Error {
|
|
12
|
-
readonly statusCode: number;
|
|
13
|
-
readonly code: string;
|
|
14
|
-
/** Whether the error message is safe to expose to API clients. */
|
|
15
|
-
readonly expose: boolean;
|
|
16
|
-
constructor(message: string, statusCode?: number, code?: string);
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Error thrown when input validation fails
|
|
20
|
-
*/
|
|
21
|
-
declare class ValidationError extends ArcisError {
|
|
22
|
-
readonly errors: string[];
|
|
23
|
-
constructor(errors: string[]);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Error thrown when rate limit is exceeded
|
|
28
|
-
*/
|
|
29
|
-
declare class RateLimitError extends ArcisError {
|
|
30
|
-
readonly retryAfter: number;
|
|
31
|
-
constructor(message: string, retryAfter: number);
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Error thrown when input is too large
|
|
35
|
-
*/
|
|
36
|
-
declare class InputTooLargeError extends ArcisError {
|
|
37
|
-
readonly maxSize: number;
|
|
38
|
-
readonly actualSize: number;
|
|
39
|
-
constructor(maxSize: number, actualSize: number);
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Error thrown when security threat is detected
|
|
43
|
-
*/
|
|
44
|
-
declare class SecurityThreatError extends ArcisError {
|
|
45
|
-
readonly threatType: string;
|
|
46
|
-
readonly pattern: string;
|
|
47
|
-
constructor(threatType: string, pattern: string);
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Error thrown when sanitization fails
|
|
51
|
-
*/
|
|
52
|
-
declare class SanitizationError extends ArcisError {
|
|
53
|
-
constructor(message: string);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
1
|
/**
|
|
57
2
|
* @module @arcis/node/core/constants
|
|
58
3
|
* Named constants for Arcis - no magic numbers
|
|
59
4
|
*/
|
|
60
|
-
declare const INPUT: {
|
|
5
|
+
export declare const INPUT: {
|
|
61
6
|
/** Default maximum input size (1MB) */
|
|
62
7
|
readonly DEFAULT_MAX_SIZE: 1000000;
|
|
63
8
|
/** Maximum recursion depth for nested objects */
|
|
64
9
|
readonly MAX_RECURSION_DEPTH: 10;
|
|
65
10
|
};
|
|
66
|
-
declare const RATE_LIMIT: {
|
|
11
|
+
export declare const RATE_LIMIT: {
|
|
67
12
|
/** Default window size (1 minute) */
|
|
68
13
|
readonly DEFAULT_WINDOW_MS: 60000;
|
|
69
14
|
/** Default max requests per window */
|
|
@@ -77,7 +22,7 @@ declare const RATE_LIMIT: {
|
|
|
77
22
|
/** Maximum window size (24 hours) */
|
|
78
23
|
readonly MAX_WINDOW_MS: 86400000;
|
|
79
24
|
};
|
|
80
|
-
declare const HEADERS: {
|
|
25
|
+
export declare const HEADERS: {
|
|
81
26
|
/** Default Content Security Policy */
|
|
82
27
|
readonly DEFAULT_CSP: string;
|
|
83
28
|
/** Default HSTS max age (1 year in seconds) */
|
|
@@ -97,10 +42,17 @@ declare const HEADERS: {
|
|
|
97
42
|
* Detection patterns — used to flag whether a string contains XSS payloads.
|
|
98
43
|
* Must stay in sync with XSS_REMOVE_PATTERNS below.
|
|
99
44
|
*/
|
|
100
|
-
declare const XSS_PATTERNS: readonly [RegExp, RegExp, RegExp, RegExp, RegExp, RegExp, RegExp, RegExp, RegExp, RegExp];
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
45
|
+
export declare const XSS_PATTERNS: readonly [RegExp, RegExp, RegExp, RegExp, RegExp, RegExp, RegExp, RegExp, RegExp, RegExp];
|
|
46
|
+
/**
|
|
47
|
+
* Removal patterns — used by sanitizeXss() to strip dangerous content.
|
|
48
|
+
* More targeted than XSS_PATTERNS: each pattern captures the full dangerous
|
|
49
|
+
* substring (tag, attribute + value, protocol) so it can be replaced safely.
|
|
50
|
+
* Must stay in sync with XSS_PATTERNS above.
|
|
51
|
+
*/
|
|
52
|
+
export declare const XSS_REMOVE_PATTERNS: readonly [RegExp, RegExp, RegExp, RegExp, RegExp, RegExp, RegExp, RegExp, RegExp, RegExp, RegExp, RegExp, RegExp, RegExp];
|
|
53
|
+
export declare const SQL_PATTERNS: readonly [RegExp, RegExp, RegExp, RegExp, RegExp, RegExp, RegExp, RegExp, RegExp, RegExp, RegExp, RegExp, RegExp];
|
|
54
|
+
export declare const PATH_PATTERNS: readonly [RegExp, RegExp, RegExp, RegExp, RegExp, RegExp, RegExp, RegExp, RegExp, RegExp, RegExp];
|
|
55
|
+
export declare const COMMAND_PATTERNS: readonly [RegExp, RegExp, RegExp];
|
|
104
56
|
/**
|
|
105
57
|
* Prototype pollution keys to block.
|
|
106
58
|
* Stored lowercase — always compare with key.toLowerCase().
|
|
@@ -112,10 +64,10 @@ declare const COMMAND_PATTERNS: readonly [RegExp, RegExp, RegExp];
|
|
|
112
64
|
* - __defineGetter__/__defineSetter__: legacy property definition (can override getters/setters)
|
|
113
65
|
* - __lookupGetter__/__lookupSetter__: legacy property introspection
|
|
114
66
|
*/
|
|
115
|
-
declare const DANGEROUS_PROTO_KEYS: Set<string>;
|
|
67
|
+
export declare const DANGEROUS_PROTO_KEYS: Set<string>;
|
|
116
68
|
/** MongoDB operators to block */
|
|
117
|
-
declare const NOSQL_DANGEROUS_KEYS: Set<string>;
|
|
118
|
-
declare const REDACTION: {
|
|
69
|
+
export declare const NOSQL_DANGEROUS_KEYS: Set<string>;
|
|
70
|
+
export declare const REDACTION: {
|
|
119
71
|
/** Replacement text for redacted values */
|
|
120
72
|
readonly REPLACEMENT: "[REDACTED]";
|
|
121
73
|
/** Truncation indicator */
|
|
@@ -127,7 +79,7 @@ declare const REDACTION: {
|
|
|
127
79
|
/** Default sensitive keys to redact */
|
|
128
80
|
readonly SENSITIVE_KEYS: Set<string>;
|
|
129
81
|
};
|
|
130
|
-
declare const VALIDATION: {
|
|
82
|
+
export declare const VALIDATION: {
|
|
131
83
|
/**
|
|
132
84
|
* Email regex pattern.
|
|
133
85
|
* Rejects consecutive dots in local part (e.g. test..foo@example.com),
|
|
@@ -143,7 +95,7 @@ declare const VALIDATION: {
|
|
|
143
95
|
/** UUID regex pattern (v4) */
|
|
144
96
|
readonly UUID: RegExp;
|
|
145
97
|
};
|
|
146
|
-
declare const ERRORS: {
|
|
98
|
+
export declare const ERRORS: {
|
|
147
99
|
/** Generic error message (production) */
|
|
148
100
|
readonly INTERNAL_SERVER_ERROR: "Internal Server Error";
|
|
149
101
|
/** Input too large error */
|
|
@@ -165,6 +117,5 @@ declare const ERRORS: {
|
|
|
165
117
|
readonly MAX_ITEMS: (field: string, max: number) => string;
|
|
166
118
|
};
|
|
167
119
|
};
|
|
168
|
-
declare const BLOCKED: "[BLOCKED]";
|
|
169
|
-
|
|
170
|
-
export { ArcisError, ValidationError as ArcisValidationError, BLOCKED, COMMAND_PATTERNS, DANGEROUS_PROTO_KEYS, ERRORS, HEADERS, INPUT, InputTooLargeError, NOSQL_DANGEROUS_KEYS, PATH_PATTERNS, RATE_LIMIT, REDACTION, RateLimitError, SQL_PATTERNS, SanitizationError, SecurityThreatError, VALIDATION, XSS_PATTERNS };
|
|
120
|
+
export declare const BLOCKED: "[BLOCKED]";
|
|
121
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/core/constants.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,eAAO,MAAM,KAA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AO,MAAM;;CAEhC,CAAC;AAKX,eAAO,MAAM,OAAO,EAAG,WAAoB,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module @arcis/node/core/errors
|
|
3
|
+
* Custom error classes for Arcis
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Base class for all Arcis errors
|
|
7
|
+
*/
|
|
8
|
+
export declare class ArcisError extends Error {
|
|
9
|
+
readonly statusCode: number;
|
|
10
|
+
readonly code: string;
|
|
11
|
+
/** Whether the error message is safe to expose to API clients. */
|
|
12
|
+
readonly expose: boolean;
|
|
13
|
+
constructor(message: string, statusCode?: number, code?: string);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Error thrown when input validation fails
|
|
17
|
+
*/
|
|
18
|
+
export declare class ValidationError extends ArcisError {
|
|
19
|
+
readonly errors: string[];
|
|
20
|
+
constructor(errors: string[]);
|
|
21
|
+
}
|
|
22
|
+
/** Alias for ValidationError (backwards compatibility) */
|
|
23
|
+
export { ValidationError as ArcisValidationError };
|
|
24
|
+
/**
|
|
25
|
+
* Error thrown when rate limit is exceeded
|
|
26
|
+
*/
|
|
27
|
+
export declare class RateLimitError extends ArcisError {
|
|
28
|
+
readonly retryAfter: number;
|
|
29
|
+
constructor(message: string, retryAfter: number);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Error thrown when input is too large
|
|
33
|
+
*/
|
|
34
|
+
export declare class InputTooLargeError extends ArcisError {
|
|
35
|
+
readonly maxSize: number;
|
|
36
|
+
readonly actualSize: number;
|
|
37
|
+
constructor(maxSize: number, actualSize: number);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Error thrown when security threat is detected
|
|
41
|
+
*/
|
|
42
|
+
export declare class SecurityThreatError extends ArcisError {
|
|
43
|
+
readonly threatType: string;
|
|
44
|
+
readonly pattern: string;
|
|
45
|
+
constructor(threatType: string, pattern: string);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Error thrown when sanitization fails
|
|
49
|
+
*/
|
|
50
|
+
export declare class SanitizationError extends ArcisError {
|
|
51
|
+
constructor(message: string);
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/core/errors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,qBAAa,UAAW,SAAQ,KAAK;IACnC,SAAgB,UAAU,EAAE,MAAM,CAAC;IACnC,SAAgB,IAAI,EAAE,MAAM,CAAC;IAC7B,kEAAkE;IAClE,SAAgB,MAAM,EAAE,OAAO,CAAC;gBAEpB,OAAO,EAAE,MAAM,EAAE,UAAU,SAAM,EAAE,IAAI,SAAgB;CAcpE;AAED;;GAEG;AACH,qBAAa,eAAgB,SAAQ,UAAU;IAC7C,SAAgB,MAAM,EAAE,MAAM,EAAE,CAAC;gBAErB,MAAM,EAAE,MAAM,EAAE;CAK7B;AAED,0DAA0D;AAC1D,OAAO,EAAE,eAAe,IAAI,oBAAoB,EAAE,CAAC;AAEnD;;GAEG;AACH,qBAAa,cAAe,SAAQ,UAAU;IAC5C,SAAgB,UAAU,EAAE,MAAM,CAAC;gBAEvB,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM;CAKhD;AAED;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,UAAU;IAChD,SAAgB,OAAO,EAAE,MAAM,CAAC;IAChC,SAAgB,UAAU,EAAE,MAAM,CAAC;gBAEvB,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM;CAMhD;AAED;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,UAAU;IACjD,SAAgB,UAAU,EAAE,MAAM,CAAC;IACnC,SAAgB,OAAO,EAAE,MAAM,CAAC;gBAEpB,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;CAMhD;AAED;;GAEG;AACH,qBAAa,iBAAkB,SAAQ,UAAU;gBACnC,OAAO,EAAE,MAAM;CAI5B"}
|
package/dist/core/index.d.ts
CHANGED
|
@@ -1,170 +1,8 @@
|
|
|
1
|
-
export { A as ArcisFunction, a as ArcisMiddleware, b as ArcisOptions, E as ErrorHandlerOptions, F as FieldValidator, H as HeaderOptions, c as HstsOptions, d as HttpError, L as LogOptions, R as RateLimitEntry, e as RateLimitOptions, f as RateLimitResult, g as RateLimitStore, h as RateLimiterMiddleware, S as SafeLogger, i as SanitizeOptions, j as SanitizeResult, T as ThreatInfo, k as ThreatType, V as ValidationConfig, l as ValidationError, m as ValidationResult, n as ValidationSchema } from '../types-BOkx5YJc.js';
|
|
2
|
-
import 'express';
|
|
3
|
-
|
|
4
1
|
/**
|
|
5
|
-
* @module @arcis/node/core
|
|
6
|
-
*
|
|
2
|
+
* @module @arcis/node/core
|
|
3
|
+
* Core types, constants, and errors for Arcis
|
|
7
4
|
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
readonly statusCode: number;
|
|
13
|
-
readonly code: string;
|
|
14
|
-
/** Whether the error message is safe to expose to API clients. */
|
|
15
|
-
readonly expose: boolean;
|
|
16
|
-
constructor(message: string, statusCode?: number, code?: string);
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Error thrown when input validation fails
|
|
20
|
-
*/
|
|
21
|
-
declare class ValidationError extends ArcisError {
|
|
22
|
-
readonly errors: string[];
|
|
23
|
-
constructor(errors: string[]);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Error thrown when rate limit is exceeded
|
|
28
|
-
*/
|
|
29
|
-
declare class RateLimitError extends ArcisError {
|
|
30
|
-
readonly retryAfter: number;
|
|
31
|
-
constructor(message: string, retryAfter: number);
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Error thrown when input is too large
|
|
35
|
-
*/
|
|
36
|
-
declare class InputTooLargeError extends ArcisError {
|
|
37
|
-
readonly maxSize: number;
|
|
38
|
-
readonly actualSize: number;
|
|
39
|
-
constructor(maxSize: number, actualSize: number);
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Error thrown when security threat is detected
|
|
43
|
-
*/
|
|
44
|
-
declare class SecurityThreatError extends ArcisError {
|
|
45
|
-
readonly threatType: string;
|
|
46
|
-
readonly pattern: string;
|
|
47
|
-
constructor(threatType: string, pattern: string);
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Error thrown when sanitization fails
|
|
51
|
-
*/
|
|
52
|
-
declare class SanitizationError extends ArcisError {
|
|
53
|
-
constructor(message: string);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* @module @arcis/node/core/constants
|
|
58
|
-
* Named constants for Arcis - no magic numbers
|
|
59
|
-
*/
|
|
60
|
-
declare const INPUT: {
|
|
61
|
-
/** Default maximum input size (1MB) */
|
|
62
|
-
readonly DEFAULT_MAX_SIZE: 1000000;
|
|
63
|
-
/** Maximum recursion depth for nested objects */
|
|
64
|
-
readonly MAX_RECURSION_DEPTH: 10;
|
|
65
|
-
};
|
|
66
|
-
declare const RATE_LIMIT: {
|
|
67
|
-
/** Default window size (1 minute) */
|
|
68
|
-
readonly DEFAULT_WINDOW_MS: 60000;
|
|
69
|
-
/** Default max requests per window */
|
|
70
|
-
readonly DEFAULT_MAX_REQUESTS: 100;
|
|
71
|
-
/** Default HTTP status code for rate limited responses */
|
|
72
|
-
readonly DEFAULT_STATUS_CODE: 429;
|
|
73
|
-
/** Default error message */
|
|
74
|
-
readonly DEFAULT_MESSAGE: "Too many requests, please try again later.";
|
|
75
|
-
/** Minimum window size (1 second) */
|
|
76
|
-
readonly MIN_WINDOW_MS: 1000;
|
|
77
|
-
/** Maximum window size (24 hours) */
|
|
78
|
-
readonly MAX_WINDOW_MS: 86400000;
|
|
79
|
-
};
|
|
80
|
-
declare const HEADERS: {
|
|
81
|
-
/** Default Content Security Policy */
|
|
82
|
-
readonly DEFAULT_CSP: string;
|
|
83
|
-
/** Default HSTS max age (1 year in seconds) */
|
|
84
|
-
readonly HSTS_MAX_AGE: 31536000;
|
|
85
|
-
/** Default X-Frame-Options value */
|
|
86
|
-
readonly FRAME_OPTIONS: "DENY";
|
|
87
|
-
/** Default X-Content-Type-Options value */
|
|
88
|
-
readonly CONTENT_TYPE_OPTIONS: "nosniff";
|
|
89
|
-
/** Default Referrer-Policy value */
|
|
90
|
-
readonly REFERRER_POLICY: "strict-origin-when-cross-origin";
|
|
91
|
-
/** Default Permissions-Policy value */
|
|
92
|
-
readonly PERMISSIONS_POLICY: "geolocation=(), microphone=(), camera=()";
|
|
93
|
-
/** Default Cache-Control value for security */
|
|
94
|
-
readonly CACHE_CONTROL: "no-store, no-cache, must-revalidate, proxy-revalidate";
|
|
95
|
-
};
|
|
96
|
-
/**
|
|
97
|
-
* Detection patterns — used to flag whether a string contains XSS payloads.
|
|
98
|
-
* Must stay in sync with XSS_REMOVE_PATTERNS below.
|
|
99
|
-
*/
|
|
100
|
-
declare const XSS_PATTERNS: readonly [RegExp, RegExp, RegExp, RegExp, RegExp, RegExp, RegExp, RegExp, RegExp, RegExp];
|
|
101
|
-
declare const SQL_PATTERNS: readonly [RegExp, RegExp, RegExp, RegExp, RegExp, RegExp, RegExp, RegExp, RegExp, RegExp, RegExp, RegExp, RegExp];
|
|
102
|
-
declare const PATH_PATTERNS: readonly [RegExp, RegExp, RegExp, RegExp, RegExp, RegExp, RegExp, RegExp, RegExp, RegExp, RegExp];
|
|
103
|
-
declare const COMMAND_PATTERNS: readonly [RegExp, RegExp, RegExp];
|
|
104
|
-
/**
|
|
105
|
-
* Prototype pollution keys to block.
|
|
106
|
-
* Stored lowercase — always compare with key.toLowerCase().
|
|
107
|
-
*
|
|
108
|
-
* Includes:
|
|
109
|
-
* - __proto__: direct prototype assignment
|
|
110
|
-
* - constructor: access to constructor.prototype chain
|
|
111
|
-
* - prototype: direct prototype property
|
|
112
|
-
* - __defineGetter__/__defineSetter__: legacy property definition (can override getters/setters)
|
|
113
|
-
* - __lookupGetter__/__lookupSetter__: legacy property introspection
|
|
114
|
-
*/
|
|
115
|
-
declare const DANGEROUS_PROTO_KEYS: Set<string>;
|
|
116
|
-
/** MongoDB operators to block */
|
|
117
|
-
declare const NOSQL_DANGEROUS_KEYS: Set<string>;
|
|
118
|
-
declare const REDACTION: {
|
|
119
|
-
/** Replacement text for redacted values */
|
|
120
|
-
readonly REPLACEMENT: "[REDACTED]";
|
|
121
|
-
/** Truncation indicator */
|
|
122
|
-
readonly TRUNCATED: "[TRUNCATED]";
|
|
123
|
-
/** Max depth indicator */
|
|
124
|
-
readonly MAX_DEPTH: "[MAX_DEPTH]";
|
|
125
|
-
/** Default max message length */
|
|
126
|
-
readonly DEFAULT_MAX_LENGTH: 10000;
|
|
127
|
-
/** Default sensitive keys to redact */
|
|
128
|
-
readonly SENSITIVE_KEYS: Set<string>;
|
|
129
|
-
};
|
|
130
|
-
declare const VALIDATION: {
|
|
131
|
-
/**
|
|
132
|
-
* Email regex pattern.
|
|
133
|
-
* Rejects consecutive dots in local part (e.g. test..foo@example.com),
|
|
134
|
-
* leading/trailing dots, and other common invalid forms.
|
|
135
|
-
*/
|
|
136
|
-
readonly EMAIL: RegExp;
|
|
137
|
-
/**
|
|
138
|
-
* URL regex pattern.
|
|
139
|
-
* Only allows http:// and https:// — explicitly rejects javascript:,
|
|
140
|
-
* data:, vbscript:, and other dangerous URI schemes.
|
|
141
|
-
*/
|
|
142
|
-
readonly URL: RegExp;
|
|
143
|
-
/** UUID regex pattern (v4) */
|
|
144
|
-
readonly UUID: RegExp;
|
|
145
|
-
};
|
|
146
|
-
declare const ERRORS: {
|
|
147
|
-
/** Generic error message (production) */
|
|
148
|
-
readonly INTERNAL_SERVER_ERROR: "Internal Server Error";
|
|
149
|
-
/** Input too large error */
|
|
150
|
-
readonly INPUT_TOO_LARGE: (maxSize: number) => string;
|
|
151
|
-
/** Validation error messages */
|
|
152
|
-
readonly VALIDATION: {
|
|
153
|
-
readonly REQUIRED: (field: string) => string;
|
|
154
|
-
readonly INVALID_TYPE: (field: string, type: string) => string;
|
|
155
|
-
readonly MIN_LENGTH: (field: string, min: number) => string;
|
|
156
|
-
readonly MAX_LENGTH: (field: string, max: number) => string;
|
|
157
|
-
readonly MIN_VALUE: (field: string, min: number) => string;
|
|
158
|
-
readonly MAX_VALUE: (field: string, max: number) => string;
|
|
159
|
-
readonly INVALID_FORMAT: (field: string) => string;
|
|
160
|
-
readonly INVALID_EMAIL: (field: string) => string;
|
|
161
|
-
readonly INVALID_URL: (field: string) => string;
|
|
162
|
-
readonly INVALID_UUID: (field: string) => string;
|
|
163
|
-
readonly INVALID_ENUM: (field: string, values: unknown[]) => string;
|
|
164
|
-
readonly MIN_ITEMS: (field: string, min: number) => string;
|
|
165
|
-
readonly MAX_ITEMS: (field: string, max: number) => string;
|
|
166
|
-
};
|
|
167
|
-
};
|
|
168
|
-
declare const BLOCKED: "[BLOCKED]";
|
|
169
|
-
|
|
170
|
-
export { ArcisError, ValidationError as ArcisValidationError, BLOCKED, COMMAND_PATTERNS, DANGEROUS_PROTO_KEYS, ERRORS, HEADERS, INPUT, InputTooLargeError, NOSQL_DANGEROUS_KEYS, PATH_PATTERNS, RATE_LIMIT, REDACTION, RateLimitError, SQL_PATTERNS, SanitizationError, SecurityThreatError, VALIDATION, XSS_PATTERNS };
|
|
5
|
+
export type { ArcisOptions, ArcisFunction, ArcisMiddleware, SanitizeOptions, SanitizeResult, ThreatInfo, ThreatType, RateLimitOptions, RateLimitStore, RateLimitEntry, RateLimitResult, RateLimiterMiddleware, HeaderOptions, HstsOptions, ValidationConfig, ValidationSchema, FieldValidator, ValidationResult, ValidationError, LogOptions, SafeLogger, ErrorHandlerOptions, HttpError, } from './types';
|
|
6
|
+
export { INPUT, RATE_LIMIT, HEADERS, XSS_PATTERNS, SQL_PATTERNS, PATH_PATTERNS, COMMAND_PATTERNS, DANGEROUS_PROTO_KEYS, NOSQL_DANGEROUS_KEYS, REDACTION, VALIDATION, ERRORS, BLOCKED, } from './constants';
|
|
7
|
+
export { ArcisError, ValidationError as ArcisValidationError, RateLimitError, InputTooLargeError, SecurityThreatError, SanitizationError, } from './errors';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,YAAY,EAEV,YAAY,EACZ,aAAa,EACb,eAAe,EAEf,eAAe,EACf,cAAc,EACd,UAAU,EACV,UAAU,EAEV,gBAAgB,EAChB,cAAc,EACd,cAAc,EACd,eAAe,EACf,qBAAqB,EAErB,aAAa,EACb,WAAW,EAEX,gBAAgB,EAChB,gBAAgB,EAChB,cAAc,EACd,gBAAgB,EAChB,eAAe,EAEf,UAAU,EACV,UAAU,EAEV,mBAAmB,EACnB,SAAS,GACV,MAAM,SAAS,CAAC;AAGjB,OAAO,EACL,KAAK,EACL,UAAU,EACV,OAAO,EACP,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,gBAAgB,EAChB,oBAAoB,EACpB,oBAAoB,EACpB,SAAS,EACT,UAAU,EACV,MAAM,EACN,OAAO,GACR,MAAM,aAAa,CAAC;AAGrB,OAAO,EACL,UAAU,EACV,eAAe,IAAI,oBAAoB,EACvC,cAAc,EACd,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,GAClB,MAAM,UAAU,CAAC"}
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import { Request, RequestHandler, Response, NextFunction } from 'express';
|
|
2
|
-
|
|
3
1
|
/**
|
|
4
2
|
* @module @arcis/node/core/types
|
|
5
3
|
* All TypeScript interfaces and types for Arcis
|
|
6
4
|
*/
|
|
7
|
-
|
|
5
|
+
import type { Request, Response, NextFunction, RequestHandler } from 'express';
|
|
8
6
|
/** Main Arcis configuration options */
|
|
9
|
-
interface ArcisOptions {
|
|
7
|
+
export interface ArcisOptions {
|
|
10
8
|
/** Enable/configure input sanitization. Default: true */
|
|
11
9
|
sanitize?: boolean | SanitizeOptions;
|
|
12
10
|
/** Enable/configure rate limiting. Default: true */
|
|
@@ -17,7 +15,7 @@ interface ArcisOptions {
|
|
|
17
15
|
logging?: boolean | LogOptions;
|
|
18
16
|
}
|
|
19
17
|
/** Sanitization configuration */
|
|
20
|
-
interface SanitizeOptions {
|
|
18
|
+
export interface SanitizeOptions {
|
|
21
19
|
/** Sanitize XSS attempts. Default: true */
|
|
22
20
|
xss?: boolean;
|
|
23
21
|
/** Sanitize SQL injection attempts. Default: true */
|
|
@@ -48,7 +46,7 @@ interface SanitizeOptions {
|
|
|
48
46
|
freeze?: boolean;
|
|
49
47
|
}
|
|
50
48
|
/** Result of sanitizing a string */
|
|
51
|
-
interface SanitizeResult {
|
|
49
|
+
export interface SanitizeResult {
|
|
52
50
|
/** The sanitized value */
|
|
53
51
|
value: string;
|
|
54
52
|
/** Whether any sanitization was applied */
|
|
@@ -57,7 +55,7 @@ interface SanitizeResult {
|
|
|
57
55
|
threats: ThreatInfo[];
|
|
58
56
|
}
|
|
59
57
|
/** Information about a detected threat */
|
|
60
|
-
interface ThreatInfo {
|
|
58
|
+
export interface ThreatInfo {
|
|
61
59
|
/** Type of threat detected */
|
|
62
60
|
type: ThreatType;
|
|
63
61
|
/** Pattern that matched */
|
|
@@ -68,9 +66,9 @@ interface ThreatInfo {
|
|
|
68
66
|
location?: string;
|
|
69
67
|
}
|
|
70
68
|
/** Types of security threats */
|
|
71
|
-
type ThreatType = 'xss' | 'sql_injection' | 'nosql_injection' | 'path_traversal' | 'command_injection' | 'prototype_pollution' | 'header_injection' | 'ssti' | 'xxe';
|
|
69
|
+
export type ThreatType = 'xss' | 'sql_injection' | 'nosql_injection' | 'path_traversal' | 'command_injection' | 'prototype_pollution' | 'header_injection' | 'ssti' | 'xxe';
|
|
72
70
|
/** Rate limiting configuration */
|
|
73
|
-
interface RateLimitOptions {
|
|
71
|
+
export interface RateLimitOptions {
|
|
74
72
|
/** Maximum requests per window. Default: 100 */
|
|
75
73
|
max?: number;
|
|
76
74
|
/** Window size in milliseconds. Default: 60000 (1 minute) */
|
|
@@ -87,7 +85,7 @@ interface RateLimitOptions {
|
|
|
87
85
|
store?: RateLimitStore;
|
|
88
86
|
}
|
|
89
87
|
/** External store interface for distributed rate limiting */
|
|
90
|
-
interface RateLimitStore {
|
|
88
|
+
export interface RateLimitStore {
|
|
91
89
|
/** Get current count for a key */
|
|
92
90
|
get(key: string): Promise<RateLimitEntry | null>;
|
|
93
91
|
/** Set entry for a key */
|
|
@@ -102,26 +100,26 @@ interface RateLimitStore {
|
|
|
102
100
|
close?(): Promise<void>;
|
|
103
101
|
}
|
|
104
102
|
/** Rate limit entry stored in a store */
|
|
105
|
-
interface RateLimitEntry {
|
|
103
|
+
export interface RateLimitEntry {
|
|
106
104
|
/** Number of requests in the current window */
|
|
107
105
|
count: number;
|
|
108
106
|
/** Timestamp when the window resets */
|
|
109
107
|
resetTime: number;
|
|
110
108
|
}
|
|
111
109
|
/** Result from incrementing a rate limit counter */
|
|
112
|
-
interface RateLimitResult {
|
|
110
|
+
export interface RateLimitResult {
|
|
113
111
|
/** Current request count */
|
|
114
112
|
count: number;
|
|
115
113
|
/** When the window resets */
|
|
116
114
|
resetTime: Date;
|
|
117
115
|
}
|
|
118
116
|
/** Rate limiter middleware with cleanup support */
|
|
119
|
-
interface RateLimiterMiddleware extends RequestHandler {
|
|
117
|
+
export interface RateLimiterMiddleware extends RequestHandler {
|
|
120
118
|
/** Clean up the rate limiter (clear intervals, close stores) */
|
|
121
119
|
close: () => void;
|
|
122
120
|
}
|
|
123
121
|
/** Security headers configuration */
|
|
124
|
-
interface HeaderOptions {
|
|
122
|
+
export interface HeaderOptions {
|
|
125
123
|
/** Content Security Policy. true = default, string = custom, false = disabled */
|
|
126
124
|
contentSecurityPolicy?: boolean | string;
|
|
127
125
|
/** Enable X-XSS-Protection header. Default: true (sends '0' to disable legacy XSS auditor) */
|
|
@@ -150,7 +148,7 @@ interface HeaderOptions {
|
|
|
150
148
|
dnsPrefetchControl?: boolean;
|
|
151
149
|
}
|
|
152
150
|
/** HSTS (HTTP Strict Transport Security) options */
|
|
153
|
-
interface HstsOptions {
|
|
151
|
+
export interface HstsOptions {
|
|
154
152
|
/** Max age in seconds. Default: 31536000 (1 year) */
|
|
155
153
|
maxAge?: number;
|
|
156
154
|
/** Include subdomains. Default: true */
|
|
@@ -159,18 +157,18 @@ interface HstsOptions {
|
|
|
159
157
|
preload?: boolean;
|
|
160
158
|
}
|
|
161
159
|
/** Validation configuration */
|
|
162
|
-
interface ValidationConfig {
|
|
160
|
+
export interface ValidationConfig {
|
|
163
161
|
/** Strip fields not in schema. Default: true (prevents mass assignment) */
|
|
164
162
|
stripUnknown?: boolean;
|
|
165
163
|
/** Stop on first error. Default: false */
|
|
166
164
|
abortEarly?: boolean;
|
|
167
165
|
}
|
|
168
166
|
/** Validation schema for request data */
|
|
169
|
-
interface ValidationSchema {
|
|
167
|
+
export interface ValidationSchema {
|
|
170
168
|
[key: string]: FieldValidator;
|
|
171
169
|
}
|
|
172
170
|
/** Field validation rules */
|
|
173
|
-
interface FieldValidator {
|
|
171
|
+
export interface FieldValidator {
|
|
174
172
|
/** Expected data type */
|
|
175
173
|
type: 'string' | 'number' | 'boolean' | 'email' | 'url' | 'uuid' | 'array' | 'object';
|
|
176
174
|
/** Whether field is required. Default: false */
|
|
@@ -194,7 +192,7 @@ interface FieldValidator {
|
|
|
194
192
|
custom?: (value: unknown) => true | false | string;
|
|
195
193
|
}
|
|
196
194
|
/** Validation result */
|
|
197
|
-
interface ValidationResult {
|
|
195
|
+
export interface ValidationResult {
|
|
198
196
|
/** Whether validation passed */
|
|
199
197
|
valid: boolean;
|
|
200
198
|
/** Validation errors */
|
|
@@ -203,7 +201,7 @@ interface ValidationResult {
|
|
|
203
201
|
data: Record<string, unknown>;
|
|
204
202
|
}
|
|
205
203
|
/** Single validation error */
|
|
206
|
-
interface ValidationError {
|
|
204
|
+
export interface ValidationError {
|
|
207
205
|
/** Field that failed validation */
|
|
208
206
|
field: string;
|
|
209
207
|
/** Human-readable error message */
|
|
@@ -212,8 +210,8 @@ interface ValidationError {
|
|
|
212
210
|
code: string;
|
|
213
211
|
}
|
|
214
212
|
/** Safe logging configuration */
|
|
215
|
-
type LogLevel = 'debug' | 'info' | 'warn' | 'error' | 'silent';
|
|
216
|
-
interface LogOptions {
|
|
213
|
+
export type LogLevel = 'debug' | 'info' | 'warn' | 'error' | 'silent';
|
|
214
|
+
export interface LogOptions {
|
|
217
215
|
/** Additional keys to redact beyond defaults */
|
|
218
216
|
redactKeys?: string[];
|
|
219
217
|
/** Maximum message length before truncation. Default: 10000 */
|
|
@@ -224,7 +222,7 @@ interface LogOptions {
|
|
|
224
222
|
level?: LogLevel;
|
|
225
223
|
}
|
|
226
224
|
/** Safe logger interface */
|
|
227
|
-
interface SafeLogger {
|
|
225
|
+
export interface SafeLogger {
|
|
228
226
|
/** Log at specified level */
|
|
229
227
|
log: (level: string, message: string, data?: unknown) => void;
|
|
230
228
|
/** Log info message */
|
|
@@ -237,7 +235,7 @@ interface SafeLogger {
|
|
|
237
235
|
debug: (message: string, data?: unknown) => void;
|
|
238
236
|
}
|
|
239
237
|
/** Error handler configuration */
|
|
240
|
-
interface ErrorHandlerOptions {
|
|
238
|
+
export interface ErrorHandlerOptions {
|
|
241
239
|
/** Show stack traces and detailed errors. Default: false */
|
|
242
240
|
isDev?: boolean;
|
|
243
241
|
/** Log errors. Default: true */
|
|
@@ -248,7 +246,7 @@ interface ErrorHandlerOptions {
|
|
|
248
246
|
customHandler?: (err: Error, req: Request, res: Response) => void;
|
|
249
247
|
}
|
|
250
248
|
/** Extended Error with optional status code */
|
|
251
|
-
interface HttpError extends Error {
|
|
249
|
+
export interface HttpError extends Error {
|
|
252
250
|
statusCode?: number;
|
|
253
251
|
status?: number;
|
|
254
252
|
/**
|
|
@@ -259,14 +257,14 @@ interface HttpError extends Error {
|
|
|
259
257
|
expose?: boolean;
|
|
260
258
|
}
|
|
261
259
|
/** Generic Arcis middleware type */
|
|
262
|
-
type ArcisMiddleware = (req: Request, res: Response, next: NextFunction) => void | Promise<void>;
|
|
260
|
+
export type ArcisMiddleware = (req: Request, res: Response, next: NextFunction) => void | Promise<void>;
|
|
263
261
|
/** Array of middlewares returned by arcis() with an attached cleanup method */
|
|
264
|
-
type ArcisMiddlewareStack = RequestHandler[] & {
|
|
262
|
+
export type ArcisMiddlewareStack = RequestHandler[] & {
|
|
265
263
|
/** Clean up resources created by arcis() (rate limiter intervals, etc.) */
|
|
266
264
|
close: () => void;
|
|
267
265
|
};
|
|
268
266
|
/** Arcis function with attached utilities */
|
|
269
|
-
interface ArcisFunction {
|
|
267
|
+
export interface ArcisFunction {
|
|
270
268
|
(options?: ArcisOptions): ArcisMiddlewareStack;
|
|
271
269
|
sanitize: (options?: SanitizeOptions) => RequestHandler;
|
|
272
270
|
rateLimit: (options?: RateLimitOptions) => RateLimiterMiddleware;
|
|
@@ -275,5 +273,4 @@ interface ArcisFunction {
|
|
|
275
273
|
logger: (options?: LogOptions) => SafeLogger;
|
|
276
274
|
errorHandler: (options?: ErrorHandlerOptions | boolean) => (err: Error, req: Request, res: Response, next: NextFunction) => void;
|
|
277
275
|
}
|
|
278
|
-
|
|
279
|
-
export type { ArcisFunction as A, ErrorHandlerOptions as E, FieldValidator as F, HeaderOptions as H, LogOptions as L, RateLimitEntry as R, SafeLogger as S, ThreatInfo as T, ValidationConfig as V, ArcisMiddleware as a, ArcisOptions as b, HstsOptions as c, HttpError as d, RateLimitOptions as e, RateLimitResult as f, RateLimitStore as g, RateLimiterMiddleware as h, SanitizeOptions as i, SanitizeResult as j, ThreatType as k, ValidationError as l, ValidationResult as m, ValidationSchema as n, ArcisMiddlewareStack as o };
|
|
276
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceR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