@decentnetwork/lan 0.1.9 → 0.1.10

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
@@ -279,10 +279,21 @@ export class DaemonServer {
279
279
  const autoAcceptFriends = this.config.friends?.autoAccept ?? true;
280
280
  const pendingPath = resolve(this.config.carrier.dataDir, "..", "pending-friends.json");
281
281
  this.pendingFriends = new PendingFriendsStore(pendingPath);
282
- const pubkeyHexToUserid = async (pubkeyHex) => {
283
- const { carrierIdFromPublicKey } = await import("@decentnetwork/peer");
284
- const bytes = Buffer.from(pubkeyHex, "hex");
285
- return carrierIdFromPublicKey(new Uint8Array(bytes));
282
+ const pubkeyHexToUserid = async (input) => {
283
+ // The SDK's friend-request event hands us EITHER a 64-char
284
+ // hex pubkey OR a base58 userid directly, depending on
285
+ // version. Detect by character set: hex is exactly 64 chars
286
+ // of [0-9a-f]; otherwise treat input as already-base58 userid
287
+ // and pass through. This caught us when the SDK switched
288
+ // formats and decentlan crashed the daemon (unhandled
289
+ // throw from carrierIdFromPublicKey because the base58
290
+ // bytes-from-hex was the wrong length).
291
+ if (/^[0-9a-fA-F]{64}$/.test(input)) {
292
+ const { carrierIdFromPublicKey } = await import("@decentnetwork/peer");
293
+ const bytes = Buffer.from(input, "hex");
294
+ return carrierIdFromPublicKey(new Uint8Array(bytes));
295
+ }
296
+ return input;
286
297
  };
287
298
  this.peerManager.on("friend-request", (req) => {
288
299
  void pubkeyHexToUserid(req.pubkey).then((userid) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decentnetwork/lan",
3
- "version": "0.1.9",
3
+ "version": "0.1.10",
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",