@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
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module @arcis/node/middleware/main
|
|
3
|
+
* Main arcis() middleware factory
|
|
4
|
+
*/
|
|
5
|
+
import type { ArcisOptions, ArcisFunction, ArcisMiddlewareStack } from '../core/types';
|
|
6
|
+
/**
|
|
7
|
+
* Create Arcis middleware with all protections enabled.
|
|
8
|
+
*
|
|
9
|
+
* @param options - Configuration options
|
|
10
|
+
* @returns Array of Express middleware
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* // Full protection (recommended)
|
|
14
|
+
* app.use(arcis());
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* // Custom configuration
|
|
18
|
+
* app.use(arcis({
|
|
19
|
+
* rateLimit: { max: 50 },
|
|
20
|
+
* headers: { frameOptions: 'SAMEORIGIN' }
|
|
21
|
+
* }));
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* // Disable specific features
|
|
25
|
+
* app.use(arcis({
|
|
26
|
+
* rateLimit: false,
|
|
27
|
+
* sanitize: { sql: false }
|
|
28
|
+
* }));
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* // Cleanup on shutdown
|
|
32
|
+
* const middleware = arcis();
|
|
33
|
+
* app.use(middleware);
|
|
34
|
+
* process.on('SIGTERM', () => middleware.close());
|
|
35
|
+
*/
|
|
36
|
+
export declare function arcis(options?: ArcisOptions): ArcisMiddlewareStack;
|
|
37
|
+
declare const arcisWithMethods: ArcisFunction;
|
|
38
|
+
export { arcisWithMethods as arcisFunction };
|
|
39
|
+
export default arcisWithMethods;
|
|
40
|
+
//# sourceMappingURL=main.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../src/middleware/main.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EACV,YAAY,EACZ,aAAa,EACb,oBAAoB,EAIrB,MAAM,eAAe,CAAC;AAQvB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,KAAK,CAAC,OAAO,GAAE,YAAiB,GAAG,oBAAoB,CAuCtE;AAGD,QAAA,MAAM,gBAAgB,EAAY,aAAa,CAAC;AAQhD,OAAO,EAAE,gBAAgB,IAAI,aAAa,EAAE,CAAC;AAC7C,eAAe,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module @arcis/node/middleware/rate-limit-sliding
|
|
3
|
+
* Sliding window rate limiting middleware.
|
|
4
|
+
*
|
|
5
|
+
* More accurate than fixed window — uses a weighted sum of the previous
|
|
6
|
+
* and current window to approximate a true sliding window.
|
|
7
|
+
*
|
|
8
|
+
* Algorithm:
|
|
9
|
+
* weight = (windowMs - elapsed) / windowMs
|
|
10
|
+
* count = (prevWindow * weight) + currentWindow
|
|
11
|
+
* allow = count < limit
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* app.use(createSlidingWindowLimiter({ max: 100, window: '15m' }));
|
|
15
|
+
*/
|
|
16
|
+
import type { Request, RequestHandler } from 'express';
|
|
17
|
+
export interface SlidingWindowOptions {
|
|
18
|
+
/** Maximum requests per window. Default: 100 */
|
|
19
|
+
max?: number;
|
|
20
|
+
/** Window size in ms or duration string. Default: '1m' */
|
|
21
|
+
window?: string | number;
|
|
22
|
+
/** Error message when limit exceeded */
|
|
23
|
+
message?: string;
|
|
24
|
+
/** HTTP status code for rate limited responses. Default: 429 */
|
|
25
|
+
statusCode?: number;
|
|
26
|
+
/** Function to generate rate limit key from request */
|
|
27
|
+
keyGenerator?: (req: Request) => string;
|
|
28
|
+
/** Function to skip rate limiting for certain requests */
|
|
29
|
+
skip?: (req: Request) => boolean;
|
|
30
|
+
}
|
|
31
|
+
export interface SlidingWindowMiddleware extends RequestHandler {
|
|
32
|
+
close: () => void;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Create sliding window rate limiter middleware.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* // 100 requests per 15 minutes
|
|
39
|
+
* app.use(createSlidingWindowLimiter({ max: 100, window: '15m' }));
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* // Strict API limit
|
|
43
|
+
* app.use('/api', createSlidingWindowLimiter({ max: 30, window: '1m' }));
|
|
44
|
+
*/
|
|
45
|
+
export declare function createSlidingWindowLimiter(options?: SlidingWindowOptions): SlidingWindowMiddleware;
|
|
46
|
+
//# sourceMappingURL=rate-limit-sliding.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rate-limit-sliding.d.ts","sourceRoot":"","sources":["../../src/middleware/rate-limit-sliding.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,OAAO,EAA0B,cAAc,EAAE,MAAM,SAAS,CAAC;AAI/E,MAAM,WAAW,oBAAoB;IACnC,gDAAgD;IAChD,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,0DAA0D;IAC1D,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,wCAAwC;IACxC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gEAAgE;IAChE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,uDAAuD;IACvD,YAAY,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,MAAM,CAAC;IACxC,0DAA0D;IAC1D,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,OAAO,CAAC;CAClC;AAOD,MAAM,WAAW,uBAAwB,SAAQ,cAAc;IAC7D,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,0BAA0B,CAAC,OAAO,GAAE,oBAAyB,GAAG,uBAAuB,CAiGtG"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module @arcis/node/middleware/rate-limit-token
|
|
3
|
+
* Token bucket rate limiting middleware.
|
|
4
|
+
*
|
|
5
|
+
* Allows burst traffic while enforcing an average rate.
|
|
6
|
+
* Tokens refill at a steady rate. Each request costs 1 token.
|
|
7
|
+
*
|
|
8
|
+
* Algorithm:
|
|
9
|
+
* tokens = min(capacity, tokens + elapsed * refillRate)
|
|
10
|
+
* if tokens >= cost: allow, subtract cost
|
|
11
|
+
* else: deny
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* app.use(createTokenBucketLimiter({ capacity: 50, refillRate: 10 }));
|
|
15
|
+
*/
|
|
16
|
+
import type { Request, RequestHandler } from 'express';
|
|
17
|
+
export interface TokenBucketOptions {
|
|
18
|
+
/** Maximum tokens (burst size). Default: 100 */
|
|
19
|
+
capacity?: number;
|
|
20
|
+
/** Tokens added per second. Default: 10 */
|
|
21
|
+
refillRate?: number;
|
|
22
|
+
/** Tokens consumed per request. Default: 1 */
|
|
23
|
+
cost?: number;
|
|
24
|
+
/** Error message when limit exceeded */
|
|
25
|
+
message?: string;
|
|
26
|
+
/** HTTP status code for rate limited responses. Default: 429 */
|
|
27
|
+
statusCode?: number;
|
|
28
|
+
/** Function to generate rate limit key from request */
|
|
29
|
+
keyGenerator?: (req: Request) => string;
|
|
30
|
+
/** Function to skip rate limiting for certain requests */
|
|
31
|
+
skip?: (req: Request) => boolean;
|
|
32
|
+
}
|
|
33
|
+
export interface TokenBucketMiddleware extends RequestHandler {
|
|
34
|
+
close: () => void;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Create token bucket rate limiter middleware.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* // Allow bursts of 50, sustained rate of 10/sec
|
|
41
|
+
* app.use(createTokenBucketLimiter({ capacity: 50, refillRate: 10 }));
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* // Strict API: 5 requests burst, 1/sec sustained
|
|
45
|
+
* app.use('/api/expensive', createTokenBucketLimiter({
|
|
46
|
+
* capacity: 5,
|
|
47
|
+
* refillRate: 1,
|
|
48
|
+
* }));
|
|
49
|
+
*/
|
|
50
|
+
export declare function createTokenBucketLimiter(options?: TokenBucketOptions): TokenBucketMiddleware;
|
|
51
|
+
//# sourceMappingURL=rate-limit-token.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rate-limit-token.d.ts","sourceRoot":"","sources":["../../src/middleware/rate-limit-token.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,OAAO,EAA0B,cAAc,EAAE,MAAM,SAAS,CAAC;AAG/E,MAAM,WAAW,kBAAkB;IACjC,gDAAgD;IAChD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,2CAA2C;IAC3C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,8CAA8C;IAC9C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,wCAAwC;IACxC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gEAAgE;IAChE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,uDAAuD;IACvD,YAAY,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,MAAM,CAAC;IACxC,0DAA0D;IAC1D,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,OAAO,CAAC;CAClC;AAOD,MAAM,WAAW,qBAAsB,SAAQ,cAAc;IAC3D,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,GAAE,kBAAuB,GAAG,qBAAqB,CA2FhG"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module @arcis/node/middleware/rate-limit
|
|
3
|
+
* Rate limiting middleware
|
|
4
|
+
*/
|
|
5
|
+
import type { RateLimitOptions, RateLimiterMiddleware } from '../core/types';
|
|
6
|
+
/**
|
|
7
|
+
* Create Express middleware for rate limiting.
|
|
8
|
+
*
|
|
9
|
+
* @param options - Rate limit configuration
|
|
10
|
+
* @returns Express middleware with cleanup method
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* app.use(createRateLimiter({ max: 100, windowMs: 60000 }));
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* // Skip rate limiting for certain routes
|
|
17
|
+
* app.use(createRateLimiter({
|
|
18
|
+
* max: 50,
|
|
19
|
+
* skip: (req) => req.path === '/health'
|
|
20
|
+
* }));
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* // Cleanup on shutdown
|
|
24
|
+
* const limiter = createRateLimiter();
|
|
25
|
+
* app.use(limiter);
|
|
26
|
+
* process.on('SIGTERM', () => limiter.close());
|
|
27
|
+
*/
|
|
28
|
+
export declare function createRateLimiter(options?: RateLimitOptions): RateLimiterMiddleware;
|
|
29
|
+
/**
|
|
30
|
+
* Alias for createRateLimiter
|
|
31
|
+
* @see createRateLimiter
|
|
32
|
+
*/
|
|
33
|
+
export declare const rateLimit: typeof createRateLimiter;
|
|
34
|
+
//# sourceMappingURL=rate-limit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rate-limit.d.ts","sourceRoot":"","sources":["../../src/middleware/rate-limit.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,gBAAgB,EAAE,qBAAqB,EAAkB,MAAM,eAAe,CAAC;AAO7F;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,GAAE,gBAAqB,GAAG,qBAAqB,CAiHvF;AAED;;;GAGG;AACH,eAAO,MAAM,SAAS,0BAAoB,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module @arcis/node/sanitizers/command
|
|
3
|
+
* Command injection prevention
|
|
4
|
+
*/
|
|
5
|
+
import type { SanitizeResult } from '../core/types';
|
|
6
|
+
/**
|
|
7
|
+
* Sanitizes a string to prevent command injection attacks.
|
|
8
|
+
* Replaces shell metacharacters and dangerous commands with [BLOCKED].
|
|
9
|
+
*
|
|
10
|
+
* @param input - The string to sanitize
|
|
11
|
+
* @param collectThreats - Whether to collect threat information (default: false for performance)
|
|
12
|
+
* @returns Sanitized string or SanitizeResult if collectThreats is true
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* sanitizeCommand("file.txt; rm -rf /")
|
|
16
|
+
* // Returns: "file.txt rm -rf /"
|
|
17
|
+
*/
|
|
18
|
+
export declare function sanitizeCommand(input: string, collectThreats?: false): string;
|
|
19
|
+
export declare function sanitizeCommand(input: string, collectThreats: true): SanitizeResult;
|
|
20
|
+
/**
|
|
21
|
+
* Checks if a string contains command injection patterns.
|
|
22
|
+
* Does not sanitize — use sanitizeCommand() for that.
|
|
23
|
+
*
|
|
24
|
+
* @param input - The string to check
|
|
25
|
+
* @returns True if command injection patterns detected
|
|
26
|
+
*/
|
|
27
|
+
export declare function detectCommandInjection(input: string): boolean;
|
|
28
|
+
//# sourceMappingURL=command.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../src/sanitizers/command.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAc,MAAM,eAAe,CAAC;AAEhE;;;;;;;;;;;GAWG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;AAC/E,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,IAAI,GAAG,cAAc,CAAC;AA4CrF;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAW7D"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module @arcis/node/sanitizers/encode
|
|
3
|
+
* Context-aware output encoding for XSS prevention.
|
|
4
|
+
*
|
|
5
|
+
* Wrong-context encoding is the #1 cause of XSS bypasses in "protected" apps.
|
|
6
|
+
* A single sanitize() is not enough when output goes to JS, CSS, or attribute contexts.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Encodes for HTML body context. Entity-encodes & < > " '
|
|
10
|
+
*
|
|
11
|
+
* Use when outputting to HTML element content:
|
|
12
|
+
* `<p>${encodeForHtml(userInput)}</p>`
|
|
13
|
+
*/
|
|
14
|
+
export declare function encodeForHtml(value: string): string;
|
|
15
|
+
/**
|
|
16
|
+
* Encodes for HTML attribute context.
|
|
17
|
+
* All non-alphanumeric characters are encoded as `&#xHH;` hex entities.
|
|
18
|
+
*
|
|
19
|
+
* Use when outputting to HTML attributes:
|
|
20
|
+
* `<div title="${encodeForAttribute(userInput)}">`
|
|
21
|
+
*/
|
|
22
|
+
export declare function encodeForAttribute(value: string): string;
|
|
23
|
+
/**
|
|
24
|
+
* Encodes for JavaScript string context.
|
|
25
|
+
* Non-alphanumeric characters are escaped as `\xHH` (ASCII) or `\uHHHH` (Unicode).
|
|
26
|
+
*
|
|
27
|
+
* Use when embedding in JS string literals:
|
|
28
|
+
* `var x = '${encodeForJs(userInput)}';`
|
|
29
|
+
*/
|
|
30
|
+
export declare function encodeForJs(value: string): string;
|
|
31
|
+
/**
|
|
32
|
+
* Encodes for URL parameter context. Percent-encodes all non-unreserved chars.
|
|
33
|
+
*
|
|
34
|
+
* Use when building query strings:
|
|
35
|
+
* `?q=${encodeForUrl(userInput)}`
|
|
36
|
+
*/
|
|
37
|
+
export declare function encodeForUrl(value: string): string;
|
|
38
|
+
/**
|
|
39
|
+
* Encodes for CSS value context.
|
|
40
|
+
* Non-alphanumeric characters are hex-escaped as `\HH ` (trailing space per CSS spec).
|
|
41
|
+
*
|
|
42
|
+
* Use when embedding in CSS values:
|
|
43
|
+
* `content: '${encodeForCss(userInput)}';`
|
|
44
|
+
*/
|
|
45
|
+
export declare function encodeForCss(value: string): string;
|
|
46
|
+
//# sourceMappingURL=encode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encode.d.ts","sourceRoot":"","sources":["../../src/sanitizers/encode.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAaH;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAGnD;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAiBxD;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAmBjD;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAOlD;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAkBlD"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module @arcis/node/sanitizers/headers
|
|
3
|
+
* HTTP Header Injection & CRLF Injection prevention
|
|
4
|
+
*
|
|
5
|
+
* Prevents attackers from injecting newline characters (\r\n) into HTTP header
|
|
6
|
+
* values, which can lead to response splitting, session fixation, XSS via
|
|
7
|
+
* injected headers, and cache poisoning.
|
|
8
|
+
*/
|
|
9
|
+
import type { SanitizeResult } from '../core/types';
|
|
10
|
+
/**
|
|
11
|
+
* Sanitizes a header value by stripping CRLF sequences, bare CR/LF, and null bytes.
|
|
12
|
+
*
|
|
13
|
+
* @param input - The header value to sanitize
|
|
14
|
+
* @param collectThreats - Whether to collect threat information (default: false)
|
|
15
|
+
* @returns Sanitized string or SanitizeResult if collectThreats is true
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* sanitizeHeaderValue("safe-value")
|
|
19
|
+
* // Returns: "safe-value"
|
|
20
|
+
*
|
|
21
|
+
* sanitizeHeaderValue("value\r\nX-Injected: evil")
|
|
22
|
+
* // Returns: "valueX-Injected: evil"
|
|
23
|
+
*/
|
|
24
|
+
export declare function sanitizeHeaderValue(input: string, collectThreats?: false): string;
|
|
25
|
+
export declare function sanitizeHeaderValue(input: string, collectThreats: true): SanitizeResult;
|
|
26
|
+
/**
|
|
27
|
+
* Sanitizes an object of header key-value pairs.
|
|
28
|
+
* Strips CRLF/null bytes from both keys and values.
|
|
29
|
+
*
|
|
30
|
+
* @param headers - Object with header names as keys and header values as values
|
|
31
|
+
* @returns New object with sanitized header names and values
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* sanitizeHeaders({ "X-Custom": "safe", "X-Bad\r\n": "value\r\ninjected" })
|
|
35
|
+
* // Returns: { "X-Custom": "safe", "X-Bad": "valueinjected" }
|
|
36
|
+
*/
|
|
37
|
+
export declare function sanitizeHeaders(headers: Record<string, string>): Record<string, string>;
|
|
38
|
+
/**
|
|
39
|
+
* Checks if a string contains HTTP header injection patterns (CRLF, null bytes).
|
|
40
|
+
* Does not sanitize — use sanitizeHeaderValue() for that.
|
|
41
|
+
*
|
|
42
|
+
* @param input - The string to check
|
|
43
|
+
* @returns True if header injection patterns detected
|
|
44
|
+
*/
|
|
45
|
+
export declare function detectHeaderInjection(input: string): boolean;
|
|
46
|
+
//# sourceMappingURL=headers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"headers.d.ts","sourceRoot":"","sources":["../../src/sanitizers/headers.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAc,MAAM,eAAe,CAAC;AAUhE;;;;;;;;;;;;;GAaG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;AACnF,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,IAAI,GAAG,cAAc,CAAC;AAuCzF;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAcvF;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAK5D"}
|
|
@@ -1,24 +1,19 @@
|
|
|
1
|
-
export { c as createSanitizer, d as detectCommandInjection, a as detectHeaderInjection, b as detectJsonpInjection, e as detectNoSqlInjection, f as detectPathTraversal, g as detectPii, h as detectPrototypePollution, i as detectSql, j as detectSsti, k as detectXss, l as detectXxe, m as encodeForAttribute, n as encodeForCss, o as encodeForHtml, p as encodeForJs, q as encodeForUrl, r as getDangerousOperators, s as getDangerousProtoKeys, t as isDangerousNoSqlKey, u as isDangerousProtoKey, v as redactObjectPii, w as redactPii, x as sanitizeCommand, y as sanitizeHeaderValue, z as sanitizeHeaders, A as sanitizeJsonpCallback, B as sanitizeObject, C as sanitizePath, D as sanitizeSql, E as sanitizeSsti, F as sanitizeString, G as sanitizeXss, H as sanitizeXxe, I as scanObjectPii, J as scanPii } from '../encode-jl9sOwmA.js';
|
|
2
|
-
import 'express';
|
|
3
|
-
import '../types-BOkx5YJc.js';
|
|
4
|
-
|
|
5
1
|
/**
|
|
6
|
-
* @module @arcis/node/sanitizers
|
|
7
|
-
*
|
|
2
|
+
* @module @arcis/node/sanitizers
|
|
3
|
+
* All sanitization functions for Arcis
|
|
8
4
|
*/
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
export { encodeHtmlEntities, isPlainObject };
|
|
5
|
+
export { sanitizeString, sanitizeObject, createSanitizer } from './sanitize';
|
|
6
|
+
export { sanitizeXss, detectXss } from './xss';
|
|
7
|
+
export { sanitizeSql, detectSql } from './sql';
|
|
8
|
+
export { sanitizePath, detectPathTraversal } from './path';
|
|
9
|
+
export { sanitizeCommand, detectCommandInjection } from './command';
|
|
10
|
+
export { isDangerousNoSqlKey, detectNoSqlInjection, getDangerousOperators } from './nosql';
|
|
11
|
+
export { isDangerousProtoKey, detectPrototypePollution, getDangerousProtoKeys } from './prototype';
|
|
12
|
+
export { sanitizeSsti, detectSsti } from './ssti';
|
|
13
|
+
export { sanitizeXxe, detectXxe } from './xxe';
|
|
14
|
+
export { sanitizeJsonpCallback, detectJsonpInjection } from './jsonp';
|
|
15
|
+
export { sanitizeHeaderValue, sanitizeHeaders, detectHeaderInjection } from './headers';
|
|
16
|
+
export { scanPii, detectPii, redactPii, scanObjectPii, redactObjectPii } from './pii';
|
|
17
|
+
export { encodeForHtml, encodeForAttribute, encodeForJs, encodeForUrl, encodeForCss } from './encode';
|
|
18
|
+
export { encodeHtmlEntities, isPlainObject } from './utils';
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/sanitizers/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAG7E,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,QAAQ,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AAGpE,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAG3F,OAAO,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAGnG,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAGlD,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAG/C,OAAO,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAGtE,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAGxF,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,OAAO,CAAC;AAGtF,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,WAAW,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAGtG,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module @arcis/node/sanitizers/jsonp
|
|
3
|
+
* JSONP callback sanitization to prevent XSS via callback parameters
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Validates and sanitizes a JSONP callback parameter.
|
|
7
|
+
*
|
|
8
|
+
* Returns the callback name if safe, or null if the callback is dangerous.
|
|
9
|
+
* Use this to validate `?callback=` query parameters before wrapping responses.
|
|
10
|
+
*
|
|
11
|
+
* @param callback - The callback parameter value
|
|
12
|
+
* @param maxLength - Maximum allowed length (default: 128)
|
|
13
|
+
* @returns The safe callback name, or null if invalid
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* const cb = sanitizeJsonpCallback(req.query.callback);
|
|
18
|
+
* if (cb) {
|
|
19
|
+
* res.set('Content-Type', 'application/javascript');
|
|
20
|
+
* res.send(`${cb}(${JSON.stringify(data)})`);
|
|
21
|
+
* } else {
|
|
22
|
+
* res.status(400).json({ error: 'Invalid callback' });
|
|
23
|
+
* }
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare function sanitizeJsonpCallback(callback: string, maxLength?: number): string | null;
|
|
27
|
+
/**
|
|
28
|
+
* Checks if a JSONP callback parameter contains potentially dangerous content.
|
|
29
|
+
*
|
|
30
|
+
* @param callback - The callback parameter value
|
|
31
|
+
* @returns True if the callback is dangerous / invalid
|
|
32
|
+
*/
|
|
33
|
+
export declare function detectJsonpInjection(callback: string): boolean;
|
|
34
|
+
//# sourceMappingURL=jsonp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsonp.d.ts","sourceRoot":"","sources":["../../src/sanitizers/jsonp.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAiBH;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,SAAM,GAAG,MAAM,GAAG,IAAI,CAoBtF;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAiB9D"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module @arcis/node/sanitizers/nosql
|
|
3
|
+
* NoSQL injection prevention (MongoDB operators)
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Checks if a key is a dangerous MongoDB operator.
|
|
7
|
+
*
|
|
8
|
+
* @param key - The key to check
|
|
9
|
+
* @returns True if the key is a MongoDB operator
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* isDangerousNoSqlKey('$gt') // true
|
|
13
|
+
* isDangerousNoSqlKey('name') // false
|
|
14
|
+
*/
|
|
15
|
+
export declare function isDangerousNoSqlKey(key: string): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Recursively checks if an object contains dangerous MongoDB operators.
|
|
18
|
+
*
|
|
19
|
+
* @param obj - The object to check
|
|
20
|
+
* @param maxDepth - Maximum recursion depth (default: 10)
|
|
21
|
+
* @returns True if dangerous operators found
|
|
22
|
+
*/
|
|
23
|
+
export declare function detectNoSqlInjection(obj: unknown, maxDepth?: number): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Get list of all MongoDB operators considered dangerous.
|
|
26
|
+
* Useful for documentation or custom validation.
|
|
27
|
+
*
|
|
28
|
+
* @returns Array of dangerous operator strings
|
|
29
|
+
*/
|
|
30
|
+
export declare function getDangerousOperators(): string[];
|
|
31
|
+
//# sourceMappingURL=nosql.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nosql.d.ts","sourceRoot":"","sources":["../../src/sanitizers/nosql.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAExD;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,OAAO,EAAE,QAAQ,SAAK,GAAG,OAAO,CAsBzE;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,IAAI,MAAM,EAAE,CAEhD"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module @arcis/node/sanitizers/path
|
|
3
|
+
* Path traversal prevention
|
|
4
|
+
*/
|
|
5
|
+
import type { SanitizeResult } from '../core/types';
|
|
6
|
+
/**
|
|
7
|
+
* Sanitizes a string to prevent path traversal attacks.
|
|
8
|
+
* Removes ../ and ..\ patterns (including URL-encoded variants).
|
|
9
|
+
*
|
|
10
|
+
* @param input - The string to sanitize
|
|
11
|
+
* @param collectThreats - Whether to collect threat information (default: false for performance)
|
|
12
|
+
* @returns Sanitized string or SanitizeResult if collectThreats is true
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* sanitizePath("../../etc/passwd")
|
|
16
|
+
* // Returns: "etc/passwd"
|
|
17
|
+
*/
|
|
18
|
+
export declare function sanitizePath(input: string, collectThreats?: false): string;
|
|
19
|
+
export declare function sanitizePath(input: string, collectThreats: true): SanitizeResult;
|
|
20
|
+
/**
|
|
21
|
+
* Checks if a string contains path traversal patterns.
|
|
22
|
+
* Does not sanitize — use sanitizePath() for that.
|
|
23
|
+
*
|
|
24
|
+
* @param input - The string to check
|
|
25
|
+
* @returns True if path traversal patterns detected
|
|
26
|
+
*/
|
|
27
|
+
export declare function detectPathTraversal(input: string): boolean;
|
|
28
|
+
//# sourceMappingURL=path.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path.d.ts","sourceRoot":"","sources":["../../src/sanitizers/path.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAc,MAAM,eAAe,CAAC;AAEhE;;;;;;;;;;;GAWG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;AAC5E,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,IAAI,GAAG,cAAc,CAAC;AA4ClF;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAW1D"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module @arcis/node/sanitizers/pii
|
|
3
|
+
* PII (Personally Identifiable Information) detection and redaction
|
|
4
|
+
*
|
|
5
|
+
* Detects: email addresses, phone numbers, credit card numbers, SSNs, IP addresses
|
|
6
|
+
*/
|
|
7
|
+
export type PiiType = 'email' | 'phone' | 'credit_card' | 'ssn' | 'ip_address';
|
|
8
|
+
export interface PiiMatch {
|
|
9
|
+
type: PiiType;
|
|
10
|
+
value: string;
|
|
11
|
+
start: number;
|
|
12
|
+
end: number;
|
|
13
|
+
}
|
|
14
|
+
export interface PiiScanOptions {
|
|
15
|
+
/** PII types to scan for. Default: all types */
|
|
16
|
+
types?: PiiType[];
|
|
17
|
+
}
|
|
18
|
+
export interface PiiRedactOptions extends PiiScanOptions {
|
|
19
|
+
/** Replacement for redacted values. Default: '[REDACTED]' */
|
|
20
|
+
replacement?: string;
|
|
21
|
+
/** Use type-specific replacements like '[EMAIL]', '[SSN]'. Default: false */
|
|
22
|
+
typeLabels?: boolean;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Scan a string for PII and return all matches.
|
|
26
|
+
*
|
|
27
|
+
* @param input - String to scan
|
|
28
|
+
* @param options - Optional scan configuration
|
|
29
|
+
* @returns Array of PII matches with type, value, and position
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* scanPii('Call me at 555-123-4567 or email john@example.com')
|
|
33
|
+
* // [
|
|
34
|
+
* // { type: 'phone', value: '555-123-4567', start: 11, end: 23 },
|
|
35
|
+
* // { type: 'email', value: 'john@example.com', start: 33, end: 49 }
|
|
36
|
+
* // ]
|
|
37
|
+
*/
|
|
38
|
+
export declare function scanPii(input: string, options?: PiiScanOptions): PiiMatch[];
|
|
39
|
+
/**
|
|
40
|
+
* Check if a string contains any PII.
|
|
41
|
+
*
|
|
42
|
+
* @param input - String to check
|
|
43
|
+
* @param options - Optional scan configuration
|
|
44
|
+
* @returns true if PII is detected
|
|
45
|
+
*/
|
|
46
|
+
export declare function detectPii(input: string, options?: PiiScanOptions): boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Redact PII from a string, replacing matches with a placeholder.
|
|
49
|
+
*
|
|
50
|
+
* @param input - String to redact
|
|
51
|
+
* @param options - Redaction options
|
|
52
|
+
* @returns String with PII replaced
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* redactPii('Email: john@example.com, SSN: 123-45-6789')
|
|
56
|
+
* // 'Email: [REDACTED], SSN: [REDACTED]'
|
|
57
|
+
*
|
|
58
|
+
* redactPii('Email: john@example.com', { typeLabels: true })
|
|
59
|
+
* // 'Email: [EMAIL]'
|
|
60
|
+
*/
|
|
61
|
+
export declare function redactPii(input: string, options?: PiiRedactOptions): string;
|
|
62
|
+
/**
|
|
63
|
+
* Scan an object's string values for PII recursively.
|
|
64
|
+
*
|
|
65
|
+
* @param obj - Object to scan
|
|
66
|
+
* @param options - Optional scan configuration
|
|
67
|
+
* @returns Array of PII matches with the field path prepended
|
|
68
|
+
*/
|
|
69
|
+
export declare function scanObjectPii(obj: Record<string, unknown>, options?: PiiScanOptions, path?: string): (PiiMatch & {
|
|
70
|
+
field: string;
|
|
71
|
+
})[];
|
|
72
|
+
/**
|
|
73
|
+
* Redact PII from all string values in an object recursively.
|
|
74
|
+
*
|
|
75
|
+
* @param obj - Object to redact
|
|
76
|
+
* @param options - Redaction options
|
|
77
|
+
* @returns New object with PII redacted
|
|
78
|
+
*/
|
|
79
|
+
export declare function redactObjectPii<T extends Record<string, unknown>>(obj: T, options?: PiiRedactOptions): T;
|
|
80
|
+
//# sourceMappingURL=pii.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pii.d.ts","sourceRoot":"","sources":["../../src/sanitizers/pii.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,MAAM,MAAM,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,aAAa,GAAG,KAAK,GAAG,YAAY,CAAC;AAE/E,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,cAAc;IAC7B,gDAAgD;IAChD,KAAK,CAAC,EAAE,OAAO,EAAE,CAAC;CACnB;AAED,MAAM,WAAW,gBAAiB,SAAQ,cAAc;IACtD,6DAA6D;IAC7D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,6EAA6E;IAC7E,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAkED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,GAAE,cAAmB,GAAG,QAAQ,EAAE,CAuC/E;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,GAAE,cAAmB,GAAG,OAAO,CAE9E;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,GAAE,gBAAqB,GAAG,MAAM,CAiB/E;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAC3B,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5B,OAAO,GAAE,cAAmB,EAC5B,IAAI,SAAK,GACR,CAAC,QAAQ,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,EAAE,CA8BlC;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/D,GAAG,EAAE,CAAC,EACN,OAAO,GAAE,gBAAqB,GAC7B,CAAC,CAsBH"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module @arcis/node/sanitizers/prototype
|
|
3
|
+
* Prototype pollution prevention
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Checks if a key is dangerous for prototype pollution.
|
|
7
|
+
* Case-insensitive — catches __PROTO__, Constructor, etc.
|
|
8
|
+
*
|
|
9
|
+
* @param key - The key to check
|
|
10
|
+
* @returns True if the key could cause prototype pollution
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* isDangerousProtoKey('__proto__') // true
|
|
14
|
+
* isDangerousProtoKey('__PROTO__') // true
|
|
15
|
+
* isDangerousProtoKey('Constructor') // true
|
|
16
|
+
* isDangerousProtoKey('name') // false
|
|
17
|
+
*/
|
|
18
|
+
export declare function isDangerousProtoKey(key: string): boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Recursively checks if an object contains prototype pollution keys.
|
|
21
|
+
*
|
|
22
|
+
* @param obj - The object to check
|
|
23
|
+
* @param maxDepth - Maximum recursion depth (default: 10)
|
|
24
|
+
* @returns True if dangerous keys found
|
|
25
|
+
*/
|
|
26
|
+
export declare function detectPrototypePollution(obj: unknown, maxDepth?: number): boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Get list of all keys considered dangerous for prototype pollution.
|
|
29
|
+
* Useful for documentation or custom validation.
|
|
30
|
+
*
|
|
31
|
+
* @returns Array of dangerous key strings
|
|
32
|
+
*/
|
|
33
|
+
export declare function getDangerousProtoKeys(): string[];
|
|
34
|
+
//# sourceMappingURL=prototype.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prototype.d.ts","sourceRoot":"","sources":["../../src/sanitizers/prototype.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH;;;;;;;;;;;;GAYG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAExD;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,OAAO,EAAE,QAAQ,SAAK,GAAG,OAAO,CAsB7E;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,IAAI,MAAM,EAAE,CAEhD"}
|