@c4a/extract 0.7.5 → 0.7.9

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.
@@ -13203,15 +13203,21 @@ function replaceWithCount(value, pattern, replacement, count) {
13203
13203
  return replacement(...args.slice(0, -2));
13204
13204
  });
13205
13205
  }
13206
+ var SECRET_TEXT_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)";
13207
+ var SECRET_TEXT_ASSIGNMENT = `(?:=\\s*|:\\s+(?=\\S)|:\\s*(?=["']))`;
13208
+ var AUTHORIZATION_TEXT_PATTERN = new RegExp(`(\\bauthorization\\s*:\\s*(?:bearer|basic)\\s+)` + `(?!${escapeRegExp(INDEXER_OUTPUT_REDACTION_MARKER)})[^\\s,;]+`, "giu");
13209
+ var QUERY_SECRET_TEXT_PATTERN = new RegExp(`([?&](?:access_token|refresh_token|api_key|password|secret)=)` + `(?!${escapeRegExp(INDEXER_OUTPUT_REDACTION_MARKER)})[^&#\\s]+`, "giu");
13210
+ var ASSIGNMENT_SECRET_TEXT_PATTERN = new RegExp(`((?:["']?${SECRET_TEXT_KEY}["']?)\\s*${SECRET_TEXT_ASSIGNMENT})` + `(?!["']?${escapeRegExp(INDEXER_OUTPUT_REDACTION_MARKER)})` + `(?:"(?:\\\\.|[^"])*"|'(?:\\\\.|[^'])*'|[^\\s,;}\\]]+)`, "giu");
13206
13211
  function redactKnownText(value, count) {
13212
+ if (!value.includes(":") && !value.includes("=") && !value.includes("-----BEGIN ")) {
13213
+ return value;
13214
+ }
13207
13215
  let output = value;
13208
13216
  output = replaceWithCount(output, /-----BEGIN (?:RSA |EC |OPENSSH )?PRIVATE KEY-----[\s\S]*?-----END (?:RSA |EC |OPENSSH )?PRIVATE KEY-----/gu, INDEXER_OUTPUT_REDACTION_MARKER, count);
13209
- 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);
13217
+ output = replaceWithCount(output, AUTHORIZATION_TEXT_PATTERN, (_match, prefix) => `${prefix}${INDEXER_OUTPUT_REDACTION_MARKER}`, count);
13210
13218
  output = replaceWithCount(output, /([a-z][a-z0-9+.-]*:\/\/)[^\s/@:]+:[^\s/@]+@/giu, (_match, prefix) => `${prefix}${INDEXER_OUTPUT_REDACTION_MARKER}@`, count);
13211
- 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);
13212
- 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)";
13213
- const assignment = `(?:=\\s*|:\\s+(?=\\S)|:\\s*(?=["']))`;
13214
- output = replaceWithCount(output, new RegExp(`((?:["']?${key}["']?)\\s*${assignment})` + `(?!["']?${escapeRegExp(INDEXER_OUTPUT_REDACTION_MARKER)})` + `(?:"(?:\\\\.|[^"])*"|'(?:\\\\.|[^'])*'|[^\\s,;}\\]]+)`, "giu"), (_match, prefix) => `${prefix}"${INDEXER_OUTPUT_REDACTION_MARKER}"`, count);
13219
+ output = replaceWithCount(output, QUERY_SECRET_TEXT_PATTERN, (_match, prefix) => `${prefix}${INDEXER_OUTPUT_REDACTION_MARKER}`, count);
13220
+ output = replaceWithCount(output, ASSIGNMENT_SECRET_TEXT_PATTERN, (_match, prefix) => `${prefix}"${INDEXER_OUTPUT_REDACTION_MARKER}"`, count);
13215
13221
  return output;
13216
13222
  }
13217
13223
  function redactBlockedText(value, blocked, count) {
@@ -14220,6 +14226,7 @@ var buildEdgeHashId = (edge2, packageName, modulePath, versionLabel) => hashStab
14220
14226
  isExternal: edge2.isExternal,
14221
14227
  grounding: edge2.grounding,
14222
14228
  source: edge2.source,
14229
+ file: edge2.file ?? null,
14223
14230
  line: edge2.line ?? null,
14224
14231
  versionLabel
14225
14232
  });
package/index.js CHANGED
@@ -13196,15 +13196,21 @@ function replaceWithCount(value, pattern, replacement, count) {
13196
13196
  return replacement(...args.slice(0, -2));
13197
13197
  });
13198
13198
  }
