@napplet/sdk 0.2.0 → 0.3.0

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
@@ -12,7 +12,7 @@
12
12
  ### How It Works
13
13
 
14
14
  1. Import `@napplet/shim` in your entry point to install the `window.napplet` global
15
- 2. Import named exports from `@napplet/sdk` -- `relay`, `ipc`, `storage`, `keys`
15
+ 2. Import named exports from `@napplet/sdk` -- `relay`, `ifc`, `storage`, `keys`
16
16
  3. Each SDK method delegates to its `window.napplet.*` counterpart at call time
17
17
  4. If `window.napplet` is not installed when a method is called, a descriptive error is thrown
18
18
 
@@ -26,7 +26,7 @@ npm install @napplet/sdk @napplet/shim
26
26
 
27
27
  ```ts
28
28
  import '@napplet/shim';
29
- import { relay, ipc, storage, keys, media, notify, config, type NostrEvent } from '@napplet/sdk';
29
+ import { relay, ifc, storage, keys, media, notify, config, resource, type NappletConnect, type NostrEvent } from '@napplet/sdk';
30
30
 
31
31
  // Subscribe to kind 1 notes
32
32
  const sub = relay.subscribe(
@@ -43,9 +43,9 @@ const signed = await relay.publish({
43
43
  created_at: Math.floor(Date.now() / 1000),
44
44
  });
45
45
 
46
- // Inter-pane messaging
47
- ipc.emit('chat:message', [], JSON.stringify({ text: 'hi' }));
48
- const ipcSub = ipc.on('bot:response', (payload) => {
46
+ // Inter-frame messaging
47
+ ifc.emit('chat:message', [], JSON.stringify({ text: 'hi' }));
48
+ const ifcSub = ifc.on('bot:response', (payload) => {
49
49
  console.log('Bot says:', payload);
50
50
  });
51
51
 
@@ -87,9 +87,28 @@ const configSub = config.subscribe((v) => {
87
87
  // Deep-link settings UI
88
88
  config.openSettings({ section: 'appearance' });
89
89
 
90
+ // Fetch external bytes via the shell (the iframe sandbox + strict CSP block direct fetch)
91
+ const avatarBlob = await resource.bytes('https://example.com/avatar.png');
92
+ const handle = resource.bytesAsObjectURL('blossom:sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855');
93
+ imgEl.src = handle.url;
94
+ // handle.revoke() when done
95
+
96
+ // Check shell-assigned class (v0.29.0, NUB-CLASS)
97
+ import { getClass, CLASS_DOMAIN } from '@napplet/sdk';
98
+ if (window.napplet.shell.supports(`nub:${CLASS_DOMAIN}`)) {
99
+ const cls = getClass(); // number | undefined
100
+ if (cls === 2) { /* NUB-CLASS-2 posture */ }
101
+ }
102
+
103
+ // Use direct network access if the user approved `connect` origins (v0.29.0, NUB-CONNECT)
104
+ import { connectGranted, connectOrigins } from '@napplet/sdk';
105
+ if (connectGranted()) {
106
+ const res = await fetch(`${connectOrigins()[0]}/items`);
107
+ }
108
+
90
109
  // Clean up
91
110
  sub.close();
92
- ipcSub.close();
111
+ ifcSub.close();
93
112
  keySub.close();
94
113
  configSub.close();
95
114
  ```
@@ -107,9 +126,9 @@ Relay operations through the shell's relay pool. Mirrors `window.napplet.relay`.
107
126
  | `publishEncrypted(template, recipient, encryption?)` | `Promise<NostrEvent>` | Send event template for encryption, signing, and broadcast |
108
127
  | `query(filters)` | `Promise<NostrEvent[]>` | One-shot query: subscribe, collect until EOSE, resolve |
109
128
 
110
- ### `ipc`
129
+ ### `ifc`
111
130
 
112
- Inter-napplet communication between napplets. Mirrors `window.napplet.ipc`.
131
+ Inter-frame communication between napplets. Mirrors `window.napplet.ifc`.
113
132
 
114
133
  Messages are sent as JSON envelope objects (`{ type: 'ifc.emit', topic, payload }`) and received as
115
134
  (`{ type: 'ifc.event', topic, payload, sender }`).
@@ -175,7 +194,7 @@ Per-napplet declarative configuration (NUB-CONFIG). Mirrors `window.napplet.conf
175
194
 
176
195
  ### FromSchema type inference (NUB-CONFIG)
177
196
 
178
- `json-schema-to-ts` is declared as an optional `peerDependency` of `@napplet/nub-config`. Install it in your napplet to get `FromSchema<typeof schema>` typing for your `config.subscribe` callback -- the `values` parameter is inferred directly from your schema (enums, required fields, defaults all flow through). Authors who skip `json-schema-to-ts` pay no install cost and `config.subscribe` still works with the default `Record<string, unknown>` typing.
197
+ `json-schema-to-ts` is declared as an optional `peerDependency` of `@napplet/nub` (scoped to the `@napplet/nub/config` domain's `FromSchema` typing). Install it in your napplet to get `FromSchema<typeof schema>` typing for your `config.subscribe` callback -- the `values` parameter is inferred directly from your schema (enums, required fields, defaults all flow through). Authors who skip `json-schema-to-ts` pay no install cost and `config.subscribe` still works with the default `Record<string, unknown>` typing.
179
198
 
180
199
  ```ts
181
200
  import '@napplet/shim';
@@ -203,6 +222,78 @@ Install the peer when you want typed callbacks:
203
222
  npm install --save-dev json-schema-to-ts
204
223
  ```
205
224
 
225
+ ### `resource`
226
+
227
+ Sandboxed byte fetching (NUB-RESOURCE). Mirrors `window.napplet.resource`. Required because the iframe sandbox + strict CSP block direct `fetch()` / `<img src=externalUrl>` / `XMLHttpRequest`.
228
+
229
+ | Method | Returns | Description |
230
+ |--------|---------|-------------|
231
+ | `bytes(url, opts?)` | `Promise<Blob>` | Fetch bytes through the shell. `opts.signal` accepts an `AbortSignal`. |
232
+ | `bytesAsObjectURL(url)` | `{ url: string; revoke: () => void }` | Synchronous handle whose `url` resolves to a blob URL once the fetch completes. |
233
+
234
+ Four canonical schemes: `data:` (in-shim), `https:` (shell-side under policy), `blossom:sha256:<hex>` (hash-verified), `nostr:<bech32>` (single-hop NIP-19).
235
+
236
+ Bare helper aliases are also re-exported for consumers that prefer functional imports:
237
+
238
+ ```ts
239
+ import { resourceBytes, resourceBytesAsObjectURL } from '@napplet/sdk';
240
+
241
+ const blob = await resourceBytes('https://example.com/avatar.png');
242
+ const handle = resourceBytesAsObjectURL('blossom:sha256:...');
243
+ ```
244
+
245
+ ### `connect` (v0.29.0)
246
+
247
+ User-gated direct network access (NUB-CONNECT). State-only — no method namespace, no wire messages. The SDK re-exports the `NappletConnect` type, the `CONNECT_DOMAIN` constant, the `installConnectShim` installer, and the `connectGranted` / `connectOrigins` / `normalizeConnectOrigin` helper functions.
248
+
249
+ ```ts
250
+ import type { NappletConnect } from '@napplet/sdk';
251
+ import { CONNECT_DOMAIN, installConnectShim, connectGranted, connectOrigins, normalizeConnectOrigin } from '@napplet/sdk';
252
+
253
+ // Napplet-side runtime (window.napplet.connect is populated by the shim at install)
254
+ if (connectGranted()) {
255
+ const origins: readonly string[] = connectOrigins();
256
+ const res = await fetch(`${origins[0]}/items`);
257
+ }
258
+
259
+ // Build-side / shell-side shared origin validator
260
+ const normalized = normalizeConnectOrigin('https://api.example.com'); // returns input byte-identical on success; throws on invalid
261
+ ```
262
+
263
+ | Export | Kind | Source | Description |
264
+ |--------|------|--------|-------------|
265
+ | `NappletConnect` | type | `@napplet/nub/connect` | `{ readonly granted: boolean; readonly origins: readonly string[] }` |
266
+ | `CONNECT_DOMAIN` | const | `@napplet/nub/connect` | The domain identifier string `'connect'` |
267
+ | `installConnectShim` | function | `@napplet/nub/connect` | Side-effect installer — reads the discovery meta tag and mounts `window.napplet.connect` |
268
+ | `connectGranted()` | function | `@napplet/nub/connect` | `() => boolean` — readonly helper; safer than direct `window.napplet.connect.granted` access |
269
+ | `connectOrigins()` | function | `@napplet/nub/connect` | `() => readonly string[]` — readonly helper |
270
+ | `normalizeConnectOrigin(origin)` | function | `@napplet/nub/connect` | Shared origin validator (used by vite-plugin AND shell implementations); throws on invalid input with `[@napplet/nub/connect]`-prefixed messages |
271
+
272
+ ### `class` (v0.29.0)
273
+
274
+ Shell-assigned integer class (NUB-CLASS). Wire-only — the shell sends exactly one `class.assigned` envelope per napplet lifecycle; the shim writes the integer to `window.napplet.class`. The SDK re-exports the wire type, the domain constant, the installer, and a `getClass()` helper.
275
+
276
+ ```ts
277
+ import type { ClassAssignedMessage, NappletClass, ClassNubMessage } from '@napplet/sdk';
278
+ import { CLASS_DOMAIN, installClassShim, getClass } from '@napplet/sdk';
279
+
280
+ if (window.napplet.shell.supports(`nub:${CLASS_DOMAIN}`)) {
281
+ const cls = getClass(); // number | undefined
282
+ // cls === 1 → NUB-CLASS-1 (strict baseline)
283
+ // cls === 2 → NUB-CLASS-2 (user-approved explicit-origin)
284
+ // cls === undefined → shell doesn't implement nub:class OR envelope hasn't arrived yet
285
+ }
286
+ ```
287
+
288
+ | Export | Kind | Source | Description |
289
+ |--------|------|--------|-------------|
290
+ | `ClassAssignedMessage` | type | `@napplet/nub/class` | `{ type: 'class.assigned'; id: string; class: number }` |
291
+ | `NappletClass` | type | `@napplet/nub/class` | `{ readonly class: number \| undefined }` |
292
+ | `ClassMessage` / `ClassNubMessage` | type | `@napplet/nub/class` | Discriminated union alias (class.assigned is the only member in v1) |
293
+ | `CLASS_DOMAIN` | const | `@napplet/nub/class` | The domain identifier string `'class'` |
294
+ | `installClassShim` | function | `@napplet/nub/class` | Side-effect installer — registers the `class.assigned` dispatcher handler and mounts `window.napplet.class` |
295
+ | `getClass()` | function | `@napplet/nub/class` | `() => number \| undefined` — readonly helper |
296
+
206
297
  ### `keys`
207
298
 
208
299
  Keyboard forwarding and action keybindings. Mirrors `window.napplet.keys`.
@@ -213,6 +304,33 @@ Keyboard forwarding and action keybindings. Mirrors `window.napplet.keys`.
213
304
  | `unregisterAction(actionId)` | `void` | Remove a previously registered action |
214
305
  | `onAction(actionId, callback)` | `{ close(): void }` | Register a local handler for a bound key (zero-latency, not a wire message) |
215
306
 
307
+ ### `identity`
308
+
309
+ Read-only user queries and class-gated decrypt (NUB-IDENTITY). The identity namespace
310
+ is NOT exported as a top-level SDK object — use `window.napplet.identity.*` directly
311
+ after importing `@napplet/shim`, or use the bare-name helpers below.
312
+
313
+ | Method | Returns | Description |
314
+ |--------|---------|-------------|
315
+ | `window.napplet.identity.getPublicKey()` | `Promise<string>` | Shell-owned user pubkey; never the napplet's own key |
316
+ | `window.napplet.identity.decrypt(event)` | `Promise<{ rumor: Rumor; sender: string }>` | Class-gated decrypt (NIP-04 / NIP-44 / NIP-17 auto-detect); `sender` is shell-authenticated |
317
+
318
+ Bare helper aliases are also re-exported for consumers that prefer functional imports:
319
+
320
+ ```ts
321
+ import { identityGetPublicKey, identityDecrypt } from '@napplet/sdk';
322
+ import type { Rumor } from '@napplet/sdk';
323
+
324
+ const pubkey = await identityGetPublicKey();
325
+ const { rumor, sender } = await identityDecrypt(giftWrapEvent);
326
+ ```
327
+
328
+ `identity.decrypt` is legal only for napplets assigned `class: 1` per NUB-CLASS-1
329
+ (strict baseline posture with `connect-src 'none'`). Other classes receive a
330
+ `class-forbidden` error. See the [@napplet/nub identity section](../nub/README.md#identity-nub-v0290)
331
+ for the 8-code error vocabulary, auto-detect behavior, and the rationale for
332
+ class-gating this API.
333
+
216
334
  ### `shell`
217
335
 
218
336
  Namespaced capability query. Access via `window.napplet.shell.supports()` after importing `@napplet/shim`.
@@ -293,14 +411,19 @@ handlers in shell implementations or protocol-aware code.
293
411
 
294
412
  | Type | NUB Package | Description |
295
413
  |------|-------------|-------------|
296
- | `RelayNubMessage` | `@napplet/nub-relay` | Discriminated union of all relay domain messages |
297
- | `IdentityNubMessage` | `@napplet/nub-identity` | Discriminated union of all identity domain messages |
298
- | `StorageNubMessage` | `@napplet/nub-storage` | Discriminated union of all storage domain messages |
299
- | `IfcNubMessage` | `@napplet/nub-ifc` | Discriminated union of all IFC domain messages |
300
- | `KeysNubMessage` | `@napplet/nub-keys` | Discriminated union of all keys domain messages |
301
- | `MediaNubMessage` | `@napplet/nub-media` | Discriminated union of all media domain messages |
302
- | `NotifyNubMessage` | `@napplet/nub-notify` | Discriminated union of all notify domain messages |
303
- | `ConfigNubMessage` | `@napplet/nub-config` | Discriminated union of all config domain messages |
414
+ | `RelayNubMessage` | `@napplet/nub/relay` | Discriminated union of all relay domain messages |
415
+ | `IdentityNubMessage` | `@napplet/nub/identity` | Discriminated union of all identity domain messages |
416
+ | `StorageNubMessage` | `@napplet/nub/storage` | Discriminated union of all storage domain messages |
417
+ | `IfcNubMessage` | `@napplet/nub/ifc` | Discriminated union of all IFC domain messages |
418
+ | `KeysNubMessage` | `@napplet/nub/keys` | Discriminated union of all keys domain messages |
419
+ | `MediaNubMessage` | `@napplet/nub/media` | Discriminated union of all media domain messages |
420
+ | `NotifyNubMessage` | `@napplet/nub/notify` | Discriminated union of all notify domain messages |
421
+ | `ConfigNubMessage` | `@napplet/nub/config` | Discriminated union of all config domain messages |
422
+ | `ResourceNubMessage` | `@napplet/nub/resource` | Discriminated union of all resource domain messages |
423
+ | `ConnectNubMessage` * | `@napplet/nub/connect` | State-only NUB — no wire messages. The `NappletConnect` runtime state type is the consumer-facing import. |
424
+ | `ClassNubMessage` | `@napplet/nub/class` | Discriminated union of all class domain messages (v1: only `ClassAssignedMessage`) |
425
+
426
+ \* There is no `ConnectNubMessage` type; NUB-CONNECT has no postMessage wire. The consumer-facing import is the `NappletConnect` runtime state interface.
304
427
 
305
428
  Individual message types (e.g., `RelaySubscribeMessage`, `IdentityGetPublicKeyMessage`) are also re-exported from
306
429
  `@napplet/sdk` for fine-grained typing.
@@ -310,8 +433,8 @@ Individual message types (e.g., `RelaySubscribeMessage`, `IdentityGetPublicKeyMe
310
433
  Each NUB domain has a string constant re-exported from its package:
