@digilogiclabs/platform-core 1.17.2 → 1.17.3

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.
package/dist/auth.mjs CHANGED
@@ -359,6 +359,29 @@ function containsHtml(str) {
359
359
  function stripHtml(str) {
360
360
  return str.replace(/<[^>]*>/g, "");
361
361
  }
362
+ function stripNullBytes(value) {
363
+ if (value === null || value === void 0) return value;
364
+ return value.replace(/\u0000/g, "");
365
+ }
366
+ function stripNullBytesDeep(value, depth = 8) {
367
+ if (depth <= 0) {
368
+ throw new Error("stripNullBytesDeep: max depth exceeded (circular?)");
369
+ }
370
+ if (typeof value === "string") {
371
+ return value.replace(/\u0000/g, "");
372
+ }
373
+ if (Array.isArray(value)) {
374
+ return value.map((v) => stripNullBytesDeep(v, depth - 1));
375
+ }
376
+ if (value !== null && typeof value === "object") {
377
+ const out = {};
378
+ for (const [k, v] of Object.entries(value)) {
379
+ out[k] = stripNullBytesDeep(v, depth - 1);
380
+ }
381
+ return out;
382
+ }
383
+ return value;
384
+ }
362
385
  function constantTimeEqual(a, b) {
363
386
  try {
364
387
  const aBuf = Buffer.from(a, "utf-8");
@@ -1897,6 +1920,8 @@ export {
1897
1920
  sanitizeApiError,
1898
1921
  storeBetaCode,
1899
1922
  stripHtml,
1923
+ stripNullBytes,
1924
+ stripNullBytesDeep,
1900
1925
  validateBetaCode,
1901
1926
  validateEnvVars,
1902
1927
  verifyCronAuth,