@lapxo/bound 0.2.4 → 0.2.6

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 (333) hide show
  1. package/CITATION.cff +1 -1
  2. package/README.md +20 -3
  3. package/TARGET.bound +85 -47
  4. package/dist/cli/accept.js +61 -590
  5. package/dist/cli/act-result.js +3 -103
  6. package/dist/cli/args.js +3 -44
  7. package/dist/cli/custodian.js +2 -29
  8. package/dist/cli/host.js +4 -32
  9. package/dist/cli/names.js +1 -12
  10. package/dist/cli/native-descendant.js +1 -19
  11. package/dist/cli/native.js +3 -60
  12. package/dist/cli/observe.js +1 -13
  13. package/dist/cli/owner.js +3 -139
  14. package/dist/cli/pass.js +22 -321
  15. package/dist/cli/place.js +6 -282
  16. package/dist/cli/release-result.js +3 -80
  17. package/dist/cli/retained-judgment.js +1 -25
  18. package/dist/cli/standing-result.js +4 -19
  19. package/dist/cli/takes.js +10 -112
  20. package/dist/cli/verb.d.ts +1 -2
  21. package/dist/cli/verb.js +85 -684
  22. package/dist/engine/computation.js +2 -0
  23. package/dist/engine/conformance.js +4 -0
  24. package/dist/engine/encoding.js +1 -2
  25. package/dist/engine/index.d.ts +1 -13
  26. package/dist/engine/index.js +2 -11
  27. package/dist/engine/object.js +1 -38
  28. package/dist/engine/ports.js +2 -117
  29. package/dist/fold/admission-history.js +1 -17
  30. package/dist/fold/bootstrap-anchor.js +1 -28
  31. package/dist/fold/ceilings.js +1 -142
  32. package/dist/fold/claims.js +2 -132
  33. package/dist/fold/closed.js +24 -235
  34. package/dist/fold/configures.js +1 -25
  35. package/dist/fold/digests.js +10 -226
  36. package/dist/fold/evidence.js +1 -22
  37. package/dist/fold/fold-worker.js +1 -13
  38. package/dist/fold/kept.js +12 -173
  39. package/dist/fold/keys.js +3 -91
  40. package/dist/fold/laid.js +3 -90
  41. package/dist/fold/nos.js +1 -48
  42. package/dist/fold/object.js +1 -2
  43. package/dist/fold/observed.js +28 -534
  44. package/dist/fold/opened.js +1 -33
  45. package/dist/fold/own.js +3 -217
  46. package/dist/fold/paid.js +1 -92
  47. package/dist/fold/place-inputs.js +1 -70
  48. package/dist/fold/places.js +3 -100
  49. package/dist/fold/rank.js +1 -9
  50. package/dist/fold/reach.js +1 -83
  51. package/dist/fold/readers.js +6 -142
  52. package/dist/fold/receipts.js +1 -47
  53. package/dist/fold/region-declarations.js +1 -13
  54. package/dist/fold/region.js +8 -286
  55. package/dist/fold/release-policy.js +1 -101
  56. package/dist/fold/resolved.js +6 -145
  57. package/dist/fold/roles.js +2 -59
  58. package/dist/fold/second.js +4 -71
  59. package/dist/fold/shards.js +12 -100
  60. package/dist/fold/signed.js +3 -81
  61. package/dist/fold/signers.js +1 -54
  62. package/dist/fold/stranger.js +6 -24
  63. package/dist/fold/views.js +1 -66
  64. package/dist/fold/wire.js +1 -46
  65. package/dist/fold/zoom.js +3 -81
  66. package/dist/host/act-cost.js +1 -25
  67. package/dist/host/adapters/keys/ed25519.js +1 -30
  68. package/dist/host/adapters/modules/javascript.js +1 -50
  69. package/dist/host/adapters/transport/http.js +1 -28
  70. package/dist/host/admitted-place.js +1 -35
  71. package/dist/host/archive.js +1 -152
  72. package/dist/host/call-context.js +1 -14
  73. package/dist/host/capsule-process.js +2 -62
  74. package/dist/host/capsule.js +9 -171
  75. package/dist/host/cell-receipts.js +12 -128
  76. package/dist/host/command-server.js +4 -0
  77. package/dist/host/commit-result.js +1 -5
  78. package/dist/host/content-needed.js +1 -8
  79. package/dist/host/content-store.js +1 -31
  80. package/dist/host/contextual-place.js +2 -72
  81. package/dist/host/digest.js +2 -15
  82. package/dist/host/hash.js +1 -9
  83. package/dist/host/host-controls.js +1 -19
  84. package/dist/host/in-process-act.js +3 -84
  85. package/dist/host/in-process-context.js +3 -91
  86. package/dist/host/in-process-root.js +6 -84
  87. package/dist/host/in-process.js +4 -55
  88. package/dist/host/index.d.ts +1 -15
  89. package/dist/host/index.js +1 -7
  90. package/dist/host/io.js +1 -11
  91. package/dist/host/lifetime.js +1 -79
  92. package/dist/host/located.js +6 -105
  93. package/dist/host/native/authority-card-view.js +5 -0
  94. package/dist/host/native/authority-card.js +1 -0
  95. package/dist/host/native/bounded-file.js +1 -32
  96. package/dist/host/native/command.js +1 -91
  97. package/dist/host/native/control-bridge-worker.js +2 -88
  98. package/dist/host/native/control-bridge.js +1 -110
  99. package/dist/host/native/control-selection.js +1 -32
  100. package/dist/host/native/custody.js +1 -91
  101. package/dist/host/native/deadline.js +1 -28
  102. package/dist/host/native/descendants.js +1 -528
  103. package/dist/host/native/generated-custodian.js +5 -267
  104. package/dist/host/native/generated.js +1 -379
  105. package/dist/host/native/image.js +1 -45
  106. package/dist/host/native/installed-package.d.ts +1 -0
  107. package/dist/host/native/installed-package.js +5 -0
  108. package/dist/host/native/jobs.js +2 -148
  109. package/dist/host/native/loader.js +1 -269
  110. package/dist/host/native/materialize.js +1 -175
  111. package/dist/host/native/module-closure.js +1 -130
  112. package/dist/host/native/module-delivery.d.ts +1 -62
  113. package/dist/host/native/module-delivery.js +1 -151
  114. package/dist/host/native/module-inventory.js +2 -0
  115. package/dist/host/native/module-syntax.js +1 -69
  116. package/dist/host/native/native-binary.js +1 -115
  117. package/dist/host/native/native-program.js +1 -72
  118. package/dist/host/native/node-jobs.js +3 -187
  119. package/dist/host/native/node-launch.js +1 -159
  120. package/dist/host/native/preload.js +1 -45
  121. package/dist/host/native/probes.js +1 -0
  122. package/dist/host/native/reading-witness-admission.js +5 -0
  123. package/dist/host/native/reading.js +1 -249
  124. package/dist/host/native/receipt-environment.js +1 -41
  125. package/dist/host/native/references.js +1 -30
  126. package/dist/host/native/root.js +1 -37
  127. package/dist/host/native/route.js +1 -216
  128. package/dist/host/native/runtime.js +1 -9
  129. package/dist/host/native-place-state.js +1 -0
  130. package/dist/host/native-reader-context.js +1 -8
  131. package/dist/host/native-receiver.js +1 -25
  132. package/dist/host/objects.js +1 -38
  133. package/dist/host/order.js +1 -2
  134. package/dist/host/persistent-host.js +1 -0
  135. package/dist/host/physical-lines.d.ts +1 -0
  136. package/dist/host/physical-lines.js +1 -0
  137. package/dist/host/place-act-transaction.js +4 -78
  138. package/dist/host/place-clock-selection.js +5 -124
  139. package/dist/host/ports/ingress.js +2 -57
  140. package/dist/host/ports/local-act.js +5 -183
  141. package/dist/host/ports/place-act.js +1 -134
  142. package/dist/host/ports/publication.js +1 -56
  143. package/dist/host/ports/signing.js +1 -74
  144. package/dist/host/ports/store.js +1 -18
  145. package/dist/host/ports/transport.js +1 -48
  146. package/dist/host/process-lifetime.js +1 -17
  147. package/dist/host/profile-composition.d.ts +1 -0
  148. package/dist/host/profile-composition.js +2 -0
  149. package/dist/host/provide.js +1 -183
  150. package/dist/host/read-only.js +1 -9
  151. package/dist/host/reading-closures.js +7 -227
  152. package/dist/host/reading-context.js +1 -53
  153. package/dist/host/reading-identity-types.js +0 -0
  154. package/dist/host/reading-identity.js +3 -0
  155. package/dist/host/reading-preparation.js +6 -0
  156. package/dist/host/reference-authenticated.d.ts +1 -40
  157. package/dist/host/reference-authenticated.js +3 -100
  158. package/dist/host/reference-contracts.js +1 -6
  159. package/dist/host/reference-export.js +6 -81
  160. package/dist/host/reference-native-api.d.ts +1 -3
  161. package/dist/host/reference-native-api.js +1 -3
  162. package/dist/host/reference-native.js +1 -74
  163. package/dist/host/reference-profile.js +1 -63
  164. package/dist/host/reference-standing.js +2 -18
  165. package/dist/host/reference.js +1 -24
  166. package/dist/host/refusals.js +2 -43
  167. package/dist/host/release.js +4 -256
  168. package/dist/host/root-clock-source.js +1 -307
  169. package/dist/host/selected-capsules.js +1 -50
  170. package/dist/host/selected-topos.js +1 -80
  171. package/dist/host/signature-era.js +1 -12
  172. package/dist/host/signing.js +2 -48
  173. package/dist/host/source-content.js +2 -111
  174. package/dist/host/standing-carrier.js +1 -18
  175. package/dist/host/standing-projection.js +1 -50
  176. package/dist/host/timing.js +1 -7
  177. package/dist/host/walk.js +20 -193
  178. package/dist/host/work-trace.js +1 -0
  179. package/dist/judge/late.js +1 -33
  180. package/dist/judge/take.js +2 -75
  181. package/dist/judge/widening.js +1 -25
  182. package/dist/land/act.js +8 -336
  183. package/dist/land/alias.js +1 -41
  184. package/dist/land/held.js +1 -23
  185. package/dist/land/inert.js +1 -33
  186. package/dist/land/leaving.js +1 -55
  187. package/dist/land/ledger.js +6 -188
  188. package/dist/land/owned.js +4 -66
  189. package/dist/land/sign.js +1 -53
  190. package/dist/land/standing-pin.js +1 -49
  191. package/dist/land/vouched.js +1 -112
  192. package/dist/land/withdraw.js +1 -24
  193. package/dist/observe/files.js +1 -88
  194. package/dist/observe/identity.js +1 -61
  195. package/dist/observe/match.js +1 -8
  196. package/dist/observe/regions.js +7 -306
  197. package/dist/observe/run.js +1 -41
  198. package/dist/observe/runner.js +4 -101
  199. package/dist/public-types.d.ts +2019 -0
  200. package/dist/render/capsule.js +1 -30
  201. package/dist/render/field.js +1 -40
  202. package/dist/render/names.js +1 -4
  203. package/dist/render/open.js +1 -61
  204. package/dist/render/page.js +1 -7
  205. package/dist/render/receipt-projection.js +1 -0
  206. package/dist/render/receipts.js +1 -47
  207. package/dist/render/shape.js +1 -74
  208. package/dist/render/target.js +4 -52
  209. package/dist/render/view.js +7 -197
  210. package/dist/vendor/bundle.json +1 -0
  211. package/dist/vendor/library14.js +1 -0
  212. package/dist/vendor/object-provider.js +42 -0
  213. package/dist/vendor/runtime.js +61 -0
  214. package/dist/wasm/adapter.d.ts +1 -51
  215. package/dist/wasm/adapter.js +1 -180
  216. package/dist/wasm/node-worker.js +1 -13
  217. package/dist/wasm/object.js +1 -76
  218. package/dist/wasm/worker.js +1 -7
  219. package/docs/contracts/authenticated-reference.publication.json +1 -1
  220. package/docs/contracts/authority-preflight.md +17 -0
  221. package/docs/contracts/authority-preflight.publication.json +25 -0
  222. package/docs/contracts/closure-delivery.md +1 -1
  223. package/docs/contracts/closure-delivery.publication.json +1 -1
  224. package/docs/contracts/conformance.json +142 -0
  225. package/docs/contracts/determinism.bound +9 -0
  226. package/docs/contracts/engine-object-projection.publication.json +1 -1
  227. package/docs/contracts/engine.md +21 -1
  228. package/docs/contracts/installed-package.md +21 -0
  229. package/docs/contracts/installed-package.publication.json +25 -0
  230. package/docs/contracts/materialized-leaf-sequence.md +15 -0
  231. package/docs/contracts/materialized-leaf-sequence.publication.json +25 -0
  232. package/docs/contracts/module-inventory.md +15 -0
  233. package/docs/contracts/module-inventory.publication.json +25 -0
  234. package/docs/contracts/native-host.md +29 -1
  235. package/docs/contracts/native-host.publication.json +4 -4
  236. package/docs/contracts/native-probes.md +13 -0
  237. package/docs/contracts/native-probes.publication.json +25 -0
  238. package/docs/contracts/native-publication.inventory.json +10 -1
  239. package/docs/contracts/native-view-batch.md +17 -0
  240. package/docs/contracts/native-view-batch.publication.json +25 -0
  241. package/docs/contracts/optional-wasm-adapter.publication.json +1 -1
  242. package/docs/contracts/physical-lines.md +19 -0
  243. package/docs/contracts/physical-lines.publication.json +25 -0
  244. package/docs/contracts/profile-composition.md +17 -0
  245. package/docs/contracts/profile-composition.publication.json +25 -0
  246. package/docs/contracts/profile-preparation-native-meaning.md +9 -0
  247. package/docs/contracts/publication.md +12 -0
  248. package/docs/contracts/reading-identity.md +61 -0
  249. package/docs/contracts/reading-identity.publication.json +25 -0
  250. package/docs/contracts/reading-witness-admission.md +49 -0
  251. package/docs/contracts/readme.publication.json +1 -1
  252. package/docs/contracts/reference-port.md +11 -0
  253. package/docs/contracts/reference-port.publication.json +1 -1
  254. package/docs/contracts/refusals.bound +346 -94
  255. package/docs/contracts/refusals.md +119 -39
  256. package/docs/contracts/refusals.publication.json +2 -2
  257. package/docs/contracts/views.md +8 -0
  258. package/docs/reference.md +9 -0
  259. package/licenses/wasm/{fast-text-encoding.txt → NOTICE.txt} +111 -0
  260. package/package.json +84 -34
  261. package/receipts.bound +12952 -10449
  262. package/samples/authority-preflight/no.json +6 -0
  263. package/samples/authority-preflight/yes.json +30 -0
  264. package/samples/engine-alphabet/reader.js +3 -1457
  265. package/samples/engine-alphabet/receipts.bound +7 -7
  266. package/samples/engine-interval/reader.js +3 -1457
  267. package/samples/engine-interval/receipts.bound +7 -7
  268. package/samples/installed-package/consumer.mjs +29 -0
  269. package/samples/installed-package/fixture.json +48 -0
  270. package/samples/installed-package/no.json +10 -0
  271. package/samples/installed-package/yes.json +52 -0
  272. package/samples/materialized-leaf-sequence/no.json +11 -0
  273. package/samples/materialized-leaf-sequence/yes.json +10 -0
  274. package/samples/module-inventory/yes.json +28 -0
  275. package/samples/native/physical-line-reader.mjs +1 -0
  276. package/samples/native/physical-line-reader.source.mjs +13 -0
  277. package/samples/native-host/no.json +6 -1
  278. package/samples/native-host/yes.json +18 -1
  279. package/samples/native-probes/inputs/inspection.json +28 -0
  280. package/samples/native-probes/no.json +7 -0
  281. package/samples/native-probes/yes.json +28 -0
  282. package/samples/native-view-batch/no.json +14 -0
  283. package/samples/native-view-batch/yes.json +10 -0
  284. package/samples/no/engine-order/reader.js +3 -1457
  285. package/samples/no/module-inventory/no.json +10 -0
  286. package/samples/physical-lines/no.json +5 -0
  287. package/samples/physical-lines/yes.json +9 -0
  288. package/samples/profile-composition/no.json +6 -0
  289. package/samples/profile-composition/yes.json +14 -0
  290. package/samples/reading-identity/no.json +26 -0
  291. package/samples/reading-identity/yes.json +69 -0
  292. package/vectors/native/authority-preflight.vector.json +55 -0
  293. package/vectors/native/installed-package.vector.json +31 -0
  294. package/vectors/native/materialized-leaf-sequence.vector.json +31 -0
  295. package/vectors/native/module-inventory.vector.json +56 -0
  296. package/vectors/native/native-host.vector.json +214 -0
  297. package/vectors/native/native-probes.vector.json +31 -0
  298. package/vectors/native/native-view-batch.vector.json +31 -0
  299. package/vectors/native/physical-lines.vector.json +105 -0
  300. package/vectors/native/profile-composition.vector.json +53 -0
  301. package/vectors/native/reading-identity.vector.json +139 -0
  302. package/vectors/native/refusals.vector.json +138 -0
  303. package/vendor/syntax/LICENSE.md +7 -0
  304. package/vendor/syntax/parser.js +1 -0
  305. package/.github/workflows/release.yml +0 -67
  306. package/.github/workflows/test.yml +0 -35
  307. package/dist/engine/object.d.ts +0 -17
  308. package/dist/engine/ports.d.ts +0 -37
  309. package/dist/fold/claims.d.ts +0 -29
  310. package/dist/host/call-context.d.ts +0 -20
  311. package/dist/host/commit-result.d.ts +0 -6
  312. package/dist/host/in-process-act.d.ts +0 -82
  313. package/dist/host/in-process-context.d.ts +0 -46
  314. package/dist/host/in-process-root.d.ts +0 -117
  315. package/dist/host/in-process.d.ts +0 -41
  316. package/dist/host/native/module-closure.d.ts +0 -35
  317. package/dist/host/native-receiver.d.ts +0 -19
  318. package/dist/host/place-act-transaction.d.ts +0 -24
  319. package/dist/host/place-clock-selection.d.ts +0 -55
  320. package/dist/host/ports/local-act.d.ts +0 -44
  321. package/dist/host/ports/place-act.d.ts +0 -49
  322. package/dist/host/ports/publication.d.ts +0 -10
  323. package/dist/host/reference-export.d.ts +0 -33
  324. package/dist/host/reference-native.d.ts +0 -30
  325. package/dist/host/reference-profile.d.ts +0 -23
  326. package/dist/host/refusals.d.ts +0 -14
  327. package/dist/host/root-clock-source.d.ts +0 -86
  328. package/licenses/wasm/jitl-quickjs-ffi-types.txt +0 -21
  329. package/licenses/wasm/jitl-quickjs-wasmfile-release-sync.txt +0 -47
  330. package/licenses/wasm/quickjs-emscripten-core.txt +0 -21
  331. package/licenses/wasm/topos.txt +0 -21
  332. /package/{licenses/wasm/bound.txt → dist/vendor/28cba430228db1c04f446c93f81b09a2705d6bf3e222d35adbe5a4cee4061884.LICENSE} +0 -0
  333. /package/{licenses/wasm/obligations.txt → dist/vendor/7aca161279d14bc0e054dcc281cd110aeb95be2e026b42fdf527a260e58b2aae.LICENSE} +0 -0
