core-3nweb-client-lib 0.20.4 → 0.20.8
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/startup.d.ts +0 -1
- package/build/core/index.d.ts +1 -1
- package/build/core/index.js +1 -4
- package/build/core-ipc/common-caps.d.ts +3 -7
- package/build/core-ipc/generic.d.ts +11 -14
- package/build/core-ipc/generic.js +14 -13
- package/build/core-ipc/startup-caps.d.ts +3 -7
- package/build/core-ipc/startup-caps.js +0 -3
- package/package.json +1 -1
package/build/core/index.d.ts
CHANGED
|
@@ -22,7 +22,7 @@ export declare class Core {
|
|
|
22
22
|
private closingProc;
|
|
23
23
|
private constructor();
|
|
24
24
|
static make(conf: CoreConf, makeNet: () => NetClient, makeResolver: ServiceLocatorMaker, makeCryptor: makeCryptor): Core;
|
|
25
|
-
start(
|
|
25
|
+
start(): {
|
|
26
26
|
capsForStartup: web3n.startup.W3N;
|
|
27
27
|
coreInit: Promise<string>;
|
|
28
28
|
};
|
package/build/core/index.js
CHANGED
|
@@ -112,16 +112,13 @@ class Core {
|
|
|
112
112
|
const core = new Core(makeNet, makeResolver, makeCryptor, dirs, logger, conf.signUpUrl);
|
|
113
113
|
return core;
|
|
114
114
|
}
|
|
115
|
-
start(
|
|
115
|
+
start() {
|
|
116
116
|
const signUp = new sign_up_1.SignUp(this.signUpUrl, this.cryptor.cryptor, this.makeNet, this.appDirs.getUsersOnDisk, this.logger.logError);
|
|
117
117
|
const signIn = new sign_in_1.SignIn(this.cryptor.cryptor, this.initForExistingUserWithoutCache, this.initForExistingUserWithCache, this.appDirs.getUsersOnDisk, this.logger.logError);
|
|
118
118
|
const capsForStartup = {
|
|
119
119
|
signUp: signUp.exposedService(),
|
|
120
120
|
signIn: signIn.exposedService()
|
|
121
121
|
};
|
|
122
|
-
if (logCAP) {
|
|
123
|
-
capsForStartup.log = (type, msg, e) => this.logger.appLog(type, STARTUP_APP_DOMAIN, msg, e);
|
|
124
|
-
}
|
|
125
122
|
Object.freeze(capsForStartup);
|
|
126
123
|
const initFromSignUp$ = signUp.newUser$
|
|
127
124
|
.pipe(operators_1.mergeMap(this.initForNewUser, 1));
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import { Caller, ExposedServices } from "../ipc-via-protobuf/connector";
|
|
2
|
-
import {
|
|
2
|
+
import { ClientCAPsWraps, CAPsExposures, TypeDifference } from "./generic";
|
|
3
3
|
declare type W3N = web3n.caps.common.W3N;
|
|
4
|
-
export declare function exposeW3N<T extends W3N>(coreSide: ExposedServices, w3n: T, extraCAPs?:
|
|
5
|
-
|
|
6
|
-
}): void;
|
|
7
|
-
export declare function makeW3Nclient<T extends W3N>(clientSide: Caller, extraCAPs?: {
|
|
8
|
-
[cap in keyof T]: MakeCapClient;
|
|
9
|
-
}): 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;
|
|
10
6
|
export {};
|
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
import { ExposedObj, ExposedFn, ExposedServices, Caller } from "../ipc-via-protobuf/connector";
|
|
2
|
-
export declare type
|
|
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;
|
|
3
9
|
export declare type MakeCapClient = (clientSide: Caller, objPath: string[]) => any;
|
|
4
|
-
export declare
|
|
5
|
-
[cap in keyof T]:
|
|
6
|
-
}
|
|
7
|
-
export declare function
|
|
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;
|
|
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;
|
|
@@ -16,20 +16,9 @@
|
|
|
16
16
|
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
17
|
*/
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
-
exports.makeClientSide = exports.exposeCAPs =
|
|
19
|
+
exports.makeClientSide = exports.exposeCAPs = void 0;
|
|
20
20
|
const connector_1 = require("../ipc-via-protobuf/connector");
|
|
21
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
22
|
function exposeCAPs(coreSide, w3n, mainCAPs, extraCAPs) {
|
|
34
23
|
const expW3N = {};
|
|
35
24
|
addCAPsInExposure(expW3N, coreSide, w3n, mainCAPs);
|
|
@@ -39,6 +28,17 @@ function exposeCAPs(coreSide, w3n, mainCAPs, extraCAPs) {
|
|
|
39
28
|
coreSide.exposeW3NService(expW3N);
|
|
40
29
|
}
|
|
41
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
42
|
function makeClientSide(clientSide, mainCAPs, extraCAPs) {
|
|
43
43
|
const objPath = [connector_1.W3N_NAME];
|
|
44
44
|
const lstOfCAPs = clientSide.listObj(objPath);
|
|
@@ -50,7 +50,8 @@ function makeClientSide(clientSide, mainCAPs, extraCAPs) {
|
|
|
50
50
|
assert_1.assert(typeof makeCap === 'function');
|
|
51
51
|
w3n[cap] = makeCap(clientSide, capObjPath);
|
|
52
52
|
}
|
|
53
|
-
else if (extraCAPs
|
|
53
|
+
else if (extraCAPs) {
|
|
54
|
+
assert_1.assert(!!exposeCAPs);
|
|
54
55
|
const makeCap = extraCAPs[cap];
|
|
55
56
|
assert_1.assert(typeof makeCap === 'function');
|
|
56
57
|
w3n[cap] = makeCap(clientSide, capObjPath);
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import { ExposedServices, Caller } from "../ipc-via-protobuf/connector";
|
|
2
|
-
import {
|
|
2
|
+
import { ClientCAPsWraps, CAPsExposures, TypeDifference } from "./generic";
|
|
3
3
|
declare type W3N = web3n.startup.W3N;
|
|
4
|
-
export declare function exposeStartupW3N<T extends W3N>(coreSide: ExposedServices, w3n: T, extraCAPs?:
|
|
5
|
-
|
|
6
|
-
}): void;
|
|
7
|
-
export declare function makeStartupW3Nclient<T extends W3N>(clientSide: Caller, extraCAPs?: {
|
|
8
|
-
[cap in keyof T]: MakeCapClient;
|
|
9
|
-
}): 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;
|
|
10
6
|
export {};
|
|
@@ -18,14 +18,12 @@
|
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
19
|
exports.makeStartupW3Nclient = exports.exposeStartupW3N = void 0;
|
|
20
20
|
const connector_1 = require("../ipc-via-protobuf/connector");
|
|
21
|
-
const log_cap_1 = require("../ipc-via-protobuf/log-cap");
|
|
22
21
|
const startup_cap_1 = require("../ipc-via-protobuf/startup-cap");
|
|
23
22
|
const generic_1 = require("./generic");
|
|
24
23
|
function exposeStartupW3N(coreSide, w3n, extraCAPs) {
|
|
25
24
|
const startupCAPsExposures = {
|
|
26
25
|
signIn: startup_cap_1.wrapSignInCAP,
|
|
27
26
|
signUp: startup_cap_1.wrapSignUpCAP,
|
|
28
|
-
log: log_cap_1.exposeLogger,
|
|
29
27
|
};
|
|
30
28
|
generic_1.exposeCAPs(coreSide, w3n, startupCAPsExposures, extraCAPs);
|
|
31
29
|
}
|
|
@@ -35,7 +33,6 @@ exports.exposeStartupW3N = exposeStartupW3N;
|
|
|
35
33
|
const unused = connector_1.W3N_NAME;
|
|
36
34
|
function makeStartupW3Nclient(clientSide, extraCAPs) {
|
|
37
35
|
const mainCAPs = {
|
|
38
|
-
log: log_cap_1.makeLogCaller,
|
|
39
36
|
signIn: startup_cap_1.makeSignInCaller,
|
|
40
37
|
signUp: startup_cap_1.makeSignUpCaller,
|
|
41
38
|
};
|