edge-book 0.2.3 → 0.2.5
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/edge-book.js +55 -2
- package/package.json +1 -1
package/dist/edge-book.js
CHANGED
|
@@ -179,6 +179,20 @@ var EdgeBookStore = class {
|
|
|
179
179
|
if (!identity) throw new EdgeBookError("not_initialized", `Edge Book is not initialized at ${this.home}`);
|
|
180
180
|
return identity;
|
|
181
181
|
}
|
|
182
|
+
// Update profile fields on an existing identity without rotating keys, so the
|
|
183
|
+
// agent_id (and any pairing built on it) survives. `owner_label` is the human
|
|
184
|
+
// who owns the agent; `display_name` is the agent's own name.
|
|
185
|
+
async setProfile(input) {
|
|
186
|
+
const identity = await this.identity();
|
|
187
|
+
if (input.displayName !== void 0 && input.displayName !== "") identity.display_name = input.displayName;
|
|
188
|
+
if (input.ownerLabel !== void 0) identity.owner_label = input.ownerLabel;
|
|
189
|
+
if (input.shareOwnerLabel !== void 0) identity.share_owner_label = input.shareOwnerLabel;
|
|
190
|
+
identity.updated_at = now();
|
|
191
|
+
await writeJson(this.file(IDENTITY_FILE), identity, 384);
|
|
192
|
+
await this.writeCard();
|
|
193
|
+
await this.audit("identity.update", identity.agent_id, { display_name: identity.display_name, owner_label: identity.owner_label });
|
|
194
|
+
return identity;
|
|
195
|
+
}
|
|
182
196
|
async config() {
|
|
183
197
|
return readJson(this.file(CONFIG_FILE), {});
|
|
184
198
|
}
|
|
@@ -201,6 +215,8 @@ var EdgeBookStore = class {
|
|
|
201
215
|
agent_id: identity.agent_id,
|
|
202
216
|
handle: identity.handle,
|
|
203
217
|
display_name: identity.display_name,
|
|
218
|
+
// Opt-in only: include the human owner name when the owner enabled sharing.
|
|
219
|
+
...identity.share_owner_label && identity.owner_label ? { owner_label: identity.owner_label } : {},
|
|
204
220
|
card_url: cardUrl || `file://${this.file(CARD_FILE)}`,
|
|
205
221
|
card_version: 1,
|
|
206
222
|
public_keys: [{ id: `${identity.agent_id}#main`, type: "ed25519", public_key_pem: identity.public_key_pem }],
|
|
@@ -283,6 +299,9 @@ var EdgeBookStore = class {
|
|
|
283
299
|
peer_agent_id: card.agent_id,
|
|
284
300
|
aliases: Array.from(new Set([...existing?.aliases ?? [], card.handle].filter(Boolean))),
|
|
285
301
|
display_name: card.display_name,
|
|
302
|
+
// Carry the peer's shared human name (undefined if they didn't opt in, or
|
|
303
|
+
// dropped on refresh if they turned sharing off).
|
|
304
|
+
owner_label: card.owner_label,
|
|
286
305
|
card_url: card.card_url,
|
|
287
306
|
known_endpoints: card.transports,
|
|
288
307
|
public_keys: card.public_keys,
|
|
@@ -1249,6 +1268,7 @@ function publicIdentity(identity) {
|
|
|
1249
1268
|
handle: identity.handle,
|
|
1250
1269
|
name: identity.display_name,
|
|
1251
1270
|
display_name: identity.display_name,
|
|
1271
|
+
owner_label: identity.owner_label,
|
|
1252
1272
|
public_key: compactPem(identity.public_key_pem)
|
|
1253
1273
|
};
|
|
1254
1274
|
}
|
|
@@ -3144,7 +3164,10 @@ function usage() {
|
|
|
3144
3164
|
return `Edge Book
|
|
3145
3165
|
|
|
3146
3166
|
Usage:
|
|
3147
|
-
edge-book init [--home <dir>] [--handle <handle>] [--name <
|
|
3167
|
+
edge-book init [--home <dir>] [--handle <handle>] [--name <agent name>] [--owner <human owner>]
|
|
3168
|
+
edge-book profile show [--home <dir>]
|
|
3169
|
+
edge-book profile set [--name <agent name>] [--owner <human owner>] [--share-owner | --no-share-owner] [--home <dir>]
|
|
3170
|
+
# owner name is private by default; --share-owner exposes it on your card
|
|
3148
3171
|
|
|
3149
3172
|
Hosted reader:
|
|
3150
3173
|
edge-book dialout [--host <ws-url>] [--home <dir>]
|
|
@@ -3236,11 +3259,41 @@ async function handleCli(inputArgs, ctx = {}) {
|
|
|
3236
3259
|
if (command === "init") {
|
|
3237
3260
|
const handle = takeFlag(args, "--handle");
|
|
3238
3261
|
const displayName = takeFlag(args, "--name");
|
|
3262
|
+
const ownerLabel = takeFlag(args, "--owner");
|
|
3239
3263
|
const directUrl = takeFlag(args, "--direct-url");
|
|
3240
3264
|
const relayUrl = takeFlag(args, "--relay-url");
|
|
3241
|
-
const identity = await store.init({ handle, displayName, directUrl, relayUrl });
|
|
3265
|
+
const identity = await store.init({ handle, displayName, ownerLabel, directUrl, relayUrl });
|
|
3242
3266
|
return { text: `Initialized ${identity.agent_id} at ${store.home}`, json: identity };
|
|
3243
3267
|
}
|
|
3268
|
+
if (command === "profile") {
|
|
3269
|
+
const action = args.shift() || "show";
|
|
3270
|
+
if (action === "show") {
|
|
3271
|
+
const id = await store.identity();
|
|
3272
|
+
const shared = id.share_owner_label ? "shared with contacts" : "private (default)";
|
|
3273
|
+
return {
|
|
3274
|
+
text: `display_name: ${id.display_name}
|
|
3275
|
+
owner_label: ${id.owner_label || "(unset)"}
|
|
3276
|
+
share_owner_label: ${id.share_owner_label ? "true" : "false"} (${shared})`,
|
|
3277
|
+
json: { agent_id: id.agent_id, display_name: id.display_name, owner_label: id.owner_label, share_owner_label: Boolean(id.share_owner_label) }
|
|
3278
|
+
};
|
|
3279
|
+
}
|
|
3280
|
+
if (action === "set") {
|
|
3281
|
+
const displayName = takeFlag(args, "--name");
|
|
3282
|
+
const ownerLabel = takeFlag(args, "--owner");
|
|
3283
|
+
const shareOwner = takeBoolFlag(args, "--share-owner");
|
|
3284
|
+
const noShareOwner = takeBoolFlag(args, "--no-share-owner");
|
|
3285
|
+
const shareOwnerLabel = shareOwner ? true : noShareOwner ? false : void 0;
|
|
3286
|
+
if (displayName === void 0 && ownerLabel === void 0 && shareOwnerLabel === void 0) {
|
|
3287
|
+
throw new EdgeBookError("missing_arg", "profile set needs --name (agent name), --owner (human owner), and/or --share-owner|--no-share-owner");
|
|
3288
|
+
}
|
|
3289
|
+
const id = await store.setProfile({ displayName, ownerLabel, shareOwnerLabel });
|
|
3290
|
+
return {
|
|
3291
|
+
text: `Updated profile: display_name=${id.display_name} owner_label=${id.owner_label || "(unset)"} share_owner_label=${id.share_owner_label ? "true" : "false"}`,
|
|
3292
|
+
json: { agent_id: id.agent_id, display_name: id.display_name, owner_label: id.owner_label, share_owner_label: Boolean(id.share_owner_label) }
|
|
3293
|
+
};
|
|
3294
|
+
}
|
|
3295
|
+
throw new EdgeBookError("unknown_action", `Unknown profile action: ${action} (use "show" or "set")`);
|
|
3296
|
+
}
|
|
3244
3297
|
if (command === "doctor") {
|
|
3245
3298
|
const result = await store.doctor();
|
|
3246
3299
|
return { text: JSON.stringify(result, null, 2), json: result };
|