@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
|
@@ -7,7 +7,11 @@
|
|
|
7
7
|
* -- nothing shared rotates, because nothing was shared -- and, because a
|
|
8
8
|
* removal reveals no new key, it is a SINGLE log entry (unlike enrollment's
|
|
9
9
|
* two): the client's Ed25519 verification method leaves all four signing
|
|
10
|
-
* relationships,
|
|
10
|
+
* relationships, EVERY key-agreement method its controller marker claims
|
|
11
|
+
* (`controller: did:key:<signing multibase>`, read off the document rather
|
|
12
|
+
* than derived, so a client with several published keys is fully revoked and
|
|
13
|
+
* a deliberately unmarked recovery-code method is never touched) leaves
|
|
14
|
+
* `keyAgreement`, its update key leaves
|
|
11
15
|
* `updateKeys`, and both of its standing commitments leave `nextKeyHashes` --
|
|
12
16
|
* the carry-over hash of its active update key, and the hash of its staged
|
|
13
17
|
* key.
|
|
@@ -34,7 +38,7 @@
|
|
|
34
38
|
*/
|
|
35
39
|
import { deriveNextKeyHash, updateDID } from '@interop/did-method-webvh';
|
|
36
40
|
import { assertCarryOverCommitments, concludeWithPublishedLog, effectiveParameters, publishUpdatedLog, readPublishedLog, relationIds, updateKeyMultibase, updateKeySigner, withLogConflictRetry } from './didWebvh.js';
|
|
37
|
-
import { attributeClientUpdateKey } from './listClients.js';
|
|
41
|
+
import { attributeClientUpdateKey, markedKeyAgreementMultibases } from './listClients.js';
|
|
38
42
|
/**
|
|
39
43
|
* Thrown when the log attribution cannot isolate the revoked client's staged
|
|
40
44
|
* commitment to a single hash -- more than one candidate survives after the
|
|
@@ -244,11 +248,14 @@ async function currentRevokedUpdateKey({ published, revokedClient, vmPresent })
|
|
|
244
248
|
* excluded from the staged-hash attribution
|
|
245
249
|
* @param [options.expectedDid] {string} the account DID the log must resolve
|
|
246
250
|
* to, from the caller's stored account pointer
|
|
247
|
-
* @returns {Promise<{ did: string, doc: DIDDoc }>} the
|
|
248
|
-
* resolved document AFTER the edit -- what the roster
|
|
249
|
-
* resolves its remaining recipients from, so the
|
|
250
|
-
* the log it just extended
|
|
251
|
-
*
|
|
251
|
+
* @returns {Promise<{ did: string, doc: DIDDoc, log: DIDLog }>} the
|
|
252
|
+
* account's DID, its resolved document AFTER the edit -- what the roster
|
|
253
|
+
* rotation that follows resolves its remaining recipients from, so the
|
|
254
|
+
* caller needs no re-fetch of the log it just extended -- and the post-edit
|
|
255
|
+
* log itself, from which that rotation's controller view is built (the
|
|
256
|
+
* revocation cascade's post-edit anchoring). On the idempotent no-op path
|
|
257
|
+
* these are the already-published document and log, which state the same
|
|
258
|
+
* thing.
|
|
252
259
|
*/
|
|
253
260
|
export async function revokeWebvhClient(options) {
|
|
254
261
|
return withLogConflictRetry(() => revokeWebvhClientOnce(options));
|
|
@@ -257,7 +264,7 @@ export async function revokeWebvhClient(options) {
|
|
|
257
264
|
* One attempt of {@link revokeWebvhClient}, re-invoked by the conflict retry.
|
|
258
265
|
*
|
|
259
266
|
* @param options {object} see {@link revokeWebvhClient}
|
|
260
|
-
* @returns {Promise<{ did: string, doc: DIDDoc }>}
|
|
267
|
+
* @returns {Promise<{ did: string, doc: DIDDoc, log: DIDLog }>}
|
|
261
268
|
*/
|
|
262
269
|
async function revokeWebvhClientOnce({ idStore, updateKeys, revokedClient, knownLatentHashes = [], expectedDid }) {
|
|
263
270
|
const published = await readPublishedLog({
|
|
@@ -269,9 +276,18 @@ async function revokeWebvhClientOnce({ idStore, updateKeys, revokedClient, known
|
|
|
269
276
|
}
|
|
270
277
|
const { did, doc } = published;
|
|
271
278
|
const signingVmId = `${did}#${revokedClient.signingKeyMultibase}`;
|
|
272
|
-
|
|
279
|
+
// Every key-agreement method the revoked client's controller marker claims,
|
|
280
|
+
// read off the document rather than paired from the caller's snapshot: a
|
|
281
|
+
// client that published more than one is fully revoked, and a caller whose
|
|
282
|
+
// snapshot named a key the document never carried cannot leave a live
|
|
283
|
+
// method behind.
|
|
284
|
+
const keyAgreementVmIds = new Set(markedKeyAgreementMultibases({
|
|
285
|
+
doc,
|
|
286
|
+
signingKeyMultibase: revokedClient.signingKeyMultibase
|
|
287
|
+
}).map(multibase => `${did}#${multibase}`));
|
|
273
288
|
const existingMethods = (doc.verificationMethod ?? []);
|
|
274
|
-
const vmPresent = existingMethods.some(method => method.id === signingVmId ||
|
|
289
|
+
const vmPresent = existingMethods.some(method => method.id === signingVmId ||
|
|
290
|
+
(method.id !== undefined && keyAgreementVmIds.has(method.id)));
|
|
275
291
|
// The key the log states for this client now, which a self-rotation since
|
|
276
292
|
// the caller's listing may have moved on.
|
|
277
293
|
const revokedUpdateKey = await currentRevokedUpdateKey({
|
|
@@ -291,7 +307,8 @@ async function revokeWebvhClientOnce({ idStore, updateKeys, revokedClient, known
|
|
|
291
307
|
if (!vmPresent && !keyPresent && !hashPresent) {
|
|
292
308
|
// Nothing left to remove, but a torn earlier publish can still have left
|
|
293
309
|
// did.json lagging the log.
|
|
294
|
-
|
|
310
|
+
const concluded = await concludeWithPublishedLog({ idStore, published });
|
|
311
|
+
return { ...concluded, log: published.log };
|
|
295
312
|
}
|
|
296
313
|
if (!published.updateKeys.includes(activeKey)) {
|
|
297
314
|
throw new Error("did:webvh: the published log does not authorize this client's active " +
|
|
@@ -309,7 +326,7 @@ async function revokeWebvhClientOnce({ idStore, updateKeys, revokedClient, known
|
|
|
309
326
|
})
|
|
310
327
|
: undefined;
|
|
311
328
|
const removedHashes = new Set([revokedHash, stagedHash].filter((hash) => hash !== undefined));
|
|
312
|
-
const removedVmIds = new Set([signingVmId,
|
|
329
|
+
const removedVmIds = new Set([signingVmId, ...keyAgreementVmIds]);
|
|
313
330
|
const signer = await updateKeySigner({ seed: updateKeys.updateSeed });
|
|
314
331
|
const updated = await updateDID({
|
|
315
332
|
log: published.log,
|
|
@@ -320,11 +337,11 @@ async function revokeWebvhClientOnce({ idStore, updateKeys, revokedClient, known
|
|
|
320
337
|
verificationMethods: existingMethods.filter(method => !method.id || !removedVmIds.has(method.id)),
|
|
321
338
|
authentication: relationIds(doc.authentication).filter(id => id !== signingVmId),
|
|
322
339
|
assertionMethod: relationIds(doc.assertionMethod).filter(id => id !== signingVmId),
|
|
323
|
-
keyAgreement: relationIds(doc.keyAgreement).filter(id => id
|
|
340
|
+
keyAgreement: relationIds(doc.keyAgreement).filter(id => !keyAgreementVmIds.has(id)),
|
|
324
341
|
capabilityInvocation: relationIds(doc.capabilityInvocation).filter(id => id !== signingVmId),
|
|
325
342
|
capabilityDelegation: relationIds(doc.capabilityDelegation).filter(id => id !== signingVmId)
|
|
326
343
|
});
|
|
327
344
|
await publishUpdatedLog({ idStore, updated, ifMatch: published.etag });
|
|
328
|
-
return { did: updated.did, doc: updated.doc };
|
|
345
|
+
return { did: updated.did, doc: updated.doc, log: updated.log };
|
|
329
346
|
}
|
|
330
347
|
//# sourceMappingURL=revokeClient.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"revokeClient.js","sourceRoot":"","sources":["../../src/webvh/revokeClient.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH
|
|
1
|
+
{"version":3,"file":"revokeClient.js","sourceRoot":"","sources":["../../src/webvh/revokeClient.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AAMxE,OAAO,EACL,0BAA0B,EAC1B,wBAAwB,EACxB,mBAAmB,EACnB,iBAAiB,EACjB,gBAAgB,EAChB,WAAW,EACX,kBAAkB,EAClB,eAAe,EACf,oBAAoB,EACrB,MAAM,eAAe,CAAA;AACtB,OAAO,EACL,wBAAwB,EACxB,4BAA4B,EAC7B,MAAM,kBAAkB,CAAA;AAuBzB;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,8BAA+B,SAAQ,KAAK;IACvD,UAAU,CAAU;IACpB,YAAY,EAAE,UAAU,EAA4B;QAClD,KAAK,CACH,kEAAkE;YAChE,qEAAqE;YACrE,kEAAkE,CACrE,CAAA;QACD,IAAI,CAAC,IAAI,GAAG,gCAAgC,CAAA;QAC5C,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;IAC9B,CAAC;CACF;AAED;;;;;;;;;;;;;;GAcG;AACH,KAAK,UAAU,mBAAmB,CAAC,EACjC,GAAG,EACH,gBAAgB,EAChB,iBAAiB,EAKlB;IACC,MAAM,WAAW,GAAG,MAAM,iBAAiB,CAAC,gBAAgB,CAAC,CAAA;IAC7D,MAAM,MAAM,GAAG,mBAAmB,CAAC,GAAG,CAAC,CAAA;IACvC,MAAM,KAAK,GAAG,CAAC,KAAa,EAAe,EAAE;QAC3C,MAAM,QAAQ,GAAG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G,CAAC,oBAAoB,CAAC,CAAC,MAAM,CAChE,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,WAAW,CACzB;KACF,CAAC,CAAA;IACF,MAAM,iBAAiB,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,CAAC,IAAI,EAAE,CAAC,CAAA;IACtE,OAAO,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,CAAA;AACjE,CAAC"}
|
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
import type { DIDDoc, DIDLog } from '@interop/did-method-webvh';
|
|
2
|
-
import type
|
|
2
|
+
import { type ResourceLogHeadPin, type ResourceLogPinStore } from '../resourceLog/pin.js';
|
|
3
|
+
/**
|
|
4
|
+
* The pin-slot key for an account's did:webvh log (`id/did.jsonl`) -- what a
|
|
5
|
+
* ceremony taking its own read of the log names its pin by, and what
|
|
6
|
+
* {@link verifyAccountLog} derives internally.
|
|
7
|
+
*
|
|
8
|
+
* @param options {object}
|
|
9
|
+
* @param options.spaceId {string} the account's Space id
|
|
10
|
+
* @returns {string}
|
|
11
|
+
*/
|
|
12
|
+
export declare function accountLogPinId({ spaceId }: {
|
|
13
|
+
spaceId: string;
|
|
14
|
+
}): string;
|
|
3
15
|
/**
|
|
4
16
|
* Thrown when the account has published no DID log at all (the resource is
|
|
5
17
|
* absent). Distinguished from every other failure because it is the one
|
|
@@ -59,7 +71,8 @@ export declare function checkAccountLogContinuity({ log, pin }: {
|
|
|
59
71
|
* @param options.spaceId {string} the account's Space id
|
|
60
72
|
* @param options.host {string} the storage server the account lives on
|
|
61
73
|
* @param [options.pinStore] {ResourceLogPinStore} this client's chain-head
|
|
62
|
-
*
|
|
74
|
+
* pins; the account log's slot is keyed by {@link accountLogPinId} over the
|
|
75
|
+
* `spaceId` above
|
|
63
76
|
* @returns {Promise<object>} the resolved document, the raw log, and the
|
|
64
77
|
* log's effective `updateKeys` / `nextKeyHashes`
|
|
65
78
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verifyLog.d.ts","sourceRoot":"","sources":["../../src/webvh/verifyLog.ts"],"names":[],"mappings":"AA6BA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAA;AAI/D,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"verifyLog.d.ts","sourceRoot":"","sources":["../../src/webvh/verifyLog.ts"],"names":[],"mappings":"AA6BA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAA;AAI/D,OAAO,EAEL,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,EACzB,MAAM,uBAAuB,CAAA;AAE9B;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,EAAE,OAAO,EAAE,EAAE;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAMxE;AAED;;;;;;GAMG;AACH,qBAAa,sBAAuB,SAAQ,KAAK;gBACnC,OAAO,SAA0C;CAI9D;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,yBAAyB,CAAC,EACxC,GAAG,EACH,GAAG,EACJ,EAAE;IACD,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,EAAE,kBAAkB,GAAG,IAAI,CAAA;CAC/B,GAAG,kBAAkB,CA4CrB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAsB,gBAAgB,CAAC,EACrC,GAAG,EACH,OAAO,EACP,IAAI,EACJ,QAAQ,EACT,EAAE;IACD,GAAG,EAAE,MAAM,CAAA;IACX,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,CAAC,EAAE,mBAAmB,CAAA;CAC/B,GAAG,OAAO,CAAC;IACV,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,EAAE,MAAM,CAAA;IACX,UAAU,EAAE,MAAM,EAAE,CAAA;IACpB,aAAa,EAAE,MAAM,EAAE,CAAA;CACxB,CAAC,CA6CD"}
|
package/dist/webvh/verifyLog.js
CHANGED
|
@@ -30,6 +30,23 @@ import { readLogFromString, resolveDIDFromLog } from '@interop/did-method-webvh'
|
|
|
30
30
|
import { resourcePath, toUrl } from '@interop/was-client/paths';
|
|
31
31
|
import { DID_LOG_RESOURCE, ID_COLLECTION } from '../space/collections.js';
|
|
32
32
|
import { ResourceLogContinuityError } from '../resourceLog/errors.js';
|
|
33
|
+
import { resourceLogPinId } from '../resourceLog/pin.js';
|
|
34
|
+
/**
|
|
35
|
+
* The pin-slot key for an account's did:webvh log (`id/did.jsonl`) -- what a
|
|
36
|
+
* ceremony taking its own read of the log names its pin by, and what
|
|
37
|
+
* {@link verifyAccountLog} derives internally.
|
|
38
|
+
*
|
|
39
|
+
* @param options {object}
|
|
40
|
+
* @param options.spaceId {string} the account's Space id
|
|
41
|
+
* @returns {string}
|
|
42
|
+
*/
|
|
43
|
+
export function accountLogPinId({ spaceId }) {
|
|
44
|
+
return resourceLogPinId({
|
|
45
|
+
spaceId,
|
|
46
|
+
collectionId: ID_COLLECTION.id,
|
|
47
|
+
resourceId: DID_LOG_RESOURCE
|
|
48
|
+
});
|
|
49
|
+
}
|
|
33
50
|
/**
|
|
34
51
|
* Thrown when the account has published no DID log at all (the resource is
|
|
35
52
|
* absent). Distinguished from every other failure because it is the one
|
|
@@ -133,7 +150,8 @@ export function checkAccountLogContinuity({ log, pin }) {
|
|
|
133
150
|
* @param options.spaceId {string} the account's Space id
|
|
134
151
|
* @param options.host {string} the storage server the account lives on
|
|
135
152
|
* @param [options.pinStore] {ResourceLogPinStore} this client's chain-head
|
|
136
|
-
*
|
|
153
|
+
* pins; the account log's slot is keyed by {@link accountLogPinId} over the
|
|
154
|
+
* `spaceId` above
|
|
137
155
|
* @returns {Promise<object>} the resolved document, the raw log, and the
|
|
138
156
|
* log's effective `updateKeys` / `nextKeyHashes`
|
|
139
157
|
*/
|
|
@@ -159,12 +177,13 @@ export async function verifyAccountLog({ did, spaceId, host, pinStore }) {
|
|
|
159
177
|
'pointer names.');
|
|
160
178
|
}
|
|
161
179
|
if (pinStore) {
|
|
162
|
-
const
|
|
180
|
+
const logId = accountLogPinId({ spaceId });
|
|
181
|
+
const pin = await pinStore.read({ logId });
|
|
163
182
|
const served = checkAccountLogContinuity({ log, pin });
|
|
164
183
|
// Advanced only when the served head is genuinely ahead of the pin: the
|
|
165
184
|
// checks above have already refused everything that is not.
|
|
166
185
|
if (!pin || pin.head !== served.head) {
|
|
167
|
-
await pinStore.write(served);
|
|
186
|
+
await pinStore.write({ logId, pin: served });
|
|
168
187
|
}
|
|
169
188
|
}
|
|
170
189
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verifyLog.js","sourceRoot":"","sources":["../../src/webvh/verifyLog.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAA;AAEhF,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAA;AAC/D,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAA;AACzE,OAAO,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAA;
|
|
1
|
+
{"version":3,"file":"verifyLog.js","sourceRoot":"","sources":["../../src/webvh/verifyLog.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAA;AAEhF,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAA;AAC/D,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAA;AACzE,OA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,CAAC;YACrC,MAAM,QAAQ,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,CAAA;QAC9C,CAAC;IACH,CAAC;IACD,OAAO;QACL,GAAG,EAAE,QAAQ,CAAC,GAAG;QACjB,GAAG;QACH,UAAU,EAAE,QAAQ,CAAC,IAAI,CAAC,UAAU,IAAI,EAAE;QAC1C,aAAa,EAAE,QAAQ,CAAC,IAAI,CAAC,aAAa,IAAI,EAAE;KACjD,CAAA;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@interop/wallet-core",
|
|
3
3
|
"description": "Shared wallet-domain logic (WAS sync engine core and wallet Space layout contracts) for Interop wallet apps.",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.42.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"build": "pnpm run clear && tsc",
|
|
@@ -90,6 +90,12 @@
|
|
|
90
90
|
"import": "./dist/recovery/index.js",
|
|
91
91
|
"default": "./dist/recovery/index.js"
|
|
92
92
|
},
|
|
93
|
+
"./unlock": {
|
|
94
|
+
"types": "./dist/unlock/index.d.ts",
|
|
95
|
+
"react-native": "./dist/unlock/index.js",
|
|
96
|
+
"import": "./dist/unlock/index.js",
|
|
97
|
+
"default": "./dist/unlock/index.js"
|
|
98
|
+
},
|
|
93
99
|
"./keys": {
|
|
94
100
|
"types": "./dist/keys/index.d.ts",
|
|
95
101
|
"react-native": "./dist/keys/index.js",
|
|
@@ -132,22 +138,22 @@
|
|
|
132
138
|
"types": "dist/index.d.ts",
|
|
133
139
|
"sideEffects": false,
|
|
134
140
|
"dependencies": {
|
|
135
|
-
"@interop/data-integrity-core": "^8.
|
|
141
|
+
"@interop/data-integrity-core": "^8.7.1",
|
|
136
142
|
"@interop/data-integrity-proof": "^3.4.3",
|
|
137
|
-
"@interop/did-method-webvh": "^5.
|
|
143
|
+
"@interop/did-method-webvh": "^5.5.0",
|
|
138
144
|
"@interop/ed25519-signature": "^7.1.4",
|
|
139
145
|
"@interop/ed25519-verification-key": "^8.0.3",
|
|
140
146
|
"@interop/ezcap": "^7.4.1",
|
|
141
147
|
"@interop/security-document-loader": "^10.0.0",
|
|
142
148
|
"@interop/social-core": "^0.8.1",
|
|
143
149
|
"@interop/vc": "^11.0.6",
|
|
144
|
-
"@interop/was-client": "^0.
|
|
150
|
+
"@interop/was-client": "^0.39.1",
|
|
145
151
|
"@interop/webkms-client": "^14.7.1",
|
|
146
152
|
"@interop/x25519-key-agreement-key": "^5.2.1",
|
|
147
153
|
"@noble/ciphers": "^2.3.0",
|
|
148
154
|
"@noble/hashes": "^2.3.0",
|
|
149
155
|
"@scure/base": "^2.3.0",
|
|
150
|
-
"byoe-context": "^0.
|
|
156
|
+
"byoe-context": "^0.5.0"
|
|
151
157
|
},
|
|
152
158
|
"devDependencies": {
|
|
153
159
|
"@eslint/js": "^10.0.1",
|
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
import type { IKeyAgreementKey, IKeyResolver, IZcap } from '@interop/data-integrity-core';
|
|
2
|
-
import type { AccountPointer, RecordSigner, SignedRecord } from '../keyring/record.js';
|
|
3
|
-
/**
|
|
4
|
-
* A recovery record's account binding is absent, malformed, or does not
|
|
5
|
-
* verify under the typed code's binding MAC key. Its own class, distinct from
|
|
6
|
-
* a proof or decrypt failure: this is the refusal that says the record's
|
|
7
|
-
* `{ controller, pointer }` core was not written by a holder of this code --
|
|
8
|
-
* a forged record redirecting recovery at another account, or a record from
|
|
9
|
-
* before the account moved hosts (either way the code cannot recover here
|
|
10
|
-
* and must be re-issued).
|
|
11
|
-
*/
|
|
12
|
-
export declare class RecoveryBindingError extends Error {
|
|
13
|
-
constructor(message: string);
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* The unwrapped contents of a recovery keyring record: the code-authenticated
|
|
17
|
-
* account binding (controller + pointer) plus the delegation and bind
|
|
18
|
-
* timestamp. `pointer` is required -- a recovery record exists only on WAS
|
|
19
|
-
* deployments (there is nothing to recover toward without a Space).
|
|
20
|
-
*/
|
|
21
|
-
export interface RecoveryRecordContents {
|
|
22
|
-
controller: string;
|
|
23
|
-
pointer: AccountPointer;
|
|
24
|
-
delegation: IZcap;
|
|
25
|
-
createdAt: string;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* A stored recovery record: the shared signed frame plus the account-binding
|
|
29
|
-
* tag the frame proof also covers.
|
|
30
|
-
*/
|
|
31
|
-
export interface SignedRecoveryRecord extends SignedRecord {
|
|
32
|
-
binding: string;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Where a recovery record's proof stands after the unwrap: `'verified'` when
|
|
36
|
-
* the code-derived unlock key signed it (checked before decryption), or a
|
|
37
|
-
* pending marker naming the signer the caller must still check against the
|
|
38
|
-
* account's verified did:webvh document -- the re-mint case, where an enrolled
|
|
39
|
-
* client signed on the code's behalf. The pending case is a value the caller
|
|
40
|
-
* cannot ignore by accident: the shell is not trustworthy until
|
|
41
|
-
* `verifyRecordProof` is run against the document-listed keys. The account
|
|
42
|
-
* the document belongs to is the one the code-authenticated pointer names --
|
|
43
|
-
* the binding is verified either way, so the pending state defers the shell's
|
|
44
|
-
* authenticity only, never the account identity.
|
|
45
|
-
*/
|
|
46
|
-
export type RecoveryRecordProofState = 'verified' | {
|
|
47
|
-
pending: {
|
|
48
|
-
verificationMethod: string;
|
|
49
|
-
keyMultibase: string;
|
|
50
|
-
};
|
|
51
|
-
};
|
|
52
|
-
/**
|
|
53
|
-
* Computes the account-binding tag: HMAC-SHA-256 over the binding values
|
|
54
|
-
* under the code-derived binding MAC key, base64url (no pad). Issuance calls
|
|
55
|
-
* it to stamp the record; recovery recomputes it to verify.
|
|
56
|
-
*
|
|
57
|
-
* @param options {object}
|
|
58
|
-
* @param options.bindingMacKey {Uint8Array} the code-derived MAC key
|
|
59
|
-
* @param options.controller {string} the account did:key
|
|
60
|
-
* @param options.pointer {AccountPointer} the account pointer
|
|
61
|
-
* @returns {string}
|
|
62
|
-
*/
|
|
63
|
-
export declare function computeRecoveryBinding({ bindingMacKey, controller, pointer }: {
|
|
64
|
-
bindingMacKey: Uint8Array;
|
|
65
|
-
controller: string;
|
|
66
|
-
pointer: AccountPointer;
|
|
67
|
-
}): string;
|
|
68
|
-
/**
|
|
69
|
-
* Reads the `binding` frame member off a stored recovery record without
|
|
70
|
-
* decrypting anything. The re-mint path uses it to carry the tag forward
|
|
71
|
-
* verbatim -- it cannot recompute the tag (no code bytes) and does not need
|
|
72
|
-
* to. Refuses a record with no binding: such a record predates the
|
|
73
|
-
* code-authenticated core and cannot be re-minted -- its code must be
|
|
74
|
-
* re-issued.
|
|
75
|
-
*
|
|
76
|
-
* @param options {object}
|
|
77
|
-
* @param options.record {unknown} the stored record envelope
|
|
78
|
-
* @returns {string}
|
|
79
|
-
*/
|
|
80
|
-
export declare function recoveryRecordBinding({ record }: {
|
|
81
|
-
record: unknown;
|
|
82
|
-
}): string;
|
|
83
|
-
/**
|
|
84
|
-
* Wraps the recovery record: controller, pointer, and the pre-minted
|
|
85
|
-
* `did.jsonl` PUT delegation, encrypted under the code's unlock KAK via the
|
|
86
|
-
* keyring EDV cipher context, then signed into the same frame the keyring
|
|
87
|
-
* record uses -- with the account-binding tag as one more frame member the
|
|
88
|
-
* proof covers. Issuance passes the code-derived `bindingMacKey` (the tag is
|
|
89
|
-
* computed here) and the code-derived unlock signer; the revocation cascade's
|
|
90
|
-
* re-mint path passes the standing record's `binding` verbatim and an
|
|
91
|
-
* enrolled client's account signer (see this module's header for the policy
|
|
92
|
-
* the reader applies to the two). Exactly one of the two binding inputs must
|
|
93
|
-
* be given.
|
|
94
|
-
*
|
|
95
|
-
* @param options {object}
|
|
96
|
-
* @param options.controller {string} the account did:key
|
|
97
|
-
* @param options.pointer {AccountPointer} the account pointer
|
|
98
|
-
* @param options.delegation {IZcap} the PUT-on-`did.jsonl` delegation to the
|
|
99
|
-
* code-derived signing DID
|
|
100
|
-
* @param options.keyAgreementKey {IKeyAgreementKey} the code's unlock KAK
|
|
101
|
-
* @param options.keyResolver {IKeyResolver}
|
|
102
|
-
* @param options.signer {RecordSigner} the signing key: the code's unlock
|
|
103
|
-
* key at issuance, an enrolled client's account key on a re-mint
|
|
104
|
-
* @param [options.bindingMacKey] {Uint8Array} the code-derived binding MAC
|
|
105
|
-
* key -- the issuance path, which computes the tag
|
|
106
|
-
* @param [options.binding] {string} the standing record's tag, carried
|
|
107
|
-
* forward verbatim -- the re-mint path, which cannot recompute it
|
|
108
|
-
* @param [options.createdAt] {string} the bind timestamp to stamp, as an ISO
|
|
109
|
-
* string; defaults to now. Supplied by a caller that pins record freshness.
|
|
110
|
-
* @returns {Promise<SignedRecoveryRecord>}
|
|
111
|
-
*/
|
|
112
|
-
export declare function wrapRecoveryRecord({ controller, pointer, delegation, keyAgreementKey, keyResolver, signer, bindingMacKey, binding, createdAt }: {
|
|
113
|
-
controller: string;
|
|
114
|
-
pointer: AccountPointer;
|
|
115
|
-
delegation: IZcap;
|
|
116
|
-
keyAgreementKey: IKeyAgreementKey;
|
|
117
|
-
keyResolver: IKeyResolver;
|
|
118
|
-
signer: RecordSigner;
|
|
119
|
-
bindingMacKey?: Uint8Array;
|
|
120
|
-
binding?: string;
|
|
121
|
-
createdAt?: string;
|
|
122
|
-
}): Promise<SignedRecoveryRecord>;
|
|
123
|
-
/**
|
|
124
|
-
* Unwraps and validates a recovery record: the ordinary keyring-record checks
|
|
125
|
-
* plus the required pointer, delegation, and account binding. A record
|
|
126
|
-
* without a delegation is not a recovery record (an ordinary keyring record
|
|
127
|
-
* found under a code's unlock Space would mean a corrupted issuance) and is
|
|
128
|
-
* refused.
|
|
129
|
-
*
|
|
130
|
-
* The account binding is verified before the contents are returned: the
|
|
131
|
-
* decrypted `{ controller, pointer }` must carry the tag the code-derived
|
|
132
|
-
* MAC key computes over them, or the record is refused as forged
|
|
133
|
-
* ({@link RecoveryBindingError}) -- the check that closes the host-forgery
|
|
134
|
-
* redirect, since the host never holds the MAC key. Nothing downstream may
|
|
135
|
-
* trust the pointer before this returns.
|
|
136
|
-
*
|
|
137
|
-
* Proof verification is mixed-signer and ordered deliberately. A proof by the
|
|
138
|
-
* code's own unlock key is verified BEFORE decryption -- the strong path,
|
|
139
|
-
* where the typed code alone establishes what may have signed the record. A
|
|
140
|
-
* proof by any other key can only be checked after decryption, because the
|
|
141
|
-
* re-minting client is knowable only once the code-authenticated pointer says
|
|
142
|
-
* which account this is and that account's log has been verified; the
|
|
143
|
-
* contents come back with a pending proof state naming the signer, and the
|
|
144
|
-
* caller completes the check with {@link verifyRecordProof} against the
|
|
145
|
-
* document's keys. That second phase is what makes an unexpected signer
|
|
146
|
-
* refuse: a record whose proof belongs to neither class ends in a
|
|
147
|
-
* `RecordProofError` there.
|
|
148
|
-
*
|
|
149
|
-
* @param options {object}
|
|
150
|
-
* @param options.record {unknown} the stored `{ version, encryption,
|
|
151
|
-
* wrapped, binding, proof }` envelope
|
|
152
|
-
* @param options.keyAgreementKey {IKeyAgreementKey} the code's unlock KAK
|
|
153
|
-
* @param options.keyResolver {IKeyResolver}
|
|
154
|
-
* @param options.expectedKeyMultibase {string} the code-derived unlock
|
|
155
|
-
* signing key's multibase
|
|
156
|
-
* @param options.bindingMacKey {Uint8Array} the code-derived binding MAC
|
|
157
|
-
* key the record's account binding must verify under
|
|
158
|
-
* @returns {Promise<{ contents: RecoveryRecordContents,
|
|
159
|
-
* proofState: RecoveryRecordProofState }>}
|
|
160
|
-
*/
|
|
161
|
-
export declare function unwrapRecoveryRecord({ record, keyAgreementKey, keyResolver, expectedKeyMultibase, bindingMacKey }: {
|
|
162
|
-
record: unknown;
|
|
163
|
-
keyAgreementKey: IKeyAgreementKey;
|
|
164
|
-
keyResolver: IKeyResolver;
|
|
165
|
-
expectedKeyMultibase: string;
|
|
166
|
-
bindingMacKey: Uint8Array;
|
|
167
|
-
}): Promise<{
|
|
168
|
-
contents: RecoveryRecordContents;
|
|
169
|
-
proofState: RecoveryRecordProofState;
|
|
170
|
-
}>;
|
|
171
|
-
//# sourceMappingURL=recoveryRecord.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"recoveryRecord.d.ts","sourceRoot":"","sources":["../../src/recovery/recoveryRecord.ts"],"names":[],"mappings":"AA+CA,OAAO,KAAK,EACV,gBAAgB,EAChB,YAAY,EACZ,KAAK,EACN,MAAM,8BAA8B,CAAA;AAarC,OAAO,KAAK,EACV,cAAc,EACd,YAAY,EACZ,YAAY,EACb,MAAM,sBAAsB,CAAA;AAQ7B;;;;;;;;GAQG;AACH,qBAAa,oBAAqB,SAAQ,KAAK;gBACjC,OAAO,EAAE,MAAM;CAI5B;AAED;;;;;GAKG;AACH,MAAM,WAAW,sBAAsB;IACrC,UAAU,EAAE,MAAM,CAAA;IAClB,OAAO,EAAE,cAAc,CAAA;IACvB,UAAU,EAAE,KAAK,CAAA;IACjB,SAAS,EAAE,MAAM,CAAA;CAClB;AAED;;;GAGG;AACH,MAAM,WAAW,oBAAqB,SAAQ,YAAY;IACxD,OAAO,EAAE,MAAM,CAAA;CAChB;AAED;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,wBAAwB,GAClC,UAAU,GAAG;IAAE,OAAO,EAAE;QAAE,kBAAkB,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,CAAA;AAyBhF;;;;;;;;;;GAUG;AACH,wBAAgB,sBAAsB,CAAC,EACrC,aAAa,EACb,UAAU,EACV,OAAO,EACR,EAAE;IACD,aAAa,EAAE,UAAU,CAAA;IACzB,UAAU,EAAE,MAAM,CAAA;IAClB,OAAO,EAAE,cAAc,CAAA;CACxB,GAAG,MAAM,CAIT;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,qBAAqB,CAAC,EAAE,MAAM,EAAE,EAAE;IAAE,MAAM,EAAE,OAAO,CAAA;CAAE,GAAG,MAAM,CAS7E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