@decentnetwork/lan 0.1.109 → 0.1.110

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.
Binary file
Binary file
Binary file
Binary file
@@ -197,10 +197,23 @@ const dkApi = {
197
197
  alias: (userid, alias) => dkPost("/api/friend-alias", { userid, alias }),
198
198
  markRead: (userid) => dkPost("/api/chat-mark-read", { userid }),
199
199
  setProfile: (name, description) => dkPost("/api/set-profile", { name, description }),
200
- sendFile: (userid, file) => fetch(
201
- "/api/file-send?userid=" + encodeURIComponent(userid) + "&name=" + encodeURIComponent(file.name),
202
- { method: "POST", body: file }
203
- ).then((r) => r.json()).catch((e) => ({ ok: false, error: String(e) }))
200
+ sendFile: async (userid, file) => {
201
+ try {
202
+ const r = await fetch(
203
+ "/api/file-send?userid=" + encodeURIComponent(userid) + "&name=" + encodeURIComponent(file.name),
204
+ { method: "POST", body: file }
205
+ );
206
+ const txt = await r.text();
207
+ try {
208
+ return JSON.parse(txt);
209
+ } catch {
210
+ if (r.status === 404) return { ok: false, error: "file upload not supported \u2014 update & restart `agentnet ui`" };
211
+ return { ok: false, error: (txt || "HTTP " + r.status).slice(0, 120) };
212
+ }
213
+ } catch (e) {
214
+ return { ok: false, error: String(e) };
215
+ }
216
+ }
204
217
  };
205
218
  const DK_ME_FALLBACK = {
206
219
  name: "\u2026",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decentnetwork/lan",
3
- "version": "0.1.109",
3
+ "version": "0.1.110",
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",