@interop/wallet-core 0.39.0 → 0.40.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 +3 -2
- package/dist/clients/revocation.d.ts.map +1 -1
- package/dist/clients/revocation.js +5 -10
- package/dist/clients/revocation.js.map +1 -1
- package/dist/keyring/fetch.d.ts +2 -1
- package/dist/keyring/fetch.d.ts.map +1 -1
- package/dist/keyring/fetch.js +7 -2
- package/dist/keyring/fetch.js.map +1 -1
- package/dist/keyring/index.d.ts +15 -9
- package/dist/keyring/index.d.ts.map +1 -1
- package/dist/keyring/index.js +14 -8
- package/dist/keyring/index.js.map +1 -1
- package/dist/keyring/kdf.d.ts +3 -1
- package/dist/keyring/kdf.d.ts.map +1 -1
- package/dist/keyring/kdf.js +16 -2
- package/dist/keyring/kdf.js.map +1 -1
- package/dist/keyring/record.d.ts +207 -41
- package/dist/keyring/record.d.ts.map +1 -1
- package/dist/keyring/record.js +318 -32
- package/dist/keyring/record.js.map +1 -1
- package/dist/keyring/unlockSpace.d.ts +25 -0
- package/dist/keyring/unlockSpace.d.ts.map +1 -1
- package/dist/keyring/unlockSpace.js +31 -2
- package/dist/keyring/unlockSpace.js.map +1 -1
- package/dist/keys/rosterLogStore.d.ts.map +1 -1
- package/dist/keys/rosterLogStore.js +6 -1
- package/dist/keys/rosterLogStore.js.map +1 -1
- package/dist/keys/userKeyRoster.d.ts +22 -3
- package/dist/keys/userKeyRoster.d.ts.map +1 -1
- package/dist/keys/userKeyRoster.js +11 -59
- package/dist/keys/userKeyRoster.js.map +1 -1
- package/dist/recovery/index.d.ts +8 -3
- package/dist/recovery/index.d.ts.map +1 -1
- package/dist/recovery/index.js +7 -2
- package/dist/recovery/index.js.map +1 -1
- package/dist/recovery/recoveryCode.d.ts +7 -0
- package/dist/recovery/recoveryCode.d.ts.map +1 -1
- package/dist/recovery/recoveryCode.js +10 -0
- package/dist/recovery/recoveryCode.js.map +1 -1
- package/dist/recovery/recoveryRecord.d.ts +134 -43
- package/dist/recovery/recoveryRecord.d.ts.map +1 -1
- package/dist/recovery/recoveryRecord.js +226 -23
- package/dist/recovery/recoveryRecord.js.map +1 -1
- package/dist/request/index.d.ts +1 -1
- package/dist/request/index.js +1 -1
- package/dist/request/matching.d.ts +24 -5
- package/dist/request/matching.d.ts.map +1 -1
- package/dist/request/matching.js +36 -39
- package/dist/request/matching.js.map +1 -1
- package/dist/request/walletInput.d.ts.map +1 -1
- package/dist/request/walletInput.js +3 -6
- package/dist/request/walletInput.js.map +1 -1
- package/dist/resourceLog/controller.d.ts +7 -4
- package/dist/resourceLog/controller.d.ts.map +1 -1
- package/dist/resourceLog/controller.js +17 -35
- package/dist/resourceLog/controller.js.map +1 -1
- package/dist/resourceLog/index.d.ts +1 -0
- package/dist/resourceLog/index.d.ts.map +1 -1
- package/dist/resourceLog/index.js +1 -0
- package/dist/resourceLog/index.js.map +1 -1
- package/dist/resourceLog/seal.d.ts +9 -1
- package/dist/resourceLog/seal.d.ts.map +1 -1
- package/dist/resourceLog/seal.js +21 -11
- package/dist/resourceLog/seal.js.map +1 -1
- package/dist/resourceLog/verify.d.ts.map +1 -1
- package/dist/resourceLog/verify.js +26 -9
- package/dist/resourceLog/verify.js.map +1 -1
- package/dist/resourceLog/vmFragment.d.ts +33 -0
- package/dist/resourceLog/vmFragment.d.ts.map +1 -0
- package/dist/resourceLog/vmFragment.js +39 -0
- package/dist/resourceLog/vmFragment.js.map +1 -0
- package/dist/space/publicLink.d.ts +2 -0
- package/dist/space/publicLink.d.ts.map +1 -1
- package/dist/space/publicLink.js +13 -1
- package/dist/space/publicLink.js.map +1 -1
- package/dist/space/wasLink.d.ts +5 -0
- package/dist/space/wasLink.d.ts.map +1 -1
- package/dist/space/wasLink.js +7 -2
- package/dist/space/wasLink.js.map +1 -1
- package/dist/webvh/didWeb.d.ts +3 -11
- package/dist/webvh/didWeb.d.ts.map +1 -1
- package/dist/webvh/didWeb.js +5 -1
- package/dist/webvh/didWeb.js.map +1 -1
- package/dist/webvh/listClients.d.ts +3 -1
- package/dist/webvh/listClients.d.ts.map +1 -1
- package/dist/webvh/listClients.js +46 -29
- package/dist/webvh/listClients.js.map +1 -1
- package/dist/webvh/verifyLog.d.ts.map +1 -1
- package/dist/webvh/verifyLog.js +5 -1
- package/dist/webvh/verifyLog.js.map +1 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"record.d.ts","sourceRoot":"","sources":["../../src/keyring/record.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"record.d.ts","sourceRoot":"","sources":["../../src/keyring/record.ts"],"names":[],"mappings":"AAwCA,OAAO,KAAK,EACV,gBAAgB,EAChB,YAAY,EACb,MAAM,8BAA8B,CAAA;AACrC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAA;AAC/D,OAAO,EAIL,KAAK,SAAS,EAEf,MAAM,yBAAyB,CAAA;AAGhC;;;;;;GAMG;AACH,eAAO,MAAM,sBAAsB,IAAI,CAAA;AAEvC;;;;;;GAMG;AACH,MAAM,WAAW,YAAY;IAC3B,YAAY,EAAE,MAAM,CAAA;IACpB,IAAI,CAAC,KAAK,EAAE;QAAE,IAAI,EAAE,UAAU,CAAA;KAAE,GAAG,OAAO,CAAC,UAAU,CAAC,CAAA;CACvD;AAED;;;;;GAKG;AACH,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,oBAAoB,CAAA;IAC1B,WAAW,EAAE,gBAAgB,CAAA;IAC7B,kBAAkB,EAAE,MAAM,CAAA;IAC1B,YAAY,EAAE,iBAAiB,CAAA;IAC/B,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,UAAU,EAAE,MAAM,CAAA;CACnB;AAED;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,CAAA;IACf,UAAU,EAAE,oBAAoB,CAAA;IAChC,OAAO,EAAE,OAAO,CAAA;IAChB,KAAK,EAAE,W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AAW,EACX,MAAM,EACN,SAAS,EACV,EAAE;IACD,UAAU,EAAE,MAAM,CAAA;IAClB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,EAAE,cAAc,CAAA;IACxB,eAAe,EAAE,gBAAgB,CAAA;IACjC,WAAW,EAAE,YAAY,CAAA;IACzB,MAAM,EAAE,YAAY,CAAA;IACpB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,GAAG,OAAO,CAAC,YAAY,CAAC,CA6BxB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,mBAAmB,CAAC,EACxC,MAAM,EACN,eAAe,EACf,WAAW,EACX,oBAAoB,EACrB,EAAE;IACD,MAAM,EAAE,OAAO,CAAA;IACf,eAAe,EAAE,gBAAgB,CAAA;IACjC,WAAW,EAAE,YAAY,CAAA;IACzB,oBAAoB,EAAE,MAAM,CAAA;CAC7B,GAAG,OAAO,CAAC,qBAAqB,CAAC,CA2CjC;AAED;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAAC,EACnC,SAAS,EACV,EAAE;IACD,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,GAAG,MAAM,CAQT;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,CAAC,EACnC,KAAK,EACL,KAAK,EACN,EAAE;IACD,KAAK,EAAE,OAAO,CAAA;IACd,KAAK,EAAE,MAAM,CAAA;CACd,GAAG,MAAM,CAKT;AAED;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,cAAc,GAAG,SAAS,CAsB7E"}
|
package/dist/keyring/record.js
CHANGED
|
@@ -1,12 +1,158 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2026 Interop Alliance. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* The keyring record codec: the `{ version, encryption, wrapped, proof }`
|
|
6
|
+
* envelope stored as the one resource of an account's unlock Space. Its
|
|
7
|
+
* plaintext carries the account controller, the email captured at bind time,
|
|
8
|
+
* the account pointer, and the bind timestamp -- and deliberately no key
|
|
9
|
+
* material of any kind, so the record locates an account without authorizing
|
|
10
|
+
* anything against it.
|
|
11
|
+
*
|
|
12
|
+
* The wrap is an EDV document envelope sealed under the record's own key
|
|
13
|
+
* epoch: every EDV envelope seals to an epoch key, so the record carries its
|
|
14
|
+
* one-epoch descriptor in its `encryption` member, epoch[0] wrapped to the
|
|
15
|
+
* unlock key-agreement key. The record stays self-contained -- unlock KAK in,
|
|
16
|
+
* contents out. The cipher's `keyring` collection context labels errors only
|
|
17
|
+
* (the codec is agnostic to it).
|
|
18
|
+
*
|
|
19
|
+
* The authenticity layer is the `proof` member, and it is load-bearing: the
|
|
20
|
+
* unlock KAK's public half is derivable from the unlock did:key the server
|
|
21
|
+
* stores as the unlock Space's controller, so a malicious storage host can
|
|
22
|
+
* seal a record of its own that decrypts perfectly. Confidentiality was never
|
|
23
|
+
* the missing property. So a record carries an eddsa-jcs-2022 Data Integrity
|
|
24
|
+
* proof over its sibling members (`version`, `encryption`, `wrapped`), signed
|
|
25
|
+
* by the unlock identity's Ed25519 key -- which derives from the unlock secret,
|
|
26
|
+
* so a fresh client holds the verification prior by construction and the
|
|
27
|
+
* server never holds the signing key. The proof is verified BEFORE the record
|
|
28
|
+
* is decrypted, and there is no unwrap path that skips it. Because the
|
|
29
|
+
* signature covers the ciphertext, the encrypted bind timestamp is covered
|
|
30
|
+
* transitively while staying inside the plaintext, so bind times do not leak
|
|
31
|
+
* to a reader of the unlock Space.
|
|
32
|
+
*/
|
|
33
|
+
import { createDataIntegrityProofTemplate, defaultWebvhLogVerifier, signDataIntegrityProof, signerFromExternalKey, verifyEntryProofs } from '@interop/did-method-webvh';
|
|
1
34
|
import { createEdvDocCipher, initRecipients, ownerRecipient } from '@interop/was-client/edv';
|
|
2
35
|
import { KEYRING_COLLECTION } from '../space/collections.js';
|
|
3
36
|
/**
|
|
4
|
-
* The version stamped on the stored `{ version, encryption, wrapped }`
|
|
5
|
-
* envelope: the record whose envelope seals under the record's
|
|
6
|
-
* (the `encryption` member)
|
|
7
|
-
*
|
|
37
|
+
* The version stamped on the stored `{ version, encryption, wrapped, proof }`
|
|
38
|
+
* keyring envelope: the signed record, whose envelope seals under the record's
|
|
39
|
+
* own key epoch (the `encryption` member) and whose sibling members carry a
|
|
40
|
+
* Data Integrity proof by the unlock identity's signing key. Any other version
|
|
41
|
+
* is refused as unusable -- such accounts are re-provisioned, not migrated.
|
|
42
|
+
*/
|
|
43
|
+
export const KEYRING_RECORD_VERSION = 2;
|
|
44
|
+
/**
|
|
45
|
+
* A record's proof is absent, malformed, signed by a key this client does not
|
|
46
|
+
* accept, or does not verify over the record's own members. Its own class,
|
|
47
|
+
* distinct from a decrypt failure or an unusable-version refusal: this is the
|
|
48
|
+
* refusal that says the storage host forged or tampered with the record, which
|
|
49
|
+
* an app maps to its own login copy.
|
|
50
|
+
*/
|
|
51
|
+
export class RecordProofError extends Error {
|
|
52
|
+
constructor(message, options) {
|
|
53
|
+
super(message, options);
|
|
54
|
+
this.name = 'RecordProofError';
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Adapts a signing key agent (the unlock identity's `CapabilityAgent`, or an
|
|
59
|
+
* enrolled client's own key agent) to the record signer seam: the agent's
|
|
60
|
+
* did:key id supplies the public multibase, its signer the raw signature.
|
|
61
|
+
*
|
|
62
|
+
* @param options {object}
|
|
63
|
+
* @param options.keyAgent {object} a did:key `CapabilityAgent`-shaped agent
|
|
64
|
+
* @returns {RecordSigner}
|
|
65
|
+
*/
|
|
66
|
+
export function recordSignerFromAgent({ keyAgent }) {
|
|
67
|
+
const [scheme, method, keyMultibase] = keyAgent.id.split(':');
|
|
68
|
+
if (scheme !== 'did' || method !== 'key' || !keyMultibase) {
|
|
69
|
+
throw new Error(`Not a did:key agent id: "${keyAgent.id}".`);
|
|
70
|
+
}
|
|
71
|
+
const signer = keyAgent.getSigner();
|
|
72
|
+
return {
|
|
73
|
+
keyMultibase,
|
|
74
|
+
async sign({ data }) {
|
|
75
|
+
const signature = await signer.sign({ data });
|
|
76
|
+
// Re-wrap as a plain Uint8Array: a signer may return a Node Buffer (or
|
|
77
|
+
// a cross-realm view), which the kernel's strict byte check rejects.
|
|
78
|
+
return new Uint8Array(signature.buffer, signature.byteOffset, signature.byteLength);
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Signs a record's frame members and returns the stored signed record. Shared
|
|
84
|
+
* by the keyring and recovery wrap paths (and available to an app's own record
|
|
85
|
+
* kinds), so one construction produces every signed record: the proof covers
|
|
86
|
+
* `{ version, encryption, wrapped }` plus any record-kind members under JCS
|
|
87
|
+
* canonicalization.
|
|
88
|
+
*
|
|
89
|
+
* @param options {object}
|
|
90
|
+
* @param options.version {number} the frame version to stamp
|
|
91
|
+
* @param options.encryption {CollectionEncryption} the record's descriptor
|
|
92
|
+
* @param options.wrapped {unknown} the sealed envelope
|
|
93
|
+
* @param options.signer {RecordSigner} the signing key
|
|
94
|
+
* @param [options.members] {object} additional record-kind frame members the
|
|
95
|
+
* proof must cover (e.g. the recovery record's `binding`)
|
|
96
|
+
* @returns {Promise<SignedRecord>}
|
|
8
97
|
*/
|
|
9
|
-
export
|
|
98
|
+
export async function signRecordFrame({ version, encryption, wrapped, signer, members }) {
|
|
99
|
+
const frame = { version, encryption, wrapped, ...(members ?? {}) };
|
|
100
|
+
const proofTemplate = createDataIntegrityProofTemplate({
|
|
101
|
+
verificationMethod: `did:key:${signer.keyMultibase}#${signer.keyMultibase}`
|
|
102
|
+
});
|
|
103
|
+
const proof = await signDataIntegrityProof(
|
|
104
|
+
// The kernel types its signable documents as did:webvh artifacts, but the
|
|
105
|
+
// construction is generic (JCS canonicalization over whatever it is
|
|
106
|
+
// handed), so the record frame rides through as one.
|
|
107
|
+
frame, proofTemplate, signerFromExternalKey({
|
|
108
|
+
publicKeyMultibase: signer.keyMultibase,
|
|
109
|
+
sign: signer.sign
|
|
110
|
+
}));
|
|
111
|
+
return { ...frame, proof: proof };
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Structural check of a record's `proof` member against the fixed shape,
|
|
115
|
+
* before any cryptography runs.
|
|
116
|
+
*
|
|
117
|
+
* @param options {object}
|
|
118
|
+
* @param options.proof {unknown}
|
|
119
|
+
* @param options.label {string} names the record kind in the refusal
|
|
120
|
+
* @returns {RecordProof}
|
|
121
|
+
*/
|
|
122
|
+
function checkRecordProofShape({ proof, label }) {
|
|
123
|
+
const candidate = proof;
|
|
124
|
+
if (candidate === null ||
|
|
125
|
+
typeof candidate !== 'object' ||
|
|
126
|
+
candidate.type !== 'DataIntegrityProof' ||
|
|
127
|
+
candidate.cryptosuite !== 'eddsa-jcs-2022' ||
|
|
128
|
+
candidate.proofPurpose !== 'assertionMethod' ||
|
|
129
|
+
typeof candidate.verificationMethod !== 'string' ||
|
|
130
|
+
typeof candidate.proofValue !== 'string') {
|
|
131
|
+
throw new RecordProofError(`The ${label} record carries no proof in the fixed shape ` +
|
|
132
|
+
`(DataIntegrityProof / eddsa-jcs-2022 / assertionMethod).`);
|
|
133
|
+
}
|
|
134
|
+
return candidate;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* The signing key's public multibase named by a proof's `verificationMethod`:
|
|
138
|
+
* its fragment. The signer emits `did:key:<multibase>#<multibase>`; the DID
|
|
139
|
+
* half is not what authorizes anything -- the multibase IS the key, and the
|
|
140
|
+
* caller's allowlist decides whether it may sign this record.
|
|
141
|
+
*
|
|
142
|
+
* @param options {object}
|
|
143
|
+
* @param options.verificationMethod {string}
|
|
144
|
+
* @param options.label {string} names the record kind in the refusal
|
|
145
|
+
* @returns {string}
|
|
146
|
+
*/
|
|
147
|
+
export function recordProofKeyMultibase({ verificationMethod, label }) {
|
|
148
|
+
const hashIndex = verificationMethod.lastIndexOf('#');
|
|
149
|
+
const keyMultibase = hashIndex === -1 ? '' : verificationMethod.slice(hashIndex + 1);
|
|
150
|
+
if (!keyMultibase) {
|
|
151
|
+
throw new RecordProofError(`The ${label} record's proof names a verification method with no key ` +
|
|
152
|
+
`fragment.`);
|
|
153
|
+
}
|
|
154
|
+
return keyMultibase;
|
|
155
|
+
}
|
|
10
156
|
/**
|
|
11
157
|
* Mints the one-epoch descriptor a fresh record is sealed under: epoch[0]
|
|
12
158
|
* wrapped to the given KAK alone, built through `initRecipients` against a
|
|
@@ -67,9 +213,15 @@ export async function recordCipher({ keyAgreementKey, keyResolver, encryption, c
|
|
|
67
213
|
/**
|
|
68
214
|
* Validates the common `{ version, encryption, wrapped }` frame of a stored
|
|
69
215
|
* record (keyring or recovery -- `label` names the refusals) and returns its
|
|
70
|
-
* members. Exported so an app's
|
|
71
|
-
*
|
|
72
|
-
* the version and shape checks.
|
|
216
|
+
* members, the `proof` among them for the signed frame. Exported so an app's
|
|
217
|
+
* own record kinds open their records through the same frame validation the
|
|
218
|
+
* codec here seals with, rather than re-deriving the version and shape checks.
|
|
219
|
+
*
|
|
220
|
+
* A frame at the keyring record version is the signed frame, so it must carry
|
|
221
|
+
* a fixed-shape proof; a record kind stamping its own version is unaffected
|
|
222
|
+
* (its authenticity story is its own). Validating the shape here does not
|
|
223
|
+
* verify it -- {@link verifyRecordProof} does, and every unwrap path in this
|
|
224
|
+
* module runs it before decrypting.
|
|
73
225
|
*
|
|
74
226
|
* @param options {object}
|
|
75
227
|
* @param options.record {unknown}
|
|
@@ -77,38 +229,110 @@ export async function recordCipher({ keyAgreementKey, keyResolver, encryption, c
|
|
|
77
229
|
* kind's own label
|
|
78
230
|
* @param [options.version] {number} the version the frame must carry;
|
|
79
231
|
* defaults to the keyring record version
|
|
80
|
-
* @returns {{ encryption: CollectionEncryption, wrapped: unknown
|
|
232
|
+
* @returns {{ encryption: CollectionEncryption, wrapped: unknown,
|
|
233
|
+
* proof?: RecordProof }}
|
|
81
234
|
*/
|
|
82
235
|
export function parseRecordFrame({ record, label, version = KEYRING_RECORD_VERSION }) {
|
|
83
236
|
if (record === null || typeof record !== 'object') {
|
|
84
237
|
throw new Error(`Malformed ${label} record.`);
|
|
85
238
|
}
|
|
86
|
-
const { version: recordVersion, encryption, wrapped } = record;
|
|
239
|
+
const { version: recordVersion, encryption, wrapped, proof } = record;
|
|
87
240
|
if (recordVersion !== version) {
|
|
241
|
+
// Two retired version-1 shapes are named rather than reported as an
|
|
242
|
+
// unsupported number, so neither refusal is read as corruption: the
|
|
243
|
+
// pre-extraction record (a data-seed wrap with no descriptor) and the
|
|
244
|
+
// unsigned envelope this version's proof replaced. Both are unusable.
|
|
245
|
+
if (version === KEYRING_RECORD_VERSION && recordVersion === 1) {
|
|
246
|
+
if (encryption === undefined) {
|
|
247
|
+
throw new Error(`The ${label} record uses the retired pre-extraction version 1 ` +
|
|
248
|
+
'shape (a data-seed wrap with no encryption descriptor); such ' +
|
|
249
|
+
'accounts are re-provisioned, not migrated.');
|
|
250
|
+
}
|
|
251
|
+
throw new Error(`The ${label} record uses the retired unsigned version 1 shape (no ` +
|
|
252
|
+
'proof over its frame, so a storage host could substitute it); ' +
|
|
253
|
+
'such accounts are re-provisioned, not migrated.');
|
|
254
|
+
}
|
|
88
255
|
throw new Error(`Unsupported ${label} record version "${String(recordVersion)}".`);
|
|
89
256
|
}
|
|
90
257
|
if (wrapped === undefined || wrapped === null) {
|
|
91
258
|
throw new Error(`Malformed ${label} record.`);
|
|
92
259
|
}
|
|
93
|
-
// A version-1 frame carrying a wrap but no descriptor is the retired
|
|
94
|
-
// pre-extraction record shape, which shipped under this same version number
|
|
95
|
-
// and wrapped a data seed. It is unusable, not merely damaged -- name the
|
|
96
|
-
// shape so the refusal is not read as corruption.
|
|
97
|
-
if (encryption === undefined && version === KEYRING_RECORD_VERSION) {
|
|
98
|
-
throw new Error(`The ${label} record uses the retired pre-extraction version 1 shape ` +
|
|
99
|
-
'(a data-seed wrap with no encryption descriptor); such accounts are ' +
|
|
100
|
-
're-provisioned, not migrated.');
|
|
101
|
-
}
|
|
102
260
|
if (encryption === null || typeof encryption !== 'object') {
|
|
103
261
|
throw new Error(`The ${label} record is missing its encryption descriptor.`);
|
|
104
262
|
}
|
|
105
|
-
return {
|
|
263
|
+
return {
|
|
264
|
+
encryption: encryption,
|
|
265
|
+
wrapped,
|
|
266
|
+
...(version === KEYRING_RECORD_VERSION
|
|
267
|
+
? { proof: checkRecordProofShape({ proof, label }) }
|
|
268
|
+
: {})
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Verifies a stored record's proof: the fixed proof shape, the signing key
|
|
273
|
+
* against the caller's allowlist, and the signature over the record's sibling
|
|
274
|
+
* members (everything except `proof`, JCS-canonicalized). Refuses with
|
|
275
|
+
* {@link RecordProofError} in every failing case -- a class of its own, so an
|
|
276
|
+
* app tells "the host forged or tampered with this record" apart from a wrong
|
|
277
|
+
* unlock secret or an unusable version.
|
|
278
|
+
*
|
|
279
|
+
* Standalone as well as internal, because the recovery record's re-minted
|
|
280
|
+
* signer is only knowable after the record is decrypted (see
|
|
281
|
+
* `unwrapRecoveryRecord`).
|
|
282
|
+
*
|
|
283
|
+
* @param options {object}
|
|
284
|
+
* @param options.record {unknown} the stored record, proof included
|
|
285
|
+
* @param options.allowedKeyMultibases {string | string[]} the signing keys
|
|
286
|
+
* this caller accepts, as public multibases or as verification-method ids
|
|
287
|
+
* whose fragment is one
|
|
288
|
+
* @param [options.label] {string} names the record kind in refusals;
|
|
289
|
+
* defaults to the keyring record
|
|
290
|
+
* @returns {Promise<string>} the verified signing key's public multibase
|
|
291
|
+
*/
|
|
292
|
+
export async function verifyRecordProof({ record, allowedKeyMultibases, label = 'keyring' }) {
|
|
293
|
+
if (record === null || typeof record !== 'object') {
|
|
294
|
+
throw new RecordProofError(`Malformed ${label} record.`);
|
|
295
|
+
}
|
|
296
|
+
const { proof, ...frame } = record;
|
|
297
|
+
const checked = checkRecordProofShape({ proof, label });
|
|
298
|
+
const keyMultibase = recordProofKeyMultibase({
|
|
299
|
+
verificationMethod: checked.verificationMethod,
|
|
300
|
+
label
|
|
301
|
+
});
|
|
302
|
+
const allowed = new Set((typeof allowedKeyMultibases === 'string'
|
|
303
|
+
? [allowedKeyMultibases]
|
|
304
|
+
: allowedKeyMultibases).map(entry => {
|
|
305
|
+
const hashIndex = entry.lastIndexOf('#');
|
|
306
|
+
return hashIndex === -1 ? entry : entry.slice(hashIndex + 1);
|
|
307
|
+
}));
|
|
308
|
+
if (!allowed.has(keyMultibase)) {
|
|
309
|
+
throw new RecordProofError(`The ${label} record is signed by a key this client does not accept ` +
|
|
310
|
+
`for it ("${keyMultibase}").`);
|
|
311
|
+
}
|
|
312
|
+
try {
|
|
313
|
+
await verifyEntryProofs({ ...frame, proof: checked }, {
|
|
314
|
+
verifier: defaultWebvhLogVerifier,
|
|
315
|
+
// Authorization is the allowlist check above, made before any
|
|
316
|
+
// cryptography runs; the key material resolves from the proof's own
|
|
317
|
+
// verification method, which that check has already pinned.
|
|
318
|
+
authorize: () => { },
|
|
319
|
+
resolveVM: async () => ({ publicKeyMultibase: keyMultibase })
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
catch (err) {
|
|
323
|
+
throw new RecordProofError(`The ${label} record's proof does not verify over its contents.`, { cause: err });
|
|
324
|
+
}
|
|
325
|
+
return keyMultibase;
|
|
106
326
|
}
|
|
107
327
|
/**
|
|
108
328
|
* Wraps the account-pointer contents into a keyring record: the controller,
|
|
109
329
|
* email, and pointer (+ timestamp) sealed under a freshly minted record epoch
|
|
110
|
-
* whose key is wrapped to the unlock KAK
|
|
111
|
-
* of any kind.
|
|
330
|
+
* whose key is wrapped to the unlock KAK, then signed by the unlock identity's
|
|
331
|
+
* signing key. Deliberately carries no key material of any kind.
|
|
332
|
+
*
|
|
333
|
+
* The timestamp stays inside the plaintext (the signature covers the
|
|
334
|
+
* ciphertext, so it is covered transitively), so bind times do not leak to a
|
|
335
|
+
* reader of the unlock Space.
|
|
112
336
|
*
|
|
113
337
|
* @param options {object}
|
|
114
338
|
* @param options.controller {string} the account did:key
|
|
@@ -117,10 +341,14 @@ export function parseRecordFrame({ record, label, version = KEYRING_RECORD_VERSI
|
|
|
117
341
|
* no-WAS deployments)
|
|
118
342
|
* @param options.keyAgreementKey {IKeyAgreementKey} the unlock KAK
|
|
119
343
|
* @param options.keyResolver {IKeyResolver}
|
|
120
|
-
* @
|
|
121
|
-
*
|
|
344
|
+
* @param options.signer {RecordSigner} the unlock identity's signing key
|
|
345
|
+
* (`recordSignerFromAgent` over the unlock agent)
|
|
346
|
+
* @param [options.createdAt] {string} the bind timestamp to stamp, as an ISO
|
|
347
|
+
* string; defaults to now. Supplied by a caller that pins record freshness,
|
|
348
|
+
* so it knows the stamp without unwrapping the record it just wrote.
|
|
349
|
+
* @returns {Promise<SignedRecord>}
|
|
122
350
|
*/
|
|
123
|
-
export async function wrapKeyringRecord({ controller, email, pointer, keyAgreementKey, keyResolver }) {
|
|
351
|
+
export async function wrapKeyringRecord({ controller, email, pointer, keyAgreementKey, keyResolver, signer, createdAt }) {
|
|
124
352
|
const encryption = await mintRecordEncryption({ keyAgreementKey });
|
|
125
353
|
const cipher = await recordCipher({
|
|
126
354
|
keyAgreementKey,
|
|
@@ -140,28 +368,45 @@ export async function wrapKeyringRecord({ controller, email, pointer, keyAgreeme
|
|
|
140
368
|
}
|
|
141
369
|
}
|
|
142
370
|
: {}),
|
|
143
|
-
createdAt:
|
|
371
|
+
createdAt: recordCreatedAtStamp({ createdAt })
|
|
144
372
|
}
|
|
145
373
|
});
|
|
146
|
-
return {
|
|
374
|
+
return signRecordFrame({
|
|
375
|
+
version: KEYRING_RECORD_VERSION,
|
|
376
|
+
encryption,
|
|
377
|
+
wrapped: envelope,
|
|
378
|
+
signer
|
|
379
|
+
});
|
|
147
380
|
}
|
|
148
381
|
/**
|
|
149
|
-
* Unwraps and validates a keyring record.
|
|
150
|
-
*
|
|
151
|
-
*
|
|
152
|
-
*
|
|
382
|
+
* Unwraps and validates a keyring record. Verifies the record's proof against
|
|
383
|
+
* the unlock identity's own signing key BEFORE decrypting -- there is no
|
|
384
|
+
* unwrap path that skips it, so a record the storage host substituted is
|
|
385
|
+
* refused ({@link RecordProofError}) rather than decrypted and inspected.
|
|
386
|
+
* Rejects a record whose `version` is not the current one (accounts are
|
|
387
|
+
* re-provisioned, not migrated), and sanity-checks the decrypted plaintext
|
|
388
|
+
* (non-empty controller, well-formed pointer when present, a parseable
|
|
389
|
+
* `createdAt`).
|
|
153
390
|
*
|
|
154
391
|
* @param options {object}
|
|
155
392
|
* @param options.record {unknown}
|
|
156
393
|
* @param options.keyAgreementKey {IKeyAgreementKey} the unlock KAK
|
|
157
394
|
* @param options.keyResolver {IKeyResolver}
|
|
395
|
+
* @param options.expectedKeyMultibase {string} the unlock identity's signing
|
|
396
|
+
* key multibase, derived from the typed secret -- the only key that may have
|
|
397
|
+
* signed this record
|
|
158
398
|
* @returns {Promise<KeyringRecordContents>}
|
|
159
399
|
*/
|
|
160
|
-
export async function unwrapKeyringRecord({ record, keyAgreementKey, keyResolver }) {
|
|
400
|
+
export async function unwrapKeyringRecord({ record, keyAgreementKey, keyResolver, expectedKeyMultibase }) {
|
|
161
401
|
const { encryption, wrapped } = parseRecordFrame({
|
|
162
402
|
record,
|
|
163
403
|
label: 'keyring'
|
|
164
404
|
});
|
|
405
|
+
await verifyRecordProof({
|
|
406
|
+
record,
|
|
407
|
+
allowedKeyMultibases: expectedKeyMultibase,
|
|
408
|
+
label: 'keyring'
|
|
409
|
+
});
|
|
165
410
|
const cipher = await recordCipher({
|
|
166
411
|
keyAgreementKey,
|
|
167
412
|
keyResolver,
|
|
@@ -174,8 +419,13 @@ export async function unwrapKeyringRecord({ record, keyAgreementKey, keyResolver
|
|
|
174
419
|
throw new Error('Keyring record is missing a controller.');
|
|
175
420
|
}
|
|
176
421
|
const pointer = parseRecordPointer(plaintext.pointer);
|
|
422
|
+
const createdAt = parseRecordCreatedAt({
|
|
423
|
+
value: plaintext.createdAt,
|
|
424
|
+
label: 'Keyring'
|
|
425
|
+
});
|
|
177
426
|
return {
|
|
178
427
|
controller: plaintext.controller,
|
|
428
|
+
createdAt,
|
|
179
429
|
// A record bound without an email simply has no email; anything
|
|
180
430
|
// non-string is ignored, not fatal.
|
|
181
431
|
...(typeof plaintext.email === 'string' && plaintext.email
|
|
@@ -184,6 +434,42 @@ export async function unwrapKeyringRecord({ record, keyAgreementKey, keyResolver
|
|
|
184
434
|
...(pointer ? { pointer } : {})
|
|
185
435
|
};
|
|
186
436
|
}
|
|
437
|
+
/**
|
|
438
|
+
* The bind timestamp a wrap path stamps into a record's plaintext: the
|
|
439
|
+
* caller's, validated as a parseable ISO timestamp, or now. A caller supplies
|
|
440
|
+
* one when it pins record freshness, so it knows the stamp of the record it is
|
|
441
|
+
* writing without reading it back.
|
|
442
|
+
*
|
|
443
|
+
* @param options {object}
|
|
444
|
+
* @param [options.createdAt] {string} the caller's timestamp
|
|
445
|
+
* @returns {string}
|
|
446
|
+
*/
|
|
447
|
+
export function recordCreatedAtStamp({ createdAt }) {
|
|
448
|
+
if (createdAt === undefined) {
|
|
449
|
+
return new Date().toISOString();
|
|
450
|
+
}
|
|
451
|
+
if (typeof createdAt !== 'string' || Number.isNaN(Date.parse(createdAt))) {
|
|
452
|
+
throw new Error(`Invalid record createdAt timestamp "${createdAt}".`);
|
|
453
|
+
}
|
|
454
|
+
return createdAt;
|
|
455
|
+
}
|
|
456
|
+
/**
|
|
457
|
+
* Parses and validates the required `createdAt` member of a record plaintext:
|
|
458
|
+
* the moment the record was bound, as an ISO timestamp that must parse. Apps
|
|
459
|
+
* pin freshness on it, so a record that cannot state its own bind time is
|
|
460
|
+
* refused rather than defaulted.
|
|
461
|
+
*
|
|
462
|
+
* @param options {object}
|
|
463
|
+
* @param options.value {unknown} the plaintext's `createdAt` member
|
|
464
|
+
* @param options.label {string} names the record kind in the refusal
|
|
465
|
+
* @returns {string}
|
|
466
|
+
*/
|
|
467
|
+
export function parseRecordCreatedAt({ value, label }) {
|
|
468
|
+
if (typeof value !== 'string' || Number.isNaN(Date.parse(value))) {
|
|
469
|
+
throw new Error(`${label} record has no valid createdAt timestamp.`);
|
|
470
|
+
}
|
|
471
|
+
return value;
|
|
472
|
+
}
|
|
187
473
|
/**
|
|
188
474
|
* Parses and validates the optional `pointer` member of a keyring record
|
|
189
475
|
* plaintext. An absent member is a no-WAS record (returns undefined); a
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"record.js","sourceRoot":"","sources":["../../src/keyring/record.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"record.js","sourceRoot":"","sources":["../../src/keyring/record.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,OAAO,EACL,gCAAgC,EAChC,uBAAuB,EACvB,sBAAsB,EACtB,qBAAqB,EACrB,iBAAiB,EAClB,MAAM,2BAA2B,CAAA;AAOlC,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,cAAc,EAGf,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAE5D;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAA;AAwCvC;;;;;;GAMG;AACH,MAAM,OAAO,gBAAiB,SAAQ,KAAK;IACzC,YAAY,OAAe,EAAE,OAA6B;QACxD,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;QACvB,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAA;IAChC,CAAC;CACF;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,qBAAqB,CAAC,EACpC,QAAQ,EAQT;IACC,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IAC7D,IAAI,MAAM,KAAK,KAAK,IAAI,MAAM,KAAK,KAAK,IAAI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AC,CAAC,EAAE,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAA;AACnD,CAAC"}
|
|
@@ -59,6 +59,31 @@ export declare function putUnlockKeyring({ storageServerUrl, zcapClient, spaceId
|
|
|
59
59
|
spaceId: string;
|
|
60
60
|
record: object;
|
|
61
61
|
}): Promise<void>;
|
|
62
|
+
/**
|
|
63
|
+
* Reads the keyring record with an explicitly attached management capability,
|
|
64
|
+
* rather than by root invocation, or returns `null` when it does not exist.
|
|
65
|
+
* The `zcapClient` here is an enrolled client's (not the unlock identity's);
|
|
66
|
+
* the attached `capability` -- the management zcap the unlock identity
|
|
67
|
+
* delegated at bind time, provided it allows GET -- authorizes the read
|
|
68
|
+
* against the unlock Space. This is what lets the revocation cascade's
|
|
69
|
+
* re-mint read a recovery code's standing record without holding the code:
|
|
70
|
+
* the record's code-authenticated binding rides the frame in the clear, so
|
|
71
|
+
* carrying it forward verbatim needs no decryption.
|
|
72
|
+
*
|
|
73
|
+
* @param options {object}
|
|
74
|
+
* @param options.storageServerUrl {string}
|
|
75
|
+
* @param options.zcapClient {ZcapClient} an enrolled client's zcap client
|
|
76
|
+
* @param options.spaceId {string} the unlock Space id
|
|
77
|
+
* @param options.capability {IZcap} the delegated management zcap (must
|
|
78
|
+
* allow GET)
|
|
79
|
+
* @returns {Promise<unknown | null>}
|
|
80
|
+
*/
|
|
81
|
+
export declare function getUnlockKeyringWithCapability({ storageServerUrl, zcapClient, spaceId, capability }: {
|
|
82
|
+
storageServerUrl: string;
|
|
83
|
+
zcapClient: ZcapClient;
|
|
84
|
+
spaceId: string;
|
|
85
|
+
capability: IZcap;
|
|
86
|
+
}): Promise<unknown | null>;
|
|
62
87
|
/**
|
|
63
88
|
* Writes (upserts) the keyring record with an explicitly attached management
|
|
64
89
|
* capability, rather than by root invocation. The `zcapClient` here is an
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unlockSpace.d.ts","sourceRoot":"","sources":["../../src/keyring/unlockSpace.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"unlockSpace.d.ts","sourceRoot":"","sources":["../../src/keyring/unlockSpace.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAA;AACzD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAGhD;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,uBAAuB,CAAA;AAoIrD;;;;;;;;;;;;;GAaG;AACH,wBAAsB,iBAAiB,CAAC,EACtC,gBAAgB,EAChB,UAAU,EACV,OAAO,EACP,UAAU,EACV,IAAwB,EACzB,EAAE;IACD,gBAAgB,EAAE,MAAM,CAAA;IACxB,UAAU,EAAE,UAAU,CAAA;IACtB,OAAO,EAAE,MAAM,CAAA;IACf,UAAU,EAAE,MAAM,CAAA;IAClB,IAAI,CAAC,EAAE,MAAM,CAAA;CACd,GAAG,OAAO,CAAC,IAAI,CAAC,CAUhB;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,gBAAgB,CAAC,EACrC,gBAAgB,EAChB,UAAU,EACV,OAAO,EACR,EAAE;IACD,gBAAgB,EAAE,MAAM,CAAA;IACxB,UAAU,EAAE,UAAU,CAAA;IACtB,OAAO,EAAE,MAAM,CAAA;CAChB,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CAQ1B;AAED;;;;;;;;;GASG;AACH,wBAAsB,gBAAgB,CAAC,EACrC,gBAAgB,EAChB,UAAU,EACV,OAAO,EACP,MAAM,EACP,EAAE;IACD,gBAAgB,EAAE,MAAM,CAAA;IACxB,UAAU,EAAE,UAAU,CAAA;IACtB,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,EAAE,MAAM,CAAA;CACf,GAAG,OAAO,CAAC,IAAI,CAAC,CAShB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,8BAA8B,CAAC,EACnD,gBAAgB,EAChB,UAAU,EACV,OAAO,EACP,UAAU,EACX,EAAE;IACD,gBAAgB,EAAE,MAAM,CAAA;IACxB,UAAU,EAAE,UAAU,CAAA;IACtB,OAAO,EAAE,MAAM,CAAA;IACf,UAAU,EAAE,KAAK,CAAA;CAClB,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CAQ1B;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,8BAA8B,CAAC,EACnD,gBAAgB,EAChB,UAAU,EACV,OAAO,EACP,MAAM,EACN,UAAU,EACX,EAAE;IACD,gBAAgB,EAAE,MAAM,CAAA;IACxB,UAAU,EAAE,UAAU,CAAA;IACtB,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,EAAE,MAAM,CAAA;IACd,UAAU,EAAE,KAAK,CAAA;CAClB,GAAG,OAAO,CAAC,IAAI,CAAC,CAUhB;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,iBAAiB,CAAC,EACtC,gBAAgB,EAChB,UAAU,EACV,OAAO,EACR,EAAE;IACD,gBAAgB,EAAE,MAAM,CAAA;IACxB,UAAU,EAAE,UAAU,CAAA;IACtB,OAAO,EAAE,MAAM,CAAA;CAChB,GAAG,OAAO,CAAC,IAAI,CAAC,CAGhB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,+BAA+B,CAAC,EACpD,gBAAgB,EAChB,UAAU,EACV,OAAO,EACP,UAAU,EACX,EAAE;IACD,gBAAgB,EAAE,MAAM,CAAA;IACxB,UAAU,EAAE,UAAU,CAAA;IACtB,OAAO,EAAE,MAAM,CAAA;IACf,UAAU,EAAE,KAAK,CAAA;CAClB,GAAG,OAAO,CAAC,IAAI,CAAC,CAchB"}
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
* surfacing the miss as a 404-shaped `null`.
|
|
21
21
|
*/
|
|
22
22
|
import { WasClient } from '@interop/was-client';
|
|
23
|
+
import { resourcePath, spacePath } from '@interop/was-client/paths';
|
|
23
24
|
import { errorStatus } from '@interop/was-client/sync';
|
|
24
25
|
import { KEYRING_COLLECTION, KEYRING_RESOURCE } from '../space/collections.js';
|
|
25
26
|
/**
|
|
@@ -175,6 +176,34 @@ export async function putUnlockKeyring({ storageServerUrl, zcapClient, spaceId,
|
|
|
175
176
|
record
|
|
176
177
|
});
|
|
177
178
|
}
|
|
179
|
+
/**
|
|
180
|
+
* Reads the keyring record with an explicitly attached management capability,
|
|
181
|
+
* rather than by root invocation, or returns `null` when it does not exist.
|
|
182
|
+
* The `zcapClient` here is an enrolled client's (not the unlock identity's);
|
|
183
|
+
* the attached `capability` -- the management zcap the unlock identity
|
|
184
|
+
* delegated at bind time, provided it allows GET -- authorizes the read
|
|
185
|
+
* against the unlock Space. This is what lets the revocation cascade's
|
|
186
|
+
* re-mint read a recovery code's standing record without holding the code:
|
|
187
|
+
* the record's code-authenticated binding rides the frame in the clear, so
|
|
188
|
+
* carrying it forward verbatim needs no decryption.
|
|
189
|
+
*
|
|
190
|
+
* @param options {object}
|
|
191
|
+
* @param options.storageServerUrl {string}
|
|
192
|
+
* @param options.zcapClient {ZcapClient} an enrolled client's zcap client
|
|
193
|
+
* @param options.spaceId {string} the unlock Space id
|
|
194
|
+
* @param options.capability {IZcap} the delegated management zcap (must
|
|
195
|
+
* allow GET)
|
|
196
|
+
* @returns {Promise<unknown | null>}
|
|
197
|
+
*/
|
|
198
|
+
export async function getUnlockKeyringWithCapability({ storageServerUrl, zcapClient, spaceId, capability }) {
|
|
199
|
+
const was = unlockSpaceClient({ storageServerUrl, zcapClient });
|
|
200
|
+
const result = await was
|
|
201
|
+
.space(spaceId)
|
|
202
|
+
.collection(KEYRING_COLLECTION.id, { capability, encryption: 'plaintext' })
|
|
203
|
+
.resource(KEYRING_RESOURCE)
|
|
204
|
+
.get();
|
|
205
|
+
return result === null ? null : result;
|
|
206
|
+
}
|
|
178
207
|
/**
|
|
179
208
|
* Writes (upserts) the keyring record with an explicitly attached management
|
|
180
209
|
* capability, rather than by root invocation. The `zcapClient` here is an
|
|
@@ -200,7 +229,7 @@ export async function putUnlockKeyringWithCapability({ storageServerUrl, zcapCli
|
|
|
200
229
|
const body = new TextEncoder().encode(JSON.stringify(record));
|
|
201
230
|
await was.request({
|
|
202
231
|
capability,
|
|
203
|
-
path:
|
|
232
|
+
path: resourcePath(spaceId, KEYRING_COLLECTION.id, KEYRING_RESOURCE),
|
|
204
233
|
method: 'PUT',
|
|
205
234
|
headers: { 'content-type': 'application/json' },
|
|
206
235
|
body
|
|
@@ -243,7 +272,7 @@ export async function deleteUnlockSpaceWithCapability({ storageServerUrl, zcapCl
|
|
|
243
272
|
try {
|
|
244
273
|
await was.request({
|
|
245
274
|
capability,
|
|
246
|
-
path:
|
|
275
|
+
path: spacePath(spaceId),
|
|
247
276
|
method: 'DELETE'
|
|
248
277
|
});
|
|
249
278
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unlockSpace.js","sourceRoot":"","sources":["../../src/keyring/unlockSpace.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AAGtD,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAE9E;;;;GAIG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,oBAAoB,CAAA;AAErD;;;;;;;;GAQG;AACH,SAAS,iBAAiB,CAAC,EACzB,gBAAgB,EAChB,UAAU,EAIX;IACC,OAAO,IAAI,SAAS,CAAC;QACnB,SAAS,EAAE,gBAAgB;QAC3B,UAAU;KACX,CAAC,CAAA;AACJ,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,KAAK,UAAU,yBAAyB,CAAC,EACvC,gBAAgB,EAChB,UAAU,EACV,OAAO,EACP,YAAY,EACZ,IAAI,EAOL;IACC,MAAM,GAAG,GAAG,iBAAiB,CAAC,EAAE,gBAAgB,EAAE,UAAU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,GAAG,iCAAiC,
|
|
1
|
+
{"version":3,"file":"rosterLogStore.d.ts","sourceRoot":"","sources":["../../src/keys/rosterLogStore.ts"],"names":[],"mappings":"AA4BA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAA;AACxE,OAAO,EAGL,KAAK,gBAAgB,EACtB,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAQL,KAAK,qBAAqB,EAC1B,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EAEvB,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAAE,8BAA8B,EAAE,MAAM,6BAA6B,CAAA;AAE5E,OAAO,EAAE,8BAA8B,EAAE,CAAA;AAEzC;;;;;;;;GAQG;AACH,MAAM,WAAW,iCAAkC,SAAQ,yBAAyB;IAClF,IAAI,IAAI,OAAO,CAAC,QAAQ,GAAG,MAAM,CAAC,CAAA;CACnC;AAED;;;;;;;;GAQG;AACH,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,yBAAyB,GAC/B,KAAK,IAAI,iCAAiC,CAK5C;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,0BAA0B,CAAC,EACzC,GAAG,EACH,iBAAiB,EACjB,QAAQ,EACR,MAAM,EACP,EAAE;IACD,GAAG,EAAE,gBAAgB,CAAA;IACrB,iBAAiB,EAAE,MAAM,OAAO,CAAC,qBAAqB,CAAC,CAAA;IACvD,QAAQ,EAAE,mBAAmB,CAAA;IAC7B,MAAM,EAAE,iBAAiB,CAAA;CAC1B,GAAG,iCAAiC,CAyHpC"}
|
|
@@ -117,12 +117,17 @@ export function logGovernedDescriptorStore({ log, resolveController, pinStore, s
|
|
|
117
117
|
},
|
|
118
118
|
async seal() {
|
|
119
119
|
const controller = await resolveController();
|
|
120
|
+
// Reuse the log view the most recent read or confirmed append on this
|
|
121
|
+
// store instance verified: a rotation that just appended anchors past
|
|
122
|
+
// the removal, so the sweep resolves noop with no re-fetch, and a stale
|
|
123
|
+
// view is safe (sealResourceLog's append path re-reads before writing).
|
|
120
124
|
const { sealed, verified } = await sealResourceLog({
|
|
121
125
|
store: log,
|
|
122
126
|
controller,
|
|
123
127
|
expectedMethod: RESOURCE_LOG_METHOD,
|
|
124
128
|
pinStore,
|
|
125
|
-
signer
|
|
129
|
+
signer,
|
|
130
|
+
...(lastVerified === null ? {} : { verified: lastVerified })
|
|
126
131
|
});
|
|
127
132
|
if (verified !== null) {
|
|
128
133
|
lastVerified = verified;
|