nostr-bray 1.29.1 → 1.29.3
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/cli.js +6 -1
- package/dist/heartwood-context.js +30 -5
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -266,9 +266,13 @@ const nip65 = new Nip65Manager(pool, config.relays);
|
|
|
266
266
|
let ctx;
|
|
267
267
|
if (config.bunkerUri) {
|
|
268
268
|
const { BunkerContext } = await import('./bunker-context.js');
|
|
269
|
+
const { HeartwoodContext } = await import('./heartwood-context.js');
|
|
269
270
|
ctx = await BunkerContext.connect(config.bunkerUri);
|
|
270
271
|
await ctx.resolvePublicKey();
|
|
271
|
-
|
|
272
|
+
const hw = await HeartwoodContext.probe(ctx);
|
|
273
|
+
if (hw)
|
|
274
|
+
ctx = hw;
|
|
275
|
+
console.error(`Connected to ${hw ? 'Heartwood' : 'bunker'} — signing as ${ctx.activeNpub}`);
|
|
272
276
|
}
|
|
273
277
|
else {
|
|
274
278
|
ctx = new IdentityContext(config.secretKey, config.secretFormat);
|
|
@@ -373,6 +377,7 @@ async function run(cmdArgs) {
|
|
|
373
377
|
break;
|
|
374
378
|
case 'switch':
|
|
375
379
|
await ctx.switch(req(1, 'switch <target> [index]'), cmdArgs[2] ? parseInt(cmdArgs[2], 10) : undefined);
|
|
380
|
+
console.error(`Now signing as ${ctx.activeNpub}`);
|
|
376
381
|
console.log(ctx.activeNpub);
|
|
377
382
|
break;
|
|
378
383
|
case 'prove':
|
|
@@ -36,7 +36,12 @@ export class HeartwoodContext extends BunkerContext {
|
|
|
36
36
|
/** Derive a named persona on the Heartwood device. */
|
|
37
37
|
async derivePersona(name, index) {
|
|
38
38
|
const result = await this.signer.sendRequest('heartwood_derive_persona', [name, String(index)]);
|
|
39
|
-
|
|
39
|
+
const identity = JSON.parse(result);
|
|
40
|
+
// Log purpose so we can verify it matches nostr:persona:{name} convention
|
|
41
|
+
if (identity.purpose && identity.purpose !== `nostr:persona:${name}`) {
|
|
42
|
+
console.error(`[heartwood] note: device returned purpose "${identity.purpose}", bray uses "nostr:persona:${name}"`);
|
|
43
|
+
}
|
|
44
|
+
return identity;
|
|
40
45
|
}
|
|
41
46
|
/** List all known identities on the Heartwood device. */
|
|
42
47
|
async listIdentities() {
|
|
@@ -49,10 +54,30 @@ export class HeartwoodContext extends BunkerContext {
|
|
|
49
54
|
? [purposeOrName, String(index)]
|
|
50
55
|
: [purposeOrName];
|
|
51
56
|
const raw = await this.signer.sendRequest('heartwood_switch', params);
|
|
52
|
-
//
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
57
|
+
// Parse response — device may return { npub } object or a bare npub string
|
|
58
|
+
const { decode, npubEncode } = await import('nostr-tools/nip19');
|
|
59
|
+
let npub;
|
|
60
|
+
try {
|
|
61
|
+
const parsed = JSON.parse(raw);
|
|
62
|
+
if (typeof parsed === 'string') {
|
|
63
|
+
npub = parsed;
|
|
64
|
+
}
|
|
65
|
+
else if (parsed && typeof parsed.npub === 'string') {
|
|
66
|
+
npub = parsed.npub;
|
|
67
|
+
}
|
|
68
|
+
else if (parsed && typeof parsed.pubkey === 'string') {
|
|
69
|
+
// Some devices return { pubkey: hex }
|
|
70
|
+
npub = npubEncode(parsed.pubkey);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
catch {
|
|
74
|
+
// raw may itself be a bare npub (no JSON wrapping)
|
|
75
|
+
if (typeof raw === 'string' && raw.startsWith('npub1'))
|
|
76
|
+
npub = raw;
|
|
77
|
+
}
|
|
78
|
+
if (!npub) {
|
|
79
|
+
throw new Error(`heartwood_switch returned unexpected response: ${JSON.stringify(raw)}`);
|
|
80
|
+
}
|
|
56
81
|
const decoded = decode(npub);
|
|
57
82
|
if (decoded.type === 'npub') {
|
|
58
83
|
this.pubkeyHex = decoded.data;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nostr-bray",
|
|
3
|
-
"version": "1.29.
|
|
3
|
+
"version": "1.29.3",
|
|
4
4
|
"mcpName": "dev.forgesworn/bray",
|
|
5
5
|
"description": "Trust-aware Nostr for AI and humans. Three dimensions of trust -- verification, proximity, and access -- woven into every interaction.",
|
|
6
6
|
"type": "module",
|