@interop/wallet-core 0.30.1 → 0.32.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/dist/clients/listing.d.ts +9 -2
- package/dist/clients/listing.d.ts.map +1 -1
- package/dist/clients/listing.js +16 -4
- package/dist/clients/listing.js.map +1 -1
- package/dist/clients/revocation.d.ts +5 -1
- package/dist/clients/revocation.d.ts.map +1 -1
- package/dist/clients/revocation.js +6 -2
- package/dist/clients/revocation.js.map +1 -1
- package/dist/clients/rosterPolicy.d.ts +6 -1
- package/dist/clients/rosterPolicy.d.ts.map +1 -1
- package/dist/clients/rosterPolicy.js +8 -2
- package/dist/clients/rosterPolicy.js.map +1 -1
- package/dist/enrollment/enrollment.d.ts +7 -1
- package/dist/enrollment/enrollment.d.ts.map +1 -1
- package/dist/enrollment/enrollment.js +7 -2
- package/dist/enrollment/enrollment.js.map +1 -1
- package/dist/recovery/recoveryWebvh.d.ts +22 -5
- package/dist/recovery/recoveryWebvh.d.ts.map +1 -1
- package/dist/recovery/recoveryWebvh.js +84 -32
- package/dist/recovery/recoveryWebvh.js.map +1 -1
- package/dist/webvh/didWebvh.d.ts +145 -10
- package/dist/webvh/didWebvh.d.ts.map +1 -1
- package/dist/webvh/didWebvh.js +205 -43
- package/dist/webvh/didWebvh.js.map +1 -1
- package/dist/webvh/index.d.ts +4 -1
- package/dist/webvh/index.d.ts.map +1 -1
- package/dist/webvh/index.js +4 -1
- package/dist/webvh/index.js.map +1 -1
- package/dist/webvh/revokeClient.d.ts +9 -1
- package/dist/webvh/revokeClient.d.ts.map +1 -1
- package/dist/webvh/revokeClient.js +23 -7
- package/dist/webvh/revokeClient.js.map +1 -1
- package/dist/webvh/verifyLog.d.ts +18 -1
- package/dist/webvh/verifyLog.d.ts.map +1 -1
- package/dist/webvh/verifyLog.js +95 -1
- package/dist/webvh/verifyLog.js.map +1 -1
- package/dist/webvh/wasIdStore.d.ts +6 -0
- package/dist/webvh/wasIdStore.d.ts.map +1 -1
- package/dist/webvh/wasIdStore.js +20 -4
- package/dist/webvh/wasIdStore.js.map +1 -1
- package/package.json +1 -1
|
@@ -33,9 +33,8 @@
|
|
|
33
33
|
* the authorized controller. Every step is idempotent/resumable: re-running
|
|
34
34
|
* with the same key material converges without forking the log.
|
|
35
35
|
*/
|
|
36
|
-
import { deriveNextKeyHash,
|
|
37
|
-
import {
|
|
38
|
-
import { assertCarryOverCommitments, MULTIKEY_VM_TYPE, publishWebvhLog, readPublishedLog, relationIds, updateKeyMultibase, updateKeySigner } from '../webvh/didWebvh.js';
|
|
36
|
+
import { deriveNextKeyHash, updateDID } from '@interop/did-method-webvh';
|
|
37
|
+
import { assertCarryOverCommitments, MULTIKEY_VM_TYPE, publishUpdatedLog, putLogResource, readPublishedLog, relationIds, updateKeyMultibase, updateKeySigner, withLogConflictRetry } from '../webvh/didWebvh.js';
|
|
39
38
|
/**
|
|
40
39
|
* The verification-method id a code's key-agreement key publishes under --
|
|
41
40
|
* the ordinary `<did>#<multibase>` form, indistinguishable by id from any
|
|
@@ -68,12 +67,15 @@ export class RecoveryKeyNotCommittedError extends Error {
|
|
|
68
67
|
*
|
|
69
68
|
* @param options {object}
|
|
70
69
|
* @param options.store {RecoveryLogStore}
|
|
70
|
+
* @param [options.expectedDid] {string} the account DID the log must resolve
|
|
71
|
+
* to, where the caller holds one
|
|
71
72
|
* @returns {Promise<PublishedWebvhLog>}
|
|
72
73
|
*/
|
|
73
|
-
async function readLogOrThrow({ store }) {
|
|
74
|
+
async function readLogOrThrow({ store, expectedDid }) {
|
|
74
75
|
// readPublishedLog only calls getIdResourceRaw, so the narrow seam is safe.
|
|
75
76
|
const published = await readPublishedLog({
|
|
76
|
-
idStore: store
|
|
77
|
+
idStore: store,
|
|
78
|
+
...(expectedDid !== undefined ? { expectedDid } : {})
|
|
77
79
|
});
|
|
78
80
|
if (!published) {
|
|
79
81
|
throw new Error('did:webvh: did.jsonl is missing; nothing to recover.');
|
|
@@ -83,19 +85,18 @@ async function readLogOrThrow({ store }) {
|
|
|
83
85
|
/**
|
|
84
86
|
* Publishes `did.jsonl` through the narrow recovery seam -- the log only,
|
|
85
87
|
* never `did.json` (the delegation covers nothing else; the recovered
|
|
86
|
-
* session republishes the projection once it is the controller).
|
|
88
|
+
* session republishes the projection once it is the controller). The write is
|
|
89
|
+
* conditional on the read the entry was built on, and a lost race surfaces as
|
|
90
|
+
* a `WebvhLogConflictError` (the mapping lives in `putLogResource`).
|
|
87
91
|
*
|
|
88
92
|
* @param options {object}
|
|
89
93
|
* @param options.store {RecoveryLogStore}
|
|
90
|
-
* @param options.log {
|
|
94
|
+
* @param options.log {DIDLog}
|
|
95
|
+
* @param [options.ifMatch] {string} publish only if `did.jsonl` is unchanged
|
|
91
96
|
* @returns {Promise<void>}
|
|
92
97
|
*/
|
|
93
|
-
async function publishLogOnly({ store, log }) {
|
|
94
|
-
await
|
|
95
|
-
resourceId: DID_LOG_RESOURCE,
|
|
96
|
-
content: logToJsonlString(log),
|
|
97
|
-
contentType: 'text/jsonl'
|
|
98
|
-
});
|
|
98
|
+
async function publishLogOnly({ store, log, ifMatch }) {
|
|
99
|
+
await putLogResource({ store, log, ifMatch });
|
|
99
100
|
}
|
|
100
101
|
/**
|
|
101
102
|
* ISSUANCE (run by an enrolled client, root authority): publishes a recovery
|
|
@@ -103,17 +104,33 @@ async function publishLogOnly({ store, log }) {
|
|
|
103
104
|
* `keyAgreement` verification method (an ordinary, unmarked Multikey entry)
|
|
104
105
|
* and committing its update-key hash in `nextKeyHashes`. The code's update
|
|
105
106
|
* key joins `updateKeys` nowhere. Idempotent: a posture already published is
|
|
106
|
-
* a no-op, so re-running a torn issuance converges.
|
|
107
|
+
* a no-op, so re-running a torn issuance converges. The entry publishes
|
|
108
|
+
* conditionally on the log this call read; a race lost to a concurrent
|
|
109
|
+
* ceremony re-runs and rebases on the new head.
|
|
107
110
|
*
|
|
108
111
|
* @param options {object}
|
|
109
112
|
* @param options.idStore {WebvhIdStore}
|
|
110
113
|
* @param options.updateKeys {ClientWebvhUpdateKeys} the ISSUING client's
|
|
111
114
|
* own did:webvh update-key seeds
|
|
112
115
|
* @param options.recovery {RecoveryPublicKeys} the code's public halves
|
|
116
|
+
* @param [options.expectedDid] {string} the account DID the log must
|
|
117
|
+
* resolve to, from the caller's stored account pointer
|
|
118
|
+
* @returns {Promise<{ did: string }>}
|
|
119
|
+
*/
|
|
120
|
+
export async function publishRecoveryKey(options) {
|
|
121
|
+
return withLogConflictRetry(() => publishRecoveryKeyOnce(options));
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* One attempt of {@link publishRecoveryKey}, re-invoked by the conflict retry.
|
|
125
|
+
*
|
|
126
|
+
* @param options {object} see {@link publishRecoveryKey}
|
|
113
127
|
* @returns {Promise<{ did: string }>}
|
|
114
128
|
*/
|
|
115
|
-
|
|
116
|
-
const published = await readLogOrThrow({
|
|
129
|
+
async function publishRecoveryKeyOnce({ idStore, updateKeys, recovery, expectedDid }) {
|
|
130
|
+
const published = await readLogOrThrow({
|
|
131
|
+
store: idStore,
|
|
132
|
+
...(expectedDid !== undefined ? { expectedDid } : {})
|
|
133
|
+
});
|
|
117
134
|
const { did, doc } = published;
|
|
118
135
|
const recoveryHash = await deriveNextKeyHash(recovery.updateKeyMultibase);
|
|
119
136
|
const vmId = recoveryVmId({
|
|
@@ -156,10 +173,7 @@ export async function publishRecoveryKey({ idStore, updateKeys, recovery }) {
|
|
|
156
173
|
capabilityInvocation: relationIds(doc.capabilityInvocation),
|
|
157
174
|
capabilityDelegation: relationIds(doc.capabilityDelegation)
|
|
158
175
|
});
|
|
159
|
-
|
|
160
|
-
throw new Error('did:webvh: updateDID returned no webDoc despite the did:web alsoKnownAs.');
|
|
161
|
-
}
|
|
162
|
-
await publishWebvhLog({ idStore, log: updated.log, webDoc: updated.webDoc });
|
|
176
|
+
await publishUpdatedLog({ idStore, updated, ifMatch: published.etag });
|
|
163
177
|
return { did: updated.did };
|
|
164
178
|
}
|
|
165
179
|
/**
|
|
@@ -170,15 +184,32 @@ export async function publishRecoveryKey({ idStore, updateKeys, recovery }) {
|
|
|
170
184
|
* caller's, and runs after this so the resolver's document no longer backs
|
|
171
185
|
* the removed entry.
|
|
172
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
|
+
*
|
|
173
190
|
* @param options {object}
|
|
174
191
|
* @param options.idStore {WebvhIdStore}
|
|
175
192
|
* @param options.updateKeys {ClientWebvhUpdateKeys} the REVOKING client's
|
|
176
193
|
* own did:webvh update-key seeds
|
|
177
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.
|
|
204
|
+
*
|
|
205
|
+
* @param options {object} see {@link removeRecoveryKey}
|
|
178
206
|
* @returns {Promise<{ did: string }>}
|
|
179
207
|
*/
|
|
180
|
-
|
|
181
|
-
const published = await readLogOrThrow({
|
|
208
|
+
async function removeRecoveryKeyOnce({ idStore, updateKeys, recovery, expectedDid }) {
|
|
209
|
+
const published = await readLogOrThrow({
|
|
210
|
+
store: idStore,
|
|
211
|
+
...(expectedDid !== undefined ? { expectedDid } : {})
|
|
212
|
+
});
|
|
182
213
|
const { did, doc } = published;
|
|
183
214
|
const recoveryHash = await deriveNextKeyHash(recovery.updateKeyMultibase);
|
|
184
215
|
const vmId = recoveryVmId({
|
|
@@ -212,10 +243,7 @@ export async function removeRecoveryKey({ idStore, updateKeys, recovery }) {
|
|
|
212
243
|
capabilityInvocation: relationIds(doc.capabilityInvocation),
|
|
213
244
|
capabilityDelegation: relationIds(doc.capabilityDelegation)
|
|
214
245
|
});
|
|
215
|
-
|
|
216
|
-
throw new Error('did:webvh: updateDID returned no webDoc despite the did:web alsoKnownAs.');
|
|
217
|
-
}
|
|
218
|
-
await publishWebvhLog({ idStore, log: updated.log, webDoc: updated.webDoc });
|
|
246
|
+
await publishUpdatedLog({ idStore, updated, ifMatch: published.etag });
|
|
219
247
|
return { did: updated.did };
|
|
220
248
|
}
|
|
221
249
|
/**
|
|
@@ -227,7 +255,10 @@ export async function removeRecoveryKey({ idStore, updateKeys, recovery }) {
|
|
|
227
255
|
* detected by the new client's update key already being authorized (no-op),
|
|
228
256
|
* a torn one by the standing commitments (the commit step re-runs
|
|
229
257
|
* convergently -- the spent code's hash is deliberately carried through the
|
|
230
|
-
* commit entry, so a resumed commit can re-state the revealed key).
|
|
258
|
+
* commit entry, so a resumed commit can re-state the revealed key). Both
|
|
259
|
+
* entries publish conditionally on the read they were built on, and a race
|
|
260
|
+
* lost to a concurrent ceremony re-runs the continuation from the top -- the
|
|
261
|
+
* same resumable path a tear takes.
|
|
231
262
|
*
|
|
232
263
|
* @param options {object}
|
|
233
264
|
* @param options.store {RecoveryLogStore} public log read + delegated PUT
|
|
@@ -243,12 +274,26 @@ export async function removeRecoveryKey({ idStore, updateKeys, recovery }) {
|
|
|
243
274
|
* holds them and can sign the add entry)
|
|
244
275
|
* @param options.replacement {RecoveryPublicKeys} the replacement code's
|
|
245
276
|
* public halves, committed and published in the same continuation
|
|
277
|
+
* @param [options.expectedDid] {string} the account DID the log must resolve
|
|
278
|
+
* to, where the recovering flow already knows it
|
|
246
279
|
* @returns {Promise<{ did: string, webDoc?: object }>} the account DID and,
|
|
247
280
|
* when the add entry ran here, the final `did.json` projection for the
|
|
248
281
|
* recovered session to republish
|
|
249
282
|
*/
|
|
250
|
-
export async function recoverWebvhClient(
|
|
251
|
-
|
|
283
|
+
export async function recoverWebvhClient(options) {
|
|
284
|
+
return withLogConflictRetry(() => recoverWebvhClientOnce(options));
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* One attempt of {@link recoverWebvhClient}, re-invoked by the conflict retry.
|
|
288
|
+
*
|
|
289
|
+
* @param options {object} see {@link recoverWebvhClient}
|
|
290
|
+
* @returns {Promise<{ did: string, webDoc?: object }>}
|
|
291
|
+
*/
|
|
292
|
+
async function recoverWebvhClientOnce({ store, recovery, newClientKeys, newClientUpdateSeeds, replacement, expectedDid }) {
|
|
293
|
+
let published = await readLogOrThrow({
|
|
294
|
+
store,
|
|
295
|
+
...(expectedDid !== undefined ? { expectedDid } : {})
|
|
296
|
+
});
|
|
252
297
|
// Already complete (a torn earlier run finished the add entry): the new
|
|
253
298
|
// client's update key is authorized, which only the add entry writes.
|
|
254
299
|
if (published.updateKeys.includes(newClientKeys.updateKeyMultibase)) {
|
|
@@ -288,8 +333,13 @@ export async function recoverWebvhClient({ store, recovery, newClientKeys, newCl
|
|
|
288
333
|
])
|
|
289
334
|
]
|
|
290
335
|
});
|
|
291
|
-
await publishLogOnly({
|
|
292
|
-
|
|
336
|
+
await publishLogOnly({
|
|
337
|
+
store,
|
|
338
|
+
log: updated.log,
|
|
339
|
+
ifMatch: published.etag
|
|
340
|
+
});
|
|
341
|
+
// The same account the reveal entry just extended.
|
|
342
|
+
published = await readLogOrThrow({ store, expectedDid: published.did });
|
|
293
343
|
}
|
|
294
344
|
// The add-and-retire entry: the new client's verification methods and
|
|
295
345
|
// update key in; the spent code's VM, update key, and hash out; the
|
|
@@ -358,7 +408,9 @@ export async function recoverWebvhClient({ store, recovery, newClientKeys, newCl
|
|
|
358
408
|
capabilityInvocation: withReference(doc.capabilityInvocation, signingVmId),
|
|
359
409
|
capabilityDelegation: withReference(doc.capabilityDelegation, signingVmId)
|
|
360
410
|
});
|
|
361
|
-
|
|
411
|
+
// Conditional on the read this entry was built on: the re-read above when
|
|
412
|
+
// the commit entry ran here, the first read when it was skipped.
|
|
413
|
+
await publishLogOnly({ store, log: updated.log, ifMatch: published.etag });
|
|
362
414
|
return { did: updated.did, webDoc: updated.webDoc };
|
|
363
415
|
}
|
|
364
416
|
//# sourceMappingURL=recoveryWebvh.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recoveryWebvh.js","sourceRoot":"","sources":["../../src/recovery/recoveryWebvh.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,OAAO,
|
|
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,iBAAiB,EACjB,cAAc,EACd,gBAAgB,EAChB,WAAW,EACX,kBAAkB,EAClB,eAAe,EACf,oBAAoB,EACrB,MAAM,sBAAsB,CAAA;AAQ7B;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,YAAY,CAAC,EAC3B,GAAG,EACH,wBAAwB,EAIzB;IACC,OAAO,GAAG,GAAG,IAAI,wBAAwB,EAAE,CAAA;AAC7C,CAAC;AAYD;;;;GAIG;AACH,MAAM,OAAO,4BAA6B,SAAQ,KAAK;IACrD,YACE,OAAO,GAAG,4DAA4D;QACpE,4CAA4C;QAE9C,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,8BAA8B,CAAA;IAC5C,CAAC;CACF;AAYD;;;;;;;;GAQG;AACH,KAAK,UAAU,cAAc,CAAC,EAC5B,KAAK,EACL,WAAW,EAIZ;IACC,4EAA4E;IAC5E,MAAM,SAAS,GAAG,MAAM,gBAAgB,CAAC;QACvC,OAAO,EAAE,KAAqB;QAC9B,GAAG,CAAC,WAAW,KAAK,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Ac,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"}
|
package/dist/webvh/didWebvh.d.ts
CHANGED
|
@@ -9,12 +9,19 @@ import type { DidWebKeyMap } from './didWeb.js';
|
|
|
9
9
|
*/
|
|
10
10
|
export interface WebvhIdStore {
|
|
11
11
|
/**
|
|
12
|
-
* The raw text body of an `id` collection resource (the JSON-Lines log)
|
|
13
|
-
* `undefined` when it is not published.
|
|
12
|
+
* The raw text body of an `id` collection resource (the JSON-Lines log)
|
|
13
|
+
* together with its ETag validator, or `undefined` when it is not published.
|
|
14
|
+
* The `etag` is the compare-and-swap token a ceremony hands back as
|
|
15
|
+
* {@link putIdResource}'s `ifMatch`; it is absent against a backend that does
|
|
16
|
+
* not version resources, in which case the ceremony's publish degrades to an
|
|
17
|
+
* unconditional write.
|
|
14
18
|
*/
|
|
15
19
|
getIdResourceRaw(options: {
|
|
16
20
|
resourceId: string;
|
|
17
|
-
}): Promise<
|
|
21
|
+
}): Promise<{
|
|
22
|
+
text: string;
|
|
23
|
+
etag?: string;
|
|
24
|
+
} | undefined>;
|
|
18
25
|
/**
|
|
19
26
|
* The parsed JSON body of an `id` collection resource (the DID document), or
|
|
20
27
|
* `undefined` when it is not published.
|
|
@@ -23,12 +30,22 @@ export interface WebvhIdStore {
|
|
|
23
30
|
resourceId: string;
|
|
24
31
|
}): Promise<unknown>;
|
|
25
32
|
/**
|
|
26
|
-
* Writes (upserts) an `id` collection resource
|
|
33
|
+
* Writes (upserts) an `id` collection resource, optionally conditionally:
|
|
34
|
+
* `ifMatch` writes only if the resource's current ETag matches (an
|
|
35
|
+
* update-if-unchanged), `ifNoneMatch` writes only if the resource is absent
|
|
36
|
+
* (a create-if-absent). With neither the write is unconditional.
|
|
37
|
+
*
|
|
38
|
+
* Contract: a failed precondition MUST surface as an error whose `name` is
|
|
39
|
+
* `'PreconditionFailedError'` (was-client's class; any implementation may
|
|
40
|
+
* throw its own error carrying that name), which this module maps to
|
|
41
|
+
* {@link WebvhLogConflictError}.
|
|
27
42
|
*/
|
|
28
43
|
putIdResource(options: {
|
|
29
44
|
resourceId: string;
|
|
30
45
|
content: object | string;
|
|
31
46
|
contentType?: string;
|
|
47
|
+
ifMatch?: string;
|
|
48
|
+
ifNoneMatch?: boolean;
|
|
32
49
|
}): Promise<void>;
|
|
33
50
|
/**
|
|
34
51
|
* Writes (upserts) `keys.json` in the private `key-map` collection.
|
|
@@ -134,6 +151,54 @@ export declare function updateKeyMultibase({ seed }: {
|
|
|
134
151
|
export declare function updateKeySigner({ seed }: {
|
|
135
152
|
seed: Uint8Array;
|
|
136
153
|
}): Promise<Signer>;
|
|
154
|
+
/**
|
|
155
|
+
* Thrown when a conditional publish of `did.jsonl` lost a race to a concurrent
|
|
156
|
+
* ceremony: the log moved on between the read this ceremony built its entry on
|
|
157
|
+
* and the PUT that would have appended it. The `cause` is the store's
|
|
158
|
+
* precondition error. A ceremony that meets one either re-runs (rebasing its
|
|
159
|
+
* entry on the new head -- what {@link withLogConflictRetry} does) or refuses,
|
|
160
|
+
* but it never overwrites the winner's entry.
|
|
161
|
+
*/
|
|
162
|
+
export declare class WebvhLogConflictError extends Error {
|
|
163
|
+
constructor(message?: string, options?: {
|
|
164
|
+
cause?: unknown;
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Re-runs `run` when it fails with a {@link WebvhLogConflictError}, up to three
|
|
169
|
+
* total attempts, then rethrows. The retry IS the rebase: every ceremony in
|
|
170
|
+
* this module re-reads the published head and rebuilds its entry on it, and
|
|
171
|
+
* every one of them detects its own completion from durable state alone, so a
|
|
172
|
+
* naive re-run after a lost race appends on top of the winner instead of over
|
|
173
|
+
* it. A ceremony whose preconditions no longer hold after the re-read (the
|
|
174
|
+
* retrying client was itself revoked, the staged key it was about to reveal is
|
|
175
|
+
* no longer committed) surfaces its own typed refusal instead of looping.
|
|
176
|
+
*
|
|
177
|
+
* @param run {Function} the ceremony body, re-invokable from the top
|
|
178
|
+
* @returns {Promise<*>} whatever the ceremony returns
|
|
179
|
+
*/
|
|
180
|
+
export declare function withLogConflictRetry<T>(run: () => Promise<T>): Promise<T>;
|
|
181
|
+
/**
|
|
182
|
+
* PUTs the serialized log to `did.jsonl`, forwarding the conditional-write
|
|
183
|
+
* preconditions and mapping a failed one to {@link WebvhLogConflictError}. The
|
|
184
|
+
* single place that mapping exists: the store seam is app-implemented, so the
|
|
185
|
+
* precondition error is matched on `err.name` rather than by `instanceof`,
|
|
186
|
+
* keeping the check implementation-agnostic. With neither precondition the PUT
|
|
187
|
+
* is unconditional -- the degradation on a backend that serves no ETags.
|
|
188
|
+
*
|
|
189
|
+
* @param options {object}
|
|
190
|
+
* @param options.store {object} anything with the seam's `putIdResource`
|
|
191
|
+
* @param options.log {DIDLog}
|
|
192
|
+
* @param [options.ifMatch] {string} publish only if the log is unchanged
|
|
193
|
+
* @param [options.ifNoneMatch] {boolean} publish only if the log is absent
|
|
194
|
+
* @returns {Promise<void>}
|
|
195
|
+
*/
|
|
196
|
+
export declare function putLogResource({ store, log, ifMatch, ifNoneMatch }: {
|
|
197
|
+
store: Pick<WebvhIdStore, 'putIdResource'>;
|
|
198
|
+
log: DIDLog;
|
|
199
|
+
ifMatch?: string;
|
|
200
|
+
ifNoneMatch?: boolean;
|
|
201
|
+
}): Promise<void>;
|
|
137
202
|
/**
|
|
138
203
|
* Publishes an already-created log: PUT `did.jsonl` (`text/jsonl`) then PUT
|
|
139
204
|
* `did.json` from `webDoc` (`application/did+json`, adopting the webvh
|
|
@@ -142,16 +207,54 @@ export declare function updateKeySigner({ seed }: {
|
|
|
142
207
|
* the publish tail no longer sets per-resource policies. The shared publish
|
|
143
208
|
* tail of the create and rotate paths.
|
|
144
209
|
*
|
|
210
|
+
* The log PUT carries the caller's precondition (`ifMatch`, the ETag of the
|
|
211
|
+
* read the entry was built on, or `ifNoneMatch` for a create), so a ceremony
|
|
212
|
+
* that lost a race to a concurrent one fails with
|
|
213
|
+
* {@link WebvhLogConflictError} instead of silently erasing the winner's entry.
|
|
214
|
+
* The `did.json` projection PUT stays unconditional by design: it runs only
|
|
215
|
+
* after the log's compare-and-swap was WON, so it is already serialized behind
|
|
216
|
+
* that win; the log is the source of truth and the projection a derived cache;
|
|
217
|
+
* and {@link concludeWithPublishedLog} re-derives and republishes the
|
|
218
|
+
* projection from the resolved log on every ceremony's no-op path, healing any
|
|
219
|
+
* lag a race or a torn publish leaves behind.
|
|
220
|
+
*
|
|
145
221
|
* @param options {object}
|
|
146
222
|
* @param options.idStore {WebvhIdStore}
|
|
147
223
|
* @param options.log {DIDLog}
|
|
148
224
|
* @param options.webDoc {object}
|
|
225
|
+
* @param [options.ifMatch] {string} publish only if `did.jsonl` is unchanged
|
|
226
|
+
* @param [options.ifNoneMatch] {boolean} publish only if `did.jsonl` is absent
|
|
149
227
|
* @returns {Promise<void>}
|
|
150
228
|
*/
|
|
151
|
-
export declare function publishWebvhLog({ idStore, log, webDoc }: {
|
|
229
|
+
export declare function publishWebvhLog({ idStore, log, webDoc, ifMatch, ifNoneMatch }: {
|
|
152
230
|
idStore: WebvhIdStore;
|
|
153
231
|
log: DIDLog;
|
|
154
232
|
webDoc: object;
|
|
233
|
+
ifMatch?: string;
|
|
234
|
+
ifNoneMatch?: boolean;
|
|
235
|
+
}): Promise<void>;
|
|
236
|
+
/**
|
|
237
|
+
* The shared guard-and-publish tail of every ceremony that extends the log
|
|
238
|
+
* through `updateDID`: the parallel `webDoc` must be there (it is, whenever
|
|
239
|
+
* `alsoKnownAsWeb` was passed), then log and projection are published under the
|
|
240
|
+
* caller's compare-and-swap token.
|
|
241
|
+
*
|
|
242
|
+
* @param options {object}
|
|
243
|
+
* @param options.idStore {WebvhIdStore}
|
|
244
|
+
* @param options.updated {object} the `updateDID` result
|
|
245
|
+
* @param options.updated.log {DIDLog}
|
|
246
|
+
* @param [options.updated.webDoc] {object}
|
|
247
|
+
* @param [options.ifMatch] {string} the ETag of the read this entry was built
|
|
248
|
+
* on
|
|
249
|
+
* @returns {Promise<void>}
|
|
250
|
+
*/
|
|
251
|
+
export declare function publishUpdatedLog({ idStore, updated, ifMatch }: {
|
|
252
|
+
idStore: WebvhIdStore;
|
|
253
|
+
updated: {
|
|
254
|
+
log: DIDLog;
|
|
255
|
+
webDoc?: object;
|
|
256
|
+
};
|
|
257
|
+
ifMatch?: string;
|
|
155
258
|
}): Promise<void>;
|
|
156
259
|
/**
|
|
157
260
|
* The verified state of the published log: the log itself, the resolved DID
|
|
@@ -164,18 +267,32 @@ export interface PublishedWebvhLog {
|
|
|
164
267
|
doc: DIDDoc;
|
|
165
268
|
updateKeys: string[];
|
|
166
269
|
nextKeyHashes: string[];
|
|
270
|
+
/**
|
|
271
|
+
* The `did.jsonl` ETag observed by the read that produced this state -- the
|
|
272
|
+
* `ifMatch` token for the publish of any entry built on it. Absent against a
|
|
273
|
+
* backend that serves no ETags, where the publish degrades to unconditional.
|
|
274
|
+
*/
|
|
275
|
+
etag?: string;
|
|
167
276
|
}
|
|
168
277
|
/**
|
|
169
278
|
* Reads and resolves the published `did.jsonl`, or returns `undefined` when
|
|
170
279
|
* the log is not published. A log that exists but fails to resolve throws --
|
|
171
280
|
* a published-but-broken log is never silently re-created over.
|
|
172
281
|
*
|
|
282
|
+
* Given an `expectedDid`, a log resolving to any other DID is refused rather
|
|
283
|
+
* than built on: the substituted-account check `verifyAccountLog` runs on the
|
|
284
|
+
* world-readable read, applied here to the ceremony's own read. Callers that
|
|
285
|
+
* hold the account pointer (or an earlier read of the same log, mid-ceremony)
|
|
286
|
+
* pass it; a caller discovering the DID from the log itself cannot.
|
|
287
|
+
*
|
|
173
288
|
* @param options {object}
|
|
174
289
|
* @param options.idStore {WebvhIdStore}
|
|
290
|
+
* @param [options.expectedDid] {string} the DID the log must resolve to
|
|
175
291
|
* @returns {Promise<PublishedWebvhLog | undefined>}
|
|
176
292
|
*/
|
|
177
|
-
export declare function readPublishedLog({ idStore }: {
|
|
293
|
+
export declare function readPublishedLog({ idStore, expectedDid }: {
|
|
178
294
|
idStore: WebvhIdStore;
|
|
295
|
+
expectedDid?: string;
|
|
179
296
|
}): Promise<PublishedWebvhLog | undefined>;
|
|
180
297
|
/**
|
|
181
298
|
* The shared tail of every ceremony path that has nothing left to append to
|
|
@@ -190,7 +307,9 @@ export declare function readPublishedLog({ idStore }: {
|
|
|
190
307
|
* unconditionally rather than compared first: the write is idempotent and one
|
|
191
308
|
* request either way, and the resolved log is the source of truth for what the
|
|
192
309
|
* projection must say. A ceremony that no-ops on the log therefore still heals
|
|
193
|
-
* a torn earlier publish.
|
|
310
|
+
* a torn earlier publish. The projection PUT is deliberately unconditional
|
|
311
|
+
* here too: healing it is the whole point, and the log it was derived from is
|
|
312
|
+
* the state this call just read and resolved.
|
|
194
313
|
*
|
|
195
314
|
* @param options {object}
|
|
196
315
|
* @param options.idStore {WebvhIdStore}
|
|
@@ -236,6 +355,12 @@ export declare function effectiveParameters(log: DIDLog): Array<{
|
|
|
236
355
|
* client-held update keys a lost seed is lost update authority, and no KMS
|
|
237
356
|
* repair path exists by design.
|
|
238
357
|
*
|
|
358
|
+
* The create publishes `did.jsonl` create-if-absent, so two concurrent signups
|
|
359
|
+
* cannot double-create the log: the loser re-runs (see
|
|
360
|
+
* {@link withLogConflictRetry}) and takes the adoption path against the
|
|
361
|
+
* winner's log -- adopting it when it holds this client's seeds, and raising
|
|
362
|
+
* the lost-seed refusal when it does not.
|
|
363
|
+
*
|
|
239
364
|
* @param options {object}
|
|
240
365
|
* @param options.idStore {WebvhIdStore}
|
|
241
366
|
* @param options.wasServerUrl {string}
|
|
@@ -246,7 +371,7 @@ export declare function effectiveParameters(log: DIDLog): Array<{
|
|
|
246
371
|
* @param options.updateKeys {ClientWebvhUpdateKeys} already durably persisted
|
|
247
372
|
* @returns {Promise<{ did: string }>}
|
|
248
373
|
*/
|
|
249
|
-
export declare function ensureDidWebvh(
|
|
374
|
+
export declare function ensureDidWebvh(options: {
|
|
250
375
|
idStore: WebvhIdStore;
|
|
251
376
|
wasServerUrl: string;
|
|
252
377
|
spaceId: string;
|
|
@@ -277,6 +402,11 @@ export declare function ensureDidWebvh({ idStore, wasServerUrl, spaceId, didWebK
|
|
|
277
402
|
* than left to the resolver, so a diverged client fails with a statement of
|
|
278
403
|
* what diverged instead of persisting rolled seeds and then failing opaquely.
|
|
279
404
|
*
|
|
405
|
+
* The entry publishes conditionally on the log this ceremony read, so a
|
|
406
|
+
* concurrent ceremony's entry is never erased; a lost race re-runs from the top
|
|
407
|
+
* (see {@link withLogConflictRetry}), which mints and persists a fresh staged
|
|
408
|
+
* seed again -- the documented cost of a torn rotation, one unused staged key.
|
|
409
|
+
*
|
|
280
410
|
* @param options {object}
|
|
281
411
|
* @param options.idStore {WebvhIdStore}
|
|
282
412
|
* @param options.updateKeys {ClientWebvhUpdateKeys} the current seeds
|
|
@@ -284,7 +414,7 @@ export declare function ensureDidWebvh({ idStore, wasServerUrl, spaceId, didWebK
|
|
|
284
414
|
* that changes the log's authorized update keys
|
|
285
415
|
* @returns {Promise<{ did: string }>}
|
|
286
416
|
*/
|
|
287
|
-
export declare function rotateWebvhUpdateKey(
|
|
417
|
+
export declare function rotateWebvhUpdateKey(options: {
|
|
288
418
|
idStore: WebvhIdStore;
|
|
289
419
|
updateKeys: ClientWebvhUpdateKeys;
|
|
290
420
|
persistUpdateKeys: (next: ClientWebvhUpdateKeys) => Promise<void>;
|
|
@@ -348,13 +478,18 @@ export declare function relationIds(relation: Array<string | {
|
|
|
348
478
|
* (no-op). Re-running with the same key set converges without forking the
|
|
349
479
|
* log.
|
|
350
480
|
*
|
|
481
|
+
* Each entry publishes conditionally on the read it was built on (the add
|
|
482
|
+
* entry on the mid-ceremony re-read), so a concurrent ceremony -- a revocation,
|
|
483
|
+
* another enrollment -- can never be erased by this one; a lost race re-runs
|
|
484
|
+
* from the top (see {@link withLogConflictRetry}) and rebases on the new head.
|
|
485
|
+
*
|
|
351
486
|
* @param options {object}
|
|
352
487
|
* @param options.idStore {WebvhIdStore}
|
|
353
488
|
* @param options.updateKeys {ClientWebvhUpdateKeys} THIS client's seeds
|
|
354
489
|
* @param options.newClient {WebvhEnrollmentKeys} the enrollee's public halves
|
|
355
490
|
* @returns {Promise<{ did: string }>}
|
|
356
491
|
*/
|
|
357
|
-
export declare function enrollWebvhClient(
|
|
492
|
+
export declare function enrollWebvhClient(options: {
|
|
358
493
|
idStore: WebvhIdStore;
|
|
359
494
|
updateKeys: ClientWebvhUpdateKeys;
|
|
360
495
|
newClient: WebvhEnrollmentKeys;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"didWebvh.d.ts","sourceRoot":"","sources":["../../src/webvh/didWebvh.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"didWebvh.d.ts","sourceRoot":"","sources":["../../src/webvh/didWebvh.ts"],"names":[],"mappings":"AAwEA,OAAO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