@zuplo/cli 7.14.8 → 7.15.1

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 (118) hide show
  1. package/LICENSE.third-party.txt +236 -0
  2. package/LICENSE.txt +5 -78
  3. package/README.md +18 -3
  4. package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/webapi/jwe/general/decrypt.js +3 -2
  5. package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/webapi/jwks/remote.js +1 -1
  6. package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/webapi/jws/general/verify.js +2 -8
  7. package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/webapi/lib/jwe_decrypt.js +11 -8
  8. package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/webapi/lib/jwt_claims_set.js +2 -0
  9. package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/webapi/lib/key_management.js +0 -1
  10. package/node_modules/@modelcontextprotocol/client/node_modules/jose/package.json +1 -1
  11. package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/jwe/general/decrypt.js +3 -2
  12. package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/jwks/remote.js +1 -1
  13. package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/jws/general/verify.js +2 -8
  14. package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/lib/jwe_decrypt.js +11 -8
  15. package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/lib/jwt_claims_set.js +2 -0
  16. package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/lib/key_management.js +0 -1
  17. package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/package.json +1 -1
  18. package/node_modules/@posthog/core/dist/privacy.d.ts +6 -1
  19. package/node_modules/@posthog/core/dist/privacy.d.ts.map +1 -1
  20. package/node_modules/@posthog/core/dist/privacy.js +69 -10
  21. package/node_modules/@posthog/core/dist/privacy.mjs +65 -9
  22. package/node_modules/@posthog/core/dist/traces/span.d.ts +6 -0
  23. package/node_modules/@posthog/core/dist/traces/span.d.ts.map +1 -1
  24. package/node_modules/@posthog/core/dist/traces/span.js +18 -0
  25. package/node_modules/@posthog/core/dist/traces/span.mjs +18 -0
  26. package/node_modules/@posthog/core/package.json +2 -2
  27. package/node_modules/@posthog/core/src/privacy.ts +100 -18
  28. package/node_modules/@posthog/core/src/traces/span.spec.ts +15 -1
  29. package/node_modules/@posthog/core/src/traces/span.ts +23 -0
  30. package/node_modules/@posthog/types/dist/traces.d.ts +10 -0
  31. package/node_modules/@posthog/types/dist/traces.d.ts.map +1 -1
  32. package/node_modules/@posthog/types/package.json +1 -1
  33. package/node_modules/@posthog/types/src/traces.ts +12 -0
  34. package/node_modules/@zuplo/core/LICENSE.third-party.txt +622 -0
  35. package/node_modules/@zuplo/core/LICENSE.txt +5 -78
  36. package/node_modules/@zuplo/core/README.md +7 -0
  37. package/node_modules/@zuplo/core/constants.minified.js +7 -20
  38. package/node_modules/@zuplo/core/customer.cli.minified.js +28 -41
  39. package/node_modules/@zuplo/core/index.minified.js +35 -48
  40. package/node_modules/@zuplo/core/package.json +4 -2
  41. package/node_modules/@zuplo/core/zeno.js +8 -21
  42. package/node_modules/@zuplo/graphql/LICENSE.third-party.txt +29 -0
  43. package/node_modules/@zuplo/graphql/LICENSE.txt +5 -78
  44. package/node_modules/@zuplo/graphql/README.md +7 -0
  45. package/node_modules/@zuplo/graphql/out/esm/index.js +7 -20
  46. package/node_modules/@zuplo/graphql/out/esm/index.js.map +1 -1
  47. package/node_modules/@zuplo/graphql/package.json +3 -2
  48. package/node_modules/@zuplo/openapi-tools/LICENSE.txt +7 -0
  49. package/node_modules/@zuplo/openapi-tools/README.md +7 -0
  50. package/node_modules/@zuplo/openapi-tools/package.json +3 -2
  51. package/node_modules/@zuplo/otel/LICENSE.third-party.txt +243 -0
  52. package/node_modules/@zuplo/otel/LICENSE.txt +5 -78
  53. package/node_modules/@zuplo/otel/README.md +33 -0
  54. package/node_modules/@zuplo/otel/out/esm/chunk-6YAK7LGJ.js +13 -0
  55. package/node_modules/@zuplo/otel/out/esm/chunk-6YAK7LGJ.js.map +1 -0
  56. package/node_modules/@zuplo/otel/out/esm/index.js +8 -21
  57. package/node_modules/@zuplo/otel/out/types/index.d.ts +41 -0
  58. package/node_modules/@zuplo/otel/package.json +3 -2
  59. package/node_modules/@zuplo/runtime/LICENSE.third-party.txt +511 -0
  60. package/node_modules/@zuplo/runtime/LICENSE.txt +5 -78
  61. package/node_modules/@zuplo/runtime/README.md +7 -0
  62. package/node_modules/@zuplo/runtime/out/esm/chunk-5JGLAPFA.js +13 -0
  63. package/node_modules/@zuplo/runtime/out/esm/chunk-5JGLAPFA.js.map +1 -0
  64. package/node_modules/@zuplo/runtime/out/esm/{chunk-6R2COTV6.js → chunk-AJ3MMWJS.js} +9 -22
  65. package/node_modules/@zuplo/runtime/out/esm/chunk-AJ3MMWJS.js.map +1 -0
  66. package/node_modules/@zuplo/runtime/out/esm/chunk-BH4DKEES.js +13 -0
  67. package/node_modules/@zuplo/runtime/out/esm/chunk-BH4DKEES.js.map +1 -0
  68. package/node_modules/@zuplo/runtime/out/esm/chunk-G42UYZ6V.js +24 -0
  69. package/node_modules/@zuplo/runtime/out/esm/{chunk-2HVCLUM4.js.map → chunk-G42UYZ6V.js.map} +1 -1
  70. package/node_modules/@zuplo/runtime/out/esm/chunk-OE2WMJXK.js +431 -0
  71. package/node_modules/@zuplo/runtime/out/esm/chunk-OE2WMJXK.js.map +1 -0
  72. package/node_modules/@zuplo/runtime/out/esm/chunk-R6UNMRUU.js +13 -0
  73. package/node_modules/@zuplo/runtime/out/esm/chunk-R6UNMRUU.js.map +1 -0
  74. package/node_modules/@zuplo/runtime/out/esm/{chunk-PY52EHDX.js → chunk-T2WKOG7J.js} +9 -22
  75. package/node_modules/@zuplo/runtime/out/esm/chunk-T2WKOG7J.js.map +1 -0
  76. package/node_modules/@zuplo/runtime/out/esm/{chunk-SNTU476S.js → chunk-TOJD4RET.js} +9 -22
  77. package/node_modules/@zuplo/runtime/out/esm/chunk-TOJD4RET.js.map +1 -0
  78. package/node_modules/@zuplo/runtime/out/esm/chunk-VXPFMOL5.js +13 -0
  79. package/node_modules/@zuplo/runtime/out/esm/chunk-VXPFMOL5.js.map +1 -0
  80. package/node_modules/@zuplo/runtime/out/esm/index.js +8 -21
  81. package/node_modules/@zuplo/runtime/out/esm/index.js.map +1 -1
  82. package/node_modules/@zuplo/runtime/out/esm/internal/index.js +8 -21
  83. package/node_modules/@zuplo/runtime/out/esm/mcp/messages/index.js +8 -21
  84. package/node_modules/@zuplo/runtime/out/esm/mcp-gateway/index.js +11 -39
  85. package/node_modules/@zuplo/runtime/out/esm/mcp-gateway/index.js.map +1 -1
  86. package/node_modules/@zuplo/runtime/out/esm/mocks/index.js +8 -21
  87. package/node_modules/@zuplo/runtime/out/esm/mocks/index.js.map +1 -1
  88. package/node_modules/@zuplo/runtime/out/esm/sdks/aws/index.js +8 -21
  89. package/node_modules/@zuplo/runtime/out/esm/sdks/aws/index.js.map +1 -1
  90. package/node_modules/@zuplo/runtime/out/types/index.d.ts +248 -6
  91. package/node_modules/@zuplo/runtime/out/types/internal/index.d.ts +101 -0
  92. package/node_modules/@zuplo/runtime/out/types/mcp-gateway/index.d.ts +127 -0
  93. package/node_modules/@zuplo/runtime/package.json +3 -2
  94. package/node_modules/ansi-regex/index.js +22 -17
  95. package/node_modules/ansi-regex/package.json +1 -1
  96. package/node_modules/ansi-regex/readme.md +8 -0
  97. package/node_modules/express-rate-limit/dist/index.cjs +33 -4
  98. package/node_modules/express-rate-limit/dist/index.mjs +33 -4
  99. package/node_modules/express-rate-limit/package.json +1 -1
  100. package/package.json +12 -11
  101. package/node_modules/@zuplo/otel/out/esm/chunk-PVCAT62X.js +0 -26
  102. package/node_modules/@zuplo/otel/out/esm/chunk-PVCAT62X.js.map +0 -1
  103. package/node_modules/@zuplo/runtime/out/esm/chunk-2HVCLUM4.js +0 -37
  104. package/node_modules/@zuplo/runtime/out/esm/chunk-6R2COTV6.js.map +0 -1
  105. package/node_modules/@zuplo/runtime/out/esm/chunk-A3QGJZO7.js +0 -26
  106. package/node_modules/@zuplo/runtime/out/esm/chunk-A3QGJZO7.js.map +0 -1
  107. package/node_modules/@zuplo/runtime/out/esm/chunk-DB6LKZ36.js +0 -429
  108. package/node_modules/@zuplo/runtime/out/esm/chunk-DB6LKZ36.js.map +0 -1
  109. package/node_modules/@zuplo/runtime/out/esm/chunk-PY52EHDX.js.map +0 -1
  110. package/node_modules/@zuplo/runtime/out/esm/chunk-SNTU476S.js.map +0 -1
  111. package/node_modules/@zuplo/runtime/out/esm/chunk-TYV53J3B.js +0 -26
  112. package/node_modules/@zuplo/runtime/out/esm/chunk-TYV53J3B.js.map +0 -1
  113. package/node_modules/@zuplo/runtime/out/esm/chunk-UKQQD2JN.js +0 -26
  114. package/node_modules/@zuplo/runtime/out/esm/chunk-UKQQD2JN.js.map +0 -1
  115. package/node_modules/@zuplo/runtime/out/esm/chunk-VP5Q3DEN.js +0 -26
  116. package/node_modules/@zuplo/runtime/out/esm/chunk-VP5Q3DEN.js.map +0 -1
  117. /package/node_modules/@zuplo/runtime/out/esm/{chunk-2HVCLUM4.js.LEGAL.txt → chunk-G42UYZ6V.js.LEGAL.txt} +0 -0
  118. /package/node_modules/@zuplo/runtime/out/esm/{chunk-DB6LKZ36.js.LEGAL.txt → chunk-OE2WMJXK.js.LEGAL.txt} +0 -0
