@nulladrift/core 0.7.1 → 0.9.0

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.
Files changed (36) hide show
  1. package/dist/{chunk-6WXMFDJM.js → chunk-4FHVM76T.js} +100 -19
  2. package/dist/chunk-4FHVM76T.js.map +1 -0
  3. package/dist/{chunk-TBVL7XVR.js → chunk-5OCXDAFS.js} +18 -5
  4. package/dist/chunk-5OCXDAFS.js.map +1 -0
  5. package/dist/{chunk-DF52BV5H.js → chunk-FVT77BL4.js} +22 -2
  6. package/dist/chunk-FVT77BL4.js.map +1 -0
  7. package/dist/{chunk-2TZBS4SQ.js → chunk-R6LTBT2G.js} +1 -1
  8. package/dist/chunk-R6LTBT2G.js.map +1 -0
  9. package/dist/{chunk-2BZR6CAV.js → chunk-TRNJNLQQ.js} +2 -2
  10. package/dist/{chunk-WEU7FBSB.js → chunk-ZD2C4FMT.js} +18 -4
  11. package/dist/chunk-ZD2C4FMT.js.map +1 -0
  12. package/dist/diff/index.d.ts +1 -1
  13. package/dist/diff/index.js +5 -5
  14. package/dist/diff/schema.d.ts +1 -1
  15. package/dist/diff/schema.js +2 -2
  16. package/dist/index.d.ts +15 -4
  17. package/dist/index.js +17 -11
  18. package/dist/index.js.map +1 -1
  19. package/dist/lock/canonical.d.ts +1 -1
  20. package/dist/lock/credentials.d.ts +3 -1
  21. package/dist/lock/credentials.js +1 -1
  22. package/dist/lock/jsonschema.d.ts +7 -2
  23. package/dist/lock/jsonschema.js +3 -1
  24. package/dist/lock/normalize.d.ts +7 -8
  25. package/dist/lock/normalize.js +3 -3
  26. package/dist/lock/reseal.d.ts +1 -1
  27. package/dist/lock/types.d.ts +1 -1
  28. package/dist/lock/types.js +1 -1
  29. package/dist/{types-Tbdp5tnv.d.ts → types-lvJ3uBbs.d.ts} +52 -1
  30. package/package.json +1 -1
  31. package/dist/chunk-2TZBS4SQ.js.map +0 -1
  32. package/dist/chunk-6WXMFDJM.js.map +0 -1
  33. package/dist/chunk-DF52BV5H.js.map +0 -1
  34. package/dist/chunk-TBVL7XVR.js.map +0 -1
  35. package/dist/chunk-WEU7FBSB.js.map +0 -1
  36. /package/dist/{chunk-2BZR6CAV.js.map → chunk-TRNJNLQQ.js.map} +0 -0
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/lock/types.ts"],"sourcesContent":["/** The shape of `mcp.lock`. Mirrors schema/mcp.lock.schema.json, which is the published contract. */\n\n/**\n * Bumped to 2 when the root stopped naming a protocol.\n *\n * Version 1 keyed everything under `servers`, which made the format MCP's rather than the\n * product's: an agent's grants, an OpenAPI surface or a token's scopes had nowhere to live\n * without a second root key and a second diff path. Version 2 keys them all under `subjects`,\n * each tagged with what it is.\n *\n * A version 1 file is upgraded on read rather than refused, and the upgrade is lossless:\n * `kind` is not part of any digest (see `reseal.ts`, which covers an explicit field list), so\n * an upgraded lock reseals to exactly the digests it arrived with and nobody sees drift that\n * is really a format change.\n */\nexport const LOCKFILE_VERSION = 2;\n\nimport type { CapabilityKind } from \"../risk/capability\";\n\nexport type JsonValue = string | number | boolean | null | JsonValue[] | { [key: string]: JsonValue };\nexport type JsonObject = { [key: string]: JsonValue };\n\nexport interface Lockfile {\n lockfileVersion: number;\n generatedBy?: string;\n policy?: LockPolicy;\n /**\n * Everything this project has pinned, keyed by identity. One map rather than a key per kind,\n * so adding a kind is a new member of `LockedSubject` and not a new branch in every consumer.\n */\n subjects: Record<string, LockedSubject>;\n}\n\n/**\n * What a pinned thing is.\n *\n * The list is short because only one reader exists. The point of naming it at all is that the\n * diff engine, the policy evaluator and the audit log already do not care which one they are\n * looking at, so the cost of the second is a reader and a vocabulary rather than a redesign.\n */\nexport const SUBJECT_KINDS = [\"mcp-server\"] as const;\nexport type SubjectKind = (typeof SUBJECT_KINDS)[number];\n\nexport interface LockPolicy {\n /** Reverse-DNS `_meta` key prefixes to leave out, for servers that put build ids there. */\n ignoreMetaPrefixes?: string[];\n allowUnreachable?: boolean;\n /**\n * Capabilities no server in this project may have. Checked against the surface itself rather\n * than against the diff, so accepting drift cannot make one allowed and a repository that never\n * changes is still covered.\n *\n * There is deliberately no steering equivalent: a capability is a fact about schema shape, and\n * a steering signal is a regular expression over prose that legitimate servers trip.\n */\n deniedCapabilities?: CapabilityKind[];\n}\n\nexport type ClientKind =\n | \"claude-code\"\n | \"claude-desktop\"\n | \"vscode\"\n | \"cursor\"\n | \"copilot\"\n | \"windsurf\"\n | \"generic\"\n | \"manual\";\n\nexport interface LockedSource {\n client: ClientKind;\n /** Repo-relative where possible, else with the home directory written as `~`. Never an absolute machine path. */\n file: string;\n scope?: \"project\" | \"user\" | \"local\";\n}\n\nexport interface LockedStdioTransport {\n type: \"stdio\";\n command: string;\n args?: string[];\n /** Names only. The lock is committed; the values are credentials. */\n envKeys?: string[];\n cwd?: string;\n}\n\nexport interface LockedHttpTransport {\n type: \"http\" | \"sse\";\n /** Query string removed: query strings routinely carry tokens. */\n url: string;\n headerKeys?: string[];\n}\n\nexport type LockedTransport = LockedStdioTransport | LockedHttpTransport;\n\nexport interface LockedProtocol {\n era: \"modern\" | \"legacy\";\n version: string;\n supportedVersions?: string[];\n}\n\n/**\n * What a stdio invocation actually ran: the artifact behind the command, by content address.\n *\n * Everything else in a locked server describes what the server *says* -- its tools, its\n * instructions, even `serverInfo.version`, which is self-reported over the wire. None of it says\n * what code is answering. A release that keeps every tool name, description and schema byte for\n * byte while changing what the tools do is invisible to all of it, and that is the supply-chain\n * attack this category exists to catch.\n *\n * Deliberately outside the server digest. A lock written before this existed, or a run that\n * could not reach a registry, has no provenance; folding it into the digest would turn every\n * upgrade of this tool and every offline run into drift against servers nobody touched. It is\n * compared on its own instead -- before the digest short-circuit, since the case it exists for\n * is the one where the digest has not moved.\n */\nexport interface LockedProvenance {\n ecosystem: \"npm\" | \"pypi\" | \"oci\" | \"file\";\n /** The package, image or path, as its registry names it. */\n name: string;\n /** The exact version that ran: never a range, a dist-tag or `latest`. Absent for a file. */\n version?: string;\n /**\n * A content address for exactly those bytes: npm's `dist.integrity`, a PyPI distribution's\n * sha256, an OCI manifest digest, or the sha256 of the file. Absent when it could not be\n * established, which is a gap in the record rather than a claim about the artifact.\n */\n integrity?: string;\n /**\n * How the invocation asked for it -- `@1.2.3`, `^1`, or nothing at all. Kept because it is the\n * actionable half: a server that floats will move on its own, and the fix is in the config.\n */\n requested?: string;\n}\n\nexport interface LockedServerInfo {\n name?: string;\n title?: string;\n version?: string;\n description?: string;\n websiteUrl?: string;\n}\n\nexport interface LockedAnnotations {\n title?: string;\n readOnlyHint?: boolean;\n destructiveHint?: boolean;\n idempotentHint?: boolean;\n openWorldHint?: boolean;\n}\n\n/** Annotations resolved against the spec's defaults. See docs/lockfile.md §4. */\nexport interface LockedBehavior {\n readOnly: boolean;\n destructive: boolean;\n idempotent: boolean;\n openWorld: boolean;\n}\n\nexport interface LockedIcon {\n src: string;\n mimeType?: string;\n sizes?: string[];\n theme?: \"light\" | \"dark\";\n}\n\nexport interface LockedTool {\n name: string;\n title?: string;\n description?: string;\n inputSchema: JsonObject;\n outputSchema?: JsonObject;\n annotations?: LockedAnnotations;\n behavior: LockedBehavior;\n /** `propertyPath -> HeaderName`, sorted. Derived from `x-mcp-header`. */\n headerParams?: string[];\n icons?: LockedIcon[];\n meta?: JsonObject;\n digest: string;\n}\n\nexport interface LockedResource {\n uri: string;\n name: string;\n title?: string;\n description?: string;\n mimeType?: string;\n annotations?: JsonObject;\n icons?: LockedIcon[];\n meta?: JsonObject;\n digest: string;\n}\n\nexport interface LockedResourceTemplate {\n uriTemplate: string;\n name: string;\n title?: string;\n description?: string;\n mimeType?: string;\n annotations?: JsonObject;\n icons?: LockedIcon[];\n meta?: JsonObject;\n digest: string;\n}\n\nexport interface LockedPromptArgument {\n name: string;\n title?: string;\n description?: string;\n required?: boolean;\n}\n\nexport interface LockedPrompt {\n name: string;\n title?: string;\n description?: string;\n arguments?: LockedPromptArgument[];\n icons?: LockedIcon[];\n meta?: JsonObject;\n digest: string;\n}\n\n/** What every pinned thing carries, whatever it is. */\nexport interface LockedSubjectBase {\n kind: SubjectKind;\n source: LockedSource;\n digest: string;\n}\n\n/** An MCP server's declared capability surface. The first subject kind, and so far the only one. */\nexport interface LockedMcpServer extends LockedSubjectBase {\n kind: \"mcp-server\";\n transport: LockedTransport;\n /** What the command resolved to. Stdio only, and only when it could be established. */\n provenance?: LockedProvenance;\n protocol: LockedProtocol;\n serverInfo?: LockedServerInfo;\n capabilities?: JsonObject;\n instructions?: string;\n tools?: LockedTool[];\n resources?: LockedResource[];\n resourceTemplates?: LockedResourceTemplate[];\n prompts?: LockedPrompt[];\n}\n\n/**\n * A union of one, deliberately. An agent's grants or an OpenAPI surface joins here, and every\n * consumer that switches on `kind` gets a compiler error pointing at the branch it is missing.\n */\nexport type LockedSubject = LockedMcpServer;\n\n/** Anything in the lock that carries its own digest and is matched by a stable key. */\nexport type LockedMember = LockedTool | LockedResource | LockedResourceTemplate | LockedPrompt;\n"],"mappings":";AAeO,IAAM,mBAAmB;AAyBzB,IAAM,gBAAgB,CAAC,YAAY;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/risk/untrusted.ts","../src/risk/capability.ts","../src/diff/index.ts"],"sourcesContent":["/**\n * Coercion for values that arrived from somewhere else.\n *\n * Everything in `risk/` reads a declaration a server sent, or a reading a collector posted. The\n * types say `{ name?: string }[]`, and a type is a claim about a value this code never checked:\n * `tools` is whatever was in the JSON, so it can be absent, a string, or an array with a `null`\n * in it. `tool.name` on that `null` throws a TypeError.\n *\n * In the CLI that aborts one audit, which is survivable. In the control plane the same call sits\n * inside ingest, where one malformed element in one tool of one server would fail the whole\n * request -- every other server in that reading included. A classifier is a security control, and\n * a security control that can be switched off by sending it a `null` is one an attacker turns off\n * rather than evades.\n *\n * So the guard belongs here, at the point the value is first believed, rather than at each of the\n * places that go on to read it.\n */\n\n/** The members of `value` that are objects, or an empty list if it is not a list at all. */\nexport function objectsIn(value: unknown): Array<Record<string, unknown>> {\n if (!Array.isArray(value)) return [];\n return value.filter((member): member is Record<string, unknown> => typeof member === \"object\" && member !== null);\n}\n\n/** `value` if it is a non-null object, otherwise an empty one, so a property read is always safe. */\nexport function objectOr(value: unknown): Record<string, unknown> {\n return typeof value === \"object\" && value !== null ? (value as Record<string, unknown>) : {};\n}\n\n/** `value` if it is a string, otherwise undefined: a `name` that is a number is not a name. */\nexport function stringOr(value: unknown): string | undefined {\n return typeof value === \"string\" ? value : undefined;\n}\n","/**\n * What a server could do to you, derived from what it declares.\n *\n * This answers one question and refuses another. It answers *what could this tool do if the\n * model decides to use it*, from the tool's name, its argument names and its schema shape. It\n * does not answer *is this tool malicious*, which is a judgement, needs a corpus, and would make\n * a verdict depend on something other than the bytes on the wire.\n *\n * The distinction matters because it is the same one the severity table already makes: rank by\n * shape, never by intent. A tool named `run_command` taking a `command` argument is arbitrary\n * execution whatever its description claims, and that is a fact about the declaration rather\n * than an opinion about the author.\n *\n * Nothing here is stored in the lockfile. Capabilities are derived from the schemas that *are*\n * stored, so sharpening a pattern re-reads existing locks instead of showing every user a wave\n * of drift that no server caused.\n */\n\n/** Ordered worst-first; the order is the comparison. */\nimport { objectOr, objectsIn, stringOr } from \"./untrusted\";\n\nexport const CAPABILITY_SEVERITIES = [\"critical\", \"high\", \"medium\", \"low\"] as const;\nexport type CapabilitySeverity = (typeof CAPABILITY_SEVERITIES)[number];\n\nexport const CAPABILITY_KINDS = [\n \"process-exec\",\n \"code-eval\",\n \"credential-access\",\n \"file-write\",\n \"network-egress\",\n \"database\",\n \"privilege\",\n \"agent-control\",\n \"env-access\",\n \"file-read\",\n] as const;\nexport type CapabilityKind = (typeof CAPABILITY_KINDS)[number];\n\nexport interface Capability {\n kind: CapabilityKind;\n severity: CapabilitySeverity;\n /** Where it was seen: `name`, or `arg:<argument>`. Shown so a finding can be checked. */\n evidence: string;\n}\n\ninterface Rule {\n kind: CapabilityKind;\n severity: CapabilitySeverity;\n /** Matched against the tool name, with separators normalised to `_`. */\n name?: RegExp;\n /** Matched against each top-level argument name, normalised the same way. */\n arg?: RegExp;\n}\n\n/*\n * Deliberately narrow. A pattern that fires on `get_user` because it contains \"user\" teaches\n * people to ignore the output, and an ignored signal is worse than none: it spends the attention\n * the real findings need.\n */\nconst RULES: Rule[] = [\n { kind: \"process-exec\", severity: \"critical\", name: /(^|_)(exec|execute|spawn|shell|bash|sh|cmd|command|run_command|terminal|subprocess)(_|$)/, arg: /(^|_)(command|cmd|argv|shell|exec|script)(_|$)/ },\n // `source` is deliberately absent: in `copy_file(source, destination)` it is a path, and\n // labelling a file copy as arbitrary code execution at CRITICAL is the false positive that\n // teaches people to stop reading the line. `code` has to be the whole argument name for the\n // same reason -- a crawl of 468 published tools flagged `location_code` as arbitrary code\n // execution, and `country_code`, `status_code` and `zip_code` are all waiting behind it.\n { kind: \"code-eval\", severity: \"critical\", name: /(^|_)(eval|evaluate|run_code|exec_code|interpret|compile)(_|$)/, arg: /^code$|(^|_)(source_code|code_to_run|js_code|python_code|expression|program|snippet)(_|$)/ },\n { kind: \"credential-access\", severity: \"critical\", name: /(^|_)(secret|secrets|credential|credentials|token|keychain|vault|password)(_|$)/, arg: /(^|_)(secret|credential|password|private_key|api_key|access_token)(_|$)/ },\n { kind: \"file-write\", severity: \"high\", name: /(^|_)(write|create_file|put_file|save|delete|remove|unlink|rename|move|copy|chmod|mkdir|rmdir|edit)(_|$)/, arg: /(^|_)(contents|content|data|destination|dest_path|target_path)(_|$)/ },\n { kind: \"network-egress\", severity: \"high\", name: /(^|_)(fetch|request|http|curl|download|upload|post|webhook|navigate|browse|send)(_|$)/, arg: /(^|_)(url|uri|endpoint|host|hostname|webhook|callback)(_|$)/ },\n // Narrowed to things that are actually SQL-shaped. `query`, `select` and `update` on their\n // own matched `simulate-research-query`, `browser_select_option` and `trigger-resource-update`,\n // none of which is a database.\n { kind: \"database\", severity: \"high\", name: /(^|_)(sql|execute_sql|run_sql|query_db|db_query|migrate)(_|$)/, arg: /(^|_)(sql|statement|dsn|connection_string)(_|$)/ },\n { kind: \"privilege\", severity: \"high\", name: /(^|_)(sudo|root|admin|grant|revoke|permission|permissions|acl|policy)(_|$)/, arg: /(^|_)(role|scope|scopes|permission|permissions|privilege)(_|$)/ },\n { kind: \"agent-control\", severity: \"high\", name: /(^|_)(prompt|system_prompt|instruction|instructions|memory|context|persona)(_|$)/, arg: /(^|_)(system_prompt|instruction|instructions|persona)(_|$)/ },\n { kind: \"env-access\", severity: \"medium\", name: /(^|_)(env|environment|getenv|setenv|config|settings)(_|$)/, arg: /(^|_)(env|environment|env_var)(_|$)/ },\n { kind: \"file-read\", severity: \"low\", name: /(^|_)(read|read_file|cat|open|load|list_directory|ls|glob|search_files)(_|$)/, arg: /(^|_)(path|file|filename|filepath|directory|dir)(_|$)/ },\n];\n\n/*\n * Cyrillic and Greek letters that are drawn like Latin ones. `run_comm\\u0430nd` reads as\n * `run_command` to a person and matched nothing at all, so a single substituted character\n * bought a tool complete invisibility to a classifier whose whole job is reading names.\n * Folding them is the difference between a check and a formality.\n */\nconst CONFUSABLES: Record<string, string> = {\n \"\\u0430\": \"a\", \"\\u0435\": \"e\", \"\\u043E\": \"o\", \"\\u0441\": \"c\", \"\\u0440\": \"p\", \"\\u0445\": \"x\",\n \"\\u0443\": \"y\", \"\\u0456\": \"i\", \"\\u0458\": \"j\", \"\\u04BB\": \"h\", \"\\u0501\": \"d\", \"\\u051B\": \"q\",\n \"\\u03BF\": \"o\", \"\\u03B1\": \"a\", \"\\u03B5\": \"e\", \"\\u03BD\": \"v\", \"\\u03C1\": \"p\", \"\\u03C5\": \"u\",\n \"\\u0131\": \"i\", \"\\u1E9E\": \"s\",\n};\n\n/** Built from the map above, so the pattern and the replacements cannot drift apart. */\nconst CONFUSABLE_PATTERN = new RegExp(`[${Object.keys(CONFUSABLES).join(\"\")}]`, \"g\");\n\n/** `browser.take-screenshot` and `browser_take_screenshot` are the same shape. */\nfunction normalize(identifier: string): string {\n return identifier\n .toLowerCase()\n .replace(CONFUSABLE_PATTERN, (character) => CONFUSABLES[character] ?? character)\n .replace(/[-.\\s/]+/g, \"_\");\n}\n\n/*\n * Nested properties count. `tool({ opts: { command } })` is the same capability as\n * `tool({ command })`, and only the top level was examined, so one wrapping object hid it.\n * Depth is bounded because a schema is attacker-supplied and need not terminate.\n */\nfunction argumentNames(inputSchema: unknown, depth = 0): string[] {\n if (depth > 6 || typeof inputSchema !== \"object\" || inputSchema === null) return [];\n const node = inputSchema as { properties?: unknown; items?: unknown };\n const names: string[] = [];\n const properties = node.properties;\n if (typeof properties === \"object\" && properties !== null) {\n for (const [name, child] of Object.entries(properties as Record<string, unknown>)) {\n names.push(name);\n names.push(...argumentNames(child, depth + 1));\n }\n }\n if (node.items !== undefined) names.push(...argumentNames(node.items, depth + 1));\n return names;\n}\n\n/**\n * The capabilities one tool declares. Worst first, one entry per kind: a tool matching\n * `process-exec` by both its name and an argument is not twice as dangerous.\n */\nexport function toolCapabilities(tool: { name?: string; inputSchema?: unknown } | null | undefined): Capability[] {\n // The argument is whatever was in the JSON; see risk/untrusted.\n const subject = objectOr(tool);\n const name = normalize(stringOr(subject.name) ?? \"\");\n const args = argumentNames(subject.inputSchema).map((argument) => [argument, normalize(argument)] as const);\n const found = new Map<CapabilityKind, Capability>();\n\n for (const rule of RULES) {\n if (found.has(rule.kind)) continue;\n if (rule.name?.test(name)) {\n found.set(rule.kind, { kind: rule.kind, severity: rule.severity, evidence: \"name\" });\n continue;\n }\n const hit = rule.arg ? args.find(([, normalized]) => rule.arg?.test(normalized)) : undefined;\n if (hit) found.set(rule.kind, { kind: rule.kind, severity: rule.severity, evidence: `arg:${hit[0]}` });\n }\n\n return [...found.values()].sort(\n (a, b) => CAPABILITY_SEVERITIES.indexOf(a.severity) - CAPABILITY_SEVERITIES.indexOf(b.severity) || a.kind.localeCompare(b.kind),\n );\n}\n\n/** Every capability a set of tools declares between them, with the tools that declare each. */\nexport function surfaceCapabilities(\n tools: ReadonlyArray<{ name?: string; inputSchema?: unknown }> | null | undefined,\n): Array<Capability & { tools: string[] }> {\n const byKind = new Map<CapabilityKind, Capability & { tools: string[] }>();\n for (const tool of objectsIn(tools)) {\n const label = stringOr(tool.name) ?? \"?\";\n for (const capability of toolCapabilities(tool)) {\n const existing = byKind.get(capability.kind);\n if (existing) existing.tools.push(label);\n else byKind.set(capability.kind, { ...capability, tools: [label] });\n }\n }\n return [...byKind.values()].sort(\n (a, b) => CAPABILITY_SEVERITIES.indexOf(a.severity) - CAPABILITY_SEVERITIES.indexOf(b.severity) || a.kind.localeCompare(b.kind),\n );\n}\n","/** Comparing a freshly captured lock against the committed one. */\nimport { stableKey } from \"../lock/canonical\";\nimport { isEscalation } from \"../lock/normalize\";\nimport type {\n LockedPrompt,\n LockedResource,\n LockedResourceTemplate,\n LockedMcpServer,\n LockedTool,\n Lockfile,\n} from \"../lock/types\";\nimport { toolCapabilities, type CapabilitySeverity } from \"../risk/capability\";\nimport { classifySchemaChange } from \"./schema\";\nimport type { Change, ChangeKind, Severity } from \"./types\";\nimport { SEVERITY, sortChanges } from \"./types\";\n\nfunction change(kind: ChangeKind, server: string, summary: string, extra?: Partial<Change>): Change {\n return { kind, severity: SEVERITY[kind], server, summary, ...extra };\n}\n\nfunction same(a: unknown, b: unknown): boolean {\n return stableKey(a ?? null) === stableKey(b ?? null);\n}\n\nfunction indexBy<T>(members: T[] | undefined, key: (member: T) => string): Map<string, T> {\n return new Map((members ?? []).map((member) => [key(member), member]));\n}\n\n/**\n * What a server declares, flattened so that an extension is one of the names.\n *\n * `capabilities` is a handful of top-level keys, and one of them, `extensions`, is a map of\n * reverse-DNS ids: that is the mechanism the specification uses to ship capability outside the\n * core. Comparing only the top level means a server that gains an extension still has\n * `extensions` before and after, so nothing reads as gained and the finding lands on the generic\n * \"declared capabilities changed\" with the detail left inside a JSON blob for a reviewer to go\n * and read. As more of what a server can do arrives as an extension, \"what did this one just\n * gain\" becomes an extension question, and it deserves an answer in words.\n *\n * The `extensions` key itself is not a name. Reporting both it and the id it contains would say\n * the same thing twice on the reading where a server declares its first extension.\n */\nfunction declaredNames(capabilities: LockedMcpServer[\"capabilities\"]): string[] {\n const names: string[] = [];\n for (const [key, value] of Object.entries(capabilities ?? {})) {\n if (key === \"extensions\" && value !== null && typeof value === \"object\" && !Array.isArray(value)) {\n for (const id of Object.keys(value)) names.push(`extensions/${id}`);\n continue;\n }\n names.push(key);\n }\n return names;\n}\n\n/** Describes the delta between two capability maps in the direction that matters. */\nfunction compareCapabilities(before: LockedMcpServer, after: LockedMcpServer, name: string): Change[] {\n if (same(before.capabilities, after.capabilities)) return [];\n const previous = declaredNames(before.capabilities);\n const next = declaredNames(after.capabilities);\n const gained = next.filter((key) => !previous.includes(key));\n const lost = previous.filter((key) => !next.includes(key));\n\n if (gained.length > 0 && lost.length === 0) {\n return [change(\"server.capabilities.widened\", name, `server now declares ${gained.join(\", \")}`, { before: before.capabilities, after: after.capabilities })];\n }\n if (lost.length > 0 && gained.length === 0) {\n return [change(\"server.capabilities.narrowed\", name, `server no longer declares ${lost.join(\", \")}`, { before: before.capabilities, after: after.capabilities })];\n }\n return [change(\"server.capabilities.changed\", name, \"declared capabilities changed\", { before: before.capabilities, after: after.capabilities })];\n}\n\n\n/*\n * What a tool can do, compared across a reading.\n *\n * The schema diff says a tool \"accepts input it did not before\", which is the same sentence\n * whether the new argument is `nickname` or `command`. The classifier already knows the\n * difference and says so at pin time; the diff did not ask, so the finding a reviewer approved\n * described arbitrary command execution in the words of an optional string.\n *\n * A tool that is new is compared against nothing, so everything it can do is gained. That is the\n * honest reading: a server that adds a tool taking `command` has gained command execution just as\n * surely as one that adds the argument to a tool already there.\n */\nconst CAPABILITY_SEVERITY: Record<CapabilitySeverity, Severity> = {\n critical: \"high\",\n high: \"high\",\n medium: \"medium\",\n low: \"low\",\n};\n\nfunction compareToolCapabilities(server: string, before: LockedTool[] | undefined, after: LockedTool[] | undefined): Change[] {\n const previous = indexBy(before, (tool) => tool.name);\n const changes: Change[] = [];\n\n for (const tool of after ?? []) {\n /*\n * Only tools that were already here. A tool that is new is reported once, by `tool.added`,\n * which names what it can do: raising a second finding for the same fact makes a reviewer\n * read the arrival of one tool twice.\n */\n const existing = previous.get(tool.name);\n if (!existing) continue;\n const had = new Set(toolCapabilities(existing).map((capability) => capability.kind));\n for (const capability of toolCapabilities(tool)) {\n if (had.has(capability.kind)) continue;\n changes.push(\n change(\"tool.capability.gained\", server, `can now ${capability.kind} (${capability.evidence})`, {\n member: tool.name,\n severity: CAPABILITY_SEVERITY[capability.severity],\n after: { kind: capability.kind, severity: capability.severity, evidence: capability.evidence },\n }),\n );\n }\n }\n return changes;\n}\n\nfunction compareTool(name: string, before: LockedTool, after: LockedTool): Change[] {\n if (before.digest === after.digest) return [];\n const changes: Change[] = [];\n const at = { member: before.name };\n\n if (!same(before.description, after.description)) {\n changes.push(\n change(\"tool.description.changed\", name, `description changed (${before.description?.length ?? 0} → ${after.description?.length ?? 0} characters)`, {\n ...at,\n before: before.description,\n after: after.description,\n }),\n );\n }\n\n const inputVerdict = classifySchemaChange(before.inputSchema, after.inputSchema);\n if (inputVerdict !== \"same\") {\n const kind = (`tool.input_schema.${inputVerdict}` satisfies ChangeKind) as ChangeKind;\n const wording = inputVerdict === \"widened\" ? \"accepts input it did not before\" : inputVerdict === \"narrowed\" ? \"accepts less input than before\" : \"input schema changed\";\n changes.push(change(kind, name, wording, { ...at, before: before.inputSchema, after: after.inputSchema }));\n }\n\n if (!same(before.outputSchema, after.outputSchema)) {\n changes.push(change(\"tool.output_schema.changed\", name, \"output schema changed\", { ...at, before: before.outputSchema, after: after.outputSchema }));\n }\n\n if (!same(before.behavior, after.behavior)) {\n const escalated = isEscalation(before.behavior, after.behavior);\n changes.push(\n change(escalated ? \"tool.behavior.escalated\" : \"tool.behavior.relaxed\", name, escalated ? describeEscalation(before, after) : \"declares fewer powers than before\", {\n ...at,\n before: before.behavior,\n after: after.behavior,\n }),\n );\n }\n\n if (!same(before.headerParams, after.headerParams)) {\n changes.push(\n change(\"tool.header_params.changed\", name, \"arguments mirrored into HTTP headers changed\", { ...at, before: before.headerParams ?? [], after: after.headerParams ?? [] }),\n );\n }\n\n /*\n * The digest covers more than the fields called out above -- title, icons, `_meta`. If none of\n * them fired, something in that remainder moved, and silence would be worse than a vague\n * finding.\n */\n if (changes.length === 0) {\n changes.push(change(\"tool.changed\", name, \"tool definition changed (title, icons or _meta)\", { ...at, before, after }));\n }\n return changes;\n}\n\nfunction describeEscalation(before: LockedTool, after: LockedTool): string {\n const gained: string[] = [];\n if (before.behavior.readOnly && !after.behavior.readOnly) gained.push(\"may now modify\");\n if (!before.behavior.destructive && after.behavior.destructive) gained.push(\"may now destroy\");\n if (before.behavior.idempotent && !after.behavior.idempotent) gained.push(\"repeat calls now compound\");\n if (!before.behavior.openWorld && after.behavior.openWorld) gained.push(\"may now reach external systems\");\n return gained.join(\"; \");\n}\n\ninterface MemberSpec<T> {\n key: (member: T) => string;\n label: (member: T) => string;\n added: ChangeKind;\n removed: ChangeKind;\n changed: ChangeKind;\n noun: string;\n /** Extra wording for a member that is new, where arriving is itself the finding. */\n arriving?: (member: T) => string;\n}\n\nfunction compareMembers<T extends { digest: string }>(\n name: string,\n before: T[] | undefined,\n after: T[] | undefined,\n spec: MemberSpec<T>,\n deep?: (key: string, a: T, b: T) => Change[],\n): Change[] {\n const changes: Change[] = [];\n const previous = indexBy(before, spec.key);\n const next = indexBy(after, spec.key);\n\n for (const [key, member] of next) {\n const existing = previous.get(key);\n if (!existing) {\n const extra = spec.arriving?.(member);\n changes.push(\n change(spec.added, name, `new ${spec.noun} ${spec.label(member)}${extra ? ` \\u00b7 ${extra}` : \"\"}`, { member: spec.label(member), after: member }),\n );\n continue;\n }\n if (existing.digest === member.digest) continue;\n changes.push(...(deep ? deep(key, existing, member) : [change(spec.changed, name, `${spec.noun} ${spec.label(member)} changed`, { member: spec.label(member), before: existing, after: member })]));\n }\n for (const [key, member] of previous) {\n if (!next.has(key)) changes.push(change(spec.removed, name, `${spec.noun} ${spec.label(member)} is gone`, { member: spec.label(member), before: member }));\n }\n return changes;\n}\n\n/**\n * Whether the code behind the server is the code that was pinned.\n *\n * Absence on either side says nothing. A lock written before provenance existed, or a run that\n * could not reach a registry, has none, and reporting that would turn every upgrade of this tool\n * and every offline run into drift against servers nobody touched. Neither does a change of\n * package name: that only happens when the command or its arguments changed, which\n * `server.transport.changed` already reports, and saying it twice is how a reviewer learns to\n * skim.\n */\nfunction compareProvenance(name: string, before: LockedMcpServer, after: LockedMcpServer): Change[] {\n const was = before.provenance;\n const now = after.provenance;\n if (!was || !now) return [];\n if (was.ecosystem !== now.ecosystem || was.name !== now.name) return [];\n\n const surfaceHeld = before.digest === after.digest;\n\n /*\n * Said out loud when the surface held still, because that is the case nothing else in the\n * report covers. A release that changed its tools is described by the tool changes; one that\n * changed only its code is described by this line and nothing else.\n */\n const unexplained = surfaceHeld ? \", and the declared surface did not change: nothing else in this report describes what the new code does\" : \"\";\n const integrityMoved = was.integrity !== undefined && now.integrity !== undefined && was.integrity !== now.integrity;\n\n if (was.version !== undefined && was.version === now.version) {\n if (!integrityMoved) return [];\n /*\n * Substitution is claimed only where the registry guarantees one artifact per version. npm\n * refuses to republish a version, so different bytes under the same one means something\n * between here and the registry served them. PyPI lets a maintainer add files to a release\n * after the fact, so the same version with a different recorded file has an ordinary\n * explanation, and it is reported as the milder kind.\n */\n if (was.ecosystem === \"npm\") {\n return [\n change(\n \"server.artifact.substituted\",\n name,\n `${was.name}@${was.version} now has different contents than when it was pinned: the same version, different bytes`,\n { before: was, after: now },\n ),\n ];\n }\n return [change(\"server.artifact.changed\", name, `the files published for ${was.name}@${was.version} are not the ones that were pinned${unexplained}`, { before: was, after: now })];\n }\n\n if (was.version !== now.version) {\n const moved = `the package behind this server moved from ${was.version ?? \"an unknown version\"} to ${now.version ?? \"an unknown version\"}`;\n return [change(\"server.artifact.changed\", name, `${moved}${unexplained}`, { before: was, after: now })];\n }\n\n /*\n * No version on either side: a file, or an image, whose tag is a pointer rather than a release.\n * A moved tag and a rebuilt binary are both ordinary, so both are the medium kind.\n */\n if (!integrityMoved) return [];\n const what =\n was.ecosystem === \"oci\"\n ? `the image ${was.name}:${was.requested ?? \"latest\"} now resolves to a different digest`\n : \"the file this server runs from has different contents than when it was pinned\";\n return [change(\"server.artifact.changed\", name, `${what}${unexplained}`, { before: was, after: now })];\n}\n\nfunction compareServer(name: string, before: LockedMcpServer, after: LockedMcpServer): Change[] {\n /*\n * Provenance first, and outside the short-circuit: the attack it exists for is new code behind\n * an unchanged surface, which is exactly the case where the digests match.\n */\n const provenance = compareProvenance(name, before, after);\n if (before.digest === after.digest) return provenance;\n const changes: Change[] = [...provenance];\n\n if (!same(before.transport, after.transport)) {\n changes.push(change(\"server.transport.changed\", name, \"the server is reached differently than when it was pinned\", { before: before.transport, after: after.transport }));\n }\n if (!same(before.serverInfo, after.serverInfo)) {\n const from = before.serverInfo?.version ?? \"unknown\";\n const to = after.serverInfo?.version ?? \"unknown\";\n changes.push(change(\"server.identity.changed\", name, `server identity changed (version ${from} → ${to})`, { before: before.serverInfo, after: after.serverInfo }));\n }\n if (!same(before.protocol, after.protocol)) {\n changes.push(\n change(\"server.protocol.changed\", name, `protocol changed (${before.protocol.era}/${before.protocol.version} → ${after.protocol.era}/${after.protocol.version})`, {\n before: before.protocol,\n after: after.protocol,\n }),\n );\n }\n if (!same(before.instructions, after.instructions)) {\n changes.push(\n change(\"server.instructions.changed\", name, \"server instructions changed: this text goes into the model's system prompt\", {\n before: before.instructions,\n after: after.instructions,\n }),\n );\n }\n changes.push(...compareCapabilities(before, after, name));\n\n changes.push(\n ...compareMembers<LockedTool>(name, before.tools, after.tools, {\n key: (t) => t.name,\n label: (t) => t.name,\n added: \"tool.added\",\n removed: \"tool.removed\",\n changed: \"tool.changed\",\n noun: \"tool\",\n arriving: (t) => {\n const can = toolCapabilities(t);\n return can.length > 0 ? `can ${can.map((capability) => capability.kind).join(\", \")}` : \"\";\n },\n }, (_key, a, b) =>\n compareTool(name, a, b),\n ),\n );\n changes.push(...compareToolCapabilities(name, before.tools, after.tools));\n changes.push(\n ...compareMembers<LockedResource>(name, before.resources, after.resources, {\n key: (r) => r.uri,\n label: (r) => `${r.name} (${r.uri})`,\n added: \"resource.added\",\n removed: \"resource.removed\",\n changed: \"resource.changed\",\n noun: \"resource\",\n }),\n );\n changes.push(\n ...compareMembers<LockedResourceTemplate>(name, before.resourceTemplates, after.resourceTemplates, {\n key: (t) => t.uriTemplate,\n // The template itself is the capability -- widening it from file:///project/{path} to\n // file:///{path} is the whole finding -- so it belongs in the label, not just the body.\n label: (t) => `${t.name} (${t.uriTemplate})`,\n added: \"resource_template.added\",\n removed: \"resource_template.removed\",\n changed: \"resource_template.changed\",\n noun: \"resource template\",\n }),\n );\n changes.push(\n ...compareMembers<LockedPrompt>(name, before.prompts, after.prompts, {\n key: (p) => p.name,\n label: (p) => p.name,\n added: \"prompt.added\",\n removed: \"prompt.removed\",\n changed: \"prompt.changed\",\n noun: \"prompt\",\n }),\n );\n\n return changes;\n}\n\n/**\n * A server renamed in config would naively read as a removal plus an addition: two alarming\n * findings for a cosmetic edit. Collapsing requires an identical transport *and* an identical\n * digest, so a rename that also changed capabilities stays a remove and an add -- which is what\n * it is, and hiding a capability change inside a cosmetic one is the failure mode worth avoiding.\n */\nfunction detectRenames(before: Lockfile, after: Lockfile, removed: string[], added: string[]): { changes: Change[]; renamed: Set<string> } {\n const changes: Change[] = [];\n const renamed = new Set<string>();\n const availableAdds = [...added];\n\n for (const oldName of removed) {\n const oldEntry = before.subjects[oldName];\n if (!oldEntry) continue;\n const match = availableAdds.find((newName) => {\n const candidate = after.subjects[newName];\n return candidate !== undefined && candidate.digest === oldEntry.digest && same(candidate.transport, oldEntry.transport);\n });\n if (!match) continue;\n\n availableAdds.splice(availableAdds.indexOf(match), 1);\n renamed.add(oldName);\n renamed.add(match);\n changes.push(change(\"server.renamed\", match, `renamed from \"${oldName}\"; capabilities are unchanged`, { before: oldName, after: match }));\n }\n return { changes, renamed };\n}\n\nexport function diffLockfiles(before: Lockfile, after: Lockfile): Change[] {\n const beforeNames = Object.keys(before.subjects);\n const afterNames = Object.keys(after.subjects);\n const removed = beforeNames.filter((name) => !afterNames.includes(name));\n const added = afterNames.filter((name) => !beforeNames.includes(name));\n\n const { changes: renameChanges, renamed } = detectRenames(before, after, removed, added);\n const changes: Change[] = [...renameChanges];\n\n for (const name of added) {\n if (renamed.has(name)) continue;\n const entry = after.subjects[name];\n const toolCount = entry?.tools?.length ?? 0;\n changes.push(change(\"server.added\", name, `new server with ${toolCount} tool${toolCount === 1 ? \"\" : \"s\"}`, { after: entry }));\n }\n for (const name of removed) {\n if (renamed.has(name)) continue;\n changes.push(change(\"server.removed\", name, \"server is no longer configured\", { before: before.subjects[name] }));\n }\n for (const name of afterNames) {\n const a = before.subjects[name];\n const b = after.subjects[name];\n if (!a || !b) continue;\n changes.push(...compareServer(name, a, b));\n }\n\n return sortChanges(changes);\n}\n"],"mappings":";;;;;;;;;;;;;;;AAmBO,SAAS,UAAU,OAAgD;AACxE,MAAI,CAAC,MAAM,QAAQ,KAAK,EAAG,QAAO,CAAC;AACnC,SAAO,MAAM,OAAO,CAAC,WAA8C,OAAO,WAAW,YAAY,WAAW,IAAI;AAClH;AAGO,SAAS,SAAS,OAAyC;AAChE,SAAO,OAAO,UAAU,YAAY,UAAU,OAAQ,QAAoC,CAAC;AAC7F;AAGO,SAAS,SAAS,OAAoC;AAC3D,SAAO,OAAO,UAAU,WAAW,QAAQ;AAC7C;;;ACXO,IAAM,wBAAwB,CAAC,YAAY,QAAQ,UAAU,KAAK;AAGlE,IAAM,mBAAmB;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAwBA,IAAM,QAAgB;AAAA,EACpB,EAAE,MAAM,gBAAgB,UAAU,YAAY,MAAM,4FAA4F,KAAK,iDAAiD;AAAA;AAAA;AAAA;AAAA;AAA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OAAO;AACxB,QAAI,QAAQ,IAAI,IAAI,EAAG;AACvB,UAAM,QAAQ,MAAM,SAAS,IAAI;AACjC,UAAM,YAAY,OAAO,OAAO,UAAU;AAC1C,YAAQ,KAAK,OAAO,gBAAgB,MAAM,mBAAmB,SAAS,QAAQ,cAAc,IAAI,KAAK,GAAG,IAAI,EAAE,OAAO,MAAM,CAAC,CAAC;AAAA,EAC/H;AACA,aAAW,QAAQ,SAAS;AAC1B,QAAI,QAAQ,IAAI,IAAI,EAAG;AACvB,YAAQ,KAAK,OAAO,kBAAkB,MAAM,kCAAkC,EAAE,QAAQ,OAAO,SAAS,IAAI,EAAE,CAAC,CAAC;AAAA,EAClH;AACA,aAAW,QAAQ,YAAY;AAC7B,UAAM,IAAI,OAAO,SAAS,IAAI;AAC9B,UAAM,IAAI,MAAM,SAAS,IAAI;AAC7B,QAAI,CAAC,KAAK,CAAC,EAAG;AACd,YAAQ,KAAK,GAAG,cAAc,MAAM,GAAG,CAAC,CAAC;AAAA,EAC3C;AAEA,SAAO,YAAY,OAAO;AAC5B;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/lock/jsonschema.ts"],"sourcesContent":["/**\n * Just enough JSON Schema to see through the indirection servers actually use.\n *\n * Two parts of this tool have to look inside a tool's `inputSchema`: the widening heuristic and\n * the `x-mcp-header` scan. Both used to read only the literal node in front of them, so a schema\n * that put its properties behind `$ref` or `allOf` -- which the generators for Pydantic, Zod and\n * most OpenAPI toolchains do by default -- looked empty to both. A widened parameter went out as\n * a bare `.changed`, and a parameter newly mirrored into an HTTP header was missed entirely.\n *\n * This is not a validator. It resolves local `$ref`, flattens `allOf`, and leaves the\n * alternation keywords for the caller to branch on. Remote `$ref` is never fetched: an audit\n * that reaches out to a URL named by the thing it is auditing is not an audit.\n */\nimport type { JsonObject, JsonValue } from \"./types\";\n\n/** Depth caps. A hostile or merely recursive schema must not be able to hang the run. */\nexport const MAX_REF_DEPTH = 32;\nexport const MAX_VISIT_DEPTH = 12;\nexport const MAX_FACTS = 5_000;\n\nexport function asObject(value: JsonValue | undefined): JsonObject | undefined {\n return value !== null && value !== undefined && typeof value === \"object\" && !Array.isArray(value) ? (value as JsonObject) : undefined;\n}\n\n/** RFC 6901 token decoding: `~1` is `/` and `~0` is `~`, in that order. */\nfunction decodeToken(token: string): string {\n let decoded = token;\n try {\n decoded = decodeURIComponent(token);\n } catch {\n // A malformed escape is a literal, not a reason to abandon the schema.\n }\n return decoded.replace(/~1/g, \"/\").replace(/~0/g, \"~\");\n}\n\n/** Resolves a local JSON pointer. Anything with a non-empty URI part is left unresolved. */\nexport function resolvePointer(root: JsonValue, ref: string): JsonValue | undefined {\n if (!ref.startsWith(\"#\")) return undefined;\n const pointer = ref.slice(1);\n if (pointer !== \"\" && !pointer.startsWith(\"/\")) return undefined; // `#anchor`, which needs an anchor index.\n\n let node: JsonValue | undefined = root;\n for (const token of pointer.split(\"/\").slice(1)) {\n const object = asObject(node);\n if (object === undefined) return undefined;\n node = object[decodeToken(token)];\n }\n return node;\n}\n\n/**\n * The keywords in effect at a node, with `$ref` followed and `allOf` folded in.\n *\n * The node's own keywords win over anything it inherits, `properties` are unioned, and\n * `required` is the union of every contributor -- which is what `allOf` means. Alternation\n * (`anyOf` / `oneOf` / `then` / `else`) is deliberately left in place: a caller that wants to\n * treat branches as separate possibilities can, and one that does not is no worse off.\n */\nexport function effectiveSchema(node: JsonValue | undefined, root: JsonValue, seenRefs: ReadonlySet<string> = new Set(), depth = 0): JsonObject | undefined {\n const object = asObject(node);\n if (object === undefined) return undefined;\n if (depth > MAX_REF_DEPTH) return object;\n\n /*\n * No prototype, and own-property checks rather than `in`. `name in merged` on a plain object is\n * true for `constructor`, `toString` and `__proto__`, so a property with one of those names was\n * skipped as already merged, and `merged[\"__proto__\"] = ...` set the prototype instead.\n */\n const out = Object.create(null) as JsonObject;\n const merge = (source: JsonObject): void => {\n for (const [key, value] of Object.entries(source)) {\n if (key === \"$ref\" || key === \"allOf\") continue;\n if (key === \"properties\") {\n // First contributor wins on a conflict, and keeps its position: the merged object reads\n // in the order a person wrote it, not inside-out from the inheritance chain.\n const merged = Object.assign(Object.create(null) as JsonObject, asObject(out[\"properties\"]) ?? {});\n for (const [name, schema] of Object.entries(asObject(value) ?? {})) {\n if (!Object.hasOwn(merged, name)) Object.defineProperty(merged, name, { value: schema, enumerable: true, writable: true, configurable: true });\n }\n out[\"properties\"] = merged;\n } else if (key === \"required\" && Array.isArray(value)) {\n const already = Array.isArray(out[\"required\"]) ? (out[\"required\"] as JsonValue[]) : [];\n out[\"required\"] = [...new Set([...already, ...value].filter((entry): entry is string => typeof entry === \"string\"))];\n } else if (!Object.hasOwn(out, key)) {\n out[key] = value;\n }\n }\n };\n\n // The node itself first, so its own keywords take precedence over what it inherits.\n merge(object);\n\n const ref = object[\"$ref\"];\n if (typeof ref === \"string\" && !seenRefs.has(ref)) {\n const resolved = effectiveSchema(resolvePointer(root, ref), root, new Set([...seenRefs, ref]), depth + 1);\n if (resolved) merge(resolved);\n }\n\n const allOf = object[\"allOf\"];\n if (Array.isArray(allOf)) {\n for (const branch of allOf) {\n const resolved = effectiveSchema(branch, root, seenRefs, depth + 1);\n if (resolved) merge(resolved);\n }\n }\n\n return out;\n}\n\n/** The alternation branches at a node, labelled so a caller can key facts by them. */\nexport function alternatives(object: JsonObject): Array<{ label: string; schema: JsonValue }> {\n const branches: Array<{ label: string; schema: JsonValue }> = [];\n for (const keyword of [\"anyOf\", \"oneOf\"] as const) {\n const value = object[keyword];\n if (!Array.isArray(value)) continue;\n value.forEach((schema, index) => branches.push({ label: `${keyword}[${index}]`, schema }));\n }\n for (const keyword of [\"then\", \"else\", \"not\"] as const) {\n if (object[keyword] !== undefined) branches.push({ label: keyword, schema: object[keyword] as JsonValue });\n }\n return branches;\n}\n"],"mappings":";AAgBO,IAAM,gBAAgB;AACtB,IAAM,kBAAkB;AACxB,IAAM,YAAY;AAElB,SAAS,SAAS,OAAsD;AAC7E,SAAO,UAAU,QAAQ,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AAS,KAAK,EAAE,OAAO,GAAG,OAAO,IAAI,KAAK,KAAK,OAAO,CAAC,CAAC;AAAA,EAC3F;AACA,aAAW,WAAW,CAAC,QAAQ,QAAQ,KAAK,GAAY;AACtD,QAAI,OAAO,OAAO,MAAM,OAAW,UAAS,KAAK,EAAE,OAAO,SAAS,QAAQ,OAAO,OAAO,EAAe,CAAC;AAAA,EAC3G;AACA,SAAO;AACT;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/lock/normalize.ts"],"sourcesContent":["/** Turning what a server sent into the stable, reviewable form the lock stores. */\nimport { redactPath } from \"./credentials\";\nimport { alternatives, asObject, effectiveSchema, MAX_VISIT_DEPTH } from \"./jsonschema\";\nimport type { JsonObject, JsonValue, LockedAnnotations, LockedBehavior } from \"./types\";\n\n/**\n * Resolves the four behavioural annotations against the spec's defaults, which are not neutral:\n * an absent `readOnlyHint` means \"may modify\" and an absent `destructiveHint` means \"may\n * destroy\". A server deleting an annotation is therefore an escalation, and the lock has to be\n * able to show it as a changed value rather than a removed line. See docs/lockfile.md §4.\n *\n * `destructiveHint` and `idempotentHint` are defined to be meaningful only when `readOnlyHint`\n * is false, so a read-only tool resolves to non-destructive and idempotent regardless of what\n * it claims: a tool that changes nothing cannot destroy anything, and repeating it has no\n * additional effect.\n */\nexport function resolveBehavior(annotations: LockedAnnotations | undefined): LockedBehavior {\n const readOnly = annotations?.readOnlyHint ?? false;\n return {\n readOnly,\n destructive: readOnly ? false : (annotations?.destructiveHint ?? true),\n idempotent: readOnly ? true : (annotations?.idempotentHint ?? false),\n openWorld: annotations?.openWorldHint ?? true,\n };\n}\n\n/** True when `next` claims any power `previous` did not. */\nexport function isEscalation(previous: LockedBehavior, next: LockedBehavior): boolean {\n return (\n (previous.readOnly && !next.readOnly) ||\n (!previous.destructive && next.destructive) ||\n (previous.idempotent && !next.idempotent) ||\n (!previous.openWorld && next.openWorld)\n );\n}\n\n/**\n * Sorts `required` arrays wherever they appear. Member order there is semantically\n * insignificant and is the most common source of diffs that mean nothing. Every other array\n * keeps server order, because order *is* significant in `prefixItems`, `allOf` and `icons`, and\n * we only reorder where we can show it is safe.\n *\n * The rule is positional rather than schema-aware: a non-schema object with a string-array\n * member literally named `required` would also be sorted. That costs nothing we can observe and\n * avoids carrying a JSON Schema interpreter around.\n */\nexport function normalizeSchema(value: JsonValue): JsonValue {\n if (Array.isArray(value)) return value.map(normalizeSchema);\n if (value === null || typeof value !== \"object\") return value;\n\n // No prototype, so a member named `__proto__` is kept (see toJson in canonical.ts).\n const out = Object.create(null) as JsonObject;\n for (const [key, member] of Object.entries(value)) {\n if (key === \"required\" && Array.isArray(member) && member.every((entry) => typeof entry === \"string\")) {\n out[key] = [...(member as string[])].sort();\n continue;\n }\n out[key] = normalizeSchema(member);\n }\n return out;\n}\n\n/**\n * Finds input properties carrying an `x-mcp-header` annotation, which mirrors the argument's\n * value into an `Mcp-Param-*` HTTP header on Streamable HTTP, where proxies and WAFs can read\n * it. A server adding this to an existing parameter redirects that argument's data with no\n * visible change to the tool's signature, so it gets its own line in the lock.\n *\n * `$ref` and `allOf` are resolved first. Schema generators put properties behind `$defs` as a\n * matter of course, and a scan that only read literal nodes found nothing in those -- which is\n * the worst outcome for a field whose entire purpose is to move data somewhere new.\n */\nexport function extractHeaderParams(schema: JsonValue): string[] {\n const found: string[] = [];\n /*\n * Bounded twice. A `$ref` already on the way down is not followed again: a definition whose\n * properties point back at it was walked once per property per level, P^12 calls, so a\n * 200-byte schema held `check` for minutes on a blocked event loop that no timeout could\n * interrupt. Headers inside a recursion are the ones its first pass already found. And a hard\n * ceiling on visits, which leaves a marker in the lock rather than an incomplete list that\n * looks complete.\n */\n let budget = MAX_HEADER_VISITS;\n\n const walk = (node: JsonValue, path: string[], depth: number, refsOnPath: ReadonlySet<string>): void => {\n if (depth > MAX_VISIT_DEPTH) return;\n if (budget <= 0) return;\n budget -= 1;\n const object = effectiveSchema(node, schema);\n if (!object) return;\n\n const properties = asObject(object[\"properties\"]);\n if (properties) {\n for (const [name, child] of Object.entries(properties)) {\n const resolved = effectiveSchema(child, schema);\n if (!resolved) continue;\n const header = resolved[\"x-mcp-header\"];\n if (typeof header === \"string\" && header.length > 0) found.push(`${[...path, name].join(\".\")} -> ${header}`);\n const ref = asObject(child)?.[\"$ref\"];\n if (typeof ref === \"string\" && refsOnPath.has(ref)) continue;\n walk(child, [...path, name], depth + 1, typeof ref === \"string\" ? new Set([...refsOnPath, ref]) : refsOnPath);\n }\n }\n\n // A parameter reachable only through one branch of an `anyOf` is still reachable.\n for (const branch of alternatives(object)) {\n const ref = asObject(branch.schema)?.[\"$ref\"];\n if (typeof ref === \"string\" && refsOnPath.has(ref)) continue;\n walk(branch.schema, path, depth + 1, typeof ref === \"string\" ? new Set([...refsOnPath, ref]) : refsOnPath);\n }\n };\n\n const rootRef = asObject(schema)?.[\"$ref\"];\n walk(schema, [], 0, new Set(typeof rootRef === \"string\" ? [rootRef] : []));\n if (budget <= 0) found.push(`(schema too large to scan for headers past ${MAX_HEADER_VISITS} nodes)`);\n return [...new Set(found)].sort();\n}\n\n/** How many schema nodes the header scan visits before it stops and says so. */\nexport const MAX_HEADER_VISITS = 20_000;\n\n/** Drops `_meta` keys under any ignored prefix. Returns undefined when nothing is left to pin. */\nexport function stripIgnoredMeta(meta: JsonValue | undefined, ignoredPrefixes: readonly string[]): JsonObject | undefined {\n if (meta === null || meta === undefined || typeof meta !== \"object\" || Array.isArray(meta)) return undefined;\n const out = Object.create(null) as JsonObject;\n for (const [key, value] of Object.entries(meta)) {\n if (ignoredPrefixes.some((prefix) => key.startsWith(prefix))) continue;\n out[key] = value;\n }\n return Object.keys(out).length > 0 ? out : undefined;\n}\n\n/** Strips the query string: query strings routinely carry tokens, and the lock is committed. */\nexport function sanitizeUrl(raw: string): string {\n /*\n * A placeholder (`${HOST}`, `${PORT}`) is kept exactly as written. Parsing first lowercased a\n * placeholder in the host, so the lock named a variable the config never used, and failed on one\n * in the port, which wrote the address raw, query string and all.\n */\n if (raw.includes(\"${\")) return sanitizeText(raw);\n try {\n const url = new URL(raw);\n url.search = \"\";\n url.hash = \"\";\n /*\n * `https://alice:s3cr3t@host/mcp` survived this untouched, because `toString()` keeps\n * userinfo. The query string was stripped on the grounds that credentials usually sit there;\n * userinfo is the one place a credential sits by definition.\n */\n url.username = \"\";\n url.password = \"\";\n // A hosted server whose address embeds the key keeps it in the path, past both of the above.\n url.pathname = redactPath(url.pathname);\n return url.toString();\n } catch {\n return sanitizeText(raw);\n }\n}\n\n/** The same, as text, for an address a URL parser cannot or should not normalize. */\nfunction sanitizeText(raw: string): string {\n const withoutUser = raw.replace(/^([a-z][a-z0-9+.-]*:\\/\\/)[^/@]*@/i, \"$1\");\n const base = withoutUser.split(/[?#]/)[0] ?? withoutUser;\n const parts = /^([a-z][a-z0-9+.-]*:\\/\\/[^/]*)(\\/.*)?$/i.exec(base);\n return parts ? `${parts[1]}${parts[2] ? redactPath(parts[2]) : \"\"}` : base;\n}\n"],"mappings":";;;;;;;;;;;AAgBO,SAAS,gBAAgB,aAA4D;AAC1F,QAAM,WAAW,aAAa,gBAAgB;AAC9C,SAAO;AAAA,IACL;AAAA,IACA,aAAa,WAAW,QAAS,aAAa,mBAAmB;AAAA,IACjE,YAAY,WAAW,OAAQ,aAAa,kBAAkB;AAAA,IAC9D,WAAW,aAAa,iBAAiB;AAAA,EAC3C;AACF;AAGO,SAAS,aAAa,UAA0B,MAA+B;AACpF,SACG,SAAS,YAAY,CAAC,KAAK,YAC3B,CAAC,SAAS,eAAe,KAAK,eAC9B,SAAS,cAAc,CAAC,KAAK,cAC7B,CAAC,SAAS,aAAa,KAAK;AAEjC;AAYO,SAAS,gBAAgB,OAA6B;AAC3D,MAAI,MAAM,QAAQ,KAAK,EAAG,QAAO,MAAM,IAAI,eAAe;AAC1D,MAAI,UAAU,QAAQ,OAAO,UAAU,SAAU,QAAO;AAGxD,QAAM,MAAM,uBAAO,OAAO,IAAI;AAC9B,aAAW,CAAC,KAAK,MAAM,KA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,qCAAqC,IAAI;AACzE,QAAM,OAAO,YAAY,MAAM,MAAM,EAAE,CAAC,KAAK;AAC7C,QAAM,QAAQ,0CAA0C,KAAK,IAAI;AACjE,SAAO,QAAQ,GAAG,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC,IAAI,WAAW,MAAM,CAAC,CAAC,IAAI,EAAE,KAAK;AACxE;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/lock/credentials.ts"],"sourcesContent":["/**\n * Credentials a config writes literally, found so the lock can leave them out.\n *\n * Environment and header values were never written to the lock, only their names, and a URL\n * loses its query string and its user:password. That covered every place a credential belongs.\n * It did not cover the places configs actually put them: `--api-key sk-...` in `args`,\n * `-e GITHUB_TOKEN=ghp_...` in a `docker run`, a connection string with a password, a token as a\n * segment of a hosted server's URL. The lock is the file the README tells you to commit, and the\n * reading `push` sends is the same data, so each of those went into git and over the wire.\n *\n * A credential is replaced, not hashed. A rotated key is not a change to what a server can do,\n * so there is nothing for drift to see in it, and a hash of a short password is something a\n * dictionary can be run against. This matches what already happens to an `env` value.\n *\n * Everything here errs toward leaving a value alone. A false positive hides a real change to how\n * a server is started, which is the thing the lock exists to show; a value is only replaced when\n * its name says it is a credential, its issuer's format does, or it is too random to be anything\n * else. A `${VAR}` placeholder is never touched: that is how a config is supposed to do this.\n */\n\n/** What a credential is replaced with. Plain ASCII, so it survives a URL path unescaped. */\nexport const REDACTED = \"REDACTED\";\n\n/**\n * Whether a name says its value is a credential: a flag (`--github-token`, `--key`), an\n * environment assignment (`GITHUB_PAT=`, `DD_API_KEY_SECONDARY=`), a JSON key (`braveApiKey`), a\n * query or connection-string parameter (`api_key=`, `Password=`).\n *\n * Read as words, camelCase split, so the credential word can sit anywhere in the name. It was a\n * suffix match, which missed `--key`, `GITHUB_PAT`, `braveApiKey` and every name with a word after\n * the credential one. A name whose last word says it holds something *about* a credential (where\n * it is, what kind it is) is left alone: `--token-file`, `--key-id`, `--auth-type`, `--max-tokens`.\n */\nconst CREDENTIAL_WORDS = new Set([\n \"key\", \"apikey\", \"token\", \"secret\", \"password\", \"passwd\", \"pwd\", \"pass\", \"pat\", \"auth\", \"bearer\",\n \"credential\", \"credentials\", \"privatekey\", \"accesskey\", \"clientsecret\", \"sig\", \"signature\", \"jwt\", \"cookie\",\n]);\nconst DESCRIBES_IT = new Set([\n \"file\", \"path\", \"dir\", \"directory\", \"url\", \"uri\", \"endpoint\", \"host\", \"type\", \"mode\", \"method\", \"header\",\n \"name\", \"id\", \"env\", \"var\", \"length\", \"limit\", \"count\", \"max\", \"min\", \"size\", \"timeout\", \"ttl\", \"format\",\n \"prefix\", \"location\", \"store\", \"provider\", \"region\", \"scope\", \"scopes\", \"version\", \"algorithm\", \"kind\", \"expiry\",\n]);\n\nfunction nameWords(name: string): string[] {\n return name\n .replace(/^-+/, \"\")\n .replace(/([a-z0-9])([A-Z])/g, \"$1 $2\")\n .toLowerCase()\n .split(/[^a-z0-9]+/)\n .filter(Boolean);\n}\n\nexport function isCredentialName(name: string): boolean {\n const words = nameWords(name);\n const last = words[words.length - 1];\n if (last === undefined || DESCRIBES_IT.has(last) || words[0] === \"no\") return false;\n return words.some((word) => CREDENTIAL_WORDS.has(word));\n}\n\n/** Headers that carry a credential whatever their value looks like. */\nconst CREDENTIAL_HEADERS = new Set([\"authorization\", \"proxy-authorization\", \"cookie\", \"set-cookie\"]);\n\n/**\n * Formats a credential has wherever it appears, because its issuer made it recognisable on\n * purpose (so leaked ones can be found). Each is specific enough not to match a package name.\n */\nconst ISSUER_FORMATS: RegExp[] = [\n /\\b(?:AKIA|ASIA)[0-9A-Z]{16}\\b/g, // AWS access key id\n /\\bgh[pousr]_[A-Za-z0-9]{36,}\\b/g, // GitHub\n /\\bgithub_pat_[A-Za-z0-9_]{40,}\\b/g,\n /\\bglpat-[A-Za-z0-9_-]{20,}/g, // GitLab\n /\\bxox[abprs]-[A-Za-z0-9-]{10,}/g, // Slack\n /\\b[rs]k_(?:live|test)_[A-Za-z0-9]{16,}\\b/g, // Stripe\n /\\bsk-ant-[A-Za-z0-9_-]{20,}/g, // Anthropic\n /\\bsk-(?:proj-|svcacct-|admin-)?[A-Za-z0-9_-]{32,}/g, // OpenAI\n /\\bAIza[0-9A-Za-z_-]{35}\\b/g, // Google API key\n /\\bnpm_[A-Za-z0-9]{36}\\b/g,\n /\\beyJ[A-Za-z0-9_-]{8,}\\.eyJ[A-Za-z0-9_-]{8,}\\.[A-Za-z0-9_-]{8,}/g, // JWT\n];\n\n/** A value written as a placeholder for the client to fill in, which is the safe way to do this. */\nconst PLACEHOLDER = /\\$\\{|^\\$[A-Za-z_]/;\n\n/**\n * A token with no issuer format: long, URL-safe, mixing upper case, lower case and digits, and\n * switching between them constantly.\n *\n * Requiring all three classes leaves out UUIDs, hex digests and commit hashes, which are lower\n * case and far more often an identifier than a secret. Requiring the switching leaves out long\n * names: `AnthropicClaudeDesktopExtension2025` has every class but changes class six times in\n * thirty-five characters, where a random token changes on most of them.\n */\nfunction looksRandom(value: string): boolean {\n if (value.length < 32 || !/^[A-Za-z0-9_-]+$/.test(value)) return false;\n if (!/[a-z]/.test(value) || !/[A-Z]/.test(value) || !/[0-9]/.test(value)) return false;\n const kind = (character: string) => (/[a-z]/.test(character) ? 0 : /[A-Z]/.test(character) ? 1 : /[0-9]/.test(character) ? 2 : 3);\n let switches = 0;\n for (let index = 1; index < value.length; index += 1) {\n if (kind(value[index] ?? \"\") !== kind(value[index - 1] ?? \"\")) switches += 1;\n }\n return switches >= value.length / 3;\n}\n\n/** `decodeURIComponent`, for a check: a malformed escape is just text. */\nfunction decoded(value: string): string {\n try {\n return decodeURIComponent(value);\n } catch {\n return value;\n }\n}\n\n/** A value worth replacing when its name already says it is a credential. */\nfunction isSecretValue(value: string): boolean {\n if (value === \"\" || value === REDACTED || PLACEHOLDER.test(value)) return false;\n // A path or a URL names where the secret lives, not the secret: `--token-file`-style use.\n if (/^(?:[./~]|[A-Za-z]:\\\\|[a-z][a-z0-9+.-]*:\\/\\/)/i.test(value)) return false;\n return true;\n}\n\n/** Replaces each issuer-formatted credential inside a value, leaving the rest of it readable. */\nfunction redactFormats(value: string): string {\n let out = value;\n for (const format of ISSUER_FORMATS) out = out.replace(format, REDACTED);\n return out;\n}\n\n/** In a URL inside an argument: the password, credential parameters in the query or fragment, key path segments. */\nfunction redactUrl(value: string): string {\n if (!/^[a-z][a-z0-9+.-]*:\\/\\//i.test(value)) return value;\n let url: URL;\n try {\n url = new URL(value);\n } catch {\n return redactPairs(value);\n }\n let changed = false;\n if (url.password && !PLACEHOLDER.test(decoded(url.password))) {\n url.password = REDACTED;\n changed = true;\n }\n for (const [key, parameter] of [...url.searchParams]) {\n if (isCredentialName(key) && isSecretValue(parameter)) {\n url.searchParams.set(key, REDACTED);\n changed = true;\n }\n }\n const path = redactPath(url.pathname);\n if (path !== url.pathname) {\n url.pathname = path;\n changed = true;\n }\n const hash = url.hash ? redactPairs(url.hash) : url.hash;\n if (hash !== url.hash) {\n url.hash = hash;\n changed = true;\n }\n return changed ? url.toString() : value;\n}\n\n/**\n * `name=value` pairs inside a larger string whose name is a credential: a query string a URL\n * parser would not take (`jdbc:postgresql://...&password=`), a fragment (`#access_token=`), a\n * connection string (`Server=db;Password=...`).\n */\nfunction redactPairs(text: string): string {\n return text.replace(/(^|[?&;#\\s,])([A-Za-z_][A-Za-z0-9_.-]*)=([^&;#\\s,]*)/g, (whole, lead: string, name: string, value: string) =>\n isCredentialName(name) && isSecretValue(value) ? `${lead}${name}=${REDACTED}` : whole,\n );\n}\n\n/** A header written as `Name: value`, for a header that is a credential. */\nfunction redactHeader(text: string): string | undefined {\n const header = /^([A-Za-z][A-Za-z0-9-]*)\\s*:\\s*(\\S.*)$/s.exec(text);\n if (!header) return undefined;\n const [, name = \"\", value = \"\"] = header;\n if (!(CREDENTIAL_HEADERS.has(name.toLowerCase()) || isCredentialName(name)) || PLACEHOLDER.test(value)) return undefined;\n return `${name}: ${REDACTED}`;\n}\n\n/** JSON in an argument (`--config {\"braveApiKey\":\"...\"}`), its credential-named values replaced. */\nfunction redactJson(text: string): string | undefined {\n if (!/^\\s*[[{]/.test(text)) return undefined;\n let parsed: unknown;\n try {\n parsed = JSON.parse(text);\n } catch {\n return undefined;\n }\n let changed = false;\n const walk = (node: unknown): unknown => {\n if (Array.isArray(node)) return node.map(walk);\n if (node !== null && typeof node === \"object\") {\n const out: Record<string, unknown> = Object.create(null) as Record<string, unknown>;\n for (const [key, child] of Object.entries(node)) {\n if (typeof child === \"string\" && isCredentialName(key) && isSecretValue(child)) {\n out[key] = REDACTED;\n changed = true;\n } else if (typeof child === \"string\") {\n const next = redactText(child);\n if (next !== child) changed = true;\n out[key] = next;\n } else {\n out[key] = walk(child);\n }\n }\n return out;\n }\n return node;\n };\n const result = walk(parsed);\n return changed ? JSON.stringify(result) : undefined;\n}\n\n/** Everything that can hide a credential inside one string, in the order that keeps the rest readable. */\nfunction redactText(text: string): string {\n if (PLACEHOLDER.test(text) && !/[?&;#]/.test(text)) return text;\n if (looksRandom(text)) return REDACTED;\n const json = redactJson(text);\n if (json !== undefined) return json;\n const header = redactHeader(text);\n if (header !== undefined) return header;\n return redactFormats(redactPairs(redactUrl(text)));\n}\n\n/**\n * `args` with every credential written literally in them replaced by {@link REDACTED}.\n *\n * Handles a flag and its value (`--api-key KEY`, `--api-key=KEY`), an environment assignment in\n * an argument (`-e GITHUB_TOKEN=ghp_...`, as `docker run` takes them), a URL's password or\n * credential query parameter, an issuer-formatted token anywhere, and an argument that is nothing\n * but a long random token. Arguments are returned in place and in order, so a change to anything\n * else about how a server is started is still drift.\n */\nexport function redactArgs(args: readonly string[]): string[] {\n const out = [...args];\n for (let index = 0; index < out.length; index += 1) {\n const argument = out[index] ?? \"\";\n\n // `--name=value`, `-n=value`, and `NAME=value` (an environment assignment).\n const assignment = /^(-{0,2}[A-Za-z][A-Za-z0-9_.-]*)=(.*)$/s.exec(argument);\n if (assignment) {\n const [, name = \"\", value = \"\"] = assignment;\n if (isCredentialName(name) && isSecretValue(value)) {\n out[index] = `${name}=${REDACTED}`;\n continue;\n }\n // Any other assignment: its value can still hold a header, a URL with a password, JSON, a token.\n if (!PLACEHOLDER.test(value) || /[?&;#]/.test(value)) out[index] = `${name}=${redactText(value)}`;\n continue;\n }\n\n // `--name value`: the flag names a credential, so the next argument is one.\n const flag = /^-{1,2}([A-Za-z][A-Za-z0-9_.-]*)$/.exec(argument);\n const next = out[index + 1];\n if (flag && next !== undefined && !next.startsWith(\"-\")) {\n const name = flag[1] ?? \"\";\n if (isCredentialName(name) && isSecretValue(next) && !looksLikeAnOperand(next)) {\n out[index + 1] = REDACTED;\n index += 1;\n continue;\n }\n // `-u user:password`, `--user user:password`: curl's form, and every tool that copied it.\n if ([\"u\", \"user\", \"basic-auth\"].includes(name.toLowerCase()) && /^[^:\\s]+:[^\\s]+$/.test(next) && !PLACEHOLDER.test(next)) {\n out[index + 1] = `${next.slice(0, next.indexOf(\":\"))}:${REDACTED}`;\n index += 1;\n continue;\n }\n }\n\n out[index] = redactText(argument);\n }\n return out;\n}\n\n/**\n * Whether the word after a flag is more likely the next operand than the flag's value: a script, a\n * package, a path. A boolean credential flag (`--auth`) followed by `server.js` is not a key.\n */\nfunction looksLikeAnOperand(value: string): boolean {\n return value.startsWith(\"@\") || value.includes(\"/\") || /\\.(m?[jt]s|cjs|py|json|ya?ml|toml|sh|exe)$/i.test(value);\n}\n\n/**\n * A URL path with any segment that is a credential replaced, for hosted servers whose address\n * embeds the key (`https://host/api/<token>/mcp`). The rest of the path stays, so a server that\n * moves to a different path or host is still drift.\n */\nexport function redactPath(pathname: string): string {\n return pathname\n .split(\"/\")\n .map((segment) => {\n if (segment === \"\" || PLACEHOLDER.test(decoded(segment))) return segment;\n if (looksRandom(segment)) return REDACTED;\n // A UUID or a long hex string in a hosted server's address is its key far more often than\n // not (Pipedream, Composio and the like put the account's key there).\n if (/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(segment) || /^[0-9a-f]{32,}$/i.test(segment)) return REDACTED;\n return redactFormats(segment);\n })\n .join(\"/\");\n}\n\n/** How many credentials were left out of a locked transport, for saying so. */\nexport function countRedacted(transport: { args?: readonly string[]; url?: string }): number {\n const occurrences = (text: string) => text.split(REDACTED).length - 1;\n return (transport.args ?? []).reduce((total, argument) => total + occurrences(argument), 0) + occurrences(transport.url ?? \"\");\n}\n"],"mappings":";AAqBO,IAAM,WAAW;AAYxB,IAAM,mBAAmB,oBAAI,IAAI;AAAA,EAC/B;AAAA,EAAO;AAAA,EAAU;AAAA,EAAS;AAAA,EAAU;AAAA,EAAY;AAAA,EAAU;AAAA,EAAO;AAAA,EAAQ;AAAA,EAAO;AAAA,EAAQ;AAAA,EACxF;AAAA,EAAc;AAAA,EAAe;AAAA,EAAc;AAAA,EAAa;AAAA,EAAgB;AAAA,EAAO;AAAA,EAAa;AAAA,EAAO;AACrG,CAAC;AACD,IAAM,eAAe,oBAAI,IAAI;AAAA,EAC3B;AAAA,EAAQ;AAAA,EAAQ;AAAA,EAAO;AAAA,EAAa;AAAA,EAAO;AAAA,EAAO;AAAA,EAAY;AAAA,EAAQ;AAAA,EAAQ;AAAA,EAAQ;AAAA,EAAU;AAAA,EAChG;AAAA,EAAQ;AAAA,EAAM;AAAA,EAAO;AAAA,EAAO;AAAA,EAAU;AAAA,EAAS;AAAA,EAAS;AAAA,EAAO;AAAA,EAAO;AAAA,EAAQ;AAAA,EAAW;AAAA,EAAO;AAAA,EAChG;AAAA,EAAU;AAAA,EAAY;AAAA,EAAS;AAAA,EAAY;AAAA,EAAU;AAAA,EAAS;AAAA,EAAU;AAAA,EAAW;AAAA,EAAa;AAAA,EAAQ;AAC1G,CAAC;AAED,SAAS,UAAU,MAAwB;AACzC,SAAO,KACJ,QAAQ,OAAO,EAAE,EACjB,QAAQ,sBAAsB,OAAO,EACrC,YAAY,EACZ,MAAM,YAAY,EAClB,OAAO,OAAO;AACnB;AAEO,SAAS,iBAAiB,MAAuB;AAC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