311
434
 
312
435
  ```ts
313
- import { RELAY_DOMAIN, IDENTITY_DOMAIN, STORAGE_DOMAIN, IFC_DOMAIN, THEME_DOMAIN, KEYS_DOMAIN, MEDIA_DOMAIN, NOTIFY_DOMAIN, CONFIG_DOMAIN } from '@napplet/sdk';
314
- // Values: 'relay', 'identity', 'storage', 'ifc', 'theme', 'keys', 'media', 'notify', 'config'
436
+ import { RELAY_DOMAIN, IDENTITY_DOMAIN, STORAGE_DOMAIN, IFC_DOMAIN, THEME_DOMAIN, KEYS_DOMAIN, MEDIA_DOMAIN, NOTIFY_DOMAIN, CONFIG_DOMAIN, RESOURCE_DOMAIN, CONNECT_DOMAIN, CLASS_DOMAIN } from '@napplet/sdk';
437
+ // Values: 'relay', 'identity', 'storage', 'ifc', 'theme', 'keys', 'media', 'notify', 'config', 'resource', 'connect', 'class'
315
438
  ```
316
439
 
317
440
  These constants are re-exported from the individual NUB packages. Use them with the shell capability query
@@ -329,6 +452,22 @@ if (window.napplet.shell.supports('nub:identity')) {
329
452
  if (window.napplet.shell.supports('nub:config')) {
330
453
  // NUB-CONFIG is available -- schema registration and subscribe()
331
454
  }
455
+
456
+ if (window.napplet.shell.supports('nub:resource')) {
457
+ // resource.bytes(url) is available; check per-scheme too:
458
+ if (window.napplet.shell.supports('resource:scheme:blossom')) { /* ... */ }
459
+ }
460
+
461
+ if (window.napplet.shell.supports('nub:connect')) {
462
+ // NUB-CONNECT is available — window.napplet.connect reflects shell grant state
463
+ // Check per-scheme operator policy:
464
+ if (window.napplet.shell.supports('connect:scheme:http')) { /* cleartext http: origins permitted */ }
465
+ if (window.napplet.shell.supports('connect:scheme:ws')) { /* cleartext ws: origins permitted */ }
466
+ }
467
+
468
+ if (window.napplet.shell.supports('nub:class')) {
469
+ // NUB-CLASS is available — window.napplet.class will be populated by class.assigned
470
+ }
332
471
  ```
333
472
 
334
473
  ## Runtime Guard
@@ -355,7 +494,7 @@ This protects against importing `@napplet/sdk` without the side-effect shim impo
355
494
 
356
495
  ```ts
357
496
  import '@napplet/shim'; // required: installs window.napplet
358
- import { relay, ipc, storage, keys, media, notify } from '@napplet/sdk'; // optional: typed API
497
+ import { relay, ifc, storage, keys, media, notify } from '@napplet/sdk'; // optional: typed API
359
498
  ```
360
499
 
361
500
  If you are writing a vanilla napplet with no build step, use `window.napplet.*` directly after importing the shim -- the SDK is not required.
package/dist/index.d.ts CHANGED
@@ -1,24 +1,27 @@
1
- import { NappletGlobal, Subscription, NostrEvent, NostrFilter, EventTemplate } from '@napplet/core';
2
- export { EventTemplate, NUB_DOMAINS, NamespacedCapability, NappletMessage, NostrEvent, NostrFilter, NubDomain, ShellSupports, Subscription } from '@napplet/core';
3
- export { DOMAIN as RELAY_DOMAIN, RelayCloseMessage, RelayClosedMessage, RelayEoseMessage, RelayEventMessage, RelayInboundMessage, RelayMessage, RelayNubMessage, RelayOutboundMessage, RelayPublishEncryptedMessage, RelayPublishEncryptedResultMessage, RelayPublishMessage, RelayPublishResultMessage, RelayQueryMessage, RelayQueryResultMessage, RelaySubscribeMessage, installRelayShim, relayPublish, relayPublishEncrypted, relayQuery, relaySubscribe } from '@napplet/nub-relay';
4
- export { Badge, DOMAIN as IDENTITY_DOMAIN, IdentityGetBadgesMessage, IdentityGetBadgesResultMessage, IdentityGetBlockedMessage, IdentityGetBlockedResultMessage, IdentityGetFollowsMessage, IdentityGetFollowsResultMessage, IdentityGetListMessage, IdentityGetListResultMessage, IdentityGetMutesMessage, IdentityGetMutesResultMessage, IdentityGetProfileMessage, IdentityGetProfileResultMessage, IdentityGetPublicKeyMessage, IdentityGetPublicKeyResultMessage, IdentityGetRelaysMessage, IdentityGetRelaysResultMessage, IdentityGetZapsMessage, IdentityGetZapsResultMessage, IdentityMessage, IdentityNubMessage, RelayPermission as IdentityRelayPermission, IdentityRequestMessage, IdentityResultMessage, ProfileData, ZapReceipt, identityGetBadges, identityGetBlocked, identityGetFollows, identityGetList, identityGetMutes, identityGetProfile, identityGetPublicKey, identityGetRelays, identityGetZaps, installIdentityShim } from '@napplet/nub-identity';
5
- export { DOMAIN as STORAGE_DOMAIN, StorageGetMessage, StorageGetResultMessage, StorageKeysMessage, StorageKeysResultMessage, StorageMessage, StorageNubMessage, StorageRemoveMessage, StorageRemoveResultMessage, StorageRequestMessage, StorageResultMessage, StorageSetMessage, StorageSetResultMessage, installStorageShim, storageGetItem, storageKeys, storageRemoveItem, storageSetItem } from '@napplet/nub-storage';
6
- export { DOMAIN as IFC_DOMAIN, IfcChannelBroadcastMessage, IfcChannelCloseMessage, IfcChannelClosedMessage, IfcChannelEmitMessage, IfcChannelEventMessage, IfcChannelListMessage, IfcChannelListResultMessage, IfcChannelMessage, IfcChannelOpenMessage, IfcChannelOpenResultMessage, IfcEmitMessage, IfcEventMessage, IfcInboundMessage, IfcMessage, IfcNubMessage, IfcOutboundMessage, IfcSubscribeMessage, IfcSubscribeResultMessage, IfcTopicMessage, IfcUnsubscribeMessage, ifcEmit, ifcOn, installIfcShim } from '@napplet/nub-ifc';
7
- export { DOMAIN as THEME_DOMAIN, Theme, ThemeBackground, ThemeChangedMessage, ThemeColors, ThemeFont, ThemeGetMessage, ThemeGetResultMessage, ThemeMessage, ThemeNubMessage, ThemeRequestMessage, ThemeResultMessage } from '@napplet/nub-theme';
8
- export { Action, DOMAIN as KEYS_DOMAIN, KeyBinding, KeysActionMessage, KeysBindingsMessage, KeysForwardMessage, KeysMessage, KeysNubMessage, KeysRegisterActionMessage, KeysRegisterActionResultMessage, KeysRequestMessage, KeysResultMessage, KeysUnregisterActionMessage, RegisterResult, installKeysShim, keysOnAction, keysRegister, keysRegisterAction, keysUnregisterAction } from '@napplet/nub-keys';
9
- export { DOMAIN as MEDIA_DOMAIN, MediaAction, MediaArtwork, MediaCapabilitiesMessage, MediaCommandMessage, MediaControlsMessage, MediaMessage, MediaMetadata, MediaNubMessage, MediaRequestMessage, MediaResultMessage, MediaSessionCreateMessage, MediaSessionCreateResultMessage, MediaSessionDestroyMessage, MediaSessionUpdateMessage, MediaState, MediaStateMessage, installMediaShim, mediaCreateSession, mediaDestroySession, mediaOnCommand, mediaOnControls, mediaReportCapabilities, mediaReportState, mediaUpdateSession } from '@napplet/nub-media';
10
- export { DOMAIN as NOTIFY_DOMAIN, NotificationAction, NotificationChannel, NotificationPriority, NotifyActionMessage, NotifyBadgeMessage, NotifyChannelRegisterMessage, NotifyClickedMessage, NotifyControl, NotifyControlsMessage, NotifyDismissMessage, NotifyDismissedMessage, NotifyMessage, NotifyNubMessage, NotifyPermissionRequestMessage, NotifyPermissionResultMessage, NotifyRequestMessage, NotifyResultMessage, NotifySendMessage, NotifySendResultMessage, installNotifyShim, notifyBadge, notifyDismiss, notifyOnAction, notifyOnClicked, notifyOnControls, notifyOnDismissed, notifyRegisterChannel, notifyRequestPermission, notifySend } from '@napplet/nub-notify';
11
- export { DOMAIN as CONFIG_DOMAIN, ConfigGetMessage, ConfigMessage, ConfigNubMessage, ConfigOpenSettingsMessage, ConfigRegisterSchemaMessage, ConfigRegisterSchemaResultMessage, ConfigRequestMessage, ConfigResultMessage, ConfigSchema, ConfigSchemaErrorCode, ConfigSchemaErrorMessage, ConfigSubscribeMessage, ConfigUnsubscribeMessage, ConfigValues, ConfigValuesMessage, NappletConfigSchema, NappletConfigSchemaExtensions, installConfigShim } from '@napplet/nub-config';
1
+ import { NappletGlobal, Subscription, NostrEvent, Rumor, NostrFilter, EventTemplate } from '@napplet/core';
2
+ export { EventTemplate, NUB_DOMAINS, NamespacedCapability, NappletMessage, NostrEvent, NostrFilter, NubDomain, Rumor, ShellSupports, Subscription, UnsignedEvent } from '@napplet/core';
3
+ export { DOMAIN as RELAY_DOMAIN, RelayCloseMessage, RelayClosedMessage, RelayEoseMessage, RelayEventMessage, RelayInboundMessage, RelayMessage, RelayNubMessage, RelayOutboundMessage, RelayPublishEncryptedMessage, RelayPublishEncryptedResultMessage, RelayPublishMessage, RelayPublishResultMessage, RelayQueryMessage, RelayQueryResultMessage, RelaySubscribeMessage, installRelayShim, relayPublish, relayPublishEncrypted, relayQuery, relaySubscribe } from '@napplet/nub/relay';
4
+ export { Badge, DOMAIN as IDENTITY_DOMAIN, IdentityDecryptErrorCode, IdentityDecryptErrorMessage, IdentityDecryptMessage, IdentityDecryptResultMessage, IdentityGetBadgesMessage, IdentityGetBadgesResultMessage, IdentityGetBlockedMessage, IdentityGetBlockedResultMessage, IdentityGetFollowsMessage, IdentityGetFollowsResultMessage, IdentityGetListMessage, IdentityGetListResultMessage, IdentityGetMutesMessage, IdentityGetMutesResultMessage, IdentityGetProfileMessage, IdentityGetProfileResultMessage, IdentityGetPublicKeyMessage, IdentityGetPublicKeyResultMessage, IdentityGetRelaysMessage, IdentityGetRelaysResultMessage, IdentityGetZapsMessage, IdentityGetZapsResultMessage, IdentityMessage, IdentityNubMessage, RelayPermission as IdentityRelayPermission, IdentityRequestMessage, IdentityResultMessage, ProfileData, ZapReceipt, identityDecrypt, identityGetBadges, identityGetBlocked, identityGetFollows, identityGetList, identityGetMutes, identityGetProfile, identityGetPublicKey, identityGetRelays, identityGetZaps, installIdentityShim } from '@napplet/nub/identity';
5
+ export { DOMAIN as STORAGE_DOMAIN, StorageGetMessage, StorageGetResultMessage, StorageKeysMessage, StorageKeysResultMessage, StorageMessage, StorageNubMessage, StorageRemoveMessage, StorageRemoveResultMessage, StorageRequestMessage, StorageResultMessage, StorageSetMessage, StorageSetResultMessage, installStorageShim, storageGetItem, storageKeys, storageRemoveItem, storageSetItem } from '@napplet/nub/storage';
6
+ export { DOMAIN as IFC_DOMAIN, IfcChannelBroadcastMessage, IfcChannelCloseMessage, IfcChannelClosedMessage, IfcChannelEmitMessage, IfcChannelEventMessage, IfcChannelListMessage, IfcChannelListResultMessage, IfcChannelMessage, IfcChannelOpenMessage, IfcChannelOpenResultMessage, IfcEmitMessage, IfcEventMessage, IfcInboundMessage, IfcMessage, IfcNubMessage, IfcOutboundMessage, IfcSubscribeMessage, IfcSubscribeResultMessage, IfcTopicMessage, IfcUnsubscribeMessage, ifcEmit, ifcOn, installIfcShim } from '@napplet/nub/ifc';
7
+ export { DOMAIN as THEME_DOMAIN, Theme, ThemeBackground, ThemeChangedMessage, ThemeColors, ThemeFont, ThemeGetMessage, ThemeGetResultMessage, ThemeMessage, ThemeNubMessage, ThemeRequestMessage, ThemeResultMessage } from '@napplet/nub/theme';
8
+ export { Action, DOMAIN as KEYS_DOMAIN, KeyBinding, KeysActionMessage, KeysBindingsMessage, KeysForwardMessage, KeysMessage, KeysNubMessage, KeysRegisterActionMessage, KeysRegisterActionResultMessage, KeysRequestMessage, KeysResultMessage, KeysUnregisterActionMessage, RegisterResult, installKeysShim, keysOnAction, keysRegister, keysRegisterAction, keysUnregisterAction } from '@napplet/nub/keys';
9
+ export { DOMAIN as MEDIA_DOMAIN, MediaAction, MediaArtwork, MediaCapabilitiesMessage, MediaCommandMessage, MediaControlsMessage, MediaMessage, MediaMetadata, MediaNubMessage, MediaRequestMessage, MediaResultMessage, MediaSessionCreateMessage, MediaSessionCreateResultMessage, MediaSessionDestroyMessage, MediaSessionUpdateMessage, MediaState, MediaStateMessage, installMediaShim, mediaCreateSession, mediaDestroySession, mediaOnCommand, mediaOnControls, mediaReportCapabilities, mediaReportState, mediaUpdateSession } from '@napplet/nub/media';
10
+ export { DOMAIN as NOTIFY_DOMAIN, NotificationAction, NotificationChannel, NotificationPriority, NotifyActionMessage, NotifyBadgeMessage, NotifyChannelRegisterMessage, NotifyClickedMessage, NotifyControl, NotifyControlsMessage, NotifyDismissMessage, NotifyDismissedMessage, NotifyMessage, NotifyNubMessage, NotifyPermissionRequestMessage, NotifyPermissionResultMessage, NotifyRequestMessage, NotifyResultMessage, NotifySendMessage, NotifySendResultMessage, installNotifyShim, notifyBadge, notifyDismiss, notifyOnAction, notifyOnClicked, notifyOnControls, notifyOnDismissed, notifyRegisterChannel, notifyRequestPermission, notifySend } from '@napplet/nub/notify';
11
+ export { DOMAIN as CONFIG_DOMAIN, ConfigGetMessage, ConfigMessage, ConfigNubMessage, ConfigOpenSettingsMessage, ConfigRegisterSchemaMessage, ConfigRegisterSchemaResultMessage, ConfigRequestMessage, ConfigResultMessage, ConfigSchema, ConfigSchemaErrorCode, ConfigSchemaErrorMessage, ConfigSubscribeMessage, ConfigUnsubscribeMessage, ConfigValues, ConfigValuesMessage, NappletConfigSchema, NappletConfigSchemaExtensions, installConfigShim } from '@napplet/nub/config';
12
+ export { DOMAIN as RESOURCE_DOMAIN, ResourceBytesErrorMessage, ResourceBytesMessage, ResourceBytesResultMessage, ResourceCancelMessage, ResourceErrorCode, ResourceMessage, ResourceNubMessage, ResourceRequestMessage, ResourceResultMessage, ResourceScheme, ResourceSidecarEntry, installResourceShim, resourceBytes, resourceBytesAsObjectURL } from '@napplet/nub/resource';
13
+ export { DOMAIN as CONNECT_DOMAIN, NappletConnect, connectGranted, connectOrigins, installConnectShim, normalizeConnectOrigin } from '@napplet/nub/connect';
14
+ export { DOMAIN as CLASS_DOMAIN, ClassAssignedMessage, ClassMessage, ClassNubMessage, NappletClass, getClass, installClassShim } from '@napplet/nub/class';
12
15
 
13
16
  /**
14
17
  * @napplet/sdk -- Typed named exports wrapping window.napplet.
15
18
  *
16
- * Provides `relay`, `ipc`, `storage`, and `keys` objects that delegate
19
+ * Provides `relay`, `ifc`, `storage`, and `keys` objects that delegate
17
20
  * to `window.napplet.*` at call time. Developers using a bundler can import
18
21
  * individual namespaces without depending on the shim's side-effect install:
19
22
  *
20
23
  * ```ts
21
- * import { relay, ipc } from '@napplet/sdk';
24
+ * import { relay, ifc } from '@napplet/sdk';
22
25
  * ```
23
26
  *
24
27
  * The shim must still be imported somewhere in the application to install
@@ -26,8 +29,8 @@ export { DOMAIN as CONFIG_DOMAIN, ConfigGetMessage, ConfigMessage, ConfigNubMess
26
29
  *
27
30
  * Domain-specific SDK helpers are also available directly from NUB packages:
28
31
  * ```ts
29
- * import { relaySubscribe } from '@napplet/nub-relay';
30
- * import { storageGetItem } from '@napplet/nub-storage';
32
+ * import { relaySubscribe } from '@napplet/nub/relay';
33
+ * import { storageGetItem } from '@napplet/nub/storage';
31
34
  * ```
32
35
  *
33
36
  * @packageDocumentation
@@ -93,29 +96,29 @@ declare const relay: {
93
96
  query(filters: NostrFilter | NostrFilter[]): Promise<NostrEvent[]>;
94
97
  };
95
98
  /**
96
- * Inter-napplet pubsub: broadcast and receive IPC-PEER events through the shell.
99
+ * Inter-frame pubsub: broadcast and receive IFC-PEER events through the shell.
97
100
  *
98
101
  * @example
99
102
  * ```ts
100
- * import { ipc } from '@napplet/sdk';
103
+ * import { ifc } from '@napplet/sdk';
101
104
  *
102
- * ipc.emit('profile:open', [], JSON.stringify({ pubkey: '...' }));
105
+ * ifc.emit('profile:open', [], JSON.stringify({ pubkey: '...' }));
103
106
  *
104
- * const sub = ipc.on('profile:open', (payload) => {
107
+ * const sub = ifc.on('profile:open', (payload) => {
105
108
  * console.log('Profile requested:', payload);
106
109
  * });
107
110
  * ```
108
111
  */
109
- declare const ipc: {
112
+ declare const ifc: {
110
113
  /**
111
- * Broadcast an IPC-PEER event to other napplets via the shell.
114
+ * Broadcast an IFC-PEER event to other napplets via the shell.
112
115
  * @param topic The 't' tag value (e.g., 'profile:open')
113
116
  * @param extraTags Additional NIP-01 tags beyond the 't' tag (default: [])
114
117
  * @param content Event content (default: empty string)
115
118
  */
116
119
  emit(topic: string, extraTags?: string[][], content?: string): void;
117
120
  /**
118
- * Subscribe to IPC-PEER events on a specific topic.
121
+ * Subscribe to IFC-PEER events on a specific topic.
119
122
  * @param topic The 't' tag value to listen for
120
123
  * @param callback Called with `(payload, event)` for each matching event
121
124
  * @returns A Subscription handle with a `close()` method
@@ -493,6 +496,19 @@ declare const identity: {
493
496
  thumbs?: string[];
494
497
  awardedBy: string;
495
498
  }[]>;
499
+ /**
500
+ * Decrypt a received Nostr event (NIP-04 / direct NIP-44 / NIP-17 gift-wrap).
501
+ *
502
+ * Shape is auto-detected by the shell; napplets do NOT select encryption mode.
503
+ * Only legal for napplets assigned class: 1 per NUB-CLASS-1 (shell-enforced).
504
+ *
505
+ * @param event The received event (outer wrap for NIP-17, kind-4 for NIP-04, etc.)
506
+ * @returns Promise resolving to { rumor, sender }; rejects with Error on failure.
507
+ */
508
+ decrypt(event: NostrEvent): Promise<{
509
+ rumor: Rumor;
510
+ sender: string;
511
+ }>;
496
512
  };
497
513
  /**
498
514
  * Per-napplet declarative configuration (NUB-CONFIG): register a schema,
@@ -558,5 +574,38 @@ declare const config: {
558
574
  */
559
575
  readonly schema: Record<string, unknown> | null;
560
576
  };
577
+ /**
578
+ * Browser-enforced byte-fetching primitive: napplets request bytes by URL,
579
+ * shell fetches and returns a Blob. URL space is scheme-pluggable
580
+ * (`data:`, `https:`, `blossom:`, `nostr:`).
581
+ *
582
+ * @example
583
+ * ```ts
584
+ * import { resource } from '@napplet/sdk';
585
+ *
586
+ * const blob = await resource.bytes('https://example.com/avatar.png');
587
+ * const handle = resource.bytesAsObjectURL('blossom:abc123...');
588
+ * imgEl.src = handle.url;
589
+ * imgEl.onload = () => handle.revoke();
590
+ * ```
591
+ */
592
+ declare const resource: {
593
+ /**
594
+ * Fetch bytes for a URL through the shell's resource pipeline.
595
+ * @param url URL identifying the resource (any registered scheme).
596
+ * @returns Promise resolving to the fetched bytes as a Blob.
597
+ */
598
+ bytes(url: string): Promise<Blob>;
599
+ /**
600
+ * Fetch bytes and return a managed object URL handle.
601
+ * Call `revoke()` to release the underlying Blob URL.
602
+ * @param url URL identifying the resource.
603
+ * @returns Synchronous handle `{ url, revoke }`.
604
+ */
605
+ bytesAsObjectURL(url: string): {
606
+ url: string;
607
+ revoke: () => void;
608
+ };
609
+ };
561
610
 
562
- export { config, identity, ipc, keys, media, notify, relay, storage };
611
+ export { config, identity, ifc, keys, media, notify, relay, resource, storage };
package/dist/index.js CHANGED
@@ -1,29 +1,38 @@
1
1
  // src/index.ts
2
2
  import { NUB_DOMAINS } from "@napplet/core";
3
- import { DOMAIN } from "@napplet/nub-relay";
4
- import { DOMAIN as DOMAIN2 } from "@napplet/nub-identity";
5
- import { DOMAIN as DOMAIN3 } from "@napplet/nub-storage";
6
- import { DOMAIN as DOMAIN4 } from "@napplet/nub-ifc";
7
- import { DOMAIN as DOMAIN5 } from "@napplet/nub-theme";
8
- import { DOMAIN as DOMAIN6 } from "@napplet/nub-keys";
9
- import { DOMAIN as DOMAIN7 } from "@napplet/nub-media";
10
- import { DOMAIN as DOMAIN8 } from "@napplet/nub-notify";
11
- import { DOMAIN as DOMAIN9 } from "@napplet/nub-config";
12
- import { installRelayShim } from "@napplet/nub-relay";
13
- import { installIdentityShim } from "@napplet/nub-identity";
14
- import { installStorageShim } from "@napplet/nub-storage";
15
- import { installIfcShim } from "@napplet/nub-ifc";
16
- import { installKeysShim } from "@napplet/nub-keys";
17
- import { installMediaShim } from "@napplet/nub-media";
18
- import { installNotifyShim } from "@napplet/nub-notify";
19
- import { installConfigShim } from "@napplet/nub-config";
20
- import { relaySubscribe, relayPublish, relayPublishEncrypted, relayQuery } from "@napplet/nub-relay";
21
- import { identityGetPublicKey, identityGetRelays, identityGetProfile, identityGetFollows, identityGetList, identityGetZaps, identityGetMutes, identityGetBlocked, identityGetBadges } from "@napplet/nub-identity";
22
- import { storageGetItem, storageSetItem, storageRemoveItem, storageKeys } from "@napplet/nub-storage";
23
- import { ifcEmit, ifcOn } from "@napplet/nub-ifc";
24
- import { keysRegisterAction, keysUnregisterAction, keysOnAction, keysRegister } from "@napplet/nub-keys";
25
- import { mediaCreateSession, mediaUpdateSession, mediaDestroySession, mediaReportState, mediaReportCapabilities, mediaOnCommand, mediaOnControls } from "@napplet/nub-media";
26
- import { notifySend, notifyDismiss, notifyBadge, notifyRegisterChannel, notifyRequestPermission, notifyOnAction, notifyOnClicked, notifyOnDismissed, notifyOnControls } from "@napplet/nub-notify";
3
+ import { DOMAIN } from "@napplet/nub/relay";
4
+ import { DOMAIN as DOMAIN2 } from "@napplet/nub/identity";
5
+ import { DOMAIN as DOMAIN3 } from "@napplet/nub/storage";
6
+ import { DOMAIN as DOMAIN4 } from "@napplet/nub/ifc";
7
+ import { DOMAIN as DOMAIN5 } from "@napplet/nub/theme";
8
+ import { DOMAIN as DOMAIN6 } from "@napplet/nub/keys";
9
+ import { DOMAIN as DOMAIN7 } from "@napplet/nub/media";
10
+ import { DOMAIN as DOMAIN8 } from "@napplet/nub/notify";
11
+ import { DOMAIN as DOMAIN9 } from "@napplet/nub/config";
12
+ import { DOMAIN as DOMAIN10 } from "@napplet/nub/resource";
13
+ import { DOMAIN as DOMAIN11 } from "@napplet/nub/connect";
14
+ import { DOMAIN as DOMAIN12 } from "@napplet/nub/class";
15
+ import { installRelayShim } from "@napplet/nub/relay";
16
+ import { installIdentityShim } from "@napplet/nub/identity";
17
+ import { installStorageShim } from "@napplet/nub/storage";
18
+ import { installIfcShim } from "@napplet/nub/ifc";
19
+ import { installKeysShim } from "@napplet/nub/keys";
20
+ import { installMediaShim } from "@napplet/nub/media";
21
+ import { installNotifyShim } from "@napplet/nub/notify";
22
+ import { installConfigShim } from "@napplet/nub/config";
23
+ import { installResourceShim } from "@napplet/nub/resource";
24
+ import { installConnectShim } from "@napplet/nub/connect";
25
+ import { installClassShim } from "@napplet/nub/class";
26
+ import { relaySubscribe, relayPublish, relayPublishEncrypted, relayQuery } from "@napplet/nub/relay";
27
+ import { identityGetPublicKey, identityGetRelays, identityGetProfile, identityGetFollows, identityGetList, identityGetZaps, identityGetMutes, identityGetBlocked, identityGetBadges, identityDecrypt } from "@napplet/nub/identity";
28
+ import { storageGetItem, storageSetItem, storageRemoveItem, storageKeys } from "@napplet/nub/storage";
29
+ import { ifcEmit, ifcOn } from "@napplet/nub/ifc";
30
+ import { keysRegisterAction, keysUnregisterAction, keysOnAction, keysRegister } from "@napplet/nub/keys";
31
+ import { mediaCreateSession, mediaUpdateSession, mediaDestroySession, mediaReportState, mediaReportCapabilities, mediaOnCommand, mediaOnControls } from "@napplet/nub/media";
32
+ import { notifySend, notifyDismiss, notifyBadge, notifyRegisterChannel, notifyRequestPermission, notifyOnAction, notifyOnClicked, notifyOnDismissed, notifyOnControls } from "@napplet/nub/notify";
33
+ import { resourceBytes, resourceBytesAsObjectURL } from "@napplet/nub/resource";
34
+ import { connectGranted, connectOrigins, normalizeConnectOrigin } from "@napplet/nub/connect";
35
+ import { getClass } from "@napplet/nub/class";
27
36
  function requireNapplet() {
28
37
  const w = window;
29
38
  if (!w.napplet) {
@@ -71,24 +80,24 @@ var relay = {
71
80
  return requireNapplet().relay.query(filters);
72
81
  }
73
82
  };
74
- var ipc = {
83
+ var ifc = {
75
84
  /**
76
- * Broadcast an IPC-PEER event to other napplets via the shell.
85
+ * Broadcast an IFC-PEER event to other napplets via the shell.
77
86
  * @param topic The 't' tag value (e.g., 'profile:open')
78
87
  * @param extraTags Additional NIP-01 tags beyond the 't' tag (default: [])
79
88
  * @param content Event content (default: empty string)
80
89
  */
81
90
  emit(topic, extraTags, content) {
82
- requireNapplet().ipc.emit(topic, extraTags, content);
91
+ requireNapplet().ifc.emit(topic, extraTags, content);
83
92
  },
84
93
  /**
85
- * Subscribe to IPC-PEER events on a specific topic.
94
+ * Subscribe to IFC-PEER events on a specific topic.
86
95
  * @param topic The 't' tag value to listen for
87
96
  * @param callback Called with `(payload, event)` for each matching event
88
97
  * @returns A Subscription handle with a `close()` method
89
98
  */
90
99
  on(topic, callback) {
91
- return requireNapplet().ipc.on(topic, callback);
100
+ return requireNapplet().ifc.on(topic, callback);
92
101
  }
93
102
  };
94
103
  var storage = {
@@ -377,6 +386,18 @@ var identity = {
377
386
  */
378
387
  getBadges() {
379
388
  return requireNapplet().identity.getBadges();
389
+ },
390
+ /**
391
+ * Decrypt a received Nostr event (NIP-04 / direct NIP-44 / NIP-17 gift-wrap).
392
+ *
393
+ * Shape is auto-detected by the shell; napplets do NOT select encryption mode.
394
+ * Only legal for napplets assigned class: 1 per NUB-CLASS-1 (shell-enforced).
395
+ *
396
+ * @param event The received event (outer wrap for NIP-17, kind-4 for NIP-04, etc.)
397
+ * @returns Promise resolving to { rumor, sender }; rejects with Error on failure.
398
+ */
399
+ decrypt(event) {
400
+ return requireNapplet().identity.decrypt(event);
380
401
  }
381
402
  };
382
403
  var config = {
@@ -431,8 +452,29 @@ var config = {
431
452
  return requireNapplet().config.schema;
432
453
  }
433
454
  };
455
+ var resource = {
456
+ /**
457
+ * Fetch bytes for a URL through the shell's resource pipeline.
458
+ * @param url URL identifying the resource (any registered scheme).
459
+ * @returns Promise resolving to the fetched bytes as a Blob.
460
+ */
461
+ bytes(url) {
462
+ return requireNapplet().resource.bytes(url);
463
+ },
464
+ /**
465
+ * Fetch bytes and return a managed object URL handle.
466
+ * Call `revoke()` to release the underlying Blob URL.
467
+ * @param url URL identifying the resource.
468
+ * @returns Synchronous handle `{ url, revoke }`.
469
+ */
470
+ bytesAsObjectURL(url) {
471
+ return requireNapplet().resource.bytesAsObjectURL(url);
472
+ }
473
+ };
434
474
  export {
475
+ DOMAIN12 as CLASS_DOMAIN,
435
476
  DOMAIN9 as CONFIG_DOMAIN,
477
+ DOMAIN11 as CONNECT_DOMAIN,
436
478
  DOMAIN2 as IDENTITY_DOMAIN,
437
479
  DOMAIN4 as IFC_DOMAIN,
438
480
  DOMAIN6 as KEYS_DOMAIN,
@@ -440,10 +482,15 @@ export {
440
482
  DOMAIN8 as NOTIFY_DOMAIN,
441
483
  NUB_DOMAINS,
442
484
  DOMAIN as RELAY_DOMAIN,
485
+ DOMAIN10 as RESOURCE_DOMAIN,
443
486
  DOMAIN3 as STORAGE_DOMAIN,
444
487
  DOMAIN5 as THEME_DOMAIN,
445
488
  config,
489
+ connectGranted,
490
+ connectOrigins,
491
+ getClass,
446
492
  identity,
493
+ identityDecrypt,
447
494
  identityGetBadges,
448
495
  identityGetBlocked,
449
496
  identityGetFollows,
@@ -453,17 +500,20 @@ export {
453
500
  identityGetPublicKey,
454
501
  identityGetRelays,
455
502
  identityGetZaps,
503
+ ifc,
456
504
  ifcEmit,
457
505
  ifcOn,
506
+ installClassShim,
458
507
  installConfigShim,
508
+ installConnectShim,
459
509
  installIdentityShim,
460
510
  installIfcShim,
461
511
  installKeysShim,
462
512
  installMediaShim,
463
513
  installNotifyShim,
464
514
  installRelayShim,
515
+ installResourceShim,
465
516
  installStorageShim,
466
- ipc,
467
517
  keys,
468
518
  keysOnAction,
469
519
  keysRegister,
@@ -477,6 +527,7 @@ export {
477
527
  mediaReportCapabilities,
478
528
  mediaReportState,
479
529
  mediaUpdateSession,
530
+ normalizeConnectOrigin,
480
531
  notify,
481
532
  notifyBadge,
482
533
  notifyDismiss,
@@ -492,6 +543,9 @@ export {
492
543
  relayPublishEncrypted,
493
544
  relayQuery,
494
545
  relaySubscribe,
546
+ resource,
547
+ resourceBytes,
548
+ resourceBytesAsObjectURL,
495
549
  storage,
496
550
  storageGetItem,
497
551
  storageKeys,
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * @napplet/sdk -- Typed named exports wrapping window.napplet.\n *\n * Provides `relay`, `ipc`, `storage`, and `keys` objects that delegate\n * to `window.napplet.*` at call time. Developers using a bundler can import\n * individual namespaces without depending on the shim's side-effect install:\n *\n * ```ts\n * import { relay, ipc } from '@napplet/sdk';\n * ```\n *\n * The shim must still be imported somewhere in the application to install\n * the `window.napplet` global. The SDK only wraps it -- it does not install it.\n *\n * Domain-specific SDK helpers are also available directly from NUB packages:\n * ```ts\n * import { relaySubscribe } from '@napplet/nub-relay';\n * import { storageGetItem } from '@napplet/nub-storage';\n * ```\n *\n * @packageDocumentation\n */\n\nimport type {\n NappletGlobal,\n NostrEvent,\n NostrFilter,\n Subscription,\n EventTemplate,\n} from '@napplet/core';\n\n// ─── Global type augmentation ────────────────────────────────────────────────\n// Provides window.napplet autocompletion for TypeScript consumers who import\n// only the SDK (not the shim). Both shim and SDK reference NappletGlobal from\n// @napplet/core -- no duplication.\n\ndeclare global {\n interface Window {\n napplet: NappletGlobal;\n }\n}\n\n// ─── Runtime guard ──────────────────────────────────────────────────────────\n\n/**\n * Retrieve the `window.napplet` global, throwing a clear error if it is absent.\n *\n * Every SDK method calls this at invocation time -- not at module load time --\n * so the shim can be imported in any order relative to the SDK.\n */\nfunction requireNapplet(): NappletGlobal {\n const w = window as Window & { napplet?: NappletGlobal };\n if (!w.napplet) {\n throw new Error('window.napplet not installed -- import @napplet/shim first');\n }\n return w.napplet;\n}\n\n// ─── Relay namespace ────────────────────────────────────────────────────────\n\n/**\n * NIP-01 relay operations: subscribe to events, publish events, one-shot queries.\n *\n * Each method delegates to `window.napplet.relay.*` at call time, which in turn\n * routes through the shell's relay pool via postMessage.\n *\n * @example\n * ```ts\n * import { relay } from '@napplet/sdk';\n *\n * const sub = relay.subscribe(\n * { kinds: [1], limit: 10 },\n * (event) => console.log(event),\n * () => console.log('EOSE'),\n * );\n * ```\n */\nexport const relay = {\n /**\n * Open a live NIP-01 subscription through the shell's relay pool.\n * @param filters One or more NIP-01 subscription filters\n * @param onEvent Called for each matching event\n * @param onEose Called when the shell signals end of stored events (EOSE)\n * @param options Optional: `{ relay, group }` for NIP-29 scoped relay subscriptions\n * @returns A Subscription handle with a `close()` method\n */\n subscribe(\n filters: NostrFilter | NostrFilter[],\n onEvent: (event: NostrEvent) => void,\n onEose: () => void,\n options?: { relay?: string; group?: string },\n ): Subscription {\n return requireNapplet().relay.subscribe(filters, onEvent, onEose, options);\n },\n\n /**\n * Sign and publish a Nostr event through the shell.\n * @param template Unsigned event template\n * @param options Optional: `{ relay: true }` to publish via scoped relay\n * @returns The signed NostrEvent after successful publication\n */\n publish(\n template: EventTemplate,\n options?: { relay?: boolean },\n ): Promise<NostrEvent> {\n return requireNapplet().relay.publish(template, options);\n },\n\n /**\n * Publish an encrypted Nostr event through the shell.\n * @param template Unsigned event template\n * @param recipient Hex-encoded recipient public key\n * @param encryption Encryption scheme: 'nip44' (default) or 'nip04'\n * @returns The signed encrypted NostrEvent after successful publication\n */\n publishEncrypted(\n template: EventTemplate,\n recipient: string,\n encryption: 'nip44' | 'nip04' = 'nip44',\n ): Promise<NostrEvent> {\n return requireNapplet().relay.publishEncrypted(template, recipient, encryption);\n },\n\n /**\n * One-shot query: subscribe, collect events until EOSE, then resolve.\n * @param filters NIP-01 subscription filters\n * @returns Promise resolving to array of matching NostrEvent objects\n */\n query(filters: NostrFilter | NostrFilter[]): Promise<NostrEvent[]> {\n return requireNapplet().relay.query(filters);\n },\n};\n\n// ─── IPC namespace ──────────────────────────────────────────────────────────\n\n/**\n * Inter-napplet pubsub: broadcast and receive IPC-PEER events through the shell.\n *\n * @example\n * ```ts\n * import { ipc } from '@napplet/sdk';\n *\n * ipc.emit('profile:open', [], JSON.stringify({ pubkey: '...' }));\n *\n * const sub = ipc.on('profile:open', (payload) => {\n * console.log('Profile requested:', payload);\n * });\n * ```\n */\nexport const ipc = {\n /**\n * Broadcast an IPC-PEER event to other napplets via the shell.\n * @param topic The 't' tag value (e.g., 'profile:open')\n * @param extraTags Additional NIP-01 tags beyond the 't' tag (default: [])\n * @param content Event content (default: empty string)\n */\n emit(topic: string, extraTags?: string[][], content?: string): void {\n requireNapplet().ipc.emit(topic, extraTags, content);\n },\n\n /**\n * Subscribe to IPC-PEER events on a specific topic.\n * @param topic The 't' tag value to listen for\n * @param callback Called with `(payload, event)` for each matching event\n * @returns A Subscription handle with a `close()` method\n */\n on(\n topic: string,\n callback: (payload: unknown, event: NostrEvent) => void,\n ): Subscription {\n return requireNapplet().ipc.on(topic, callback);\n },\n};\n\n// ─── Services namespace ─────────────────────────────────────────────────────\n\n// ─── Storage namespace ──────────────────────────────────────────────────────\n\n/**\n * Napplet-scoped storage: async localStorage-like API proxied through the shell.\n * Each napplet's storage is isolated by identity.\n *\n * @example\n * ```ts\n * import { storage } from '@napplet/sdk';\n *\n * await storage.setItem('theme', 'dark');\n * const theme = await storage.getItem('theme'); // 'dark'\n * ```\n */\nexport const storage = {\n /**\n * Retrieve a stored value by key. Returns null if the key does not exist.\n * @param key The storage key\n * @returns The stored string value, or null if not found\n */\n getItem(key: string): Promise<string | null> {\n return requireNapplet().storage.getItem(key);\n },\n\n /**\n * Store a key-value pair.\n * @param key The storage key\n * @param value The string value to store\n */\n setItem(key: string, value: string): Promise<void> {\n return requireNapplet().storage.setItem(key, value);\n },\n\n /**\n * Remove a stored key.\n * @param key The storage key to remove\n */\n removeItem(key: string): Promise<void> {\n return requireNapplet().storage.removeItem(key);\n },\n\n /**\n * List all keys stored by this napplet.\n * @returns Array of storage key strings\n */\n keys(): Promise<string[]> {\n return requireNapplet().storage.keys();\n },\n};\n\n// ─── Media namespace ───────────────────────────────────────────────────────\n\n/**\n * Media session control: create sessions, report state and metadata,\n * declare capabilities, receive commands from the shell.\n *\n * @example\n * ```ts\n * import { media } from '@napplet/sdk';\n *\n * const { sessionId } = await media.createSession({\n * title: 'My Song', artist: 'The Artist',\n * });\n *\n * media.reportState(sessionId, { status: 'playing', position: 42.5 });\n * ```\n */\nexport const media = {\n /**\n * Create a new media session with the shell.\n * @param metadata Optional initial metadata\n * @returns The confirmed session result with sessionId\n */\n createSession(metadata?: {\n title?: string;\n artist?: string;\n album?: string;\n artwork?: { url?: string; hash?: string };\n duration?: number;\n mediaType?: 'audio' | 'video';\n }): Promise<{ sessionId: string }> {\n return requireNapplet().media.createSession(metadata);\n },\n\n /**\n * Update metadata for an existing session.\n * @param sessionId The session to update\n * @param metadata Partial metadata fields to update\n */\n updateSession(sessionId: string, metadata: {\n title?: string;\n artist?: string;\n album?: string;\n artwork?: { url?: string; hash?: string };\n duration?: number;\n mediaType?: 'audio' | 'video';\n }): void {\n requireNapplet().media.updateSession(sessionId, metadata);\n },\n\n /**\n * Destroy a media session.\n * @param sessionId The session to destroy\n */\n destroySession(sessionId: string): void {\n requireNapplet().media.destroySession(sessionId);\n },\n\n /**\n * Report current playback state for a session.\n * @param sessionId The session to report state for\n * @param state Current playback state\n */\n reportState(sessionId: string, state: {\n status: 'playing' | 'paused' | 'stopped' | 'buffering';\n position?: number;\n duration?: number;\n volume?: number;\n }): void {\n requireNapplet().media.reportState(sessionId, state);\n },\n\n /**\n * Declare which media actions the session currently supports.\n * @param sessionId The session to update capabilities for\n * @param actions Currently supported actions\n */\n reportCapabilities(sessionId: string, actions: ('play' | 'pause' | 'stop' | 'next' | 'prev' | 'seek' | 'volume')[]): void {\n requireNapplet().media.reportCapabilities(sessionId, actions);\n },\n\n /**\n * Listen for media commands from the shell.\n * @param sessionId The session to listen for commands on\n * @param callback Called with (action, value?) when a command is received\n * @returns A Subscription with `close()` to stop listening\n */\n onCommand(\n sessionId: string,\n callback: (action: 'play' | 'pause' | 'stop' | 'next' | 'prev' | 'seek' | 'volume', value?: number) => void,\n ): Subscription {\n return requireNapplet().media.onCommand(sessionId, callback);\n },\n\n /**\n * Listen for the shell's media control list.\n * @param sessionId The session to associate controls with\n * @param callback Called with the shell's supported controls\n * @returns A Subscription with `close()` to stop listening\n */\n onControls(\n sessionId: string,\n callback: (controls: ('play' | 'pause' | 'stop' | 'next' | 'prev' | 'seek' | 'volume')[]) => void,\n ): Subscription {\n return requireNapplet().media.onControls(sessionId, callback);\n },\n};\n\n// ─── Notify namespace ──────────────────────────────────────────────────────\n\n/**\n * Shell-rendered notifications: send notifications, set badge counts,\n * register channels, request permission, listen for user interaction.\n *\n * @example\n * ```ts\n * import { notify } from '@napplet/sdk';\n *\n * const { notificationId } = await notify.send({\n * title: 'New message', body: 'Alice: hey!',\n * });\n *\n * notify.badge(3);\n * ```\n */\nexport const notify = {\n /**\n * Send a notification to the shell.\n * @param notification Notification payload (title required)\n * @returns The shell-assigned notificationId\n */\n send(notification: {\n title: string;\n body?: string;\n icon?: string;\n actions?: { id: string; label: string }[];\n channel?: string;\n priority?: 'low' | 'normal' | 'high' | 'urgent';\n }): Promise<{ notificationId: string }> {\n return requireNapplet().notify.send(notification);\n },\n\n /**\n * Dismiss a notification by ID.\n * @param notificationId The notification to dismiss\n */\n dismiss(notificationId: string): void {\n requireNapplet().notify.dismiss(notificationId);\n },\n\n /**\n * Set the badge count for this napplet. Pass 0 to clear.\n * @param count Badge count\n */\n badge(count: number): void {\n requireNapplet().notify.badge(count);\n },\n\n /**\n * Register a notification channel.\n * @param channel Channel definition\n */\n registerChannel(channel: {\n channelId: string;\n label: string;\n description?: string;\n defaultPriority?: 'low' | 'normal' | 'high' | 'urgent';\n }): void {\n requireNapplet().notify.registerChannel(channel);\n },\n\n /**\n * Request permission to send notifications.\n * @param channel Optional channel to request permission for\n * @returns Whether permission was granted\n */\n requestPermission(channel?: string): Promise<{ granted: boolean }> {\n return requireNapplet().notify.requestPermission(channel);\n },\n\n /**\n * Listen for action button clicks on notifications.\n * @param callback Called with (notificationId, actionId)\n * @returns A Subscription with `close()` to stop listening\n */\n onAction(\n callback: (notificationId: string, actionId: string) => void,\n ): Subscription {\n return requireNapplet().notify.onAction(callback);\n },\n\n /**\n * Listen for notification body clicks.\n * @param callback Called with (notificationId)\n * @returns A Subscription with `close()` to stop listening\n */\n onClicked(\n callback: (notificationId: string) => void,\n ): Subscription {\n return requireNapplet().notify.onClicked(callback);\n },\n\n /**\n * Listen for notification dismissals.\n * @param callback Called with (notificationId, reason?)\n * @returns A Subscription with `close()` to stop listening\n */\n onDismissed(\n callback: (notificationId: string, reason?: string) => void,\n ): Subscription {\n return requireNapplet().notify.onDismissed(callback);\n },\n\n /**\n * Listen for the shell's notification capability list.\n * @param callback Called with supported controls\n * @returns A Subscription with `close()` to stop listening\n */\n onControls(\n callback: (controls: ('toasts' | 'badges' | 'actions' | 'channels' | 'system')[]) => void,\n ): Subscription {\n return requireNapplet().notify.onControls(callback);\n },\n};\n\n// ─── Keys namespace ────────────────────────────────────────────────────────\n\n/**\n * Keyboard forwarding and action keybindings: register named actions the shell\n * can bind to keys, listen for shell-triggered actions locally.\n *\n * @example\n * ```ts\n * import { keys } from '@napplet/sdk';\n *\n * const result = await keys.registerAction({\n * id: 'editor.save',\n * label: 'Save',\n * defaultKey: 'Ctrl+S',\n * });\n *\n * const sub = keys.onAction('editor.save', () => {\n * console.log('Save triggered!');\n * });\n * ```\n */\nexport const keys = {\n /**\n * Declare a named action that the shell can bind to a key.\n * @param action The action to register (id, label, optional defaultKey)\n * @returns The assigned binding, if any\n */\n registerAction(action: {\n id: string;\n label: string;\n defaultKey?: string;\n }): Promise<{ actionId: string; binding?: string }> {\n return requireNapplet().keys.registerAction(action);\n },\n\n /**\n * Remove a previously registered action.\n * @param actionId The action to unregister\n */\n unregisterAction(actionId: string): void {\n requireNapplet().keys.unregisterAction(actionId);\n },\n\n /**\n * Register a local handler for when a bound key is pressed.\n * @param actionId The action to listen for\n * @param callback Called when the action is triggered\n * @returns A Subscription with `close()` to stop listening\n */\n onAction(actionId: string, callback: () => void): Subscription {\n return requireNapplet().keys.onAction(actionId, callback);\n },\n\n /**\n * Convenience: register a named action AND wire a local handler in one call.\n * Returns a handle whose `close()` both unregisters the action and removes\n * the onAction listener.\n *\n * @param action The action to register (id, label, optional defaultKey)\n * @param handler Called when the shell triggers this action\n * @returns The assigned binding plus a `close()` teardown function\n *\n * @example\n * ```ts\n * import { keys } from '@napplet/sdk';\n *\n * const handle = await keys.register(\n * { id: 'editor.save', label: 'Save', defaultKey: 'Ctrl+S' },\n * () => saveDocument(),\n * );\n *\n * // Later, tear down both registration and listener:\n * handle.close();\n * ```\n */\n async register(\n action: { id: string; label: string; defaultKey?: string },\n handler: () => void,\n ): Promise<{ actionId: string; binding?: string; close: () => void }> {\n const n = requireNapplet();\n const result = await n.keys.registerAction(action);\n const sub = n.keys.onAction(action.id, handler);\n return {\n ...result,\n close() {\n sub.close();\n n.keys.unregisterAction(action.id);\n },\n };\n },\n};\n\n// ─── Identity namespace ───────────────────────────────────────────────────\n\n/**\n * Read-only user identity queries: public key, profile, follows, relays,\n * lists, zaps, mutes, blocked, badges.\n *\n * @example\n * ```ts\n * import { identity } from '@napplet/sdk';\n *\n * const pubkey = await identity.getPublicKey();\n * const profile = await identity.getProfile();\n * const follows = await identity.getFollows();\n * ```\n */\nexport const identity = {\n /**\n * Get the user's hex-encoded public key. Always succeeds.\n * @returns Hex-encoded public key string\n */\n getPublicKey(): Promise<string> {\n return requireNapplet().identity.getPublicKey();\n },\n\n /**\n * Get the user's relay list (NIP-65).\n * @returns Record mapping relay URLs to read/write permissions\n */\n getRelays(): Promise<Record<string, { read: boolean; write: boolean }>> {\n return requireNapplet().identity.getRelays();\n },\n\n /**\n * Get the user's profile metadata (kind 0).\n * @returns Profile data, or null if not found\n */\n getProfile(): Promise<{\n name?: string;\n displayName?: string;\n about?: string;\n picture?: string;\n banner?: string;\n nip05?: string;\n lud16?: string;\n website?: string;\n } | null> {\n return requireNapplet().identity.getProfile();\n },\n\n /**\n * Get the user's follow list (kind 3 contact list).\n * @returns Array of hex-encoded public keys\n */\n getFollows(): Promise<string[]> {\n return requireNapplet().identity.getFollows();\n },\n\n /**\n * Get entries from a user's categorized list.\n * @param listType List category (e.g., \"bookmarks\", \"interests\", \"pins\")\n * @returns Array of list entry values\n */\n getList(listType: string): Promise<string[]> {\n return requireNapplet().identity.getList(listType);\n },\n\n /**\n * Get zap receipts sent to the user.\n * @returns Array of zap receipt objects\n */\n getZaps(): Promise<{\n eventId: string;\n sender: string;\n amount: number;\n content?: string;\n }[]> {\n return requireNapplet().identity.getZaps();\n },\n\n /**\n * Get the user's mute list (kind 10000).\n * @returns Array of hex-encoded muted public keys\n */\n getMutes(): Promise<string[]> {\n return requireNapplet().identity.getMutes();\n },\n\n /**\n * Get the user's block list.\n * @returns Array of hex-encoded blocked public keys\n */\n getBlocked(): Promise<string[]> {\n return requireNapplet().identity.getBlocked();\n },\n\n /**\n * Get badges awarded to the user (NIP-58).\n * @returns Array of badge objects\n */\n getBadges(): Promise<{\n id: string;\n name?: string;\n description?: string;\n image?: string;\n thumbs?: string[];\n awardedBy: string;\n }[]> {\n return requireNapplet().identity.getBadges();\n },\n};\n\n// ─── Config namespace ──────────────────────────────────────────────────────\n\n/**\n * Per-napplet declarative configuration (NUB-CONFIG): register a schema,\n * read current values, subscribe to live updates, deep-link into the\n * shell-owned settings UI, and listen for schema errors.\n *\n * @example\n * ```ts\n * import { config } from '@napplet/sdk';\n *\n * await config.registerSchema({\n * type: 'object',\n * properties: { theme: { type: 'string', enum: ['light', 'dark'], default: 'dark' } },\n * });\n *\n * const sub = config.subscribe((values) => { applyTheme(values.theme); });\n *\n * config.openSettings({ section: 'appearance' });\n * ```\n */\nexport const config = {\n /**\n * Snapshot current validated + defaulted config values.\n * @returns A one-shot ConfigValues object.\n */\n get(): Promise<Record<string, unknown>> {\n return requireNapplet().config.get();\n },\n\n /**\n * Subscribe to live configuration updates.\n * First delivery is an immediate snapshot; subsequent deliveries fire on change.\n * @param callback Invoked with the full ConfigValues on every change.\n * @returns A Subscription with close() to stop listening.\n */\n subscribe(\n callback: (values: Record<string, unknown>) => void,\n ): Subscription {\n return requireNapplet().config.subscribe(callback);\n },\n\n /**\n * Request the shell open its settings UI for this napplet.\n * @param options Optional { section } to deep-link by x-napplet-section name.\n */\n openSettings(options?: { section?: string }): void {\n requireNapplet().config.openSettings(options);\n },\n\n /**\n * Register a napplet configuration schema at runtime (escape hatch;\n * prefer manifest-declared via @napplet/vite-plugin's configSchema option).\n * @param schema JSON Schema (draft-07+) describing the config surface.\n * @param version Optional `$version` migration hint.\n */\n registerSchema(\n schema: Record<string, unknown>,\n version?: number,\n ): Promise<void> {\n return requireNapplet().config.registerSchema(schema, version);\n },\n\n /**\n * Listen for schema-registration errors pushed by the shell\n * (manifest parse failure, no-schema on subscribe-before-schema, etc.).\n * @param callback Invoked with { code, error } on every push.\n * @returns A plain teardown function that detaches the listener.\n */\n onSchemaError(\n callback: (err: { code: string; error: string }) => void,\n ): () => void {\n return requireNapplet().config.onSchemaError(callback);\n },\n\n /**\n * Current schema snapshot (readonly). Populated from the\n * `<meta name=\"napplet-config-schema\">` manifest tag at shim install,\n * updated on successful registerSchema responses.\n * @returns The registered schema, or null if none.\n */\n get schema(): Record<string, unknown> | null {\n return requireNapplet().config.schema;\n },\n};\n\n// ─── Type re-exports from @napplet/core ─────────────────────────────────────\n\nexport type { NostrEvent } from '@napplet/core';\nexport type { NostrFilter } from '@napplet/core';\nexport type { Subscription } from '@napplet/core';\nexport type { EventTemplate } from '@napplet/core';\n\n// ─── Core envelope types ───────────────────────────────────────────────────\n\nexport type { NappletMessage, NubDomain, NamespacedCapability, ShellSupports } from '@napplet/core';\nexport { NUB_DOMAINS } from '@napplet/core';\n\n// ─── NUB Message Type Re-exports ───────────────────────────────────────────\n// These types let SDK consumers work with typed envelope messages directly.\n// Import from '@napplet/sdk' instead of individual NUB packages.\n\n// Relay NUB\nexport type {\n RelayMessage,\n RelaySubscribeMessage,\n RelayCloseMessage,\n RelayPublishMessage,\n RelayPublishEncryptedMessage,\n RelayQueryMessage,\n RelayEventMessage,\n RelayEoseMessage,\n RelayClosedMessage,\n RelayPublishResultMessage,\n RelayPublishEncryptedResultMessage,\n RelayQueryResultMessage,\n RelayOutboundMessage,\n RelayInboundMessage,\n RelayNubMessage,\n} from '@napplet/nub-relay';\n\n// Identity NUB\nexport type {\n ProfileData,\n ZapReceipt,\n Badge,\n RelayPermission as IdentityRelayPermission,\n IdentityMessage,\n IdentityGetPublicKeyMessage,\n IdentityGetRelaysMessage,\n IdentityGetProfileMessage,\n IdentityGetFollowsMessage,\n IdentityGetListMessage,\n IdentityGetZapsMessage,\n IdentityGetMutesMessage,\n IdentityGetBlockedMessage,\n IdentityGetBadgesMessage,\n IdentityGetPublicKeyResultMessage,\n IdentityGetRelaysResultMessage,\n IdentityGetProfileResultMessage,\n IdentityGetFollowsResultMessage,\n IdentityGetListResultMessage,\n IdentityGetZapsResultMessage,\n IdentityGetMutesResultMessage,\n IdentityGetBlockedResultMessage,\n IdentityGetBadgesResultMessage,\n IdentityRequestMessage,\n IdentityResultMessage,\n IdentityNubMessage,\n} from '@napplet/nub-identity';\n\n// Storage NUB\nexport type {\n StorageMessage,\n StorageGetMessage,\n StorageSetMessage,\n StorageRemoveMessage,\n StorageKeysMessage,\n StorageGetResultMessage,\n StorageSetResultMessage,\n StorageRemoveResultMessage,\n StorageKeysResultMessage,\n StorageRequestMessage,\n StorageResultMessage,\n StorageNubMessage,\n} from '@napplet/nub-storage';\n\n// IFC NUB\nexport type {\n IfcMessage,\n IfcEmitMessage,\n IfcSubscribeMessage,\n IfcSubscribeResultMessage,\n IfcUnsubscribeMessage,\n IfcEventMessage,\n IfcChannelOpenMessage,\n IfcChannelOpenResultMessage,\n IfcChannelEmitMessage,\n IfcChannelEventMessage,\n IfcChannelBroadcastMessage,\n IfcChannelListMessage,\n IfcChannelListResultMessage,\n IfcChannelCloseMessage,\n IfcChannelClosedMessage,\n IfcTopicMessage,\n IfcChannelMessage,\n IfcOutboundMessage,\n IfcInboundMessage,\n IfcNubMessage,\n} from '@napplet/nub-ifc';\n\n// Theme NUB\nexport type {\n ThemeColors,\n ThemeFont,\n ThemeBackground,\n Theme,\n ThemeMessage,\n ThemeGetMessage,\n ThemeGetResultMessage,\n ThemeChangedMessage,\n ThemeRequestMessage,\n ThemeResultMessage,\n ThemeNubMessage,\n} from '@napplet/nub-theme';\n\n// Keys NUB\nexport type {\n Action,\n RegisterResult,\n KeyBinding,\n KeysMessage,\n KeysForwardMessage,\n KeysRegisterActionMessage,\n KeysRegisterActionResultMessage,\n KeysUnregisterActionMessage,\n KeysBindingsMessage,\n KeysActionMessage,\n KeysRequestMessage,\n KeysResultMessage,\n KeysNubMessage,\n} from '@napplet/nub-keys';\n\n// Media NUB\nexport type {\n MediaMetadata,\n MediaArtwork,\n MediaState,\n MediaAction,\n MediaMessage,\n MediaSessionCreateMessage,\n MediaSessionCreateResultMessage,\n MediaSessionUpdateMessage,\n MediaSessionDestroyMessage,\n MediaStateMessage,\n MediaCapabilitiesMessage,\n MediaCommandMessage,\n MediaControlsMessage,\n MediaRequestMessage,\n MediaResultMessage,\n MediaNubMessage,\n} from '@napplet/nub-media';\n\n// Notify NUB\nexport type {\n NotificationPriority,\n NotificationAction,\n NotificationChannel,\n NotifyControl,\n NotifyMessage,\n NotifySendMessage,\n NotifySendResultMessage,\n NotifyDismissMessage,\n NotifyBadgeMessage,\n NotifyChannelRegisterMessage,\n NotifyPermissionRequestMessage,\n NotifyPermissionResultMessage,\n NotifyActionMessage,\n NotifyClickedMessage,\n NotifyDismissedMessage,\n NotifyControlsMessage,\n NotifyRequestMessage,\n NotifyResultMessage,\n NotifyNubMessage,\n} from '@napplet/nub-notify';\n\n// Config NUB\nexport type {\n NappletConfigSchema,\n ConfigSchema,\n ConfigValues,\n ConfigSchemaErrorCode,\n NappletConfigSchemaExtensions,\n ConfigMessage,\n ConfigRegisterSchemaMessage,\n ConfigGetMessage,\n ConfigSubscribeMessage,\n ConfigUnsubscribeMessage,\n ConfigOpenSettingsMessage,\n ConfigRegisterSchemaResultMessage,\n ConfigValuesMessage,\n ConfigSchemaErrorMessage,\n ConfigRequestMessage,\n ConfigResultMessage,\n ConfigNubMessage,\n} from '@napplet/nub-config';\n\n// ─── NUB Domain Constants ──────────────────────────────────────────────────\n\nexport { DOMAIN as RELAY_DOMAIN } from '@napplet/nub-relay';\nexport { DOMAIN as IDENTITY_DOMAIN } from '@napplet/nub-identity';\nexport { DOMAIN as STORAGE_DOMAIN } from '@napplet/nub-storage';\nexport { DOMAIN as IFC_DOMAIN } from '@napplet/nub-ifc';\nexport { DOMAIN as THEME_DOMAIN } from '@napplet/nub-theme';\nexport { DOMAIN as KEYS_DOMAIN } from '@napplet/nub-keys';\nexport { DOMAIN as MEDIA_DOMAIN } from '@napplet/nub-media';\nexport { DOMAIN as NOTIFY_DOMAIN } from '@napplet/nub-notify';\nexport { DOMAIN as CONFIG_DOMAIN } from '@napplet/nub-config';\n\n// ─── NUB Shim Installer Re-exports ─────────────────────────────────────────\n// Allow consumers to cherry-pick shim installers per domain.\n\nexport { installRelayShim } from '@napplet/nub-relay';\nexport { installIdentityShim } from '@napplet/nub-identity';\nexport { installStorageShim } from '@napplet/nub-storage';\nexport { installIfcShim } from '@napplet/nub-ifc';\nexport { installKeysShim } from '@napplet/nub-keys';\nexport { installMediaShim } from '@napplet/nub-media';\nexport { installNotifyShim } from '@napplet/nub-notify';\nexport { installConfigShim } from '@napplet/nub-config';\n\n// ─── NUB SDK Helper Re-exports ──────────────────────────────────────────────\n// Allow consumers to use domain-specific SDK functions from @napplet/sdk.\n\nexport { relaySubscribe, relayPublish, relayPublishEncrypted, relayQuery } from '@napplet/nub-relay';\nexport { identityGetPublicKey, identityGetRelays, identityGetProfile, identityGetFollows, identityGetList, identityGetZaps, identityGetMutes, identityGetBlocked, identityGetBadges } from '@napplet/nub-identity';\nexport { storageGetItem, storageSetItem, storageRemoveItem, storageKeys } from '@napplet/nub-storage';\nexport { ifcEmit, ifcOn } from '@napplet/nub-ifc';\nexport { keysRegisterAction, keysUnregisterAction, keysOnAction, keysRegister } from '@napplet/nub-keys';\nexport { mediaCreateSession, mediaUpdateSession, mediaDestroySession, mediaReportState, mediaReportCapabilities, mediaOnCommand, mediaOnControls } from '@napplet/nub-media';\nexport { notifySend, notifyDismiss, notifyBadge, notifyRegisterChannel, notifyRequestPermission, not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AAO;AAAA,EAC9C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,eACE,QACA,SACe;AACf,WAAO,eAAe,EAAE,OAAO,eAAe,QAAQ,OAAO;AAAA,EAC/D;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,cACE,UACY;AACZ,WAAO,eAAe,EAAE,OAAO,cAAc,QAAQ;AAAA,EACvD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,IAAI,SAAyC;AAC3C,WAAO,eAAe,EAAE,OAAO;AAAA,EACjC;AACF;","names":["DOMAIN"]}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * @napplet/sdk -- Typed named exports wrapping window.napplet.\n *\n * Provides `relay`, `ifc`, `storage`, and `keys` objects that delegate\n * to `window.napplet.*` at call time. Developers using a bundler can import\n * individual namespaces without depending on the shim's side-effect install:\n *\n * ```ts\n * import { relay, ifc } from '@napplet/sdk';\n * ```\n *\n * The shim must still be imported somewhere in the application to install\n * the `window.napplet` global. The SDK only wraps it -- it does not install it.\n *\n * Domain-specific SDK helpers are also available directly from NUB packages:\n * ```ts\n * import { relaySubscribe } from '@napplet/nub/relay';\n * import { storageGetItem } from '@napplet/nub/storage';\n * ```\n *\n * @packageDocumentation\n */\n\nimport type {\n NappletGlobal,\n NostrEvent,\n NostrFilter,\n Rumor,\n Subscription,\n EventTemplate,\n} from '@napplet/core';\n\n// ─── Global type augmentation ────────────────────────────────────────────────\n// Provides window.napplet autocompletion for TypeScript consumers who import\n// only the SDK (not the shim). Both shim and SDK reference NappletGlobal from\n// @napplet/core -- no duplication.\n\ndeclare global {\n interface Window {\n napplet: NappletGlobal;\n }\n}\n\n// ─── Runtime guard ──────────────────────────────────────────────────────────\n\n/**\n * Retrieve the `window.napplet` global, throwing a clear error if it is absent.\n *\n * Every SDK method calls this at invocation time -- not at module load time --\n * so the shim can be imported in any order relative to the SDK.\n */\nfunction requireNapplet(): NappletGlobal {\n const w = window as Window & { napplet?: NappletGlobal };\n if (!w.napplet) {\n throw new Error('window.napplet not installed -- import @napplet/shim first');\n }\n return w.napplet;\n}\n\n// ─── Relay namespace ────────────────────────────────────────────────────────\n\n/**\n * NIP-01 relay operations: subscribe to events, publish events, one-shot queries.\n *\n * Each method delegates to `window.napplet.relay.*` at call time, which in turn\n * routes through the shell's relay pool via postMessage.\n *\n * @example\n * ```ts\n * import { relay } from '@napplet/sdk';\n *\n * const sub = relay.subscribe(\n * { kinds: [1], limit: 10 },\n * (event) => console.log(event),\n * () => console.log('EOSE'),\n * );\n * ```\n */\nexport const relay = {\n /**\n * Open a live NIP-01 subscription through the shell's relay pool.\n * @param filters One or more NIP-01 subscription filters\n * @param onEvent Called for each matching event\n * @param onEose Called when the shell signals end of stored events (EOSE)\n * @param options Optional: `{ relay, group }` for NIP-29 scoped relay subscriptions\n * @returns A Subscription handle with a `close()` method\n */\n subscribe(\n filters: NostrFilter | NostrFilter[],\n onEvent: (event: NostrEvent) => void,\n onEose: () => void,\n options?: { relay?: string; group?: string },\n ): Subscription {\n return requireNapplet().relay.subscribe(filters, onEvent, onEose, options);\n },\n\n /**\n * Sign and publish a Nostr event through the shell.\n * @param template Unsigned event template\n * @param options Optional: `{ relay: true }` to publish via scoped relay\n * @returns The signed NostrEvent after successful publication\n */\n publish(\n template: EventTemplate,\n options?: { relay?: boolean },\n ): Promise<NostrEvent> {\n return requireNapplet().relay.publish(template, options);\n },\n\n /**\n * Publish an encrypted Nostr event through the shell.\n * @param template Unsigned event template\n * @param recipient Hex-encoded recipient public key\n * @param encryption Encryption scheme: 'nip44' (default) or 'nip04'\n * @returns The signed encrypted NostrEvent after successful publication\n */\n publishEncrypted(\n template: EventTemplate,\n recipient: string,\n encryption: 'nip44' | 'nip04' = 'nip44',\n ): Promise<NostrEvent> {\n return requireNapplet().relay.publishEncrypted(template, recipient, encryption);\n },\n\n /**\n * One-shot query: subscribe, collect events until EOSE, then resolve.\n * @param filters NIP-01 subscription filters\n * @returns Promise resolving to array of matching NostrEvent objects\n */\n query(filters: NostrFilter | NostrFilter[]): Promise<NostrEvent[]> {\n return requireNapplet().relay.query(filters);\n },\n};\n\n// ─── IFC namespace ──────────────────────────────────────────────────────────\n\n/**\n * Inter-frame pubsub: broadcast and receive IFC-PEER events through the shell.\n *\n * @example\n * ```ts\n * import { ifc } from '@napplet/sdk';\n *\n * ifc.emit('profile:open', [], JSON.stringify({ pubkey: '...' }));\n *\n * const sub = ifc.on('profile:open', (payload) => {\n * console.log('Profile requested:', payload);\n * });\n * ```\n */\nexport const ifc = {\n /**\n * Broadcast an IFC-PEER event to other napplets via the shell.\n * @param topic The 't' tag value (e.g., 'profile:open')\n * @param extraTags Additional NIP-01 tags beyond the 't' tag (default: [])\n * @param content Event content (default: empty string)\n */\n emit(topic: string, extraTags?: string[][], content?: string): void {\n requireNapplet().ifc.emit(topic, extraTags, content);\n },\n\n /**\n * Subscribe to IFC-PEER events on a specific topic.\n * @param topic The 't' tag value to listen for\n * @param callback Called with `(payload, event)` for each matching event\n * @returns A Subscription handle with a `close()` method\n */\n on(\n topic: string,\n callback: (payload: unknown, event: NostrEvent) => void,\n ): Subscription {\n return requireNapplet().ifc.on(topic, callback);\n },\n};\n\n// ─── Services namespace ─────────────────────────────────────────────────────\n\n// ─── Storage namespace ──────────────────────────────────────────────────────\n\n/**\n * Napplet-scoped storage: async localStorage-like API proxied through the shell.\n * Each napplet's storage is isolated by identity.\n *\n * @example\n * ```ts\n * import { storage } from '@napplet/sdk';\n *\n * await storage.setItem('theme', 'dark');\n * const theme = await storage.getItem('theme'); // 'dark'\n * ```\n */\nexport const storage = {\n /**\n * Retrieve a stored value by key. Returns null if the key does not exist.\n * @param key The storage key\n * @returns The stored string value, or null if not found\n */\n getItem(key: string): Promise<string | null> {\n return requireNapplet().storage.getItem(key);\n },\n\n /**\n * Store a key-value pair.\n * @param key The storage key\n * @param value The string value to store\n */\n setItem(key: string, value: string): Promise<void> {\n return requireNapplet().storage.setItem(key, value);\n },\n\n /**\n * Remove a stored key.\n * @param key The storage key to remove\n */\n removeItem(key: string): Promise<void> {\n return requireNapplet().storage.removeItem(key);\n },\n\n /**\n * List all keys stored by this napplet.\n * @returns Array of storage key strings\n */\n keys(): Promise<string[]> {\n return requireNapplet().storage.keys();\n },\n};\n\n// ─── Media namespace ───────────────────────────────────────────────────────\n\n/**\n * Media session control: create sessions, report state and metadata,\n * declare capabilities, receive commands from the shell.\n *\n * @example\n * ```ts\n * import { media } from '@napplet/sdk';\n *\n * const { sessionId } = await media.createSession({\n * title: 'My Song', artist: 'The Artist',\n * });\n *\n * media.reportState(sessionId, { status: 'playing', position: 42.5 });\n * ```\n */\nexport const media = {\n /**\n * Create a new media session with the shell.\n * @param metadata Optional initial metadata\n * @returns The confirmed session result with sessionId\n */\n createSession(metadata?: {\n title?: string;\n artist?: string;\n album?: string;\n artwork?: { url?: string; hash?: string };\n duration?: number;\n mediaType?: 'audio' | 'video';\n }): Promise<{ sessionId: string }> {\n return requireNapplet().media.createSession(metadata);\n },\n\n /**\n * Update metadata for an existing session.\n * @param sessionId The session to update\n * @param metadata Partial metadata fields to update\n */\n updateSession(sessionId: string, metadata: {\n title?: string;\n artist?: string;\n album?: string;\n artwork?: { url?: string; hash?: string };\n duration?: number;\n mediaType?: 'audio' | 'video';\n }): void {\n requireNapplet().media.updateSession(sessionId, metadata);\n },\n\n /**\n * Destroy a media session.\n * @param sessionId The session to destroy\n */\n destroySession(sessionId: string): void {\n requireNapplet().media.destroySession(sessionId);\n },\n\n /**\n * Report current playback state for a session.\n * @param sessionId The session to report state for\n * @param state Current playback state\n */\n reportState(sessionId: string, state: {\n status: 'playing' | 'paused' | 'stopped' | 'buffering';\n position?: number;\n duration?: number;\n volume?: number;\n }): void {\n requireNapplet().media.reportState(sessionId, state);\n },\n\n /**\n * Declare which media actions the session currently supports.\n * @param sessionId The session to update capabilities for\n * @param actions Currently supported actions\n */\n reportCapabilities(sessionId: string, actions: ('play' | 'pause' | 'stop' | 'next' | 'prev' | 'seek' | 'volume')[]): void {\n requireNapplet().media.reportCapabilities(sessionId, actions);\n },\n\n /**\n * Listen for media commands from the shell.\n * @param sessionId The session to listen for commands on\n * @param callback Called with (action, value?) when a command is received\n * @returns A Subscription with `close()` to stop listening\n */\n onCommand(\n sessionId: string,\n callback: (action: 'play' | 'pause' | 'stop' | 'next' | 'prev' | 'seek' | 'volume', value?: number) => void,\n ): Subscription {\n return requireNapplet().media.onCommand(sessionId, callback);\n },\n\n /**\n * Listen for the shell's media control list.\n * @param sessionId The session to associate controls with\n * @param callback Called with the shell's supported controls\n * @returns A Subscription with `close()` to stop listening\n */\n onControls(\n sessionId: string,\n callback: (controls: ('play' | 'pause' | 'stop' | 'next' | 'prev' | 'seek' | 'volume')[]) => void,\n ): Subscription {\n return requireNapplet().media.onControls(sessionId, callback);\n },\n};\n\n// ─── Notify namespace ──────────────────────────────────────────────────────\n\n/**\n * Shell-rendered notifications: send notifications, set badge counts,\n * register channels, request permission, listen for user interaction.\n *\n * @example\n * ```ts\n * import { notify } from '@napplet/sdk';\n *\n * const { notificationId } = await notify.send({\n * title: 'New message', body: 'Alice: hey!',\n * });\n *\n * notify.badge(3);\n * ```\n */\nexport const notify = {\n /**\n * Send a notification to the shell.\n * @param notification Notification payload (title required)\n * @returns The shell-assigned notificationId\n */\n send(notification: {\n title: string;\n body?: string;\n icon?: string;\n actions?: { id: string; label: string }[];\n channel?: string;\n priority?: 'low' | 'normal' | 'high' | 'urgent';\n }): Promise<{ notificationId: string }> {\n return requireNapplet().notify.send(notification);\n },\n\n /**\n * Dismiss a notification by ID.\n * @param notificationId The notification to dismiss\n */\n dismiss(notificationId: string): void {\n requireNapplet().notify.dismiss(notificationId);\n },\n\n /**\n * Set the badge count for this napplet. Pass 0 to clear.\n * @param count Badge count\n */\n badge(count: number): void {\n requireNapplet().notify.badge(count);\n },\n\n /**\n * Register a notification channel.\n * @param channel Channel definition\n */\n registerChannel(channel: {\n channelId: string;\n label: string;\n description?: string;\n defaultPriority?: 'low' | 'normal' | 'high' | 'urgent';\n }): void {\n requireNapplet().notify.registerChannel(channel);\n },\n\n /**\n * Request permission to send notifications.\n * @param channel Optional channel to request permission for\n * @returns Whether permission was granted\n */\n requestPermission(channel?: string): Promise<{ granted: boolean }> {\n return requireNapplet().notify.requestPermission(channel);\n },\n\n /**\n * Listen for action button clicks on notifications.\n * @param callback Called with (notificationId, actionId)\n * @returns A Subscription with `close()` to stop listening\n */\n onAction(\n callback: (notificationId: string, actionId: string) => void,\n ): Subscription {\n return requireNapplet().notify.onAction(callback);\n },\n\n /**\n * Listen for notification body clicks.\n * @param callback Called with (notificationId)\n * @returns A Subscription with `close()` to stop listening\n */\n onClicked(\n callback: (notificationId: string) => void,\n ): Subscription {\n return requireNapplet().notify.onClicked(callback);\n },\n\n /**\n * Listen for notification dismissals.\n * @param callback Called with (notificationId, reason?)\n * @returns A Subscription with `close()` to stop listening\n */\n onDismissed(\n callback: (notificationId: string, reason?: string) => void,\n ): Subscription {\n return requireNapplet().notify.onDismissed(callback);\n },\n\n /**\n * Listen for the shell's notification capability list.\n * @param callback Called with supported controls\n * @returns A Subscription with `close()` to stop listening\n */\n onControls(\n callback: (controls: ('toasts' | 'badges' | 'actions' | 'channels' | 'system')[]) => void,\n ): Subscription {\n return requireNapplet().notify.onControls(callback);\n },\n};\n\n// ─── Keys namespace ────────────────────────────────────────────────────────\n\n/**\n * Keyboard forwarding and action keybindings: register named actions the shell\n * can bind to keys, listen for shell-triggered actions locally.\n *\n * @example\n * ```ts\n * import { keys } from '@napplet/sdk';\n *\n * const result = await keys.registerAction({\n * id: 'editor.save',\n * label: 'Save',\n * defaultKey: 'Ctrl+S',\n * });\n *\n * const sub = keys.onAction('editor.save', () => {\n * console.log('Save triggered!');\n * });\n * ```\n */\nexport const keys = {\n /**\n * Declare a named action that the shell can bind to a key.\n * @param action The action to register (id, label, optional defaultKey)\n * @returns The assigned binding, if any\n */\n registerAction(action: {\n id: string;\n label: string;\n defaultKey?: string;\n }): Promise<{ actionId: string; binding?: string }> {\n return requireNapplet().keys.registerAction(action);\n },\n\n /**\n * Remove a previously registered action.\n * @param actionId The action to unregister\n */\n unregisterAction(actionId: string): void {\n requireNapplet().keys.unregisterAction(actionId);\n },\n\n /**\n * Register a local handler for when a bound key is pressed.\n * @param actionId The action to listen for\n * @param callback Called when the action is triggered\n * @returns A Subscription with `close()` to stop listening\n */\n onAction(actionId: string, callback: () => void): Subscription {\n return requireNapplet().keys.onAction(actionId, callback);\n },\n\n /**\n * Convenience: register a named action AND wire a local handler in one call.\n * Returns a handle whose `close()` both unregisters the action and removes\n * the onAction listener.\n *\n * @param action The action to register (id, label, optional defaultKey)\n * @param handler Called when the shell triggers this action\n * @returns The assigned binding plus a `close()` teardown function\n *\n * @example\n * ```ts\n * import { keys } from '@napplet/sdk';\n *\n * const handle = await keys.register(\n * { id: 'editor.save', label: 'Save', defaultKey: 'Ctrl+S' },\n * () => saveDocument(),\n * );\n *\n * // Later, tear down both registration and listener:\n * handle.close();\n * ```\n */\n async register(\n action: { id: string; label: string; defaultKey?: string },\n handler: () => void,\n ): Promise<{ actionId: string; binding?: string; close: () => void }> {\n const n = requireNapplet();\n const result = await n.keys.registerAction(action);\n const sub = n.keys.onAction(action.id, handler);\n return {\n ...result,\n close() {\n sub.close();\n n.keys.unregisterAction(action.id);\n },\n };\n },\n};\n\n// ─── Identity namespace ───────────────────────────────────────────────────\n\n/**\n * Read-only user identity queries: public key, profile, follows, relays,\n * lists, zaps, mutes, blocked, badges.\n *\n * @example\n * ```ts\n * import { identity } from '@napplet/sdk';\n *\n * const pubkey = await identity.getPublicKey();\n * const profile = await identity.getProfile();\n * const follows = await identity.getFollows();\n * ```\n */\nexport const identity = {\n /**\n * Get the user's hex-encoded public key. Always succeeds.\n * @returns Hex-encoded public key string\n */\n getPublicKey(): Promise<string> {\n return requireNapplet().identity.getPublicKey();\n },\n\n /**\n * Get the user's relay list (NIP-65).\n * @returns Record mapping relay URLs to read/write permissions\n */\n getRelays(): Promise<Record<string, { read: boolean; write: boolean }>> {\n return requireNapplet().identity.getRelays();\n },\n\n /**\n * Get the user's profile metadata (kind 0).\n * @returns Profile data, or null if not found\n */\n getProfile(): Promise<{\n name?: string;\n displayName?: string;\n about?: string;\n picture?: string;\n banner?: string;\n nip05?: string;\n lud16?: string;\n website?: string;\n } | null> {\n return requireNapplet().identity.getProfile();\n },\n\n /**\n * Get the user's follow list (kind 3 contact list).\n * @returns Array of hex-encoded public keys\n */\n getFollows(): Promise<string[]> {\n return requireNapplet().identity.getFollows();\n },\n\n /**\n * Get entries from a user's categorized list.\n * @param listType List category (e.g., \"bookmarks\", \"interests\", \"pins\")\n * @returns Array of list entry values\n */\n getList(listType: string): Promise<string[]> {\n return requireNapplet().identity.getList(listType);\n },\n\n /**\n * Get zap receipts sent to the user.\n * @returns Array of zap receipt objects\n */\n getZaps(): Promise<{\n eventId: string;\n sender: string;\n amount: number;\n content?: string;\n }[]> {\n return requireNapplet().identity.getZaps();\n },\n\n /**\n * Get the user's mute list (kind 10000).\n * @returns Array of hex-encoded muted public keys\n */\n getMutes(): Promise<string[]> {\n return requireNapplet().identity.getMutes();\n },\n\n /**\n * Get the user's block list.\n * @returns Array of hex-encoded blocked public keys\n */\n getBlocked(): Promise<string[]> {\n return requireNapplet().identity.getBlocked();\n },\n\n /**\n * Get badges awarded to the user (NIP-58).\n * @returns Array of badge objects\n */\n getBadges(): Promise<{\n id: string;\n name?: string;\n description?: string;\n image?: string;\n thumbs?: string[];\n awardedBy: string;\n }[]> {\n return requireNapplet().identity.getBadges();\n },\n\n /**\n * Decrypt a received Nostr event (NIP-04 / direct NIP-44 / NIP-17 gift-wrap).\n *\n * Shape is auto-detected by the shell; napplets do NOT select encryption mode.\n * Only legal for napplets assigned class: 1 per NUB-CLASS-1 (shell-enforced).\n *\n * @param event The received event (outer wrap for NIP-17, kind-4 for NIP-04, etc.)\n * @returns Promise resolving to { rumor, sender }; rejects with Error on failure.\n */\n decrypt(event: NostrEvent): Promise<{ rumor: Rumor; sender: string }> {\n return requireNapplet().identity.decrypt(event);\n },\n};\n\n// ─── Config namespace ──────────────────────────────────────────────────────\n\n/**\n * Per-napplet declarative configuration (NUB-CONFIG): register a schema,\n * read current values, subscribe to live updates, deep-link into the\n * shell-owned settings UI, and listen for schema errors.\n *\n * @example\n * ```ts\n * import { config } from '@napplet/sdk';\n *\n * await config.registerSchema({\n * type: 'object',\n * properties: { theme: { type: 'string', enum: ['light', 'dark'], default: 'dark' } },\n * });\n *\n * const sub = config.subscribe((values) => { applyTheme(values.theme); });\n *\n * config.openSettings({ section: 'appearance' });\n * ```\n */\nexport const config = {\n /**\n * Snapshot current validated + defaulted config values.\n * @returns A one-shot ConfigValues object.\n */\n get(): Promise<Record<string, unknown>> {\n return requireNapplet().config.get();\n },\n\n /**\n * Subscribe to live configuration updates.\n * First delivery is an immediate snapshot; subsequent deliveries fire on change.\n * @param callback Invoked with the full ConfigValues on every change.\n * @returns A Subscription with close() to stop listening.\n */\n subscribe(\n callback: (values: Record<string, unknown>) => void,\n ): Subscription {\n return requireNapplet().config.subscribe(callback);\n },\n\n /**\n * Request the shell open its settings UI for this napplet.\n * @param options Optional { section } to deep-link by x-napplet-section name.\n */\n openSettings(options?: { section?: string }): void {\n requireNapplet().config.openSettings(options);\n },\n\n /**\n * Register a napplet configuration schema at runtime (escape hatch;\n * prefer manifest-declared via @napplet/vite-plugin's configSchema option).\n * @param schema JSON Schema (draft-07+) describing the config surface.\n * @param version Optional `$version` migration hint.\n */\n registerSchema(\n schema: Record<string, unknown>,\n version?: number,\n ): Promise<void> {\n return requireNapplet().config.registerSchema(schema, version);\n },\n\n /**\n * Listen for schema-registration errors pushed by the shell\n * (manifest parse failure, no-schema on subscribe-before-schema, etc.).\n * @param callback Invoked with { code, error } on every push.\n * @returns A plain teardown function that detaches the listener.\n */\n onSchemaError(\n callback: (err: { code: string; error: string }) => void,\n ): () => void {\n return requireNapplet().config.onSchemaError(callback);\n },\n\n /**\n * Current schema snapshot (readonly). Populated from the\n * `<meta name=\"napplet-config-schema\">` manifest tag at shim install,\n * updated on successful registerSchema responses.\n * @returns The registered schema, or null if none.\n */\n get schema(): Record<string, unknown> | null {\n return requireNapplet().config.schema;\n },\n};\n\n// ─── Resource namespace ────────────────────────────────────────────────────\n\n/**\n * Browser-enforced byte-fetching primitive: napplets request bytes by URL,\n * shell fetches and returns a Blob. URL space is scheme-pluggable\n * (`data:`, `https:`, `blossom:`, `nostr:`).\n *\n * @example\n * ```ts\n * import { resource } from '@napplet/sdk';\n *\n * const blob = await resource.bytes('https://example.com/avatar.png');\n * const handle = resource.bytesAsObjectURL('blossom:abc123...');\n * imgEl.src = handle.url;\n * imgEl.onload = () => handle.revoke();\n * ```\n */\nexport const resource = {\n /**\n * Fetch bytes for a URL through the shell's resource pipeline.\n * @param url URL identifying the resource (any registered scheme).\n * @returns Promise resolving to the fetched bytes as a Blob.\n */\n bytes(url: string): Promise<Blob> {\n return requireNapplet().resource.bytes(url);\n },\n\n /**\n * Fetch bytes and return a managed object URL handle.\n * Call `revoke()` to release the underlying Blob URL.\n * @param url URL identifying the resource.\n * @returns Synchronous handle `{ url, revoke }`.\n */\n bytesAsObjectURL(url: string): { url: string; revoke: () => void } {\n return requireNapplet().resource.bytesAsObjectURL(url);\n },\n};\n\n// ─── Type re-exports from @napplet/core ─────────────────────────────────────\n\nexport type { NostrEvent } from '@napplet/core';\nexport type { NostrFilter } from '@napplet/core';\nexport type { Subscription } from '@napplet/core';\nexport type { EventTemplate } from '@napplet/core';\nexport type { Rumor } from '@napplet/core';\nexport type { UnsignedEvent } from '@napplet/core';\n\n// ─── Core envelope types ───────────────────────────────────────────────────\n\nexport type { NappletMessage, NubDomain, NamespacedCapability, ShellSupports } from '@napplet/core';\nexport { NUB_DOMAINS } from '@napplet/core';\n\n// ─── NUB Message Type Re-exports ───────────────────────────────────────────\n// These types let SDK consumers work with typed envelope messages directly.\n// Import from '@napplet/sdk' instead of individual NUB packages.\n\n// Relay NUB\nexport type {\n RelayMessage,\n RelaySubscribeMessage,\n RelayCloseMessage,\n RelayPublishMessage,\n RelayPublishEncryptedMessage,\n RelayQueryMessage,\n RelayEventMessage,\n RelayEoseMessage,\n RelayClosedMessage,\n RelayPublishResultMessage,\n RelayPublishEncryptedResultMessage,\n RelayQueryResultMessage,\n RelayOutboundMessage,\n RelayInboundMessage,\n RelayNubMessage,\n} from '@napplet/nub/relay';\n\n// Identity NUB\nexport type {\n ProfileData,\n ZapReceipt,\n Badge,\n RelayPermission as IdentityRelayPermission,\n IdentityMessage,\n IdentityGetPublicKeyMessage,\n IdentityGetRelaysMessage,\n IdentityGetProfileMessage,\n IdentityGetFollowsMessage,\n IdentityGetListMessage,\n IdentityGetZapsMessage,\n IdentityGetMutesMessage,\n IdentityGetBlockedMessage,\n IdentityGetBadgesMessage,\n IdentityGetPublicKeyResultMessage,\n IdentityGetRelaysResultMessage,\n IdentityGetProfileResultMessage,\n IdentityGetFollowsResultMessage,\n IdentityGetListResultMessage,\n IdentityGetZapsResultMessage,\n IdentityGetMutesResultMessage,\n IdentityGetBlockedResultMessage,\n IdentityGetBadgesResultMessage,\n IdentityRequestMessage,\n IdentityResultMessage,\n IdentityNubMessage,\n IdentityDecryptMessage,\n IdentityDecryptResultMessage,\n IdentityDecryptErrorMessage,\n IdentityDecryptErrorCode,\n} from '@napplet/nub/identity';\n\n// Storage NUB\nexport type {\n StorageMessage,\n StorageGetMessage,\n StorageSetMessage,\n StorageRemoveMessage,\n StorageKeysMessage,\n StorageGetResultMessage,\n StorageSetResultMessage,\n StorageRemoveResultMessage,\n StorageKeysResultMessage,\n StorageRequestMessage,\n StorageResultMessage,\n StorageNubMessage,\n} from '@napplet/nub/storage';\n\n// IFC NUB\nexport type {\n IfcMessage,\n IfcEmitMessage,\n IfcSubscribeMessage,\n IfcSubscribeResultMessage,\n IfcUnsubscribeMessage,\n IfcEventMessage,\n IfcChannelOpenMessage,\n IfcChannelOpenResultMessage,\n IfcChannelEmitMessage,\n IfcChannelEventMessage,\n IfcChannelBroadcastMessage,\n IfcChannelListMessage,\n IfcChannelListResultMessage,\n IfcChannelCloseMessage,\n IfcChannelClosedMessage,\n IfcTopicMessage,\n IfcChannelMessage,\n IfcOutboundMessage,\n IfcInboundMessage,\n IfcNubMessage,\n} from '@napplet/nub/ifc';\n\n// Theme NUB\nexport type {\n ThemeColors,\n ThemeFont,\n ThemeBackground,\n Theme,\n ThemeMessage,\n ThemeGetMessage,\n ThemeGetResultMessage,\n ThemeChangedMessage,\n ThemeRequestMessage,\n ThemeResultMessage,\n ThemeNubMessage,\n} from '@napplet/nub/theme';\n\n// Keys NUB\nexport type {\n Action,\n RegisterResult,\n KeyBinding,\n KeysMessage,\n KeysForwardMessage,\n KeysRegisterActionMessage,\n KeysRegisterActionResultMessage,\n KeysUnregisterActionMessage,\n KeysBindingsMessage,\n KeysActionMessage,\n KeysRequestMessage,\n KeysResultMessage,\n KeysNubMessage,\n} from '@napplet/nub/keys';\n\n// Media NUB\nexport type {\n MediaMetadata,\n MediaArtwork,\n MediaState,\n MediaAction,\n MediaMessage,\n MediaSessionCreateMessage,\n MediaSessionCreateResultMessage,\n MediaSessionUpdateMessage,\n MediaSessionDestroyMessage,\n MediaStateMessage,\n MediaCapabilitiesMessage,\n MediaCommandMessage,\n MediaControlsMessage,\n MediaRequestMessage,\n MediaResultMessage,\n MediaNubMessage,\n} from '@napplet/nub/media';\n\n// Notify NUB\nexport type {\n NotificationPriority,\n NotificationAction,\n NotificationChannel,\n NotifyControl,\n NotifyMessage,\n NotifySendMessage,\n NotifySendResultMessage,\n NotifyDismissMessage,\n NotifyBadgeMessage,\n NotifyChannelRegisterMessage,\n NotifyPermissionRequestMessage,\n NotifyPermissionResultMessage,\n NotifyActionMessage,\n NotifyClickedMessage,\n NotifyDismissedMessage,\n NotifyControlsMessage,\n NotifyRequestMessage,\n NotifyResultMessage,\n NotifyNubMessage,\n} from '@napplet/nub/notify';\n\n// Config NUB\nexport type {\n NappletConfigSchema,\n ConfigSchema,\n ConfigValues,\n ConfigSchemaErrorCode,\n NappletConfigSchemaExtensions,\n ConfigMessage,\n ConfigRegisterSchemaMessage,\n ConfigGetMessage,\n ConfigSubscribeMessage,\n ConfigUnsubscribeMessage,\n ConfigOpenSettingsMessage,\n ConfigRegisterSchemaResultMessage,\n ConfigValuesMessage,\n ConfigSchemaErrorMessage,\n ConfigRequestMessage,\n ConfigResultMessage,\n ConfigNubMessage,\n} from '@napplet/nub/config';\n\n// Resource NUB\nexport type {\n ResourceErrorCode,\n ResourceScheme,\n ResourceMessage,\n ResourceBytesMessage,\n ResourceCancelMessage,\n ResourceBytesResultMessage,\n ResourceBytesErrorMessage,\n ResourceSidecarEntry,\n ResourceRequestMessage,\n ResourceResultMessage,\n ResourceNubMessage,\n} from '@napplet/nub/resource';\n\n// Connect NUB\nexport type {\n NappletConnect,\n} from '@napplet/nub/connect';\n\n// Class NUB\nexport type {\n ClassMessage,\n ClassAssignedMessage,\n NappletClass,\n ClassNubMessage,\n} from '@napplet/nub/class';\n\n// ─── NUB Domain Constants ──────────────────────────────────────────────────\n\nexport { DOMAIN as RELAY_DOMAIN } from '@napplet/nub/relay';\nexport { DOMAIN as IDENTITY_DOMAIN } from '@napplet/nub/identity';\nexport { DOMAIN as STORAGE_DOMAIN } from '@napplet/nub/storage';\nexport { DOMAIN as IFC_DOMAIN } from '@napplet/nub/ifc';\nexport { DOMAIN as THEME_DOMAIN } from '@napplet/nub/theme';\nexport { DOMAIN as KEYS_DOMAIN } from '@napplet/nub/keys';\nexport { DOMAIN as MEDIA_DOMAIN } from '@napplet/nub/media';\nexport { DOMAIN as NOTIFY_DOMAIN } from '@napplet/nub/notify';\nexport { DOMAIN as CONFIG_DOMAIN } from '@napplet/nub/config';\nexport { DOMAIN as RESOURCE_DOMAIN } from '@napplet/nub/resource';\nexport { DOMAIN as CONNECT_DOMAIN } from '@napplet/nub/connect';\nexport { DOMAIN as CLASS_DOMAIN } from '@napplet/nub/class';\n\n// ─── NUB Shim Installer Re-exports ─────────────────────────────────────────\n// Allow consumers to cherry-pick shim installers per domain.\n\nexport { installRelayShim } from '@napplet/nub/relay';\nexport { installIdentityShim } from '@napplet/nub/identity';\nexport { installStorageShim } from '@napplet/nub/storage';\nexport { installIfcShim } from '@napplet/nub/ifc';\nexport { installKeysShim } from '@napplet/nub/keys';\nexport { installMediaShim } from '@napplet/nub/media';\nexport { installNotifyShim } from '@napplet/nub/notify';\nexport { installConfigShim } from '@napplet/nub/config';\nexport { installResourceShim } from '@napplet/nub/resource';\nexport { installConnectShim } from '@napplet/nub/connect';\nexport { installClassShim } from '@napplet/nub/class';\n\n// ─── NUB SDK Helper Re-exports ──────────────────────────────────────────────\n// Allow consumers to use domain-specific SDK functions from @napplet/sdk.\n\nexport { relaySubscribe, relayPublish, relayPublishEncrypted, relayQuery } from '@napplet/nub/relay';\nexport { identityGetPublicKey, identityGetRelays, identityGetProfile, identityGetFollows, identityGetList, identityGetZaps, identityGetMutes, identityGetBlocked, identityGetBadges, identityDecrypt } from '@napplet/nub/identity';\nexport { storageGetItem, storageSetItem, storageRemoveItem, storageKeys } from '@napplet/nub/storage';\nexport { ifcEmit, ifcOn } from '@napplet/nub/ifc';\nexport { keysRegisterAction, keysUnregisterAction, keysOnAction, keysRegister } from '@napplet/nub/keys';\nexport { mediaCreateSession, mediaUpdateSession, mediaDestroySession, mediaReportState, mediaReportCapabilities, mediaOnCommand, mediaOnControls } from '@napplet/nub/media';\nexport { notifySend, notifyDismiss, notifyBadge, notifyRegisterChannel, notifyRequestPermission, notifyOnAction, notifyOnClicked, notifyOnDismissed, notifyOnControls } from '@napplet/nub/notify';\nexport { resourceBytes, resourceBytesAsObjectURL } from '@napplet/nub/resource';\nexport { connectGranted, connectOrigins, normalizeConnectOrigin } from '@napplet/nub/connect';\nexport { getClass } from '@napplet/nub/class';\n"],"mappings":";AAoyBA,SAAS,mBAAmB;AAiO5B,SAAmB,cAAoB;AACvC,SAAmB,UAAVA,eAAiC;AAC1C,SAAmB,UAA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E,OAAO,IAAI;AAAA,EACrC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,UACE,UACc;AACd,WAAO,eAAe,EAAE,OAAO,UAAU,QAAQ;AAAA,EACnD;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,aAAa,SAAsC;AACjD,mBAAe,EAAE,OAAO,aAAa,OAAO;AAAA,EAC9C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,eACE,QACA,SACe;AACf,WAAO,eAAe,EAAE,OAAO,eAAe,QAAQ,OAAO;AAAA,EAC/D;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,cACE,UACY;AACZ,WAAO,eAAe,EAAE,OAAO,cAAc,QAAQ;AAAA,EACvD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,IAAI,SAAyC;AAC3C,WAAO,eAAe,EAAE,OAAO;AAAA,EACjC;AACF;AAmBO,IAAM,WAAW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMtB,MAAM,KAA4B;AAChC,WAAO,eAAe,EAAE,SAAS,MAAM,GAAG;AAAA,EAC5C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,iBAAiB,KAAkD;AACjE,WAAO,eAAe,EAAE,SAAS,iBAAiB,GAAG;AAAA,EACvD;AACF;","names":["DOMAIN"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@napplet/sdk",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Typed named exports wrapping window.napplet for bundler-consuming napplet developers",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -20,25 +20,13 @@
20
20
  "access": "public"
21
21
  },
22
22
  "dependencies": {
23
- "@napplet/core": "workspace:*",
24
- "@napplet/nub-relay": "workspace:*",
25
- "@napplet/nub-identity": "workspace:*",
26
- "@napplet/nub-storage": "workspace:*",
27
- "@napplet/nub-ifc": "workspace:*",
28
- "@napplet/nub-theme": "workspace:*",
29
- "@napplet/nub-keys": "workspace:*",
30
- "@napplet/nub-media": "workspace:*",
31
- "@napplet/nub-notify": "workspace:*",
32
- "@napplet/nub-config": "workspace:*"
23
+ "@napplet/core": "0.3.0",
24
+ "@napplet/nub": "0.3.0"
33
25
  },
34
26
  "devDependencies": {
35
27
  "tsup": "^8.5.0",
36
28
  "typescript": "^5.9.3"
37
29
  },
38
- "scripts": {
39
- "build": "tsup",
40
- "type-check": "tsc --noEmit"
41
- },
42
30
  "license": "MIT",
43
31
  "repository": {
44
32
  "type": "git",
@@ -51,5 +39,9 @@
51
39
  "sdk",
52
40
  "iframe",
53
41
  "nip-01"
54
- ]
55
- }
42
+ ],
43
+ "scripts": {
44
+ "build": "tsup",
45
+ "type-check": "tsc --noEmit"
46
+ }
47
+ }