@interop/wallet-core 0.40.0 → 0.42.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -3
- package/dist/clients/listing.d.ts +4 -3
- package/dist/clients/listing.d.ts.map +1 -1
- package/dist/clients/listing.js.map +1 -1
- package/dist/clients/policy.d.ts +3 -2
- package/dist/clients/policy.d.ts.map +1 -1
- package/dist/clients/policy.js +3 -3
- package/dist/clients/policy.js.map +1 -1
- package/dist/clients/revocation.d.ts +14 -4
- package/dist/clients/revocation.d.ts.map +1 -1
- package/dist/clients/revocation.js +29 -14
- package/dist/clients/revocation.js.map +1 -1
- package/dist/clients/rosterPolicy.d.ts +22 -15
- package/dist/clients/rosterPolicy.d.ts.map +1 -1
- package/dist/clients/rosterPolicy.js +32 -15
- package/dist/clients/rosterPolicy.js.map +1 -1
- package/dist/descriptors/index.d.ts +1 -1
- package/dist/descriptors/index.d.ts.map +1 -1
- package/dist/descriptors/index.js +1 -1
- package/dist/descriptors/index.js.map +1 -1
- package/dist/descriptors/logSource.d.ts +58 -6
- package/dist/descriptors/logSource.d.ts.map +1 -1
- package/dist/descriptors/logSource.js +57 -15
- package/dist/descriptors/logSource.js.map +1 -1
- package/dist/enrollment/enrollment.d.ts +30 -2
- package/dist/enrollment/enrollment.d.ts.map +1 -1
- package/dist/enrollment/enrollment.js +58 -30
- package/dist/enrollment/enrollment.js.map +1 -1
- package/dist/enrollment/index.d.ts +4 -1
- package/dist/enrollment/index.d.ts.map +1 -1
- package/dist/enrollment/index.js +4 -1
- package/dist/enrollment/index.js.map +1 -1
- package/dist/keyring/fetch.d.ts +12 -0
- package/dist/keyring/fetch.d.ts.map +1 -1
- package/dist/keyring/fetch.js +0 -2
- package/dist/keyring/fetch.js.map +1 -1
- package/dist/keyring/index.d.ts +7 -6
- package/dist/keyring/index.d.ts.map +1 -1
- package/dist/keyring/index.js +7 -6
- package/dist/keyring/index.js.map +1 -1
- package/dist/keyring/kdf.d.ts +22 -6
- package/dist/keyring/kdf.d.ts.map +1 -1
- package/dist/keyring/kdf.js +9 -14
- package/dist/keyring/kdf.js.map +1 -1
- package/dist/keyring/record.d.ts +30 -10
- package/dist/keyring/record.d.ts.map +1 -1
- package/dist/keyring/record.js +31 -15
- package/dist/keyring/record.js.map +1 -1
- package/dist/keys/index.d.ts +5 -3
- package/dist/keys/index.d.ts.map +1 -1
- package/dist/keys/index.js +3 -2
- package/dist/keys/index.js.map +1 -1
- package/dist/keys/rosterLogStore.d.ts +22 -2
- package/dist/keys/rosterLogStore.d.ts.map +1 -1
- package/dist/keys/rosterLogStore.js +40 -20
- package/dist/keys/rosterLogStore.js.map +1 -1
- package/dist/keys/rosterStore.d.ts +13 -1
- package/dist/keys/rosterStore.d.ts.map +1 -1
- package/dist/keys/rosterStore.js +18 -0
- package/dist/keys/rosterStore.js.map +1 -1
- package/dist/keys/userKeyCascade.d.ts +10 -3
- package/dist/keys/userKeyCascade.d.ts.map +1 -1
- package/dist/keys/userKeyCascade.js +10 -4
- package/dist/keys/userKeyCascade.js.map +1 -1
- package/dist/keys/userKeyRoster.d.ts +29 -21
- package/dist/keys/userKeyRoster.d.ts.map +1 -1
- package/dist/keys/userKeyRoster.js +47 -23
- package/dist/keys/userKeyRoster.js.map +1 -1
- package/dist/recovery/index.d.ts +21 -11
- package/dist/recovery/index.d.ts.map +1 -1
- package/dist/recovery/index.js +19 -10
- package/dist/recovery/index.js.map +1 -1
- package/dist/recovery/recoveryCode.d.ts +5 -17
- package/dist/recovery/recoveryCode.d.ts.map +1 -1
- package/dist/recovery/recoveryCode.js +4 -14
- package/dist/recovery/recoveryCode.js.map +1 -1
- package/dist/recovery/recoveryDelegation.d.ts +151 -0
- package/dist/recovery/recoveryDelegation.d.ts.map +1 -0
- package/dist/recovery/recoveryDelegation.js +261 -0
- package/dist/recovery/recoveryDelegation.js.map +1 -0
- package/dist/recovery/recoveryWebvh.d.ts +13 -22
- package/dist/recovery/recoveryWebvh.d.ts.map +1 -1
- package/dist/recovery/recoveryWebvh.js +53 -139
- package/dist/recovery/recoveryWebvh.js.map +1 -1
- package/dist/resourceLog/append.d.ts +12 -3
- package/dist/resourceLog/append.d.ts.map +1 -1
- package/dist/resourceLog/append.js +17 -10
- package/dist/resourceLog/append.js.map +1 -1
- package/dist/resourceLog/index.d.ts +1 -1
- package/dist/resourceLog/index.d.ts.map +1 -1
- package/dist/resourceLog/index.js +1 -1
- package/dist/resourceLog/index.js.map +1 -1
- package/dist/resourceLog/pin.d.ts +46 -8
- package/dist/resourceLog/pin.d.ts.map +1 -1
- package/dist/resourceLog/pin.js +32 -7
- package/dist/resourceLog/pin.js.map +1 -1
- package/dist/resourceLog/seal.d.ts +4 -1
- package/dist/resourceLog/seal.d.ts.map +1 -1
- package/dist/resourceLog/seal.js +6 -2
- package/dist/resourceLog/seal.js.map +1 -1
- package/dist/unlock/index.d.ts +40 -0
- package/dist/unlock/index.d.ts.map +1 -0
- package/dist/unlock/index.js +36 -0
- package/dist/unlock/index.js.map +1 -0
- package/dist/unlock/ladder.d.ts +100 -0
- package/dist/unlock/ladder.d.ts.map +1 -0
- package/dist/unlock/ladder.js +144 -0
- package/dist/unlock/ladder.js.map +1 -0
- package/dist/unlock/selfEnroll.d.ts +83 -0
- package/dist/unlock/selfEnroll.d.ts.map +1 -0
- package/dist/unlock/selfEnroll.js +126 -0
- package/dist/unlock/selfEnroll.js.map +1 -0
- package/dist/unlock/standingClient.d.ts +68 -0
- package/dist/unlock/standingClient.d.ts.map +1 -0
- package/dist/unlock/standingClient.js +81 -0
- package/dist/unlock/standingClient.js.map +1 -0
- package/dist/unlock/standingWebvh.d.ts +153 -0
- package/dist/unlock/standingWebvh.d.ts.map +1 -0
- package/dist/unlock/standingWebvh.js +370 -0
- package/dist/unlock/standingWebvh.js.map +1 -0
- package/dist/unlock/unlockRecord.d.ts +207 -0
- package/dist/unlock/unlockRecord.d.ts.map +1 -0
- package/dist/unlock/unlockRecord.js +435 -0
- package/dist/unlock/unlockRecord.js.map +1 -0
- package/dist/webvh/didWebvh.d.ts +166 -7
- package/dist/webvh/didWebvh.d.ts.map +1 -1
- package/dist/webvh/didWebvh.js +286 -31
- package/dist/webvh/didWebvh.js.map +1 -1
- package/dist/webvh/index.d.ts +15 -3
- package/dist/webvh/index.d.ts.map +1 -1
- package/dist/webvh/index.js +14 -3
- package/dist/webvh/index.js.map +1 -1
- package/dist/webvh/keyAgreement.d.ts +72 -0
- package/dist/webvh/keyAgreement.d.ts.map +1 -0
- package/dist/webvh/keyAgreement.js +47 -0
- package/dist/webvh/keyAgreement.js.map +1 -0
- package/dist/webvh/listClients.d.ts +69 -20
- package/dist/webvh/listClients.d.ts.map +1 -1
- package/dist/webvh/listClients.js +102 -14
- package/dist/webvh/listClients.js.map +1 -1
- package/dist/webvh/revokeClient.d.ts +21 -11
- package/dist/webvh/revokeClient.d.ts.map +1 -1
- package/dist/webvh/revokeClient.js +31 -14
- package/dist/webvh/revokeClient.js.map +1 -1
- package/dist/webvh/verifyLog.d.ts +15 -2
- package/dist/webvh/verifyLog.d.ts.map +1 -1
- package/dist/webvh/verifyLog.js +22 -3
- package/dist/webvh/verifyLog.js.map +1 -1
- package/package.json +11 -5
- package/dist/recovery/recoveryRecord.d.ts +0 -171
- package/dist/recovery/recoveryRecord.d.ts.map +0 -1
- package/dist/recovery/recoveryRecord.js +0 -290
- package/dist/recovery/recoveryRecord.js.map +0 -1
|
@@ -34,7 +34,8 @@
|
|
|
34
34
|
* with the same key material converges without forking the log.
|
|
35
35
|
*/
|
|
36
36
|
import { deriveNextKeyHash, updateDID } from '@interop/did-method-webvh';
|
|
37
|
-
import { assertCarryOverCommitments,
|
|
37
|
+
import { assertCarryOverCommitments, markedVerificationMethodPair, MULTIKEY_VM_TYPE, putLogResource, readPublishedLog, relationIds, updateKeySigner, withLogConflictRetry } from '../webvh/didWebvh.js';
|
|
38
|
+
import { publishUnlockKey, removeUnlockKey } from '../unlock/standingWebvh.js';
|
|
38
39
|
/**
|
|
39
40
|
* The verification-method id a code's key-agreement key publishes under --
|
|
40
41
|
* the ordinary `<did>#<multibase>` form, indistinguishable by id from any
|
|
@@ -101,12 +102,12 @@ async function publishLogOnly({ store, log, ifMatch }) {
|
|
|
101
102
|
/**
|
|
102
103
|
* ISSUANCE (run by an enrolled client, root authority): publishes a recovery
|
|
103
104
|
* code's split posture into the document -- one entry adding the code's
|
|
104
|
-
* `keyAgreement` verification method (an ordinary, unmarked Multikey entry
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
*
|
|
109
|
-
*
|
|
105
|
+
* `keyAgreement` verification method (an ordinary, unmarked Multikey entry,
|
|
106
|
+
* the key published verbatim: a code is high-entropy, so no commitment is
|
|
107
|
+
* needed) and committing its update-key hash in `nextKeyHashes`. The code's
|
|
108
|
+
* update key joins `updateKeys` nowhere. A thin wrapper over the standing
|
|
109
|
+
* unlock-key posture core ({@link publishUnlockKey}), which owns idempotence
|
|
110
|
+
* and the conditional publish.
|
|
110
111
|
*
|
|
111
112
|
* @param options {object}
|
|
112
113
|
* @param options.idStore {WebvhIdStore}
|
|
@@ -117,134 +118,44 @@ async function publishLogOnly({ store, log, ifMatch }) {
|
|
|
117
118
|
* resolve to, from the caller's stored account pointer
|
|
118
119
|
* @returns {Promise<{ did: string }>}
|
|
119
120
|
*/
|
|
120
|
-
export async function publishRecoveryKey(
|
|
121
|
-
return
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
...(expectedDid !== undefined ? { expectedDid } : {})
|
|
133
|
-
});
|
|
134
|
-
const { did, doc } = published;
|
|
135
|
-
const recoveryHash = await deriveNextKeyHash(recovery.updateKeyMultibase);
|
|
136
|
-
const vmId = recoveryVmId({
|
|
137
|
-
did,
|
|
138
|
-
keyAgreementKeyMultibase: recovery.keyAgreementKeyMultibase
|
|
139
|
-
});
|
|
140
|
-
const vmPresent = (doc.verificationMethod ?? []).some(method => method.id === vmId);
|
|
141
|
-
const hashCommitted = published.nextKeyHashes.includes(recoveryHash);
|
|
142
|
-
if (vmPresent && hashCommitted) {
|
|
143
|
-
return { did };
|
|
144
|
-
}
|
|
145
|
-
const activeKey = await updateKeyMultibase({ seed: updateKeys.updateSeed });
|
|
146
|
-
if (!published.updateKeys.includes(activeKey)) {
|
|
147
|
-
throw new Error("did:webvh: the published log does not authorize this client's active " +
|
|
148
|
-
'update key; finalize the pending rotation before issuing a ' +
|
|
149
|
-
'recovery code.');
|
|
150
|
-
}
|
|
151
|
-
await assertCarryOverCommitments({ published });
|
|
152
|
-
const existingMethods = (doc.verificationMethod ?? []);
|
|
153
|
-
const recoveryMethod = {
|
|
154
|
-
id: vmId,
|
|
155
|
-
type: MULTIKEY_VM_TYPE,
|
|
156
|
-
controller: did,
|
|
157
|
-
publicKeyMultibase: recovery.keyAgreementKeyMultibase
|
|
158
|
-
};
|
|
159
|
-
const signer = await updateKeySigner({ seed: updateKeys.updateSeed });
|
|
160
|
-
const updated = await updateDID({
|
|
161
|
-
log: published.log,
|
|
162
|
-
signer,
|
|
163
|
-
alsoKnownAsWeb: true,
|
|
164
|
-
updateKeys: published.updateKeys,
|
|
165
|
-
nextKeyHashes: [...new Set([...published.nextKeyHashes, recoveryHash])],
|
|
166
|
-
verificationMethods: [
|
|
167
|
-
...existingMethods.filter(method => method.id !== vmId),
|
|
168
|
-
recoveryMethod
|
|
169
|
-
],
|
|
170
|
-
authentication: relationIds(doc.authentication),
|
|
171
|
-
assertionMethod: relationIds(doc.assertionMethod),
|
|
172
|
-
keyAgreement: [...new Set([...relationIds(doc.keyAgreement), vmId])],
|
|
173
|
-
capabilityInvocation: relationIds(doc.capabilityInvocation),
|
|
174
|
-
capabilityDelegation: relationIds(doc.capabilityDelegation)
|
|
121
|
+
export async function publishRecoveryKey({ idStore, updateKeys, recovery, expectedDid }) {
|
|
122
|
+
return publishUnlockKey({
|
|
123
|
+
idStore,
|
|
124
|
+
updateKeys,
|
|
125
|
+
unlockKeys: {
|
|
126
|
+
keyAgreement: {
|
|
127
|
+
publicKeyMultibase: recovery.keyAgreementKeyMultibase
|
|
128
|
+
},
|
|
129
|
+
updateKeyMultibase: recovery.updateKeyMultibase
|
|
130
|
+
},
|
|
131
|
+
...(expectedDid !== undefined ? { expectedDid } : {}),
|
|
132
|
+
verb: 'issuing a recovery code'
|
|
175
133
|
});
|
|
176
|
-
await publishUpdatedLog({ idStore, updated, ifMatch: published.etag });
|
|
177
|
-
return { did: updated.did };
|
|
178
134
|
}
|
|
179
135
|
/**
|
|
180
136
|
* REVOCATION (run by an enrolled client, root authority): removes a recovery
|
|
181
137
|
* code's posture from the document -- its `keyAgreement` verification method
|
|
182
|
-
* and its committed update-key hash -- in one entry
|
|
183
|
-
* roster-side half (rotating the
|
|
184
|
-
* caller's, and runs after this so
|
|
185
|
-
* the removed entry.
|
|
186
|
-
*
|
|
187
|
-
* The entry publishes conditionally on the log this call read; a race lost to
|
|
188
|
-
* a concurrent ceremony re-runs and rebases on the new head.
|
|
189
|
-
*
|
|
190
|
-
* @param options {object}
|
|
191
|
-
* @param options.idStore {WebvhIdStore}
|
|
192
|
-
* @param options.updateKeys {ClientWebvhUpdateKeys} the REVOKING client's
|
|
193
|
-
* own did:webvh update-key seeds
|
|
194
|
-
* @param options.recovery {RecoveryPublicKeys} the code's public halves
|
|
195
|
-
* @param [options.expectedDid] {string} the account DID the log must
|
|
196
|
-
* resolve to, from the caller's stored account pointer
|
|
197
|
-
* @returns {Promise<{ did: string }>}
|
|
198
|
-
*/
|
|
199
|
-
export async function removeRecoveryKey(options) {
|
|
200
|
-
return withLogConflictRetry(() => removeRecoveryKeyOnce(options));
|
|
201
|
-
}
|
|
202
|
-
/**
|
|
203
|
-
* One attempt of {@link removeRecoveryKey}, re-invoked by the conflict retry.
|
|
138
|
+
* and its committed update-key hash -- in one entry, through the same shared
|
|
139
|
+
* posture core ({@link removeUnlockKey}). The roster-side half (rotating the
|
|
140
|
+
* user key epoch off the code's wrap) is the caller's, and runs after this so
|
|
141
|
+
* the resolver's document no longer backs the removed entry.
|
|
204
142
|
*
|
|
205
|
-
* @param options {object} see {@link
|
|
143
|
+
* @param options {object} see {@link publishRecoveryKey}
|
|
206
144
|
* @returns {Promise<{ did: string }>}
|
|
207
145
|
*/
|
|
208
|
-
async function
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
const hashCommitted = published.nextKeyHashes.includes(recoveryHash);
|
|
221
|
-
if (!vmPresent && !hashCommitted) {
|
|
222
|
-
return { did };
|
|
223
|
-
}
|
|
224
|
-
const activeKey = await updateKeyMultibase({ seed: updateKeys.updateSeed });
|
|
225
|
-
if (!published.updateKeys.includes(activeKey)) {
|
|
226
|
-
throw new Error("did:webvh: the published log does not authorize this client's active " +
|
|
227
|
-
'update key; finalize the pending rotation before revoking a ' +
|
|
228
|
-
'recovery code.');
|
|
229
|
-
}
|
|
230
|
-
await assertCarryOverCommitments({ published });
|
|
231
|
-
const existingMethods = (doc.verificationMethod ?? []);
|
|
232
|
-
const signer = await updateKeySigner({ seed: updateKeys.updateSeed });
|
|
233
|
-
const updated = await updateDID({
|
|
234
|
-
log: published.log,
|
|
235
|
-
signer,
|
|
236
|
-
alsoKnownAsWeb: true,
|
|
237
|
-
updateKeys: published.updateKeys,
|
|
238
|
-
nextKeyHashes: published.nextKeyHashes.filter(hash => hash !== recoveryHash),
|
|
239
|
-
verificationMethods: existingMethods.filter(method => method.id !== vmId),
|
|
240
|
-
authentication: relationIds(doc.authentication),
|
|
241
|
-
assertionMethod: relationIds(doc.assertionMethod),
|
|
242
|
-
keyAgreement: relationIds(doc.keyAgreement).filter(id => id !== vmId),
|
|
243
|
-
capabilityInvocation: relationIds(doc.capabilityInvocation),
|
|
244
|
-
capabilityDelegation: relationIds(doc.capabilityDelegation)
|
|
146
|
+
export async function removeRecoveryKey({ idStore, updateKeys, recovery, expectedDid }) {
|
|
147
|
+
return removeUnlockKey({
|
|
148
|
+
idStore,
|
|
149
|
+
updateKeys,
|
|
150
|
+
unlockKeys: {
|
|
151
|
+
keyAgreement: {
|
|
152
|
+
publicKeyMultibase: recovery.keyAgreementKeyMultibase
|
|
153
|
+
},
|
|
154
|
+
updateKeyMultibase: recovery.updateKeyMultibase
|
|
155
|
+
},
|
|
156
|
+
...(expectedDid !== undefined ? { expectedDid } : {}),
|
|
157
|
+
verb: 'revoking a recovery code'
|
|
245
158
|
});
|
|
246
|
-
await publishUpdatedLog({ idStore, updated, ifMatch: published.etag });
|
|
247
|
-
return { did: updated.did };
|
|
248
159
|
}
|
|
249
160
|
/**
|
|
250
161
|
* RECOVERY (run by the code-derived client through the delegated `did.jsonl`
|
|
@@ -355,24 +266,27 @@ async function recoverWebvhClientOnce({ store, recovery, newClientKeys, newClien
|
|
|
355
266
|
did,
|
|
356
267
|
keyAgreementKeyMultibase: replacement.keyAgreementKeyMultibase
|
|
357
268
|
});
|
|
269
|
+
// A three-way controller split. The new client's signing method and the
|
|
270
|
+
// replacement code's key-agreement method are controlled by the account;
|
|
271
|
+
// the new client's key-agreement method alone carries the controller marker
|
|
272
|
+
// (see clientKeyAgreementController) -- which is exactly what tells the two
|
|
273
|
+
// simultaneously published keyAgreement methods apart. The marked pair goes
|
|
274
|
+
// through the shared builder, which refuses a new client whose key-agreement
|
|
275
|
+
// key is not its signing key's canonical twin; the replacement code's
|
|
276
|
+
// unmarked method is appended after it.
|
|
358
277
|
const addedMethods = [
|
|
359
|
-
{
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
id: vmId(newClientKeys.keyAgreementKeyMultibase),
|
|
365
|
-
publicKeyMultibase: newClientKeys.keyAgreementKeyMultibase
|
|
366
|
-
},
|
|
278
|
+
...markedVerificationMethodPair({
|
|
279
|
+
controller: did,
|
|
280
|
+
signingKeyMultibase: newClientKeys.signingKeyMultibase,
|
|
281
|
+
keyAgreementKeyMultibase: newClientKeys.keyAgreementKeyMultibase
|
|
282
|
+
}),
|
|
367
283
|
{
|
|
368
284
|
id: replacementVmId,
|
|
285
|
+
type: MULTIKEY_VM_TYPE,
|
|
286
|
+
controller: did,
|
|
369
287
|
publicKeyMultibase: replacement.keyAgreementKeyMultibase
|
|
370
288
|
}
|
|
371
|
-
]
|
|
372
|
-
...method,
|
|
373
|
-
type: MULTIKEY_VM_TYPE,
|
|
374
|
-
controller: did
|
|
375
|
-
}));
|
|
289
|
+
];
|
|
376
290
|
const existingMethods = (doc.verificationMethod ?? []);
|
|
377
291
|
const verificationMethods = [
|
|
378
292
|
...existingMethods.filter(method => method.id !== spentVmId &&
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recoveryWebvh.js","sourceRoot":"","sources":["../../src/recovery/recoveryWebvh.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AAExE,OAAO,EACL,0BAA0B,EAC1B,gBAAgB,EAChB,
|
|
1
|
+
{"version":3,"file":"recoveryWebvh.js","sourceRoot":"","sources":["../../src/recovery/recoveryWebvh.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AAExE,OAAO,EACL,0BAA0B,EAC1B,4BAA4B,EAC5B,gBAAgB,EAChB,cAAc,EACd,gBAAgB,EAChB,WAAW,EACX,eAAe,EACf,oBAAoB,EACrB,MAAM,sBAAsB,CAAA;AAO7B,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAE9E;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QACnB,cAAc,EAAE,aAAa,CAAC,GAAG,CAAC,cAAc,EAAE,WAAW,CAAC;QAC9D,eAAe,EAAE,aAAa,CAAC,GAAG,CAAC,eAAe,EAAE,WAAW,CAAC;QAChE,YAAY,EAAE;YACZ,GAAG,IAAI,GAAG,CAAC;gBACT,GAAG,WAAW,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,SAAS,CAAC;gBAC/D,IAAI,CAAC,aAAa,CAAC,wBAAwB,CAAC;gBAC5C,eAAe;aAChB,CAAC;SACH;QACD,oBAAoB,EAAE,aAAa,CAAC,GAAG,CAAC,oBAAoB,EAAE,WAAW,CAAC;QAC1E,oBAAoB,EAAE,aAAa,CAAC,GAAG,CAAC,oBAAoB,EAAE,WAAW,CAAC;KAC3E,CAAC,CAAA;IACF,0EAA0E;IAC1E,iEAAiE;IACjE,MAAM,cAAc,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,OAAO,EAAE,SAAS,CAAC,IAAI,EAAE,CAAC,CAAA;IAC1E,OAAO,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAA;AACrD,CAAC"}
|
|
@@ -19,13 +19,16 @@ import { type VerifiedResourceLog } from './verify.js';
|
|
|
19
19
|
* (also confirming any `history` dispatch hint the caller followed)
|
|
20
20
|
* @param options.pinStore {ResourceLogPinStore} this client's pin for this
|
|
21
21
|
* log
|
|
22
|
+
* @param options.logId {string} the pin-slot key for this log, from
|
|
23
|
+
* `resourceLogPinId`
|
|
22
24
|
* @returns {Promise<{ verified: VerifiedResourceLog; etag?: string } | null>}
|
|
23
25
|
*/
|
|
24
|
-
export declare function readResourceLog({ store, controller, expectedMethod, pinStore }: {
|
|
26
|
+
export declare function readResourceLog({ store, controller, expectedMethod, pinStore, logId }: {
|
|
25
27
|
store: ResourceLogStore;
|
|
26
28
|
controller: ResourceLogController;
|
|
27
29
|
expectedMethod: string;
|
|
28
30
|
pinStore: ResourceLogPinStore;
|
|
31
|
+
logId: string;
|
|
29
32
|
}): Promise<{
|
|
30
33
|
verified: VerifiedResourceLog;
|
|
31
34
|
etag?: string;
|
|
@@ -44,6 +47,8 @@ export declare function readResourceLog({ store, controller, expectedMethod, pin
|
|
|
44
47
|
* @param options.controller {ResourceLogController}
|
|
45
48
|
* @param options.expectedMethod {string}
|
|
46
49
|
* @param options.pinStore {ResourceLogPinStore}
|
|
50
|
+
* @param options.logId {string} the pin-slot key for this log, from
|
|
51
|
+
* `resourceLogPinId`
|
|
47
52
|
* @param options.signer {ResourceLogSigner}
|
|
48
53
|
* @param options.buildState {function} `(verified) => state | null` -- the
|
|
49
54
|
* full next state rebased on the verified head, or `null` when the head
|
|
@@ -54,11 +59,12 @@ export declare function readResourceLog({ store, controller, expectedMethod, pin
|
|
|
54
59
|
* @returns {Promise<VerifiedResourceLog>} the read-back, re-verified log
|
|
55
60
|
* (whether or not this call appended)
|
|
56
61
|
*/
|
|
57
|
-
export declare function appendResourceLog({ store, controller, expectedMethod, pinStore, signer, buildState, versionTime, maxAttempts }: {
|
|
62
|
+
export declare function appendResourceLog({ store, controller, expectedMethod, pinStore, logId, signer, buildState, versionTime, maxAttempts }: {
|
|
58
63
|
store: ResourceLogStore;
|
|
59
64
|
controller: ResourceLogController;
|
|
60
65
|
expectedMethod: string;
|
|
61
66
|
pinStore: ResourceLogPinStore;
|
|
67
|
+
logId: string;
|
|
62
68
|
signer: ResourceLogSigner;
|
|
63
69
|
buildState: (verified: VerifiedResourceLog) => Promise<ResourceLogEntry['state'] | null> | ResourceLogEntry['state'] | null;
|
|
64
70
|
versionTime?: string;
|
|
@@ -77,6 +83,8 @@ export declare function appendResourceLog({ store, controller, expectedMethod, p
|
|
|
77
83
|
* @param options.controller {ResourceLogController}
|
|
78
84
|
* @param options.method {string} the format identifier to declare
|
|
79
85
|
* @param options.pinStore {ResourceLogPinStore}
|
|
86
|
+
* @param options.logId {string} the pin-slot key for this log, from
|
|
87
|
+
* `resourceLogPinId`
|
|
80
88
|
* @param options.signer {ResourceLogSigner}
|
|
81
89
|
* @param options.state {ResourceLogEntry['state']} the full initial state
|
|
82
90
|
* @param [options.previousLog] {object} handover successors only
|
|
@@ -84,11 +92,12 @@ export declare function appendResourceLog({ store, controller, expectedMethod, p
|
|
|
84
92
|
* @returns {Promise<{ verified: VerifiedResourceLog; created: boolean }>}
|
|
85
93
|
* the verified log as it now stands, and whether this call created it
|
|
86
94
|
*/
|
|
87
|
-
export declare function createResourceLog({ store, controller, method, pinStore, signer, state, previousLog, versionTime }: {
|
|
95
|
+
export declare function createResourceLog({ store, controller, method, pinStore, logId, signer, state, previousLog, versionTime }: {
|
|
88
96
|
store: ResourceLogStore;
|
|
89
97
|
controller: ResourceLogController;
|
|
90
98
|
method: string;
|
|
91
99
|
pinStore: ResourceLogPinStore;
|
|
100
|
+
logId: string;
|
|
92
101
|
signer: ResourceLogSigner;
|
|
93
102
|
state: ResourceLogEntry['state'];
|
|
94
103
|
previousLog?: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"append.d.ts","sourceRoot":"","sources":["../../src/resourceLog/append.ts"],"names":[],"mappings":"AAeA,OAAO,EAEL,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACtB,MAAM,yBAAyB,CAAA;AAChC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAA;AAE5D,OAAO,EAGL,KAAK,iBAAiB,EACvB,MAAM,YAAY,CAAA;AACnB,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAA;AACnD,OAAO,EAAqB,KAAK,mBAAmB,EAAE,MAAM,aAAa,CAAA;AAEzE
|
|
1
|
+
{"version":3,"file":"append.d.ts","sourceRoot":"","sources":["../../src/resourceLog/append.ts"],"names":[],"mappings":"AAeA,OAAO,EAEL,KAAK,gBAAgB,EACrB,KAAK,gBA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M,CAAA;IACpB,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAgE/B;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAsB,iBAAiB,CAAC,EACtC,KAAK,EACL,UAAU,EACV,MAAM,EACN,QAAQ,EACR,KAAK,EACL,MAAM,EACN,KAAK,EACL,WAAW,EACX,WAAW,EACZ,EAAE;IACD,KAAK,EAAE,gBAAgB,CAAA;IACvB,UAAU,EAAE,qBAAqB,CAAA;IACjC,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,mBAAmB,CAAA;IAC7B,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,iBAAiB,CAAA;IACzB,KAAK,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAA;IAChC,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;IAAE,QAAQ,EAAE,mBAAmB,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,CAmC/D"}
|
|
@@ -33,21 +33,23 @@ import { verifyResourceLog } from './verify.js';
|
|
|
33
33
|
* (also confirming any `history` dispatch hint the caller followed)
|
|
34
34
|
* @param options.pinStore {ResourceLogPinStore} this client's pin for this
|
|
35
35
|
* log
|
|
36
|
+
* @param options.logId {string} the pin-slot key for this log, from
|
|
37
|
+
* `resourceLogPinId`
|
|
36
38
|
* @returns {Promise<{ verified: VerifiedResourceLog; etag?: string } | null>}
|
|
37
39
|
*/
|
|
38
|
-
export async function readResourceLog({ store, controller, expectedMethod, pinStore }) {
|
|
40
|
+
export async function readResourceLog({ store, controller, expectedMethod, pinStore, logId }) {
|
|
39
41
|
const current = await store.read();
|
|
40
42
|
if (current === null) {
|
|
41
43
|
return null;
|
|
42
44
|
}
|
|
43
|
-
const pin = await pinStore.read();
|
|
45
|
+
const pin = await pinStore.read({ logId });
|
|
44
46
|
const verified = await verifyResourceLog({
|
|
45
47
|
entries: current.entries,
|
|
46
48
|
controller,
|
|
47
49
|
expectedMethod,
|
|
48
50
|
pin
|
|
49
51
|
});
|
|
50
|
-
await pinStore.write(verified.pin);
|
|
52
|
+
await pinStore.write({ logId, pin: verified.pin });
|
|
51
53
|
return { verified, etag: current.etag };
|
|
52
54
|
}
|
|
53
55
|
/**
|
|
@@ -64,6 +66,8 @@ export async function readResourceLog({ store, controller, expectedMethod, pinSt
|
|
|
64
66
|
* @param options.controller {ResourceLogController}
|
|
65
67
|
* @param options.expectedMethod {string}
|
|
66
68
|
* @param options.pinStore {ResourceLogPinStore}
|
|
69
|
+
* @param options.logId {string} the pin-slot key for this log, from
|
|
70
|
+
* `resourceLogPinId`
|
|
67
71
|
* @param options.signer {ResourceLogSigner}
|
|
68
72
|
* @param options.buildState {function} `(verified) => state | null` -- the
|
|
69
73
|
* full next state rebased on the verified head, or `null` when the head
|
|
@@ -74,14 +78,15 @@ export async function readResourceLog({ store, controller, expectedMethod, pinSt
|
|
|
74
78
|
* @returns {Promise<VerifiedResourceLog>} the read-back, re-verified log
|
|
75
79
|
* (whether or not this call appended)
|
|
76
80
|
*/
|
|
77
|
-
export async function appendResourceLog({ store, controller, expectedMethod, pinStore, signer, buildState, versionTime, maxAttempts = 3 }) {
|
|
81
|
+
export async function appendResourceLog({ store, controller, expectedMethod, pinStore, logId, signer, buildState, versionTime, maxAttempts = 3 }) {
|
|
78
82
|
let lastConflict;
|
|
79
83
|
for (let attempt = 0; attempt < maxAttempts; attempt++) {
|
|
80
84
|
const current = await readResourceLog({
|
|
81
85
|
store,
|
|
82
86
|
controller,
|
|
83
87
|
expectedMethod,
|
|
84
|
-
pinStore
|
|
88
|
+
pinStore,
|
|
89
|
+
logId
|
|
85
90
|
});
|
|
86
91
|
if (current === null) {
|
|
87
92
|
throw new Error('Cannot append to the resource log: the log does not exist yet ' +
|
|
@@ -124,9 +129,9 @@ export async function appendResourceLog({ store, controller, expectedMethod, pin
|
|
|
124
129
|
entries: readBack.entries,
|
|
125
130
|
controller,
|
|
126
131
|
expectedMethod,
|
|
127
|
-
pin: await pinStore.read()
|
|
132
|
+
pin: await pinStore.read({ logId })
|
|
128
133
|
});
|
|
129
|
-
await pinStore.write(confirmed.pin);
|
|
134
|
+
await pinStore.write({ logId, pin: confirmed.pin });
|
|
130
135
|
return confirmed;
|
|
131
136
|
}
|
|
132
137
|
throw new Error(`Appending to the resource log lost the compare-and-swap race ` +
|
|
@@ -145,6 +150,8 @@ export async function appendResourceLog({ store, controller, expectedMethod, pin
|
|
|
145
150
|
* @param options.controller {ResourceLogController}
|
|
146
151
|
* @param options.method {string} the format identifier to declare
|
|
147
152
|
* @param options.pinStore {ResourceLogPinStore}
|
|
153
|
+
* @param options.logId {string} the pin-slot key for this log, from
|
|
154
|
+
* `resourceLogPinId`
|
|
148
155
|
* @param options.signer {ResourceLogSigner}
|
|
149
156
|
* @param options.state {ResourceLogEntry['state']} the full initial state
|
|
150
157
|
* @param [options.previousLog] {object} handover successors only
|
|
@@ -152,7 +159,7 @@ export async function appendResourceLog({ store, controller, expectedMethod, pin
|
|
|
152
159
|
* @returns {Promise<{ verified: VerifiedResourceLog; created: boolean }>}
|
|
153
160
|
* the verified log as it now stands, and whether this call created it
|
|
154
161
|
*/
|
|
155
|
-
export async function createResourceLog({ store, controller, method, pinStore, signer, state, previousLog, versionTime }) {
|
|
162
|
+
export async function createResourceLog({ store, controller, method, pinStore, logId, signer, state, previousLog, versionTime }) {
|
|
156
163
|
const genesis = await buildResourceLogGenesis({
|
|
157
164
|
state,
|
|
158
165
|
method,
|
|
@@ -182,9 +189,9 @@ export async function createResourceLog({ store, controller, method, pinStore, s
|
|
|
182
189
|
entries: current.entries,
|
|
183
190
|
controller,
|
|
184
191
|
expectedMethod: method,
|
|
185
|
-
pin: await pinStore.read()
|
|
192
|
+
pin: await pinStore.read({ logId })
|
|
186
193
|
});
|
|
187
|
-
await pinStore.write(verified.pin);
|
|
194
|
+
await pinStore.write({ logId, pin: verified.pin });
|
|
188
195
|
return { verified, created };
|
|
189
196
|
}
|
|
190
197
|
//# sourceMappingURL=append.js.map
|
|
@@ -1 +1 @@
|
|
|
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
|
|
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,GAA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7 +19,7 @@
|
|
|
19
19
|
export { webvhResourceLogController, type ResourceLogController } from './controller.js';
|
|
20
20
|
export { ResourceLogClosedError, ResourceLogContinuityError, ResourceLogIntegrityError } from './errors.js';
|
|
21
21
|
export { buildResourceLogEntry, buildResourceLogGenesis, type ResourceLogSigner } from './entry.js';
|
|
22
|
-
export { memoryResourceLogPinStore, type ResourceLogHeadPin, type ResourceLogPinStore } from './pin.js';
|
|
22
|
+
export { memoryResourceLogPinStore, resourceLogPinId, type ResourceLogHeadPin, type ResourceLogPinStore } from './pin.js';
|
|
23
23
|
export { isTerminalResourceLogEntry, verifyResourceLog, verifyResourceLogHandover, type VerifiedResourceLog } from './verify.js';
|
|
24
24
|
export { appendResourceLog, createResourceLog, readResourceLog } from './append.js';
|
|
25
25
|
export { latestAssertionRemovalIndex, sealResourceLog } from './seal.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/resourceLog/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;GAcG;AACH,OAAO,EACL,0BAA0B,EAC1B,KAAK,qBAAqB,EAC3B,MAAM,iBAAiB,CAAA;AACxB,OAAO,EACL,sBAAsB,EACtB,0BAA0B,EAC1B,yBAAyB,EAC1B,MAAM,aAAa,CAAA;AACpB,OAAO,EACL,qBAAqB,EACrB,uBAAuB,EACvB,KAAK,iBAAiB,EACvB,MAAM,YAAY,CAAA;AACnB,OAAO,EACL,yBAAyB,EACzB,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,EACzB,MAAM,UAAU,CAAA;AACjB,OAAO,EACL,0BAA0B,EAC1B,iBAAiB,EACjB,yBAAyB,EACzB,KAAK,mBAAmB,EACzB,MAAM,aAAa,CAAA;AACpB,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EAChB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,2BAA2B,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/resourceLog/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;GAcG;AACH,OAAO,EACL,0BAA0B,EAC1B,KAAK,qBAAqB,EAC3B,MAAM,iBAAiB,CAAA;AACxB,OAAO,EACL,sBAAsB,EACtB,0BAA0B,EAC1B,yBAAyB,EAC1B,MAAM,aAAa,CAAA;AACpB,OAAO,EACL,qBAAqB,EACrB,uBAAuB,EACvB,KAAK,iBAAiB,EACvB,MAAM,YAAY,CAAA;AACnB,OAAO,EACL,yBAAyB,EACzB,gBAAgB,EAChB,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,EACzB,MAAM,UAAU,CAAA;AACjB,OAAO,EACL,0BAA0B,EAC1B,iBAAiB,EACjB,yBAAyB,EACzB,KAAK,mBAAmB,EACzB,MAAM,aAAa,CAAA;AACpB,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EAChB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,2BAA2B,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA"}
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
export { webvhResourceLogController } from './controller.js';
|
|
20
20
|
export { ResourceLogClosedError, ResourceLogContinuityError, ResourceLogIntegrityError } from './errors.js';
|
|
21
21
|
export { buildResourceLogEntry, buildResourceLogGenesis } from './entry.js';
|
|
22
|
-
export { memoryResourceLogPinStore } from './pin.js';
|
|
22
|
+
export { memoryResourceLogPinStore, resourceLogPinId } from './pin.js';
|
|
23
23
|
export { isTerminalResourceLogEntry, verifyResourceLog, verifyResourceLogHandover } from './verify.js';
|
|
24
24
|
export { appendResourceLog, createResourceLog, readResourceLog } from './append.js';
|
|
25
25
|
export { latestAssertionRemovalIndex, sealResourceLog } from './seal.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/resourceLog/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;GAcG;AACH,OAAO,EACL,0BAA0B,EAE3B,MAAM,iBAAiB,CAAA;AACxB,OAAO,EACL,sBAAsB,EACtB,0BAA0B,EAC1B,yBAAyB,EAC1B,MAAM,aAAa,CAAA;AACpB,OAAO,EACL,qBAAqB,EACrB,uBAAuB,EAExB,MAAM,YAAY,CAAA;AACnB,OAAO,EACL,yBAAyB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/resourceLog/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;GAcG;AACH,OAAO,EACL,0BAA0B,EAE3B,MAAM,iBAAiB,CAAA;AACxB,OAAO,EACL,sBAAsB,EACtB,0BAA0B,EAC1B,yBAAyB,EAC1B,MAAM,aAAa,CAAA;AACpB,OAAO,EACL,qBAAqB,EACrB,uBAAuB,EAExB,MAAM,YAAY,CAAA;AACnB,OAAO,EACL,yBAAyB,EACzB,gBAAgB,EAGjB,MAAM,UAAU,CAAA;AACjB,OAAO,EACL,0BAA0B,EAC1B,iBAAiB,EACjB,yBAAyB,EAE1B,MAAM,aAAa,CAAA;AACpB,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EAChB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,2BAA2B,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA"}
|
|
@@ -11,6 +11,12 @@
|
|
|
11
11
|
* adopted. Storage is the app's concern (freewallet: beside its other pins in
|
|
12
12
|
* localStorage; DCW: a table row), so only the seam lives here, plus an
|
|
13
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.
|
|
14
20
|
*/
|
|
15
21
|
/**
|
|
16
22
|
* One log's pin: the format identifier from the genesis `parameters.method`,
|
|
@@ -25,18 +31,50 @@ export interface ResourceLogHeadPin {
|
|
|
25
31
|
head: string;
|
|
26
32
|
}
|
|
27
33
|
/**
|
|
28
|
-
* Where a client keeps its chain-head pins, one record per log
|
|
29
|
-
* resolves `null` before first contact
|
|
30
|
-
* transitions (advance after full verification,
|
|
31
|
-
* handover) -- the verifier never regresses a pin.
|
|
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.
|
|
32
44
|
*/
|
|
33
45
|
export interface ResourceLogPinStore {
|
|
34
|
-
read(
|
|
35
|
-
|
|
46
|
+
read(options: {
|
|
47
|
+
logId: string;
|
|
48
|
+
}): Promise<ResourceLogHeadPin | null>;
|
|
49
|
+
write(options: {
|
|
50
|
+
logId: string;
|
|
51
|
+
pin: ResourceLogHeadPin;
|
|
52
|
+
}): Promise<void>;
|
|
36
53
|
}
|
|
37
54
|
/**
|
|
38
|
-
*
|
|
39
|
-
*
|
|
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.
|
|
40
78
|
*
|
|
41
79
|
* @returns {ResourceLogPinStore}
|
|
42
80
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pin.d.ts","sourceRoot":"","sources":["../../src/resourceLog/pin.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH
|
|
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
CHANGED
|
@@ -11,21 +11,46 @@
|
|
|
11
11
|
* adopted. Storage is the app's concern (freewallet: beside its other pins in
|
|
12
12
|
* localStorage; DCW: a table row), so only the seam lives here, plus an
|
|
13
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}
|
|
14
35
|
*/
|
|
36
|
+
export function resourceLogPinId({ spaceId, collectionId, resourceId }) {
|
|
37
|
+
return `space/${spaceId}/${collectionId}/${resourceId}`;
|
|
38
|
+
}
|
|
15
39
|
/**
|
|
16
|
-
* An in-memory pin store: continuity within one session only
|
|
17
|
-
*
|
|
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.
|
|
18
43
|
*
|
|
19
44
|
* @returns {ResourceLogPinStore}
|
|
20
45
|
*/
|
|
21
46
|
export function memoryResourceLogPinStore() {
|
|
22
|
-
|
|
47
|
+
const pins = new Map();
|
|
23
48
|
return {
|
|
24
|
-
async read() {
|
|
25
|
-
return
|
|
49
|
+
async read({ logId }) {
|
|
50
|
+
return pins.get(logId) ?? null;
|
|
26
51
|
},
|
|
27
|
-
async write(
|
|
28
|
-
pin
|
|
52
|
+
async write({ logId, pin }) {
|
|
53
|
+
pins.set(logId, pin);
|
|
29
54
|
}
|
|
30
55
|
};
|
|
31
56
|
}
|