core-3nweb-client-lib 0.19.5 → 0.20.3
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 +2 -2
- package/build/api-defs/web3n.d.ts +2 -1
- package/build/core/asmail/delivery/index.js +1 -1
- package/build/core/index.js +1 -1
- package/build/core/sign-up.js +5 -6
- package/build/ipc-via-protobuf/asmail-cap.js +4 -4
- package/build/ipc-via-protobuf/bytes.js +1 -1
- package/build/ipc-via-protobuf/connector-clients-side.js +3 -0
- package/build/ipc-via-protobuf/connector-services-side.js +1 -1
- package/build/ipc-via-protobuf/connector.d.ts +2 -2
- package/build/ipc-via-protobuf/connector.js +4 -1
- package/build/ipc-via-protobuf/file.d.ts +2 -1
- package/build/ipc-via-protobuf/file.js +1 -1
- package/build/ipc-via-protobuf/fs.d.ts +2 -1
- package/build/ipc-via-protobuf/fs.js +1 -1
- package/build/ipc-via-protobuf/log-cap.js +1 -1
- package/build/ipc-via-protobuf/mailerid.js +1 -1
- package/build/ipc-via-protobuf/proto-defs.js +1 -1
- package/build/ipc-via-protobuf/protobuf-msg.d.ts +2 -9
- package/build/ipc-via-protobuf/protobuf-msg.js +13 -70
- package/build/ipc-via-protobuf/protos/asmail.proto +1 -1
- package/build/ipc-via-protobuf/startup-cap.js +1 -1
- package/build/ipc-via-protobuf/storage-cap.js +1 -1
- package/build/lib-client/cryptor/cryptor-in-worker.d.ts +19 -5
- package/build/lib-client/cryptor/cryptor-in-worker.js +191 -157
- package/build/lib-client/cryptor/cryptor-wasm.js +1 -0
- package/build/lib-client/cryptor/cryptor.d.ts +5 -3
- package/build/lib-client/cryptor/cryptor.js +19 -7
- package/build/lib-client/cryptor/cryptor.wasm +0 -0
- package/build/lib-client/cryptor/{cryptor-in-proc.d.ts → in-proc-js.d.ts} +0 -0
- package/build/lib-client/cryptor/{cryptor-in-proc.js → in-proc-js.js} +0 -0
- package/build/lib-client/cryptor/in-proc-wasm.d.ts +2 -0
- package/build/lib-client/cryptor/in-proc-wasm.js +187 -0
- package/build/lib-client/cryptor/proto-defs.js +50 -0
- package/build/lib-client/cryptor/protos/cryptor.proto +45 -0
- package/build/lib-client/cryptor/wasm-mp1-modules.d.ts +5 -0
- package/build/lib-client/cryptor/wasm-mp1-modules.js +79 -0
- package/build/lib-client/cryptor/worker-js.d.ts +1 -0
- package/build/lib-client/cryptor/worker-js.js +139 -0
- package/build/lib-client/cryptor/worker-wasm.d.ts +1 -0
- package/build/lib-client/cryptor/worker-wasm.js +37 -0
- package/build/lib-client/key-derivation.js +1 -1
- package/build/lib-client/protobuf-loader.d.ts +12 -0
- package/build/lib-client/protobuf-loader.js +96 -0
- package/build/lib-index.d.ts +5 -3
- package/build/lib-index.js +5 -3
- package/package.json +2 -2
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
Copyright (C) 2020 - 2021 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.ProtoType = void 0;
|
|
20
|
+
const protobuf = require("protobufjs");
|
|
21
|
+
const path_1 = require("path");
|
|
22
|
+
const fs = require("fs");
|
|
23
|
+
class ProtoType {
|
|
24
|
+
constructor(type) {
|
|
25
|
+
this.type = type;
|
|
26
|
+
Object.freeze(this);
|
|
27
|
+
}
|
|
28
|
+
static makeFrom(searchDir, protoFile, typeName, fallbackMod) {
|
|
29
|
+
const root = loadRoot(searchDir, protoFile, fallbackMod);
|
|
30
|
+
const type = root.lookupType(typeName);
|
|
31
|
+
return new ProtoType(type);
|
|
32
|
+
}
|
|
33
|
+
pack(msg) {
|
|
34
|
+
const err = this.type.verify(msg);
|
|
35
|
+
if (err) {
|
|
36
|
+
throw new Error(err);
|
|
37
|
+
}
|
|
38
|
+
return this.type.encode(msg).finish();
|
|
39
|
+
}
|
|
40
|
+
unpack(bytes) {
|
|
41
|
+
if (!bytes) {
|
|
42
|
+
throw {
|
|
43
|
+
runtimeException: true,
|
|
44
|
+
type: 'ipc',
|
|
45
|
+
missingBodyBytes: true
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
return this.type.decode(bytes);
|
|
49
|
+
}
|
|
50
|
+
packToBase64(msg) {
|
|
51
|
+
return this.pack(msg).toString('base64');
|
|
52
|
+
}
|
|
53
|
+
unpackFromBase64(str) {
|
|
54
|
+
return this.unpack(Buffer.from(str, 'base64'));
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
exports.ProtoType = ProtoType;
|
|
58
|
+
Object.freeze(ProtoType.prototype);
|
|
59
|
+
Object.freeze(ProtoType);
|
|
60
|
+
const roots = new Map();
|
|
61
|
+
function loadRoot(searchDir, fileName, fallbackMod) {
|
|
62
|
+
const filePath = path_1.resolve(searchDir, 'protos', fileName);
|
|
63
|
+
let root = roots.get(filePath);
|
|
64
|
+
if (!root) {
|
|
65
|
+
// if proto files file, we try to get definitions from the module
|
|
66
|
+
try {
|
|
67
|
+
root = protobuf.loadSync(filePath);
|
|
68
|
+
}
|
|
69
|
+
catch (err) {
|
|
70
|
+
if (!fallbackMod) {
|
|
71
|
+
throw err;
|
|
72
|
+
}
|
|
73
|
+
const protos = fallbackMod.protos;
|
|
74
|
+
if (!protos || (typeof protos !== 'object')) {
|
|
75
|
+
throw new Error(`proto-defs doesn't have expected object`);
|
|
76
|
+
}
|
|
77
|
+
const initFunc = fs.readFileSync;
|
|
78
|
+
try {
|
|
79
|
+
fs.readFileSync = (fName) => {
|
|
80
|
+
const protoDefsStr = protos[fName];
|
|
81
|
+
if (!protoDefsStr) {
|
|
82
|
+
throw new Error(`Don't have in module proto definition for ${fName}`);
|
|
83
|
+
}
|
|
84
|
+
return Buffer.from(protoDefsStr, 'utf8');
|
|
85
|
+
};
|
|
86
|
+
root = protobuf.loadSync(fileName);
|
|
87
|
+
}
|
|
88
|
+
finally {
|
|
89
|
+
fs.readFileSync = initFunc;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
roots.set(filePath, root);
|
|
93
|
+
}
|
|
94
|
+
return root;
|
|
95
|
+
}
|
|
96
|
+
Object.freeze(exports);
|
package/build/lib-index.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ import * as signupClientFuncs from './lib-client/3nweb-signup';
|
|
|
19
19
|
import * as signupApi from './lib-common/user-admin-api/signup';
|
|
20
20
|
import { user as midUser } from './lib-common/mid-sigs-NaCl-Ed';
|
|
21
21
|
import * as srvLocFuncs from './lib-client/service-locator';
|
|
22
|
-
import * as
|
|
22
|
+
import * as cryptor from './lib-client/cryptor/cryptor';
|
|
23
23
|
export declare namespace raw3NWebClients {
|
|
24
24
|
type StorageOwner = StorageOwnerClient;
|
|
25
25
|
const StorageOwner: typeof StorageOwnerClient;
|
|
@@ -37,6 +37,8 @@ export declare namespace raw3NWebClients {
|
|
|
37
37
|
function getLibVersion(): string;
|
|
38
38
|
}
|
|
39
39
|
export declare namespace cryptors {
|
|
40
|
-
const makeInProcessCryptor: typeof
|
|
41
|
-
const
|
|
40
|
+
const makeInProcessCryptor: typeof cryptor.makeInProcessCryptor;
|
|
41
|
+
const makeInProcessWasmCryptor: typeof cryptor.makeInProcessWasmCryptor;
|
|
42
|
+
const makeInWorkerCryptor: cryptor.makeCryptor;
|
|
43
|
+
const makeInWorkerWasmCryptor: cryptor.makeCryptor;
|
|
42
44
|
}
|
package/build/lib-index.js
CHANGED
|
@@ -60,7 +60,7 @@ const sender_1 = require("./lib-client/asmail/sender");
|
|
|
60
60
|
const provisioner_1 = require("./lib-client/mailer-id/provisioner");
|
|
61
61
|
const signupClientFuncs = require("./lib-client/3nweb-signup");
|
|
62
62
|
const srvLocFuncs = require("./lib-client/service-locator");
|
|
63
|
-
const
|
|
63
|
+
const cryptor = require("./lib-client/cryptor/cryptor");
|
|
64
64
|
var raw3NWebClients;
|
|
65
65
|
(function (raw3NWebClients) {
|
|
66
66
|
raw3NWebClients.StorageOwner = service_1.StorageOwner;
|
|
@@ -77,8 +77,10 @@ var raw3NWebClients;
|
|
|
77
77
|
Object.freeze(raw3NWebClients);
|
|
78
78
|
var cryptors;
|
|
79
79
|
(function (cryptors) {
|
|
80
|
-
cryptors.makeInProcessCryptor =
|
|
81
|
-
cryptors.
|
|
80
|
+
cryptors.makeInProcessCryptor = cryptor.makeInProcessCryptor;
|
|
81
|
+
cryptors.makeInProcessWasmCryptor = cryptor.makeInProcessWasmCryptor;
|
|
82
|
+
cryptors.makeInWorkerCryptor = cryptor.makeInWorkerCryptor;
|
|
83
|
+
cryptors.makeInWorkerWasmCryptor = cryptor.makeInWorkerWasmCryptor;
|
|
82
84
|
})(cryptors = exports.cryptors || (exports.cryptors = {}));
|
|
83
85
|
Object.freeze(cryptors);
|
|
84
86
|
Object.freeze(exports);
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "core-3nweb-client-lib",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.3",
|
|
4
4
|
"description": "3NWeb client core library, embeddable into different environments",
|
|
5
5
|
"main": "build/lib-index.js",
|
|
6
6
|
"types": "build/lib-index.d.ts",
|
|
7
7
|
"scripts": {
|
|
8
|
-
"build": "tsc -p ts-code && bash packing/copy-api-and-proto-defs.sh",
|
|
8
|
+
"build": "tsc -p ts-code && bash packing/copy-api-and-proto-defs.sh && bash packing/build-wasm-cryptor.sh",
|
|
9
9
|
"test": "node build/tests/jasmine.js"
|
|
10
10
|
},
|
|
11
11
|
"repository": {
|