core-3nweb-client-lib 0.37.3 → 0.38.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/build/api-defs/keys.d.ts +45 -0
- package/build/core/keyring/correspondent-keys.d.ts +20 -19
- package/build/core/keyring/correspondent-keys.js +44 -0
- package/build/core/keyring/index.js +5 -0
- package/build/core/keyring/keyrings-cap-ipc.js +2 -0
- package/build/lib-common/service-api/asmail/retrieval.js +3 -0
- package/package.json +1 -1
package/build/api-defs/keys.d.ts
CHANGED
|
@@ -123,6 +123,10 @@ declare namespace web3n.keys {
|
|
|
123
123
|
|
|
124
124
|
introKeyOnASMailServer: IntroKeyOnASMailServer;
|
|
125
125
|
|
|
126
|
+
getCorrespondentKeys: (
|
|
127
|
+
correspondentAddr: string
|
|
128
|
+
) => Promise<CorrespondentKeysInfo|undefined>;
|
|
129
|
+
|
|
126
130
|
}
|
|
127
131
|
|
|
128
132
|
interface IntroKeyOnASMailServer {
|
|
@@ -151,4 +155,45 @@ declare namespace web3n.keys {
|
|
|
151
155
|
provCert: keys.SignedLoad;
|
|
152
156
|
}
|
|
153
157
|
|
|
158
|
+
interface CorrespondentKeysInfo {
|
|
159
|
+
sendingPair: IntroductorySendingPairInfo|RatchetedSendingPairInfo|null;
|
|
160
|
+
receptionPairs: {
|
|
161
|
+
suggested: ReceptionPairInfo|null;
|
|
162
|
+
inUse: ReceptionPairInfo|null;
|
|
163
|
+
old: ReceptionPairInfo|null;
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
interface IntroductorySendingPairInfo {
|
|
168
|
+
type: 'intro';
|
|
169
|
+
recipientKId: string;
|
|
170
|
+
alg: string;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
interface RatchetedSendingPairInfo {
|
|
174
|
+
type: 'ratcheted';
|
|
175
|
+
pids: string[];
|
|
176
|
+
timestamp: number;
|
|
177
|
+
alg: string;
|
|
178
|
+
senderKId: string;
|
|
179
|
+
recipientKId: string;
|
|
180
|
+
sentMsgs?: {
|
|
181
|
+
count: number;
|
|
182
|
+
lastTS: number;
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
interface ReceptionPairInfo {
|
|
187
|
+
pids: string[];
|
|
188
|
+
alg: string;
|
|
189
|
+
recipientKId: string;
|
|
190
|
+
isSenderIntroKey?: boolean,
|
|
191
|
+
senderKId: string;
|
|
192
|
+
receivedMsgs?: {
|
|
193
|
+
counts: number[][];
|
|
194
|
+
lastTS: number;
|
|
195
|
+
};
|
|
196
|
+
timestamp: number;
|
|
197
|
+
}
|
|
198
|
+
|
|
154
199
|
}
|
|
@@ -8,6 +8,7 @@ import { Decryptor } from '../../lib-common/async-cryptor-wrap';
|
|
|
8
8
|
import { AsyncSBoxCryptor } from 'xsp-files';
|
|
9
9
|
type JsonKey = web3n.keys.JsonKey;
|
|
10
10
|
type JsonKeyShort = web3n.keys.JsonKeyShort;
|
|
11
|
+
type CorrespondentKeysInfo = web3n.keys.CorrespondentKeysInfo;
|
|
11
12
|
export interface ReceptionPair {
|
|
12
13
|
pids: string[];
|
|
13
14
|
recipientKey: JWKeyPair;
|
|
@@ -20,23 +21,6 @@ export interface ReceptionPair {
|
|
|
20
21
|
};
|
|
21
22
|
timestamp: number;
|
|
22
23
|
}
|
|
23
|
-
/**
|
|
24
|
-
* Sending pairs are a rotating public key cryptography key material for sending
|
|
25
|
-
* messages.
|
|
26
|
-
*
|
|
27
|
-
* Let's note naming convention. Since this is a sending pair, this side of
|
|
28
|
-
* communication is called a sender, while the other side is a recipient.
|
|
29
|
-
*/
|
|
30
|
-
export interface BaseSendingPair {
|
|
31
|
-
/**
|
|
32
|
-
* This is recipients' public key, to which encryption is done.
|
|
33
|
-
* If this is an introductory pair, this key is recipient's published intro
|
|
34
|
-
* public key.
|
|
35
|
-
* Else, if this is an ratcheted pair, this key comes from crypto material
|
|
36
|
-
* that recipients suggests from time to time for further use.
|
|
37
|
-
*/
|
|
38
|
-
recipientPKey: JsonKeyShort;
|
|
39
|
-
}
|
|
40
24
|
/**
|
|
41
25
|
* Introductory pair appears when the first message is sent to a new
|
|
42
26
|
* correspondent. By nature it is an introductory message that uses recipient's
|
|
@@ -47,14 +31,22 @@ export interface BaseSendingPair {
|
|
|
47
31
|
* a flag that allows to distinguish it from ratcheted pair with a clean
|
|
48
32
|
* if-statement.
|
|
49
33
|
*/
|
|
50
|
-
export interface IntroductorySendingPair
|
|
34
|
+
export interface IntroductorySendingPair {
|
|
51
35
|
type: 'intro';
|
|
36
|
+
/**
|
|
37
|
+
* This is recipients' public key, to which encryption is done.
|
|
38
|
+
* If this is an introductory pair, this key is recipient's published intro
|
|
39
|
+
* public key.
|
|
40
|
+
* Else, if this is an ratcheted pair, this key comes from crypto material
|
|
41
|
+
* that recipients suggests from time to time for further use.
|
|
42
|
+
*/
|
|
43
|
+
recipientPKey: JsonKey;
|
|
52
44
|
}
|
|
53
45
|
/**
|
|
54
46
|
* Ratcheted sending pair is a sending pair with pair ids (pids), attached to
|
|
55
47
|
* it. These ids are used to identify correct key material.
|
|
56
48
|
*/
|
|
57
|
-
export interface RatchetedSendingPair
|
|
49
|
+
export interface RatchetedSendingPair {
|
|
58
50
|
type: 'ratcheted';
|
|
59
51
|
pids: string[];
|
|
60
52
|
timestamp: number;
|
|
@@ -66,6 +58,14 @@ export interface RatchetedSendingPair extends BaseSendingPair {
|
|
|
66
58
|
* and is moved to the sending pair when it is used by the other side.
|
|
67
59
|
*/
|
|
68
60
|
senderKey: JWKeyPair;
|
|
61
|
+
/**
|
|
62
|
+
* This is recipients' public key, to which encryption is done.
|
|
63
|
+
* If this is an introductory pair, this key is recipient's published intro
|
|
64
|
+
* public key.
|
|
65
|
+
* Else, if this is an ratcheted pair, this key comes from crypto material
|
|
66
|
+
* that recipients suggests from time to time for further use.
|
|
67
|
+
*/
|
|
68
|
+
recipientPKey: JsonKeyShort;
|
|
69
69
|
/**
|
|
70
70
|
* This is a precomputed message master key that comes from a given pair.
|
|
71
71
|
* This exist only as a speedup measure, to save time of public key crypto
|
|
@@ -142,5 +142,6 @@ export declare class CorrespondentKeys {
|
|
|
142
142
|
msgMasterKey: Uint8Array;
|
|
143
143
|
msgCount: number;
|
|
144
144
|
}>;
|
|
145
|
+
toInfo(): CorrespondentKeysInfo;
|
|
145
146
|
}
|
|
146
147
|
export {};
|
|
@@ -312,6 +312,17 @@ class CorrespondentKeys {
|
|
|
312
312
|
}
|
|
313
313
|
return { msgMasterKey, msgCount, currentPair };
|
|
314
314
|
}
|
|
315
|
+
toInfo() {
|
|
316
|
+
const { sendingPair: sp, receptionPairs: rp } = this.keys;
|
|
317
|
+
return {
|
|
318
|
+
sendingPair: (sp ? turnSendingPairToInfo(sp) : null),
|
|
319
|
+
receptionPairs: {
|
|
320
|
+
inUse: (rp.inUse ? turnReceptionPairToInfo(rp.inUse) : null),
|
|
321
|
+
old: (rp.old ? turnReceptionPairToInfo(rp.old) : null),
|
|
322
|
+
suggested: (rp.suggested ? turnReceptionPairToInfo(rp.suggested) : null)
|
|
323
|
+
}
|
|
324
|
+
};
|
|
325
|
+
}
|
|
315
326
|
}
|
|
316
327
|
exports.CorrespondentKeys = CorrespondentKeys;
|
|
317
328
|
Object.freeze(CorrespondentKeys.prototype);
|
|
@@ -352,4 +363,37 @@ function updateMsgCountInRatchetedSendingPair(p) {
|
|
|
352
363
|
}
|
|
353
364
|
return p.sentMsgs.count;
|
|
354
365
|
}
|
|
366
|
+
function turnSendingPairToInfo(sp) {
|
|
367
|
+
if (sp.type === 'ratcheted') {
|
|
368
|
+
const { pids, timestamp, sentMsgs } = sp;
|
|
369
|
+
return {
|
|
370
|
+
type: 'ratcheted',
|
|
371
|
+
recipientKId: sp.recipientPKey.kid,
|
|
372
|
+
senderKId: sp.senderKey.pkey.kid,
|
|
373
|
+
alg: sp.senderKey.pkey.alg,
|
|
374
|
+
pids,
|
|
375
|
+
timestamp,
|
|
376
|
+
sentMsgs
|
|
377
|
+
};
|
|
378
|
+
}
|
|
379
|
+
else if (sp.type === 'intro') {
|
|
380
|
+
return {
|
|
381
|
+
type: 'intro',
|
|
382
|
+
recipientKId: sp.recipientPKey.kid,
|
|
383
|
+
alg: sp.recipientPKey.alg
|
|
384
|
+
};
|
|
385
|
+
}
|
|
386
|
+
else {
|
|
387
|
+
return null;
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
function turnReceptionPairToInfo(rp) {
|
|
391
|
+
const { pids, timestamp, receivedMsgs, isSenderIntroKey } = rp;
|
|
392
|
+
return {
|
|
393
|
+
pids, timestamp, receivedMsgs, isSenderIntroKey,
|
|
394
|
+
alg: rp.recipientKey.pkey.alg,
|
|
395
|
+
recipientKId: rp.recipientKey.pkey.kid,
|
|
396
|
+
senderKId: rp.senderPKey.kid
|
|
397
|
+
};
|
|
398
|
+
}
|
|
355
399
|
Object.freeze(exports);
|
|
@@ -319,6 +319,11 @@ class Keyrings {
|
|
|
319
319
|
makeKeyringsCAP() {
|
|
320
320
|
const w = {
|
|
321
321
|
introKeyOnASMailServer: this.publishedKeys.makeIntroKeyCAP(),
|
|
322
|
+
getCorrespondentKeys: async (addr) => {
|
|
323
|
+
var _a;
|
|
324
|
+
const cAddr = (0, canonical_address_1.toCanonicalAddress)(addr);
|
|
325
|
+
return (_a = this.corrKeys.get(cAddr)) === null || _a === void 0 ? void 0 : _a.toInfo();
|
|
326
|
+
}
|
|
322
327
|
};
|
|
323
328
|
return Object.freeze(w);
|
|
324
329
|
}
|
|
@@ -23,6 +23,7 @@ const service_side_wrap_1 = require("../../core-ipc/json-ipc-wrapping/service-si
|
|
|
23
23
|
function exposeKeyringsCAP(cap) {
|
|
24
24
|
return {
|
|
25
25
|
introKeyOnASMailServer: exposeIntroKey(cap.introKeyOnASMailServer),
|
|
26
|
+
getCorrespondentKeys: (0, service_side_wrap_1.wrapReqReplySrvMethod)(cap, 'getCorrespondentKeys')
|
|
26
27
|
};
|
|
27
28
|
}
|
|
28
29
|
function exposeIntroKey(cap) {
|
|
@@ -45,6 +46,7 @@ function makeIntroKeyCaller(caller, objPath) {
|
|
|
45
46
|
function makeKeyringsCaller(caller, objPath) {
|
|
46
47
|
return {
|
|
47
48
|
introKeyOnASMailServer: makeIntroKeyCaller(caller, objPath.concat('introKeyOnASMailServer')),
|
|
49
|
+
getCorrespondentKeys: (0, caller_side_wrap_1.makeReqRepFuncCaller)(caller, objPath.concat('getCorrespondentKeys'))
|
|
48
50
|
};
|
|
49
51
|
}
|
|
50
52
|
Object.freeze(exports);
|
|
@@ -145,4 +145,7 @@ var msgMainObjRecieved;
|
|
|
145
145
|
msgMainObjRecieved.EVENT_NAME = 'msg-main-obj-received';
|
|
146
146
|
})(msgMainObjRecieved || (exports.msgMainObjRecieved = msgMainObjRecieved = {}));
|
|
147
147
|
Object.freeze(msgMainObjRecieved);
|
|
148
|
+
// XXX add event about message removal
|
|
149
|
+
// it is useful in multi-device case, pass implicit implicit signal that will
|
|
150
|
+
// have context-specific meaning.
|
|
148
151
|
Object.freeze(exports);
|