@arcis/node 1.0.0 → 1.2.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 (54) hide show
  1. package/README.md +156 -222
  2. package/dist/core/index.d.mts +4 -4
  3. package/dist/core/index.d.ts +4 -4
  4. package/dist/core/index.js +13 -2
  5. package/dist/core/index.js.map +1 -1
  6. package/dist/core/index.mjs +13 -2
  7. package/dist/core/index.mjs.map +1 -1
  8. package/dist/index-A-m-pPeW.d.mts +340 -0
  9. package/dist/index-CgK94hY_.d.mts +532 -0
  10. package/dist/index-Co5kPRZz.d.ts +340 -0
  11. package/dist/index-D_bdJcF0.d.ts +532 -0
  12. package/dist/index.d.mts +144 -108
  13. package/dist/index.d.ts +144 -108
  14. package/dist/index.js +1541 -211
  15. package/dist/index.js.map +1 -1
  16. package/dist/index.mjs +1515 -212
  17. package/dist/index.mjs.map +1 -1
  18. package/dist/logging/index.d.mts +1 -1
  19. package/dist/logging/index.d.ts +1 -1
  20. package/dist/logging/index.js +12 -1
  21. package/dist/logging/index.js.map +1 -1
  22. package/dist/logging/index.mjs +12 -1
  23. package/dist/logging/index.mjs.map +1 -1
  24. package/dist/middleware/index.d.mts +2 -2
  25. package/dist/middleware/index.d.ts +2 -2
  26. package/dist/middleware/index.js +524 -4
  27. package/dist/middleware/index.js.map +1 -1
  28. package/dist/middleware/index.mjs +517 -5
  29. package/dist/middleware/index.mjs.map +1 -1
  30. package/dist/{headers-DBQedhrb.d.mts → pii-CXcHMlnX.d.mts} +156 -2
  31. package/dist/{headers-BJq2OA0i.d.ts → pii-DhNpl7M3.d.ts} +156 -2
  32. package/dist/sanitizers/index.d.mts +2 -2
  33. package/dist/sanitizers/index.d.ts +2 -2
  34. package/dist/sanitizers/index.js +331 -3
  35. package/dist/sanitizers/index.js.map +1 -1
  36. package/dist/sanitizers/index.mjs +321 -4
  37. package/dist/sanitizers/index.mjs.map +1 -1
  38. package/dist/stores/index.d.mts +1 -1
  39. package/dist/stores/index.d.ts +1 -1
  40. package/dist/stores/index.js.map +1 -1
  41. package/dist/stores/index.mjs.map +1 -1
  42. package/dist/{types-BOdL3ZWo.d.mts → types-CsOFHoD9.d.mts} +6 -1
  43. package/dist/{types-BOdL3ZWo.d.ts → types-CsOFHoD9.d.ts} +6 -1
  44. package/dist/validation/index.d.mts +2 -2
  45. package/dist/validation/index.d.ts +2 -2
  46. package/dist/validation/index.js +504 -2
  47. package/dist/validation/index.js.map +1 -1
  48. package/dist/validation/index.mjs +498 -3
  49. package/dist/validation/index.mjs.map +1 -1
  50. package/package.json +114 -109
  51. package/dist/index-BgHPM7LC.d.ts +0 -129
  52. package/dist/index-BpT7flAQ.d.ts +0 -255
  53. package/dist/index-JaFOUKyK.d.mts +0 -255
  54. package/dist/index-nAgXexwD.d.mts +0 -129
@@ -1,5 +1,5 @@
1
1
  import { RequestHandler } from 'express';
2
- import { i as SanitizeOptions, j as SanitizeResult } from './types-BOdL3ZWo.mjs';
2
+ import { i as SanitizeOptions, j as SanitizeResult } from './types-CsOFHoD9.mjs';
3
3
 
4
4
  /**
5
5
  * @module @arcis/node/sanitizers/sanitize
@@ -170,6 +170,80 @@ declare function sanitizeCommand(input: string, collectThreats: true): SanitizeR
170
170
  */
