@arcis/node 1.2.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.
Files changed (122) hide show
  1. package/dist/core/{index.d.mts → constants.d.ts} +21 -70
  2. package/dist/core/constants.d.ts.map +1 -0
  3. package/dist/core/errors.d.ts +53 -0
  4. package/dist/core/errors.d.ts.map +1 -0
  5. package/dist/core/index.d.ts +6 -168
  6. package/dist/core/index.d.ts.map +1 -0
  7. package/dist/{types-CsOFHoD9.d.mts → core/types.d.ts} +38 -31
  8. package/dist/core/types.d.ts.map +1 -0
  9. package/dist/index.d.ts +71 -166
  10. package/dist/index.d.ts.map +1 -0
  11. package/dist/index.js +151 -4
  12. package/dist/index.js.map +1 -1
  13. package/dist/index.mjs +145 -5
  14. package/dist/index.mjs.map +1 -1
  15. package/dist/logging/index.d.ts +4 -36
  16. package/dist/logging/index.d.ts.map +1 -0
  17. package/dist/logging/{index.d.mts → redactor.d.ts} +5 -9
  18. package/dist/logging/redactor.d.ts.map +1 -0
  19. package/dist/middleware/bot-detection.d.ts +86 -0
  20. package/dist/middleware/bot-detection.d.ts.map +1 -0
  21. package/dist/middleware/cookies.d.ts +48 -0
  22. package/dist/middleware/cookies.d.ts.map +1 -0
  23. package/dist/middleware/cors.d.ts +65 -0
  24. package/dist/middleware/cors.d.ts.map +1 -0
  25. package/dist/middleware/csrf.d.ts +109 -0
  26. package/dist/middleware/csrf.d.ts.map +1 -0
  27. package/dist/middleware/error-handler.d.ts +43 -0
  28. package/dist/middleware/error-handler.d.ts.map +1 -0
  29. package/dist/middleware/headers.d.ts +29 -0
  30. package/dist/middleware/headers.d.ts.map +1 -0
  31. package/dist/middleware/hpp.d.ts +56 -0
  32. package/dist/middleware/hpp.d.ts.map +1 -0
  33. package/dist/middleware/index.d.ts +16 -3
  34. package/dist/middleware/index.d.ts.map +1 -0
  35. package/dist/middleware/index.js +28 -3
  36. package/dist/middleware/index.js.map +1 -1
  37. package/dist/middleware/index.mjs +28 -3
  38. package/dist/middleware/index.mjs.map +1 -1
  39. package/dist/middleware/main.d.ts +40 -0
  40. package/dist/middleware/main.d.ts.map +1 -0
  41. package/dist/middleware/rate-limit-sliding.d.ts +46 -0
  42. package/dist/middleware/rate-limit-sliding.d.ts.map +1 -0
  43. package/dist/middleware/rate-limit-token.d.ts +51 -0
  44. package/dist/middleware/rate-limit-token.d.ts.map +1 -0
  45. package/dist/middleware/rate-limit.d.ts +34 -0
  46. package/dist/middleware/rate-limit.d.ts.map +1 -0
  47. package/dist/sanitizers/command.d.ts +28 -0
  48. package/dist/sanitizers/command.d.ts.map +1 -0
  49. package/dist/sanitizers/encode.d.ts +46 -0
  50. package/dist/sanitizers/encode.d.ts.map +1 -0
  51. package/dist/sanitizers/headers.d.ts +46 -0
  52. package/dist/sanitizers/headers.d.ts.map +1 -0
  53. package/dist/sanitizers/index.d.ts +17 -22
  54. package/dist/sanitizers/index.d.ts.map +1 -0
  55. package/dist/sanitizers/index.js +72 -0
  56. package/dist/sanitizers/index.js.map +1 -1
  57. package/dist/sanitizers/index.mjs +68 -1
  58. package/dist/sanitizers/index.mjs.map +1 -1
  59. package/dist/sanitizers/jsonp.d.ts +34 -0
  60. package/dist/sanitizers/jsonp.d.ts.map +1 -0
  61. package/dist/sanitizers/nosql.d.ts +31 -0
  62. package/dist/sanitizers/nosql.d.ts.map +1 -0
  63. package/dist/sanitizers/path.d.ts +28 -0
  64. package/dist/sanitizers/path.d.ts.map +1 -0
  65. package/dist/sanitizers/pii.d.ts +80 -0
  66. package/dist/sanitizers/pii.d.ts.map +1 -0
  67. package/dist/sanitizers/prototype.d.ts +34 -0
  68. package/dist/sanitizers/prototype.d.ts.map +1 -0
  69. package/dist/sanitizers/sanitize.d.ts +51 -0
  70. package/dist/sanitizers/sanitize.d.ts.map +1 -0
  71. package/dist/sanitizers/sql.d.ts +28 -0
  72. package/dist/sanitizers/sql.d.ts.map +1 -0
  73. package/dist/sanitizers/ssti.d.ts +20 -0
  74. package/dist/sanitizers/ssti.d.ts.map +1 -0
  75. package/dist/sanitizers/utils.d.ts +19 -0
  76. package/dist/sanitizers/utils.d.ts.map +1 -0
  77. package/dist/sanitizers/xss.d.ts +35 -0
  78. package/dist/sanitizers/xss.d.ts.map +1 -0
  79. package/dist/sanitizers/xxe.d.ts +20 -0
  80. package/dist/sanitizers/xxe.d.ts.map +1 -0
  81. package/dist/stores/index.d.ts +6 -104
  82. package/dist/stores/index.d.ts.map +1 -0
  83. package/dist/stores/memory.d.ts +35 -0
  84. package/dist/stores/memory.d.ts.map +1 -0
  85. package/dist/stores/{index.d.mts → redis.d.ts} +6 -45
  86. package/dist/stores/redis.d.ts.map +1 -0
  87. package/dist/utils/duration.d.ts +34 -0
  88. package/dist/utils/duration.d.ts.map +1 -0
  89. package/dist/utils/fingerprint.d.ts +64 -0
  90. package/dist/utils/fingerprint.d.ts.map +1 -0
  91. package/dist/utils/index.d.ts +10 -0
  92. package/dist/utils/index.d.ts.map +1 -0
  93. package/dist/utils/index.js +188 -0
  94. package/dist/utils/index.js.map +1 -0
  95. package/dist/utils/index.mjs +182 -0
  96. package/dist/utils/index.mjs.map +1 -0
  97. package/dist/utils/ip.d.ts +70 -0
  98. package/dist/utils/ip.d.ts.map +1 -0
  99. package/dist/validation/email.d.ts +82 -0
  100. package/dist/validation/email.d.ts.map +1 -0
  101. package/dist/validation/file.d.ts +90 -0
  102. package/dist/validation/file.d.ts.map +1 -0
  103. package/dist/validation/index.d.ts +10 -3
  104. package/dist/validation/index.d.ts.map +1 -0
  105. package/dist/validation/redirect.d.ts +64 -0
  106. package/dist/validation/redirect.d.ts.map +1 -0
  107. package/dist/validation/schema.d.ts +36 -0
  108. package/dist/validation/schema.d.ts.map +1 -0
  109. package/dist/validation/url.d.ts +65 -0
  110. package/dist/validation/url.d.ts.map +1 -0
  111. package/package.json +8 -6
  112. package/dist/index-A-m-pPeW.d.mts +0 -340
  113. package/dist/index-CgK94hY_.d.mts +0 -532
  114. package/dist/index-Co5kPRZz.d.ts +0 -340
  115. package/dist/index-D_bdJcF0.d.ts +0 -532
  116. package/dist/index.d.mts +0 -175
  117. package/dist/middleware/index.d.mts +0 -3
  118. package/dist/pii-CXcHMlnX.d.mts +0 -438
  119. package/dist/pii-DhNpl7M3.d.ts +0 -438
  120. package/dist/sanitizers/index.d.mts +0 -24
  121. package/dist/types-CsOFHoD9.d.ts +0 -269
  122. package/dist/validation/index.d.mts +0 -3
