@kehto/paja 0.35.0 → 0.35.1

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/README.md CHANGED
@@ -81,9 +81,20 @@ is presentation-only — the target iframe keeps its identity and the loaded
81
81
  napplet keeps running — and Paja remembers the choice per browser origin. In
82
82
  runtime-pointer mode, ACL controls always display and mutate
83
83
  the active tab's resolver-verified d-tag and aggregate hash; a grant or revoke
84
- rerenders that same identity immediately. Paja auto-connects a browser NIP-07 signer when `window.nostr` is
85
- available, can connect to a bunker/NIP-46 URI, and only uses the generated local
86
- development signer when the Dev signer button is selected. Sign, publish, DM
84
+ rerenders that same identity immediately. Paja starts with **None** selected and never
85
+ asks an available browser extension for its public key on first startup. Choose
86
+ **Dev**, **NIP-07**, or **Bunker** explicitly; **None** disconnects and cancels pending
87
+ connections. The selected method (including None) is remembered per browser origin
88
+ under `kehto:paja:signer-method:v1`. Reload restores Dev or reconnects an explicitly
89
+ selected NIP-07 extension. Bunker restores selected but disconnected: enter its URI
90
+ again. Only the method is stored, never credentials, keys, URIs, or approvals.
91
+ Invalid or unreadable storage defaults to None; failed writes still allow selection
92
+ for the current session. An unavailable extension stays selected with an error,
93
+ without falling back to another signer. Fixed simulation identity is independent of
94
+ signing authority. Known NAP-IDENTITY gap: signer changes currently re-initialize
95
+ the hosted frame rather than delivering `identity.changed` to the existing frame;
96
+ the new frame reads the updated identity. The browser suite keeps that push gap
97
+ explicitly skipped. Sign, publish, DM
87
98
  send, filesystem picker, Blossom upload, and external-link requests use one serialized in-page
88
99
  confirmation dialog. Deny has initial focus and Escape denies. A napplet-scoped
89
100
  serial or BLE chooser receives runtime approval first; Paja then keeps the
@@ -552,11 +563,15 @@ shell user's BUD-03 list through the same approval-bound relay path, then uses
552
563
  the current window's verified pointer-manifest servers, followed by upload-runtime
553
564
  fallbacks and saved extra resource servers. Every bootstrap and author relay is
554
565
  authorized as its exact `ws:`/`wss:` destination before its socket opens. The
