@zuplo/cli 7.9.11 → 7.9.12
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/node_modules/@posthog/core/dist/featureFlagUtils.d.ts.map +1 -1
- package/node_modules/@posthog/core/dist/featureFlagUtils.js +2 -1
- package/node_modules/@posthog/core/dist/featureFlagUtils.mjs +2 -1
- package/node_modules/@posthog/core/dist/index.d.ts +1 -0
- package/node_modules/@posthog/core/dist/index.d.ts.map +1 -1
- package/node_modules/@posthog/core/dist/index.js +66 -10
- package/node_modules/@posthog/core/dist/index.mjs +1 -0
- package/node_modules/@posthog/core/dist/privacy.d.ts +35 -0
- package/node_modules/@posthog/core/dist/privacy.d.ts.map +1 -0
- package/node_modules/@posthog/core/dist/privacy.js +366 -0
- package/node_modules/@posthog/core/dist/privacy.mjs +319 -0
- package/node_modules/@posthog/core/package.json +2 -2
- package/node_modules/@posthog/core/src/featureFlagUtils.ts +2 -0
- package/node_modules/@posthog/core/src/index.ts +1 -0
- package/node_modules/@posthog/core/src/privacy.ts +696 -0
- package/node_modules/@posthog/types/dist/index.d.ts +1 -1
- package/node_modules/@posthog/types/dist/index.d.ts.map +1 -1
- package/node_modules/@posthog/types/dist/posthog-config.d.ts +39 -8
- package/node_modules/@posthog/types/dist/posthog-config.d.ts.map +1 -1
- package/node_modules/@posthog/types/package.json +1 -1
- package/node_modules/@posthog/types/src/index.ts +1 -0
- package/node_modules/@posthog/types/src/posthog-config.ts +41 -8
- package/node_modules/@zuplo/core/customer.cli.minified.js +215 -215
- package/node_modules/@zuplo/core/index.minified.js +220 -220
- package/node_modules/@zuplo/core/package.json +1 -1
- package/node_modules/@zuplo/graphql/package.json +1 -1
- package/node_modules/@zuplo/openapi-tools/package.json +1 -1
- package/node_modules/@zuplo/otel/package.json +1 -1
- package/node_modules/@zuplo/runtime/out/esm/chunk-2XSPVUOE.js +411 -0
- package/node_modules/@zuplo/runtime/out/esm/chunk-2XSPVUOE.js.map +1 -0
- package/node_modules/@zuplo/runtime/out/esm/chunk-PBDT4FDO.js +37 -0
- package/node_modules/@zuplo/runtime/out/esm/chunk-PBDT4FDO.js.map +1 -0
- package/node_modules/@zuplo/runtime/out/esm/{chunk-QTXBMT6O.js → chunk-VTO3F6DK.js} +2 -2
- package/node_modules/@zuplo/runtime/out/esm/{chunk-7AHIER5R.js → chunk-YJ2BHVUH.js} +2 -2
- package/node_modules/@zuplo/runtime/out/esm/index.js +1 -1
- package/node_modules/@zuplo/runtime/out/esm/index.js.map +1 -1
- package/node_modules/@zuplo/runtime/out/esm/internal/index.js +1 -1
- package/node_modules/@zuplo/runtime/out/esm/mcp-gateway/index.js +1 -1
- package/node_modules/@zuplo/runtime/out/esm/mocks/index.js +1 -1
- package/node_modules/@zuplo/runtime/out/esm/sdks/aws/index.js +1 -1
- package/node_modules/@zuplo/runtime/out/types/index.d.ts +152 -54
- package/node_modules/@zuplo/runtime/out/types/internal/index.d.ts +32 -0
- package/node_modules/@zuplo/runtime/package.json +1 -1
- package/node_modules/express-rate-limit/dist/index.cjs +9 -7
- package/node_modules/express-rate-limit/dist/index.mjs +9 -7
- package/node_modules/express-rate-limit/package.json +9 -9
- package/package.json +11 -11
- package/node_modules/@zuplo/runtime/out/esm/chunk-DDUIJEX3.js +0 -411
- package/node_modules/@zuplo/runtime/out/esm/chunk-DDUIJEX3.js.map +0 -1
- package/node_modules/@zuplo/runtime/out/esm/chunk-KESHY2P3.js +0 -37
- package/node_modules/@zuplo/runtime/out/esm/chunk-KESHY2P3.js.map +0 -1
- /package/node_modules/@zuplo/runtime/out/esm/{chunk-DDUIJEX3.js.LEGAL.txt → chunk-2XSPVUOE.js.LEGAL.txt} +0 -0
- /package/node_modules/@zuplo/runtime/out/esm/{chunk-KESHY2P3.js.LEGAL.txt → chunk-PBDT4FDO.js.LEGAL.txt} +0 -0
- /package/node_modules/@zuplo/runtime/out/esm/{chunk-QTXBMT6O.js.map → chunk-VTO3F6DK.js.map} +0 -0
- /package/node_modules/@zuplo/runtime/out/esm/{chunk-7AHIER5R.js.map → chunk-YJ2BHVUH.js.map} +0 -0
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
const REDACTED_VALUE = '[redacted]';
|
|
2
|
+
const BINARY_REDACTED_VALUE = '[binary data redacted - not supported by PostHog MCP analytics]';
|
|
3
|
+
const BASE64_PATTERN = /^[A-Za-z0-9+/\n\r]+=*$/;
|
|
4
|
+
const BASE64URL_PATTERN = /^[A-Za-z0-9_-]+={0,2}$/;
|
|
5
|
+
const BASE64URL_SPECIFIC_CHAR_PATTERN = /[-_]/;
|
|
6
|
+
const BASE64_DATA_URL_PREFIX_PATTERN = /^data:[^,\s]*;base64,/i;
|
|
7
|
+
const BASE64_DATA_URL_PAYLOAD_PATTERN = /^[A-Za-z0-9+/_-]+={0,2}$/;
|
|
8
|
+
const SIZE_GATE = 10240;
|
|
9
|
+
const POSTHOG_TOKEN_PATTERN = /\bph[a-z]_[A-Za-z0-9_-]{20,}\b/g;
|
|
10
|
+
const SENSITIVE_KEY_PATTERN = /^(authorization|cookie|set-cookie|x-api-key|api[-_]?key|api[-_]?token|access[-_]?token|refresh[-_]?token|token|password|secret|client[-_]?secret|private[-_]?key)$/i;
|
|
11
|
+
const URL_PATTERN = /[a-z][a-z0-9+.-]{0,63}:[^\s<>"]+/gi;
|
|
12
|
+
const URL_END_PATTERN = /[\s<>"]/;
|
|
13
|
+
const URL_PATTERN_ONCE = new RegExp(URL_PATTERN.source, 'i');
|
|
14
|
+
const URL_AUTHORITY_SEARCH = /[a-z][a-z0-9+.-]{0,63}:\/\//i;
|
|
15
|
+
const URL_AUTHORITY_PATTERN = new RegExp(`^${URL_AUTHORITY_SEARCH.source}`, 'i');
|
|
16
|
+
const URL_AUTHORITY_SEARCH_ALL = new RegExp(URL_AUTHORITY_SEARCH.source, 'gi');
|
|
17
|
+
const URL_FIELD_CHARACTERS = '=&';
|
|
18
|
+
const LEGACY_FIELD_SEPARATOR = ';';
|
|
19
|
+
const URL_TRAILING_PUNCTUATION = ".,;:!?)]}'";
|
|
20
|
+
const MAX_URL_LENGTH = 8192;
|
|
21
|
+
const MAX_URL_QUERY_FIELDS = 128;
|
|
22
|
+
const SENSITIVE_QUERY_KEY_SEGMENT_PATTERN = /(^|[-_./;])(auth|token|secret|password|passwd|pwd|credential|signature|sig|key|hmac|sas|bearer|jwt|session|sessionid)([-_./;]|$)/i;
|
|
23
|
+
const SENSITIVE_QUERY_KEY_EXACT_PATTERN = /^(code|AWSAccessKeyId|GoogleAccessId|Policy)$/i;
|
|
24
|
+
const UNICODE_SPACE_PATTERN = /[\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000]/g;
|
|
25
|
+
const EMAIL_PATTERN = /[A-Za-z0-9._%+-]{1,64}@[A-Za-z0-9.-]{1,255}\.[A-Za-z]{2,24}/g;
|
|
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
|
+
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
|
+
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;
|
|
30
|
+
const DIGIT_GROUP_PATTERN = /\d+/g;
|
|
31
|
+
const PHONE_NANP_PATTERN = /(^|[^\w+])((?:\+?1[ ./-]?)?(?:\(\d{3}\)[ ./-]?|\d{3}[ ./-])\d{3}[ ./-]\d{4})(?![\w])/g;
|
|
32
|
+
const PHONE_INTL_PATTERN = /(^|[^\w])(\+\d{1,3}(?:[ ./()-]{0,2}\d){7,13})(?![\w])/g;
|
|
33
|
+
function shouldRedactKey(key) {
|
|
34
|
+
return SENSITIVE_KEY_PATTERN.test(key);
|
|
35
|
+
}
|
|
36
|
+
function shouldRedactQueryKey(key) {
|
|
37
|
+
return shouldRedactKey(key) || SENSITIVE_QUERY_KEY_SEGMENT_PATTERN.test(key) || SENSITIVE_QUERY_KEY_EXACT_PATTERN.test(key);
|
|
38
|
+
}
|
|
39
|
+
function isBase64DataUrl(value) {
|
|
40
|
+
const prefix = BASE64_DATA_URL_PREFIX_PATTERN.exec(value);
|
|
41
|
+
if (!prefix) return false;
|
|
42
|
+
let payload;
|
|
43
|
+
try {
|
|
44
|
+
payload = decodeURIComponent(value.slice(prefix[0].length));
|
|
45
|
+
} catch {
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
return BASE64_DATA_URL_PAYLOAD_PATTERN.test(payload.replace(/[\r\n]/g, ''));
|
|
49
|
+
}
|
|
50
|
+
function exceedsUrlFieldLimit(fields) {
|
|
51
|
+
return fields.split('&', MAX_URL_QUERY_FIELDS + 1).length > MAX_URL_QUERY_FIELDS;
|
|
52
|
+
}
|
|
53
|
+
function hasLegacySensitiveField(value) {
|
|
54
|
+
return value.split(LEGACY_FIELD_SEPARATOR).some((piece)=>shouldRedactQueryKey(piece.split('=', 1)[0]));
|
|
55
|
+
}
|
|
56
|
+
function sanitizeUrlFieldValue(key, value, allowNestedUrls) {
|
|
57
|
+
if (shouldRedactQueryKey(key)) return REDACTED_VALUE;
|
|
58
|
+
if (value.includes(LEGACY_FIELD_SEPARATOR) && hasLegacySensitiveField(value)) return REDACTED_VALUE;
|
|
59
|
+
if (!URL_PATTERN_ONCE.test(value)) return value;
|
|
60
|
+
return allowNestedUrls ? sanitizeUrlsInString(value, {
|
|
61
|
+
allowNestedUrls: false,
|
|
62
|
+
stripPunctuation: true
|
|
63
|
+
}) : REDACTED_VALUE;
|
|
64
|
+
}
|
|
65
|
+
function sanitizeUrlFields(fields, allowNestedUrls) {
|
|
66
|
+
const sanitized = new URLSearchParams();
|
|
67
|
+
let changed = false;
|
|
68
|
+
let lastFieldSensitive = false;
|
|
69
|
+
for (const [key, value] of new URLSearchParams(fields)){
|
|
70
|
+
const sanitizedValue = sanitizeUrlFieldValue(key, value, allowNestedUrls);
|
|
71
|
+
changed ||= sanitizedValue !== value;
|
|
72
|
+
lastFieldSensitive = shouldRedactQueryKey(key) || sanitizedValue !== value;
|
|
73
|
+
sanitized.append(key, sanitizedValue);
|
|
74
|
+
}
|
|
75
|
+
return {
|
|
76
|
+
changed,
|
|
77
|
+
lastFieldSensitive,
|
|
78
|
+
serialized: sanitized.toString()
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
function splitTrailingPunctuation(value) {
|
|
82
|
+
let end = value.length;
|
|
83
|
+
while(end > 0 && URL_TRAILING_PUNCTUATION.includes(value[end - 1]))end--;
|
|
84
|
+
return {
|
|
85
|
+
address: value.slice(0, end),
|
|
86
|
+
suffix: value.slice(end)
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
function sanitizeFragmentTail(tail, headLastFieldSensitive, allowNestedUrls) {
|
|
90
|
+
if (!headLastFieldSensitive) return sanitizeFragmentPart(tail, allowNestedUrls);
|
|
91
|
+
return {
|
|
92
|
+
value: '' === tail ? '' : REDACTED_VALUE,
|
|
93
|
+
lastFieldSensitive: true
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
function splitFragmentParts(hash) {
|
|
97
|
+
const fragment = hash.slice(1);
|
|
98
|
+
const separator = fragment.indexOf('?');
|
|
99
|
+
if (separator < 0) return {
|
|
100
|
+
head: fragment,
|
|
101
|
+
tail: null
|
|
102
|
+
};
|
|
103
|
+
return {
|
|
104
|
+
head: fragment.slice(0, separator),
|
|
105
|
+
tail: fragment.slice(separator + 1)
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
function sanitizeFragmentPart(part, allowNestedUrls) {
|
|
109
|
+
if (!part.includes('=')) return {
|
|
110
|
+
value: sanitizeFragmentText(part, allowNestedUrls),
|
|
111
|
+
lastFieldSensitive: false
|
|
112
|
+
};
|
|
113
|
+
const fields = sanitizeUrlFields(part, allowNestedUrls);
|
|
114
|
+
return {
|
|
115
|
+
value: fields.changed ? fields.serialized : part,
|
|
116
|
+
lastFieldSensitive: fields.lastFieldSensitive
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
function sanitizeFragmentText(text, allowNestedUrls) {
|
|
120
|
+
if (!allowNestedUrls) return URL_PATTERN_ONCE.test(text) ? REDACTED_VALUE : text;
|
|
121
|
+
return sanitizeUrlsInString(text, {
|
|
122
|
+
allowNestedUrls: false,
|
|
123
|
+
stripPunctuation: true
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
function findEmbeddedAuthorityIndexes(value) {
|
|
127
|
+
if (!value.includes('://')) return [];
|
|
128
|
+
const starts = [
|
|
129
|
+
...value.matchAll(URL_AUTHORITY_SEARCH_ALL)
|
|
130
|
+
].map((match)=>match.index);
|
|
131
|
+
const indexes = [];
|
|
132
|
+
const delimiters = {
|
|
133
|
+
query: false,
|
|
134
|
+
fragment: false,
|
|
135
|
+
fragmentQuery: false
|
|
136
|
+
};
|
|
137
|
+
let pending = 0;
|
|
138
|
+
let inFields = false;
|
|
139
|
+
let lastStructural = '';
|
|
140
|
+
for(let cursor = 0; cursor < value.length && pending < starts.length; cursor++){
|
|
141
|
+
if (starts[pending] === cursor) {
|
|
142
|
+
if (cursor > 0 && '=' !== lastStructural) indexes.push(cursor);
|
|
143
|
+
pending++;
|
|
144
|
+
}
|
|
145
|
+
const character = value[cursor];
|
|
146
|
+
if (isDelimiter(character, delimiters, lastStructural)) {
|
|
147
|
+
lastStructural = character;
|
|
148
|
+
inFields = true;
|
|
149
|
+
} else if (inFields && URL_FIELD_CHARACTERS.includes(character)) lastStructural = character;
|
|
150
|
+
}
|
|
151
|
+
return indexes;
|
|
152
|
+
}
|
|
153
|
+
function isDelimiter(character, seen, lastStructural) {
|
|
154
|
+
if ('#' === character) return seen.fragment ? false : seen.fragment = true;
|
|
155
|
+
if ('?' !== character) return false;
|
|
156
|
+
if (seen.fragment) {
|
|
157
|
+
if ('=' === lastStructural) return false;
|
|
158
|
+
return seen.fragmentQuery ? false : seen.fragmentQuery = true;
|
|
159
|
+
}
|
|
160
|
+
return seen.query ? false : seen.query = true;
|
|
161
|
+
}
|
|
162
|
+
function sanitizeUrl(value, mode) {
|
|
163
|
+
const embedded = findEmbeddedAuthorityIndexes(value);
|
|
164
|
+
if (0 === embedded.length) return sanitizeSingleUrl(value, mode);
|
|
165
|
+
let result = '';
|
|
166
|
+
let start = 0;
|
|
167
|
+
for (const index of embedded){
|
|
168
|
+
result += sanitizeSingleUrl(value.slice(start, index), {
|
|
169
|
+
...mode,
|
|
170
|
+
stripPunctuation: false
|
|
171
|
+
});
|
|
172
|
+
start = index;
|
|
173
|
+
}
|
|
174
|
+
return result + sanitizeSingleUrl(value.slice(start), mode);
|
|
175
|
+
}
|
|
176
|
+
function sanitizeSingleUrl(value, mode) {
|
|
177
|
+
if (value.length > MAX_URL_LENGTH && URL_AUTHORITY_PATTERN.test(value)) return REDACTED_VALUE;
|
|
178
|
+
const { address, suffix } = mode.stripPunctuation ? splitTrailingPunctuation(value) : {
|
|
179
|
+
address: value,
|
|
180
|
+
suffix: ''
|
|
181
|
+
};
|
|
182
|
+
let url;
|
|
183
|
+
try {
|
|
184
|
+
url = new URL(address);
|
|
185
|
+
} catch {
|
|
186
|
+
return REDACTED_VALUE + suffix;
|
|
187
|
+
}
|
|
188
|
+
const query = url.search.slice(1);
|
|
189
|
+
const hasFragment = '' !== url.hash;
|
|
190
|
+
const fragment = splitFragmentParts(url.hash);
|
|
191
|
+
if (exceedsUrlFieldLimit(query) || exceedsUrlFieldLimit(fragment.head) || exceedsUrlFieldLimit(fragment.tail ?? '')) return REDACTED_VALUE + suffix;
|
|
192
|
+
let changed = false;
|
|
193
|
+
if (url.username || url.password) {
|
|
194
|
+
url.username = REDACTED_VALUE;
|
|
195
|
+
url.password = '';
|
|
196
|
+
changed = true;
|
|
197
|
+
}
|
|
198
|
+
const sanitizedQuery = sanitizeUrlFields(query, mode.allowNestedUrls);
|
|
199
|
+
if (sanitizedQuery.changed) {
|
|
200
|
+
url.search = sanitizedQuery.serialized;
|
|
201
|
+
changed = true;
|
|
202
|
+
}
|
|
203
|
+
const sanitizedHead = sanitizeFragmentPart(fragment.head, mode.allowNestedUrls);
|
|
204
|
+
const sanitizedTail = null === fragment.tail ? null : sanitizeFragmentTail(fragment.tail, sanitizedHead.lastFieldSensitive, mode.allowNestedUrls);
|
|
205
|
+
const sanitizedHash = null === sanitizedTail ? sanitizedHead.value : `${sanitizedHead.value}?${sanitizedTail.value}`;
|
|
206
|
+
if (sanitizedHash !== url.hash.slice(1)) {
|
|
207
|
+
url.hash = sanitizedHash;
|
|
208
|
+
changed = true;
|
|
209
|
+
}
|
|
210
|
+
const trailingFields = hasFragment ? sanitizedTail ?? sanitizedHead : sanitizedQuery;
|
|
211
|
+
return (changed ? url.toString() : address) + (trailingFields.lastFieldSensitive ? '' : suffix);
|
|
212
|
+
}
|
|
213
|
+
function sanitizeUrlsInString(text, mode) {
|
|
214
|
+
return text.replace(URL_PATTERN, (match)=>sanitizeUrl(match, {
|
|
215
|
+
...mode,
|
|
216
|
+
stripPunctuation: mode.stripPunctuation && match.length !== text.length
|
|
217
|
+
}));
|
|
218
|
+
}
|
|
219
|
+
function isBinaryBlob(value) {
|
|
220
|
+
return value.length >= SIZE_GATE && (BASE64_PATTERN.test(value) || isBase64DataUrl(value) || BASE64URL_SPECIFIC_CHAR_PATTERN.test(value) && BASE64URL_PATTERN.test(value));
|
|
221
|
+
}
|
|
222
|
+
function redactCredentials(value) {
|
|
223
|
+
return value.replace(POSTHOG_TOKEN_PATTERN, REDACTED_VALUE);
|
|
224
|
+
}
|
|
225
|
+
function redactUrls(value) {
|
|
226
|
+
return sanitizeUrlsInString(value, {
|
|
227
|
+
allowNestedUrls: true,
|
|
228
|
+
stripPunctuation: true
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
function redactCapturedHead(value, redact, options) {
|
|
232
|
+
const scannedHeadLength = 4 * options.maxStringLength;
|
|
233
|
+
if (value.length > scannedHeadLength) {
|
|
234
|
+
const head = redact(value.slice(0, headLength(value, scannedHeadLength)));
|
|
235
|
+
if (head.length >= 2 * options.maxStringLength) return head + options.truncationSuffix;
|
|
236
|
+
}
|
|
237
|
+
return redact(value);
|
|
238
|
+
}
|
|
239
|
+
function headLength(value, scannedHeadLength) {
|
|
240
|
+
let end = scannedHeadLength;
|
|
241
|
+
while(end > 0 && !URL_END_PATTERN.test(value[end - 1]))end--;
|
|
242
|
+
return end;
|
|
243
|
+
}
|
|
244
|
+
function sanitizeString(value, options) {
|
|
245
|
+
return isBinaryBlob(value) ? BINARY_REDACTED_VALUE : redactCapturedHead(value, (head)=>redactUrls(redactCredentials(head)), options);
|
|
246
|
+
}
|
|
247
|
+
function sanitizeFreeText(value, options) {
|
|
248
|
+
if (isBinaryBlob(value)) return BINARY_REDACTED_VALUE;
|
|
249
|
+
return redactCapturedHead(value, (head)=>redactUrls(redactPii(redactCredentials(head))), options);
|
|
250
|
+
}
|
|
251
|
+
function passesLuhn(digits) {
|
|
252
|
+
let sum = 0;
|
|
253
|
+
let double = false;
|
|
254
|
+
for(let index = digits.length - 1; index >= 0; index--){
|
|
255
|
+
let digit = digits.charCodeAt(index) - 48;
|
|
256
|
+
if (digit < 0 || digit > 9) return false;
|
|
257
|
+
if (double) {
|
|
258
|
+
digit *= 2;
|
|
259
|
+
if (digit > 9) digit -= 9;
|
|
260
|
+
}
|
|
261
|
+
sum += digit;
|
|
262
|
+
double = !double;
|
|
263
|
+
}
|
|
264
|
+
return sum % 10 === 0;
|
|
265
|
+
}
|
|
266
|
+
function redactCardInMatch(match) {
|
|
267
|
+
const groups = [];
|
|
268
|
+
for(let m = DIGIT_GROUP_PATTERN.exec(match); null !== m; m = DIGIT_GROUP_PATTERN.exec(match))groups.push({
|
|
269
|
+
digits: m[0],
|
|
270
|
+
start: m.index,
|
|
271
|
+
end: m.index + m[0].length
|
|
272
|
+
});
|
|
273
|
+
let output = '';
|
|
274
|
+
let cursor = 0;
|
|
275
|
+
let first = 0;
|
|
276
|
+
while(first < groups.length){
|
|
277
|
+
let digits = '';
|
|
278
|
+
let matchedLast = -1;
|
|
279
|
+
for(let last = first; last < groups.length; last++){
|
|
280
|
+
digits += groups[last].digits;
|
|
281
|
+
if (digits.length > 19) break;
|
|
282
|
+
if (digits.length >= 13 && passesLuhn(digits)) matchedLast = last;
|
|
283
|
+
}
|
|
284
|
+
if (matchedLast >= 0) {
|
|
285
|
+
output += match.slice(cursor, groups[first].start) + REDACTED_VALUE;
|
|
286
|
+
cursor = groups[matchedLast].end;
|
|
287
|
+
first = matchedLast + 1;
|
|
288
|
+
} else first++;
|
|
289
|
+
}
|
|
290
|
+
return output + match.slice(cursor);
|
|
291
|
+
}
|
|
292
|
+
function redactPii(value) {
|
|
293
|
+
let result = value.replace(UNICODE_SPACE_PATTERN, ' ');
|
|
294
|
+
result = result.replace(EMAIL_PATTERN, REDACTED_VALUE);
|
|
295
|
+
result = result.replace(IPV4_PATTERN, REDACTED_VALUE);
|
|
296
|
+
result = result.replace(IPV6_PATTERN, `$1${REDACTED_VALUE}`);
|
|
297
|
+
result = result.replace(CREDIT_CARD_CANDIDATE_PATTERN, redactCardInMatch);
|
|
298
|
+
result = result.replace(US_SSN_PATTERN, REDACTED_VALUE);
|
|
299
|
+
result = result.replace(PHONE_NANP_PATTERN, `$1${REDACTED_VALUE}`);
|
|
300
|
+
result = result.replace(PHONE_INTL_PATTERN, `$1${REDACTED_VALUE}`);
|
|
301
|
+
return result;
|
|
302
|
+
}
|
|
303
|
+
function sanitizeCapturedValue(value, options) {
|
|
304
|
+
return sanitizeValueWith(value, (stringValue)=>sanitizeString(stringValue, options));
|
|
305
|
+
}
|
|
306
|
+
function sanitizeFreeTextValue(value, options) {
|
|
307
|
+
return sanitizeValueWith(value, (stringValue)=>sanitizeFreeText(stringValue, options));
|
|
308
|
+
}
|
|
309
|
+
function sanitizeValueWith(value, sanitizeStringFn) {
|
|
310
|
+
if (null == value) return value;
|
|
311
|
+
if ('string' == typeof value) return sanitizeStringFn(value);
|
|
312
|
+
if (Array.isArray(value)) return value.map((item)=>sanitizeValueWith(item, sanitizeStringFn));
|
|
313
|
+
if (value instanceof Date) return value;
|
|
314
|
+
if ('object' != typeof value) return value;
|
|
315
|
+
const result = {};
|
|
316
|
+
for (const [key, nestedValue] of Object.entries(value))result[key] = shouldRedactKey(key) ? REDACTED_VALUE : sanitizeValueWith(nestedValue, sanitizeStringFn);
|
|
317
|
+
return result;
|
|
318
|
+
}
|
|
319
|
+
export { redactPii, sanitizeCapturedValue, sanitizeFreeText, sanitizeFreeTextValue };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@posthog/core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.57.0",
|
|
4
4
|
"bugs": {
|
|
5
5
|
"url": "https://github.com/PostHog/posthog-js/issues"
|
|
6
6
|
},
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
}
|
|
71
71
|
},
|
|
72
72
|
"dependencies": {
|
|
73
|
-
"@posthog/types": "^1.
|
|
73
|
+
"@posthog/types": "^1.415.0"
|
|
74
74
|
},
|
|
75
75
|
"devDependencies": {
|
|
76
76
|
"@rslib/core": "0.23.2",
|
|
@@ -110,6 +110,7 @@ export { uuidv7 } from './vendor/uuidv7'
|
|
|
110
110
|
export * from './cookie'
|
|
111
111
|
export * from './posthog-core'
|
|
112
112
|
export * from './posthog-core-stateless'
|
|
113
|
+
export * from './privacy'
|
|
113
114
|
export * from './tracing-headers'
|
|
114
115
|
export * from './types'
|
|
115
116
|
export { getValidationError, getLengthFromRules, getRequirementsHint } from './surveys/validation'
|