@interop/wallet-core 0.11.0 → 0.13.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 +8 -2
- package/dist/enrollment/enrollment.d.ts +35 -1
- package/dist/enrollment/enrollment.d.ts.map +1 -1
- package/dist/enrollment/enrollment.js +31 -51
- package/dist/enrollment/enrollment.js.map +1 -1
- package/dist/keys/clientLabels.d.ts +85 -0
- package/dist/keys/clientLabels.d.ts.map +1 -0
- package/dist/keys/clientLabels.js +96 -0
- package/dist/keys/clientLabels.js.map +1 -0
- package/dist/keys/index.d.ts +13 -1
- package/dist/keys/index.d.ts.map +1 -1
- package/dist/keys/index.js +12 -1
- package/dist/keys/index.js.map +1 -1
- package/dist/keys/pukRoster.d.ts +65 -0
- package/dist/keys/pukRoster.d.ts.map +1 -1
- package/dist/keys/pukRoster.js +97 -0
- package/dist/keys/pukRoster.js.map +1 -1
- package/dist/keys/wasLabelsStore.d.ts +26 -0
- package/dist/keys/wasLabelsStore.d.ts.map +1 -0
- package/dist/keys/wasLabelsStore.js +27 -0
- package/dist/keys/wasLabelsStore.js.map +1 -0
- package/dist/space/collections.d.ts +10 -0
- package/dist/space/collections.d.ts.map +1 -1
- package/dist/space/collections.js +10 -0
- package/dist/space/collections.js.map +1 -1
- package/dist/space/index.d.ts +1 -1
- package/dist/space/index.d.ts.map +1 -1
- package/dist/space/index.js +1 -1
- package/dist/space/index.js.map +1 -1
- package/dist/webvh/didWebvh.d.ts +14 -0
- package/dist/webvh/didWebvh.d.ts.map +1 -1
- package/dist/webvh/didWebvh.js +25 -0
- package/dist/webvh/didWebvh.js.map +1 -1
- package/dist/webvh/index.d.ts +12 -0
- package/dist/webvh/index.d.ts.map +1 -1
- package/dist/webvh/index.js +11 -0
- package/dist/webvh/index.js.map +1 -1
- package/dist/webvh/listClients.d.ts +80 -0
- package/dist/webvh/listClients.d.ts.map +1 -0
- package/dist/webvh/listClients.js +114 -0
- package/dist/webvh/listClients.js.map +1 -0
- package/dist/webvh/revokeClient.d.ts +7 -1
- package/dist/webvh/revokeClient.d.ts.map +1 -1
- package/dist/webvh/revokeClient.js +8 -27
- package/dist/webvh/revokeClient.js.map +1 -1
- package/dist/webvh/verifyLog.d.ts +37 -0
- package/dist/webvh/verifyLog.d.ts.map +1 -0
- package/dist/webvh/verifyLog.js +75 -0
- package/dist/webvh/verifyLog.js.map +1 -0
- package/dist/webvh/wasIdStore.d.ts +34 -0
- package/dist/webvh/wasIdStore.d.ts.map +1 -0
- package/dist/webvh/wasIdStore.js +43 -0
- package/dist/webvh/wasIdStore.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { Ed25519VerificationKey } from '@interop/ed25519-verification-key';
|
|
2
|
+
import { X25519KeyAgreementKey2020 } from '@interop/x25519-key-agreement-key';
|
|
3
|
+
import { effectiveParameters, relationIds } from './didWebvh.js';
|
|
4
|
+
/**
|
|
5
|
+
* The multibase of an Ed25519 signing key's canonical X25519 twin -- the
|
|
6
|
+
* key-agreement key the client's enrollment published and its roster wraps
|
|
7
|
+
* are minted to.
|
|
8
|
+
*
|
|
9
|
+
* @param options {object}
|
|
10
|
+
* @param options.signingKeyMultibase {string}
|
|
11
|
+
* @returns {string}
|
|
12
|
+
*/
|
|
13
|
+
export function keyAgreementTwinMultibase({ signingKeyMultibase }) {
|
|
14
|
+
const keyPair = new Ed25519VerificationKey({
|
|
15
|
+
controller: `did:key:${signingKeyMultibase}`,
|
|
16
|
+
publicKeyMultibase: signingKeyMultibase
|
|
17
|
+
});
|
|
18
|
+
const twin = X25519KeyAgreementKey2020.fromEd25519VerificationKey2020({
|
|
19
|
+
keyPair
|
|
20
|
+
});
|
|
21
|
+
if (typeof twin.publicKeyMultibase !== 'string') {
|
|
22
|
+
throw new Error('did:webvh: converting the signing key to its X25519 twin produced no ' +
|
|
23
|
+
'publicKeyMultibase.');
|
|
24
|
+
}
|
|
25
|
+
return twin.publicKeyMultibase;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* The update keys an entry newly revealed: the effective `updateKeys` at
|
|
29
|
+
* `index` minus the previous entry's.
|
|
30
|
+
*
|
|
31
|
+
* @param params {Array<{ updateKeys: string[] }>}
|
|
32
|
+
* @param index {number}
|
|
33
|
+
* @returns {string[]}
|
|
34
|
+
*/
|
|
35
|
+
function addedUpdateKeys(params, index) {
|
|
36
|
+
const previous = new Set(index > 0 ? params[index - 1].updateKeys : []);
|
|
37
|
+
return params[index].updateKeys.filter(key => !previous.has(key));
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Attributes one client's ACTIVE update key from the log: its initial key is
|
|
41
|
+
* whatever the entry publishing its verification methods revealed, and each
|
|
42
|
+
* later entry that retired the attributed key while revealing exactly one
|
|
43
|
+
* replacement is that client's self-rotation. Returns `undefined` on any
|
|
44
|
+
* ambiguity (an entry revealing several keys beside the client's methods, a
|
|
45
|
+
* retirement with several candidate replacements) or when the attributed key
|
|
46
|
+
* is not authorized by the final entry.
|
|
47
|
+
*
|
|
48
|
+
* @param options {object}
|
|
49
|
+
* @param options.log {DIDLog}
|
|
50
|
+
* @param options.addIndex {number} the entry that published the client's
|
|
51
|
+
* verification methods
|
|
52
|
+
* @returns {string | undefined}
|
|
53
|
+
*/
|
|
54
|
+
function attributeActiveUpdateKey({ log, addIndex }) {
|
|
55
|
+
const params = effectiveParameters(log);
|
|
56
|
+
const initial = addedUpdateKeys(params, addIndex);
|
|
57
|
+
if (initial.length !== 1) {
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
60
|
+
let active = initial[0];
|
|
61
|
+
for (let index = addIndex + 1; index < params.length; index++) {
|
|
62
|
+
const stillPresent = params[index].updateKeys.includes(active);
|
|
63
|
+
if (stillPresent) {
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
const revealed = addedUpdateKeys(params, index);
|
|
67
|
+
if (revealed.length !== 1) {
|
|
68
|
+
return undefined;
|
|
69
|
+
}
|
|
70
|
+
active = revealed[0];
|
|
71
|
+
}
|
|
72
|
+
return params[params.length - 1].updateKeys.includes(active)
|
|
73
|
+
? active
|
|
74
|
+
: undefined;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Lists the enrolled wallet clients of a VERIFIED did:webvh log (see the
|
|
78
|
+
* module doc: enumeration keyed on the final document's
|
|
79
|
+
* `capabilityInvocation`, update keys and enrollment times recovered by log
|
|
80
|
+
* attribution). Order follows the document's `capabilityInvocation` array --
|
|
81
|
+
* enrollment order, since every roster edit appends.
|
|
82
|
+
*
|
|
83
|
+
* @param options {object}
|
|
84
|
+
* @param options.log {DIDLog} a resolved, caller-verified log
|
|
85
|
+
* @returns {EnrolledWebvhClient[]}
|
|
86
|
+
*/
|
|
87
|
+
export function listEnrolledWebvhClients({ log }) {
|
|
88
|
+
if (log.length === 0) {
|
|
89
|
+
return [];
|
|
90
|
+
}
|
|
91
|
+
const doc = log[log.length - 1].state;
|
|
92
|
+
const clients = [];
|
|
93
|
+
for (const vmId of relationIds(doc.capabilityInvocation)) {
|
|
94
|
+
const signingKeyMultibase = vmId.split('#')[1];
|
|
95
|
+
if (!signingKeyMultibase) {
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
// The entry that published this client's verification methods -- its
|
|
99
|
+
// enrollment moment, and the attribution anchor for its update key.
|
|
100
|
+
const addIndex = log.findIndex(entry => relationIds(entry.state.capabilityInvocation).includes(vmId));
|
|
101
|
+
clients.push({
|
|
102
|
+
signingKeyMultibase,
|
|
103
|
+
keyAgreementKeyMultibase: keyAgreementTwinMultibase({
|
|
104
|
+
signingKeyMultibase
|
|
105
|
+
}),
|
|
106
|
+
updateKeyMultibase: addIndex === -1
|
|
107
|
+
? undefined
|
|
108
|
+
: attributeActiveUpdateKey({ log, addIndex }),
|
|
109
|
+
addedAt: addIndex === -1 ? undefined : log[addIndex].versionTime
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
return clients;
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=listClients.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"listClients.js","sourceRoot":"","sources":["../../src/webvh/listClients.ts"],"names":[],"mappings":"AA0CA,OAAO,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAA;AAC1E,OAAO,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAA;AAC7E,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAchE;;;;;;;;GAQG;AACH,MAAM,UAAU,yBAAyB,CAAC,EACxC,mBAAmB,EAGpB;IACC,MAAM,OAAO,GAAG,IAAI,sBAAsB,CAAC;QACzC,UAAU,EAAE,WAAW,mBAAmB,EAAE;QAC5C,kBAAkB,EAAE,mBAAmB;KACxC,CAAC,CAAA;IACF,MAAM,IAAI,GAAG,yBAAyB,CAAC,8BAA8B,CAAC;QACpE,OAAO;KACR,CAAC,CAAA;IACF,IAAI,OAAO,IAAI,CAAC,kBAAkB,KAAK,QAAQ,EAAE,CAAC;QAChD,MAAM,IAAI,KAAK,CACb,uEAAuE;YACrE,qBAAqB,CACxB,CAAA;IACH,CAAC;IACD,OAAO,IAAI,CAAC,kBAAkB,CAAA;AAChC,CAAC;AAED;;;;;;;GAOG;AACH,SAAS,eAAe,CACtB,MAAuC,EACvC,KAAa;IAEb,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,CAAE,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC,CAAA;IACxE,OAAO,MAAM,CAAC,KAAK,CAAE,CAAC,UAAU,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAA;AACpE,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,SAAS,wBAAwB,CAAC,EAChC,GAAG,E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KAAK,MAAM,IAAI,IAAI,WAAW,CAAC,GAAG,CAAC,oBAAoB,CAAC,EAAE,CAAC;QACzD,MAAM,mBAAmB,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;QAC9C,IAAI,CAAC,mBAAmB,EAAE,CAAC;YACzB,SAAQ;QACV,CAAC;QACD,qEAAqE;QACrE,oEAAoE;QACpE,MAAM,QAAQ,GAAG,GAAG,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CACrC,WAAW,CAAC,KAAK,CAAC,KAAK,CAAC,oBAAoB,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAC7D,CAAA;QACD,OAAO,CAAC,IAAI,CAAC;YACX,mBAAmB;YACnB,wBAAwB,EAAE,yBAAyB,CAAC;gBAClD,mBAAmB;aACpB,CAAC;YACF,kBAAkB,EAChB,QAAQ,KAAK,CAAC,CAAC;gBACb,CAAC,CAAC,SAAS;gBACX,CAAC,CAAC,wBAAwB,CAAC,EAAE,GAAG,EAAE,QAAQ,EAAE,CAAC;YACjD,OAAO,EAAE,QAAQ,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAE,CAAC,WAAW;SAClE,CAAC,CAAA;IACJ,CAAC;IACD,OAAO,OAAO,CAAA;AAChB,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { DIDDoc } from '@interop/did-method-webvh';
|
|
1
2
|
import type { ClientWebvhUpdateKeys, WebvhClientKeys, WebvhIdStore } from './didWebvh.js';
|
|
2
3
|
/**
|
|
3
4
|
* The public halves of the client being revoked, as the document and log
|
|
@@ -51,7 +52,11 @@ export declare class StagedCommitmentAmbiguousError extends Error {
|
|
|
51
52
|
* @param [options.knownLatentHashes] {string[]} standing latent commitments
|
|
52
53
|
* the caller vouches for (the recovery registry's update-key hashes),
|
|
53
54
|
* excluded from the staged-hash attribution
|
|
54
|
-
* @returns {Promise<{ did: string }>}
|
|
55
|
+
* @returns {Promise<{ did: string, doc: DIDDoc }>} the account's DID and its
|
|
56
|
+
* resolved document AFTER the edit -- what the roster rotation that follows
|
|
57
|
+
* resolves its remaining recipients from, so the caller needs no re-fetch of
|
|
58
|
+
* the log it just extended. On the idempotent no-op path this is the
|
|
59
|
+
* already-published document, which states the same thing.
|
|
55
60
|
*/
|
|
56
61
|
export declare function revokeWebvhClient({ idStore, updateKeys, revokedClient, knownLatentHashes }: {
|
|
57
62
|
idStore: WebvhIdStore;
|
|
@@ -60,5 +65,6 @@ export declare function revokeWebvhClient({ idStore, updateKeys, revokedClient,
|
|
|
60
65
|
knownLatentHashes?: string[];
|
|
61
66
|
}): Promise<{
|
|
62
67
|
did: string;
|
|
68
|
+
doc: DIDDoc;
|
|
63
69
|
}>;
|
|
64
70
|
//# sourceMappingURL=revokeClient.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"revokeClient.d.ts","sourceRoot":"","sources":["../../src/webvh/revokeClient.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"revokeClient.d.ts","sourceRoot":"","sources":["../../src/webvh/revokeClient.ts"],"names":[],"mappings":"AAmCA,OAAO,KAAK,EACV,MAAM,EAGP,MAAM,2BAA2B,CAAA;AAUlC,OAAO,KAAK,EACV,qBAAqB,EACrB,eAAe,EACf,YAAY,EACb,MAAM,eAAe,CAAA;AAEtB;;;;;GAKG;AACH,MAAM,WAAW,iBAAkB,SAAQ,eAAe;IACxD,kBAAkB,EAAE,MAAM,CAAA;CAC3B;AAED;;;;;;GAMG;AACH,qBAAa,8BAA+B,SAAQ,KAAK;IACvD,UAAU,EAAE,MAAM,EAAE,CAAA;gBACR,EAAE,UAAU,EAAE,EAAE;QAAE,UAAU,EAAE,MAAM,EAAE,CAAA;KAAE;CASrD;AA6FD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,wBAAsB,iBAAiB,CAAC,EACtC,OAAO,EACP,UAAU,EACV,aAAa,EACb,iBAAsB,EACvB,EAAE;IACD,OAAO,EAAE,YAAY,CAAA;IACrB,UAAU,EAAE,qBAAqB,CAAA;IACjC,aAAa,EAAE,iBAAiB,CAAA;IAChC,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAA;CAC7B,GAAG,OAAO,CAAC;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC,CA2FxC"}
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
* standing commitment.
|
|
34
34
|
*/
|
|
35
35
|
import { deriveNextKeyHash, updateDID } from '@interop/did-method-webvh';
|
|
36
|
-
import { assertCarryOverCommitments, publishWebvhLog, readPublishedLog, relationIds, updateKeyMultibase, updateKeySigner } from './didWebvh.js';
|
|
36
|
+
import { assertCarryOverCommitments, effectiveParameters, publishWebvhLog, readPublishedLog, relationIds, updateKeyMultibase, updateKeySigner } from './didWebvh.js';
|
|
37
37
|
/**
|
|
38
38
|
* Thrown when the log attribution cannot isolate the revoked client's staged
|
|
39
39
|
* commitment to a single hash -- more than one candidate survives after the
|
|
@@ -51,29 +51,6 @@ export class StagedCommitmentAmbiguousError extends Error {
|
|
|
51
51
|
this.candidates = candidates;
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
|
-
/**
|
|
55
|
-
* The per-entry EFFECTIVE `updateKeys` / `nextKeyHashes` of a log, with
|
|
56
|
-
* did:webvh's carry-forward semantics applied (an entry that omits a
|
|
57
|
-
* parameter inherits the previous entry's value).
|
|
58
|
-
*
|
|
59
|
-
* @param log {DIDLog}
|
|
60
|
-
* @returns {Array<{ updateKeys: string[]; nextKeyHashes: string[] }>}
|
|
61
|
-
*/
|
|
62
|
-
function effectiveParameters(log) {
|
|
63
|
-
const out = [];
|
|
64
|
-
let updateKeys = [];
|
|
65
|
-
let nextKeyHashes = [];
|
|
66
|
-
for (const entry of log) {
|
|
67
|
-
if (entry.parameters?.updateKeys) {
|
|
68
|
-
updateKeys = entry.parameters.updateKeys;
|
|
69
|
-
}
|
|
70
|
-
if (entry.parameters?.nextKeyHashes) {
|
|
71
|
-
nextKeyHashes = entry.parameters.nextKeyHashes;
|
|
72
|
-
}
|
|
73
|
-
out.push({ updateKeys, nextKeyHashes });
|
|
74
|
-
}
|
|
75
|
-
return out;
|
|
76
|
-
}
|
|
77
54
|
/**
|
|
78
55
|
* Recovers the revoked client's staged-key hash from the log (see the module
|
|
79
56
|
* doc for why attribution works and where it can be ambiguous). Resolves
|
|
@@ -179,7 +156,11 @@ async function attributeStagedHash({ log, revokedUpdateKey, knownLatentHashes })
|
|
|
179
156
|
* @param [options.knownLatentHashes] {string[]} standing latent commitments
|
|
180
157
|
* the caller vouches for (the recovery registry's update-key hashes),
|
|
181
158
|
* excluded from the staged-hash attribution
|
|
182
|
-
* @returns {Promise<{ did: string }>}
|
|
159
|
+
* @returns {Promise<{ did: string, doc: DIDDoc }>} the account's DID and its
|
|
160
|
+
* resolved document AFTER the edit -- what the roster rotation that follows
|
|
161
|
+
* resolves its remaining recipients from, so the caller needs no re-fetch of
|
|
162
|
+
* the log it just extended. On the idempotent no-op path this is the
|
|
163
|
+
* already-published document, which states the same thing.
|
|
183
164
|
*/
|
|
184
165
|
export async function revokeWebvhClient({ idStore, updateKeys, revokedClient, knownLatentHashes = [] }) {
|
|
185
166
|
const published = await readPublishedLog({ idStore });
|
|
@@ -200,7 +181,7 @@ export async function revokeWebvhClient({ idStore, updateKeys, revokedClient, kn
|
|
|
200
181
|
const keyPresent = published.updateKeys.includes(revokedClient.updateKeyMultibase);
|
|
201
182
|
const hashPresent = published.nextKeyHashes.includes(revokedHash);
|
|
202
183
|
if (!vmPresent && !keyPresent && !hashPresent) {
|
|
203
|
-
return { did };
|
|
184
|
+
return { did, doc };
|
|
204
185
|
}
|
|
205
186
|
if (!published.updateKeys.includes(activeKey)) {
|
|
206
187
|
throw new Error("did:webvh: the published log does not authorize this client's active " +
|
|
@@ -236,6 +217,6 @@ export async function revokeWebvhClient({ idStore, updateKeys, revokedClient, kn
|
|
|
236
217
|
throw new Error('did:webvh: updateDID returned no webDoc despite the did:web alsoKnownAs.');
|
|
237
218
|
}
|
|
238
219
|
await publishWebvhLog({ idStore, log: updated.log, webDoc: updated.webDoc });
|
|
239
|
-
return { did: updated.did };
|
|
220
|
+
return { did: updated.did, doc: updated.doc };
|
|
240
221
|
}
|
|
241
222
|
//# sourceMappingURL=revokeClient.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"revokeClient.js","sourceRoot":"","sources":["../../src/webvh/revokeClient.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;
|
|
1
|
+
{"version":3,"file":"revokeClient.js","sourceRoot":"","sources":["../../src/webvh/revokeClient.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AAMxE,OAAO,EACL,0BAA0B,EAC1B,mBAAmB,EACnB,eAAe,EACf,gBAAgB,EAChB,WAAW,EACX,kBAAkB,EAClB,eAAe,EAChB,MAAM,eAAe,CAAA;AAiBtB;;;;;;GAMG;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,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,MAAM,IAAI,KAAK,CACb,0EAA0E,CAC3E,CAAA;IACH,CAAC;IACD,MAAM,eAAe,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAA;IAC5E,OAAO,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,CAAA;AAC/C,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { DIDDoc, DIDLog } from '@interop/did-method-webvh';
|
|
2
|
+
/**
|
|
3
|
+
* Thrown when the account has published no DID log at all (the resource is
|
|
4
|
+
* absent). Distinguished from every other failure because it is the one
|
|
5
|
+
* expected state of an in-flight ceremony -- a client completing its
|
|
6
|
+
* enrollment before the other side has approved it reads this as "not yet",
|
|
7
|
+
* not as a broken account.
|
|
8
|
+
*/
|
|
9
|
+
export declare class AccountLogMissingError extends Error {
|
|
10
|
+
constructor(message?: string);
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Fetches and locally verifies the account's world-readable DID log.
|
|
14
|
+
*
|
|
15
|
+
* Throws {@link AccountLogMissingError} when the log resource is absent, and
|
|
16
|
+
* an ordinary error when the fetch fails, the log does not resolve, or it
|
|
17
|
+
* resolves to a DID other than the one named.
|
|
18
|
+
*
|
|
19
|
+
* @param options {object}
|
|
20
|
+
* @param options.did {string} the account's did:webvh, as the caller's
|
|
21
|
+
* stored account pointer names it
|
|
22
|
+
* @param options.spaceId {string} the account's Space id
|
|
23
|
+
* @param options.host {string} the storage server the account lives on
|
|
24
|
+
* @returns {Promise<object>} the resolved document, the raw log, and the
|
|
25
|
+
* log's effective `updateKeys` / `nextKeyHashes`
|
|
26
|
+
*/
|
|
27
|
+
export declare function verifyAccountLog({ did, spaceId, host }: {
|
|
28
|
+
did: string;
|
|
29
|
+
spaceId: string;
|
|
30
|
+
host: string;
|
|
31
|
+
}): Promise<{
|
|
32
|
+
doc: DIDDoc;
|
|
33
|
+
log: DIDLog;
|
|
34
|
+
updateKeys: string[];
|
|
35
|
+
nextKeyHashes: string[];
|
|
36
|
+
}>;
|
|
37
|
+
//# sourceMappingURL=verifyLog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verifyLog.d.ts","sourceRoot":"","sources":["../../src/webvh/verifyLog.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAA;AAG/D;;;;;;GAMG;AACH,qBAAa,sBAAuB,SAAQ,KAAK;gBACnC,OAAO,SAA0C;CAI9D;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,gBAAgB,CAAC,EACrC,GAAG,EACH,OAAO,EACP,IAAI,EACL,EAAE;IACD,GAAG,EAAE,MAAM,CAAA;IACX,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,EAAE,MAAM,CAAA;CACb,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,CAmCD"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2026 Interop Alliance. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* The account's published-log verification step: fetch the world-readable
|
|
6
|
+
* did:webvh log out of the Space's `id` collection, resolve it locally, and
|
|
7
|
+
* refuse a log that resolves to a different DID than the account pointer
|
|
8
|
+
* names. Every ceremony that reads or edits the document -- listing the
|
|
9
|
+
* enrolled clients, approving a connect code, disconnecting a client,
|
|
10
|
+
* rotating the wrap-set roster -- runs it first, so it lives here once
|
|
11
|
+
* instead of once per wallet.
|
|
12
|
+
*
|
|
13
|
+
* The fetch is unauthenticated on purpose: the log is world-readable by
|
|
14
|
+
* policy, and its own hash chain (SCID-pinned, prerotation-checked,
|
|
15
|
+
* update-key signed) is what makes it trustworthy, not the channel. The
|
|
16
|
+
* caller supplies the DID it expects; a resolved DID that does not match is
|
|
17
|
+
* the substituted-account refusal, and the only thing the transport could
|
|
18
|
+
* ever buy back.
|
|
19
|
+
*/
|
|
20
|
+
import { readLogFromString, resolveDIDFromLog } from '@interop/did-method-webvh';
|
|
21
|
+
import { DID_LOG_RESOURCE, ID_COLLECTION } from '../space/collections.js';
|
|
22
|
+
/**
|
|
23
|
+
* Thrown when the account has published no DID log at all (the resource is
|
|
24
|
+
* absent). Distinguished from every other failure because it is the one
|
|
25
|
+
* expected state of an in-flight ceremony -- a client completing its
|
|
26
|
+
* enrollment before the other side has approved it reads this as "not yet",
|
|
27
|
+
* not as a broken account.
|
|
28
|
+
*/
|
|
29
|
+
export class AccountLogMissingError extends Error {
|
|
30
|
+
constructor(message = 'The account has no published DID log.') {
|
|
31
|
+
super(message);
|
|
32
|
+
this.name = 'AccountLogMissingError';
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Fetches and locally verifies the account's world-readable DID log.
|
|
37
|
+
*
|
|
38
|
+
* Throws {@link AccountLogMissingError} when the log resource is absent, and
|
|
39
|
+
* an ordinary error when the fetch fails, the log does not resolve, or it
|
|
40
|
+
* resolves to a DID other than the one named.
|
|
41
|
+
*
|
|
42
|
+
* @param options {object}
|
|
43
|
+
* @param options.did {string} the account's did:webvh, as the caller's
|
|
44
|
+
* stored account pointer names it
|
|
45
|
+
* @param options.spaceId {string} the account's Space id
|
|
46
|
+
* @param options.host {string} the storage server the account lives on
|
|
47
|
+
* @returns {Promise<object>} the resolved document, the raw log, and the
|
|
48
|
+
* log's effective `updateKeys` / `nextKeyHashes`
|
|
49
|
+
*/
|
|
50
|
+
export async function verifyAccountLog({ did, spaceId, host }) {
|
|
51
|
+
const url = new URL(`/space/${spaceId}/${ID_COLLECTION.id}/${DID_LOG_RESOURCE}`, host);
|
|
52
|
+
const response = await fetch(url);
|
|
53
|
+
if (response.status === 404) {
|
|
54
|
+
throw new AccountLogMissingError();
|
|
55
|
+
}
|
|
56
|
+
if (!response.ok) {
|
|
57
|
+
throw new Error(`Fetching the account's DID log failed (HTTP ${response.status}).`);
|
|
58
|
+
}
|
|
59
|
+
const log = readLogFromString(await response.text());
|
|
60
|
+
const resolved = await resolveDIDFromLog(log);
|
|
61
|
+
if (resolved.meta.error || !resolved.did || !resolved.doc) {
|
|
62
|
+
throw new Error(`The account's DID log failed to resolve (${resolved.meta.error ?? 'the resolver returned no DID document'}).`);
|
|
63
|
+
}
|
|
64
|
+
if (resolved.did !== did) {
|
|
65
|
+
throw new Error('The published DID log resolves to a different DID than the account ' +
|
|
66
|
+
'pointer names.');
|
|
67
|
+
}
|
|
68
|
+
return {
|
|
69
|
+
doc: resolved.doc,
|
|
70
|
+
log,
|
|
71
|
+
updateKeys: resolved.meta.updateKeys ?? [],
|
|
72
|
+
nextKeyHashes: resolved.meta.nextKeyHashes ?? []
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=verifyLog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verifyLog.js","sourceRoot":"","sources":["../../src/webvh/verifyLog.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAA;AAEhF,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAA;AAEzE;;;;;;GAMG;AACH,MAAM,OAAO,sBAAuB,SAAQ,KAAK;IAC/C,YAAY,OAAO,GAAG,uCAAuC;QAC3D,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAA;IACtC,CAAC;CACF;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,KAAK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*!
|
|
2
|
+
* Copyright (c) 2026 Interop Alliance. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* The WAS-backed adapter for the did:webvh module's narrow store seam: the
|
|
6
|
+
* account's identity collections as a {@link WebvhIdStore}, so every wallet
|
|
7
|
+
* app drives the log ceremonies through one implementation instead of its own
|
|
8
|
+
* copy.
|
|
9
|
+
*
|
|
10
|
+
* Both collections are addressed as plaintext: `id` holds published documents
|
|
11
|
+
* (world-readable by policy) and `key-map` holds plain JSON, so neither goes
|
|
12
|
+
* through the encryption codec.
|
|
13
|
+
*
|
|
14
|
+
* Bodies are written as raw bytes under the content type the caller states --
|
|
15
|
+
* load-bearing, since the log is JSON Lines (`text/jsonl`), not JSON, and the
|
|
16
|
+
* DID document is served as `application/did+json`.
|
|
17
|
+
*/
|
|
18
|
+
import type { WasClient } from '@interop/was-client';
|
|
19
|
+
import type { WebvhIdStore } from './didWebvh.js';
|
|
20
|
+
/**
|
|
21
|
+
* Builds the `id`-collection store the did:webvh ceremonies read and write
|
|
22
|
+
* through.
|
|
23
|
+
*
|
|
24
|
+
* @param options {object}
|
|
25
|
+
* @param options.was {WasClient} the account's storage client, signing as an
|
|
26
|
+
* enrolled client
|
|
27
|
+
* @param options.spaceId {string} the data Space id
|
|
28
|
+
* @returns {WebvhIdStore}
|
|
29
|
+
*/
|
|
30
|
+
export declare function wasWebvhIdStore({ was, spaceId }: {
|
|
31
|
+
was: WasClient;
|
|
32
|
+
spaceId: string;
|
|
33
|
+
}): WebvhIdStore;
|
|
34
|
+
//# sourceMappingURL=wasIdStore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wasIdStore.d.ts","sourceRoot":"","sources":["../../src/webvh/wasIdStore.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAMpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAEjD;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,EAC9B,GAAG,EACH,OAAO,EACR,EAAE;IACD,GAAG,EAAE,SAAS,CAAA;IACd,OAAO,EAAE,MAAM,CAAA;CAChB,GAAG,YAAY,CAqCf"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { DID_KEYS_RESOURCE, ID_COLLECTION, KEY_MAP_COLLECTION } from '../space/collections.js';
|
|
2
|
+
/**
|
|
3
|
+
* Builds the `id`-collection store the did:webvh ceremonies read and write
|
|
4
|
+
* through.
|
|
5
|
+
*
|
|
6
|
+
* @param options {object}
|
|
7
|
+
* @param options.was {WasClient} the account's storage client, signing as an
|
|
8
|
+
* enrolled client
|
|
9
|
+
* @param options.spaceId {string} the data Space id
|
|
10
|
+
* @returns {WebvhIdStore}
|
|
11
|
+
*/
|
|
12
|
+
export function wasWebvhIdStore({ was, spaceId }) {
|
|
13
|
+
const idResource = (resourceId) => was
|
|
14
|
+
.space(spaceId)
|
|
15
|
+
.collection(ID_COLLECTION.id, { encryption: 'plaintext' })
|
|
16
|
+
.resource(resourceId);
|
|
17
|
+
return {
|
|
18
|
+
getIdResourceRaw: async ({ resourceId }) => {
|
|
19
|
+
const text = await idResource(resourceId).getText();
|
|
20
|
+
return text === null ? undefined : text;
|
|
21
|
+
},
|
|
22
|
+
getIdResource: async ({ resourceId }) => {
|
|
23
|
+
const data = await idResource(resourceId).get();
|
|
24
|
+
return data === null ? undefined : data;
|
|
25
|
+
},
|
|
26
|
+
putIdResource: async ({ resourceId, content, contentType = 'application/json' }) => {
|
|
27
|
+
const serialized = typeof content === 'string' ? content : JSON.stringify(content);
|
|
28
|
+
await idResource(resourceId).put(new TextEncoder().encode(serialized), {
|
|
29
|
+
contentType
|
|
30
|
+
});
|
|
31
|
+
},
|
|
32
|
+
putKeyMap: async ({ content }) => {
|
|
33
|
+
await was
|
|
34
|
+
.space(spaceId)
|
|
35
|
+
.collection(KEY_MAP_COLLECTION.id, { encryption: 'plaintext' })
|
|
36
|
+
.resource(DID_KEYS_RESOURCE)
|
|
37
|
+
.put(new TextEncoder().encode(JSON.stringify(content)), {
|
|
38
|
+
contentType: 'application/json'
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=wasIdStore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wasIdStore.js","sourceRoot":"","sources":["../../src/webvh/wasIdStore.ts"],"names":[],"mappings":"AAkBA,OAAO,EACL,iBAAiB,EACjB,aAAa,EACb,kBAAkB,EACnB,MAAM,yBAAyB,CAAA;AAGhC;;;;;;;;;GASG;AACH,MAAM,UAAU,eAAe,CAAC,EAC9B,GAAG,EACH,OAAO,EAIR;IACC,MAAM,UAAU,GAAG,CAAC,UAAkB,EAAE,EAAE,CACxC,GAAG;SACA,KAAK,CAAC,OAAO,CAAC;SACd,UAAU,CAAC,aAAa,CAAC,EAAE,EAAE,EAAE,UAAU,EAAE,WAAW,EAAE,CAAC;SACzD,QAAQ,CAAC,UAAU,CAAC,CAAA;IAEzB,OAAO;QACL,gBAAgB,EAAE,KAAK,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE;YACzC,MAAM,IAAI,GAAG,MAAM,UAAU,CAAC,UAAU,CAAC,CAAC,OAAO,EAAE,CAAA;YACnD,OAAO,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAA;QACzC,CAAC;QACD,aAAa,EAAE,KAAK,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE;YACtC,MAAM,IAAI,GAAG,MAAM,UAAU,CAAC,UAAU,CAAC,CAAC,GAAG,EAAE,CAAA;YAC/C,OAAO,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAA;QACzC,CAAC;QACD,aAAa,EAAE,KAAK,EAAE,EACpB,UAAU,EACV,OAAO,EACP,WAAW,GAAG,kBAAkB,EACjC,EAAE,EAAE;YACH,MAAM,UAAU,GACd,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAA;YACjE,MAAM,UAAU,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE;gBACrE,WAAW;aACZ,CAAC,CAAA;QACJ,CAAC;QACD,SAAS,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;YAC/B,MAAM,GAAG;iBACN,KAAK,CAAC,OAAO,CAAC;iBACd,UAAU,CAAC,kBAAkB,CAAC,EAAE,EAAE,EAAE,UAAU,EAAE,WAAW,EAAE,CAAC;iBAC9D,QAAQ,CAAC,iBAAiB,CAAC;iBAC3B,GAAG,CAAC,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,EAAE;gBACtD,WAAW,EAAE,kBAAkB;aAChC,CAAC,CAAA;QACN,CAAC;KACF,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.13.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"build": "pnpm run clear && tsc",
|