@dotrino/identity 0.136.0 → 0.136.2
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/package.json +3 -2
- package/src/index.d.ts +60 -2
- package/src/index.js +364 -81
- package/src/node.js +29 -5
- package/types/acta.d.ts +397 -175
- package/types/assertion.d.ts +25 -18
- package/types/avatar.d.ts +14 -3
- package/types/capabilities.d.ts +110 -61
- package/types/content.d.ts +88 -45
- package/types/core.d.ts +578 -383
- package/types/keyid.d.ts +10 -3
- package/types/machine.d.ts +5 -1
- package/types/peerStore.d.ts +80 -0
- package/types/peerSync.d.ts +20 -6
- package/types/remote.d.ts +170 -42
- package/types/session.d.ts +74 -81
- package/types/sessionFlow.d.ts +108 -33
- package/types/vaultSeal.d.ts +21 -9
- package/vault/acta.js +245 -29
- package/vault/assertion.js +13 -4
- package/vault/avatar.js +12 -1
- package/vault/capabilities.js +56 -6
- package/vault/channel.js +18 -2
- package/vault/content.js +60 -6
- package/vault/core.js +419 -88
- package/vault/externalKeys.js +34 -2
- package/vault/facade.js +182 -24
- package/vault/globals.d.ts +60 -0
- package/vault/keyid.js +10 -1
- package/vault/machine.js +7 -1
- package/vault/nativeStore.js +21 -4
- package/vault/originPolicy.js +13 -2
- package/vault/peerStore.js +57 -10
- package/vault/peerSync.js +23 -4
- package/vault/remote.js +132 -32
- package/vault/session.js +24 -7
- package/vault/sessionFlow.js +43 -9
- package/vault/sync.js +59 -15
- package/vault/vault.js +78 -49
- package/vault/vaultSeal.js +18 -7
- package/vault/vendor/compat/VERSION.txt +1 -1
- package/vault/vendor/compat/advisory.js +58 -8
- package/vault/vendor/compat/index.js +57 -6
- package/vault/vendor/compat/ranges.js +12 -2
- package/vault/vendor/proxy-client/VERSION.txt +1 -1
- package/vault/vendor/proxy-client/client.js +41 -19
- package/vault/vendor/roadmap/manifests.js +23 -23
- package/vault/vendor/store/VERSION.txt +1 -1
- package/vault/vendor/vault/VERSION.txt +1 -1
- package/vault/vendor/vault/core/libVersion.js +1 -1
- package/vault/vendor/vault/core/transport.js +15 -3
- package/vault/vendor/vault/core/vault.js +71 -1
- package/vault/vendor/vault/protocol.js +25 -0
package/types/assertion.d.ts
CHANGED
|
@@ -6,10 +6,16 @@
|
|
|
6
6
|
* Pedir alcances desconocidos NO es un aviso que se pueda ignorar: se descartan, y si no
|
|
7
7
|
* queda ninguno se emite el mínimo (`id:whoami`), que es lo que significa «solo quiero
|
|
8
8
|
* saber quién eres».
|
|
9
|
+
* @param {unknown} scopes
|
|
10
|
+
* @returns {string[]}
|
|
9
11
|
*/
|
|
10
|
-
export function cleanScopes(scopes:
|
|
11
|
-
/**
|
|
12
|
-
|
|
12
|
+
export function cleanScopes(scopes: unknown): string[];
|
|
13
|
+
/**
|
|
14
|
+
* Las claves de datos que esos alcances permiten llevar.
|
|
15
|
+
* @param {unknown} scopes
|
|
16
|
+
* @returns {Set<string>}
|
|
17
|
+
*/
|
|
18
|
+
export function claimsAllowed(scopes: unknown): Set<string>;
|
|
13
19
|
/**
|
|
14
20
|
* El cuerpo que se firma. Se construye AQUÍ y en un solo sitio, porque quien firma y quien
|
|
15
21
|
* verifica tienen que estar mirando exactamente los mismos campos: si el emisor añadiera
|
|
@@ -18,25 +24,26 @@ export function claimsAllowed(scopes: any): Set<any>;
|
|
|
18
24
|
*
|
|
19
25
|
* Lanza si le falta algo: es un error de programación de quien emite, no un dato del otro
|
|
20
26
|
* lado que pueda venir mal.
|
|
27
|
+
* @param {{ sub: string, aud: string, nonce: string, scopes?: unknown, claims?: Record<string, unknown> | null, iat: number, exp: number }} args
|
|
21
28
|
*/
|
|
22
29
|
export function assertionBody({ sub, aud, nonce, scopes, claims, iat, exp }: {
|
|
23
|
-
sub:
|
|
24
|
-
aud:
|
|
25
|
-
nonce:
|
|
26
|
-
scopes
|
|
27
|
-
claims
|
|
28
|
-
iat:
|
|
29
|
-
exp:
|
|
30
|
+
sub: string;
|
|
31
|
+
aud: string;
|
|
32
|
+
nonce: string;
|
|
33
|
+
scopes?: unknown;
|
|
34
|
+
claims?: Record<string, unknown> | null;
|
|
35
|
+
iat: number;
|
|
36
|
+
exp: number;
|
|
30
37
|
}): {
|
|
31
38
|
v: number;
|
|
32
39
|
op: string;
|
|
33
40
|
sub: string;
|
|
34
41
|
aud: string;
|
|
35
42
|
nonce: string;
|
|
36
|
-
iat:
|
|
37
|
-
exp:
|
|
38
|
-
scopes:
|
|
39
|
-
claims:
|
|
43
|
+
iat: number;
|
|
44
|
+
exp: number;
|
|
45
|
+
scopes: string[];
|
|
46
|
+
claims: Record<string, unknown>;
|
|
40
47
|
};
|
|
41
48
|
/**
|
|
42
49
|
* ¿Vale esta prueba, PARA MÍ y AHORA?
|
|
@@ -70,9 +77,9 @@ export function verifyAssertion(assertion: any, opts?: {
|
|
|
70
77
|
exp?: undefined;
|
|
71
78
|
} | {
|
|
72
79
|
ok: boolean;
|
|
73
|
-
profileId:
|
|
80
|
+
profileId: string;
|
|
74
81
|
signer: string;
|
|
75
|
-
seq:
|
|
82
|
+
seq: number;
|
|
76
83
|
scopes: any[];
|
|
77
84
|
claims: any;
|
|
78
85
|
aud: any;
|
|
@@ -120,9 +127,9 @@ export function verifySignedFor(args?: {
|
|
|
120
127
|
aud?: undefined;
|
|
121
128
|
} | {
|
|
122
129
|
ok: boolean;
|
|
123
|
-
profileId:
|
|
130
|
+
profileId: string;
|
|
124
131
|
signer: string;
|
|
125
|
-
seq:
|
|
132
|
+
seq: number;
|
|
126
133
|
aud: any;
|
|
127
134
|
reason?: undefined;
|
|
128
135
|
}>;
|
package/types/avatar.d.ts
CHANGED
|
@@ -3,9 +3,20 @@
|
|
|
3
3
|
* nace con imagen sin que el usuario tenga que subir nada. Síncrono → usable
|
|
4
4
|
* directo en plantillas. Rejilla 5×5 simétrica sobre una "moneda" redondeada,
|
|
5
5
|
* con color derivado del hash.
|
|
6
|
+
*
|
|
7
|
+
* @param {unknown} seed
|
|
8
|
+
* @param {{ size?: number }} [opts]
|
|
9
|
+
* @returns {string}
|
|
6
10
|
*/
|
|
7
|
-
export function avatarSvg(seed:
|
|
11
|
+
export function avatarSvg(seed: unknown, { size }?: {
|
|
12
|
+
size?: number;
|
|
13
|
+
}): string;
|
|
14
|
+
/**
|
|
15
|
+
* El avatar como data-URI listo para `<img src>` o `background-image`.
|
|
16
|
+
* @param {unknown} seed
|
|
17
|
+
* @param {{ size?: number }} [opts]
|
|
18
|
+
* @returns {string}
|
|
19
|
+
*/
|
|
20
|
+
export function avatarDataUri(seed: unknown, opts?: {
|
|
8
21
|
size?: number;
|
|
9
22
|
}): string;
|
|
10
|
-
/** El avatar como data-URI listo para `<img src>` o `background-image`. */
|
|
11
|
-
export function avatarDataUri(seed: any, opts: any): string;
|
package/types/capabilities.d.ts
CHANGED
|
@@ -3,11 +3,13 @@
|
|
|
3
3
|
* `publickey` (JWK string). Prueba de POSESION de una sub-clave de dispositivo (no
|
|
4
4
|
* es cadena de delegacion): la usa el vault para confirmar que quien pide enrolar
|
|
5
5
|
* `dpub` realmente tiene su privada (un token robado ya no alcanza para enrolar).
|
|
6
|
+
* @param {{ publickey: unknown, data: unknown, signature: unknown }} args
|
|
7
|
+
* @returns {Promise<boolean>}
|
|
6
8
|
*/
|
|
7
9
|
export function verifyDeviceSig({ publickey, data, signature }: {
|
|
8
|
-
publickey:
|
|
9
|
-
data:
|
|
10
|
-
signature:
|
|
10
|
+
publickey: unknown;
|
|
11
|
+
data: unknown;
|
|
12
|
+
signature: unknown;
|
|
11
13
|
}): Promise<boolean>;
|
|
12
14
|
/**
|
|
13
15
|
* Short Authentication String: 6 digitos deterministas derivados de (maestra,
|
|
@@ -15,24 +17,31 @@ export function verifyDeviceSig({ publickey, data, signature }: {
|
|
|
15
17
|
* visualmente entre las dos pantallas (PC del vault y dispositivo) al emparejar —
|
|
16
18
|
* eso mata el relay/phishing (un atacante remoto no puede mostrar el SAS correcto
|
|
17
19
|
* en el dispositivo fisico de la victima).
|
|
20
|
+
* @param {string} master
|
|
21
|
+
* @param {string} dpub
|
|
22
|
+
* @param {unknown} sn
|
|
23
|
+
* @returns {Promise<string>}
|
|
18
24
|
*/
|
|
19
|
-
export function deriveSAS(master:
|
|
25
|
+
export function deriveSAS(master: string, dpub: string, sn: unknown): Promise<string>;
|
|
20
26
|
/**
|
|
21
27
|
* Código de emparejamiento ALEATORIO de 6 dígitos. Lo genera el DISPOSITIVO y lo MUESTRA;
|
|
22
28
|
* el usuario lo tipea en el vault. El vault NO lo conoce: el dispositivo solo manda un
|
|
23
29
|
* COMPROMISO (`commitCode`), no el código → el vault lo aprende únicamente cuando vos se lo
|
|
24
30
|
* das, tipeándolo. Así, aprobar exige TENER el dispositivo (de ahí sale el código).
|
|
31
|
+
* @returns {string}
|
|
25
32
|
*/
|
|
26
33
|
export function makePairingCode(): string;
|
|
27
34
|
/**
|
|
28
35
|
* Compromiso del código: `SHA-256(code ‖ dpub ‖ sn)` en hex. Va en el ENROLL (no el código).
|
|
29
36
|
* Liga el código a ESTE dispositivo y sesión (no reusable para otro). El vault lo guarda y,
|
|
30
37
|
* cuando tipeás el código, recomputa y compara → verifica posesión sin conocer el código antes.
|
|
38
|
+
* @param {{ code: unknown, dpub: string, sn: unknown }} args
|
|
39
|
+
* @returns {Promise<string>}
|
|
31
40
|
*/
|
|
32
41
|
export function commitCode({ code, dpub, sn }: {
|
|
33
|
-
code:
|
|
34
|
-
dpub:
|
|
35
|
-
sn:
|
|
42
|
+
code: unknown;
|
|
43
|
+
dpub: string;
|
|
44
|
+
sn: unknown;
|
|
36
45
|
}): Promise<string>;
|
|
37
46
|
/** Cuerpo canónico del certificado (lo que se firma): el cert SIN la firma. */
|
|
38
47
|
/**
|
|
@@ -46,29 +55,31 @@ export function commitCode({ code, dpub, sn }: {
|
|
|
46
55
|
* Atarlo al `seq` hace las dos cosas de golpe: quitarle un permiso a un aparato surte
|
|
47
56
|
* efecto AL INSTANTE (el acta sube de `seq` y su papel deja de valer, sin esperar a
|
|
48
57
|
* ninguna renovación), y nadie tiene que abrir nada por calendario.
|
|
58
|
+
* @param {Delegation} cert
|
|
49
59
|
*/
|
|
50
|
-
export function delegationBody(cert:
|
|
51
|
-
v:
|
|
52
|
-
iss:
|
|
53
|
-
sub:
|
|
54
|
-
scope:
|
|
55
|
-
iat:
|
|
56
|
-
exp:
|
|
57
|
-
nonce:
|
|
60
|
+
export function delegationBody(cert: Delegation): {
|
|
61
|
+
v: number;
|
|
62
|
+
iss: string;
|
|
63
|
+
sub: string;
|
|
64
|
+
scope: string | string[];
|
|
65
|
+
iat: number;
|
|
66
|
+
exp: number;
|
|
67
|
+
nonce: string;
|
|
58
68
|
seq?: undefined;
|
|
59
69
|
} | {
|
|
60
|
-
v:
|
|
61
|
-
iss:
|
|
62
|
-
sub:
|
|
63
|
-
scope:
|
|
64
|
-
iat:
|
|
65
|
-
seq:
|
|
66
|
-
nonce:
|
|
70
|
+
v: number;
|
|
71
|
+
iss: string;
|
|
72
|
+
sub: string;
|
|
73
|
+
scope: string | string[];
|
|
74
|
+
iat: number;
|
|
75
|
+
seq: number;
|
|
76
|
+
nonce: string;
|
|
67
77
|
exp?: undefined;
|
|
68
78
|
};
|
|
69
79
|
/**
|
|
70
80
|
* Genera una sub-clave de DISPOSITIVO `D`. Corre EN el dispositivo / bridge; la
|
|
71
81
|
* clave maestra nunca ve la privada. Solo `publickey` (JWK string) sale del device.
|
|
82
|
+
* @param {{ label?: string }} [opts]
|
|
72
83
|
*/
|
|
73
84
|
export function makeDeviceKey({ label }?: {
|
|
74
85
|
label?: string;
|
|
@@ -106,42 +117,41 @@ export function makeDeviceEncKey(): Promise<{
|
|
|
106
117
|
* Existe para que nadie la importe a mano: `deriveBits` es el ÚNICO uso correcto, y
|
|
107
118
|
* pedir otro (`deriveKey`) hace fallar la importación en Node con un error que no
|
|
108
119
|
* dice nada útil.
|
|
120
|
+
* @param {JsonWebKey} encPrivateJwk
|
|
121
|
+
* @returns {Promise<CryptoKey>}
|
|
109
122
|
*/
|
|
110
|
-
export function importDeviceEncKey(encPrivateJwk:
|
|
123
|
+
export function importDeviceEncKey(encPrivateJwk: JsonWebKey): Promise<CryptoKey>;
|
|
111
124
|
/**
|
|
112
125
|
* Firma un certificado de delegación con una `privateKey` (CryptoKey) cuyo pubkey
|
|
113
126
|
* es `iss`. Lo usa el handler del vault (con la clave maestra). Devuelve el cert
|
|
114
127
|
* completo `{ v, iss, sub, scope, iat, seq, nonce, sig }`.
|
|
128
|
+
* @param {SigningKey} privateKey
|
|
129
|
+
* @param {string} iss
|
|
130
|
+
* @param {{ sub: string, scope: string | string[], iat: number, seq: number, nonce?: string }} body
|
|
131
|
+
* @returns {Promise<Delegation>}
|
|
115
132
|
*/
|
|
116
|
-
export function signDelegationWith(privateKey:
|
|
117
|
-
sub:
|
|
118
|
-
scope:
|
|
119
|
-
iat:
|
|
120
|
-
seq:
|
|
121
|
-
nonce
|
|
122
|
-
}): Promise<
|
|
123
|
-
sig: any;
|
|
124
|
-
v: number;
|
|
125
|
-
iss: any;
|
|
126
|
-
sub: any;
|
|
127
|
-
scope: any;
|
|
128
|
-
iat: any;
|
|
129
|
-
seq: any;
|
|
130
|
-
nonce: any;
|
|
131
|
-
}>;
|
|
133
|
+
export function signDelegationWith(privateKey: SigningKey, iss: string, { sub, scope, iat, seq, nonce }: {
|
|
134
|
+
sub: string;
|
|
135
|
+
scope: string | string[];
|
|
136
|
+
iat: number;
|
|
137
|
+
seq: number;
|
|
138
|
+
nonce?: string;
|
|
139
|
+
}): Promise<Delegation>;
|
|
132
140
|
/**
|
|
133
141
|
* Firma datos con la clave de DISPOSITIVO (formato byte-idéntico a `signData` del
|
|
134
142
|
* vault → lo que el dispositivo/bridge usa para firmar cada pin/acción).
|
|
143
|
+
* @param {{ privateJwk?: JsonWebKey, privateKey?: SigningKey | null, publickey?: string, data: unknown, sign?: ((text: string) => Promise<string>) | null }} args
|
|
144
|
+
* @returns {Promise<{ signature: string, publickey: string }>}
|
|
135
145
|
*/
|
|
136
146
|
export function signWithDevice({ privateJwk, privateKey, publickey, data, sign }: {
|
|
137
|
-
privateJwk
|
|
138
|
-
privateKey
|
|
139
|
-
publickey
|
|
140
|
-
data:
|
|
141
|
-
sign:
|
|
147
|
+
privateJwk?: JsonWebKey;
|
|
148
|
+
privateKey?: SigningKey | null;
|
|
149
|
+
publickey?: string;
|
|
150
|
+
data: unknown;
|
|
151
|
+
sign?: ((text: string) => Promise<string>) | null;
|
|
142
152
|
}): Promise<{
|
|
143
|
-
signature:
|
|
144
|
-
publickey:
|
|
153
|
+
signature: string;
|
|
154
|
+
publickey: string;
|
|
145
155
|
}>;
|
|
146
156
|
/**
|
|
147
157
|
* Verifica un CERTIFICADO de delegación (offline; no requiere la clave maestra):
|
|
@@ -150,38 +160,77 @@ export function signWithDevice({ privateJwk, privateKey, publickey, data, sign }
|
|
|
150
160
|
* 3) `scope` incluye `expectedScope` (si se pide),
|
|
151
161
|
* 4) `sub` === `expectedSub` (si se pide),
|
|
152
162
|
* 5) `nonce` no revocado (`revoked`: fn(nonce)→bool, Set o mapa).
|
|
153
|
-
* @
|
|
163
|
+
* @param {{ cert?: any, expectedScope?: string | null, expectedSub?: string | null, actaSeq?: number | null, sealers?: string[] | null, revoked?: RevokedSet | null }} [args]
|
|
164
|
+
* @returns {Promise<{ok:boolean, reason?:string, iss?: string, sub?: string, scope?: string | string[], iat?: number, seq?: number, nonce?: string}>}
|
|
154
165
|
*/
|
|
155
166
|
export function verifyDelegation({ cert, expectedScope, expectedSub, actaSeq, sealers, revoked }?: {
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
167
|
+
cert?: any;
|
|
168
|
+
expectedScope?: string | null;
|
|
169
|
+
expectedSub?: string | null;
|
|
170
|
+
actaSeq?: number | null;
|
|
171
|
+
sealers?: string[] | null;
|
|
172
|
+
revoked?: RevokedSet | null;
|
|
173
|
+
}): Promise<{
|
|
159
174
|
ok: boolean;
|
|
160
175
|
reason?: string;
|
|
161
|
-
iss?:
|
|
162
|
-
sub?:
|
|
163
|
-
scope?:
|
|
164
|
-
iat?:
|
|
165
|
-
seq?:
|
|
166
|
-
nonce?:
|
|
167
|
-
}
|
|
176
|
+
iss?: string;
|
|
177
|
+
sub?: string;
|
|
178
|
+
scope?: string | string[];
|
|
179
|
+
iat?: number;
|
|
180
|
+
seq?: number;
|
|
181
|
+
nonce?: string;
|
|
182
|
+
}>;
|
|
168
183
|
/**
|
|
169
184
|
* Verificación de CADENA de una acción/pin delegado (lo único que llama el bridge):
|
|
170
185
|
* 1) el dispositivo `D` (= `data.publickey`) firmó `data`,
|
|
171
186
|
* 2) el cert delega a ESTE dispositivo (`cert.sub === data.publickey`),
|
|
172
187
|
* 3) el cert es válido (firma de una selladora, scope, revocación),
|
|
173
188
|
* 4) opcional: `cert.iss === trustedIssuer` (fija la identidad maestra esperada).
|
|
174
|
-
* @
|
|
189
|
+
* @param {{ data?: any, signature?: unknown, cert?: any, expectedScope?: string | null, actaSeq?: number | null, sealers?: string[] | null, revoked?: RevokedSet | null }} [args]
|
|
190
|
+
* @returns {Promise<{ok:boolean, reason?:string, issuer?:string, device?:string, scope?: string | string[]}>}
|
|
175
191
|
*/
|
|
176
192
|
export function verifyChain({ data, signature, cert, expectedScope, actaSeq, sealers, revoked }?: {
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
193
|
+
data?: any;
|
|
194
|
+
signature?: unknown;
|
|
195
|
+
cert?: any;
|
|
196
|
+
expectedScope?: string | null;
|
|
197
|
+
actaSeq?: number | null;
|
|
198
|
+
sealers?: string[] | null;
|
|
199
|
+
revoked?: RevokedSet | null;
|
|
200
|
+
}): Promise<{
|
|
180
201
|
ok: boolean;
|
|
181
202
|
reason?: string;
|
|
182
203
|
issuer?: string;
|
|
183
204
|
device?: string;
|
|
205
|
+
scope?: string | string[];
|
|
206
|
+
}>;
|
|
207
|
+
/**
|
|
208
|
+
* Una llave que firma: una CryptoKey, o una llave que vive fuera (el chip del teléfono) y
|
|
209
|
+
* firma por su cuenta.
|
|
210
|
+
*/
|
|
211
|
+
export type SigningKey = CryptoKey | {
|
|
212
|
+
external: true;
|
|
213
|
+
sign: (bytes: Uint8Array) => Promise<string>;
|
|
184
214
|
};
|
|
215
|
+
/**
|
|
216
|
+
* Un certificado de delegación: `iss` autoriza a `sub` para `scope`, válido mientras el acta
|
|
217
|
+
* no lo deje atrás (`seq`). Los viejos llevaban `exp` en vez de `seq`.
|
|
218
|
+
*/
|
|
219
|
+
export type Delegation = {
|
|
220
|
+
v: number;
|
|
221
|
+
iss: string;
|
|
222
|
+
sub: string;
|
|
223
|
+
scope: string | string[];
|
|
224
|
+
iat: number;
|
|
225
|
+
seq?: number;
|
|
226
|
+
exp?: number;
|
|
227
|
+
nonce?: string;
|
|
228
|
+
sig: string;
|
|
229
|
+
};
|
|
230
|
+
/**
|
|
231
|
+
* Qué nonces están revocados: una función, un Set o un objeto `{ nonce: true }`.
|
|
232
|
+
*/
|
|
233
|
+
export type RevokedSet = ((nonce: string) => boolean) | Set<string> | Record<string, unknown>;
|
|
185
234
|
import { pubkeyId } from './keyid.js';
|
|
186
235
|
import { keyLabel } from './keyid.js';
|
|
187
236
|
export { pubkeyId, keyLabel };
|
package/types/content.d.ts
CHANGED
|
@@ -1,19 +1,27 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* Genera una clave de contenido nueva (AES-256-GCM). Devuelve los bytes en base64.
|
|
3
|
+
* @returns {Promise<string>}
|
|
4
|
+
*/
|
|
2
5
|
export function makeContentKey(): Promise<string>;
|
|
3
6
|
/**
|
|
4
7
|
* Envuelve la CEK hacia la llave de cifrado de un miembro. La envoltura es pública: solo
|
|
5
8
|
* la abre quien tenga la privada de `memberEncPub`, así que puede viajar en el acta.
|
|
9
|
+
* @param {{ cek: string, memberEncPub: string }} args
|
|
6
10
|
* @returns {Promise<{epk:string, iv:string, ct:string}>}
|
|
7
11
|
*/
|
|
8
12
|
export function wrapForMember({ cek, memberEncPub }: {
|
|
9
|
-
cek:
|
|
10
|
-
memberEncPub:
|
|
13
|
+
cek: string;
|
|
14
|
+
memberEncPub: string;
|
|
11
15
|
}): Promise<{
|
|
12
16
|
epk: string;
|
|
13
17
|
iv: string;
|
|
14
18
|
ct: string;
|
|
15
19
|
}>;
|
|
16
|
-
/**
|
|
20
|
+
/**
|
|
21
|
+
* Abre la envoltura con la llave de cifrado privada de ESTE miembro.
|
|
22
|
+
* @param {{ wrap: any, myEncPrivateKey: any }} args
|
|
23
|
+
* @returns {Promise<string>}
|
|
24
|
+
*/
|
|
17
25
|
export function openWrap({ wrap, myEncPrivateKey }: {
|
|
18
26
|
wrap: any;
|
|
19
27
|
myEncPrivateKey: any;
|
|
@@ -22,30 +30,35 @@ export function openWrap({ wrap, myEncPrivateKey }: {
|
|
|
22
30
|
* Genera la CEK de una generación y la envuelve a TODOS los miembros que tengan llave de
|
|
23
31
|
* cifrado. Un miembro sin `encPub` simplemente no recibe envoltura (y por tanto no lee el
|
|
24
32
|
* contenido): se devuelve la lista para que la consola lo diga en vez de fallar en silencio.
|
|
33
|
+
* @param {{ members?: Array<{ pub: string, encPub?: string | null }> | null, gen?: number, cek?: string | null, now?: number }} args
|
|
34
|
+
* @returns {Promise<{ generation: KeyringGeneration, cek: string, sinLlave: Array<string | undefined> }>}
|
|
25
35
|
*/
|
|
26
36
|
export function makeGeneration({ members, gen, cek, now }: {
|
|
27
|
-
members
|
|
37
|
+
members?: Array<{
|
|
38
|
+
pub: string;
|
|
39
|
+
encPub?: string | null;
|
|
40
|
+
}> | null;
|
|
28
41
|
gen?: number;
|
|
29
|
-
cek?:
|
|
42
|
+
cek?: string | null;
|
|
30
43
|
now?: number;
|
|
31
44
|
}): Promise<{
|
|
32
|
-
generation:
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
wraps: {};
|
|
36
|
-
};
|
|
37
|
-
cek: any;
|
|
38
|
-
sinLlave: any[];
|
|
45
|
+
generation: KeyringGeneration;
|
|
46
|
+
cek: string;
|
|
47
|
+
sinLlave: Array<string | undefined>;
|
|
39
48
|
}>;
|
|
40
|
-
/**
|
|
49
|
+
/**
|
|
50
|
+
* La CEK vigente para mí, sacada del llavero del acta. `null` si no tengo envoltura.
|
|
51
|
+
* @param {{ keyring?: KeyringGeneration[] | null, myPub: string, myEncPrivateKey: any }} args
|
|
52
|
+
* @returns {Promise<{ gen: number, cek: string } | null>}
|
|
53
|
+
*/
|
|
41
54
|
export function myContentKey({ keyring, myPub, myEncPrivateKey }: {
|
|
42
|
-
keyring
|
|
43
|
-
myPub:
|
|
55
|
+
keyring?: KeyringGeneration[] | null;
|
|
56
|
+
myPub: string;
|
|
44
57
|
myEncPrivateKey: any;
|
|
45
58
|
}): Promise<{
|
|
46
|
-
gen:
|
|
59
|
+
gen: number;
|
|
47
60
|
cek: string;
|
|
48
|
-
}>;
|
|
61
|
+
} | null>;
|
|
49
62
|
/**
|
|
50
63
|
* Cifra con una clave simétrica. Devuelve `{ gen, iv, ct }` (el `gen` dice con cuál).
|
|
51
64
|
*
|
|
@@ -53,13 +66,15 @@ export function myContentKey({ keyring, myPub, myEncPrivateKey }: {
|
|
|
53
66
|
* cajones de secretos, cada entrada del gestor de contraseñas, el transporte). Por eso NO
|
|
54
67
|
* lleva la marca: la marca dice «esto es de la cuenta» y solo la pone `sealAccount`. En
|
|
55
68
|
* 0.107.0 la ponía aquí, y marcaba como de la cuenta sobres que la cuenta no abre.
|
|
69
|
+
* @param {{ cek: string, gen: number, plaintext: string }} args
|
|
70
|
+
* @returns {Promise<{ gen: number, iv: string, ct: string }>}
|
|
56
71
|
*/
|
|
57
72
|
export function encryptWithCek({ cek, gen, plaintext }: {
|
|
58
|
-
cek:
|
|
59
|
-
gen:
|
|
60
|
-
plaintext:
|
|
73
|
+
cek: string;
|
|
74
|
+
gen: number;
|
|
75
|
+
plaintext: string;
|
|
61
76
|
}): Promise<{
|
|
62
|
-
gen:
|
|
77
|
+
gen: number;
|
|
63
78
|
iv: string;
|
|
64
79
|
ct: string;
|
|
65
80
|
}>;
|
|
@@ -72,53 +87,63 @@ export function encryptWithCek({ cek, gen, plaintext }: {
|
|
|
72
87
|
* archivos: el archivo se cifra con una CEK nueva y solo la CEK pasa por el sellado de
|
|
73
88
|
* siempre (`wrapForMember`, o la bóveda).
|
|
74
89
|
*
|
|
75
|
-
* @param {{ cek: string, bytes: Uint8Array }} o
|
|
90
|
+
* @param {{ cek: string, bytes: Uint8Array<ArrayBuffer> }} o
|
|
76
91
|
* @returns {Promise<{ iv: Uint8Array, ct: Uint8Array }>}
|
|
77
92
|
*/
|
|
78
93
|
export function encryptBytesWithCek({ cek, bytes }: {
|
|
79
94
|
cek: string;
|
|
80
|
-
bytes: Uint8Array
|
|
95
|
+
bytes: Uint8Array<ArrayBuffer>;
|
|
81
96
|
}): Promise<{
|
|
82
97
|
iv: Uint8Array;
|
|
83
98
|
ct: Uint8Array;
|
|
84
99
|
}>;
|
|
85
|
-
/**
|
|
100
|
+
/**
|
|
101
|
+
* El inverso de `encryptBytesWithCek`. Lanza si los bytes no son de esa clave o se tocaron.
|
|
102
|
+
* @param {{ cek: string, iv: Uint8Array<ArrayBuffer>, ct: Uint8Array<ArrayBuffer> }} args
|
|
103
|
+
* @returns {Promise<Uint8Array>}
|
|
104
|
+
*/
|
|
86
105
|
export function decryptBytesWithCek({ cek, iv, ct }: {
|
|
87
|
-
cek:
|
|
88
|
-
iv:
|
|
89
|
-
ct:
|
|
90
|
-
}): Promise<Uint8Array
|
|
91
|
-
/**
|
|
106
|
+
cek: string;
|
|
107
|
+
iv: Uint8Array<ArrayBuffer>;
|
|
108
|
+
ct: Uint8Array<ArrayBuffer>;
|
|
109
|
+
}): Promise<Uint8Array>;
|
|
110
|
+
/**
|
|
111
|
+
* Cierra con la LLAVE DE LA CUENTA (generación `gen`): el sobre lleva la marca.
|
|
112
|
+
* @param {{ cek: string, gen: number, plaintext: string }} args
|
|
113
|
+
* @returns {Promise<CekEnvelope>}
|
|
114
|
+
*/
|
|
92
115
|
export function sealAccount({ cek, gen, plaintext }: {
|
|
93
|
-
cek:
|
|
94
|
-
gen:
|
|
95
|
-
plaintext:
|
|
96
|
-
}): Promise<
|
|
97
|
-
gen: any;
|
|
98
|
-
iv: string;
|
|
99
|
-
ct: string;
|
|
100
|
-
t: string;
|
|
101
|
-
}>;
|
|
116
|
+
cek: string;
|
|
117
|
+
gen: number;
|
|
118
|
+
plaintext: string;
|
|
119
|
+
}): Promise<CekEnvelope>;
|
|
102
120
|
/**
|
|
103
121
|
* Descifra un sobre teniendo YA la CEK. Es el inverso exacto de `encryptWithCek`.
|
|
104
122
|
*
|
|
105
123
|
* Existe para quien administra: tiene la clave a mano (la sacó de donde la guarde) y no
|
|
106
124
|
* necesita el llavero ni ser miembro. El camino normal —el del aparato que solo tiene su
|
|
107
125
|
* propia llave— es `decryptWithKeyring`.
|
|
126
|
+
* @param {{ cek: string, envelope: { iv: string, ct: string } }} args
|
|
127
|
+
* @returns {Promise<string>}
|
|
108
128
|
*/
|
|
109
129
|
export function decryptWithCek({ cek, envelope }: {
|
|
110
|
-
cek:
|
|
111
|
-
envelope:
|
|
130
|
+
cek: string;
|
|
131
|
+
envelope: {
|
|
132
|
+
iv: string;
|
|
133
|
+
ct: string;
|
|
134
|
+
};
|
|
112
135
|
}): Promise<string>;
|
|
113
136
|
/**
|
|
114
137
|
* Descifra un sobre. Hay que darle el llavero porque el contenido viejo está cifrado con
|
|
115
138
|
* generaciones anteriores: por eso las CEK antiguas se conservan (32 bytes cada una) en vez
|
|
116
139
|
* de re-cifrarlo todo de golpe al rotar.
|
|
140
|
+
* @param {{ envelope: any, keyring?: KeyringGeneration[] | null, myPub: string, myEncPrivateKey: any }} args
|
|
141
|
+
* @returns {Promise<string>}
|
|
117
142
|
*/
|
|
118
143
|
export function decryptWithKeyring({ envelope, keyring, myPub, myEncPrivateKey }: {
|
|
119
144
|
envelope: any;
|
|
120
|
-
keyring
|
|
121
|
-
myPub:
|
|
145
|
+
keyring?: KeyringGeneration[] | null;
|
|
146
|
+
myPub: string;
|
|
122
147
|
myEncPrivateKey: any;
|
|
123
148
|
}): Promise<string>;
|
|
124
149
|
/**
|
|
@@ -160,7 +185,7 @@ export function resealStale(value: any, { gen, reseal, now }: {
|
|
|
160
185
|
* generación vigente cuando la llave rota (`resealStale`).
|
|
161
186
|
*/
|
|
162
187
|
export const CEK_ENVELOPE: "dotrino-cek";
|
|
163
|
-
export function isCekEnvelope(v: any):
|
|
188
|
+
export function isCekEnvelope(v: any): v is CekEnvelope;
|
|
164
189
|
/**
|
|
165
190
|
* MIGRACIÓN, con fecha de caducidad: hasta 0.107.0 los sobres de la cuenta salían SIN marca,
|
|
166
191
|
* como `{ gen, iv, ct }` a secas. Hasta esta fecha, `resealStale` también prueba esos: si
|
|
@@ -169,7 +194,7 @@ export function isCekEnvelope(v: any): boolean;
|
|
|
169
194
|
* quita el código cuando pase (y su prueba con él).
|
|
170
195
|
*/
|
|
171
196
|
export const LEGACY_UNMARKED_UNTIL: number;
|
|
172
|
-
export function isLegacyCekEnvelope(v: any):
|
|
197
|
+
export function isLegacyCekEnvelope(v: any): v is CekEnvelope;
|
|
173
198
|
declare namespace _default {
|
|
174
199
|
export { makeContentKey };
|
|
175
200
|
export { wrapForMember };
|
|
@@ -189,3 +214,21 @@ declare namespace _default {
|
|
|
189
214
|
export { resealStale };
|
|
190
215
|
}
|
|
191
216
|
export default _default;
|
|
217
|
+
/**
|
|
218
|
+
* La envoltura de la clave de contenido para un miembro: ECDH efímero + AES-GCM.
|
|
219
|
+
*/
|
|
220
|
+
export type Wrap = {
|
|
221
|
+
epk: string;
|
|
222
|
+
iv: string;
|
|
223
|
+
ct: string;
|
|
224
|
+
};
|
|
225
|
+
/**
|
|
226
|
+
* Un sobre cerrado con la clave de la cuenta (`gen` dice con cuál).
|
|
227
|
+
*/
|
|
228
|
+
export type CekEnvelope = {
|
|
229
|
+
t?: string;
|
|
230
|
+
gen: number;
|
|
231
|
+
iv: string;
|
|
232
|
+
ct: string;
|
|
233
|
+
};
|
|
234
|
+
export type KeyringGeneration = import("./acta.js").KeyringGeneration;
|