@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
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/core/constants.ts","../../src/core/errors.ts"],"names":[],"mappings":";AAQO,IAAM,KAAA,GAAQ;AAAA;AAAA,EAEnB,gBAAA,EAAkB,GAAA;AAAA;AAAA,EAElB,mBAAA,EAAqB;AACvB;AAKO,IAAM,UAAA,GAAa;AAAA;AAAA,EAExB,iBAAA,EAAmB,GAAA;AAAA;AAAA,EAEnB,oBAAA,EAAsB,GAAA;AAAA;AAAA,EAEtB,mBAAA,EAAqB,GAAA;AAAA;AAAA,EAErB,eAAA,EAAiB,4CAAA;AAAA;AAAA,EAEjB,aAAA,EAAe,GAAA;AAAA;AAAA,EAEf,aAAA,EAAe;AACjB;AAKO,IAAM,OAAA,GAAU;AAAA;AAAA,EAErB,WAAA,EAAa;AAAA,IACX,oBAAA;AAAA,IACA,mBAAA;AAAA,IACA,kCAAA;AAAA,IACA,6BAAA;AAAA,IACA,iBAAA;AAAA,IACA,mBAAA;AAAA,IACA;AAAA,GACF,CAAE,KAAK,IAAI,CAAA;AAAA;AAAA,EAEX,YAAA,EAAc,OAAA;AAAA;AAAA,EAEd,aAAA,EAAe,MAAA;AAAA;AAAA,EAEf,oBAAA,EAAsB,SAAA;AAAA;AAAA,EAEtB,eAAA,EAAiB,iCAAA;AAAA;AAAA,EAEjB,kBAAA,EAAoB,0CAAA;AAAA;AAAA,EAEpB,aAAA,EAAe;AACjB;AAUO,IAAM,YAAA,GAAe;AAAA;A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,KAAA,CAAM,OAAA,EAAS,KAAK,qBAAqB,CAAA;AACzC,IAAA,IAAA,CAAK,IAAA,GAAO,gBAAA;AACZ,IAAA,IAAA,CAAK,UAAA,GAAa,UAAA;AAAA,EACpB;AACF;AAKO,IAAM,kBAAA,GAAN,cAAiC,UAAA,CAAW;AAAA,EAIjD,WAAA,CAAY,SAAiB,UAAA,EAAoB;AAC/C,IAAA,KAAA,CAAM,CAAA,8BAAA,EAAiC,OAAO,CAAA,MAAA,CAAA,EAAU,GAAA,EAAK,iBAAiB,CAAA;AAC9E,IAAA,IAAA,CAAK,IAAA,GAAO,oBAAA;AACZ,IAAA,IAAA,CAAK,OAAA,GAAU,OAAA;AACf,IAAA,IAAA,CAAK,UAAA,GAAa,UAAA;AAAA,EACpB;AACF;AAKO,IAAM,mBAAA,GAAN,cAAkC,UAAA,CAAW;AAAA,EAIlD,WAAA,CAAY,YAAoB,OAAA,EAAiB;AAC/C,IAAA,KAAA,CAAM,sCAAA,EAAwC,KAAK,iBAAiB,CAAA;AACpE,IAAA,IAAA,CAAK,IAAA,GAAO,qBAAA;AACZ,IAAA,IAAA,CAAK,UAAA,GAAa,UAAA;AAClB,IAAA,IAAA,CAAK,OAAA,GAAU,OAAA;AAAA,EACjB;AACF;AAKO,IAAM,iBAAA,GAAN,cAAgC,UAAA,CAAW;AAAA,EAChD,YAAY,OAAA,EAAiB;AAC3B,IAAA,KAAA,CAAM,OAAA,EAAS,KAAK,oBAAoB,CAAA;AACxC,IAAA,IAAA,CAAK,IAAA,GAAO,mBAAA;AAAA,EACd;AACF","file":"index.mjs","sourcesContent":["/**\r\n * @module @arcis/node/core/constants\r\n * Named constants for Arcis - no magic numbers\r\n */\r\n\r\n// =============================================================================\r\n// INPUT LIMITS\r\n// =============================================================================\r\nexport const INPUT = {\r\n /** Default maximum input size (1MB) */\r\n DEFAULT_MAX_SIZE: 1_000_000,\r\n /** Maximum recursion depth for nested objects */\r\n MAX_RECURSION_DEPTH: 10,\r\n} as const;\r\n\r\n// =============================================================================\r\n// RATE LIMITING\r\n// =============================================================================\r\nexport const RATE_LIMIT = {\r\n /** Default window size (1 minute) */\r\n DEFAULT_WINDOW_MS: 60_000,\r\n /** Default max requests per window */\r\n DEFAULT_MAX_REQUESTS: 100,\r\n /** Default HTTP status code for rate limited responses */\r\n DEFAULT_STATUS_CODE: 429,\r\n /** Default error message */\r\n DEFAULT_MESSAGE: 'Too many requests, please try again later.',\r\n /** Minimum window size (1 second) */\r\n MIN_WINDOW_MS: 1_000,\r\n /** Maximum window size (24 hours) */\r\n MAX_WINDOW_MS: 86_400_000,\r\n} as const;\r\n\r\n// =============================================================================\r\n// SECURITY HEADERS\r\n// =============================================================================\r\nexport const HEADERS = {\r\n /** Default Content Security Policy */\r\n DEFAULT_CSP: [\r\n \"default-src 'self'\",\r\n \"script-src 'self'\",\r\n \"style-src 'self' 'unsafe-inline'\",\r\n \"img-src 'self' data: https:\",\r\n \"font-src 'self'\",\r\n \"object-src 'none'\",\r\n \"frame-ancestors 'none'\",\r\n ].join('; '),\r\n /** Default HSTS max age (1 year in seconds) */\r\n HSTS_MAX_AGE: 31_536_000,\r\n /** Default X-Frame-Options value */\r\n FRAME_OPTIONS: 'DENY' as const,\r\n /** Default X-Content-Type-Options value */\r\n CONTENT_TYPE_OPTIONS: 'nosniff',\r\n /** Default Referrer-Policy value */\r\n REFERRER_POLICY: 'strict-origin-when-cross-origin',\r\n /** Default Permissions-Policy value */\r\n PERMISSIONS_POLICY: 'geolocation=(), microphone=(), camera=()',\r\n /** Default Cache-Control value for security */\r\n CACHE_CONTROL: 'no-store, no-cache, must-revalidate, proxy-revalidate',\r\n} as const;\r\n\r\n// =============================================================================\r\n// XSS PATTERNS (ReDoS-safe)\r\n// =============================================================================\r\n\r\n/**\r\n * Detection patterns — used to flag whether a string contains XSS payloads.\r\n * Must stay in sync with XSS_REMOVE_PATTERNS below.\r\n */\r\nexport const XSS_PATTERNS = [\r\n /** Script tags (ReDoS-safe version) */\r\n /<script[^>]*>[\\s\\S]*?<\\/script>/gi,\r\n /** javascript: protocol (allow optional spaces before colon) */\r\n /javascript\\s*:/gi,\r\n /** vbscript: protocol */\r\n /vbscript\\s*:/gi,\r\n /** Event handlers (onclick, onerror, etc.) — any separator before attribute */\r\n /(?:[\\s/])on\\w+\\s*=/gi,\r\n /** iframe tags */\r\n /<iframe/gi,\r\n /** object tags */\r\n /<object/gi,\r\n /** embed tags */\r\n /<embed/gi,\r\n /** data: URIs (only dangerous ones, avoid false positives) */\r\n /(?:^|[\\s\"'=])data:/gi,\r\n /** URL-encoded script tags */\r\n /%3Cscript/gi,\r\n /** SVG with onload */\r\n /<svg[^>]*onload/gi,\r\n] as const;\r\n\r\n/**\r\n * Removal patterns — used by sanitizeXss() to strip dangerous content.\r\n * More targeted than XSS_PATTERNS: each pattern captures the full dangerous\r\n * substring (tag, attribute + value, protocol) so it can be replaced safely.\r\n * Must stay in sync with XSS_PATTERNS above.\r\n */\r\nexport const XSS_REMOVE_PATTERNS = [\r\n /** Full script blocks (content + tags) */\r\n /<script[^>]*>[\\s\\S]*?<\\/script>/gi,\r\n /** Standalone/unclosed script tags */\r\n /<script[^>]*>/gi,\r\n /** iframe — full block and partial/unclosed */\r\n /<iframe[^>]*>[\\s\\S]*?<\\/iframe>/gi,\r\n /<iframe[^>]*/gi,\r\n /** object — full block and partial/unclosed */\r\n /<object[^>]*>[\\s\\S]*?<\\/object>/gi,\r\n /<object[^>]*/gi,\r\n /** embed tags */\r\n /<embed[^>]*/gi,\r\n /** SVG with inline event handlers */\r\n /<svg[^>]*onload[^>]*>/gi,\r\n /** URL-encoded script tags */\r\n /%3Cscript/gi,\r\n /** Event handlers with quoted values: onclick=\"...\", onerror='...' */\r\n /(?:[\\s/])on\\w+\\s*=\\s*[\"'][^\"']*[\"']/gi,\r\n /** Event handlers with unquoted values: onload=value */\r\n /(?:[\\s/])on\\w+\\s*=\\s*[^\\s>]*/gi,\r\n /** javascript: and vbscript: protocols (allow optional spaces before colon) */\r\n /javascript\\s*:/gi,\r\n /vbscript\\s*:/gi,\r\n /** data: URIs with HTML/script content */\r\n /data\\s*:\\s*text\\/html[^>\\s]*/gi,\r\n] as const;\r\n\r\n// =============================================================================\r\n// SQL INJECTION PATTERNS\r\n// =============================================================================\r\nexport const SQL_PATTERNS = [\r\n /** SQL keywords */\r\n /(\\b(SELECT|INSERT|UPDATE|DELETE|DROP|UNION|ALTER|CREATE|TRUNCATE|EXEC|EXECUTE)\\b)/gi,\r\n /** SQL comments: ANSI (--), C-style (slash-star ... star-slash), MySQL (#) */\r\n /(--|\\/\\*|\\*\\/|#)/g,\r\n /** SQL statement separators */\r\n /(;|\\|\\||&&)/g,\r\n /** Boolean injection: OR 1=1 */\r\n /\\bOR\\s+\\d+\\s*=\\s*\\d+/gi,\r\n /** Boolean injection: OR 'a'='a' or OR \"a\"=\"a\" (including mixed quotes) */\r\n /\\bOR\\s+(['\"])[^'\"]*\\1\\s*=\\s*(['\"])[^'\"]*\\2/gi,\r\n /\\bOR\\s+('[^']*'|\"[^\"]*\")\\s*=\\s*('[^']*'|\"[^\"]*\")/gi,\r\n /** Boolean injection: AND 1=1 */\r\n /\\bAND\\s+\\d+\\s*=\\s*\\d+/gi,\r\n /** Boolean injection: AND 'a'='a' or AND \"a\"=\"a\" (including mixed quotes) */\r\n /\\bAND\\s+(['\"])[^'\"]*\\1\\s*=\\s*(['\"])[^'\"]*\\2/gi,\r\n /\\bAND\\s+('[^']*'|\"[^\"]*\")\\s*=\\s*('[^']*'|\"[^\"]*\")/gi,\r\n /** Time-based blind: SLEEP() */\r\n /\\bSLEEP\\s*\\(\\s*\\d+\\s*\\)/gi,\r\n /** Time-based blind: BENCHMARK() */\r\n /\\bBENCHMARK\\s*\\(/gi,\r\n] as const;\r\n\r\n// =============================================================================\r\n// PATH TRAVERSAL PATTERNS\r\n// =============================================================================\r\nexport const PATH_PATTERNS = [\r\n /** Unix path traversal */\r\n /\\.\\.\\//g,\r\n /** Windows path traversal */\r\n /\\.\\.\\\\/g,\r\n /** URL-encoded traversal (%2e%2e) */\r\n /%2e%2e/gi,\r\n /** Double URL-encoded traversal (%252e) */\r\n /%252e/gi,\r\n /** Mixed encoding: ..%2F */\r\n /\\.\\.%2F/gi,\r\n /** Mixed encoding: %2e./ and .%2e/ */\r\n /%2e\\.[\\\\/]/gi,\r\n /\\.%2e[\\\\/]/gi,\r\n /** Fully URL-encoded: %2e%2e%2f */\r\n /%2e%2e%2f/gi,\r\n /** Null byte injection in paths */\r\n /\\0/g,\r\n] as const;\r\n\r\n// =============================================================================\r\n// COMMAND INJECTION PATTERNS\r\n// =============================================================================\r\nexport const COMMAND_PATTERNS = [\r\n /**\r\n * Shell metacharacters that enable command chaining/substitution.\r\n * Bare ( and ) are excluded — they appear in common legitimate values\r\n * (function calls in code fields, math expressions, etc.).\r\n * Command substitution is caught by the $( combined pattern below.\r\n * NOTE: ';', '&', '|' may appear in legitimate URL query strings\r\n * and Markdown; consider disabling command checking (command: false)\r\n * for fields that intentionally allow those characters.\r\n */\r\n /[;&|`]/g,\r\n /** Command substitution: $( ... ) — matched as a pair to reduce false positives */\r\n /\\$\\(/g,\r\n] as const;\r\n\r\n// =============================================================================\r\n// DANGEROUS KEYS\r\n// =============================================================================\r\n\r\n/**\r\n * Prototype pollution keys to block.\r\n * Stored lowercase — always compare with key.toLowerCase().\r\n *\r\n * Includes:\r\n * - __proto__: direct prototype assignment\r\n * - constructor: access to constructor.prototype chain\r\n * - prototype: direct prototype property\r\n * - __defineGetter__/__defineSetter__: legacy property definition (can override getters/setters)\r\n * - __lookupGetter__/__lookupSetter__: legacy property introspection\r\n */\r\nexport const DANGEROUS_PROTO_KEYS = new Set([\r\n '__proto__',\r\n 'constructor',\r\n 'prototype',\r\n '__definegetter__',\r\n '__definesetter__',\r\n '__lookupgetter__',\r\n '__lookupsetter__',\r\n]);\r\n\r\n/** MongoDB operators to block */\r\nexport const NOSQL_DANGEROUS_KEYS = new Set([\r\n // Comparison\r\n '$gt', '$gte', '$lt', '$lte', '$ne', '$eq', '$in', '$nin',\r\n // Logical\r\n '$and', '$or', '$not', '$nor',\r\n // Element / evaluation\r\n '$exists', '$type', '$regex', '$where', '$expr', '$mod', '$text',\r\n // Array\r\n '$elemMatch', '$all', '$size',\r\n // JavaScript execution (critical)\r\n '$function', '$accumulator',\r\n // Aggregation pipeline operators (injectable via $lookup etc.)\r\n '$lookup', '$match', '$project', '$group', '$sort', '$limit', '$skip',\r\n '$unwind', '$addFields', '$replaceRoot',\r\n]);\r\n\r\n// =============================================================================\r\n// REDACTION\r\n// =============================================================================\r\nexport const REDACTION = {\r\n /** Replacement text for redacted values */\r\n REPLACEMENT: '[REDACTED]',\r\n /** Truncation indicator */\r\n TRUNCATED: '[TRUNCATED]',\r\n /** Max depth indicator */\r\n MAX_DEPTH: '[MAX_DEPTH]',\r\n /** Default max message length */\r\n DEFAULT_MAX_LENGTH: 10_000,\r\n /** Default sensitive keys to redact */\r\n SENSITIVE_KEYS: new Set([\r\n 'password', 'passwd', 'pwd', 'secret', 'token', 'apikey',\r\n 'api_key', 'apiKey', 'auth', 'authorization', 'credit_card',\r\n 'creditcard', 'cc', 'ssn', 'social_security', 'private_key',\r\n 'privateKey', 'access_token', 'accessToken', 'refresh_token',\r\n 'refreshToken', 'bearer', 'jwt', 'session', 'cookie',\r\n 'credentials', 'x-api-key', 'x-auth-token',\r\n ]),\r\n} as const;\r\n\r\n// =============================================================================\r\n// VALIDATION PATTERNS\r\n// =============================================================================\r\nexport const VALIDATION = {\r\n /**\r\n * Email regex pattern.\r\n * Rejects consecutive dots in local part (e.g. test..foo@example.com),\r\n * leading/trailing dots, and other common invalid forms.\r\n */\r\n EMAIL: /^[^\\s@.][^\\s@]*(?:\\.[^\\s@.][^\\s@]*)*@[^\\s@]+\\.[^\\s@]+$/,\r\n /**\r\n * URL regex pattern.\r\n * Only allows http:// and https:// — explicitly rejects javascript:,\r\n * data:, vbscript:, and other dangerous URI schemes.\r\n */\r\n URL: /^https?:\\/\\/[^\\s/$.?#][^\\s]*$/,\r\n /** UUID regex pattern (v4) */\r\n UUID: /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,\r\n} as const;\r\n\r\n// =============================================================================\r\n// ERROR MESSAGES\r\n// =============================================================================\r\nexport const ERRORS = {\r\n /** Generic error message (production) */\r\n INTERNAL_SERVER_ERROR: 'Internal Server Error',\r\n /** Input too large error */\r\n INPUT_TOO_LARGE: (maxSize: number) => `Input exceeds maximum size of ${maxSize} bytes`,\r\n /** Validation error messages */\r\n VALIDATION: {\r\n REQUIRED: (field: string) => `${field} is required`,\r\n INVALID_TYPE: (field: string, type: string) => `${field} must be a ${type}`,\r\n MIN_LENGTH: (field: string, min: number) => `${field} must be at least ${min} characters`,\r\n MAX_LENGTH: (field: string, max: number) => `${field} must be at most ${max} characters`,\r\n MIN_VALUE: (field: string, min: number) => `${field} must be at least ${min}`,\r\n MAX_VALUE: (field: string, max: number) => `${field} must be at most ${max}`,\r\n INVALID_FORMAT: (field: string) => `${field} format is invalid`,\r\n INVALID_EMAIL: (field: string) => `${field} must be a valid email`,\r\n INVALID_URL: (field: string) => `${field} must be a valid URL`,\r\n INVALID_UUID: (field: string) => `${field} must be a valid UUID`,\r\n INVALID_ENUM: (field: string, values: unknown[]) => `${field} must be one of: ${values.join(', ')}`,\r\n MIN_ITEMS: (field: string, min: number) => `${field} must have at least ${min} items`,\r\n MAX_ITEMS: (field: string, max: number) => `${field} must have at most ${max} items`,\r\n },\r\n} as const;\r\n\r\n// =============================================================================\r\n// BLOCKED TEXT (for sanitizer replacements)\r\n// =============================================================================\r\nexport const BLOCKED = '[BLOCKED]' as const;\r\n","/**\r\n * @module @arcis/node/core/errors\r\n * Custom error classes for Arcis\r\n */\r\n\r\n/**\r\n * Base class for all Arcis errors\r\n */\r\nexport class ArcisError extends Error {\r\n public readonly statusCode: number;\r\n public readonly code: string;\r\n /** Whether the error message is safe to expose to API clients. */\r\n public readonly expose: boolean;\r\n\r\n constructor(message: string, statusCode = 500, code = 'ARCIS_ERROR') {\r\n super(message);\r\n this.name = 'ArcisError';\r\n this.statusCode = statusCode;\r\n this.code = code;\r\n // Client errors (4xx) have controlled messages — safe to expose.\r\n // Server errors (5xx) may contain internal details — hide by default.\r\n this.expose = statusCode < 500;\r\n\r\n // Maintains proper stack trace for where error was thrown (V8 engines)\r\n if (Error.captureStackTrace) {\r\n Error.captureStackTrace(this, this.constructor);\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Error thrown when input validation fails\r\n */\r\nexport class ValidationError extends ArcisError {\r\n public readonly errors: string[];\r\n\r\n constructor(errors: string[]) {\r\n super('Validation failed', 400, 'VALIDATION_ERROR');\r\n this.name = 'ValidationError';\r\n this.errors = errors;\r\n }\r\n}\r\n\r\n/** Alias for ValidationError (backwards compatibility) */\r\nexport { ValidationError as ArcisValidationError };\r\n\r\n/**\r\n * Error thrown when rate limit is exceeded\r\n */\r\nexport class RateLimitError extends ArcisError {\r\n public readonly retryAfter: number;\r\n\r\n constructor(message: string, retryAfter: number) {\r\n super(message, 429, 'RATE_LIMIT_EXCEEDED');\r\n this.name = 'RateLimitError';\r\n this.retryAfter = retryAfter;\r\n }\r\n}\r\n\r\n/**\r\n * Error thrown when input is too large\r\n */\r\nexport class InputTooLargeError extends ArcisError {\r\n public readonly maxSize: number;\r\n public readonly actualSize: number;\r\n\r\n constructor(maxSize: number, actualSize: number) {\r\n super(`Input exceeds maximum size of ${maxSize} bytes`, 413, 'INPUT_TOO_LARGE');\r\n this.name = 'InputTooLargeError';\r\n this.maxSize = maxSize;\r\n this.actualSize = actualSize;\r\n }\r\n}\r\n\r\n/**\r\n * Error thrown when security threat is detected\r\n */\r\nexport class SecurityThreatError extends ArcisError {\r\n public readonly threatType: string;\r\n public readonly pattern: string;\r\n\r\n constructor(threatType: string, pattern: string) {\r\n super('Request blocked for security reasons', 400, 'SECURITY_THREAT');\r\n this.name = 'SecurityThreatError';\r\n this.threatType = threatType;\r\n this.pattern = pattern;\r\n }\r\n}\r\n\r\n/**\r\n * Error thrown when sanitization fails\r\n */\r\nexport class SanitizationError extends ArcisError {\r\n constructor(message: string) {\r\n super(message, 400, 'SANITIZATION_ERROR');\r\n this.name = 'SanitizationError';\r\n }\r\n}\r\n"]}
@@ -0,0 +1,284 @@
1
+ import { RequestHandler } from 'express';
2
+ import { i as SanitizeOptions, j as SanitizeResult } from './types-BOdL3ZWo.js';
3
+
4
+ /**
5
+ * @module @arcis/node/sanitizers/sanitize
6
+ * Main sanitization functions that combine all sanitizers
7
+ */
8
+
9
+ /**
10
+ * Sanitize a string value against multiple attack vectors.
11
+ *
12
+ * Order matters: We do XSS encoding LAST because:
13
+ * 1. Other sanitizers need to see the original patterns (e.g., SQL keywords)
14
+ * 2. HTML encoding is the final safe output transformation
15
+ * 3. Encoded entities like &lt; shouldn't be treated as SQL/command threats
16
+ *
17
+ * @param value - The string to sanitize
18
+ * @param options - Sanitization options
19
+ * @returns The sanitized string
20
+ *
21
+ * @example
22
+ * sanitizeString("<script>alert('xss')</script>")
23
+ * // Returns: "&lt;script&gt;alert(&#x27;xss&#x27;)&lt;/script&gt;"
24
+ *
25
+ * @example
26
+ * sanitizeString("../../etc/passwd")
27
+ * // Returns: "etc/passwd"
28
+ */
29
+ declare function sanitizeString(value: string, options?: SanitizeOptions): string;
30
+ /**
31
+ * Sanitize an object recursively, including nested objects and arrays.
32
+ * Also removes prototype pollution and NoSQL injection keys.
33
+ *
34
+ * @param obj - The object to sanitize
35
+ * @param options - Sanitization options
36
+ * @returns The sanitized object
37
+ */
38
+ declare function sanitizeObject(obj: unknown, options?: SanitizeOptions): unknown;
39
+ /**
40
+ * Create Express middleware for request sanitization.
41
+ * Sanitizes req.body, req.query, and req.params.
42
+ *
43
+ * @param options - Sanitization options
44
+ * @returns Express middleware
45
+ *
46
+ * @example
47
+ * app.use(createSanitizer());
48
+ *
49
+ * @example
50
+ * app.use(createSanitizer({ xss: true, sql: true, nosql: true }));
51
+ */
52
+ declare function createSanitizer(options?: SanitizeOptions): RequestHandler;
53
+
54
+ /**
55
+ * @module @arcis/node/sanitizers/xss
56
+ * XSS (Cross-Site Scripting) prevention
57
+ */
58
+
59
+ /**
60
+ * Sanitizes a string to prevent XSS attacks.
61
+ *
62
+ * Strategy:
63
+ * 1. Remove dangerous patterns (script tags, event handlers, etc.)
64
+ * 2. HTML-encode the remaining content
65
+ *
66
+ * @param input - The string to sanitize
67
+ * @param collectThreats - Whether to collect threat information (default: false for performance)
68
+ * @returns Sanitized string or SanitizeResult if collectThreats is true
69
+ *
70
+ * @example
71
+ * sanitizeXss("<script>alert('xss')</script>")
72
+ * // Returns: "&lt;script&gt;alert(&#x27;xss&#x27;)&lt;/script&gt;"
73
+ *
74
+ * @example
75
+ * sanitizeXss("<img onerror='alert(1)'>")
76
+ * // Returns: "&lt;img&gt;" (event handler removed)
77
+ */
78
+ declare function sanitizeXss(input: string, collectThreats?: false, htmlEncode?: boolean): string;
79
+ declare function sanitizeXss(input: string, collectThreats: true, htmlEncode?: boolean): SanitizeResult;
80
+ /**
81
+ * Checks if a string contains potential XSS patterns.
82
+ * Does not sanitize — use sanitizeXss() for that.
83
+ *
84
+ * @param input - The string to check
85
+ * @returns True if XSS patterns detected
86
+ */
87
+ declare function detectXss(input: string): boolean;
88
+
89
+ /**
90
+ * @module @arcis/node/sanitizers/sql
91
+ * SQL injection prevention
92
+ */
93
+
94
+ /**
95
+ * Sanitizes a string to prevent SQL injection attacks.
96
+ * Replaces dangerous SQL patterns with [BLOCKED].
97
+ *
98
+ * @param input - The string to sanitize
99
+ * @param collectThreats - Whether to collect threat information (default: false for performance)
100
+ * @returns Sanitized string or SanitizeResult if collectThreats is true
101
+ *
102
+ * @example
103
+ * sanitizeSql("'; DROP TABLE users; --")
104
+ * // Returns: "'; TABLE users "
105
+ */
106
+ declare function sanitizeSql(input: string, collectThreats?: false): string;
107
+ declare function sanitizeSql(input: string, collectThreats: true): SanitizeResult;
108
+ /**
109
+ * Checks if a string contains potential SQL injection patterns.
110
+ * Does not sanitize — use sanitizeSql() for that.
111
+ *
112
+ * @param input - The string to check
113
+ * @returns True if SQL injection patterns detected
114
+ */
115
+ declare function detectSql(input: string): boolean;
116
+
117
+ /**
118
+ * @module @arcis/node/sanitizers/path
119
+ * Path traversal prevention
120
+ */
121
+
122
+ /**
123
+ * Sanitizes a string to prevent path traversal attacks.
124
+ * Removes ../ and ..\ patterns (including URL-encoded variants).
125
+ *
126
+ * @param input - The string to sanitize
127
+ * @param collectThreats - Whether to collect threat information (default: false for performance)
128
+ * @returns Sanitized string or SanitizeResult if collectThreats is true
129
+ *
130
+ * @example
131
+ * sanitizePath("../../etc/passwd")
132
+ * // Returns: "etc/passwd"
133
+ */
134
+ declare function sanitizePath(input: string, collectThreats?: false): string;
135
+ declare function sanitizePath(input: string, collectThreats: true): SanitizeResult;
136
+ /**
137
+ * Checks if a string contains path traversal patterns.
138
+ * Does not sanitize — use sanitizePath() for that.
139
+ *
140
+ * @param input - The string to check
141
+ * @returns True if path traversal patterns detected
142
+ */
143
+ declare function detectPathTraversal(input: string): boolean;
144
+
145
+ /**
146
+ * @module @arcis/node/sanitizers/command
147
+ * Command injection prevention
148
+ */
149
+
150
+ /**
151
+ * Sanitizes a string to prevent command injection attacks.
152
+ * Replaces shell metacharacters and dangerous commands with [BLOCKED].
153
+ *
154
+ * @param input - The string to sanitize
155
+ * @param collectThreats - Whether to collect threat information (default: false for performance)
156
+ * @returns Sanitized string or SanitizeResult if collectThreats is true
157
+ *
158
+ * @example
159
+ * sanitizeCommand("file.txt; rm -rf /")
160
+ * // Returns: "file.txt rm -rf /"
161
+ */
162
+ declare function sanitizeCommand(input: string, collectThreats?: false): string;
163
+ declare function sanitizeCommand(input: string, collectThreats: true): SanitizeResult;
164
+ /**
165
+ * Checks if a string contains command injection patterns.
166
+ * Does not sanitize — use sanitizeCommand() for that.
167
+ *
168
+ * @param input - The string to check
169
+ * @returns True if command injection patterns detected
170
+ */
171
+ declare function detectCommandInjection(input: string): boolean;
172
+
173
+ /**
174
+ * @module @arcis/node/sanitizers/nosql
175
+ * NoSQL injection prevention (MongoDB operators)
176
+ */
177
+ /**
178
+ * Checks if a key is a dangerous MongoDB operator.
179
+ *
180
+ * @param key - The key to check
181
+ * @returns True if the key is a MongoDB operator
182
+ *
183
+ * @example
184
+ * isDangerousNoSqlKey('$gt') // true
185
+ * isDangerousNoSqlKey('name') // false
186
+ */
187
+ declare function isDangerousNoSqlKey(key: string): boolean;
188
+ /**
189
+ * Recursively checks if an object contains dangerous MongoDB operators.
190
+ *
191
+ * @param obj - The object to check
192
+ * @param maxDepth - Maximum recursion depth (default: 10)
193
+ * @returns True if dangerous operators found
194
+ */
195
+ declare function detectNoSqlInjection(obj: unknown, maxDepth?: number): boolean;
196
+ /**
197
+ * Get list of all MongoDB operators considered dangerous.
198
+ * Useful for documentation or custom validation.
199
+ *
200
+ * @returns Array of dangerous operator strings
201
+ */
202
+ declare function getDangerousOperators(): string[];
203
+
204
+ /**
205
+ * @module @arcis/node/sanitizers/prototype
206
+ * Prototype pollution prevention
207
+ */
208
+ /**
209
+ * Checks if a key is dangerous for prototype pollution.
210
+ * Case-insensitive — catches __PROTO__, Constructor, etc.
211
+ *
212
+ * @param key - The key to check
213
+ * @returns True if the key could cause prototype pollution
214
+ *
215
+ * @example
216
+ * isDangerousProtoKey('__proto__') // true
217
+ * isDangerousProtoKey('__PROTO__') // true
218
+ * isDangerousProtoKey('Constructor') // true
219
+ * isDangerousProtoKey('name') // false
220
+ */
221
+ declare function isDangerousProtoKey(key: string): boolean;
222
+ /**
223
+ * Recursively checks if an object contains prototype pollution keys.
224
+ *
225
+ * @param obj - The object to check
226
+ * @param maxDepth - Maximum recursion depth (default: 10)
227
+ * @returns True if dangerous keys found
228
+ */
229
+ declare function detectPrototypePollution(obj: unknown, maxDepth?: number): boolean;
230
+ /**
231
+ * Get list of all keys considered dangerous for prototype pollution.
232
+ * Useful for documentation or custom validation.
233
+ *
234
+ * @returns Array of dangerous key strings
235
+ */
236
+ declare function getDangerousProtoKeys(): string[];
237
+
238
+ /**
239
+ * @module @arcis/node/sanitizers/headers
240
+ * HTTP Header Injection & CRLF Injection prevention
241
+ *
242
+ * Prevents attackers from injecting newline characters (\r\n) into HTTP header
243
+ * values, which can lead to response splitting, session fixation, XSS via
244
+ * injected headers, and cache poisoning.
245
+ */
246
+
247
+ /**
248
+ * Sanitizes a header value by stripping CRLF sequences, bare CR/LF, and null bytes.
249
+ *
250
+ * @param input - The header value to sanitize
251
+ * @param collectThreats - Whether to collect threat information (default: false)
252
+ * @returns Sanitized string or SanitizeResult if collectThreats is true
253
+ *
254
+ * @example
255
+ * sanitizeHeaderValue("safe-value")
256
+ * // Returns: "safe-value"
257
+ *
258
+ * sanitizeHeaderValue("value\r\nX-Injected: evil")
259
+ * // Returns: "valueX-Injected: evil"
260
+ */
261
+ declare function sanitizeHeaderValue(input: string, collectThreats?: false): string;
262
+ declare function sanitizeHeaderValue(input: string, collectThreats: true): SanitizeResult;
263
+ /**
264
+ * Sanitizes an object of header key-value pairs.
265
+ * Strips CRLF/null bytes from both keys and values.
266
+ *
267
+ * @param headers - Object with header names as keys and header values as values
268
+ * @returns New object with sanitized header names and values
269
+ *
270
+ * @example
271
+ * sanitizeHeaders({ "X-Custom": "safe", "X-Bad\r\n": "value\r\ninjected" })
272
+ * // Returns: { "X-Custom": "safe", "X-Bad": "valueinjected" }
273
+ */
274
+ declare function sanitizeHeaders(headers: Record<string, string>): Record<string, string>;
275
+ /**
276
+ * Checks if a string contains HTTP header injection patterns (CRLF, null bytes).
277
+ * Does not sanitize — use sanitizeHeaderValue() for that.
278
+ *
279
+ * @param input - The string to check
280
+ * @returns True if header injection patterns detected
281
+ */
282
+ declare function detectHeaderInjection(input: string): boolean;
283
+
284
+ export { detectHeaderInjection as a, detectNoSqlInjection as b, createSanitizer as c, detectCommandInjection as d, detectPathTraversal as e, detectPrototypePollution as f, detectSql as g, detectXss as h, getDangerousOperators as i, getDangerousProtoKeys as j, isDangerousNoSqlKey as k, isDangerousProtoKey as l, sanitizeHeaderValue as m, sanitizeHeaders as n, sanitizeObject as o, sanitizePath as p, sanitizeSql as q, sanitizeString as r, sanitizeCommand as s, sanitizeXss as t };
@@ -0,0 +1,284 @@
1
+ import { RequestHandler } from 'express';
2
+ import { i as SanitizeOptions, j as SanitizeResult } from './types-BOdL3ZWo.mjs';
3
+
4
+ /**
5
+ * @module @arcis/node/sanitizers/sanitize
6
+ * Main sanitization functions that combine all sanitizers
7
+ */
8
+
9
+ /**
10
+ * Sanitize a string value against multiple attack vectors.
11
+ *
12
+ * Order matters: We do XSS encoding LAST because:
13
+ * 1. Other sanitizers need to see the original patterns (e.g., SQL keywords)
14
+ * 2. HTML encoding is the final safe output transformation
15
+ * 3. Encoded entities like &lt; shouldn't be treated as SQL/command threats
16
+ *
17
+ * @param value - The string to sanitize
18
+ * @param options - Sanitization options
19
+ * @returns The sanitized string
20
+ *
21
+ * @example
22
+ * sanitizeString("<script>alert('xss')</script>")
23
+ * // Returns: "&lt;script&gt;alert(&#x27;xss&#x27;)&lt;/script&gt;"
24
+ *
25
+ * @example
26
+ * sanitizeString("../../etc/passwd")
27
+ * // Returns: "etc/passwd"
28
+ */
29
+ declare function sanitizeString(value: string, options?: SanitizeOptions): string;
30
+ /**
31
+ * Sanitize an object recursively, including nested objects and arrays.
32
+ * Also removes prototype pollution and NoSQL injection keys.
33
+ *
34
+ * @param obj - The object to sanitize
35
+ * @param options - Sanitization options
36
+ * @returns The sanitized object
37
+ */
38
+ declare function sanitizeObject(obj: unknown, options?: SanitizeOptions): unknown;
39
+ /**
40
+ * Create Express middleware for request sanitization.
41
+ * Sanitizes req.body, req.query, and req.params.
42
+ *
43
+ * @param options - Sanitization options
44
+ * @returns Express middleware
45
+ *
46
+ * @example
47
+ * app.use(createSanitizer());
48
+ *
49
+ * @example
50
+ * app.use(createSanitizer({ xss: true, sql: true, nosql: true }));
51
+ */
52
+ declare function createSanitizer(options?: SanitizeOptions): RequestHandler;
53
+
54
+ /**
55
+ * @module @arcis/node/sanitizers/xss
56
+ * XSS (Cross-Site Scripting) prevention
57
+ */
58
+
59
+ /**
60
+ * Sanitizes a string to prevent XSS attacks.
61
+ *
62
+ * Strategy:
63
+ * 1. Remove dangerous patterns (script tags, event handlers, etc.)
64
+ * 2. HTML-encode the remaining content
65
+ *
66
+ * @param input - The string to sanitize
67
+ * @param collectThreats - Whether to collect threat information (default: false for performance)
68
+ * @returns Sanitized string or SanitizeResult if collectThreats is true
69
+ *
70
+ * @example
71
+ * sanitizeXss("<script>alert('xss')</script>")
72
+ * // Returns: "&lt;script&gt;alert(&#x27;xss&#x27;)&lt;/script&gt;"
73
+ *
74
+ * @example
75
+ * sanitizeXss("<img onerror='alert(1)'>")
76
+ * // Returns: "&lt;img&gt;" (event handler removed)
77
+ */
78
+ declare function sanitizeXss(input: string, collectThreats?: false, htmlEncode?: boolean): string;
79
+ declare function sanitizeXss(input: string, collectThreats: true, htmlEncode?: boolean): SanitizeResult;
80
+ /**
81
+ * Checks if a string contains potential XSS patterns.
82
+ * Does not sanitize — use sanitizeXss() for that.
83
+ *
84
+ * @param input - The string to check
85
+ * @returns True if XSS patterns detected
86
+ */
87
+ declare function detectXss(input: string): boolean;
88
+
89
+ /**
90
+ * @module @arcis/node/sanitizers/sql
91
+ * SQL injection prevention
92
+ */
93
+
94
+ /**
95
+ * Sanitizes a string to prevent SQL injection attacks.
96
+ * Replaces dangerous SQL patterns with [BLOCKED].
97
+ *
98
+ * @param input - The string to sanitize
99
+ * @param collectThreats - Whether to collect threat information (default: false for performance)
100
+ * @returns Sanitized string or SanitizeResult if collectThreats is true
101
+ *
102
+ * @example
103
+ * sanitizeSql("'; DROP TABLE users; --")
104
+ * // Returns: "'; TABLE users "
105
+ */
106
+ declare function sanitizeSql(input: string, collectThreats?: false): string;
107
+ declare function sanitizeSql(input: string, collectThreats: true): SanitizeResult;
108
+ /**
109
+ * Checks if a string contains potential SQL injection patterns.
110
+ * Does not sanitize — use sanitizeSql() for that.
111
+ *
112
+ * @param input - The string to check
113
+ * @returns True if SQL injection patterns detected
114
+ */
115
+ declare function detectSql(input: string): boolean;
116
+
117
+ /**
118
+ * @module @arcis/node/sanitizers/path
119
+ * Path traversal prevention
120
+ */
121
+
122
+ /**
123
+ * Sanitizes a string to prevent path traversal attacks.
124
+ * Removes ../ and ..\ patterns (including URL-encoded variants).
125
+ *
126
+ * @param input - The string to sanitize
127
+ * @param collectThreats - Whether to collect threat information (default: false for performance)
128
+ * @returns Sanitized string or SanitizeResult if collectThreats is true
129
+ *
130
+ * @example
131
+ * sanitizePath("../../etc/passwd")
132
+ * // Returns: "etc/passwd"
133
+ */
134
+ declare function sanitizePath(input: string, collectThreats?: false): string;
135
+ declare function sanitizePath(input: string, collectThreats: true): SanitizeResult;
136
+ /**
137
+ * Checks if a string contains path traversal patterns.
138
+ * Does not sanitize — use sanitizePath() for that.
139
+ *
140
+ * @param input - The string to check
141
+ * @returns True if path traversal patterns detected
142
+ */
143
+ declare function detectPathTraversal(input: string): boolean;
144
+
145
+ /**
146
+ * @module @arcis/node/sanitizers/command
147
+ * Command injection prevention
148
+ */
149
+
150
+ /**
151
+ * Sanitizes a string to prevent command injection attacks.
152
+ * Replaces shell metacharacters and dangerous commands with [BLOCKED].
153
+ *
154
+ * @param input - The string to sanitize
155
+ * @param collectThreats - Whether to collect threat information (default: false for performance)
156
+ * @returns Sanitized string or SanitizeResult if collectThreats is true
157
+ *
158
+ * @example
159
+ * sanitizeCommand("file.txt; rm -rf /")
160
+ * // Returns: "file.txt rm -rf /"
161
+ */
162
+ declare function sanitizeCommand(input: string, collectThreats?: false): string;
163
+ declare function sanitizeCommand(input: string, collectThreats: true): SanitizeResult;
164
+ /**
165
+ * Checks if a string contains command injection patterns.
166
+ * Does not sanitize — use sanitizeCommand() for that.
167
+ *
168
+ * @param input - The string to check
169
+ * @returns True if command injection patterns detected
170
+ */
171
+ declare function detectCommandInjection(input: string): boolean;
172
+
173
+ /**
174
+ * @module @arcis/node/sanitizers/nosql
175
+ * NoSQL injection prevention (MongoDB operators)
176
+ */
177
+ /**
178
+ * Checks if a key is a dangerous MongoDB operator.
179
+ *
180
+ * @param key - The key to check
181
+ * @returns True if the key is a MongoDB operator
182
+ *
183
+ * @example
184
+ * isDangerousNoSqlKey('$gt') // true
185
+ * isDangerousNoSqlKey('name') // false
186
+ */
187
+ declare function isDangerousNoSqlKey(key: string): boolean;
188
+ /**
189
+ * Recursively checks if an object contains dangerous MongoDB operators.
190
+ *
191
+ * @param obj - The object to check
192
+ * @param maxDepth - Maximum recursion depth (default: 10)
193
+ * @returns True if dangerous operators found
194
+ */
195
+ declare function detectNoSqlInjection(obj: unknown, maxDepth?: number): boolean;
196
+ /**
197
+ * Get list of all MongoDB operators considered dangerous.
198
+ * Useful for documentation or custom validation.
199
+ *
200
+ * @returns Array of dangerous operator strings
201
+ */
202
+ declare function getDangerousOperators(): string[];
203
+
204
+ /**
205
+ * @module @arcis/node/sanitizers/prototype
206
+ * Prototype pollution prevention
207
+ */
208
+ /**
209
+ * Checks if a key is dangerous for prototype pollution.
210
+ * Case-insensitive — catches __PROTO__, Constructor, etc.
211
+ *
212
+ * @param key - The key to check
213
+ * @returns True if the key could cause prototype pollution
214
+ *
215
+ * @example
216
+ * isDangerousProtoKey('__proto__') // true
217
+ * isDangerousProtoKey('__PROTO__') // true
218
+ * isDangerousProtoKey('Constructor') // true
219
+ * isDangerousProtoKey('name') // false
220
+ */
221
+ declare function isDangerousProtoKey(key: string): boolean;
222
+ /**
223
+ * Recursively checks if an object contains prototype pollution keys.
224
+ *
225
+ * @param obj - The object to check
226
+ * @param maxDepth - Maximum recursion depth (default: 10)
227
+ * @returns True if dangerous keys found
228
+ */
229
+ declare function detectPrototypePollution(obj: unknown, maxDepth?: number): boolean;
230
+ /**
231
+ * Get list of all keys considered dangerous for prototype pollution.
232
+ * Useful for documentation or custom validation.
233
+ *
234
+ * @returns Array of dangerous key strings
235
+ */
236
+ declare function getDangerousProtoKeys(): string[];
237
+
238
+ /**
239
+ * @module @arcis/node/sanitizers/headers
240
+ * HTTP Header Injection & CRLF Injection prevention
241
+ *
242
+ * Prevents attackers from injecting newline characters (\r\n) into HTTP header
243
+ * values, which can lead to response splitting, session fixation, XSS via
244
+ * injected headers, and cache poisoning.
245
+ */
246
+
247
+ /**
248
+ * Sanitizes a header value by stripping CRLF sequences, bare CR/LF, and null bytes.
249
+ *
250
+ * @param input - The header value to sanitize
251
+ * @param collectThreats - Whether to collect threat information (default: false)
252
+ * @returns Sanitized string or SanitizeResult if collectThreats is true
253
+ *
254
+ * @example
255
+ * sanitizeHeaderValue("safe-value")
256
+ * // Returns: "safe-value"
257
+ *
258
+ * sanitizeHeaderValue("value\r\nX-Injected: evil")
259
+ * // Returns: "valueX-Injected: evil"
260
+ */
261
+ declare function sanitizeHeaderValue(input: string, collectThreats?: false): string;
262
+ declare function sanitizeHeaderValue(input: string, collectThreats: true): SanitizeResult;
263
+ /**
264
+ * Sanitizes an object of header key-value pairs.
265
+ * Strips CRLF/null bytes from both keys and values.
266
+ *
267
+ * @param headers - Object with header names as keys and header values as values
268
+ * @returns New object with sanitized header names and values
269
+ *
270
+ * @example
271
+ * sanitizeHeaders({ "X-Custom": "safe", "X-Bad\r\n": "value\r\ninjected" })
272
+ * // Returns: { "X-Custom": "safe", "X-Bad": "valueinjected" }
273
+ */
274
+ declare function sanitizeHeaders(headers: Record<string, string>): Record<string, string>;
275
+ /**
276
+ * Checks if a string contains HTTP header injection patterns (CRLF, null bytes).
277
+ * Does not sanitize — use sanitizeHeaderValue() for that.
278
+ *
279
+ * @param input - The string to check
280
+ * @returns True if header injection patterns detected
281
+ */
282
+ declare function detectHeaderInjection(input: string): boolean;
283
+
284
+ export { detectHeaderInjection as a, detectNoSqlInjection as b, createSanitizer as c, detectCommandInjection as d, detectPathTraversal as e, detectPrototypePollution as f, detectSql as g, detectXss as h, getDangerousOperators as i, getDangerousProtoKeys as j, isDangerousNoSqlKey as k, isDangerousProtoKey as l, sanitizeHeaderValue as m, sanitizeHeaders as n, sanitizeObject as o, sanitizePath as p, sanitizeSql as q, sanitizeString as r, sanitizeCommand as s, sanitizeXss as t };