@posthog/core 1.71.1 → 1.71.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/privacy.d.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  export interface TextSanitizationOptions {
2
2
  maxStringLength: number;
3
3
  truncationSuffix: string;
4
+ /** Further credentials to redact, run on the text the URL pass has not rewritten yet. */
5
+ redactSecrets?: (text: string) => string;
4
6
  }
5
7
  /** Whether a key names a credential, so its value is captured as `[redacted]` whatever it holds. */
6
8
  export declare function shouldRedactKey(key: string): boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"privacy.d.ts","sourceRoot":"","sources":["../src/privacy.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,uBAAuB;IACtC,eAAe,EAAE,MAAM,CAAA;IACvB,gBAAgB,EAAE,MAAM,CAAA;CACzB;AAsHD,oGAAoG;AACpG,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAEpD;AAgbD;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,uBAAuB,GAAG,MAAM,CAKxF;AA6HD;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAU/C;AAED,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAK/F;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAK/F"}
1
+ {"version":3,"file":"privacy.d.ts","sourceRoot":"","sources":["../src/privacy.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,uBAAuB;IACtC,eAAe,EAAE,MAAM,CAAA;IACvB,gBAAgB,EAAE,MAAM,CAAA;IACxB,yFAAyF;IACzF,aAAa,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAA;CACzC;AAsHD,oGAAoG;AACpG,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAEpD;AAqbD;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,uBAAuB,GAAG,MAAM,CAKxF;AA6HD;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAU/C;AAED,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAK/F;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAK/F"}
package/dist/privacy.js CHANGED
@@ -273,12 +273,16 @@ function headLength(value, scannedHeadLength) {
273
273
  while(end > 0 && !URL_END_PATTERN.test(value[end - 1]))end--;
274
274
  return end;
275
275
  }
276
+ function redactSecrets(value, options) {
277
+ const redacted = redactCredentials(value);
278
+ return options.redactSecrets ? options.redactSecrets(redacted) : redacted;
279
+ }
276
280
  function sanitizeString(value, options) {
277
- return isBinaryBlob(value) ? BINARY_REDACTED_VALUE : redactCapturedHead(value, (head)=>redactUrls(redactCredentials(head)), options);
281
+ return isBinaryBlob(value) ? BINARY_REDACTED_VALUE : redactCapturedHead(value, (head)=>redactUrls(redactSecrets(head, options)), options);
278
282
  }
279
283
  function sanitizeFreeText(value, options) {
280
284
  if (isBinaryBlob(value)) return BINARY_REDACTED_VALUE;
281
- return redactCapturedHead(value, (head)=>redactUrls(redactPii(redactCredentials(head))), options);
285
+ return redactCapturedHead(value, (head)=>redactUrls(redactPii(redactSecrets(head, options))), options);
282
286
  }
283
287
  function passesLuhn(digits) {
284
288
  let sum = 0;
package/dist/privacy.mjs CHANGED
@@ -244,12 +244,16 @@ function headLength(value, scannedHeadLength) {
244
244
  while(end > 0 && !URL_END_PATTERN.test(value[end - 1]))end--;
245
245
  return end;
246
246
  }
247
+ function redactSecrets(value, options) {
248
+ const redacted = redactCredentials(value);
249
+ return options.redactSecrets ? options.redactSecrets(redacted) : redacted;
250
+ }
247
251
  function sanitizeString(value, options) {
248
- return isBinaryBlob(value) ? BINARY_REDACTED_VALUE : redactCapturedHead(value, (head)=>redactUrls(redactCredentials(head)), options);
252
+ return isBinaryBlob(value) ? BINARY_REDACTED_VALUE : redactCapturedHead(value, (head)=>redactUrls(redactSecrets(head, options)), options);
249
253
  }
250
254
  function sanitizeFreeText(value, options) {
251
255
  if (isBinaryBlob(value)) return BINARY_REDACTED_VALUE;
252
- return redactCapturedHead(value, (head)=>redactUrls(redactPii(redactCredentials(head))), options);
256
+ return redactCapturedHead(value, (head)=>redactUrls(redactPii(redactSecrets(head, options))), options);
253
257
  }
254
258
  function passesLuhn(digits) {
255
259
  let sum = 0;
@@ -37,10 +37,10 @@ const stripLeadingDollar = function(s) {
37
37
  return s.replace(/^\$/, '');
38
38
  };
39
39
  function isDistinctIdStringLike(value) {
40
- return [
40
+ return includes([
41
41
  'distinct_id',
42
42
  'distinctid'
43
- ].includes(value.toLowerCase());
43
+ ], value.toLowerCase());
44
44
  }
45
45
  function safeJsonStringify(value) {
46
46
  const ancestors = [];
@@ -8,10 +8,10 @@ const stripLeadingDollar = function(s) {
8
8
  return s.replace(/^\$/, '');
9
9
  };
10
10
  function isDistinctIdStringLike(value) {
11
- return [
11
+ return includes([
12
12
  'distinct_id',
13
13
  'distinctid'
14
- ].includes(value.toLowerCase());
14
+ ], value.toLowerCase());
15
15
  }
16
16
  function safeJsonStringify(value) {
17
17
  const ancestors = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@posthog/core",
3
- "version": "1.71.1",
3
+ "version": "1.71.3",
4
4
  "bugs": {
5
5
  "url": "https://github.com/PostHog/posthog-js/issues"
6
6
  },
package/src/privacy.ts CHANGED
@@ -6,6 +6,8 @@
6
6
  export interface TextSanitizationOptions {
7
7
  maxStringLength: number
8
8
  truncationSuffix: string
9
+ /** Further credentials to redact, run on the text the URL pass has not rewritten yet. */
10
+ redactSecrets?: (text: string) => string
9
11
  }
10
12
 
11
13
  const REDACTED_VALUE = '[redacted]'
@@ -553,10 +555,15 @@ function headLength(value: string, scannedHeadLength: number): number {
553
555
  return end
554
556
  }
555
557
 
558
+ function redactSecrets(value: string, options: TextSanitizationOptions): string {
559
+ const redacted = redactCredentials(value)
560
+ return options.redactSecrets ? options.redactSecrets(redacted) : redacted
561
+ }
562
+
556
563
  function sanitizeString(value: string, options: TextSanitizationOptions): string {
557
564
  return isBinaryBlob(value)
558
565
  ? BINARY_REDACTED_VALUE
559
- : redactCapturedHead(value, (head) => redactUrls(redactCredentials(head)), options)
566
+ : redactCapturedHead(value, (head) => redactUrls(redactSecrets(head, options)), options)
560
567
  }
561
568
 
562
569
  /**
@@ -575,7 +582,7 @@ export function sanitizeFreeText(value: string, options: TextSanitizationOptions
575
582
  if (isBinaryBlob(value)) {
576
583
  return BINARY_REDACTED_VALUE
577
584
  }
578
- return redactCapturedHead(value, (head) => redactUrls(redactPii(redactCredentials(head))), options)
585
+ return redactCapturedHead(value, (head) => redactUrls(redactPii(redactSecrets(head, options))), options)
579
586
  }
580
587
 
581
588
  function passesLuhn(digits: string): boolean {
@@ -21,7 +21,7 @@ export const stripLeadingDollar = function (s: string): string {
21
21
  }
22
22
 
23
23
  export function isDistinctIdStringLike(value: string): boolean {
24
- return ['distinct_id', 'distinctid'].includes(value.toLowerCase())
24
+ return includes(['distinct_id', 'distinctid'], value.toLowerCase())
25
25
  }
26
26
 
27
27
  export function safeJsonStringify(value: unknown): string {