core-3nweb-client-lib 0.51.0 → 0.52.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/asmail.d.ts +27 -4
- package/build/api-defs/files.d.ts +6 -3
- package/build/core/asmail/asmail-cap-ipc.js +22 -3
- package/build/core/asmail/delivery/common.d.ts +3 -0
- package/build/core/asmail/delivery/common.js +5 -0
- package/build/core/asmail/delivery/index.js +6 -6
- package/build/core/asmail/delivery/msg.js +1 -6
- package/build/core/asmail/delivery/per-recipient-wip.js +3 -5
- package/build/core/asmail/filtering.d.ts +11 -0
- package/build/core/asmail/filtering.js +219 -0
- package/build/core/asmail/inbox/inbox-events.d.ts +1 -0
- package/build/core/asmail/inbox/inbox-events.js +3 -0
- package/build/core/asmail/inbox/index.d.ts +1 -0
- package/build/core/asmail/inbox/index.js +8 -0
- package/build/core/asmail/index.d.ts +2 -0
- package/build/core/asmail/index.js +29 -4
- package/build/core/asmail/sending-params/index.d.ts +2 -0
- package/build/core/asmail/sending-params/index.js +11 -1
- package/build/core/asmail/sending-params/own-params.d.ts +2 -0
- package/build/core/asmail/sending-params/own-params.js +27 -5
- package/build/core/asmail/sending-params/params-from-others.d.ts +2 -0
- package/build/core/asmail/sending-params/params-from-others.js +28 -3
- package/build/core/keyring/index.d.ts +2 -0
- package/build/core/keyring/index.js +4 -2
- package/build/core/keyring/peer-keys/dataset/v2/logs.d.ts +13 -1
- package/build/core/keyring/peer-keys/dataset/v2/logs.js +17 -1
- package/build/core/keyring/peer-keys/dataset/v2/peer-keys-db.d.ts +2 -0
- package/build/core/keyring/peer-keys/dataset/v2/peer-keys-db.js +31 -1
- package/build/core/keyring/peer-keys/index.d.ts +2 -0
- package/build/core/keyring/peer-keys/index.js +11 -1
- package/build/core/storage/synced/remote-events.d.ts +1 -0
- package/build/core/storage/synced/remote-events.js +3 -0
- package/build/core/storage/synced/storage.d.ts +2 -0
- package/build/core/storage/synced/storage.js +13 -0
- package/build/core/storage/synced/upsyncer.js +2 -1
- package/build/lib-client/3nstorage/storage-owner.js +1 -2
- package/build/lib-client/asmail/sender.d.ts +0 -6
- package/build/lib-client/asmail/sender.js +20 -64
- package/build/lib-client/service-locator.d.ts +1 -2
- package/build/lib-client/service-locator.js +0 -1
- package/build/lib-common/awaitable-state.d.ts +1 -0
- package/build/lib-common/awaitable-state.js +3 -0
- package/build/lib-common/canonical-address.js +3 -0
- package/build/lib-common/periodic-trigger.d.ts +1 -0
- package/build/lib-common/periodic-trigger.js +44 -0
- package/build/tests/caps-api/asmail.js +34 -4
- package/package.json +1 -1
|
@@ -37,6 +37,9 @@ function toCanonicalAddress(address) {
|
|
|
37
37
|
domain = address.substring(indOfAt + 1);
|
|
38
38
|
user = address.substring(0, indOfAt).replace(whiteSpace, '');
|
|
39
39
|
}
|
|
40
|
+
if (domain.endsWith('.')) {
|
|
41
|
+
domain = domain.substring(0, domain.length - 1);
|
|
42
|
+
}
|
|
40
43
|
checkDomainString(domain, address);
|
|
41
44
|
return (user + '@' + domain).toLowerCase();
|
|
42
45
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function startPeriodicConditionalTriggerProc(shouldTrigger: () => boolean, trigger: () => void, timeoutSecond: number): (() => void);
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
Copyright (C) 2026 3NSoft Inc.
|
|
4
|
+
|
|
5
|
+
This program is free software: you can redistribute it and/or modify it under
|
|
6
|
+
the terms of the GNU General Public License as published by the Free Software
|
|
7
|
+
Foundation, either version 3 of the License, or (at your option) any later
|
|
8
|
+
version.
|
|
9
|
+
|
|
10
|
+
This program is distributed in the hope that it will be useful, but
|
|
11
|
+
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
13
|
+
See the GNU General Public License for more details.
|
|
14
|
+
|
|
15
|
+
You should have received a copy of the GNU General Public License along with
|
|
16
|
+
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
exports.startPeriodicConditionalTriggerProc = startPeriodicConditionalTriggerProc;
|
|
20
|
+
function startPeriodicConditionalTriggerProc(shouldTrigger, trigger, timeoutSecond) {
|
|
21
|
+
let checkActive = true;
|
|
22
|
+
function checkAndTrigger() {
|
|
23
|
+
if (!checkActive) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
if (shouldTrigger()) {
|
|
27
|
+
trigger();
|
|
28
|
+
}
|
|
29
|
+
setNext();
|
|
30
|
+
}
|
|
31
|
+
let triggerTime = undefined;
|
|
32
|
+
function setNext() {
|
|
33
|
+
var _a;
|
|
34
|
+
triggerTime = setTimeout(checkAndTrigger, timeoutSecond * 1000);
|
|
35
|
+
if (typeof triggerTime === 'object') {
|
|
36
|
+
(_a = triggerTime.unref) === null || _a === void 0 ? void 0 : _a.call(triggerTime);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return () => {
|
|
40
|
+
checkActive = false;
|
|
41
|
+
clearTimeout(triggerTime);
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
Object.freeze(exports);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
|
-
Copyright (C) 2016, 2018, 2020 3NSoft Inc.
|
|
3
|
+
Copyright (C) 2016, 2018, 2020, 2026 3NSoft Inc.
|
|
4
4
|
|
|
5
5
|
This program is free software: you can redistribute it and/or modify it under
|
|
6
6
|
the terms of the GNU General Public License as published by the Free Software
|
|
@@ -22,6 +22,7 @@ const spec_module_1 = require("../libs-for-tests/spec-module");
|
|
|
22
22
|
const path_1 = require("path");
|
|
23
23
|
const assert_1 = require("../../lib-common/assert");
|
|
24
24
|
const canonical_address_1 = require("../../lib-common/canonical-address");
|
|
25
|
+
const json_equal_1 = require("../libs-for-tests/json-equal");
|
|
25
26
|
describe('ASMail', () => {
|
|
26
27
|
const s = (0, setups_1.setupWithUsers)(true, ['Bob Perkins @company.inc', 'John Morrison @bank.com']);
|
|
27
28
|
beforeAll(() => {
|
|
@@ -37,6 +38,7 @@ describe('ASMail', () => {
|
|
|
37
38
|
expect(typeof w3n.mail.config).toBe('object');
|
|
38
39
|
expect(typeof w3n.mail.getUserId).toBe('function');
|
|
39
40
|
expect(typeof w3n.mail.getReportAddressForDomain).toBe('function');
|
|
41
|
+
expect(typeof w3n.mail.filter).toBe('object');
|
|
40
42
|
}
|
|
41
43
|
}, undefined, s);
|
|
42
44
|
(0, jasmine_utils_1.itCond)('gets current user id', async () => {
|
|
@@ -75,6 +77,32 @@ describe('ASMail', () => {
|
|
|
75
77
|
await config.setOnServer('init-pub-key', null).then(() => fail(`public key shouldn't be set directly`), err => expect(err).toBeTruthy());
|
|
76
78
|
}, undefined, s);
|
|
77
79
|
});
|
|
80
|
+
describe(`filter`, () => {
|
|
81
|
+
let filter;
|
|
82
|
+
beforeAll(() => {
|
|
83
|
+
filter = s.testAppCapsByUserIndex(0).mail.filter;
|
|
84
|
+
});
|
|
85
|
+
(0, jasmine_utils_1.itCond)(`manages filtering rules, applied to incoming and outgoing messages`, async () => {
|
|
86
|
+
let rules = await filter.listRules();
|
|
87
|
+
expect(Array.isArray(rules)).toBeTrue();
|
|
88
|
+
let oneAddrBlock = await filter.addRule({
|
|
89
|
+
ruleType: 'block-address',
|
|
90
|
+
domain: 'some.do.ma.in',
|
|
91
|
+
username: 'blocked user'
|
|
92
|
+
});
|
|
93
|
+
expect(oneAddrBlock.ruleIndex).toBe(rules.length);
|
|
94
|
+
await filter.addRule({
|
|
95
|
+
ruleType: 'block-domain',
|
|
96
|
+
domain: 'bad.do.ma.in'
|
|
97
|
+
});
|
|
98
|
+
rules = await filter.listRules();
|
|
99
|
+
expect((0, json_equal_1.deepEqual)(rules[oneAddrBlock.ruleIndex], oneAddrBlock.rule)).toBeTrue();
|
|
100
|
+
let foundAndRemoved = await filter.removeRule(oneAddrBlock.ruleIndex, oneAddrBlock.rule);
|
|
101
|
+
expect(foundAndRemoved).toBeTrue();
|
|
102
|
+
foundAndRemoved = await filter.removeRule(oneAddrBlock.ruleIndex, oneAddrBlock.rule);
|
|
103
|
+
expect(foundAndRemoved).toBeFalse();
|
|
104
|
+
});
|
|
105
|
+
});
|
|
78
106
|
(0, jasmine_utils_1.itCond)('inbox lists incoming messages (no messages)', async () => {
|
|
79
107
|
(0, assert_1.assert)(s.users.length > 0);
|
|
80
108
|
for (const u of s.users) {
|
|
@@ -88,9 +116,11 @@ describe('ASMail', () => {
|
|
|
88
116
|
(0, assert_1.assert)(s.users.length > 0);
|
|
89
117
|
for (const u of s.users) {
|
|
90
118
|
const w3n = s.testAppCapsByUser(u);
|
|
91
|
-
const
|
|
92
|
-
|
|
93
|
-
|
|
119
|
+
const someAddr = await w3n.mail.getUserId();
|
|
120
|
+
const domain = someAddr.substring(someAddr.indexOf('@'));
|
|
121
|
+
const domainReportAddr = await w3n.mail.getReportAddressForDomain(domain);
|
|
122
|
+
expect(typeof domainReportAddr).toBe('string');
|
|
123
|
+
expect((0, canonical_address_1.checkAndTransformAddress)(domainReportAddr)).toBeTruthy();
|
|
94
124
|
}
|
|
95
125
|
}, undefined, s);
|
|
96
126
|
(0, spec_module_1.loadSpecs)(s, (0, path_1.join)(__dirname, 'asmail', 'specs'));
|