@slicedearth/whoisleuth-cli 1.45.0 → 2.0.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 (268) hide show
  1. package/DISCLOSURE +7 -3
  2. package/NOTICE +5 -4
  3. package/README.md +74 -124
  4. package/SECURITY.md +6 -3
  5. package/bin/whoisleuth.mjs +7 -4
  6. package/cli/archive-inspect.mjs +28 -10
  7. package/cli/arguments.mjs +450 -173
  8. package/cli/artifact-structure.mjs +2507 -0
  9. package/cli/artifact-verify.mjs +286 -64
  10. package/cli/bounded-json.mjs +1 -0
  11. package/cli/bulk-checkpoint.mjs +35 -23
  12. package/cli/bulk-command-runner.mjs +2 -5
  13. package/cli/bulk.mjs +9 -2
  14. package/cli/case-pack.mjs +435 -46
  15. package/cli/ci-report.mjs +6 -1
  16. package/cli/collection-preflight.mjs +2 -2
  17. package/cli/command-catalogue.mjs +12 -3
  18. package/cli/command-reference.mjs +948 -106
  19. package/cli/completion.mjs +504 -218
  20. package/cli/config-profile.mjs +13 -3
  21. package/cli/ct-event-intake.mjs +32 -2
  22. package/cli/discover.mjs +7 -1
  23. package/cli/discovery-observation-snapshot.mjs +24 -28
  24. package/cli/discovery-scan-command-runner.mjs +13 -14
  25. package/cli/discovery-scan.mjs +17 -3
  26. package/cli/discovery-snapshot.mjs +15 -7
  27. package/cli/discovery-workflow.mjs +2 -3
  28. package/cli/doctor.mjs +2 -2
  29. package/cli/domain-control-monitor.mjs +215 -36
  30. package/cli/domain-control-observations.mjs +34 -17
  31. package/cli/errors.mjs +8 -3
  32. package/cli/evidence-command-runner.mjs +17 -11
  33. package/cli/evidence-signing.mjs +68 -50
  34. package/cli/export-evidence.mjs +11 -4
  35. package/cli/external-observation-mapping.mjs +3 -3
  36. package/cli/formatters/html.mjs +3 -3
  37. package/cli/formatters/json.mjs +20 -32
  38. package/cli/formatters/terminal.mjs +586 -22
  39. package/cli/input.mjs +62 -0
  40. package/cli/interactive-launcher.mjs +226 -0
  41. package/cli/interchange-report.mjs +226 -0
  42. package/cli/investigation-manifest.mjs +16 -17
  43. package/cli/investigation-plan.mjs +167 -16
  44. package/cli/investigation-run.mjs +80 -24
  45. package/cli/local-mmdb-review.mjs +45 -14
  46. package/cli/lookalike-calibration.mjs +3 -1
  47. package/cli/lookup-brief.mjs +13 -8
  48. package/cli/lookup-browser.mjs +844 -0
  49. package/cli/lookup-command-runner.mjs +96 -33
  50. package/cli/lookup-diff.mjs +11 -2
  51. package/cli/lookup-plan.mjs +1 -0
  52. package/cli/mail-review.mjs +206 -94
  53. package/cli/manual.mjs +5 -5
  54. package/cli/network-command-runner.mjs +78 -0
  55. package/cli/offline-evidence-review.mjs +45 -14
  56. package/cli/open-asset-model-bridge.mjs +1 -1
  57. package/cli/output-file.mjs +70 -14
  58. package/cli/page-compare.mjs +18 -10
  59. package/cli/progress-events.mjs +2 -1
  60. package/cli/progress.mjs +3 -3
  61. package/cli/registry-cohort.mjs +343 -61
  62. package/cli/registry-doctor.mjs +67 -28
  63. package/cli/registry-support.mjs +2 -1
  64. package/cli/retained-artifact-diff.mjs +375 -0
  65. package/cli/risk-calibration.mjs +89 -40
  66. package/cli/runner.mjs +322 -246
  67. package/cli/saved-lookup.mjs +439 -49
  68. package/cli/sharing-review.mjs +18 -7
  69. package/cli/source-reliability.mjs +75 -36
  70. package/cli/terminal-presentation.mjs +43 -18
  71. package/docs/cli-reference.md +125 -1334
  72. package/docs/cli.md +87 -236
  73. package/frontend/src/lib/analysis/domain-control-manifest-core.js +3 -0
  74. package/frontend/src/lib/analysis/domain-control-records.js +3 -0
  75. package/lib/application-version.mjs +3 -0
  76. package/lib/availability.mjs +72 -52
  77. package/lib/bounded-contract-normalizers.mjs +2 -4
  78. package/lib/bounded-file.mjs +91 -4
  79. package/lib/bounded-json.mjs +287 -0
  80. package/lib/browser-library-profile.mjs +1 -1
  81. package/lib/certificate-extension-profile.mjs +2 -1
  82. package/lib/classify.mjs +56 -5
  83. package/lib/client-behavior-profile.mjs +1 -1
  84. package/lib/credential-surface-profile.mjs +1 -1
  85. package/lib/cryptographic-assurance.mjs +173 -0
  86. package/lib/ct-query.mjs +3 -3
  87. package/lib/ct-search.mjs +120 -64
  88. package/lib/distributed-operation-budget.mjs +4 -2
  89. package/lib/dns-delegation-health.mjs +9 -6
  90. package/lib/dns-intelligence.mjs +4 -3
  91. package/lib/dns-resolver-selection.mjs +6 -4
  92. package/lib/dnssec-chain-validation.mjs +1052 -0
  93. package/lib/dnssec-evidence-validation.mjs +23 -10
  94. package/lib/domain-assurance.mjs +12 -12
  95. package/lib/domain-change-packet.mjs +7 -5
  96. package/lib/domain-control-flight-recorder.mjs +442 -78
  97. package/lib/domain-control-manifest.mjs +314 -171
  98. package/lib/domain-posture-analysis.mjs +5 -2
  99. package/lib/domain-posture.mjs +7 -4
  100. package/lib/encrypted-dns-contract.mjs +2 -3
  101. package/lib/evidence-export.mjs +1243 -88
  102. package/lib/evidence-report-markdown.mjs +3 -0
  103. package/lib/evidence-report.mjs +5 -0
  104. package/lib/external-intelligence-risk.mjs +26 -10
  105. package/lib/favicon.mjs +8 -5
  106. package/lib/feature-policy.mjs +1 -1
  107. package/lib/homepage-metadata-contract.mjs +290 -0
  108. package/lib/hostname.mjs +1 -1
  109. package/lib/html-signals.mjs +89 -5
  110. package/lib/http-evidence-bounds.mjs +3 -0
  111. package/lib/http-intelligence.mjs +332 -6
  112. package/lib/interchange-fidelity-registry.mjs +124 -0
  113. package/lib/local-geoip-evidence.mjs +2 -1
  114. package/lib/lookup-cache.mjs +6 -4
  115. package/lib/lookup-network-evidence-bounds.mjs +9 -0
  116. package/lib/lookup.mjs +27 -4
  117. package/lib/observed-network-context.mjs +1 -1
  118. package/lib/outbound-identity.mjs +2 -3
  119. package/lib/page-fingerprints.mjs +2 -2
  120. package/lib/page-role-profile.mjs +1 -1
  121. package/lib/perceptual-hash.mjs +12 -4
  122. package/lib/portable-generator.mjs +29 -0
  123. package/lib/provider-policy-admission.mjs +11 -4
  124. package/lib/rdap-bootstrap.mjs +76 -16
  125. package/lib/rdap-client.mjs +20 -12
  126. package/lib/rdap-normalization.mjs +324 -80
  127. package/lib/rdap-registrar.mjs +5 -1
  128. package/lib/rdap-transport.mjs +2 -2
  129. package/lib/rdap-validation.mjs +65 -14
  130. package/lib/rdap.mjs +2 -2
  131. package/lib/registrable-domain.mjs +36 -0
  132. package/lib/registry-capabilities.mjs +3 -0
  133. package/lib/registry-capability-catalogue.mjs +12 -2
  134. package/lib/registry-comparison.mjs +28 -11
  135. package/lib/registry-insights.mjs +7 -0
  136. package/lib/response-policy.mjs +27 -4
  137. package/lib/risk-calibration-summary.mjs +340 -0
  138. package/lib/risk-scoring.mjs +4 -3
  139. package/lib/rpki-evidence.mjs +9 -8
  140. package/lib/safe-fetch.mjs +121 -50
  141. package/lib/security-txt.mjs +27 -4
  142. package/lib/service-binding-dns.mjs +6 -1
  143. package/lib/smtp-transport-review.mjs +787 -0
  144. package/lib/sslbl-certificates.generated.mjs +136 -134
  145. package/lib/sslbl-intelligence.mjs +6 -8
  146. package/lib/static-html-analysis.mjs +301 -4
  147. package/lib/structured-data-identity.mjs +51 -19
  148. package/lib/threat-intelligence-fixtures.mjs +2 -4
  149. package/lib/threat-intelligence-manifests.mjs +2 -7
  150. package/lib/threat-intelligence-runtime.mjs +5 -15
  151. package/lib/threat-intelligence-types.mjs +21 -1
  152. package/lib/threatfox-intelligence.mjs +7 -3
  153. package/lib/tls-intelligence.mjs +15 -9
  154. package/lib/tlsa-evidence.mjs +37 -7
  155. package/lib/urlhaus-intelligence.mjs +4 -2
  156. package/lib/urlscan-intelligence.mjs +6 -5
  157. package/lib/website-security-posture.mjs +1 -1
  158. package/lib/website-technology.mjs +1 -1
  159. package/lib/whois-authority.mjs +43 -8
  160. package/lib/whois-chain.mjs +25 -3
  161. package/lib/whois-normalization.mjs +3 -1
  162. package/lib/whois-transport.mjs +12 -3
  163. package/lib/zone-intent-review.mjs +1 -1
  164. package/package.json +12 -4
  165. package/packages/cases/case-brand-profile-references.mjs +85 -0
  166. package/{frontend/src/lib/analysis/case-evidence-model.js → packages/cases/case-evidence-model.mjs} +43 -14
  167. package/packages/cases/case-investigation-branch-model.mjs +132 -0
  168. package/packages/cases/case-migration-model.mjs +476 -0
  169. package/{frontend/src/lib/analysis/case-model.js → packages/cases/case-model.mjs} +3 -3
  170. package/{frontend/src/lib/analysis/case-record-contracts.js → packages/cases/case-record-contracts.mjs} +3 -19
  171. package/{frontend/src/lib/analysis/case-record-core.js → packages/cases/case-record-core.mjs} +58 -31
  172. package/packages/cases/case-record-model.mjs +9 -0
  173. package/{frontend/src/lib/analysis/case-record-operations.js → packages/cases/case-record-operations.mjs} +106 -33
  174. package/{frontend/src/lib/analysis/case-report.js → packages/cases/case-report.mjs} +143 -16
  175. package/packages/cases/case-response-model.mjs +1604 -0
  176. package/packages/cases/case-response-packet.mjs +1312 -0
  177. package/{frontend/src/lib/analysis/case-storage-model.js → packages/cases/case-storage-model.mjs} +2 -2
  178. package/{frontend/src/lib/analysis/http-summary.js → packages/cases/http-summary.mjs} +1 -1
  179. package/packages/cases/opaque-reference-id.mjs +9 -0
  180. package/packages/comparison/comparison-ledger-bulk.mjs +366 -0
  181. package/packages/comparison/comparison-ledger-contract.mjs +241 -0
  182. package/packages/comparison/comparison-ledger-json.mjs +80 -0
  183. package/packages/comparison/comparison-ledger-serialization.mjs +52 -0
  184. package/packages/comparison/favicon-similarity.mjs +78 -0
  185. package/{frontend/src/lib/analysis/page-similarity.js → packages/comparison/page-similarity.mjs} +4 -3
  186. package/{frontend/src/lib/analysis/relationship-evidence.js → packages/comparison/relationship-evidence.mjs} +6 -7
  187. package/packages/contracts/analyst-review-state-contract.mjs +61 -0
  188. package/packages/contracts/analyst-review-state.mjs +50 -0
  189. package/packages/contracts/case-portability.mjs +1310 -0
  190. package/packages/contracts/cli-command-catalogue.mjs +2 -0
  191. package/packages/contracts/cli-lookup.mjs +394 -0
  192. package/packages/contracts/domain-control-flight-recorder.mjs +461 -0
  193. package/packages/contracts/domain-control-manifest.mjs +1027 -0
  194. package/packages/contracts/domain-control-monitor.mjs +310 -0
  195. package/packages/contracts/domain-control-review.mjs +828 -0
  196. package/packages/contracts/domain-name.mjs +4 -0
  197. package/packages/contracts/external-observation-interchange.mjs +224 -0
  198. package/packages/contracts/extracted-domain-lifecycle.mjs +218 -0
  199. package/packages/contracts/investigation-portability.mjs +331 -0
  200. package/packages/contracts/offline-comparison.mjs +160 -0
  201. package/packages/contracts/risk-calibration.mjs +1288 -0
  202. package/packages/contracts/schema-compatibility.mjs +71 -0
  203. package/packages/contracts/schema-lifecycle.mjs +1702 -0
  204. package/packages/contracts/sslbl-snapshot.mjs +17 -0
  205. package/packages/contracts/workspace-portability.mjs +1347 -0
  206. package/packages/evidence/artifact-integrity.mjs +65 -0
  207. package/packages/evidence/decision-fact.mjs +735 -0
  208. package/packages/evidence/domain-control-runtime.mjs +547 -0
  209. package/packages/evidence/domain-name.mjs +41 -0
  210. package/packages/evidence/observation.mjs +384 -0
  211. package/{frontend/src/lib/analysis/external-findings-import.js → packages/interchange/external-findings-import.mjs} +86 -20
  212. package/packages/interchange/retained-text.mjs +8 -0
  213. package/{frontend/src/lib/analysis/acquisition-decision-packet.js → packages/investigation/acquisition-decision-packet.mjs} +11 -8
  214. package/{frontend/src/lib/analysis/bulk-domain-comparison.js → packages/investigation/bulk-domain-comparison.mjs} +28 -9
  215. package/{frontend/src/lib/analysis/bulk-mail-exposure.js → packages/investigation/bulk-mail-exposure.mjs} +67 -18
  216. package/{frontend/src/lib/analysis/bulk-review-export.js → packages/investigation/bulk-review-export.mjs} +10 -9
  217. package/packages/investigation/bulk-review-policy.mjs +1 -0
  218. package/{frontend/src/lib/analysis/investigation-capsule.js → packages/investigation/investigation-capsule.mjs} +50 -18
  219. package/packages/investigation/lookup-artefact-inputs.mjs +1 -0
  220. package/{frontend/src/lib/analysis/lookup-asset-graph.js → packages/investigation/lookup-asset-graph.mjs} +4 -2
  221. package/packages/investigation/lookup-claim-passport.mjs +232 -0
  222. package/packages/investigation/lookup-claim-readiness.mjs +287 -0
  223. package/packages/investigation/lookup-investigation-brief.mjs +172 -0
  224. package/packages/monitoring/analyst-review-state.mjs +680 -0
  225. package/{frontend/src/lib/analysis/brand-profile-model.js → packages/workspace/brand-profile-model.mjs} +97 -50
  226. package/{frontend/src/lib/analysis/bulk-review-model.js → packages/workspace/bulk-review-model.mjs} +15 -15
  227. package/{frontend/src/lib/analysis/bulk-session-model.js → packages/workspace/bulk-session-model.mjs} +179 -39
  228. package/{frontend/src/lib/analysis/bulk-sort.js → packages/workspace/bulk-sort.mjs} +12 -5
  229. package/{frontend/src/lib/analysis/campaign-model.js → packages/workspace/campaign-model.mjs} +20 -22
  230. package/{frontend/src/lib/analysis/detection-rule-model.js → packages/workspace/detection-rule-model.mjs} +15 -17
  231. package/packages/workspace/hostile-input.mjs +172 -0
  232. package/{frontend/src/lib/analysis/investigation-guide.js → packages/workspace/investigation-guide.mjs} +51 -46
  233. package/{frontend/src/lib/analysis/investigation-template-model.js → packages/workspace/investigation-template-model.mjs} +15 -15
  234. package/{frontend/src/lib/analysis/page-baseline.js → packages/workspace/page-baseline.mjs} +6 -13
  235. package/{frontend/src/lib/analysis/relationship-observation-model.js → packages/workspace/relationship-observation-model.mjs} +13 -17
  236. package/{frontend/src/lib/analysis/shortlist-model.js → packages/workspace/shortlist-model.mjs} +20 -18
  237. package/{frontend/src/lib/analysis/watchlist-history.js → packages/workspace/watchlist-history.mjs} +9 -16
  238. package/{frontend/src/lib/analysis/watchlist-store.js → packages/workspace/watchlist-store.mjs} +24 -17
  239. package/{frontend/src/lib/analysis/website-snapshot-model.js → packages/workspace/website-snapshot-model.mjs} +18 -12
  240. package/{frontend/src/lib/analysis/workspace-archive-crypto.js → packages/workspace/workspace-archive-crypto.mjs} +49 -19
  241. package/{frontend/src/lib/analysis/workspace-archive.js → packages/workspace/workspace-archive.mjs} +195 -84
  242. package/third-party-notices.txt +112 -5834
  243. package/frontend/src/lib/analysis/artifact-integrity.js +0 -21
  244. package/frontend/src/lib/analysis/bulk-retry-plan.js +0 -79
  245. package/frontend/src/lib/analysis/bulk-source-coverage.js +0 -76
  246. package/frontend/src/lib/analysis/case-migration-model.js +0 -253
  247. package/frontend/src/lib/analysis/case-record-model.js +0 -7
  248. package/frontend/src/lib/analysis/case-response-model.js +0 -669
  249. package/frontend/src/lib/analysis/case-response-packet.js +0 -573
  250. package/frontend/src/lib/analysis/lookup-decision-support.js +0 -487
  251. package/frontend/src/lib/analysis/lookup-investigation-brief.js +0 -153
  252. package/frontend/src/lib/analysis/lookup-presentation.js +0 -58
  253. package/frontend/src/lib/analysis/lookup-response.js +0 -2
  254. package/frontend/src/lib/analysis/lookup-source-refresh.js +0 -277
  255. package/frontend/src/lib/analysis/lookup-summary-model.js +0 -398
  256. package/frontend/src/lib/analysis/scoring.js +0 -55
  257. package/frontend/src/lib/analysis/utils.js +0 -232
  258. package/frontend/src/lib/analysis/visualization-bounds.js +0 -26
  259. package/frontend/src/lib/analysis/visualization-force-graph.js +0 -352
  260. package/frontend/src/lib/analysis/visualization-matrix.js +0 -88
  261. package/frontend/src/lib/analysis/visualization-models.js +0 -369
  262. package/frontend/src/lib/analysis/visualization-time-series.js +0 -144
  263. package/lib/bounded-json-response.mjs +0 -157
  264. package/lib/lookup-response-contract.mjs +0 -346
  265. package/lib/observation.mjs +0 -114
  266. /package/{frontend/src/lib/analysis/acquisition-due-diligence.js → packages/investigation/acquisition-due-diligence.mjs} +0 -0
  267. /package/{frontend/src/lib/analysis/evidence-coverage-ledger.js → packages/investigation/evidence-coverage-ledger.mjs} +0 -0
  268. /package/{frontend/src/lib/analysis/dns-record-normalization.js → packages/workspace/dns-record-normalization.mjs} +0 -0
