core-3nweb-client-lib 0.24.1 → 0.24.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 +292 -0
- package/build/api-defs/common-caps.d.ts +81 -0
- package/build/api-defs/files.d.ts +1037 -0
- package/build/api-defs/mailerid.d.ts +29 -0
- package/build/api-defs/startup.d.ts +121 -0
- package/build/api-defs/storage.d.ts +69 -0
- package/build/api-defs/web3n.d.ts +50 -0
- package/build/core-ipc/common-caps.d.ts +1 -0
- package/build/core-ipc/common-caps.js +11 -1
- package/build/core-ipc/generic.d.ts +1 -0
- package/build/core-ipc/generic.js +24 -3
- package/build/ipc-via-protobuf/connector-clients-side.d.ts +3 -1
- package/build/ipc-via-protobuf/connector-clients-side.js +16 -3
- package/build/ipc-via-protobuf/connector.d.ts +3 -2
- package/build/ipc-via-protobuf/connector.js +6 -5
- package/build/ipc-via-protobuf/storage-cap.d.ts +1 -0
- package/build/ipc-via-protobuf/storage-cap.js +10 -2
- package/build/lib-index.d.ts +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (C) 2020 3NSoft Inc.
|
|
3
|
+
|
|
4
|
+
This program is free software: you can redistribute it and/or modify it under
|
|
5
|
+
the terms of the GNU General Public License as published by the Free Software
|
|
6
|
+
Foundation, either version 3 of the License, or (at your option) any later
|
|
7
|
+
version.
|
|
8
|
+
|
|
9
|
+
This program is distributed in the hope that it will be useful, but
|
|
10
|
+
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
12
|
+
See the GNU General Public License for more details.
|
|
13
|
+
|
|
14
|
+
You should have received a copy of the GNU General Public License along with
|
|
15
|
+
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
declare namespace web3n.mailerid {
|
|
20
|
+
|
|
21
|
+
interface Service {
|
|
22
|
+
|
|
23
|
+
getUserId(): Promise<string>;
|
|
24
|
+
|
|
25
|
+
login(serviceUrl: string): Promise<string>;
|
|
26
|
+
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (C) 2016 - 2017, 2020 3NSoft Inc.
|
|
3
|
+
|
|
4
|
+
This program is free software: you can redistribute it and/or modify it under
|
|
5
|
+
the terms of the GNU General Public License as published by the Free Software
|
|
6
|
+
Foundation, either version 3 of the License, or (at your option) any later
|
|
7
|
+
version.
|
|
8
|
+
|
|
9
|
+
This program is distributed in the hope that it will be useful, but
|
|
10
|
+
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
12
|
+
See the GNU General Public License for more details.
|
|
13
|
+
|
|
14
|
+
You should have received a copy of the GNU General Public License along with
|
|
15
|
+
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
declare namespace web3n.startup {
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* This is a collection of functions, that are are used by startup
|
|
23
|
+
* functionality, when user creates new account in 3NWeb domains.
|
|
24
|
+
*/
|
|
25
|
+
interface SignUpService {
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* @param name is a part of address that comes before @domain
|
|
29
|
+
* @param signupToken
|
|
30
|
+
* @return a promise, resolvable to an array of available 3NWeb addresses
|
|
31
|
+
* with a given name part of the address.
|
|
32
|
+
* Array will be empty, when there are no available addresses for a given
|
|
33
|
+
* name.
|
|
34
|
+
*/
|
|
35
|
+
getAvailableAddresses(
|
|
36
|
+
name: string, signupToken?: string
|
|
37
|
+
): Promise<string[]>;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* @param userId
|
|
41
|
+
* @param signupToken
|
|
42
|
+
* @return a promise, resolvable to flag that indicates whether an account
|
|
43
|
+
* for given user has been created (true value), or not (false value).
|
|
44
|
+
*/
|
|
45
|
+
addUser(userId: string, signupToken?: string): Promise<boolean>;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* @param userId
|
|
49
|
+
* @return a promise, resolvable to flag that indicates whether given user
|
|
50
|
+
* account is active (true value), or not (false value).
|
|
51
|
+
*/
|
|
52
|
+
isActivated(userId: string): Promise<boolean>;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* This returns a promise, resolvable when MailerId login and storage
|
|
56
|
+
* secret keys, have been derived from a password.
|
|
57
|
+
* @param pass
|
|
58
|
+
* @param progressCB is a callback for progress notification
|
|
59
|
+
*/
|
|
60
|
+
createUserParams(
|
|
61
|
+
pass: string,
|
|
62
|
+
progressCB: (progress: number) => void
|
|
63
|
+
): Promise<void>;
|
|
64
|
+
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* This is a collection of functions, that are are used by startup
|
|
69
|
+
* functionality, when user signs into existing account, whether already
|
|
70
|
+
* cached on this device, or not.
|
|
71
|
+
*/
|
|
72
|
+
interface SignInService {
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* This returns an array of users, whose storages are found on a disk.
|
|
76
|
+
*/
|
|
77
|
+
getUsersOnDisk(): Promise<string[]>;
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* This starts a login process, when application is started without user
|
|
81
|
+
* storage on a disk.
|
|
82
|
+
* It returns a promise, resolvable either to true, if provisioning has
|
|
83
|
+
* started, or to false, if given address is not known to the MailerId
|
|
84
|
+
* server.
|
|
85
|
+
* @param address
|
|
86
|
+
*/
|
|
87
|
+
startLoginToRemoteStorage(address: string): Promise<boolean>;
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* This completes login and setup of user's storage on a disk.
|
|
91
|
+
* It returns a promise, resolvable either to true, when provisioning is
|
|
92
|
+
* done, or to false, when given password is incorrect.
|
|
93
|
+
* @param pass is a MailerId login password
|
|
94
|
+
* @param progressCB is a callback for progress notification
|
|
95
|
+
*/
|
|
96
|
+
completeLoginAndLocalSetup(
|
|
97
|
+
pass: string,
|
|
98
|
+
progressCB: (progress: number) => void
|
|
99
|
+
): Promise<boolean>;
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* This method initializes core to run from an existing on a disk storage.
|
|
103
|
+
* It returns a promise, resolvable either to true, when password opens
|
|
104
|
+
* storage, and to false, when given password is incorrect.
|
|
105
|
+
* @param address is user' address.
|
|
106
|
+
* @param pass is user's password.
|
|
107
|
+
* @param progressCB is a callback for progress notification
|
|
108
|
+
*/
|
|
109
|
+
useExistingStorage(
|
|
110
|
+
address: string, pass: string,
|
|
111
|
+
progressCB: (progress: number) => void
|
|
112
|
+
): Promise<boolean>;
|
|
113
|
+
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
interface W3N {
|
|
117
|
+
signIn: startup.SignInService;
|
|
118
|
+
signUp: startup.SignUpService;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (C) 2016 - 2017, 2021 3NSoft Inc.
|
|
3
|
+
|
|
4
|
+
This program is free software: you can redistribute it and/or modify it under
|
|
5
|
+
the terms of the GNU General Public License as published by the Free Software
|
|
6
|
+
Foundation, either version 3 of the License, or (at your option) any later
|
|
7
|
+
version.
|
|
8
|
+
|
|
9
|
+
This program is distributed in the hope that it will be useful, but
|
|
10
|
+
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
12
|
+
See the GNU General Public License for more details.
|
|
13
|
+
|
|
14
|
+
You should have received a copy of the GNU General Public License along with
|
|
15
|
+
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* This is a namespace for things used by storage and any file functionality.
|
|
20
|
+
*/
|
|
21
|
+
declare namespace web3n.storage {
|
|
22
|
+
|
|
23
|
+
interface Service {
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* This returns a promise of an app's fs in local storage.
|
|
27
|
+
* @param appName is a reversed domain. If omitted, this app's main
|
|
28
|
+
* domain is assumed.
|
|
29
|
+
*/
|
|
30
|
+
getAppLocalFS(appName?: string): Promise<files.WritableFS>;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* This returns a promise of an app's fs in synced storage.
|
|
34
|
+
* @param appName is a reversed domain. If omitted, this app's main
|
|
35
|
+
* domain is assumed.
|
|
36
|
+
*/
|
|
37
|
+
getAppSyncedFS(appName?: string): Promise<files.WritableFS>;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* This returns a promise, resolvable to user fs. It will be either
|
|
41
|
+
* writable or readonly, depending on app's manifest setting.
|
|
42
|
+
* @param type is a type of fs requested, like synced, local, or device.
|
|
43
|
+
* @param path is an optional to get more specific fs.
|
|
44
|
+
*/
|
|
45
|
+
getUserFS?: (type: StorageType, path?: string) => Promise<files.FSItem>;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* This returns a promise, resolvable to system fs. It will be either
|
|
49
|
+
* writable or readonly, depending on app's manifest setting.
|
|
50
|
+
* @param type is a type of fs requested, like synced, local, or device.
|
|
51
|
+
* @param path is an optional to get more specific fs.
|
|
52
|
+
*/
|
|
53
|
+
getSysFS?: (type: StorageType, path?: string) => Promise<files.FSItem>;
|
|
54
|
+
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
type StorageType = 'device'|'synced'|'local';
|
|
58
|
+
type StorageUse = 'user'|'system'|'app';
|
|
59
|
+
|
|
60
|
+
interface StorageException extends web3n.RuntimeException {
|
|
61
|
+
type: 'storage';
|
|
62
|
+
appName?: string;
|
|
63
|
+
badAppName?: boolean;
|
|
64
|
+
notAllowedToOpenFS?: boolean;
|
|
65
|
+
storageType?: StorageType;
|
|
66
|
+
storageSegment: StorageUse;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (C) 2016 - 2018, 2020 3NSoft Inc.
|
|
3
|
+
|
|
4
|
+
This program is free software: you can redistribute it and/or modify it under
|
|
5
|
+
the terms of the GNU General Public License as published by the Free Software
|
|
6
|
+
Foundation, either version 3 of the License, or (at your option) any later
|
|
7
|
+
version.
|
|
8
|
+
|
|
9
|
+
This program is distributed in the hope that it will be useful, but
|
|
10
|
+
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
12
|
+
See the GNU General Public License for more details.
|
|
13
|
+
|
|
14
|
+
You should have received a copy of the GNU General Public License along with
|
|
15
|
+
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/// <reference path="./asmail.d.ts" />
|
|
19
|
+
/// <reference path="./common-caps.d.ts" />
|
|
20
|
+
/// <reference path="./files.d.ts" />
|
|
21
|
+
/// <reference path="./mailerid.d.ts" />
|
|
22
|
+
/// <reference path="./startup.d.ts" />
|
|
23
|
+
/// <reference path="./storage.d.ts" />
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
declare namespace web3n {
|
|
27
|
+
|
|
28
|
+
interface RuntimeException {
|
|
29
|
+
runtimeException: true;
|
|
30
|
+
type?: string;
|
|
31
|
+
cause?: any;
|
|
32
|
+
message?: string;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
interface EncryptionException {
|
|
36
|
+
failedCipherVerification?: true;
|
|
37
|
+
failedSignatureVerification?: true;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
interface AsyncIterator<T> {
|
|
41
|
+
next(): Promise<IteratorResult<T>>;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
interface Observer<T> {
|
|
45
|
+
next?: (value: T) => void;
|
|
46
|
+
error?: (err: any) => void;
|
|
47
|
+
complete?: () => void;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
}
|
|
@@ -3,4 +3,5 @@ import { ClientCAPsWraps, CAPsExposures, TypeDifference } from "./generic";
|
|
|
3
3
|
declare type W3N = web3n.caps.common.W3N;
|
|
4
4
|
export declare function exposeW3N<T extends W3N>(coreSide: ExposedServices, w3n: T, extraCAPs?: CAPsExposures<TypeDifference<T, W3N>>): void;
|
|
5
5
|
export declare function makeW3Nclient<T extends W3N>(clientSide: Caller, extraCAPs?: ClientCAPsWraps<TypeDifference<T, W3N>>): T;
|
|
6
|
+
export declare function promiseW3Nclient<T extends W3N>(clientSide: Caller, extraCAPs?: ClientCAPsWraps<TypeDifference<T, W3N>>): Promise<T>;
|
|
6
7
|
export {};
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
17
|
*/
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
-
exports.makeW3Nclient = exports.exposeW3N = void 0;
|
|
19
|
+
exports.promiseW3Nclient = exports.makeW3Nclient = exports.exposeW3N = 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 asmail_cap_1 = require("../ipc-via-protobuf/asmail-cap");
|
|
@@ -46,4 +46,14 @@ function makeW3Nclient(clientSide, extraCAPs) {
|
|
|
46
46
|
return generic_1.makeClientSide(clientSide, mainCAPs, extraCAPs);
|
|
47
47
|
}
|
|
48
48
|
exports.makeW3Nclient = makeW3Nclient;
|
|
49
|
+
function promiseW3Nclient(clientSide, extraCAPs) {
|
|
50
|
+
const mainCAPs = {
|
|
51
|
+
log: log_cap_1.makeLogCaller,
|
|
52
|
+
mail: asmail_cap_1.makeASMailCaller,
|
|
53
|
+
mailerid: mailerid_1.makeMailerIdCaller,
|
|
54
|
+
storage: storage_cap_1.promiseStorageCaller,
|
|
55
|
+
};
|
|
56
|
+
return generic_1.promiseClientSide(clientSide, mainCAPs, extraCAPs);
|
|
57
|
+
}
|
|
58
|
+
exports.promiseW3Nclient = promiseW3Nclient;
|
|
49
59
|
Object.freeze(exports);
|
|
@@ -11,3 +11,4 @@ export declare type ClientCAPsWraps<T> = {
|
|
|
11
11
|
[cap in keyof Required<T>]: MakeCapClient;
|
|
12
12
|
};
|
|
13
13
|
export declare function makeClientSide<T extends W3N, W3N extends object>(clientSide: Caller, mainCAPs: ClientCAPsWraps<W3N>, extraCAPs: ClientCAPsWraps<TypeDifference<T, W3N>> | undefined): T;
|
|
14
|
+
export declare function promiseClientSide<T extends W3N, W3N extends object>(clientSide: Caller, mainCAPs: ClientCAPsWraps<W3N>, extraCAPs: ClientCAPsWraps<TypeDifference<T, W3N>> | undefined): Promise<T>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
|
-
Copyright (C) 2021 3NSoft Inc.
|
|
3
|
+
Copyright (C) 2021 - 2022 3NSoft Inc.
|
|
4
4
|
|
|
5
5
|
This program is free software: you can redistribute it and/or modify it under
|
|
6
6
|
the terms of the GNU General Public License as published by the Free Software
|
|
@@ -16,7 +16,7 @@
|
|
|
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 = void 0;
|
|
19
|
+
exports.promiseClientSide = 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
22
|
function exposeCAPs(coreSide, w3n, mainCAPs, extraCAPs) {
|
|
@@ -40,6 +40,7 @@ function addCAPsInExposure(expW3N, coreSide, w3n, capExposures) {
|
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
function makeClientSide(clientSide, mainCAPs, extraCAPs) {
|
|
43
|
+
assert_1.assert(!!clientSide.listObj);
|
|
43
44
|
const objPath = [connector_1.W3N_NAME];
|
|
44
45
|
const lstOfCAPs = clientSide.listObj(objPath);
|
|
45
46
|
const w3n = {};
|
|
@@ -51,7 +52,6 @@ function makeClientSide(clientSide, mainCAPs, extraCAPs) {
|
|
|
51
52
|
w3n[cap] = makeCap(clientSide, capObjPath);
|
|
52
53
|
}
|
|
53
54
|
else if (extraCAPs) {
|
|
54
|
-
assert_1.assert(!!exposeCAPs);
|
|
55
55
|
const makeCap = extraCAPs[cap];
|
|
56
56
|
assert_1.assert(typeof makeCap === 'function');
|
|
57
57
|
w3n[cap] = makeCap(clientSide, capObjPath);
|
|
@@ -60,4 +60,25 @@ function makeClientSide(clientSide, mainCAPs, extraCAPs) {
|
|
|
60
60
|
return w3n;
|
|
61
61
|
}
|
|
62
62
|
exports.makeClientSide = makeClientSide;
|
|
63
|
+
async function promiseClientSide(clientSide, mainCAPs, extraCAPs) {
|
|
64
|
+
assert_1.assert(!!clientSide.listObjAsync);
|
|
65
|
+
const objPath = [connector_1.W3N_NAME];
|
|
66
|
+
const lstOfCAPs = (await clientSide.listObjAsync(objPath));
|
|
67
|
+
const w3n = {};
|
|
68
|
+
for (const cap of lstOfCAPs) {
|
|
69
|
+
const capObjPath = objPath.concat(cap);
|
|
70
|
+
if (mainCAPs[cap]) {
|
|
71
|
+
const makeCap = mainCAPs[cap];
|
|
72
|
+
assert_1.assert(typeof makeCap === 'function');
|
|
73
|
+
w3n[cap] = await makeCap(clientSide, capObjPath);
|
|
74
|
+
}
|
|
75
|
+
else if (extraCAPs) {
|
|
76
|
+
const makeCap = extraCAPs[cap];
|
|
77
|
+
assert_1.assert(typeof makeCap === 'function');
|
|
78
|
+
w3n[cap] = await makeCap(clientSide, capObjPath);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return w3n;
|
|
82
|
+
}
|
|
83
|
+
exports.promiseClientSide = promiseClientSide;
|
|
63
84
|
Object.freeze(exports);
|
|
@@ -4,12 +4,13 @@ import { ClientsSide, EnvelopeBody, Envelope, IPCException, Caller } from "./con
|
|
|
4
4
|
export declare class ClientsSideImpl implements ClientsSide {
|
|
5
5
|
private readonly sendMsg;
|
|
6
6
|
private readonly syncReqToListObj;
|
|
7
|
+
private readonly asyncReqToListObj;
|
|
7
8
|
private readonly fnCalls;
|
|
8
9
|
private fnCallCounter;
|
|
9
10
|
private readonly weakRefs;
|
|
10
11
|
private readonly srvRefs;
|
|
11
12
|
private isStopped;
|
|
12
|
-
constructor(sendMsg: (msg: Envelope) => void, syncReqToListObj:
|
|
13
|
+
constructor(sendMsg: (msg: Envelope) => void, syncReqToListObj: Caller['listObj'], asyncReqToListObj: Caller['listObjAsync']);
|
|
13
14
|
stop(exc: IPCException): void;
|
|
14
15
|
private sendCallCancellation;
|
|
15
16
|
processInterimCallReply(fnCallNum: number, body: EnvelopeBody): void;
|
|
@@ -25,4 +26,5 @@ export declare class ClientsSideImpl implements ClientsSide {
|
|
|
25
26
|
private sendObjDropMsg;
|
|
26
27
|
srvRefOf(clientObj: any): ObjectReference<any>;
|
|
27
28
|
listObj(path: string[]): string[];
|
|
29
|
+
listObjAsync(path: string[]): Promise<string[]>;
|
|
28
30
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
|
-
Copyright (C) 2020 -
|
|
3
|
+
Copyright (C) 2020 - 2022 3NSoft Inc.
|
|
4
4
|
|
|
5
5
|
This program is free software: you can redistribute it and/or modify it under
|
|
6
6
|
the terms of the GNU General Public License as published by the Free Software
|
|
@@ -24,14 +24,19 @@ const connector_1 = require("./connector");
|
|
|
24
24
|
// XXX can have an optimized use of WeakRef and FinalizationRegistry, when
|
|
25
25
|
// these are available.
|
|
26
26
|
class ClientsSideImpl {
|
|
27
|
-
constructor(sendMsg, syncReqToListObj) {
|
|
27
|
+
constructor(sendMsg, syncReqToListObj, asyncReqToListObj) {
|
|
28
28
|
this.sendMsg = sendMsg;
|
|
29
29
|
this.syncReqToListObj = syncReqToListObj;
|
|
30
|
+
this.asyncReqToListObj = asyncReqToListObj;
|
|
30
31
|
this.fnCalls = new Map();
|
|
31
32
|
this.fnCallCounter = 1;
|
|
32
33
|
this.weakRefs = new Set();
|
|
33
34
|
this.srvRefs = new WeakMap();
|
|
34
35
|
this.isStopped = false;
|
|
36
|
+
if ((this.asyncReqToListObj && this.syncReqToListObj)
|
|
37
|
+
|| (!this.asyncReqToListObj && !this.syncReqToListObj)) {
|
|
38
|
+
throw new Error(`Expect either sync or async obj listing function.`);
|
|
39
|
+
}
|
|
35
40
|
Object.seal(this);
|
|
36
41
|
}
|
|
37
42
|
stop(exc) {
|
|
@@ -126,7 +131,9 @@ class ClientsSideImpl {
|
|
|
126
131
|
}
|
|
127
132
|
caller() {
|
|
128
133
|
const callerWrap = {
|
|
129
|
-
listObj: this.listObj.bind(this),
|
|
134
|
+
listObj: (this.syncReqToListObj ? this.listObj.bind(this) : undefined),
|
|
135
|
+
listObjAsync: (this.asyncReqToListObj ?
|
|
136
|
+
this.listObjAsync.bind(this) : undefined),
|
|
130
137
|
registerClientDrop: this.registerClientDrop.bind(this),
|
|
131
138
|
srvRefOf: this.srvRefOf.bind(this),
|
|
132
139
|
startObservableCall: this.startObservableCall.bind(this),
|
|
@@ -201,6 +208,12 @@ class ClientsSideImpl {
|
|
|
201
208
|
}
|
|
202
209
|
return this.syncReqToListObj(path);
|
|
203
210
|
}
|
|
211
|
+
listObjAsync(path) {
|
|
212
|
+
if (this.isStopped) {
|
|
213
|
+
throw connector_1.makeIPCException({ 'ipcNotConnected': true });
|
|
214
|
+
}
|
|
215
|
+
return this.asyncReqToListObj(path);
|
|
216
|
+
}
|
|
204
217
|
}
|
|
205
218
|
exports.ClientsSideImpl = ClientsSideImpl;
|
|
206
219
|
Object.freeze(ClientsSideImpl.prototype);
|
|
@@ -21,7 +21,8 @@ export interface Caller {
|
|
|
21
21
|
startObservableCall(path: string[], req: EnvelopeBody, obs: Subject<EnvelopeBody>): () => void;
|
|
22
22
|
registerClientDrop(o: any, srvRef: ObjectReference<any>): void;
|
|
23
23
|
srvRefOf(clientObj: any): ObjectReference<any>;
|
|
24
|
-
listObj(path: string[])
|
|
24
|
+
listObj?: (path: string[]) => string[];
|
|
25
|
+
listObjAsync?: (path: string[]) => Promise<string[]>;
|
|
25
26
|
}
|
|
26
27
|
export interface ClientsSide {
|
|
27
28
|
caller(): Caller;
|
|
@@ -35,7 +36,7 @@ export declare class ObjectsConnector {
|
|
|
35
36
|
private messagingProc;
|
|
36
37
|
private readonly services;
|
|
37
38
|
private readonly clients;
|
|
38
|
-
constructor(msgSink: Observer<Envelope>, msgSrc: Observable<Envelope>, sides: 'clients' | 'services' | 'clients-and-services',
|
|
39
|
+
constructor(msgSink: Observer<Envelope>, msgSrc: Observable<Envelope>, sides: 'clients' | 'services' | 'clients-and-services', listObj?: Caller['listObj'], listObjAsync?: Caller['listObjAsync']);
|
|
39
40
|
get caller(): Caller;
|
|
40
41
|
get exposedServices(): ExposedServices;
|
|
41
42
|
private stop;
|
|
@@ -27,12 +27,12 @@ function makeServicesSide(sendMsg) {
|
|
|
27
27
|
const srvClassFn = require('./connector-services-side').ServicesSideImpl;
|
|
28
28
|
return new srvClassFn(sendMsg);
|
|
29
29
|
}
|
|
30
|
-
function makeClientsSide(sendMsg, syncReqToListObj) {
|
|
30
|
+
function makeClientsSide(sendMsg, syncReqToListObj, asyncReqToListObj) {
|
|
31
31
|
const classFn = require('./connector-clients-side').ClientsSideImpl;
|
|
32
32
|
return new classFn(sendMsg, syncReqToListObj);
|
|
33
33
|
}
|
|
34
34
|
class ObjectsConnector {
|
|
35
|
-
constructor(msgSink, msgSrc, sides,
|
|
35
|
+
constructor(msgSink, msgSrc, sides, listObj, listObjAsync) {
|
|
36
36
|
this.msgSink = msgSink;
|
|
37
37
|
this.messagingProc = undefined;
|
|
38
38
|
this.messagingProc = msgSrc.subscribe({
|
|
@@ -49,10 +49,11 @@ class ObjectsConnector {
|
|
|
49
49
|
this.services = (((sides === 'services') || (sides === 'clients-and-services')) ?
|
|
50
50
|
makeServicesSide(sendMsg) : undefined);
|
|
51
51
|
if ((sides === 'clients') || (sides === 'clients-and-services')) {
|
|
52
|
-
if (!
|
|
53
|
-
|
|
52
|
+
if ((!listObj && !listObjAsync)
|
|
53
|
+
|| (listObj && listObjAsync)) {
|
|
54
|
+
throw new Error(`Client side needs either listObj, or listObjAsync argument`);
|
|
54
55
|
}
|
|
55
|
-
this.clients = makeClientsSide(sendMsg,
|
|
56
|
+
this.clients = makeClientsSide(sendMsg, listObj, listObjAsync);
|
|
56
57
|
}
|
|
57
58
|
else {
|
|
58
59
|
this.clients = undefined;
|
|
@@ -2,4 +2,5 @@ import { ExposedObj, Caller, ExposedServices } from './connector';
|
|
|
2
2
|
declare type Storage = web3n.storage.Service;
|
|
3
3
|
export declare function exposeStorageCAP(cap: Storage, expServices: ExposedServices): ExposedObj<Storage>;
|
|
4
4
|
export declare function makeStorageCaller(caller: Caller, objPath: string[]): Storage;
|
|
5
|
+
export declare function promiseStorageCaller(caller: Caller, objPath: string[]): Promise<Storage>;
|
|
5
6
|
export {};
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
17
|
*/
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
-
exports.makeStorageCaller = exports.exposeStorageCAP = void 0;
|
|
19
|
+
exports.promiseStorageCaller = exports.makeStorageCaller = exports.exposeStorageCAP = void 0;
|
|
20
20
|
const protobuf_msg_1 = require("./protobuf-msg");
|
|
21
21
|
const fs_1 = require("./fs");
|
|
22
22
|
const protobuf_type_1 = require("../lib-client/protobuf-type");
|
|
@@ -37,6 +37,15 @@ function exposeStorageCAP(cap, expServices) {
|
|
|
37
37
|
exports.exposeStorageCAP = exposeStorageCAP;
|
|
38
38
|
function makeStorageCaller(caller, objPath) {
|
|
39
39
|
const lstStorageCAP = caller.listObj(objPath);
|
|
40
|
+
return instantiateStorageCaller(caller, lstStorageCAP, objPath);
|
|
41
|
+
}
|
|
42
|
+
exports.makeStorageCaller = makeStorageCaller;
|
|
43
|
+
async function promiseStorageCaller(caller, objPath) {
|
|
44
|
+
const lstStorageCAP = (await caller.listObjAsync(objPath));
|
|
45
|
+
return instantiateStorageCaller(caller, lstStorageCAP, objPath);
|
|
46
|
+
}
|
|
47
|
+
exports.promiseStorageCaller = promiseStorageCaller;
|
|
48
|
+
function instantiateStorageCaller(caller, lstStorageCAP, objPath) {
|
|
40
49
|
const sysFS = lstStorageCAP.includes('getSysFS');
|
|
41
50
|
const userFS = lstStorageCAP.includes('getUserFS');
|
|
42
51
|
const storage = {
|
|
@@ -51,7 +60,6 @@ function makeStorageCaller(caller, objPath) {
|
|
|
51
60
|
}
|
|
52
61
|
return storage;
|
|
53
62
|
}
|
|
54
|
-
exports.makeStorageCaller = makeStorageCaller;
|
|
55
63
|
var getAppLocalFS;
|
|
56
64
|
(function (getAppLocalFS) {
|
|
57
65
|
const requestType = protobuf_type_1.ProtoType.for(storage_proto_1.storage.GetAppLocalFSRequestBody);
|
package/build/lib-index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "core-3nweb-client-lib",
|
|
3
|
-
"version": "0.24.
|
|
3
|
+
"version": "0.24.4",
|
|
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": "bash packing/protos-to-node-module.sh && tsc -p ts-code && bash packing/build-wasm-cryptor.sh",
|
|
8
|
+
"build": "bash packing/protos-to-node-module.sh && tsc -p ts-code && bash packing/copy-api.sh && bash packing/build-wasm-cryptor.sh",
|
|
9
9
|
"test": "node build/tests/jasmine.js"
|
|
10
10
|
},
|
|
11
11
|
"repository": {
|