13199
+ var SECRET_TEXT_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)";
13200
+ var SECRET_TEXT_ASSIGNMENT = `(?:=\\s*|:\\s+(?=\\S)|:\\s*(?=["']))`;
13201
+ var AUTHORIZATION_TEXT_PATTERN = new RegExp(`(\\bauthorization\\s*:\\s*(?:bearer|basic)\\s+)` + `(?!${escapeRegExp(INDEXER_OUTPUT_REDACTION_MARKER)})[^\\s,;]+`, "giu");
13202
+ var QUERY_SECRET_TEXT_PATTERN = new RegExp(`([?&](?:access_token|refresh_token|api_key|password|secret)=)` + `(?!${escapeRegExp(INDEXER_OUTPUT_REDACTION_MARKER)})[^&#\\s]+`, "giu");
13203
+ var ASSIGNMENT_SECRET_TEXT_PATTERN = new RegExp(`((?:["']?${SECRET_TEXT_KEY}["']?)\\s*${SECRET_TEXT_ASSIGNMENT})` + `(?!["']?${escapeRegExp(INDEXER_OUTPUT_REDACTION_MARKER)})` + `(?:"(?:\\\\.|[^"])*"|'(?:\\\\.|[^'])*'|[^\\s,;}\\]]+)`, "giu");
13199
13204
  function redactKnownText(value, count) {
13205
+ if (!value.includes(":") && !value.includes("=") && !value.includes("-----BEGIN ")) {
13206
+ return value;
13207
+ }
13200
13208
  let output = value;
13201
13209
  output = replaceWithCount(output, /-----BEGIN (?:RSA |EC |OPENSSH )?PRIVATE KEY-----[\s\S]*?-----END (?:RSA |EC |OPENSSH )?PRIVATE KEY-----/gu, INDEXER_OUTPUT_REDACTION_MARKER, count);
13202
- 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);
13210
+ output = replaceWithCount(output, AUTHORIZATION_TEXT_PATTERN, (_match, prefix) => `${prefix}${INDEXER_OUTPUT_REDACTION_MARKER}`, count);
13203
13211
  output = replaceWithCount(output, /([a-z][a-z0-9+.-]*:\/\/)[^\s/@:]+:[^\s/@]+@/giu, (_match, prefix) => `${prefix}${INDEXER_OUTPUT_REDACTION_MARKER}@`, count);
13204
- 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);
13205
- 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)";
13206
- const assignment = `(?:=\\s*|:\\s+(?=\\S)|:\\s*(?=["']))`;
13207
- output = replaceWithCount(output, new RegExp(`((?:["']?${key}["']?)\\s*${assignment})` + `(?!["']?${escapeRegExp(INDEXER_OUTPUT_REDACTION_MARKER)})` + `(?:"(?:\\\\.|[^"])*"|'(?:\\\\.|[^'])*'|[^\\s,;}\\]]+)`, "giu"), (_match, prefix) => `${prefix}"${INDEXER_OUTPUT_REDACTION_MARKER}"`, count);
13212
+ output = replaceWithCount(output, QUERY_SECRET_TEXT_PATTERN, (_match, prefix) => `${prefix}${INDEXER_OUTPUT_REDACTION_MARKER}`, count);
13213
+ output = replaceWithCount(output, ASSIGNMENT_SECRET_TEXT_PATTERN, (_match, prefix) => `${prefix}"${INDEXER_OUTPUT_REDACTION_MARKER}"`, count);
13208
13214
  return output;
13209
13215
  }
