core-3nweb-client-lib 0.44.12 → 0.45.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/core/asmail/msg/opener.js +1 -1
- package/build/core/asmail/msg/packer.js +1 -1
- package/build/core/index.d.ts +2 -2
- package/build/core/keyring/correspondent-keys.js +1 -1
- package/build/core/keyring/index.js +1 -1
- package/build/core/startup/sign-in.d.ts +1 -1
- package/build/core/startup/sign-up.d.ts +1 -1
- package/build/core/storage/index.d.ts +1 -1
- package/build/lib-client/key-derivation.d.ts +1 -1
- package/build/lib-client/xsp-fs/node-persistence.js +1 -1
- package/build/tests/caps-api/asmail/specs/events.d.ts +2 -0
- package/build/tests/caps-api/asmail/specs/events.js +63 -0
- package/build/tests/caps-api/asmail/specs/send-to-wrong-address.d.ts +2 -0
- package/build/tests/caps-api/asmail/specs/send-to-wrong-address.js +68 -0
- package/build/tests/caps-api/asmail/specs/send-with-attacment-from-storage.d.ts +2 -0
- package/build/tests/caps-api/asmail/specs/send-with-attacment-from-storage.js +259 -0
- package/build/tests/caps-api/asmail/specs/send-without-attachments.d.ts +2 -0
- package/build/tests/caps-api/asmail/specs/send-without-attachments.js +90 -0
- package/build/tests/caps-api/asmail/test-utils.d.ts +12 -0
- package/build/tests/caps-api/asmail/test-utils.js +60 -0
- package/build/tests/caps-api/asmail.js +86 -0
- package/build/tests/caps-api/file-sink-checks/different-cases.d.ts +2 -0
- package/build/tests/caps-api/file-sink-checks/different-cases.js +47 -0
- package/build/tests/caps-api/file-sink-checks/splice.d.ts +2 -0
- package/build/tests/caps-api/file-sink-checks/splice.js +122 -0
- package/build/tests/caps-api/file-sink-checks/truncate.d.ts +2 -0
- package/build/tests/caps-api/file-sink-checks/truncate.js +122 -0
- package/build/tests/caps-api/fs-checks/local-to-synced-linking/link.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/local-to-synced-linking/link.js +82 -0
- package/build/tests/caps-api/fs-checks/local-to-synced-linking/reversed-linking.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/local-to-synced-linking/reversed-linking.js +50 -0
- package/build/tests/caps-api/fs-checks/not-versioned/deleteFile.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/not-versioned/deleteFile.js +73 -0
- package/build/tests/caps-api/fs-checks/not-versioned/deleteFolder.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/not-versioned/deleteFolder.js +75 -0
- package/build/tests/caps-api/fs-checks/not-versioned/getByteSink.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/not-versioned/getByteSink.js +96 -0
- package/build/tests/caps-api/fs-checks/not-versioned/getByteSource.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/not-versioned/getByteSource.js +67 -0
- package/build/tests/caps-api/fs-checks/not-versioned/getXAttr.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/not-versioned/getXAttr.js +77 -0
- package/build/tests/caps-api/fs-checks/not-versioned/link.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/not-versioned/link.js +115 -0
- package/build/tests/caps-api/fs-checks/not-versioned/listFolder.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/not-versioned/listFolder.js +129 -0
- package/build/tests/caps-api/fs-checks/not-versioned/listXAttrs.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/not-versioned/listXAttrs.js +73 -0
- package/build/tests/caps-api/fs-checks/not-versioned/makeFolder.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/not-versioned/makeFolder.js +95 -0
- package/build/tests/caps-api/fs-checks/not-versioned/move.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/not-versioned/move.js +127 -0
- package/build/tests/caps-api/fs-checks/not-versioned/readBytes.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/not-versioned/readBytes.js +80 -0
- package/build/tests/caps-api/fs-checks/not-versioned/readJSONFile.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/not-versioned/readJSONFile.js +59 -0
- package/build/tests/caps-api/fs-checks/not-versioned/readLink.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/not-versioned/readLink.js +39 -0
- package/build/tests/caps-api/fs-checks/not-versioned/readTxtFile.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/not-versioned/readTxtFile.js +54 -0
- package/build/tests/caps-api/fs-checks/not-versioned/readonlyFile.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/not-versioned/readonlyFile.js +55 -0
- package/build/tests/caps-api/fs-checks/not-versioned/readonlySubRoot.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/not-versioned/readonlySubRoot.js +55 -0
- package/build/tests/caps-api/fs-checks/not-versioned/select.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/not-versioned/select.js +119 -0
- package/build/tests/caps-api/fs-checks/not-versioned/stat.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/not-versioned/stat.js +96 -0
- package/build/tests/caps-api/fs-checks/not-versioned/updateXAttrs.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/not-versioned/updateXAttrs.js +126 -0
- package/build/tests/caps-api/fs-checks/not-versioned/writableFile.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/not-versioned/writableFile.js +79 -0
- package/build/tests/caps-api/fs-checks/not-versioned/writableSubRoot.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/not-versioned/writableSubRoot.js +90 -0
- package/build/tests/caps-api/fs-checks/not-versioned/writeBytes.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/not-versioned/writeBytes.js +137 -0
- package/build/tests/caps-api/fs-checks/not-versioned/writeJSONFile.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/not-versioned/writeJSONFile.js +101 -0
- package/build/tests/caps-api/fs-checks/not-versioned/writeTxtFile.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/not-versioned/writeTxtFile.js +100 -0
- package/build/tests/caps-api/fs-checks/sync-on-one-dev/startUpload.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/sync-on-one-dev/startUpload.js +187 -0
- package/build/tests/caps-api/fs-checks/sync-on-one-dev/stat.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/sync-on-one-dev/stat.js +70 -0
- package/build/tests/caps-api/fs-checks/sync-on-one-dev/status.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/sync-on-one-dev/status.js +53 -0
- package/build/tests/caps-api/fs-checks/sync-on-one-dev/upload.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/sync-on-one-dev/upload.js +194 -0
- package/build/tests/caps-api/fs-checks/sync-with-two-devs/conflicts.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/sync-with-two-devs/conflicts.js +396 -0
- package/build/tests/caps-api/fs-checks/sync-with-two-devs/update-propagation.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/sync-with-two-devs/update-propagation.js +229 -0
- package/build/tests/caps-api/fs-checks/test-utils.d.ts +34 -0
- package/build/tests/caps-api/fs-checks/test-utils.js +95 -0
- package/build/tests/caps-api/fs-checks/versioned/archiveCurrent.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/versioned/archiveCurrent.js +73 -0
- package/build/tests/caps-api/fs-checks/versioned/getByteSink.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/versioned/getByteSink.js +122 -0
- package/build/tests/caps-api/fs-checks/versioned/getByteSource.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/versioned/getByteSource.js +71 -0
- package/build/tests/caps-api/fs-checks/versioned/listFolder.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/versioned/listFolder.js +109 -0
- package/build/tests/caps-api/fs-checks/versioned/listVersions.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/versioned/listVersions.js +48 -0
- package/build/tests/caps-api/fs-checks/versioned/readBytes.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/versioned/readBytes.js +90 -0
- package/build/tests/caps-api/fs-checks/versioned/readJSONFile.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/versioned/readJSONFile.js +60 -0
- package/build/tests/caps-api/fs-checks/versioned/readTxtFile.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/versioned/readTxtFile.js +56 -0
- package/build/tests/caps-api/fs-checks/versioned/stat.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/versioned/stat.js +80 -0
- package/build/tests/caps-api/fs-checks/versioned/watchFile.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/versioned/watchFile.js +64 -0
- package/build/tests/caps-api/fs-checks/versioned/writeBytes.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/versioned/writeBytes.js +128 -0
- package/build/tests/caps-api/fs-checks/versioned/writeJSONFile.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/versioned/writeJSONFile.js +111 -0
- package/build/tests/caps-api/fs-checks/versioned/writeTxtFile.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/versioned/writeTxtFile.js +107 -0
- package/build/tests/caps-api/fs-checks/with-core-restarts/xattrs.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/with-core-restarts/xattrs.js +50 -0
- package/build/tests/caps-api/keyrings.js +69 -0
- package/build/tests/caps-api/mailerid.d.ts +1 -0
- package/build/tests/caps-api/mailerid.js +59 -0
- package/build/tests/caps-api/startup/signin-empty-cache.d.ts +1 -0
- package/build/tests/caps-api/startup/signin-empty-cache.js +108 -0
- package/build/tests/caps-api/startup/signin-with-cache.d.ts +1 -0
- package/build/tests/caps-api/startup/signin-with-cache.js +83 -0
- package/build/tests/caps-api/startup/signup-with-token.d.ts +1 -0
- package/build/tests/caps-api/startup/signup-with-token.js +53 -0
- package/build/tests/caps-api/startup/signup.d.ts +1 -0
- package/build/tests/caps-api/startup/signup.js +86 -0
- package/build/tests/caps-api/storage.d.ts +1 -0
- package/build/tests/caps-api/storage.js +225 -0
- package/build/tests/computer.3nweb.core/id-manager.d.ts +1 -0
- package/build/tests/computer.3nweb.core/id-manager.js +78 -0
- package/build/tests/computer.3nweb.core/inbox/msg-indexing.d.ts +1 -0
- package/build/tests/computer.3nweb.core/inbox/msg-indexing.js +145 -0
- package/build/tests/computer.3nweb.core/keyrings.d.ts +1 -0
- package/build/tests/computer.3nweb.core/keyrings.js +64 -0
- package/build/tests/computer.3nweb.core/test-utils.d.ts +21 -0
- package/build/tests/computer.3nweb.core/test-utils.js +92 -0
- package/build/tests/jasmine.d.ts +1 -0
- package/build/tests/jasmine.js +45 -0
- package/build/tests/libs-for-tests/bytes-equal.d.ts +1 -0
- package/build/tests/libs-for-tests/bytes-equal.js +32 -0
- package/build/tests/libs-for-tests/caps-ipc-wrap.d.ts +11 -0
- package/build/tests/libs-for-tests/caps-ipc-wrap.js +55 -0
- package/build/tests/libs-for-tests/core-runner.d.ts +39 -0
- package/build/tests/libs-for-tests/core-runner.js +231 -0
- package/build/tests/libs-for-tests/jasmine-utils.d.ts +13 -0
- package/build/tests/libs-for-tests/jasmine-utils.js +110 -0
- package/build/tests/libs-for-tests/json-equal.d.ts +1 -0
- package/build/tests/libs-for-tests/json-equal.js +78 -0
- package/build/tests/libs-for-tests/services-runner.d.ts +18 -0
- package/build/tests/libs-for-tests/services-runner.js +64 -0
- package/build/tests/libs-for-tests/setups.d.ts +51 -0
- package/build/tests/libs-for-tests/setups.js +305 -0
- package/build/tests/libs-for-tests/spec-module.d.ts +16 -0
- package/build/tests/libs-for-tests/spec-module.js +92 -0
- package/build/tests/libs-for-tests/startup.d.ts +1 -0
- package/build/tests/libs-for-tests/startup.js +29 -0
- package/build/tests/libs-for-tests/watching.d.ts +7 -0
- package/build/tests/libs-for-tests/watching.js +33 -0
- package/build/tests/units/canonical-address.d.ts +1 -0
- package/build/tests/units/canonical-address.js +41 -0
- package/build/tests/units/device-fs.d.ts +1 -0
- package/build/tests/units/device-fs.js +70 -0
- package/build/tests/units/folder-node-serialization.d.ts +1 -0
- package/build/tests/units/folder-node-serialization.js +74 -0
- package/build/tests/units/mid-sigs-NaCl-Ed.d.ts +1 -0
- package/build/tests/units/mid-sigs-NaCl-Ed.js +123 -0
- package/build/tests/units/number-line.d.ts +1 -0
- package/build/tests/units/number-line.js +63 -0
- package/build/tests/units/obj-folders.d.ts +1 -0
- package/build/tests/units/obj-folders.js +152 -0
- package/package.json +11 -3
- package/postinstall.js +1 -1
- package/build/cryptors.d.ts +0 -1
- package/build/cryptors.js +0 -34
- package/build/lib-client/cryptor/cryptor-in-worker.d.ts +0 -20
- package/build/lib-client/cryptor/cryptor-in-worker.js +0 -357
- package/build/lib-client/cryptor/cryptor-wasm.js +0 -1
- package/build/lib-client/cryptor/cryptor.d.ts +0 -30
- package/build/lib-client/cryptor/cryptor.js +0 -44
- package/build/lib-client/cryptor/cryptor.wasm +0 -0
- package/build/lib-client/cryptor/in-proc-js.d.ts +0 -2
- package/build/lib-client/cryptor/in-proc-js.js +0 -57
- package/build/lib-client/cryptor/in-proc-wasm.d.ts +0 -2
- package/build/lib-client/cryptor/in-proc-wasm.js +0 -176
- package/build/lib-client/cryptor/serialization-for-wasm.d.ts +0 -35
- package/build/lib-client/cryptor/serialization-for-wasm.js +0 -57
- package/build/lib-client/cryptor/wasm-mp1-modules.d.ts +0 -5
- package/build/lib-client/cryptor/wasm-mp1-modules.js +0 -78
- package/build/lib-client/cryptor/worker-js.js +0 -131
- package/build/lib-client/cryptor/worker-wasm.js +0 -37
- package/build/protos/cryptor.proto.js +0 -1804
- /package/build/lib-client/{cryptor/cryptor-work-labels.d.ts → cryptor-work-labels.d.ts} +0 -0
- /package/build/lib-client/{cryptor/cryptor-work-labels.js → cryptor-work-labels.js} +0 -0
- /package/build/{lib-client/cryptor/worker-js.d.ts → tests/caps-api/asmail.d.ts} +0 -0
- /package/build/{lib-client/cryptor/worker-wasm.d.ts → tests/caps-api/keyrings.d.ts} +0 -0
|
@@ -21,7 +21,7 @@ exports.openMsg = openMsg;
|
|
|
21
21
|
const buffer_utils_1 = require("../../../lib-common/buffer-utils");
|
|
22
22
|
const error_1 = require("../../../lib-common/exceptions/error");
|
|
23
23
|
const xsp_files_1 = require("xsp-files");
|
|
24
|
-
const cryptor_work_labels_1 = require("../../../lib-client/cryptor
|
|
24
|
+
const cryptor_work_labels_1 = require("../../../lib-client/cryptor-work-labels");
|
|
25
25
|
class OpenedMsg {
|
|
26
26
|
constructor(msgId, main) {
|
|
27
27
|
this.msgId = msgId;
|
|
@@ -24,7 +24,7 @@ const buffer_utils_1 = require("../../../lib-common/buffer-utils");
|
|
|
24
24
|
const folder_node_serialization_1 = require("../../../lib-client/xsp-fs/folder-node-serialization");
|
|
25
25
|
const json_utils_1 = require("../../../lib-common/json-utils");
|
|
26
26
|
const attachments_container_1 = require("./attachments-container");
|
|
27
|
-
const cryptor_work_labels_1 = require("../../../lib-client/cryptor
|
|
27
|
+
const cryptor_work_labels_1 = require("../../../lib-client/cryptor-work-labels");
|
|
28
28
|
function turnKeysToB64(obj) {
|
|
29
29
|
obj.key = buffer_utils_1.base64.pack(obj.key);
|
|
30
30
|
if (!obj.folder) {
|
package/build/core/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { FactoryOfFSs } from './storage';
|
|
2
|
-
import { makeCryptor } from '../lib-client/cryptor/cryptor';
|
|
3
2
|
import { NetClient } from '../lib-client/request-utils';
|
|
4
3
|
import { ServiceLocatorMaker } from '../lib-client/service-locator';
|
|
4
|
+
import type { makeCryptor } from 'ecma-nacl-cryptors';
|
|
5
|
+
export type { makeCryptor } from 'ecma-nacl-cryptors';
|
|
5
6
|
type RequestedCAPs = web3n.caps.common.RequestedCAPs;
|
|
6
7
|
type W3N = web3n.caps.common.W3N;
|
|
7
8
|
type ProgressCB = web3n.startup.ProgressCB;
|
|
@@ -58,4 +59,3 @@ export declare class Core {
|
|
|
58
59
|
storage$: import("rxjs").Observable<import("./storage/synced/remote-events").StorageConnectionStatus>;
|
|
59
60
|
};
|
|
60
61
|
}
|
|
61
|
-
export {};
|
|
@@ -27,7 +27,7 @@ const ecma_nacl_1 = require("ecma-nacl");
|
|
|
27
27
|
const buffer_utils_1 = require("../../lib-common/buffer-utils");
|
|
28
28
|
const error_1 = require("../../lib-common/exceptions/error");
|
|
29
29
|
const async_cryptor_wrap_1 = require("../../lib-common/async-cryptor-wrap");
|
|
30
|
-
const cryptor_work_labels_1 = require("../../lib-client/cryptor
|
|
30
|
+
const cryptor_work_labels_1 = require("../../lib-client/cryptor-work-labels");
|
|
31
31
|
function generatePids() {
|
|
32
32
|
const pids = [];
|
|
33
33
|
for (let i = 0; i < 5; i += 1) {
|
|
@@ -27,7 +27,7 @@ const buffer_utils_1 = require("../../lib-common/buffer-utils");
|
|
|
27
27
|
const canonical_address_1 = require("../../lib-common/canonical-address");
|
|
28
28
|
const common_2 = require("../asmail/delivery/common");
|
|
29
29
|
const keyring_storage_1 = require("./keyring-storage");
|
|
30
|
-
const cryptor_work_labels_1 = require("../../lib-client/cryptor
|
|
30
|
+
const cryptor_work_labels_1 = require("../../lib-client/cryptor-work-labels");
|
|
31
31
|
const published_intro_key_1 = require("./published-intro-key");
|
|
32
32
|
var common_3 = require("./common");
|
|
33
33
|
Object.defineProperty(exports, "KEY_USE", { enumerable: true, get: function () { return common_3.KEY_USE; } });
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ScryptGenParams } from '../../lib-client/key-derivation';
|
|
2
2
|
import type { GetUsersOnDisk } from '../app-files';
|
|
3
|
-
import { Cryptor } from '../../lib-client/cryptor/cryptor';
|
|
4
3
|
import { LogError } from '../../lib-client/logging/log-to-file';
|
|
4
|
+
import type { Cryptor } from 'ecma-nacl-cryptors';
|
|
5
5
|
export type GenerateKey = (derivParams: ScryptGenParams) => Promise<Uint8Array>;
|
|
6
6
|
export type StartInitWithoutCache = (address: string) => Promise<CompleteInitWithoutCache | undefined>;
|
|
7
7
|
export type CompleteInitWithoutCache = (midLoginKey: GenerateKey, storageKey: GenerateKey) => Promise<boolean>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { NetClient } from '../../lib-client/request-utils';
|
|
2
2
|
import * as keyDeriv from '../../lib-client/key-derivation';
|
|
3
3
|
import type { GetUsersOnDisk } from '../app-files';
|
|
4
|
-
import { Cryptor } from '../../lib-client/cryptor/cryptor';
|
|
5
4
|
import { LogError } from '../../lib-client/logging/log-to-file';
|
|
5
|
+
import type { Cryptor } from 'ecma-nacl-cryptors';
|
|
6
6
|
type JsonKey = web3n.keys.JsonKey;
|
|
7
7
|
export interface ScryptGenParams {
|
|
8
8
|
logN: number;
|
|
@@ -7,7 +7,7 @@ import { AsyncSBoxCryptor } from 'xsp-files';
|
|
|
7
7
|
import { StoragePathForUser } from '../app-files';
|
|
8
8
|
import { LogError } from '../../lib-client/logging/log-to-file';
|
|
9
9
|
import { MakeNet } from '..';
|
|
10
|
-
import { Cryptor } from '
|
|
10
|
+
import type { Cryptor } from 'ecma-nacl-cryptors';
|
|
11
11
|
type WritableFS = web3n.files.WritableFS;
|
|
12
12
|
type StorageType = web3n.storage.StorageType;
|
|
13
13
|
type FSItem = web3n.files.FSItem;
|
|
@@ -25,7 +25,7 @@ const xsp_files_1 = require("xsp-files");
|
|
|
25
25
|
const buffer_utils_1 = require("../../lib-common/buffer-utils");
|
|
26
26
|
const deferred_1 = require("../../lib-common/processes/deferred");
|
|
27
27
|
const random = require("../../lib-common/random-node");
|
|
28
|
-
const cryptor_work_labels_1 = require("../cryptor
|
|
28
|
+
const cryptor_work_labels_1 = require("../cryptor-work-labels");
|
|
29
29
|
const pv1 = require("./xsp-payload-v1");
|
|
30
30
|
const pv2 = require("./xsp-payload-v2");
|
|
31
31
|
const SEG_SIZE = 16; // in 256-byte blocks = 4K in bytes
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
Copyright (C) 2017 - 2018, 2020 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.specs = void 0;
|
|
20
|
+
const test_utils_1 = require("../test-utils");
|
|
21
|
+
exports.specs = {
|
|
22
|
+
description: '.subscribe',
|
|
23
|
+
its: []
|
|
24
|
+
};
|
|
25
|
+
const it = {
|
|
26
|
+
expectation: `delivers new messages to listeners of event 'message'`
|
|
27
|
+
};
|
|
28
|
+
it.func = async function (s) {
|
|
29
|
+
const u1_w3n = s.testAppCapsByUserIndex(0);
|
|
30
|
+
const u2 = s.users[1];
|
|
31
|
+
const u2_w3n = s.testAppCapsByUser(u2);
|
|
32
|
+
// user 2 starts listening for events, collecting 'em into an array
|
|
33
|
+
const incomingMsgs = [];
|
|
34
|
+
const receptionPromise = new Promise((resolve, reject) => {
|
|
35
|
+
u2_w3n.mail.inbox.subscribe('message', {
|
|
36
|
+
next: (msg) => {
|
|
37
|
+
incomingMsgs.push(msg);
|
|
38
|
+
// promise will resolve when at least two messages come
|
|
39
|
+
if (incomingMsgs.length >= 2) {
|
|
40
|
+
resolve(incomingMsgs);
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
error: reject
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
const txtBody1 = 'Some text\nBlah-blah-blah';
|
|
47
|
+
const txtBody2 = 'Another text message';
|
|
48
|
+
// user 1 sends messages to user 2
|
|
49
|
+
const msgId1 = await (0, test_utils_1.sendTxtMsg)(u1_w3n, u2.userId, txtBody1);
|
|
50
|
+
expect(msgId1).toBeTruthy();
|
|
51
|
+
const msgId2 = await (0, test_utils_1.sendTxtMsg)(u1_w3n, u2.userId, txtBody2);
|
|
52
|
+
expect(msgId2).toBeTruthy();
|
|
53
|
+
// user 2 gets incoming message
|
|
54
|
+
await receptionPromise;
|
|
55
|
+
[[msgId1, txtBody1], [msgId2, txtBody2]]
|
|
56
|
+
.forEach(([msgId, txtBody]) => {
|
|
57
|
+
const msg = incomingMsgs.find(m => (m.msgId === msgId));
|
|
58
|
+
expect(msg).withContext(`message ${msgId} should be present in a list of all messages`).toBeTruthy();
|
|
59
|
+
expect(msg.plainTxtBody).toBe(txtBody);
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
exports.specs.its.push(it);
|
|
63
|
+
Object.freeze(exports);
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
Copyright (C) 2016 - 2018, 2020, 2024 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.specs = void 0;
|
|
20
|
+
exports.specs = {
|
|
21
|
+
description: '.sendMsg',
|
|
22
|
+
its: []
|
|
23
|
+
};
|
|
24
|
+
const it = {
|
|
25
|
+
expectation: 'send message to unknown user'
|
|
26
|
+
};
|
|
27
|
+
it.func = async function (s) {
|
|
28
|
+
const u = s.users[0];
|
|
29
|
+
const w3n = s.testAppCapsByUser(u);
|
|
30
|
+
const txtBody = 'Some text\nBlah-blah-blah';
|
|
31
|
+
const recipient = `Unknown ${u.userId}`;
|
|
32
|
+
// user 1 sends message to user 2
|
|
33
|
+
const msg = {
|
|
34
|
+
msgType: 'mail',
|
|
35
|
+
plainTxtBody: txtBody
|
|
36
|
+
};
|
|
37
|
+
// start sending
|
|
38
|
+
const idForSending = 'q2w3e';
|
|
39
|
+
await w3n.mail.delivery.addMsg([recipient], msg, idForSending);
|
|
40
|
+
// register delivery progress callback
|
|
41
|
+
const notifs = [];
|
|
42
|
+
// observe, while waiting for delivery completion
|
|
43
|
+
const observation = new Promise(async (resolve, reject) => {
|
|
44
|
+
const observer = {
|
|
45
|
+
next: (p) => { notifs.push(p); },
|
|
46
|
+
complete: resolve, error: reject
|
|
47
|
+
};
|
|
48
|
+
const cbDetach = w3n.mail.delivery.observeDelivery(idForSending, observer);
|
|
49
|
+
expect(typeof cbDetach).toBe('function');
|
|
50
|
+
});
|
|
51
|
+
expect(await w3n.mail.delivery.currentState(idForSending)).toBeTruthy();
|
|
52
|
+
// notifications should have something
|
|
53
|
+
await observation;
|
|
54
|
+
// test on localhost may complete requestbefore observation start
|
|
55
|
+
if (notifs.length > 0) {
|
|
56
|
+
const lastInfo = notifs[notifs.length - 1];
|
|
57
|
+
expect(lastInfo).withContext('There has to be at least one event fired').toBeTruthy();
|
|
58
|
+
// it has to be an error
|
|
59
|
+
expect(typeof lastInfo.recipients[recipient].err).toBe('object');
|
|
60
|
+
const exc = lastInfo.recipients[recipient].err;
|
|
61
|
+
expect(exc.unknownRecipient).toBe(true);
|
|
62
|
+
expect(typeof lastInfo.recipients[recipient].idOnDelivery).toBe('undefined');
|
|
63
|
+
}
|
|
64
|
+
await w3n.mail.delivery.rmMsg(idForSending);
|
|
65
|
+
expect(await w3n.mail.delivery.currentState(idForSending)).toBeFalsy();
|
|
66
|
+
};
|
|
67
|
+
exports.specs.its.push(it);
|
|
68
|
+
Object.freeze(exports);
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
Copyright (C) 2016 - 2018, 2020, 2025 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.specs = void 0;
|
|
20
|
+
const random_node_1 = require("../../../../lib-common/random-node");
|
|
21
|
+
const test_utils_1 = require("../test-utils");
|
|
22
|
+
const sleep_1 = require("../../../../lib-common/processes/sleep");
|
|
23
|
+
const random_node_2 = require("../../../../lib-common/random-node");
|
|
24
|
+
const files = [{
|
|
25
|
+
content: 'This is file content for file #1',
|
|
26
|
+
name: 'file1'
|
|
27
|
+
}, {
|
|
28
|
+
content: 'Content for file #2 (longer file)\n' + (0, random_node_1.stringOfB64CharsSync)(100000),
|
|
29
|
+
name: 'file2'
|
|
30
|
+
}];
|
|
31
|
+
const folder = {
|
|
32
|
+
name: 'parent folder',
|
|
33
|
+
files: [files[0]],
|
|
34
|
+
folders: [{
|
|
35
|
+
name: 'child folder 1',
|
|
36
|
+
files: [files[0]],
|
|
37
|
+
folders: []
|
|
38
|
+
}, {
|
|
39
|
+
name: 'child folder 2',
|
|
40
|
+
files: [files[1]],
|
|
41
|
+
folders: []
|
|
42
|
+
}]
|
|
43
|
+
};
|
|
44
|
+
exports.specs = {
|
|
45
|
+
description: '.sendMsg',
|
|
46
|
+
its: []
|
|
47
|
+
};
|
|
48
|
+
let it = {
|
|
49
|
+
expectation: 'sending and getting message with attachments from synced fs'
|
|
50
|
+
};
|
|
51
|
+
it.func = async function (s) {
|
|
52
|
+
const u1_w3n = s.testAppCapsByUserIndex(0);
|
|
53
|
+
const u2 = s.users[1];
|
|
54
|
+
const txtBody = 'Some text\nBlah-blah-blah';
|
|
55
|
+
// user 1 sends message to user 2
|
|
56
|
+
const recipient = u2.userId;
|
|
57
|
+
// make fs objects for attachment
|
|
58
|
+
const appFS = await u1_w3n.storage.getAppSyncedFS('app.3nweb.test');
|
|
59
|
+
const filesToAttach = [];
|
|
60
|
+
for (const fp of files) {
|
|
61
|
+
const path = fp.name;
|
|
62
|
+
await appFS.writeTxtFile(path, fp.content);
|
|
63
|
+
const file = await appFS.readonlyFile(path);
|
|
64
|
+
filesToAttach.push(file);
|
|
65
|
+
}
|
|
66
|
+
const makeFolderIn = async (parent, folder) => {
|
|
67
|
+
const fs = await parent.writableSubRoot(folder.name);
|
|
68
|
+
for (const fp of folder.files) {
|
|
69
|
+
await fs.writeTxtFile(fp.name, fp.content);
|
|
70
|
+
}
|
|
71
|
+
for (const fp of folder.folders) {
|
|
72
|
+
await makeFolderIn(fs, fp);
|
|
73
|
+
}
|
|
74
|
+
return fs;
|
|
75
|
+
};
|
|
76
|
+
const folderToAttach = await makeFolderIn(appFS, folder);
|
|
77
|
+
// put together and send message
|
|
78
|
+
const outMsg = {
|
|
79
|
+
msgType: 'mail',
|
|
80
|
+
plainTxtBody: txtBody
|
|
81
|
+
};
|
|
82
|
+
outMsg.attachments = { files: {}, folders: {} };
|
|
83
|
+
for (const file of filesToAttach) {
|
|
84
|
+
outMsg.attachments.files[file.name] = file;
|
|
85
|
+
}
|
|
86
|
+
outMsg.attachments.folders[folderToAttach.name] = folderToAttach;
|
|
87
|
+
const idForSending = 'a1b2';
|
|
88
|
+
await u1_w3n.mail.delivery.addMsg([recipient], outMsg, idForSending);
|
|
89
|
+
expect(await u1_w3n.mail.delivery.currentState(idForSending)).toBeTruthy();
|
|
90
|
+
const notifs = [];
|
|
91
|
+
await new Promise((resolve, reject) => {
|
|
92
|
+
const observer = {
|
|
93
|
+
next: (p) => { notifs.push(p); },
|
|
94
|
+
complete: resolve, error: reject
|
|
95
|
+
};
|
|
96
|
+
const cbDetach = u1_w3n.mail.delivery.observeDelivery(idForSending, observer);
|
|
97
|
+
expect(typeof cbDetach).toBe('function');
|
|
98
|
+
});
|
|
99
|
+
expect(notifs.length).toBeGreaterThan(0);
|
|
100
|
+
const lastInfo = notifs[notifs.length - 1];
|
|
101
|
+
expect(typeof lastInfo).toBe('object');
|
|
102
|
+
expect(lastInfo.allDone).toBe('all-ok');
|
|
103
|
+
(0, test_utils_1.throwDeliveryErrorFrom)(lastInfo);
|
|
104
|
+
await u1_w3n.mail.delivery.rmMsg(idForSending);
|
|
105
|
+
expect(await u1_w3n.mail.delivery.currentState(idForSending)).toBeFalsy();
|
|
106
|
+
const recInfo = lastInfo.recipients[recipient];
|
|
107
|
+
expect(typeof recInfo.idOnDelivery).toBe('string');
|
|
108
|
+
const msgId = recInfo.idOnDelivery;
|
|
109
|
+
expect(msgId).toBeTruthy();
|
|
110
|
+
// user 2 gets incoming message after some delay
|
|
111
|
+
await (0, sleep_1.sleep)(500);
|
|
112
|
+
const u2_w3n = s.testAppCapsByUser(u2);
|
|
113
|
+
// check message
|
|
114
|
+
const msgs = await u2_w3n.mail.inbox.listMsgs();
|
|
115
|
+
const msgInfo = msgs.find(m => (m.msgId === msgId));
|
|
116
|
+
expect(msgInfo).withContext(`message ${msgId} should be present in a list of all messages`).toBeTruthy();
|
|
117
|
+
const inMsg = await u2_w3n.mail.inbox.getMsg(msgId);
|
|
118
|
+
expect(inMsg).toBeTruthy();
|
|
119
|
+
expect(inMsg.plainTxtBody).toBe(txtBody);
|
|
120
|
+
// check attachments presence
|
|
121
|
+
expect(inMsg.attachments).withContext(`attachments should be present in message ${msgId}`).toBeDefined();
|
|
122
|
+
const attachments = inMsg.attachments;
|
|
123
|
+
if (!attachments) {
|
|
124
|
+
throw new Error(`skipping further checks`);
|
|
125
|
+
}
|
|
126
|
+
expect(attachments.writable).toBeFalse();
|
|
127
|
+
// check files in attachments
|
|
128
|
+
for (const fp of files) {
|
|
129
|
+
expect(await attachments.readTxtFile(fp.name)).withContext(`file content should be exactly what has been sent`).toBe(fp.content);
|
|
130
|
+
await (0, sleep_1.sleep)(10);
|
|
131
|
+
const file = await attachments.readonlyFile(fp.name);
|
|
132
|
+
expect(file.writable).toBeFalse();
|
|
133
|
+
expect(await file.readTxt()).toBe(fp.content);
|
|
134
|
+
}
|
|
135
|
+
// check folder in attachments
|
|
136
|
+
const checkFolderIn = async (parent, params) => {
|
|
137
|
+
expect(await parent.checkFolderPresence(params.name)).withContext(`folder ${params.name} should be present in ${parent.name}`).toBe(true);
|
|
138
|
+
const fs = await parent.readonlySubRoot(params.name);
|
|
139
|
+
expect(fs.writable).toBeFalse();
|
|
140
|
+
for (const fp of params.files) {
|
|
141
|
+
expect(await fs.readTxtFile(fp.name)).withContext(`file content should be exactly what has been sent`).toBe(fp.content);
|
|
142
|
+
}
|
|
143
|
+
for (const fp of params.folders) {
|
|
144
|
+
await checkFolderIn(fs, fp);
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
await checkFolderIn(attachments, folder);
|
|
148
|
+
};
|
|
149
|
+
exports.specs.its.push(it);
|
|
150
|
+
async function doRoundTripSendingToEstablishInvites(u1, u1_w3n, u2, u2_w3n) {
|
|
151
|
+
// send message from 1 to 2
|
|
152
|
+
await (0, test_utils_1.sendTxtMsg)(u1_w3n, u2.userId, 'some text');
|
|
153
|
+
// read message from 1, and send reply, which establishes channel with invite
|
|
154
|
+
await u2_w3n.mail.inbox.listMsgs();
|
|
155
|
+
const msg = {
|
|
156
|
+
msgType: 'mail',
|
|
157
|
+
plainTxtBody: 'some text'
|
|
158
|
+
};
|
|
159
|
+
const idForSending = 'h3j4k5';
|
|
160
|
+
await u2_w3n.mail.delivery.addMsg([u1.userId], msg, idForSending);
|
|
161
|
+
await new Promise((resolve, reject) => {
|
|
162
|
+
u2_w3n.mail.delivery.observeDelivery(idForSending, { complete: resolve, error: reject });
|
|
163
|
+
});
|
|
164
|
+
await u2_w3n.mail.delivery.rmMsg(idForSending);
|
|
165
|
+
// read message from 2, to pick up established channel with invite
|
|
166
|
+
await u1_w3n.mail.inbox.listMsgs();
|
|
167
|
+
}
|
|
168
|
+
it = {
|
|
169
|
+
expectation: 'sending and getting message with MBs attachment'
|
|
170
|
+
};
|
|
171
|
+
it.func = async function (s) {
|
|
172
|
+
// XXX While this runs, storage call gets stopFromOtherSide=true ipc exception.
|
|
173
|
+
// And it isn't clear why. It looks like stop comes from an afterAll
|
|
174
|
+
// cleanup.
|
|
175
|
+
// On windows in vm this fail happens consistently.
|
|
176
|
+
const u1 = s.users[0];
|
|
177
|
+
const u1_w3n = s.testAppCapsByUser(u1, false);
|
|
178
|
+
const u2 = s.users[1];
|
|
179
|
+
const u2_w3n = s.testAppCapsByUser(u2, false);
|
|
180
|
+
// send small messages to establish trusted channel, else we hit a limit
|
|
181
|
+
// for a message from an unknown sender
|
|
182
|
+
await doRoundTripSendingToEstablishInvites(u1, u1_w3n, u2, u2_w3n);
|
|
183
|
+
// this text body will be used as a known end of long attachment, which
|
|
184
|
+
// recipient will check.
|
|
185
|
+
const txtBody = (0, random_node_1.stringOfB64CharsSync)(1000);
|
|
186
|
+
const fileName = 'big file';
|
|
187
|
+
// user 1 sends message to user 2
|
|
188
|
+
const recipient = u2.userId;
|
|
189
|
+
// make big file for attachment
|
|
190
|
+
const appFS = await u1_w3n.storage.getAppSyncedFS('app.3nweb.test');
|
|
191
|
+
// fingerprint bytes at the end
|
|
192
|
+
const endBytes = new Uint8Array(txtBody.split('').map(char => char.charCodeAt(0)));
|
|
193
|
+
const bytesToFile = new Uint8Array(3000000 + endBytes.length);
|
|
194
|
+
const rand = await (0, random_node_2.bytes)(1000);
|
|
195
|
+
for (let ofs = 0; ofs < 3000000; ofs += 1000) {
|
|
196
|
+
bytesToFile.set(rand, 1000);
|
|
197
|
+
}
|
|
198
|
+
bytesToFile.set(endBytes, 3000000);
|
|
199
|
+
await appFS.writeBytes(fileName, bytesToFile, { create: true });
|
|
200
|
+
// put together and send message
|
|
201
|
+
const outMsg = {
|
|
202
|
+
msgType: 'mail',
|
|
203
|
+
plainTxtBody: txtBody
|
|
204
|
+
};
|
|
205
|
+
outMsg.attachments = { files: {} };
|
|
206
|
+
outMsg.attachments.files[fileName] = await appFS.readonlyFile(fileName);
|
|
207
|
+
const idForSending = 'q2w3e4';
|
|
208
|
+
await u1_w3n.mail.delivery.addMsg([recipient], outMsg, idForSending);
|
|
209
|
+
expect(await u1_w3n.mail.delivery.currentState(idForSending)).toBeTruthy();
|
|
210
|
+
const notifs = [];
|
|
211
|
+
await new Promise((resolve, reject) => {
|
|
212
|
+
const observer = {
|
|
213
|
+
next: (p) => { notifs.push(p); },
|
|
214
|
+
complete: resolve, error: reject
|
|
215
|
+
};
|
|
216
|
+
const cbDetach = u1_w3n.mail.delivery.observeDelivery(idForSending, observer);
|
|
217
|
+
expect(typeof cbDetach).toBe('function');
|
|
218
|
+
});
|
|
219
|
+
expect(notifs.length).toBeGreaterThan(0);
|
|
220
|
+
const lastInfo = notifs[notifs.length - 1];
|
|
221
|
+
expect(typeof lastInfo).toBe('object');
|
|
222
|
+
expect(lastInfo.allDone).toBe('all-ok');
|
|
223
|
+
(0, test_utils_1.throwDeliveryErrorFrom)(lastInfo);
|
|
224
|
+
await u1_w3n.mail.delivery.rmMsg(idForSending);
|
|
225
|
+
expect(await u1_w3n.mail.delivery.currentState(idForSending)).toBeFalsy();
|
|
226
|
+
const recInfo = lastInfo.recipients[recipient];
|
|
227
|
+
expect(typeof recInfo.idOnDelivery).toBe('string');
|
|
228
|
+
const msgId = recInfo.idOnDelivery;
|
|
229
|
+
expect(msgId).toBeTruthy();
|
|
230
|
+
// user 2 gets incoming message, after a little wait
|
|
231
|
+
await (0, sleep_1.sleep)(500);
|
|
232
|
+
// check message
|
|
233
|
+
const msgs = await u2_w3n.mail.inbox.listMsgs();
|
|
234
|
+
const msgInfo = msgs.find(m => (m.msgId === msgId));
|
|
235
|
+
expect(msgInfo).withContext(`message ${msgId} should be present in a list of all messages`).toBeTruthy();
|
|
236
|
+
const inMsg = await u2_w3n.mail.inbox.getMsg(msgId);
|
|
237
|
+
expect(inMsg).toBeTruthy();
|
|
238
|
+
expect(inMsg.plainTxtBody).toBe(txtBody);
|
|
239
|
+
// check attachments presence
|
|
240
|
+
expect(!!inMsg.attachments).withContext(`attachments should be present in message ${msgId}`).toBe(true);
|
|
241
|
+
const attachments = inMsg.attachments;
|
|
242
|
+
if (!attachments) {
|
|
243
|
+
throw new Error(`skipping further checks`);
|
|
244
|
+
}
|
|
245
|
+
// check file attachment
|
|
246
|
+
const fileBytes = await attachments.readBytes(fileName);
|
|
247
|
+
// fingerprint bytes at the end
|
|
248
|
+
const receivedEndBytes = new Uint8Array(txtBody.split('').map(char => char.charCodeAt(0)));
|
|
249
|
+
const fileEnd = fileBytes.subarray(fileBytes.length - receivedEndBytes.length);
|
|
250
|
+
for (let i = 0; i < fileEnd.length; i += 1) {
|
|
251
|
+
if (fileEnd[i] !== receivedEndBytes[i]) {
|
|
252
|
+
throw new Error(`Byte at position ${i} in the end part of an attachment is not as expected`);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
};
|
|
256
|
+
it.timeout = 15 * 1000;
|
|
257
|
+
// XXX skip this, till we capture described above error
|
|
258
|
+
// specs.its.push(it);
|
|
259
|
+
Object.freeze(exports);
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
Copyright (C) 2016 - 2018, 2020 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.specs = void 0;
|
|
20
|
+
const test_utils_1 = require("../test-utils");
|
|
21
|
+
const sleep_1 = require("../../../../lib-common/processes/sleep");
|
|
22
|
+
const json_equal_1 = require("../../../libs-for-tests/json-equal");
|
|
23
|
+
exports.specs = {
|
|
24
|
+
description: '.sendMsg',
|
|
25
|
+
its: []
|
|
26
|
+
};
|
|
27
|
+
const it = {
|
|
28
|
+
expectation: 'send message to existing address and get it'
|
|
29
|
+
};
|
|
30
|
+
it.func = async function (s) {
|
|
31
|
+
const u1_w3n = s.testAppCapsByUserIndex(0);
|
|
32
|
+
const u2 = s.users[1];
|
|
33
|
+
const txtBody = 'Some text\nBlah-blah-blah';
|
|
34
|
+
const htmlBody = `Some html. Note that core isn't looking/checking this`;
|
|
35
|
+
const jsonBody = {
|
|
36
|
+
field1: 123,
|
|
37
|
+
field2: 'blah-blah'
|
|
38
|
+
};
|
|
39
|
+
// user 1 sends message to user 2
|
|
40
|
+
const recipient = u2.userId;
|
|
41
|
+
const outMsg = {
|
|
42
|
+
msgType: 'mail',
|
|
43
|
+
plainTxtBody: txtBody,
|
|
44
|
+
htmlTxtBody: htmlBody,
|
|
45
|
+
jsonBody
|
|
46
|
+
};
|
|
47
|
+
const idForSending = 'a4b5';
|
|
48
|
+
await u1_w3n.mail.delivery.addMsg([recipient], outMsg, idForSending);
|
|
49
|
+
expect(await u1_w3n.mail.delivery.currentState(idForSending)).toBeTruthy();
|
|
50
|
+
const notifs = [];
|
|
51
|
+
await new Promise((resolve, reject) => {
|
|
52
|
+
const observer = {
|
|
53
|
+
next: (p) => { notifs.push(p); },
|
|
54
|
+
complete: resolve, error: reject
|
|
55
|
+
};
|
|
56
|
+
const cbDetach = u1_w3n.mail.delivery.observeDelivery(idForSending, observer);
|
|
57
|
+
expect(typeof cbDetach).toBe('function');
|
|
58
|
+
});
|
|
59
|
+
expect(notifs.length).toBeGreaterThan(0);
|
|
60
|
+
const lastInfo = notifs[notifs.length - 1];
|
|
61
|
+
expect(typeof lastInfo).toBe('object');
|
|
62
|
+
expect(lastInfo.allDone).toBe('all-ok');
|
|
63
|
+
(0, test_utils_1.throwDeliveryErrorFrom)(lastInfo);
|
|
64
|
+
await u1_w3n.mail.delivery.rmMsg(idForSending);
|
|
65
|
+
await u1_w3n.mail.delivery.rmMsg(idForSending); // noop after first rm
|
|
66
|
+
expect(await u1_w3n.mail.delivery.currentState(idForSending)).toBeFalsy();
|
|
67
|
+
const recInfo = lastInfo.recipients[recipient];
|
|
68
|
+
expect(typeof recInfo.bytesSent).toBe('number');
|
|
69
|
+
expect(typeof recInfo.idOnDelivery).toBe('string');
|
|
70
|
+
const msgId = recInfo.idOnDelivery;
|
|
71
|
+
expect(msgId).toBeTruthy();
|
|
72
|
+
// user 2 checks messages after some delay
|
|
73
|
+
await (0, sleep_1.sleep)(500);
|
|
74
|
+
const u2_w3n = s.testAppCapsByUser(u2);
|
|
75
|
+
const msgs = await u2_w3n.mail.inbox.listMsgs();
|
|
76
|
+
const msgInfo = msgs.find(m => (m.msgId === msgId));
|
|
77
|
+
expect(msgInfo).withContext(`message ${msgId} should be present in a list of all messages`).not.toBeUndefined();
|
|
78
|
+
expect(msgInfo.msgType).toBe('mail');
|
|
79
|
+
const inMsg = await u2_w3n.mail.inbox.getMsg(msgId);
|
|
80
|
+
expect(inMsg).toBeTruthy();
|
|
81
|
+
expect(inMsg.msgId).toBe(msgId);
|
|
82
|
+
expect(inMsg.msgType).toBe('mail');
|
|
83
|
+
expect(inMsg.plainTxtBody).toBe(txtBody);
|
|
84
|
+
expect(inMsg.htmlTxtBody).toBe(htmlBody);
|
|
85
|
+
expect((0, json_equal_1.deepEqual)(inMsg.jsonBody, jsonBody)).toBeTrue();
|
|
86
|
+
await u2_w3n.mail.inbox.removeMsg(msgId);
|
|
87
|
+
await u2_w3n.mail.inbox.removeMsg(msgId); // second call is a noop
|
|
88
|
+
};
|
|
89
|
+
exports.specs.its.push(it);
|
|
90
|
+
Object.freeze(exports);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { SpecIt as GenericSpecIt } from "../../libs-for-tests/spec-module";
|
|
2
|
+
import { MultiUserSetup } from "../../libs-for-tests/setups";
|
|
3
|
+
type commonW3N = web3n.caps.common.W3N;
|
|
4
|
+
/**
|
|
5
|
+
* This function to be run in renderer's context via execExpects
|
|
6
|
+
* @param recipient
|
|
7
|
+
* @param txtBody
|
|
8
|
+
*/
|
|
9
|
+
export declare function sendTxtMsg(w3n: commonW3N, recipient: string, txtBody: string): Promise<string>;
|
|
10
|
+
export type SpecIt = GenericSpecIt<MultiUserSetup>;
|
|
11
|
+
export declare function throwDeliveryErrorFrom(lastNotif: web3n.asmail.DeliveryProgress): void;
|
|
12
|
+
export {};
|