171
171
  declare function detectCommandInjection(input: string): boolean;
172
172
 
173
+ /**
174
+ * @module @arcis/node/sanitizers/ssti
175
+ * Server-Side Template Injection (SSTI) prevention
176
+ */
177
+
178
+ /**
179
+ * Sanitizes a string to prevent SSTI attacks.
180
+ * Removes template expression syntax.
181
+ */
182
+ declare function sanitizeSsti(input: string, collectThreats?: false): string;
183
+ declare function sanitizeSsti(input: string, collectThreats: true): SanitizeResult;
184
+ /**
185
+ * Checks if a string contains SSTI patterns.
186
+ * Does not sanitize — use sanitizeSsti() for that.
187
+ *
188
+ * @param input - The string to check
189
+ * @returns True if SSTI patterns detected
190
+ */
191
+ declare function detectSsti(input: string): boolean;
192
+
193
+ /**
194
+ * @module @arcis/node/sanitizers/xxe
195
+ * XML External Entity (XXE) injection prevention
196
+ */
197
+
198
+ /**
199
+ * Sanitizes a string to prevent XXE attacks.
200
+ * Removes DOCTYPE, ENTITY, and CDATA constructs.
201
+ */
202
+ declare function sanitizeXxe(input: string, collectThreats?: false): string;
203
+ declare function sanitizeXxe(input: string, collectThreats: true): SanitizeResult;
204
+ /**
205
+ * Checks if a string contains XXE patterns.
206
+ * Does not sanitize — use sanitizeXxe() for that.
207
+ *
208
+ * @param input - The string to check
209
+ * @returns True if XXE patterns detected
210
+ */
211
+ declare function detectXxe(input: string): boolean;
212
+
213
+ /**
214
+ * @module @arcis/node/sanitizers/jsonp
215
+ * JSONP callback sanitization to prevent XSS via callback parameters
216
+ */
217
+ /**
218
+ * Validates and sanitizes a JSONP callback parameter.
219
+ *
220
+ * Returns the callback name if safe, or null if the callback is dangerous.
221
+ * Use this to validate `?callback=` query parameters before wrapping responses.
222
+ *
223
+ * @param callback - The callback parameter value
224
+ * @param maxLength - Maximum allowed length (default: 128)
225
+ * @returns The safe callback name, or null if invalid
226
+ *
227
+ * @example
228
+ * ```ts
229
+ * const cb = sanitizeJsonpCallback(req.query.callback);
230
+ * if (cb) {
231
+ * res.set('Content-Type', 'application/javascript');
232
+ * res.send(`${cb}(${JSON.stringify(data)})`);
233
+ * } else {
234
+ * res.status(400).json({ error: 'Invalid callback' });
235
+ * }
236
+ * ```
237
+ */
238
+ declare function sanitizeJsonpCallback(callback: string, maxLength?: number): string | null;
239
+ /**
240
+ * Checks if a JSONP callback parameter contains potentially dangerous content.
241
+ *
242
+ * @param callback - The callback parameter value
243
+ * @returns True if the callback is dangerous / invalid
244
+ */
245
+ declare function detectJsonpInjection(callback: string): boolean;
246
+
173
247
  /**
174
248
  * @module @arcis/node/sanitizers/nosql
175
249
  * NoSQL injection prevention (MongoDB operators)
@@ -281,4 +355,84 @@ declare function sanitizeHeaders(headers: Record<string, string>): Record<string
281
355
  */
282
356
  declare function detectHeaderInjection(input: string): boolean;
