@nemigo/electron 1.5.0 → 2.0.0
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/security.d.ts +5 -4
- package/dist/security.js +6 -6
- package/package.json +11 -6
package/dist/security.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { WebContents } from "electron";
|
|
1
2
|
/**
|
|
2
3
|
* Политика защиты навигации и управления доступом к внешним URL.
|
|
3
4
|
* Защищает от навигационных атак, ограничивая переходы только разрешенным домены
|
|
@@ -25,13 +26,13 @@ export declare class NetworkSecurity {
|
|
|
25
26
|
*
|
|
26
27
|
* ```typescript
|
|
27
28
|
* app.on("web-contents-created", (_, contents) => {
|
|
28
|
-
* contents.on("will-navigate",
|
|
29
|
-
* contents.setWindowOpenHandler(
|
|
29
|
+
* contents.on("will-navigate", () => ...); // __handleNavigation
|
|
30
|
+
* contents.setWindowOpenHandler(() => ...); // __handleWindowOpen
|
|
30
31
|
* });
|
|
31
32
|
* ```
|
|
32
33
|
*/
|
|
33
34
|
init(): this;
|
|
34
|
-
|
|
35
|
-
|
|
35
|
+
__handleNavigation(contents: WebContents): void;
|
|
36
|
+
__handleWindowOpen(contents: WebContents): void;
|
|
36
37
|
}
|
|
37
38
|
export default NetworkSecurity;
|
package/dist/security.js
CHANGED
|
@@ -32,19 +32,19 @@ export class NetworkSecurity {
|
|
|
32
32
|
*
|
|
33
33
|
* ```typescript
|
|
34
34
|
* app.on("web-contents-created", (_, contents) => {
|
|
35
|
-
* contents.on("will-navigate",
|
|
36
|
-
* contents.setWindowOpenHandler(
|
|
35
|
+
* contents.on("will-navigate", () => ...); // __handleNavigation
|
|
36
|
+
* contents.setWindowOpenHandler(() => ...); // __handleWindowOpen
|
|
37
37
|
* });
|
|
38
38
|
* ```
|
|
39
39
|
*/
|
|
40
40
|
init() {
|
|
41
41
|
app.on("web-contents-created", (_, contents) => {
|
|
42
|
-
this.
|
|
43
|
-
this.
|
|
42
|
+
this.__handleNavigation(contents);
|
|
43
|
+
this.__handleWindowOpen(contents);
|
|
44
44
|
});
|
|
45
45
|
return this;
|
|
46
46
|
}
|
|
47
|
-
|
|
47
|
+
__handleNavigation(contents) {
|
|
48
48
|
contents.on("will-navigate", (e, url) => {
|
|
49
49
|
if (url.startsWith("file://"))
|
|
50
50
|
return;
|
|
@@ -57,7 +57,7 @@ export class NetworkSecurity {
|
|
|
57
57
|
}
|
|
58
58
|
});
|
|
59
59
|
}
|
|
60
|
-
|
|
60
|
+
__handleWindowOpen(contents) {
|
|
61
61
|
contents.setWindowOpenHandler(({ url }) => {
|
|
62
62
|
const { origin } = new URL(url);
|
|
63
63
|
// Если URL в разрешенном списке — открываем во внешнем браузере
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nemigo/electron",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Vlad Logvin",
|
|
@@ -14,8 +14,12 @@
|
|
|
14
14
|
"scripts": {
|
|
15
15
|
"build": "svelte-package && rimraf .svelte-kit",
|
|
16
16
|
"check": "tsc --noemit",
|
|
17
|
-
"
|
|
18
|
-
"
|
|
17
|
+
"eslint": "eslint ./",
|
|
18
|
+
"eslint:fix": "eslint --fix ./",
|
|
19
|
+
"lint": "biome lint",
|
|
20
|
+
"lint:fix": "biome lint --fix --unsafe",
|
|
21
|
+
"lint:fix:unsafe": "biome lint --fix --unsafe",
|
|
22
|
+
"format": "biome check --write --linter-enabled=false"
|
|
19
23
|
},
|
|
20
24
|
"exports": {
|
|
21
25
|
"./security": {
|
|
@@ -24,11 +28,12 @@
|
|
|
24
28
|
}
|
|
25
29
|
},
|
|
26
30
|
"peerDependencies": {
|
|
27
|
-
"@nemigo/helpers": ">=
|
|
31
|
+
"@nemigo/helpers": ">=2.0.0",
|
|
28
32
|
"electron": ">=32.0.0"
|
|
29
33
|
},
|
|
30
34
|
"devDependencies": {
|
|
31
|
-
"@nemigo/configs": "
|
|
32
|
-
"@nemigo/helpers": "
|
|
35
|
+
"@nemigo/configs": "2.0.0",
|
|
36
|
+
"@nemigo/helpers": "2.0.0",
|
|
37
|
+
"electron": "39.0.0"
|
|
33
38
|
}
|
|
34
39
|
}
|