@posthog/core 1.71.2 → 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 +2 -0
- package/dist/privacy.d.ts.map +1 -1
- package/dist/privacy.js +6 -2
- package/dist/privacy.mjs +6 -2
- package/package.json +1 -1
- package/src/privacy.ts +9 -2
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;
|
package/dist/privacy.d.ts.map
CHANGED
|
@@ -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;
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
256
|
+
return redactCapturedHead(value, (head)=>redactUrls(redactPii(redactSecrets(head, options))), options);
|
|
253
257
|
}
|
|
254
258
|
function passesLuhn(digits) {
|
|
255
259
|
let sum = 0;
|
package/package.json
CHANGED
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(
|
|
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(
|
|
585
|
+
return redactCapturedHead(value, (head) => redactUrls(redactPii(redactSecrets(head, options))), options)
|
|
579
586
|
}
|
|
580
587
|
|
|
581
588
|
function passesLuhn(digits: string): boolean {
|