core-3nweb-client-lib 0.27.7 → 0.27.9
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.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import { Observer,
|
|
2
|
+
import { Observer, SubjectLike, Subscribable } from "rxjs";
|
|
3
3
|
import { ObjectReference, Value } from "./protobuf-msg";
|
|
4
4
|
import { ProtoType } from '../lib-client/protobuf-type';
|
|
5
5
|
export interface ExposedServices {
|
|
@@ -18,7 +18,7 @@ export interface ServicesSide {
|
|
|
18
18
|
}
|
|
19
19
|
export interface Caller {
|
|
20
20
|
startPromiseCall(path: string[], req: EnvelopeBody): Promise<EnvelopeBody>;
|
|
21
|
-
startObservableCall(path: string[], req: EnvelopeBody, obs:
|
|
21
|
+
startObservableCall(path: string[], req: EnvelopeBody, obs: SubjectLike<EnvelopeBody>): () => void;
|
|
22
22
|
registerClientDrop(o: any, srvRef: ObjectReference<any>): void;
|
|
23
23
|
srvRefOf(clientObj: any): ObjectReference<any>;
|
|
24
24
|
listObj?: (path: string[]) => string[];
|
|
@@ -42,7 +42,7 @@ export declare class NodesContainer {
|
|
|
42
42
|
node?: T;
|
|
43
43
|
nodePromise?: Promise<T>;
|
|
44
44
|
};
|
|
45
|
-
setPromise(objId: string, promise: Promise<
|
|
45
|
+
setPromise<T extends Node>(objId: string, promise: Promise<T>): Promise<T>;
|
|
46
46
|
delete(node: Node): boolean;
|
|
47
47
|
reserveId(objId: string): boolean;
|
|
48
48
|
clear(): void;
|
|
@@ -127,7 +127,16 @@ class FolderNode extends node_in_fs_1.NodeInFS {
|
|
|
127
127
|
return rf;
|
|
128
128
|
}
|
|
129
129
|
static async rootFromLinkParams(storage, params) {
|
|
130
|
-
|
|
130
|
+
let { node: existingNode, nodePromise } = storage.nodes.getNodeOrPromise(params.objId);
|
|
131
|
+
if (nodePromise) {
|
|
132
|
+
try {
|
|
133
|
+
existingNode = await nodePromise;
|
|
134
|
+
}
|
|
135
|
+
catch (err) {
|
|
136
|
+
// ignore errors from other invokation
|
|
137
|
+
return FolderNode.rootFromLinkParams(storage, params);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
131
140
|
if (existingNode) {
|
|
132
141
|
if (existingNode.type !== 'folder') {
|
|
133
142
|
throw new Error(`Existing object ${params.objId} type is ${existingNode.type}, while link parameters ask for folder.`);
|
|
@@ -135,12 +144,16 @@ class FolderNode extends node_in_fs_1.NodeInFS {
|
|
|
135
144
|
// Note that, although we return existing folder node, we should check
|
|
136
145
|
// if link parameters contained correct key. Only holder of a correct
|
|
137
146
|
// key may use existing object.
|
|
138
|
-
existingNode.crypto.compareKey(params.fKey)
|
|
147
|
+
if (!existingNode.crypto.compareKey(params.fKey)) {
|
|
148
|
+
throw new Error(`Link parameters don't contain correct key to instantiate target folder.`);
|
|
149
|
+
}
|
|
139
150
|
return existingNode;
|
|
140
151
|
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
152
|
+
return await storage.nodes.setPromise(params.objId, storage.getObjSrc(params.objId)
|
|
153
|
+
.then(async (src) => {
|
|
154
|
+
const key = buffer_utils_1.base64.open(params.fKey);
|
|
155
|
+
return FolderNode.rootFromObjBytes(storage, params.folderName, params.objId, src, key);
|
|
156
|
+
}));
|
|
144
157
|
}
|
|
145
158
|
static rootFromJSON(storage, name, folderJson) {
|
|
146
159
|
const rf = new FolderNode(storage, name, 'readonly-root', EMPTY_ARR, 0, undefined, EMPTY_ARR, false);
|
|
@@ -294,7 +307,7 @@ class FolderNode extends node_in_fs_1.NodeInFS {
|
|
|
294
307
|
return nodePromise;
|
|
295
308
|
}
|
|
296
309
|
const deferred = (0, deferred_1.defer)();
|
|
297
|
-
this.storage.nodes.setPromise(info.objId, deferred.promise);
|
|
310
|
+
const nodeSet = this.storage.nodes.setPromise(info.objId, deferred.promise);
|
|
298
311
|
try {
|
|
299
312
|
let node;
|
|
300
313
|
if (info.isFile) {
|
|
@@ -311,14 +324,14 @@ class FolderNode extends node_in_fs_1.NodeInFS {
|
|
|
311
324
|
throw new Error(`Unknown type of fs node`);
|
|
312
325
|
}
|
|
313
326
|
deferred.resolve(node);
|
|
314
|
-
return
|
|
327
|
+
return nodeSet;
|
|
315
328
|
}
|
|
316
329
|
catch (exc) {
|
|
317
330
|
if (exc.objNotFound) {
|
|
318
331
|
await this.fixMissingChildAndThrow(exc, info);
|
|
319
332
|
}
|
|
320
333
|
deferred.reject((0, error_1.errWithCause)(exc, `Failed to instantiate fs node '${this.name}/${info.name}'`));
|
|
321
|
-
return
|
|
334
|
+
return nodeSet;
|
|
322
335
|
}
|
|
323
336
|
}
|
|
324
337
|
getFolder(name, undefOnMissing = false) {
|