core-3nweb-client-lib 0.37.2 → 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/asmail.d.ts +10 -0
- package/build/api-defs/files.d.ts +3 -1
- 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-client/local-files/device-fs.js +8 -3
- package/build/lib-client/xsp-fs/fs.js +8 -3
- package/build/lib-common/service-api/asmail/retrieval.js +3 -0
- package/package.json +1 -1
|
@@ -252,6 +252,10 @@ declare namespace web3n.asmail {
|
|
|
252
252
|
}
|
|
253
253
|
|
|
254
254
|
interface MsgInfo {
|
|
255
|
+
/**
|
|
256
|
+
* msgId is an identifier generated by user's ASMail server on message
|
|
257
|
+
* delivery to identify it in an inbox.
|
|
258
|
+
*/
|
|
255
259
|
msgId: string;
|
|
256
260
|
msgType: string;
|
|
257
261
|
deliveryTS: number;
|
|
@@ -265,6 +269,12 @@ declare namespace web3n.asmail {
|
|
|
265
269
|
}
|
|
266
270
|
|
|
267
271
|
interface OutgoingMessage extends MsgStruct {
|
|
272
|
+
/**
|
|
273
|
+
* msgId is an identifier generated by recipient's ASMail when message
|
|
274
|
+
* delivery process has started. Its purpose is to restart an interrupted
|
|
275
|
+
* delivery.
|
|
276
|
+
* (Do we even need it here, as core is responsible for restarts?)
|
|
277
|
+
*/
|
|
268
278
|
msgId?: string;
|
|
269
279
|
attachments?: AttachmentsContainer;
|
|
270
280
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright (C) 2016 - 2018, 2020, 2022 3NSoft Inc.
|
|
2
|
+
Copyright (C) 2016 - 2018, 2020, 2022, 2025 3NSoft Inc.
|
|
3
3
|
|
|
4
4
|
This program is free software: you can redistribute it and/or modify it under
|
|
5
5
|
the terms of the GNU General Public License as published by the Free Software
|
|
@@ -46,6 +46,8 @@ declare namespace web3n.files {
|
|
|
46
46
|
isEndless?: true;
|
|
47
47
|
storageClosed?: true;
|
|
48
48
|
remoteNotSet?: true;
|
|
49
|
+
notLinkableFile?: true;
|
|
50
|
+
notLinkableFolder?: true;
|
|
49
51
|
}
|
|
50
52
|
|
|
51
53
|
interface exceptionCode {
|
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);
|
|
@@ -657,9 +657,14 @@ class DeviceFS {
|
|
|
657
657
|
}
|
|
658
658
|
async link(path, target) {
|
|
659
659
|
// do sanity checks
|
|
660
|
-
if (!target
|
|
661
|
-
(typeof target.getLinkParams !== 'function')) {
|
|
662
|
-
|
|
660
|
+
if (!target
|
|
661
|
+
|| (typeof target.getLinkParams !== 'function')) {
|
|
662
|
+
if (target.listFolder) {
|
|
663
|
+
throw (0, file_1.makeFileException)('notLinkableFolder', target.name);
|
|
664
|
+
}
|
|
665
|
+
else {
|
|
666
|
+
throw (0, file_1.makeFileException)('notLinkableFile', target.name);
|
|
667
|
+
}
|
|
663
668
|
}
|
|
664
669
|
const params = await target.getLinkParams();
|
|
665
670
|
// note, we could check (params.storageType !== 'device'), but, since we
|
|
@@ -339,9 +339,14 @@ class XspFS {
|
|
|
339
339
|
throw new Error(`Cannot create link to ${params.storageType} from ${storage.type} storage.`);
|
|
340
340
|
}
|
|
341
341
|
async link(path, target) {
|
|
342
|
-
if (!target
|
|
343
|
-
(typeof target.getLinkParams !== 'function')) {
|
|
344
|
-
|
|
342
|
+
if (!target
|
|
343
|
+
|| (typeof target.getLinkParams !== 'function')) {
|
|
344
|
+
if (target.listFolder) {
|
|
345
|
+
throw (0, file_1.makeFileException)('notLinkableFolder', target.name);
|
|
346
|
+
}
|
|
347
|
+
else {
|
|
348
|
+
throw (0, file_1.makeFileException)('notLinkableFile', target.name);
|
|
349
|
+
}
|
|
345
350
|
}
|
|
346
351
|
const params = await target.getLinkParams();
|
|
347
352
|
this.ensureLinkingAllowedTo(params);
|
|
@@ -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);
|