555
- host refreshes signer-derived bootstrap URLs only at signer initialization or a
556
- signer lifecycle change; a resource request reads that bounded host cache and
557
- never calls an external signer's `getRelays()` hook, because that hook can
558
- perform opaque extension work before an origin exists to approve. If refreshing
559
- the cache fails, configured host bootstrap relays remain available. The user-list
566
+ host uses only configured discovery/super relays for bootstrap discovery,
567
+ including contact-list and followed-author warming. Paja neither reads nor calls
568
+ the obsolete NIP-07 `getRelays()` extension property, including during signer
569
+ initialization and account changes; there is no signer-bootstrap cache.
570
+ The retained NAP `identity.getRelays` operation returns an empty relay map for
571
+ unsupported external-user metadata, not host URLs presented as user NIP-65
572
+ preferences. This follows [current NIP-07](https://github.com/nostr-protocol/nips/blob/master/07.md)
573
+ (checked 2026-11-12) and [NAP-IDENTITY at `43cb3a4`](https://github.com/napplet/naps/blob/43cb3a4e855570ec4b90b9cc05f0c721e5ad0aab/naps/NAP-IDENTITY.md),
574
+ which permits empty unsupported results. The user-list
560
575
  lookup works independently of upload mode; an upload runtime may reuse the same
561
576
  servers when present. ROM-specific event and publisher locations retain
562
577
  priority over the user/runtime fallbacks. URI length is capped at 8192 characters;
@@ -3450,7 +3450,7 @@ function uploadMap(action) {
3450
3450
  return { senderCap: "upload:write", recipientCap: null };
3451
3451
  }
3452
3452
  function intentMap(action) {
3453
- if (action === "changed" || action === "invoke.result" || action === "available.result" || action === "handlers.result") {
3453
+ if (action === "changed" || action === "deliver" || action === "invoke.result" || action === "available.result" || action === "handlers.result") {
3454
3454
  return { senderCap: null, recipientCap: "intent:read" };
3455
3455
  }
3456
3456
  if (action === "invoke") return { senderCap: "intent:write", recipientCap: null };
@@ -27206,30 +27206,13 @@ function readAuthors(candidates) {
27206
27206
  }
27207
27207
  return [...authors];
27208
27208
  }
27209
- async function getSignerRelayUrls(signerProvider, direction) {
27210
- const signer = signerProvider?.getSigner();
27211
- if (!signer?.getRelays) return [];
27212
- try {
27213
- const relays = await signer.getRelays();
27214
- return dedupeRelayUrls(Object.entries(relays).flatMap(([url, permissions]) => {
27215
- if (direction === "read" && permissions.read) return [url];
27216
- if (direction === "write" && permissions.write) return [url];
27217
- return [];
27218
- }));
27219
- } catch {
27220
- return [];
27221
- }
27222
- }
27223
- async function getPajaBootstrapRelayUrls(getSimulation, signerProvider, getHostRelayUrls) {
27224
- return dedupeRelayUrls([
27225
- ...getHostRelayUrls?.() ?? getPajaRelayUrls(getSimulation()),
27226
- ...await getSignerRelayUrls(signerProvider, "read")
27227
- ]);
27209
+ function getPajaBootstrapRelayUrls(getSimulation, getHostRelayUrls) {
27210
+ return dedupeRelayUrls(getHostRelayUrls?.() ?? getPajaRelayUrls(getSimulation()));
27228
27211
  }
27229
- function createPajaContactListLoader(backend, getSimulation, signerProvider, getHostRelayUrls) {
27212
+ function createPajaContactListLoader(backend, getSimulation, getHostRelayUrls) {
27230
27213
  return async (pubkey2, signal) => {
27231
27214
  if (!/^[0-9a-fA-F]{64}$/.test(pubkey2) || signal?.aborted) return [];
27232
- const relayUrls2 = await getPajaBootstrapRelayUrls(getSimulation, signerProvider, getHostRelayUrls);
27215
+ const relayUrls2 = getPajaBootstrapRelayUrls(getSimulation, getHostRelayUrls);
27233
27216
  if (signal?.aborted) return [];
27234
27217
  const filters = [{
27235
27218
  kinds: [PAJA_CONTACT_LIST_KIND],
@@ -27245,15 +27228,14 @@ function createPajaContactListLoader(backend, getSimulation, signerProvider, get
27245
27228
  function latestEvent(events, kind, pubkey2) {
27246
27229
  return events.filter((event) => event.kind === kind && event.pubkey === pubkey2).sort((a, b) => b.created_at - a.created_at)[0];
27247
27230
  }
27248
- function createPajaRelayListLoader(backend, getSimulation, signerProvider, getHostRelayUrls) {
27231
+ function createPajaRelayListLoader(backend, getSimulation, getHostRelayUrls) {
27249
27232
  const registry2 = createNip65Registry();
27250
27233
  return async (pubkeys) => {
27251
27234
  const uniquePubkeys = [...new Set(pubkeys.filter((pubkey2) => /^[0-9a-fA-F]{64}$/.test(pubkey2)))];
27252
27235
  const missing = uniquePubkeys.filter((pubkey2) => !registry2.has(pubkey2));
27253
27236
  if (missing.length > 0) {
27254
- const events = await backend.query(await getPajaBootstrapRelayUrls(
27237
+ const events = await backend.query(getPajaBootstrapRelayUrls(
27255
27238
  getSimulation,
27256
- signerProvider,
27257
27239
  getHostRelayUrls
27258
27240
  ), [{
27259
27241
  kinds: [PAJA_NIP65_RELAY_LIST_KIND],
@@ -27710,7 +27692,6 @@ function createOutboxRouter(backend, getSimulation, relayConfig, confirmRequest,
27710
27692
  loadRelayLists: createPajaRelayListLoader(
27711
27693
  backend,
27712
27694
  getSimulation,
27713
- signerProvider,
27714
27695
  () => relayConfig.getRelayUrls(["discovery", "super"])
27715
27696
  ),
27716
27697
  fallbackRelays: relayConfig.outboxRelays,
@@ -30164,22 +30145,6 @@ function createDevServices(backend, getSimulation, relayConfig, onThemeService,
30164
30145
  const getReadRelays = () => relayConfig.getRelayUrls(["discovery", "super"]);
30165
30146
  const getWriteRelays = () => relayConfig.getRelayUrls(["outbox"]);
30166
30147
  const getAllRelays = () => relayConfig.getRelayUrls();
30167
- const signerBootstrapRelays = [];
30168
- let signerBootstrapGeneration = 0;
30169
- const refreshSignerBootstrapRelays = () => {
30170
- const generation2 = ++signerBootstrapGeneration;
30171
- signerBootstrapRelays.splice(0);
30172
- const signer = signerProvider?.getSigner();
30173
- if (!signer?.getRelays) return;
30174
- void Promise.resolve().then(() => signer.getRelays()).then((relays) => {
30175
- if (generation2 !== signerBootstrapGeneration || !relays || typeof relays !== "object") return;
30176
- for (const [url, permissions] of Object.entries(relays)) {
30177
- if (permissions?.read && typeof url === "string") signerBootstrapRelays.push(url);
30178
- }
30179
- }).catch(() => {
30180
- });
30181
- };
30182
- refreshSignerBootstrapRelays();
30183
30148
  const baseOutboxRouter = createOutboxRouter(backend, getSimulation, relayConfig, confirmRequest, signerProvider);
30184
30149
  const queryApprovedResourceRelays = async (relayUrls2, filters, context) => {
30185
30150
  const unique = [...new Set(relayUrls2.filter((relay) => isPajaRelayAllowed(relay, () => relayConfig.getRelayUrls())))];
@@ -30195,14 +30160,7 @@ function createDevServices(backend, getSimulation, relayConfig, onThemeService,
30195
30160
  };
30196
30161
  const discoverBlossomServerList = async (pubkey2, context) => {
30197
30162
  const relayListEvents = await queryApprovedResourceRelays(
30198
- // Resource requests never call an external signer's getRelays hook. The
30199
- // host refreshes signerBootstrapRelays on lifecycle changes, so each URL
30200
- // below is already concrete and can be approved before opening a socket.
30201
- await getPajaBootstrapRelayUrls(
30202
- getSimulation,
30203
- void 0,
30204
- () => [...getReadRelays(), ...signerBootstrapRelays]
30205
- ),
30163
+ getReadRelays(),
30206
30164
  [{ kinds: [10002], authors: [pubkey2], limit: 2 }],
30207
30165
  context
30208
30166
  );
@@ -30228,7 +30186,7 @@ function createDevServices(backend, getSimulation, relayConfig, onThemeService,
30228
30186
  });
30229
30187
  const socialCache = createPajaSocialCache({
30230
30188
  baseRouter: baseOutboxRouter,
30231
- loadContactList: createPajaContactListLoader(backend, getSimulation, signerProvider, getReadRelays),
30189
+ loadContactList: createPajaContactListLoader(backend, getSimulation, getReadRelays),
30232
30190
  verifyEvent: (event) => verifyEvent(event),
30233
30191
  // Background warming is speculative relay traffic, so it only runs for a
30234
30192
  // signer account. `getFollows` still answers on demand for any requested
@@ -30376,7 +30334,9 @@ function createDevServices(backend, getSimulation, relayConfig, onThemeService,
30376
30334
  if (!identitySigner || key !== identitySignerKey) {
30377
30335
  identitySigner = connectedSigner && signerProvider ? {
30378
30336
  getPublicKey: () => signerProvider.getSigner()?.getPublicKey?.() ?? "",
30379
- getRelays: () => signerProvider.getSigner()?.getRelays?.() ?? {}
30337
+ // NAP-IDENTITY permits empty unsupported metadata results.
30338
+ // Host bootstrap URLs are not the user's NIP-65 preferences.
30339
+ getRelays: () => ({})
30380
30340
  } : createRuntimeSigner(getSimulation, confirmRequest, signerProvider);
30381
30341
  identitySignerKey = key;
30382
30342
  }
@@ -30496,7 +30456,6 @@ function createDevServices(backend, getSimulation, relayConfig, onThemeService,
30496
30456
  return {
30497
30457
  services,
30498
30458
  refreshAvailability,
30499
- refreshSignerBootstrapRelays,
30500
30459
  setWindowBlossomServers: blossomEventResolver.setWindowServers
30501
30460
  };
30502
30461
  }
@@ -30565,7 +30524,6 @@ function createPajaAdapter(config, getSimulation, onThemeService, onThemeBroadca
30565
30524
  if (getSimulation().capabilities.domains.fs) queueMicrotask(() => onEnvironmentChanged?.());
30566
30525
  });
30567
30526
  signerProvider?.subscribe?.(() => {
30568
- serviceBundle.refreshSignerBootstrapRelays();
30569
30527
  const availabilityChanged = serviceBundle.refreshAvailability();
30570
30528
  if (uploadRuntime) {
30571
30529
  void uploadRuntime.refreshIdentity().finally(() => onEnvironmentChanged?.());
@@ -31126,6 +31084,12 @@ function renderSignerStatus(state, signerPubkey) {
31126
31084
  clearConsent.textContent = `Forget ${state.signerConsentCount} remembered approval${state.signerConsentCount === 1 ? "" : "s"}`;
31127
31085
  clearConsent.onclick = () => state.clearSignerConsent();
31128
31086
  const previousInput = controls.querySelector("#signer-bunker-uri")?.value ?? "";
31087
+ const noneButton = document.createElement("button");
31088
+ noneButton.type = "button";
31089
+ noneButton.id = "signer-none";
31090
+ noneButton.dataset.active = String(state.signer.method === "none");
31091
+ noneButton.textContent = "None";
31092
+ noneButton.addEventListener("click", () => state.useNoSigner());
31129
31093
  const devButton = document.createElement("button");
31130
31094
  devButton.type = "button";
31131
31095
  devButton.id = "signer-dev";
@@ -31151,7 +31115,7 @@ function renderSignerStatus(state, signerPubkey) {
31151
31115
  bunkerButton.dataset.active = String(state.signer.method === "nip46");
31152
31116
  bunkerButton.textContent = "Bunker";
31153
31117
  bunkerButton.addEventListener("click", () => void state.connectBunker(bunkerInput.value));
31154
- controls.replaceChildren(devButton, nip07Button, bunkerInput, bunkerButton);
31118
+ controls.replaceChildren(noneButton, devButton, nip07Button, bunkerInput, bunkerButton);
31155
31119
  }
31156
31120
 
31157
31121
  // src/browser-nip46-client.ts
@@ -31332,6 +31296,7 @@ function createNip46Client(options) {
31332
31296
  }
31333
31297
 
31334
31298
  // src/browser-signers.ts
31299
+ var SIGNER_METHOD_KEY = "kehto:paja:signer-method:v1";
31335
31300
  function cloneState(state) {
31336
31301
  return { ...state };
31337
31302
  }
@@ -31380,12 +31345,25 @@ function createNip07Adapter(signer) {
31380
31345
  return {
31381
31346
  getPublicKey: signer.getPublicKey?.bind(signer),
31382
31347
  signEvent: signer.signEvent?.bind(signer),
31383
- getRelays: signer.getRelays?.bind(signer),
31384
31348
  nip04: signer.nip04,
31385
31349
  nip44: signer.nip44
31386
31350
  };
31387
31351
  }
31388
31352
  function createPajaSignerController(options) {
31353
+ const readPreference = () => {
31354
+ try {
31355
+ const method = (options.storage ?? localStorage).getItem(SIGNER_METHOD_KEY);
31356
+ if (method === "dev" || method === "nip07" || method === "nip46") return method;
31357
+ } catch {
31358
+ }
31359
+ return "none";
31360
+ };
31361
+ const persist = (method) => {
31362
+ try {
31363
+ (options.storage ?? localStorage).setItem(SIGNER_METHOD_KEY, method);
31364
+ } catch {
31365
+ }
31366
+ };
31389
31367
  let state = {
31390
31368
  method: "none",
31391
31369
  status: "disconnected",
@@ -31395,6 +31373,7 @@ function createPajaSignerController(options) {
31395
31373
  };
31396
31374
  let activeSigner = null;
31397
31375
  let activeClient = null;
31376
+ let generation2 = 0;
31398
31377
  const listeners = /* @__PURE__ */ new Set();
31399
31378
  const update = (next) => {
31400
31379
  state = { ...state, ...next };
@@ -31418,6 +31397,8 @@ function createPajaSignerController(options) {
31418
31397
  return () => listeners.delete(listener);
31419
31398
  },
31420
31399
  useDevSigner() {
31400
+ persist("dev");
31401
+ generation2 += 1;
31421
31402
  closeClient();
31422
31403
  activeSigner = null;
31423
31404
  update({
@@ -31428,7 +31409,16 @@ function createPajaSignerController(options) {
31428
31409
  error: null
31429
31410
  });
31430
31411
  },
31412
+ useNoSigner() {
31413
+ persist("none");
31414
+ generation2 += 1;
31415
+ closeClient();
31416
+ activeSigner = null;
31417
+ update({ method: "none", status: "disconnected", pubkey: null, relay: null, error: null });
31418
+ },
31431
31419
  async connectNip07() {
31420
+ persist("nip07");
31421
+ const current = ++generation2;
31432
31422
  closeClient();
31433
31423
  activeSigner = null;
31434
31424
  update({ method: "nip07", status: "connecting", pubkey: null, relay: null, error: null });
@@ -31436,14 +31426,18 @@ function createPajaSignerController(options) {
31436
31426
  const signer = readNip07Signer();
31437
31427
  if (!signer) throw new Error("NIP-07 signer not found");
31438
31428
  const pubkey2 = await signer.getPublicKey();
31429
+ if (current !== generation2) return;
31439
31430
  activeSigner = createNip07Adapter(signer);
31440
31431
  update({ method: "nip07", status: "connected", pubkey: pubkey2, relay: null, error: null });
31441
31432
  } catch (error) {
31433
+ if (current !== generation2) return;
31442
31434
  activeSigner = null;
31443
31435
  update({ method: "nip07", status: "error", pubkey: null, relay: null, error: toErrorMessage5(error) });
31444
31436
  }
31445
31437
  },
31446
31438
  async connectBunker(uri) {
31439
+ persist("nip46");
31440
+ const current = ++generation2;
31447
31441
  closeClient();
31448
31442
  activeSigner = null;
31449
31443
  const parsed = parseBunkerUri(uri.trim());
@@ -31464,15 +31458,27 @@ function createPajaSignerController(options) {
31464
31458
  bunkerPubkey: parsed.pubkey,
31465
31459
  secret: parsed.secret
31466
31460
  });
31467
- const pubkey2 = await client.connect();
31468
31461
  activeClient = client;
31462
+ const pubkey2 = await client.connect();
31463
+ if (current !== generation2) return;
31469
31464
  activeSigner = client.getSigner();
31470
31465
  update({ method: "nip46", status: "connected", pubkey: pubkey2, relay: parsed.relay, error: null });
31471
31466
  } catch (error) {
31467
+ if (current !== generation2) return;
31472
31468
  closeClient();
31473
31469
  activeSigner = null;
31474
31470
  update({ method: "nip46", status: "error", pubkey: null, relay: parsed.relay, error: toErrorMessage5(error) });
31475
31471
  }
31472
+ },
31473
+ async restorePreference() {
31474
+ const method = readPreference();
31475
+ if (method === "nip07") return this.connectNip07();
31476
+ if (method === "dev") return this.useDevSigner();
31477
+ if (method === "none") return this.useNoSigner();
31478
+ generation2 += 1;
31479
+ closeClient();
31480
+ activeSigner = null;
31481
+ update({ method: "nip46", status: "disconnected", pubkey: null, relay: null, error: null });
31476
31482
  }
31477
31483
  };
31478
31484
  }
@@ -32151,10 +32157,6 @@ function createHostSignerController(getState, refreshState, confirmRequest) {
32151
32157
  }
32152
32158
  });
32153
32159
  }
32154
- function hasNip07Signer() {
32155
- const signer = globalThis.nostr;
32156
- return typeof signer === "object" && signer !== null;
32157
- }
32158
32160
 
32159
32161
  // src/browser-host-runtime.ts
32160
32162
  function unregisterSingleFrameWindow(bridge, runtime, windowId) {
@@ -35297,6 +35299,9 @@ function createPajaBrowserState(context, relayEventCounts, relayInventory) {
35297
35299
  useDevSigner() {
35298
35300
  signerController.useDevSigner();
35299
35301
  },
35302
+ useNoSigner() {
35303
+ signerController.useNoSigner();
35304
+ },
35300
35305
  connectNip07() {
35301
35306
  return signerController.connectNip07();
35302
35307
  },
@@ -35632,7 +35637,7 @@ async function installPajaHost() {
35632
35637
  startFrameNavigation(state, context);
35633
35638
  void reportTargetCorsDiagnostic(state);
35634
35639
  }
35635
- if (hasNip07Signer()) void state.connectNip07();
35640
+ void signerController.restorePreference();
35636
35641
  }
35637
35642
  if (typeof document !== "undefined") {
35638
35643
  try {