@interop/wallet-core 0.78.0 → 0.79.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 +16 -3
- package/dist/clientAnnex/credentialAnchoredGenesis.d.ts +2 -2
- package/dist/clientAnnex/credentialAnchoredGenesis.d.ts.map +1 -1
- package/dist/clientAnnex/credentialAnchoredGenesis.js +1 -1
- package/dist/clientAnnex/credentialAnchoredGenesis.js.map +1 -1
- package/dist/clientAnnex/establish.d.ts +2 -2
- package/dist/clientAnnex/establish.d.ts.map +1 -1
- package/dist/clientAnnex/forget.d.ts +1 -1
- package/dist/clientAnnex/forget.d.ts.map +1 -1
- package/dist/clientAnnex/heal.d.ts.map +1 -1
- package/dist/clientAnnex/heal.js +3 -1
- package/dist/clientAnnex/heal.js.map +1 -1
- package/dist/clientAnnex/ladder.d.ts +3 -98
- package/dist/clientAnnex/ladder.d.ts.map +1 -1
- package/dist/clientAnnex/ladder.js +4 -140
- package/dist/clientAnnex/ladder.js.map +1 -1
- package/dist/clientAnnex/log.d.ts +26 -10
- package/dist/clientAnnex/log.d.ts.map +1 -1
- package/dist/clientAnnex/log.js +40 -17
- package/dist/clientAnnex/log.js.map +1 -1
- package/dist/clientAnnex/mend.d.ts +2 -2
- package/dist/clientAnnex/mend.d.ts.map +1 -1
- package/dist/clientAnnex/mend.js +1 -1
- package/dist/clientAnnex/mend.js.map +1 -1
- package/dist/clientAnnex/rosterDeliveredEpochs.d.ts +1 -1
- package/dist/clientAnnex/rosterDeliveredEpochs.d.ts.map +1 -1
- package/dist/clientAnnex/selfEnroll.d.ts +1 -1
- package/dist/clientAnnex/selfEnroll.d.ts.map +1 -1
- package/dist/clientAnnex/selfEnroll.js +2 -1
- package/dist/clientAnnex/selfEnroll.js.map +1 -1
- package/dist/clients/revocation.d.ts +1 -1
- package/dist/clients/revocation.d.ts.map +1 -1
- package/dist/clients/rosterPolicy.d.ts +1 -1
- package/dist/clients/rosterPolicy.d.ts.map +1 -1
- package/dist/descriptors/logSource.d.ts +2 -1
- package/dist/descriptors/logSource.d.ts.map +1 -1
- package/dist/descriptors/logSource.js +1 -1
- package/dist/descriptors/logSource.js.map +1 -1
- package/dist/enrollment/enrollment.d.ts +2 -2
- package/dist/enrollment/enrollment.d.ts.map +1 -1
- package/dist/enrollment/enrollment.js +2 -1
- package/dist/enrollment/enrollment.js.map +1 -1
- package/dist/genesis/accountGenesis.d.ts +1 -1
- package/dist/genesis/accountGenesis.d.ts.map +1 -1
- package/dist/genesis/accountGenesis.js +11 -5
- package/dist/genesis/accountGenesis.js.map +1 -1
- package/dist/keyring/fetch.d.ts +1 -1
- package/dist/keyring/fetch.d.ts.map +1 -1
- package/dist/keyring/fetch.js +1 -1
- package/dist/keyring/fetch.js.map +1 -1
- package/dist/keyring/index.d.ts +15 -8
- package/dist/keyring/index.d.ts.map +1 -1
- package/dist/keyring/index.js +11 -6
- package/dist/keyring/index.js.map +1 -1
- package/dist/keyring/kdf.d.ts +0 -69
- package/dist/keyring/kdf.d.ts.map +1 -1
- package/dist/keyring/kdf.js +7 -86
- package/dist/keyring/kdf.js.map +1 -1
- package/dist/keyring/record.d.ts +1 -200
- package/dist/keyring/record.d.ts.map +1 -1
- package/dist/keyring/record.js +5 -251
- package/dist/keyring/record.js.map +1 -1
- package/dist/keyring/recordEnvelope.d.ts +270 -0
- package/dist/keyring/recordEnvelope.d.ts.map +1 -0
- package/dist/keyring/recordEnvelope.js +282 -0
- package/dist/keyring/recordEnvelope.js.map +1 -0
- package/dist/keyring/unlockIdentity.d.ts +71 -0
- package/dist/keyring/unlockIdentity.d.ts.map +1 -0
- package/dist/keyring/unlockIdentity.js +96 -0
- package/dist/keyring/unlockIdentity.js.map +1 -0
- package/dist/keyring/unlockSpace.d.ts +12 -1
- package/dist/keyring/unlockSpace.d.ts.map +1 -1
- package/dist/keyring/unlockSpace.js +15 -2
- package/dist/keyring/unlockSpace.js.map +1 -1
- package/dist/keys/index.d.ts +6 -3
- package/dist/keys/index.d.ts.map +1 -1
- package/dist/keys/index.js +6 -3
- package/dist/keys/index.js.map +1 -1
- package/dist/keys/rosterLogStore.d.ts +1 -1
- package/dist/keys/rosterLogStore.d.ts.map +1 -1
- package/dist/keys/rosterLogStore.js +1 -1
- package/dist/keys/rosterLogStore.js.map +1 -1
- package/dist/keys/rosterRecipientKid.d.ts +28 -0
- package/dist/keys/rosterRecipientKid.d.ts.map +1 -0
- package/dist/keys/rosterRecipientKid.js +27 -0
- package/dist/keys/rosterRecipientKid.js.map +1 -0
- package/dist/keys/spaceEpochs.d.ts +1 -1
- package/dist/keys/spaceEpochs.d.ts.map +1 -1
- package/dist/keys/spaceEpochs.js +2 -2
- package/dist/keys/spaceEpochs.js.map +1 -1
- package/dist/keys/userKey.d.ts +4 -46
- package/dist/keys/userKey.d.ts.map +1 -1
- package/dist/keys/userKey.js +8 -60
- package/dist/keys/userKey.js.map +1 -1
- package/dist/keys/userKeyCascade.d.ts +1 -33
- package/dist/keys/userKeyCascade.d.ts.map +1 -1
- package/dist/keys/userKeyCascade.js +2 -49
- package/dist/keys/userKeyCascade.js.map +1 -1
- package/dist/keys/userKeyGenerations.d.ts +47 -0
- package/dist/keys/userKeyGenerations.d.ts.map +1 -0
- package/dist/keys/userKeyGenerations.js +50 -0
- package/dist/keys/userKeyGenerations.js.map +1 -0
- package/dist/keys/userKeyRoster.d.ts +1 -19
- package/dist/keys/userKeyRoster.d.ts.map +1 -1
- package/dist/keys/userKeyRoster.js +13 -19
- package/dist/keys/userKeyRoster.js.map +1 -1
- package/dist/keys/userKeyRosterCascade.d.ts +1 -1
- package/dist/keys/userKeyRosterCascade.d.ts.map +1 -1
- package/dist/keys/userKeySigning.d.ts +44 -0
- package/dist/keys/userKeySigning.d.ts.map +1 -0
- package/dist/keys/userKeySigning.js +65 -0
- package/dist/keys/userKeySigning.js.map +1 -0
- package/dist/recovery/recoveryCode.d.ts.map +1 -1
- package/dist/recovery/recoveryCode.js +3 -4
- package/dist/recovery/recoveryCode.js.map +1 -1
- package/dist/recovery/recoveryDelegation.d.ts +1 -1
- package/dist/recovery/recoveryDelegation.d.ts.map +1 -1
- package/dist/space/collections.d.ts +1 -43
- package/dist/space/collections.d.ts.map +1 -1
- package/dist/space/collections.js +2 -34
- package/dist/space/collections.js.map +1 -1
- package/dist/space/systemCollections.d.ts +55 -0
- package/dist/space/systemCollections.d.ts.map +1 -0
- package/dist/space/systemCollections.js +46 -0
- package/dist/space/systemCollections.js.map +1 -0
- package/dist/sync/contactsConflict.d.ts +56 -10
- package/dist/sync/contactsConflict.d.ts.map +1 -1
- package/dist/sync/contactsConflict.js +82 -18
- package/dist/sync/contactsConflict.js.map +1 -1
- package/dist/sync/engine.d.ts +9 -3
- package/dist/sync/engine.d.ts.map +1 -1
- package/dist/sync/engine.js.map +1 -1
- package/dist/sync/pull.d.ts +25 -4
- package/dist/sync/pull.d.ts.map +1 -1
- package/dist/sync/pull.js +27 -3
- package/dist/sync/pull.js.map +1 -1
- package/dist/sync/remint.d.ts +10 -4
- package/dist/sync/remint.d.ts.map +1 -1
- package/dist/sync/remint.js +28 -6
- package/dist/sync/remint.js.map +1 -1
- package/dist/unlock/ladderDerivation.d.ts +98 -0
- package/dist/unlock/ladderDerivation.d.ts.map +1 -0
- package/dist/unlock/ladderDerivation.js +157 -0
- package/dist/unlock/ladderDerivation.js.map +1 -0
- package/dist/unlock/retire.d.ts +1 -1
- package/dist/unlock/retire.d.ts.map +1 -1
- package/dist/unlock/standingClient.js +1 -1
- package/dist/unlock/standingClient.js.map +1 -1
- package/dist/unlock/standingWebvh.d.ts.map +1 -1
- package/dist/unlock/standingWebvh.js +3 -3
- package/dist/unlock/standingWebvh.js.map +1 -1
- package/dist/unlock/unlockRecord.d.ts +2 -1
- package/dist/unlock/unlockRecord.d.ts.map +1 -1
- package/dist/unlock/unlockRecord.js +11 -2
- package/dist/unlock/unlockRecord.js.map +1 -1
- package/dist/webvh/accountEntry.d.ts +2 -1
- package/dist/webvh/accountEntry.d.ts.map +1 -1
- package/dist/webvh/accountEntry.js.map +1 -1
- package/dist/webvh/didWebvh.d.ts +1 -11
- package/dist/webvh/didWebvh.d.ts.map +1 -1
- package/dist/webvh/didWebvh.js +5 -13
- package/dist/webvh/didWebvh.js.map +1 -1
- package/dist/webvh/updateKeyMultibase.d.ts +12 -0
- package/dist/webvh/updateKeyMultibase.d.ts.map +1 -0
- package/dist/webvh/updateKeyMultibase.js +23 -0
- package/dist/webvh/updateKeyMultibase.js.map +1 -0
- package/dist/webvh/wasIdStore.d.ts +5 -3
- package/dist/webvh/wasIdStore.d.ts.map +1 -1
- package/dist/webvh/wasIdStore.js.map +1 -1
- package/package.json +53 -11
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
import { createEdvDocCipher, createEdvEncryptOnlyDocCipher, initRecipients, ownerRecipient } from '@interop/was-client/edv/cipher';
|
|
2
|
+
import { KEYRING_COLLECTION } from '../space/systemCollections.js';
|
|
3
|
+
/**
|
|
4
|
+
* The version stamped on the stored `{ version, encryption, wrapped, proof }`
|
|
5
|
+
* keyring envelope: the signed record, whose envelope seals under the record's
|
|
6
|
+
* own key epoch (the `encryption` member) and whose sibling members carry a
|
|
7
|
+
* Data Integrity proof by the unlock identity's signing key. Any other version
|
|
8
|
+
* is refused as unusable -- such accounts are re-provisioned, not migrated.
|
|
9
|
+
*/
|
|
10
|
+
export const KEYRING_RECORD_VERSION = 2;
|
|
11
|
+
/**
|
|
12
|
+
* A record's proof is absent, malformed, signed by a key this client does not
|
|
13
|
+
* accept, or does not verify over the record's own members. Its own class,
|
|
14
|
+
* distinct from a decrypt failure or an unusable-version refusal: this is the
|
|
15
|
+
* refusal that says the storage host forged or tampered with the record, which
|
|
16
|
+
* an app maps to its own login copy.
|
|
17
|
+
*/
|
|
18
|
+
export class RecordProofError extends Error {
|
|
19
|
+
constructor(message, options) {
|
|
20
|
+
super(message, options);
|
|
21
|
+
this.name = 'RecordProofError';
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Checks the shape of a record's `proof` member against the fixed shape.
|
|
26
|
+
* Verifies nothing: no cryptography runs here, so a match says only that
|
|
27
|
+
* the member could be a proof, not that it is genuine.
|
|
28
|
+
*
|
|
29
|
+
* @param options {object}
|
|
30
|
+
* @param options.proof {unknown}
|
|
31
|
+
* @param options.label {string} names the record kind in the refusal
|
|
32
|
+
* @returns {RecordProof}
|
|
33
|
+
*/
|
|
34
|
+
export function checkRecordProofShape({ proof, label }) {
|
|
35
|
+
const candidate = proof;
|
|
36
|
+
if (candidate === null ||
|
|
37
|
+
typeof candidate !== 'object' ||
|
|
38
|
+
candidate.type !== 'DataIntegrityProof' ||
|
|
39
|
+
candidate.cryptosuite !== 'eddsa-jcs-2022' ||
|
|
40
|
+
candidate.proofPurpose !== 'assertionMethod' ||
|
|
41
|
+
typeof candidate.verificationMethod !== 'string' ||
|
|
42
|
+
typeof candidate.proofValue !== 'string') {
|
|
43
|
+
throw new RecordProofError(`The ${label} record carries no proof in the fixed shape ` +
|
|
44
|
+
`(DataIntegrityProof / eddsa-jcs-2022 / assertionMethod).`);
|
|
45
|
+
}
|
|
46
|
+
return candidate;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Mints the one-epoch descriptor a fresh record is sealed under: epoch[0]
|
|
50
|
+
* wrapped to the given KAK alone, built through `initRecipients` against a
|
|
51
|
+
* throwaway in-memory store (the descriptor's home is the record itself).
|
|
52
|
+
* Exported for any consumer sealing a self-contained
|
|
53
|
+
* `{ version, encryption, wrapped }` record -- the keyring and recovery
|
|
54
|
+
* records here, and a wallet app's own locally stored records (e.g.
|
|
55
|
+
* freewallet's client-key record and unlock-methods registry).
|
|
56
|
+
*
|
|
57
|
+
* @param options {object}
|
|
58
|
+
* @param options.keyAgreementKey {IKeyAgreementKey} the wrapping KAK (for
|
|
59
|
+
* the keyring record, the unlock KAK)
|
|
60
|
+
* @returns {Promise<CollectionEncryption>}
|
|
61
|
+
*/
|
|
62
|
+
export async function mintRecordEncryption({ keyAgreementKey }) {
|
|
63
|
+
let stored = null;
|
|
64
|
+
const store = {
|
|
65
|
+
async read() {
|
|
66
|
+
return stored ? { descriptor: stored } : null;
|
|
67
|
+
},
|
|
68
|
+
async replace(next) {
|
|
69
|
+
stored = next;
|
|
70
|
+
},
|
|
71
|
+
async create(next) {
|
|
72
|
+
stored = next;
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
return initRecipients({
|
|
76
|
+
store,
|
|
77
|
+
recipients: [ownerRecipient({ keyAgreementKey })]
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Builds the record's reading cipher: an EDV cipher over the record's own
|
|
82
|
+
* descriptor, from the reader's key-agreement key. The unwrap paths' cipher
|
|
83
|
+
* (and the recovery record's, which reuses the keyring cipher context
|
|
84
|
+
* verbatim); the wrap paths seal through {@link recordSealCipher} instead. An
|
|
85
|
+
* app's own record kind passes its own `collectionId` so its failures name
|
|
86
|
+
* the record kind. The context labels errors only -- the codec is agnostic to
|
|
87
|
+
* it, so a record kind's real swap protection is its contents validation on
|
|
88
|
+
* unwrap.
|
|
89
|
+
*
|
|
90
|
+
* @param options {object}
|
|
91
|
+
* @param options.keyAgreementKey {IKeyAgreementKey} the wrapping KAK (for
|
|
92
|
+
* the keyring record, the unlock KAK)
|
|
93
|
+
* @param options.keyResolver {IKeyResolver}
|
|
94
|
+
* @param options.encryption {CollectionEncryption} the record's descriptor
|
|
95
|
+
* @param [options.collectionId] {string} the cipher context failures are
|
|
96
|
+
* labeled with; defaults to the keyring context
|
|
97
|
+
* @returns {Promise<DocCipher>}
|
|
98
|
+
*/
|
|
99
|
+
export async function recordCipher({ keyAgreementKey, keyResolver, encryption, collectionId = KEYRING_COLLECTION.id }) {
|
|
100
|
+
return createEdvDocCipher({
|
|
101
|
+
keyAgreementKey,
|
|
102
|
+
keyResolver,
|
|
103
|
+
collectionId,
|
|
104
|
+
encryption
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Builds the record's sealing cipher: an encrypt-only EDV cipher over the
|
|
109
|
+
* record's own descriptor, needing no key-agreement secret -- a write seals to
|
|
110
|
+
* the descriptor's epoch public key, reconstructed from the epoch id. This is
|
|
111
|
+
* what lets the recovery re-mint, which holds only the code's unlock KAK
|
|
112
|
+
* public half, re-seal a record it can never open; the issuance wraps go
|
|
113
|
+
* through the same construction and produce the same envelope shape. Decrypt
|
|
114
|
+
* on it refuses with was-client's typed `EncryptOnlyCipherError`.
|
|
115
|
+
*
|
|
116
|
+
* @param options {object}
|
|
117
|
+
* @param options.encryption {CollectionEncryption} the record's descriptor
|
|
118
|
+
* @param [options.collectionId] {string} the cipher context failures are
|
|
119
|
+
* labeled with; defaults to the keyring context
|
|
120
|
+
* @returns {Promise<DocCipher>}
|
|
121
|
+
*/
|
|
122
|
+
export async function recordSealCipher({ encryption, collectionId = KEYRING_COLLECTION.id }) {
|
|
123
|
+
return createEdvEncryptOnlyDocCipher({ collectionId, encryption });
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Reads the addressed id a stored record envelope must be decrypted under.
|
|
127
|
+
*
|
|
128
|
+
* A record's members seal through {@link recordSealCipher}, which builds on
|
|
129
|
+
* was-client's default content-derived id mode: the id does not exist until
|
|
130
|
+
* after encryption, so the codec computes it from the JWE ciphertext and
|
|
131
|
+
* stamps it onto the cleartext envelope afterwards. That stamped member is
|
|
132
|
+
* the only value {@link recordCipher}'s decrypt accepts -- the record's own
|
|
133
|
+
* well-known resource id does not verify, and the sealed members of an unlock
|
|
134
|
+
* record have no resource id of their own at all.
|
|
135
|
+
*
|
|
136
|
+
* The check this id feeds is therefore inert here, and deliberately so. In
|
|
137
|
+
* content-derived mode the id is a hash of the ciphertext, so a substituted
|
|
138
|
+
* envelope carries a matching stamp and the comparison always passes. It
|
|
139
|
+
* detects corruption rather than substitution. A record's protection against a
|
|
140
|
+
* substituting storage host is the frame's `eddsa-jcs-2022` proof over
|
|
141
|
+
* `wrapped` and every sealed member, verified by `record.ts`'s
|
|
142
|
+
* `verifyRecordProof` before any unwrap path decrypts. Do not read this id
|
|
143
|
+
* as a security boundary.
|
|
144
|
+
*
|
|
145
|
+
* @param options {object}
|
|
146
|
+
* @param options.wrapped {unknown} the stored envelope
|
|
147
|
+
* @param options.label {string} `'keyring'`, `'recovery'`, or an app record
|
|
148
|
+
* kind's own label, naming the refusal
|
|
149
|
+
* @returns {string} the envelope's addressed id
|
|
150
|
+
*/
|
|
151
|
+
export function recordEnvelopeId({ wrapped, label }) {
|
|
152
|
+
const id = wrapped !== null && typeof wrapped === 'object'
|
|
153
|
+
? wrapped.id
|
|
154
|
+
: undefined;
|
|
155
|
+
if (typeof id !== 'string' || !id) {
|
|
156
|
+
throw new Error(`Malformed ${label} record: the sealed envelope carries no id.`);
|
|
157
|
+
}
|
|
158
|
+
return id;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Validates the common `{ version, encryption, wrapped }` frame of a stored
|
|
162
|
+
* record (keyring or recovery -- `label` names the refusals) and returns its
|
|
163
|
+
* members, the `proof` among them for the signed frame. Exported so an app's
|
|
164
|
+
* own record kinds open their records through the same frame validation the
|
|
165
|
+
* codec here seals with, rather than re-deriving the version and shape checks.
|
|
166
|
+
*
|
|
167
|
+
* A frame at the keyring record version is the signed frame, so it must carry
|
|
168
|
+
* a fixed-shape proof; a record kind stamping its own version is unaffected
|
|
169
|
+
* (its authenticity story is its own). Validating the shape here does not
|
|
170
|
+
* verify it -- `record.ts`'s `verifyRecordProof` does, and every unwrap path
|
|
171
|
+
* there runs it before decrypting.
|
|
172
|
+
*
|
|
173
|
+
* @param options {object}
|
|
174
|
+
* @param options.record {unknown}
|
|
175
|
+
* @param options.label {string} `'keyring'`, `'recovery'`, or an app record
|
|
176
|
+
* kind's own label
|
|
177
|
+
* @param [options.version] {number} the version the frame must carry;
|
|
178
|
+
* defaults to the keyring record version
|
|
179
|
+
* @returns {{ encryption: CollectionEncryption, wrapped: unknown,
|
|
180
|
+
* proof?: RecordProof }}
|
|
181
|
+
*/
|
|
182
|
+
export function parseRecordFrame({ record, label, version = KEYRING_RECORD_VERSION }) {
|
|
183
|
+
if (record === null || typeof record !== 'object') {
|
|
184
|
+
throw new Error(`Malformed ${label} record.`);
|
|
185
|
+
}
|
|
186
|
+
const { version: recordVersion, encryption, wrapped, proof } = record;
|
|
187
|
+
if (recordVersion !== version) {
|
|
188
|
+
// Two retired version-1 shapes are named rather than reported as an
|
|
189
|
+
// unsupported number, so neither refusal is read as corruption: the
|
|
190
|
+
// pre-extraction record (a data-seed wrap with no descriptor) and the
|
|
191
|
+
// unsigned envelope this version's proof replaced. Both are unusable.
|
|
192
|
+
if (version === KEYRING_RECORD_VERSION && recordVersion === 1) {
|
|
193
|
+
if (encryption === undefined) {
|
|
194
|
+
throw new Error(`The ${label} record uses the retired pre-extraction version 1 ` +
|
|
195
|
+
'shape (a data-seed wrap with no encryption descriptor); such ' +
|
|
196
|
+
'accounts are re-provisioned, not migrated.');
|
|
197
|
+
}
|
|
198
|
+
throw new Error(`The ${label} record uses the retired unsigned version 1 shape (no ` +
|
|
199
|
+
'proof over its frame, so a storage host could substitute it); ' +
|
|
200
|
+
'such accounts are re-provisioned, not migrated.');
|
|
201
|
+
}
|
|
202
|
+
throw new Error(`Unsupported ${label} record version "${String(recordVersion)}".`);
|
|
203
|
+
}
|
|
204
|
+
if (wrapped === undefined || wrapped === null) {
|
|
205
|
+
throw new Error(`Malformed ${label} record.`);
|
|
206
|
+
}
|
|
207
|
+
if (encryption === null || typeof encryption !== 'object') {
|
|
208
|
+
throw new Error(`The ${label} record is missing its encryption descriptor.`);
|
|
209
|
+
}
|
|
210
|
+
return {
|
|
211
|
+
encryption: encryption,
|
|
212
|
+
wrapped,
|
|
213
|
+
...(version === KEYRING_RECORD_VERSION
|
|
214
|
+
? { proof: checkRecordProofShape({ proof, label }) }
|
|
215
|
+
: {})
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* The bind timestamp a wrap path stamps into a record's plaintext: the
|
|
220
|
+
* caller's, validated as a parseable ISO timestamp, or now. A caller supplies
|
|
221
|
+
* one when it pins record freshness, so it knows the stamp of the record it is
|
|
222
|
+
* writing without reading it back.
|
|
223
|
+
*
|
|
224
|
+
* @param options {object}
|
|
225
|
+
* @param [options.createdAt] {string} the caller's timestamp
|
|
226
|
+
* @returns {string}
|
|
227
|
+
*/
|
|
228
|
+
export function recordCreatedAtStamp({ createdAt }) {
|
|
229
|
+
if (createdAt === undefined) {
|
|
230
|
+
return new Date().toISOString();
|
|
231
|
+
}
|
|
232
|
+
if (typeof createdAt !== 'string' || Number.isNaN(Date.parse(createdAt))) {
|
|
233
|
+
throw new Error(`Invalid record createdAt timestamp "${createdAt}".`);
|
|
234
|
+
}
|
|
235
|
+
return createdAt;
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Parses and validates the required `createdAt` member of a record plaintext:
|
|
239
|
+
* the moment the record was bound, as an ISO timestamp that must parse. Apps
|
|
240
|
+
* pin freshness on it, so a record that cannot state its own bind time is
|
|
241
|
+
* refused rather than defaulted.
|
|
242
|
+
*
|
|
243
|
+
* @param options {object}
|
|
244
|
+
* @param options.value {unknown} the plaintext's `createdAt` member
|
|
245
|
+
* @param options.label {string} names the record kind in the refusal
|
|
246
|
+
* @returns {string}
|
|
247
|
+
*/
|
|
248
|
+
export function parseRecordCreatedAt({ value, label }) {
|
|
249
|
+
if (typeof value !== 'string' || Number.isNaN(Date.parse(value))) {
|
|
250
|
+
throw new Error(`${label} record has no valid createdAt timestamp.`);
|
|
251
|
+
}
|
|
252
|
+
return value;
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Parses and validates the optional `pointer` member of a keyring record
|
|
256
|
+
* plaintext. An absent member is a no-WAS record (returns undefined); a
|
|
257
|
+
* present-but-malformed one throws -- a record that claims a pointer but
|
|
258
|
+
* cannot state where the account lives is unusable.
|
|
259
|
+
*
|
|
260
|
+
* @param value {unknown} the record's `pointer` member
|
|
261
|
+
* @returns {AccountPointer | undefined}
|
|
262
|
+
*/
|
|
263
|
+
export function parseRecordPointer(value) {
|
|
264
|
+
if (value === undefined) {
|
|
265
|
+
return undefined;
|
|
266
|
+
}
|
|
267
|
+
if (value === null || typeof value !== 'object') {
|
|
268
|
+
throw new Error('Keyring record has a malformed account pointer.');
|
|
269
|
+
}
|
|
270
|
+
const { did, spaceId, host } = value;
|
|
271
|
+
if (typeof spaceId !== 'string' || !spaceId) {
|
|
272
|
+
throw new Error('Keyring record account pointer is missing its spaceId.');
|
|
273
|
+
}
|
|
274
|
+
if (typeof host !== 'string' || !host) {
|
|
275
|
+
throw new Error('Keyring record account pointer is missing its host.');
|
|
276
|
+
}
|
|
277
|
+
if (did !== undefined && (typeof did !== 'string' || !did)) {
|
|
278
|
+
throw new Error('Keyring record account pointer has a malformed did.');
|
|
279
|
+
}
|
|
280
|
+
return { ...(did ? { did } : {}), spaceId, host };
|
|
281
|
+
}
|
|
282
|
+
//# sourceMappingURL=recordEnvelope.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recordEnvelope.js","sourceRoot":"","sources":["../../src/keyring/recordEnvelope.ts"],"names":[],"mappings":"AA4BA,OAAO,EACL,kBAAkB,EAClB,6BAA6B,EAC7B,cAAc,EACd,cAAc,EAGf,MAAM,gCAAgC,CAAA;AACvC,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAA;AAElE;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAA;AA4BvC;;;;;;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;;;;;;;;;GASG;AACH,MAAM,UAAU,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AE,OAAO,EAAE,IAAI,EAAE,CAAA;AACnD,CAAC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { CapabilityAgent } from '@interop/capability-agent';
|
|
2
|
+
import type { ProfileAgents } from '@interop/was-client/identity';
|
|
3
|
+
import type { UnlockKdf } from './kdf.js';
|
|
4
|
+
import type { RecordSigner } from './record.js';
|
|
5
|
+
/**
|
|
6
|
+
* The load-bearing `CapabilityAgent` derivation names for an unlock identity
|
|
7
|
+
* (the counterpart of the data identity's bootstrap names): every unlock
|
|
8
|
+
* derivation runs through these exact strings, so they can never change
|
|
9
|
+
* without stranding existing accounts.
|
|
10
|
+
*/
|
|
11
|
+
export declare const UNLOCK_HANDLE = "unlock";
|
|
12
|
+
export declare const UNLOCK_KEY_NAME = "unlock-key";
|
|
13
|
+
/**
|
|
14
|
+
* Derives the full unlock identity from an unlock secret: the unlock
|
|
15
|
+
* CapabilityAgent, a ZcapClient that can both invoke and delegate (the
|
|
16
|
+
* unlock agent delegates a management zcap on its own Space to the account
|
|
17
|
+
* controller at bind time), the unlock KAK + resolver for wrap/unwrap, the
|
|
18
|
+
* record signer that signs and verifies the keyring record's proof, and the
|
|
19
|
+
* unlock Space id. Performs no I/O -- the derivation seam for tests and future
|
|
20
|
+
* unlock methods.
|
|
21
|
+
*
|
|
22
|
+
* @param options {object}
|
|
23
|
+
* @param options.secret {string | Uint8Array}
|
|
24
|
+
* @param options.kdf {UnlockKdf}
|
|
25
|
+
* @returns {Promise<UnlockIdentity>}
|
|
26
|
+
*/
|
|
27
|
+
export declare function deriveUnlockIdentity({ secret, kdf }: {
|
|
28
|
+
secret: string | Uint8Array;
|
|
29
|
+
kdf: UnlockKdf;
|
|
30
|
+
}): Promise<UnlockIdentity>;
|
|
31
|
+
/**
|
|
32
|
+
* Assembles the unlock identity from an already-derived 32-byte unlock seed.
|
|
33
|
+
* The seam that lets an app run the expensive stretch once per typed secret:
|
|
34
|
+
* `deriveUnlockSeed` yields the seed, and both this assembly and the
|
|
35
|
+
* standing-credential expansion (`unlock/standingClient`) consume it.
|
|
36
|
+
*
|
|
37
|
+
* @param options {object}
|
|
38
|
+
* @param options.seed {Uint8Array} the method's 32-byte unlock seed
|
|
39
|
+
* @returns {Promise<UnlockIdentity>}
|
|
40
|
+
*/
|
|
41
|
+
export declare function unlockIdentityFromSeed({ seed }: {
|
|
42
|
+
seed: Uint8Array;
|
|
43
|
+
}): Promise<UnlockIdentity>;
|
|
44
|
+
/**
|
|
45
|
+
* The unlock Space id an unlock identity addresses: was-client's
|
|
46
|
+
* `deriveSpaceId` over the unlock did:key (`base64url(SHA-256(did))`,
|
|
47
|
+
* unpadded) -- a discovery convention, not an authorization one (holding the
|
|
48
|
+
* id grants nothing). The address is wire-level (it is the one durable
|
|
49
|
+
* locator a fresh client holds), so it comes from the one shared derivation
|
|
50
|
+
* rather than a local restatement of it.
|
|
51
|
+
*
|
|
52
|
+
* @param options {object}
|
|
53
|
+
* @param options.did {string} the unlock identity's did:key
|
|
54
|
+
* @returns {string}
|
|
55
|
+
*/
|
|
56
|
+
export declare function unlockSpaceIdFor({ did }: {
|
|
57
|
+
did: string;
|
|
58
|
+
}): string;
|
|
59
|
+
/**
|
|
60
|
+
* The derived unlock identity, as `deriveUnlockIdentity` returns it. Stated
|
|
61
|
+
* explicitly rather than inferred from the return: the agent set's members
|
|
62
|
+
* are named by `ProfileAgents`, so the emitted declaration references this
|
|
63
|
+
* package's own copy of those types rather than whichever copy a linked
|
|
64
|
+
* dependency happens to carry.
|
|
65
|
+
*/
|
|
66
|
+
export interface UnlockIdentity extends Pick<ProfileAgents, 'zcapClient' | 'keyAgreementKey' | 'keyResolver'> {
|
|
67
|
+
agent: CapabilityAgent;
|
|
68
|
+
recordSigner: RecordSigner;
|
|
69
|
+
spaceId: string;
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=unlockIdentity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unlockIdentity.d.ts","sourceRoot":"","sources":["../../src/keyring/unlockIdentity.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAE3D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAA;AAEjE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAEzC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE/C;;;;;GAKG;AACH,eAAO,MAAM,aAAa,WAAW,CAAA;AACrC,eAAO,MAAM,eAAe,eAAe,CAAA;AAE3C;;;;;;;;;;;;;GAaG;AACH,wBAAsB,oBAAoB,CAAC,EACzC,MAAM,EACN,GAAG,EACJ,EAAE;IACD,MAAM,EAAE,MAAM,GAAG,UAAU,CAAA;IAC3B,GAAG,EAAE,SAAS,CAAA;CACf,GAAG,OAAO,CAAC,cAAc,CAAC,CAG1B;AAED;;;;;;;;;GASG;AACH,wBAAsB,sBAAsB,CAAC,EAC3C,IAAI,EACL,EAAE;IACD,IAAI,EAAE,UAAU,CAAA;CACjB,GAAG,OAAO,CAAC,cAAc,CAAC,CA4B1B;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,GAAG,EAAE,EAAE;IAAE,GAAG,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAEjE;AAED;;;;;;GAMG;AACH,MAAM,WAAW,cAAe,SAAQ,IAAI,CAC1C,aAAa,EACb,YAAY,GAAG,iBAAiB,GAAG,aAAa,CACjD;IACC,KAAK,EAAE,eAAe,CAAA;IACtB,YAAY,EAAE,YAAY,CAAA;IAC1B,OAAO,EAAE,MAAM,CAAA;CAChB"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2026 Interop Alliance. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* The unlock identity: what an unlock seed (`kdf.ts`) expands into. The
|
|
6
|
+
* identity's only jobs are addressing the minimal unlock Space and holding
|
|
7
|
+
* the key-agreement key the keyring record is encrypted to.
|
|
8
|
+
*
|
|
9
|
+
* Kept apart from the KDF so a caller that only derives a seed loads a hash
|
|
10
|
+
* library and nothing else. This file imports `kdf.ts`, and `kdf.ts` imports
|
|
11
|
+
* nothing from here.
|
|
12
|
+
*/
|
|
13
|
+
import { deriveSpaceId } from '@interop/was-client/sync';
|
|
14
|
+
import { CapabilityAgent } from '@interop/capability-agent';
|
|
15
|
+
import { agentsFromKeyAgent } from '@interop/was-client/identity';
|
|
16
|
+
import { deriveUnlockSeed } from './kdf.js';
|
|
17
|
+
import { recordSignerFromAgent } from './record.js';
|
|
18
|
+
/**
|
|
19
|
+
* The load-bearing `CapabilityAgent` derivation names for an unlock identity
|
|
20
|
+
* (the counterpart of the data identity's bootstrap names): every unlock
|
|
21
|
+
* derivation runs through these exact strings, so they can never change
|
|
22
|
+
* without stranding existing accounts.
|
|
23
|
+
*/
|
|
24
|
+
export const UNLOCK_HANDLE = 'unlock';
|
|
25
|
+
export const UNLOCK_KEY_NAME = 'unlock-key';
|
|
26
|
+
/**
|
|
27
|
+
* Derives the full unlock identity from an unlock secret: the unlock
|
|
28
|
+
* CapabilityAgent, a ZcapClient that can both invoke and delegate (the
|
|
29
|
+
* unlock agent delegates a management zcap on its own Space to the account
|
|
30
|
+
* controller at bind time), the unlock KAK + resolver for wrap/unwrap, the
|
|
31
|
+
* record signer that signs and verifies the keyring record's proof, and the
|
|
32
|
+
* unlock Space id. Performs no I/O -- the derivation seam for tests and future
|
|
33
|
+
* unlock methods.
|
|
34
|
+
*
|
|
35
|
+
* @param options {object}
|
|
36
|
+
* @param options.secret {string | Uint8Array}
|
|
37
|
+
* @param options.kdf {UnlockKdf}
|
|
38
|
+
* @returns {Promise<UnlockIdentity>}
|
|
39
|
+
*/
|
|
40
|
+
export async function deriveUnlockIdentity({ secret, kdf }) {
|
|
41
|
+
const seed = await deriveUnlockSeed({ secret, kdf });
|
|
42
|
+
return unlockIdentityFromSeed({ seed });
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Assembles the unlock identity from an already-derived 32-byte unlock seed.
|
|
46
|
+
* The seam that lets an app run the expensive stretch once per typed secret:
|
|
47
|
+
* `deriveUnlockSeed` yields the seed, and both this assembly and the
|
|
48
|
+
* standing-credential expansion (`unlock/standingClient`) consume it.
|
|
49
|
+
*
|
|
50
|
+
* @param options {object}
|
|
51
|
+
* @param options.seed {Uint8Array} the method's 32-byte unlock seed
|
|
52
|
+
* @returns {Promise<UnlockIdentity>}
|
|
53
|
+
*/
|
|
54
|
+
export async function unlockIdentityFromSeed({ seed }) {
|
|
55
|
+
const agent = await CapabilityAgent.fromSeed({
|
|
56
|
+
seed,
|
|
57
|
+
handle: UNLOCK_HANDLE,
|
|
58
|
+
keyName: UNLOCK_KEY_NAME
|
|
59
|
+
});
|
|
60
|
+
// The unlock KAK is the Montgomery form of the unlock signing key -- the same
|
|
61
|
+
// derivation the client side uses (`agentsFromSeed`), so a returning user
|
|
62
|
+
// reconstitutes the exact key that wrapped the keyring record.
|
|
63
|
+
const { zcapClient, keyAgreementKey, keyResolver } = agentsFromKeyAgent({
|
|
64
|
+
keyAgent: agent
|
|
65
|
+
});
|
|
66
|
+
// The record signer is the unlock signing key itself, named by its public
|
|
67
|
+
// multibase: the keyring record's proof is made and checked against a key
|
|
68
|
+
// that derives from the secret, so the storage host never holds it and a
|
|
69
|
+
// fresh client holds the verification prior by construction.
|
|
70
|
+
const recordSigner = recordSignerFromAgent({ keyAgent: agent });
|
|
71
|
+
const spaceId = unlockSpaceIdFor({ did: agent.id });
|
|
72
|
+
return {
|
|
73
|
+
agent,
|
|
74
|
+
zcapClient,
|
|
75
|
+
keyAgreementKey,
|
|
76
|
+
keyResolver,
|
|
77
|
+
recordSigner,
|
|
78
|
+
spaceId
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* The unlock Space id an unlock identity addresses: was-client's
|
|
83
|
+
* `deriveSpaceId` over the unlock did:key (`base64url(SHA-256(did))`,
|
|
84
|
+
* unpadded) -- a discovery convention, not an authorization one (holding the
|
|
85
|
+
* id grants nothing). The address is wire-level (it is the one durable
|
|
86
|
+
* locator a fresh client holds), so it comes from the one shared derivation
|
|
87
|
+
* rather than a local restatement of it.
|
|
88
|
+
*
|
|
89
|
+
* @param options {object}
|
|
90
|
+
* @param options.did {string} the unlock identity's did:key
|
|
91
|
+
* @returns {string}
|
|
92
|
+
*/
|
|
93
|
+
export function unlockSpaceIdFor({ did }) {
|
|
94
|
+
return deriveSpaceId(did);
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=unlockIdentity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unlockIdentity.js","sourceRoot":"","sources":["../../src/keyring/unlockIdentity.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;GAQG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAA;AAEjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAE3C,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAGnD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,QAAQ,CAAA;AACrC,MAAM,CAAC,MAAM,eAAe,GAAG,YAAY,CAAA;AAE3C;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,EACzC,MAAM,EACN,GAAG,EAIJ;IACC,MAAM,IAAI,GAAG,MAAM,gBAAgB,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAA;IACpD,OAAO,sBAAsB,CAAC,EAAE,IAAI,EAAE,CAAC,CAAA;AACzC,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAAC,EAC3C,IAAI,EAGL;IACC,MAAM,KAAK,GAAG,MAAM,eAAe,CAAC,QAAQ,CAAC;QAC3C,IAAI;QACJ,MAAM,EAAE,aAAa;QACrB,OAAO,EAAE,eAAe;KACzB,CAAC,CAAA;IACF,8EAA8E;IAC9E,0EAA0E;IAC1E,+DAA+D;IAC/D,MAAM,EAAE,UAAU,EAAE,eAAe,EAAE,WAAW,EAAE,GAAG,kBAAkB,CAAC;QACtE,QAAQ,EAAE,KAAK;KAChB,CAAC,CAAA;IAEF,0EAA0E;IAC1E,0EAA0E;IAC1E,yEAAyE;IACzE,6DAA6D;IAC7D,MAAM,YAAY,GAAG,qBAAqB,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAA;IAE/D,MAAM,OAAO,GAAG,gBAAgB,CAAC,EAAE,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAA;IACnD,OAAO;QACL,KAAK;QACL,UAAU;QACV,eAAe;QACf,WAAW;QACX,YAAY;QACZ,OAAO;KACR,CAAA;AACH,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,gBAAgB,CAAC,EAAE,GAAG,EAAmB;IACvD,OAAO,aAAa,CAAC,GAAG,CAAC,CAAA;AAC3B,CAAC"}
|
|
@@ -30,9 +30,20 @@ import type { ZcapClient } from '@interop/ezcap';
|
|
|
30
30
|
* apps unless a caller deliberately overrides it.
|
|
31
31
|
*/
|
|
32
32
|
export declare const UNLOCK_SPACE_NAME = "Freewallet Keyring";
|
|
33
|
+
/**
|
|
34
|
+
* The Space Description `type` array every unlock Space is created with,
|
|
35
|
+
* passphrase, passkey, and recovery-code alike (the keyring record inside
|
|
36
|
+
* names the credential kind). Wire-level and permanent: the server treats a
|
|
37
|
+
* Space's `type` as immutable after creation, and it is what recognizes an
|
|
38
|
+
* unlock Space from its Space Metadata object alone. `AuxiliarySpace` marks a
|
|
39
|
+
* bookkeeping Space holding no user data; `UnlockSpace` names the role.
|
|
40
|
+
* Sorted lexically, as the WAS spec recommends for a stable serialization.
|
|
41
|
+
*/
|
|
42
|
+
export declare const UNLOCK_SPACE_TYPE: string[];
|
|
33
43
|
/**
|
|
34
44
|
* Ensures the unlock Space and its single `keyring` collection exist
|
|
35
|
-
* (upsert -- idempotent).
|
|
45
|
+
* (upsert -- idempotent). The Space is configured with
|
|
46
|
+
* {@link UNLOCK_SPACE_TYPE}. Runs with the unlock root capability, so `force`
|
|
36
47
|
* lets the collection upsert treat a 404 from the pre-merge describe as
|
|
37
48
|
* genuinely absent rather than unreadable.
|
|
38
49
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unlockSpace.d.ts","sourceRoot":"","sources":["../../src/keyring/unlockSpace.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAAa,KAAK,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AACxE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAA;AACzD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAIhD;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,uBAAuB,CAAA;
|
|
1
|
+
{"version":3,"file":"unlockSpace.d.ts","sourceRoot":"","sources":["../../src/keyring/unlockSpace.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAAa,KAAK,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AACxE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAA;AACzD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAIhD;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,uBAAuB,CAAA;AAErD;;;;;;;;GAQG;AACH,eAAO,MAAM,iBAAiB,UAA6C,CAAA;AAwI3E;;;;;;;;;;;;;;;;;GAiBG;A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U,EACX,EAAE;IACD,gBAAgB,EAAE,MAAM,CAAA;IACxB,UAAU,EAAE,UAAU,CAAA;IACtB,kBAAkB,CAAC,EAAE,kBAAkB,CAAA;IACvC,OAAO,EAAE,MAAM,CAAA;IACf,UAAU,CAAC,EAAE,KAAK,CAAA;CACnB,GAAG,OAAO,CAAC;IAAE,OAAO,EAAE,SAAS,GAAG,WAAW,CAAA;CAAE,CAAC,CAOhD"}
|
|
@@ -30,6 +30,16 @@ import { plaintextCollection } from '../space/plaintextCollection.js';
|
|
|
30
30
|
* apps unless a caller deliberately overrides it.
|
|
31
31
|
*/
|
|
32
32
|
export const UNLOCK_SPACE_NAME = 'Freewallet Keyring';
|
|
33
|
+
/**
|
|
34
|
+
* The Space Description `type` array every unlock Space is created with,
|
|
35
|
+
* passphrase, passkey, and recovery-code alike (the keyring record inside
|
|
36
|
+
* names the credential kind). Wire-level and permanent: the server treats a
|
|
37
|
+
* Space's `type` as immutable after creation, and it is what recognizes an
|
|
38
|
+
* unlock Space from its Space Metadata object alone. `AuxiliarySpace` marks a
|
|
39
|
+
* bookkeeping Space holding no user data; `UnlockSpace` names the role.
|
|
40
|
+
* Sorted lexically, as the WAS spec recommends for a stable serialization.
|
|
41
|
+
*/
|
|
42
|
+
export const UNLOCK_SPACE_TYPE = ['AuxiliarySpace', 'Space', 'UnlockSpace'];
|
|
33
43
|
/**
|
|
34
44
|
* The bare WAS client for an unlock Space (see the module doc for why it wires
|
|
35
45
|
* in no encryption provider). Each exported function builds one and hands it
|
|
@@ -118,7 +128,8 @@ async function putPlaintextRecord({ was, spaceId, collectionId, resourceId, reco
|
|
|
118
128
|
}
|
|
119
129
|
/**
|
|
120
130
|
* Ensures the unlock Space and its single `keyring` collection exist
|
|
121
|
-
* (upsert -- idempotent).
|
|
131
|
+
* (upsert -- idempotent). The Space is configured with
|
|
132
|
+
* {@link UNLOCK_SPACE_TYPE}. Runs with the unlock root capability, so `force`
|
|
122
133
|
* lets the collection upsert treat a 404 from the pre-merge describe as
|
|
123
134
|
* genuinely absent rather than unreadable.
|
|
124
135
|
*
|
|
@@ -139,7 +150,9 @@ export async function ensureUnlockSpace({ storageServerUrl, zcapClient, serviceD
|
|
|
139
150
|
zcapClient,
|
|
140
151
|
serviceDescription
|
|
141
152
|
});
|
|
142
|
-
await was
|
|
153
|
+
await was
|
|
154
|
+
.space(spaceId)
|
|
155
|
+
.configure({ name, controller, type: UNLOCK_SPACE_TYPE });
|
|
143
156
|
await ensurePlaintextCollection({
|
|
144
157
|
was,
|
|
145
158
|
spaceId,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unlockSpace.js","sourceRoot":"","sources":["../../src/keyring/unlockSpace.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAAE,SAAS,EAA2B,MAAM,qBAAqB,CAAA;AAGxE,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAC9E,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAA;AAErE;;;;GAIG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,oBAAoB,CAAA;AAErD;;;;;;;;;;;;GAYG;AACH,SAAS,iBAAiB,CAAC,EACzB,gBAAgB,EAChB,UAAU,EACV,kBAAkB,EAKnB;IACC,OAAO,IAAI,SAAS,CAAC;QACnB,SAAS,EAAE,gBAAgB;QAC3B,UAAU;QACV,kBAAkB;KACnB,CAAC,CAAA;AACJ,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,KAAK,UAAU,yBAAyB,CAAC,EACvC,GAAG,EACH,OAAO,EACP,YAAY,EACZ,IAAI,EAML;IACC,MAAM,GAAG;SACN,KAAK,CAAC,OAAO,CAAC;SACd,UAAU,CAAC,YAAY,CAAC;SACxB,SAAS,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAA;AACrC,CAAC;AAED;;;;;;;;;;;;;;;G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EAAE,iBAAiB,CAAC;YACrB,gBAAgB;YAChB,UAAU;YACV,kBAAkB;SACnB,CAAC;QACF,OAAO;QACP,YAAY,EAAE,kBAAkB,CAAC,EAAE;QACnC,UAAU,EAAE,gBAAgB;QAC5B,MAAM;QACN,UAAU;KACX,CAAC,CAAA;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,EACtC,gBAAgB,EAChB,UAAU,EACV,kBAAkB,EAClB,OAAO,EACP,UAAU,EAOX;IACC,MAAM,GAAG,GAAG,iBAAiB,CAAC;QAC5B,gBAAgB;QAChB,UAAU;QACV,kBAAkB;KACnB,CAAC,CAAA;IACF,OAAO,GAAG,CAAC,KAAK,CAAC,OAAO,EAAE,EAAE,UAAU,EAAE,CAAC,CAAC,iBAAiB,EAAE,CAAA;AAC/D,CAAC"}
|
package/dist/keys/index.d.ts
CHANGED
|
@@ -95,12 +95,15 @@
|
|
|
95
95
|
* `WalletSpaceProvisioningError` when a collection was left without its
|
|
96
96
|
* epoch so the engine never memoizes a torn run.
|
|
97
97
|
*/
|
|
98
|
-
export { mintUserKey, USER_KEY_SALT,
|
|
98
|
+
export { mintUserKey, USER_KEY_SALT, userKeyVaultKeys } from './userKey.js';
|
|
99
|
+
export { userKeyRecordSigner, userKeySigningKeyMultibase, userKeySigningSeed } from './userKeySigning.js';
|
|
99
100
|
export type { UserKey } from './userKey.js';
|
|
100
101
|
export { assertEnrolledClientKeyRecord, decodeClientKeyRecord, encodeClientKeyRecord, isEnrolledClientKeyRecord, parseClientRecordPending, parseClientRecordUserKey, parseClientRecordWebvhKeys } from './clientKeyRecord.js';
|
|
101
102
|
export type { ClientKeyRecord, ClientKeyRecordJson, ClientKeyRecordPending, EnrolledClientKeyRecord } from './clientKeyRecord.js';
|
|
102
|
-
export { addUserKeyRosterRecipient, convergeUserKeyRosterToDocument, currentEpochOf, enrolledClientRosterRecipients, ensureUserKeyRoster, UserKeyRosterContinuityError, UserKeyRosterIntegrityError, UserKeyRosterUnwrapError, userKeyRosterLogSigner, userKeyRosterRecipientResolver, readUserKeyRoster, replaceUserKeyRosterRecipients,
|
|
103
|
-
export {
|
|
103
|
+
export { addUserKeyRosterRecipient, convergeUserKeyRosterToDocument, currentEpochOf, enrolledClientRosterRecipients, ensureUserKeyRoster, UserKeyRosterContinuityError, UserKeyRosterIntegrityError, UserKeyRosterUnwrapError, userKeyRosterLogSigner, userKeyRosterRecipientResolver, readUserKeyRoster, replaceUserKeyRosterRecipients, rosterRecipientsToRetire, rosterWrapsRecipient, rotateUserKeyRoster } from './userKeyRoster.js';
|
|
104
|
+
export { rosterRecipientKid } from './rosterRecipientKid.js';
|
|
105
|
+
export { cascadeCollectionsToUserKey, rotateCollectionEpochsToUserKey } from './userKeyCascade.js';
|
|
106
|
+
export { unwrapUserKeyGenerations, userKeyAsRecipient } from './userKeyGenerations.js';
|
|
104
107
|
export type { CollectionUserKeyRotationOutcome, UserKeyCascadeResult } from './userKeyCascade.js';
|
|
105
108
|
export { anchorRosterStoreAt, retireRosterRecipientAndCascade, rotateRosterToDocumentAndCascade } from './userKeyRosterCascade.js';
|
|
106
109
|
export type { CascadeCollections, RosterCascadeResult, RosterSealReport, UserKeyAdoptedHook } from './userKeyRosterCascade.js';
|
package/dist/keys/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/keys/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6FG;AACH,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/keys/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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B,uBAAuB,EACxB,MAAM,oBAAoB,CAAA;AAC3B,YAAY,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAA;AAEtE,OAAO,EACL,uBAAuB,EACvB,4BAA4B,EAC5B,0BAA0B,EAC3B,MAAM,yBAAyB,CAAA;AAChC,YAAY,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AACjE,OAAO,EACL,4BAA4B,EAC5B,kBAAkB,EACnB,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAA;AAC/D,YAAY,EAAE,iCAAiC,EAAE,MAAM,qBAAqB,CAAA;AAE5E,OAAO,EACL,uBAAuB,EACvB,uBAAuB,EACvB,4BAA4B,EAC5B,sBAAsB,EACvB,MAAM,kBAAkB,CAAA;AACzB,YAAY,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAA;AAE/D,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,cAAc,EACf,MAAM,mBAAmB,CAAA;AAC1B,YAAY,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AAE9E,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAA"}
|
package/dist/keys/index.js
CHANGED
|
@@ -95,10 +95,13 @@
|
|
|
95
95
|
* `WalletSpaceProvisioningError` when a collection was left without its
|
|
96
96
|
* epoch so the engine never memoizes a torn run.
|
|
97
97
|
*/
|
|
98
|
-
export { mintUserKey, USER_KEY_SALT,
|
|
98
|
+
export { mintUserKey, USER_KEY_SALT, userKeyVaultKeys } from './userKey.js';
|
|
99
|
+
export { userKeyRecordSigner, userKeySigningKeyMultibase, userKeySigningSeed } from './userKeySigning.js';
|
|
99
100
|
export { assertEnrolledClientKeyRecord, decodeClientKeyRecord, encodeClientKeyRecord, isEnrolledClientKeyRecord, parseClientRecordPending, parseClientRecordUserKey, parseClientRecordWebvhKeys } from './clientKeyRecord.js';
|
|
100
|
-
export { addUserKeyRosterRecipient, convergeUserKeyRosterToDocument, currentEpochOf, enrolledClientRosterRecipients, ensureUserKeyRoster, UserKeyRosterContinuityError, UserKeyRosterIntegrityError, UserKeyRosterUnwrapError, userKeyRosterLogSigner, userKeyRosterRecipientResolver, readUserKeyRoster, replaceUserKeyRosterRecipients,
|
|
101
|
-
export {
|
|
101
|
+
export { addUserKeyRosterRecipient, convergeUserKeyRosterToDocument, currentEpochOf, enrolledClientRosterRecipients, ensureUserKeyRoster, UserKeyRosterContinuityError, UserKeyRosterIntegrityError, UserKeyRosterUnwrapError, userKeyRosterLogSigner, userKeyRosterRecipientResolver, readUserKeyRoster, replaceUserKeyRosterRecipients, rosterRecipientsToRetire, rosterWrapsRecipient, rotateUserKeyRoster } from './userKeyRoster.js';
|
|
102
|
+
export { rosterRecipientKid } from './rosterRecipientKid.js';
|
|
103
|
+
export { cascadeCollectionsToUserKey, rotateCollectionEpochsToUserKey } from './userKeyCascade.js';
|
|
104
|
+
export { unwrapUserKeyGenerations, userKeyAsRecipient } from './userKeyGenerations.js';
|
|
102
105
|
export { anchorRosterStoreAt, retireRosterRecipientAndCascade, rotateRosterToDocumentAndCascade } from './userKeyRosterCascade.js';
|
|
103
106
|
export { accountCollectionStores, collectionDescriptorLogStore, collectionDescriptorStores } from './collectionLogStore.js';
|
|
104
107
|
export { userKeyRosterDescriptorStore, userKeyRosterPinId } from './rosterStore.js';
|
package/dist/keys/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/keys/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6FG;AACH,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/keys/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;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,CAAA;AAGzB,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,cAAc,EACf,MAAM,mBAAmB,CAAA;AAG1B,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAA"}
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
* current-epoch wrap) appends nothing, leaving the log's head carrying a
|
|
32
32
|
* controller version before the membership change it should have sealed.
|
|
33
33
|
*/
|
|
34
|
-
import { EPOCH_CONFIGURATION_STATE_TYPE, type EncryptionDescriptorStore } from '@interop/was-client/edv';
|
|
34
|
+
import { EPOCH_CONFIGURATION_STATE_TYPE, type EncryptionDescriptorStore } from '@interop/was-client/edv/core';
|
|
35
35
|
import type { ResourceLogPinStore, ResourceLogSigner, ResourceLogStore } from '@interop/vh-resource-log';
|
|
36
36
|
import { type ResourceLogClass, type WebvhResourceLogController } from '../resourceLog/index.js';
|
|
37
37
|
export { EPOCH_CONFIGURATION_STATE_TYPE };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rosterLogStore.d.ts","sourceRoot":"","sources":["../../src/keys/rosterLogStore.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,OAAO,EAEL,8BAA8B,EAC9B,KAAK,yBAAyB,EAC/B,MAAM,
|
|
1
|
+
{"version":3,"file":"rosterLogStore.d.ts","sourceRoot":"","sources":["../../src/keys/rosterLogStore.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,OAAO,EAEL,8BAA8B,EAC9B,KAAK,yBAAyB,EAC/B,MAAM,8BAA8B,CAAA;AACrC,OAAO,KAAK,EACV,mBAAmB,EACnB,iBAAiB,EACjB,gBAAgB,EACjB,MAAM,0BAA0B,CAAA;AACjC,OAAO,EAEL,KAAK,gBAAgB,EACrB,KAAK,0BAA0B,EAChC,MAAM,yBAAyB,CAAA;AAEhC,OAAO,EAA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