@proton-app/main 0.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 +50 -0
- package/dist/files.d.ts +10 -0
- package/dist/files.js +21 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +22 -0
- package/dist/ipc.d.ts +24 -0
- package/dist/ipc.js +49 -0
- package/dist/window.d.ts +10 -0
- package/dist/window.js +29 -0
- package/package.json +74 -0
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,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setupCspPolicy = exports.devCsp = exports.csp = void 0;
|
|
4
|
+
const electron_1 = require("electron");
|
|
5
|
+
const ts_1 = require("@bouko/ts");
|
|
6
|
+
/**
|
|
7
|
+
* Content Security Policies.
|
|
8
|
+
*
|
|
9
|
+
* Production:
|
|
10
|
+
* - Restrict all resources to the app bundle (`'self'`) by default.
|
|
11
|
+
* - Allow network access only to Supabase.
|
|
12
|
+
* - Enable safe playback of audio/media via `blob:` and `data:` URLs.
|
|
13
|
+
* - Explicitly disable dangerous features such as plugins and framing.
|
|
14
|
+
*
|
|
15
|
+
* Development:
|
|
16
|
+
* - Relax restrictions to support hot reload, devtools, and local servers.
|
|
17
|
+
* - Allow inline scripts and eval (required by some bundlers/dev servers).
|
|
18
|
+
* - Permit WebSocket connections to localhost.
|
|
19
|
+
**/
|
|
20
|
+
exports.csp = "default-src 'self'; " +
|
|
21
|
+
"script-src 'self'; " +
|
|
22
|
+
"style-src 'self'; " +
|
|
23
|
+
"img-src 'self' data: https:; " +
|
|
24
|
+
"font-src 'self' data:; " +
|
|
25
|
+
`connect-src 'self' blob: ${(0, ts_1.getEnv)("BASE_URL")} ${(0, ts_1.getEnv)("DB_URL")}; ` +
|
|
26
|
+
"media-src 'self' blob: data:; " +
|
|
27
|
+
"worker-src 'self' blob:; " +
|
|
28
|
+
"object-src 'none'; " +
|
|
29
|
+
"base-uri 'self'; " +
|
|
30
|
+
"frame-ancestors 'none';";
|
|
31
|
+
exports.devCsp = "default-src 'self' http://localhost:* blob: data:; " +
|
|
32
|
+
"script-src 'self' 'unsafe-eval' 'unsafe-inline' http://localhost:*; " +
|
|
33
|
+
"style-src 'self' 'unsafe-inline' http://localhost:*; " +
|
|
34
|
+
"img-src 'self' data: blob: http://localhost:* https:; " +
|
|
35
|
+
"media-src 'self' blob: data:; " +
|
|
36
|
+
"worker-src 'self' blob: http://localhost:*; " +
|
|
37
|
+
`connect-src 'self' blob: http://localhost:* ws://localhost:* ${(0, ts_1.getEnv)("BASE_URL")} ${(0, ts_1.getEnv)("DB_URL")};`;
|
|
38
|
+
const setupCspPolicy = () => electron_1.session.defaultSession.webRequest.onHeadersReceived((details, callback) => {
|
|
39
|
+
if (details.url.startsWith("file://") || details.url.startsWith("http://localhost")) {
|
|
40
|
+
callback({
|
|
41
|
+
responseHeaders: {
|
|
42
|
+
...details.responseHeaders,
|
|
43
|
+
"Content-Security-Policy": [!electron_1.app.isPackaged ? exports.devCsp : exports.csp],
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
callback({ responseHeaders: details.responseHeaders });
|
|
49
|
+
});
|
|
50
|
+
exports.setupCspPolicy = setupCspPolicy;
|
package/dist/files.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { BrowserWindow } from "electron";
|
|
2
|
+
type Props = {
|
|
3
|
+
window: BrowserWindow;
|
|
4
|
+
title: string;
|
|
5
|
+
defaultPath: "music";
|
|
6
|
+
};
|
|
7
|
+
export declare function choosePath({ window, title, defaultPath }: Props): Promise<string | null>;
|
|
8
|
+
export declare const getUserDataPath: (...segments: string[]) => string;
|
|
9
|
+
export declare const getAppDataPath: (...segments: string[]) => string;
|
|
10
|
+
export {};
|
package/dist/files.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getAppDataPath = exports.getUserDataPath = void 0;
|
|
4
|
+
exports.choosePath = choosePath;
|
|
5
|
+
const electron_1 = require("electron");
|
|
6
|
+
const path_1 = require("path");
|
|
7
|
+
async function choosePath({ window, title, defaultPath }) {
|
|
8
|
+
const result = await electron_1.dialog.showOpenDialog(window, {
|
|
9
|
+
title,
|
|
10
|
+
defaultPath: defaultPath ? electron_1.app.getPath(defaultPath) : undefined,
|
|
11
|
+
properties: ["openDirectory", "createDirectory"]
|
|
12
|
+
});
|
|
13
|
+
if (result.canceled || result.filePaths.length === 0)
|
|
14
|
+
return null;
|
|
15
|
+
return result.filePaths[0];
|
|
16
|
+
}
|
|
17
|
+
;
|
|
18
|
+
const getUserDataPath = (...segments) => (0, path_1.join)(electron_1.app.getPath("userData"), ...segments);
|
|
19
|
+
exports.getUserDataPath = getUserDataPath;
|
|
20
|
+
const getAppDataPath = (...segments) => (0, path_1.join)(electron_1.app.getPath("appData"), ...segments);
|
|
21
|
+
exports.getAppDataPath = getAppDataPath;
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/// <reference path="../types/ipc.d.ts" />
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
15
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
16
|
+
};
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
require("../types/ipc");
|
|
19
|
+
__exportStar(require("./csp"), exports);
|
|
20
|
+
__exportStar(require("./files"), exports);
|
|
21
|
+
__exportStar(require("./ipc"), exports);
|
|
22
|
+
__exportStar(require("./window"), exports);
|
package/dist/ipc.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export declare function setupAppIpc(): void;
|
|
2
|
+
export type IpcSchema = Record<string, Record<string, {
|
|
3
|
+
input?: unknown;
|
|
4
|
+
result: unknown;
|
|
5
|
+
}>>;
|
|
6
|
+
type Input<S extends IpcSchema, N extends keyof S, K extends keyof S[N]> = S[N][K] extends {
|
|
7
|
+
input: infer I;
|
|
8
|
+
} ? I : undefined;
|
|
9
|
+
type Result<S extends IpcSchema, N extends keyof S, K extends keyof S[N]> = S[N][K] extends {
|
|
10
|
+
result: infer R;
|
|
11
|
+
} ? R : never;
|
|
12
|
+
type Namespace<S extends IpcSchema, N extends keyof S> = {
|
|
13
|
+
on<K extends keyof S[N] & string>(key: K, handler: (input: Input<S, N, K>) => Result<S, N, K> | Promise<Result<S, N, K>>): void;
|
|
14
|
+
};
|
|
15
|
+
type Client<S extends IpcSchema> = {
|
|
16
|
+
[N in keyof S]: Namespace<S, N>;
|
|
17
|
+
};
|
|
18
|
+
export declare class IpcManager<S extends IpcSchema> {
|
|
19
|
+
private delimiter;
|
|
20
|
+
readonly ipc: Client<S>;
|
|
21
|
+
constructor(delimiter?: string);
|
|
22
|
+
private makeNamespace;
|
|
23
|
+
}
|
|
24
|
+
export {};
|
package/dist/ipc.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IpcManager = void 0;
|
|
4
|
+
exports.setupAppIpc = setupAppIpc;
|
|
5
|
+
const electron_1 = require("electron");
|
|
6
|
+
const files_1 = require("./files");
|
|
7
|
+
function setupAppIpc() {
|
|
8
|
+
electron_1.ipcMain.on("app:minimize", (event) => {
|
|
9
|
+
const window = electron_1.BrowserWindow.fromWebContents(event.sender);
|
|
10
|
+
window?.minimize();
|
|
11
|
+
});
|
|
12
|
+
electron_1.ipcMain.on("app:close", (event) => {
|
|
13
|
+
const window = electron_1.BrowserWindow.fromWebContents(event.sender);
|
|
14
|
+
window?.close();
|
|
15
|
+
});
|
|
16
|
+
electron_1.ipcMain.on("app:open-link", (_, url) => {
|
|
17
|
+
if (url)
|
|
18
|
+
electron_1.shell.openExternal(url);
|
|
19
|
+
});
|
|
20
|
+
electron_1.ipcMain.handle("app:choose-path", async (event) => {
|
|
21
|
+
const window = electron_1.BrowserWindow.fromWebContents(event.sender);
|
|
22
|
+
if (!window)
|
|
23
|
+
return;
|
|
24
|
+
return await (0, files_1.choosePath)({
|
|
25
|
+
window: window,
|
|
26
|
+
title: "Choose Vault Folder",
|
|
27
|
+
defaultPath: "music"
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
class IpcManager {
|
|
32
|
+
delimiter;
|
|
33
|
+
ipc;
|
|
34
|
+
constructor(delimiter = ":") {
|
|
35
|
+
this.delimiter = delimiter;
|
|
36
|
+
this.ipc = new Proxy({}, {
|
|
37
|
+
get: (_target, ns) => this.makeNamespace(ns),
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
makeNamespace(ns) {
|
|
41
|
+
const ch = (key) => `${ns}${this.delimiter}${key}`;
|
|
42
|
+
return {
|
|
43
|
+
on: (key, handler) => {
|
|
44
|
+
electron_1.ipcMain.handle(ch(key), (_event, input) => handler(input));
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
exports.IpcManager = IpcManager;
|
package/dist/window.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { BrowserWindow } from "electron";
|
|
2
|
+
export type Options = {
|
|
3
|
+
entry: string;
|
|
4
|
+
preload: string;
|
|
5
|
+
width: number;
|
|
6
|
+
height: number;
|
|
7
|
+
icon?: string;
|
|
8
|
+
};
|
|
9
|
+
export declare function createWindow(opts: Options): BrowserWindow;
|
|
10
|
+
export declare const getMainWindow: () => BrowserWindow | null;
|
package/dist/window.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getMainWindow = void 0;
|
|
4
|
+
exports.createWindow = createWindow;
|
|
5
|
+
const electron_1 = require("electron");
|
|
6
|
+
let mainWindow = null;
|
|
7
|
+
function createWindow(opts) {
|
|
8
|
+
if (mainWindow && !mainWindow.isDestroyed())
|
|
9
|
+
return mainWindow;
|
|
10
|
+
mainWindow = new electron_1.BrowserWindow({
|
|
11
|
+
width: opts.width,
|
|
12
|
+
height: opts.height,
|
|
13
|
+
icon: opts.icon,
|
|
14
|
+
show: false,
|
|
15
|
+
frame: false,
|
|
16
|
+
resizable: false,
|
|
17
|
+
webPreferences: {
|
|
18
|
+
preload: opts.preload,
|
|
19
|
+
contextIsolation: true,
|
|
20
|
+
nodeIntegration: false
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
mainWindow.once("ready-to-show", () => mainWindow?.show());
|
|
24
|
+
mainWindow.on("closed", () => (mainWindow = null));
|
|
25
|
+
void mainWindow.loadURL(opts.entry);
|
|
26
|
+
return mainWindow;
|
|
27
|
+
}
|
|
28
|
+
const getMainWindow = () => mainWindow;
|
|
29
|
+
exports.getMainWindow = getMainWindow;
|
package/package.json
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
{
|
|
2
|
+
|
|
3
|
+
"name": "@proton-app/main",
|
|
4
|
+
|
|
5
|
+
"version": "0.0.1",
|
|
6
|
+
|
|
7
|
+
"description": "",
|
|
8
|
+
|
|
9
|
+
"keywords": [],
|
|
10
|
+
|
|
11
|
+
"author": "",
|
|
12
|
+
|
|
13
|
+
"license": "ISC",
|
|
14
|
+
|
|
15
|
+
"main": "./dist/index.js",
|
|
16
|
+
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
|
|
19
|
+
"files": [
|
|
20
|
+
|
|
21
|
+
"dist"
|
|
22
|
+
|
|
23
|
+
],
|
|
24
|
+
|
|
25
|
+
"publishConfig": {
|
|
26
|
+
|
|
27
|
+
"access": "public"
|
|
28
|
+
|
|
29
|
+
},
|
|
30
|
+
|
|
31
|
+
"exports": {
|
|
32
|
+
|
|
33
|
+
".": {
|
|
34
|
+
|
|
35
|
+
"default": "./dist/index.js",
|
|
36
|
+
|
|
37
|
+
"types": "./dist/index.d.ts"
|
|
38
|
+
|
|
39
|
+
},
|
|
40
|
+
|
|
41
|
+
"./types": "./dist/index.d.ts"
|
|
42
|
+
|
|
43
|
+
},
|
|
44
|
+
|
|
45
|
+
"engines": {},
|
|
46
|
+
|
|
47
|
+
"scripts": {
|
|
48
|
+
|
|
49
|
+
"build": "tsc"
|
|
50
|
+
|
|
51
|
+
},
|
|
52
|
+
|
|
53
|
+
"dependencies": {
|
|
54
|
+
|
|
55
|
+
"@bouko/ts": "^0.3.8",
|
|
56
|
+
|
|
57
|
+
"path": "^0.12.7"
|
|
58
|
+
|
|
59
|
+
},
|
|
60
|
+
|
|
61
|
+
"devDependencies": {
|
|
62
|
+
|
|
63
|
+
"@types/react": "^19.2.13",
|
|
64
|
+
|
|
65
|
+
"electron": "^39.2.7",
|
|
66
|
+
|
|
67
|
+
"react-router-dom": "^7.12.0",
|
|
68
|
+
|
|
69
|
+
"typescript": "^5.9.3"
|
|
70
|
+
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
}
|
|
74
|
+
|