@decentnetwork/lan 0.1.17 → 0.1.18
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/cli/commands.d.ts +1 -1
- package/dist/cli/commands.js +20 -2
- package/dist/cli/index.js +34 -10
- package/package.json +1 -1
package/dist/cli/commands.d.ts
CHANGED
|
@@ -90,7 +90,7 @@ export declare function cmdFriendRequest(args: {
|
|
|
90
90
|
* (this takes ~45s), then wait for the request to arrive.
|
|
91
91
|
*/
|
|
92
92
|
export declare function cmdFriendAccept(args: {
|
|
93
|
-
|
|
93
|
+
userid?: string;
|
|
94
94
|
waitForRequest?: boolean;
|
|
95
95
|
waitMs?: number;
|
|
96
96
|
configDir?: string;
|
package/dist/cli/commands.js
CHANGED
|
@@ -460,6 +460,21 @@ export async function cmdFriendRequest(args) {
|
|
|
460
460
|
export async function cmdFriendAccept(args) {
|
|
461
461
|
const dir = args.configDir || ConfigLoader.defaultConfigDir();
|
|
462
462
|
const config = await ConfigLoader.load(resolve(dir, "config.yaml"));
|
|
463
|
+
// When the daemon is up, route the accept through IPC — no need
|
|
464
|
+
// to bring the daemon down. This is what 'friends accept' does
|
|
465
|
+
// and 'friend-accept' is just an alias for that path now.
|
|
466
|
+
if (daemonPid(config) !== null) {
|
|
467
|
+
if (!args.userid) {
|
|
468
|
+
throw new Error("userid is required when the daemon is up. Use 'agentnet friends pending' to see queued requests, then 'agentnet friend-accept <userid>'.");
|
|
469
|
+
}
|
|
470
|
+
await cmdFriendsAccept({ userid: args.userid, configDir: args.configDir });
|
|
471
|
+
return;
|
|
472
|
+
}
|
|
473
|
+
// Daemon-down fallback: open a standalone peer. This path stays
|
|
474
|
+
// because it's the only way to accept a request when the daemon
|
|
475
|
+
// can't run (e.g. the operator hasn't set up the helper binary
|
|
476
|
+
// yet). The --wait interactive mode is also useful for one-shot
|
|
477
|
+
// bootstrapping.
|
|
463
478
|
assertDaemonNotRunning(config, "friend-accept");
|
|
464
479
|
const { Peer } = await import("@decentnetwork/peer");
|
|
465
480
|
const keyFile = resolve(config.carrier.dataDir, "keypair.json");
|
|
@@ -487,7 +502,10 @@ export async function cmdFriendAccept(args) {
|
|
|
487
502
|
if (stored.length === 0) {
|
|
488
503
|
console.warn(`Self-announce got 0 storage nodes — request may still arrive via express relay`);
|
|
489
504
|
}
|
|
490
|
-
|
|
505
|
+
// The SDK uses `pubkey` as the local-var name historically; semantically
|
|
506
|
+
// this is the sender's userid (base58). Keep the variable name to
|
|
507
|
+
// minimize churn but document the mapping.
|
|
508
|
+
let pubkey = args.userid;
|
|
491
509
|
const wait = args.waitForRequest;
|
|
492
510
|
if (!pubkey || wait) {
|
|
493
511
|
const waitMs = args.waitMs ?? 120000;
|
|
@@ -500,7 +518,7 @@ export async function cmdFriendAccept(args) {
|
|
|
500
518
|
catch (err) {
|
|
501
519
|
if (!pubkey)
|
|
502
520
|
throw err;
|
|
503
|
-
console.warn(`No incoming request — will try acceptance with provided
|
|
521
|
+
console.warn(`No incoming request — will try acceptance with provided userid ${pubkey}`);
|
|
504
522
|
}
|
|
505
523
|
}
|
|
506
524
|
console.log(`Accepting friend request from ${pubkey}...`);
|
package/dist/cli/index.js
CHANGED
|
@@ -112,8 +112,8 @@ async function main() {
|
|
|
112
112
|
configDir: argv["config-dir"],
|
|
113
113
|
});
|
|
114
114
|
})
|
|
115
|
-
.command("friend-request", "Send a friend request (
|
|
116
|
-
.
|
|
115
|
+
.command("friend-request <address>", "Send a friend request (routes through the running daemon when up; opens a standalone peer when down)", (y) => y
|
|
116
|
+
.positional("address", { type: "string", demandOption: true, describe: "Recipient Carrier address" })
|
|
117
117
|
.option("hello", { type: "string", describe: "Greeting message" })
|
|
118
118
|
.option("wait-ms", { type: "number", default: 8000, describe: "Wait time for relay delivery" })
|
|
119
119
|
.option("config-dir", { type: "string" }), async (argv) => {
|
|
@@ -124,13 +124,27 @@ async function main() {
|
|
|
124
124
|
configDir: argv["config-dir"],
|
|
125
125
|
});
|
|
126
126
|
})
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
127
|
+
// `friend-accept` is the legacy daemon-down command. With autoAccept
|
|
128
|
+
// on by default (the standard config), this is rarely used — but we
|
|
129
|
+
// keep it as an alias for `friends accept` so an operator running
|
|
130
|
+
// an old recipe doesn't dead-end.
|
|
131
|
+
//
|
|
132
|
+
// Positional userid is supported. The flag is named --userid (NOT
|
|
133
|
+
// --pubkey) because Carrier's identifier model is address + userid;
|
|
134
|
+
// "pubkey" only exists as a hex-encoded internal representation
|
|
135
|
+
// operators never need to touch.
|
|
136
|
+
.command("friend-accept [userid]", "Accept a queued friend-request by userid (alias of 'friends accept')", (y) => y
|
|
137
|
+
.positional("userid", { type: "string", describe: "Sender's Carrier userid (base58)" })
|
|
138
|
+
.option("userid", { type: "string", describe: "Sender's Carrier userid (base58)" })
|
|
139
|
+
// --wait is kept for the daemon-down interactive path
|
|
140
|
+
// (rarely used now; only matters when autoAccept is off
|
|
141
|
+
// AND the operator wants to run a one-shot accept without
|
|
142
|
+
// bringing the daemon up).
|
|
143
|
+
.option("wait", { type: "boolean", default: false, describe: "Daemon-down mode: wait for an incoming request" })
|
|
130
144
|
.option("wait-ms", { type: "number", default: 120000, describe: "Time to wait for request (ms)" })
|
|
131
145
|
.option("config-dir", { type: "string" }), async (argv) => {
|
|
132
146
|
await cmdFriendAccept({
|
|
133
|
-
|
|
147
|
+
userid: argv.userid,
|
|
134
148
|
waitForRequest: argv.wait,
|
|
135
149
|
waitMs: argv["wait-ms"],
|
|
136
150
|
configDir: argv["config-dir"],
|
|
@@ -149,14 +163,24 @@ async function main() {
|
|
|
149
163
|
.command("pending", "List queued friend-requests (over IPC; daemon must be up)", (yy) => yy.option("config-dir", { type: "string" }), async (argv) => {
|
|
150
164
|
await cmdFriendsPending({ configDir: argv["config-dir"] });
|
|
151
165
|
})
|
|
152
|
-
|
|
153
|
-
|
|
166
|
+
// Accept positional userid OR `--userid X`. Operators expect
|
|
167
|
+
// `agentnet friends accept <userid>` to just work — without
|
|
168
|
+
// a positional that fails with "Unknown argument: <userid>"
|
|
169
|
+
// because yargs treats the unflagged value as junk.
|
|
170
|
+
.command("accept [userid]", "Accept a queued friend-request by userid (over IPC; daemon stays up)", (yy) => yy
|
|
171
|
+
.positional("userid", { type: "string", describe: "Sender's Carrier userid (base58)" })
|
|
172
|
+
.option("userid", { type: "string", describe: "Same as positional; either form works" })
|
|
154
173
|
.option("config-dir", { type: "string" }), async (argv) => {
|
|
174
|
+
if (!argv.userid)
|
|
175
|
+
throw new Error("userid is required (positional or --userid)");
|
|
155
176
|
await cmdFriendsAccept({ userid: argv.userid, configDir: argv["config-dir"] });
|
|
156
177
|
})
|
|
157
|
-
.command("reject", "Drop a queued friend-request by userid (over IPC; daemon stays up)", (yy) => yy
|
|
158
|
-
.
|
|
178
|
+
.command("reject [userid]", "Drop a queued friend-request by userid (over IPC; daemon stays up)", (yy) => yy
|
|
179
|
+
.positional("userid", { type: "string", describe: "Sender's Carrier userid (base58)" })
|
|
180
|
+
.option("userid", { type: "string", describe: "Same as positional; either form works" })
|
|
159
181
|
.option("config-dir", { type: "string" }), async (argv) => {
|
|
182
|
+
if (!argv.userid)
|
|
183
|
+
throw new Error("userid is required (positional or --userid)");
|
|
160
184
|
await cmdFriendsReject({ userid: argv.userid, configDir: argv["config-dir"] });
|
|
161
185
|
})
|
|
162
186
|
.demandCommand(1, "Specify a friends subcommand (run 'agentnet friends --help')"), () => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@decentnetwork/lan",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.18",
|
|
4
4
|
"description": "Private virtual LAN for self-hosted services and AI agents, built on Elastos Carrier. NAT-traversal, name service, ACL, all over a peer-to-peer mesh — no public IP required.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|