@c4a/extract-mdx 0.7.1 → 0.7.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/index.js +29 -4
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -18178,6 +18178,8 @@ function keyTokens(key) {
|
|
|
18178
18178
|
return key.replace(/([a-z0-9])([A-Z])/gu, "$1-$2").replace(/[^A-Za-z0-9]+/gu, "-").toLowerCase().split("-").filter(Boolean);
|
|
18179
18179
|
}
|
|
18180
18180
|
function sensitiveKey(key, value) {
|
|
18181
|
+
if (value === INDEXER_OUTPUT_REDACTION_MARKER)
|
|
18182
|
+
return false;
|
|
18181
18183
|
const tokens = keyTokens(key);
|
|
18182
18184
|
if (tokens.length === 0)
|
|
18183
18185
|
return false;
|
|
@@ -18219,12 +18221,12 @@ function replaceWithCount(value, pattern, replacement, count) {
|
|
|
18219
18221
|
function redactKnownText(value, count) {
|
|
18220
18222
|
let output = value;
|
|
18221
18223
|
output = replaceWithCount(output, /-----BEGIN (?:RSA |EC |OPENSSH )?PRIVATE KEY-----[\s\S]*?-----END (?:RSA |EC |OPENSSH )?PRIVATE KEY-----/gu, INDEXER_OUTPUT_REDACTION_MARKER, count);
|
|
18222
|
-
output = replaceWithCount(output,
|
|
18224
|
+
output = replaceWithCount(output, new RegExp(`(\\bauthorization\\s*:\\s*(?:bearer|basic)\\s+)` + `(?!${escapeRegExp(INDEXER_OUTPUT_REDACTION_MARKER)})[^\\s,;]+`, "giu"), (_match, prefix) => `${prefix}${INDEXER_OUTPUT_REDACTION_MARKER}`, count);
|
|
18223
18225
|
output = replaceWithCount(output, /([a-z][a-z0-9+.-]*:\/\/)[^\s/@:]+:[^\s/@]+@/giu, (_match, prefix) => `${prefix}${INDEXER_OUTPUT_REDACTION_MARKER}@`, count);
|
|
18224
|
-
output = replaceWithCount(output,
|
|
18226
|
+
output = replaceWithCount(output, new RegExp(`([?&](?:access_token|refresh_token|api_key|password|secret)=)` + `(?!${escapeRegExp(INDEXER_OUTPUT_REDACTION_MARKER)})[^&#\\s]+`, "giu"), (_match, prefix) => `${prefix}${INDEXER_OUTPUT_REDACTION_MARKER}`, count);
|
|
18225
18227
|
const key = "(?:[A-Za-z0-9_.-]*(?:password|passwd|pwd|secret|token|credential|cookie)[A-Za-z0-9_.-]*|api[-_]?key|access[-_]?(?:key|token)|private[-_]?key|client[-_]?secret|authorization)";
|
|
18226
18228
|
const assignment = `(?:=\\s*|:\\s+(?=\\S)|:\\s*(?=["']))`;
|
|
18227
|
-
output = replaceWithCount(output, new RegExp(`((?:["']?${key}["']?)\\s*${assignment})(?:"(?:\\\\.|[^"])*"|'(?:\\\\.|[^'])*'|[^\\s,;}\\]]+)`, "giu"), (_match, prefix) => `${prefix}"${INDEXER_OUTPUT_REDACTION_MARKER}"`, count);
|
|
18229
|
+
output = replaceWithCount(output, new RegExp(`((?:["']?${key}["']?)\\s*${assignment})` + `(?!["']?${escapeRegExp(INDEXER_OUTPUT_REDACTION_MARKER)})` + `(?:"(?:\\\\.|[^"])*"|'(?:\\\\.|[^'])*'|[^\\s,;}\\]]+)`, "giu"), (_match, prefix) => `${prefix}"${INDEXER_OUTPUT_REDACTION_MARKER}"`, count);
|
|
18228
18230
|
return output;
|
|
18229
18231
|
}
|
|
18230
18232
|
function redactBlockedText(value, blocked, count) {
|
|
@@ -18492,6 +18494,25 @@ function createIndexerEvidenceAdapterFact(input) {
|
|
|
18492
18494
|
FACT_PAYLOADS.set(fact2, payload);
|
|
18493
18495
|
return fact2;
|
|
18494
18496
|
}
|
|
18497
|
+
function indexerEvidenceAdapterFactPayloads(result) {
|
|
18498
|
+
const payloads = result.files.flatMap((file) => file.facts.map((fact2) => {
|
|
18499
|
+
const payload = FACT_PAYLOADS.get(fact2);
|
|
18500
|
+
if (payload === undefined) {
|
|
18501
|
+
throw new TypeError(`Evidence Adapter fact payload ${fact2.fact_ref} is no longer materialized in this process`);
|
|
18502
|
+
}
|
|
18503
|
+
if (indexerEvidenceAdapterProtocolDigest(payload) !== fact2.payload_digest) {
|
|
18504
|
+
throw new TypeError(`Evidence Adapter fact payload ${fact2.fact_ref} is stale`);
|
|
18505
|
+
}
|
|
18506
|
+
return { fact_ref: fact2.fact_ref, payload };
|
|
18507
|
+
})).sort((left, right) => compareCanonicalText(left.fact_ref, right.fact_ref));
|
|
18508
|
+
return assertIndexerOutputSafe({ channel: "ipc-envelope", value: payloads });
|
|
18509
|
+
}
|
|
18510
|
+
function materializeIndexerEvidenceAdapterResult(result) {
|
|
18511
|
+
return {
|
|
18512
|
+
result,
|
|
18513
|
+
fact_payloads: indexerEvidenceAdapterFactPayloads(result)
|
|
18514
|
+
};
|
|
18515
|
+
}
|
|
18495
18516
|
function indexerEvidenceAdapterOutputDigest(value) {
|
|
18496
18517
|
return indexerEvidenceAdapterProtocolDigest(value);
|
|
18497
18518
|
}
|
|
@@ -34405,7 +34426,11 @@ function mdxSourcesToEvidenceAdapterResult(files, invocation) {
|
|
|
34405
34426
|
}]
|
|
34406
34427
|
});
|
|
34407
34428
|
}
|
|
34429
|
+
function mdxSourcesToEvidenceAdapterMaterialization(files, invocation) {
|
|
34430
|
+
return materializeIndexerEvidenceAdapterResult(mdxSourcesToEvidenceAdapterResult(files, invocation));
|
|
34431
|
+
}
|
|
34408
34432
|
export {
|
|
34409
34433
|
parseMdxSources,
|
|
34410
|
-
mdxSourcesToEvidenceAdapterResult
|
|
34434
|
+
mdxSourcesToEvidenceAdapterResult,
|
|
34435
|
+
mdxSourcesToEvidenceAdapterMaterialization
|
|
34411
34436
|
};
|