@@ -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"}
@@ -0,0 +1,51 @@
1
+ /**
2
+ * @module @arcis/node/sanitizers/sanitize
3
+ * Main sanitization functions that combine all sanitizers
4
+ */
5
+ import type { RequestHandler } from 'express';
6
+ import type { SanitizeOptions } from '../core/types';
7
+ /**
8
+ * Sanitize a string value against multiple attack vectors.
9
+ *
10
+ * Order matters: We do XSS encoding LAST because:
11
+ * 1. Other sanitizers need to see the original patterns (e.g., SQL keywords)
12
+ * 2. HTML encoding is the final safe output transformation
13
+ * 3. Encoded entities like &lt; shouldn't be treated as SQL/command threats
14
+ *
15
+ * @param value - The string to sanitize
16
+ * @param options - Sanitization options
17
+ * @returns The sanitized string
18
+ *
19
+ * @example
20
+ * sanitizeString("<script>alert('xss')</script>")
21
+ * // Returns: "&lt;script&gt;alert(&#x27;xss&#x27;)&lt;/script&gt;"
22
+ *
23
+ * @example
24
+ * sanitizeString("../../etc/passwd")
25
+ * // Returns: "etc/passwd"
26
+ */
27
+ export declare function sanitizeString(value: string, options?: SanitizeOptions): string;
28
+ /**
29
+ * Sanitize an object recursively, including nested objects and arrays.
30
+ * Also removes prototype pollution and NoSQL injection keys.
31
+ *
32
+ * @param obj - The object to sanitize
33
+ * @param options - Sanitization options
34
+ * @returns The sanitized object
35
+ */
36
+ export declare function sanitizeObject(obj: unknown, options?: SanitizeOptions): unknown;
37
+ /**
38
+ * Create Express middleware for request sanitization.
39
+ * Sanitizes req.body, req.query, and req.params.
40
+ *
41
+ * @param options - Sanitization options
42
+ * @returns Express middleware
43
+ *
44
+ * @example
45
+ * app.use(createSanitizer());
46
+ *
47
+ * @example
48
+ * app.use(createSanitizer({ xss: true, sql: true, nosql: true }));
49
+ */
50
+ export declare function createSanitizer(options?: SanitizeOptions): RequestHandler;
51
+ //# sourceMappingURL=sanitize.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sanitize.d.ts","sourceRoot":"","sources":["../../src/sanitizers/sanitize.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAmC,cAAc,EAAE,MAAM,SAAS,CAAC;AAG/E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAMrD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,GAAE,eAAoB,GAAG,MAAM,CA8CnF;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,GAAE,eAAoB,GAAG,OAAO,CAQnF;AA+CD;;;;;;;;;;;;GAYG;AACH,wBAAgB,eAAe,CAAC,OAAO,GAAE,eAAoB,GAAG,cAAc,CAoB7E"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * @module @arcis/node/sanitizers/sql
3
+ * SQL injection prevention
4
+ */
5
+ import type { SanitizeResult } from '../core/types';
6
+ /**
7
+ * Sanitizes a string to prevent SQL injection attacks.
8
+ * Replaces dangerous SQL patterns 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
+ * sanitizeSql("'; DROP TABLE users; --")
16
+ * // Returns: "'; TABLE users "
17
+ */
18
+ export declare function sanitizeSql(input: string, collectThreats?: false): string;
19
+ export declare function sanitizeSql(input: string, collectThreats: true): SanitizeResult;
20
+ /**
21
+ * Checks if a string contains potential SQL injection patterns.
22
+ * Does not sanitize — use sanitizeSql() for that.
23
+ *
24
+ * @param input - The string to check
25
+ * @returns True if SQL injection patterns detected
26
+ */
27
+ export declare function detectSql(input: string): boolean;
28
+ //# sourceMappingURL=sql.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sql.d.ts","sourceRoot":"","sources":["../../src/sanitizers/sql.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAc,MAAM,eAAe,CAAC;AAEhE;;;;;;;;;;;GAWG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;AAC3E,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,IAAI,GAAG,cAAc,CAAC;AA8CjF;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAWhD"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * @module @arcis/node/sanitizers/ssti
3
+ * Server-Side Template Injection (SSTI) prevention
4
+ */
5
+ import type { SanitizeResult } from '../core/types';
6
+ /**
7
+ * Sanitizes a string to prevent SSTI attacks.
8
+ * Removes template expression syntax.
9
+ */
10
+ export declare function sanitizeSsti(input: string, collectThreats?: false): string;
11
+ export declare function sanitizeSsti(input: string, collectThreats: true): SanitizeResult;
12
+ /**
13
+ * Checks if a string contains SSTI patterns.
14
+ * Does not sanitize — use sanitizeSsti() for that.
15
+ *
16
+ * @param input - The string to check
17
+ * @returns True if SSTI patterns detected
18
+ */
19
+ export declare function detectSsti(input: string): boolean;
20
+ //# sourceMappingURL=ssti.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ssti.d.ts","sourceRoot":"","sources":["../../src/sanitizers/ssti.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAc,MAAM,eAAe,CAAC;AAkChE;;;GAGG;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;AA0ClF;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAWjD"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * @module @arcis/node/sanitizers/utils
3
+ * Shared utilities for sanitizers
4
+ */
5
+ /**
6
+ * Encodes HTML entities to prevent interpretation as markup.
7
+ *
8
+ * @param str - The string to encode
9
+ * @returns The encoded string
10
+ */
11
+ export declare function encodeHtmlEntities(str: string): string;
12
+ /**
13
+ * Checks if a value is a plain object (not null, array, Date, etc.)
14
+ *
15
+ * @param value - Value to check
16
+ * @returns True if plain object
17
+ */
18
+ export declare function isPlainObject(value: unknown): value is Record<string, unknown>;
19
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/sanitizers/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAOtD;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAS9E"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * @module @arcis/node/sanitizers/xss
3
+ * XSS (Cross-Site Scripting) prevention
4
+ */
5
+ import type { SanitizeResult } from '../core/types';
6
+ /**
7
+ * Sanitizes a string to prevent XSS attacks.
8
+ *
9
+ * Strategy:
10
+ * 1. Remove dangerous patterns (script tags, event handlers, etc.)
11
+ * 2. HTML-encode the remaining content
12
+ *
13
+ * @param input - The string to sanitize
14
+ * @param collectThreats - Whether to collect threat information (default: false for performance)
15
+ * @returns Sanitized string or SanitizeResult if collectThreats is true
16
+ *
17
+ * @example
18
+ * sanitizeXss("<script>alert('xss')</script>")
19
+ * // Returns: "&lt;script&gt;alert(&#x27;xss&#x27;)&lt;/script&gt;"
20
+ *
21
+ * @example
22
+ * sanitizeXss("<img onerror='alert(1)'>")
23
+ * // Returns: "&lt;img&gt;" (event handler removed)
24
+ */
25
+ export declare function sanitizeXss(input: string, collectThreats?: false, htmlEncode?: boolean): string;
26
+ export declare function sanitizeXss(input: string, collectThreats: true, htmlEncode?: boolean): SanitizeResult;
27
+ /**
28
+ * Checks if a string contains potential XSS patterns.
29
+ * Does not sanitize — use sanitizeXss() for that.
30
+ *
31
+ * @param input - The string to check
32
+ * @returns True if XSS patterns detected
33
+ */
34
+ export declare function detectXss(input: string): boolean;
35
+ //# sourceMappingURL=xss.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"xss.d.ts","sourceRoot":"","sources":["../../src/sanitizers/xss.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,cAAc,EAAc,MAAM,eAAe,CAAC;AAEhE;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,KAAK,EAAE,UAAU,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;AACjG,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,IAAI,EAAE,UAAU,CAAC,EAAE,OAAO,GAAG,cAAc,CAAC;AAwDvG;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAoBhD"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * @module @arcis/node/sanitizers/xxe
3
+ * XML External Entity (XXE) injection prevention
4
+ */
5
+ import type { SanitizeResult } from '../core/types';
6
+ /**
7
+ * Sanitizes a string to prevent XXE attacks.
8
+ * Removes DOCTYPE, ENTITY, and CDATA constructs.
9
+ */
10
+ export declare function sanitizeXxe(input: string, collectThreats?: false): string;
11
+ export declare function sanitizeXxe(input: string, collectThreats: true): SanitizeResult;
12
+ /**
13
+ * Checks if a string contains XXE patterns.
14
+ * Does not sanitize — use sanitizeXxe() for that.
15
+ *
16
+ * @param input - The string to check
17
+ * @returns True if XXE patterns detected
18
+ */
19
+ export declare function detectXxe(input: string): boolean;
20
+ //# sourceMappingURL=xxe.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"xxe.d.ts","sourceRoot":"","sources":["../../src/sanitizers/xxe.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAc,MAAM,eAAe,CAAC;AAiChE;;;GAGG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;AAC3E,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,IAAI,GAAG,cAAc,CAAC;AA0CjF;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAWhD"}
@@ -1,106 +1,8 @@
1
- import { g as RateLimitStore, R as RateLimitEntry } from '../types-CsOFHoD9.js';
2
- import 'express';
3
-
4
1
  /**
5
- * @module @arcis/node/stores/memory
6
- * In-memory rate limit store
2
+ * @module @arcis/node/stores
3
+ * Rate limit stores for Arcis
7
4
  */