@@ -55,7 +55,7 @@ const EMAIL_PATTERN = /[A-Za-z0-9._%+-]{1,64}@[A-Za-z0-9.-]{1,255}\.[A-Za-z]{2,2
55
55
  const IPV4_PATTERN = /\b(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\b/g;
56
56
  const IPV6_PATTERN = /(^|[^\w:])((?:(?:[0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4}|(?:[0-9A-Fa-f]{1,4}:){1,7}:|(?:[0-9A-Fa-f]{1,4}:){1,6}:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4}){0,5}|::(?:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4}){0,6})))(?=$|[^\w:])/g;
57
57
  const US_SSN_PATTERN = /\b\d{3}[ .-]\d{2}[ .-]\d{4}\b/g;
58
- const CREDIT_CARD_CANDIDATE_PATTERN = /\b\d(?:[ ./-]?\d){12,}\b/g;
58
+ const CARD_SEPARATORS = ' ./-';
59
59
  const DIGIT_GROUP_PATTERN = /\d+/g;
60
60
  const PHONE_NANP_PATTERN = /(^|[^\w+])((?:\+?1[ ./-]?)?(?:\(\d{3}\)[ ./-]?|\d{3}[ ./-])\d{3}[ ./-]\d{4})(?![\w])/g;
61
61
  const PHONE_INTL_PATTERN = /(^|[^\w])(\+\d{1,3}(?:[ ./()-]{0,2}\d){7,13})(?![\w])/g;