283
357
 
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 };
358
+ /**
359
+ * @module @arcis/node/sanitizers/pii
360
+ * PII (Personally Identifiable Information) detection and redaction
361
+ *
362
+ * Detects: email addresses, phone numbers, credit card numbers, SSNs, IP addresses
363
+ */
364
+ type PiiType = 'email' | 'phone' | 'credit_card' | 'ssn' | 'ip_address';
365
+ interface PiiMatch {
366
+ type: PiiType;
367
+ value: string;
368
+ start: number;
369
+ end: number;
370
+ }
371
+ interface PiiScanOptions {
372
+ /** PII types to scan for. Default: all types */
373
+ types?: PiiType[];
374
+ }
375
+ interface PiiRedactOptions extends PiiScanOptions {
376
+ /** Replacement for redacted values. Default: '[REDACTED]' */
377
+ replacement?: string;
378
+ /** Use type-specific replacements like '[EMAIL]', '[SSN]'. Default: false */
379
+ typeLabels?: boolean;
380
+ }
381
+ /**
382
+ * Scan a string for PII and return all matches.
383
+ *
384
+ * @param input - String to scan
385
+ * @param options - Optional scan configuration
386
+ * @returns Array of PII matches with type, value, and position
387
+ *
388
+ * @example
389
+ * scanPii('Call me at 555-123-4567 or email john@example.com')
390
+ * // [
391
+ * // { type: 'phone', value: '555-123-4567', start: 11, end: 23 },
392
+ * // { type: 'email', value: 'john@example.com', start: 33, end: 49 }
393
+ * // ]
394
+ */
395
+ declare function scanPii(input: string, options?: PiiScanOptions): PiiMatch[];
396
+ /**
397
+ * Check if a string contains any PII.
398
+ *
399
+ * @param input - String to check
400
+ * @param options - Optional scan configuration
401
+ * @returns true if PII is detected
402
+ */
403
+ declare function detectPii(input: string, options?: PiiScanOptions): boolean;
404
+ /**
405
+ * Redact PII from a string, replacing matches with a placeholder.
406
+ *
407
+ * @param input - String to redact
408
+ * @param options - Redaction options
409
+ * @returns String with PII replaced
410
+ *
411
+ * @example
412
+ * redactPii('Email: john@example.com, SSN: 123-45-6789')
413
+ * // 'Email: [REDACTED], SSN: [REDACTED]'
414
+ *
415
+ * redactPii('Email: john@example.com', { typeLabels: true })
416
+ * // 'Email: [EMAIL]'
417
+ */
418
+ declare function redactPii(input: string, options?: PiiRedactOptions): string;
419
+ /**
420
+ * Scan an object's string values for PII recursively.
421
+ *
422
+ * @param obj - Object to scan
423
+ * @param options - Optional scan configuration
424
+ * @returns Array of PII matches with the field path prepended
425
+ */
426
+ declare function scanObjectPii(obj: Record<string, unknown>, options?: PiiScanOptions, path?: string): (PiiMatch & {
427
+ field: string;
428
+ })[];
429
+ /**
430
+ * Redact PII from all string values in an object recursively.
431
+ *
432
+ * @param obj - Object to redact
433
+ * @param options - Redaction options
434
+ * @returns New object with PII redacted
435
+ */
436
+ declare function redactObjectPii<T extends Record<string, unknown>>(obj: T, options?: PiiRedactOptions): T;
437
+
438
+ export { sanitizeString as A, sanitizeXss as B, sanitizeXxe as C, scanObjectPii as D, scanPii as E, type PiiRedactOptions as F, type PiiScanOptions as G, type PiiType as H, type PiiMatch as P, detectHeaderInjection as a, detectJsonpInjection as b, createSanitizer as c, detectCommandInjection as d, detectNoSqlInjection as e, detectPathTraversal as f, detectPii as g, detectPrototypePollution as h, detectSql as i, detectSsti as j, detectXss as k, detectXxe as l, getDangerousOperators as m, getDangerousProtoKeys as n, isDangerousNoSqlKey as o, isDangerousProtoKey as p, redactPii as q, redactObjectPii as r, sanitizeCommand as s, sanitizeHeaderValue as t, sanitizeHeaders as u, sanitizeJsonpCallback as v, sanitizeObject as w, sanitizePath as x, sanitizeSql as y, sanitizeSsti as z };
@@ -1,5 +1,5 @@
1
1
  import { RequestHandler } from 'express';
