core-3nweb-client-lib 0.20.6 → 0.21.0
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/common-caps.d.ts +0 -1
- package/build/api-defs/startup.d.ts +0 -1
- package/build/core/index.d.ts +3 -3
- package/build/core/index.js +24 -31
- package/build/core-ipc/common-caps.d.ts +3 -3
- package/build/core-ipc/generic.d.ts +5 -2
- package/build/core-ipc/startup-caps.d.ts +3 -3
- package/build/core-ipc/startup-caps.js +0 -3
- package/build/lib-index.d.ts +1 -0
- package/build/lib-index.js +3 -0
- package/package.json +1 -1
package/build/core/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { FactoryOfFSs } from './storage';
|
|
|
2
2
|
import { makeCryptor } from '../lib-client/cryptor/cryptor';
|
|
3
3
|
import { NetClient } from '../lib-client/request-utils';
|
|
4
4
|
import { ServiceLocatorMaker } from '../lib-client/service-locator';
|
|
5
|
-
declare type
|
|
5
|
+
declare type RequestedCAPs = web3n.caps.common.AppManifest['capsRequested'];
|
|
6
6
|
declare type W3N = web3n.caps.common.W3N;
|
|
7
7
|
export interface CoreConf {
|
|
8
8
|
dataDir: string;
|
|
@@ -22,14 +22,14 @@ 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
|
};
|
|
29
29
|
private initForNewUser;
|
|
30
30
|
private initForExistingUserWithoutCache;
|
|
31
31
|
private initForExistingUserWithCache;
|
|
32
|
-
makeCAPsForApp(appDomain: string,
|
|
32
|
+
makeCAPsForApp(appDomain: string, requestedCAPs: RequestedCAPs): {
|
|
33
33
|
caps: W3N;
|
|
34
34
|
close: () => void;
|
|
35
35
|
};
|
package/build/core/index.js
CHANGED
|
@@ -30,7 +30,6 @@ const operators_1 = require("rxjs/operators");
|
|
|
30
30
|
const app_files_1 = require("./app-files");
|
|
31
31
|
const ASMAIL_APP_NAME = 'computer.3nweb.core.asmail';
|
|
32
32
|
const MAILERID_APP_NAME = 'computer.3nweb.core.mailerid';
|
|
33
|
-
const STARTUP_APP_DOMAIN = 'startup.3nweb.computer';
|
|
34
33
|
class Core {
|
|
35
34
|
constructor(makeNet, makeResolver, makeCryptor, appDirs, logger, signUpUrl) {
|
|
36
35
|
this.makeNet = makeNet;
|
|
@@ -112,16 +111,13 @@ class Core {
|
|
|
112
111
|
const core = new Core(makeNet, makeResolver, makeCryptor, dirs, logger, conf.signUpUrl);
|
|
113
112
|
return core;
|
|
114
113
|
}
|
|
115
|
-
start(
|
|
114
|
+
start() {
|
|
116
115
|
const signUp = new sign_up_1.SignUp(this.signUpUrl, this.cryptor.cryptor, this.makeNet, this.appDirs.getUsersOnDisk, this.logger.logError);
|
|
117
116
|
const signIn = new sign_in_1.SignIn(this.cryptor.cryptor, this.initForExistingUserWithoutCache, this.initForExistingUserWithCache, this.appDirs.getUsersOnDisk, this.logger.logError);
|
|
118
117
|
const capsForStartup = {
|
|
119
118
|
signUp: signUp.exposedService(),
|
|
120
119
|
signIn: signIn.exposedService()
|
|
121
120
|
};
|
|
122
|
-
if (logCAP) {
|
|
123
|
-
capsForStartup.log = (type, msg, e) => this.logger.appLog(type, STARTUP_APP_DOMAIN, msg, e);
|
|
124
|
-
}
|
|
125
121
|
Object.freeze(capsForStartup);
|
|
126
122
|
const initFromSignUp$ = signUp.newUser$
|
|
127
123
|
.pipe(operators_1.mergeMap(this.initForNewUser, 1));
|
|
@@ -132,50 +128,47 @@ class Core {
|
|
|
132
128
|
return { coreInit, capsForStartup };
|
|
133
129
|
}
|
|
134
130
|
;
|
|
135
|
-
makeCAPsForApp(appDomain,
|
|
131
|
+
makeCAPsForApp(appDomain, requestedCAPs) {
|
|
136
132
|
if (!this.isInitialized || this.closingProc) {
|
|
137
133
|
throw new Error(`Core is either not yet initialized, or is already closed.`);
|
|
138
134
|
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
const
|
|
143
|
-
const mail = this.makeMailCAP(manifest);
|
|
144
|
-
const log = this.makeLogCAP(manifest);
|
|
145
|
-
const mailerid = this.makeMailerIdCAP(manifest);
|
|
135
|
+
const { storage, close } = this.makeStorageCAP(appDomain, requestedCAPs);
|
|
136
|
+
const mail = this.makeMailCAP(requestedCAPs);
|
|
137
|
+
const log = this.makeLogCAP(appDomain, requestedCAPs);
|
|
138
|
+
const mailerid = this.makeMailerIdCAP(requestedCAPs);
|
|
146
139
|
const caps = { mail, log, mailerid, storage };
|
|
147
140
|
return { caps, close };
|
|
148
141
|
}
|
|
149
142
|
;
|
|
150
|
-
makeStorageCAP(
|
|
151
|
-
if (
|
|
152
|
-
const { cap: storage, close } = this.storages.makeStorageCAP(
|
|
143
|
+
makeStorageCAP(appDomain, requestedCAPs) {
|
|
144
|
+
if (requestedCAPs.storage) {
|
|
145
|
+
const { cap: storage, close } = this.storages.makeStorageCAP(appDomain, makeStoragePolicy(appDomain, requestedCAPs));
|
|
153
146
|
return { storage, close };
|
|
154
147
|
}
|
|
155
148
|
else {
|
|
156
149
|
return { close: () => { } };
|
|
157
150
|
}
|
|
158
151
|
}
|
|
159
|
-
makeMailCAP(
|
|
160
|
-
if (
|
|
161
|
-
&& (
|
|
162
|
-
&& (
|
|
152
|
+
makeMailCAP(requestedCAPs) {
|
|
153
|
+
if (requestedCAPs.mail
|
|
154
|
+
&& (requestedCAPs.mail.receivingFrom === 'all')
|
|
155
|
+
&& (requestedCAPs.mail.sendingTo === 'all')) {
|
|
163
156
|
return this.asmail.makeASMailCAP();
|
|
164
157
|
}
|
|
165
158
|
else {
|
|
166
159
|
return undefined;
|
|
167
160
|
}
|
|
168
161
|
}
|
|
169
|
-
makeLogCAP(
|
|
170
|
-
if (
|
|
171
|
-
return (type, msg, e) => this.logger.appLog(type,
|
|
162
|
+
makeLogCAP(appDomain, requestedCAPs) {
|
|
163
|
+
if (requestedCAPs.log === 'all') {
|
|
164
|
+
return (type, msg, e) => this.logger.appLog(type, appDomain, msg, e);
|
|
172
165
|
}
|
|
173
166
|
else {
|
|
174
167
|
return undefined;
|
|
175
168
|
}
|
|
176
169
|
}
|
|
177
|
-
makeMailerIdCAP(
|
|
178
|
-
if (
|
|
170
|
+
makeMailerIdCAP(requestedCAPs) {
|
|
171
|
+
if (requestedCAPs.mailerid === true) {
|
|
179
172
|
return this.idManager.makeMailerIdCAP();
|
|
180
173
|
}
|
|
181
174
|
else {
|
|
@@ -218,24 +211,24 @@ class Core {
|
|
|
218
211
|
exports.Core = Core;
|
|
219
212
|
Object.freeze(Core.prototype);
|
|
220
213
|
Object.freeze(Core);
|
|
221
|
-
function makeStoragePolicy(
|
|
222
|
-
if (!
|
|
214
|
+
function makeStoragePolicy(appDomain, requestedCAPs) {
|
|
215
|
+
if (!requestedCAPs.storage) {
|
|
223
216
|
throw new Error(`Missing storage setting in app's manifest`);
|
|
224
217
|
}
|
|
225
|
-
const capReq =
|
|
218
|
+
const capReq = requestedCAPs.storage;
|
|
226
219
|
let policy;
|
|
227
220
|
if (capReq.appFS === 'default') {
|
|
228
221
|
policy = {
|
|
229
222
|
canOpenAppFS: singleDomainAppFSChecker({
|
|
230
|
-
domain:
|
|
223
|
+
domain: appDomain,
|
|
231
224
|
storage: 'synced-n-local'
|
|
232
225
|
})
|
|
233
226
|
};
|
|
234
227
|
}
|
|
235
228
|
else if (Array.isArray(capReq.appFS)) {
|
|
236
229
|
const okDomains = capReq.appFS
|
|
237
|
-
.filter(fsInfo => (fsInfo.domain ===
|
|
238
|
-
fsInfo.domain.endsWith('.' +
|
|
230
|
+
.filter(fsInfo => (fsInfo.domain === appDomain) ||
|
|
231
|
+
fsInfo.domain.endsWith('.' + appDomain))
|
|
239
232
|
.map(fsInfo => json_utils_1.copy(fsInfo));
|
|
240
233
|
policy = {
|
|
241
234
|
canOpenAppFS: severalDomainsAppFSChecker(okDomains)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Caller, ExposedServices } from "../ipc-via-protobuf/connector";
|
|
2
|
-
import { ClientCAPsWraps, CAPsExposures } from "./generic";
|
|
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
|
-
export declare function makeW3Nclient<T extends W3N>(clientSide: Caller, extraCAPs?:
|
|
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;
|
|
6
6
|
export {};
|
|
@@ -2,9 +2,12 @@ import { ExposedObj, ExposedFn, ExposedServices, Caller } from "../ipc-via-proto
|
|
|
2
2
|
export declare type CAPsExposures<T> = {
|
|
3
3
|
[cap in keyof Required<T>]: (cap: any, coreSide: ExposedServices) => ExposedObj<any> | ExposedFn;
|
|
4
4
|
};
|
|
5
|
-
export declare
|
|
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;
|
|
6
9
|
export declare type MakeCapClient = (clientSide: Caller, objPath: string[]) => any;
|
|
7
10
|
export declare type ClientCAPsWraps<T> = {
|
|
8
11
|
[cap in keyof Required<T>]: MakeCapClient;
|
|
9
12
|
};
|
|
10
|
-
export declare function makeClientSide<T extends W3N, W3N extends object>(clientSide: Caller, mainCAPs: ClientCAPsWraps<W3N>, extraCAPs:
|
|
13
|
+
export declare function makeClientSide<T extends W3N, W3N extends object>(clientSide: Caller, mainCAPs: ClientCAPsWraps<W3N>, extraCAPs: ClientCAPsWraps<TypeDifference<T, W3N>> | undefined): T;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ExposedServices, Caller } from "../ipc-via-protobuf/connector";
|
|
2
|
-
import { ClientCAPsWraps, CAPsExposures } from "./generic";
|
|
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
|
-
export declare function makeStartupW3Nclient<T extends W3N>(clientSide: Caller, extraCAPs?:
|
|
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;
|
|
6
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
|
};
|
package/build/lib-index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export * from "./core-ipc/startup-caps";
|
|
|
4
4
|
export * from "./ipc-via-protobuf/connector";
|
|
5
5
|
export { FileMsg, makeFileCaller, exposeFileService } from "./ipc-via-protobuf/file";
|
|
6
6
|
export { FSMsg, makeFSCaller, exposeFSService } from "./ipc-via-protobuf/fs";
|
|
7
|
+
export { makeLogCaller, exposeLogger } from "./ipc-via-protobuf/log-cap";
|
|
7
8
|
export * from "./core";
|
|
8
9
|
export { makeServiceLocator, ServiceLocatorMaker } from "./lib-client/service-locator";
|
|
9
10
|
export { makeNetClient } from "./lib-client/request-utils";
|
package/build/lib-index.js
CHANGED
|
@@ -36,6 +36,9 @@ Object.defineProperty(exports, "exposeFileService", { enumerable: true, get: fun
|
|
|
36
36
|
var fs_1 = require("./ipc-via-protobuf/fs");
|
|
37
37
|
Object.defineProperty(exports, "makeFSCaller", { enumerable: true, get: function () { return fs_1.makeFSCaller; } });
|
|
38
38
|
Object.defineProperty(exports, "exposeFSService", { enumerable: true, get: function () { return fs_1.exposeFSService; } });
|
|
39
|
+
var log_cap_1 = require("./ipc-via-protobuf/log-cap");
|
|
40
|
+
Object.defineProperty(exports, "makeLogCaller", { enumerable: true, get: function () { return log_cap_1.makeLogCaller; } });
|
|
41
|
+
Object.defineProperty(exports, "exposeLogger", { enumerable: true, get: function () { return log_cap_1.exposeLogger; } });
|
|
39
42
|
__exportStar(require("./core"), exports);
|
|
40
43
|
var service_locator_1 = require("./lib-client/service-locator");
|
|
41
44
|
Object.defineProperty(exports, "makeServiceLocator", { enumerable: true, get: function () { return service_locator_1.makeServiceLocator; } });
|