Add a Sockethub client patch for the extension CSP
The bundled @sockethub/client compiles schemas with Ajv's new Function, which a Manifest V3 extension CSP blocks. Patch both Ajv instances to no-ops so the client loads; the Sockethub server still validates every message. Upstream issue #1336 / PR #1338 track a real fix.
This commit is contained in:
1 parent
808ed43d2f
commit
ec2eab2e3d
4 files changed
+60
-2
No files matched your search
@@ -18,6 +18,20 @@ from 2022; Dashtab pins the `next` line (`5.0.0-beta.0`) that matches the
|
||||
`io` factory is passed explicitly so the client never falls back to its dynamic
|
||||
`import("socket.io-client")`.
|
||||
|
||||
### CSP and the interim client patch
|
||||
|
||||
`@sockethub/client` bundles `@sockethub/schemas`, which validates with Ajv, and
|
||||
Ajv compiles JSON schemas with `new Function`. A Manifest V3 extension page
|
||||
forbids `unsafe-eval`, so importing the client throws before any request.
|
||||
Dashtab therefore ships a pnpm patch
|
||||
(`patches/@sockethub__client@5.0.0-beta.0.patch`) that replaces both Ajv
|
||||
instances with a no-op, skipping client-side validation; the Sockethub server
|
||||
still validates every message. Upstream issue
|
||||
[sockethub#1336](https://github.com/sockethub/sockethub/issues/1336) and PR
|
||||
[sockethub#1338](https://github.com/sockethub/sockethub/pull/1338) add a
|
||||
CSP-safe path. Once that ships, remove the patch (drop `patchedDependencies`
|
||||
from `pnpm-workspace.yaml`) and upgrade the client.
|
||||
|
||||
## Connection lifecycle
|
||||
|
||||
There is one global Sockethub server URL, stored in the `settings` namespace
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
diff --git a/dist/sockethub-client.js b/dist/sockethub-client.js
|
||||
index 12a1bc1309a3681fd8e2a1b79a49becb1902852b..650f67e26051ab7538fe654c5fdb5c8da5963669 100644
|
||||
--- a/dist/sockethub-client.js
|
||||
+++ b/dist/sockethub-client.js
|
||||
@@ -16979,7 +16979,24 @@ var ServiceDescriptorSchema = {
|
||||
};
|
||||
|
||||
// ../schemas/src/service-descriptor.ts
|
||||
-var ajv = new import_ajv.default({ strictTypes: false, allErrors: true });
|
||||
+// DASHTAB PATCH: Ajv compiles schemas with `new Function`, which a Manifest V3
|
||||
+// extension CSP (`script-src 'self'`, no `unsafe-eval`) blocks. Replace both Ajv
|
||||
+// instances with a no-op that accepts every value. The server validates every
|
||||
+// inbound message, so skipping client-side validation is safe here. Remove this
|
||||
+// patch once @sockethub/client supports CSP-restricted environments.
|
||||
+var __dashtabNoopValidate = () => true;
|
||||
+var __dashtabNoopAjv = {
|
||||
+ opts: { code: {} },
|
||||
+ compile: () => __dashtabNoopValidate,
|
||||
+ getSchema: () => __dashtabNoopValidate,
|
||||
+ addSchema() {},
|
||||
+ addFormat() {},
|
||||
+ addKeyword() {},
|
||||
+ addVocabulary() {},
|
||||
+ errorsText: () => "",
|
||||
+ errors: []
|
||||
+};
|
||||
+var ajv = __dashtabNoopAjv;
|
||||
var validator;
|
||||
function validateServiceDescriptor(descriptor) {
|
||||
validator ??= ajv.compile(ServiceDescriptorSchema);
|
||||
@@ -17092,7 +17109,7 @@ function composeFinalError(error, options) {
|
||||
}
|
||||
|
||||
// ../schemas/src/validator.ts
|
||||
-var ajv2 = new import_ajv2.default({ strictTypes: false, allErrors: true });
|
||||
+var ajv2 = __dashtabNoopAjv;
|
||||
import_ajv_formats.default(ajv2);
|
||||
import_ajv_formats_draft2019.default(ajv2);
|
||||
var schemaURL = "https://sockethub.org/schemas/v0";
|
||||
Generated
+5
-2
@@ -4,6 +4,9 @@ settings:
|
||||
autoInstallPeers: true
|
||||
excludeLinksFromLockfile: false
|
||||
|
||||
patchedDependencies:
|
||||
'@sockethub/client@5.0.0-beta.0': 9aba6e87aa0bd7ab23c7b15ed939665fc03978cd37dfc39099501d3867d4e43b
|
||||
|
||||
importers:
|
||||
|
||||
.:
|
||||
@@ -64,7 +67,7 @@ importers:
|
||||
version: 7.1.0(@babel/core@7.29.7(supports-color@10.2.2))(rollup@4.52.5)(supports-color@10.2.2)
|
||||
'@sockethub/client':
|
||||
specifier: 5.0.0-beta.0
|
||||
version: 5.0.0-beta.0(socket.io-client@4.8.4(supports-color@10.2.2))
|
||||
version: 5.0.0-beta.0(patch_hash=9aba6e87aa0bd7ab23c7b15ed939665fc03978cd37dfc39099501d3867d4e43b)(socket.io-client@4.8.4(supports-color@10.2.2))
|
||||
'@tailwindcss/vite':
|
||||
specifier: ^4.3.3
|
||||
version: 4.3.3(vite@8.3.1(@types/node@26.6.3)(jiti@2.7.0)(terser@5.51.2)(yaml@2.9.1))
|
||||
@@ -8387,7 +8390,7 @@ snapshots:
|
||||
|
||||
'@socket.io/component-emitter@3.1.2': {}
|
||||
|
||||
'@sockethub/client@5.0.0-beta.0(socket.io-client@4.8.4(supports-color@10.2.2))':
|
||||
'@sockethub/client@5.0.0-beta.0(patch_hash=9aba6e87aa0bd7ab23c7b15ed939665fc03978cd37dfc39099501d3867d4e43b)(socket.io-client@4.8.4(supports-color@10.2.2))':
|
||||
dependencies:
|
||||
'@sockethub/schemas': 3.0.0-beta.0
|
||||
eventemitter3: 5.0.4
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
allowBuilds:
|
||||
core-js: false
|
||||
esbuild: true
|
||||
patchedDependencies:
|
||||
'@sockethub/client@5.0.0-beta.0': patches/@sockethub__client@5.0.0-beta.0.patch
|
||||
Reference in new issue
Block a user