@interop/wallet-core 0.78.1 → 0.79.1
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 +18 -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 +39 -19
- 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 +59 -11
package/dist/keyring/kdf.d.ts
CHANGED
|
@@ -1,14 +1,3 @@
|
|
|
1
|
-
import { CapabilityAgent } from '@interop/capability-agent';
|
|
2
|
-
import type { ProfileAgents } from '@interop/was-client/identity';
|
|
3
|
-
import type { RecordSigner } from './record.js';
|
|
4
|
-
/**
|
|
5
|
-
* The load-bearing `CapabilityAgent` derivation names for an unlock identity
|
|
6
|
-
* (the counterpart of the data identity's bootstrap names): every unlock
|
|
7
|
-
* derivation runs through these exact strings, so they can never change
|
|
8
|
-
* without stranding existing accounts.
|
|
9
|
-
*/
|
|
10
|
-
export declare const UNLOCK_HANDLE = "unlock";
|
|
11
|
-
export declare const UNLOCK_KEY_NAME = "unlock-key";
|
|
12
1
|
/**
|
|
13
2
|
* Unlock-derivation parameters, one variant per KDF family: Argon2id
|
|
14
3
|
* (memory-hard) stretches a low-entropy passphrase; HKDF expands
|
|
@@ -75,62 +64,4 @@ export declare function deriveUnlockSeed({ secret, kdf }: {
|
|
|
75
64
|
secret: string | Uint8Array;
|
|
76
65
|
kdf: UnlockKdf;
|
|
77
66
|
}): Promise<Uint8Array>;
|
|
78
|
-
/**
|
|
79
|
-
* Derives the full unlock identity from an unlock secret: the unlock
|
|
80
|
-
* CapabilityAgent, a ZcapClient that can both invoke and delegate (the
|
|
81
|
-
* unlock agent delegates a management zcap on its own Space to the account
|
|
82
|
-
* controller at bind time), the unlock KAK + resolver for wrap/unwrap, the
|
|
83
|
-
* record signer that signs and verifies the keyring record's proof, and the
|
|
84
|
-
* unlock Space id. Performs no I/O -- the derivation seam for tests and future
|
|
85
|
-
* unlock methods.
|
|
86
|
-
*
|
|
87
|
-
* @param options {object}
|
|
88
|
-
* @param options.secret {string | Uint8Array}
|
|
89
|
-
* @param options.kdf {UnlockKdf}
|
|
90
|
-
* @returns {Promise<UnlockIdentity>}
|
|
91
|
-
*/
|
|
92
|
-
export declare function deriveUnlockIdentity({ secret, kdf }: {
|
|
93
|
-
secret: string | Uint8Array;
|
|
94
|
-
kdf: UnlockKdf;
|
|
95
|
-
}): Promise<UnlockIdentity>;
|
|
96
|
-
/**
|
|
97
|
-
* Assembles the unlock identity from an already-derived 32-byte unlock seed.
|
|
98
|
-
* The seam that lets an app run the expensive stretch once per typed secret:
|
|
99
|
-
* `deriveUnlockSeed` yields the seed, and both this assembly and the
|
|
100
|
-
* standing-credential expansion (`unlock/standingClient`) consume it.
|
|
101
|
-
*
|
|
102
|
-
* @param options {object}
|
|
103
|
-
* @param options.seed {Uint8Array} the method's 32-byte unlock seed
|
|
104
|
-
* @returns {Promise<UnlockIdentity>}
|
|
105
|
-
*/
|
|
106
|
-
export declare function unlockIdentityFromSeed({ seed }: {
|
|
107
|
-
seed: Uint8Array;
|
|
108
|
-
}): Promise<UnlockIdentity>;
|
|
109
|
-
/**
|
|
110
|
-
* The unlock Space id an unlock identity addresses: was-client's
|
|
111
|
-
* `deriveSpaceId` over the unlock did:key (`base64url(SHA-256(did))`,
|
|
112
|
-
* unpadded) -- a discovery convention, not an authorization one (holding the
|
|
113
|
-
* id grants nothing). The address is wire-level (it is the one durable
|
|
114
|
-
* locator a fresh client holds), so it comes from the one shared derivation
|
|
115
|
-
* rather than a local restatement of it.
|
|
116
|
-
*
|
|
117
|
-
* @param options {object}
|
|
118
|
-
* @param options.did {string} the unlock identity's did:key
|
|
119
|
-
* @returns {string}
|
|
120
|
-
*/
|
|
121
|
-
export declare function unlockSpaceIdFor({ did }: {
|
|
122
|
-
did: string;
|
|
123
|
-
}): string;
|
|
124
|
-
/**
|
|
125
|
-
* The derived unlock identity, as `deriveUnlockIdentity` returns it. Stated
|
|
126
|
-
* explicitly rather than inferred from the return: the agent set's members
|
|
127
|
-
* are named by `ProfileAgents`, so the emitted declaration references this
|
|
128
|
-
* package's own copy of those types rather than whichever copy a linked
|
|
129
|
-
* dependency happens to carry.
|
|
130
|
-
*/
|
|
131
|
-
export interface UnlockIdentity extends Pick<ProfileAgents, 'zcapClient' | 'keyAgreementKey' | 'keyResolver'> {
|
|
132
|
-
agent: CapabilityAgent;
|
|
133
|
-
recordSigner: RecordSigner;
|
|
134
|
-
spaceId: string;
|
|
135
|
-
}
|
|
136
67
|
//# sourceMappingURL=kdf.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kdf.d.ts","sourceRoot":"","sources":["../../src/keyring/kdf.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"kdf.d.ts","sourceRoot":"","sources":["../../src/keyring/kdf.ts"],"names":[],"mappings":"AA8BA;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,SAAS,GACjB;IACE,OAAO,EAAE,MAAM,CAAA;IACf,SAAS,EAAE,UAAU,CAAA;IACrB,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,MAAM,CAAA;IACd,WAAW,EAAE,MAAM,CAAA;IACnB,IAAI,EAAE,MAAM,CAAA;CACb,GACD;IACE,OAAO,EAAE,MAAM,CAAA;IACf,SAAS,EAAE,MAAM,CAAA;IACjB,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAEL;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,WAAW,EAAE,SAOzB,CAAA;AAoBD;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,gBAAgB,CAAC,EACrC,MAAM,EACN,GAAG,EACJ,EAAE;IACD,MAAM,EAAE,MAAM,GAAG,UAAU,CAAA;IAC3B,GAAG,EAAE,SAAS,CAAA;CACf,GAAG,OAAO,CAAC,UAAU,CAAC,CAuBtB"}
|
package/dist/keyring/kdf.js
CHANGED
|
@@ -3,10 +3,13 @@
|
|
|
3
3
|
*/
|
|
4
4
|
/**
|
|
5
5
|
* The unlock derivation: an unlock secret (a passphrase, or a passkey PRF
|
|
6
|
-
* output) to the unlock
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
6
|
+
* output) to the 32-byte unlock seed. `unlockIdentity.ts` expands that seed
|
|
7
|
+
* into the unlock identity that locates an account's keyring record and
|
|
8
|
+
* wraps/unwraps it. Nothing about the account is derivable from the secret.
|
|
9
|
+
*
|
|
10
|
+
* This file's only runtime imports are `@noble/hashes` modules, so an offline
|
|
11
|
+
* caller that only derives a seed loads no identity or proof dependencies.
|
|
12
|
+
* Keep it that way.
|
|
10
13
|
*
|
|
11
14
|
* The derivation is wire-level: two wallet apps must produce byte-identical
|
|
12
15
|
* output for the same secret and parameter set, or the same passphrase would
|
|
@@ -15,21 +18,9 @@
|
|
|
15
18
|
* React Native does not provide; Argon2id and HKDF are both fully specified
|
|
16
19
|
* (RFC 9106 / RFC 5869), so any two implementations agree bit for bit.
|
|
17
20
|
*/
|
|
18
|
-
import { deriveSpaceId } from '@interop/was-client/sync';
|
|
19
|
-
import { CapabilityAgent } from '@interop/capability-agent';
|
|
20
21
|
import { argon2idAsync } from '@noble/hashes/argon2.js';
|
|
21
22
|
import { hkdf } from '@noble/hashes/hkdf.js';
|
|
22
23
|
import { sha256, sha512 } from '@noble/hashes/sha2.js';
|
|
23
|
-
import { agentsFromKeyAgent } from '@interop/was-client/identity';
|
|
24
|
-
import { recordSignerFromAgent } from './record.js';
|
|
25
|
-
/**
|
|
26
|
-
* The load-bearing `CapabilityAgent` derivation names for an unlock identity
|
|
27
|
-
* (the counterpart of the data identity's bootstrap names): every unlock
|
|
28
|
-
* derivation runs through these exact strings, so they can never change
|
|
29
|
-
* without stranding existing accounts.
|
|
30
|
-
*/
|
|
31
|
-
export const UNLOCK_HANDLE = 'unlock';
|
|
32
|
-
export const UNLOCK_KEY_NAME = 'unlock-key';
|
|
33
24
|
/**
|
|
34
25
|
* The number of bytes an unlock derivation produces (a 32-byte seed, which is
|
|
35
26
|
* what `CapabilityAgent.fromSeed` takes).
|
|
@@ -111,74 +102,4 @@ export async function deriveUnlockSeed({ secret, kdf }) {
|
|
|
111
102
|
}
|
|
112
103
|
return hkdf(nobleHash(kdf.hash), secretBytes, salt, new TextEncoder().encode(kdf.info), UNLOCK_SEED_BYTES);
|
|
113
104
|
}
|
|
114
|
-
/**
|
|
115
|
-
* Derives the full unlock identity from an unlock secret: the unlock
|
|
116
|
-
* CapabilityAgent, a ZcapClient that can both invoke and delegate (the
|
|
117
|
-
* unlock agent delegates a management zcap on its own Space to the account
|
|
118
|
-
* controller at bind time), the unlock KAK + resolver for wrap/unwrap, the
|
|
119
|
-
* record signer that signs and verifies the keyring record's proof, and the
|
|
120
|
-
* unlock Space id. Performs no I/O -- the derivation seam for tests and future
|
|
121
|
-
* unlock methods.
|
|
122
|
-
*
|
|
123
|
-
* @param options {object}
|
|
124
|
-
* @param options.secret {string | Uint8Array}
|
|
125
|
-
* @param options.kdf {UnlockKdf}
|
|
126
|
-
* @returns {Promise<UnlockIdentity>}
|
|
127
|
-
*/
|
|
128
|
-
export async function deriveUnlockIdentity({ secret, kdf }) {
|
|
129
|
-
const seed = await deriveUnlockSeed({ secret, kdf });
|
|
130
|
-
return unlockIdentityFromSeed({ seed });
|
|
131
|
-
}
|
|
132
|
-
/**
|
|
133
|
-
* Assembles the unlock identity from an already-derived 32-byte unlock seed.
|
|
134
|
-
* The seam that lets an app run the expensive stretch once per typed secret:
|
|
135
|
-
* `deriveUnlockSeed` yields the seed, and both this assembly and the
|
|
136
|
-
* standing-credential expansion (`unlock/standingClient`) consume it.
|
|
137
|
-
*
|
|
138
|
-
* @param options {object}
|
|
139
|
-
* @param options.seed {Uint8Array} the method's 32-byte unlock seed
|
|
140
|
-
* @returns {Promise<UnlockIdentity>}
|
|
141
|
-
*/
|
|
142
|
-
export async function unlockIdentityFromSeed({ seed }) {
|
|
143
|
-
const agent = await CapabilityAgent.fromSeed({
|
|
144
|
-
seed,
|
|
145
|
-
handle: UNLOCK_HANDLE,
|
|
146
|
-
keyName: UNLOCK_KEY_NAME
|
|
147
|
-
});
|
|
148
|
-
// The unlock KAK is the Montgomery form of the unlock signing key -- the same
|
|
149
|
-
// derivation the client side uses (`agentsFromSeed`), so a returning user
|
|
150
|
-
// reconstitutes the exact key that wrapped the keyring record.
|
|
151
|
-
const { zcapClient, keyAgreementKey, keyResolver } = agentsFromKeyAgent({
|
|
152
|
-
keyAgent: agent
|
|
153
|
-
});
|
|
154
|
-
// The record signer is the unlock signing key itself, named by its public
|
|
155
|
-
// multibase: the keyring record's proof is made and checked against a key
|
|
156
|
-
// that derives from the secret, so the storage host never holds it and a
|
|
157
|
-
// fresh client holds the verification prior by construction.
|
|
158
|
-
const recordSigner = recordSignerFromAgent({ keyAgent: agent });
|
|
159
|
-
const spaceId = unlockSpaceIdFor({ did: agent.id });
|
|
160
|
-
return {
|
|
161
|
-
agent,
|
|
162
|
-
zcapClient,
|
|
163
|
-
keyAgreementKey,
|
|
164
|
-
keyResolver,
|
|
165
|
-
recordSigner,
|
|
166
|
-
spaceId
|
|
167
|
-
};
|
|
168
|
-
}
|
|
169
|
-
/**
|
|
170
|
-
* The unlock Space id an unlock identity addresses: was-client's
|
|
171
|
-
* `deriveSpaceId` over the unlock did:key (`base64url(SHA-256(did))`,
|
|
172
|
-
* unpadded) -- a discovery convention, not an authorization one (holding the
|
|
173
|
-
* id grants nothing). The address is wire-level (it is the one durable
|
|
174
|
-
* locator a fresh client holds), so it comes from the one shared derivation
|
|
175
|
-
* rather than a local restatement of it.
|
|
176
|
-
*
|
|
177
|
-
* @param options {object}
|
|
178
|
-
* @param options.did {string} the unlock identity's did:key
|
|
179
|
-
* @returns {string}
|
|
180
|
-
*/
|
|
181
|
-
export function unlockSpaceIdFor({ did }) {
|
|
182
|
-
return deriveSpaceId(did);
|
|
183
|
-
}
|
|
184
105
|
//# sourceMappingURL=kdf.js.map
|
package/dist/keyring/kdf.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kdf.js","sourceRoot":"","sources":["../../src/keyring/kdf.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH
|
|
1
|
+
{"version":3,"file":"kdf.js","sourceRoot":"","sources":["../../src/keyring/kdf.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAA;AACvD,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAA;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AAEtD;;;GAGG;AACH,MAAM,iBAAiB,GAAG,EAAE,CAAA;AAgC5B;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,MAAM,WAAW,GAAc;IACpC,OAAO,EAAE,CAAC;IACV,SAAS,EAAE,UAAU;IACrB,MAAM,EAAE,MAAM;IACd,MAAM,EAAE,CAAC;IACT,WAAW,EAAE,CAAC;IACd,IAAI,EAAE,uCAAuC;CAC9C,CAAA;AAED;;;;;;;GAOG;AACH,SAAS,SAAS,CAAC,IAAY;IAC7B,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACvB,OAAO,MAAM,CAAA;IACf,CAAC;IACD,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACvB,OAAO,MAAM,CAAA;IACf,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,gCAAgC,IAAI,IAAI,CAAC,CAAA;AAC3D,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,EACrC,MAAM,EACN,GAAG,EAIJ;IACC,0EAA0E;IAC1E,kEAAkE;IAClE,MAAM,WAAW,GACf,OAAO,MAAM,KAAK,QAAQ;QACxB,CAAC,CAAC,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC;QAClC,CAAC,CAAC,IAAI,UAAU,CAAC,MAAM,CAAC,CAAA;IAC5B,MAAM,IAAI,GAAG,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;IAC/C,IAAI,GAAG,CAAC,SAAS,KAAK,UAAU,EAAE,CAAC;QACjC,OAAO,aAAa,CAAC,WAAW,EAAE,IAAI,EAAE;YACtC,CAAC,EAAE,GAAG,CAAC,MAAM;YACb,CAAC,EAAE,GAAG,CAAC,MAAM;YACb,CAAC,EAAE,GAAG,CAAC,WAAW;YAClB,KAAK,EAAE,iBAAiB;SACzB,CAAC,CAAA;IACJ,CAAC;IACD,OAAO,IAAI,CACT,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,EACnB,WAAW,EACX,IAAI,EACJ,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,EAClC,iBAAiB,CAClB,CAAA;AACH,CAAC"}
|
package/dist/keyring/record.d.ts
CHANGED
|
@@ -1,14 +1,6 @@
|
|
|
1
1
|
import type { IKeyAgreementKey, IKeyResolver } from '@interop/data-integrity-core';
|
|
2
2
|
import type { CollectionEncryption } from '@interop/was-client';
|
|
3
|
-
import {
|
|
4
|
-
/**
|
|
5
|
-
* The version stamped on the stored `{ version, encryption, wrapped, proof }`
|
|
6
|
-
* keyring envelope: the signed record, whose envelope seals under the record's
|
|
7
|
-
* own key epoch (the `encryption` member) and whose sibling members carry a
|
|
8
|
-
* Data Integrity proof by the unlock identity's signing key. Any other version
|
|
9
|
-
* is refused as unusable -- such accounts are re-provisioned, not migrated.
|
|
10
|
-
*/
|
|
11
|
-
export declare const KEYRING_RECORD_VERSION = 2;
|
|
3
|
+
import type { AccountPointer, KeyringRecordContents, SignedRecord } from './recordEnvelope.js';
|
|
12
4
|
/**
|
|
13
5
|
* The record signer's seam: the signing key's public multibase (which names
|
|
14
6
|
* the key in the proof's `verificationMethod`) and a raw detached-signature
|
|
@@ -22,42 +14,6 @@ export interface RecordSigner {
|
|
|
22
14
|
data: Uint8Array;
|
|
23
15
|
}): Promise<Uint8Array>;
|
|
24
16
|
}
|
|
25
|
-
/**
|
|
26
|
-
* The fixed proof shape a signed record carries: an eddsa-jcs-2022 Data
|
|
27
|
-
* Integrity proof over the record's sibling members, `assertionMethod`
|
|
28
|
-
* purpose, with the signing key named by a `did:key:<multibase>#<multibase>`
|
|
29
|
-
* verification method.
|
|
30
|
-
*/
|
|
31
|
-
export interface RecordProof {
|
|
32
|
-
type: 'DataIntegrityProof';
|
|
33
|
-
cryptosuite: 'eddsa-jcs-2022';
|
|
34
|
-
verificationMethod: string;
|
|
35
|
-
proofPurpose: 'assertionMethod';
|
|
36
|
-
created?: string;
|
|
37
|
-
proofValue: string;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* A stored signed record: the frame members the proof secures, plus the proof
|
|
41
|
-
* itself.
|
|
42
|
-
*/
|
|
43
|
-
export interface SignedRecord {
|
|
44
|
-
version: number;
|
|
45
|
-
encryption: CollectionEncryption;
|
|
46
|
-
wrapped: unknown;
|
|
47
|
-
proof: RecordProof;
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* A record's proof is absent, malformed, signed by a key this client does not
|
|
51
|
-
* accept, or does not verify over the record's own members. Its own class,
|
|
52
|
-
* distinct from a decrypt failure or an unusable-version refusal: this is the
|
|
53
|
-
* refusal that says the storage host forged or tampered with the record, which
|
|
54
|
-
* an app maps to its own login copy.
|
|
55
|
-
*/
|
|
56
|
-
export declare class RecordProofError extends Error {
|
|
57
|
-
constructor(message: string, options?: {
|
|
58
|
-
cause?: unknown;
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
17
|
/**
|
|
62
18
|
* Adapts a signing key agent (the unlock identity's `CapabilityAgent`, or an
|
|
63
19
|
* enrolled client's own key agent) to the record signer seam: the agent's
|
|
@@ -130,98 +86,6 @@ export declare function recordProofKeyMultibase({ verificationMethod, label }: {
|
|
|
130
86
|
verificationMethod: string;
|
|
131
87
|
label: string;
|
|
132
88
|
}): string;
|
|
133
|
-
/**
|
|
134
|
-
* Mints the one-epoch descriptor a fresh record is sealed under: epoch[0]
|
|
135
|
-
* wrapped to the given KAK alone, built through `initRecipients` against a
|
|
136
|
-
* throwaway in-memory store (the descriptor's home is the record itself).
|
|
137
|
-
* Exported for any consumer sealing a self-contained
|
|
138
|
-
* `{ version, encryption, wrapped }` record -- the keyring and recovery
|
|
139
|
-
* records here, and a wallet app's own locally stored records (e.g.
|
|
140
|
-
* freewallet's client-key record and unlock-methods registry).
|
|
141
|
-
*
|
|
142
|
-
* @param options {object}
|
|
143
|
-
* @param options.keyAgreementKey {IKeyAgreementKey} the wrapping KAK (for
|
|
144
|
-
* the keyring record, the unlock KAK)
|
|
145
|
-
* @returns {Promise<CollectionEncryption>}
|
|
146
|
-
*/
|
|
147
|
-
export declare function mintRecordEncryption({ keyAgreementKey }: {
|
|
148
|
-
keyAgreementKey: IKeyAgreementKey;
|
|
149
|
-
}): Promise<CollectionEncryption>;
|
|
150
|
-
/**
|
|
151
|
-
* Builds the record's reading cipher: an EDV cipher over the record's own
|
|
152
|
-
* descriptor, from the reader's key-agreement key. The unwrap paths' cipher
|
|
153
|
-
* (and the recovery record's, which reuses the keyring cipher context
|
|
154
|
-
* verbatim); the wrap paths seal through {@link recordSealCipher} instead. An
|
|
155
|
-
* app's own record kind passes its own `collectionId` so its failures name
|
|
156
|
-
* the record kind. The context labels errors only -- the codec is agnostic to
|
|
157
|
-
* it, so a record kind's real swap protection is its contents validation on
|
|
158
|
-
* unwrap.
|
|
159
|
-
*
|
|
160
|
-
* @param options {object}
|
|
161
|
-
* @param options.keyAgreementKey {IKeyAgreementKey} the wrapping KAK (for
|
|
162
|
-
* the keyring record, the unlock KAK)
|
|
163
|
-
* @param options.keyResolver {IKeyResolver}
|
|
164
|
-
* @param options.encryption {CollectionEncryption} the record's descriptor
|
|
165
|
-
* @param [options.collectionId] {string} the cipher context failures are
|
|
166
|
-
* labeled with; defaults to the keyring context
|
|
167
|
-
* @returns {Promise<DocCipher>}
|
|
168
|
-
*/
|
|
169
|
-
export declare function recordCipher({ keyAgreementKey, keyResolver, encryption, collectionId }: {
|
|
170
|
-
keyAgreementKey: IKeyAgreementKey;
|
|
171
|
-
keyResolver: IKeyResolver;
|
|
172
|
-
encryption: CollectionEncryption;
|
|
173
|
-
collectionId?: string;
|
|
174
|
-
}): Promise<DocCipher>;
|
|
175
|
-
/**
|
|
176
|
-
* Builds the record's sealing cipher: an encrypt-only EDV cipher over the
|
|
177
|
-
* record's own descriptor, needing no key-agreement secret -- a write seals to
|
|
178
|
-
* the descriptor's epoch public key, reconstructed from the epoch id. This is
|
|
179
|
-
* what lets the recovery re-mint, which holds only the code's unlock KAK
|
|
180
|
-
* public half, re-seal a record it can never open; the issuance wraps go
|
|
181
|
-
* through the same construction and produce the same envelope shape. Decrypt
|
|
182
|
-
* on it refuses with was-client's typed `EncryptOnlyCipherError`.
|
|
183
|
-
*
|
|
184
|
-
* @param options {object}
|
|
185
|
-
* @param options.encryption {CollectionEncryption} the record's descriptor
|
|
186
|
-
* @param [options.collectionId] {string} the cipher context failures are
|
|
187
|
-
* labeled with; defaults to the keyring context
|
|
188
|
-
* @returns {Promise<DocCipher>}
|
|
189
|
-
*/
|
|
190
|
-
export declare function recordSealCipher({ encryption, collectionId }: {
|
|
191
|
-
encryption: CollectionEncryption;
|
|
192
|
-
collectionId?: string;
|
|
193
|
-
}): Promise<DocCipher>;
|
|
194
|
-
/**
|
|
195
|
-
* Validates the common `{ version, encryption, wrapped }` frame of a stored
|
|
196
|
-
* record (keyring or recovery -- `label` names the refusals) and returns its
|
|
197
|
-
* members, the `proof` among them for the signed frame. Exported so an app's
|
|
198
|
-
* own record kinds open their records through the same frame validation the
|
|
199
|
-
* codec here seals with, rather than re-deriving the version and shape checks.
|
|
200
|
-
*
|
|
201
|
-
* A frame at the keyring record version is the signed frame, so it must carry
|
|
202
|
-
* a fixed-shape proof; a record kind stamping its own version is unaffected
|
|
203
|
-
* (its authenticity story is its own). Validating the shape here does not
|
|
204
|
-
* verify it -- {@link verifyRecordProof} does, and every unwrap path in this
|
|
205
|
-
* module runs it before decrypting.
|
|
206
|
-
*
|
|
207
|
-
* @param options {object}
|
|
208
|
-
* @param options.record {unknown}
|
|
209
|
-
* @param options.label {string} `'keyring'`, `'recovery'`, or an app record
|
|
210
|
-
* kind's own label
|
|
211
|
-
* @param [options.version] {number} the version the frame must carry;
|
|
212
|
-
* defaults to the keyring record version
|
|
213
|
-
* @returns {{ encryption: CollectionEncryption, wrapped: unknown,
|
|
214
|
-
* proof?: RecordProof }}
|
|
215
|
-
*/
|
|
216
|
-
export declare function parseRecordFrame({ record, label, version }: {
|
|
217
|
-
record: unknown;
|
|
218
|
-
label: string;
|
|
219
|
-
version?: number;
|
|
220
|
-
}): {
|
|
221
|
-
encryption: CollectionEncryption;
|
|
222
|
-
wrapped: unknown;
|
|
223
|
-
proof?: RecordProof;
|
|
224
|
-
};
|
|
225
89
|
/**
|
|
226
90
|
* Verifies a stored record's proof: the fixed proof shape, the signing key
|
|
227
91
|
* against the caller's allowlist, and the signature over the record's sibling
|
|
@@ -248,31 +112,6 @@ export declare function verifyRecordProof({ record, allowedKeyMultibases, label
|
|
|
248
112
|
allowedKeyMultibases: string | string[];
|
|
249
113
|
label?: string;
|
|
250
114
|
}): Promise<string>;
|
|
251
|
-
/**
|
|
252
|
-
* The account pointer a keyring record carries in place of the retired data
|
|
253
|
-
* seed: where the account lives (`spaceId` + `host`, the WAS server's base
|
|
254
|
-
* URL, which carries a base path when the server is deployed under a
|
|
255
|
-
* sub-path) and, once provisioning has published it, the account's stable
|
|
256
|
-
* did:webvh id. Discovery only -- holding the pointer authorizes nothing.
|
|
257
|
-
*/
|
|
258
|
-
export interface AccountPointer {
|
|
259
|
-
did?: string;
|
|
260
|
-
spaceId: string;
|
|
261
|
-
host: string;
|
|
262
|
-
}
|
|
263
|
-
/**
|
|
264
|
-
* The unwrapped contents of a keyring record: the account controller (the
|
|
265
|
-
* first enrolled client's did:key today), the account email captured at bind
|
|
266
|
-
* time (when one was given -- carried so any unlock method recovers it; a
|
|
267
|
-
* passkey login has no login form to ask on), and the account pointer (absent
|
|
268
|
-
* only on no-WAS deployments, where there is no Space to point at).
|
|
269
|
-
*/
|
|
270
|
-
export interface KeyringRecordContents {
|
|
271
|
-
controller: string;
|
|
272
|
-
email?: string;
|
|
273
|
-
pointer?: AccountPointer;
|
|
274
|
-
createdAt: string;
|
|
275
|
-
}
|
|
276
115
|
/**
|
|
277
116
|
* Wraps the account-pointer contents into a keyring record: the controller,
|
|
278
117
|
* email, and pointer (+ timestamp) sealed under a freshly minted record epoch
|
|
@@ -330,42 +169,4 @@ export declare function unwrapKeyringRecord({ record, keyAgreementKey, keyResolv
|
|
|
330
169
|
keyResolver: IKeyResolver;
|
|
331
170
|
expectedKeyMultibase: string;
|
|
332
171
|
}): Promise<KeyringRecordContents>;
|
|
333
|
-
/**
|
|
334
|
-
* The bind timestamp a wrap path stamps into a record's plaintext: the
|
|
335
|
-
* caller's, validated as a parseable ISO timestamp, or now. A caller supplies
|
|
336
|
-
* one when it pins record freshness, so it knows the stamp of the record it is
|
|
337
|
-
* writing without reading it back.
|
|
338
|
-
*
|
|
339
|
-
* @param options {object}
|
|
340
|
-
* @param [options.createdAt] {string} the caller's timestamp
|
|
341
|
-
* @returns {string}
|
|
342
|
-
*/
|
|
343
|
-
export declare function recordCreatedAtStamp({ createdAt }: {
|
|
344
|
-
createdAt?: string;
|
|
345
|
-
}): string;
|
|
346
|
-
/**
|
|
347
|
-
* Parses and validates the required `createdAt` member of a record plaintext:
|
|
348
|
-
* the moment the record was bound, as an ISO timestamp that must parse. Apps
|
|
349
|
-
* pin freshness on it, so a record that cannot state its own bind time is
|
|
350
|
-
* refused rather than defaulted.
|
|
351
|
-
*
|
|
352
|
-
* @param options {object}
|
|
353
|
-
* @param options.value {unknown} the plaintext's `createdAt` member
|
|
354
|
-
* @param options.label {string} names the record kind in the refusal
|
|
355
|
-
* @returns {string}
|
|
356
|
-
*/
|
|
357
|
-
export declare function parseRecordCreatedAt({ value, label }: {
|
|
358
|
-
value: unknown;
|
|
359
|
-
label: string;
|
|
360
|
-
}): string;
|
|
361
|
-
/**
|
|
362
|
-
* Parses and validates the optional `pointer` member of a keyring record
|
|
363
|
-
* plaintext. An absent member is a no-WAS record (returns undefined); a
|
|
364
|
-
* present-but-malformed one throws -- a record that claims a pointer but
|
|
365
|
-
* cannot state where the account lives is unusable.
|
|
366
|
-
*
|
|
367
|
-
* @param value {unknown} the record's `pointer` member
|
|
368
|
-
* @returns {AccountPointer | undefined}
|
|
369
|
-
*/
|
|
370
|
-
export declare function parseRecordPointer(value: unknown): AccountPointer | undefined;
|
|
371
172
|
//# sourceMappingURL=record.d.ts.map
|
|
@@ -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":"AAsCA,OAAO,KAAK,EACV,gBAAgB,EAChB,YAAY,EACb,MAAM,8BAA8B,CAAA;AACrC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAA;AAe/D,OAAO,KAAK,EACV,cAAc,EACd,qBAAqB,EAErB,YAAY,EACb,MAAM,qBAAqB,CAAA;AAE5B;;;;;;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;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CAAC,EACpC,QAAQ,EACT,EAAE;IACD,QAAQ,EAAE;QACR,EAAE,EAAE,MAAM,CAAA;QACV,SAAS,EAAE,MAAM;YACf,IAAI,EAAE,CAAC,KAAK,EAAE;gBAAE,IAAI,EAAE,UAAU,CAAA;aAAE,KAAK,OAAO,CAAC,UAAU,CAAC,CAAA;SAC3D,CAAA;KACF,CAAA;CACF,GAAG,YAAY,CAmBf;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,oBAAoB,CAAC,EACzC,IAAI,EACL,EAAE;IACD,IAAI,EAAE,UAAU,CAAA;CACjB,GAAG,OAAO,CAAC,YAAY,CAAC,CAQxB;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,eAAe,CAAC,EACpC,OAAO,EACP,UAAU,EACV,OAAO,EACP,MAAM,EACN,OAAO,EACR,EAAE;IACD,OAAO,EAAE,MAAM,CAAA;IACf,UAAU,EAAE,oBAAoB,CAAA;IAChC,OAAO,EAAE,OAAO,CAAA;IAChB,MAAM,EAAE,YAAY,CAAA;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAClC,GAAG,OAAO,CAAC,YAAY,CAAC,CAiBxB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,uBAAuB,CAAC,EACtC,kBAAkB,EAClB,KAAK,EACN,EAAE;IACD,kBAAkB,EAAE,MAAM,CAAA;IAC1B,KAAK,EAAE,MAAM,CAAA;CACd,GAAG,MAAM,CAST;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,iBAAiB,CAAC,EACtC,MAAM,EACN,oBAAoB,EACpB,KAAiB,EAClB,EAAE;IACD,MAAM,EAAE,OAAO,CAAA;IACf,oBAAoB,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;IACvC,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,GAAG,OAAO,CAAC,MAAM,CAAC,CAyClB;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAsB,iBAAiB,CAAC,EACtC,UAAU,EACV,KAAK,EACL,OAAO,EACP,eAAe,EACf,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,MAAM,EAAE,YAAY,CAAA;IACpB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,GAAG,OAAO,CAAC,YAAY,CAAC,CAyBxB;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,CA4CjC"}
|