@decentnetwork/beagle 0.1.91 → 0.1.92
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/desktop/app.js +2 -2
- package/dist/server.js +55 -16
- package/package.json +1 -1
package/dist/desktop/app.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
window.__DK_UI_VERSION="0.1.
|
|
1
|
+
window.__DK_UI_VERSION="0.1.92";
|
|
2
2
|
"use strict";
|
|
3
3
|
(() => {
|
|
4
4
|
// packages/beagle-ui/dist/beagle-ui.js
|
|
@@ -2443,7 +2443,7 @@ ${peer.address}`
|
|
|
2443
2443
|
const register = () => {
|
|
2444
2444
|
const l = label.trim();
|
|
2445
2445
|
if (l)
|
|
2446
|
-
post("/api/ens-register", { name: l, displayName: me.name });
|
|
2446
|
+
post("/api/ens-register", { name: l, displayName: me.name, description: me.description || "" });
|
|
2447
2447
|
};
|
|
2448
2448
|
const bind = (chain, address) => post("/api/ens-bind-wallet", { chain, address });
|
|
2449
2449
|
const bindEth = async () => {
|
package/dist/server.js
CHANGED
|
@@ -75,6 +75,29 @@ async function ensFetchJson(path) {
|
|
|
75
75
|
clearTimeout(timer);
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
|
+
/** The record beagle writes for its own name: what the profile page shows
|
|
79
|
+
* (displayName, description) on top of whatever the record already held —
|
|
80
|
+
* wallet binds, socials, avatar, referee — so a profile edit never strips a
|
|
81
|
+
* bind. Shared by /api/ens-register and /api/set-profile; the two used to
|
|
82
|
+
* build it separately, and only register did, which is why a status message
|
|
83
|
+
* edited in Profile never reached https://app.beagle.chat/<name>. */
|
|
84
|
+
function ensProfileRecord(identity, name, carried, displayName, description) {
|
|
85
|
+
return {
|
|
86
|
+
name,
|
|
87
|
+
owner: identity.userid,
|
|
88
|
+
addresses: carried?.addresses ?? {},
|
|
89
|
+
texts: {
|
|
90
|
+
...(carried?.texts ?? {}),
|
|
91
|
+
description,
|
|
92
|
+
displayName,
|
|
93
|
+
carrierAddress: identity.address,
|
|
94
|
+
carrierUserId: identity.userid,
|
|
95
|
+
},
|
|
96
|
+
referee: carried?.referee ?? "",
|
|
97
|
+
nft: carried?.nft ?? "",
|
|
98
|
+
nftid: carried?.nftid ?? 0,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
78
101
|
/** Sign a name record with the Carrier identity and POST it to the gateway.
|
|
79
102
|
* The record itself (as a JSON string) is what gets signed; the gateway
|
|
80
103
|
* re-parses `signature.message` and verifies against `owner` inside it. */
|
|
@@ -1219,24 +1242,15 @@ export function startBeagleServer(opts) {
|
|
|
1219
1242
|
const mine = existing ?? (await ensFetchJson(`/getAddress/${encodeURIComponent(identity.userid)}`));
|
|
1220
1243
|
const carried = mine && mine.owner === identity.userid ? mine : null;
|
|
1221
1244
|
const displayName = (typeof body.displayName === "string" && body.displayName.trim().slice(0, 64)) || label;
|
|
1245
|
+
// The description IS the Profile status message. It used to fall
|
|
1246
|
+
// through to "<name>'s Beagle Chat Profile", a placeholder that then
|
|
1247
|
+
// sat on the public page as if the person had written it.
|
|
1248
|
+
const node = (diag.ok ? diag.data?.node : null) ?? {};
|
|
1222
1249
|
const description = (typeof body.description === "string" && body.description.trim().slice(0, 200)) ||
|
|
1250
|
+
(typeof node.statusMessage === "string" && node.statusMessage.trim().slice(0, 200)) ||
|
|
1223
1251
|
carried?.texts?.description ||
|
|
1224
|
-
|
|
1225
|
-
const r = await ensSignAndSet(opts.call, {
|
|
1226
|
-
name: fullName,
|
|
1227
|
-
owner: identity.userid,
|
|
1228
|
-
addresses: carried?.addresses ?? {},
|
|
1229
|
-
texts: {
|
|
1230
|
-
...(carried?.texts ?? {}),
|
|
1231
|
-
description,
|
|
1232
|
-
displayName,
|
|
1233
|
-
carrierAddress: identity.address,
|
|
1234
|
-
carrierUserId: identity.userid,
|
|
1235
|
-
},
|
|
1236
|
-
referee: carried?.referee ?? "",
|
|
1237
|
-
nft: carried?.nft ?? "",
|
|
1238
|
-
nftid: carried?.nftid ?? 0,
|
|
1239
|
-
});
|
|
1252
|
+
"";
|
|
1253
|
+
const r = await ensSignAndSet(opts.call, ensProfileRecord({ userid: identity.userid, address: identity.address }, fullName, carried, displayName, description));
|
|
1240
1254
|
sendJson(res, r.ok ? 200 : 502, r.ok ? { ok: true, name: fullName } : { ok: false, error: r.error });
|
|
1241
1255
|
return;
|
|
1242
1256
|
}
|
|
@@ -2257,6 +2271,31 @@ export function startBeagleServer(opts) {
|
|
|
2257
2271
|
const { name, description, punkId } = await readBody(req);
|
|
2258
2272
|
const r = await opts.call({ op: "set-profile", name, description, punkId });
|
|
2259
2273
|
sendJson(res, r.ok ? 200 : 400, r);
|
|
2274
|
+
// Also the public record, when this identity registered a beagles.eth
|
|
2275
|
+
// name here: displayName and description on the record ARE the
|
|
2276
|
+
// profile name and status message, and editing them in Profile used
|
|
2277
|
+
// to change only what Carrier advertises, never the page. Best
|
|
2278
|
+
// effort, after the reply: the gateway being down must not turn a
|
|
2279
|
+
// profile save into a failure. A punk-only call (the avatar advertise
|
|
2280
|
+
// on poll) carries neither field and leaves the record alone.
|
|
2281
|
+
if (r.ok && (typeof name === "string" || typeof description === "string")) {
|
|
2282
|
+
void (async () => {
|
|
2283
|
+
const diag = await opts.call({ op: "diag" });
|
|
2284
|
+
const identity = (diag.ok ? diag.data?.identity : null) ?? {};
|
|
2285
|
+
if (!identity.userid || !identity.address)
|
|
2286
|
+
return;
|
|
2287
|
+
const mine = await ensFetchJson(`/getAddress/${encodeURIComponent(identity.userid)}`);
|
|
2288
|
+
if (!mine || mine.owner !== identity.userid)
|
|
2289
|
+
return; // not registered here — nothing to sign
|
|
2290
|
+
const displayName = (typeof name === "string" && name.trim().slice(0, 64)) ||
|
|
2291
|
+
mine.texts?.displayName ||
|
|
2292
|
+
mine.name.replace(/\.beagles\.eth$/, "");
|
|
2293
|
+
const desc = typeof description === "string" ? description.trim().slice(0, 200) : (mine.texts?.description ?? "");
|
|
2294
|
+
const w = await ensSignAndSet(opts.call, ensProfileRecord({ userid: identity.userid, address: identity.address }, mine.name, mine, displayName, desc));
|
|
2295
|
+
if (!w.ok)
|
|
2296
|
+
console.warn(`[ens] profile saved, but the ${mine.name} record was not updated: ${w.error}`);
|
|
2297
|
+
})().catch((e) => console.warn(`[ens] record update after profile save failed: ${e.message}`));
|
|
2298
|
+
}
|
|
2260
2299
|
return;
|
|
2261
2300
|
}
|
|
2262
2301
|
if (req.method === "GET" && url === "/api/routes") {
|
package/package.json
CHANGED