hypha-rpc 0.1.0-post5 → 0.1.0-post6
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.
|
@@ -430,7 +430,7 @@ class RPC extends _utils_js__WEBPACK_IMPORTED_MODULE_0__.MessageEmitter {
|
|
|
430
430
|
}
|
|
431
431
|
|
|
432
432
|
throw new Error(
|
|
433
|
-
`Permission denied for protected service: ${service_id}, workspace mismatch: ${ws} != ${context["ws"]}`,
|
|
433
|
+
`Permission denied for getting protected service: ${service_id}, workspace mismatch: ${ws} != ${context["ws"]}`,
|
|
434
434
|
);
|
|
435
435
|
}
|
|
436
436
|
async get_remote_service(service_uri, timeout) {
|
|
@@ -612,13 +612,13 @@ class RPC extends _utils_js__WEBPACK_IMPORTED_MODULE_0__.MessageEmitter {
|
|
|
612
612
|
const serviceInfo = this._extract_service_info(service);
|
|
613
613
|
if (notify) {
|
|
614
614
|
if (this.manager_id) {
|
|
615
|
-
this.emit({
|
|
615
|
+
await this.emit({
|
|
616
616
|
type: "service-added",
|
|
617
617
|
to: "*/" + this.manager_id,
|
|
618
618
|
service: serviceInfo,
|
|
619
619
|
});
|
|
620
620
|
} else {
|
|
621
|
-
this.emit({ type: "service-added", to: "*", service: serviceInfo });
|
|
621
|
+
await this.emit({ type: "service-added", to: "*", service: serviceInfo });
|
|
622
622
|
}
|
|
623
623
|
}
|
|
624
624
|
return serviceInfo;
|
|
@@ -962,9 +962,10 @@ class RPC extends _utils_js__WEBPACK_IMPORTED_MODULE_0__.MessageEmitter {
|
|
|
962
962
|
let reject = null;
|
|
963
963
|
let heartbeat_task = null;
|
|
964
964
|
try {
|
|
965
|
-
(0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.assert)(data.method && data.ctx && data.from
|
|
965
|
+
(0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.assert)(data.method && data.ctx && data.from);
|
|
966
966
|
const method_name = data.from + ":" + data.method;
|
|
967
967
|
const remote_workspace = data.from.split("/")[0];
|
|
968
|
+
const remote_client_id = data.from.split("/")[1];
|
|
968
969
|
// Make sure the target id is an absolute id
|
|
969
970
|
data["to"] = data["to"].includes("/")
|
|
970
971
|
? data["to"]
|
|
@@ -1031,9 +1032,9 @@ class RPC extends _utils_js__WEBPACK_IMPORTED_MODULE_0__.MessageEmitter {
|
|
|
1031
1032
|
if (this._method_annotations.has(method)) {
|
|
1032
1033
|
// For services, it should not be protected
|
|
1033
1034
|
if (this._method_annotations.get(method).visibility === "protected") {
|
|
1034
|
-
if (local_workspace !== remote_workspace) {
|
|
1035
|
+
if (local_workspace !== remote_workspace && (remote_workspace !== "*" || remote_client_id !== this.manager_id)) {
|
|
1035
1036
|
throw new Error(
|
|
1036
|
-
"Permission denied for protected method " +
|
|
1037
|
+
"Permission denied for invoking protected method " +
|
|
1037
1038
|
method_name +
|
|
1038
1039
|
", workspace mismatch: " +
|
|
1039
1040
|
local_workspace +
|
|
@@ -2104,7 +2105,7 @@ async function getRTCService(server, service_id, config) {
|
|
|
2104
2105
|
const rpc = await _setupRPC(config);
|
|
2105
2106
|
pc.rpc = rpc;
|
|
2106
2107
|
async function getService(name) {
|
|
2107
|
-
return await rpc.get_remote_service(config.peer_id + ":" + name);
|
|
2108
|
+
return await rpc.get_remote_service(config.workspace + "/" + config.peer_id + ":" + name);
|
|
2108
2109
|
}
|
|
2109
2110
|
async function disconnect() {
|
|
2110
2111
|
await rpc.disconnect();
|