core-3nweb-client-lib 0.20.3 → 0.20.7
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 +4 -9
- package/build/core-ipc/common-caps.js +18 -48
- package/build/core-ipc/generic.d.ts +13 -0
- package/build/core-ipc/generic.js +63 -0
- package/build/core-ipc/startup-caps.d.ts +3 -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,11 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Caller, ExposedServices } from "../ipc-via-protobuf/connector";
|
|
2
|
+
import { ClientCAPsWraps, CAPsExposures, TypeDifference } from "./generic";
|
|
2
3
|
declare type W3N = web3n.caps.common.W3N;
|
|
3
|
-
export declare
|
|
4
|
-
export declare
|
|
5
|
-
export declare function exposeW3N<T extends W3N>(coreSide: ExposedServices, w3n: T, extraCAPs?: {
|
|
6
|
-
[cap in keyof T]: CapExposer;
|
|
7
|
-
}): void;
|
|
8
|
-
export declare function makeW3Nclient<T extends W3N>(clientSide: Caller, extraCAPs?: {
|
|
9
|
-
[cap in keyof T]: MakeCapClient;
|
|
10
|
-
}): T;
|
|
4
|
+
export declare function exposeW3N<T extends W3N>(coreSide: ExposedServices, w3n: T, extraCAPs?: CAPsExposures<TypeDifference<T, W3N>>): void;
|
|
5
|
+
export declare function makeW3Nclient<T extends W3N>(clientSide: Caller, extraCAPs?: ClientCAPsWraps<TypeDifference<T, W3N>>): T;
|
|
11
6
|
export {};
|
|
@@ -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,13 @@
|
|
|
1
|
+
import { ExposedObj, ExposedFn, ExposedServices, Caller } from "../ipc-via-protobuf/connector";
|
|
2
|
+
export declare type CAPsExposures<T> = {
|
|
3
|
+
[cap in keyof Required<T>]: (cap: any, coreSide: ExposedServices) => ExposedObj<any> | ExposedFn;
|
|
4
|
+
};
|
|
5
|
+
export declare type TypeDifference<T extends TExc, TExc extends object> = {
|
|
6
|
+
[cap in Exclude<keyof T, keyof TExc>]: T[cap];
|
|
7
|
+
};
|
|
8
|
+
export declare function exposeCAPs<T extends W3N, W3N extends object>(coreSide: ExposedServices, w3n: T, mainCAPs: CAPsExposures<W3N>, extraCAPs: CAPsExposures<TypeDifference<T, W3N>> | undefined): void;
|
|
9
|
+
export declare type MakeCapClient = (clientSide: Caller, objPath: string[]) => any;
|
|
10
|
+
export declare type ClientCAPsWraps<T> = {
|
|
11
|
+
[cap in keyof Required<T>]: MakeCapClient;
|
|
12
|
+
};
|
|
13
|
+
export declare function makeClientSide<T extends W3N, W3N extends object>(clientSide: Caller, mainCAPs: ClientCAPsWraps<W3N>, extraCAPs: ClientCAPsWraps<TypeDifference<T, W3N>> | undefined): T;
|
|
@@ -0,0 +1,63 @@
|
|
|
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 = void 0;
|
|
20
|
+
const connector_1 = require("../ipc-via-protobuf/connector");
|
|
21
|
+
const assert_1 = require("../lib-common/assert");
|
|
22
|
+
function exposeCAPs(coreSide, w3n, mainCAPs, extraCAPs) {
|
|
23
|
+
const expW3N = {};
|
|
24
|
+
addCAPsInExposure(expW3N, coreSide, w3n, mainCAPs);
|
|
25
|
+
if (extraCAPs) {
|
|
26
|
+
addCAPsInExposure(expW3N, coreSide, w3n, extraCAPs);
|
|
27
|
+
}
|
|
28
|
+
coreSide.exposeW3NService(expW3N);
|
|
29
|
+
}
|
|
30
|
+
exports.exposeCAPs = exposeCAPs;
|
|
31
|
+
function addCAPsInExposure(expW3N, coreSide, w3n, capExposures) {
|
|
32
|
+
for (const capName in capExposures) {
|
|
33
|
+
const expose = capExposures[capName];
|
|
34
|
+
assert_1.assert(typeof expose === 'function');
|
|
35
|
+
assert_1.assert(!expW3N[capName], `Capability ${capName} is already exposed, and we specifically have no shadowing.`);
|
|
36
|
+
const cap = w3n[capName];
|
|
37
|
+
if (cap) {
|
|
38
|
+
expW3N[capName] = expose(cap, coreSide);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
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) {
|
|
54
|
+
assert_1.assert(!!exposeCAPs);
|
|
55
|
+
const makeCap = extraCAPs[cap];
|
|
56
|
+
assert_1.assert(typeof makeCap === 'function');
|
|
57
|
+
w3n[cap] = makeCap(clientSide, capObjPath);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return w3n;
|
|
61
|
+
}
|
|
62
|
+
exports.makeClientSide = makeClientSide;
|
|
63
|
+
Object.freeze(exports);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ExposedServices, Caller } from "../ipc-via-protobuf/connector";
|
|
2
|
+
import { ClientCAPsWraps, CAPsExposures, TypeDifference } from "./generic";
|
|
2
3
|
declare type W3N = web3n.startup.W3N;
|
|
3
|
-
export declare function exposeStartupW3N(coreSide: ExposedServices, w3n: W3N): void;
|
|
4
|
-
export declare function makeStartupW3Nclient(clientSide: Caller): W3N;
|
|
4
|
+
export declare function exposeStartupW3N<T extends W3N>(coreSide: ExposedServices, w3n: T, extraCAPs?: CAPsExposures<TypeDifference<T, W3N>>): void;
|
|
5
|
+
export declare function makeStartupW3Nclient<T extends W3N>(clientSide: Caller, extraCAPs?: ClientCAPsWraps<TypeDifference<T, W3N>>): W3N;
|
|
5
6
|
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);
|