core-3nweb-client-lib 0.20.3 → 0.20.4
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 +1 -1
- package/build/core-ipc/common-caps.d.ts +2 -3
- package/build/core-ipc/common-caps.js +18 -48
- package/build/core-ipc/generic.d.ts +16 -0
- package/build/core-ipc/generic.js +62 -0
- package/build/core-ipc/startup-caps.d.ts +7 -2
- package/build/core-ipc/startup-caps.js +16 -18
- package/build/lib-client/cryptor/cryptor-wasm.js +1 -1
- package/build/lib-client/cryptor/cryptor.wasm +0 -0
- package/package.json +1 -1
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Caller, ExposedServices } from "../ipc-via-protobuf/connector";
|
|
2
|
+
import { CapExposer, MakeCapClient } from "./generic";
|
|
2
3
|
declare type W3N = web3n.caps.common.W3N;
|
|
3
|
-
export declare type CapExposer = (cap: any, coreSide: ExposedServices) => ExposedObj<any> | ExposedFn;
|
|
4
|
-
export declare type MakeCapClient = (clientSide: Caller, objPath: string[]) => any;
|
|
5
4
|
export declare function exposeW3N<T extends W3N>(coreSide: ExposedServices, w3n: T, extraCAPs?: {
|
|
6
5
|
[cap in keyof T]: CapExposer;
|
|
7
6
|
}): void;
|
|
@@ -22,58 +22,28 @@ const log_cap_1 = require("../ipc-via-protobuf/log-cap");
|
|
|
22
22
|
const asmail_cap_1 = require("../ipc-via-protobuf/asmail-cap");
|
|
23
23
|
const storage_cap_1 = require("../ipc-via-protobuf/storage-cap");
|
|
24
24
|
const mailerid_1 = require("../ipc-via-protobuf/mailerid");
|
|
25
|
-
const
|
|
25
|
+
const generic_1 = require("./generic");
|
|
26
26
|
function exposeW3N(coreSide, w3n, extraCAPs) {
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
if (w3n.mail) {
|
|
35
|
-
expW3N.mail = asmail_cap_1.exposeASMailCAP(w3n.mail, coreSide);
|
|
36
|
-
}
|
|
37
|
-
if (w3n.storage) {
|
|
38
|
-
expW3N.storage = storage_cap_1.exposeStorageCAP(w3n.storage, coreSide);
|
|
39
|
-
}
|
|
40
|
-
if (extraCAPs) {
|
|
41
|
-
for (const [capName, expose] of Object.entries(extraCAPs)) {
|
|
42
|
-
assert_1.assert(typeof expose === 'function');
|
|
43
|
-
const cap = w3n[capName];
|
|
44
|
-
if (cap) {
|
|
45
|
-
expW3N[capName] = expose(cap, coreSide);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
coreSide.exposeW3NService(expW3N);
|
|
27
|
+
const commonCAPsExposures = {
|
|
28
|
+
log: log_cap_1.exposeLogger,
|
|
29
|
+
mail: asmail_cap_1.exposeASMailCAP,
|
|
30
|
+
mailerid: mailerid_1.exposeMailerIdCAP,
|
|
31
|
+
storage: storage_cap_1.exposeStorageCAP,
|
|
32
|
+
};
|
|
33
|
+
generic_1.exposeCAPs(coreSide, w3n, commonCAPsExposures, extraCAPs);
|
|
50
34
|
}
|
|
51
35
|
exports.exposeW3N = exposeW3N;
|
|
36
|
+
// This is not used, but it ensures that some require runs, providing function
|
|
37
|
+
// for protobuf-something.
|
|
38
|
+
const unused = connector_1.W3N_NAME;
|
|
52
39
|
function makeW3Nclient(clientSide, extraCAPs) {
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
else if (cap === 'mailerid') {
|
|
62
|
-
w3n.mailerid = mailerid_1.makeMailerIdCaller(clientSide, capObjPath);
|
|
63
|
-
}
|
|
64
|
-
else if (cap === 'mail') {
|
|
65
|
-
w3n.mail = asmail_cap_1.makeASMailCaller(clientSide, capObjPath);
|
|
66
|
-
}
|
|
67
|
-
else if (cap === 'storage') {
|
|
68
|
-
w3n.storage = storage_cap_1.makeStorageCaller(clientSide, capObjPath);
|
|
69
|
-
}
|
|
70
|
-
else if (extraCAPs && extraCAPs[cap]) {
|
|
71
|
-
const makeCap = extraCAPs[cap];
|
|
72
|
-
assert_1.assert(typeof makeCap === 'function');
|
|
73
|
-
w3n[cap] = makeCap(clientSide, capObjPath);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
return w3n;
|
|
40
|
+
const mainCAPs = {
|
|
41
|
+
log: log_cap_1.makeLogCaller,
|
|
42
|
+
mail: asmail_cap_1.makeASMailCaller,
|
|
43
|
+
mailerid: mailerid_1.makeMailerIdCaller,
|
|
44
|
+
storage: storage_cap_1.makeStorageCaller,
|
|
45
|
+
};
|
|
46
|
+
return generic_1.makeClientSide(clientSide, mainCAPs, extraCAPs);
|
|
77
47
|
}
|
|
78
48
|
exports.makeW3Nclient = makeW3Nclient;
|
|
79
49
|
Object.freeze(exports);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ExposedObj, ExposedFn, ExposedServices, Caller } from "../ipc-via-protobuf/connector";
|
|
2
|
+
export declare type CapExposer = (cap: any, coreSide: ExposedServices) => ExposedObj<any> | ExposedFn;
|
|
3
|
+
export declare type MakeCapClient = (clientSide: Caller, objPath: string[]) => any;
|
|
4
|
+
export declare function addCAPsInExposure<T extends object>(expW3N: ExposedObj<T>, coreSide: ExposedServices, w3n: T, capExposures: {
|
|
5
|
+
[cap in keyof T]: CapExposer;
|
|
6
|
+
}): void;
|
|
7
|
+
export declare function exposeCAPs<T extends W3N, W3N extends object>(coreSide: ExposedServices, w3n: T, mainCAPs: {
|
|
8
|
+
[cap in keyof W3N]: CapExposer;
|
|
9
|
+
}, extraCAPs?: {
|
|
10
|
+
[cap in keyof T]: CapExposer;
|
|
11
|
+
}): void;
|
|
12
|
+
export declare function makeClientSide<T extends W3N, W3N extends object>(clientSide: Caller, mainCAPs: {
|
|
13
|
+
[cap in keyof W3N]: MakeCapClient;
|
|
14
|
+
}, extraCAPs?: {
|
|
15
|
+
[cap in keyof T]: MakeCapClient;
|
|
16
|
+
}): T;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
Copyright (C) 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.makeClientSide = exports.exposeCAPs = exports.addCAPsInExposure = void 0;
|
|
20
|
+
const connector_1 = require("../ipc-via-protobuf/connector");
|
|
21
|
+
const assert_1 = require("../lib-common/assert");
|
|
22
|
+
function addCAPsInExposure(expW3N, coreSide, w3n, capExposures) {
|
|
23
|
+
for (const [capName, expose] of Object.entries(capExposures)) {
|
|
24
|
+
assert_1.assert(typeof expose === 'function');
|
|
25
|
+
assert_1.assert(!expW3N[capName], `Capability ${capName} is already exposed, and we specifically have no shadowing.`);
|
|
26
|
+
const cap = w3n[capName];
|
|
27
|
+
if (cap) {
|
|
28
|
+
expW3N[capName] = expose(cap, coreSide);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.addCAPsInExposure = addCAPsInExposure;
|
|
33
|
+
function exposeCAPs(coreSide, w3n, mainCAPs, extraCAPs) {
|
|
34
|
+
const expW3N = {};
|
|
35
|
+
addCAPsInExposure(expW3N, coreSide, w3n, mainCAPs);
|
|
36
|
+
if (extraCAPs) {
|
|
37
|
+
addCAPsInExposure(expW3N, coreSide, w3n, extraCAPs);
|
|
38
|
+
}
|
|
39
|
+
coreSide.exposeW3NService(expW3N);
|
|
40
|
+
}
|
|
41
|
+
exports.exposeCAPs = exposeCAPs;
|
|
42
|
+
function makeClientSide(clientSide, mainCAPs, extraCAPs) {
|
|
43
|
+
const objPath = [connector_1.W3N_NAME];
|
|
44
|
+
const lstOfCAPs = clientSide.listObj(objPath);
|
|
45
|
+
const w3n = {};
|
|
46
|
+
for (const cap of lstOfCAPs) {
|
|
47
|
+
const capObjPath = objPath.concat(cap);
|
|
48
|
+
if (mainCAPs[cap]) {
|
|
49
|
+
const makeCap = mainCAPs[cap];
|
|
50
|
+
assert_1.assert(typeof makeCap === 'function');
|
|
51
|
+
w3n[cap] = makeCap(clientSide, capObjPath);
|
|
52
|
+
}
|
|
53
|
+
else if (extraCAPs && extraCAPs[cap]) {
|
|
54
|
+
const makeCap = extraCAPs[cap];
|
|
55
|
+
assert_1.assert(typeof makeCap === 'function');
|
|
56
|
+
w3n[cap] = makeCap(clientSide, capObjPath);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return w3n;
|
|
60
|
+
}
|
|
61
|
+
exports.makeClientSide = makeClientSide;
|
|
62
|
+
Object.freeze(exports);
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { ExposedServices, Caller } from "../ipc-via-protobuf/connector";
|
|
2
|
+
import { CapExposer, MakeCapClient } from "./generic";
|
|
2
3
|
declare type W3N = web3n.startup.W3N;
|
|
3
|
-
export declare function exposeStartupW3N(coreSide: ExposedServices, w3n:
|
|
4
|
-
|
|
4
|
+
export declare function exposeStartupW3N<T extends W3N>(coreSide: ExposedServices, w3n: T, extraCAPs?: {
|
|
5
|
+
[cap in keyof T]: CapExposer;
|
|
6
|
+
}): void;
|
|
7
|
+
export declare function makeStartupW3Nclient<T extends W3N>(clientSide: Caller, extraCAPs?: {
|
|
8
|
+
[cap in keyof T]: MakeCapClient;
|
|
9
|
+
}): W3N;
|
|
5
10
|
export {};
|
|
@@ -20,28 +20,26 @@ exports.makeStartupW3Nclient = exports.exposeStartupW3N = void 0;
|
|
|
20
20
|
const connector_1 = require("../ipc-via-protobuf/connector");
|
|
21
21
|
const log_cap_1 = require("../ipc-via-protobuf/log-cap");
|
|
22
22
|
const startup_cap_1 = require("../ipc-via-protobuf/startup-cap");
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
const generic_1 = require("./generic");
|
|
24
|
+
function exposeStartupW3N(coreSide, w3n, extraCAPs) {
|
|
25
|
+
const startupCAPsExposures = {
|
|
26
|
+
signIn: startup_cap_1.wrapSignInCAP,
|
|
27
|
+
signUp: startup_cap_1.wrapSignUpCAP,
|
|
28
|
+
log: log_cap_1.exposeLogger,
|
|
27
29
|
};
|
|
28
|
-
|
|
29
|
-
expW3N.log = log_cap_1.exposeLogger(w3n.log);
|
|
30
|
-
}
|
|
31
|
-
coreSide.exposeW3NService(expW3N);
|
|
30
|
+
generic_1.exposeCAPs(coreSide, w3n, startupCAPsExposures, extraCAPs);
|
|
32
31
|
}
|
|
33
32
|
exports.exposeStartupW3N = exposeStartupW3N;
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
33
|
+
// This is not used, but it ensures that some require runs, providing function
|
|
34
|
+
// for protobuf-something.
|
|
35
|
+
const unused = connector_1.W3N_NAME;
|
|
36
|
+
function makeStartupW3Nclient(clientSide, extraCAPs) {
|
|
37
|
+
const mainCAPs = {
|
|
38
|
+
log: log_cap_1.makeLogCaller,
|
|
39
|
+
signIn: startup_cap_1.makeSignInCaller,
|
|
40
|
+
signUp: startup_cap_1.makeSignUpCaller,
|
|
40
41
|
};
|
|
41
|
-
|
|
42
|
-
w3n.log = log_cap_1.makeLogCaller(clientSide, objPath.concat('log'));
|
|
43
|
-
}
|
|
44
|
-
return w3n;
|
|
42
|
+
return generic_1.makeClientSide(clientSide, mainCAPs, extraCAPs);
|
|
45
43
|
}
|
|
46
44
|
exports.makeStartupW3Nclient = makeStartupW3Nclient;
|
|
47
45
|
Object.freeze(exports);
|