@kehto/paja 0.6.3 → 0.9.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 +132 -16
- package/dist/browser-host.js +15590 -11208
- package/dist/browser-host.js.map +1 -1
- package/dist/{chunk-ADMLM2LH.js → chunk-OWVINAW7.js} +531 -35
- package/dist/chunk-OWVINAW7.js.map +1 -0
- package/dist/cli.d.ts +18 -1
- package/dist/cli.js +10 -6
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +280 -5
- package/dist/index.js +11 -1
- package/dist/{server-qAXYczds.d.ts → server-efRTBcMR.d.ts} +132 -7
- package/package.json +12 -12
- package/dist/chunk-ADMLM2LH.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,20 +1,47 @@
|
|
|
1
|
-
import { P as PajaRawOptions, b as PajaHostConfig } from './server-
|
|
2
|
-
export { D as DEFAULT_PAJA_AGGREGATE_HASH, c as DEFAULT_PAJA_DTAG, d as DEFAULT_PAJA_HOST, e as DEFAULT_PAJA_PORT, f as DEFAULT_PAJA_RUNTIME_WAIT_MS, g as DEFAULT_PAJA_WINDOW_ID, h as DEFAULT_READY_TIMEOUT_MS, J as JsonPrimitive, i as JsonRecord, j as JsonValue, k as PAJA_SIMULATION_DOMAINS, l as PajaCapabilityDomain, a as PajaCommand, m as PajaHmrStrategy, n as PajaOptions, o as PajaOptionsError, p as PajaPointerRuntimeConfig, q as PajaServer, r as PajaServerOptions, t as PajaSimulation, u as PajaSimulationError, v as PajaSimulationRawOptions, x as PajaTargetMode, R as ReadinessError, y as ReadinessFetch, W as WaitForTargetUrlOptions, z as createPajaHostConfig, A as createPajaRuntimeHostConfig, B as formatPajaUrl, C as normalizePajaOptions, E as normalizePajaSimulation, s as startPajaServer, F as summarizePajaSimulation, w as waitForTargetUrl } from './server-
|
|
1
|
+
import { P as PajaRawOptions, b as PajaHostConfig } from './server-efRTBcMR.js';
|
|
2
|
+
export { D as DEFAULT_PAJA_AGGREGATE_HASH, c as DEFAULT_PAJA_DTAG, d as DEFAULT_PAJA_HOST, e as DEFAULT_PAJA_PORT, f as DEFAULT_PAJA_RUNTIME_WAIT_MS, g as DEFAULT_PAJA_WINDOW_ID, h as DEFAULT_READY_TIMEOUT_MS, J as JsonPrimitive, i as JsonRecord, j as JsonValue, k as PAJA_SIMULATION_DOMAINS, l as PajaCapabilityDomain, a as PajaCommand, m as PajaHmrStrategy, n as PajaOptions, o as PajaOptionsError, p as PajaPointerRuntimeConfig, q as PajaServer, r as PajaServerOptions, t as PajaSimulation, u as PajaSimulationError, v as PajaSimulationRawOptions, x as PajaTargetMode, R as ReadinessError, y as ReadinessFetch, W as WaitForTargetUrlOptions, z as createPajaHostConfig, A as createPajaRuntimeHostConfig, B as formatPajaUrl, C as normalizePajaOptions, E as normalizePajaSimulation, s as startPajaServer, F as summarizePajaSimulation, w as waitForTargetUrl } from './server-efRTBcMR.js';
|
|
3
3
|
import { NostrEvent } from 'nostr-tools';
|
|
4
4
|
import { Filter } from 'nostr-tools/filter';
|
|
5
5
|
import { ResolvedNapplet } from '@kehto/nip/5d';
|
|
6
6
|
import { ShellCapabilities } from '@kehto/shell';
|
|
7
|
+
import { IntentCatalogEntry, IntentTargetController, IntentRetentionParams, IntentRetainedDelivery } from '@kehto/services';
|
|
7
8
|
|
|
9
|
+
/**
|
|
10
|
+
* Load a JSON Paja config file from disk.
|
|
11
|
+
*
|
|
12
|
+
* @param configPath - Path to a JSON config file.
|
|
13
|
+
* @returns Raw options parsed from the config file.
|
|
14
|
+
*/
|
|
8
15
|
declare function loadPajaConfigFile(configPath: string): PajaRawOptions;
|
|
16
|
+
/**
|
|
17
|
+
* Resolve raw options by merging an optional config file with explicit values.
|
|
18
|
+
*
|
|
19
|
+
* @param raw - CLI/config options, optionally including `configPath`.
|
|
20
|
+
* @returns Raw options with config-file defaults applied.
|
|
21
|
+
*/
|
|
9
22
|
declare function resolvePajaRawOptions(raw: PajaRawOptions): PajaRawOptions;
|
|
23
|
+
/**
|
|
24
|
+
* Merge two raw Paja option objects, with override values taking precedence.
|
|
25
|
+
*
|
|
26
|
+
* @param base - Base options, usually from a config file.
|
|
27
|
+
* @param override - Explicit options, usually from CLI args.
|
|
28
|
+
* @returns Merged raw options.
|
|
29
|
+
*/
|
|
10
30
|
declare function mergePajaRawOptions(base: PajaRawOptions, override: PajaRawOptions): PajaRawOptions;
|
|
11
31
|
|
|
32
|
+
/**
|
|
33
|
+
* Render the browser host page for a Paja runtime config.
|
|
34
|
+
*
|
|
35
|
+
* @param config - Serializable host-page config.
|
|
36
|
+
* @returns Complete HTML document served by Paja.
|
|
37
|
+
*/
|
|
12
38
|
declare function renderPajaHtml(config: PajaHostConfig): string;
|
|
13
39
|
|
|
14
40
|
/** Named/addressable NIP-5D napplet manifest kind (`35129`). */
|
|
15
41
|
declare const PAJA_NAPPLET_MANIFEST_KIND = 35129;
|
|
16
42
|
/** All NIP-5D napplet manifest kinds accepted by Paja pointers (`5129`, `15129`, `35129`). */
|
|
17
43
|
declare const PAJA_NAPPLET_MANIFEST_KINDS: readonly number[];
|
|
44
|
+
/** Decoded naddr/nevent pointer accepted by Paja runtime-pointer mode. */
|
|
18
45
|
type PajaDecodedPointer = {
|
|
19
46
|
readonly type: 'naddr';
|
|
20
47
|
readonly value: string;
|
|
@@ -30,44 +57,292 @@ type PajaDecodedPointer = {
|
|
|
30
57
|
readonly kind?: number;
|
|
31
58
|
readonly relays: readonly string[];
|
|
32
59
|
};
|
|
60
|
+
/** Fully resolved pointer plus verified napplet artifact bytes. */
|
|
33
61
|
interface PajaResolvedPointer {
|
|
62
|
+
/** Decoded pointer input. */
|
|
34
63
|
readonly pointer: PajaDecodedPointer;
|
|
64
|
+
/** Manifest event resolved from relays. */
|
|
35
65
|
readonly event: NostrEvent;
|
|
66
|
+
/** Ordered relay URLs queried for the pointer, with embedded hints first. */
|
|
36
67
|
readonly relays: readonly string[];
|
|
68
|
+
/** Blossom server hints used for blob fetches. */
|
|
37
69
|
readonly blossomServers: readonly string[];
|
|
70
|
+
/** Resolved manifest `d` tag. */
|
|
38
71
|
readonly dTag: string;
|
|
72
|
+
/** Verified NIP-5A aggregate hash. */
|
|
39
73
|
readonly aggregateHash: string;
|
|
74
|
+
/** Verified target `/index.html` content. */
|
|
40
75
|
readonly indexHtml: string;
|
|
76
|
+
/** Parsed NIP-5D manifest. */
|
|
41
77
|
readonly manifest: ResolvedNapplet['manifest'];
|
|
42
78
|
}
|
|
79
|
+
/** Relay-pool contract for runtime-pointer resolution. */
|
|
43
80
|
interface PajaPointerRelayPool {
|
|
81
|
+
/** Query relays synchronously for matching manifest events. */
|
|
44
82
|
querySync(relays: string[], filter: Filter, params?: {
|
|
45
83
|
readonly maxWait?: number;
|
|
46
84
|
readonly label?: string;
|
|
47
85
|
readonly id?: string;
|
|
48
86
|
}): Promise<NostrEvent[]>;
|
|
87
|
+
/** Subscribe until all relays reach EOSE, fail, or the shared deadline expires. */
|
|
88
|
+
subscribeManyEose?(relays: string[], filter: Filter, params: {
|
|
89
|
+
readonly maxWait?: number;
|
|
90
|
+
readonly label?: string;
|
|
91
|
+
readonly id?: string;
|
|
92
|
+
readonly onevent: (event: NostrEvent) => void;
|
|
93
|
+
readonly onclose: (reasons: string[]) => void;
|
|
94
|
+
}): {
|
|
95
|
+
close(reason?: string): void | Promise<void>;
|
|
96
|
+
};
|
|
49
97
|
close?(relays: string[]): void;
|
|
50
98
|
destroy?(): void;
|
|
51
99
|
}
|
|
100
|
+
/** Options for resolving a Paja runtime pointer. */
|
|
52
101
|
interface ResolvePajaPointerOptions {
|
|
102
|
+
/** Relay pool override; defaults to a `nostr-tools` `SimplePool`. */
|
|
53
103
|
readonly pool?: PajaPointerRelayPool;
|
|
104
|
+
/** Fetch override used for Blossom blob URLs. */
|
|
54
105
|
readonly fetcher?: (url: string) => Promise<Response>;
|
|
106
|
+
/** Extra relay candidates appended after embedded pointer hints. */
|
|
55
107
|
readonly relays?: readonly string[];
|
|
108
|
+
/** Extra Blossom server hints appended during artifact fetch. */
|
|
56
109
|
readonly blossomServers?: readonly string[];
|
|
110
|
+
/** One overall deadline for relay connection, fanout, and EOSE in milliseconds. */
|
|
57
111
|
readonly maxWaitMs?: number;
|
|
58
112
|
}
|
|
113
|
+
/**
|
|
114
|
+
* Decode a NIP-19 naddr/nevent pointer for Paja runtime-pointer mode.
|
|
115
|
+
*
|
|
116
|
+
* @param value - NIP-19 pointer string.
|
|
117
|
+
* @returns Structured pointer metadata.
|
|
118
|
+
*/
|
|
59
119
|
declare function decodePajaPointer(value: string): PajaDecodedPointer;
|
|
120
|
+
/**
|
|
121
|
+
* Resolve a Paja runtime pointer into verified napplet HTML and manifest data.
|
|
122
|
+
*
|
|
123
|
+
* @param value - NIP-19 naddr or nevent pointer.
|
|
124
|
+
* @param options - Relay, fetch, and Blossom overrides.
|
|
125
|
+
* @returns Verified napplet artifact ready for srcdoc injection.
|
|
126
|
+
*/
|
|
60
127
|
declare function resolvePajaPointer(value: string, options?: ResolvePajaPointerOptions): Promise<PajaResolvedPointer>;
|
|
128
|
+
/**
|
|
129
|
+
* Inject Kehto's Class-1 CSP for verified runtime-pointer srcdoc output.
|
|
130
|
+
* NIP-5D mandates the verified srcdoc and opaque sandbox, but this baseline CSP
|
|
131
|
+
* is Kehto policy rather than a protocol requirement.
|
|
132
|
+
*
|
|
133
|
+
* @param html - Verified target HTML.
|
|
134
|
+
* @param origins - Origins the resolved target may connect to.
|
|
135
|
+
* @returns HTML with a CSP meta tag inserted.
|
|
136
|
+
*/
|
|
61
137
|
declare function injectPajaRuntimeCsp(html: string, origins: readonly string[]): string;
|
|
62
138
|
|
|
63
|
-
declare const
|
|
139
|
+
declare const PAJA_LEGACY_COMPATIBILITY_DOMAIN: string;
|
|
140
|
+
/** Domain list mirrored from the upstream web runtime for parity checks. */
|
|
141
|
+
declare const PAJA_UPSTREAM_WEB_DOMAINS: readonly ["ble", "common", "config", "count", "cvm", "dm", "identity", string, "inc", "intent", "keys", "link", "lists", "media", "notify", "outbox", "relay", "resource", "serial", "storage", "theme", "upload", "webrtc"];
|
|
142
|
+
/** Domains required during the initial Paja handshake. */
|
|
64
143
|
declare const PAJA_HANDSHAKE_DOMAINS: readonly ["shell"];
|
|
144
|
+
/** Compatibility aliases for renamed upstream capability domains. */
|
|
65
145
|
declare const PAJA_COMPATIBILITY_ALIASES: {
|
|
66
|
-
readonly
|
|
146
|
+
readonly [PAJA_LEGACY_COMPATIBILITY_DOMAIN]: "inc";
|
|
67
147
|
};
|
|
148
|
+
/** Domains Paja advertises through its simulated shell capability surface. */
|
|
68
149
|
declare const PAJA_ADVERTISED_DOMAINS: readonly ["relay", "outbox", "identity", "storage", "inc", "theme", "keys", "link", "common", "lists", "serial", "ble", "webrtc", "media", "notify", "config", "resource", "cvm", "upload", "intent", "count"];
|
|
150
|
+
/** Service names Paja expects the host runtime to provide. */
|
|
69
151
|
declare const PAJA_REQUIRED_SERVICES: readonly ["config", "cvm", "identity", "intent", "keys", "link", "common", "lists", "serial", "ble", "webrtc", "media", "notifications", "notify", "outbox", "relay", "resource", "theme", "upload", "count"];
|
|
152
|
+
/**
|
|
153
|
+
* Find advertised Paja domains missing from a shell capability snapshot.
|
|
154
|
+
*
|
|
155
|
+
* @param capabilities - Shell capability snapshot to inspect.
|
|
156
|
+
* @returns Advertised domains not present in the snapshot.
|
|
157
|
+
*/
|
|
70
158
|
declare function getMissingAdvertisedDomains(capabilities: ShellCapabilities): string[];
|
|
159
|
+
/**
|
|
160
|
+
* Find required service names missing from a runtime service list.
|
|
161
|
+
*
|
|
162
|
+
* @param services - Runtime service names to inspect.
|
|
163
|
+
* @returns Required service names that are absent.
|
|
164
|
+
*/
|
|
71
165
|
declare function getMissingServices(services: readonly string[]): string[];
|
|
72
166
|
|
|
73
|
-
|
|
167
|
+
/**
|
|
168
|
+
* Persistent Paja catalog of resolver-verified napplet installations.
|
|
169
|
+
*
|
|
170
|
+
* The catalog deliberately contains only serializable facts copied from a
|
|
171
|
+
* verified pointer result. Runtime frames, sessions, and controller state are
|
|
172
|
+
* owned elsewhere, so closing a tab cannot alter handler eligibility.
|
|
173
|
+
*
|
|
174
|
+
* @packageDocumentation
|
|
175
|
+
*/
|
|
176
|
+
|
|
177
|
+
/** Serializable verified pointer and manifest facts for one installed napplet. */
|
|
178
|
+
interface InstalledNappletRecord {
|
|
179
|
+
/** Verified manifest d-tag used as the handler identity. */
|
|
180
|
+
readonly dTag: string;
|
|
181
|
+
/** Verified NIP-5A aggregate hash for the installed artifact. */
|
|
182
|
+
readonly aggregateHash: string;
|
|
183
|
+
/** Pointer identity that can later be re-resolved and verified. */
|
|
184
|
+
readonly pointer: PajaDecodedPointer;
|
|
185
|
+
/** Optional manifest title for handler selection UI. */
|
|
186
|
+
readonly title?: string;
|
|
187
|
+
/** Exact manifest convention contracts used for intent eligibility. */
|
|
188
|
+
readonly archetypes: readonly {
|
|
189
|
+
readonly slug: string;
|
|
190
|
+
readonly convention: string;
|
|
191
|
+
readonly eventKinds?: readonly number[];
|
|
192
|
+
}[];
|
|
193
|
+
}
|
|
194
|
+
/** Listener notified when an installed artifact is inserted or removed. */
|
|
195
|
+
type InstalledNappletCatalogListener = (dTag: string) => void;
|
|
196
|
+
/**
|
|
197
|
+
* Stores verified Paja installations separately from the browser runtime.
|
|
198
|
+
*
|
|
199
|
+
* @example
|
|
200
|
+
* ```ts
|
|
201
|
+
* const catalog = new InstalledNappletCatalog();
|
|
202
|
+
* catalog.install(resolvedPointer);
|
|
203
|
+
* const candidates = catalog.intentCatalog();
|
|
204
|
+
* ```
|
|
205
|
+
*/
|
|
206
|
+
declare class InstalledNappletCatalog {
|
|
207
|
+
private readonly records;
|
|
208
|
+
private readonly listeners;
|
|
209
|
+
/** Insert or replace a record from an already resolver-verified pointer. */
|
|
210
|
+
install(resolved: PajaResolvedPointer): InstalledNappletRecord;
|
|
211
|
+
/** Remove an artifact explicitly; frame teardown never calls this method. */
|
|
212
|
+
remove(dTag: string): boolean;
|
|
213
|
+
/** Return whether a verified installation exists for a d-tag. */
|
|
214
|
+
has(dTag: string): boolean;
|
|
215
|
+
/** Return immutable serializable installed-artifact facts. */
|
|
216
|
+
installed(): readonly InstalledNappletRecord[];
|
|
217
|
+
/** Return a verified record by d-tag. */
|
|
218
|
+
get(dTag: string): InstalledNappletRecord | undefined;
|
|
219
|
+
/**
|
|
220
|
+
* Atomically confirm that a resolved target still belongs to the exact record
|
|
221
|
+
* selected before an async operation. The record object is the catalog version
|
|
222
|
+
* token, so even a same-identity replacement cannot pass this check.
|
|
223
|
+
*/
|
|
224
|
+
validateCurrent(selected: InstalledNappletRecord, target: Pick<InstalledNappletRecord, 'dTag' | 'aggregateHash'>): InstalledNappletRecord | null;
|
|
225
|
+
/** Return exact handler candidates derived only from installed manifests. */
|
|
226
|
+
intentCatalog(): IntentCatalogEntry[];
|
|
227
|
+
/** Subscribe to explicit install and artifact-removal changes. */
|
|
228
|
+
onChanged(listener: InstalledNappletCatalogListener): () => void;
|
|
229
|
+
private notify;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* Browser-owned retained NAP-INTENT target lifecycle policy.
|
|
234
|
+
*
|
|
235
|
+
* Retention is intentionally independent from browser frames. The host supplies
|
|
236
|
+
* generation creation/reuse, source-bound readiness, current-generation checks,
|
|
237
|
+
* and delivery. This controller freezes responsibility before an accepted
|
|
238
|
+
* result, then starts that policy only afterward.
|
|
239
|
+
*
|
|
240
|
+
* @packageDocumentation
|
|
241
|
+
*/
|
|
242
|
+
|
|
243
|
+
/** Opaque current target generation controlled by the browser host. */
|
|
244
|
+
interface BrowserIntentGeneration {
|
|
245
|
+
/** Host-owned stable identifier for one target generation. */
|
|
246
|
+
readonly id: string;
|
|
247
|
+
}
|
|
248
|
+
/** Terminal reasons exposed only to host observability and cleanup policy. */
|
|
249
|
+
type BrowserIntentTerminalReason = 'open-failed' | 'ready-failed' | 'no-current-target' | 'send-failed';
|
|
250
|
+
/** Browser lifecycle callbacks injected by the Paja host. */
|
|
251
|
+
interface BrowserIntentControllerOptions {
|
|
252
|
+
/** Open a compatible target or reuse its current generation. */
|
|
253
|
+
openOrReuse(params: IntentRetentionParams, attempt: number): BrowserIntentGeneration | null | Promise<BrowserIntentGeneration | null>;
|
|
254
|
+
/** Await source-bound NAP-SHELL readiness for a selected generation. */
|
|
255
|
+
waitForReady(generation: BrowserIntentGeneration): void | Promise<void>;
|
|
256
|
+
/** Return true only while the generation remains the selected current target. */
|
|
257
|
+
isCurrent(generation: BrowserIntentGeneration): boolean | Promise<boolean>;
|
|
258
|
+
/** Send the retained delivery to the current ready generation exactly once. */
|
|
259
|
+
send(generation: BrowserIntentGeneration, delivery: IntentRetentionParams['delivery']): void | Promise<void>;
|
|
260
|
+
/** Maximum open/replacement attempts after acceptance. Finite values clamp to 1–10; defaults to two. */
|
|
261
|
+
maxAttempts?: number;
|
|
262
|
+
/** Observe terminal post-acceptance policy without producing another result. */
|
|
263
|
+
onTerminal?(params: IntentRetentionParams, reason: BrowserIntentTerminalReason): void;
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Retains immutable delivery responsibility before the intent service accepts.
|
|
267
|
+
*
|
|
268
|
+
* It has no public lifecycle state: host callbacks own generation identity,
|
|
269
|
+
* readiness, reuse, and replacement. A returned task is inert until its
|
|
270
|
+
* `start()` method is invoked by the intent service after sending acceptance.
|
|
271
|
+
*/
|
|
272
|
+
declare class BrowserIntentController implements IntentTargetController {
|
|
273
|
+
private readonly options;
|
|
274
|
+
private readonly maxAttempts;
|
|
275
|
+
constructor(options: BrowserIntentControllerOptions);
|
|
276
|
+
retain(params: IntentRetentionParams): IntentRetainedDelivery;
|
|
277
|
+
private start;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* Target dev-server CORS diagnostics.
|
|
282
|
+
*
|
|
283
|
+
* Paja loads the napplet target into a `srcdoc` iframe sandboxed without
|
|
284
|
+
* `allow-same-origin`, so the napplet document has an opaque origin and sends
|
|
285
|
+
* `Origin: null` on every subresource fetch. `<script type="module">` is always
|
|
286
|
+
* fetched in CORS mode, so a dev server that does not allow the `null` origin
|
|
287
|
+
* blocks the napplet's entry module and the iframe renders blank.
|
|
288
|
+
*
|
|
289
|
+
* These helpers probe the target with an explicit `Origin: null` request so
|
|
290
|
+
* Paja can report the cause instead of leaving an empty frame behind.
|
|
291
|
+
*/
|
|
292
|
+
/** Whether the target dev server will serve the sandboxed frame's subresources. */
|
|
293
|
+
type PajaTargetCorsStatus = 'allowed' | 'blocked' | 'unreachable';
|
|
294
|
+
/** Result of probing a target dev server for opaque-origin CORS support. */
|
|
295
|
+
interface PajaTargetCorsDiagnostic {
|
|
296
|
+
/** Classification of the probe result. */
|
|
297
|
+
readonly status: PajaTargetCorsStatus;
|
|
298
|
+
/** Target URL that was probed. */
|
|
299
|
+
readonly targetUrl: string;
|
|
300
|
+
/** `access-control-allow-origin` value the target returned, when any. */
|
|
301
|
+
readonly allowOrigin: string | null;
|
|
302
|
+
/** Human-readable explanation of the classification. */
|
|
303
|
+
readonly detail: string;
|
|
304
|
+
/** Actionable remedy, present only when `status` is not `allowed`. */
|
|
305
|
+
readonly hint: string | null;
|
|
306
|
+
}
|
|
307
|
+
/** Remedy shown whenever the target rejects the sandboxed frame's `null` origin. */
|
|
308
|
+
declare const PAJA_TARGET_CORS_HINT: string;
|
|
309
|
+
/**
|
|
310
|
+
* Classify an `access-control-allow-origin` response value for an opaque origin.
|
|
311
|
+
*
|
|
312
|
+
* @param targetUrl - Target URL the header came from.
|
|
313
|
+
* @param allowOrigin - Raw `access-control-allow-origin` header value, or `null` when absent.
|
|
314
|
+
* @returns Diagnostic describing whether the sandboxed frame can load assets.
|
|
315
|
+
* @example
|
|
316
|
+
* ```ts
|
|
317
|
+
* classifyTargetCors('http://127.0.0.1:5173/', '*').status; // 'allowed'
|
|
318
|
+
* classifyTargetCors('http://127.0.0.1:5173/', null).status; // 'blocked'
|
|
319
|
+
* ```
|
|
320
|
+
*/
|
|
321
|
+
declare function classifyTargetCors(targetUrl: string, allowOrigin: string | null): PajaTargetCorsDiagnostic;
|
|
322
|
+
/** Minimal fetch surface the probe depends on. */
|
|
323
|
+
type PajaTargetCorsFetch = (input: string, init: {
|
|
324
|
+
method: string;
|
|
325
|
+
headers: Record<string, string>;
|
|
326
|
+
}) => Promise<{
|
|
327
|
+
headers: {
|
|
328
|
+
get(name: string): string | null;
|
|
329
|
+
};
|
|
330
|
+
}>;
|
|
331
|
+
/**
|
|
332
|
+
* Probe a target dev server for opaque-origin CORS support.
|
|
333
|
+
*
|
|
334
|
+
* Sends `Origin: null` explicitly — a browser cannot forge that header, but the
|
|
335
|
+
* Paja server can, which is why the probe runs server-side.
|
|
336
|
+
*
|
|
337
|
+
* @param targetUrl - Absolute target URL served by the napplet dev server.
|
|
338
|
+
* @param fetchImpl - Fetch implementation; defaults to the global `fetch`.
|
|
339
|
+
* @returns Diagnostic describing whether the sandboxed frame can load assets.
|
|
340
|
+
* @example
|
|
341
|
+
* ```ts
|
|
342
|
+
* const diagnostic = await probeTargetCors('http://127.0.0.1:5173/');
|
|
343
|
+
* if (diagnostic.status === 'blocked') console.warn(diagnostic.hint);
|
|
344
|
+
* ```
|
|
345
|
+
*/
|
|
346
|
+
declare function probeTargetCors(targetUrl: string, fetchImpl?: PajaTargetCorsFetch): Promise<PajaTargetCorsDiagnostic>;
|
|
347
|
+
|
|
348
|
+
export { BrowserIntentController, type BrowserIntentControllerOptions, type BrowserIntentGeneration, type BrowserIntentTerminalReason, InstalledNappletCatalog, type InstalledNappletCatalogListener, type InstalledNappletRecord, PAJA_ADVERTISED_DOMAINS, PAJA_COMPATIBILITY_ALIASES, PAJA_HANDSHAKE_DOMAINS, PAJA_NAPPLET_MANIFEST_KIND, PAJA_NAPPLET_MANIFEST_KINDS, PAJA_REQUIRED_SERVICES, PAJA_TARGET_CORS_HINT, PAJA_UPSTREAM_WEB_DOMAINS, type PajaDecodedPointer, PajaHostConfig, type PajaPointerRelayPool, PajaRawOptions, type PajaResolvedPointer, type PajaTargetCorsDiagnostic, type PajaTargetCorsFetch, type PajaTargetCorsStatus, type ResolvePajaPointerOptions, classifyTargetCors, decodePajaPointer, getMissingAdvertisedDomains, getMissingServices, injectPajaRuntimeCsp, loadPajaConfigFile, mergePajaRawOptions, probeTargetCors, renderPajaHtml, resolvePajaPointer, resolvePajaRawOptions };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
BrowserIntentController,
|
|
2
3
|
DEFAULT_PAJA_AGGREGATE_HASH,
|
|
3
4
|
DEFAULT_PAJA_DTAG,
|
|
4
5
|
DEFAULT_PAJA_HOST,
|
|
@@ -6,6 +7,7 @@ import {
|
|
|
6
7
|
DEFAULT_PAJA_RUNTIME_WAIT_MS,
|
|
7
8
|
DEFAULT_PAJA_WINDOW_ID,
|
|
8
9
|
DEFAULT_READY_TIMEOUT_MS,
|
|
10
|
+
InstalledNappletCatalog,
|
|
9
11
|
PAJA_ADVERTISED_DOMAINS,
|
|
10
12
|
PAJA_COMPATIBILITY_ALIASES,
|
|
11
13
|
PAJA_HANDSHAKE_DOMAINS,
|
|
@@ -13,10 +15,12 @@ import {
|
|
|
13
15
|
PAJA_NAPPLET_MANIFEST_KINDS,
|
|
14
16
|
PAJA_REQUIRED_SERVICES,
|
|
15
17
|
PAJA_SIMULATION_DOMAINS,
|
|
18
|
+
PAJA_TARGET_CORS_HINT,
|
|
16
19
|
PAJA_UPSTREAM_WEB_DOMAINS,
|
|
17
20
|
PajaOptionsError,
|
|
18
21
|
PajaSimulationError,
|
|
19
22
|
ReadinessError,
|
|
23
|
+
classifyTargetCors,
|
|
20
24
|
createPajaHostConfig,
|
|
21
25
|
createPajaRuntimeHostConfig,
|
|
22
26
|
decodePajaPointer,
|
|
@@ -28,14 +32,16 @@ import {
|
|
|
28
32
|
mergePajaRawOptions,
|
|
29
33
|
normalizePajaOptions,
|
|
30
34
|
normalizePajaSimulation,
|
|
35
|
+
probeTargetCors,
|
|
31
36
|
renderPajaHtml,
|
|
32
37
|
resolvePajaPointer,
|
|
33
38
|
resolvePajaRawOptions,
|
|
34
39
|
startPajaServer,
|
|
35
40
|
summarizePajaSimulation,
|
|
36
41
|
waitForTargetUrl
|
|
37
|
-
} from "./chunk-
|
|
42
|
+
} from "./chunk-OWVINAW7.js";
|
|
38
43
|
export {
|
|
44
|
+
BrowserIntentController,
|
|
39
45
|
DEFAULT_PAJA_AGGREGATE_HASH,
|
|
40
46
|
DEFAULT_PAJA_DTAG,
|
|
41
47
|
DEFAULT_PAJA_HOST,
|
|
@@ -43,6 +49,7 @@ export {
|
|
|
43
49
|
DEFAULT_PAJA_RUNTIME_WAIT_MS,
|
|
44
50
|
DEFAULT_PAJA_WINDOW_ID,
|
|
45
51
|
DEFAULT_READY_TIMEOUT_MS,
|
|
52
|
+
InstalledNappletCatalog,
|
|
46
53
|
PAJA_ADVERTISED_DOMAINS,
|
|
47
54
|
PAJA_COMPATIBILITY_ALIASES,
|
|
48
55
|
PAJA_HANDSHAKE_DOMAINS,
|
|
@@ -50,10 +57,12 @@ export {
|
|
|
50
57
|
PAJA_NAPPLET_MANIFEST_KINDS,
|
|
51
58
|
PAJA_REQUIRED_SERVICES,
|
|
52
59
|
PAJA_SIMULATION_DOMAINS,
|
|
60
|
+
PAJA_TARGET_CORS_HINT,
|
|
53
61
|
PAJA_UPSTREAM_WEB_DOMAINS,
|
|
54
62
|
PajaOptionsError,
|
|
55
63
|
PajaSimulationError,
|
|
56
64
|
ReadinessError,
|
|
65
|
+
classifyTargetCors,
|
|
57
66
|
createPajaHostConfig,
|
|
58
67
|
createPajaRuntimeHostConfig,
|
|
59
68
|
decodePajaPointer,
|
|
@@ -65,6 +74,7 @@ export {
|
|
|
65
74
|
mergePajaRawOptions,
|
|
66
75
|
normalizePajaOptions,
|
|
67
76
|
normalizePajaSimulation,
|
|
77
|
+
probeTargetCors,
|
|
68
78
|
renderPajaHtml,
|
|
69
79
|
resolvePajaPointer,
|
|
70
80
|
resolvePajaRawOptions,
|