2
- import { i as SanitizeOptions, j as SanitizeResult } from './types-BOdL3ZWo.js';
2
+ import { i as SanitizeOptions, j as SanitizeResult } from './types-CsOFHoD9.js';
3
3
 
4
4
  /**
5
5
  * @module @arcis/node/sanitizers/sanitize
@@ -170,6 +170,80 @@ declare function sanitizeCommand(input: string, collectThreats: true): SanitizeR
170
170
  */
171
171
  declare function detectCommandInjection(input: string): boolean;
172
172
 
173
+ /**
174
+ * @module @arcis/node/sanitizers/ssti
175
+ * Server-Side Template Injection (SSTI) prevention
176
+ */
177
+
178
+ /**
179
+ * Sanitizes a string to prevent SSTI attacks.
180
+ * Removes template expression syntax.
181
+ */
182
+ declare function sanitizeSsti(input: string, collectThreats?: false): string;
183
+ declare function sanitizeSsti(input: string, collectThreats: true): SanitizeResult;
184
+ /**
185
+ * Checks if a string contains SSTI patterns.
186
+ * Does not sanitize — use sanitizeSsti() for that.
187
+ *
188
+ * @param input - The string to check
189
+ * @returns True if SSTI patterns detected
190
+ */
191
+ declare function detectSsti(input: string): boolean;
192
+
193
+ /**
194
+ * @module @arcis/node/sanitizers/xxe
195
+ * XML External Entity (XXE) injection prevention
196
+ */
197
+
198
+ /**
199
+ * Sanitizes a string to prevent XXE attacks.
200
+ * Removes DOCTYPE, ENTITY, and CDATA constructs.
201
+ */
202
+ declare function sanitizeXxe(input: string, collectThreats?: false): string;
203
+ declare function sanitizeXxe(input: string, collectThreats: true): SanitizeResult;
204
+ /**
205
+ * Checks if a string contains XXE patterns.
206
+ * Does not sanitize — use sanitizeXxe() for that.
207
+ *
208
+ * @param input - The string to check
209
+ * @returns True if XXE patterns detected
210
+ */
211
+ declare function detectXxe(input: string): boolean;
212
+
213
+ /**
214
+ * @module @arcis/node/sanitizers/jsonp
215
+ * JSONP callback sanitization to prevent XSS via callback parameters
216
+ */
217
+ /**
218
+ * Validates and sanitizes a JSONP callback parameter.
219
+ *
220
+ * Returns the callback name if safe, or null if the callback is dangerous.
221
+ * Use this to validate `?callback=` query parameters before wrapping responses.
222
+ *
223
+ * @param callback - The callback parameter value
224
+ * @param maxLength - Maximum allowed length (default: 128)
225
+ * @returns The safe callback name, or null if invalid
226
+ *
227
+ * @example
228
+ * ```ts
229
+ * const cb = sanitizeJsonpCallback(req.query.callback);
230
+ * if (cb) {
231
+ * res.set('Content-Type', 'application/javascript');
232
+ * res.send(`${cb}(${JSON.stringify(data)})`);
233
+ * } else {
234
+ * res.status(400).json({ error: 'Invalid callback' });
235
+ * }
236
+ * ```
237
+ */
238
+ declare function sanitizeJsonpCallback(callback: string, maxLength?: number): string | null;
239
+ /**
240
+ * Checks if a JSONP callback parameter contains potentially dangerous content.
241
+ *
242
+ * @param callback - The callback parameter value
243
+ * @returns True if the callback is dangerous / invalid
244
+ */
245
+ declare function detectJsonpInjection(callback: string): boolean;
246
+
173
247
  /**
174
248
  * @module @arcis/node/sanitizers/nosql
175
249
  * NoSQL injection prevention (MongoDB operators)
@@ -281,4 +355,84 @@ declare function sanitizeHeaders(headers: Record<string, string>): Record<string
281
355
  */
