hypha-rpc 0.1.0-post6 → 0.1.1
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/dist/hypha-rpc-websocket.js +29 -12
- package/dist/hypha-rpc-websocket.js.map +1 -1
- package/dist/hypha-rpc-websocket.min.js +1 -1
- package/dist/hypha-rpc-websocket.min.js.map +1 -1
- package/package.json +1 -1
- package/src/rpc.js +14 -5
- package/src/webrtc-client.js +3 -1
- package/src/websocket-client.js +12 -6
- package/tests/websocket_client_test.js +1 -4
|
@@ -240,7 +240,7 @@ class RPC extends _utils_js__WEBPACK_IMPORTED_MODULE_0__.MessageEmitter {
|
|
|
240
240
|
});
|
|
241
241
|
}
|
|
242
242
|
}
|
|
243
|
-
}
|
|
243
|
+
};
|
|
244
244
|
connection.on_connect(updateServices);
|
|
245
245
|
updateServices();
|
|
246
246
|
} else {
|
|
@@ -445,7 +445,7 @@ class RPC extends _utils_js__WEBPACK_IMPORTED_MODULE_0__.MessageEmitter {
|
|
|
445
445
|
if (service_id.includes("@")) {
|
|
446
446
|
service_id = service_id.split("@")[0];
|
|
447
447
|
const app_id = service_uri.split("@")[1];
|
|
448
|
-
if (this._app_id)
|
|
448
|
+
if (this._app_id && this._app_id !== "*")
|
|
449
449
|
(0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.assert)(
|
|
450
450
|
app_id === this._app_id,
|
|
451
451
|
`Invalid app id: ${app_id} != ${this._app_id}`,
|
|
@@ -618,7 +618,11 @@ class RPC extends _utils_js__WEBPACK_IMPORTED_MODULE_0__.MessageEmitter {
|
|
|
618
618
|
service: serviceInfo,
|
|
619
619
|
});
|
|
620
620
|
} else {
|
|
621
|
-
await this.emit({
|
|
621
|
+
await this.emit({
|
|
622
|
+
type: "service-added",
|
|
623
|
+
to: "*",
|
|
624
|
+
service: serviceInfo,
|
|
625
|
+
});
|
|
622
626
|
}
|
|
623
627
|
}
|
|
624
628
|
return serviceInfo;
|
|
@@ -1020,7 +1024,9 @@ class RPC extends _utils_js__WEBPACK_IMPORTED_MODULE_0__.MessageEmitter {
|
|
|
1020
1024
|
method = indexObject(this._object_store, data["method"]);
|
|
1021
1025
|
} catch (e) {
|
|
1022
1026
|
console.debug("Failed to find method", method_name, this._client_id, e);
|
|
1023
|
-
throw new Error(
|
|
1027
|
+
throw new Error(
|
|
1028
|
+
`Method not found: ${method_name} at ${this._client_id}`,
|
|
1029
|
+
);
|
|
1024
1030
|
}
|
|
1025
1031
|
|
|
1026
1032
|
(0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.assert)(
|
|
@@ -1032,7 +1038,10 @@ class RPC extends _utils_js__WEBPACK_IMPORTED_MODULE_0__.MessageEmitter {
|
|
|
1032
1038
|
if (this._method_annotations.has(method)) {
|
|
1033
1039
|
// For services, it should not be protected
|
|
1034
1040
|
if (this._method_annotations.get(method).visibility === "protected") {
|
|
1035
|
-
if (
|
|
1041
|
+
if (
|
|
1042
|
+
local_workspace !== remote_workspace &&
|
|
1043
|
+
(remote_workspace !== "*" || remote_client_id !== this.manager_id)
|
|
1044
|
+
) {
|
|
1036
1045
|
throw new Error(
|
|
1037
1046
|
"Permission denied for invoking protected method " +
|
|
1038
1047
|
method_name +
|
|
@@ -2105,7 +2114,9 @@ async function getRTCService(server, service_id, config) {
|
|
|
2105
2114
|
const rpc = await _setupRPC(config);
|
|
2106
2115
|
pc.rpc = rpc;
|
|
2107
2116
|
async function getService(name) {
|
|
2108
|
-
return await rpc.get_remote_service(
|
|
2117
|
+
return await rpc.get_remote_service(
|
|
2118
|
+
config.workspace + "/" + config.peer_id + ":" + name,
|
|
2119
|
+
);
|
|
2109
2120
|
}
|
|
2110
2121
|
async function disconnect() {
|
|
2111
2122
|
await rpc.disconnect();
|
|
@@ -4261,9 +4272,10 @@ class WebsocketRPCConnection {
|
|
|
4261
4272
|
"Successfully connected: " + JSON.stringify(first_message),
|
|
4262
4273
|
);
|
|
4263
4274
|
this.connection_info = first_message;
|
|
4264
|
-
if(this.connection_info.reconnection_token) {
|
|
4265
|
-
this._reconnection_token =
|
|
4266
|
-
|
|
4275
|
+
if (this.connection_info.reconnection_token) {
|
|
4276
|
+
this._reconnection_token =
|
|
4277
|
+
this.connection_info.reconnection_token;
|
|
4278
|
+
}
|
|
4267
4279
|
}
|
|
4268
4280
|
resolve();
|
|
4269
4281
|
};
|
|
@@ -4370,8 +4382,13 @@ async function connectToServer(config) {
|
|
|
4370
4382
|
);
|
|
4371
4383
|
await connection.open();
|
|
4372
4384
|
(0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.assert)(connection.connection_info, "Failed to connect to the server");
|
|
4373
|
-
if(
|
|
4374
|
-
|
|
4385
|
+
if (
|
|
4386
|
+
config.workspace &&
|
|
4387
|
+
connection.connection_info.workspace !== config.workspace
|
|
4388
|
+
) {
|
|
4389
|
+
throw new Error(
|
|
4390
|
+
`Connected to the wrong workspace: ${connection.connection_info.workspace}, expected: ${config.workspace}`,
|
|
4391
|
+
);
|
|
4375
4392
|
}
|
|
4376
4393
|
const workspace = connection.connection_info.workspace;
|
|
4377
4394
|
const manager_id = connection.connection_info.manager_id;
|
|
@@ -4402,7 +4419,7 @@ async function connectToServer(config) {
|
|
|
4402
4419
|
await rpc.disconnect();
|
|
4403
4420
|
await connection.disconnect();
|
|
4404
4421
|
}
|
|
4405
|
-
if(connection.connection_info){
|
|
4422
|
+
if (connection.connection_info) {
|
|
4406
4423
|
wm.config = Object.assign(wm.config, connection.connection_info);
|
|
4407
4424
|
}
|
|
4408
4425
|
wm.export = _export;
|