@scp-dev/broker 0.3.0 → 0.4.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/dist/index.js +14 -2
- package/package.json +3 -3
- package/src/server.ts +14 -2
package/dist/index.js
CHANGED
|
@@ -1972,14 +1972,26 @@ async function startBroker(options) {
|
|
|
1972
1972
|
}
|
|
1973
1973
|
case "adopt": {
|
|
1974
1974
|
const actor = actorOf(s);
|
|
1975
|
-
const adopted = core.adopt(
|
|
1975
|
+
const adopted = await core.adopt(
|
|
1976
1976
|
actor,
|
|
1977
1977
|
{ endpoint: params.endpoint, ...params.parent !== void 0 ? { parent: params.parent } : {} },
|
|
1978
|
-
{
|
|
1978
|
+
{
|
|
1979
|
+
tty: actor.kind === "endpoint" && s.data.terminal === true,
|
|
1980
|
+
send: (from, send, origin) => {
|
|
1981
|
+
loadPolicy();
|
|
1982
|
+
if (policyError) throw new RelayError3("policy_refused", policyError);
|
|
1983
|
+
return judge.send(from, send, { tty: false, ...origin }, deliver);
|
|
1984
|
+
}
|
|
1985
|
+
}
|
|
1979
1986
|
);
|
|
1980
1987
|
bridge?.resync();
|
|
1981
1988
|
return adopted;
|
|
1982
1989
|
}
|
|
1990
|
+
case "link_accept": {
|
|
1991
|
+
const linked = core.linkAccept(actorOf(s), { id: params.id });
|
|
1992
|
+
bridge?.resync();
|
|
1993
|
+
return linked;
|
|
1994
|
+
}
|
|
1983
1995
|
case "unlink": {
|
|
1984
1996
|
const unlinked = core.unlink(actorOf(s), params.endpoint !== void 0 ? { endpoint: params.endpoint } : {});
|
|
1985
1997
|
bridge?.resync();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scp-dev/broker",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Swarm Communication Protocol local broker: a unix socket JSON-RPC daemon over the relay core, its client and the bridge to an account hub.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://scp.dev",
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
"typecheck": "tsc -p ."
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@scp-dev/core": "0.
|
|
41
|
-
"@scp-dev/hub": "0.6.
|
|
40
|
+
"@scp-dev/core": "0.3.0",
|
|
41
|
+
"@scp-dev/hub": "0.6.1"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"tsup": "^8.5.1"
|
package/src/server.ts
CHANGED
|
@@ -962,14 +962,26 @@ export async function startBroker(options: BrokerOptions): Promise<Broker> {
|
|
|
962
962
|
}
|
|
963
963
|
case "adopt": {
|
|
964
964
|
const actor = actorOf(s)
|
|
965
|
-
const adopted = core.adopt(
|
|
965
|
+
const adopted = await core.adopt(
|
|
966
966
|
actor,
|
|
967
967
|
{ endpoint: params.endpoint, ...(params.parent !== undefined ? { parent: params.parent } : {}) },
|
|
968
|
-
{
|
|
968
|
+
{
|
|
969
|
+
tty: actor.kind === "endpoint" && s.data.terminal === true,
|
|
970
|
+
send: (from: string, send: SendParams, origin: { link: "session" | "self" }) => {
|
|
971
|
+
loadPolicy()
|
|
972
|
+
if (policyError) throw new RelayError("policy_refused", policyError)
|
|
973
|
+
return judge.send(from, send, { tty: false, ...origin }, deliver)
|
|
974
|
+
},
|
|
975
|
+
},
|
|
969
976
|
)
|
|
970
977
|
bridge?.resync()
|
|
971
978
|
return adopted
|
|
972
979
|
}
|
|
980
|
+
case "link_accept": {
|
|
981
|
+
const linked = core.linkAccept(actorOf(s), { id: params.id })
|
|
982
|
+
bridge?.resync()
|
|
983
|
+
return linked
|
|
984
|
+
}
|
|
973
985
|
case "unlink": {
|
|
974
986
|
const unlinked = core.unlink(actorOf(s), params.endpoint !== undefined ? { endpoint: params.endpoint } : {})
|
|
975
987
|
bridge?.resync()
|