282
356
  declare function detectHeaderInjection(input: string): boolean;
283
357
 
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 };
358
+ /**
359
+ * @module @arcis/node/sanitizers/pii
360
+ * PII (Personally Identifiable Information) detection and redaction
361
+ *
362
+ * Detects: email addresses, phone numbers, credit card numbers, SSNs, IP addresses
363
+ */
364
+ type PiiType = 'email' | 'phone' | 'credit_card' | 'ssn' | 'ip_address';
365
+ interface PiiMatch {
366
+ type: PiiType;
367
+ value: string;
368
+ start: number;
369
+ end: number;
370
+ }
371
+ interface PiiScanOptions {
372
+ /** PII types to scan for. Default: all types */
373
+ types?: PiiType[];
374
+ }
375
+ interface PiiRedactOptions extends PiiScanOptions {
376
+ /** Replacement for redacted values. Default: '[REDACTED]' */
377
+ replacement?: string;
378
+ /** Use type-specific replacements like '[EMAIL]', '[SSN]'. Default: false */
379
+ typeLabels?: boolean;
380
+ }
381
+ /**
382
+ * Scan a string for PII and return all matches.
383
+ *
384
+ * @param input - String to scan
385
+ * @param options - Optional scan configuration
386
+ * @returns Array of PII matches with type, value, and position
387
+ *
388
+ * @example
389
+ * scanPii('Call me at 555-123-4567 or email john@example.com')
390
+ * // [
391
+ * // { type: 'phone', value: '555-123-4567', start: 11, end: 23 },
392
+ * // { type: 'email', value: 'john@example.com', start: 33, end: 49 }
393
+ * // ]
394
+ */
395
+ declare function scanPii(input: string, options?: PiiScanOptions): PiiMatch[];
396
+ /**
397
+ * Check if a string contains any PII.
398
+ *
399
+ * @param input - String to check
400
+ * @param options - Optional scan configuration
401
+ * @returns true if PII is detected
402
+ */
403
+ declare function detectPii(input: string, options?: PiiScanOptions): boolean;
404
+ /**
405
+ * Redact PII from a string, replacing matches with a placeholder.
406
+ *
407
+ * @param input - String to redact
408
+ * @param options - Redaction options
409
+ * @returns String with PII replaced
410
+ *
411
+ * @example
412
+ * redactPii('Email: john@example.com, SSN: 123-45-6789')
413
+ * // 'Email: [REDACTED], SSN: [REDACTED]'
414
+ *
415
+ * redactPii('Email: john@example.com', { typeLabels: true })
416
+ * // 'Email: [EMAIL]'
417
+ */
418
+ declare function redactPii(input: string, options?: PiiRedactOptions): string;
419
+ /**
420
+ * Scan an object's string values for PII recursively.
421
+ *
422
+ * @param obj - Object to scan
423
+ * @param options - Optional scan configuration
424
+ * @returns Array of PII matches with the field path prepended
425
+ */
426
+ declare function scanObjectPii(obj: Record<string, unknown>, options?: PiiScanOptions, path?: string): (PiiMatch & {
427
+ field: string;
428
+ })[];
429
+ /**
430
+ * Redact PII from all string values in an object recursively.
431
+ *
432
+ * @param obj - Object to redact
433
+ * @param options - Redaction options
434
+ * @returns New object with PII redacted
435
+ */
436
+ declare function redactObjectPii<T extends Record<string, unknown>>(obj: T, options?: PiiRedactOptions): T;
437
+
438
+ export { sanitizeString as A, sanitizeXss as B, sanitizeXxe as C, scanObjectPii as D, scanPii as E, type PiiRedactOptions as F, type PiiScanOptions as G, type PiiType as H, type PiiMatch as P, detectHeaderInjection as a, detectJsonpInjection as b, createSanitizer as c, detectCommandInjection as d, detectNoSqlInjection as e, detectPathTraversal as f, detectPii as g, detectPrototypePollution as h, detectSql as i, detectSsti as j, detectXss as k, detectXxe as l, getDangerousOperators as m, getDangerousProtoKeys as n, isDangerousNoSqlKey as o, isDangerousProtoKey as p, redactPii as q, redactObjectPii as r, sanitizeCommand as s, sanitizeHeaderValue as t, sanitizeHeaders as u, sanitizeJsonpCallback as v, sanitizeObject as w, sanitizePath as x, sanitizeSql as y, sanitizeSsti as z };
@@ -1,6 +1,6 @@
1
- export { c as createSanitizer, d as detectCommandInjection, a as detectHeaderInjection, b as detectNoSqlInjection, e as detectPathTraversal, f as detectPrototypePollution, g as detectSql, h as detectXss, i as getDangerousOperators, j as getDangerousProtoKeys, k as isDangerousNoSqlKey, l as isDangerousProtoKey, s as sanitizeCommand, m as sanitizeHeaderValue, n as sanitizeHeaders, o as sanitizeObject, p as sanitizePath, q as sanitizeSql, r as sanitizeString, t as sanitizeXss } from '../headers-DBQedhrb.mjs';
1
+ export { c as createSanitizer, d as detectCommandInjection, a as detectHeaderInjection, b as detectJsonpInjection, e as detectNoSqlInjection, f as detectPathTraversal, g as detectPii, h as detectPrototypePollution, i as detectSql, j as detectSsti, k as detectXss, l as detectXxe, m as getDangerousOperators, n as getDangerousProtoKeys, o as isDangerousNoSqlKey, p as isDangerousProtoKey, r as redactObjectPii, q as redactPii, s as sanitizeCommand, t as sanitizeHeaderValue, u as sanitizeHeaders, v as sanitizeJsonpCallback, w as sanitizeObject, x as sanitizePath, y as sanitizeSql, z as sanitizeSsti, A as sanitizeString, B as sanitizeXss, C as sanitizeXxe, D as scanObjectPii, E as scanPii } from '../pii-CXcHMlnX.mjs';
2
2
  import 'express';
