@decentnetwork/beagle 0.1.50 → 0.1.52
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/carrier-node.d.ts +8 -1
- package/dist/carrier-node.js +16 -1
- package/dist/desktop/app.js +1 -1
- package/dist/embedded-host.js +31 -6
- package/dist/server.js +16 -1
- package/package.json +3 -3
package/dist/carrier-node.d.ts
CHANGED
|
@@ -98,7 +98,14 @@ export declare class CarrierNode extends EventEmitter {
|
|
|
98
98
|
sendFile(userid: string, data: Uint8Array, name: string): string | null;
|
|
99
99
|
cancelSend(userid: string, fileId: string): boolean;
|
|
100
100
|
acceptFile(userid: string, fileNumber: number): void;
|
|
101
|
-
|
|
101
|
+
/** Returns the SDK's delivery verdict — "acked" is the only outcome that
|
|
102
|
+
* earns a "sent" checkmark. Older SDKs resolve void: report "accepted"
|
|
103
|
+
* (bytes out, delivery unproven) rather than inventing a confirmation. */
|
|
104
|
+
sendInlineFile(userid: string, data: Uint8Array, name: string): Promise<"acked" | "accepted" | "offline">;
|
|
105
|
+
/** True when the friend is a NATIVE Carrier client (iOS/Android/C): it can
|
|
106
|
+
* only receive files as the inline envelope — a toxcore sendFile offer is
|
|
107
|
+
* invisible to it and would hang at "sending" until the 60s give-up. */
|
|
108
|
+
isNativeFriend(userid: string): boolean;
|
|
102
109
|
/** Send on an application packet id. Used for the components channel (165);
|
|
103
110
|
* unavailable on an SDK build without custom packets, which simply means
|
|
104
111
|
* this peer can't offer forms — never that chat breaks. */
|
package/dist/carrier-node.js
CHANGED
|
@@ -204,11 +204,26 @@ export class CarrierNode extends EventEmitter {
|
|
|
204
204
|
acceptFile(userid, fileNumber) {
|
|
205
205
|
this.#require().acceptFile(userid, fileNumber);
|
|
206
206
|
}
|
|
207
|
+
/** Returns the SDK's delivery verdict — "acked" is the only outcome that
|
|
208
|
+
* earns a "sent" checkmark. Older SDKs resolve void: report "accepted"
|
|
209
|
+
* (bytes out, delivery unproven) rather than inventing a confirmation. */
|
|
207
210
|
async sendInlineFile(userid, data, name) {
|
|
208
211
|
const peer = this.#require();
|
|
209
212
|
if (!peer.sendInlineFile)
|
|
210
213
|
throw new Error("This peer SDK build has no inline-file support");
|
|
211
|
-
await peer.sendInlineFile(userid, { name, data });
|
|
214
|
+
const r = await peer.sendInlineFile(userid, { name, data });
|
|
215
|
+
return (r && typeof r === "object" ? r.delivery : undefined) ?? "accepted";
|
|
216
|
+
}
|
|
217
|
+
/** True when the friend is a NATIVE Carrier client (iOS/Android/C): it can
|
|
218
|
+
* only receive files as the inline envelope — a toxcore sendFile offer is
|
|
219
|
+
* invisible to it and would hang at "sending" until the 60s give-up. */
|
|
220
|
+
isNativeFriend(userid) {
|
|
221
|
+
try {
|
|
222
|
+
return this.#require().isNativeFriend?.(userid) ?? false;
|
|
223
|
+
}
|
|
224
|
+
catch {
|
|
225
|
+
return false;
|
|
226
|
+
}
|
|
212
227
|
}
|
|
213
228
|
/** Send on an application packet id. Used for the components channel (165);
|
|
214
229
|
* unavailable on an SDK build without custom packets, which simply means
|
package/dist/desktop/app.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
window.__DK_UI_VERSION="0.1.
|
|
1
|
+
window.__DK_UI_VERSION="0.1.52";
|
|
2
2
|
const ICON_PATHS = {
|
|
3
3
|
// ---- tab bar (the four must feel like one set) ----
|
|
4
4
|
users: '<path d="M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"/><circle cx="9" cy="7" r="4"/><path d="M22 21v-2a4 4 0 0 0-3-3.87"/><path d="M16 3.13a4 4 0 0 1 0 7.75"/>',
|
package/dist/embedded-host.js
CHANGED
|
@@ -592,24 +592,49 @@ export class EmbeddedHost {
|
|
|
592
592
|
this.#events.emit("event", { type: "chat", userid, dir: "out" });
|
|
593
593
|
return { queued: true, name: safe, size: data.length };
|
|
594
594
|
}
|
|
595
|
+
// A NATIVE friend (iOS/Android/C Carrier) cannot see the toxcore transfer
|
|
596
|
+
// protocol AT ALL — offering it one just hangs the chip at "sending" until
|
|
597
|
+
// the 60s give-up. Its only file path is the inline envelope, so reject an
|
|
598
|
+
// oversized file BEFORE any bytes move, with the reason (ticket req. 2).
|
|
599
|
+
const native = this.#node.isNativeFriend(userid);
|
|
600
|
+
if (native && data.length > INLINE_MAX_BYTES) {
|
|
601
|
+
throw new Error(`This friend is a native (iOS/Android) client — files are sent inline and limited to ` +
|
|
602
|
+
`${(INLINE_MAX_BYTES / 1024 / 1024).toFixed(1)} MB (this is ${(data.length / 1024 / 1024).toFixed(1)} MB).`);
|
|
603
|
+
}
|
|
595
604
|
const msg = this.#messages.appendFile(userid, "out", { name: safe, size: data.length, status: "sending", sent: 0 });
|
|
596
605
|
if (!msg)
|
|
597
606
|
throw new Error("Could not create file message");
|
|
598
607
|
await mkdir(this.outboxDir, { recursive: true });
|
|
599
608
|
await writeFile(resolve(this.outboxDir, msg.id), data);
|
|
600
|
-
const fileId = this.#node.sendFile(userid, new Uint8Array(data), safe);
|
|
609
|
+
const fileId = native ? null : this.#node.sendFile(userid, new Uint8Array(data), safe);
|
|
601
610
|
if (!fileId) {
|
|
602
|
-
//
|
|
603
|
-
// path a native iOS/Android friend can receive at all.
|
|
611
|
+
// Native friend, or no transfer slot — the inline envelope path.
|
|
604
612
|
if (data.length > INLINE_MAX_BYTES) {
|
|
605
613
|
this.#messages.patchFile(userid, msg.id, { status: "failed" });
|
|
606
614
|
throw new Error(`Could not start the transfer, and the file is too large (${(data.length / 1024 / 1024).toFixed(1)} MB) ` +
|
|
607
615
|
`for the inline fallback (limit ${(INLINE_MAX_BYTES / 1024 / 1024).toFixed(1)} MB).`);
|
|
608
616
|
}
|
|
609
|
-
|
|
610
|
-
|
|
617
|
+
// "sent" means the PEER CONFIRMED receipt — nothing less. Stamping it
|
|
618
|
+
// when sendInlineFile resolved was the fake-sent of INBOX 2026-08-21:
|
|
619
|
+
// bytes left the machine, the phone had nothing, the UI showed a
|
|
620
|
+
// checkmark. The SDK's verdict now decides the chip.
|
|
621
|
+
let delivery;
|
|
622
|
+
try {
|
|
623
|
+
delivery = await this.#node.sendInlineFile(userid, new Uint8Array(data), safe);
|
|
624
|
+
}
|
|
625
|
+
catch (e) {
|
|
626
|
+
this.#messages.patchFile(userid, msg.id, { status: "failed" });
|
|
627
|
+
this.#events.emit("event", { type: "chat", userid, dir: "out" });
|
|
628
|
+
throw e;
|
|
629
|
+
}
|
|
630
|
+
const status = delivery === "acked" ? "sent" : delivery === "offline" ? "queued" : "failed";
|
|
631
|
+
this.#messages.patchFile(userid, msg.id, { status, sent: delivery === "acked" ? data.length : 0 });
|
|
611
632
|
this.#events.emit("event", { type: "chat", userid, dir: "out" });
|
|
612
|
-
|
|
633
|
+
if (delivery === "accepted") {
|
|
634
|
+
throw new Error(`The peer never confirmed receiving "${safe}" — it likely did not arrive. ` +
|
|
635
|
+
`Check that their app is open and try again.`);
|
|
636
|
+
}
|
|
637
|
+
return { inline: true, name: safe, size: data.length, delivery };
|
|
613
638
|
}
|
|
614
639
|
this.#activeSends.set(fileId, { peer: userid, msgId: msg.id });
|
|
615
640
|
this.#meta.ensure(userid);
|
package/dist/server.js
CHANGED
|
@@ -355,6 +355,21 @@ async function pickWritableSaveDir(downloadsDir) {
|
|
|
355
355
|
return alt;
|
|
356
356
|
}
|
|
357
357
|
}
|
|
358
|
+
/**
|
|
359
|
+
* Turn a bare permission error into the one command that fixes it.
|
|
360
|
+
*
|
|
361
|
+
* The daemon runs as root and the files it leaves under ~/.agentnet are
|
|
362
|
+
* root-owned, so this unprivileged process cannot write them — and "EACCES:
|
|
363
|
+
* permission denied, open '/Users/x/.agentnet/downloads/a.jpg'" tells the user
|
|
364
|
+
* nothing about what to do. Daemons from lan 0.1.278 repair this themselves at
|
|
365
|
+
* startup; older ones need the sweep run once by hand.
|
|
366
|
+
*/
|
|
367
|
+
function permissionHint(err) {
|
|
368
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
369
|
+
if (!/EACCES|EPERM|permission denied/i.test(msg))
|
|
370
|
+
return msg;
|
|
371
|
+
return `${msg}\n\nThis is the root-owned ~/.agentnet problem. Fix it once with:\n sudo agentnet fix-perms`;
|
|
372
|
+
}
|
|
358
373
|
/** Resolve a saved file by name across downloads/ and sent/, with a
|
|
359
374
|
* path-traversal guard. Returns null when absent from both. */
|
|
360
375
|
function findSavedFile(downloadsDir, name) {
|
|
@@ -1071,7 +1086,7 @@ export function startBeagleServer(opts) {
|
|
|
1071
1086
|
sendJson(res, 200, { ok: true, ...(r.data ?? {}) });
|
|
1072
1087
|
}
|
|
1073
1088
|
catch (e) {
|
|
1074
|
-
sendJson(res, 500, { ok: false, error:
|
|
1089
|
+
sendJson(res, 500, { ok: false, error: permissionHint(e) });
|
|
1075
1090
|
}
|
|
1076
1091
|
finally {
|
|
1077
1092
|
if (!keep)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@decentnetwork/beagle",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.52",
|
|
4
4
|
"description": "Beagle — P2P chat, file transfer and calls for regular users, on the Decent Network. No admin privilege required.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@decentnetwork/chat-components": "^0.1.3",
|
|
29
|
-
"@decentnetwork/lan": "^0.1.
|
|
30
|
-
"@decentnetwork/peer": "^0.1.
|
|
29
|
+
"@decentnetwork/lan": "^0.1.279",
|
|
30
|
+
"@decentnetwork/peer": "^0.1.140",
|
|
31
31
|
"@decentnetwork/peer-webrtc": "^0.2.16",
|
|
32
32
|
"js-yaml": "^4.1.0",
|
|
33
33
|
"yargs": "^17.7.2"
|