xypriss 9.12.40 → 9.12.41

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 (2) hide show
  1. package/dist/index.d.ts +75 -5
  2. package/package.json +1 -1
package/dist/index.d.ts CHANGED
@@ -321,18 +321,88 @@ interface PaginationInfo {
321
321
  * Configuration for internal response manipulation.
322
322
  *
323
323
  /**
324
- * Rules for masking or replacing fields in responses.
324
+ * Defines a rule for masking, replacing, or redacting field keys/values in JSON responses.
325
+ *
326
+ * Response manipulation rules are processed natively by XHSC (Go engine) with zero Node.js overhead.
327
+ * They allow automatic redaction of sensitive credentials, PII (emails, API keys), and system file paths.
328
+ *
329
+ * @see {@link https://xypriss.nehonix.com/docs/security/response-manipulation}
330
+ *
331
+ * @example
332
+ * ### 1. Redact Internal System Paths in Error Messages (`replaceMatch`)
333
+ * ```ts
334
+ * {
335
+ * valuePattern: /(?<=\s|^|["':(])(?:[a-zA-Z]:[/\\][a-zA-Z0-9_.-]+(?:[/\\][a-zA-Z0-9_.-]+)*|\/(?:[a-zA-Z0-9_.-]+\/)+[a-zA-Z0-9_.-]*)/g,
336
+ * replaceMatch: "[REDACTED_PATH]",
337
+ * }
338
+ * // Input: { error: "fs.move failed: /tmp/xuser/521f00d8/file.jpg to /storage/public" }
339
+ * // Output: { error: "fs.move failed: [REDACTED_PATH] to [REDACTED_PATH]" }
340
+ * ```
341
+ *
342
+ * @example
343
+ * ### 2. Partial Masking of API Keys preserving prefix (`preserve`)
344
+ * ```ts
345
+ * {
346
+ * field: "api_key",
347
+ * preserve: 4,
348
+ * }
349
+ * // Input: { api_key: "xy_live_998877665544332211" }
350
+ * // Output: { api_key: "xy_l********************" }
351
+ * ```
352
+ *
353
+ * @example
354
+ * ### 3. Complete Field Replacement (`replacement`)
355
+ * ```ts
356
+ * {
357
+ * field: "user.password",
358
+ * replacement: "********",
359
+ * }
360
+ * // Input: { user: { password: "mySecretPassword123" } }
361
+ * // Output: { user: { password: "********" } }
362
+ * ```
325
363
  *
326
364
  * @interface ResponseManipulationRule
327
365
  */
328
366
  interface ResponseManipulationRule {
329
- /** Field name (dot notation) or RegExp pattern for matching keys */
367
+ /**
368
+ * Target field name (dot notation e.g., `"user.password"`) or RegExp pattern for matching JSON keys.
369
+ * If omitted, the rule evaluates against all JSON string values using `valuePattern`.
370
+ */
330
371
  field?: string | RegExp;
331
- /** RegExp pattern for matching field values */
372
+ /**
373
+ * RegExp pattern for matching string field values (e.g. matching file paths, email formats, or JWT tokens).
374
+ */
332
375
  valuePattern?: RegExp;
333
- /** Mask string (e.g., "****") or replacement value */
376
+ /**
377
+ * Replacement string for replacing **ONLY the matched substring** (via regex substitution)
378
+ * instead of replacing the entire JSON field value.
379
+ *
380
+ * @example
381
+ * // Replaces "/tmp/secret.png" with "[REDACTED_PATH]" inside a longer error string
382
+ * replaceMatch: "[REDACTED_PATH]"
383
+ */
384
+ replaceMatch?: string;
385
+ /**
386
+ * When set to `true`, forces `replacement` to operate as a substring replacement for `valuePattern`
387
+ * matches rather than replacing the entire field value.
388
+ * @default false
389
+ */
390
+ replaceOnlyMatch?: boolean;
391
+ /**
392
+ * Replacement value or mask string for replacing the **ENTIRE field value**.
393
+ * Can be a string, number, boolean, or object.
394
+ *
395
+ * @example
396
+ * replacement: "[MASKED_CREDENTIAL]"
397
+ */
334
398
  replacement?: any;
335
- /** Number of characters to preserve (at the beginning) for string masking */
399
+ /**
400
+ * Number of initial characters to preserve unmasked when masking string values.
401
+ *
402
+ * @example
403
+ * // preserve: 4 on "123456789" produces "1234*****"
404
+ * preserve: 4
405
+ */
336
406
  preserve?: number;
337
407
  }
338
408
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xypriss",
3
- "version": "9.12.40",
3
+ "version": "9.12.41",
4
4
  "description": "XyPriss is a high-performance, TypeScript-first hyper-system web framework powered by a native Go core (XHSC), featuring robust multi-tenant sandboxing, secure native file streaming, and zero Express dependencies.",
5
5
  "author": {
6
6
  "DEV.to": "https://dev.to/nehonix",