@bouko/electron 1.0.0 → 1.0.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/dist/csp.d.ts +17 -0
- package/dist/csp.js +48 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +6 -2
package/dist/csp.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Content Security Policies.
|
|
3
|
+
*
|
|
4
|
+
* Production:
|
|
5
|
+
* - Restrict all resources to the app bundle (`'self'`) by default.
|
|
6
|
+
* - Allow network access only to Supabase.
|
|
7
|
+
* - Enable safe playback of audio/media via `blob:` and `data:` URLs.
|
|
8
|
+
* - Explicitly disable dangerous features such as plugins and framing.
|
|
9
|
+
*
|
|
10
|
+
* Development:
|
|
11
|
+
* - Relax restrictions to support hot reload, devtools, and local servers.
|
|
12
|
+
* - Allow inline scripts and eval (required by some bundlers/dev servers).
|
|
13
|
+
* - Permit WebSocket connections to localhost.
|
|
14
|
+
**/
|
|
15
|
+
export declare const csp: string;
|
|
16
|
+
export declare const devCsp: string;
|
|
17
|
+
export declare const setupCspPolicy: () => void;
|
package/dist/csp.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { app, session } from "electron";
|
|
2
|
+
import { getEnv } from "@bouko/ts";
|
|
3
|
+
/**
|
|
4
|
+
* Content Security Policies.
|
|
5
|
+
*
|
|
6
|
+
* Production:
|
|
7
|
+
* - Restrict all resources to the app bundle (`'self'`) by default.
|
|
8
|
+
* - Allow network access only to Supabase.
|
|
9
|
+
* - Enable safe playback of audio/media via `blob:` and `data:` URLs.
|
|
10
|
+
* - Explicitly disable dangerous features such as plugins and framing.
|
|
11
|
+
*
|
|
12
|
+
* Development:
|
|
13
|
+
* - Relax restrictions to support hot reload, devtools, and local servers.
|
|
14
|
+
* - Allow inline scripts and eval (required by some bundlers/dev servers).
|
|
15
|
+
* - Permit WebSocket connections to localhost.
|
|
16
|
+
**/
|
|
17
|
+
export const csp = "default-src 'self'; " +
|
|
18
|
+
"script-src 'self'; " +
|
|
19
|
+
"style-src 'self'; " +
|
|
20
|
+
"img-src 'self' data: https:; " +
|
|
21
|
+
"font-src 'self' data:; " +
|
|
22
|
+
`connect-src 'self' blob: ${getEnv("DB_URL")}; ` +
|
|
23
|
+
"media-src 'self' blob: data:; " +
|
|
24
|
+
"worker-src 'self' blob:; " +
|
|
25
|
+
"object-src 'none'; " +
|
|
26
|
+
"base-uri 'self'; " +
|
|
27
|
+
"frame-ancestors 'none';";
|
|
28
|
+
export const devCsp = "default-src 'self' http://localhost:* blob: data:; " +
|
|
29
|
+
"script-src 'self' 'unsafe-eval' 'unsafe-inline' http://localhost:*; " +
|
|
30
|
+
"style-src 'self' 'unsafe-inline' http://localhost:*; " +
|
|
31
|
+
"img-src 'self' data: blob: http://localhost:* https:; " +
|
|
32
|
+
"media-src 'self' blob: data:; " +
|
|
33
|
+
"worker-src 'self' blob: http://localhost:*; " +
|
|
34
|
+
`connect-src 'self' blob: http://localhost:* ws://localhost:* ${getEnv("DB_URL")};`;
|
|
35
|
+
export const setupCspPolicy = () => session.defaultSession.webRequest.onHeadersReceived((details, callback) => {
|
|
36
|
+
if (details.url.startsWith("file://") ||
|
|
37
|
+
details.url.startsWith("http://localhost")) {
|
|
38
|
+
callback({
|
|
39
|
+
responseHeaders: {
|
|
40
|
+
...details.responseHeaders,
|
|
41
|
+
"Content-Security-Policy": [!app.isPackaged ? devCsp : csp],
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
// Do NOT touch third-party pages (SoundCloud, etc.)
|
|
47
|
+
callback({ responseHeaders: details.responseHeaders });
|
|
48
|
+
});
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
"name": "@bouko/electron",
|
|
4
4
|
|
|
5
|
-
"version": "1.0.
|
|
5
|
+
"version": "1.0.1",
|
|
6
6
|
|
|
7
7
|
"description": "",
|
|
8
8
|
|
|
@@ -38,12 +38,16 @@
|
|
|
38
38
|
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
|
|
41
|
-
"electron": "^39.2.7"
|
|
41
|
+
"electron": "^39.2.7",
|
|
42
|
+
|
|
43
|
+
"react-router-dom": "^7.12.0"
|
|
42
44
|
|
|
43
45
|
},
|
|
44
46
|
|
|
45
47
|
"dependencies": {
|
|
46
48
|
|
|
49
|
+
"@bouko/ts": "^0.3.8",
|
|
50
|
+
|
|
47
51
|
"path": "^0.12.7"
|
|
48
52
|
|
|
49
53
|
}
|