@arcis/node 1.0.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 (52) hide show
  1. package/README.md +222 -0
  2. package/dist/core/index.d.mts +170 -0
  3. package/dist/core/index.d.ts +170 -0
  4. package/dist/core/index.js +327 -0
  5. package/dist/core/index.js.map +1 -0
  6. package/dist/core/index.mjs +307 -0
  7. package/dist/core/index.mjs.map +1 -0
  8. package/dist/headers-BJq2OA0i.d.ts +284 -0
  9. package/dist/headers-DBQedhrb.d.mts +284 -0
  10. package/dist/index-BgHPM7LC.d.ts +129 -0
  11. package/dist/index-BpT7flAQ.d.ts +255 -0
  12. package/dist/index-JaFOUKyK.d.mts +255 -0
  13. package/dist/index-nAgXexwD.d.mts +129 -0
  14. package/dist/index.d.mts +139 -0
  15. package/dist/index.d.ts +139 -0
  16. package/dist/index.js +1860 -0
  17. package/dist/index.js.map +1 -0
  18. package/dist/index.mjs +1797 -0
  19. package/dist/index.mjs.map +1 -0
  20. package/dist/logging/index.d.mts +38 -0
  21. package/dist/logging/index.d.ts +38 -0
  22. package/dist/logging/index.js +140 -0
  23. package/dist/logging/index.js.map +1 -0
  24. package/dist/logging/index.mjs +136 -0
  25. package/dist/logging/index.mjs.map +1 -0
  26. package/dist/middleware/index.d.mts +3 -0
  27. package/dist/middleware/index.d.ts +3 -0
  28. package/dist/middleware/index.js +1173 -0
  29. package/dist/middleware/index.js.map +1 -0
  30. package/dist/middleware/index.mjs +1156 -0
  31. package/dist/middleware/index.mjs.map +1 -0
  32. package/dist/sanitizers/index.d.mts +24 -0
  33. package/dist/sanitizers/index.d.ts +24 -0
  34. package/dist/sanitizers/index.js +610 -0
  35. package/dist/sanitizers/index.js.map +1 -0
  36. package/dist/sanitizers/index.mjs +587 -0
  37. package/dist/sanitizers/index.mjs.map +1 -0
  38. package/dist/stores/index.d.mts +106 -0
  39. package/dist/stores/index.d.ts +106 -0
  40. package/dist/stores/index.js +149 -0
  41. package/dist/stores/index.js.map +1 -0
  42. package/dist/stores/index.mjs +145 -0
  43. package/dist/stores/index.mjs.map +1 -0
  44. package/dist/types-BOdL3ZWo.d.mts +264 -0
  45. package/dist/types-BOdL3ZWo.d.ts +264 -0
  46. package/dist/validation/index.d.mts +3 -0
  47. package/dist/validation/index.d.ts +3 -0
  48. package/dist/validation/index.js +705 -0
  49. package/dist/validation/index.js.map +1 -0
  50. package/dist/validation/index.mjs +699 -0
  51. package/dist/validation/index.mjs.map +1 -0
  52. package/package.json +109 -0