8
-
9
- /**
10
- * In-memory rate limit store.
11
- * Suitable for single-instance deployments.
12
- * For distributed systems, use RedisStore or a custom store.
13
- *
14
- * @example
15
- * const store = new MemoryStore(60000); // 1 minute window
16
- * const limiter = createRateLimiter({ store });
17
- */
18
- declare class MemoryStore implements RateLimitStore {
19
- private store;
20
- private cleanupInterval;
21
- private windowMs;
22
- constructor(windowMs?: number);
23
- /**
24
- * Start the cleanup interval to remove expired entries.
25
- */
26
- private startCleanup;
27
- get(key: string): Promise<RateLimitEntry | null>;
28
- set(key: string, entry: RateLimitEntry): Promise<void>;
29
- increment(key: string): Promise<number>;
30
- decrement(key: string): Promise<void>;
31
- reset(key: string): Promise<void>;
32
- close(): Promise<void>;
33
- /**
34
- * Get current store size (for monitoring).
35
- */
36
- get size(): number;
37
- }
38
-
39
- /**
40
- * @module @arcis/node/stores/redis
41
- * Redis rate limit store
42
- *
43
- * Note: This is a reference implementation. You'll need to install
44
- * the 'ioredis' or 'redis' package and pass your client instance.
45
- */
46
-
47
- /** Generic Redis client interface (works with ioredis, redis, etc.) */
48
- interface RedisClientLike {
49
- get(key: string): Promise<string | null>;
50
- set(key: string, value: string, mode?: string, duration?: number): Promise<unknown>;
51
- setex(key: string, seconds: number, value: string): Promise<unknown>;
52
- expire(key: string, seconds: number): Promise<unknown>;
53
- incr(key: string): Promise<number>;
54
- decr(key: string): Promise<number>;
55
- del(key: string): Promise<number>;
56
- ttl(key: string): Promise<number>;
57
- quit?(): Promise<unknown>;
58
- disconnect?(): Promise<unknown>;
59
- }
60
- interface RedisStoreOptions {
61
- /** Redis client instance */
62
- client: RedisClientLike;
63
- /** Key prefix. Default: 'arcis:rl:' */
64
- prefix?: string;
65
- /** Window size in milliseconds. Default: 60000 */
66
- windowMs?: number;
67
- }
68
- /**
69
- * Redis rate limit store for distributed deployments.
70
- *
71
- * @example
72
- * import Redis from 'ioredis';
73
- *
74
- * const redis = new Redis();
75
- * const store = new RedisStore({ client: redis });
76
- * const limiter = createRateLimiter({ store });
77
- *
78
- * // Cleanup on shutdown
79
- * process.on('SIGTERM', async () => {
80
- * await store.close();
81
- * });
82
- */
83
- declare class RedisStore implements RateLimitStore {
84
- private client;
85
- private prefix;
86
- private windowMs;
87
- private windowSec;
88
- constructor(options: RedisStoreOptions);
89
- private getKey;
90
- get(key: string): Promise<RateLimitEntry | null>;
91
- set(key: string, entry: RateLimitEntry): Promise<void>;
92
- increment(key: string): Promise<number>;
93
- decrement(key: string): Promise<void>;
94
- reset(key: string): Promise<void>;
95
- close(): Promise<void>;
96
- }
97
- /**
98
- * Create a Redis store with the given options.
99
- * Convenience function for functional programming style.
100
- *
101
- * @example
102
- * const store = createRedisStore({ client: redisClient });
103
- */
104
- declare function createRedisStore(options: RedisStoreOptions): RedisStore;
105
-
106
- export { MemoryStore, type RedisClientLike, RedisStore, type RedisStoreOptions, createRedisStore };
5
+ export { MemoryStore } from './memory';
6
+ export { RedisStore, createRedisStore } from './redis';
7
+ export type { RedisClientLike, RedisStoreOptions } from './redis';
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/stores/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AACvD,YAAY,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * @module @arcis/node/stores/memory
3
+ * In-memory rate limit store
4
+ */
5
+ import type { RateLimitStore, RateLimitEntry } from '../core/types';
6
+ /**
7
+ * In-memory rate limit store.
8
+ * Suitable for single-instance deployments.
9
+ * For distributed systems, use RedisStore or a custom store.
10
+ *
11
+ * @example
12
+ * const store = new MemoryStore(60000); // 1 minute window
13
+ * const limiter = createRateLimiter({ store });
14
+ */
15
+ export declare class MemoryStore implements RateLimitStore {
16
+ private store;
17
+ private cleanupInterval;
18
+ private windowMs;
19
+ constructor(windowMs?: number);
20
+ /**
21
+ * Start the cleanup interval to remove expired entries.
22
+ */
23
+ private startCleanup;
24
+ get(key: string): Promise<RateLimitEntry | null>;
25
+ set(key: string, entry: RateLimitEntry): Promise<void>;
26
+ increment(key: string): Promise<number>;
27
+ decrement(key: string): Promise<void>;
28
+ reset(key: string): Promise<void>;
29
+ close(): Promise<void>;
30
+ /**
31
+ * Get current store size (for monitoring).
32
+ */
33
+ get size(): number;
34
+ }
35
+ //# sourceMappingURL=memory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../../src/stores/memory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAGpE;;;;;;;;GAQG;AACH,qBAAa,WAAY,YAAW,cAAc;IAChD,OAAO,CAAC,KAAK,CAA0C;IACvD,OAAO,CAAC,eAAe,CAA+C;IACtE,OAAO,CAAC,QAAQ,CAAS;gBAEb,QAAQ,GAAE,MAAqC;IAU3D;;OAEG;IACH,OAAO,CAAC,YAAY;IAuBd,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC;IAahD,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAItD,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAcvC,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAOrC,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIjC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAQ5B;;OAEG;IACH,IAAI,IAAI,IAAI,MAAM,CAEjB;CACF"}
@@ -1,41 +1,3 @@
1
- import { g as RateLimitStore, R as RateLimitEntry } from '../types-CsOFHoD9.mjs';
2
- import 'express';
3
-
4
- /**
5
- * @module @arcis/node/stores/memory
6
- * In-memory rate limit store
7
- */
8
-
9
- /**
10
- * In-memory rate limit store.
11
- * Suitable for single-instance deployments.
12
- * For distributed systems, use RedisStore or a custom store.
13
- *
14
- * @example
15
- * const store = new MemoryStore(60000); // 1 minute window
16
- * const limiter = createRateLimiter({ store });
17
- */
18
- declare class MemoryStore implements RateLimitStore {
19
- private store;
20
- private cleanupInterval;
21
- private windowMs;
22
- constructor(windowMs?: number);
23
- /**
24
- * Start the cleanup interval to remove expired entries.
25
- */
26
- private startCleanup;
27
- get(key: string): Promise<RateLimitEntry | null>;
28
- set(key: string, entry: RateLimitEntry): Promise<void>;
29
- increment(key: string): Promise<number>;
30
- decrement(key: string): Promise<void>;
31
- reset(key: string): Promise<void>;
32
- close(): Promise<void>;
33
- /**
34
- * Get current store size (for monitoring).
35
- */
36
- get size(): number;
37
- }
38
-
39
1
  /**
40
2
  * @module @arcis/node/stores/redis
41
3
  * Redis rate limit store
@@ -43,9 +5,9 @@ declare class MemoryStore implements RateLimitStore {
43
5
  * Note: This is a reference implementation. You'll need to install
44
6
  * the 'ioredis' or 'redis' package and pass your client instance.
45
7
  */