@@ -0,0 +1,4 @@
1
+ // Dependency-neutral DNS name bounds shared by wire contracts and pure
2
+ // normalisers. These are canonical A-label limits, not raw-input allowances.
3
+ export const MAX_DOMAIN_NAME_LENGTH = 253;
4
+ export const MAX_DOMAIN_LABEL_LENGTH = 63;
@@ -0,0 +1,224 @@
1
+ import { defineSchemaCompatibility } from "./schema-compatibility.mjs";
2
+ import { defineSchemaLifecycleFamily } from "./schema-lifecycle.mjs";
3
+ export const EXTERNAL_OBSERVATION_INTERCHANGE_CONTRACT_OWNER = 'packages/contracts/external-observation-interchange.mts';
4
+ export const EXTERNAL_FINDINGS_SCHEMA = 'whoisleuth.external-findings';
5
+ export const EXTERNAL_FINDINGS_VERSION = 4;
6
+ export const SUPPORTED_EXTERNAL_FINDINGS_VERSIONS = Object.freeze([EXTERNAL_FINDINGS_VERSION]);
7
+ export const MAX_EXTERNAL_FINDINGS_IMPORT_BYTES = 384 * 1024;
8
+ export const MAX_EXTERNAL_FINDINGS = 100;
9
+ export const MAX_EXTERNAL_FINDINGS_PER_DOMAIN = 20;
10
+ export const MAX_EXTERNAL_FINDING_DOMAINS = 25;
11
+ export const EXTERNAL_FINDING_ROWS_SCHEMA = 'whoisleuth.external-finding-rows';
12
+ export const EXTERNAL_FINDING_ROWS_VERSION = 1;
13
+ export const DOMAIN_OBSERVATION_ROWS_SCHEMA = 'whoisleuth.domain-observation-rows';
14
+ export const DNS_OBSERVATION_ROWS_SCHEMA = 'whoisleuth.dns-observation-rows';
15
+ export const CERTIFICATE_OBSERVATION_ROWS_SCHEMA = 'whoisleuth.certificate-observation-rows';
16
+ export const SUPPORTED_OBSERVATION_ROWS_VERSION = 1;
17
+ export const MAX_CONVERSION_INPUT_ROWS = MAX_EXTERNAL_FINDINGS * 4;
18
+ export const EXTERNAL_OBSERVATION_INTERCHANGE_COMPATIBILITY_FACADES = Object.freeze([
19
+ ['frontend/src/lib/analysis/external-findings-import.ts', 'packages/interchange/external-findings-import.mts'],
20
+ ['frontend/src/lib/analysis/external-findings-converters.ts', 'packages/interchange/external-findings-converters.mts'],
21
+ ]);
22
+ export const EXTERNAL_FINDINGS_COMPATIBILITY = defineSchemaCompatibility({
23
+ id: 'export.external-findings', kind: 'export', schema: EXTERNAL_FINDINGS_SCHEMA,
24
+ currentVersion: EXTERNAL_FINDINGS_VERSION, supportedVersions: SUPPORTED_EXTERNAL_FINDINGS_VERSIONS,
25
+ acceptsUnversionedLegacy: false, futureVersionBehavior: 'reject', migration: 'exact_current_only', writeSemantics: 'non_destructive_merge',
26
+ byteBudget: MAX_EXTERNAL_FINDINGS_IMPORT_BYTES, owner: EXTERNAL_OBSERVATION_INTERCHANGE_CONTRACT_OWNER,
27
+ note: 'Strict local findings import. Version 4 can retain bounded certificate event identity and name-completeness metadata while analyst assertions remain a separate case workflow.',
28
+ });
29
+ export const EXTERNAL_FINDING_ROWS_COMPATIBILITY = defineSchemaCompatibility({
30
+ id: 'import.external-finding-rows', kind: 'export', schema: EXTERNAL_FINDING_ROWS_SCHEMA,
31
+ currentVersion: EXTERNAL_FINDING_ROWS_VERSION, supportedVersions: [EXTERNAL_FINDING_ROWS_VERSION],
32
+ acceptsUnversionedLegacy: true, futureVersionBehavior: 'reject', migration: 'normalize_to_current', writeSemantics: 'non_destructive_merge',
33
+ byteBudget: MAX_EXTERNAL_FINDINGS_IMPORT_BYTES, owner: EXTERNAL_OBSERVATION_INTERCHANGE_CONTRACT_OWNER,
34
+ note: 'Bounded fixed-column JSON rows converted through the strict findings parser.',
35
+ });
36
+ export const DOMAIN_OBSERVATION_ROWS_COMPATIBILITY = defineSchemaCompatibility({
37
+ id: 'import.domain-observation-rows', kind: 'export', schema: DOMAIN_OBSERVATION_ROWS_SCHEMA,
38
+ currentVersion: SUPPORTED_OBSERVATION_ROWS_VERSION, supportedVersions: [SUPPORTED_OBSERVATION_ROWS_VERSION],
39
+ acceptsUnversionedLegacy: false, futureVersionBehavior: 'reject', migration: 'normalize_to_current', writeSemantics: 'non_destructive_merge',
40
+ byteBudget: MAX_EXTERNAL_FINDINGS_IMPORT_BYTES, owner: EXTERNAL_OBSERVATION_INTERCHANGE_CONTRACT_OWNER,
41
+ note: 'Typed external domain-state observations retained with source-qualified provenance.',
42
+ });
43
+ export const DNS_OBSERVATION_ROWS_COMPATIBILITY = defineSchemaCompatibility({
44
+ id: 'import.dns-observation-rows', kind: 'export', schema: DNS_OBSERVATION_ROWS_SCHEMA,
45
+ currentVersion: SUPPORTED_OBSERVATION_ROWS_VERSION, supportedVersions: [SUPPORTED_OBSERVATION_ROWS_VERSION],
46
+ acceptsUnversionedLegacy: false, futureVersionBehavior: 'reject', migration: 'normalize_to_current', writeSemantics: 'non_destructive_merge',
47
+ byteBudget: MAX_EXTERNAL_FINDINGS_IMPORT_BYTES, owner: EXTERNAL_OBSERVATION_INTERCHANGE_CONTRACT_OWNER,
48
+ note: 'Typed external DNS observations; only valid relational values project graph edges.',
49
+ });
50
+ export const CERTIFICATE_OBSERVATION_ROWS_COMPATIBILITY = defineSchemaCompatibility({
51
+ id: 'import.certificate-observation-rows', kind: 'export', schema: CERTIFICATE_OBSERVATION_ROWS_SCHEMA,
52
+ currentVersion: SUPPORTED_OBSERVATION_ROWS_VERSION, supportedVersions: [SUPPORTED_OBSERVATION_ROWS_VERSION],
53
+ acceptsUnversionedLegacy: false, futureVersionBehavior: 'reject', migration: 'normalize_to_current', writeSemantics: 'non_destructive_merge',
54
+ byteBudget: MAX_EXTERNAL_FINDINGS_IMPORT_BYTES, owner: EXTERNAL_OBSERVATION_INTERCHANGE_CONTRACT_OWNER,
55
+ note: 'Typed external certificate observations requiring an exact SHA-256 fingerprint.',
56
+ });
57
+ export const EXTERNAL_OBSERVATION_INTERCHANGE_COMPATIBILITY = Object.freeze([
58
+ EXTERNAL_FINDINGS_COMPATIBILITY,
59
+ EXTERNAL_FINDING_ROWS_COMPATIBILITY,
60
+ DOMAIN_OBSERVATION_ROWS_COMPATIBILITY,
61
+ DNS_OBSERVATION_ROWS_COMPATIBILITY,
62
+ CERTIFICATE_OBSERVATION_ROWS_COMPATIBILITY,
63
+ ]);
64
+ const EXTERNAL_INTERCHANGE_FIXTURES = Object.freeze([
65
+ { id: 'external-findings-v4', path: 'test/fixtures/external-observation-interchange/external-findings-v4.json', bytes: 634, sha256: 'ceab916e1dcf99704c94e1b0cd82f5a061f138ae6a07ce8335273080c73b7624', schema: EXTERNAL_FINDINGS_SCHEMA, version: 4, role: 'current', expectation: 'accepted_exact', expectedOutputFixtureId: null },
66
+ { id: 'external-finding-rows-v1', path: 'test/fixtures/external-observation-interchange/external-finding-rows-v1.json', bytes: 435, sha256: '09048325d801fdc837134580fd887cacde28744c9f87a43afc388c96117a4659', schema: EXTERNAL_FINDING_ROWS_SCHEMA, version: 1, role: 'input', expectation: 'normalises_to_current_output', expectedOutputFixtureId: 'external-finding-rows-v1-output' },
67
+ { id: 'external-finding-rows-v1-output', path: 'test/fixtures/external-observation-interchange/external-finding-rows-v1-output.json', bytes: 581, sha256: '7f84a9f6177d3245acd6fc21275276694fbe9e8cd94922b1e6997a73afa3149a', schema: EXTERNAL_FINDINGS_SCHEMA, version: 4, role: 'current', expectation: 'accepted_exact', expectedOutputFixtureId: null },
68
+ { id: 'domain-observation-rows-v1', path: 'test/fixtures/external-observation-interchange/domain-observation-rows-v1.json', bytes: 390, sha256: '2f95ab21e57e1a6aaab03cea75a4d58fd9e1234ba87f5268a899b23103359474', schema: DOMAIN_OBSERVATION_ROWS_SCHEMA, version: 1, role: 'input', expectation: 'normalises_to_current_output', expectedOutputFixtureId: 'domain-observation-rows-v1-output' },
69
+ { id: 'domain-observation-rows-v1-output', path: 'test/fixtures/external-observation-interchange/domain-observation-rows-v1-output.json', bytes: 1_027, sha256: 'bba949308e9bb5b58bf5611d6dec23f074979522627631948cffc2f0056ac817', schema: EXTERNAL_FINDINGS_SCHEMA, version: 4, role: 'current', expectation: 'accepted_exact', expectedOutputFixtureId: null },
70
+ { id: 'dns-observation-rows-v1', path: 'test/fixtures/external-observation-interchange/dns-observation-rows-v1.json', bytes: 369, sha256: 'afb1808a8a81339a1801d337259c19c77ed957583b4ae06579b38ea6a8f68ed1', schema: DNS_OBSERVATION_ROWS_SCHEMA, version: 1, role: 'input', expectation: 'normalises_to_current_output', expectedOutputFixtureId: 'dns-observation-rows-v1-output' },
71
+ { id: 'dns-observation-rows-v1-output', path: 'test/fixtures/external-observation-interchange/dns-observation-rows-v1-output.json', bytes: 988, sha256: '4c9a49b96181d2907eb95319d15975758823994fe029c051486f1cb6869221a0', schema: EXTERNAL_FINDINGS_SCHEMA, version: 4, role: 'current', expectation: 'accepted_exact', expectedOutputFixtureId: null },
72
+ { id: 'certificate-observation-rows-v1', path: 'test/fixtures/external-observation-interchange/certificate-observation-rows-v1.json', bytes: 515, sha256: '68363a5fe074b08a386dbc95a0993a2933ebcf05ba2f96148df632842d1c5869', schema: CERTIFICATE_OBSERVATION_ROWS_SCHEMA, version: 1, role: 'input', expectation: 'normalises_to_current_output', expectedOutputFixtureId: 'certificate-observation-rows-v1-output' },
73
+ { id: 'certificate-observation-rows-v1-output', path: 'test/fixtures/external-observation-interchange/certificate-observation-rows-v1-output.json', bytes: 1_244, sha256: '6c484601b872f10bfdb7d9519d4b216f14ef277e7a429e4cc131154ad0e07652', schema: EXTERNAL_FINDINGS_SCHEMA, version: 4, role: 'current', expectation: 'accepted_exact', expectedOutputFixtureId: null },
74
+ ].map((fixture) => Object.freeze({
75
+ ...fixture,
76
+ contentDigestSha256: null,
77
+ scope: 'repository',
78
+ })));
79
+ function externalFixtureIds(schema, version) {
80
+ return Object.freeze(EXTERNAL_INTERCHANGE_FIXTURES
81
+ .filter((fixture) => fixture.schema === schema && fixture.version === version)
82
+ .map((fixture) => fixture.id));
83
+ }
84
+ const EXTERNAL_INTERCHANGE_CONTRACTS = Object.freeze([
85
+ ...SUPPORTED_EXTERNAL_FINDINGS_VERSIONS.map((version) => Object.freeze({
86
+ compatibilityId: EXTERNAL_FINDINGS_COMPATIBILITY.id,
87
+ schema: EXTERNAL_FINDINGS_SCHEMA,
88
+ version,
89
+ role: 'document',
90
+ lifecycle: version === EXTERNAL_FINDINGS_VERSION ? 'current' : 'legacy',
91
+ readable: true,
92
+ emitted: version === EXTERNAL_FINDINGS_VERSION,
93
+ exactKeys: true,
94
+ extensionPolicy: 'reject',
95
+ futureVersionBehaviour: 'reject',
96
+ migrationTarget: version === EXTERNAL_FINDINGS_VERSION ? null : { schema: EXTERNAL_FINDINGS_SCHEMA, version: EXTERNAL_FINDINGS_VERSION },
97
+ canonicalisation: null,
98
+ byteBudget: MAX_EXTERNAL_FINDINGS_IMPORT_BYTES,
99
+ fixtureIds: externalFixtureIds(EXTERNAL_FINDINGS_SCHEMA, version),
100
+ })),
101
+ ...[
102
+ [EXTERNAL_FINDING_ROWS_COMPATIBILITY.id, EXTERNAL_FINDING_ROWS_SCHEMA],
103
+ [DOMAIN_OBSERVATION_ROWS_COMPATIBILITY.id, DOMAIN_OBSERVATION_ROWS_SCHEMA],
104
+ [DNS_OBSERVATION_ROWS_COMPATIBILITY.id, DNS_OBSERVATION_ROWS_SCHEMA],
105
+ [CERTIFICATE_OBSERVATION_ROWS_COMPATIBILITY.id, CERTIFICATE_OBSERVATION_ROWS_SCHEMA],
106
+ ].map(([compatibilityId, schema]) => Object.freeze({
107
+ compatibilityId,
108
+ schema,
109
+ version: 1,
110
+ role: 'input',
111
+ lifecycle: 'current',
112
+ readable: true,
113
+ emitted: false,
114
+ exactKeys: true,
115
+ extensionPolicy: 'reject',
116
+ futureVersionBehaviour: 'reject',
117
+ migrationTarget: { schema: EXTERNAL_FINDINGS_SCHEMA, version: EXTERNAL_FINDINGS_VERSION },
118
+ canonicalisation: null,
119
+ byteBudget: MAX_EXTERNAL_FINDINGS_IMPORT_BYTES,
120
+ fixtureIds: externalFixtureIds(schema, 1),
121
+ })),
122
+ ]);
123
+ function externalShape(id, schema, versions, requiredKeys, normalisation) {
124
+ return Object.freeze({
125
+ id,
126
+ schema,
127
+ versions,
128
+ objects: [{ path: '$', requiredKeys, optionalKeys: [], unknownKeys: 'reject' }],
129
+ fixedArrays: [],
130
+ normalisation,
131
+ target: normalisation === 'input_to_current'
132
+ ? { schema: EXTERNAL_FINDINGS_SCHEMA, version: EXTERNAL_FINDINGS_VERSION }
133
+ : null,
134
+ });
135
+ }
136
+ const externalConsumerCommon = Object.freeze({
137
+ expiryPolicyId: 'external-interchange.expiry.not-applicable',
138
+ requestMode: 'none',
139
+ bindingState: 'declared_unenforced',
140
+ policyState: 'current',
141
+ });
142
+ export const EXTERNAL_OBSERVATION_INTERCHANGE_LIFECYCLE_FAMILY = defineSchemaLifecycleFamily({
143
+ id: 'external-observation-interchange',
144
+ owner: EXTERNAL_OBSERVATION_INTERCHANGE_CONTRACT_OWNER,
145
+ privacy: 'analyst_authored_sensitive',
146
+ compatibility: EXTERNAL_OBSERVATION_INTERCHANGE_COMPATIBILITY,
147
+ contracts: EXTERNAL_INTERCHANGE_CONTRACTS,
148
+ fixtures: EXTERNAL_INTERCHANGE_FIXTURES,
149
+ metadata: {
150
+ metadataVersion: 3,
151
+ enforcement: 'declarative_only',
152
+ shapes: [
153
+ externalShape('external-interchange.findings.v4', EXTERNAL_FINDINGS_SCHEMA, [...SUPPORTED_EXTERNAL_FINDINGS_VERSIONS], ['schema', 'schemaVersion', 'source', 'findings'], 'preserve_document'),
154
+ externalShape('external-interchange.finding-rows.v1', EXTERNAL_FINDING_ROWS_SCHEMA, [1], ['schema', 'schemaVersion', 'source', 'rows'], 'input_to_current'),
155
+ externalShape('external-interchange.domain-rows.v1', DOMAIN_OBSERVATION_ROWS_SCHEMA, [1], ['schema', 'schemaVersion', 'source', 'observations'], 'input_to_current'),
156
+ externalShape('external-interchange.dns-rows.v1', DNS_OBSERVATION_ROWS_SCHEMA, [1], ['schema', 'schemaVersion', 'source', 'observations'], 'input_to_current'),
157
+ externalShape('external-interchange.certificate-rows.v1', CERTIFICATE_OBSERVATION_ROWS_SCHEMA, [1], ['schema', 'schemaVersion', 'source', 'observations'], 'input_to_current'),
158
+ ],
159
+ boundProfiles: [{ id: 'external-interchange.document.bounds', bounds: [
160
+ { id: 'raw-bytes', path: '$', phase: 'raw_intake', unit: 'bytes', minimum: 1, maximum: MAX_EXTERNAL_FINDINGS_IMPORT_BYTES, handling: 'reject' },
161
+ { id: 'serialised-bytes', path: '$', phase: 'serialised', unit: 'bytes', minimum: 1, maximum: MAX_EXTERNAL_FINDINGS_IMPORT_BYTES, handling: 'reject' },
162
+ { id: 'rows', path: '$', phase: 'pre_accumulation', unit: 'items', minimum: 1, maximum: MAX_CONVERSION_INPUT_ROWS, handling: 'reject' },
163
+ ] }],
164
+ hooks: [
165
+ { id: 'external-interchange.findings.normalise', role: 'normaliser', runtime: 'shared', module: 'packages/interchange/external-findings-import.mts', exportName: 'parseExternalFindingsDocument' },
166
+ { id: 'external-interchange.findings.serialise', role: 'serialiser', runtime: 'shared', module: 'packages/interchange/external-findings-import.mts', exportName: 'serializeExternalFindingsDocument' },
167
+ { id: 'external-interchange.finding-rows.convert', role: 'normaliser', runtime: 'shared', module: 'packages/interchange/external-findings-converters.mts', exportName: 'convertExternalFindingRows' },
168
+ { id: 'external-interchange.observation-rows.convert', role: 'normaliser', runtime: 'shared', module: 'packages/interchange/external-findings-converters.mts', exportName: 'convertSupportedExternalFindings' },
169
+ { id: 'external-interchange.findings.merge', role: 'merger', runtime: 'shared', module: 'packages/interchange/external-findings-import.mts', exportName: 'mergeExternalFindingsIntoCases' },
170
+ ],
171
+ serialisationProfiles: [{
172
+ id: 'external-interchange.findings.json.v4', schema: EXTERNAL_FINDINGS_SCHEMA,
173
+ versions: [...SUPPORTED_EXTERNAL_FINDINGS_VERSIONS], mediaType: 'application/json', encoding: 'utf-8', bom: false,
174
+ indentSpaces: 2, terminalLf: true, propertyOrder: 'normalised_fixed', canonicalisation: null, integrity: 'none',
175
+ serializerHookId: 'external-interchange.findings.serialise', verifierHookIds: [],
176
+ }],
177
+ privacyProfiles: [
178
+ { id: 'external-interchange.privacy.transient', classification: 'analyst_authored_sensitive', projection: 'browser_import', includedCategories: ['source-attribution', 'bounded-observations', 'completeness', 'limitations'], excludedCategories: ['raw-upstream-payloads', 'expanded-contacts', 'credentials', 'cookies', 'query-bearing-urls'], notePolicy: 'discarded', retention: 'transient_report', network: 'none', sharingReview: 'required' },
179
+ { id: 'external-interchange.privacy.case-merge', classification: 'analyst_authored_sensitive', projection: 'browser_import', includedCategories: ['source-attribution', 'bounded-observations', 'completeness', 'limitations'], excludedCategories: ['raw-upstream-payloads', 'expanded-contacts', 'credentials', 'cookies', 'query-bearing-urls'], notePolicy: 'discarded', retention: 'browser_indexeddb', network: 'none', sharingReview: 'not_applicable' },
180
+ ],
181
+ expiryProfiles: [{ id: 'external-interchange.expiry.not-applicable', field: null, anchor: null, handling: 'not_applicable', phase: 'not_applicable', maximumLifetimeDays: null }],
182
+ consumerEdges: [
183
+ {
184
+ id: 'external-interchange.consumer.findings-normalise', plane: 'shared', operation: 'normalise-strict-findings',
185
+ acceptedContracts: [{ schema: EXTERNAL_FINDINGS_SCHEMA, versions: [...SUPPORTED_EXTERNAL_FINDINGS_VERSIONS], mode: 'direct' }],
186
+ emittedContract: { schema: EXTERNAL_FINDINGS_SCHEMA, version: EXTERNAL_FINDINGS_VERSION },
187
+ shapeIds: ['external-interchange.findings.v4'], boundProfileIds: ['external-interchange.document.bounds'],
188
+ hookIds: ['external-interchange.findings.normalise', 'external-interchange.findings.serialise'],
189
+ serialisationProfileId: 'external-interchange.findings.json.v4', privacyProfileId: 'external-interchange.privacy.transient',
190
+ retentionEffect: 'transient_report', ...externalConsumerCommon,
191
+ },
192
+ {
193
+ id: 'external-interchange.consumer.finding-rows', plane: 'shared', operation: 'convert-finding-rows',
194
+ acceptedContracts: [{ schema: EXTERNAL_FINDING_ROWS_SCHEMA, versions: [1], mode: 'direct' }],
195
+ emittedContract: { schema: EXTERNAL_FINDINGS_SCHEMA, version: EXTERNAL_FINDINGS_VERSION },
196
+ shapeIds: ['external-interchange.finding-rows.v1', 'external-interchange.findings.v4'], boundProfileIds: ['external-interchange.document.bounds'],
197
+ hookIds: ['external-interchange.finding-rows.convert', 'external-interchange.findings.serialise'],
198
+ serialisationProfileId: 'external-interchange.findings.json.v4', privacyProfileId: 'external-interchange.privacy.transient',
199
+ retentionEffect: 'transient_report', ...externalConsumerCommon,
200
+ },
201
+ {
202
+ id: 'external-interchange.consumer.observation-rows', plane: 'shared', operation: 'convert-observation-rows',
203
+ acceptedContracts: [
204
+ { schema: DOMAIN_OBSERVATION_ROWS_SCHEMA, versions: [1], mode: 'direct' },
205
+ { schema: DNS_OBSERVATION_ROWS_SCHEMA, versions: [1], mode: 'direct' },
206
+ { schema: CERTIFICATE_OBSERVATION_ROWS_SCHEMA, versions: [1], mode: 'direct' },
207
+ ],
208
+ emittedContract: { schema: EXTERNAL_FINDINGS_SCHEMA, version: EXTERNAL_FINDINGS_VERSION },
209
+ shapeIds: ['external-interchange.domain-rows.v1', 'external-interchange.dns-rows.v1', 'external-interchange.certificate-rows.v1', 'external-interchange.findings.v4'],
210
+ boundProfileIds: ['external-interchange.document.bounds'], hookIds: ['external-interchange.observation-rows.convert', 'external-interchange.findings.serialise'],
211
+ serialisationProfileId: 'external-interchange.findings.json.v4', privacyProfileId: 'external-interchange.privacy.transient',
212
+ retentionEffect: 'transient_report', ...externalConsumerCommon,
213
+ },
214
+ {
215
+ id: 'external-interchange.consumer.case-merge', plane: 'shared', operation: 'non-destructive-case-merge',
216
+ acceptedContracts: [{ schema: EXTERNAL_FINDINGS_SCHEMA, versions: [EXTERNAL_FINDINGS_VERSION], mode: 'direct' }], emittedContract: null,
217
+ shapeIds: ['external-interchange.findings.v4'], boundProfileIds: ['external-interchange.document.bounds'],
218
+ hookIds: ['external-interchange.findings.merge'], serialisationProfileId: null,
219
+ privacyProfileId: 'external-interchange.privacy.case-merge', retentionEffect: 'browser_indexeddb', ...externalConsumerCommon,
220
+ },
221
+ ],
222
+ consumerRelationships: [],
223
+ },
224
+ });
@@ -0,0 +1,218 @@
1
+ function formatSlug(id) {
2
+ return id.replaceAll('.', '-');
3
+ }
4
+ function lifecycleShapeId(format, version, v4) {
5
+ return v4
6
+ ? `${formatSlug(format.descriptor.id)}.v${version}`
7
+ : `${formatSlug(format.descriptor.id)}.document`;
8
+ }
9
+ function contractState(format, version) {
10
+ const current = version === format.descriptor.currentVersion;
11
+ const outputOnly = format.descriptor.futureVersionBehavior === 'not_applicable';
12
+ return {
13
+ lifecycle: current ? 'current' : outputOnly ? 'retired' : 'legacy',
14
+ readable: !outputOnly,
15
+ emitted: current,
16
+ futureVersionBehaviour: outputOnly
17
+ ? 'not_applicable'
18
+ : format.descriptor.futureVersionBehavior,
19
+ migrationTarget: !current && format.descriptor.migration === 'normalize_to_current'
20
+ ? { schema: format.lifecycleSchema, version: format.descriptor.currentVersion }
21
+ : null,
22
+ };
23
+ }
24
+ function fixtureRecord(format, fixture, v4) {
25
+ const state = contractState(format, fixture.version);
26
+ const output = format.fixtures.find((candidate) => candidate.version === format.descriptor.currentVersion);
27
+ return {
28
+ ...fixture,
29
+ contentDigestSha256: null,
30
+ schema: format.lifecycleSchema,
31
+ role: state.lifecycle === 'current' ? 'current' : 'historical',
32
+ expectation: state.lifecycle === 'retired'
33
+ ? 'historical_output_exact'
34
+ : state.lifecycle === 'legacy' && format.descriptor.migration === 'normalize_to_current'
35
+ ? 'normalises_to_current_output'
36
+ : 'accepted_exact',
37
+ expectedOutputFixtureId: state.lifecycle === 'legacy' && format.descriptor.migration === 'normalize_to_current'
38
+ ? output?.id ?? null
39
+ : null,
40
+ scope: 'repository',
41
+ ...(v4 ? { shapeId: lifecycleShapeId(format, fixture.version, true) } : {}),
42
+ };
43
+ }
44
+ function buildExtractedLifecycleFamily(options, metadataVersion) {
45
+ const v4 = metadataVersion === 4;
46
+ const fixtures = options.formats.flatMap((format) => format.fixtures.map((fixture) => (fixtureRecord(format, fixture, v4))));
47
+ const contracts = options.formats.flatMap((format) => format.descriptor.supportedVersions.map((version) => ({
48
+ compatibilityId: format.descriptor.id,
49
+ schema: format.lifecycleSchema,
50
+ version,
51
+ role: 'document',
52
+ ...contractState(format, version),
53
+ exactKeys: true,
54
+ extensionPolicy: 'reject',
55
+ canonicalisation: null,
56
+ byteBudget: format.descriptor.byteBudget,
57
+ fixtureIds: fixtures
58
+ .filter((fixture) => fixture.schema === format.lifecycleSchema && fixture.version === version)
59
+ .map((fixture) => fixture.id),
60
+ })));
61
+ const shapes = options.formats.flatMap((format) => (v4
62
+ ? format.descriptor.supportedVersions
63
+ : [format.descriptor.currentVersion]).map((version) => ({
64
+ id: lifecycleShapeId(format, version, v4),
65
+ schema: format.lifecycleSchema,
66
+ versions: v4 ? [version] : format.descriptor.supportedVersions,
67
+ objects: [{
68
+ path: '$',
69
+ requiredKeys: format.requiredKeys,
70
+ optionalKeys: format.optionalKeys,
71
+ ...(v4 ? { alternativeRequiredKeys: [] } : {}),
72
+ unknownKeys: 'reject',
73
+ }],
74
+ fixedArrays: [],
75
+ normalisation: 'preserve_document',
76
+ target: null,
77
+ ...(v4 ? { discriminator: null } : {}),
78
+ })));
79
+ const boundProfiles = options.formats.map((format) => ({
80
+ id: `${formatSlug(format.descriptor.id)}.bounds`,
81
+ bounds: format.descriptor.byteBudget === null
82
+ ? [{
83
+ id: 'aggregate-depth', path: '$', phase: 'pre_accumulation',
84
+ unit: 'depth', minimum: 0, maximum: 64, handling: 'reject',
85
+ }]
86
+ : [{
87
+ id: 'serialised-bytes', path: '$', phase: 'serialised',
88
+ unit: 'bytes', minimum: 1, maximum: format.descriptor.byteBudget,
89
+ handling: 'reject',
90
+ }],
91
+ }));
92
+ const serializerHookId = `${options.id}.serialise`;
93
+ const implementationHooks = new Map();
94
+ for (const format of options.formats) {
95
+ const key = `${format.hook.module}\u0000${format.hook.exportName}`;
96
+ if (!implementationHooks.has(key)) {
97
+ implementationHooks.set(key, {
98
+ id: `${options.id}.${formatSlug(format.descriptor.id)}.implementation`,
99
+ ...format.hook,
100
+ });
101
+ }
102
+ }
103
+ const hookIdFor = (format) => implementationHooks
104
+ .get(`${format.hook.module}\u0000${format.hook.exportName}`).id;
105
+ const hooks = [
106
+ ...implementationHooks.values(),
107
+ {
108
+ id: serializerHookId,
109
+ role: 'serialiser',
110
+ runtime: 'shared',
111
+ module: options.serializerModule ?? options.owner,
112
+ exportName: options.serializerExportName,
113
+ },
114
+ ];
115
+ const serialisedFormat = options.formats[0];
116
+ const serialisationProfileId = `${options.id}.json`;
117
+ const privacyProfileId = `${options.id}.privacy`;
118
+ const expiryPolicyId = `${options.id}.expiry`;
119
+ const consumerEdges = options.formats.map((format, index) => {
120
+ const outputOnly = format.descriptor.futureVersionBehavior === 'not_applicable';
121
+ const acceptedVersions = outputOnly ? [] : format.descriptor.supportedVersions;
122
+ const edgeVersions = outputOnly ? [format.descriptor.currentVersion] : format.descriptor.supportedVersions;
123
+ const shapeIds = v4
124
+ ? edgeVersions.map((version) => lifecycleShapeId(format, version, true))
125
+ : [lifecycleShapeId(format, format.descriptor.currentVersion, false)];
126
+ const hookId = hookIdFor(format);
127
+ const serialises = index === 0;
128
+ return {
129
+ id: `${options.id}.${formatSlug(format.descriptor.id)}.consumer`,
130
+ plane: options.plane,
131
+ operation: outputOnly ? 'produce-reviewed-output' : 'validate-and-produce',
132
+ acceptedContracts: acceptedVersions.length
133
+ ? [{
134
+ schema: format.lifecycleSchema,
135
+ versions: acceptedVersions,
136
+ mode: 'direct',
137
+ ...(metadataVersion >= 3 ? { discriminator: null } : {}),
138
+ }]
139
+ : [],
140
+ emittedContract: {
141
+ schema: format.lifecycleSchema,
142
+ version: format.descriptor.currentVersion,
143
+ ...(v4 ? { discriminator: null } : {}),
144
+ },
145
+ shapeIds,
146
+ boundProfileIds: [`${formatSlug(format.descriptor.id)}.bounds`],
147
+ hookIds: serialises ? [hookId, serializerHookId] : [hookId],
148
+ serialisationProfileId: serialises ? serialisationProfileId : null,
149
+ privacyProfileId,
150
+ expiryPolicyId,
151
+ requestMode: 'none',
152
+ retentionEffect: options.retention,
153
+ bindingState: 'declared_unenforced',
154
+ policyState: 'current',
155
+ };
156
+ });
157
+ const metadata = {
158
+ metadataVersion,
159
+ enforcement: 'declarative_only',
160
+ shapes,
161
+ boundProfiles,
162
+ hooks,
163
+ serialisationProfiles: [{
164
+ id: serialisationProfileId,
165
+ schema: serialisedFormat.lifecycleSchema,
166
+ versions: [serialisedFormat.descriptor.currentVersion],
167
+ mediaType: 'application/json',
168
+ encoding: 'utf-8',
169
+ bom: false,
170
+ indentSpaces: 2,
171
+ terminalLf: true,
172
+ propertyOrder: 'normalised_fixed',
173
+ canonicalisation: null,
174
+ integrity: 'none',
175
+ serializerHookId,
176
+ verifierHookIds: [],
177
+ }],
178
+ privacyProfiles: [{
179
+ id: privacyProfileId,
180
+ classification: 'analyst_authored_sensitive',
181
+ projection: options.projection,
182
+ includedCategories: options.includedCategories,
183
+ excludedCategories: options.excludedCategories,
184
+ notePolicy: 'discarded',
185
+ retention: options.retention,
186
+ network: 'none',
187
+ sharingReview: options.retention === 'operator_controlled_output' ? 'required' : 'not_applicable',
188
+ }],
189
+ expiryProfiles: [{
190
+ id: expiryPolicyId,
191
+ field: null,
192
+ anchor: null,
193
+ handling: 'not_applicable',
194
+ phase: 'not_applicable',
195
+ maximumLifetimeDays: null,
196
+ }],
197
+ consumerEdges,
198
+ consumerRelationships: [],
199
+ };
200
+ return {
201
+ id: options.id,
202
+ owner: options.owner,
203
+ privacy: 'analyst_authored_sensitive',
204
+ compatibility: options.formats.map((format) => format.descriptor),
205
+ contracts,
206
+ fixtures,
207
+ metadata,
208
+ };
209
+ }
210
+ export function buildExtractedLifecycleFamilyV2(options) {
211
+ return buildExtractedLifecycleFamily(options, 2);
212
+ }
213
+ export function buildExtractedLifecycleFamilyV3(options) {
214
+ return buildExtractedLifecycleFamily(options, 3);
215
+ }
216
+ export function buildExtractedLifecycleFamilyV4(options) {
217
+ return buildExtractedLifecycleFamily(options, 4);
218
+ }