package/README.md ADDED
@@ -0,0 +1,222 @@
1
+ # Arcis
2
+
3
+ arcis One-line security middleware for Node.js, Python, and Go.
4
+
5
+ Arcis protects your code like how Dependabot protects your dependencies.
6
+
7
+
8
+ **15 attack vectors handled so far.**
9
+
10
+ | Category | What it stops |
11
+ |----------|--------------|
12
+ | XSS | Script injection, event handlers, `javascript:` URIs, SVG/iframe payloads |
13
+ | SQL Injection | Keywords, boolean logic, comments, time-based blind (`SLEEP`, `BENCHMARK`) |
14
+ | NoSQL Injection | MongoDB operators (`$gt`, `$where`, `$regex`, 25+ blocked operators) |
15
+ | Command Injection | Shell metacharacters, dangerous commands, redirections |
16
+ | Path Traversal | `../`, encoded variants (`%2e%2e`), null byte injection |
17
+ | Prototype Pollution | `__proto__`, `constructor`, `__defineGetter__`, 7 keys blocked (case-insensitive) |
18
+ | HTTP Header Injection | CRLF injection, response splitting, null bytes |
19
+ | SSRF | Private IPs, loopback, link-local, cloud metadata, dangerous protocols |
20
+ | Open Redirect | Absolute URLs, `javascript:`, protocol-relative, backslash/control char bypass |
21
+ | Error Leakage | Stack traces, DB errors, connection strings, internal IPs scrubbed in production |
22
+ | CORS Misconfiguration | Whitelist-based origins, `null` origin blocked, `Vary: Origin` enforced |
23
+ | Cookie Security | HttpOnly, Secure, SameSite enforced on all cookies |
24
+ | Rate Limiting | Per-IP, in-memory or Redis, `X-RateLimit-*` headers |
25
+ | Security Headers | CSP, HSTS, X-Frame-Options, 10 headers out of the box |
26
+ | Input Validation | Type checking, ranges, enums, mass assignment prevention, safe logging |
27
+
28
+ **1040+ tests** across Node.js (613) and Python (430).
29
+
30
+ ## Install
31
+
32
+ ```bash
33
+ npm install @arcis/node # Node.js
34
+ pip install arcis # Python
35
+ go get github.com/GagancM/arcis # Go
36
+ ```
37
+
38
+ **Install directly from GitHub:**
39
+
40
+ ```bash
41
+ # Node.js
42
+ npm install github:Gagancm/arcis#main --install-strategy=nested
43
+
44
+ # Python
45
+ pip install git+https://github.com/Gagancm/arcis.git#subdirectory=packages/arcis-python
46
+
47
+ # Go
48
+ go get github.com/Gagancm/arcis
49
+ ```
50
+
51
+ ## Quick Start
52
+
53
+ ### Node.js
54
+
55
+ Arcis has two layers: **framework-agnostic core functions** that work anywhere, and **middleware adapters** for specific frameworks.
56
+
57
+ #### With Express (built-in adapter)
58
+
59
+ ```js
60
+ import { arcis } from '@arcis/node';
61
+
62
+ app.use(arcis());
63
+ // That's it. Sanitization, rate limiting, and security headers are on.
64
+ ```
65
+
66
+ #### With any framework (Fastify, Koa, Hono, etc.)
67
+
68
+ The core sanitization, validation, and logging functions have zero framework dependencies. Use them directly in any Node.js project:
69
+
70
+ ```js
71
+ import {
72
+ sanitizeString,
73
+ sanitizeObject,
74
+ detectXss,
75
+ detectSql,
76
+ detectCommandInjection,
77
+ detectPathTraversal,
78
+ createSafeLogger,
79
+ createRedactor,
80
+ } from '@arcis/node';
81
+
82
+ // Sanitize user input — works anywhere
83
+ const clean = sanitizeString(userInput);
84
+ const cleanBody = sanitizeObject(requestBody);
85
+
86
+ // Detect threats without sanitizing
87
+ if (detectXss(value)) { /* reject */ }
88
+ if (detectSql(value)) { /* reject */ }
89
+
90
+ // Safe logging — no framework needed
91
+ const logger = createSafeLogger();
92
+ logger.info('User login', { email, password: 'will-be-redacted' });
93
+ ```
94
+
95
+ **Writing your own middleware is straightforward.** Here's a Fastify example:
96
+
97
+ ```js
98
+ import { sanitizeObject } from '@arcis/node';
99
+
100
+ fastify.addHook('preHandler', async (request, reply) => {
101
+ if (request.body) request.body = sanitizeObject(request.body);
102
+ if (request.query) request.query = sanitizeObject(request.query);
103
+ });
104
+ ```
105
+
106
+ Koa:
107
+
108
+ ```js
109
+ import { sanitizeObject } from '@arcis/node';
110
+
111
+ app.use(async (ctx, next) => {
112
+ if (ctx.request.body) ctx.request.body = sanitizeObject(ctx.request.body);
113
+ if (ctx.query) ctx.query = sanitizeObject(ctx.query);
114
+ await next();
115
+ });
116
+ ```
117
+
118
+ Hono:
119
+
120
+ ```js
121
+ import { sanitizeObject } from '@arcis/node';
122
+
123
+ app.use('*', async (c, next) => {
124
+ const body = await c.req.json().catch(() => null);
125
+ if (body) c.set('sanitizedBody', sanitizeObject(body));
126
+ await next();
127
+ });
128
+ ```
129
+
130
+ > Built-in adapters for Fastify, Koa, and Hono are on the roadmap. The core functions work today.
131
+
132
+ ### Python
133
+
134
+ ```python
135
+ # Flask
136
+ from arcis import Arcis
137
+ Arcis(app)
138
+
139
+ # FastAPI
140
+ from arcis import ArcisMiddleware
141
+ app.add_middleware(ArcisMiddleware)
142
+
143
+ # Django — add to MIDDLEWARE in settings.py
144
+ 'arcis.django.ArcisMiddleware'
145
+ ```
146
+
147
+ ### Go
148
+
149
+ ```go
150
+ // Gin
151
+ r.Use(arcisgin.Middleware())
152
+
153
+ // Echo
154
+ e.Use(arcisecho.Middleware())
155
+ ```
156
+
157
+ ## What It Does
158
+
159
+ One `app.use(arcis())` gives you all 15 categories above. Or use individual functions for fine-grained control:
160
+
161
+ - **Sanitize** — `sanitizeString()`, `sanitizeObject()` strip dangerous patterns
162
+ - **Detect** — `detectXss()`, `detectSql()`, `detectHeaderInjection()` flag threats without modifying input
163
+ - **Validate** — `validateUrl()` blocks SSRF, `validateRedirect()` blocks open redirects
164
+ - **Protect** — rate limiting, security headers, safe logging, error handling
165
+
166
+ ## Architecture
167
+
168
+ Arcis separates **core security logic** from **framework adapters**:
169
+
170
+ ```
171
+ @arcis/node
172
+ ├── Core (framework-agnostic)
173
+ │ ├── sanitizeString / sanitizeObject — clean any input
174
+ │ ├── detectXss / detectSql / ... — threat detection
175
+ │ ├── createSafeLogger / createRedactor — safe logging
176
+ │ ├── MemoryStore / RedisStore — rate limit backends
177
+ │ └── Error classes and constants
178
+
179
+ └── Adapters (framework-specific)
180
+ └── Express middleware (arcis(), arcis.sanitize(), arcis.rateLimit(), ...)
181
+ ```
182
+
183
+ The core functions are pure — no `req`, `res`, or `next`. They take values in and return values out. This means they work with Express, Fastify, Koa, Hono, Nest, raw `http.createServer`, Bun, Deno, serverless functions, or anything else.
184
+
185
+ Subpath imports are available for tree-shaking:
186
+
187
+ ```js
188
+ import { sanitizeString } from '@arcis/node/sanitizers';
189
+ import { createSafeLogger } from '@arcis/node/logging';
190
+ import { MemoryStore } from '@arcis/node/stores';
191
+ ```
192
+
193
+ ## Supported Frameworks
194
+
195
+ | SDK | Built-in Adapters | Core Functions | Status |
196
+ |-----|-------------------|----------------|--------|
197
+ | Node.js | Express | Work with any framework | Stable |
198
+ | Python | Flask, FastAPI, Django | Work standalone | Stable |
199
+ | Go | net/http, Gin, Echo | Work standalone | Stable |
200
+ | Java | Spring Boot | — | Planned |
201
+ | C# | ASP.NET Core | — | Planned |
202
+
203
+ **Node.js roadmap:** Built-in adapters for Fastify, Koa, and Hono are planned. The core functions already work with these frameworks — you just wire a short middleware wrapper (see examples above).
204
+
205
+
206
+ ## How It Works
207
+
208
+ All SDKs load security patterns from a shared `patterns.json` at runtime. A shared spec (`API_SPEC.md`) and test vectors (`TEST_VECTORS.json`) enforce identical behavior across languages.
209
+
210
+ ## Documentation
211
+
212
+ Detailed configuration, API reference, Redis setup, granular middleware usage, and architecture docs are in the [Wiki](https://github.com/Gagancm/arcis/wiki).
213
+
214
+ ## Contributing
215
+
216
+ 1. All changes must pass existing tests
217
+ 2. New features require test cases aligned with `spec/TEST_VECTORS.json`
218
+ 3. Pattern changes in `packages/core/patterns.json` must be reflected in all SDKs
219
+
220
+ ## License
221
+
222
+ MIT
@@ -0,0 +1,170 @@
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-BOdL3ZWo.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
+ /**
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];
102
+ declare const PATH_PATTERNS: readonly [RegExp, RegExp, RegExp, RegExp, RegExp, RegExp, RegExp, RegExp, RegExp];
103
+ declare const COMMAND_PATTERNS: readonly [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 };
@@ -0,0 +1,170 @@
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-BOdL3ZWo.js';
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
+ /**
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];
102
+ declare const PATH_PATTERNS: readonly [RegExp, RegExp, RegExp, RegExp, RegExp, RegExp, RegExp, RegExp, RegExp];
103
+ declare const COMMAND_PATTERNS: readonly [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 };