@kehto/shell 0.24.4 → 0.24.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/README.md CHANGED
@@ -304,3 +304,19 @@ for outer URL encoding, review, routing, and verified launcher behavior.
304
304
  ## GAMEPAD integration
305
305
 
306
306
  This non-normative guidance defers to the living [NAP-GAMEPAD](https://github.com/napplet/naps/pull/108). Services export `createGamepadService` and `browserGamepadOptions`; shell exports `denyNappletControllerAccess`. Paja and the playground register one host reader and deny native gamepad/HID/USB paths before frame execution. Source-bound subscriptions receive immediate full snapshots; only the visible host's input owner gets live controls. Focus loss supplies neutral controls and timestamp zero; unsubscribe, window destruction, and service removal release polling. Non-browser or denied native readers report the proposal's unavailable reasons. See [Controller input](https://github.com/kehto/web/blob/main/docs/gamepad.md).
307
+
308
+ ## UUID support on HTTP origins
309
+
310
+ Shell event injection, cache queries, and source-session registration use native
311
+ `crypto.randomUUID()` when available. On browsers that omit it (including
312
+ non-localhost plain HTTP origins), the shell generates UUID v4 identifiers from
313
+ 16 `crypto.getRandomValues()` bytes. If both methods are unavailable, UUID
314
+ creation throws an explicit capability error. This internal host UUID helper
315
+ never falls back to weak randomness; other identifier generators are outside
316
+ its scope. It does not provide secure-context APIs such as `crypto.subtle` on
317
+ HTTP, so this change does not establish HTTP support for uploads or other domains.
318
+
319
+ This is a supported platform capability choice, not a deprecated caller API.
320
+ Both standard Web Crypto paths remain quiet. Source-bound identity and optional
321
+ shell readiness are unchanged (NAP-SHELL at `napplet/naps`
322
+ `1e1046bcadabbc552804f6d3354f565184f9fefb`).
package/dist/index.js CHANGED
@@ -1,6 +1,20 @@
1
1
  // src/shell-bridge.ts
2
2
  import { createRuntime } from "@kehto/runtime";
3
3
 
4
+ // src/random-uuid.ts
5
+ function randomUUID() {
6
+ const provider = globalThis.crypto;
7
+ if (typeof provider?.randomUUID === "function") return provider.randomUUID();
8
+ if (typeof provider?.getRandomValues !== "function") {
9
+ throw new Error("@kehto/shell requires crypto.randomUUID or crypto.getRandomValues for UUID generation");
10
+ }
11
+ const bytes = provider.getRandomValues(new Uint8Array(16));
12
+ bytes[6] = bytes[6] & 15 | 64;
13
+ bytes[8] = bytes[8] & 63 | 128;
14
+ const hex = Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0")).join("");
15
+ return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
16
+ }
17
+
4
18
  // src/hooks-adapter.ts
5
19
  function bytesToHex(bytes) {
6
20
  return Array.from(bytes, (b) => b.toString(16).padStart(2, "0")).join("");
@@ -66,7 +80,7 @@ function createCacheAdapter(shellHooks) {
66
80
  async query(filters) {
67
81
  const workerRelay = shellHooks.workerRelay.getWorkerRelay();
68
82
  if (!workerRelay) return [];
69
- const subId = crypto.randomUUID();
83
+ const subId = randomUUID();
70
84
  return workerRelay.query(["REQ", subId, ...filters]);
71
85
  },
72
86
  store(event) {
@@ -113,7 +127,7 @@ function createCryptoAdapter(shellHooks) {
113
127
  return shellHooks.crypto.verifyEvent(event);
114
128
  },
115
129
  randomUUID() {
116
- return crypto.randomUUID();
130
+ return randomUUID();
117
131
  },
118
132
  randomBytes(length) {
119
133
  const bytes = new Uint8Array(length);
@@ -1140,7 +1154,7 @@ function registerNip5dSessionIfNeeded({
1140
1154
  dTag: identity.dTag,
1141
1155
  aggregateHash: identity.aggregateHash,
1142
1156
  registeredAt: Date.now(),
1143
- instanceId: crypto.randomUUID(),
1157
+ instanceId: randomUUID(),
1144
1158
  provenance: "nip-5d"
1145
1159
  };
1146
1160
  runtime.sessionRegistry.register(windowId, entry);