@@ -295,6 +295,40 @@ function passesLuhn(digits) {
295
295
  }
296
296
  return sum % 10 === 0;
297
297
  }
298
+ function isDigitAt(text, index) {
299
+ const code = text.charCodeAt(index);
300
+ return code >= 48 && code <= 57;
301
+ }
302
+ function isWordAt(text, index) {
303
+ const code = text.charCodeAt(index);
304
+ return isDigitAt(text, index) || 95 === code || code >= 65 && code <= 90 || code >= 97 && code <= 122;
305
+ }
306
+ function digitsEnd(text, index) {
307
+ let end = index;
308
+ while(isDigitAt(text, end))end++;
309
+ return end;
310
+ }
311
+ function findCardCandidate(text, from) {
312
+ for(let start = from; start < text.length; start++){
313
+ if (!isDigitAt(text, start) || isWordAt(text, start - 1)) continue;
314
+ let digits = 0;
315
+ let end = -1;
316
+ let groupStart = start;
317
+ for(;;){
318
+ const groupEnd = digitsEnd(text, groupStart);
319
+ digits += groupEnd - groupStart;
320
+ if (digits >= 13 && !isWordAt(text, groupEnd)) end = groupEnd;
321
+ groupStart = groupEnd + 1;
322
+ if (!CARD_SEPARATORS.includes(text.charAt(groupEnd)) || !isDigitAt(text, groupStart)) break;
323
+ }
324
+ if (end >= 0) return [
325
+ start,
326
+ end
327
+ ];
328
+ start = groupStart - 1;
329
+ }
330
+ return null;
331
+ }
298
332
  function redactCardInMatch(match) {
299
333
  const groups = [];
300
334
  for(let m = DIGIT_GROUP_PATTERN.exec(match); null !== m; m = DIGIT_GROUP_PATTERN.exec(match))groups.push({
@@ -321,48 +355,73 @@ function redactCardInMatch(match) {
321
355
  }
322
356
  return output + match.slice(cursor);
323
357
  }
358
+ function redactCards(text) {
359
+ let output = '';
360
+ let cursor = 0;
361
+ for(let run = findCardCandidate(text, 0); null !== run; run = findCardCandidate(text, run[1])){
362
+ output += text.slice(cursor, run[0]) + redactCardInMatch(text.slice(run[0], run[1]));
363
+ cursor = run[1];
364
+ }
365
+ return output + text.slice(cursor);
366
+ }
324
367
  function redactPii(value) {
325
368
  let result = value.replace(UNICODE_SPACE_PATTERN, ' ');
326
369
  result = result.replace(EMAIL_PATTERN, REDACTED_VALUE);
327
370
  result = result.replace(IPV4_PATTERN, REDACTED_VALUE);
328
371
  result = result.replace(IPV6_PATTERN, `$1${REDACTED_VALUE}`);
329
- result = result.replace(CREDIT_CARD_CANDIDATE_PATTERN, redactCardInMatch);
372
+ result = redactCards(result);
330
373
  result = result.replace(US_SSN_PATTERN, REDACTED_VALUE);
331
374
  result = result.replace(PHONE_NANP_PATTERN, `$1${REDACTED_VALUE}`);
332
375
  result = result.replace(PHONE_INTL_PATTERN, `$1${REDACTED_VALUE}`);
333
376
  return result;
334
377
  }
335
378
  function sanitizeCapturedValue(value, options) {
336
- return sanitizeValueWith(value, (stringValue)=>sanitizeString(stringValue, options));
379
+ return sanitizeValueWith(value, {
380
+ text: (stringValue)=>sanitizeString(stringValue, options),
381
+ readsKeysAndNumbers: false
382
+ });
337
383
  }
338
384
  function sanitizeFreeTextValue(value, options) {
339
- return sanitizeValueWith(value, (stringValue)=>sanitizeFreeText(stringValue, options));
385
+ return sanitizeValueWith(value, {
386
+ text: (stringValue)=>sanitizeFreeText(stringValue, options),
387
+ readsKeysAndNumbers: true
388
+ });
340
389
  }
341
- function sanitizeValueWith(value, sanitizeStringFn) {
390
+ function sanitizeValueWith(value, sanitizer) {
342
391
  if (null == value) return value;
343
- if ('string' == typeof value) return sanitizeStringFn(value);
344
- if (Array.isArray(value)) return value.map((item)=>sanitizeValueWith(item, sanitizeStringFn));
392
+ if ('string' == typeof value) return sanitizer.text(value);
393
+ if ('number' == typeof value && sanitizer.readsKeysAndNumbers) {
394
+ const text = String(value);
395
+ return sanitizer.text(text) === text ? value : REDACTED_VALUE;
396
+ }
397
+ if (Array.isArray(value)) return value.map((item)=>sanitizeValueWith(item, sanitizer));
345
398
  if (value instanceof Date) return value;
346
399
  if ('object' != typeof value) return value;
347
400
  const result = {};
348
- for (const [key, nestedValue] of Object.entries(value))result[key] = shouldRedactKey(key) ? REDACTED_VALUE : sanitizeValueWith(nestedValue, sanitizeStringFn);
401
+ for (const [key, nestedValue] of Object.entries(value)){
402
+ const capturedKey = sanitizer.readsKeysAndNumbers ? sanitizer.text(key) : key;
403
+ result[capturedKey] = shouldRedactKey(key) ? REDACTED_VALUE : sanitizeValueWith(nestedValue, sanitizer);
404
+ }
349
405
  return result;
350
406
  }
351
407
  __webpack_require__.d(__webpack_exports__, {
352
408
  redactPii: ()=>redactPii,
353
409
  sanitizeCapturedValue: ()=>sanitizeCapturedValue,
354
410
  sanitizeFreeText: ()=>sanitizeFreeText,
355
- sanitizeFreeTextValue: ()=>sanitizeFreeTextValue
411
+ sanitizeFreeTextValue: ()=>sanitizeFreeTextValue,
412
+ shouldRedactKey: ()=>shouldRedactKey
356
413
  });
357
414
  exports.redactPii = __webpack_exports__.redactPii;
358
415
  exports.sanitizeCapturedValue = __webpack_exports__.sanitizeCapturedValue;
359
416
  exports.sanitizeFreeText = __webpack_exports__.sanitizeFreeText;
360
417
  exports.sanitizeFreeTextValue = __webpack_exports__.sanitizeFreeTextValue;
418
+ exports.shouldRedactKey = __webpack_exports__.shouldRedactKey;
361
419
  for(var __rspack_i in __webpack_exports__)if (-1 === [
362
420
  "redactPii",
363
421
  "sanitizeCapturedValue",
364
422
  "sanitizeFreeText",
365
- "sanitizeFreeTextValue"
423
+ "sanitizeFreeTextValue",
424
+ "shouldRedactKey"
366
425
  ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
367
426
  Object.defineProperty(exports, '__esModule', {
368
427
  value: true
@@ -26,7 +26,7 @@ const EMAIL_PATTERN = /[A-Za-z0-9._%+-]{1,64}@[A-Za-z0-9.-]{1,255}\.[A-Za-z]{2,2
26
26
  const IPV4_PATTERN = /\b(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\b/g;
27
27
  const IPV6_PATTERN = /(^|[^\w:])((?:(?:[0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4}|(?:[0-9A-Fa-f]{1,4}:){1,7}:|(?:[0-9A-Fa-f]{1,4}:){1,6}:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4}){0,5}|::(?:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4}){0,6})))(?=$|[^\w:])/g;
28
28
  const US_SSN_PATTERN = /\b\d{3}[ .-]\d{2}[ .-]\d{4}\b/g;
29
- const CREDIT_CARD_CANDIDATE_PATTERN = /\b\d(?:[ ./-]?\d){12,}\b/g;
29
+ const CARD_SEPARATORS = ' ./-';
30
30
  const DIGIT_GROUP_PATTERN = /\d+/g;
31
31
  const PHONE_NANP_PATTERN = /(^|[^\w+])((?:\+?1[ ./-]?)?(?:\(\d{3}\)[ ./-]?|\d{3}[ ./-])\d{3}[ ./-]\d{4})(?![\w])/g;
32
32
  const PHONE_INTL_PATTERN = /(^|[^\w])(\+\d{1,3}(?:[ ./()-]{0,2}\d){7,13})(?![\w])/g;
@@ -266,6 +266,40 @@ function passesLuhn(digits) {
266
266
  }
267
267
  return sum % 10 === 0;
268
268
  }
269
+ function isDigitAt(text, index) {
270
+ const code = text.charCodeAt(index);
271
+ return code >= 48 && code <= 57;
272
+ }
273
+ function isWordAt(text, index) {
274
+ const code = text.charCodeAt(index);
275
+ return isDigitAt(text, index) || 95 === code || code >= 65 && code <= 90 || code >= 97 && code <= 122;
276
+ }
277
+ function digitsEnd(text, index) {
278
+ let end = index;
279
+ while(isDigitAt(text, end))end++;
280
+ return end;
281
+ }
282
+ function findCardCandidate(text, from) {
283
+ for(let start = from; start < text.length; start++){
284
+ if (!isDigitAt(text, start) || isWordAt(text, start - 1)) continue;
285
+ let digits = 0;
286
+ let end = -1;
287
+ let groupStart = start;
288
+ for(;;){
289
+ const groupEnd = digitsEnd(text, groupStart);
290
+ digits += groupEnd - groupStart;
291
+ if (digits >= 13 && !isWordAt(text, groupEnd)) end = groupEnd;
292
+ groupStart = groupEnd + 1;
293
+ if (!CARD_SEPARATORS.includes(text.charAt(groupEnd)) || !isDigitAt(text, groupStart)) break;
294
+ }
295
+ if (end >= 0) return [
296
+ start,
297
+ end
298
+ ];
299
+ start = groupStart - 1;
300
+ }
301
+ return null;
302
+ }
269
303
  function redactCardInMatch(match) {
270
304
  const groups = [];
271
305
  for(let m = DIGIT_GROUP_PATTERN.exec(match); null !== m; m = DIGIT_GROUP_PATTERN.exec(match))groups.push({
@@ -292,31 +326,53 @@ function redactCardInMatch(match) {
292
326
  }
293
327
  return output + match.slice(cursor);
294
328
  }
329
+ function redactCards(text) {
330
+ let output = '';
331
+ let cursor = 0;
332
+ for(let run = findCardCandidate(text, 0); null !== run; run = findCardCandidate(text, run[1])){
333
+ output += text.slice(cursor, run[0]) + redactCardInMatch(text.slice(run[0], run[1]));
334
+ cursor = run[1];
335
+ }
336
+ return output + text.slice(cursor);
337
+ }
295
338
  function redactPii(value) {
296
339
  let result = value.replace(UNICODE_SPACE_PATTERN, ' ');
297
340
  result = result.replace(EMAIL_PATTERN, REDACTED_VALUE);
298
341
  result = result.replace(IPV4_PATTERN, REDACTED_VALUE);
299
342
  result = result.replace(IPV6_PATTERN, `$1${REDACTED_VALUE}`);
300
- result = result.replace(CREDIT_CARD_CANDIDATE_PATTERN, redactCardInMatch);
343
+ result = redactCards(result);
301
344
  result = result.replace(US_SSN_PATTERN, REDACTED_VALUE);
302
345
  result = result.replace(PHONE_NANP_PATTERN, `$1${REDACTED_VALUE}`);
303
346
  result = result.replace(PHONE_INTL_PATTERN, `$1${REDACTED_VALUE}`);
304
347
  return result;
305
348
  }
306
349
  function sanitizeCapturedValue(value, options) {
307
- return sanitizeValueWith(value, (stringValue)=>sanitizeString(stringValue, options));
350
+ return sanitizeValueWith(value, {
351
+ text: (stringValue)=>sanitizeString(stringValue, options),
352
+ readsKeysAndNumbers: false
353
+ });
308
354
  }
309
355
  function sanitizeFreeTextValue(value, options) {
310
- return sanitizeValueWith(value, (stringValue)=>sanitizeFreeText(stringValue, options));
356
+ return sanitizeValueWith(value, {
357
+ text: (stringValue)=>sanitizeFreeText(stringValue, options),
358
+ readsKeysAndNumbers: true
359
+ });
311
360
  }
312
- function sanitizeValueWith(value, sanitizeStringFn) {
361
+ function sanitizeValueWith(value, sanitizer) {
313
362
  if (null == value) return value;
314
- if ('string' == typeof value) return sanitizeStringFn(value);
315
- if (Array.isArray(value)) return value.map((item)=>sanitizeValueWith(item, sanitizeStringFn));
363
+ if ('string' == typeof value) return sanitizer.text(value);
364
+ if ('number' == typeof value && sanitizer.readsKeysAndNumbers) {
365
+ const text = String(value);
366
+ return sanitizer.text(text) === text ? value : REDACTED_VALUE;
367
+ }
368
+ if (Array.isArray(value)) return value.map((item)=>sanitizeValueWith(item, sanitizer));
316
369
  if (value instanceof Date) return value;
317
370
  if ('object' != typeof value) return value;
318
371
  const result = {};
319
- for (const [key, nestedValue] of Object.entries(value))result[key] = shouldRedactKey(key) ? REDACTED_VALUE : sanitizeValueWith(nestedValue, sanitizeStringFn);
372
+ for (const [key, nestedValue] of Object.entries(value)){
373
+ const capturedKey = sanitizer.readsKeysAndNumbers ? sanitizer.text(key) : key;
374
+ result[capturedKey] = shouldRedactKey(key) ? REDACTED_VALUE : sanitizeValueWith(nestedValue, sanitizer);
375
+ }
320
376
  return result;
321
377
  }
322
- export { redactPii, sanitizeCapturedValue, sanitizeFreeText, sanitizeFreeTextValue };
378
+ export { redactPii, sanitizeCapturedValue, sanitizeFreeText, sanitizeFreeTextValue, shouldRedactKey };
@@ -88,6 +88,8 @@ export declare class PostHogSpan implements Span {
88
88
  recordException(error: unknown): this;
89
89
  updateName(name: string): this;
90
90
  traceparent(): string | null;
91
+ get traceId(): string;
92
+ get spanId(): string;
91
93
  tracestate(): string | null;
92
94
  /** Context a child span inherits when this handle is its parent. */
93
95
  childContext(): {
@@ -130,6 +132,8 @@ export declare class NoopSpan implements Span {
130
132
  recordException(): this;
131
133
  updateName(): this;
132
134
  traceparent(): string | null;
135
+ get traceId(): string | null;
136
+ get spanId(): string | null;
133
137
  tracestate(): string | null;
134
138
  end(): void;
135
139
  }
@@ -146,6 +150,8 @@ export declare class PassThroughSpan extends NoopSpan {
146
150
  private readonly _tracestate?;
147
151
  constructor(_traceparent: string, _tracestate?: string | undefined);
148
152
  traceparent(): string;
153
+ get traceId(): string | null;
154
+ get spanId(): string | null;
149
155
  tracestate(): string | null;
150
156
  }
151
157
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"span.d.ts","sourceRoot":"","sources":["../../src/traces/span.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,cAAc,EAAE,kBAAkB,EAAE,QAAQ,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AACvH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACtC,OAAO,KAAK,EAAE,kBAAkB,EAAmB,UAAU,EAAE,MAAM,SAAS,CAAA;AAmB9E;;;GAGG;AACH,wBAAgB,YAAY,IAAI,MAAM,GAAG,SAAS,CAGjD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CAAC,UAAU,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,GAAG,cAAc,CAKhG;AAED;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,cAAc,EAAE,kBAAkB,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,CAAC,GAAG,CAAC,CAE7G;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAqB/F"}
@@ -176,6 +176,12 @@ class PostHogSpan {
176
176
  traceparent() {
177
177
  return (0, external_traceparent_js_namespaceObject.formatTraceparent)(this._traceId, this._spanId, this._traceFlags);
178
178
  }
179
+ get traceId() {
180
+ return this._traceId;
181
+ }
182
+ get spanId() {
183
+ return this._spanId;
184
+ }
179
185
  tracestate() {
180
186
  return this._traceState ?? null;
181
187
  }
@@ -315,6 +321,12 @@ class NoopSpan {
315
321
  traceparent() {
316
322
  return null;
317
323
  }
324
+ get traceId() {
325
+ return null;
326
+ }
327
+ get spanId() {
328
+ return null;
329
+ }
318
330
  tracestate() {
319
331
  return null;
320
332
  }
@@ -328,6 +340,12 @@ class PassThroughSpan extends NoopSpan {
328
340
  traceparent() {
329
341
  return this._traceparent;
330
342
  }
343
+ get traceId() {
344
+ return this._traceparent.split('-')[1] ?? null;
345
+ }
346
+ get spanId() {
347
+ return this._traceparent.split('-')[2] ?? null;
348
+ }
331
349
  tracestate() {
332
350
  return this._tracestate ?? null;
333
351
  }
@@ -133,6 +133,12 @@ class PostHogSpan {
133
133
  traceparent() {
134
134
  return formatTraceparent(this._traceId, this._spanId, this._traceFlags);
135
135
  }
136
+ get traceId() {
137
+ return this._traceId;
138
+ }
139
+ get spanId() {
140
+ return this._spanId;
141
+ }
136
142
  tracestate() {
137
143
  return this._traceState ?? null;
138
144
  }
@@ -272,6 +278,12 @@ class NoopSpan {
272
278
  traceparent() {
273
279
  return null;
274
280
  }
281
+ get traceId() {
282
+ return null;
283
+ }
284
+ get spanId() {
285
+ return null;
286
+ }
275
287
  tracestate() {
276
288
  return null;
277
289
  }
@@ -285,6 +297,12 @@ class PassThroughSpan extends NoopSpan {
285
297
  traceparent() {
286
298
  return this._traceparent;
287
299
  }
300
+ get traceId() {
301
+ return this._traceparent.split('-')[1] ?? null;
302
+ }
303
+ get spanId() {
304
+ return this._traceparent.split('-')[2] ?? null;
305
+ }
288
306
  tracestate() {
289
307
  return this._tracestate ?? null;
290
308
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@posthog/core",
3
- "version": "1.64.1",
3
+ "version": "1.65.0",
4
4
  "bugs": {
5
5
  "url": "https://github.com/PostHog/posthog-js/issues"
6
6
  },
@@ -72,7 +72,7 @@
72
72
  }
73
73
  },
74
74
  "dependencies": {
75
- "@posthog/types": "^1.421.0"
75
+ "@posthog/types": "^1.422.0"
76
76
  },
77
77
  "devDependencies": {
78
78
  "@rslib/core": "0.23.2",
@@ -104,11 +104,12 @@ const IPV6_PATTERN =
104
104
  // 9-digit IDs are never mistaken for an SSN.
105
105
  const US_SSN_PATTERN = /\b\d{3}[ .-]\d{2}[ .-]\d{4}\b/g
106
106
  // A run of >=13 digits optionally grouped by a single space, dot, dash, or
107
- // slash. This only marks the numeric region; `redactCardInMatch` then looks for
108
- // the actual card as a run of whole separator-delimited groups that passes Luhn,
109
- // so an adjacent field such as an expiry (`4111 1111 1111 1111 12/30`) is not
110
- // absorbed into a failing check that would leak the card.
111
- const CREDIT_CARD_CANDIDATE_PATTERN = /\b\d(?:[ ./-]?\d){12,}\b/g
107
+ // slash; see `findCardCandidate`. This only marks the numeric region;
108
+ // `redactCardInMatch` then looks for the actual card as a run of whole
109
+ // separator-delimited groups that passes Luhn, so an adjacent field such as an
110
+ // expiry (`4111 1111 1111 1111 12/30`) is not absorbed into a failing check that
111
+ // would leak the card.
112
+ const CARD_SEPARATORS = ' ./-'
112
113
  // Matches each separator-delimited digit group inside a card candidate.
113
114
  const DIGIT_GROUP_PATTERN = /\d+/g
114
115
  // Phone matching is structural rather than "any 10–15 digits", so dates
@@ -123,11 +124,8 @@ const PHONE_INTL_PATTERN = /(^|[^\w])(\+\d{1,3}(?:[ ./()-]{0,2}\d){7,13})(?![\w]
123
124
 
124
125
  type JsonRecord = Record<string, unknown>
125
126
 
126
- function isRecord(value: unknown): value is JsonRecord {
127
- return !!value && typeof value === 'object' && !Array.isArray(value)
128
- }
129
-
130
- function shouldRedactKey(key: string): boolean {
127
+ /** Whether a key names a credential, so its value is captured as `[redacted]` whatever it holds. */
128
+ export function shouldRedactKey(key: string): boolean {
131
129
  return SENSITIVE_KEY_PATTERN.test(key)
132
130
  }
133
131
 
@@ -600,6 +598,60 @@ function passesLuhn(digits: string): boolean {
600
598
  return sum % 10 === 0
601
599
  }
602
600
 
601
+ function isDigitAt(text: string, index: number): boolean {
602
+ const code = text.charCodeAt(index)
603
+ return code >= 48 && code <= 57
604
+ }
605
+
606
+ function isWordAt(text: string, index: number): boolean {
607
+ const code = text.charCodeAt(index)
608
+ return isDigitAt(text, index) || code === 95 || (code >= 65 && code <= 90) || (code >= 97 && code <= 122)
609
+ }
610
+
611
+ function digitsEnd(text: string, index: number): number {
612
+ let end = index
613
+ while (isDigitAt(text, end)) {
614
+ end++
615
+ }
616
+ return end
617
+ }
618
+
619
+ /**
620
+ * Where the next card candidate at or after `from` starts and ends: a run of 13
621
+ * or more digits in whole groups joined by one space, dot, dash, or slash, with
622
+ * no word character on either side. The run only marks the numeric region;
623
+ * {@link redactCardInMatch} finds the cards in it.
624
+ *
625
+ * A loop rather than a pattern: a backtracking pattern over a megabyte-long run
626
+ * of digit groups overflows the stack, and the throw drops the event.
627
+ */
628
+ function findCardCandidate(text: string, from: number): [start: number, end: number] | null {
629
+ for (let start = from; start < text.length; start++) {
630
+ if (!isDigitAt(text, start) || isWordAt(text, start - 1)) {
631
+ continue
632
+ }
633
+ let digits = 0
634
+ let end = -1
635
+ let groupStart = start
636
+ for (;;) {
637
+ const groupEnd = digitsEnd(text, groupStart)
638
+ digits += groupEnd - groupStart
639
+ if (digits >= 13 && !isWordAt(text, groupEnd)) {
640
+ end = groupEnd
641
+ }
642
+ groupStart = groupEnd + 1
643
+ if (!CARD_SEPARATORS.includes(text.charAt(groupEnd)) || !isDigitAt(text, groupStart)) {
644
+ break
645
+ }
646
+ }
647
+ if (end >= 0) {
648
+ return [start, end]
649
+ }
650
+ start = groupStart - 1
651
+ }
652
+ return null
653
+ }
654
+
603
655
  // A card candidate can span more than one card plus adjacent fields (e.g. an
604
656
  // expiry, or a second card). This redacts every card in it: scanning
605
657
  // left-to-right over the whole separator-delimited digit groups, at each start it
@@ -639,6 +691,16 @@ function redactCardInMatch(match: string): string {
639
691
  return output + match.slice(cursor)
640
692
  }
641
693
 
694
+ function redactCards(text: string): string {
695
+ let output = ''
696
+ let cursor = 0
697
+ for (let run = findCardCandidate(text, 0); run !== null; run = findCardCandidate(text, run[1])) {
698
+ output += text.slice(cursor, run[0]) + redactCardInMatch(text.slice(run[0], run[1]))
699
+ cursor = run[1]
700
+ }
701
+ return output + text.slice(cursor)
702
+ }
703
+
642
704
  /**
643
705
  * Redacts structured personal identifiers (emails, IP addresses, credit-card
644
706
  * numbers, US SSNs, and phone numbers) from a free-text string. Intended for the
@@ -653,7 +715,7 @@ export function redactPii(value: string): string {
653
715
  result = result.replace(EMAIL_PATTERN, REDACTED_VALUE)
654
716
  result = result.replace(IPV4_PATTERN, REDACTED_VALUE)
655
717
  result = result.replace(IPV6_PATTERN, `$1${REDACTED_VALUE}`)
656
- result = result.replace(CREDIT_CARD_CANDIDATE_PATTERN, redactCardInMatch)
718
+ result = redactCards(result)
657
719
  result = result.replace(US_SSN_PATTERN, REDACTED_VALUE)
658
720
  result = result.replace(PHONE_NANP_PATTERN, `$1${REDACTED_VALUE}`)
659
721
  result = result.replace(PHONE_INTL_PATTERN, `$1${REDACTED_VALUE}`)
@@ -661,29 +723,48 @@ export function redactPii(value: string): string {
661
723
  }
662
724
 
663
725
  export function sanitizeCapturedValue(value: unknown, options: TextSanitizationOptions): unknown {
664
- return sanitizeValueWith(value, (stringValue) => sanitizeString(stringValue, options))
726
+ return sanitizeValueWith(value, {
727
+ text: (stringValue) => sanitizeString(stringValue, options),
728
+ readsKeysAndNumbers: false,
729
+ })
665
730
  }
666
731
 
667
732
  /**
668
733
  * {@link sanitizeCapturedValue} with the intent-grade string pass
669
734
  * ({@link sanitizeFreeText}) on every string leaf, so nested agent-narrated
670
- * values get structured-PII redaction in the load-bearing order too.
735
+ * values get structured-PII redaction in the load-bearing order too. Keys and
736
+ * numbers are read as free text as well, since a value sent as JSON text carries
737
+ * them: a number that holds an identifier becomes `[redacted]`, so the text
738
+ * stays valid JSON.
671
739
  */
672
740
  export function sanitizeFreeTextValue(value: unknown, options: TextSanitizationOptions): unknown {
673
- return sanitizeValueWith(value, (stringValue) => sanitizeFreeText(stringValue, options))
741
+ return sanitizeValueWith(value, {
742
+ text: (stringValue) => sanitizeFreeText(stringValue, options),
743
+ readsKeysAndNumbers: true,
744
+ })
674
745
  }
675
746
 
676
- function sanitizeValueWith(value: unknown, sanitizeStringFn: (value: string) => string): unknown {
747
+ interface ValueSanitizer {
748
+ text: (value: string) => string
749
+ readsKeysAndNumbers: boolean
750
+ }
751
+
752
+ function sanitizeValueWith(value: unknown, sanitizer: ValueSanitizer): unknown {
677
753
  if (value == null) {
678
754
  return value
679
755
  }
680
756
 
681
757
  if (typeof value === 'string') {
682
- return sanitizeStringFn(value)
758
+ return sanitizer.text(value)
759
+ }
760
+
761
+ if (typeof value === 'number' && sanitizer.readsKeysAndNumbers) {
762
+ const text = String(value)
763
+ return sanitizer.text(text) === text ? value : REDACTED_VALUE
683
764
  }
684
765
 
685
766
  if (Array.isArray(value)) {
686
- return value.map((item) => sanitizeValueWith(item, sanitizeStringFn))
767
+ return value.map((item) => sanitizeValueWith(item, sanitizer))
687
768
  }
688
769
 
689
770
  if (value instanceof Date) {
@@ -696,7 +777,8 @@ function sanitizeValueWith(value: unknown, sanitizeStringFn: (value: string) =>
696
777
 
697
778
  const result: JsonRecord = {}
698
779
  for (const [key, nestedValue] of Object.entries(value)) {
699
- result[key] = shouldRedactKey(key) ? REDACTED_VALUE : sanitizeValueWith(nestedValue, sanitizeStringFn)
780
+ const capturedKey = sanitizer.readsKeysAndNumbers ? sanitizer.text(key) : key
781
+ result[capturedKey] = shouldRedactKey(key) ? REDACTED_VALUE : sanitizeValueWith(nestedValue, sanitizer)
700
782
  }
701
783
  return result
702
784
  }
@@ -1,4 +1,4 @@
1
- import { NOOP_SPAN, PostHogSpan, describeError, truncateAttributeValue } from './span'
1
+ import { NOOP_SPAN, PassThroughSpan, PostHogSpan, describeError, truncateAttributeValue } from './span'
2
2
  import { buildOtlpSpan } from './otlp'
3
3
  import { resolveTracesConfig } from './config'
4
4
  import type { SpanInit } from './span'
@@ -962,6 +962,18 @@ describe('PostHogSpan', () => {
962
962
  expect(createSpan().traceparent()).toBe(`00-${TRACE_ID}-${SPAN_ID}-01`)
963
963
  })
964
964
 
965
+ it('exposes the trace and span ids as getters', () => {
966
+ const span = createSpan()
967
+ expect(span.traceId).toBe(TRACE_ID)
968
+ expect(span.spanId).toBe(SPAN_ID)
969
+ })
970
+
971
+ it('reads the ids of a pass-through span from its traceparent', () => {
972
+ const span = new PassThroughSpan(`00-${TRACE_ID}-${SPAN_ID}-01`)
973
+ expect(span.traceId).toBe(TRACE_ID)
974
+ expect(span.spanId).toBe(SPAN_ID)
975
+ })
976
+
965
977
  it('returns null tracestate when it has none', () => {
966
978
  expect(createSpan().tracestate()).toBeNull()
967
979
  })
@@ -1008,6 +1020,8 @@ describe('NoopSpan', () => {
1008
1020
  // An id that was never recorded must not propagate to another service.
1009
1021
  expect(NOOP_SPAN.traceparent()).toBeNull()
1010
1022
  expect(NOOP_SPAN.tracestate()).toBeNull()
1023
+ expect(NOOP_SPAN.traceId).toBeNull()
1024
+ expect(NOOP_SPAN.spanId).toBeNull()
1011
1025
  })
1012
1026
  })
1013
1027
 
@@ -269,6 +269,14 @@ export class PostHogSpan implements Span {
269
269
  return formatTraceparent(this._traceId, this._spanId, this._traceFlags)
270
270
  }
271
271
 
272
+ get traceId(): string {
273
+ return this._traceId
274
+ }
275
+
276
+ get spanId(): string {
277
+ return this._spanId
278
+ }
279
+
272
280
  tracestate(): string | null {
273
281
  return this._traceState ?? null
274
282
  }
@@ -490,6 +498,12 @@ export class NoopSpan implements Span {
490
498
  traceparent(): string | null {
491
499
  return null
492
500
  }
501
+ get traceId(): string | null {
502
+ return null
503
+ }
504
+ get spanId(): string | null {
505
+ return null
506
+ }
493
507
  tracestate(): string | null {
494
508
  return null
495
509
  }
@@ -519,6 +533,15 @@ export class PassThroughSpan extends NoopSpan {
519
533
  return this._traceparent
520
534
  }
521
535
 
536
+ // `00-<traceId>-<spanId>-<flags>`: the inbound header is already normalized.
537
+ override get traceId(): string | null {
538
+ return this._traceparent.split('-')[1] ?? null
539
+ }
540
+
541
+ override get spanId(): string | null {
542
+ return this._traceparent.split('-')[2] ?? null
543
+ }
544
+
522
545
  override tracestate(): string | null {
523
546
  return this._tracestate ?? null
524
547
  }
@@ -143,6 +143,16 @@ export interface Span {
143
143
  * never recorded cannot propagate.
144
144
  */
145
145
  traceparent(): string | null;
146
+ /**
147
+ * This span's 32-hex-char trace id, for correlating logs from other
148
+ * loggers (pino, winston) with the trace. `null` when there is no id to
149
+ * report: the same cases where `traceparent()` returns `null`.
150
+ */
151
+ readonly traceId: string | null;
152
+ /**
153
+ * This span's 16-hex-char span id. `null` when `traceparent()` is `null`.
154
+ */
155
+ readonly spanId: string | null;
146
156
  /** This span's W3C `tracestate` value, or `null` when it has none. */
147
157
  tracestate(): string | null;
148
158
  /**