@@ -1,81 +1,6 @@
1
- import { installedReferenceContracts } from "./reference-contracts.js";
2
- import { BoundRefusal, describeRefusal, readRefusalCatalog } from "./refusals.js";
3
- import { readFileSync } from 'node:fs';
4
- import { authorityAtEpoch, canonical, parse } from '@lapxo/topos/wire';
5
- import { sha256 as hash } from "./hash.js";
6
- import { signerFor } from "./signing.js";
7
- import { signConsentLot } from "../land/sign.js";
8
- import { underRootAuthority } from "../land/act.js";
9
- import { storeOf } from "../land/ledger.js";
10
- import { authorityFor, rootSigner } from "../fold/signers.js";
11
- import { admissionAnchor, admissionHistoryAt } from "../fold/admission-history.js";
12
- import { authenticatedRootStanding } from "./admitted-place.js";
13
- import { eraOf } from "../fold/digests.js";
14
- import { epochOf } from "../cli/owner.js";
15
- import { fieldOf } from "../fold/claims.js";
16
- import { prepareNativeReference } from "./reference-native.js";
17
- import { referenceContextBytes, referenceContracts, referenceStanding } from "./reference-standing.js";
18
- import { encodeReference } from "./reference-profile.js";
19
- const catalog = () => readFileSync(new URL('../../docs/contracts/refusals.bound', import.meta.url), 'utf8');
20
- export { BoundRefusal as ReferenceExportRefusal } from "./refusals.js";
21
- function fail(code) {
22
- const refusal = new BoundRefusal('reference-export/' + code, 'REFUSE·reference-export/' + code);
23
- const entry = describeRefusal(refusal, readRefusalCatalog(catalog()));
24
- throw new BoundRefusal(entry.code, 'REFUSE·' + entry.code + ' ' + entry.meaning);
25
- }
26
- /** Signs a public snapshot proof; never lands, refreshes evidence or changes the Root. */
27
- export async function exportAuthenticatedReference(root, source, options = {}) {
28
- try {
29
- encodeReference({ class: 'standing', algorithm: 'sha256', digest: '0'.repeat(64), blob: 'sha256:' + '0'.repeat(64), source });
30
- }
31
- catch {
32
- fail('source');
33
- }
34
- return underRootAuthority(storeOf(root), 'reference export', async () => {
35
- const history = admissionHistoryAt(root, Number.MAX_SAFE_INTEGER), standing = authenticatedRootStanding(root), epoch = epochOf(history), era = eraOf(standing);
36
- const authority = authorityFor(history, admissionAnchor(root), era.admitted);
37
- const one = (scope, measure = 'id', form = 'alphabet') => { const rows = standing.filter(line => fieldOf(line, 'scope') === scope && fieldOf(line, 'value') !== 'withdraw'); if (rows.length !== 1 || fieldOf(rows[0], 'role') !== 'writes' || fieldOf(rows[0], 'measure') !== measure || fieldOf(rows[0], 'form') !== form || authority.of(rows[0]).kind !== 'admitted')
38
- fail('context'); return fieldOf(rows[0], 'value'); };
39
- if (one('reference/authentication') !== 'authenticated-standing@1')
40
- fail('context');
41
- const proofScope = one('reference/proof-scope'), contracts = { refusals: one('reference/contracts/refusals'), standing: one('reference/contracts/standing') };
42
- const installed = installedReferenceContracts();
43
- if (!referenceContracts(contracts) || contracts.refusals !== installed.refusals || contracts.standing !== installed.standing)
44
- fail('context');
45
- const count = one('reference/records'), maxRecords = Number(count), range = /^(0|[1-9][0-9]*)\.\.(0|[1-9][0-9]*)$/.exec(one('reference/export-bytes', 'bytes', 'interval'));
46
- if (!/^(0|[1-9][0-9]*)$/.test(count) || !Number.isSafeInteger(maxRecords) || maxRecords < 1 || !range || Number(range[1]) > Number(range[2]) || !Number.isSafeInteger(Number(range[2])) || Number(range[2]) < 1)
47
- fail('budget');
48
- const maxBytes = Number(range[2]);
49
- const originals = standing.filter(line => fieldOf(line, 'value') !== 'withdraw' || fieldOf(line, 'type') !== '');
50
- if (!originals.length || originals.length > maxRecords || Buffer.byteLength(originals.join('\n')) > maxBytes)
51
- fail('budget');
52
- if (originals.some(line => authority.of(line).kind !== 'admitted'))
53
- fail('history');
54
- const key = options.key ?? rootSigner(root).id, signer = authority.admitted.find(s => s.id === key);
55
- const stamp = canonical({ scope: proofScope, role: 'writes', form: 'alphabet', measure: 'digest', value: hash(JSON.stringify(['authenticated-standing@1', originals]) + '\n'), by: 'target', at: 'witness:' + 'sha256:' + '0'.repeat(64) });
56
- const probe = parse(stamp);
57
- if (!signer || probe.kind !== 'fact' || authorityAtEpoch({ ...probe.value.fields, by: key, epoch: String(epoch) }, signer, epoch, proofScope, 'authority').kind !== 'admitted')
58
- fail('authority');
59
- const held = await prepareNativeReference(root), semantic = referenceStanding(originals, held.records), semanticIdentity = hash(semantic);
60
- const context = { profile: 'reference-export-context@1', semanticIdentity, epoch, proofScope, policy: held.policy, formImplementation: held.formImplementation, signers: authority.admitted, algorithms: era.admitted, contracts, maxBytes, maxRecords };
61
- const snapshot = hash(referenceContextBytes(context));
62
- if (Buffer.byteLength(JSON.stringify({ originals, context, snapshot }) + '\n') > maxBytes)
63
- fail('budget');
64
- const drafted = canonical({ ...probe.value.fields, at: 'witness:' + snapshot });
65
- let signed;
66
- try {
67
- signed = await signConsentLot([drafted], { epoch, by: key, algorithm: era.era }, signer.publicKey, era.admitted, signerFor(standing, key, options.signer, options.keyFile, options.hostSigner));
68
- }
69
- catch {
70
- fail('signer');
71
- }
72
- if (signed.kind !== 'fact')
73
- fail('signer');
74
- const carrier = JSON.stringify(['authenticated-standing@1', originals, signed.lines[0]]) + '\n';
75
- const reference = encodeReference({ class: 'standing', algorithm: 'sha256', digest: semanticIdentity.slice(7), blob: hash(carrier), source });
76
- const result = { profile: 'reference-export@1', reference, carrier, context: { ...context, snapshot } };
77
- if (Buffer.byteLength(JSON.stringify(result) + '\n') > maxBytes)
78
- fail('budget');
79
- return result;
80
- });
81
- }
1
+ var M=Object.defineProperty;var m=(t,a)=>M(t,"name",{value:a,configurable:!0});import{installedReferenceContracts as T}from"./reference-contracts.js";import{BoundRefusal as _,describeRefusal as X,readRefusalCatalog as q}from"./refusals.js";import{readFileSync as z}from"node:fs";import{library14_authorityAtEpoch as D,library14_canonical as J,library14_parse as P}from"../vendor/runtime.js";import{sha256 as x}from"./hash.js";import{signerFor as Q}from"./signing.js";import{signConsentLot as V}from"../land/sign.js";import{underRootAuthority as W}from"../land/act.js";import{storeOf as Y}from"../land/ledger.js";import{authorityFor as Z,rootSigner as ee}from"../fold/signers.js";import{admissionAnchor as te,admissionHistoryAt as re}from"../fold/admission-history.js";import{authenticatedRootStanding as ne}from"./admitted-place.js";import{eraOf as oe}from"../fold/digests.js";import{epochOf as ie}from"../cli/owner.js";import{fieldOf as i}from"../fold/claims.js";import{prepareNativeReference as ae}from"./reference-native.js";import{referenceContextBytes as se,referenceContracts as ce,referenceStanding as fe}from"./reference-standing.js";import{encodeReference as U}from"./reference-profile.js";const me=m(()=>z(new URL("../../docs/contracts/refusals.bound",import.meta.url),"utf8"),"catalog");import{BoundRefusal as _e}from"./refusals.js";function e(t){const a=new _("reference-export/"+t,"REFUSE\xB7reference-export/"+t),r=X(a,q(me()));throw new _(r.code,"REFUSE\xB7"+r.code+" "+r.meaning)}m(e,"fail");async function Ie(t,a,r={}){try{U({class:"standing",algorithm:"sha256",digest:"0".repeat(64),blob:"sha256:"+"0".repeat(64),source:a})}catch{e("source")}return W(Y(t),"reference export",async()=>{const A=re(t,Number.MAX_SAFE_INTEGER),d=ne(t),l=ie(A),u=oe(d),p=Z(A,te(t),u.admitted),s=m((o,H="id",K="alphabet")=>{const f=d.filter(L=>i(L,"scope")===o&&i(L,"value")!=="withdraw");return(f.length!==1||i(f[0],"role")!=="writes"||i(f[0],"measure")!==H||i(f[0],"form")!==K||p.of(f[0]).kind!=="admitted")&&e("context"),i(f[0],"value")},"one");s("reference/authentication")!=="authenticated-standing@1"&&e("context");const R=s("reference/proof-scope"),g={refusals:s("reference/contracts/refusals"),standing:s("reference/contracts/standing")},O=T();(!ce(g)||g.refusals!==O.refusals||g.standing!==O.standing)&&e("context");const B=s("reference/records"),h=Number(B),c=/^(0|[1-9][0-9]*)\.\.(0|[1-9][0-9]*)$/.exec(s("reference/export-bytes","bytes","interval"));(!/^(0|[1-9][0-9]*)$/.test(B)||!Number.isSafeInteger(h)||h<1||!c||Number(c[1])>Number(c[2])||!Number.isSafeInteger(Number(c[2]))||Number(c[2])<1)&&e("budget");const y=Number(c[2]),n=d.filter(o=>i(o,"value")!=="withdraw"||i(o,"type")!=="");(!n.length||n.length>h||Buffer.byteLength(n.join(`
2
+ `))>y)&&e("budget"),n.some(o=>p.of(o).kind!=="admitted")&&e("history");const b=r.key??ee(t).id,S=p.admitted.find(o=>o.id===b),$=J({scope:R,role:"writes",form:"alphabet",measure:"digest",value:x(JSON.stringify(["authenticated-standing@1",n])+`
3
+ `),by:"target",at:"witness:sha256:"+"0".repeat(64)}),w=P($);(!S||w.kind!=="fact"||D({...w.value.fields,by:b,epoch:String(l)},S,l,R,"authority").kind!=="admitted")&&e("authority");const N=await ae(t),j=fe(n,N.records),F=x(j),E={profile:"reference-export-context@1",semanticIdentity:F,epoch:l,proofScope:R,policy:N.policy,formImplementation:N.formImplementation,signers:p.admitted,algorithms:u.admitted,contracts:g,maxBytes:y,maxRecords:h},k=x(se(E));Buffer.byteLength(JSON.stringify({originals:n,context:E,snapshot:k})+`
4
+ `)>y&&e("budget");const G=J({...w.value.fields,at:"witness:"+k});let v;try{v=await V([G],{epoch:l,by:b,algorithm:u.era},S.publicKey,u.admitted,Q(d,b,r.signer,r.keyFile,r.hostSigner))}catch{e("signer")}v.kind!=="fact"&&e("signer");const I=JSON.stringify(["authenticated-standing@1",n,v.lines[0]])+`
5
+ `,C={profile:"reference-export@1",reference:U({class:"standing",algorithm:"sha256",digest:F.slice(7),blob:x(I),source:a}),carrier:I,context:{...E,snapshot:k}};return Buffer.byteLength(JSON.stringify(C)+`
6
+ `)>y&&e("budget"),C})}m(Ie,"exportAuthenticatedReference");export{_e as ReferenceExportRefusal,Ie as exportAuthenticatedReference};
@@ -1,3 +1 @@
1
- /** Native host boundary. The platform-free reference inspector remains /reference. */
2
- export { openAuthenticatedReference } from './reference-native.ts';
3
- export { exportAuthenticatedReference } from './reference-export.ts';
1
+ export {public8_exportAuthenticatedReference as exportAuthenticatedReference,public8_inspectReference as inspectReference,public8_inspectReferencePreview as inspectReferencePreview,public8_openAuthenticatedReference as openAuthenticatedReference} from "../public-types.js";
@@ -1,3 +1 @@
1
- /** Native host boundary. The platform-free reference inspector remains /reference. */
2
- export { openAuthenticatedReference } from "./reference-native.js";
3
- export { exportAuthenticatedReference } from "./reference-export.js";
1
+ import{openAuthenticatedReference as t}from"./reference-native.js";import{exportAuthenticatedReference as c}from"./reference-export.js";import{inspectReference as f,inspectReferencePreview as p}from"./reference.js";export{c as exportAuthenticatedReference,f as inspectReference,p as inspectReferencePreview,t as openAuthenticatedReference};
@@ -1,74 +1 @@
1
- import { readContent } from "../engine/ports.js";
2
- import { installedReferenceContracts } from "./reference-contracts.js";
3
- import { BoundRefusal } from "./refusals.js";
4
- import { foldObjectsWithWasm } from "../wasm/object.js";
5
- /** Native ports for authenticated #bound opening; trusted policy belongs to the selected local place. */
6
- import { sha256 as hash, isSha256 } from "./hash.js";
7
- import { canonical, parse, transportSelection } from '@lapxo/topos/wire';
8
- import { semanticStandingBytes } from '@lapxo/topos/standing';
9
- import { authorityFor, rootSigner } from "../fold/signers.js";
10
- import { eraOf } from "../fold/digests.js";
11
- import { lockStanding, lockLines } from "../fold/keys.js";
12
- import { signedOwnerLines } from "../cli/owner.js";
13
- import { admittedObjects } from "./objects.js";
14
- import { storeOf } from "../land/ledger.js";
15
- import { objectFold } from "../engine/index.js";
16
- import { toposAt, contentAt } from "./selected-topos.js";
17
- import { transportBytes } from "./ports/transport.js";
18
- import { decodeReference } from "./reference-profile.js";
19
- import { inspectAuthenticatedReference } from "./reference-authenticated.js";
20
- import { verifyBytes } from "./adapters/keys/ed25519.js";
21
- export function authenticatedReferenceSelected(standing) {
22
- const selected = standing.flatMap(line => { const p = parse(line); return p.kind === 'fact' && p.value.fields.scope === 'reference/authentication' ? [p.value.fields] : []; });
23
- if (!selected.length)
24
- return false;
25
- if (selected.length !== 1 || selected[0].value !== 'authenticated-standing@1')
26
- throw Error('REFUSE·reference conflicting or unknown authentication profile');
27
- return true;
28
- }
29
- /** One context preparation shared by native export and native inspection. */
30
- export async function prepareNativeReference(root) {
31
- const store = storeOf(root), held = await admittedObjects(root, signedOwnerLines(store), () => { }, true);
32
- const policy = held.configuration.map(fields => canonical(fields));
33
- const implementations = [...new Set(held.records.filter(r => r.record === 'cell').map(r => r.fields.topos))].sort().map(pin => { const selected = toposAt(pin, store), selectors = selected.parts.filter(f => f.scope === 'wire/topos/context-view'); if (selectors.length !== 1)
34
- throw Error('REFUSE·reference host context selector'); const offers = selected.parts.filter(f => f.kind === 'check' && f.view === selectors[0].value); if (offers.length !== 1)
35
- throw Error('REFUSE·reference host context offer'); const offer = offers[0], closure = [...new Set((offer.restsOn ?? '').split('|').filter(Boolean))].sort(); for (const digest of closure)
36
- contentAt(digest, store); return [pin, offer.value, closure]; });
37
- return { ...held, policy: hash(semanticStandingBytes(policy)), formImplementation: hash(JSON.stringify(implementations)) };
38
- }
39
- export async function openAuthenticatedReference(root, fragment, options = {}) {
40
- const store = storeOf(root), standing = lockStanding(store), era = eraOf(standing), authority = authorityFor(lockLines(store), rootSigner(root), era.admitted);
41
- if (!authenticatedReferenceSelected(standing))
42
- throw Error('REFUSE·reference no admitted authenticated-standing@1 profile');
43
- const one = (scope) => { const found = standing.flatMap(line => { const p = parse(line); return p.kind === 'fact' && p.value.fields.scope === scope ? [{ line, fields: p.value.fields }] : []; }); if (found.length !== 1 || found[0].fields.role !== 'writes' || found[0].fields.measure !== 'id' || found[0].fields.form !== 'alphabet' || authority.of(found[0].line).kind !== 'admitted')
44
- throw new BoundRefusal(scope === 'engine/object' ? 'reference/backend' : 'authenticated-reference/context', 'REFUSE·reference missing, conflicting or unauthenticated ' + scope); return found[0].fields.value; };
45
- if (one('reference/authentication') !== 'authenticated-standing@1')
46
- throw Error('REFUSE·reference authentication profile');
47
- const snapshot = one('reference/snapshot'), epochText = one('reference/epoch'), proofScope = one('reference/proof-scope'), recordsText = one('reference/records');
48
- if (!isSha256(snapshot) || !/^\d+$/.test(epochText) || !Number.isSafeInteger(Number(epochText)) || !/^\d+$/.test(recordsText) || !Number.isSafeInteger(Number(recordsText)) || Number(recordsText) < 1 || !proofScope)
49
- throw Error('REFUSE·reference authority snapshot or resource contract');
50
- const backend = one('engine/object');
51
- if (!['esm@1', 'wasm@1'].includes(backend))
52
- throw new BoundRefusal('reference/backend', 'REFUSE·reference unsupported declared backend');
53
- if (options.signal?.aborted)
54
- throw new BoundRefusal('reference/cancelled', 'REFUSE·reference cancelled');
55
- const reference = decodeReference(fragment);
56
- // Provider selection is made from HOST-declared cells/configuration, never carrier-picked code.
57
- const held = await prepareNativeReference(root);
58
- if (!held.records.some(r => r.record === 'cell'))
59
- throw Error('REFUSE·reference host has no declared object interpretation');
60
- const context = held.context, policy = held.configuration.map(fields => canonical(fields)), selection = transportSelection(held.configuration, new URL(reference.source).protocol.slice(0, -1));
61
- if (!selection)
62
- throw Error('REFUSE·reference no admitted transport policy');
63
- if (options.content && options.content.name !== selection.name)
64
- throw new BoundRefusal('authenticated-reference/transport', 'REFUSE·reference injected content binding conflicts with declaration');
65
- const contracts = { refusals: one('reference/contracts/refusals'), standing: one('reference/contracts/standing') }, expectedPolicy = one('reference/policy'), expectedImplementation = one('reference/form-implementation');
66
- const installed = installedReferenceContracts();
67
- if (contracts.refusals !== installed.refusals || contracts.standing !== installed.standing || !isSha256(expectedPolicy) || expectedImplementation !== held.formImplementation)
68
- throw new BoundRefusal('authenticated-reference/context', 'REFUSE·reference expected interpretation differs');
69
- const result = await inspectAuthenticatedReference(fragment, { snapshot, epoch: Number(epochText), proofScope, contracts, policy: expectedPolicy, formImplementation: expectedImplementation, signers: authority.admitted, algorithms: era.admitted, objects: context, maxBytes: selection.responseBytes, maxRecords: Number(recordsText), digestBytes: hash, verifyBytes, fetchBytes: (source, blob) => options.content ? readContent(source, blob, { read: options.content.read, digestBytes: hash }, { timeoutMs: selection.timeoutMs, maxBytes: selection.responseBytes }, options.signal) : transportBytes(source, blob, policy) });
70
- if (options.signal?.aborted)
71
- throw new BoundRefusal('reference/cancelled', 'REFUSE·reference cancelled');
72
- const readings = backend === 'wasm@1' ? await foldObjectsWithWasm(root, result.records, context, held.configuration, options.signal) : objectFold(result.records, context);
73
- return { ...result, backend, readings };
74
- }
1
+ var _=Object.defineProperty;var d=(n,r)=>_(n,"name",{value:r,configurable:!0});import{readContent as L}from"../engine/ports.js";import{installedReferenceContracts as C}from"./reference-contracts.js";import{BoundRefusal as m}from"./refusals.js";import{foldObjectsWithWasm as T}from"../wasm/object.js";import{sha256 as E,isSha256 as v}from"./hash.js";import{library14_canonical as N,library14_parse as j,library14_transportSelection as W}from"../vendor/runtime.js";import{library10_semanticStandingBytes as $}from"../vendor/runtime.js";import{authorityFor as J,rootSigner as P}from"../fold/signers.js";import{eraOf as q}from"../fold/digests.js";import{lockStanding as z,lockLines as D}from"../fold/keys.js";import{signedOwnerLines as G}from"../cli/owner.js";import{admittedObjects as H}from"./objects.js";import{storeOf as O}from"../land/ledger.js";import{objectFold as K}from"../engine/index.js";import{toposAt as Q,contentAt as V}from"./selected-topos.js";import{transportBytes as X}from"./ports/transport.js";import{decodeReference as Y}from"./reference-profile.js";import{inspectAuthenticatedReference as Z}from"./reference-authenticated.js";import{verifyBytes as ee}from"./adapters/keys/ed25519.js";function te(n){const r=n.flatMap(e=>{const s=j(e);return s.kind==="fact"&&s.value.fields.scope==="reference/authentication"?[s.value.fields]:[]});if(!r.length)return!1;if(r.length!==1||r[0].value!=="authenticated-standing@1")throw Error("REFUSE\xB7reference conflicting or unknown authentication profile");return!0}d(te,"authenticatedReferenceSelected");async function re(n){const r=O(n),e=await H(n,G(r),()=>{},!0),s=e.configuration.map(o=>N(o)),p=[...new Set(e.records.filter(o=>o.record==="cell").map(o=>o.fields.topos))].sort().map(o=>{const u=Q(o,r),t=u.parts.filter(c=>c.scope==="wire/topos/context-view");if(t.length!==1)throw Error("REFUSE\xB7reference host context selector");const h=u.parts.filter(c=>c.kind==="check"&&c.view===t[0].value);if(h.length!==1)throw Error("REFUSE\xB7reference host context offer");const f=h[0],g=[...new Set((f.restsOn??"").split("|").filter(Boolean))].sort();for(const c of g)V(c,r);return[o,f.value,g]});return{...e,policy:E($(s)),formImplementation:E(JSON.stringify(p))}}d(re,"prepareNativeReference");async function xe(n,r,e={}){const s=O(n),p=z(s),o=q(p),u=J(D(s),P(n),o.admitted);if(!te(p))throw Error("REFUSE\xB7reference no admitted authenticated-standing@1 profile");const t=d(i=>{const a=p.flatMap(k=>{const x=j(k);return x.kind==="fact"&&x.value.fields.scope===i?[{line:k,fields:x.value.fields}]:[]});if(a.length!==1||a[0].fields.role!=="writes"||a[0].fields.measure!=="id"||a[0].fields.form!=="alphabet"||u.of(a[0].line).kind!=="admitted")throw new m(i==="engine/object"?"reference/backend":"authenticated-reference/context","REFUSE\xB7reference missing, conflicting or unauthenticated "+i);return a[0].fields.value},"one");if(t("reference/authentication")!=="authenticated-standing@1")throw Error("REFUSE\xB7reference authentication profile");const h=t("reference/snapshot"),f=t("reference/epoch"),g=t("reference/proof-scope"),c=t("reference/records");if(!v(h)||!/^\d+$/.test(f)||!Number.isSafeInteger(Number(f))||!/^\d+$/.test(c)||!Number.isSafeInteger(Number(c))||Number(c)<1||!g)throw Error("REFUSE\xB7reference authority snapshot or resource contract");const y=t("engine/object");if(!["esm@1","wasm@1"].includes(y))throw new m("reference/backend","REFUSE\xB7reference unsupported declared backend");if(e.signal?.aborted)throw new m("reference/cancelled","REFUSE\xB7reference cancelled");const I=Y(r),l=await re(n);if(!l.records.some(i=>i.record==="cell"))throw Error("REFUSE\xB7reference host has no declared object interpretation");const S=l.context,A=l.configuration.map(i=>N(i)),w=W(l.configuration,new URL(I.source).protocol.slice(0,-1));if(!w)throw Error("REFUSE\xB7reference no admitted transport policy");if(e.content&&e.content.name!==w.name)throw new m("authenticated-reference/transport","REFUSE\xB7reference injected content binding conflicts with declaration");const b={refusals:t("reference/contracts/refusals"),standing:t("reference/contracts/standing")},F=t("reference/policy"),U=t("reference/form-implementation"),B=C();if(b.refusals!==B.refusals||b.standing!==B.standing||!v(F)||U!==l.formImplementation)throw new m("authenticated-reference/context","REFUSE\xB7reference expected interpretation differs");const R=await Z(r,{snapshot:h,epoch:Number(f),proofScope:g,contracts:b,policy:F,formImplementation:U,signers:u.admitted,algorithms:o.admitted,objects:S,maxBytes:w.responseBytes,maxRecords:Number(c),digestBytes:E,verifyBytes:ee,fetchBytes:d((i,a)=>e.content?L(i,a,{read:e.content.read,digestBytes:E},{timeoutMs:w.timeoutMs,maxBytes:w.responseBytes},e.signal):X(i,a,A,{signal:e.signal}),"fetchBytes")});if(e.signal?.aborted)throw new m("reference/cancelled","REFUSE\xB7reference cancelled");const M=y==="wasm@1"?await T(n,R.records,S,l.configuration,e.signal):K(R.records,S);return{...R,backend:y,readings:M}}d(xe,"openAuthenticatedReference");export{te as authenticatedReferenceSelected,xe as openAuthenticatedReference,re as prepareNativeReference};
@@ -1,63 +1 @@
1
- import { BoundRefusal } from "./refusals.js";
2
- const hex = /^[0-9a-f]{64}$/;
3
- const refuse = (cause) => { throw new BoundRefusal('reference/format', `REFUSE·reference ${cause}`); };
4
- const keys = ['class', 'algorithm', 'digest', 'blob', 'source'];
5
- function check(reference) {
6
- if (Object.keys(reference).length !== keys.length || keys.some(key => !Object.prototype.hasOwnProperty.call(reference, key)))
7
- refuse('fields');
8
- if (reference.class !== 'standing')
9
- refuse('unknown class');
10
- if (reference.algorithm !== 'sha256')
11
- refuse('unknown algorithm');
12
- if (!hex.test(reference.digest) || !/^sha256:[0-9a-f]{64}$/.test(reference.blob))
13
- refuse('digest');
14
- let source;
15
- try {
16
- source = new URL(reference.source);
17
- }
18
- catch {
19
- return refuse('source URL');
20
- }
21
- if (source.username || source.password || source.hash)
22
- refuse('source credentials or fragment');
23
- if (source.href !== reference.source)
24
- refuse('noncanonical source URL');
25
- return reference;
26
- }
27
- export function encodeReference(reference) {
28
- check(reference);
29
- return '#bound:1?' + keys.map(key => key + '=' + encodeURIComponent(reference[key])).join('&');
30
- }
31
- export function decodeReference(fragment) {
32
- if (!fragment.startsWith('#bound:1?'))
33
- refuse('profile');
34
- const parameters = new URLSearchParams(fragment.slice('#bound:1?'.length));
35
- if ([...parameters].length !== keys.length || new Set(parameters.keys()).size !== keys.length)
36
- refuse('duplicate or missing field');
37
- const reference = check(Object.fromEntries(parameters));
38
- if (encodeReference(reference) !== fragment)
39
- refuse('noncanonical encoding');
40
- return Object.freeze(reference);
41
- }
42
- export function inspectReferenceBytes(reference, bytes, { maxBytes, readSemanticStanding, semanticStandingBytes, digestBytes }) {
43
- if (bytes.byteLength > maxBytes)
44
- refuse('bytes budget');
45
- if (digestBytes(bytes) !== reference.blob.slice(7))
46
- refuse('blob integrity');
47
- let document;
48
- try {
49
- document = JSON.parse(new TextDecoder('utf-8', { fatal: true }).decode(bytes));
50
- }
51
- catch {
52
- refuse('document');
53
- }
54
- if (document === null || typeof document !== 'object' || document.profile !== 'semantic-standing@1' || typeof document.standing !== 'string' || Object.keys(document).length !== 2)
55
- refuse('document profile');
56
- if (new TextDecoder('utf-8', { fatal: true }).decode(bytes) !== JSON.stringify({ profile: document.profile, standing: document.standing }))
57
- refuse('noncanonical document wrapper');
58
- const lines = readSemanticStanding(document.standing);
59
- const semantic = semanticStandingBytes(lines);
60
- if (digestBytes(new TextEncoder().encode(semantic)) !== reference.digest)
61
- refuse('standing identity');
62
- return { reference, lines, standing: semantic, authentication: 'not demonstrated; inspect only' };
63
- }
1
+ var g=Object.defineProperty;var s=(t,n)=>g(t,"name",{value:n,configurable:!0});import{BoundRefusal as h}from"./refusals.js";const p=/^[0-9a-f]{64}$/,e=s(t=>{throw new h("reference/format",`REFUSE\xB7reference ${t}`)},"refuse"),c=["class","algorithm","digest","blob","source"];function d(t){(Object.keys(t).length!==c.length||c.some(i=>!Object.prototype.hasOwnProperty.call(t,i)))&&e("fields"),t.class!=="standing"&&e("unknown class"),t.algorithm!=="sha256"&&e("unknown algorithm"),(!p.test(t.digest)||!/^sha256:[0-9a-f]{64}$/.test(t.blob))&&e("digest");let n;try{n=new URL(t.source)}catch{return e("source URL")}return(n.username||n.password||n.hash)&&e("source credentials or fragment"),n.href!==t.source&&e("noncanonical source URL"),t}s(d,"check");function m(t){return d(t),"#bound:1?"+c.map(n=>n+"="+encodeURIComponent(t[n])).join("&")}s(m,"encodeReference");function y(t){t.startsWith("#bound:1?")||e("profile");const n=new URLSearchParams(t.slice(9));([...n].length!==c.length||new Set(n.keys()).size!==c.length)&&e("duplicate or missing field");const i=d(Object.fromEntries(n));return m(i)!==t&&e("noncanonical encoding"),Object.freeze(i)}s(y,"decodeReference");function R(t,n,{maxBytes:i,readSemanticStanding:u,semanticStandingBytes:f,digestBytes:a}){n.byteLength>i&&e("bytes budget"),a(n)!==t.blob.slice(7)&&e("blob integrity");let o;try{o=JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(n))}catch{e("document")}(o===null||typeof o!="object"||o.profile!=="semantic-standing@1"||typeof o.standing!="string"||Object.keys(o).length!==2)&&e("document profile"),new TextDecoder("utf-8",{fatal:!0}).decode(n)!==JSON.stringify({profile:o.profile,standing:o.standing})&&e("noncanonical document wrapper");const r=u(o.standing),l=f(r);return a(new TextEncoder().encode(l))!==t.digest&&e("standing identity"),{reference:t,lines:r,standing:l,authentication:"not demonstrated; inspect only"}}s(R,"inspectReferenceBytes");export{y as decodeReference,m as encodeReference,R as inspectReferenceBytes};
@@ -1,18 +1,2 @@
1
- import { parse } from '@lapxo/topos/wire';
2
- import { cellInputs } from '@lapxo/topos/cell-inputs';
3
- import { semanticStandingBytes } from '@lapxo/topos/standing';
4
- /** Shared projection after admission; transport order never replaces effective order. */
5
- export function referenceStanding(originals, records) {
6
- const membership = new Set([...cellInputs(records, 'semantic-live@2').values()].flat().map(line => semanticStandingBytes([line])));
7
- const fields = (line) => { const p = parse(line); if (p.kind !== 'fact')
8
- throw Error('REFUSE·authenticated-reference original parse'); return p.value.fields; };
9
- const effective = [...originals].sort((a, b) => Number(fields(a).epoch) - Number(fields(b).epoch));
10
- return semanticStandingBytes(effective.filter(line => fields(line).type === undefined || membership.has(semanticStandingBytes([line]))));
11
- }
12
- export function referenceContracts(value) {
13
- return value !== null && typeof value === 'object' && !Array.isArray(value) && Object.keys(value).length === 2 && /^sha256:[a-f0-9]{64}$/.test(value.refusals) && /^sha256:[a-f0-9]{64}$/.test(value.standing);
14
- }
15
- /** This versioned context frame binds interpretation contracts without changing wire fields. */
16
- export function referenceContextBytes(context) {
17
- return new TextEncoder().encode(JSON.stringify(['reference-export-context@1', context.semanticIdentity, context.epoch, context.proofScope, context.policy, context.formImplementation, context.signers, context.algorithms, context.contracts.refusals, context.contracts.standing, context.maxBytes, context.maxRecords]) + '\n');
18
- }
1
+ var c=Object.defineProperty;var t=(e,s)=>c(e,"name",{value:s,configurable:!0});import{library14_parse as p}from"../vendor/runtime.js";import{library11_cellInputs as m}from"../vendor/runtime.js";import{library10_semanticStandingBytes as i}from"../vendor/runtime.js";function h(e,s){const o=new Set([...m(s,"semantic-live@2").values()].flat().map(r=>i([r]))),a=t(r=>{const n=p(r);if(n.kind!=="fact")throw Error("REFUSE\xB7authenticated-reference original parse");return n.value.fields},"fields"),f=[...e].sort((r,n)=>Number(a(r).epoch)-Number(a(n).epoch));return i(f.filter(r=>a(r).type===void 0||o.has(i([r]))))}t(h,"referenceStanding");function g(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length===2&&/^sha256:[a-f0-9]{64}$/.test(e.refusals)&&/^sha256:[a-f0-9]{64}$/.test(e.standing)}t(g,"referenceContracts");function b(e){return new TextEncoder().encode(JSON.stringify(["reference-export-context@1",e.semanticIdentity,e.epoch,e.proofScope,e.policy,e.formImplementation,e.signers,e.algorithms,e.contracts.refusals,e.contracts.standing,e.maxBytes,e.maxRecords])+`
2
+ `)}t(b,"referenceContextBytes");export{b as referenceContextBytes,g as referenceContracts,h as referenceStanding};
@@ -1,24 +1 @@
1
- /** Host composition. Location supplies bytes, never identity or authority. No store writes. */
2
- import { createHash } from 'node:crypto';
3
- import { readSemanticStanding, semanticStandingBytes } from '@lapxo/topos/core';
4
- import { parse, transportSelection } from '@lapxo/topos/wire';
5
- import { transportBytes } from "./ports/transport.js";
6
- import { decodeReference, inspectReferenceBytes } from "./reference-profile.js";
7
- export async function inspectReference(fragment, policy) {
8
- const reference = decodeReference(fragment), scheme = new URL(reference.source).protocol.slice(0, -1);
9
- const fields = policy.flatMap(line => { const got = parse(line); return got.kind === 'fact' ? [got.value.fields] : []; });
10
- const selected = transportSelection(fields, scheme);
11
- if (selected === undefined)
12
- throw Error(`REFUSE·transport ${scheme} no admitted content-request/1 policy`);
13
- let bytes;
14
- try {
15
- bytes = await transportBytes(reference.source, reference.blob, policy);
16
- }
17
- catch (error) {
18
- const cause = error instanceof Error ? error.message : 'transport failed';
19
- if (cause.startsWith('REFUSE·'))
20
- throw error;
21
- throw Error(`REFUSE·transport ${scheme} ${cause}`);
22
- }
23
- return inspectReferenceBytes(reference, bytes, { maxBytes: selected.responseBytes, readSemanticStanding, semanticStandingBytes, digestBytes: value => createHash('sha256').update(value).digest('hex') });
24
- }
1
+ var E=Object.defineProperty;var a=(o,r)=>E(o,"name",{value:r,configurable:!0});import{createHash as f}from"node:crypto";import{library6_readSemanticStanding as _,library6_semanticStandingBytes as U}from"../vendor/runtime.js";import{library14_parse as w,library14_transportSelection as b}from"../vendor/runtime.js";import{library5_decodeLocatedReference as x,library5_locatedReferenceIdentity as L,library5_inspectLocatedReference as v}from"../vendor/runtime.js";import{ContentUnavailable as P}from"./adapters/transport/http.js";import{library5_decodeReferenceProjection as j,library5_inspectReferenceProjection as F}from"../vendor/runtime.js";import{BoundRefusal as i}from"./refusals.js";import{transportBytes as S}from"./ports/transport.js";import{decodeReference as $,inspectReferenceBytes as k}from"./reference-profile.js";async function J(o,r,c={}){if(o.startsWith("#topos-reference:")){let e;try{e=x(o)}catch(t){throw new i("reference/format",String(t))}const s=L(e),m=a(()=>({kind:"needs",reference:e,identity:s,needs:"needs/bytes/"+e.blob,authentication:"not demonstrated; inspect only"}),"needs");if(!e.location||e["location-class"]==="viewer")return m();const y=new URL(e.location).protocol.slice(0,-1),B=r.flatMap(t=>{const R=w(t);return R.kind==="fact"?[R.value.fields]:[]}),h=b(B,y);if(!h)throw new i("reference/transport",`REFUSE\xB7transport ${y} no admitted content-request/1 policy`);let u;try{u=await S(e.location,e.blob,r,c)}catch(t){if(t instanceof P)return m();throw t}try{return{...v(e,u,{maxBytes:h.responseBytes,digestBytes:a(t=>f("sha256").update(t).digest("hex"),"digestBytes")}),reference:e,authentication:"not demonstrated; inspect only"}}catch(t){throw new i("reference/format",String(t))}}const n=$(o),d=new URL(n.source).protocol.slice(0,-1),g=r.flatMap(e=>{const s=w(e);return s.kind==="fact"?[s.value.fields]:[]}),l=b(g,d);if(l===void 0)throw new i("reference/transport",`REFUSE\xB7transport ${d} no admitted content-request/1 policy`);let p;try{p=await S(n.source,n.blob,r,c)}catch(e){const s=e instanceof Error?e.message:"transport failed";throw s.startsWith("REFUSE\xB7")?e:Error(`REFUSE\xB7transport ${d} ${s}`)}return k(n,p,{maxBytes:l.responseBytes,readSemanticStanding:_,semanticStandingBytes:U,digestBytes:a(e=>f("sha256").update(e).digest("hex"),"digestBytes")})}a(J,"inspectReference");function K(o,r,c){try{return F(j(o,r,c),n=>"sha256:"+f("sha256").update(n).digest("hex"),r,c)}catch(n){throw new i("reference/format",String(n))}}a(K,"inspectReferencePreview");export{J as inspectReference,K as inspectReferencePreview};
@@ -1,43 +1,2 @@
1
- import { parse, canonical } from '@lapxo/topos/wire';
2
- /** Stable code assigned at the cause. Details are diagnostic, never parsed as policy. */
3
- export class BoundRefusal extends Error {
4
- constructor(code, diagnostic) { super(diagnostic); this.name = 'BoundRefusal'; this.code = code; }
5
- }
6
- /** Pure machine contract reader. A catalog is data, never an authority grant. */
7
- export function readRefusalCatalog(text) {
8
- const groups = new Map();
9
- let profile = false;
10
- for (const line of text.trimEnd().split('\n')) {
11
- const parsed = parse(line);
12
- if (parsed.kind !== 'fact' || canonical(parsed.value.fields) !== line)
13
- throw new BoundRefusal('catalog/invalid', 'REFUSE·invalid refusal catalog line');
14
- const f = parsed.value.fields;
15
- if (f.scope === 'refusal/catalog' && f.measure === 'id' && f.value === 'bound-refusals@1' && f.role === 'writes' && f.form === 'alphabet' && !profile) {
16
- profile = true;
17
- continue;
18
- }
19
- if (f.role !== 'writes' || f.form !== 'alphabet' || !f.scope?.startsWith('refusal/') || !['code', 'class', 'next'].includes(f.measure ?? ''))
20
- throw new BoundRefusal('catalog/invalid', 'REFUSE·invalid refusal catalog record');
21
- const group = groups.get(f.scope) ?? new Map();
22
- if (group.has(f.measure))
23
- throw new BoundRefusal('catalog/invalid', 'REFUSE·duplicate refusal catalog field');
24
- group.set(f.measure, f);
25
- groups.set(f.scope, group);
26
- }
27
- const entries = [];
28
- for (const [scope, group] of groups) {
29
- const code = group.get('code')?.value, category = group.get('class')?.value, meaning = group.get('class')?.about, next = group.get('next')?.value;
30
- if (group.size !== 3 || !code || scope !== 'refusal/' + code || !category || !meaning || !next)
31
- throw new BoundRefusal('catalog/invalid', 'REFUSE·incomplete refusal catalog entry');
32
- entries.push(Object.freeze({ code, category, meaning, next }));
33
- }
34
- if (!profile || !entries.length)
35
- throw new BoundRefusal('catalog/invalid', 'REFUSE·missing refusal catalog profile');
36
- return Object.freeze(entries);
37
- }
38
- export function describeRefusal(error, catalog) {
39
- const entry = catalog.find(row => row.code === error.code);
40
- if (!entry)
41
- throw new BoundRefusal('catalog/invalid', 'REFUSE·undeclared refusal code');
42
- return entry;
43
- }
1
+ var d=Object.defineProperty;var s=(o,a)=>d(o,"name",{value:a,configurable:!0});import{library14_parse as g,library14_canonical as p}from"../vendor/runtime.js";class l extends Error{static{s(this,"BoundRefusal")}constructor(a,r){super(r),this.name="BoundRefusal",this.code=a}}function v(o){throw new l(o,"REFUSE\xB7"+o)}s(v,"refuseBound");function w(o){const a=new Map;let r=!1;for(const i of o.trimEnd().split(`
2
+ `)){const t=g(i);if(t.kind!=="fact"||p(t.value.fields)!==i)throw new l("catalog/invalid","REFUSE\xB7invalid refusal catalog line");const e=t.value.fields;if(e.scope==="refusal/catalog"&&e.measure==="id"&&e.value==="bound-refusals@1"&&e.role==="writes"&&e.form==="alphabet"&&!r){r=!0;continue}if(e.role!=="writes"||e.form!=="alphabet"||!e.scope?.startsWith("refusal/")||!["code","class","next"].includes(e.measure??""))throw new l("catalog/invalid","REFUSE\xB7invalid refusal catalog record");const n=a.get(e.scope)??new Map;if(n.has(e.measure))throw new l("catalog/invalid","REFUSE\xB7duplicate refusal catalog field");n.set(e.measure,e),a.set(e.scope,n)}const c=[];for(const[i,t]of a){const e=t.get("code")?.value,n=t.get("class")?.value,u=t.get("class")?.about,f=t.get("next")?.value;if(t.size!==3||!e||i!=="refusal/"+e||!n||!u||!f)throw new l("catalog/invalid","REFUSE\xB7incomplete refusal catalog entry");c.push(Object.freeze({code:e,category:n,meaning:u,next:f}))}if(!r||!c.length)throw new l("catalog/invalid","REFUSE\xB7missing refusal catalog profile");return Object.freeze(c)}s(w,"readRefusalCatalog");function h(o,a){const r=a.find(c=>c.code===o.code);if(!r)throw new l("catalog/invalid","REFUSE\xB7undeclared refusal code");return r}s(h,"describeRefusal");function R(o,a,r){try{return{profile:"bound-refusal@1",...h(o,w(a)),catalog:r(a)}}catch{return{profile:"bound-refusal@1",code:"catalog/invalid",unmeasured:["category","meaning","next","catalog"]}}}s(R,"refusalRecord");export{l as BoundRefusal,h as describeRefusal,w as readRefusalCatalog,R as refusalRecord,v as refuseBound};