core-3nweb-client-lib 0.37.3 → 0.38.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/build/api-defs/keys.d.ts +42 -0
- package/build/core/keyring/correspondent-keys.d.ts +2 -0
- package/build/core/keyring/correspondent-keys.js +41 -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,42 @@ 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
|
+
}
|
|
171
|
+
|
|
172
|
+
interface RatchetedSendingPairInfo {
|
|
173
|
+
type: 'ratcheted';
|
|
174
|
+
pids: string[];
|
|
175
|
+
timestamp: number;
|
|
176
|
+
senderKId: string;
|
|
177
|
+
recipientKId: string;
|
|
178
|
+
sentMsgs?: {
|
|
179
|
+
count: number;
|
|
180
|
+
lastTS: number;
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
interface ReceptionPairInfo {
|
|
185
|
+
pids: string[];
|
|
186
|
+
recipientKId: string;
|
|
187
|
+
isSenderIntroKey?: boolean,
|
|
188
|
+
senderKId: string;
|
|
189
|
+
receivedMsgs?: {
|
|
190
|
+
counts: number[][];
|
|
191
|
+
lastTS: number;
|
|
192
|
+
};
|
|
193
|
+
timestamp: number;
|
|
194
|
+
}
|
|
195
|
+
|
|
154
196
|
}
|
|
@@ -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;
|
|
@@ -142,5 +143,6 @@ export declare class CorrespondentKeys {
|
|
|
142
143
|
msgMasterKey: Uint8Array;
|
|
143
144
|
msgCount: number;
|
|
144
145
|
}>;
|
|
146
|
+
toInfo(): CorrespondentKeysInfo;
|
|
145
147
|
}
|
|
146
148
|
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,34 @@ 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
|
+
pids,
|
|
374
|
+
timestamp,
|
|
375
|
+
sentMsgs
|
|
376
|
+
};
|
|
377
|
+
}
|
|
378
|
+
else if (sp.type === 'intro') {
|
|
379
|
+
return {
|
|
380
|
+
type: 'intro',
|
|
381
|
+
recipientKId: sp.recipientPKey.kid
|
|
382
|
+
};
|
|
383
|
+
}
|
|
384
|
+
else {
|
|
385
|
+
return null;
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
function turnReceptionPairToInfo(rp) {
|
|
389
|
+
const { pids, timestamp, receivedMsgs, isSenderIntroKey } = rp;
|
|
390
|
+
return {
|
|
391
|
+
pids, timestamp, receivedMsgs, isSenderIntroKey,
|
|
392
|
+
recipientKId: rp.recipientKey.pkey.kid,
|
|
393
|
+
senderKId: rp.senderPKey.kid
|
|
394
|
+
};
|
|
395
|
+
}
|
|
355
396
|
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);
|