@digilogiclabs/platform-core 1.17.2 → 1.18.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.
@@ -22,6 +22,47 @@ declare function containsUrls(str: string): boolean;
22
22
  declare function containsHtml(str: string): boolean;
23
23
  /** Strip all HTML tags from a string */
24
24
  declare function stripHtml(str: string): string;
25
+ /**
26
+ * Strip null bytes (U+0000) from a string.
27
+ *
28
+ * Postgres rejects null bytes in `text`/`varchar` columns with a hard
29
+ * `invalid byte sequence` error (→ HTTP 500 in app handlers). Apps that
30
+ * forward raw user input — search queries, filter params, form fields —
31
+ * into Drizzle/raw SQL queries hit this on malicious or malformed clients
32
+ * that inject `%00` in URLs.
33
+ *
34
+ * Pass `undefined`/`null` through unchanged so it composes cleanly with
35
+ * optional query params: `stripNullBytes(url.searchParams.get('q'))?.trim()`.
36
+ *
37
+ * @example
38
+ * ```typescript
39
+ * import { stripNullBytes } from '@digilogiclabs/platform-core/auth';
40
+ *
41
+ * const q = stripNullBytes(url.searchParams.get('q'))?.trim();
42
+ * const results = await db.select().where(ilike(column, `%${q}%`));
43
+ * ```
44
+ */
45
+ declare function stripNullBytes(value: string): string;
46
+ declare function stripNullBytes(value: null | undefined): null | undefined;
47
+ declare function stripNullBytes(value: string | null | undefined): string | null | undefined;
48
+ /**
49
+ * Recursively strip null bytes from all string values in a plain object or
50
+ * array. Non-string values pass through unchanged. Use on parsed JSON
51
+ * request bodies before forwarding to DB queries.
52
+ *
53
+ * Preserves the object's own keys and order; does NOT mutate the input.
54
+ * Arrays stay arrays. Stops at 8 levels deep as a guard against accidental
55
+ * circular references (throws at depth-limit exceeded).
56
+ *
57
+ * @example
58
+ * ```typescript
59
+ * import { stripNullBytesDeep } from '@digilogiclabs/platform-core/auth';
60
+ *
61
+ * const body = stripNullBytesDeep(await request.json());
62
+ * const parsed = schema.safeParse(body);
63
+ * ```
64
+ */
65
+ declare function stripNullBytesDeep<T>(value: T, depth?: number): T;
25
66
  /**
26
67
  * Defang URLs to prevent auto-linking in email clients.
27
68
  * Converts https://evil.com → hxxps://evil[.]com
@@ -85,4 +126,4 @@ declare function sanitizeApiError(error: unknown, statusCode: number, isDevelopm
85
126
  */
86
127
  declare function getCorrelationId(headers: Record<string, string | string[] | undefined> | ((name: string) => string | null | undefined)): string;
87
128
 
88
- export { HTML_TAG_PATTERN as H, URL_PROTOCOL_PATTERN as U, containsUrls as a, containsHtml as b, constantTimeEqual as c, sanitizeApiError as d, escapeHtml as e, defangUrl as f, getCorrelationId as g, sanitizeForEmail as h, URL_DOMAIN_PATTERN as i, stripHtml as s };
129
+ export { HTML_TAG_PATTERN as H, URL_PROTOCOL_PATTERN as U, containsUrls as a, containsHtml as b, constantTimeEqual as c, stripNullBytes as d, escapeHtml as e, stripNullBytesDeep as f, sanitizeApiError as g, getCorrelationId as h, defangUrl as i, sanitizeForEmail as j, URL_DOMAIN_PATTERN as k, stripHtml as s };
@@ -22,6 +22,47 @@ declare function containsUrls(str: string): boolean;
22
22
  declare function containsHtml(str: string): boolean;
23
23
  /** Strip all HTML tags from a string */
24
24
  declare function stripHtml(str: string): string;
25
+ /**
26
+ * Strip null bytes (U+0000) from a string.
27
+ *
28
+ * Postgres rejects null bytes in `text`/`varchar` columns with a hard
29
+ * `invalid byte sequence` error (→ HTTP 500 in app handlers). Apps that
30
+ * forward raw user input — search queries, filter params, form fields —
31
+ * into Drizzle/raw SQL queries hit this on malicious or malformed clients
32
+ * that inject `%00` in URLs.
33
+ *
34
+ * Pass `undefined`/`null` through unchanged so it composes cleanly with
35
+ * optional query params: `stripNullBytes(url.searchParams.get('q'))?.trim()`.
36
+ *
37
+ * @example
38
+ * ```typescript
39
+ * import { stripNullBytes } from '@digilogiclabs/platform-core/auth';
40
+ *
41
+ * const q = stripNullBytes(url.searchParams.get('q'))?.trim();
42
+ * const results = await db.select().where(ilike(column, `%${q}%`));
43
+ * ```
44
+ */
45
+ declare function stripNullBytes(value: string): string;
46
+ declare function stripNullBytes(value: null | undefined): null | undefined;
47
+ declare function stripNullBytes(value: string | null | undefined): string | null | undefined;
48
+ /**
49
+ * Recursively strip null bytes from all string values in a plain object or
50
+ * array. Non-string values pass through unchanged. Use on parsed JSON
51
+ * request bodies before forwarding to DB queries.
52
+ *
53
+ * Preserves the object's own keys and order; does NOT mutate the input.
54
+ * Arrays stay arrays. Stops at 8 levels deep as a guard against accidental
55
+ * circular references (throws at depth-limit exceeded).
56
+ *
57
+ * @example
58
+ * ```typescript
59
+ * import { stripNullBytesDeep } from '@digilogiclabs/platform-core/auth';
60
+ *
61
+ * const body = stripNullBytesDeep(await request.json());
62
+ * const parsed = schema.safeParse(body);
63
+ * ```
64
+ */
65
+ declare function stripNullBytesDeep<T>(value: T, depth?: number): T;
25
66
  /**
26
67
  * Defang URLs to prevent auto-linking in email clients.
27
68
  * Converts https://evil.com → hxxps://evil[.]com
@@ -85,4 +126,4 @@ declare function sanitizeApiError(error: unknown, statusCode: number, isDevelopm
85
126
  */
86
127
  declare function getCorrelationId(headers: Record<string, string | string[] | undefined> | ((name: string) => string | null | undefined)): string;
87
128
 
88
- export { HTML_TAG_PATTERN as H, URL_PROTOCOL_PATTERN as U, containsUrls as a, containsHtml as b, constantTimeEqual as c, sanitizeApiError as d, escapeHtml as e, defangUrl as f, getCorrelationId as g, sanitizeForEmail as h, URL_DOMAIN_PATTERN as i, stripHtml as s };
129
+ export { HTML_TAG_PATTERN as H, URL_PROTOCOL_PATTERN as U, containsUrls as a, containsHtml as b, constantTimeEqual as c, stripNullBytes as d, escapeHtml as e, stripNullBytesDeep as f, sanitizeApiError as g, getCorrelationId as h, defangUrl as i, sanitizeForEmail as j, URL_DOMAIN_PATTERN as k, stripHtml as s };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digilogiclabs/platform-core",
3
- "version": "1.17.2",
3
+ "version": "1.18.0",
4
4
  "description": "Vendor-agnostic infrastructure abstraction layer for DLL Platform",
5
5
  "keywords": [
6
6
  "platform",