@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.
- package/CITATION.cff +1 -1
- package/README.md +20 -3
- package/TARGET.bound +85 -47
- package/dist/cli/accept.js +61 -590
- package/dist/cli/act-result.js +3 -103
- package/dist/cli/args.js +3 -44
- package/dist/cli/custodian.js +2 -29
- package/dist/cli/host.js +4 -32
- package/dist/cli/names.js +1 -12
- package/dist/cli/native-descendant.js +1 -19
- package/dist/cli/native.js +3 -60
- package/dist/cli/observe.js +1 -13
- package/dist/cli/owner.js +3 -139
- package/dist/cli/pass.js +22 -321
- package/dist/cli/place.js +6 -282
- package/dist/cli/release-result.js +3 -80
- package/dist/cli/retained-judgment.js +1 -25
- package/dist/cli/standing-result.js +4 -19
- package/dist/cli/takes.js +10 -112
- package/dist/cli/verb.d.ts +1 -2
- package/dist/cli/verb.js +85 -684
- package/dist/engine/computation.js +2 -0
- package/dist/engine/conformance.js +4 -0
- package/dist/engine/encoding.js +1 -2
- package/dist/engine/index.d.ts +1 -13
- package/dist/engine/index.js +2 -11
- package/dist/engine/object.js +1 -38
- package/dist/engine/ports.js +2 -117
- package/dist/fold/admission-history.js +1 -17
- package/dist/fold/bootstrap-anchor.js +1 -28
- package/dist/fold/ceilings.js +1 -142
- package/dist/fold/claims.js +2 -132
- package/dist/fold/closed.js +24 -235
- package/dist/fold/configures.js +1 -25
- package/dist/fold/digests.js +10 -226
- package/dist/fold/evidence.js +1 -22
- package/dist/fold/fold-worker.js +1 -13
- package/dist/fold/kept.js +12 -173
- package/dist/fold/keys.js +3 -91
- package/dist/fold/laid.js +3 -90
- package/dist/fold/nos.js +1 -48
- package/dist/fold/object.js +1 -2
- package/dist/fold/observed.js +28 -534
- package/dist/fold/opened.js +1 -33
- package/dist/fold/own.js +3 -217
- package/dist/fold/paid.js +1 -92
- package/dist/fold/place-inputs.js +1 -70
- package/dist/fold/places.js +3 -100
- package/dist/fold/rank.js +1 -9
- package/dist/fold/reach.js +1 -83
- package/dist/fold/readers.js +6 -142
- package/dist/fold/receipts.js +1 -47
- package/dist/fold/region-declarations.js +1 -13
- package/dist/fold/region.js +8 -286
- package/dist/fold/release-policy.js +1 -101
- package/dist/fold/resolved.js +6 -145
- package/dist/fold/roles.js +2 -59
- package/dist/fold/second.js +4 -71
- package/dist/fold/shards.js +12 -100
- package/dist/fold/signed.js +3 -81
- package/dist/fold/signers.js +1 -54
- package/dist/fold/stranger.js +6 -24
- package/dist/fold/views.js +1 -66
- package/dist/fold/wire.js +1 -46
- package/dist/fold/zoom.js +3 -81
- package/dist/host/act-cost.js +1 -25
- package/dist/host/adapters/keys/ed25519.js +1 -30
- package/dist/host/adapters/modules/javascript.js +1 -50
- package/dist/host/adapters/transport/http.js +1 -28
- package/dist/host/admitted-place.js +1 -35
- package/dist/host/archive.js +1 -152
- package/dist/host/call-context.js +1 -14
- package/dist/host/capsule-process.js +2 -62
- package/dist/host/capsule.js +9 -171
- package/dist/host/cell-receipts.js +12 -128
- package/dist/host/command-server.js +4 -0
- package/dist/host/commit-result.js +1 -5
- package/dist/host/content-needed.js +1 -8
- package/dist/host/content-store.js +1 -31
- package/dist/host/contextual-place.js +2 -72
- package/dist/host/digest.js +2 -15
- package/dist/host/hash.js +1 -9
- package/dist/host/host-controls.js +1 -19
- package/dist/host/in-process-act.js +3 -84
- package/dist/host/in-process-context.js +3 -91
- package/dist/host/in-process-root.js +6 -84
- package/dist/host/in-process.js +4 -55
- package/dist/host/index.d.ts +1 -15
- package/dist/host/index.js +1 -7
- package/dist/host/io.js +1 -11
- package/dist/host/lifetime.js +1 -79
- package/dist/host/located.js +6 -105
- package/dist/host/native/authority-card-view.js +5 -0
- package/dist/host/native/authority-card.js +1 -0
- package/dist/host/native/bounded-file.js +1 -32
- package/dist/host/native/command.js +1 -91
- package/dist/host/native/control-bridge-worker.js +2 -88
- package/dist/host/native/control-bridge.js +1 -110
- package/dist/host/native/control-selection.js +1 -32
- package/dist/host/native/custody.js +1 -91
- package/dist/host/native/deadline.js +1 -28
- package/dist/host/native/descendants.js +1 -528
- package/dist/host/native/generated-custodian.js +5 -267
- package/dist/host/native/generated.js +1 -379
- package/dist/host/native/image.js +1 -45
- package/dist/host/native/installed-package.d.ts +1 -0
- package/dist/host/native/installed-package.js +5 -0
- package/dist/host/native/jobs.js +2 -148
- package/dist/host/native/loader.js +1 -269
- package/dist/host/native/materialize.js +1 -175
- package/dist/host/native/module-closure.js +1 -130
- package/dist/host/native/module-delivery.d.ts +1 -62
- package/dist/host/native/module-delivery.js +1 -151
- package/dist/host/native/module-inventory.js +2 -0
- package/dist/host/native/module-syntax.js +1 -69
- package/dist/host/native/native-binary.js +1 -115
- package/dist/host/native/native-program.js +1 -72
- package/dist/host/native/node-jobs.js +3 -187
- package/dist/host/native/node-launch.js +1 -159
- package/dist/host/native/preload.js +1 -45
- package/dist/host/native/probes.js +1 -0
- package/dist/host/native/reading-witness-admission.js +5 -0
- package/dist/host/native/reading.js +1 -249
- package/dist/host/native/receipt-environment.js +1 -41
- package/dist/host/native/references.js +1 -30
- package/dist/host/native/root.js +1 -37
- package/dist/host/native/route.js +1 -216
- package/dist/host/native/runtime.js +1 -9
- package/dist/host/native-place-state.js +1 -0
- package/dist/host/native-reader-context.js +1 -8
- package/dist/host/native-receiver.js +1 -25
- package/dist/host/objects.js +1 -38
- package/dist/host/order.js +1 -2
- package/dist/host/persistent-host.js +1 -0
- package/dist/host/physical-lines.d.ts +1 -0
- package/dist/host/physical-lines.js +1 -0
- package/dist/host/place-act-transaction.js +4 -78
- package/dist/host/place-clock-selection.js +5 -124
- package/dist/host/ports/ingress.js +2 -57
- package/dist/host/ports/local-act.js +5 -183
- package/dist/host/ports/place-act.js +1 -134
- package/dist/host/ports/publication.js +1 -56
- package/dist/host/ports/signing.js +1 -74
- package/dist/host/ports/store.js +1 -18
- package/dist/host/ports/transport.js +1 -48
- package/dist/host/process-lifetime.js +1 -17
- package/dist/host/profile-composition.d.ts +1 -0
- package/dist/host/profile-composition.js +2 -0
- package/dist/host/provide.js +1 -183
- package/dist/host/read-only.js +1 -9
- package/dist/host/reading-closures.js +7 -227
- package/dist/host/reading-context.js +1 -53
- package/dist/host/reading-identity-types.js +0 -0
- package/dist/host/reading-identity.js +3 -0
- package/dist/host/reading-preparation.js +6 -0
- package/dist/host/reference-authenticated.d.ts +1 -40
- package/dist/host/reference-authenticated.js +3 -100
- package/dist/host/reference-contracts.js +1 -6
- package/dist/host/reference-export.js +6 -81
- package/dist/host/reference-native-api.d.ts +1 -3
- package/dist/host/reference-native-api.js +1 -3
- package/dist/host/reference-native.js +1 -74
- package/dist/host/reference-profile.js +1 -63
- package/dist/host/reference-standing.js +2 -18
- package/dist/host/reference.js +1 -24
- package/dist/host/refusals.js +2 -43
- package/dist/host/release.js +4 -256
- package/dist/host/root-clock-source.js +1 -307
- package/dist/host/selected-capsules.js +1 -50
- package/dist/host/selected-topos.js +1 -80
- package/dist/host/signature-era.js +1 -12
- package/dist/host/signing.js +2 -48
- package/dist/host/source-content.js +2 -111
- package/dist/host/standing-carrier.js +1 -18
- package/dist/host/standing-projection.js +1 -50
- package/dist/host/timing.js +1 -7
- package/dist/host/walk.js +20 -193
- package/dist/host/work-trace.js +1 -0
- package/dist/judge/late.js +1 -33
- package/dist/judge/take.js +2 -75
- package/dist/judge/widening.js +1 -25
- package/dist/land/act.js +8 -336
- package/dist/land/alias.js +1 -41
- package/dist/land/held.js +1 -23
- package/dist/land/inert.js +1 -33
- package/dist/land/leaving.js +1 -55
- package/dist/land/ledger.js +6 -188
- package/dist/land/owned.js +4 -66
- package/dist/land/sign.js +1 -53
- package/dist/land/standing-pin.js +1 -49
- package/dist/land/vouched.js +1 -112
- package/dist/land/withdraw.js +1 -24
- package/dist/observe/files.js +1 -88
- package/dist/observe/identity.js +1 -61
- package/dist/observe/match.js +1 -8
- package/dist/observe/regions.js +7 -306
- package/dist/observe/run.js +1 -41
- package/dist/observe/runner.js +4 -101
- package/dist/public-types.d.ts +2019 -0
- package/dist/render/capsule.js +1 -30
- package/dist/render/field.js +1 -40
- package/dist/render/names.js +1 -4
- package/dist/render/open.js +1 -61
- package/dist/render/page.js +1 -7
- package/dist/render/receipt-projection.js +1 -0
- package/dist/render/receipts.js +1 -47
- package/dist/render/shape.js +1 -74
- package/dist/render/target.js +4 -52
- package/dist/render/view.js +7 -197
- package/dist/vendor/bundle.json +1 -0
- package/dist/vendor/library14.js +1 -0
- package/dist/vendor/object-provider.js +42 -0
- package/dist/vendor/runtime.js +61 -0
- package/dist/wasm/adapter.d.ts +1 -51
- package/dist/wasm/adapter.js +1 -180
- package/dist/wasm/node-worker.js +1 -13
- package/dist/wasm/object.js +1 -76
- package/dist/wasm/worker.js +1 -7
- package/docs/contracts/authenticated-reference.publication.json +1 -1
- package/docs/contracts/authority-preflight.md +17 -0
- package/docs/contracts/authority-preflight.publication.json +25 -0
- package/docs/contracts/closure-delivery.md +1 -1
- package/docs/contracts/closure-delivery.publication.json +1 -1
- package/docs/contracts/conformance.json +142 -0
- package/docs/contracts/determinism.bound +9 -0
- package/docs/contracts/engine-object-projection.publication.json +1 -1
- package/docs/contracts/engine.md +21 -1
- package/docs/contracts/installed-package.md +21 -0
- package/docs/contracts/installed-package.publication.json +25 -0
- package/docs/contracts/materialized-leaf-sequence.md +15 -0
- package/docs/contracts/materialized-leaf-sequence.publication.json +25 -0
- package/docs/contracts/module-inventory.md +15 -0
- package/docs/contracts/module-inventory.publication.json +25 -0
- package/docs/contracts/native-host.md +29 -1
- package/docs/contracts/native-host.publication.json +4 -4
- package/docs/contracts/native-probes.md +13 -0
- package/docs/contracts/native-probes.publication.json +25 -0
- package/docs/contracts/native-publication.inventory.json +10 -1
- package/docs/contracts/native-view-batch.md +17 -0
- package/docs/contracts/native-view-batch.publication.json +25 -0
- package/docs/contracts/optional-wasm-adapter.publication.json +1 -1
- package/docs/contracts/physical-lines.md +19 -0
- package/docs/contracts/physical-lines.publication.json +25 -0
- package/docs/contracts/profile-composition.md +17 -0
- package/docs/contracts/profile-composition.publication.json +25 -0
- package/docs/contracts/profile-preparation-native-meaning.md +9 -0
- package/docs/contracts/publication.md +12 -0
- package/docs/contracts/reading-identity.md +61 -0
- package/docs/contracts/reading-identity.publication.json +25 -0
- package/docs/contracts/reading-witness-admission.md +49 -0
- package/docs/contracts/readme.publication.json +1 -1
- package/docs/contracts/reference-port.md +11 -0
- package/docs/contracts/reference-port.publication.json +1 -1
- package/docs/contracts/refusals.bound +346 -94
- package/docs/contracts/refusals.md +119 -39
- package/docs/contracts/refusals.publication.json +2 -2
- package/docs/contracts/views.md +8 -0
- package/docs/reference.md +9 -0
- package/licenses/wasm/{fast-text-encoding.txt → NOTICE.txt} +111 -0
- package/package.json +84 -34
- package/receipts.bound +12952 -10449
- package/samples/authority-preflight/no.json +6 -0
- package/samples/authority-preflight/yes.json +30 -0
- package/samples/engine-alphabet/reader.js +3 -1457
- package/samples/engine-alphabet/receipts.bound +7 -7
- package/samples/engine-interval/reader.js +3 -1457
- package/samples/engine-interval/receipts.bound +7 -7
- package/samples/installed-package/consumer.mjs +29 -0
- package/samples/installed-package/fixture.json +48 -0
- package/samples/installed-package/no.json +10 -0
- package/samples/installed-package/yes.json +52 -0
- package/samples/materialized-leaf-sequence/no.json +11 -0
- package/samples/materialized-leaf-sequence/yes.json +10 -0
- package/samples/module-inventory/yes.json +28 -0
- package/samples/native/physical-line-reader.mjs +1 -0
- package/samples/native/physical-line-reader.source.mjs +13 -0
- package/samples/native-host/no.json +6 -1
- package/samples/native-host/yes.json +18 -1
- package/samples/native-probes/inputs/inspection.json +28 -0
- package/samples/native-probes/no.json +7 -0
- package/samples/native-probes/yes.json +28 -0
- package/samples/native-view-batch/no.json +14 -0
- package/samples/native-view-batch/yes.json +10 -0
- package/samples/no/engine-order/reader.js +3 -1457
- package/samples/no/module-inventory/no.json +10 -0
- package/samples/physical-lines/no.json +5 -0
- package/samples/physical-lines/yes.json +9 -0
- package/samples/profile-composition/no.json +6 -0
- package/samples/profile-composition/yes.json +14 -0
- package/samples/reading-identity/no.json +26 -0
- package/samples/reading-identity/yes.json +69 -0
- package/vectors/native/authority-preflight.vector.json +55 -0
- package/vectors/native/installed-package.vector.json +31 -0
- package/vectors/native/materialized-leaf-sequence.vector.json +31 -0
- package/vectors/native/module-inventory.vector.json +56 -0
- package/vectors/native/native-host.vector.json +214 -0
- package/vectors/native/native-probes.vector.json +31 -0
- package/vectors/native/native-view-batch.vector.json +31 -0
- package/vectors/native/physical-lines.vector.json +105 -0
- package/vectors/native/profile-composition.vector.json +53 -0
- package/vectors/native/reading-identity.vector.json +139 -0
- package/vectors/native/refusals.vector.json +138 -0
- package/vendor/syntax/LICENSE.md +7 -0
- package/vendor/syntax/parser.js +1 -0
- package/.github/workflows/release.yml +0 -67
- package/.github/workflows/test.yml +0 -35
- package/dist/engine/object.d.ts +0 -17
- package/dist/engine/ports.d.ts +0 -37
- package/dist/fold/claims.d.ts +0 -29
- package/dist/host/call-context.d.ts +0 -20
- package/dist/host/commit-result.d.ts +0 -6
- package/dist/host/in-process-act.d.ts +0 -82
- package/dist/host/in-process-context.d.ts +0 -46
- package/dist/host/in-process-root.d.ts +0 -117
- package/dist/host/in-process.d.ts +0 -41
- package/dist/host/native/module-closure.d.ts +0 -35
- package/dist/host/native-receiver.d.ts +0 -19
- package/dist/host/place-act-transaction.d.ts +0 -24
- package/dist/host/place-clock-selection.d.ts +0 -55
- package/dist/host/ports/local-act.d.ts +0 -44
- package/dist/host/ports/place-act.d.ts +0 -49
- package/dist/host/ports/publication.d.ts +0 -10
- package/dist/host/reference-export.d.ts +0 -33
- package/dist/host/reference-native.d.ts +0 -30
- package/dist/host/reference-profile.d.ts +0 -23
- package/dist/host/refusals.d.ts +0 -14
- package/dist/host/root-clock-source.d.ts +0 -86
- package/licenses/wasm/jitl-quickjs-ffi-types.txt +0 -21
- package/licenses/wasm/jitl-quickjs-wasmfile-release-sync.txt +0 -47
- package/licenses/wasm/quickjs-emscripten-core.txt +0 -21
- package/licenses/wasm/topos.txt +0 -21
- /package/{licenses/wasm/bound.txt → dist/vendor/28cba430228db1c04f446c93f81b09a2705d6bf3e222d35adbe5a4cee4061884.LICENSE} +0 -0
- /package/{licenses/wasm/obligations.txt → dist/vendor/7aca161279d14bc0e054dcc281cd110aeb95be2e026b42fdf527a260e58b2aae.LICENSE} +0 -0
package/dist/fold/signed.js
CHANGED
|
@@ -1,81 +1,3 @@
|
|
|
1
|
-
import { join }
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import { fieldOf, foldClaims, isWire, sayingOf } from "./claims.js";
|
|
5
|
-
import { signaturesOf } from "./digests.js";
|
|
6
|
-
import { lockLines, lockStanding } from "./keys.js";
|
|
7
|
-
import { wordOf } from "./wire.js";
|
|
8
|
-
import { authorityFor, rootSigner } from "./signers.js";
|
|
9
|
-
import { ledgerLines, shardLines, storeOf } from "../land/ledger.js";
|
|
10
|
-
import { verifiesFields } from "../land/sign.js";
|
|
11
|
-
import { observeText } from "../observe/files.js";
|
|
12
|
-
const held = new Map();
|
|
13
|
-
const told = new Map();
|
|
14
|
-
/** Lines told to a place's own lock for a preview: folded as if the file held them, and standing only as its signed lines do. */
|
|
15
|
-
export const tellOwn = (place, lines) => void told.set(place, lines);
|
|
16
|
-
function verified(root, place, preview = true) {
|
|
17
|
-
const store = storeOf(root);
|
|
18
|
-
const lock = lockLines(store);
|
|
19
|
-
const publicText = observeText(join(root, place, LOCK)) ?? '';
|
|
20
|
-
const hasAuthority = lock.some(line => fieldOf(line, 'sig') !== '');
|
|
21
|
-
const algorithms = hasAuthority ? signaturesOf(store).admitted : [];
|
|
22
|
-
const signers = algorithms.length ? authorityFor(lock, rootSigner(root), algorithms).admitted : [];
|
|
23
|
-
const history = signers.flatMap(signer => place ? shardLines(store, signer.id, `${place}/${LOCK}`) : ledgerLines(store, signer.id)).filter(line => fieldOf(line, 'sig') !== '');
|
|
24
|
-
const text = [publicText, ...history, ...(preview ? told.get(place) ?? [] : [])].join('\n');
|
|
25
|
-
const key = `${root} ${place}`;
|
|
26
|
-
const last = held.get(key);
|
|
27
|
-
if (last !== undefined && last.text === text && last.lock === lock)
|
|
28
|
-
return last;
|
|
29
|
-
const lines = [...new Set(text.split('\n').filter(isWire))];
|
|
30
|
-
// Unrestricted coverage does not construct a region coordinate. Restricted
|
|
31
|
-
// coverage still requires the lock's declared namespace before comparison.
|
|
32
|
-
const family = signers.some(signer => !signer.coverage.includes('*')) ? wordOf(lockStanding(store), 'families', 'region') : '';
|
|
33
|
-
const stands = (line) => ownRecordAdmitted(line, place, family, signers, algorithms);
|
|
34
|
-
const applied = new Set(lines.filter(stands));
|
|
35
|
-
// A published copy of an authenticated delivery is not another inscription.
|
|
36
|
-
const projected = new Set([...applied].map(sayingOf));
|
|
37
|
-
const got = { text, lock, lines, applied, projected, folded: new Map() };
|
|
38
|
-
held.set(key, got);
|
|
39
|
-
return got;
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* A place's own lock, folded as the tree folds its own: a line that carries a signature stands only when a key the
|
|
43
|
-
* tree's lock admits signed it, inside the window that key held at the epoch it signed and inside its coverage of the
|
|
44
|
-
* place, the line's scope read as a region of the place; a line that carries none is the place's target text until the
|
|
45
|
-
* place signs its lock, and never stands where only signed lines are asked for.
|
|
46
|
-
*/
|
|
47
|
-
export function ownLockOf(root, place, signedOnly = false) {
|
|
48
|
-
const got = verified(root, place);
|
|
49
|
-
const kept = got.folded.get(signedOnly);
|
|
50
|
-
if (kept !== undefined)
|
|
51
|
-
return kept;
|
|
52
|
-
const standing = foldClaims(got.lines.filter((line) => got.applied.has(line) || (!signedOnly && !/ sig=/.test(line) && !got.projected.has(sayingOf(line))))).standing
|
|
53
|
-
.filter((line) => fieldOf(line, 'value') !== 'withdraw');
|
|
54
|
-
got.folded.set(signedOnly, standing);
|
|
55
|
-
return standing;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* What a place's own lock holds by signature — a key the tree admits signed the line, inside its window and its coverage
|
|
59
|
-
* of the place — withdrawal or not: whether one line stands there so, the lines that do, and how many were written into
|
|
60
|
-
* the lock rather than applied to it.
|
|
61
|
-
*/
|
|
62
|
-
export const admittedIn = (root, place, line) => verified(root, place).applied.has(line);
|
|
63
|
-
export const appliedIn = (root, place) => [...verified(root, place).applied];
|
|
64
|
-
export const forksIn = (root, place) => ((got) => foldClaims(got.lines.filter((line) => got.applied.has(line) || (!/ sig=/.test(line) && !got.projected.has(sayingOf(line))))).forks.map((fork) => fork.key))(verified(root, place));
|
|
65
|
-
export const writtenIn = (root, place) => ((got) => got.lines.filter((line) => !got.applied.has(line)).length)(verified(root, place));
|
|
66
|
-
/** Authenticated history excludes prospective lines told only for admission. */
|
|
67
|
-
export const appliedHistoryIn = (root, place) => [...verified(root, place, false).applied];
|
|
68
|
-
/** Shared signature/window/coordinate coverage boundary for own history. */
|
|
69
|
-
export function ownRecordAdmitted(line, place, family, signers, algorithms) {
|
|
70
|
-
const got = parse(line);
|
|
71
|
-
if (got.kind !== 'fact' || got.value.fields['sig'] === undefined)
|
|
72
|
-
return false;
|
|
73
|
-
const fields = got.value.fields;
|
|
74
|
-
const signer = signers.find((one) => one.id === fields['by']);
|
|
75
|
-
const epoch = Number(fields['epoch']) || 0;
|
|
76
|
-
if (signer === undefined || !verifiesFields(fields, signer.publicKey, algorithms))
|
|
77
|
-
return false;
|
|
78
|
-
const window = windowAt(signer, epoch);
|
|
79
|
-
return epoch >= window.start && (window.close === null || epoch <= window.close)
|
|
80
|
-
&& signer.coverage.some((prefix) => prefix === '*' || within(region(`${family}/${place}/${fields['scope'] ?? ''}`, './'), region(prefix, './')));
|
|
81
|
-
}
|
|
1
|
+
var E=Object.defineProperty;var s=(e,t)=>E(e,"name",{value:t,configurable:!0});import{AsyncLocalStorage as F}from"node:async_hooks";import{realpathSync as L}from"node:fs";import{join as K}from"../host/io.js";import{library0_region as O,library0_within as R}from"../vendor/runtime.js";import{library14_LOCK as $,library14_parse as T,library14_windowAt as q}from"../vendor/runtime.js";import{fieldOf as h,foldClaims as j,isWire as H,sayingOf as y}from"./claims.js";import{signaturesOf as N}from"./digests.js";import{lockLines as P,lockStanding as U}from"./keys.js";import{wordOf as W}from"./wire.js";import{authorityFor as z,rootSigner as B}from"./signers.js";import{ledgerLines as D,shardLines as G,storeOf as J}from"../land/ledger.js";import{verifiesFields as Q}from"../land/sign.js";import{observeText as V}from"../observe/files.js";const A=new Map,k=new Map,w=new F;function pt(e,t){const r=L(e),o=w.getStore(),i={root:r,told:new Map(o?o.root===r?o.told:[]:k)};return w.run(i,()=>{try{const n=t();if(n!==null&&(typeof n=="object"||typeof n=="function")&&"then"in n)throw Error("REFUSE\xB7own preview requires synchronous work");return n}finally{i.told.clear()}})}s(pt,"withOwnPreview");const mt=s((e,t)=>{(w.getStore()?.told??k).set(e,t)},"tellOwn");function p(e,t,r=!0){const o=J(e),i=P(o),n=V(K(e,t,$))??"",a=i.some(l=>h(l,"sig")!=="")?N(o).admitted:[],f=a.length?z(i,B(e),a).admitted:[],m=f.flatMap(l=>t?G(o,l.id,`${t}/${$}`):D(o,l.id)).filter(l=>h(l,"sig")!==""),c=w.getStore(),I=c?c.root===L(e)?c.told.get(t):void 0:k.get(t),g=[n,...m,...r?I??[]:[]].join(`
|
|
2
|
+
`),v=`${e} ${t}`,u=A.get(v);if(u!==void 0&&u.text===g&&u.lock===i)return u;const x=[...new Set(g.split(`
|
|
3
|
+
`).filter(H))],M=f.some(l=>!l.coverage.includes("*"))?W(U(o),"families","region"):"",_=s(l=>X(l,t,M,f,a),"stands"),S=new Set(x.filter(_)),C=new Set([...S].map(y)),b={text:g,lock:i,lines:x,applied:S,projected:C,folded:new Map};return A.set(v,b),b}s(p,"verified");function ut(e,t,r=!1){const o=p(e,t),i=o.folded.get(r);if(i!==void 0)return i;const n=j(o.lines.filter(d=>o.applied.has(d)||!r&&!/ sig=/.test(d)&&!o.projected.has(y(d)))).standing.filter(d=>h(d,"value")!=="withdraw");return o.folded.set(r,n),n}s(ut,"ownLockOf");const wt=s((e,t,r)=>p(e,t).applied.has(r),"admittedIn"),gt=s((e,t)=>[...p(e,t).applied],"appliedIn"),ht=s((e,t)=>(r=>j(r.lines.filter(o=>r.applied.has(o)||!/ sig=/.test(o)&&!r.projected.has(y(o)))).forks.map(o=>o.key))(p(e,t)),"forksIn"),yt=s((e,t)=>(r=>r.lines.filter(o=>!r.applied.has(o)).length)(p(e,t)),"writtenIn"),kt=s((e,t)=>[...p(e,t,!1).applied],"appliedHistoryIn");function X(e,t,r,o,i){const n=T(e);if(n.kind!=="fact"||n.value.fields.sig===void 0)return!1;const d=n.value.fields,a=o.find(c=>c.id===d.by),f=Number(d.epoch)||0;if(a===void 0||!Q(d,a.publicKey,i))return!1;const m=q(a,f);return f>=m.start&&(m.close===null||f<=m.close)&&a.coverage.some(c=>c==="*"||R(O(`${r}/${t}/${d.scope??""}`,"./"),O(c,"./")))}s(X,"ownRecordAdmitted");export{wt as admittedIn,kt as appliedHistoryIn,gt as appliedIn,ht as forksIn,ut as ownLockOf,X as ownRecordAdmitted,mt as tellOwn,pt as withOwnPreview,yt as writtenIn};
|
package/dist/fold/signers.js
CHANGED
|
@@ -1,54 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { authorityOf, isKeyClaim, signersOf } from '@lapxo/topos/wire';
|
|
3
|
-
import { verifiesFields } from "../land/sign.js";
|
|
4
|
-
import { fieldOf, parsedLine as parse } from "./claims.js";
|
|
5
|
-
import { keyFor, lockStanding } from "./keys.js";
|
|
6
|
-
import { storeOf } from "../land/ledger.js";
|
|
7
|
-
/** A lock line about the signers: the authority fold reads it. */
|
|
8
|
-
export function isSignerLock(line) {
|
|
9
|
-
const got = parse(line);
|
|
10
|
-
return got.kind === 'fact' && isKeyClaim(got.value.fields);
|
|
11
|
-
}
|
|
12
|
-
/** The authority view of a ledger: which signers the lock admits from its root, and what each line carries. */
|
|
13
|
-
export function authorityFor(lines, root, admitted, published) {
|
|
14
|
-
const fields = lines
|
|
15
|
-
.map((line) => parse(line))
|
|
16
|
-
.flatMap((got) => (got.kind === 'fact' ? [got.value.fields] : []));
|
|
17
|
-
const lock = signersOf(fields, root, (f, key) => verifiesFields(f, key, admitted));
|
|
18
|
-
return {
|
|
19
|
-
admitted: lock.admitted,
|
|
20
|
-
potential: lock.potential,
|
|
21
|
-
of: (line) => {
|
|
22
|
-
const got = parse(line);
|
|
23
|
-
return got.kind === 'fact'
|
|
24
|
-
? authorityOf(got.value.fields, lock.admitted, (f, key) => verifiesFields(f, key, admitted), published)
|
|
25
|
-
: { kind: 'grey', why: `not a claim line: ${got.why}` };
|
|
26
|
-
},
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
/** The key this lock admits for a class of writing: the fold is kept by whoever runs it, and the lock says who that is. */
|
|
30
|
-
export function writerFor(standing, kind) {
|
|
31
|
-
for (const line of standing) {
|
|
32
|
-
const key = /^keys\/([^/]+)$/.exec(fieldOf(line, 'scope'))?.[1];
|
|
33
|
-
if (key && fieldOf(line, 'measure') === 'class' && fieldOf(line, 'value') === kind)
|
|
34
|
-
return key;
|
|
35
|
-
}
|
|
36
|
-
return undefined;
|
|
37
|
-
}
|
|
38
|
-
export function publicKeyOf(root, keyId) {
|
|
39
|
-
const anchor = bootstrapAnchor(root);
|
|
40
|
-
if (anchor?.id === keyId)
|
|
41
|
-
return anchor.publicKey;
|
|
42
|
-
const said = lockStanding(storeOf(root))
|
|
43
|
-
.find((line) => fieldOf(line, 'scope') === `keys/${keyId}` && fieldOf(line, 'measure') === 'public-key' && fieldOf(line, 'value') !== 'withdraw');
|
|
44
|
-
return said === undefined ? undefined : fieldOf(said, 'value');
|
|
45
|
-
}
|
|
46
|
-
export function releaseSigner(lines) {
|
|
47
|
-
const said = (id, measure) => fieldOf(lines.find((line) => fieldOf(line, 'scope') === `keys/${id}` && fieldOf(line, 'measure') === measure && fieldOf(line, 'value') !== 'withdraw') ?? '', 'value') || undefined;
|
|
48
|
-
const id = writerFor(lines, 'authorize') ?? '';
|
|
49
|
-
return { id, keyClass: 'authorize', publicKey: said(id, 'public-key') ?? '', coverage: ['*'], depth: { lo: 1, hi: 16 }, admittedBy: [] };
|
|
50
|
-
}
|
|
51
|
-
export function rootSigner(root) {
|
|
52
|
-
const id = keyFor(storeOf(root), 'authorize');
|
|
53
|
-
return { id, keyClass: 'authorize', publicKey: publicKeyOf(root, id) ?? '', coverage: ['*'], depth: { lo: 1, hi: 16 }, admittedBy: [] };
|
|
54
|
-
}
|
|
1
|
+
var m=Object.defineProperty;var a=(e,r)=>m(e,"name",{value:r,configurable:!0});import{bootstrapAnchor as h}from"./bootstrap-anchor.js";import{library14_authorityOf as k,library14_isKeyClaim as v,library14_signersOf as b}from"../vendor/runtime.js";import{verifiesFields as d}from"../land/sign.js";import{fieldOf as t,parsedLine as c}from"./claims.js";import{keyFor as g,lockStanding as w}from"./keys.js";import{storeOf as l}from"../land/ledger.js";function B(e){const r=c(e);return r.kind==="fact"&&v(r.value.fields)}a(B,"isSignerLock");function L(e,r,i,o){const s=e.map(n=>c(n)).flatMap(n=>n.kind==="fact"?[n.value.fields]:[]),u=b(s,r,(n,f)=>d(n,f,i));return{admitted:u.admitted,potential:u.potential,of:a(n=>{const f=c(n);return f.kind==="fact"?k(f.value.fields,u.admitted,(p,y)=>d(p,y,i),o):{kind:"grey",why:`not a claim line: ${f.why}`}},"of")}}a(L,"authorityFor");function x(e,r){for(const i of e){const o=/^keys\/([^/]+)$/.exec(t(i,"scope"))?.[1];if(o&&t(i,"measure")==="class"&&t(i,"value")===r)return o}}a(x,"writerFor");function O(e,r){const i=h(e);if(i?.id===r)return i.publicKey;const o=w(l(e)).find(s=>t(s,"scope")===`keys/${r}`&&t(s,"measure")==="public-key"&&t(s,"value")!=="withdraw");return o===void 0?void 0:t(o,"value")}a(O,"publicKeyOf");function A(e){const r=a((o,s)=>t(e.find(u=>t(u,"scope")===`keys/${o}`&&t(u,"measure")===s&&t(u,"value")!=="withdraw")??"","value")||void 0,"said"),i=x(e,"authorize")??"";return{id:i,keyClass:"authorize",publicKey:r(i,"public-key")??"",coverage:["*"],depth:{lo:1,hi:16},admittedBy:[]}}a(A,"releaseSigner");function M(e){const r=g(l(e),"authorize");return{id:r,keyClass:"authorize",publicKey:O(e,r)??"",coverage:["*"],depth:{lo:1,hi:16},admittedBy:[]}}a(M,"rootSigner");export{L as authorityFor,B as isSignerLock,O as publicKeyOf,A as releaseSigner,M as rootSigner,x as writerFor};
|
package/dist/fold/stranger.js
CHANGED
|
@@ -1,24 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export
|
|
7
|
-
const dir = join(store, 'ledger');
|
|
8
|
-
return !existsSync(dir) || readdirSync(dir).length === 0;
|
|
9
|
-
}
|
|
10
|
-
export function sayStranger(root) {
|
|
11
|
-
const lines = (observeText(join(root, LOCK)) ?? '').split('\n').filter(isWire);
|
|
12
|
-
const needs = [...new Set(lines.flatMap((line) => fieldOf(line, 'needs').split('|').filter(Boolean)))].sort();
|
|
13
|
-
const uses = lines.filter((line) => {
|
|
14
|
-
const scope = fieldOf(line, 'scope');
|
|
15
|
-
return scope.startsWith('uses/') && !scope.slice('uses/'.length).includes('/') && fieldOf(line, 'value') !== 'withdraw';
|
|
16
|
-
}).map((line) => fieldOf(line, 'scope'));
|
|
17
|
-
const shape = fieldOf(lines.find((line) => fieldOf(line, 'scope').startsWith('view/') && fieldOf(line, 'shape') !== '' && fieldOf(line, 'value') !== 'withdraw') ?? '', 'shape');
|
|
18
|
-
process.stdout.write('RECEIPTS 0 read · 1 opened\n');
|
|
19
|
-
process.stdout.write(`NEEDS ${needs.join(' ')}\n`);
|
|
20
|
-
for (const scope of uses)
|
|
21
|
-
process.stdout.write(`OPEN ${scope}/\n`);
|
|
22
|
-
if (shape)
|
|
23
|
-
process.stdout.write(`RENDER ${shape}\n`);
|
|
24
|
-
}
|
|
1
|
+
var u=Object.defineProperty;var n=(s,e)=>u(s,"name",{value:e,configurable:!0});import{hostOutput as r}from"../host/call-context.js";import{existsSync as d,join as a,readdirSync as l}from"../host/io.js";import{library14_LOCK as m}from"../vendor/runtime.js";import{fieldOf as o,isWire as h}from"./claims.js";import{observeText as E}from"../observe/files.js";function x(s){const e=a(s,"ledger");return!d(e)||l(e).length===0}n(x,"emptyLedger");function C(s){const e=(E(a(s,m))??"").split(`
|
|
2
|
+
`).filter(h),c=[...new Set(e.flatMap(t=>o(t,"needs").split("|").filter(Boolean)))].sort(),f=e.filter(t=>{const p=o(t,"scope");return p.startsWith("uses/")&&!p.slice(5).includes("/")&&o(t,"value")!=="withdraw"}).map(t=>o(t,"scope")),i=o(e.find(t=>o(t,"scope").startsWith("view/")&&o(t,"shape")!==""&&o(t,"value")!=="withdraw")??"","shape");r("out",`RECEIPTS 0 read \xB7 1 opened
|
|
3
|
+
`),r("out",`NEEDS ${c.join(" ")}
|
|
4
|
+
`);for(const t of f)r("out",`OPEN ${t}/
|
|
5
|
+
`);i&&r("out",`RENDER ${i}
|
|
6
|
+
`)}n(C,"sayStranger");export{x as emptyLedger,C as sayStranger};
|
package/dist/fold/views.js
CHANGED
|
@@ -1,66 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { wordOf, wordsOf } from "./wire.js";
|
|
3
|
-
/**
|
|
4
|
-
* A view is a signed line `view/<name>` whose value lists regions in the order they are written, each at the resolution
|
|
5
|
-
* it asks for (`region@n`, the steps of each line it keeps, three when it asks for none, and the one the view is called
|
|
6
|
-
* at for `region@*`), and whose shape, when it has one, names the coordinate the view renders into. What renders a region is
|
|
7
|
-
* read where the fold is known, and a view asking one nothing renders is refused there, by name.
|
|
8
|
-
*/
|
|
9
|
-
export function viewsOf(standing) {
|
|
10
|
-
const held = wordsOf(standing, 'families');
|
|
11
|
-
const family = `${held.includes('view') || !held.length ? 'view' : wordOf(standing, 'families', 'view')}/`;
|
|
12
|
-
const views = new Map();
|
|
13
|
-
for (const line of standing) {
|
|
14
|
-
const scope = fieldOf(line, 'scope');
|
|
15
|
-
if (!scope.startsWith(family) || fieldOf(line, 'role') !== 'demands' || fieldOf(line, 'value') === 'withdraw')
|
|
16
|
-
continue;
|
|
17
|
-
const name = scope.slice(family.length);
|
|
18
|
-
if (views.has(name))
|
|
19
|
-
continue;
|
|
20
|
-
const regions = fieldOf(line, 'value').split('|').filter(Boolean)
|
|
21
|
-
.map((token) => ({ name: token.split('@')[0], at: token.includes('@') && Number.isFinite(Number(token.split('@')[1])) ? Number(token.split('@')[1]) : 3, ...(token.endsWith('@*') ? { called: true } : {}) }));
|
|
22
|
-
views.set(name, { name, regions, shape: fieldOf(line, 'shape') });
|
|
23
|
-
}
|
|
24
|
-
return views;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* A view the wire's views/world list names writes at a world that holds no view of that name of its own: the tree's line
|
|
28
|
-
* of the name, at the shape it names. A place's own view of a shape shadows the list at that shape: own over root, one
|
|
29
|
-
* writer. Two views naming the same shape in one place is a refuse at rank, before any render.
|
|
30
|
-
*/
|
|
31
|
-
export const defaulted = (standing, view, own, tree) => {
|
|
32
|
-
const family = `${wordOf(standing, 'families', 'view')}/`;
|
|
33
|
-
const owns = (name) => own.some((line) => fieldOf(line, 'scope') === `${family}${name}` && fieldOf(line, 'value') !== 'withdraw');
|
|
34
|
-
const writes = (shape) => shape !== '' && own.some((line) => fieldOf(line, 'scope').startsWith(family) && fieldOf(line, 'shape') === shape && fieldOf(line, 'value') !== 'withdraw');
|
|
35
|
-
return !writes(view.shape) && wordsOf(standing, 'views/world').includes(view.name) && tree.get(view.name)?.shape === view.shape && !owns(view.name);
|
|
36
|
-
};
|
|
37
|
-
/** Shapes two standing views of one place both name: rank refuses before a render, one path, one writer. */
|
|
38
|
-
export function sharedShapes(standing) {
|
|
39
|
-
const named = new Map();
|
|
40
|
-
for (const line of standing) {
|
|
41
|
-
const scope = fieldOf(line, 'scope');
|
|
42
|
-
if (!scope.startsWith('view/') || fieldOf(line, 'role') !== 'demands' || fieldOf(line, 'value') === 'withdraw')
|
|
43
|
-
continue;
|
|
44
|
-
const shape = fieldOf(line, 'shape');
|
|
45
|
-
if (!shape)
|
|
46
|
-
continue;
|
|
47
|
-
named.set(shape, [...(named.get(shape) ?? []), scope.slice('view/'.length)]);
|
|
48
|
-
}
|
|
49
|
-
return [...named].filter(([, names]) => new Set(names).size > 1).map(([shape, names]) => `${shape} · view/${[...new Set(names)].join(' · view/')}`);
|
|
50
|
-
}
|
|
51
|
-
;
|
|
52
|
-
const placed = new WeakMap();
|
|
53
|
-
export function placesOf(standing, view) {
|
|
54
|
-
const known = placed.get(standing) ?? new Map();
|
|
55
|
-
placed.set(standing, known);
|
|
56
|
-
const asked = known.get(`${view.name} ${view.shape}`);
|
|
57
|
-
if (asked !== undefined)
|
|
58
|
-
return asked;
|
|
59
|
-
const scope = `${wordOf(standing, 'families', 'view')}/${view.name}`;
|
|
60
|
-
const lines = standing.filter((one) => fieldOf(one, 'scope') === scope && fieldOf(one, 'value') !== 'withdraw');
|
|
61
|
-
const same = lines.filter((one) => fieldOf(one, 'value') === fieldOf(lines[0] ?? '', 'value') && fieldOf(one, 'shape') === view.shape);
|
|
62
|
-
const places = !view.shape ? [] : [...new Set(same.flatMap((one) => fieldOf(one, 'needs').split('|'))
|
|
63
|
-
.filter((need) => need === view.shape || need.endsWith(`/${view.shape}`)).map((need) => need.slice(0, need.length - view.shape.length)))];
|
|
64
|
-
known.set(`${view.name} ${view.shape}`, places);
|
|
65
|
-
return places;
|
|
66
|
-
}
|
|
1
|
+
var u=Object.defineProperty;var p=(n,s)=>u(n,"name",{value:s,configurable:!0});import{fieldOf as t}from"./claims.js";import{wordOf as f,wordsOf as h}from"./wire.js";function v(n){const s=h(n,"families"),a=`${s.includes("view")||!s.length?"view":f(n,"families","view")}/`,i=new Map;for(const o of n){const c=t(o,"scope");if(!c.startsWith(a)||t(o,"role")!=="demands"||t(o,"value")==="withdraw")continue;const r=c.slice(a.length);if(i.has(r))continue;const l=t(o,"value").split("|").filter(Boolean).map(e=>({name:e.split("@")[0],at:e.includes("@")&&Number.isFinite(Number(e.split("@")[1]))?Number(e.split("@")[1]):3,...e.endsWith("@*")?{called:!0}:{}}));i.set(r,{name:r,regions:l,shape:t(o,"shape")})}return i}p(v,"viewsOf");const W=p((n,s,a,i)=>{const o=`${f(n,"families","view")}/`,c=p(l=>a.some(e=>t(e,"scope")===`${o}${l}`&&t(e,"value")!=="withdraw"),"owns");return!p(l=>l!==""&&a.some(e=>t(e,"scope").startsWith(o)&&t(e,"shape")===l&&t(e,"value")!=="withdraw"),"writes")(s.shape)&&h(n,"views/world").includes(s.name)&&i.get(s.name)?.shape===s.shape&&!c(s.name)},"defaulted");function M(n){const s=new Map;for(const a of n){const i=t(a,"scope");if(!i.startsWith("view/")||t(a,"role")!=="demands"||t(a,"value")==="withdraw")continue;const o=t(a,"shape");o&&s.set(o,[...s.get(o)??[],i.slice(5)])}return[...s].filter(([,a])=>new Set(a).size>1).map(([a,i])=>`${a} \xB7 view/${[...new Set(i)].join(" \xB7 view/")}`)}p(M,"sharedShapes");const m=new WeakMap;function O(n,s){const a=m.get(n)??new Map;m.set(n,a);const i=a.get(`${s.name} ${s.shape}`);if(i!==void 0)return i;const o=`${f(n,"families","view")}/${s.name}`,c=n.filter(e=>t(e,"scope")===o&&t(e,"value")!=="withdraw"),r=c.filter(e=>t(e,"value")===t(c[0]??"","value")&&t(e,"shape")===s.shape),l=s.shape?[...new Set(r.flatMap(e=>t(e,"needs").split("|")).filter(e=>e===s.shape||e.endsWith(`/${s.shape}`)).map(e=>e.slice(0,e.length-s.shape.length)))]:[];return a.set(`${s.name} ${s.shape}`,l),l}p(O,"placesOf");export{W as defaulted,O as placesOf,M as sharedShapes,v as viewsOf};
|
package/dist/fold/wire.js
CHANGED
|
@@ -1,46 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { fieldOf, selfName } from "./claims.js";
|
|
3
|
-
import { selectedWireList } from "../host/selected-topos.js";
|
|
4
|
-
const spoken = topos;
|
|
5
|
-
export const namesAt = (spoken['namesAt'] ?? spoken['namesLeaf']);
|
|
6
|
-
export const roleAt = (spoken['roleAt'] ?? spoken['leafRoleOf']);
|
|
7
|
-
/** The standing line that names a wire list, under `wire/`, else the older `audit/wire/` for one era. A word the wire names is read from the lock by the list it belongs to: the instrument asks for one and refuses if the lock no longer lists it, so an alphabet is never frozen here and a family that moves is a refusal, not a silence. */
|
|
8
|
-
export const wireLine = (standing, list) => standing.find((line) => fieldOf(line, 'scope') === `wire/${list}` && fieldOf(line, 'value') !== 'withdraw')
|
|
9
|
-
?? standing.find((line) => fieldOf(line, 'scope') === `audit/wire/${list}` && fieldOf(line, 'value') !== 'withdraw');
|
|
10
|
-
export function wordsOf(standing, list) {
|
|
11
|
-
const said = wireLine(standing, list);
|
|
12
|
-
return (said === undefined ? [] : fieldOf(said, 'value').split('|')).filter(Boolean);
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* A word asked in its eras, newest first, is read in the lock it is asked of: the first era that lock's own wire lists
|
|
16
|
-
* is the word there, so a place published under an older wire is read in the word it was written in, and none is a
|
|
17
|
-
* refusal. A list that names exactly one word is read as that word; a list that names none, or more than one, is a
|
|
18
|
-
* refusal. The older `audit/wire/` prefix is one era of `wire/`, not a fall-back to another lock.
|
|
19
|
-
*/
|
|
20
|
-
export function wordOf(standing, list, name) {
|
|
21
|
-
const local = wordsOf(standing, list);
|
|
22
|
-
const pins = standing.filter(line => fieldOf(line, 'scope').startsWith('uses/') && fieldOf(line, 'value') !== 'withdraw');
|
|
23
|
-
// A required word may come from selected standing without copying foreign claims.
|
|
24
|
-
const held = wireLine(standing, list) === undefined && pins.length
|
|
25
|
-
? selectedWireList(standing, Number.MAX_SAFE_INTEGER, pins, list) : local;
|
|
26
|
-
const eras = typeof name === 'string' ? [name] : name;
|
|
27
|
-
const found = eras.find((one) => held.includes(one));
|
|
28
|
-
if (found !== undefined)
|
|
29
|
-
return found;
|
|
30
|
-
throw new Error(`${selfName()}: REFUSE·wire \`${eras.join('|')}\` is not one of \`wire/${list}\`: ${held.join('|') || 'the lock lists none'}`);
|
|
31
|
-
}
|
|
32
|
-
export function theWord(standing, list) {
|
|
33
|
-
const held = wordsOf(standing, list);
|
|
34
|
-
if (held.length !== 1) {
|
|
35
|
-
throw new Error(`${selfName()}: REFUSE·wire \`wire/${list}\` names ${held.length} words, not one: ${held.join('|') || 'the lock lists none'}`);
|
|
36
|
-
}
|
|
37
|
-
return wordOf(standing, list, held);
|
|
38
|
-
}
|
|
39
|
-
export const wordOn = (standing, list, fallback) => theWord(wordsOf(standing, list).length ? standing : fallback, list);
|
|
40
|
-
/** A named word, read from the standing that lists it, else from the fallback lock. */
|
|
41
|
-
export function wordFrom(standing, list, name, fallback) {
|
|
42
|
-
const eras = typeof name === 'string' ? [name] : name;
|
|
43
|
-
return wordOf(eras.some((one) => wordsOf(standing, list).includes(one)) ? standing : fallback, list, name);
|
|
44
|
-
}
|
|
45
|
-
export const said = (lines, scope) => lines
|
|
46
|
-
.filter((line) => fieldOf(line, 'scope') === scope && fieldOf(line, 'value') !== 'withdraw').flatMap((line) => fieldOf(line, 'value').split('|').filter(Boolean));
|
|
1
|
+
var $=Object.defineProperty;var n=(r,o)=>$(r,"name",{value:o,configurable:!0});import*as m from"../vendor/library14.js";import{fieldOf as t,selfName as d}from"./claims.js";import{selectedWireList as x}from"../host/selected-topos.js";const i=m,F=i.namesAt??i.namesLeaf,R=i.roleAt??i.leafRoleOf,a=n((r,o)=>r.find(e=>t(e,"scope")===`wire/${o}`&&t(e,"value")!=="withdraw")??r.find(e=>t(e,"scope")===`audit/wire/${o}`&&t(e,"value")!=="withdraw"),"wireLine");function c(r,o){const e=a(r,o);return(e===void 0?[]:t(e,"value").split("|")).filter(Boolean)}n(c,"wordsOf");function h(r,o,e){const l=c(r,o),p=r.filter(f=>t(f,"scope").startsWith("uses/")&&t(f,"value")!=="withdraw"),s=a(r,o)===void 0&&p.length?x(r,Number.MAX_SAFE_INTEGER,p,o):l,w=typeof e=="string"?[e]:e,u=w.find(f=>s.includes(f));if(u!==void 0)return u;throw new Error(`${d()}: REFUSE\xB7wire \`${w.join("|")}\` is not one of \`wire/${o}\`: ${s.join("|")||"the lock lists none"}`)}n(h,"wordOf");function E(r,o){const e=c(r,o);if(e.length!==1)throw new Error(`${d()}: REFUSE\xB7wire \`wire/${o}\` names ${e.length} words, not one: ${e.join("|")||"the lock lists none"}`);return h(r,o,e)}n(E,"theWord");const j=n((r,o,e)=>E(c(r,o).length?r:e,o),"wordOn");function k(r,o,e,l){return h((typeof e=="string"?[e]:e).some(s=>c(r,o).includes(s))?r:l,o,e)}n(k,"wordFrom");const L=n((r,o)=>r.filter(e=>t(e,"scope")===o&&t(e,"value")!=="withdraw").flatMap(e=>t(e,"value").split("|").filter(Boolean)),"said");export{F as namesAt,R as roleAt,L as said,E as theWord,a as wireLine,k as wordFrom,h as wordOf,j as wordOn,c as wordsOf};
|
package/dist/fold/zoom.js
CHANGED
|
@@ -1,81 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import { observeText } from "../observe/files.js";
|
|
5
|
-
import { placesIn } from "./places.js";
|
|
6
|
-
/**
|
|
7
|
-
* A line of the tree seen from inside a place: every path it names under the place is read from the place's root, and
|
|
8
|
-
* a path outside it is dropped, since the place alone cannot read it. The place's name drops out of the scope, the condition
|
|
9
|
-
* and the policy a line is held at, and a cone names the coordinates it covers the same way; the place itself is `./`. In a
|
|
10
|
-
* scope the name drops out of the step after the family, or after the one word that qualifies it (prose/en, hazard/<kind>,
|
|
11
|
-
* source/<measure>); a deeper step that spells it is inside a name, such as a package a module imports, and stays.
|
|
12
|
-
*/
|
|
13
|
-
export function zoomed(line, place) {
|
|
14
|
-
const got = parse(line);
|
|
15
|
-
if (got.kind !== 'fact')
|
|
16
|
-
return line;
|
|
17
|
-
const fields = { ...got.value.fields };
|
|
18
|
-
const under = `${place}/`;
|
|
19
|
-
const paths = (value) => value.split('|').filter(Boolean)
|
|
20
|
-
.flatMap((one) => (one === under ? ['./'] : one.startsWith(under) ? [one.slice(under.length)] : [])).join('|');
|
|
21
|
-
const scope = (value) => {
|
|
22
|
-
if (value === under)
|
|
23
|
-
return './';
|
|
24
|
-
if (value.startsWith(under))
|
|
25
|
-
return value.slice(under.length);
|
|
26
|
-
const steps = value.split('/');
|
|
27
|
-
const at = steps.findIndex((step, i) => step === place && (i === 1 || i === 2) && i < steps.length - 1);
|
|
28
|
-
return at < 0 ? value : [...steps.slice(0, at), ...steps.slice(at + 1)].join('/');
|
|
29
|
-
};
|
|
30
|
-
if (fields['needs'] !== undefined) {
|
|
31
|
-
const kept = paths(fields['needs']);
|
|
32
|
-
if (kept)
|
|
33
|
-
fields['needs'] = kept;
|
|
34
|
-
else
|
|
35
|
-
delete fields['needs'];
|
|
36
|
-
}
|
|
37
|
-
for (const name of ['scope', 'condition'])
|
|
38
|
-
if (fields[name])
|
|
39
|
-
fields[name] = scope(fields[name]);
|
|
40
|
-
const at = fields['at'] ?? '';
|
|
41
|
-
const colon = at.indexOf(':');
|
|
42
|
-
if (colon > 0 && at.startsWith(under, colon + 1))
|
|
43
|
-
fields['at'] = `${at.slice(0, colon + 1)}${at.slice(colon + 1 + under.length)}`;
|
|
44
|
-
if (fields['measure'] === 'cone' && fields['value'])
|
|
45
|
-
fields['value'] = paths(fields['value']);
|
|
46
|
-
return canonical(fields);
|
|
47
|
-
}
|
|
48
|
-
/** The lines of each place's own lock that still name the place: seen from inside a place, no scope carries its name. */
|
|
49
|
-
export function namingTheirPlace(root) {
|
|
50
|
-
return placesIn(root).filter(name => !name.startsWith('.')).flatMap((name) => {
|
|
51
|
-
const own = (observeText(join(root, name, LOCK)) ?? '').split('\n').filter(isWire);
|
|
52
|
-
return foldClaims(own).standing.filter((line) => fieldOf(line, 'value') !== 'withdraw')
|
|
53
|
-
.map((line) => fieldOf(line, 'scope')).filter((scope) => scope.startsWith(`${name}/`) || scope.includes(`/${name}/`));
|
|
54
|
-
}).length;
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* What a zoom rewrote that is not the place: over each place the lock publishes, every scope and condition of the tree
|
|
58
|
-
* and of the place's receipts that spells the place as a step, zoomed from inside it. Losing the place's step after the
|
|
59
|
-
* family, or after the one word qualifying it, is the zoom; any other rewrite took a value for the place.
|
|
60
|
-
*/
|
|
61
|
-
export function zoomedOutsideThePlace(root, standing) {
|
|
62
|
-
const places = standing.filter((line) => /^publish\/[^/]+\/bootstrap$/.test(fieldOf(line, 'scope')) && fieldOf(line, 'value') !== 'withdraw')
|
|
63
|
-
.map((line) => fieldOf(line, 'scope').split('/')[1]);
|
|
64
|
-
const lost = (before, after, place) => {
|
|
65
|
-
if (after === before)
|
|
66
|
-
return false;
|
|
67
|
-
if (before === `${place}/`)
|
|
68
|
-
return after !== './';
|
|
69
|
-
if (before.startsWith(`${place}/`))
|
|
70
|
-
return after !== before.slice(place.length + 1);
|
|
71
|
-
const steps = before.split('/');
|
|
72
|
-
return ![1, 2].some((i) => steps[i] === place && i < steps.length - 1 && after === [...steps.slice(0, i), ...steps.slice(i + 1)].join('/'));
|
|
73
|
-
};
|
|
74
|
-
return places.reduce((count, place) => {
|
|
75
|
-
const text = observeText(join(root, place, RECEIPTS));
|
|
76
|
-
const receipts = text === undefined ? [] : text.split('\n').filter(isWire);
|
|
77
|
-
return count + [...standing, ...receipts].flatMap((line) => ['scope', 'condition']
|
|
78
|
-
.filter((field) => fieldOf(line, field).split('/').includes(place))
|
|
79
|
-
.filter((field) => lost(fieldOf(line, field), fieldOf(zoomed(line, place), field), place))).length;
|
|
80
|
-
}, 0);
|
|
81
|
-
}
|
|
1
|
+
var W=Object.defineProperty;var p=(l,i)=>W(l,"name",{value:i,configurable:!0});import{join as m}from"../host/io.js";import{library14_canonical as w,library14_LOCK as C,library14_parse as O,library14_RECEIPTS as T}from"../vendor/runtime.js";import{fieldOf as f,foldClaims as j,isWire as g}from"./claims.js";import{observeText as $}from"../observe/files.js";import{placesIn as y}from"./places.js";function E(l,i){const d=O(l);if(d.kind!=="fact")return l;const t={...d.value.fields},s=`${i}/`,r=p(e=>e.split("|").filter(Boolean).flatMap(a=>a===s?["./"]:a.startsWith(s)?[a.slice(s.length)]:[]).join("|"),"paths"),c=p(e=>{if(e===s)return"./";if(e.startsWith(s))return e.slice(s.length);const a=e.split("/"),u=a.findIndex((x,h)=>x===i&&(h===1||h===2)&&h<a.length-1);return u<0?e:[...a.slice(0,u),...a.slice(u+1)].join("/")},"scope");if(t.needs!==void 0){const e=r(t.needs);e?t.needs=e:delete t.needs}for(const e of["scope","condition"])t[e]&&(t[e]=c(t[e]));const o=t.at??"",n=o.indexOf(":");return n>0&&o.startsWith(s,n+1)&&(t.at=`${o.slice(0,n+1)}${o.slice(n+1+s.length)}`),t.measure==="cone"&&t.value&&(t.value=r(t.value)),w(t)}p(E,"zoomed");function k(l){return y(l).filter(i=>!i.startsWith(".")).flatMap(i=>{const d=($(m(l,i,C))??"").split(`
|
|
2
|
+
`).filter(g);return j(d).standing.filter(t=>f(t,"value")!=="withdraw").map(t=>f(t,"scope")).filter(t=>t.startsWith(`${i}/`)||t.includes(`/${i}/`))}).length}p(k,"namingTheirPlace");function z(l,i){const d=i.filter(s=>/^publish\/[^/]+\/bootstrap$/.test(f(s,"scope"))&&f(s,"value")!=="withdraw").map(s=>f(s,"scope").split("/")[1]),t=p((s,r,c)=>{if(r===s)return!1;if(s===`${c}/`)return r!=="./";if(s.startsWith(`${c}/`))return r!==s.slice(c.length+1);const o=s.split("/");return![1,2].some(n=>o[n]===c&&n<o.length-1&&r===[...o.slice(0,n),...o.slice(n+1)].join("/"))},"lost");return d.reduce((s,r)=>{const c=$(m(l,r,T)),o=c===void 0?[]:c.split(`
|
|
3
|
+
`).filter(g);return s+[...i,...o].flatMap(n=>["scope","condition"].filter(e=>f(n,e).split("/").includes(r)).filter(e=>t(f(n,e),f(E(n,r),e),r))).length},0)}p(z,"zoomedOutsideThePlace");export{k as namingTheirPlace,E as zoomed,z as zoomedOutsideThePlace};
|
package/dist/host/act-cost.js
CHANGED
|
@@ -1,25 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export class ActCosts {
|
|
3
|
-
constructor(clock = () => performance.now()) {
|
|
4
|
-
this.occupied = 0;
|
|
5
|
-
this.largest = 0;
|
|
6
|
-
this.depth = 0;
|
|
7
|
-
this.clock = clock;
|
|
8
|
-
this.began = clock();
|
|
9
|
-
}
|
|
10
|
-
begin() {
|
|
11
|
-
const started = this.clock(), outer = this.depth++ === 0;
|
|
12
|
-
let closed = false;
|
|
13
|
-
return () => { if (closed)
|
|
14
|
-
throw Error('Act measurement closed twice'); closed = true; const elapsed = Math.max(0, this.clock() - started); this.depth--; this.largest = Math.max(this.largest, elapsed); if (outer)
|
|
15
|
-
this.occupied += elapsed; };
|
|
16
|
-
}
|
|
17
|
-
measure(work) { const end = this.begin(); try {
|
|
18
|
-
return work();
|
|
19
|
-
}
|
|
20
|
-
finally {
|
|
21
|
-
end();
|
|
22
|
-
} }
|
|
23
|
-
seconds() { return Math.max(0, Math.round(Math.max(this.largest, this.clock() - this.began - this.occupied) / 1000)); }
|
|
24
|
-
}
|
|
25
|
-
export const actCosts = new ActCosts();
|
|
1
|
+
var h=Object.defineProperty;var e=(s,t)=>h(s,"name",{value:t,configurable:!0});import{AsyncLocalStorage as l}from"node:async_hooks";class n{static{e(this,"ActCosts")}constructor(t=()=>performance.now()){this.occupied=0,this.largest=0,this.depth=0,this.clock=t,this.began=t()}begin(){const t=this.clock(),r=this.depth++===0;let i=!1;return()=>{if(i)throw Error("Act measurement closed twice");i=!0;const o=Math.max(0,this.clock()-t);this.depth--,this.largest=Math.max(this.largest,o),r&&(this.occupied+=o)}}measure(t){const r=this.begin();try{return t()}finally{r()}}measurement(){const t=Math.max(0,this.clock()-this.began),r=Math.max(0,t-this.occupied);return{elapsedMilliseconds:t,declaredMilliseconds:this.occupied,largestDeclaredMilliseconds:this.largest,unpartitionedMilliseconds:r,costMilliseconds:Math.max(this.largest,r)}}seconds(){return Math.max(0,Math.round(Math.max(this.largest,this.clock()-this.began-this.occupied)/1e3))}}const d=new n,a=new l;function p(s,t=()=>performance.now()){return a.run(new n(t),s)}e(p,"withActCosts");const c=e(()=>a.getStore()??d,"current"),g={begin:e(()=>c().begin(),"begin"),measure(s){return c().measure(s)},seconds:e(()=>c().seconds(),"seconds"),measurement:e(()=>c().measurement(),"measurement")};export{n as ActCosts,g as actCosts,p as withActCosts};
|
|
@@ -1,30 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { formatSignature, parseSignature } from '@lapxo/topos/wire';
|
|
3
|
-
/**
|
|
4
|
-
* The act of signing: canonical bytes, a private key and the algorithm the wire names for this era in; a signature
|
|
5
|
-
* value out, whose form is the algebra's. The host runs the act and knows no name: which algorithms a signature may
|
|
6
|
-
* carry, this era's and the ones the lines before it were signed under, is told by whoever read the lock.
|
|
7
|
-
*/
|
|
8
|
-
export const signBytes = (bytes, privateKeyPem, algorithm) => formatSignature(algorithm, sign(null, Buffer.from(bytes, 'utf8'), createPrivateKey(privateKeyPem)).toString('base64'));
|
|
9
|
-
/** A public key as the lock carries it: base64 SPKI. A PEM is accepted where a tree still holds one. */
|
|
10
|
-
function publicKeyOf(publicKey) {
|
|
11
|
-
return publicKey.startsWith('-----')
|
|
12
|
-
? createPublicKey(publicKey)
|
|
13
|
-
: createPublicKey({ key: Buffer.from(publicKey, 'base64'), format: 'der', type: 'spki' });
|
|
14
|
-
}
|
|
15
|
-
export function verifyBytes(bytes, publicKeyPem, signature, admitted) {
|
|
16
|
-
const value = parseSignature(signature);
|
|
17
|
-
if (!value || !admitted.includes(value.algorithm))
|
|
18
|
-
return false;
|
|
19
|
-
const raw = Buffer.from(value.raw, 'base64');
|
|
20
|
-
if (raw.length === 0)
|
|
21
|
-
return false;
|
|
22
|
-
try {
|
|
23
|
-
return verify(null, Buffer.from(bytes, 'utf8'), publicKeyOf(publicKeyPem), raw);
|
|
24
|
-
}
|
|
25
|
-
catch (err) {
|
|
26
|
-
if (err instanceof Error)
|
|
27
|
-
return false;
|
|
28
|
-
throw err;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
1
|
+
var u=Object.defineProperty;var t=(r,e)=>u(r,"name",{value:e,configurable:!0});import{createPrivateKey as l,createPublicKey as o,sign as m,verify as c}from"node:crypto";import{library14_formatSignature as y,library14_parseSignature as g}from"../../../vendor/runtime.js";const S=t((r,e,f)=>y(f,m(null,Buffer.from(r,"utf8"),l(e)).toString("base64")),"signBytes");function p(r){return r.startsWith("-----")?o(r):o({key:Buffer.from(r,"base64"),format:"der",type:"spki"})}t(p,"publicKeyOf");function v(r,e,f,s){const a=g(f);if(!a||!s.includes(a.algorithm))return!1;const n=Buffer.from(a.raw,"base64");if(n.length===0)return!1;try{return c(null,Buffer.from(r,"utf8"),p(e),n)}catch(i){if(i instanceof Error)return!1;throw i}}t(v,"verifyBytes");export{S as signBytes,v as verifyBytes};
|
|
@@ -1,50 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { extname } from 'node:path';
|
|
3
|
-
/** Host module syntax, never wire or domain interpretation. Reading imports executes no module. */
|
|
4
|
-
// The package's minimum Node runtime provides this API; older build-only Node types do not.
|
|
5
|
-
const require = nodeModule.createRequire(import.meta.url);
|
|
6
|
-
const { parse } = require('acorn');
|
|
7
|
-
const stripTypeScriptTypes = nodeModule.stripTypeScriptTypes;
|
|
8
|
-
export function moduleImports(source, coordinate) {
|
|
9
|
-
const code = extname(coordinate) === '.ts' ? stripTypeScriptTypes(source, { mode: 'transform' }) : source;
|
|
10
|
-
let tree;
|
|
11
|
-
try {
|
|
12
|
-
tree = parse(code, { ecmaVersion: 'latest', sourceType: 'module', allowReturnOutsideFunction: true, allowHashBang: true });
|
|
13
|
-
}
|
|
14
|
-
catch {
|
|
15
|
-
throw Error('REFUSE·source module syntax cannot be read: ' + coordinate);
|
|
16
|
-
}
|
|
17
|
-
const found = new Set();
|
|
18
|
-
const literal = stringLiteral;
|
|
19
|
-
const visit = (node) => {
|
|
20
|
-
if (!node || typeof node !== 'object')
|
|
21
|
-
return;
|
|
22
|
-
if (Array.isArray(node)) {
|
|
23
|
-
for (const child of node)
|
|
24
|
-
visit(child);
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
const n = node;
|
|
28
|
-
let specifier;
|
|
29
|
-
if (n['type'] === 'ImportDeclaration' || n['type'] === 'ExportNamedDeclaration' || n['type'] === 'ExportAllDeclaration' || n['type'] === 'ImportExpression')
|
|
30
|
-
specifier = literal(n['source']);
|
|
31
|
-
if (n['type'] === 'CallExpression') {
|
|
32
|
-
const callee = n['callee'];
|
|
33
|
-
if (callee?.['type'] === 'Identifier' && callee['name'] === 'require')
|
|
34
|
-
specifier = literal(n['arguments'][0]);
|
|
35
|
-
}
|
|
36
|
-
if (specifier !== undefined)
|
|
37
|
-
found.add(specifier);
|
|
38
|
-
for (const child of Object.values(n))
|
|
39
|
-
visit(child);
|
|
40
|
-
};
|
|
41
|
-
visit(tree);
|
|
42
|
-
return [...found];
|
|
43
|
-
}
|
|
44
|
-
/** A JavaScript literal value; syntax inventory never executes it. */
|
|
45
|
-
export const stringLiteral = (node) => {
|
|
46
|
-
if (!node || typeof node !== 'object')
|
|
47
|
-
return;
|
|
48
|
-
const n = node;
|
|
49
|
-
return n['type'] === 'Literal' && typeof n['value'] === 'string' ? n['value'] : undefined;
|
|
50
|
-
};
|
|
1
|
+
import{moduleImports as r}from"../../native/module-syntax.js";export{r as moduleImports};
|
|
@@ -1,28 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export async function fetchBytes(location, limits) {
|
|
3
|
-
const signal = AbortSignal.timeout(limits.timeoutMs), response = await fetch(location, { signal });
|
|
4
|
-
if (!response.ok)
|
|
5
|
-
throw Error(`HTTP ${response.status}`);
|
|
6
|
-
const reader = response.body?.getReader();
|
|
7
|
-
if (!reader)
|
|
8
|
-
return new Uint8Array();
|
|
9
|
-
const chunks = [];
|
|
10
|
-
let size = 0;
|
|
11
|
-
try {
|
|
12
|
-
for (;;) {
|
|
13
|
-
const part = await reader.read();
|
|
14
|
-
if (part.done)
|
|
15
|
-
break;
|
|
16
|
-
size += part.value.length;
|
|
17
|
-
if (size > limits.responseBytes) {
|
|
18
|
-
await reader.cancel();
|
|
19
|
-
throw Error('response exceeds declared byte bound');
|
|
20
|
-
}
|
|
21
|
-
chunks.push(part.value);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
finally {
|
|
25
|
-
reader.releaseLock();
|
|
26
|
-
}
|
|
27
|
-
return Buffer.concat(chunks);
|
|
28
|
-
}
|
|
1
|
+
var h=Object.defineProperty;var s=(n,a)=>h(n,"name",{value:a,configurable:!0});import{BoundRefusal as c}from"../../refusals.js";class w extends Error{static{s(this,"ContentUnavailable")}}async function E(n,a,o={}){if(o.signal?.aborted)throw new c("reference/cancelled","REFUSE\xB7reference cancelled");const l=AbortSignal.timeout(a.timeoutMs),t=o.signal?AbortSignal.any([l,o.signal]):l;let r;const d=s(()=>{r?.cancel().catch(()=>{})},"cancel");t.addEventListener("abort",d,{once:!0});try{const e=await fetch(n,{signal:t,redirect:"manual"});if(e.status>=300&&e.status<400)throw new c("reference/transport","REFUSE\xB7transport redirect is not admitted");if(!e.ok)throw new w(`HTTP ${e.status}`);if(r=e.body?.getReader(),!r)return new Uint8Array;const f=[];let u=0;for(;;){const i=await r.read();if(t.aborted)throw t.reason;if(i.done)break;if(u+=i.value.length,u>a.responseBytes)throw await r.cancel(),new c("host-port/budget","REFUSE\xB7transport response exceeds declared byte bound");f.push(i.value)}return Buffer.concat(f)}catch(e){throw t.aborted?new c(o.signal?.aborted?"reference/cancelled":"host-port/timeout","REFUSE\xB7reference transport interrupted"):e instanceof TypeError?new w(e.message):e}finally{t.removeEventListener("abort",d),r?.releaseLock()}}s(E,"fetchBytes");export{w as ContentUnavailable,E as fetchBytes};
|
|
@@ -1,35 +1 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { admissionAnchor, admissionHistoryAt } from "../fold/admission-history.js";
|
|
3
|
-
import { projectAuthenticatedStanding, publishedStandingLines } from "./standing-projection.js";
|
|
4
|
-
import { createHash } from 'node:crypto';
|
|
5
|
-
// One bounded historical projection, never a current authority/lease verdict.
|
|
6
|
-
// Its complete inputs are reread before lookup, including original signatures.
|
|
7
|
-
let historicalProjection;
|
|
8
|
-
function historicalIdentity(history, anchor) {
|
|
9
|
-
const hash = createHash('sha256'), text = hashText.bind(undefined, hash);
|
|
10
|
-
text('authenticated-root-history/1');
|
|
11
|
-
text(String(history.length));
|
|
12
|
-
for (const line of history)
|
|
13
|
-
text(line);
|
|
14
|
-
text(JSON.stringify(anchor));
|
|
15
|
-
return hash.digest('hex');
|
|
16
|
-
}
|
|
17
|
-
/** Existing admission-snapshot authentication and folded live projection.
|
|
18
|
-
* Consumer configuration evidence only; never a new authority lock. */
|
|
19
|
-
export function authenticatedRootStanding(root) {
|
|
20
|
-
const history = admissionHistoryAt(root, Number.MAX_SAFE_INTEGER), anchor = admissionAnchor(root);
|
|
21
|
-
const identity = historicalIdentity(history, anchor);
|
|
22
|
-
if (historicalProjection?.identity === identity)
|
|
23
|
-
return [...historicalProjection.standing];
|
|
24
|
-
const standing = projectAuthenticatedStanding(history, anchor);
|
|
25
|
-
historicalProjection = { identity, standing: Object.freeze([...standing]) };
|
|
26
|
-
return [...standing];
|
|
27
|
-
}
|
|
28
|
-
/** Legacy Root lines remain unchanged; contextual public output has its own carrier. */
|
|
29
|
-
export const authenticatedStanding = authenticatedRootStanding;
|
|
30
|
-
/** Public current configuration omits withdrawal markers; typed effective history
|
|
31
|
-
* remains intact for the existing typed-object projection. Internal readers keep
|
|
32
|
-
* authenticatedStanding, including its historical markers. */
|
|
33
|
-
export function publicStandingLines(root) {
|
|
34
|
-
return publishedStandingLines(authenticatedRootStanding(root));
|
|
35
|
-
}
|
|
1
|
+
var f=Object.defineProperty;var s=(t,n)=>f(t,"name",{value:n,configurable:!0});import{hashText as g}from"./hash.js";import{admissionAnchor as m,admissionHistoryAt as p}from"../fold/admission-history.js";import{projectAuthenticatedStanding as l,publishedStandingLines as S}from"./standing-projection.js";import{createHash as b}from"node:crypto";let a;const d=new WeakMap;function x(t,n){const i=JSON.stringify(n),e=Object.isFrozen(t)?d.get(t):void 0;if(e?.anchor===i)return e.identity;const o=b("sha256"),r=g.bind(void 0,o);r("authenticated-root-history/1"),r(String(t.length));for(const u of t)r(u);r(i);const c=o.digest("hex");return Object.isFrozen(t)&&d.set(t,{anchor:i,identity:c}),c}s(x,"historicalIdentity");function h(t){const n=p(t,Number.MAX_SAFE_INTEGER),i=m(t),e=x(n,i);if(a?.identity===e)return a.standing;const o=l(n,i);return a={identity:e,standing:Object.freeze([...o])},a.standing}s(h,"authenticatedRootStanding");const E=h;function F(t){return S(h(t))}s(F,"publicStandingLines");export{h as authenticatedRootStanding,E as authenticatedStanding,F as publicStandingLines};
|