@dexto/core 1.16.5 → 1.17.0-beta.5
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/agent/DextoAgent.cjs +2 -1
- package/dist/agent/DextoAgent.d.ts.map +1 -1
- package/dist/agent/DextoAgent.js +2 -1
- package/dist/agent/schemas.d.ts +2 -2
- package/dist/approval/index.cjs +4 -0
- package/dist/approval/index.d.ts +1 -1
- package/dist/approval/index.d.ts.map +1 -1
- package/dist/approval/index.js +4 -0
- package/dist/events/index.cjs +2 -3
- package/dist/events/index.d.ts +6 -23
- package/dist/events/index.d.ts.map +1 -1
- package/dist/events/index.js +2 -3
- package/dist/llm/auth/index.d.ts +1 -1
- package/dist/llm/auth/index.d.ts.map +1 -1
- package/dist/llm/auth/types.d.ts +14 -0
- package/dist/llm/auth/types.d.ts.map +1 -1
- package/dist/llm/error-codes.cjs +3 -0
- package/dist/llm/error-codes.d.ts +3 -0
- package/dist/llm/error-codes.d.ts.map +1 -1
- package/dist/llm/error-codes.js +3 -0
- package/dist/llm/errors.cjs +27 -0
- package/dist/llm/errors.d.ts +9 -0
- package/dist/llm/errors.d.ts.map +1 -1
- package/dist/llm/errors.js +27 -0
- package/dist/llm/executor/provider-error.cjs +14 -0
- package/dist/llm/executor/provider-error.d.ts.map +1 -1
- package/dist/llm/executor/provider-error.js +14 -0
- package/dist/llm/executor/tool-output-spill.cjs +46 -14
- package/dist/llm/executor/tool-output-spill.d.ts.map +1 -1
- package/dist/llm/executor/tool-output-spill.js +46 -14
- package/dist/llm/executor/turn-executor.cjs +4 -0
- package/dist/llm/executor/turn-executor.d.ts +5 -5
- package/dist/llm/executor/turn-executor.d.ts.map +1 -1
- package/dist/llm/executor/turn-executor.js +4 -0
- package/dist/llm/index.cjs +6 -0
- package/dist/llm/index.d.ts +3 -1
- package/dist/llm/index.d.ts.map +1 -1
- package/dist/llm/index.js +4 -0
- package/dist/llm/private-address.cjs +88 -0
- package/dist/llm/private-address.d.ts +3 -0
- package/dist/llm/private-address.d.ts.map +1 -0
- package/dist/llm/private-address.js +65 -0
- package/dist/llm/providers/codex-app-server.cjs +3 -3
- package/dist/llm/providers/codex-app-server.js +3 -3
- package/dist/llm/providers/local/errors.cjs +4 -4
- package/dist/llm/providers/local/errors.js +4 -4
- package/dist/llm/safe-download.cjs +159 -0
- package/dist/llm/safe-download.d.ts +21 -0
- package/dist/llm/safe-download.d.ts.map +1 -0
- package/dist/llm/safe-download.js +126 -0
- package/dist/llm/services/factory.cjs +204 -14
- package/dist/llm/services/factory.d.ts +1 -1
- package/dist/llm/services/factory.d.ts.map +1 -1
- package/dist/llm/services/factory.js +204 -14
- package/dist/logger/logger.cjs +12 -9
- package/dist/logger/logger.d.ts.map +1 -1
- package/dist/logger/logger.js +12 -9
- package/dist/logger/v2/dexto-logger.cjs +3 -2
- package/dist/logger/v2/dexto-logger.d.ts.map +1 -1
- package/dist/logger/v2/dexto-logger.js +3 -2
- package/dist/mcp/mcp-client.cjs +17 -8
- package/dist/mcp/mcp-client.d.ts +4 -2
- package/dist/mcp/mcp-client.d.ts.map +1 -1
- package/dist/mcp/mcp-client.js +17 -8
- package/dist/mcp/schemas.cjs +3 -0
- package/dist/mcp/schemas.d.ts +3 -0
- package/dist/mcp/schemas.d.ts.map +1 -1
- package/dist/mcp/schemas.js +3 -0
- package/dist/resources/handlers/filesystem-handler.cjs +7 -6
- package/dist/resources/handlers/filesystem-handler.d.ts.map +1 -1
- package/dist/resources/handlers/filesystem-handler.js +7 -6
- package/dist/session/session-manager.cjs +2 -0
- package/dist/session/session-manager.d.ts.map +1 -1
- package/dist/session/session-manager.js +2 -0
- package/dist/systemPrompt/schemas.d.ts +3 -3
- package/dist/telemetry/decorators.cjs +2 -2
- package/dist/telemetry/decorators.js +2 -2
- package/dist/tools/activity.cjs +0 -16
- package/dist/tools/activity.d.ts +0 -2
- package/dist/tools/activity.d.ts.map +1 -1
- package/dist/tools/activity.js +0 -16
- package/dist/tools/tool-call-metadata.cjs +0 -12
- package/dist/tools/tool-call-metadata.d.ts +0 -3
- package/dist/tools/tool-call-metadata.d.ts.map +1 -1
- package/dist/tools/tool-call-metadata.js +0 -12
- package/dist/tools/tool-manager.cjs +10 -93
- package/dist/tools/tool-manager.d.ts.map +1 -1
- package/dist/tools/tool-manager.js +10 -93
- package/dist/tools/tool-output-read.cjs +4 -3
- package/dist/tools/tool-output-read.d.ts.map +1 -1
- package/dist/tools/tool-output-read.js +4 -3
- package/dist/utils/env.cjs +0 -5
- package/dist/utils/env.d.ts +0 -1
- package/dist/utils/env.d.ts.map +1 -1
- package/dist/utils/env.js +0 -4
- package/dist/utils/index.cjs +3 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +1 -0
- package/dist/utils/metadata-address.cjs +138 -0
- package/dist/utils/metadata-address.d.ts +24 -0
- package/dist/utils/metadata-address.d.ts.map +1 -0
- package/dist/utils/metadata-address.js +113 -0
- package/dist/utils/path.cjs +0 -15
- package/dist/utils/path.d.ts +0 -6
- package/dist/utils/path.d.ts.map +1 -1
- package/dist/utils/path.js +0 -14
- package/dist/utils/redactor.cjs +242 -34
- package/dist/utils/redactor.d.ts +15 -0
- package/dist/utils/redactor.d.ts.map +1 -1
- package/dist/utils/redactor.js +238 -34
- package/dist/utils/text-boundary.cjs +32 -0
- package/dist/utils/text-boundary.d.ts +3 -0
- package/dist/utils/text-boundary.d.ts.map +1 -0
- package/dist/utils/text-boundary.js +9 -0
- package/dist/workspace/index.cjs +7 -2
- package/dist/workspace/index.d.ts +1 -0
- package/dist/workspace/index.d.ts.map +1 -1
- package/dist/workspace/index.js +4 -1
- package/dist/workspace/shell-environment.cjs +96 -0
- package/dist/workspace/shell-environment.d.ts +18 -0
- package/dist/workspace/shell-environment.d.ts.map +1 -0
- package/dist/workspace/shell-environment.js +72 -0
- package/dist/workspace/types.d.ts +9 -0
- package/dist/workspace/types.d.ts.map +1 -1
- package/package.json +3 -3
package/dist/utils/redactor.cjs
CHANGED
|
@@ -18,6 +18,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var redactor_exports = {};
|
|
20
20
|
__export(redactor_exports, {
|
|
21
|
+
UNREDACTABLE_LOG_DATA: () => UNREDACTABLE_LOG_DATA,
|
|
22
|
+
redactLogMessage: () => redactLogMessage,
|
|
23
|
+
redactLogRecord: () => redactLogRecord,
|
|
24
|
+
redactLogText: () => redactLogText,
|
|
21
25
|
redactSensitiveData: () => redactSensitiveData
|
|
22
26
|
});
|
|
23
27
|
module.exports = __toCommonJS(redactor_exports);
|
|
@@ -28,7 +32,14 @@ const SENSITIVE_FIELDS = [
|
|
|
28
32
|
"access_token",
|
|
29
33
|
"refresh_token",
|
|
30
34
|
"password",
|
|
31
|
-
"secret"
|
|
35
|
+
"secret",
|
|
36
|
+
"client_secret",
|
|
37
|
+
"private_key",
|
|
38
|
+
"authorization",
|
|
39
|
+
"proxy-authorization",
|
|
40
|
+
"cookie",
|
|
41
|
+
"set-cookie",
|
|
42
|
+
"x-api-key"
|
|
32
43
|
];
|
|
33
44
|
const FILE_DATA_FIELDS = [
|
|
34
45
|
"base64",
|
|
@@ -154,46 +165,243 @@ function redactText(text, awsAccessKeyIdPattern, keepTokenValue) {
|
|
|
154
165
|
)
|
|
155
166
|
);
|
|
156
167
|
}
|
|
157
|
-
function
|
|
168
|
+
function redactString(input) {
|
|
169
|
+
const signedUrls = [];
|
|
170
|
+
const withPlaceholders = input.includes("\uE000") ? input : input.split(URL_PATTERN).map((part, index) => {
|
|
171
|
+
if (index % 2 === 0 || !isSignedUrl(part)) return part;
|
|
172
|
+
signedUrls.push(part);
|
|
173
|
+
return `\uE000${signedUrls.length - 1}\uE000`;
|
|
174
|
+
}).join("");
|
|
175
|
+
const result = redactText(withPlaceholders, AWS_ACCESS_KEY_ID_PATTERN, false);
|
|
176
|
+
return signedUrls.length === 0 ? result : result.replace(SIGNED_URL_PLACEHOLDER, (_placeholder, index) => {
|
|
177
|
+
const url = signedUrls[Number(index)];
|
|
178
|
+
return url === void 0 ? REDACTED : redactText(url, AWS_ACCESS_KEY_ID_OUTSIDE_CREDENTIAL_PATTERN, true);
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
const MAX_LOG_DEPTH = 20;
|
|
182
|
+
const MAX_LOG_NODES = 5e3;
|
|
183
|
+
const TRUNCATED = "[Truncated]";
|
|
184
|
+
const SHARED = "[Shared]";
|
|
185
|
+
const UNREDACTABLE_LOG_DATA = "[unredactable log data]";
|
|
186
|
+
function describeBinary(value) {
|
|
187
|
+
const name = value instanceof ArrayBuffer ? "ArrayBuffer" : value.constructor.name;
|
|
188
|
+
return `[${name} ${value.byteLength} bytes]`;
|
|
189
|
+
}
|
|
190
|
+
function redactValue(input, walk, mode, insideSecret, depth = 0) {
|
|
158
191
|
if (typeof input === "string") {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
192
|
+
if (insideSecret) return REDACTED;
|
|
193
|
+
return mode === "log" ? redactLogString(input) : redactString(input);
|
|
194
|
+
}
|
|
195
|
+
if (typeof input !== "object" || input === null) return input;
|
|
196
|
+
if (input instanceof ArrayBuffer || ArrayBuffer.isView(input)) return describeBinary(input);
|
|
197
|
+
if (input instanceof Date) {
|
|
198
|
+
return Number.isNaN(input.getTime()) ? "Invalid Date" : input.toISOString();
|
|
199
|
+
}
|
|
200
|
+
if (input instanceof RegExp) return String(input);
|
|
201
|
+
if (input instanceof URL) {
|
|
202
|
+
const withoutCredentials = new URL(input.href);
|
|
203
|
+
withoutCredentials.username = "";
|
|
204
|
+
withoutCredentials.password = "";
|
|
205
|
+
return redactValue(withoutCredentials.href, walk, mode, insideSecret, depth);
|
|
206
|
+
}
|
|
207
|
+
if (walk.ancestors.has(input)) return REDACTED_CIRCULAR;
|
|
208
|
+
if (walk.shared?.has(input)) return insideSecret ? REDACTED : SHARED;
|
|
209
|
+
const memoized = walk.memo?.get(input);
|
|
210
|
+
if (memoized !== void 0) return memoized;
|
|
211
|
+
if (mode === "log" && depth >= MAX_LOG_DEPTH) return TRUNCATED;
|
|
212
|
+
if (walk.remaining <= 0) return TRUNCATED;
|
|
213
|
+
walk.remaining -= 1;
|
|
214
|
+
walk.ancestors.add(input);
|
|
215
|
+
try {
|
|
216
|
+
const result = redactContainer(input, walk, mode, insideSecret, depth + 1);
|
|
217
|
+
walk.memo?.set(input, result);
|
|
218
|
+
walk.shared?.add(input);
|
|
219
|
+
return result;
|
|
220
|
+
} finally {
|
|
221
|
+
walk.ancestors.delete(input);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
function errorFields(error) {
|
|
225
|
+
const toJSON = Reflect.get(error, "toJSON");
|
|
226
|
+
const json = typeof toJSON === "function" ? toJSON.call(error) : void 0;
|
|
227
|
+
return {
|
|
228
|
+
name: error.name,
|
|
229
|
+
message: error.message,
|
|
230
|
+
stack: error.stack,
|
|
231
|
+
...error.cause !== void 0 && { cause: error.cause },
|
|
232
|
+
...Object.fromEntries(Object.entries(error)),
|
|
233
|
+
...typeof json === "object" && json !== null ? Object.fromEntries(Object.entries(json)) : {}
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
function redactContainer(input, walk, mode, insideSecret, depth) {
|
|
237
|
+
if (Array.isArray(input) || input instanceof Set) {
|
|
238
|
+
return [...input].map((item) => redactValue(item, walk, mode, insideSecret, depth));
|
|
239
|
+
}
|
|
240
|
+
if (input instanceof Map) {
|
|
241
|
+
return [...input].map(([key, value]) => [
|
|
242
|
+
redactValue(key, walk, mode, insideSecret, depth),
|
|
243
|
+
redactEntry(String(key), value, walk, mode, insideSecret, depth)
|
|
244
|
+
]);
|
|
245
|
+
}
|
|
246
|
+
const fields = mode === "log" && input instanceof Error ? errorFields(input) : Object.fromEntries(Object.entries(input));
|
|
247
|
+
const result = {};
|
|
248
|
+
for (const [key, value] of Object.entries(fields)) {
|
|
249
|
+
if (SENSITIVE_FIELDS.includes(key.toLowerCase())) {
|
|
250
|
+
result[key] = REDACTED;
|
|
251
|
+
continue;
|
|
252
|
+
}
|
|
253
|
+
const truncatedValue = truncateFileData(value, key, fields);
|
|
254
|
+
result[key] = redactEntry(key, truncatedValue, walk, mode, insideSecret, depth);
|
|
255
|
+
}
|
|
256
|
+
return result;
|
|
257
|
+
}
|
|
258
|
+
function redactEntry(key, value, walk, mode, insideSecret, depth) {
|
|
259
|
+
if (mode === "log" && !insideSecret) {
|
|
260
|
+
if (isSecretMapKey(key) && isPlainObject(value)) {
|
|
261
|
+
return redactValue(value, walk, mode, true, depth);
|
|
262
|
+
}
|
|
263
|
+
if (isSensitiveLogKey(key)) {
|
|
264
|
+
if (typeof value === "string") return REDACTED;
|
|
265
|
+
if (Array.isArray(value)) {
|
|
266
|
+
return value.map(
|
|
267
|
+
(item) => typeof item === "string" ? REDACTED : redactValue(item, walk, mode, false, depth)
|
|
188
268
|
);
|
|
189
|
-
result[key] = redactSensitiveData(truncatedValue, seen);
|
|
190
269
|
}
|
|
191
270
|
}
|
|
192
|
-
return result;
|
|
193
271
|
}
|
|
194
|
-
return
|
|
272
|
+
return redactValue(value, walk, mode, insideSecret, depth);
|
|
273
|
+
}
|
|
274
|
+
function isPlainObject(value) {
|
|
275
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
276
|
+
}
|
|
277
|
+
function redactSensitiveData(input, seen = /* @__PURE__ */ new WeakSet()) {
|
|
278
|
+
return redactValue(
|
|
279
|
+
input,
|
|
280
|
+
{ ancestors: seen, memo: /* @__PURE__ */ new WeakMap(), shared: void 0, remaining: Infinity },
|
|
281
|
+
"response",
|
|
282
|
+
false
|
|
283
|
+
);
|
|
284
|
+
}
|
|
285
|
+
const SENSITIVE_KEY_SUFFIXES = [
|
|
286
|
+
"token",
|
|
287
|
+
"secret",
|
|
288
|
+
"secrets",
|
|
289
|
+
"password",
|
|
290
|
+
"passwd",
|
|
291
|
+
"passphrase",
|
|
292
|
+
"bearer",
|
|
293
|
+
"credential",
|
|
294
|
+
"authorization",
|
|
295
|
+
"cookie",
|
|
296
|
+
"cookies",
|
|
297
|
+
"apikey",
|
|
298
|
+
"apikeys",
|
|
299
|
+
"privatekey",
|
|
300
|
+
"accesskey",
|
|
301
|
+
"secretkey",
|
|
302
|
+
"signingkey",
|
|
303
|
+
"encryptionkey"
|
|
304
|
+
];
|
|
305
|
+
const SECRET_MAP_KEYS = /* @__PURE__ */ new Set(["env", "envvars", "environment", "headers"]);
|
|
306
|
+
function normalizeKey(key) {
|
|
307
|
+
return key.toLowerCase().replace(/[^a-z0-9]/g, "");
|
|
308
|
+
}
|
|
309
|
+
function isSensitiveLogKey(key) {
|
|
310
|
+
const normalized = normalizeKey(key);
|
|
311
|
+
return SENSITIVE_KEY_SUFFIXES.some((suffix) => normalized.endsWith(suffix));
|
|
312
|
+
}
|
|
313
|
+
function isSecretMapKey(key) {
|
|
314
|
+
return SECRET_MAP_KEYS.has(normalizeKey(key));
|
|
315
|
+
}
|
|
316
|
+
const HEADER_LINE_PATTERN = /(?<![A-Za-z0-9_-])((?:proxy-)?authorization|(?:set-)?cookie|x-api-key|x-auth-token)(\s*[:=]\s*)(?!["'\\])[^\r\n]*/gi;
|
|
317
|
+
const NAME_PATTERN = /(?<![A-Za-z0-9_.-])([A-Za-z][A-Za-z0-9_.-]*)(\\?["']?)(\s*[:=]\s*)/g;
|
|
318
|
+
const VALUE_PATTERN = /\\"(?:[^"\\]|\\(?!")){0,4096}?\\"|"(?:[^"\\]|\\.){0,4096}"|'(?:[^'\\]|\\.){0,4096}'|[^\s,;&"'}\])\\]+|["'\\][^\r\n]*/y;
|
|
319
|
+
const SECRET_MAP_TEXT_PATTERN = /(?<![A-Za-z0-9_-])(env|envvars|environment|headers)(\\?["']?\s*[:=]\s*)\{([^{}]{0,8192})\}/gi;
|
|
320
|
+
const MAP_ENTRY_PATTERN = /((?:\\?["'])?[A-Za-z0-9_.-]{1,128}(?:\\?["'])?\s*[:=]\s*)(\\"(?:[^"\\]|\\(?!")){0,4096}?\\"|"(?:[^"\\]|\\.){0,4096}"|'(?:[^'\\]|\\.){0,4096}'|[^\s,}]+)/g;
|
|
321
|
+
const PLAIN_VALUE_PATTERN = /^(?:\d+(?:\.\d+)?|true|false|null|undefined)$/i;
|
|
322
|
+
function looksLikeCredential(value) {
|
|
323
|
+
return /^[\\"']/.test(value) || /[^A-Za-z]/.test(value) || value.length >= 16;
|
|
324
|
+
}
|
|
325
|
+
function maskedLike(value) {
|
|
326
|
+
for (const quote of ['\\"', '"', "'"]) {
|
|
327
|
+
if (value.length >= quote.length * 2 && value.startsWith(quote) && value.endsWith(quote)) {
|
|
328
|
+
return `${quote}${REDACTED}${quote}`;
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
return REDACTED;
|
|
332
|
+
}
|
|
333
|
+
const URL_USERINFO_PATTERN = /(?<![A-Za-z0-9+.-])([A-Za-z][A-Za-z0-9+.-]{0,31}:\/\/[^\s/@:"'?#]*:)[^\s/?#"']*@/g;
|
|
334
|
+
function maskUrlUserinfo(text) {
|
|
335
|
+
return text.replace(URL_USERINFO_PATTERN, (_match, prefix) => `${prefix}${REDACTED}@`);
|
|
336
|
+
}
|
|
337
|
+
function redactLogString(text) {
|
|
338
|
+
return redactKeyValueText(redactString(maskUrlUserinfo(text)));
|
|
339
|
+
}
|
|
340
|
+
function redactKeyValueText(text) {
|
|
341
|
+
const withMaps = text.replace(
|
|
342
|
+
HEADER_LINE_PATTERN,
|
|
343
|
+
(_match, name, separator) => `${name}${separator}${REDACTED}`
|
|
344
|
+
).replace(
|
|
345
|
+
SECRET_MAP_TEXT_PATTERN,
|
|
346
|
+
(_match, name, separator, entries) => `${name}${separator}{${entries.replace(
|
|
347
|
+
MAP_ENTRY_PATTERN,
|
|
348
|
+
(_entry, prefix, value) => `${prefix}${maskedLike(value)}`
|
|
349
|
+
)}}`
|
|
350
|
+
);
|
|
351
|
+
const names = new RegExp(NAME_PATTERN);
|
|
352
|
+
const values = new RegExp(VALUE_PATTERN);
|
|
353
|
+
let result = "";
|
|
354
|
+
let copiedUpTo = 0;
|
|
355
|
+
for (let found = names.exec(withMaps); found; found = names.exec(withMaps)) {
|
|
356
|
+
if (!isSensitiveLogKey(found[1] ?? "")) continue;
|
|
357
|
+
values.lastIndex = names.lastIndex;
|
|
358
|
+
const value = values.exec(withMaps)?.[0];
|
|
359
|
+
if (value === void 0) continue;
|
|
360
|
+
names.lastIndex = values.lastIndex;
|
|
361
|
+
if (value.startsWith(REDACTED.slice(0, -1)) || PLAIN_VALUE_PATTERN.test(value)) continue;
|
|
362
|
+
if (!found[3]?.includes("=") && !looksLikeCredential(value)) continue;
|
|
363
|
+
result += withMaps.slice(copiedUpTo, values.lastIndex - value.length) + maskedLike(value);
|
|
364
|
+
copiedUpTo = values.lastIndex;
|
|
365
|
+
}
|
|
366
|
+
return result + withMaps.slice(copiedUpTo);
|
|
367
|
+
}
|
|
368
|
+
function redactLogText(text) {
|
|
369
|
+
return redactLogString(text);
|
|
370
|
+
}
|
|
371
|
+
function redactLogMessage(message) {
|
|
372
|
+
try {
|
|
373
|
+
return redactLogText(typeof message === "string" ? message : String(message));
|
|
374
|
+
} catch {
|
|
375
|
+
return UNREDACTABLE_LOG_DATA;
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
function redactLogRecord(record, skip = []) {
|
|
379
|
+
try {
|
|
380
|
+
const entries = Object.entries(record).filter(([key]) => !skip.includes(key));
|
|
381
|
+
const redacted = redactValue(
|
|
382
|
+
Object.fromEntries(entries),
|
|
383
|
+
{
|
|
384
|
+
ancestors: /* @__PURE__ */ new WeakSet(),
|
|
385
|
+
memo: void 0,
|
|
386
|
+
shared: /* @__PURE__ */ new WeakSet(),
|
|
387
|
+
remaining: MAX_LOG_NODES
|
|
388
|
+
},
|
|
389
|
+
"log",
|
|
390
|
+
false
|
|
391
|
+
);
|
|
392
|
+
if (typeof redacted !== "object" || redacted === null || Array.isArray(redacted)) {
|
|
393
|
+
return { redacted: UNREDACTABLE_LOG_DATA };
|
|
394
|
+
}
|
|
395
|
+
return Object.fromEntries(Object.entries(redacted));
|
|
396
|
+
} catch {
|
|
397
|
+
return { redacted: UNREDACTABLE_LOG_DATA };
|
|
398
|
+
}
|
|
195
399
|
}
|
|
196
400
|
// Annotate the CommonJS export names for ESM import in node:
|
|
197
401
|
0 && (module.exports = {
|
|
402
|
+
UNREDACTABLE_LOG_DATA,
|
|
403
|
+
redactLogMessage,
|
|
404
|
+
redactLogRecord,
|
|
405
|
+
redactLogText,
|
|
198
406
|
redactSensitiveData
|
|
199
407
|
});
|
package/dist/utils/redactor.d.ts
CHANGED
|
@@ -6,5 +6,20 @@
|
|
|
6
6
|
* - Recursive and preserves structure
|
|
7
7
|
* - Easy to extend
|
|
8
8
|
*/
|
|
9
|
+
/** The text a logger writes when it could not redact an entry, never the entry itself. */
|
|
10
|
+
export declare const UNREDACTABLE_LOG_DATA = "[unredactable log data]";
|
|
9
11
|
export declare function redactSensitiveData(input: unknown, seen?: WeakSet<object>): unknown;
|
|
12
|
+
/** Redacts one log message: known secret shapes, then the value of any secret-named key. */
|
|
13
|
+
export declare function redactLogText(text: string): string;
|
|
14
|
+
/**
|
|
15
|
+
* A log message of any type, as redacted text. Never throws: an entry that cannot be read is
|
|
16
|
+
* replaced by UNREDACTABLE_LOG_DATA, not passed on as it was.
|
|
17
|
+
*/
|
|
18
|
+
export declare function redactLogMessage(message: unknown): string;
|
|
19
|
+
/**
|
|
20
|
+
* A log record (context or metadata) with secrets masked, leaving out `skip`. Never throws: a
|
|
21
|
+
* record that cannot be read (a throwing getter, a revoked proxy) becomes one key holding
|
|
22
|
+
* UNREDACTABLE_LOG_DATA, not the record itself.
|
|
23
|
+
*/
|
|
24
|
+
export declare function redactLogRecord(record: object, skip?: readonly string[]): Record<string, unknown>;
|
|
10
25
|
//# sourceMappingURL=redactor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"redactor.d.ts","sourceRoot":"","sources":["../../src/utils/redactor.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;
|
|
1
|
+
{"version":3,"file":"redactor.d.ts","sourceRoot":"","sources":["../../src/utils/redactor.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAiQH,0FAA0F;AAC1F,eAAO,MAAM,qBAAqB,4BAA4B,CAAC;AAoJ/D,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,kBAAwB,GAAG,OAAO,CAOzF;AA4ID,4FAA4F;AAC5F,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAElD;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CAMzD;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAC3B,MAAM,EAAE,MAAM,EACd,IAAI,GAAE,SAAS,MAAM,EAAO,GAC7B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAqBzB"}
|
package/dist/utils/redactor.js
CHANGED
|
@@ -6,7 +6,14 @@ const SENSITIVE_FIELDS = [
|
|
|
6
6
|
"access_token",
|
|
7
7
|
"refresh_token",
|
|
8
8
|
"password",
|
|
9
|
-
"secret"
|
|
9
|
+
"secret",
|
|
10
|
+
"client_secret",
|
|
11
|
+
"private_key",
|
|
12
|
+
"authorization",
|
|
13
|
+
"proxy-authorization",
|
|
14
|
+
"cookie",
|
|
15
|
+
"set-cookie",
|
|
16
|
+
"x-api-key"
|
|
10
17
|
];
|
|
11
18
|
const FILE_DATA_FIELDS = [
|
|
12
19
|
"base64",
|
|
@@ -132,45 +139,242 @@ function redactText(text, awsAccessKeyIdPattern, keepTokenValue) {
|
|
|
132
139
|
)
|
|
133
140
|
);
|
|
134
141
|
}
|
|
135
|
-
function
|
|
142
|
+
function redactString(input) {
|
|
143
|
+
const signedUrls = [];
|
|
144
|
+
const withPlaceholders = input.includes("\uE000") ? input : input.split(URL_PATTERN).map((part, index) => {
|
|
145
|
+
if (index % 2 === 0 || !isSignedUrl(part)) return part;
|
|
146
|
+
signedUrls.push(part);
|
|
147
|
+
return `\uE000${signedUrls.length - 1}\uE000`;
|
|
148
|
+
}).join("");
|
|
149
|
+
const result = redactText(withPlaceholders, AWS_ACCESS_KEY_ID_PATTERN, false);
|
|
150
|
+
return signedUrls.length === 0 ? result : result.replace(SIGNED_URL_PLACEHOLDER, (_placeholder, index) => {
|
|
151
|
+
const url = signedUrls[Number(index)];
|
|
152
|
+
return url === void 0 ? REDACTED : redactText(url, AWS_ACCESS_KEY_ID_OUTSIDE_CREDENTIAL_PATTERN, true);
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
const MAX_LOG_DEPTH = 20;
|
|
156
|
+
const MAX_LOG_NODES = 5e3;
|
|
157
|
+
const TRUNCATED = "[Truncated]";
|
|
158
|
+
const SHARED = "[Shared]";
|
|
159
|
+
const UNREDACTABLE_LOG_DATA = "[unredactable log data]";
|
|
160
|
+
function describeBinary(value) {
|
|
161
|
+
const name = value instanceof ArrayBuffer ? "ArrayBuffer" : value.constructor.name;
|
|
162
|
+
return `[${name} ${value.byteLength} bytes]`;
|
|
163
|
+
}
|
|
164
|
+
function redactValue(input, walk, mode, insideSecret, depth = 0) {
|
|
136
165
|
if (typeof input === "string") {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
+
if (insideSecret) return REDACTED;
|
|
167
|
+
return mode === "log" ? redactLogString(input) : redactString(input);
|
|
168
|
+
}
|
|
169
|
+
if (typeof input !== "object" || input === null) return input;
|
|
170
|
+
if (input instanceof ArrayBuffer || ArrayBuffer.isView(input)) return describeBinary(input);
|
|
171
|
+
if (input instanceof Date) {
|
|
172
|
+
return Number.isNaN(input.getTime()) ? "Invalid Date" : input.toISOString();
|
|
173
|
+
}
|
|
174
|
+
if (input instanceof RegExp) return String(input);
|
|
175
|
+
if (input instanceof URL) {
|
|
176
|
+
const withoutCredentials = new URL(input.href);
|
|
177
|
+
withoutCredentials.username = "";
|
|
178
|
+
withoutCredentials.password = "";
|
|
179
|
+
return redactValue(withoutCredentials.href, walk, mode, insideSecret, depth);
|
|
180
|
+
}
|
|
181
|
+
if (walk.ancestors.has(input)) return REDACTED_CIRCULAR;
|
|
182
|
+
if (walk.shared?.has(input)) return insideSecret ? REDACTED : SHARED;
|
|
183
|
+
const memoized = walk.memo?.get(input);
|
|
184
|
+
if (memoized !== void 0) return memoized;
|
|
185
|
+
if (mode === "log" && depth >= MAX_LOG_DEPTH) return TRUNCATED;
|
|
186
|
+
if (walk.remaining <= 0) return TRUNCATED;
|
|
187
|
+
walk.remaining -= 1;
|
|
188
|
+
walk.ancestors.add(input);
|
|
189
|
+
try {
|
|
190
|
+
const result = redactContainer(input, walk, mode, insideSecret, depth + 1);
|
|
191
|
+
walk.memo?.set(input, result);
|
|
192
|
+
walk.shared?.add(input);
|
|
193
|
+
return result;
|
|
194
|
+
} finally {
|
|
195
|
+
walk.ancestors.delete(input);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
function errorFields(error) {
|
|
199
|
+
const toJSON = Reflect.get(error, "toJSON");
|
|
200
|
+
const json = typeof toJSON === "function" ? toJSON.call(error) : void 0;
|
|
201
|
+
return {
|
|
202
|
+
name: error.name,
|
|
203
|
+
message: error.message,
|
|
204
|
+
stack: error.stack,
|
|
205
|
+
...error.cause !== void 0 && { cause: error.cause },
|
|
206
|
+
...Object.fromEntries(Object.entries(error)),
|
|
207
|
+
...typeof json === "object" && json !== null ? Object.fromEntries(Object.entries(json)) : {}
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
function redactContainer(input, walk, mode, insideSecret, depth) {
|
|
211
|
+
if (Array.isArray(input) || input instanceof Set) {
|
|
212
|
+
return [...input].map((item) => redactValue(item, walk, mode, insideSecret, depth));
|
|
213
|
+
}
|
|
214
|
+
if (input instanceof Map) {
|
|
215
|
+
return [...input].map(([key, value]) => [
|
|
216
|
+
redactValue(key, walk, mode, insideSecret, depth),
|
|
217
|
+
redactEntry(String(key), value, walk, mode, insideSecret, depth)
|
|
218
|
+
]);
|
|
219
|
+
}
|
|
220
|
+
const fields = mode === "log" && input instanceof Error ? errorFields(input) : Object.fromEntries(Object.entries(input));
|
|
221
|
+
const result = {};
|
|
222
|
+
for (const [key, value] of Object.entries(fields)) {
|
|
223
|
+
if (SENSITIVE_FIELDS.includes(key.toLowerCase())) {
|
|
224
|
+
result[key] = REDACTED;
|
|
225
|
+
continue;
|
|
226
|
+
}
|
|
227
|
+
const truncatedValue = truncateFileData(value, key, fields);
|
|
228
|
+
result[key] = redactEntry(key, truncatedValue, walk, mode, insideSecret, depth);
|
|
229
|
+
}
|
|
230
|
+
return result;
|
|
231
|
+
}
|
|
232
|
+
function redactEntry(key, value, walk, mode, insideSecret, depth) {
|
|
233
|
+
if (mode === "log" && !insideSecret) {
|
|
234
|
+
if (isSecretMapKey(key) && isPlainObject(value)) {
|
|
235
|
+
return redactValue(value, walk, mode, true, depth);
|
|
236
|
+
}
|
|
237
|
+
if (isSensitiveLogKey(key)) {
|
|
238
|
+
if (typeof value === "string") return REDACTED;
|
|
239
|
+
if (Array.isArray(value)) {
|
|
240
|
+
return value.map(
|
|
241
|
+
(item) => typeof item === "string" ? REDACTED : redactValue(item, walk, mode, false, depth)
|
|
166
242
|
);
|
|
167
|
-
result[key] = redactSensitiveData(truncatedValue, seen);
|
|
168
243
|
}
|
|
169
244
|
}
|
|
170
|
-
return result;
|
|
171
245
|
}
|
|
172
|
-
return
|
|
246
|
+
return redactValue(value, walk, mode, insideSecret, depth);
|
|
247
|
+
}
|
|
248
|
+
function isPlainObject(value) {
|
|
249
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
250
|
+
}
|
|
251
|
+
function redactSensitiveData(input, seen = /* @__PURE__ */ new WeakSet()) {
|
|
252
|
+
return redactValue(
|
|
253
|
+
input,
|
|
254
|
+
{ ancestors: seen, memo: /* @__PURE__ */ new WeakMap(), shared: void 0, remaining: Infinity },
|
|
255
|
+
"response",
|
|
256
|
+
false
|
|
257
|
+
);
|
|
258
|
+
}
|
|
259
|
+
const SENSITIVE_KEY_SUFFIXES = [
|
|
260
|
+
"token",
|
|
261
|
+
"secret",
|
|
262
|
+
"secrets",
|
|
263
|
+
"password",
|
|
264
|
+
"passwd",
|
|
265
|
+
"passphrase",
|
|
266
|
+
"bearer",
|
|
267
|
+
"credential",
|
|
268
|
+
"authorization",
|
|
269
|
+
"cookie",
|
|
270
|
+
"cookies",
|
|
271
|
+
"apikey",
|
|
272
|
+
"apikeys",
|
|
273
|
+
"privatekey",
|
|
274
|
+
"accesskey",
|
|
275
|
+
"secretkey",
|
|
276
|
+
"signingkey",
|
|
277
|
+
"encryptionkey"
|
|
278
|
+
];
|
|
279
|
+
const SECRET_MAP_KEYS = /* @__PURE__ */ new Set(["env", "envvars", "environment", "headers"]);
|
|
280
|
+
function normalizeKey(key) {
|
|
281
|
+
return key.toLowerCase().replace(/[^a-z0-9]/g, "");
|
|
282
|
+
}
|
|
283
|
+
function isSensitiveLogKey(key) {
|
|
284
|
+
const normalized = normalizeKey(key);
|
|
285
|
+
return SENSITIVE_KEY_SUFFIXES.some((suffix) => normalized.endsWith(suffix));
|
|
286
|
+
}
|
|
287
|
+
function isSecretMapKey(key) {
|
|
288
|
+
return SECRET_MAP_KEYS.has(normalizeKey(key));
|
|
289
|
+
}
|
|
290
|
+
const HEADER_LINE_PATTERN = /(?<![A-Za-z0-9_-])((?:proxy-)?authorization|(?:set-)?cookie|x-api-key|x-auth-token)(\s*[:=]\s*)(?!["'\\])[^\r\n]*/gi;
|
|
291
|
+
const NAME_PATTERN = /(?<![A-Za-z0-9_.-])([A-Za-z][A-Za-z0-9_.-]*)(\\?["']?)(\s*[:=]\s*)/g;
|
|
292
|
+
const VALUE_PATTERN = /\\"(?:[^"\\]|\\(?!")){0,4096}?\\"|"(?:[^"\\]|\\.){0,4096}"|'(?:[^'\\]|\\.){0,4096}'|[^\s,;&"'}\])\\]+|["'\\][^\r\n]*/y;
|
|
293
|
+
const SECRET_MAP_TEXT_PATTERN = /(?<![A-Za-z0-9_-])(env|envvars|environment|headers)(\\?["']?\s*[:=]\s*)\{([^{}]{0,8192})\}/gi;
|
|
294
|
+
const MAP_ENTRY_PATTERN = /((?:\\?["'])?[A-Za-z0-9_.-]{1,128}(?:\\?["'])?\s*[:=]\s*)(\\"(?:[^"\\]|\\(?!")){0,4096}?\\"|"(?:[^"\\]|\\.){0,4096}"|'(?:[^'\\]|\\.){0,4096}'|[^\s,}]+)/g;
|
|
295
|
+
const PLAIN_VALUE_PATTERN = /^(?:\d+(?:\.\d+)?|true|false|null|undefined)$/i;
|
|
296
|
+
function looksLikeCredential(value) {
|
|
297
|
+
return /^[\\"']/.test(value) || /[^A-Za-z]/.test(value) || value.length >= 16;
|
|
298
|
+
}
|
|
299
|
+
function maskedLike(value) {
|
|
300
|
+
for (const quote of ['\\"', '"', "'"]) {
|
|
301
|
+
if (value.length >= quote.length * 2 && value.startsWith(quote) && value.endsWith(quote)) {
|
|
302
|
+
return `${quote}${REDACTED}${quote}`;
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
return REDACTED;
|
|
306
|
+
}
|
|
307
|
+
const URL_USERINFO_PATTERN = /(?<![A-Za-z0-9+.-])([A-Za-z][A-Za-z0-9+.-]{0,31}:\/\/[^\s/@:"'?#]*:)[^\s/?#"']*@/g;
|
|
308
|
+
function maskUrlUserinfo(text) {
|
|
309
|
+
return text.replace(URL_USERINFO_PATTERN, (_match, prefix) => `${prefix}${REDACTED}@`);
|
|
310
|
+
}
|
|
311
|
+
function redactLogString(text) {
|
|
312
|
+
return redactKeyValueText(redactString(maskUrlUserinfo(text)));
|
|
313
|
+
}
|
|
314
|
+
function redactKeyValueText(text) {
|
|
315
|
+
const withMaps = text.replace(
|
|
316
|
+
HEADER_LINE_PATTERN,
|
|
317
|
+
(_match, name, separator) => `${name}${separator}${REDACTED}`
|
|
318
|
+
).replace(
|
|
319
|
+
SECRET_MAP_TEXT_PATTERN,
|
|
320
|
+
(_match, name, separator, entries) => `${name}${separator}{${entries.replace(
|
|
321
|
+
MAP_ENTRY_PATTERN,
|
|
322
|
+
(_entry, prefix, value) => `${prefix}${maskedLike(value)}`
|
|
323
|
+
)}}`
|
|
324
|
+
);
|
|
325
|
+
const names = new RegExp(NAME_PATTERN);
|
|
326
|
+
const values = new RegExp(VALUE_PATTERN);
|
|
327
|
+
let result = "";
|
|
328
|
+
let copiedUpTo = 0;
|
|
329
|
+
for (let found = names.exec(withMaps); found; found = names.exec(withMaps)) {
|
|
330
|
+
if (!isSensitiveLogKey(found[1] ?? "")) continue;
|
|
331
|
+
values.lastIndex = names.lastIndex;
|
|
332
|
+
const value = values.exec(withMaps)?.[0];
|
|
333
|
+
if (value === void 0) continue;
|
|
334
|
+
names.lastIndex = values.lastIndex;
|
|
335
|
+
if (value.startsWith(REDACTED.slice(0, -1)) || PLAIN_VALUE_PATTERN.test(value)) continue;
|
|
336
|
+
if (!found[3]?.includes("=") && !looksLikeCredential(value)) continue;
|
|
337
|
+
result += withMaps.slice(copiedUpTo, values.lastIndex - value.length) + maskedLike(value);
|
|
338
|
+
copiedUpTo = values.lastIndex;
|
|
339
|
+
}
|
|
340
|
+
return result + withMaps.slice(copiedUpTo);
|
|
341
|
+
}
|
|
342
|
+
function redactLogText(text) {
|
|
343
|
+
return redactLogString(text);
|
|
344
|
+
}
|
|
345
|
+
function redactLogMessage(message) {
|
|
346
|
+
try {
|
|
347
|
+
return redactLogText(typeof message === "string" ? message : String(message));
|
|
348
|
+
} catch {
|
|
349
|
+
return UNREDACTABLE_LOG_DATA;
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
function redactLogRecord(record, skip = []) {
|
|
353
|
+
try {
|
|
354
|
+
const entries = Object.entries(record).filter(([key]) => !skip.includes(key));
|
|
355
|
+
const redacted = redactValue(
|
|
356
|
+
Object.fromEntries(entries),
|
|
357
|
+
{
|
|
358
|
+
ancestors: /* @__PURE__ */ new WeakSet(),
|
|
359
|
+
memo: void 0,
|
|
360
|
+
shared: /* @__PURE__ */ new WeakSet(),
|
|
361
|
+
remaining: MAX_LOG_NODES
|
|
362
|
+
},
|
|
363
|
+
"log",
|
|
364
|
+
false
|
|
365
|
+
);
|
|
366
|
+
if (typeof redacted !== "object" || redacted === null || Array.isArray(redacted)) {
|
|
367
|
+
return { redacted: UNREDACTABLE_LOG_DATA };
|
|
368
|
+
}
|
|
369
|
+
return Object.fromEntries(Object.entries(redacted));
|
|
370
|
+
} catch {
|
|
371
|
+
return { redacted: UNREDACTABLE_LOG_DATA };
|
|
372
|
+
}
|
|
173
373
|
}
|
|
174
374
|
export {
|
|
375
|
+
UNREDACTABLE_LOG_DATA,
|
|
376
|
+
redactLogMessage,
|
|
377
|
+
redactLogRecord,
|
|
378
|
+
redactLogText,
|
|
175
379
|
redactSensitiveData
|
|
176
380
|
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var text_boundary_exports = {};
|
|
20
|
+
__export(text_boundary_exports, {
|
|
21
|
+
safeTextBoundary: () => safeTextBoundary
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(text_boundary_exports);
|
|
24
|
+
function safeTextBoundary(text, offset) {
|
|
25
|
+
const before = text.charCodeAt(offset - 1);
|
|
26
|
+
const after = text.charCodeAt(offset);
|
|
27
|
+
return before >= 55296 && before <= 56319 && after >= 56320 && after <= 57343 ? offset - 1 : offset;
|
|
28
|
+
}
|
|
29
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
30
|
+
0 && (module.exports = {
|
|
31
|
+
safeTextBoundary
|
|
32
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text-boundary.d.ts","sourceRoot":"","sources":["../../src/utils/text-boundary.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAMrE"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import "../chunk-C6A6W6XS.js";
|
|
2
|
+
function safeTextBoundary(text, offset) {
|
|
3
|
+
const before = text.charCodeAt(offset - 1);
|
|
4
|
+
const after = text.charCodeAt(offset);
|
|
5
|
+
return before >= 55296 && before <= 56319 && after >= 56320 && after <= 57343 ? offset - 1 : offset;
|
|
6
|
+
}
|
|
7
|
+
export {
|
|
8
|
+
safeTextBoundary
|
|
9
|
+
};
|