@wenathlan/devthink 2.0.15 → 2.0.20
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/CHANGELOG.md +54 -0
- package/{dist/bridge.d.ts → bridge.d.ts} +1 -1
- package/bridge.d.ts.map +1 -0
- package/bridge.js +1877 -0
- package/bun.d.ts.map +1 -0
- package/bun.js +52329 -0
- package/caps/background.json +712 -0
- package/caps/cli.json +360 -0
- package/caps/library.json +3611 -0
- package/caps/mcp.json +126 -0
- package/caps/pagebridge.json +377 -0
- package/caps/popup.json +51 -0
- package/caps/sidepanel.json +522 -0
- package/checksums.txt +142 -0
- package/cli.d.ts.map +1 -0
- package/{dist/cli.js → cli.js} +2 -2
- package/companion.d.ts.map +1 -0
- package/companion.js +389 -0
- package/crossbrowser.d.ts.map +1 -0
- package/crossbrowser.js +1191 -0
- package/dashdone.d.ts.map +1 -0
- package/dashdone.js +368 -0
- package/deno.d.ts.map +1 -0
- package/deno.js +52325 -0
- package/devthink.umd.js +52346 -0
- package/fixtures/bun.ts +7 -0
- package/fixtures/cjs.js +6 -0
- package/fixtures/deno.ts +6 -0
- package/fixtures/example-org-pagestate.json +22 -0
- package/fixtures/importers/automa-workflow.json +18 -0
- package/fixtures/importers/selenium-side.json +20 -0
- package/fixtures/importers/tabular-plan.csv +7 -0
- package/fixtures/importers/uivision-macro.json +10 -0
- package/fixtures/importers/v1-plan.json +13 -0
- package/fixtures/mcp-client.mjs +14 -0
- package/fixtures/pages/checkout.html +192 -0
- package/fixtures/pages/dashboard.html +110 -0
- package/fixtures/pages/feed.html +113 -0
- package/fixtures/pages/product-grid.html +150 -0
- package/fixtures/plans/form-inventory-plan.json +11 -0
- package/fixtures/plans/release-notes-plan.json +11 -0
- package/fixtures/recipes/agentscompete.json +11 -0
- package/fixtures/recipes/agentsforms.json +11 -0
- package/fixtures/recipes/agentsmonitor.json +11 -0
- package/fixtures/recipes/agentsreview.json +29 -0
- package/fixtures/recipes/agentswarm.json +11 -0
- package/fixtures/recipes/fillcalendar.json +12 -0
- package/fixtures/recipes/fillcheckout.json +13 -0
- package/fixtures/recipes/filldependentdropdowns.json +12 -0
- package/fixtures/recipes/fillfromcsv.json +13 -0
- package/fixtures/recipes/fillloginform.json +12 -0
- package/fixtures/recipes/fillmultistepwizard.json +13 -0
- package/fixtures/recipes/fillregistration.json +12 -0
- package/fixtures/recipes/fillsearchfilters.json +12 -0
- package/fixtures/recipes/filltypeahead.json +11 -0
- package/fixtures/recipes/monitoralerts.json +12 -0
- package/fixtures/recipes/monitoravailability.json +11 -0
- package/fixtures/recipes/monitornetworkquiet.json +12 -0
- package/fixtures/recipes/monitorpagechanges.json +11 -0
- package/fixtures/recipes/monitorpricechange.json +11 -0
- package/fixtures/recipes/monitorschedule.json +12 -0
- package/fixtures/recipes/scrapedynamicprices.json +13 -0
- package/fixtures/recipes/scrapeimagegallery.json +12 -0
- package/fixtures/recipes/scrapeinfinitefeed.json +13 -0
- package/fixtures/recipes/scrapenestedlists.json +12 -0
- package/fixtures/recipes/scrapeproductgrid.json +12 -0
- package/fixtures/recipes/scrapereviews.json +12 -0
- package/fixtures/recipes/scrapesearchresults.json +12 -0
- package/fixtures/recipes/scrapetablepagination.json +12 -0
- package/fixtures/recipes/testaccessibility.json +34 -0
- package/fixtures/recipes/testconsoleerrors.json +12 -0
- package/fixtures/recipes/testdeeplinks.json +12 -0
- package/fixtures/recipes/testformvalidation.json +13 -0
- package/fixtures/recipes/testlayoutshift.json +12 -0
- package/fixtures/recipes/testlinkcheck.json +12 -0
- package/fixtures/recipes/testloadtiming.json +12 -0
- package/fixtures/recipes/testvisualdiff.json +12 -0
- package/fixtures/workflows/changelog-digest-workflow.json +13 -0
- package/fixtures/workflows/form-survey-workflow.json +13 -0
- package/gallery.json +706 -0
- package/hardening.d.ts.map +1 -0
- package/hardening.js +188 -0
- package/headless.d.ts.map +1 -0
- package/headless.js +11522 -0
- package/http.d.ts.map +1 -0
- package/http.js +2165 -0
- package/index.cjs +54682 -0
- package/index.d.ts.map +1 -0
- package/index.js +52310 -0
- package/index.neutral.js +46343 -0
- package/{web/manifest.json → manifest.json} +1 -1
- package/mcp.d.ts.map +1 -0
- package/mcp.js +20515 -0
- package/memory.d.ts.map +1 -0
- package/{memory.ts → memory.js} +2310 -3834
- package/nativehost.template.json +10 -0
- package/node.cjs +54686 -0
- package/node.d.ts.map +1 -0
- package/pack.d.ts.map +1 -0
- package/pack.js +805 -0
- package/package.json +83 -176
- package/policy.d.ts.map +1 -0
- package/{policy.ts → policy.js} +4679 -5073
- package/progress.d.ts.map +1 -0
- package/progress.js +645 -0
- package/protocol.d.ts.map +1 -0
- package/protocol.js +8334 -0
- package/schemas/audit.schema.json +226 -0
- package/schemas/capability.schema.json +113 -0
- package/schemas/envelope.schema.json +162 -0
- package/schemas/memory.schema.json +51 -0
- package/schemas/observation.schema.json +113 -0
- package/schemas/plan.schema.json +208 -0
- package/schemas/progress.schema.json +126 -0
- package/schemas/proposal.schema.json +68 -0
- package/schemas/session.schema.json +82 -0
- package/schemas/tool.schema.json +94 -0
- package/server.d.ts.map +1 -0
- package/server.js +28877 -0
- package/umd-example.html +18 -0
- package/umd.d.ts.map +1 -0
- package/accounts.ts +0 -2087
- package/agent.ts +0 -2331
- package/antigravity.ts +0 -2139
- package/apifreeze.ts +0 -4146
- package/auth.ts +0 -642
- package/background.ts +0 -16837
- package/bridge.ts +0 -2080
- package/build.ts +0 -54
- package/bun.ts +0 -26
- package/capture.ts +0 -1614
- package/checksecrets.ts +0 -72
- package/cjs.ts +0 -9
- package/cli.ts +0 -3500
- package/commands.ts +0 -1101
- package/companion.ts +0 -450
- package/compatibility.ts +0 -37
- package/config.ts +0 -3137
- package/constants.ts +0 -943
- package/core.ts +0 -1473
- package/crossbrowser.ts +0 -1359
- package/dashdone.ts +0 -605
- package/data.ts +0 -943
- package/database.ts +0 -133
- package/debug.ts +0 -850
- package/deno.ts +0 -27
- package/devthink.ts +0 -707
- package/dist/accounts.d.ts +0 -409
- package/dist/agent.d.ts +0 -837
- package/dist/antigravity.d.ts +0 -380
- package/dist/apifreeze.d.ts +0 -113
- package/dist/auth.d.ts +0 -224
- package/dist/capture.d.ts +0 -595
- package/dist/cjs.d.ts +0 -6
- package/dist/commands.d.ts +0 -310
- package/dist/compatibility.d.ts +0 -17
- package/dist/config.d.ts +0 -1853
- package/dist/constants.d.ts +0 -637
- package/dist/core.d.ts +0 -361
- package/dist/data.d.ts +0 -330
- package/dist/database.d.ts +0 -24
- package/dist/debug.d.ts +0 -270
- package/dist/engine.d.ts +0 -74
- package/dist/environments.d.ts +0 -244
- package/dist/evidence.d.ts +0 -277
- package/dist/export.d.ts +0 -311
- package/dist/fingerprint.d.ts +0 -594
- package/dist/flow.d.ts +0 -300
- package/dist/gates.d.ts +0 -103
- package/dist/identity.d.ts +0 -51
- package/dist/ids.d.ts +0 -7
- package/dist/llm.d.ts +0 -652
- package/dist/models.d.ts +0 -1807
- package/dist/net.d.ts +0 -325
- package/dist/neutral.d.ts +0 -41
- package/dist/oauth.d.ts +0 -703
- package/dist/page.d.ts +0 -1166
- package/dist/perf.d.ts +0 -481
- package/dist/plan.d.ts +0 -134
- package/dist/project.d.ts +0 -395
- package/dist/providers.d.ts +0 -37
- package/dist/quota.d.ts +0 -453
- package/dist/recovery.d.ts +0 -621
- package/dist/request.d.ts +0 -1492
- package/dist/run.d.ts +0 -779
- package/dist/runtime.d.ts +0 -212
- package/dist/search.d.ts +0 -375
- package/dist/security.d.ts +0 -534
- package/dist/serve.d.ts +0 -136
- package/dist/session.d.ts +0 -296
- package/dist/storage.d.ts +0 -53
- package/dist/streaming.d.ts +0 -1119
- package/dist/swarm.d.ts +0 -328
- package/dist/tools.d.ts +0 -170
- package/dist/types.d.ts +0 -8357
- package/dist/utils.d.ts +0 -82
- package/dist/version.d.ts +0 -7
- package/dist/versionregistry.d.ts +0 -406
- package/dist/views.d.ts +0 -579
- package/dist/workbenchsession.d.ts +0 -69
- package/dist/workflow.d.ts +0 -649
- package/docs/readme.md +0 -92
- package/docs/schemas/antigravity.json +0 -192
- package/engine.ts +0 -1524
- package/environments.ts +0 -1005
- package/evidence.ts +0 -643
- package/export.ts +0 -889
- package/fingerprint.ts +0 -1458
- package/flow.ts +0 -1190
- package/gates.ts +0 -307
- package/gateway.ts +0 -34
- package/hardening.ts +0 -191
- package/headless.ts +0 -369
- package/http.ts +0 -2110
- package/identity.ts +0 -246
- package/ids.ts +0 -26
- package/index.ts +0 -369
- package/llm.ts +0 -2682
- package/mcp.ts +0 -1835
- package/models.ts +0 -3805
- package/modes.ts +0 -43
- package/net.ts +0 -1214
- package/neutral.ts +0 -362
- package/node.ts +0 -26
- package/oauth.ts +0 -2216
- package/offscreen.ts +0 -170
- package/pack.ts +0 -956
- package/page.ts +0 -7824
- package/pagebridge.ts +0 -1116
- package/perf.ts +0 -957
- package/plan.ts +0 -672
- package/plugin.ts +0 -76
- package/prisma.config.ts +0 -27
- package/progress.ts +0 -1308
- package/project.ts +0 -1291
- package/protocol.ts +0 -4187
- package/providers.ts +0 -246
- package/quota.ts +0 -1887
- package/recovery.ts +0 -2433
- package/request.ts +0 -4482
- package/run.ts +0 -2135
- package/runtime.ts +0 -526
- package/search.ts +0 -1760
- package/security.ts +0 -1673
- package/serve.ts +0 -419
- package/server.ts +0 -5538
- package/session.ts +0 -1162
- package/storage.ts +0 -182
- package/streaming.ts +0 -4101
- package/swarm.ts +0 -884
- package/sync.ts +0 -56
- package/tests/agentcert.test.ts +0 -128
- package/tests/agentfleet.test.ts +0 -214
- package/tests/agentreview.test.ts +0 -241
- package/tests/agentstream.test.ts +0 -335
- package/tests/agentwork.test.ts +0 -356
- package/tests/apifreeze.test.ts +0 -290
- package/tests/apimap.test.ts +0 -112
- package/tests/approvalgate.test.ts +0 -175
- package/tests/artifactmanifest.test.ts +0 -204
- package/tests/attentionfeed.test.ts +0 -163
- package/tests/backgroundruns.test.ts +0 -100
- package/tests/batchscheduling.test.ts +0 -131
- package/tests/blackboard.test.ts +0 -238
- package/tests/bridge.test.ts +0 -1088
- package/tests/browsercoverage.test.ts +0 -134
- package/tests/browserpolyfills.test.ts +0 -124
- package/tests/build.mjs +0 -1260
- package/tests/clientauth.test.ts +0 -223
- package/tests/clitools.test.ts +0 -578
- package/tests/confirmgates.test.ts +0 -190
- package/tests/containerpack.test.ts +0 -143
- package/tests/controlflow.test.ts +0 -2120
- package/tests/coordination.test.ts +0 -345
- package/tests/copyscreen.test.ts +0 -139
- package/tests/core.test.ts +0 -417
- package/tests/costcert.test.ts +0 -95
- package/tests/crossbrowser.test.ts +0 -115
- package/tests/cspaudit.test.ts +0 -79
- package/tests/dashdone.test.ts +0 -615
- package/tests/datagrid.test.ts +0 -137
- package/tests/doccheck.test.ts +0 -107
- package/tests/dombatch.test.ts +0 -109
- package/tests/emulation.test.ts +0 -282
- package/tests/environments.test.ts +0 -259
- package/tests/evidenceviews.test.ts +0 -88
- package/tests/exporttools.test.ts +0 -185
- package/tests/firefoxprep.test.ts +0 -134
- package/tests/flowlibrary.test.ts +0 -242
- package/tests/flowrun.test.ts +0 -303
- package/tests/forensics.test.ts +0 -439
- package/tests/gateway.test.ts +0 -939
- package/tests/headlesslib.test.ts +0 -171
- package/tests/httpstream.test.ts +0 -277
- package/tests/immutablelog.test.ts +0 -157
- package/tests/inboundguard.test.ts +0 -177
- package/tests/lazyload.test.ts +0 -72
- package/tests/librarymodes.test.ts +0 -623
- package/tests/llm.test.ts +0 -696
- package/tests/manifest.test.ts +0 -226
- package/tests/maskinputs.test.ts +0 -150
- package/tests/matrixverify.test.ts +0 -111
- package/tests/mavenpack.test.ts +0 -75
- package/tests/mcpserver.test.ts +0 -704
- package/tests/memory.test.ts +0 -4155
- package/tests/memorycare.test.ts +0 -230
- package/tests/migrateplan.test.ts +0 -349
- package/tests/minimization.test.ts +0 -414
- package/tests/modelroute.test.ts +0 -112
- package/tests/multiagent.test.ts +0 -440
- package/tests/nativebridge.test.ts +0 -807
- package/tests/navigation.test.ts +0 -284
- package/tests/nugetpack.test.ts +0 -83
- package/tests/orchestration.test.ts +0 -449
- package/tests/originpolicy.test.ts +0 -405
- package/tests/outputcompare.test.ts +0 -97
- package/tests/package.test.ts +0 -91
- package/tests/pagebridge.test.ts +0 -5909
- package/tests/pentest.test.ts +0 -75
- package/tests/perfrecords.test.ts +0 -257
- package/tests/permdiff.test.ts +0 -85
- package/tests/phishguard.test.ts +0 -128
- package/tests/pickerviews.test.ts +0 -155
- package/tests/pipelines.test.ts +0 -381
- package/tests/planlint.test.ts +0 -240
- package/tests/planreview.test.ts +0 -383
- package/tests/platformtargets.test.ts +0 -56
- package/tests/policy.test.ts +0 -8284
- package/tests/portability.test.ts +0 -96
- package/tests/progress.test.ts +0 -1036
- package/tests/promptlibrary.test.ts +0 -116
- package/tests/protocol.test.ts +0 -4793
- package/tests/publishingpipeline.test.ts +0 -314
- package/tests/quickactions.test.ts +0 -164
- package/tests/readiness.test.ts +0 -78
- package/tests/recipes.test.ts +0 -163
- package/tests/redactshots.test.ts +0 -216
- package/tests/registernvidiakeys.ts +0 -51
- package/tests/relayserve.test.ts +0 -304
- package/tests/releasenotes.test.ts +0 -276
- package/tests/resilience.test.ts +0 -467
- package/tests/resourceaware.test.ts +0 -187
- package/tests/runbudget.test.ts +0 -125
- package/tests/runhistory.test.ts +0 -299
- package/tests/runreplay.test.ts +0 -113
- package/tests/runresume.test.ts +0 -184
- package/tests/runstate.test.ts +0 -288
- package/tests/runtimeadapters.test.ts +0 -251
- package/tests/safariskeleton.test.ts +0 -115
- package/tests/sandboxframe.test.ts +0 -196
- package/tests/sbom.test.ts +0 -105
- package/tests/secretvault.test.ts +0 -188
- package/tests/selcache.test.ts +0 -111
- package/tests/sessioninterface.test.ts +0 -791
- package/tests/sessions.test.ts +0 -591
- package/tests/siteprefs.test.ts +0 -228
- package/tests/snapshotdelta.test.ts +0 -165
- package/tests/statusviews.test.ts +0 -237
- package/tests/stepmeter.test.ts +0 -200
- package/tests/streamparse.test.ts +0 -163
- package/tests/stylepruning.test.ts +0 -90
- package/tests/surfaces.test.ts +0 -282
- package/tests/sweep.test.ts +0 -78
- package/tests/syncbridge.test.ts +0 -164
- package/tests/taskqueue.test.ts +0 -206
- package/tests/toolcalls.test.ts +0 -336
- package/tests/toolcatalog.test.ts +0 -201
- package/tests/torture-agent.test.ts +0 -706
- package/tests/torture-auth.test.ts +0 -461
- package/tests/torture-commands.test.ts +0 -895
- package/tests/torture-data.test.ts +0 -923
- package/tests/torture-environments.test.ts +0 -285
- package/tests/torture-export.test.ts +0 -263
- package/tests/torture-http.test.ts +0 -1379
- package/tests/torture-llm.test.ts +0 -808
- package/tests/torture-memory.test.ts +0 -1084
- package/tests/torture-plan.test.ts +0 -829
- package/tests/torture-run.test.ts +0 -626
- package/tests/torture-session.test.ts +0 -928
- package/tests/torture-swarm.test.ts +0 -1245
- package/tests/torture-tools.test.ts +0 -964
- package/tests/torture-workflow.test.ts +0 -2354
- package/tests/tourviews.test.ts +0 -52
- package/tests/transparency.test.ts +0 -147
- package/tests/trigger.test.ts +0 -941
- package/tests/v1sunset.test.ts +0 -428
- package/tests/virtlist.test.ts +0 -94
- package/tests/vision.test.ts +0 -540
- package/tests/vsixpack.test.ts +0 -145
- package/tests/webapi.test.ts +0 -523
- package/tests/workflow.test.ts +0 -1785
- package/tests/workfloweditor.test.ts +0 -759
- package/tests/xpipack.test.ts +0 -128
- package/tools.ts +0 -734
- package/types.ts +0 -9908
- package/umd.ts +0 -9
- package/utils.ts +0 -249
- package/version.ts +0 -8
- package/versionregistry.ts +0 -1310
- package/views.ts +0 -2153
- package/vitest.config.ts +0 -12
- package/web/App.tsx +0 -78
- package/web/README.md +0 -47
- package/web/capacitor.config.ts +0 -46
- package/web/const.ts +0 -19
- package/web/control.shell.tsx +0 -66
- package/web/dashboardpage.ts +0 -554
- package/web/db.ts +0 -493
- package/web/design.html +0 -541
- package/web/gatewayview/Gateway.tsx +0 -345
- package/web/gatewayview/config.ts +0 -1042
- package/web/gatewayview/definition.ts +0 -174
- package/web/icons.ts +0 -15
- package/web/optionspage.ts +0 -691
- package/web/popup.ts +0 -1651
- package/web/schema.prisma +0 -176
- package/web/sidepanel.ts +0 -7941
- package/web/sitemanifest.json +0 -13
- package/web/terminal-ui.tsx +0 -622
- package/web/transparencypage.ts +0 -541
- package/web/vite.config.ts +0 -39
- package/web/workspace.ts +0 -23
- package/workbenchmemory.ts +0 -104
- package/workbenchsession.ts +0 -304
- package/workflow.ts +0 -4495
- /package/{dist/bun.d.ts → bun.d.ts} +0 -0
- /package/{dist/cli.d.ts → cli.d.ts} +0 -0
- /package/{dist/companion.d.ts → companion.d.ts} +0 -0
- /package/{dist/crossbrowser.d.ts → crossbrowser.d.ts} +0 -0
- /package/{dist/dashdone.d.ts → dashdone.d.ts} +0 -0
- /package/{dist/deno.d.ts → deno.d.ts} +0 -0
- /package/{dist/hardening.d.ts → hardening.d.ts} +0 -0
- /package/{dist/headless.d.ts → headless.d.ts} +0 -0
- /package/{dist/http.d.ts → http.d.ts} +0 -0
- /package/{dist/index.d.ts → index.d.ts} +0 -0
- /package/{dist/mcp.d.ts → mcp.d.ts} +0 -0
- /package/{dist/memory.d.ts → memory.d.ts} +0 -0
- /package/{dist/node.d.ts → node.d.ts} +0 -0
- /package/{dist/pack.d.ts → pack.d.ts} +0 -0
- /package/{dist/policy.d.ts → policy.d.ts} +0 -0
- /package/{dist/progress.d.ts → progress.d.ts} +0 -0
- /package/{dist/protocol.d.ts → protocol.d.ts} +0 -0
- /package/{dist/server.d.ts → server.d.ts} +0 -0
- /package/{dist/umd.d.ts → umd.d.ts} +0 -0
|
@@ -1,259 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import {
|
|
3
|
-
closeoffscreen,
|
|
4
|
-
defaultenvironment,
|
|
5
|
-
environmentrequirementsof,
|
|
6
|
-
environmentsof,
|
|
7
|
-
executorregistry,
|
|
8
|
-
isolatedinjection,
|
|
9
|
-
markuprenderstep,
|
|
10
|
-
offloadkinds,
|
|
11
|
-
openoffscreen,
|
|
12
|
-
poolplan,
|
|
13
|
-
routeenvironment,
|
|
14
|
-
transferablekeys,
|
|
15
|
-
workerrequestof,
|
|
16
|
-
workerresponseof,
|
|
17
|
-
acceptworkerresponse,
|
|
18
|
-
} from "../environments.js";
|
|
19
|
-
import { reviewedkinds } from "../policy.js";
|
|
20
|
-
import type { toolstep } from "../types.js";
|
|
21
|
-
|
|
22
|
-
const now = 1_000;
|
|
23
|
-
|
|
24
|
-
function step(kind: toolstep["kind"], extra: Partial<toolstep> = {}): toolstep {
|
|
25
|
-
return { id: `${kind}-step`, kind, summary: `Run the ${kind} step.`, risk: "read", ...extra };
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
describe("execution environments", () => {
|
|
29
|
-
it("routes every reviewed action kind to an allowed environment set with a default", () => {
|
|
30
|
-
const kinds = reviewedkinds();
|
|
31
|
-
expect(kinds.length).toBeGreaterThan(330);
|
|
32
|
-
const requirements = environmentrequirementsof(kinds as toolstep["kind"][]);
|
|
33
|
-
expect(requirements).toHaveLength(kinds.length);
|
|
34
|
-
for (const requirement of requirements) {
|
|
35
|
-
expect(requirement.environments.length).toBeGreaterThan(0);
|
|
36
|
-
expect(requirement.environments).toContain(requirement.defaultenvironment);
|
|
37
|
-
for (const environment of requirement.environments)
|
|
38
|
-
expect(["pagecontext", "isolatedworld", "offscreenworker", "sandboxframe"]).toContain(environment);
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
it("marks evaluate steps as isolatedworld only and untrusted markup renders as sandboxframe only", () => {
|
|
43
|
-
expect(environmentsof(step("evaluate"))).toEqual(["isolatedworld"]);
|
|
44
|
-
expect(defaultenvironment(step("evaluate"))).toBe("isolatedworld");
|
|
45
|
-
const markupstep = step("setattribute", {
|
|
46
|
-
options: JSON.stringify({ name: "data-summary", value: "inert", markup: "<p>untrusted</p>" }),
|
|
47
|
-
});
|
|
48
|
-
expect(environmentsof(markupstep)).toEqual(["sandboxframe"]);
|
|
49
|
-
expect(defaultenvironment(markupstep)).toBe("sandboxframe");
|
|
50
|
-
expect(markuprenderstep(markupstep)).toBe(true);
|
|
51
|
-
expect(
|
|
52
|
-
markuprenderstep(step("setattribute", { options: JSON.stringify({ name: "data-summary", value: "inert" }) })),
|
|
53
|
-
).toBe(false);
|
|
54
|
-
expect(markuprenderstep(step("setattribute", { options: "{not json" }))).toBe(false);
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
it("marks the parse heavy read kinds as offscreenworker eligible beside the live page", () => {
|
|
58
|
-
const families = offloadkinds();
|
|
59
|
-
expect(families.map((family) => family.task)).toEqual([
|
|
60
|
-
"htmlsnapshot",
|
|
61
|
-
"jsonpayload",
|
|
62
|
-
"tablerows",
|
|
63
|
-
"a11ytree",
|
|
64
|
-
"complexselector",
|
|
65
|
-
"stitchshots",
|
|
66
|
-
]);
|
|
67
|
-
for (const kind of [
|
|
68
|
-
"readhtml",
|
|
69
|
-
"parsehtml",
|
|
70
|
-
"readjson",
|
|
71
|
-
"parsejson",
|
|
72
|
-
"readtable",
|
|
73
|
-
"scrapetable",
|
|
74
|
-
"a11ytree",
|
|
75
|
-
"resolvexpath",
|
|
76
|
-
"deriveselector",
|
|
77
|
-
"contactsheet",
|
|
78
|
-
"timelapse",
|
|
79
|
-
"makethumbs",
|
|
80
|
-
] as const) {
|
|
81
|
-
expect(environmentsof(step(kind))).toEqual(["pagecontext", "offscreenworker"]);
|
|
82
|
-
expect(defaultenvironment(step(kind))).toBe("pagecontext");
|
|
83
|
-
}
|
|
84
|
-
expect(environmentsof(step("click"))).toEqual(["pagecontext"]);
|
|
85
|
-
expect(environmentsof(step("fillform"))).toEqual(["pagecontext"]);
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
it("maps every environmentkind to its runtime adapter in the executor registry", () => {
|
|
89
|
-
const registry = executorregistry();
|
|
90
|
-
expect(registry.map((entry) => entry.environment)).toEqual([
|
|
91
|
-
"pagecontext",
|
|
92
|
-
"isolatedworld",
|
|
93
|
-
"offscreenworker",
|
|
94
|
-
"sandboxframe",
|
|
95
|
-
]);
|
|
96
|
-
expect(registry.map((entry) => entry.adapter)).toEqual([
|
|
97
|
-
"pagebridge",
|
|
98
|
-
"scriptingapi",
|
|
99
|
-
"offscreendocument",
|
|
100
|
-
"sandboxpage",
|
|
101
|
-
]);
|
|
102
|
-
for (const entry of registry) expect(entry.description).toMatch(/\./);
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
it("routes steps by the reviewed environment field, the offload toggle and the capability grant with an inline fallback", () => {
|
|
106
|
-
expect(routeenvironment(step("readhtml"), { offload: false, granted: true }).environment).toBe("pagecontext");
|
|
107
|
-
expect(routeenvironment(step("readhtml"), { offload: true, granted: true })).toMatchObject({
|
|
108
|
-
environment: "offscreenworker",
|
|
109
|
-
fallback: false,
|
|
110
|
-
});
|
|
111
|
-
const fallback = routeenvironment(step("readhtml"), { offload: true, granted: false });
|
|
112
|
-
expect(fallback).toMatchObject({ environment: "pagecontext", fallback: true });
|
|
113
|
-
expect(fallback.reason).toMatch(/inline parsing/i);
|
|
114
|
-
expect(routeenvironment(step("evaluate"), { offload: true, granted: true }).environment).toBe("isolatedworld");
|
|
115
|
-
expect(routeenvironment(step("click"), { offload: true, granted: true }).environment).toBe("pagecontext");
|
|
116
|
-
const named = routeenvironment(step("readhtml", { environment: "offscreenworker" }), {
|
|
117
|
-
offload: false,
|
|
118
|
-
granted: true,
|
|
119
|
-
});
|
|
120
|
-
expect(named.environment).toBe("offscreenworker");
|
|
121
|
-
const refused = routeenvironment(step("click", { environment: "isolatedworld" }), { offload: true, granted: true });
|
|
122
|
-
expect(refused.environment).toBe("pagecontext");
|
|
123
|
-
expect(refused.reason).toMatch(/outside the pagecontext the click kind permits/i);
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
it("builds worker requests with the parse family and the transferable keys and reads their answers", () => {
|
|
127
|
-
const buffer = new ArrayBuffer(8);
|
|
128
|
-
const request = workerrequestof({
|
|
129
|
-
id: "w1",
|
|
130
|
-
runid: "run1",
|
|
131
|
-
stepid: "s1",
|
|
132
|
-
kind: "readhtml",
|
|
133
|
-
payload: "<html><body>heavy</body></html>",
|
|
134
|
-
options: { snapshot: buffer, label: "front page" },
|
|
135
|
-
sentat: now,
|
|
136
|
-
});
|
|
137
|
-
expect(request.task).toBe("htmlsnapshot");
|
|
138
|
-
expect(request.transferables).toEqual(["snapshot"]);
|
|
139
|
-
const partial = acceptworkerresponse(
|
|
140
|
-
workerresponseof({
|
|
141
|
-
id: "a1",
|
|
142
|
-
requestid: request.id,
|
|
143
|
-
ok: true,
|
|
144
|
-
partial: 1,
|
|
145
|
-
summary: "The first chunk streams back.",
|
|
146
|
-
receivedat: now + 5,
|
|
147
|
-
}),
|
|
148
|
-
);
|
|
149
|
-
expect(partial).toMatchObject({ done: false, partial: true });
|
|
150
|
-
const final = acceptworkerresponse(
|
|
151
|
-
workerresponseof({
|
|
152
|
-
id: "a2",
|
|
153
|
-
requestid: request.id,
|
|
154
|
-
ok: true,
|
|
155
|
-
result: "front page text",
|
|
156
|
-
summary: "The parse finished.",
|
|
157
|
-
receivedat: now + 20,
|
|
158
|
-
}),
|
|
159
|
-
);
|
|
160
|
-
expect(final).toMatchObject({ done: true, partial: false, result: "front page text" });
|
|
161
|
-
const refused = acceptworkerresponse(
|
|
162
|
-
workerresponseof({
|
|
163
|
-
id: "a3",
|
|
164
|
-
requestid: request.id,
|
|
165
|
-
ok: false,
|
|
166
|
-
summary: "The payload was malformed.",
|
|
167
|
-
receivedat: now + 25,
|
|
168
|
-
}),
|
|
169
|
-
);
|
|
170
|
-
expect(refused.done).toBe(true);
|
|
171
|
-
expect(refused.result).toBeUndefined();
|
|
172
|
-
expect(transferablekeys({ snapshot: buffer, label: "text" })).toEqual(["snapshot"]);
|
|
173
|
-
expect(transferablekeys({ label: "text" })).toEqual([]);
|
|
174
|
-
expect(() =>
|
|
175
|
-
workerrequestof({ id: "w2", runid: "run1", stepid: "s2", kind: "click", payload: "x", sentat: now }),
|
|
176
|
-
).toThrow(/outside the offscreen worker pool families/i);
|
|
177
|
-
expect(() =>
|
|
178
|
-
workerrequestof({ id: "w3", runid: "run1", stepid: "s3", kind: "readjson", payload: " ", sentat: now }),
|
|
179
|
-
).toThrow(/payload/i);
|
|
180
|
-
expect(() => workerresponseof({ id: "w4", requestid: "r", ok: true, summary: " ", receivedat: now })).toThrow(
|
|
181
|
-
/summary/i,
|
|
182
|
-
);
|
|
183
|
-
});
|
|
184
|
-
|
|
185
|
-
it("grows and shrinks the worker pool with the pending parse queue and the user configured size with no engine cap", () => {
|
|
186
|
-
expect(poolplan({ pending: 5, current: 2 })).toMatchObject({ workers: 5, added: 3, retired: 0 });
|
|
187
|
-
expect(poolplan({ pending: 1, current: 4 })).toMatchObject({ workers: 1, added: 0, retired: 3 });
|
|
188
|
-
expect(poolplan({ pending: 3, current: 3 })).toMatchObject({ workers: 3, added: 0, retired: 0 });
|
|
189
|
-
expect(poolplan({ pending: 2, current: 1, size: 8 })).toMatchObject({ workers: 8, added: 7 });
|
|
190
|
-
expect(poolplan({ pending: 9, current: 6, size: 2 })).toMatchObject({ workers: 2, retired: 4 });
|
|
191
|
-
expect(poolplan({ pending: 2, current: 2, size: 2 }).reason).toMatch(/user configured/i);
|
|
192
|
-
expect(poolplan({ pending: 2, current: 2 }).reason).toMatch(/no engine cap|match/i);
|
|
193
|
-
expect(poolplan({ pending: 1, current: 1, size: 0 })).toMatchObject({ workers: 1, added: 0, retired: 0 });
|
|
194
|
-
});
|
|
195
|
-
|
|
196
|
-
it("spawns the offscreen document on first use, reuses it across the steps of one run and closes it at completion", () => {
|
|
197
|
-
const first = openoffscreen({
|
|
198
|
-
registry: [],
|
|
199
|
-
document: "offscreen.html",
|
|
200
|
-
runid: "run1",
|
|
201
|
-
reasons: ["DOM_PARSER", "WORKERS"],
|
|
202
|
-
justification: "Heavy parsing of reviewed snapshots.",
|
|
203
|
-
now,
|
|
204
|
-
});
|
|
205
|
-
expect(first.reused).toBe(false);
|
|
206
|
-
const second = openoffscreen({
|
|
207
|
-
registry: first.registry,
|
|
208
|
-
document: "offscreen.html",
|
|
209
|
-
runid: "run1",
|
|
210
|
-
reasons: ["DOM_PARSER"],
|
|
211
|
-
justification: "Heavy parsing of reviewed snapshots.",
|
|
212
|
-
now: now + 10,
|
|
213
|
-
});
|
|
214
|
-
expect(second.reused).toBe(true);
|
|
215
|
-
expect(second.entry).toBe(first.entry);
|
|
216
|
-
const otherrun = openoffscreen({
|
|
217
|
-
registry: first.registry,
|
|
218
|
-
document: "offscreen.html",
|
|
219
|
-
runid: "run2",
|
|
220
|
-
reasons: ["DOM_PARSER"],
|
|
221
|
-
justification: "Heavy parsing of reviewed snapshots.",
|
|
222
|
-
now: now + 20,
|
|
223
|
-
});
|
|
224
|
-
expect(otherrun.reused).toBe(false);
|
|
225
|
-
const closed = closeoffscreen(otherrun.registry, "run1", now + 30);
|
|
226
|
-
expect(closed.closed).toBe(true);
|
|
227
|
-
expect(closed.registry.find((entry) => entry.runid === "run1")?.closedat).toBe(now + 30);
|
|
228
|
-
expect(closeoffscreen(closed.registry, "run1", now + 40).closed).toBe(false);
|
|
229
|
-
expect(() =>
|
|
230
|
-
openoffscreen({ registry: [], document: " ", runid: "run1", reasons: ["DOM_PARSER"], justification: "j", now }),
|
|
231
|
-
).toThrow(/document/i);
|
|
232
|
-
expect(() =>
|
|
233
|
-
openoffscreen({ registry: [], document: "offscreen.html", runid: "run1", reasons: [], justification: "j", now }),
|
|
234
|
-
).toThrow(/reasons/i);
|
|
235
|
-
expect(() =>
|
|
236
|
-
openoffscreen({
|
|
237
|
-
registry: [],
|
|
238
|
-
document: "offscreen.html",
|
|
239
|
-
runid: "run1",
|
|
240
|
-
reasons: ["DOM_PARSER"],
|
|
241
|
-
justification: " ",
|
|
242
|
-
now,
|
|
243
|
-
}),
|
|
244
|
-
).toThrow(/justification/i);
|
|
245
|
-
});
|
|
246
|
-
|
|
247
|
-
it("builds the isolated world injection of evaluate steps with reviewed arguments only", () => {
|
|
248
|
-
const injection = isolatedinjection(
|
|
249
|
-
step("evaluate", { value: "document.title", options: JSON.stringify(["arg one", "arg two"]) }),
|
|
250
|
-
);
|
|
251
|
-
expect(injection.world).toBe("ISOLATED");
|
|
252
|
-
expect(injection.code).toBe("document.title");
|
|
253
|
-
expect(injection.args).toEqual(["arg one", "arg two"]);
|
|
254
|
-
const bare = isolatedinjection(step("evaluate", { value: "1 + 1" }));
|
|
255
|
-
expect(bare.args).toEqual([]);
|
|
256
|
-
expect(() => isolatedinjection(step("evaluate", { value: " " }))).toThrow(/reviewed expression/i);
|
|
257
|
-
expect(() => isolatedinjection(step("click"))).toThrow(/evaluate kind only/i);
|
|
258
|
-
});
|
|
259
|
-
});
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import {
|
|
3
|
-
comparepairof,
|
|
4
|
-
comparepairsforsteps,
|
|
5
|
-
overlayslider,
|
|
6
|
-
shotpanelof,
|
|
7
|
-
shotpanelpan,
|
|
8
|
-
shotpanelzoom,
|
|
9
|
-
} from "../views.js";
|
|
10
|
-
import { shotpanelgate } from "../policy.js";
|
|
11
|
-
|
|
12
|
-
const now = 1_800_000_000_000;
|
|
13
|
-
|
|
14
|
-
describe("shotpanel and compareviewer", () => {
|
|
15
|
-
it("opens the shotpanel view of a granted origin with its redaction verdicts and refuses ungranted captures", () => {
|
|
16
|
-
const view = shotpanelof({
|
|
17
|
-
stepid: "step-2",
|
|
18
|
-
runid: "run-1",
|
|
19
|
-
captureid: "shot-9",
|
|
20
|
-
provenance: "fullpage",
|
|
21
|
-
origin: "https://example.com",
|
|
22
|
-
granted: ["https://example.com"],
|
|
23
|
-
redactions: [{ region: "top right card", verdict: "The card number region stays redacted." }],
|
|
24
|
-
at: now,
|
|
25
|
-
});
|
|
26
|
-
expect(view.captureid).toBe("shot-9");
|
|
27
|
-
expect(view.provenance).toBe("fullpage");
|
|
28
|
-
expect(view.redactions[0]?.verdict).toMatch(/redacted/);
|
|
29
|
-
expect(view.zoom).toBe(1);
|
|
30
|
-
expect(() =>
|
|
31
|
-
shotpanelof({
|
|
32
|
-
stepid: "step-2",
|
|
33
|
-
runid: "run-1",
|
|
34
|
-
captureid: "shot-9",
|
|
35
|
-
provenance: "viewport",
|
|
36
|
-
origin: "https://other.example",
|
|
37
|
-
granted: ["https://example.com"],
|
|
38
|
-
at: now,
|
|
39
|
-
}),
|
|
40
|
-
).toThrow(/allowlist/);
|
|
41
|
-
expect(shotpanelgate({ captureorigin: "https://example.com", granted: ["https://example.com"] }).allowed).toBe(
|
|
42
|
-
true,
|
|
43
|
-
);
|
|
44
|
-
expect(shotpanelgate({ captureorigin: "https://other.example", granted: ["https://example.com"] }).reason).toMatch(
|
|
45
|
-
/granted origins/,
|
|
46
|
-
);
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
it("zooms and pans the large stitched captures", () => {
|
|
50
|
-
let view = shotpanelof({
|
|
51
|
-
stepid: "step-2",
|
|
52
|
-
runid: "run-1",
|
|
53
|
-
captureid: "shot-9",
|
|
54
|
-
provenance: "fullpage",
|
|
55
|
-
origin: "https://example.com",
|
|
56
|
-
granted: ["https://example.com"],
|
|
57
|
-
at: now,
|
|
58
|
-
});
|
|
59
|
-
view = shotpanelzoom(view, 2);
|
|
60
|
-
expect(view.zoom).toBe(2);
|
|
61
|
-
view = shotpanelzoom(view, 1.5);
|
|
62
|
-
expect(view.zoom).toBe(3);
|
|
63
|
-
view = shotpanelpan(view, { x: 40, y: -10 });
|
|
64
|
-
expect(view.pan).toEqual({ x: 40, y: -10 });
|
|
65
|
-
expect(() => shotpanelzoom(view, 0)).toThrow(/positive/);
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
it("pairs the before and after captures of every executed write step and overlays them with a slider", () => {
|
|
69
|
-
const pair = comparepairof({ stepid: "step-5", beforecaptureid: "shot-10", aftercaptureid: "shot-11" });
|
|
70
|
-
expect(pair.slidervalue).toBe(50);
|
|
71
|
-
const slid = overlayslider(pair, 80);
|
|
72
|
-
expect(slid.slidervalue).toBe(80);
|
|
73
|
-
expect(() => overlayslider(pair, 120)).toThrow(/between zero and one hundred/);
|
|
74
|
-
expect(() => comparepairof({ stepid: "step-5", beforecaptureid: "shot-10", aftercaptureid: "shot-10" })).toThrow(
|
|
75
|
-
/distinct/,
|
|
76
|
-
);
|
|
77
|
-
const pairs = comparepairsforsteps(
|
|
78
|
-
[
|
|
79
|
-
{ stepid: "read-1", risk: "read", writeexecuted: false },
|
|
80
|
-
{ stepid: "fill-2", risk: "sensitive", writeexecuted: true },
|
|
81
|
-
{ stepid: "fill-3", risk: "sensitive", writeexecuted: false },
|
|
82
|
-
],
|
|
83
|
-
{ "fill-2": { beforecaptureid: "b-2", aftercaptureid: "a-2" }, "fill-3": { beforecaptureid: "b-3" } },
|
|
84
|
-
);
|
|
85
|
-
expect(pairs.map((candidate) => candidate.stepid)).toEqual(["fill-2"]);
|
|
86
|
-
expect(pairs[0]?.beforecaptureid).toBe("b-2");
|
|
87
|
-
});
|
|
88
|
-
});
|
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import {
|
|
3
|
-
chainrows,
|
|
4
|
-
csvfield,
|
|
5
|
-
csvof,
|
|
6
|
-
exportchain,
|
|
7
|
-
exportdescriptorof,
|
|
8
|
-
exportextractions,
|
|
9
|
-
exportnotes,
|
|
10
|
-
exportrecords,
|
|
11
|
-
noterow,
|
|
12
|
-
unmaskedfieldsof,
|
|
13
|
-
} from "../export.js";
|
|
14
|
-
import { defaultmaskshapes } from "../security.js";
|
|
15
|
-
import { appendlogentry, openrunlog } from "../security.js";
|
|
16
|
-
|
|
17
|
-
const now = 1_800_000_000_000;
|
|
18
|
-
|
|
19
|
-
describe("exporttools descriptors", () => {
|
|
20
|
-
it("validates the format and scope pair of every export", () => {
|
|
21
|
-
expect(exportdescriptorof("csv", "runs")).toEqual({ format: "csv", scope: "runs" });
|
|
22
|
-
expect(exportdescriptorof("json", "extractions").scope).toBe("extractions");
|
|
23
|
-
expect(exportdescriptorof("log", "notes").format).toBe("log");
|
|
24
|
-
expect(exportdescriptorof("jsonl", "audit").format).toBe("jsonl");
|
|
25
|
-
expect(exportdescriptorof("markdown", "extraction").scope).toBe("extraction");
|
|
26
|
-
expect(() => exportdescriptorof("xml", "runs")).toThrow(/csv, json, log, jsonl and markdown/);
|
|
27
|
-
expect(() => exportdescriptorof("csv", "profiles")).toThrow(
|
|
28
|
-
/runs, extractions, notes, session, audit and extraction/,
|
|
29
|
-
);
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
it("escapes csv fields the csv way", () => {
|
|
33
|
-
expect(csvfield("plain")).toBe("plain");
|
|
34
|
-
expect(csvfield('with "quote"')).toBe('"with ""quote"""');
|
|
35
|
-
expect(csvfield("a,b")).toBe('"a,b"');
|
|
36
|
-
expect(csvfield("line\nbreak")).toBe('"line\nbreak"');
|
|
37
|
-
expect(csvof([{ a: "1", b: "2" }, { a: "x,y" }])).toBe('a,b\n1,2\n"x,y",');
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
describe("exporttools records", () => {
|
|
42
|
-
it("honors the mask verdicts in every format: the verdicts mask the fields they hold back", () => {
|
|
43
|
-
const records = [{ name: "email", password: "hunter2", author: "user", note: "plain" }];
|
|
44
|
-
const csv = exportrecords({
|
|
45
|
-
descriptor: exportdescriptorof("csv", "extractions"),
|
|
46
|
-
records: [{ name: "email", password: "[redacted]", author: "user", note: "plain" }],
|
|
47
|
-
shapes: [...defaultmaskshapes],
|
|
48
|
-
});
|
|
49
|
-
expect(csv.result.rows).toBe(1);
|
|
50
|
-
expect(csv.content).toContain("[redacted]");
|
|
51
|
-
expect(csv.content).toContain("plain");
|
|
52
|
-
const json = exportrecords({
|
|
53
|
-
descriptor: exportdescriptorof("json", "extractions"),
|
|
54
|
-
records: [{ name: "email", password: "[redacted]", author: "user", note: "plain" }],
|
|
55
|
-
shapes: [...defaultmaskshapes],
|
|
56
|
-
});
|
|
57
|
-
expect(JSON.parse(json.content)[0].password).toBe("[redacted]");
|
|
58
|
-
expect(JSON.parse(json.content)[0].author).toBe("[redacted]");
|
|
59
|
-
const log = exportrecords({
|
|
60
|
-
descriptor: exportdescriptorof("log", "extractions"),
|
|
61
|
-
records: [{ name: "email", password: "[redacted]", note: "plain" }],
|
|
62
|
-
shapes: [...defaultmaskshapes],
|
|
63
|
-
});
|
|
64
|
-
expect(log.content).toContain("password=[redacted]");
|
|
65
|
-
expect(log.content).toContain("note=plain");
|
|
66
|
-
const usershapes = exportrecords({
|
|
67
|
-
descriptor: exportdescriptorof("csv", "extractions"),
|
|
68
|
-
records: [{ internalcode: "raw" }],
|
|
69
|
-
shapes: [...defaultmaskshapes, "internalcode"],
|
|
70
|
-
});
|
|
71
|
-
expect(usershapes.result.rows).toBe(1);
|
|
72
|
-
expect(usershapes.content).toContain("[redacted]");
|
|
73
|
-
expect(unmaskedfieldsof(records)).toEqual(["password"]);
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
it("refuses to export unmasked values in full under any format", () => {
|
|
77
|
-
const records = [{ name: "email", password: "hunter2" }];
|
|
78
|
-
const refused = exportrecords({
|
|
79
|
-
descriptor: exportdescriptorof("csv", "extractions"),
|
|
80
|
-
records,
|
|
81
|
-
shapes: [...defaultmaskshapes],
|
|
82
|
-
});
|
|
83
|
-
expect(refused.result.rows).toBe(0);
|
|
84
|
-
expect(refused.result.bytes).toBe(0);
|
|
85
|
-
expect(refused.content).toBe("");
|
|
86
|
-
expect(refused.result.reason).toMatch(/refuses 1 unmasked value.*password/);
|
|
87
|
-
expect(unmaskedfieldsof(records)).toEqual(["password"]);
|
|
88
|
-
expect(unmaskedfieldsof([{ apikey: "xyz" }])).toEqual(["apikey"]);
|
|
89
|
-
expect(unmaskedfieldsof([{ authorization: "Bearer raw" }])).toEqual(["authorization"]);
|
|
90
|
-
expect(unmaskedfieldsof([{ password: "[redacted]" }])).toEqual([]);
|
|
91
|
-
expect(unmaskedfieldsof([{ note: "plain" }])).toEqual([]);
|
|
92
|
-
expect(unmaskedfieldsof([{ password: "" }])).toEqual([]);
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
it("exports notes with the sealed bodies intact and the plain bodies masked", () => {
|
|
96
|
-
const notes = [
|
|
97
|
-
{
|
|
98
|
-
id: "n1",
|
|
99
|
-
origin: "https://example.org",
|
|
100
|
-
title: "Release notes",
|
|
101
|
-
author: "user",
|
|
102
|
-
sensitive: true,
|
|
103
|
-
sealedbody: "sealed:abc",
|
|
104
|
-
createdat: now,
|
|
105
|
-
updatedat: now,
|
|
106
|
-
},
|
|
107
|
-
{
|
|
108
|
-
id: "n2",
|
|
109
|
-
origin: "https://example.org",
|
|
110
|
-
title: "Plain note",
|
|
111
|
-
body: "the changelog",
|
|
112
|
-
author: "user",
|
|
113
|
-
sensitive: false,
|
|
114
|
-
createdat: now,
|
|
115
|
-
updatedat: now,
|
|
116
|
-
},
|
|
117
|
-
];
|
|
118
|
-
const row = noterow(notes[0] as never);
|
|
119
|
-
expect(row.sealedbody).toBe("sealed:abc");
|
|
120
|
-
expect(row.body).toBeUndefined();
|
|
121
|
-
const exported = exportnotes({
|
|
122
|
-
descriptor: exportdescriptorof("json", "notes"),
|
|
123
|
-
notes,
|
|
124
|
-
shapes: [...defaultmaskshapes],
|
|
125
|
-
});
|
|
126
|
-
expect(exported.result.rows).toBe(2);
|
|
127
|
-
expect(exported.content).toContain("sealed:abc");
|
|
128
|
-
expect(exported.content).toContain("Release notes");
|
|
129
|
-
const extractions = exportextractions({
|
|
130
|
-
descriptor: exportdescriptorof("csv", "extractions"),
|
|
131
|
-
rows: [{ title: "row", password: "[redacted]" }],
|
|
132
|
-
shapes: [...defaultmaskshapes],
|
|
133
|
-
});
|
|
134
|
-
expect(extractions.content).toContain("[redacted]");
|
|
135
|
-
const refusedextraction = exportextractions({
|
|
136
|
-
descriptor: exportdescriptorof("csv", "extractions"),
|
|
137
|
-
rows: [{ title: "row", password: "hunter2" }],
|
|
138
|
-
shapes: [...defaultmaskshapes],
|
|
139
|
-
});
|
|
140
|
-
expect(refusedextraction.result.reason).toMatch(/refuses 1 unmasked value/);
|
|
141
|
-
});
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
describe("exporttools chains", () => {
|
|
145
|
-
it("verifies the log chain before any byte leaves the store", async () => {
|
|
146
|
-
let log = openrunlog({ runid: "run:1", sessionid: "flowrun", now });
|
|
147
|
-
log = await appendlogentry({
|
|
148
|
-
log,
|
|
149
|
-
kind: "step",
|
|
150
|
-
summary: "The step ran.",
|
|
151
|
-
origin: "https://example.org",
|
|
152
|
-
stepid: "observe",
|
|
153
|
-
at: now,
|
|
154
|
-
});
|
|
155
|
-
log = await appendlogentry({
|
|
156
|
-
log,
|
|
157
|
-
kind: "flowrun",
|
|
158
|
-
summary: "The flowrun completed.",
|
|
159
|
-
origin: "https://example.org",
|
|
160
|
-
at: now + 10,
|
|
161
|
-
});
|
|
162
|
-
const rows = chainrows(log.entries);
|
|
163
|
-
expect(rows).toHaveLength(2);
|
|
164
|
-
expect(rows[0]).toMatchObject({ kind: "step", origin: "https://example.org", stepid: "observe" });
|
|
165
|
-
const csv = await exportchain({
|
|
166
|
-
descriptor: exportdescriptorof("csv", "runs"),
|
|
167
|
-
log,
|
|
168
|
-
shapes: [...defaultmaskshapes],
|
|
169
|
-
});
|
|
170
|
-
expect(csv.result.rows).toBe(2);
|
|
171
|
-
expect(csv.content.split("\n")[0]).toContain("kind");
|
|
172
|
-
const json = await exportchain({
|
|
173
|
-
descriptor: exportdescriptorof("json", "runs"),
|
|
174
|
-
log,
|
|
175
|
-
shapes: [...defaultmaskshapes],
|
|
176
|
-
});
|
|
177
|
-
expect(JSON.parse(json.content)).toHaveLength(2);
|
|
178
|
-
const second = log.entries[1];
|
|
179
|
-
if (second === undefined) throw new Error("The fixture chain needs its second entry.");
|
|
180
|
-
const broken = { ...log, entries: [...log.entries.slice(0, 1), { ...second, summary: "tampered" }] };
|
|
181
|
-
const refused = await exportchain({ descriptor: exportdescriptorof("csv", "runs"), log: broken, shapes: [] });
|
|
182
|
-
expect(refused.result.rows).toBe(0);
|
|
183
|
-
expect(refused.result.reason).toMatch(/chain|verification/i);
|
|
184
|
-
});
|
|
185
|
-
});
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import {
|
|
3
|
-
firefoxdenylist,
|
|
4
|
-
firefoxpermissionmap,
|
|
5
|
-
firefoxprepoverlay,
|
|
6
|
-
firefoxprepadapt,
|
|
7
|
-
firefoxprepsplitbundle,
|
|
8
|
-
firefoxprepdenylistcheck,
|
|
9
|
-
firefoxactionmap,
|
|
10
|
-
} from "../crossbrowser.js";
|
|
11
|
-
import type { browsermanifestsource, browsermanifestoverlay } from "../types.js";
|
|
12
|
-
|
|
13
|
-
const sourcesmanifest: browsermanifestsource = {
|
|
14
|
-
manifest_version: 3,
|
|
15
|
-
name: "Devthink",
|
|
16
|
-
version: "1.1.86",
|
|
17
|
-
description: "test",
|
|
18
|
-
permissions: ["activeTab", "storage", "scripting", "sidePanel"],
|
|
19
|
-
optional_permissions: ["tabs", "downloads", "clipboardRead", "clipboardWrite", "offscreen", "nativeMessaging"],
|
|
20
|
-
optional_host_permissions: ["https://*/*"],
|
|
21
|
-
background: { service_worker: "background.js", type: "module" },
|
|
22
|
-
action: { default_popup: "popup.html" },
|
|
23
|
-
side_panel: { default_path: "sidepanel.html" },
|
|
24
|
-
options_ui: { page: "optionspage.html", open_in_tab: true },
|
|
25
|
-
offscreen: { document: "offscreen.html", reasons: ["DOM_PARSER", "WORKERS"], justification: "test" },
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
describe("firefoxprep", () => {
|
|
29
|
-
it("writes the browser specific settings with the generated extension id", () => {
|
|
30
|
-
const overlay = firefoxprepoverlay({
|
|
31
|
-
extensionid: "devthink@wenathlan",
|
|
32
|
-
strictminversion: "115.0",
|
|
33
|
-
backgroundscript: "background.js",
|
|
34
|
-
});
|
|
35
|
-
expect(overlay.browser_specific_settings?.id).toBe("devthink@wenathlan");
|
|
36
|
-
expect(overlay.browser_specific_settings?.strict_min_version).toBe("115.0");
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
it("maps action keys to the firefox equivalents", () => {
|
|
40
|
-
expect(firefoxactionmap()).toEqual({
|
|
41
|
-
default_popup: "default_popup",
|
|
42
|
-
default_title: "default_title",
|
|
43
|
-
default_icon: "default_icon",
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
it("moves the service worker to an event page for firefox", () => {
|
|
48
|
-
const overlay = firefoxprepoverlay({ extensionid: "devthink@wenathlan", backgroundscript: "background.js" });
|
|
49
|
-
expect(overlay.background?.scripts).toEqual(["background.js"]);
|
|
50
|
-
expect(overlay.background?.service_worker).toBeUndefined();
|
|
51
|
-
const split = firefoxprepsplitbundle({ backgroundscript: "background.js" });
|
|
52
|
-
expect(split.scripts).toEqual(["background.js"]);
|
|
53
|
-
expect(split.serviceworkerdropped).toBe(true);
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
it("rewrites optional permission names where they differ", () => {
|
|
57
|
-
const map = firefoxpermissionmap();
|
|
58
|
-
expect(map.offscreen).toBe("");
|
|
59
|
-
expect(map.tabs).toBe("tabs");
|
|
60
|
-
expect(map.nativeMessaging).toBe("nativeMessaging");
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
it("keeps host permissions empty on every browser", () => {
|
|
64
|
-
const overlay = firefoxprepoverlay({ extensionid: "devthink@wenathlan", backgroundscript: "background.js" });
|
|
65
|
-
expect(overlay.host_permissions).toEqual([]);
|
|
66
|
-
const adapted = firefoxprepadapt({ manifest: sourcesmanifest, overlay, backgroundscripts: ["background.js"] });
|
|
67
|
-
expect(adapted.manifest.host_permissions).toEqual([]);
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
it("splits the background bundle for event page semantics", () => {
|
|
71
|
-
const overlay = firefoxprepoverlay({ extensionid: "devthink@wenathlan", backgroundscript: "background.js" });
|
|
72
|
-
expect(overlay.background?.scripts).toEqual(["background.js"]);
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
it("keeps the deny list in force across overlays", () => {
|
|
76
|
-
const check = firefoxprepdenylistcheck({ manifest: sourcesmanifest });
|
|
77
|
-
expect(check.ok).toBe(true);
|
|
78
|
-
expect(check.refused).toEqual([]);
|
|
79
|
-
const refused: browsermanifestsource = { ...sourcesmanifest, permissions: ["debugger", "storage"] };
|
|
80
|
-
const refusedcheck = firefoxprepdenylistcheck({ manifest: refused });
|
|
81
|
-
expect(refusedcheck.ok).toBe(false);
|
|
82
|
-
expect(refusedcheck.refused).toEqual(["debugger"]);
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
it("drops the offscreen field and the side_panel field on the firefox manifest", () => {
|
|
86
|
-
const overlay = firefoxprepoverlay({ extensionid: "devthink@wenathlan", backgroundscript: "background.js" });
|
|
87
|
-
const adapted = firefoxprepadapt({ manifest: sourcesmanifest, overlay, backgroundscripts: ["background.js"] });
|
|
88
|
-
expect(adapted.manifest.offscreen).toBeUndefined();
|
|
89
|
-
expect(adapted.manifest.side_panel).toBeUndefined();
|
|
90
|
-
expect(adapted.changes.length).toBeGreaterThan(5);
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
it("writes the browser_specific_settings gecko block with the extension id", () => {
|
|
94
|
-
const overlay = firefoxprepoverlay({
|
|
95
|
-
extensionid: "devthink@wenathlan",
|
|
96
|
-
strictminversion: "115.0",
|
|
97
|
-
backgroundscript: "background.js",
|
|
98
|
-
});
|
|
99
|
-
const adapted = firefoxprepadapt({ manifest: sourcesmanifest, overlay, backgroundscripts: ["background.js"] });
|
|
100
|
-
expect(adapted.manifest.browser_specific_settings?.gecko?.id).toBe("devthink@wenathlan");
|
|
101
|
-
expect(adapted.manifest.browser_specific_settings?.gecko?.strict_min_version).toBe("115.0");
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
it("refuses an overlay for the wrong browser", () => {
|
|
105
|
-
const wrong: browsermanifestoverlay = { browser: "safari" };
|
|
106
|
-
expect(() =>
|
|
107
|
-
firefoxprepadapt({ manifest: sourcesmanifest, overlay: wrong, backgroundscripts: ["background.js"] }),
|
|
108
|
-
).toThrow();
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
it("refuses a manifest with required host permissions", () => {
|
|
112
|
-
const overlay = firefoxprepoverlay({ extensionid: "devthink@wenathlan", backgroundscript: "background.js" });
|
|
113
|
-
const withHosts: browsermanifestsource = { ...sourcesmanifest, host_permissions: ["https://example.com/*"] };
|
|
114
|
-
expect(() => firefoxprepadapt({ manifest: withHosts, overlay, backgroundscripts: ["background.js"] })).toThrow();
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
it("removes the offscreen optional permission for firefox", () => {
|
|
118
|
-
const overlay = firefoxprepoverlay({ extensionid: "devthink@wenathlan", backgroundscript: "background.js" });
|
|
119
|
-
const adapted = firefoxprepadapt({ manifest: sourcesmanifest, overlay, backgroundscripts: ["background.js"] });
|
|
120
|
-
expect(adapted.manifest.optional_permissions).not.toContain("offscreen");
|
|
121
|
-
expect(adapted.manifest.optional_permissions).toContain("tabs");
|
|
122
|
-
expect(adapted.manifest.optional_permissions).toContain("nativeMessaging");
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
it("declares the firefox deny list of forbidden permissions", () => {
|
|
126
|
-
expect(firefoxdenylist).toContain("debugger");
|
|
127
|
-
expect(firefoxdenylist).toContain("cookies");
|
|
128
|
-
expect(firefoxdenylist).toContain("webRequest");
|
|
129
|
-
expect(firefoxdenylist).toContain("history");
|
|
130
|
-
expect(firefoxdenylist).toContain("bookmarks");
|
|
131
|
-
expect(firefoxdenylist).toContain("proxy");
|
|
132
|
-
expect(firefoxdenylist).toContain("management");
|
|
133
|
-
});
|
|
134
|
-
});
|