@interop/wallet-core 0.41.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 -4
- 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.map +1 -1
- package/dist/enrollment/enrollment.js +14 -26
- package/dist/enrollment/enrollment.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 +1 -1
- package/dist/keyring/index.d.ts.map +1 -1
- package/dist/keyring/index.js +1 -1
- 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/keys/index.d.ts +1 -1
- package/dist/keys/index.d.ts.map +1 -1
- package/dist/keys/index.js +1 -1
- package/dist/keys/index.js.map +1 -1
- package/dist/keys/rosterLogStore.d.ts +4 -1
- package/dist/keys/rosterLogStore.d.ts.map +1 -1
- package/dist/keys/rosterLogStore.js +13 -16
- 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/userKeyRoster.d.ts +17 -5
- package/dist/keys/userKeyRoster.d.ts.map +1 -1
- package/dist/keys/userKeyRoster.js +38 -13
- package/dist/keys/userKeyRoster.js.map +1 -1
- package/dist/recovery/index.d.ts +14 -12
- package/dist/recovery/index.d.ts.map +1 -1
- package/dist/recovery/index.js +13 -11
- 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 +50 -19
- package/dist/recovery/recoveryDelegation.d.ts.map +1 -1
- package/dist/recovery/recoveryDelegation.js +86 -41
- package/dist/recovery/recoveryDelegation.js.map +1 -1
- package/dist/recovery/recoveryWebvh.d.ts +13 -22
- package/dist/recovery/recoveryWebvh.d.ts.map +1 -1
- package/dist/recovery/recoveryWebvh.js +37 -129
- 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 +94 -6
- package/dist/webvh/didWebvh.d.ts.map +1 -1
- package/dist/webvh/didWebvh.js +175 -19
- package/dist/webvh/didWebvh.js.map +1 -1
- package/dist/webvh/index.d.ts +7 -2
- package/dist/webvh/index.d.ts.map +1 -1
- package/dist/webvh/index.js +7 -2
- package/dist/webvh/index.js.map +1 -1
- package/dist/webvh/keyAgreement.d.ts +22 -6
- package/dist/webvh/keyAgreement.d.ts.map +1 -1
- package/dist/webvh/keyAgreement.js +1 -1
- package/dist/webvh/keyAgreement.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 -172
- package/dist/recovery/recoveryRecord.d.ts.map +0 -1
- package/dist/recovery/recoveryRecord.js +0 -288
- package/dist/recovery/recoveryRecord.js.map +0 -1
package/dist/recovery/index.d.ts
CHANGED
|
@@ -12,16 +12,18 @@
|
|
|
12
12
|
* - `recoveryClientFromCode` -- the deterministic client key set:
|
|
13
13
|
* unlock identity, client seed (signing + key-agreement pair), and the
|
|
14
14
|
* single did:webvh update key whose hash stands pre-committed.
|
|
15
|
-
* -
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* so a storage host can never redirect recovery at
|
|
15
|
+
* - The record codec lives in `@interop/wallet-core/unlock` now
|
|
16
|
+
* (`wrapUnlockRecord` / `unwrapUnlockRecord`, re-exported here): a
|
|
17
|
+
* recovery record is an unlock record with no ladder member -- the account
|
|
18
|
+
* pointer plus the pre-minted PUT-on-`did.jsonl` bridge delegation (never
|
|
19
|
+
* a seed, never a user key wrap), signed under the mixed-signer policy
|
|
20
|
+
* (the code's unlock key at issuance, an enrolled client's account key on
|
|
21
|
+
* a re-mint), with the account core authenticated by a MAC under a
|
|
22
|
+
* code-derived key, so a storage host can never redirect recovery at
|
|
23
|
+
* another account.
|
|
23
24
|
* - `publishRecoveryKey` / `removeRecoveryKey` / `recoverWebvhClient` -- the
|
|
24
|
-
* document half: issuance's split posture
|
|
25
|
+
* document half: issuance's split posture and revocation's removal (thin
|
|
26
|
+
* wrappers over the unlock subpath's merged posture core), and the
|
|
25
27
|
* self-enrolling recovery continuation.
|
|
26
28
|
* - `delegateLogWrite` / `delegationProofKeyId` /
|
|
27
29
|
* `remintRecoveryDelegations` -- the authorization bridge: the pre-minted
|
|
@@ -35,9 +37,9 @@
|
|
|
35
37
|
*/
|
|
36
38
|
export { decodeRecoveryCode, formatRecoveryCode, generateRecoveryCode, normalizeRecoveryCode, RECOVERY_CODE_BYTES, RECOVERY_KDF, RecoveryCodeInvalidError, recoveryClientFromCode } from './recoveryCode.js';
|
|
37
39
|
export type { RecoveryClient } from './recoveryCode.js';
|
|
38
|
-
export {
|
|
39
|
-
export type {
|
|
40
|
-
export { delegateLogWrite, delegationProofKeyId, RECOVERY_DELEGATION_TTL_MS, remintRecoveryDelegations } from './recoveryDelegation.js';
|
|
40
|
+
export { computeUnlockBinding, remintUnlockRecordBridge, UnlockBindingError, unlockRecordBinding, unwrapUnlockRecord, wrapUnlockRecord } from '../unlock/unlockRecord.js';
|
|
41
|
+
export type { SignedUnlockRecord, UnlockRecordContents, UnlockRecordProofState } from '../unlock/unlockRecord.js';
|
|
42
|
+
export { delegateLogWrite, delegationProofKeyId, RECOVERY_DELEGATION_TTL_MS, remintRecoveryDelegations, ZCAP_RENEWAL_WINDOW_MS, zcapExpiring } from './recoveryDelegation.js';
|
|
41
43
|
export type { RecoveryDelegationEntry } from './recoveryDelegation.js';
|
|
42
44
|
export { publishRecoveryKey, recoverWebvhClient, RecoveryKeyNotCommittedError, recoveryVmId, removeRecoveryKey } from './recoveryWebvh.js';
|
|
43
45
|
export type { RecoveryLogStore, RecoveryPublicKeys } from './recoveryWebvh.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/recovery/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/recovery/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,oBAAoB,EACpB,qBAAqB,EACrB,mBAAmB,EACnB,YAAY,EACZ,wBAAwB,EACxB,sBAAsB,EACvB,MAAM,mBAAmB,CAAA;AAC1B,YAAY,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAEvD,OAAO,EACL,oBAAoB,EACpB,wBAAwB,EACxB,kBAAkB,EAClB,mBAAmB,EACnB,kBAAkB,EAClB,gBAAgB,EACjB,MAAM,2BAA2B,CAAA;AAClC,YAAY,EACV,kBAAkB,EAClB,oBAAoB,EACpB,sBAAsB,EACvB,MAAM,2BAA2B,CAAA;AAElC,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,0BAA0B,EAC1B,yBAAyB,EACzB,sBAAsB,EACtB,YAAY,EACb,MAAM,yBAAyB,CAAA;AAChC,YAAY,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAA;AAEtE,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,4BAA4B,EAC5B,YAAY,EACZ,iBAAiB,EAClB,MAAM,oBAAoB,CAAA;AAC3B,YAAY,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAA"}
|
package/dist/recovery/index.js
CHANGED
|
@@ -12,16 +12,18 @@
|
|
|
12
12
|
* - `recoveryClientFromCode` -- the deterministic client key set:
|
|
13
13
|
* unlock identity, client seed (signing + key-agreement pair), and the
|
|
14
14
|
* single did:webvh update key whose hash stands pre-committed.
|
|
15
|
-
* -
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* so a storage host can never redirect recovery at
|
|
15
|
+
* - The record codec lives in `@interop/wallet-core/unlock` now
|
|
16
|
+
* (`wrapUnlockRecord` / `unwrapUnlockRecord`, re-exported here): a
|
|
17
|
+
* recovery record is an unlock record with no ladder member -- the account
|
|
18
|
+
* pointer plus the pre-minted PUT-on-`did.jsonl` bridge delegation (never
|
|
19
|
+
* a seed, never a user key wrap), signed under the mixed-signer policy
|
|
20
|
+
* (the code's unlock key at issuance, an enrolled client's account key on
|
|
21
|
+
* a re-mint), with the account core authenticated by a MAC under a
|
|
22
|
+
* code-derived key, so a storage host can never redirect recovery at
|
|
23
|
+
* another account.
|
|
23
24
|
* - `publishRecoveryKey` / `removeRecoveryKey` / `recoverWebvhClient` -- the
|
|
24
|
-
* document half: issuance's split posture
|
|
25
|
+
* document half: issuance's split posture and revocation's removal (thin
|
|
26
|
+
* wrappers over the unlock subpath's merged posture core), and the
|
|
25
27
|
* self-enrolling recovery continuation.
|
|
26
28
|
* - `delegateLogWrite` / `delegationProofKeyId` /
|
|
27
29
|
* `remintRecoveryDelegations` -- the authorization bridge: the pre-minted
|
|
@@ -34,7 +36,7 @@
|
|
|
34
36
|
* was-client dependency graph (the same isolation pattern as `./keyring`).
|
|
35
37
|
*/
|
|
36
38
|
export { decodeRecoveryCode, formatRecoveryCode, generateRecoveryCode, normalizeRecoveryCode, RECOVERY_CODE_BYTES, RECOVERY_KDF, RecoveryCodeInvalidError, recoveryClientFromCode } from './recoveryCode.js';
|
|
37
|
-
export {
|
|
38
|
-
export { delegateLogWrite, delegationProofKeyId, RECOVERY_DELEGATION_TTL_MS, remintRecoveryDelegations } from './recoveryDelegation.js';
|
|
39
|
+
export { computeUnlockBinding, remintUnlockRecordBridge, UnlockBindingError, unlockRecordBinding, unwrapUnlockRecord, wrapUnlockRecord } from '../unlock/unlockRecord.js';
|
|
40
|
+
export { delegateLogWrite, delegationProofKeyId, RECOVERY_DELEGATION_TTL_MS, remintRecoveryDelegations, ZCAP_RENEWAL_WINDOW_MS, zcapExpiring } from './recoveryDelegation.js';
|
|
39
41
|
export { publishRecoveryKey, recoverWebvhClient, RecoveryKeyNotCommittedError, recoveryVmId, removeRecoveryKey } from './recoveryWebvh.js';
|
|
40
42
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/recovery/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/recovery/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,oBAAoB,EACpB,qBAAqB,EACrB,mBAAmB,EACnB,YAAY,EACZ,wBAAwB,EACxB,sBAAsB,EACvB,MAAM,mBAAmB,CAAA;AAG1B,OAAO,EACL,oBAAoB,EACpB,wBAAwB,EACxB,kBAAkB,EAClB,mBAAmB,EACnB,kBAAkB,EAClB,gBAAgB,EACjB,MAAM,2BAA2B,CAAA;AAOlC,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,0BAA0B,EAC1B,yBAAyB,EACzB,sBAAsB,EACtB,YAAY,EACb,MAAM,yBAAyB,CAAA;AAGhC,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,4BAA4B,EAC5B,YAAY,EACZ,iBAAiB,EAClB,MAAM,oBAAoB,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ProfileAgents } from '../identity/agents.js';
|
|
2
1
|
import type { UnlockKdf } from '../keyring/kdf.js';
|
|
2
|
+
import type { UnlockClientIdentity } from '../unlock/standingClient.js';
|
|
3
3
|
/**
|
|
4
4
|
* The byte length of a recovery code: 16 random bytes is ~128 bits, enough
|
|
5
5
|
* that the unlock derivation is a single expansion rather than a stretched
|
|
@@ -73,28 +73,16 @@ export declare function decodeRecoveryCode({ code }: {
|
|
|
73
73
|
* agents, and the public multibases / ids the issuance and recovery flows
|
|
74
74
|
* publish and look up.
|
|
75
75
|
*/
|
|
76
|
-
export interface RecoveryClient {
|
|
76
|
+
export interface RecoveryClient extends UnlockClientIdentity {
|
|
77
77
|
codeBytes: Uint8Array;
|
|
78
|
-
clientSeed: Uint8Array;
|
|
79
78
|
updateSeed: Uint8Array;
|
|
80
79
|
/**
|
|
81
|
-
* The symmetric key that MACs the recovery record's account binding
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
* storage host never holds it.
|
|
80
|
+
* The symmetric key that MACs the recovery record's account binding:
|
|
81
|
+
* computed at issuance, verified at recovery before the pointer is trusted.
|
|
82
|
+
* Derived from the code bytes, so the storage host never holds it.
|
|
85
83
|
*/
|
|
86
84
|
bindingMacKey: Uint8Array;
|
|
87
|
-
agents: ProfileAgents;
|
|
88
|
-
clientDid: string;
|
|
89
|
-
signingKeyMultibase: string;
|
|
90
|
-
keyAgreementKeyMultibase: string;
|
|
91
85
|
updateKeyMultibase: string;
|
|
92
|
-
/**
|
|
93
|
-
* The kid of the code's user-key-roster entry -- its key-agreement key's id
|
|
94
|
-
* exactly as `agentsFromSeed` derives it (`did:key:<ed>#<x>`), so the wrap
|
|
95
|
-
* minted at issuance is the one the recovery flow's roster read looks for.
|
|
96
|
-
*/
|
|
97
|
-
recipientKid: string;
|
|
98
86
|
}
|
|
99
87
|
/**
|
|
100
88
|
* Derives the code's whole client identity from a (possibly formatted) code.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recoveryCode.d.ts","sourceRoot":"","sources":["../../src/recovery/recoveryCode.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"recoveryCode.d.ts","sourceRoot":"","sources":["../../src/recovery/recoveryCode.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAElD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAA;AAGvE;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,KAAK,CAAA;AAErC;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,EAAE,SAM1B,CAAA;AAoBD;;;;;;GAMG;AACH,qBAAa,wBAAyB,SAAQ,KAAK;gBACrC,OAAO,SAAuC;CAI3D;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,CAI7C;AAED;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,EAAE,IAAI,EAAE,EAAE;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAErE;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,EAAE,KAAK,EAAE,EAAE;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAE1E;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,EAAE,IAAI,EAAE,EAAE;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,UAAU,CAazE;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,cAAe,SAAQ,oBAAoB;IAC1D,SAAS,EAAE,UAAU,CAAA;IACrB,UAAU,EAAE,UAAU,CAAA;IACtB;;;;OAIG;IACH,aAAa,EAAE,UAAU,CAAA;IACzB,kBAAkB,EAAE,MAAM,CAAA;CAC3B;AAED;;;;;;;;;GASG;AACH,wBAAsB,sBAAsB,CAAC,EAC3C,IAAI,EACL,EAAE;IACD,IAAI,EAAE,MAAM,CAAA;CACb,GAAG,OAAO,CAAC,cAAc,CAAC,CAgC1B"}
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
import { base58 } from '@scure/base';
|
|
21
21
|
import { hkdf } from '@noble/hashes/hkdf.js';
|
|
22
22
|
import { sha256 } from '@noble/hashes/sha2.js';
|
|
23
|
-
import {
|
|
23
|
+
import { unlockClientIdentityFromSeed } from '../unlock/standingClient.js';
|
|
24
24
|
import { updateKeyMultibase } from '../webvh/didWebvh.js';
|
|
25
25
|
/**
|
|
26
26
|
* The byte length of a recovery code: 16 random bytes is ~128 bits, enough
|
|
@@ -143,23 +143,13 @@ export async function recoveryClientFromCode({ code }) {
|
|
|
143
143
|
const clientSeed = hkdf(sha256, codeBytes, salt, new TextEncoder().encode(RECOVERY_CLIENT_SEED_INFO), 32);
|
|
144
144
|
const updateSeed = hkdf(sha256, codeBytes, salt, new TextEncoder().encode(RECOVERY_UPDATE_SEED_INFO), 32);
|
|
145
145
|
const bindingMacKey = hkdf(sha256, codeBytes, new TextEncoder().encode(RECOVERY_KDF.salt), new TextEncoder().encode(RECOVERY_BINDING_MAC_INFO), 32);
|
|
146
|
-
const
|
|
147
|
-
const { publicKeyMultibase: keyAgreementKeyMultibase } = agents.keyAgreementKey;
|
|
148
|
-
if (!keyAgreementKeyMultibase) {
|
|
149
|
-
throw new Error('The derived key-agreement key has no public multibase.');
|
|
150
|
-
}
|
|
151
|
-
const [, , signingKeyMultibase] = agents.keyAgent.id.split(':');
|
|
146
|
+
const identity = await unlockClientIdentityFromSeed({ clientSeed });
|
|
152
147
|
return {
|
|
148
|
+
...identity,
|
|
153
149
|
codeBytes,
|
|
154
|
-
clientSeed,
|
|
155
150
|
updateSeed,
|
|
156
151
|
bindingMacKey,
|
|
157
|
-
|
|
158
|
-
clientDid: agents.keyAgent.id,
|
|
159
|
-
signingKeyMultibase: signingKeyMultibase,
|
|
160
|
-
keyAgreementKeyMultibase,
|
|
161
|
-
updateKeyMultibase: await updateKeyMultibase({ seed: updateSeed }),
|
|
162
|
-
recipientKid: `${agents.keyAgent.id}#${keyAgreementKeyMultibase}`
|
|
152
|
+
updateKeyMultibase: await updateKeyMultibase({ seed: updateSeed })
|
|
163
153
|
};
|
|
164
154
|
}
|
|
165
155
|
//# sourceMappingURL=recoveryCode.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recoveryCode.js","sourceRoot":"","sources":["../../src/recovery/recoveryCode.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAA;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;
|
|
1
|
+
{"version":3,"file":"recoveryCode.js","sourceRoot":"","sources":["../../src/recovery/recoveryCode.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAA;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AAE9C,OAAO,EAAE,4BAA4B,EAAE,MAAM,6BAA6B,CAAA;AAE1E,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CA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X,SAAS;QACT,UAAU;QACV,aAAa;QACb,kBAAkB,EAAE,MAAM,kBAAkB,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC;KACnE,CAAA;AACH,CAAC"}
|
|
@@ -3,15 +3,45 @@ import type { ZcapClient } from '@interop/ezcap';
|
|
|
3
3
|
import type { PublishedKeyDocument } from '../webvh/listClients.js';
|
|
4
4
|
import type { AccountPointer, RecordSigner } from '../keyring/record.js';
|
|
5
5
|
/**
|
|
6
|
-
* The recovery delegation's lifetime:
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* write that still has to verify
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
6
|
+
* The recovery delegation's lifetime: one year, following NIST SP 800-57's
|
|
7
|
+
* one-to-two-year cryptoperiod guidance for private signature keys. The
|
|
8
|
+
* delegation's scope stays narrow (PUT on the one world-readable DID log
|
|
9
|
+
* resource, whose worst-case abuse is a log write that still has to verify
|
|
10
|
+
* against the published hash chain and prerotation commitments to resolve),
|
|
11
|
+
* but a standing bearer artifact should not outlive its signing key's
|
|
12
|
+
* recommended cryptoperiod. A code must keep working past the year, so
|
|
13
|
+
* expiry is watched rather than terminal: the registry entry records the
|
|
14
|
+
* delegation's `expires`, {@link zcapExpiring} treats the
|
|
15
|
+
* renewal window before it as stale, the re-mint refreshes a stale
|
|
16
|
+
* delegation, and the login-time recovery health check flags one the same
|
|
17
|
+
* way it flags rot (the signing client's verification method leaving the
|
|
18
|
+
* document).
|
|
13
19
|
*/
|
|
14
20
|
export declare const RECOVERY_DELEGATION_TTL_MS: number;
|
|
21
|
+
/**
|
|
22
|
+
* How long before its `expires` a standing recorded zcap counts as stale:
|
|
23
|
+
* thirty days, so a refresh (a re-mint, a login-time re-delegation) or a
|
|
24
|
+
* regenerate nudge lands well before the zcap actually lapses.
|
|
25
|
+
*/
|
|
26
|
+
export declare const ZCAP_RENEWAL_WINDOW_MS: number;
|
|
27
|
+
/**
|
|
28
|
+
* Whether a recorded zcap expiry is past or inside the renewal window -- the
|
|
29
|
+
* expiry half of the staleness predicate for every long-lived zcap a wallet
|
|
30
|
+
* records beside its registry entries (the recovery `did.jsonl` delegation,
|
|
31
|
+
* an unlock Space's management zcap). The re-mint and the wallets'
|
|
32
|
+
* login-time checks all ask this one predicate. A record carrying no expiry
|
|
33
|
+
* (or an unparseable one) is uncheckable and therefore not assumed healthy,
|
|
34
|
+
* matching the rot check's treatment of a missing `delegationKeyId`.
|
|
35
|
+
*
|
|
36
|
+
* @param options {object}
|
|
37
|
+
* @param [options.expires] {string} the recorded ISO 8601 expiry
|
|
38
|
+
* @param [options.now] {number} epoch milliseconds, for tests
|
|
39
|
+
* @returns {boolean}
|
|
40
|
+
*/
|
|
41
|
+
export declare function zcapExpiring({ expires, now }: {
|
|
42
|
+
expires?: string;
|
|
43
|
+
now?: number;
|
|
44
|
+
}): boolean;
|
|
15
45
|
/**
|
|
16
46
|
* Delegates the narrow log-write bridge to a code-derived client: PUT on the
|
|
17
47
|
* one `did.jsonl` resource, {@link RECOVERY_DELEGATION_TTL_MS} lifetime. The
|
|
@@ -42,8 +72,9 @@ export declare function delegationProofKeyId(delegation: IZcap): string | undefi
|
|
|
42
72
|
/**
|
|
43
73
|
* The members of a recovery-code registry entry the re-mint reads: where the
|
|
44
74
|
* code's unlock Space and record are (`unlockSpaceId`, `manageCapability`),
|
|
45
|
-
* which key signed the recorded delegation
|
|
46
|
-
*
|
|
75
|
+
* which key signed the recorded delegation and when it expires
|
|
76
|
+
* (`delegationKeyId` / `delegationExpires` -- either absent on an entry
|
|
77
|
+
* predating its field, which the staleness checks conservatively flag), and
|
|
47
78
|
* the re-mint fields: the code-derived signing DID the fresh delegation names
|
|
48
79
|
* and the unlock KAK public half the record is re-wrapped to. Structural on
|
|
49
80
|
* purpose -- an app's richer registry entry satisfies it, and the re-mint
|
|
@@ -55,6 +86,7 @@ export interface RecoveryDelegationEntry {
|
|
|
55
86
|
unlockSpaceId: string;
|
|
56
87
|
manageCapability?: IZcap;
|
|
57
88
|
delegationKeyId?: string;
|
|
89
|
+
delegationExpires?: string;
|
|
58
90
|
recoveryClientDid?: string;
|
|
59
91
|
unlockKeyAgreementKeyId?: string;
|
|
60
92
|
unlockKeyAgreementKeyMultibase?: string;
|
|
@@ -64,13 +96,15 @@ export interface RecoveryDelegationEntry {
|
|
|
64
96
|
* the recovery-code delta riding the revocation cascade (see the module doc
|
|
65
97
|
* for the mechanism and the skip policy).
|
|
66
98
|
*
|
|
67
|
-
* The record's
|
|
99
|
+
* The record's credential-authenticated core is preserved verbatim: the
|
|
68
100
|
* re-mint reads the standing record through the entry's management zcap and
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
101
|
+
* replaces only its bridge member ({@link remintUnlockRecordBridge}) -- the
|
|
102
|
+
* shell, the ladder member (where one rides), and the binding tag all travel
|
|
103
|
+
* untouched, since the re-mint can decrypt none of them and does not need to.
|
|
104
|
+
* A re-mint therefore can never change the pointer or controller the
|
|
105
|
+
* credential was bound against -- and after a host migration the tag no
|
|
106
|
+
* longer matches the moved pointer, so credentials must be rebound (codes
|
|
107
|
+
* re-issued) when the account moves hosts.
|
|
74
108
|
*
|
|
75
109
|
* The re-mint holds the code's KAK public half but not its signing key, so
|
|
76
110
|
* every record it re-PUTs is signed with the acting client's own account key
|
|
@@ -86,8 +120,6 @@ export interface RecoveryDelegationEntry {
|
|
|
86
120
|
* @param options.entries {RecoveryDelegationEntry[]} the registry's
|
|
87
121
|
* recovery-code entries, as the app's registry read returned them
|
|
88
122
|
* @param options.pointer {AccountPointer}
|
|
89
|
-
* @param options.controller {string} the account controller to stamp into
|
|
90
|
-
* re-wrapped records (an identity label, as at issuance)
|
|
91
123
|
* @param options.storageServerUrl {string} the unlock Spaces' storage server
|
|
92
124
|
* @param options.zcapClient {ZcapClient} the acting client's promoted
|
|
93
125
|
* signer, which mints the fresh delegations
|
|
@@ -99,11 +131,10 @@ export interface RecoveryDelegationEntry {
|
|
|
99
131
|
* persists one updated registry entry (matching on the app's entry key)
|
|
100
132
|
* @returns {Promise<{ reminted: number; skipped: number }>}
|
|
101
133
|
*/
|
|
102
|
-
export declare function remintRecoveryDelegations<Entry extends RecoveryDelegationEntry>({ doc, entries, pointer,
|
|
134
|
+
export declare function remintRecoveryDelegations<Entry extends RecoveryDelegationEntry>({ doc, entries, pointer, storageServerUrl, zcapClient, recordSigner, managementZcapClient, recordEntry }: {
|
|
103
135
|
doc: PublishedKeyDocument;
|
|
104
136
|
entries: Entry[];
|
|
105
137
|
pointer: AccountPointer;
|
|
106
|
-
controller: string;
|
|
107
138
|
storageServerUrl: string;
|
|
108
139
|
zcapClient: ZcapClient;
|
|
109
140
|
recordSigner: RecordSigner;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recoveryDelegation.d.ts","sourceRoot":"","sources":["../../src/recovery/recoveryDelegation.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"recoveryDelegation.d.ts","sourceRoot":"","sources":["../../src/recovery/recoveryDelegation.ts"],"names":[],"mappings":"AAiCA,OAAO,KAAK,EAAoB,KAAK,EAAE,MAAM,8BAA8B,CAAA;AAC3E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAGhD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAA;AAKnE,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAGxE;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,0BAA0B,QAA4B,CAAA;AAEnE;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,QAA2B,CAAA;AAE9D;;;;;;;;;;;;;GAaG;AACH,wBAAgB,YAAY,CAAC,EAC3B,OAAO,EACP,GAAgB,EACjB,EAAE;IACD,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,GAAG,CAAC,EAAE,MAAM,CAAA;CACb,GAAG,OAA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AAK,EAAE,KAAK,CAAA;KAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;CAC1D,GAAG,OAAO,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,CA+FjD"}
|
|
@@ -6,21 +6,24 @@
|
|
|
6
6
|
* delegation and the revocation cascade's re-mint of it. The delegation is a
|
|
7
7
|
* wire artifact both apps must mint byte-identically (issuance and every
|
|
8
8
|
* re-mint produce the record another replica later recovers with), so its
|
|
9
|
-
* builder lives here: PUT on the one `did.jsonl` resource,
|
|
10
|
-
* to the code-derived signing DID. Its narrow scope is what keeps
|
|
11
|
-
* loud -- a stolen code must extend the world-readable log before it
|
|
12
|
-
* anything.
|
|
9
|
+
* builder lives here: PUT on the one `did.jsonl` resource, one-year TTL,
|
|
10
|
+
* delegated to the code-derived signing DID. Its narrow scope is what keeps
|
|
11
|
+
* recovery loud -- a stolen code must extend the world-readable log before it
|
|
12
|
+
* can read anything.
|
|
13
13
|
*
|
|
14
14
|
* Beside the builder lives the re-mint core (`remintRecoveryDelegations`):
|
|
15
15
|
* revoking a client kills, by the current-key-set rule, every `did.jsonl`
|
|
16
16
|
* delegation that client signed, which would brick recovery exactly when it
|
|
17
|
-
* is needed
|
|
18
|
-
*
|
|
17
|
+
* is needed -- and a delegation left standing eventually reaches its own
|
|
18
|
+
* expiry. For each registry entry whose recorded delegation no longer
|
|
19
|
+
* chains (its signing verification method left the document) or is expired
|
|
20
|
+
* or inside the renewal window, the acting
|
|
19
21
|
* client signs a fresh delegation to the code's signing DID, re-wraps the
|
|
20
22
|
* record to the code's unlock KAK (the public half the registry records --
|
|
21
23
|
* the record carries no secrets, so re-encryption needs none), re-PUTs it
|
|
22
24
|
* through the entry's management zcap, and updates the registry's
|
|
23
|
-
* `delegationKeyId`. The skip policy is
|
|
25
|
+
* `delegationKeyId` and `delegationExpires`. The skip policy is
|
|
26
|
+
* cross-replica correctness and is
|
|
24
27
|
* decided here once: an entry that predates the re-mint fields, or whose
|
|
25
28
|
* standing record cannot be read or carries no binding, is skipped and stays
|
|
26
29
|
* flagged by the login-time health check. What stays app-side is the seams:
|
|
@@ -31,17 +34,53 @@ import { X25519KeyAgreementKey2020 } from '@interop/x25519-key-agreement-key';
|
|
|
31
34
|
import { DID_LOG_RESOURCE, ID_COLLECTION } from '../space/collections.js';
|
|
32
35
|
import { delegationKeyInDocument } from '../webvh/listClients.js';
|
|
33
36
|
import { getUnlockKeyringWithCapability, putUnlockKeyringWithCapability } from '../keyring/unlockSpace.js';
|
|
34
|
-
import {
|
|
37
|
+
import { remintUnlockRecordBridge } from '../unlock/unlockRecord.js';
|
|
35
38
|
/**
|
|
36
|
-
* The recovery delegation's lifetime:
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
* write that still has to verify
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
39
|
+
* The recovery delegation's lifetime: one year, following NIST SP 800-57's
|
|
40
|
+
* one-to-two-year cryptoperiod guidance for private signature keys. The
|
|
41
|
+
* delegation's scope stays narrow (PUT on the one world-readable DID log
|
|
42
|
+
* resource, whose worst-case abuse is a log write that still has to verify
|
|
43
|
+
* against the published hash chain and prerotation commitments to resolve),
|
|
44
|
+
* but a standing bearer artifact should not outlive its signing key's
|
|
45
|
+
* recommended cryptoperiod. A code must keep working past the year, so
|
|
46
|
+
* expiry is watched rather than terminal: the registry entry records the
|
|
47
|
+
* delegation's `expires`, {@link zcapExpiring} treats the
|
|
48
|
+
* renewal window before it as stale, the re-mint refreshes a stale
|
|
49
|
+
* delegation, and the login-time recovery health check flags one the same
|
|
50
|
+
* way it flags rot (the signing client's verification method leaving the
|
|
51
|
+
* document).
|
|
43
52
|
*/
|
|
44
|
-
export const RECOVERY_DELEGATION_TTL_MS =
|
|
53
|
+
export const RECOVERY_DELEGATION_TTL_MS = 365 * 24 * 60 * 60 * 1000;
|
|
54
|
+
/**
|
|
55
|
+
* How long before its `expires` a standing recorded zcap counts as stale:
|
|
56
|
+
* thirty days, so a refresh (a re-mint, a login-time re-delegation) or a
|
|
57
|
+
* regenerate nudge lands well before the zcap actually lapses.
|
|
58
|
+
*/
|
|
59
|
+
export const ZCAP_RENEWAL_WINDOW_MS = 30 * 24 * 60 * 60 * 1000;
|
|
60
|
+
/**
|
|
61
|
+
* Whether a recorded zcap expiry is past or inside the renewal window -- the
|
|
62
|
+
* expiry half of the staleness predicate for every long-lived zcap a wallet
|
|
63
|
+
* records beside its registry entries (the recovery `did.jsonl` delegation,
|
|
64
|
+
* an unlock Space's management zcap). The re-mint and the wallets'
|
|
65
|
+
* login-time checks all ask this one predicate. A record carrying no expiry
|
|
66
|
+
* (or an unparseable one) is uncheckable and therefore not assumed healthy,
|
|
67
|
+
* matching the rot check's treatment of a missing `delegationKeyId`.
|
|
68
|
+
*
|
|
69
|
+
* @param options {object}
|
|
70
|
+
* @param [options.expires] {string} the recorded ISO 8601 expiry
|
|
71
|
+
* @param [options.now] {number} epoch milliseconds, for tests
|
|
72
|
+
* @returns {boolean}
|
|
73
|
+
*/
|
|
74
|
+
export function zcapExpiring({ expires, now = Date.now() }) {
|
|
75
|
+
if (!expires) {
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
const expiresAt = Date.parse(expires);
|
|
79
|
+
if (Number.isNaN(expiresAt)) {
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
return expiresAt - now <= ZCAP_RENEWAL_WINDOW_MS;
|
|
83
|
+
}
|
|
45
84
|
/**
|
|
46
85
|
* The absolute URL of the account's `did.jsonl` log resource -- the
|
|
47
86
|
* invocation target of the pre-minted recovery delegation.
|
|
@@ -92,13 +131,15 @@ export function delegationProofKeyId(delegation) {
|
|
|
92
131
|
* the recovery-code delta riding the revocation cascade (see the module doc
|
|
93
132
|
* for the mechanism and the skip policy).
|
|
94
133
|
*
|
|
95
|
-
* The record's
|
|
134
|
+
* The record's credential-authenticated core is preserved verbatim: the
|
|
96
135
|
* re-mint reads the standing record through the entry's management zcap and
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
*
|
|
136
|
+
* replaces only its bridge member ({@link remintUnlockRecordBridge}) -- the
|
|
137
|
+
* shell, the ladder member (where one rides), and the binding tag all travel
|
|
138
|
+
* untouched, since the re-mint can decrypt none of them and does not need to.
|
|
139
|
+
* A re-mint therefore can never change the pointer or controller the
|
|
140
|
+
* credential was bound against -- and after a host migration the tag no
|
|
141
|
+
* longer matches the moved pointer, so credentials must be rebound (codes
|
|
142
|
+
* re-issued) when the account moves hosts.
|
|
102
143
|
*
|
|
103
144
|
* The re-mint holds the code's KAK public half but not its signing key, so
|
|
104
145
|
* every record it re-PUTs is signed with the acting client's own account key
|
|
@@ -114,8 +155,6 @@ export function delegationProofKeyId(delegation) {
|
|
|
114
155
|
* @param options.entries {RecoveryDelegationEntry[]} the registry's
|
|
115
156
|
* recovery-code entries, as the app's registry read returned them
|
|
116
157
|
* @param options.pointer {AccountPointer}
|
|
117
|
-
* @param options.controller {string} the account controller to stamp into
|
|
118
|
-
* re-wrapped records (an identity label, as at issuance)
|
|
119
158
|
* @param options.storageServerUrl {string} the unlock Spaces' storage server
|
|
120
159
|
* @param options.zcapClient {ZcapClient} the acting client's promoted
|
|
121
160
|
* signer, which mints the fresh delegations
|
|
@@ -127,20 +166,26 @@ export function delegationProofKeyId(delegation) {
|
|
|
127
166
|
* persists one updated registry entry (matching on the app's entry key)
|
|
128
167
|
* @returns {Promise<{ reminted: number; skipped: number }>}
|
|
129
168
|
*/
|
|
130
|
-
export async function remintRecoveryDelegations({ doc, entries, pointer,
|
|
169
|
+
export async function remintRecoveryDelegations({ doc, entries, pointer, storageServerUrl, zcapClient, recordSigner, managementZcapClient, recordEntry }) {
|
|
131
170
|
let reminted = 0;
|
|
132
171
|
let skipped = 0;
|
|
133
172
|
for (const entry of entries) {
|
|
134
173
|
// The current-key-set rule, decided once in `webvh`: an entry whose
|
|
135
174
|
// recorded signing key the document no longer publishes -- or that
|
|
136
|
-
// records no signing key at all -- is rotted.
|
|
175
|
+
// records no signing key at all -- is rotted. Expiry is the other
|
|
176
|
+
// staleness axis: a delegation expired or inside the renewal window
|
|
177
|
+
// (or recording no expiry at all) is re-minted even though its key
|
|
178
|
+
// still stands.
|
|
137
179
|
const stands = delegationKeyInDocument({
|
|
138
180
|
doc,
|
|
139
181
|
...(entry.delegationKeyId
|
|
140
182
|
? { delegationKeyId: entry.delegationKeyId }
|
|
141
183
|
: {})
|
|
142
184
|
});
|
|
143
|
-
|
|
185
|
+
const expiring = zcapExpiring({
|
|
186
|
+
...(entry.delegationExpires ? { expires: entry.delegationExpires } : {})
|
|
187
|
+
});
|
|
188
|
+
if (stands && !expiring) {
|
|
144
189
|
continue;
|
|
145
190
|
}
|
|
146
191
|
if (!entry.recoveryClientDid ||
|
|
@@ -153,10 +198,10 @@ export async function remintRecoveryDelegations({ doc, entries, pointer, control
|
|
|
153
198
|
continue;
|
|
154
199
|
}
|
|
155
200
|
try {
|
|
156
|
-
// The standing record
|
|
157
|
-
// verbatim (a record with
|
|
158
|
-
// re-minted -- `
|
|
159
|
-
// skipped into the health check's regenerate nudge).
|
|
201
|
+
// The standing record, whose credential-authenticated core travels
|
|
202
|
+
// verbatim (a record with no binding predates the standing layout and
|
|
203
|
+
// cannot be re-minted -- `remintUnlockRecordBridge` refuses, and the
|
|
204
|
+
// entry is skipped into the health check's regenerate nudge).
|
|
160
205
|
const standing = await getUnlockKeyringWithCapability({
|
|
161
206
|
storageServerUrl,
|
|
162
207
|
zcapClient: managementZcapClient({
|
|
@@ -165,28 +210,26 @@ export async function remintRecoveryDelegations({ doc, entries, pointer, control
|
|
|
165
210
|
spaceId: entry.unlockSpaceId,
|
|
166
211
|
capability: entry.manageCapability
|
|
167
212
|
});
|
|
168
|
-
const binding = recoveryRecordBinding({ record: standing });
|
|
169
213
|
const delegation = await delegateLogWrite({
|
|
170
214
|
zcapClient,
|
|
171
215
|
pointer,
|
|
172
216
|
recoveryClientDid: entry.recoveryClientDid
|
|
173
217
|
});
|
|
174
|
-
// The
|
|
175
|
-
//
|
|
176
|
-
//
|
|
218
|
+
// The credential's unlock KAK, public half only -- exactly enough to
|
|
219
|
+
// seal the fresh bridge to the same recipient the credential derives
|
|
220
|
+
// (sealing goes through the encrypt-only cipher, so no secret is
|
|
221
|
+
// needed).
|
|
177
222
|
const unlockKak = (await X25519KeyAgreementKey2020.from({
|
|
178
223
|
id: entry.unlockKeyAgreementKeyId,
|
|
179
224
|
controller: entry.unlockKeyAgreementKeyId.split('#')[0],
|
|
180
225
|
type: 'X25519KeyAgreementKey2020',
|
|
181
226
|
publicKeyMultibase: entry.unlockKeyAgreementKeyMultibase
|
|
182
227
|
}));
|
|
183
|
-
const wrapped = await
|
|
184
|
-
|
|
185
|
-
pointer,
|
|
228
|
+
const wrapped = await remintUnlockRecordBridge({
|
|
229
|
+
record: standing,
|
|
186
230
|
delegation,
|
|
187
231
|
keyAgreementKey: unlockKak,
|
|
188
|
-
signer: recordSigner
|
|
189
|
-
binding
|
|
232
|
+
signer: recordSigner
|
|
190
233
|
});
|
|
191
234
|
await putUnlockKeyringWithCapability({
|
|
192
235
|
storageServerUrl,
|
|
@@ -198,10 +241,12 @@ export async function remintRecoveryDelegations({ doc, entries, pointer, control
|
|
|
198
241
|
capability: entry.manageCapability
|
|
199
242
|
});
|
|
200
243
|
const delegationKeyId = delegationProofKeyId(delegation);
|
|
244
|
+
const delegationExpires = delegation.expires;
|
|
201
245
|
await recordEntry({
|
|
202
246
|
entry: {
|
|
203
247
|
...entry,
|
|
204
|
-
...(delegationKeyId ? { delegationKeyId } : {})
|
|
248
|
+
...(delegationKeyId ? { delegationKeyId } : {}),
|
|
249
|
+
...(delegationExpires ? { delegationExpires } : {})
|
|
205
250
|
}
|
|
206
251
|
});
|
|
207
252
|
reminted += 1;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recoveryDelegation.js","sourceRoot":"","sources":["../../src/recovery/recoveryDelegation.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH
|
|
1
|
+
{"version":3,"file":"recoveryDelegation.js","sourceRoot":"","sources":["../../src/recovery/recoveryDelegation.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,OAAO,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAA;AAG7E,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAA;AACzE,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAA;AAEjE,OAAO,EACL,8BAA8B,EAC9B,8BAA8B,EAC/B,MAAM,2BAA2B,CAAA;AAElC,OAAO,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAA;AAEpE;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,GAAG,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAA;AAEnE;;;;GAIG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAA;AAE9D;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,YAAY,CAAC,EAC3B,OAAO,EACP,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,EAIjB;IACC,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,IAAI,CAAA;IACb,CAAC;IACD,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;IACrC,IAAI,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,CAAC;QAC5B,OAAO,IAAI,CAAA;IACb,CAAC;IACD,OAAO,SAAS,GAAG,GAAG,IAAI,sBAAsB,CAAA;AAClD,CAAC;AAED;;;;;;;GAOG;AACH,SAAS,SAAS,CAAC,EAAE,OAAO,EAA+B;IACzD,OAAO,IAAI,GA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