46
-
8
+ import type { RateLimitStore, RateLimitEntry } from '../core/types';
47
9
  /** Generic Redis client interface (works with ioredis, redis, etc.) */
48
- interface RedisClientLike {
10
+ export interface RedisClientLike {
49
11
  get(key: string): Promise<string | null>;
50
12
  set(key: string, value: string, mode?: string, duration?: number): Promise<unknown>;
51
13
  setex(key: string, seconds: number, value: string): Promise<unknown>;
@@ -57,7 +19,7 @@ interface RedisClientLike {
57
19
  quit?(): Promise<unknown>;
58
20
  disconnect?(): Promise<unknown>;
59
21
  }
60
- interface RedisStoreOptions {
22
+ export interface RedisStoreOptions {
61
23
  /** Redis client instance */
62
24
  client: RedisClientLike;
63
25
  /** Key prefix. Default: 'arcis:rl:' */
@@ -80,7 +42,7 @@ interface RedisStoreOptions {
80
42
  * await store.close();
81
43
  * });
82
44
  */
83
- declare class RedisStore implements RateLimitStore {
45
+ export declare class RedisStore implements RateLimitStore {
84
46
  private client;
85
47
  private prefix;
86
48
  private windowMs;
@@ -101,6 +63,5 @@ declare class RedisStore implements RateLimitStore {
101
63
  * @example
102
64
  * const store = createRedisStore({ client: redisClient });
103
65
  */
104
- declare function createRedisStore(options: RedisStoreOptions): RedisStore;
105
-
106
- export { MemoryStore, type RedisClientLike, RedisStore, type RedisStoreOptions, createRedisStore };
66
+ export declare function createRedisStore(options: RedisStoreOptions): RedisStore;
67
+ //# sourceMappingURL=redis.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redis.d.ts","sourceRoot":"","sources":["../../src/stores/redis.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAGpE,uEAAuE;AACvE,MAAM,WAAW,eAAe;IAC9B,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IACzC,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACpF,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACrE,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACvD,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACnC,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACnC,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAClC,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAClC,IAAI,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IAC1B,UAAU,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;CACjC;AAED,MAAM,WAAW,iBAAiB;IAChC,4BAA4B;IAC5B,MAAM,EAAE,eAAe,CAAC;IACxB,uCAAuC;IACvC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,kDAAkD;IAClD,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;;;;;;;GAcG;AACH,qBAAa,UAAW,YAAW,cAAc;IAC/C,OAAO,CAAC,MAAM,CAAkB;IAChC,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,SAAS,CAAS;gBAEd,OAAO,EAAE,iBAAiB;IAOtC,OAAO,CAAC,MAAM;IAIR,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC;IAwBhD,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAQtD,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAgBvC,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAKrC,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAKjC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAI7B;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,iBAAiB,GAAG,UAAU,CAEvE"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * @module @arcis/node/utils/duration
3
+ * Parse human-readable duration strings into milliseconds.
4
+ *
5
+ * Supports: ms, s, m, h, d
6
+ *
7
+ * @example
8
+ * parseDuration('5m') // 300000
9
+ * parseDuration('2h') // 7200000
10
+ * parseDuration(60000) // 60000 (passthrough)
11
+ * parseDuration('500ms') // 500
12
+ */
13
+ /**
14
+ * Parse a duration string or number into milliseconds.
15
+ *
16
+ * @param value - Duration string (e.g. "5m", "2h", "30s") or number (ms)
17
+ * @returns Duration in milliseconds
18
+ * @throws {Error} If the value is not a valid duration
19
+ *
20
+ * @example
21
+ * parseDuration('15m') // 900000
22
+ * parseDuration('1d') // 86400000
23
+ * parseDuration('500ms') // 500
24
+ * parseDuration(60000) // 60000
25
+ */
26
+ export declare function parseDuration(value: string | number): number;
27
+ /**
28
+ * Format milliseconds into a human-readable duration string.
29
+ *
30
+ * @param ms - Duration in milliseconds
31
+ * @returns Human-readable string (e.g. "5m", "2h 30m")
32
+ */
33
+ export declare function formatDuration(ms: number): string;
34
+ //# sourceMappingURL=duration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"duration.d.ts","sourceRoot":"","sources":["../../src/utils/duration.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAeH;;;;;;;;;;;;GAYG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CA4B5D;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAiBjD"}