@botiverse/porthole 0.2.4 → 0.3.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 +17 -11
- package/dist/check/check.d.ts +100 -0
- package/dist/check/check.js +247 -0
- package/dist/check/drivers.d.ts +43 -0
- package/dist/check/drivers.js +181 -0
- package/dist/check/index.d.ts +8 -0
- package/dist/check/index.js +8 -0
- package/dist/check/instrument.d.ts +71 -0
- package/dist/check/instrument.js +84 -0
- package/dist/check/lint.d.ts +21 -0
- package/dist/check/lint.js +131 -0
- package/dist/check/page-source.d.ts +2 -0
- package/dist/check/page-source.js +2 -0
- package/dist/check/page.d.ts +13 -0
- package/dist/check/page.js +170 -0
- package/dist/check/tools.d.ts +61 -0
- package/dist/check/tools.js +140 -0
- package/dist/conformance/host-kit.d.ts +26 -5
- package/dist/conformance/host-kit.js +46 -22
- package/dist/conformance/index.d.ts +1 -1
- package/dist/conformance/reporter.d.ts +14 -0
- package/dist/conformance/reporter.js +28 -0
- package/dist/displays/displays.d.ts +61 -0
- package/dist/displays/displays.js +113 -0
- package/dist/host/client.d.ts +110 -0
- package/dist/host/client.js +274 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +6 -0
- package/dist/node/index.d.ts +26 -1
- package/dist/node/index.js +91 -1
- package/dist/react/frame.d.ts +79 -3
- package/dist/react/frame.js +183 -42
- package/dist/react/index.d.ts +2 -1
- package/dist/react/index.js +1 -0
- package/dist/react/view.d.ts +54 -0
- package/dist/react/view.js +151 -0
- package/dist/server/bootstrap.d.ts +27 -0
- package/dist/server/bootstrap.js +63 -0
- package/dist/server/host.d.ts +77 -8
- package/dist/server/host.js +268 -11
- package/dist/server/index.d.ts +4 -2
- package/dist/server/index.js +3 -1
- package/dist/server/pages.d.ts +19 -0
- package/dist/server/pages.js +8 -0
- package/dist/server/proxy.d.ts +24 -0
- package/dist/server/proxy.js +67 -0
- package/dist/server/server.js +14 -1
- package/dist/server/types.d.ts +8 -0
- package/docs/ADOPTING.md +278 -108
- package/docs/DECISIONS.md +280 -0
- package/docs/DESIGN.md +84 -2
- package/examples/app.mjs +82 -78
- package/examples/conformance/page.spec.mjs +23 -0
- package/examples/conformance/playwright.config.mjs +3 -2
- package/examples/conformance/porthole.spec.mjs +6 -3
- package/examples/displays.mjs +21 -0
- package/examples/mcp/server.mjs +121 -0
- package/examples/node/server.mjs +16 -34
- package/examples/workers/worker.mjs +19 -7
- package/package.json +13 -1
- package/src/check/check.ts +386 -0
- package/src/check/drivers.ts +242 -0
- package/src/check/index.ts +22 -0
- package/src/check/instrument.ts +138 -0
- package/src/check/lint.ts +238 -0
- package/src/check/page-source.ts +19 -0
- package/src/check/page.ts +230 -0
- package/src/check/tools.ts +206 -0
- package/src/conformance/host-kit.ts +82 -27
- package/src/conformance/index.ts +1 -0
- package/src/conformance/reporter.ts +38 -0
- package/src/displays/displays.ts +191 -0
- package/src/host/client.ts +395 -0
- package/src/index.ts +25 -0
- package/src/node/index.ts +112 -2
- package/src/react/frame.tsx +271 -57
- package/src/react/index.ts +9 -0
- package/src/react/view.tsx +237 -0
- package/src/server/bootstrap.ts +97 -0
- package/src/server/host.ts +372 -18
- package/src/server/index.ts +11 -1
- package/src/server/pages.ts +28 -0
- package/src/server/proxy.ts +86 -0
- package/src/server/server.ts +26 -2
- package/src/server/types.ts +5 -0
package/src/server/server.ts
CHANGED
|
@@ -251,7 +251,15 @@ export function createServer(options: ServerOptions): PortholeServer {
|
|
|
251
251
|
if (!Number.isInteger(authorizeTtl) || authorizeTtl < 0 || authorizeTtl > 300) {
|
|
252
252
|
throw new TypeError("authorize.ttlSeconds must be an integer from 0 to 300");
|
|
253
253
|
}
|
|
254
|
-
const answers = new Map<
|
|
254
|
+
const answers = new Map<
|
|
255
|
+
string,
|
|
256
|
+
{
|
|
257
|
+
readonly answer: AuthorizeAnswer;
|
|
258
|
+
readonly until: number;
|
|
259
|
+
readonly scope: string;
|
|
260
|
+
readonly subject: string | null;
|
|
261
|
+
}
|
|
262
|
+
>();
|
|
255
263
|
|
|
256
264
|
if (options.hostOrigins.length === 0) {
|
|
257
265
|
throw new TypeError("hostOrigins must name the origins that embed content");
|
|
@@ -338,7 +346,12 @@ export function createServer(options: ServerOptions): PortholeServer {
|
|
|
338
346
|
} catch {
|
|
339
347
|
given = { allow: false };
|
|
340
348
|
}
|
|
341
|
-
answer = {
|
|
349
|
+
answer = {
|
|
350
|
+
answer: given,
|
|
351
|
+
until: at + authorizeTtl * 1_000,
|
|
352
|
+
scope: access.instance.scope,
|
|
353
|
+
subject: access.subject ?? null,
|
|
354
|
+
};
|
|
342
355
|
if (authorizeTtl > 0) {
|
|
343
356
|
if (answers.size > 10_000) {
|
|
344
357
|
answers.clear();
|
|
@@ -1047,6 +1060,17 @@ export function createServer(options: ServerOptions): PortholeServer {
|
|
|
1047
1060
|
return { url: `${origin}${path}`, origin, reports: true };
|
|
1048
1061
|
},
|
|
1049
1062
|
|
|
1063
|
+
forget(filter = {}) {
|
|
1064
|
+
for (const [key, each] of answers) {
|
|
1065
|
+
if (
|
|
1066
|
+
(filter.scope === undefined || each.scope === filter.scope) &&
|
|
1067
|
+
(filter.subject === undefined || each.subject === filter.subject)
|
|
1068
|
+
) {
|
|
1069
|
+
answers.delete(key);
|
|
1070
|
+
}
|
|
1071
|
+
}
|
|
1072
|
+
},
|
|
1073
|
+
|
|
1050
1074
|
urlOf(scope, path = "/") {
|
|
1051
1075
|
if (!path.startsWith("/") || path.startsWith("//") || path.startsWith(PREFIX)) {
|
|
1052
1076
|
throw new TypeError("A clean address's path starts with one / and isn't Porthole's own");
|
package/src/server/types.ts
CHANGED
|
@@ -216,6 +216,11 @@ export interface PortholeServer {
|
|
|
216
216
|
access(request: Request): Promise<Access | null>;
|
|
217
217
|
/** The frame source every content origin matches (`https://*.example-usercontent.com`). */
|
|
218
218
|
readonly contentSource: string;
|
|
219
|
+
/**
|
|
220
|
+
* Drops cached `authorize.check` answers (`ttlSeconds`): all, or a scope's, or a subject's, so a
|
|
221
|
+
* revocation holds at once (P072).
|
|
222
|
+
*/
|
|
223
|
+
forget(filter?: { readonly scope?: string; readonly subject?: string }): void;
|
|
219
224
|
/** A clean address on a scope's origin (P068): what a tab, a link, a bookmark opens. */
|
|
220
225
|
urlOf(scope: string, path?: string): string;
|
|
221
226
|
/** A redirect entry's state, signature checked; null for one this server didn't make. */
|