3
- import '../types-BOdL3ZWo.mjs';
3
+ import '../types-CsOFHoD9.mjs';
4
4
 
5
5
  /**
6
6
  * @module @arcis/node/sanitizers/utils
@@ -1,6 +1,6 @@
1
- export { c as createSanitizer, d as detectCommandInjection, a as detectHeaderInjection, b as detectNoSqlInjection, e as detectPathTraversal, f as detectPrototypePollution, g as detectSql, h as detectXss, i as getDangerousOperators, j as getDangerousProtoKeys, k as isDangerousNoSqlKey, l as isDangerousProtoKey, s as sanitizeCommand, m as sanitizeHeaderValue, n as sanitizeHeaders, o as sanitizeObject, p as sanitizePath, q as sanitizeSql, r as sanitizeString, t as sanitizeXss } from '../headers-BJq2OA0i.js';
1
+ export { c as createSanitizer, d as detectCommandInjection, a as detectHeaderInjection, b as detectJsonpInjection, e as detectNoSqlInjection, f as detectPathTraversal, g as detectPii, h as detectPrototypePollution, i as detectSql, j as detectSsti, k as detectXss, l as detectXxe, m as getDangerousOperators, n as getDangerousProtoKeys, o as isDangerousNoSqlKey, p as isDangerousProtoKey, r as redactObjectPii, q as redactPii, s as sanitizeCommand, t as sanitizeHeaderValue, u as sanitizeHeaders, v as sanitizeJsonpCallback, w as sanitizeObject, x as sanitizePath, y as sanitizeSql, z as sanitizeSsti, A as sanitizeString, B as sanitizeXss, C as sanitizeXxe, D as scanObjectPii, E as scanPii } from '../pii-DhNpl7M3.js';
2
2
  import 'express';
3
- import '../types-BOdL3ZWo.js';
3
+ import '../types-CsOFHoD9.js';
4
4
 
5
5
  /**
6
6
  * @module @arcis/node/sanitizers/utils