@kehto/services 0.7.0 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/index.d.ts +307 -58
- package/dist/index.js +227 -158
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -154,7 +154,7 @@ runtime.registerService('keys', createKeysService({ hostBridge: electronBridge }
|
|
|
154
154
|
|
|
155
155
|
Plug a `HostKeysBridge` when the default document listener is insufficient: Electron or Tauri apps that need to register OS-level global hotkeys (chords delivered even when the host window is not focused), native shells that route chords through a platform-specific hotkey manager (macOS Carbon, Linux X11 grab, Windows RegisterHotKey), or test harnesses that inject synthetic events through a controlled `EventTarget`. The bridge owns subscription lifecycle; the service retains per-window bookkeeping (so `onWindowDestroyed` cleanup stays identical across paths).
|
|
156
156
|
|
|
157
|
-
|
|
157
|
+
A napplet drives this end to end via `@napplet/sdk` — `keys.registerAction` to claim a chord and `keys.onAction` to receive dispatches against the real backend.
|
|
158
158
|
|
|
159
159
|
### Reserved Chords
|
|
160
160
|
|
|
@@ -344,7 +344,7 @@ runtime.registerService('media', createMediaService({ hostBridge: electronBridge
|
|
|
344
344
|
|
|
345
345
|
Plug a `HostMediaBridge` when `navigator.mediaSession` is insufficient: Electron apps that need to route transport events through the main process (lock-screen integration on Windows, Now Playing integration on macOS), Linux shells that speak MPRIS over D-Bus, native mobile wrappers that forward to AVPlayer / ExoPlayer, or test harnesses that record action events without touching the DOM. The bridge owns metadata/state mirroring and OS action routing; the service retains per-session bookkeeping (sessionRegistry + per-window send handles) so `media.command` dispatch semantics stay identical across paths.
|
|
346
346
|
|
|
347
|
-
|
|
347
|
+
A napplet drives this end to end via `@napplet/nub/media` — `mediaCreateSession({ owner: 'napplet', ... })`, `mediaReportState`, and `mediaOnCommand` against the real backend.
|
|
348
348
|
|
|
349
349
|
## Public API
|
|
350
350
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ServiceHandler, Signer } from '@kehto/runtime';
|
|
2
|
-
import {
|
|
2
|
+
import { NostrFilter, NostrEvent, EventTemplate } from '@napplet/core';
|
|
3
3
|
import { MediaMetadata, MediaAction } from '@napplet/nub/media/types';
|
|
4
4
|
export { MediaAction } from '@napplet/nub/media/types';
|
|
5
5
|
import { NotifySendMessage } from '@napplet/nub/notify/types';
|
|
@@ -181,53 +181,19 @@ declare function createNotificationService(options?: NotificationServiceOptions)
|
|
|
181
181
|
* - signer.nip04.encrypt/decrypt -> DELETED
|
|
182
182
|
* - signer.nip44.encrypt/decrypt -> DELETED (shell encrypts internally
|
|
183
183
|
* inside relay.publishEncrypted)
|
|
184
|
-
* - identity.decrypt -> ADDED in v1.8 as a shell-mediated decrypt request
|
|
185
|
-
* with class gate + typed error union.
|
|
186
184
|
*
|
|
187
|
-
*
|
|
185
|
+
* Identity is strictly read-only per NAP-IDENTITY: napplets learn *about* the
|
|
186
|
+
* user but cannot act *as* the user — no signing, encryption, or decryption.
|
|
187
|
+
* (An `identity.decrypt` capability was briefly added in v1.8 and removed as a
|
|
188
|
+
* spec violation; decryption belongs to the runtime, inline over the wire.)
|
|
188
189
|
*
|
|
189
|
-
* Handles
|
|
190
|
+
* Handles 9 identity.* request types from @napplet/nub/identity. getPublicKey
|
|
190
191
|
* and getRelays return real values sourced from hooks.auth.getSigner(); the
|
|
191
192
|
* remaining 7 (getProfile/getFollows/getList/getZaps/getMutes/getBlocked/
|
|
192
|
-
* getBadges) are stub-level
|
|
193
|
-
*
|
|
193
|
+
* getBadges) are stub-level. Host apps plug real backends via
|
|
194
|
+
* runtime.registerService('identity', realHandler).
|
|
194
195
|
*/
|
|
195
196
|
|
|
196
|
-
type IdentityDecryptErrorCode = 'class-forbidden' | 'signer-denied' | 'signer-unavailable' | 'decrypt-failed' | 'malformed-wrap' | 'impersonation' | 'unsupported-encryption' | 'policy-denied';
|
|
197
|
-
interface Rumor {
|
|
198
|
-
id: string;
|
|
199
|
-
pubkey: string;
|
|
200
|
-
created_at: number;
|
|
201
|
-
kind: number;
|
|
202
|
-
tags: string[][];
|
|
203
|
-
content: string;
|
|
204
|
-
}
|
|
205
|
-
interface IdentityDecryptMessage extends NappletMessage {
|
|
206
|
-
type: 'identity.decrypt';
|
|
207
|
-
id: string;
|
|
208
|
-
event: NostrEvent;
|
|
209
|
-
}
|
|
210
|
-
interface IdentityDecryptResultMessage extends NappletMessage {
|
|
211
|
-
type: 'identity.decrypt.result';
|
|
212
|
-
id: string;
|
|
213
|
-
rumor: Rumor;
|
|
214
|
-
sender: string;
|
|
215
|
-
}
|
|
216
|
-
interface IdentityDecryptErrorMessage extends NappletMessage {
|
|
217
|
-
type: 'identity.decrypt.error';
|
|
218
|
-
id: string;
|
|
219
|
-
error: IdentityDecryptErrorCode;
|
|
220
|
-
}
|
|
221
|
-
interface GiftWrapDecryptResult {
|
|
222
|
-
seal: NostrEvent;
|
|
223
|
-
rumor: Rumor;
|
|
224
|
-
}
|
|
225
|
-
interface HostDecryptBridge {
|
|
226
|
-
nip04Decrypt(senderPubkey: string, ciphertext: string): Promise<string>;
|
|
227
|
-
nip44Decrypt(senderPubkey: string, ciphertext: string): Promise<string>;
|
|
228
|
-
unwrapGiftWrap(wrap: NostrEvent): Promise<GiftWrapDecryptResult>;
|
|
229
|
-
}
|
|
230
|
-
type VerifyEvent = (event: NostrEvent) => boolean | Promise<boolean>;
|
|
231
197
|
/**
|
|
232
198
|
* Options for creating the identity service.
|
|
233
199
|
*
|
|
@@ -246,27 +212,14 @@ interface IdentityServiceOptions {
|
|
|
246
212
|
* availability can change dynamically.
|
|
247
213
|
*/
|
|
248
214
|
getSigner: () => Signer | null;
|
|
249
|
-
/**
|
|
250
|
-
* Return the host decrypt bridge. Called only after outer event signature
|
|
251
|
-
* verification and encryption-mode detection succeed. Null means decrypt is
|
|
252
|
-
* unavailable while the rest of the identity service remains usable.
|
|
253
|
-
*/
|
|
254
|
-
getDecryptor?: () => HostDecryptBridge | null;
|
|
255
|
-
/**
|
|
256
|
-
* Verify a received event before any decrypt attempt. Host shells should
|
|
257
|
-
* wire this to their canonical Nostr event verifier; tests and old hosts
|
|
258
|
-
* default to true for backward compatibility with the 9 read-only actions.
|
|
259
|
-
*/
|
|
260
|
-
verifyEvent?: VerifyEvent;
|
|
261
215
|
}
|
|
262
216
|
/**
|
|
263
217
|
* Create an identity service that handles NIP-5D identity.* envelope messages.
|
|
264
218
|
*
|
|
265
|
-
* Supports
|
|
266
|
-
*
|
|
219
|
+
* Supports the 9 read-only identity.* request types from @napplet/nub/identity.
|
|
220
|
+
* The two nostr-info queries (getPublicKey, getRelays) resolve through the
|
|
267
221
|
* caller-supplied signer; the remaining 7 return default/empty payloads with
|
|
268
222
|
* spec-correct envelope shapes so napplets always receive a result envelope.
|
|
269
|
-
* identity.decrypt delegates to the host decrypt bridge.
|
|
270
223
|
*
|
|
271
224
|
* @param options - Identity service configuration (getSigner)
|
|
272
225
|
* @returns A ServiceHandler ready for runtime.registerService('identity', handler)
|
|
@@ -2028,4 +1981,300 @@ interface HttpUploaderOptions {
|
|
|
2028
1981
|
*/
|
|
2029
1982
|
declare function createHttpUploader(options: HttpUploaderOptions): Uploader;
|
|
2030
1983
|
|
|
2031
|
-
|
|
1984
|
+
/**
|
|
1985
|
+
* intent-types.ts — NAP-INTENT (archetype intent dispatch) value types.
|
|
1986
|
+
*
|
|
1987
|
+
* Kehto-internal model for the NAP-INTENT wire contract (upstream draft:
|
|
1988
|
+
* napplet/nubs NAP-INTENT, namespace `window.napplet.intent`). The installed
|
|
1989
|
+
* `@napplet/core` peer predates these types, so — as with {@link ./cvm-types} —
|
|
1990
|
+
* kehto defines them here, wire-compatible with the upstream shapes, rather
|
|
1991
|
+
* than redefining the generic NIP-5D envelope.
|
|
1992
|
+
*
|
|
1993
|
+
* NAP-INTENT standardizes the *envelope*, not the payload. `archetype` is the
|
|
1994
|
+
* routing axis (which role, whose default), `protocol` is the parsing axis
|
|
1995
|
+
* (which NAP-N wire format shapes `payload`); the two are orthogonal.
|
|
1996
|
+
*
|
|
1997
|
+
* @packageDocumentation
|
|
1998
|
+
*/
|
|
1999
|
+
/**
|
|
2000
|
+
* How the shell should pick the handling napplet for an intent.
|
|
2001
|
+
*
|
|
2002
|
+
* - `"default"` — route to the user's default handler for the archetype.
|
|
2003
|
+
* - `"choose"` — prompt the user with an "open with…" chooser.
|
|
2004
|
+
* - any other string — a specific napplet dTag (cross-napplet targeting; the
|
|
2005
|
+
* shell SHOULD require the user to have authorized this for the caller).
|
|
2006
|
+
*/
|
|
2007
|
+
type IntentHandlerPreference = 'default' | 'choose' | (string & {});
|
|
2008
|
+
/** Window-behavior hints carried with an intent invoke. */
|
|
2009
|
+
interface IntentBehavior {
|
|
2010
|
+
/** Bring the handler window to the foreground. */
|
|
2011
|
+
focus?: boolean;
|
|
2012
|
+
/** Force a new window rather than reusing an existing handler instance. */
|
|
2013
|
+
newWindow?: boolean;
|
|
2014
|
+
/** Prefer reusing an already-open handler instance when one exists. */
|
|
2015
|
+
reuse?: boolean;
|
|
2016
|
+
}
|
|
2017
|
+
/** A request to dispatch an action to a napplet of a given archetype. */
|
|
2018
|
+
interface IntentRequest {
|
|
2019
|
+
/** Role slug, e.g. `"note"` (see the archetype registry). */
|
|
2020
|
+
archetype: string;
|
|
2021
|
+
/** Verb, default `"open"` (e.g. `"open"` | `"edit"` | `"pick"` | `"share"`). */
|
|
2022
|
+
action?: string;
|
|
2023
|
+
/** NAP-N id shaping `payload`; omit to use the archetype's recommended default. */
|
|
2024
|
+
protocol?: string;
|
|
2025
|
+
/** Opaque payload, typed by `protocol`. */
|
|
2026
|
+
payload?: unknown;
|
|
2027
|
+
/** Handler-selection preference. */
|
|
2028
|
+
handler?: IntentHandlerPreference;
|
|
2029
|
+
/** Window-behavior hints. */
|
|
2030
|
+
behavior?: IntentBehavior;
|
|
2031
|
+
}
|
|
2032
|
+
/** A napplet that can fulfill an archetype, sourced from the manifest catalog. */
|
|
2033
|
+
interface IntentCandidate {
|
|
2034
|
+
/** dTag of the napplet that can fulfill the archetype. */
|
|
2035
|
+
dTag: string;
|
|
2036
|
+
/** Human-readable title from the manifest. */
|
|
2037
|
+
title?: string;
|
|
2038
|
+
/** Verbs this candidate supports for the archetype. */
|
|
2039
|
+
actions: string[];
|
|
2040
|
+
/** NAP-N ids this candidate accepts for the archetype. */
|
|
2041
|
+
protocols: string[];
|
|
2042
|
+
/** Whether this candidate is the user/runtime default for the archetype. */
|
|
2043
|
+
isDefault?: boolean;
|
|
2044
|
+
}
|
|
2045
|
+
/** Availability of an archetype, sourced from the installed-napplet catalog. */
|
|
2046
|
+
interface IntentAvailability {
|
|
2047
|
+
/** The archetype this availability describes. */
|
|
2048
|
+
archetype: string;
|
|
2049
|
+
/** True when at least one installed napplet fulfills the archetype. */
|
|
2050
|
+
available: boolean;
|
|
2051
|
+
/** Candidate napplets that fulfill the archetype (from manifests, not instances). */
|
|
2052
|
+
candidates: IntentCandidate[];
|
|
2053
|
+
/** True when a user/runtime default handler is set for the archetype. */
|
|
2054
|
+
hasDefault: boolean;
|
|
2055
|
+
}
|
|
2056
|
+
/** The result of an intent invocation. */
|
|
2057
|
+
interface IntentResult {
|
|
2058
|
+
/** Whether the intent was dispatched successfully. */
|
|
2059
|
+
ok: boolean;
|
|
2060
|
+
/** The requested archetype, echoed back. */
|
|
2061
|
+
archetype: string;
|
|
2062
|
+
/** The resolved action (defaults to `"open"` when the request omits it). */
|
|
2063
|
+
action: string;
|
|
2064
|
+
/** True when a handler accepted the dispatch. */
|
|
2065
|
+
handled: boolean;
|
|
2066
|
+
/** dTag of the napplet that handled the intent, when one did. */
|
|
2067
|
+
handler?: string;
|
|
2068
|
+
/** Window id the handler was created or focused in. */
|
|
2069
|
+
windowId?: string;
|
|
2070
|
+
/** The wire format actually used to deliver `payload`. */
|
|
2071
|
+
protocol?: string;
|
|
2072
|
+
/** Error reason when the intent could not be fulfilled. */
|
|
2073
|
+
error?: string;
|
|
2074
|
+
}
|
|
2075
|
+
|
|
2076
|
+
/**
|
|
2077
|
+
* intent-service.ts — NAP-INTENT (archetype intent dispatch) reference service.
|
|
2078
|
+
*
|
|
2079
|
+
* Shell-side handler for the NAP-INTENT wire protocol. It is a pure envelope
|
|
2080
|
+
* router: it validates `intent.*` envelopes, delegates archetype resolution,
|
|
2081
|
+
* default handling, window lifecycle, and payload delivery to an injected
|
|
2082
|
+
* {@link IntentResolver}, and posts the correlated result / push messages
|
|
2083
|
+
* (echoing the request `id`) back to the napplet.
|
|
2084
|
+
*
|
|
2085
|
+
* The resolver is injected (options-as-bridge) so this service has no shell or
|
|
2086
|
+
* window-manager dependency and is fully unit-testable. A concrete
|
|
2087
|
+
* catalog-backed resolver ships alongside as {@link createCatalogIntentResolver}.
|
|
2088
|
+
*
|
|
2089
|
+
* ──────────────────────────── Responsibilities ────────────────────────────
|
|
2090
|
+
* Inbound: intent.invoke, intent.available, intent.handlers
|
|
2091
|
+
* Outbound: intent.invoke.result, intent.available.result,
|
|
2092
|
+
* intent.handlers.result, intent.changed
|
|
2093
|
+
*
|
|
2094
|
+
* The shell owns archetype→handler resolution, the user's default-handler
|
|
2095
|
+
* preference, the "open with…" chooser, and window creation/focus — all behind
|
|
2096
|
+
* the {@link IntentResolver}. This service only marshals the wire protocol and
|
|
2097
|
+
* fans `intent.changed` pushes out to the napplets it has served.
|
|
2098
|
+
*
|
|
2099
|
+
* @example
|
|
2100
|
+
* ```ts
|
|
2101
|
+
* import { createIntentService, createCatalogIntentResolver } from '@kehto/services';
|
|
2102
|
+
*
|
|
2103
|
+
* const resolver = createCatalogIntentResolver({ loadCatalog, windows });
|
|
2104
|
+
* runtime.registerService('intent', createIntentService({ resolver }));
|
|
2105
|
+
* ```
|
|
2106
|
+
*
|
|
2107
|
+
* @packageDocumentation
|
|
2108
|
+
*/
|
|
2109
|
+
|
|
2110
|
+
/** Context passed to {@link IntentResolver.invoke} for trust/attribution. */
|
|
2111
|
+
interface IntentResolverContext {
|
|
2112
|
+
/** Window id of the napplet that issued the request. */
|
|
2113
|
+
windowId: string;
|
|
2114
|
+
}
|
|
2115
|
+
/**
|
|
2116
|
+
* Abstract intent resolver. Implementors own the installed-napplet catalog,
|
|
2117
|
+
* archetype→handler resolution, the user's default-handler preference, the
|
|
2118
|
+
* "open with…" chooser, window creation/focus, and payload delivery. The
|
|
2119
|
+
* service translates wire envelopes into these calls and back.
|
|
2120
|
+
*/
|
|
2121
|
+
interface IntentResolver {
|
|
2122
|
+
/**
|
|
2123
|
+
* Resolve `request.archetype` to a handler, create or focus its window, and
|
|
2124
|
+
* deliver `payload`. Returns once the handler is resolved and the window
|
|
2125
|
+
* created; delivery MAY complete asynchronously.
|
|
2126
|
+
*/
|
|
2127
|
+
invoke(request: IntentRequest, context: IntentResolverContext): IntentResult | Promise<IntentResult>;
|
|
2128
|
+
/** Report whether the runtime can currently satisfy `archetype`, and how. */
|
|
2129
|
+
available(archetype: string): IntentAvailability | Promise<IntentAvailability>;
|
|
2130
|
+
/** Report availability for every archetype the runtime can currently satisfy. */
|
|
2131
|
+
handlers(): IntentAvailability[] | Promise<IntentAvailability[]>;
|
|
2132
|
+
/**
|
|
2133
|
+
* Register for availability changes (a napplet installed/removed, or a default
|
|
2134
|
+
* handler changed). The service forwards each change to served napplets as an
|
|
2135
|
+
* `intent.changed` push. Returns an unsubscribe handle. Resolvers whose
|
|
2136
|
+
* catalog never changes at runtime MAY omit this.
|
|
2137
|
+
*/
|
|
2138
|
+
onChanged?(listener: (availability: IntentAvailability) => void): () => void;
|
|
2139
|
+
}
|
|
2140
|
+
/** Options for {@link createIntentService}. */
|
|
2141
|
+
interface IntentServiceOptions {
|
|
2142
|
+
/** The intent resolver the shell uses to route archetypes. Required. */
|
|
2143
|
+
resolver: IntentResolver;
|
|
2144
|
+
}
|
|
2145
|
+
/**
|
|
2146
|
+
* Create the NAP-INTENT service handler.
|
|
2147
|
+
*
|
|
2148
|
+
* @param options - Must provide an {@link IntentResolver}.
|
|
2149
|
+
* @returns A `ServiceHandler` ready for `runtime.registerService('intent', handler)`.
|
|
2150
|
+
* @throws If `options.resolver` is missing.
|
|
2151
|
+
*/
|
|
2152
|
+
declare function createIntentService(options: IntentServiceOptions): ServiceHandler;
|
|
2153
|
+
|
|
2154
|
+
/**
|
|
2155
|
+
* catalog-intent-resolver.ts — NAP-INTENT concrete {@link IntentResolver}.
|
|
2156
|
+
*
|
|
2157
|
+
* A reference resolver that satisfies {@link IntentResolver} from an
|
|
2158
|
+
* installed-napplet catalog plus host-supplied policy: the user's
|
|
2159
|
+
* default-handler preference, an optional "open with…" chooser, the archetype's
|
|
2160
|
+
* recommended default protocol, and a window controller that creates or focuses
|
|
2161
|
+
* the handler window and delivers the payload.
|
|
2162
|
+
*
|
|
2163
|
+
* Resolution policy (mirrors an OS implicit-intent + default-app model):
|
|
2164
|
+
* 1. Gather candidates for the archetype from the catalog.
|
|
2165
|
+
* 2. Pick the handler — an explicit `handler` dTag, a user choice
|
|
2166
|
+
* (`handler: "choose"`), the user's default, the sole candidate, or a
|
|
2167
|
+
* deterministic first-candidate fallback.
|
|
2168
|
+
* 3. Validate the resolved handler supports the requested `action` and
|
|
2169
|
+
* `protocol` (or fall back to the archetype's recommended default protocol,
|
|
2170
|
+
* then the candidate's first accepted protocol).
|
|
2171
|
+
* 4. Open or focus the handler window and return its id.
|
|
2172
|
+
*
|
|
2173
|
+
* The catalog, defaults, chooser, and window controller are all injected, so
|
|
2174
|
+
* this resolver carries no shell, manifest, or DOM dependency and is fully
|
|
2175
|
+
* unit-testable.
|
|
2176
|
+
*
|
|
2177
|
+
* @packageDocumentation
|
|
2178
|
+
*/
|
|
2179
|
+
|
|
2180
|
+
/** The actions/protocols a napplet fulfills for a single archetype. */
|
|
2181
|
+
interface IntentArchetypeSupport {
|
|
2182
|
+
/** Verbs this napplet supports for the archetype (e.g. `["open", "edit"]`). */
|
|
2183
|
+
actions: string[];
|
|
2184
|
+
/** NAP-N protocol ids this napplet accepts for the archetype. */
|
|
2185
|
+
protocols: string[];
|
|
2186
|
+
}
|
|
2187
|
+
/**
|
|
2188
|
+
* One installed napplet's intent surface, derived from its signed NIP-5A
|
|
2189
|
+
* manifest. Keyed by archetype slug so a single napplet can fulfill several
|
|
2190
|
+
* roles.
|
|
2191
|
+
*/
|
|
2192
|
+
interface IntentCatalogEntry {
|
|
2193
|
+
/** The napplet's dTag. */
|
|
2194
|
+
dTag: string;
|
|
2195
|
+
/** Human-readable title from the manifest. */
|
|
2196
|
+
title?: string;
|
|
2197
|
+
/** Archetype slug → the actions/protocols this napplet fulfills for it. */
|
|
2198
|
+
archetypes: Record<string, IntentArchetypeSupport>;
|
|
2199
|
+
}
|
|
2200
|
+
/** Parameters handed to {@link IntentWindowController.open}. */
|
|
2201
|
+
interface IntentOpenParams {
|
|
2202
|
+
/** dTag of the resolved handler napplet. */
|
|
2203
|
+
dTag: string;
|
|
2204
|
+
/** The archetype being dispatched. */
|
|
2205
|
+
archetype: string;
|
|
2206
|
+
/** The resolved action (e.g. `"open"`). */
|
|
2207
|
+
action: string;
|
|
2208
|
+
/** The wire format the payload is delivered with, when one was resolved. */
|
|
2209
|
+
protocol?: string;
|
|
2210
|
+
/** The opaque payload to deliver. */
|
|
2211
|
+
payload?: unknown;
|
|
2212
|
+
/** Window-behavior hints from the request. */
|
|
2213
|
+
behavior?: IntentBehavior;
|
|
2214
|
+
/** Window id of the napplet that issued the intent. */
|
|
2215
|
+
callerWindowId: string;
|
|
2216
|
+
}
|
|
2217
|
+
/** Creates or focuses the handler window and delivers the intent payload. */
|
|
2218
|
+
interface IntentWindowController {
|
|
2219
|
+
/**
|
|
2220
|
+
* Create or focus the handler window and deliver `payload` via `protocol`.
|
|
2221
|
+
* Returns the window id the handler was created or focused in.
|
|
2222
|
+
*/
|
|
2223
|
+
open(params: IntentOpenParams): {
|
|
2224
|
+
windowId: string;
|
|
2225
|
+
} | Promise<{
|
|
2226
|
+
windowId: string;
|
|
2227
|
+
}>;
|
|
2228
|
+
}
|
|
2229
|
+
/** Options for {@link createCatalogIntentResolver}. */
|
|
2230
|
+
interface CatalogIntentResolverOptions {
|
|
2231
|
+
/** Return the installed-napplet catalog (signed NIP-5A manifests). Required. */
|
|
2232
|
+
loadCatalog(): IntentCatalogEntry[] | Promise<IntentCatalogEntry[]>;
|
|
2233
|
+
/** Window controller used to create/focus the resolved handler's window. Required. */
|
|
2234
|
+
windows: IntentWindowController;
|
|
2235
|
+
/**
|
|
2236
|
+
* The user's default handler dTag for an archetype, or `undefined` when none
|
|
2237
|
+
* is set. Default-handler settings are user state — never set by napplets.
|
|
2238
|
+
*/
|
|
2239
|
+
getDefaultHandler?(archetype: string): string | undefined;
|
|
2240
|
+
/**
|
|
2241
|
+
* Resolve a `handler: "choose"` prompt (or a no-default ambiguity) to a dTag.
|
|
2242
|
+
* Returning `undefined` means the user cancelled. When omitted, ambiguous
|
|
2243
|
+
* resolution falls back to the first candidate.
|
|
2244
|
+
*/
|
|
2245
|
+
chooseHandler?(archetype: string, candidates: IntentCandidate[], callerWindowId: string): string | undefined | Promise<string | undefined>;
|
|
2246
|
+
/** The archetype's recommended default protocol when the caller omits one. */
|
|
2247
|
+
defaultProtocol?(archetype: string): string | undefined;
|
|
2248
|
+
}
|
|
2249
|
+
/**
|
|
2250
|
+
* A {@link IntentResolver} backed by a catalog, with a host hook to announce
|
|
2251
|
+
* catalog/default changes.
|
|
2252
|
+
*/
|
|
2253
|
+
interface CatalogIntentResolver extends IntentResolver {
|
|
2254
|
+
/**
|
|
2255
|
+
* Announce that the catalog or default handler for `archetype` changed. The
|
|
2256
|
+
* resolver recomputes availability and notifies `onChanged` listeners, which
|
|
2257
|
+
* the intent service forwards to napplets as `intent.changed` pushes.
|
|
2258
|
+
*/
|
|
2259
|
+
notifyChanged(archetype: string): void;
|
|
2260
|
+
}
|
|
2261
|
+
/**
|
|
2262
|
+
* Create a catalog-backed NAP-INTENT resolver.
|
|
2263
|
+
*
|
|
2264
|
+
* @param options - Catalog loader and window controller (required) plus
|
|
2265
|
+
* optional default-handler, chooser, and default-protocol policy hooks.
|
|
2266
|
+
* @returns A {@link CatalogIntentResolver} for `createIntentService({ resolver })`.
|
|
2267
|
+
* @throws If `options.loadCatalog` or `options.windows` is missing.
|
|
2268
|
+
*
|
|
2269
|
+
* @example
|
|
2270
|
+
* ```ts
|
|
2271
|
+
* const resolver = createCatalogIntentResolver({
|
|
2272
|
+
* loadCatalog: () => installedNapplets,
|
|
2273
|
+
* windows: { open: ({ dTag }) => ({ windowId: openWindow(dTag) }) },
|
|
2274
|
+
* getDefaultHandler: (a) => userDefaults[a],
|
|
2275
|
+
* });
|
|
2276
|
+
* ```
|
|
2277
|
+
*/
|
|
2278
|
+
declare function createCatalogIntentResolver(options: CatalogIntentResolverOptions): CatalogIntentResolver;
|
|
2279
|
+
|
|
2280
|
+
export { type AudioServiceOptions, type AudioSource, type CacheServiceOptions, type CatalogIntentResolver, type CatalogIntentResolverOptions, type ConfigSchemaValidation, type ConfigService, type ConfigServiceOptions, type CoordinatedRelayOptions, type HostCacheBridge, type HostKeyEvent, type HostKeysBridge, type HostMediaBridge, type HttpUploaderOptions, type HttpUploaderRails, type IdentityServiceOptions, type IntentArchetypeSupport, type IntentAvailability, type IntentBehavior, type IntentCandidate, type IntentCatalogEntry, type IntentHandlerPreference, type IntentOpenParams, type IntentRequest, type IntentResolver, type IntentResolverContext, type IntentResult, type IntentServiceOptions, type IntentWindowController, type KeysServiceOptions, type MediaMetadataLike, type MediaPlaybackOwner, type MediaServiceOptions, type MediaSessionCreateOptions, type MediaSessionTarget, type MediaSourceRef, type NostrTag, type Notification, type NotificationServiceOptions, type NotifyServiceOptions, type OutboxPublishOptions, type OutboxPublishResult, type OutboxQueryOptions, type OutboxRelayPlan, type OutboxRelayPool, type OutboxResult, type OutboxRouter, type OutboxRouterSubscription, type OutboxServiceOptions, type OutboxStrategy, type OutboxSubscribeOptions, type OutboxSubscriptionSink, type OutboxTarget, type RailServerConfig, type RelayListEntry, type RelayPoolOutboxRouterOptions, type RelayPoolServiceOptions, type ResourceService, type ResourceServiceOptions, type SignEvent, type ThemeService, type ThemeServiceOptions, type UploadDimensions, type UploadRail, type UploadRequest, type UploadResult, type UploadServiceOptions, type UploadState, type UploadStatus, type Uploader, type UploaderContext, createAudioService, createBrowserMediaBridge, createCacheService, createCatalogIntentResolver, createConfigService, createCoordinatedRelay, createHttpUploader, createIdentityService, createIntentService, createKeysService, createMediaService, createNotificationService, createNotifyService, createOutboxService, createRelayPoolOutboxRouter, createRelayPoolService, createResourceService, createThemeService, createUploadService };
|