@interop/wallet-core 0.51.0 → 0.52.1
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/README.md +7 -11
- package/dist/clientAnnex/credentialAnchoredGenesis.d.ts +2 -2
- package/dist/clientAnnex/credentialAnchoredGenesis.d.ts.map +1 -1
- package/dist/clientAnnex/credentialAnchoredGenesis.js +1 -1
- package/dist/clientAnnex/forget.d.ts +18 -6
- package/dist/clientAnnex/forget.d.ts.map +1 -1
- package/dist/clientAnnex/forget.js +19 -6
- package/dist/clientAnnex/forget.js.map +1 -1
- package/dist/clientAnnex/forgetLast.d.ts +33 -20
- package/dist/clientAnnex/forgetLast.d.ts.map +1 -1
- package/dist/clientAnnex/forgetLast.js +43 -17
- package/dist/clientAnnex/forgetLast.js.map +1 -1
- package/dist/clientAnnex/gc.d.ts +3 -3
- package/dist/clientAnnex/gc.d.ts.map +1 -1
- package/dist/clientAnnex/gc.js +2 -2
- package/dist/clientAnnex/gc.js.map +1 -1
- package/dist/clientAnnex/index.d.ts +5 -5
- package/dist/clientAnnex/index.d.ts.map +1 -1
- package/dist/clientAnnex/index.js +4 -4
- package/dist/clientAnnex/index.js.map +1 -1
- package/dist/clientAnnex/ladder.d.ts +19 -11
- package/dist/clientAnnex/ladder.d.ts.map +1 -1
- package/dist/clientAnnex/ladder.js +77 -14
- package/dist/clientAnnex/ladder.js.map +1 -1
- package/dist/clientAnnex/ladderAnchored.d.ts +36 -7
- package/dist/clientAnnex/ladderAnchored.d.ts.map +1 -1
- package/dist/clientAnnex/ladderAnchored.js +80 -18
- package/dist/clientAnnex/ladderAnchored.js.map +1 -1
- package/dist/clientAnnex/log.d.ts +6 -6
- package/dist/clientAnnex/log.d.ts.map +1 -1
- package/dist/clientAnnex/log.js +8 -8
- package/dist/clientAnnex/log.js.map +1 -1
- package/dist/clientAnnex/recoveryLadderAnchored.d.ts +7 -7
- package/dist/clientAnnex/recoveryLadderAnchored.js +9 -9
- package/dist/clientAnnex/recoveryLadderAnchored.js.map +1 -1
- package/dist/clientAnnex/selfEnroll.d.ts +6 -4
- package/dist/clientAnnex/selfEnroll.d.ts.map +1 -1
- package/dist/clientAnnex/selfEnroll.js +19 -7
- package/dist/clientAnnex/selfEnroll.js.map +1 -1
- package/dist/clients/listing.d.ts +1 -1
- package/dist/clients/listing.d.ts.map +1 -1
- package/dist/clients/listing.js +1 -1
- package/dist/clients/listing.js.map +1 -1
- package/dist/clients/revocation.d.ts +1 -1
- package/dist/clients/rosterPolicy.d.ts +1 -1
- package/dist/clients/rosterPolicy.d.ts.map +1 -1
- package/dist/descriptors/acquire.js +1 -1
- package/dist/descriptors/logSource.d.ts +1 -2
- package/dist/descriptors/logSource.d.ts.map +1 -1
- package/dist/descriptors/logSource.js +2 -2
- package/dist/descriptors/logSource.js.map +1 -1
- package/dist/enrollment/enrollment.d.ts +1 -1
- package/dist/enrollment/enrollment.d.ts.map +1 -1
- package/dist/enrollment/enrollment.js +2 -1
- package/dist/enrollment/enrollment.js.map +1 -1
- package/dist/genesis/accountGenesis.d.ts +1 -1
- package/dist/genesis/accountGenesis.d.ts.map +1 -1
- package/dist/genesis/accountGenesis.js +1 -1
- package/dist/index.d.ts +1 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -3
- package/dist/index.js.map +1 -1
- package/dist/keyring/kdf.d.ts +6 -20
- package/dist/keyring/kdf.d.ts.map +1 -1
- package/dist/keyring/kdf.js +8 -5
- package/dist/keyring/kdf.js.map +1 -1
- package/dist/keyring/unlockSpace.js +1 -1
- package/dist/keys/rosterLogStore.d.ts +16 -14
- package/dist/keys/rosterLogStore.d.ts.map +1 -1
- package/dist/keys/rosterLogStore.js +149 -32
- package/dist/keys/rosterLogStore.js.map +1 -1
- package/dist/keys/rosterStore.d.ts +8 -7
- package/dist/keys/rosterStore.d.ts.map +1 -1
- package/dist/keys/rosterStore.js +6 -6
- package/dist/keys/rosterStore.js.map +1 -1
- package/dist/keys/spaceEpochs.d.ts +1 -1
- package/dist/keys/spaceEpochs.js +1 -1
- package/dist/keys/userKeyRoster.d.ts +3 -3
- package/dist/keys/userKeyRoster.d.ts.map +1 -1
- package/dist/keys/userKeyRoster.js +3 -3
- package/dist/keys/userKeyRoster.js.map +1 -1
- package/dist/recovery/index.d.ts +2 -2
- package/dist/recovery/index.js +2 -2
- package/dist/recovery/recoveryDelegation.js +1 -1
- package/dist/recovery/recoveryDelegation.js.map +1 -1
- package/dist/recovery/recoveryWebvh.d.ts +4 -4
- package/dist/recovery/recoveryWebvh.js +5 -5
- package/dist/request/appKey.d.ts +9 -3
- package/dist/request/appKey.d.ts.map +1 -1
- package/dist/request/appKey.js +13 -8
- package/dist/request/appKey.js.map +1 -1
- package/dist/request/classify.d.ts.map +1 -1
- package/dist/request/classify.js +13 -1
- package/dist/request/classify.js.map +1 -1
- package/dist/request/ephemeralExchange.d.ts +6 -1
- package/dist/request/ephemeralExchange.d.ts.map +1 -1
- package/dist/request/ephemeralExchange.js +6 -1
- package/dist/request/ephemeralExchange.js.map +1 -1
- package/dist/request/exchangeClient.d.ts +0 -23
- package/dist/request/exchangeClient.d.ts.map +1 -1
- package/dist/request/exchangeClient.js +30 -1
- package/dist/request/exchangeClient.js.map +1 -1
- package/dist/request/index.d.ts +4 -1
- package/dist/request/index.d.ts.map +1 -1
- package/dist/request/index.js +4 -1
- package/dist/request/index.js.map +1 -1
- package/dist/request/interactionRequest.d.ts +23 -0
- package/dist/request/interactionRequest.d.ts.map +1 -0
- package/dist/request/interactionRequest.js +46 -0
- package/dist/request/interactionRequest.js.map +1 -0
- package/dist/request/interactionUrl.d.ts +3 -14
- package/dist/request/interactionUrl.d.ts.map +1 -1
- package/dist/request/interactionUrl.js +20 -1
- package/dist/request/interactionUrl.js.map +1 -1
- package/dist/resourceLog/controller.d.ts +48 -49
- package/dist/resourceLog/controller.d.ts.map +1 -1
- package/dist/resourceLog/controller.js +40 -20
- package/dist/resourceLog/controller.js.map +1 -1
- package/dist/resourceLog/errors.d.ts +12 -78
- package/dist/resourceLog/errors.d.ts.map +1 -1
- package/dist/resourceLog/errors.js +12 -79
- package/dist/resourceLog/errors.js.map +1 -1
- package/dist/resourceLog/index.d.ts +17 -22
- package/dist/resourceLog/index.d.ts.map +1 -1
- package/dist/resourceLog/index.js +16 -21
- package/dist/resourceLog/index.js.map +1 -1
- package/dist/resourceLog/license.d.ts +27 -26
- package/dist/resourceLog/license.d.ts.map +1 -1
- package/dist/resourceLog/license.js +31 -30
- package/dist/resourceLog/license.js.map +1 -1
- package/dist/unlock/index.d.ts +6 -6
- package/dist/unlock/index.d.ts.map +1 -1
- package/dist/unlock/index.js +5 -5
- package/dist/unlock/retire.d.ts +29 -28
- package/dist/unlock/retire.d.ts.map +1 -1
- package/dist/unlock/retire.js +25 -16
- package/dist/unlock/retire.js.map +1 -1
- package/dist/unlock/standingClient.d.ts +1 -1
- package/dist/unlock/standingClient.js +3 -3
- package/dist/unlock/standingWebvh.d.ts +28 -10
- package/dist/unlock/standingWebvh.d.ts.map +1 -1
- package/dist/unlock/standingWebvh.js +75 -37
- package/dist/unlock/standingWebvh.js.map +1 -1
- package/dist/unlock/unlockRecord.js +1 -1
- package/dist/webvh/delegatedLogStore.d.ts +2 -2
- package/dist/webvh/delegatedLogStore.js +2 -2
- package/dist/webvh/didWeb.js +1 -1
- package/dist/webvh/didWeb.js.map +1 -1
- package/dist/webvh/didWebvh.d.ts +3 -3
- package/dist/webvh/didWebvh.d.ts.map +1 -1
- package/dist/webvh/didWebvh.js +5 -5
- package/dist/webvh/didWebvh.js.map +1 -1
- package/dist/webvh/listClients.js +1 -1
- package/dist/webvh/listClients.js.map +1 -1
- package/dist/webvh/verifyLog.d.ts +1 -1
- package/dist/webvh/verifyLog.d.ts.map +1 -1
- package/dist/webvh/verifyLog.js +1 -2
- package/dist/webvh/verifyLog.js.map +1 -1
- package/package.json +5 -9
- package/dist/display/alignment.d.ts +0 -55
- package/dist/display/alignment.d.ts.map +0 -1
- package/dist/display/alignment.js +0 -117
- package/dist/display/alignment.js.map +0 -1
- package/dist/display/credentialName.d.ts +0 -42
- package/dist/display/credentialName.d.ts.map +0 -1
- package/dist/display/credentialName.js +0 -106
- package/dist/display/credentialName.js.map +0 -1
- package/dist/display/displayFields.d.ts +0 -59
- package/dist/display/displayFields.d.ts.map +0 -1
- package/dist/display/displayFields.js +0 -136
- package/dist/display/displayFields.js.map +0 -1
- package/dist/display/evidence.d.ts +0 -50
- package/dist/display/evidence.d.ts.map +0 -1
- package/dist/display/evidence.js +0 -67
- package/dist/display/evidence.js.map +0 -1
- package/dist/display/image.d.ts +0 -18
- package/dist/display/image.d.ts.map +0 -1
- package/dist/display/image.js +0 -23
- package/dist/display/image.js.map +0 -1
- package/dist/display/index.d.ts +0 -38
- package/dist/display/index.d.ts.map +0 -1
- package/dist/display/index.js +0 -32
- package/dist/display/index.js.map +0 -1
- package/dist/display/issuer.d.ts +0 -105
- package/dist/display/issuer.d.ts.map +0 -1
- package/dist/display/issuer.js +0 -126
- package/dist/display/issuer.js.map +0 -1
- package/dist/display/obv3.d.ts +0 -82
- package/dist/display/obv3.d.ts.map +0 -1
- package/dist/display/obv3.js +0 -117
- package/dist/display/obv3.js.map +0 -1
- package/dist/display/parse.d.ts +0 -66
- package/dist/display/parse.d.ts.map +0 -1
- package/dist/display/parse.js +0 -104
- package/dist/display/parse.js.map +0 -1
- package/dist/display/subject.d.ts +0 -79
- package/dist/display/subject.d.ts.map +0 -1
- package/dist/display/subject.js +0 -124
- package/dist/display/subject.js.map +0 -1
- package/dist/display/text.d.ts +0 -53
- package/dist/display/text.d.ts.map +0 -1
- package/dist/display/text.js +0 -78
- package/dist/display/text.js.map +0 -1
- package/dist/display/types.d.ts +0 -55
- package/dist/display/types.d.ts.map +0 -1
- package/dist/display/types.js +0 -41
- package/dist/display/types.js.map +0 -1
- package/dist/display/validity.d.ts +0 -51
- package/dist/display/validity.d.ts.map +0 -1
- package/dist/display/validity.js +0 -51
- package/dist/display/validity.js.map +0 -1
- package/dist/display/verificationView.d.ts +0 -115
- package/dist/display/verificationView.d.ts.map +0 -1
- package/dist/display/verificationView.js +0 -199
- package/dist/display/verificationView.js.map +0 -1
- package/dist/resourceLog/append.d.ts +0 -112
- package/dist/resourceLog/append.d.ts.map +0 -1
- package/dist/resourceLog/append.js +0 -197
- package/dist/resourceLog/append.js.map +0 -1
- package/dist/resourceLog/entry.d.ts +0 -68
- package/dist/resourceLog/entry.d.ts.map +0 -1
- package/dist/resourceLog/entry.js +0 -167
- package/dist/resourceLog/entry.js.map +0 -1
- package/dist/resourceLog/pin.d.ts +0 -82
- package/dist/resourceLog/pin.d.ts.map +0 -1
- package/dist/resourceLog/pin.js +0 -57
- package/dist/resourceLog/pin.js.map +0 -1
- package/dist/resourceLog/seal.d.ts +0 -97
- package/dist/resourceLog/seal.d.ts.map +0 -1
- package/dist/resourceLog/seal.js +0 -113
- package/dist/resourceLog/seal.js.map +0 -1
- package/dist/resourceLog/verify.d.ts +0 -96
- package/dist/resourceLog/verify.d.ts.map +0 -1
- package/dist/resourceLog/verify.js +0 -474
- package/dist/resourceLog/verify.js.map +0 -1
- package/dist/resourceLog/vmFragment.d.ts +0 -33
- package/dist/resourceLog/vmFragment.d.ts.map +0 -1
- package/dist/resourceLog/vmFragment.js +0 -39
- package/dist/resourceLog/vmFragment.js.map +0 -1
|
@@ -1,197 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) 2026 Interop Alliance. All rights reserved.
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* The append path (App Connect spec `#log-append`): read the full log and
|
|
6
|
-
* verify it (an entry is never built on an unverified head), build the new
|
|
7
|
-
* entry against the verified head anchored at the writer's current verified
|
|
8
|
-
* controller head, write compare-and-swapped on the read's validator, and on
|
|
9
|
-
* conflict re-read, re-verify, rebase, retry. A write acknowledgement is a
|
|
10
|
-
* promise, not a fact: every append is confirmed by reading the log back and
|
|
11
|
-
* re-verifying the extended history before the append -- or any ceremony step
|
|
12
|
-
* gated on it -- is treated as durable. The chain-head pin advances on every
|
|
13
|
-
* successful verification along the way, and only ever forward.
|
|
14
|
-
*/
|
|
15
|
-
import { PreconditionFailedError } from '@interop/was-client';
|
|
16
|
-
import { confirmAppend } from '@interop/was-client/log';
|
|
17
|
-
import { ResourceLogClosedError } from './errors.js';
|
|
18
|
-
import { buildResourceLogEntry, buildResourceLogGenesis } from './entry.js';
|
|
19
|
-
import { verifyResourceLog } from './verify.js';
|
|
20
|
-
/**
|
|
21
|
-
* Reads and fully verifies a log through the store seam, advancing the
|
|
22
|
-
* chain-head pin. Resolves `null` when the log resource does not exist yet
|
|
23
|
-
* (the pre-genesis state). The one read entry point every consumer -- a
|
|
24
|
-
* login-time roster read, a pre-append verification, a first-contact
|
|
25
|
-
* bootstrap -- goes through, so the pin rules cannot be bypassed by reading
|
|
26
|
-
* around them.
|
|
27
|
-
*
|
|
28
|
-
* @param options {object}
|
|
29
|
-
* @param options.store {ResourceLogStore} the log's transport seam
|
|
30
|
-
* @param options.controller {ResourceLogController} the verified controller
|
|
31
|
-
* view
|
|
32
|
-
* @param options.expectedMethod {string} the format identifier expected
|
|
33
|
-
* (also confirming any `history` dispatch hint the caller followed)
|
|
34
|
-
* @param options.pinStore {ResourceLogPinStore} this client's pin for this
|
|
35
|
-
* log
|
|
36
|
-
* @param options.logId {string} the pin-slot key for this log, from
|
|
37
|
-
* `resourceLogPinId`
|
|
38
|
-
* @returns {Promise<{ verified: VerifiedResourceLog; etag?: string } | null>}
|
|
39
|
-
*/
|
|
40
|
-
export async function readResourceLog({ store, controller, expectedMethod, pinStore, logId }) {
|
|
41
|
-
const current = await store.read();
|
|
42
|
-
if (current === null) {
|
|
43
|
-
return null;
|
|
44
|
-
}
|
|
45
|
-
const pin = await pinStore.read({ logId });
|
|
46
|
-
const verified = await verifyResourceLog({
|
|
47
|
-
entries: current.entries,
|
|
48
|
-
controller,
|
|
49
|
-
expectedMethod,
|
|
50
|
-
pin
|
|
51
|
-
});
|
|
52
|
-
await pinStore.write({ logId, pin: verified.pin });
|
|
53
|
-
return { verified, etag: current.etag };
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Appends one state change: verify, build against the verified head, CAS,
|
|
57
|
-
* rebase-and-retry on conflict, confirm by read-back. `buildState` is the
|
|
58
|
-
* rebase hook -- it is called with the current verified log on every attempt
|
|
59
|
-
* and returns the full next state built on THAT head's state (or `null` to
|
|
60
|
-
* signal the change is already present, making a re-run converge instead of
|
|
61
|
-
* duplicating an entry). Refuses a log whose verified head is a terminal
|
|
62
|
-
* handover entry ({@link ResourceLogClosedError}).
|
|
63
|
-
*
|
|
64
|
-
* @param options {object}
|
|
65
|
-
* @param options.store {ResourceLogStore}
|
|
66
|
-
* @param options.controller {ResourceLogController}
|
|
67
|
-
* @param options.expectedMethod {string}
|
|
68
|
-
* @param options.pinStore {ResourceLogPinStore}
|
|
69
|
-
* @param options.logId {string} the pin-slot key for this log, from
|
|
70
|
-
* `resourceLogPinId`
|
|
71
|
-
* @param options.signer {ResourceLogSigner}
|
|
72
|
-
* @param options.buildState {function} `(verified) => state | null` -- the
|
|
73
|
-
* full next state rebased on the verified head, or `null` when the head
|
|
74
|
-
* already carries the change
|
|
75
|
-
* @param [options.versionTime] {string} RFC3339 UTC; defaults to now
|
|
76
|
-
* @param [options.maxAttempts] {number} CAS attempts before giving up
|
|
77
|
-
* (default 3)
|
|
78
|
-
* @returns {Promise<VerifiedResourceLog>} the read-back, re-verified log
|
|
79
|
-
* (whether or not this call appended)
|
|
80
|
-
*/
|
|
81
|
-
export async function appendResourceLog({ store, controller, expectedMethod, pinStore, logId, signer, buildState, versionTime, maxAttempts = 3 }) {
|
|
82
|
-
let lastConflict;
|
|
83
|
-
for (let attempt = 0; attempt < maxAttempts; attempt++) {
|
|
84
|
-
const current = await readResourceLog({
|
|
85
|
-
store,
|
|
86
|
-
controller,
|
|
87
|
-
expectedMethod,
|
|
88
|
-
pinStore,
|
|
89
|
-
logId
|
|
90
|
-
});
|
|
91
|
-
if (current === null) {
|
|
92
|
-
throw new Error('Cannot append to the resource log: the log does not exist yet ' +
|
|
93
|
-
'(create it with its genesis entry first).');
|
|
94
|
-
}
|
|
95
|
-
const { verified, etag } = current;
|
|
96
|
-
if (verified.terminal) {
|
|
97
|
-
throw new ResourceLogClosedError({ nextLog: verified.terminal });
|
|
98
|
-
}
|
|
99
|
-
if (etag === undefined) {
|
|
100
|
-
throw new Error('Cannot append to the resource log: the backend returned no ' +
|
|
101
|
-
'validator, and the profile forbids an unconditional write.');
|
|
102
|
-
}
|
|
103
|
-
const state = await buildState(verified);
|
|
104
|
-
if (state === null) {
|
|
105
|
-
// The head already carries the change -- a torn earlier run landed it,
|
|
106
|
-
// or a concurrent writer did. Converged.
|
|
107
|
-
return verified;
|
|
108
|
-
}
|
|
109
|
-
const entry = await buildResourceLogEntry({
|
|
110
|
-
head: verified.head,
|
|
111
|
-
state,
|
|
112
|
-
controller,
|
|
113
|
-
signer,
|
|
114
|
-
versionTime
|
|
115
|
-
});
|
|
116
|
-
try {
|
|
117
|
-
await store.append(entry, { ifMatch: etag });
|
|
118
|
-
}
|
|
119
|
-
catch (err) {
|
|
120
|
-
if (err instanceof PreconditionFailedError) {
|
|
121
|
-
// A concurrent append won the CAS: re-read, re-verify, rebase, retry.
|
|
122
|
-
lastConflict = err;
|
|
123
|
-
continue;
|
|
124
|
-
}
|
|
125
|
-
throw err;
|
|
126
|
-
}
|
|
127
|
-
const readBack = await confirmAppend({ store, entry });
|
|
128
|
-
const confirmed = await verifyResourceLog({
|
|
129
|
-
entries: readBack.entries,
|
|
130
|
-
controller,
|
|
131
|
-
expectedMethod,
|
|
132
|
-
pin: await pinStore.read({ logId })
|
|
133
|
-
});
|
|
134
|
-
await pinStore.write({ logId, pin: confirmed.pin });
|
|
135
|
-
return confirmed;
|
|
136
|
-
}
|
|
137
|
-
throw new Error(`Appending to the resource log lost the compare-and-swap race ` +
|
|
138
|
-
`${maxAttempts} times in a row.`, { cause: lastConflict });
|
|
139
|
-
}
|
|
140
|
-
/**
|
|
141
|
-
* Creates a log with its genesis entry, guarded create-if-absent, and
|
|
142
|
-
* confirms by read-back. Losing the create race to a concurrent provisioner
|
|
143
|
-
* adopts the winner's log (the create is CAS, never clobbering): the served
|
|
144
|
-
* log is verified and pinned, and the caller reconciles its intended state
|
|
145
|
-
* through an ordinary {@link appendResourceLog}. First contact is where the
|
|
146
|
-
* pin is established, so the pin store is written either way.
|
|
147
|
-
*
|
|
148
|
-
* @param options {object}
|
|
149
|
-
* @param options.store {ResourceLogStore}
|
|
150
|
-
* @param options.controller {ResourceLogController}
|
|
151
|
-
* @param options.method {string} the format identifier to declare
|
|
152
|
-
* @param options.pinStore {ResourceLogPinStore}
|
|
153
|
-
* @param options.logId {string} the pin-slot key for this log, from
|
|
154
|
-
* `resourceLogPinId`
|
|
155
|
-
* @param options.signer {ResourceLogSigner}
|
|
156
|
-
* @param options.state {ResourceLogEntry['state']} the full initial state
|
|
157
|
-
* @param [options.previousLog] {object} handover successors only
|
|
158
|
-
* @param [options.versionTime] {string} RFC3339 UTC; defaults to now
|
|
159
|
-
* @returns {Promise<{ verified: VerifiedResourceLog; created: boolean }>}
|
|
160
|
-
* the verified log as it now stands, and whether this call created it
|
|
161
|
-
*/
|
|
162
|
-
export async function createResourceLog({ store, controller, method, pinStore, logId, signer, state, previousLog, versionTime }) {
|
|
163
|
-
const genesis = await buildResourceLogGenesis({
|
|
164
|
-
state,
|
|
165
|
-
method,
|
|
166
|
-
controller,
|
|
167
|
-
signer,
|
|
168
|
-
previousLog,
|
|
169
|
-
versionTime
|
|
170
|
-
});
|
|
171
|
-
let created = true;
|
|
172
|
-
try {
|
|
173
|
-
await store.create(genesis);
|
|
174
|
-
}
|
|
175
|
-
catch (err) {
|
|
176
|
-
if (!(err instanceof PreconditionFailedError)) {
|
|
177
|
-
throw err;
|
|
178
|
-
}
|
|
179
|
-
created = false;
|
|
180
|
-
}
|
|
181
|
-
const current = created
|
|
182
|
-
? await confirmAppend({ store, entry: genesis })
|
|
183
|
-
: await store.read();
|
|
184
|
-
if (current === null) {
|
|
185
|
-
throw new Error('The resource log create lost its guarded-create race, but no log ' +
|
|
186
|
-
'was served on re-read.');
|
|
187
|
-
}
|
|
188
|
-
const verified = await verifyResourceLog({
|
|
189
|
-
entries: current.entries,
|
|
190
|
-
controller,
|
|
191
|
-
expectedMethod: method,
|
|
192
|
-
pin: await pinStore.read({ logId })
|
|
193
|
-
});
|
|
194
|
-
await pinStore.write({ logId, pin: verified.pin });
|
|
195
|
-
return { verified, created };
|
|
196
|
-
}
|
|
197
|
-
//# sourceMappingURL=append.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"append.js","sourceRoot":"","sources":["../../src/resourceLog/append.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;GAUG;AACH,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAA;AAC7D,OAAO,EACL,aAAa,EAGd,MAAM,yBAAyB,CAAA;AAEhC,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AACpD,OAAO,EACL,qBAAqB,EACrB,uBAAuB,EAExB,MAAM,YAAY,CAAA;AAEnB,OAAO,EAAE,iBAAiB,EAA4B,MAAM,aAAa,CAAA;AAEzE;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,EACpC,KAAK,EACL,UAAU,EACV,cAAc,EACd,QAAQ,EACR,KAAK,EAON;IACC,MAAM,OAAO,GAAG,MAAM,KAAK,CAAC,IAAI,EAAE,CAAA;IAClC,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;QACrB,OAAO,IAAI,CAAA;IACb,CAAC;IACD,MAAM,GAAG,GAAG,MAAM,QAAQ,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,CAAC,CAAA;IAC1C,MAAM,QAAQ,GAAG,MAAM,iBAAiB,CAAC;QACvC,OAAO,EAAE,OAA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WZ;IACC,MAAM,OAAO,GAAG,MAAM,uBAAuB,CAAC;QAC5C,KAAK;QACL,MAAM;QACN,UAAU;QACV,MAAM;QACN,WAAW;QACX,WAAW;KACZ,CAAC,CAAA;IACF,IAAI,OAAO,GAAG,IAAI,CAAA;IAClB,IAAI,CAAC;QACH,MAAM,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;IAC7B,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,CAAC,GAAG,YAAY,uBAAuB,CAAC,EAAE,CAAC;YAC9C,MAAM,GAAG,CAAA;QACX,CAAC;QACD,OAAO,GAAG,KAAK,CAAA;IACjB,CAAC;IACD,MAAM,OAAO,GAAG,OAAO;QACrB,CAAC,CAAC,MAAM,aAAa,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;QAChD,CAAC,CAAC,MAAM,KAAK,CAAC,IAAI,EAAE,CAAA;IACtB,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;QACrB,MAAM,IAAI,KAAK,CACb,mEAAmE;YACjE,wBAAwB,CAC3B,CAAA;IACH,CAAC;IACD,MAAM,QAAQ,GAAG,MAAM,iBAAiB,CAAC;QACvC,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,UAAU;QACV,cAAc,EAAE,MAAM;QACtB,GAAG,EAAE,MAAM,QAAQ,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,CAAC;KACpC,CAAC,CAAA;IACF,MAAM,QAAQ,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,QAAQ,CAAC,GAAG,EAAE,CAAC,CAAA;IAClD,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAA;AAC9B,CAAC"}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import type { ResourceLogEntry } from '@interop/was-client/log';
|
|
2
|
-
import type { ResourceLogController } from './controller.js';
|
|
3
|
-
/**
|
|
4
|
-
* The writer's signing seam: its enrolled Ed25519 signing key's multibase
|
|
5
|
-
* (the fragment of its verification method in the controller document) and a
|
|
6
|
-
* raw detached-signature hook over it. The multibase names the key in the
|
|
7
|
-
* proof's `verificationMethod`; membership under `assertionMethod` at the
|
|
8
|
-
* anchored version is what authorizes the append.
|
|
9
|
-
*/
|
|
10
|
-
export interface ResourceLogSigner {
|
|
11
|
-
keyMultibase: string;
|
|
12
|
-
sign(input: {
|
|
13
|
-
data: Uint8Array;
|
|
14
|
-
}): Promise<Uint8Array>;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Builds and signs a genesis entry by the profile's two-pass SCID procedure:
|
|
18
|
-
* the preliminary entry carries the `{SCID}` placeholder as `versionId` and
|
|
19
|
-
* `parameters.scid`, its hash is the SCID, and the final entry substitutes it
|
|
20
|
-
* back in before the ordinary entry hash is computed (`versionId` input
|
|
21
|
-
* value: the SCID).
|
|
22
|
-
*
|
|
23
|
-
* @param options {object}
|
|
24
|
-
* @param options.state {ResourceLogEntry['state']} the full initial state
|
|
25
|
-
* (with its `type`)
|
|
26
|
-
* @param options.method {string} the format identifier
|
|
27
|
-
* (`RESOURCE_LOG_METHOD`)
|
|
28
|
-
* @param options.controller {ResourceLogController} the verified controller
|
|
29
|
-
* view -- the anchor source
|
|
30
|
-
* @param options.signer {ResourceLogSigner}
|
|
31
|
-
* @param [options.previousLog] {object} handover successors only: the prior
|
|
32
|
-
* log's SCID and the `versionId` of its terminal entry's predecessor
|
|
33
|
-
* @param [options.versionTime] {string} RFC3339 UTC; defaults to now
|
|
34
|
-
* @returns {Promise<ResourceLogEntry>}
|
|
35
|
-
*/
|
|
36
|
-
export declare function buildResourceLogGenesis({ state, method, controller, signer, previousLog, versionTime }: {
|
|
37
|
-
state: ResourceLogEntry['state'];
|
|
38
|
-
method: string;
|
|
39
|
-
controller: ResourceLogController;
|
|
40
|
-
signer: ResourceLogSigner;
|
|
41
|
-
previousLog?: {
|
|
42
|
-
scid: string;
|
|
43
|
-
head: string;
|
|
44
|
-
};
|
|
45
|
-
versionTime?: string;
|
|
46
|
-
}): Promise<ResourceLogEntry>;
|
|
47
|
-
/**
|
|
48
|
-
* Builds and signs the next ordinary entry against a verified head: full
|
|
49
|
-
* state, empty `parameters`, hash chained off the head's `versionId`, proof
|
|
50
|
-
* anchored at the controller's verified head. Callers hold a verified head
|
|
51
|
-
* by construction (an entry is never built on an unverified one).
|
|
52
|
-
*
|
|
53
|
-
* @param options {object}
|
|
54
|
-
* @param options.head {ResourceLogEntry} the verified head entry
|
|
55
|
-
* @param options.state {ResourceLogEntry['state']} the full next state
|
|
56
|
-
* @param options.controller {ResourceLogController}
|
|
57
|
-
* @param options.signer {ResourceLogSigner}
|
|
58
|
-
* @param [options.versionTime] {string} RFC3339 UTC; defaults to now
|
|
59
|
-
* @returns {Promise<ResourceLogEntry>}
|
|
60
|
-
*/
|
|
61
|
-
export declare function buildResourceLogEntry({ head, state, controller, signer, versionTime }: {
|
|
62
|
-
head: ResourceLogEntry;
|
|
63
|
-
state: ResourceLogEntry['state'];
|
|
64
|
-
controller: ResourceLogController;
|
|
65
|
-
signer: ResourceLogSigner;
|
|
66
|
-
versionTime?: string;
|
|
67
|
-
}): Promise<ResourceLogEntry>;
|
|
68
|
-
//# sourceMappingURL=entry.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"entry.d.ts","sourceRoot":"","sources":["../../src/resourceLog/entry.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAC/D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAA;AAE5D;;;;;;GAMG;AACH,MAAM,WAAW,iBAAiB;IAChC,YAAY,EAAE,MAAM,CAAA;IACpB,IAAI,CAAC,KAAK,EAAE;QAAE,IAAI,EAAE,UAAU,CAAA;KAAE,GAAG,OAAO,CAAC,UAAU,CAAC,CAAA;CACvD;AAqFD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,uBAAuB,CAAC,EAC5C,KAAK,EACL,MAAM,EACN,UAAU,EACV,MAAM,EACN,WAAW,EACX,WAAW,EACZ,EAAE;IACD,KAAK,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAA;IAChC,MAAM,EAAE,MAAM,CAAA;IACd,UAAU,EAAE,qBAAqB,CAAA;IACjC,MAAM,EAAE,iBAAiB,CAAA;IACzB,WAAW,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAA;IAC5C,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAmC5B;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,qBAAqB,CAAC,EAC1C,IAAI,EACJ,KAAK,EACL,UAAU,EACV,MAAM,EACN,WAAW,EACZ,EAAE;IACD,IAAI,EAAE,gBAAgB,CAAA;IACtB,KAAK,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAA;IAChC,UAAU,EAAE,qBAAqB,CAAA;IACjC,MAAM,EAAE,iBAAiB,CAAA;IACzB,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CA0B5B"}
|
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) 2026 Interop Alliance. All rights reserved.
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* Resource-log entry construction: the two-pass SCID genesis build and the
|
|
6
|
-
* ordinary next-entry build, both signed under the writer's enrolled Ed25519
|
|
7
|
-
* key with the entry anchor riding as a `versionId` DID parameter on the
|
|
8
|
-
* proof's `verificationMethod` -- the writer anchors at the head of the
|
|
9
|
-
* controller document as it last verified it. All hashing and proof
|
|
10
|
-
* construction comes from the did:webvh log kernel; nothing is re-derived
|
|
11
|
-
* here.
|
|
12
|
-
*/
|
|
13
|
-
import { buildVersionId, createDataIntegrityProofTemplate, deriveHash, parseAndValidateVersionId, SCID_PLACEHOLDER, signDataIntegrityProof, signerFromExternalKey } from '@interop/did-method-webvh';
|
|
14
|
-
/**
|
|
15
|
-
* The writer's anchored verification-method DID URL: the controller DID, the
|
|
16
|
-
* anchor at the controller's verified head as a `versionId` DID parameter
|
|
17
|
-
* (omitted for an unversioned controller), and the signing key's multibase as
|
|
18
|
-
* the fragment.
|
|
19
|
-
*
|
|
20
|
-
* @param options {object}
|
|
21
|
-
* @param options.controller {ResourceLogController}
|
|
22
|
-
* @param options.keyMultibase {string}
|
|
23
|
-
* @returns {string}
|
|
24
|
-
*/
|
|
25
|
-
function anchoredVerificationMethod({ controller, keyMultibase }) {
|
|
26
|
-
const anchor = controller.versionIds[controller.versionIds.length - 1];
|
|
27
|
-
const query = anchor === undefined ? '' : `?versionId=${anchor}`;
|
|
28
|
-
return `${controller.did}${query}#${keyMultibase}`;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Refuses a state document the profile forbids in an entry: one without a
|
|
32
|
-
* `type` schema identifier, or one carrying the projection-only `history`
|
|
33
|
-
* member.
|
|
34
|
-
*
|
|
35
|
-
* @param state {ResourceLogEntry['state']}
|
|
36
|
-
*/
|
|
37
|
-
function checkState(state) {
|
|
38
|
-
if (typeof state.type !== 'string') {
|
|
39
|
-
throw new Error('A resource log entry state must carry a type schema identifier.');
|
|
40
|
-
}
|
|
41
|
-
if ('history' in state) {
|
|
42
|
-
throw new Error('A resource log entry state must not carry a history member (the ' +
|
|
43
|
-
'profile reserves that member name).');
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Signs a fully version-identified entry under the profile's fixed proof
|
|
48
|
-
* shape.
|
|
49
|
-
*
|
|
50
|
-
* @param options {object}
|
|
51
|
-
* @param options.entry {object} the entry, `proof` absent
|
|
52
|
-
* @param options.signer {ResourceLogSigner}
|
|
53
|
-
* @param options.verificationMethod {string} the anchored DID URL
|
|
54
|
-
* @param options.created {string} the proof timestamp
|
|
55
|
-
* @returns {Promise<ResourceLogEntry>}
|
|
56
|
-
*/
|
|
57
|
-
async function signEntry({ entry, signer, verificationMethod, created }) {
|
|
58
|
-
const proofTemplate = createDataIntegrityProofTemplate({
|
|
59
|
-
verificationMethod,
|
|
60
|
-
created
|
|
61
|
-
});
|
|
62
|
-
const proof = await signDataIntegrityProof(entry, proofTemplate, signerFromExternalKey({
|
|
63
|
-
publicKeyMultibase: signer.keyMultibase,
|
|
64
|
-
sign: signer.sign
|
|
65
|
-
}));
|
|
66
|
-
// The kernel's proof type keeps proofPurpose as the full union; the
|
|
67
|
-
// template fixed it to the profile's assertionMethod shape.
|
|
68
|
-
return { ...entry, proof: [proof] };
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Builds and signs a genesis entry by the profile's two-pass SCID procedure:
|
|
72
|
-
* the preliminary entry carries the `{SCID}` placeholder as `versionId` and
|
|
73
|
-
* `parameters.scid`, its hash is the SCID, and the final entry substitutes it
|
|
74
|
-
* back in before the ordinary entry hash is computed (`versionId` input
|
|
75
|
-
* value: the SCID).
|
|
76
|
-
*
|
|
77
|
-
* @param options {object}
|
|
78
|
-
* @param options.state {ResourceLogEntry['state']} the full initial state
|
|
79
|
-
* (with its `type`)
|
|
80
|
-
* @param options.method {string} the format identifier
|
|
81
|
-
* (`RESOURCE_LOG_METHOD`)
|
|
82
|
-
* @param options.controller {ResourceLogController} the verified controller
|
|
83
|
-
* view -- the anchor source
|
|
84
|
-
* @param options.signer {ResourceLogSigner}
|
|
85
|
-
* @param [options.previousLog] {object} handover successors only: the prior
|
|
86
|
-
* log's SCID and the `versionId` of its terminal entry's predecessor
|
|
87
|
-
* @param [options.versionTime] {string} RFC3339 UTC; defaults to now
|
|
88
|
-
* @returns {Promise<ResourceLogEntry>}
|
|
89
|
-
*/
|
|
90
|
-
export async function buildResourceLogGenesis({ state, method, controller, signer, previousLog, versionTime }) {
|
|
91
|
-
checkState(state);
|
|
92
|
-
const time = versionTime ?? new Date().toISOString();
|
|
93
|
-
const parametersOf = (scid) => ({
|
|
94
|
-
method,
|
|
95
|
-
scid,
|
|
96
|
-
...(previousLog === undefined ? {} : { previousLog })
|
|
97
|
-
});
|
|
98
|
-
const scid = await deriveHash({
|
|
99
|
-
versionId: SCID_PLACEHOLDER,
|
|
100
|
-
versionTime: time,
|
|
101
|
-
parameters: parametersOf(SCID_PLACEHOLDER),
|
|
102
|
-
state
|
|
103
|
-
});
|
|
104
|
-
const parameters = parametersOf(scid);
|
|
105
|
-
const entryHash = await deriveHash({
|
|
106
|
-
versionId: scid,
|
|
107
|
-
versionTime: time,
|
|
108
|
-
parameters,
|
|
109
|
-
state
|
|
110
|
-
});
|
|
111
|
-
return signEntry({
|
|
112
|
-
entry: {
|
|
113
|
-
versionId: buildVersionId(1, entryHash),
|
|
114
|
-
versionTime: time,
|
|
115
|
-
parameters,
|
|
116
|
-
state
|
|
117
|
-
},
|
|
118
|
-
signer,
|
|
119
|
-
verificationMethod: anchoredVerificationMethod({
|
|
120
|
-
controller,
|
|
121
|
-
keyMultibase: signer.keyMultibase
|
|
122
|
-
}),
|
|
123
|
-
created: time
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* Builds and signs the next ordinary entry against a verified head: full
|
|
128
|
-
* state, empty `parameters`, hash chained off the head's `versionId`, proof
|
|
129
|
-
* anchored at the controller's verified head. Callers hold a verified head
|
|
130
|
-
* by construction (an entry is never built on an unverified one).
|
|
131
|
-
*
|
|
132
|
-
* @param options {object}
|
|
133
|
-
* @param options.head {ResourceLogEntry} the verified head entry
|
|
134
|
-
* @param options.state {ResourceLogEntry['state']} the full next state
|
|
135
|
-
* @param options.controller {ResourceLogController}
|
|
136
|
-
* @param options.signer {ResourceLogSigner}
|
|
137
|
-
* @param [options.versionTime] {string} RFC3339 UTC; defaults to now
|
|
138
|
-
* @returns {Promise<ResourceLogEntry>}
|
|
139
|
-
*/
|
|
140
|
-
export async function buildResourceLogEntry({ head, state, controller, signer, versionTime }) {
|
|
141
|
-
checkState(state);
|
|
142
|
-
const time = versionTime ?? new Date().toISOString();
|
|
143
|
-
const headOrdinal = Number.parseInt(head.versionId, 10);
|
|
144
|
-
const ordinal = headOrdinal + 1;
|
|
145
|
-
parseAndValidateVersionId(head.versionId, headOrdinal);
|
|
146
|
-
const entryHash = await deriveHash({
|
|
147
|
-
versionId: head.versionId,
|
|
148
|
-
versionTime: time,
|
|
149
|
-
parameters: {},
|
|
150
|
-
state
|
|
151
|
-
});
|
|
152
|
-
return signEntry({
|
|
153
|
-
entry: {
|
|
154
|
-
versionId: buildVersionId(ordinal, entryHash),
|
|
155
|
-
versionTime: time,
|
|
156
|
-
parameters: {},
|
|
157
|
-
state
|
|
158
|
-
},
|
|
159
|
-
signer,
|
|
160
|
-
verificationMethod: anchoredVerificationMethod({
|
|
161
|
-
controller,
|
|
162
|
-
keyMultibase: signer.keyMultibase
|
|
163
|
-
}),
|
|
164
|
-
created: time
|
|
165
|
-
});
|
|
166
|
-
}
|
|
167
|
-
//# sourceMappingURL=entry.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"entry.js","sourceRoot":"","sources":["../../src/resourceLog/entry.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;GAQG;AACH,OAAO,EACL,cAAc,EACd,gCAAgC,EAChC,UAAU,EACV,yBAAyB,EACzB,gBAAgB,EAChB,sBAAsB,EACtB,qBAAqB,EACtB,MAAM,2BAA2B,CAAA;AAgBlC;;;;;;;;;;GAUG;AACH,SAAS,0BAA0B,CAAC,EAClC,UAAU,EACV,YAAY,EAIb;IACC,MAAM,MAAM,GAAG,UAAU,CAAC,UAAU,CAAC,UAAU,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;IACtE,MAAM,KAAK,GAAG,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,cAAc,MAAM,EAAE,CAAA;IAChE,OA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AAC;QACjC,SAAS,EAAE,IAAI,CAAC,SAAS;QACzB,WAAW,EAAE,IAAI;QACjB,UAAU,EAAE,EAAE;QACd,KAAK;KACN,CAAC,CAAA;IACF,OAAO,SAAS,CAAC;QACf,KAAK,EAAE;YACL,SAAS,EAAE,cAAc,CAAC,OAAO,EAAE,SAAS,CAAC;YAC7C,WAAW,EAAE,IAAI;YACjB,UAAU,EAAE,EAAE;YACd,KAAK;SACN;QACD,MAAM;QACN,kBAAkB,EAAE,0BAA0B,CAAC;YAC7C,UAAU;YACV,YAAY,EAAE,MAAM,CAAC,YAAY;SAClC,CAAC;QACF,OAAO,EAAE,IAAI;KACd,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) 2026 Interop Alliance. All rights reserved.
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* The chain-head pin: the client-local durable record of a resource log's
|
|
6
|
-
* verified identity and latest verified head, kept per log beside the app's
|
|
7
|
-
* other continuity pins (the account pointer, the roster epoch pin). The pin
|
|
8
|
-
* is what turns one-shot verification into continuity: a served log whose
|
|
9
|
-
* SCID or method differs from the pin outside a verified handover, or whose
|
|
10
|
-
* history is not a descendant of the pinned head, is refused instead of
|
|
11
|
-
* adopted. Storage is the app's concern (freewallet: beside its other pins in
|
|
12
|
-
* localStorage; DCW: a table row), so only the seam lives here, plus an
|
|
13
|
-
* in-memory implementation for tests and single-session use.
|
|
14
|
-
*
|
|
15
|
-
* The seam is keyed: every read and write names the log it concerns with a
|
|
16
|
-
* `logId`, so one store instance serves every log a wallet holds. Wallet-core
|
|
17
|
-
* supplies the key at every call, built by {@link resourceLogPinId} (or one of
|
|
18
|
-
* the named builders over it), so an app implements one keyed store and never
|
|
19
|
-
* chooses keys itself.
|
|
20
|
-
*/
|
|
21
|
-
/**
|
|
22
|
-
* One log's pin: the format identifier from the genesis `parameters.method`,
|
|
23
|
-
* the SCID, and the `versionId` of the latest verified head. Established at
|
|
24
|
-
* first contact (trust-on-first-use of the log's identity), advanced only
|
|
25
|
-
* after a full verification whose head is the pinned head or a descendant,
|
|
26
|
-
* and replaced wholesale only across a verified handover.
|
|
27
|
-
*/
|
|
28
|
-
export interface ResourceLogHeadPin {
|
|
29
|
-
method: string;
|
|
30
|
-
scid: string;
|
|
31
|
-
head: string;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Where a client keeps its chain-head pins, one record per log, keyed by
|
|
35
|
-
* `logId`. `read` resolves `null` before first contact with that log. Writes
|
|
36
|
-
* happen only on the two legal transitions (advance after full verification,
|
|
37
|
-
* replace across a verified handover) -- the verifier never regresses a pin.
|
|
38
|
-
*
|
|
39
|
-
* The `logId` uniquely names one log among all the logs this store instance
|
|
40
|
-
* serves: one store may serve every log a wallet holds, keyed per log, and two
|
|
41
|
-
* different logs must never share a `logId`. Wallet-core supplies the key at
|
|
42
|
-
* every read and write, built by {@link resourceLogPinId} (or one of the named
|
|
43
|
-
* builders over it), so an implementation never chooses keys of its own.
|
|
44
|
-
*/
|
|
45
|
-
export interface ResourceLogPinStore {
|
|
46
|
-
read(options: {
|
|
47
|
-
logId: string;
|
|
48
|
-
}): Promise<ResourceLogHeadPin | null>;
|
|
49
|
-
write(options: {
|
|
50
|
-
logId: string;
|
|
51
|
-
pin: ResourceLogHeadPin;
|
|
52
|
-
}): Promise<void>;
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* The pin-slot key for one log: an opaque per-log identity key for pin
|
|
56
|
-
* storage, not a fetchable path or URL.
|
|
57
|
-
*
|
|
58
|
-
* It is deliberately host-free. The `spaceId` is the account's stable random
|
|
59
|
-
* id, so a log served from a claimed new host lands in the SAME pin slot and
|
|
60
|
-
* is checked against the pin already held, rather than opening a fresh
|
|
61
|
-
* trust-on-first-use slate (the mirror-fork concern).
|
|
62
|
-
*
|
|
63
|
-
* @param options {object}
|
|
64
|
-
* @param options.spaceId {string} the Space the log lives in
|
|
65
|
-
* @param options.collectionId {string} the collection holding the log
|
|
66
|
-
* @param options.resourceId {string} the log resource's id
|
|
67
|
-
* @returns {string}
|
|
68
|
-
*/
|
|
69
|
-
export declare function resourceLogPinId({ spaceId, collectionId, resourceId }: {
|
|
70
|
-
spaceId: string;
|
|
71
|
-
collectionId: string;
|
|
72
|
-
resourceId: string;
|
|
73
|
-
}): string;
|
|
74
|
-
/**
|
|
75
|
-
* An in-memory pin store: continuity within one session only, keyed by
|
|
76
|
-
* `logId` like any other implementation, so one instance serves several logs.
|
|
77
|
-
* Tests use it as the seam's reference implementation; apps persist for real.
|
|
78
|
-
*
|
|
79
|
-
* @returns {ResourceLogPinStore}
|
|
80
|
-
*/
|
|
81
|
-
export declare function memoryResourceLogPinStore(): ResourceLogPinStore;
|
|
82
|
-
//# sourceMappingURL=pin.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pin.d.ts","sourceRoot":"","sources":["../../src/resourceLog/pin.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;GAgBG;AAEH;;;;;;GAMG;AACH,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;CACb;AAED;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,mBAAmB;IAClC,IAAI,CAAC,OAAO,EAAE;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC,CAAA;IACpE,KAAK,CAAC,OAAO,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,kBAAkB,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CAC1E;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,gBAAgB,CAAC,EAC/B,OAAO,EACP,YAAY,EACZ,UAAU,EACX,EAAE;IACD,OAAO,EAAE,MAAM,CAAA;IACf,YAAY,EAAE,MAAM,CAAA;IACpB,UAAU,EAAE,MAAM,CAAA;CACnB,GAAG,MAAM,CAET;AAED;;;;;;GAMG;AACH,wBAAgB,yBAAyB,IAAI,mBAAmB,CAU/D"}
|
package/dist/resourceLog/pin.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) 2026 Interop Alliance. All rights reserved.
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* The chain-head pin: the client-local durable record of a resource log's
|
|
6
|
-
* verified identity and latest verified head, kept per log beside the app's
|
|
7
|
-
* other continuity pins (the account pointer, the roster epoch pin). The pin
|
|
8
|
-
* is what turns one-shot verification into continuity: a served log whose
|
|
9
|
-
* SCID or method differs from the pin outside a verified handover, or whose
|
|
10
|
-
* history is not a descendant of the pinned head, is refused instead of
|
|
11
|
-
* adopted. Storage is the app's concern (freewallet: beside its other pins in
|
|
12
|
-
* localStorage; DCW: a table row), so only the seam lives here, plus an
|
|
13
|
-
* in-memory implementation for tests and single-session use.
|
|
14
|
-
*
|
|
15
|
-
* The seam is keyed: every read and write names the log it concerns with a
|
|
16
|
-
* `logId`, so one store instance serves every log a wallet holds. Wallet-core
|
|
17
|
-
* supplies the key at every call, built by {@link resourceLogPinId} (or one of
|
|
18
|
-
* the named builders over it), so an app implements one keyed store and never
|
|
19
|
-
* chooses keys itself.
|
|
20
|
-
*/
|
|
21
|
-
/**
|
|
22
|
-
* The pin-slot key for one log: an opaque per-log identity key for pin
|
|
23
|
-
* storage, not a fetchable path or URL.
|
|
24
|
-
*
|
|
25
|
-
* It is deliberately host-free. The `spaceId` is the account's stable random
|
|
26
|
-
* id, so a log served from a claimed new host lands in the SAME pin slot and
|
|
27
|
-
* is checked against the pin already held, rather than opening a fresh
|
|
28
|
-
* trust-on-first-use slate (the mirror-fork concern).
|
|
29
|
-
*
|
|
30
|
-
* @param options {object}
|
|
31
|
-
* @param options.spaceId {string} the Space the log lives in
|
|
32
|
-
* @param options.collectionId {string} the collection holding the log
|
|
33
|
-
* @param options.resourceId {string} the log resource's id
|
|
34
|
-
* @returns {string}
|
|
35
|
-
*/
|
|
36
|
-
export function resourceLogPinId({ spaceId, collectionId, resourceId }) {
|
|
37
|
-
return `space/${spaceId}/${collectionId}/${resourceId}`;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* An in-memory pin store: continuity within one session only, keyed by
|
|
41
|
-
* `logId` like any other implementation, so one instance serves several logs.
|
|
42
|
-
* Tests use it as the seam's reference implementation; apps persist for real.
|
|
43
|
-
*
|
|
44
|
-
* @returns {ResourceLogPinStore}
|
|
45
|
-
*/
|
|
46
|
-
export function memoryResourceLogPinStore() {
|
|
47
|
-
const pins = new Map();
|
|
48
|
-
return {
|
|
49
|
-
async read({ logId }) {
|
|
50
|
-
return pins.get(logId) ?? null;
|
|
51
|
-
},
|
|
52
|
-
async write({ logId, pin }) {
|
|
53
|
-
pins.set(logId, pin);
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
//# sourceMappingURL=pin.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pin.js","sourceRoot":"","sources":["../../src/resourceLog/pin.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;GAgBG;AAgCH;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,gBAAgB,CAAC,EAC/B,OAAO,EACP,YAAY,EACZ,UAAU,EAKX;IACC,OAAO,SAAS,OAAO,IAAI,YAAY,IAAI,UAAU,EAAE,CAAA;AACzD,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,yBAAyB;IACvC,MAAM,IAAI,GAAG,IAAI,GAAG,EAA8B,CAAA;IAClD,OAAO;QACL,KAAK,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE;YAClB,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,IAAI,CAAA;QAChC,CAAC;QACD,KAAK,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE;YACxB,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,CAAA;QACtB,CAAC;KACF,CAAA;AACH,CAAC"}
|