13210
13216
  function redactBlockedText(value, blocked, count) {
@@ -14059,7 +14065,17 @@ var relationSourceSchema = exports_external.enum([
14059
14065
  var packageKindSchema2 = exports_external.enum(Object.values(PackageKind));
14060
14066
  var symbolParamSchema = exports_external.object({
14061
14067
  name: exports_external.string().min(1),
14062
- type: exports_external.string().min(1).nullable()
14068
+ type: exports_external.string().min(1).nullable(),
14069
+ optional: exports_external.boolean().optional(),
14070
+ rest: exports_external.boolean().optional(),
14071
+ defaultValue: exports_external.string().optional()
14072
+ });
14073
+ var registrationSchema = exports_external.object({
14074
+ kind: exports_external.enum(["http", "schedule", "event"]),
14075
+ key: exports_external.string(),
14076
+ handler: exports_external.string(),
14077
+ method: exports_external.string().optional(),
14078
+ middleware: exports_external.array(exports_external.string())
14063
14079
  });
14064
14080
  var symbolInfoSchema = exports_external.lazy(() => exports_external.object({
14065
14081
  name: exports_external.string().min(1),
@@ -14070,6 +14086,14 @@ var symbolInfoSchema = exports_external.lazy(() => exports_external.object({
14070
14086
  endLine: exports_external.number().int().positive(),
14071
14087
  members: exports_external.array(symbolInfoSchema).optional(),
14072
14088
  params: exports_external.array(symbolParamSchema).optional(),
14089
+ optional: exports_external.boolean().optional(),
14090
+ readonly: exports_external.boolean().optional(),
14091
+ defaultValue: exports_external.string().optional(),
14092
+ typeParameters: exports_external.string().optional(),
14093
+ overloads: exports_external.array(exports_external.string()).optional(),
14094
+ publicEntrypoints: exports_external.array(exports_external.string()).optional(),
14095
+ contractResolution: exports_external.enum(["resolved", "declaration-only"]).optional(),
14096
+ registration: registrationSchema.optional(),
14073
14097
  returnType: exports_external.string().min(1).nullable().optional(),
14074
14098
  typeAnnotation: exports_external.string().min(1).nullable().optional(),
14075
14099
  extends: exports_external.string().min(1).nullable().optional(),
@@ -14084,6 +14108,7 @@ var relationInfoSchema = exports_external.object({
14084
14108
  type: relationTypeSchema,
14085
14109
  from: exports_external.string().min(1),
14086
14110
  to: exports_external.string().min(1),
14111
+ file: exports_external.string().min(1).optional(),
14087
14112
  isExternal: exports_external.boolean(),
14088
14113
  grounding: groundingSchema,
14089
14114
  confidence: exports_external.number().min(0).max(1),
@@ -14490,7 +14515,7 @@ var BOM = "\uFEFF";
14490
14515
  var HASH_ID_RE = /^(?:sha256:)?[a-f0-9]{64}$/u;
14491
14516
  var SOURCE_SPAN_HASH_RE = /^[a-f0-9]{8,64}$/u;
14492
14517
  var DOCUMENT_SOURCE_SLUG_RE = /^[a-z0-9][a-z0-9._-]*$/u;
14493
- var DOCUMENT_SOURCE_BATCH_RE = /^\d{8}\/[a-z0-9][a-z0-9._-]*$/u;
14518
+ var DOCUMENT_SOURCE_BATCH_RE = /^\d{8}\/[^/\\\x00-\x1f:#?]+$/u;
14494
14519
  function isRecord2(value) {
14495
14520
  return value !== null && typeof value === "object" && !Array.isArray(value);
14496
14521
  }
@@ -14509,8 +14534,8 @@ function normalizeHashId(value) {
14509
14534
  return `sha256:${hex}`;
14510
14535
  }
14511
14536
  function assertDocumentSourceType(value) {
14512
- if (value !== "file" && value !== "lark") {
14513
- throw new TypeError(`document source_type must be file or lark: ${value}`);
14537
+ if (value !== "file" && value !== "lark" && value !== "note" && value !== "sessions") {
14538
+ throw new TypeError(`document source_type must be file, lark, note or sessions: ${value}`);
14514
14539
  }
14515
14540
  }
14516
14541
  function normalizeDocumentSourceName(name) {
@@ -14558,9 +14583,19 @@ function decodeSnapshotLocatorPath(path3) {
14558
14583
  }
14559
14584
  }
14560
14585
  function parseDocumentSourceLocator(source) {
14561
- const match = /^(file|lark):(.+)$/u.exec(source);
14586
+ const match = /^(file|lark|note|sessions):(.+)$/u.exec(source);
14562
14587
  if (match?.[1] === undefined || match[2] === undefined)
14563
14588
  return null;
14589
+ if (match[1] === "note" || match[1] === "sessions") {
14590
+ try {
14591
+ const sourceName2 = normalizeDocumentSourceName(match[2]);
14592
+ if (!sourceName2.endsWith(".md") || !/^\d{8}\//u.test(sourceName2))
14593
+ return null;
14594
+ return { sourceType: match[1], sourceName: sourceName2, documentPath: sourceName2.slice(9) };
14595
+ } catch {
14596
+ return null;
14597
+ }
14598
+ }
14564
14599
  const segments = match[2].split("/");
14565
14600
  const batched = /^\d{8}$/u.test(segments[0] ?? "") && segments.length >= 3;
14566
14601
  const sourceName = batched ? `${segments[0]}/${segments[1]}` : segments[0];
@@ -15929,6 +15964,7 @@ var buildEdgeHashId = (edge2, packageName, modulePath, versionLabel) => hashStab
15929
15964
  isExternal: edge2.isExternal,
15930
15965
  grounding: edge2.grounding,
15931
15966
  source: edge2.source,
15967
+ file: edge2.file ?? null,
15932
15968
  line: edge2.line ?? null,
15933
15969
  versionLabel
15934
15970
  });
@@ -16305,6 +16341,8 @@ function semanticExtractionPayload(extraction) {
16305
16341
  };
16306
16342
  }
16307
16343
  function relationSourceFile(relation, symbols, filePaths) {
16344
+ if (relation.file !== undefined)
16345
+ return filePaths.has(relation.file) ? relation.file : null;
16308
16346
  if (filePaths.has(relation.from))
16309
16347
  return relation.from;
16310
16348
  const candidates = symbols.filter((symbol) => symbol.name === relation.from);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@c4a/extract",
3
- "version": "0.7.5",
3
+ "version": "0.7.9",
4
4
  "type": "module",
5
5
  "description": "Language-plugin framework and repository runner for Context code evidence",
6
6
  "license": "MIT",