diff options
author | Kristóf Marussy <kristof@marussy.com> | 2022-03-14 17:59:22 +0100 |
---|---|---|
committer | Kristóf Marussy <kristof@marussy.com> | 2022-03-15 03:00:05 +0100 |
commit | d2213e7eba2ec8b478c879397dc0de64d293f367 (patch) | |
tree | 5e32ece325fa11f13117b2c9e5966d7142826af4 /packages/renderer/src/stores | |
parent | feat(renderer): Back and forward mouse buttons (diff) | |
download | sophie-d2213e7eba2ec8b478c879397dc0de64d293f367.tar.gz sophie-d2213e7eba2ec8b478c879397dc0de64d293f367.tar.zst sophie-d2213e7eba2ec8b478c879397dc0de64d293f367.zip |
feat: Temporary certificate acceptance backend
We use the 'certificate-error' event of webContents to detect
certificate verification errors and display a message to manually trust
the certificate.
Certificates are trusted per profile and only until Sophie is restarted.
We still need to build the associated UI, the current one is just a
rough prototype for debugging.
Signed-off-by: Kristóf Marussy <kristof@marussy.com>
Diffstat (limited to 'packages/renderer/src/stores')
-rw-r--r-- | packages/renderer/src/stores/Service.ts | 84 |
1 files changed, 48 insertions, 36 deletions
diff --git a/packages/renderer/src/stores/Service.ts b/packages/renderer/src/stores/Service.ts index 7878ea0..695cff4 100644 --- a/packages/renderer/src/stores/Service.ts +++ b/packages/renderer/src/stores/Service.ts | |||
@@ -25,47 +25,59 @@ import getEnv from '../env/getEnv'; | |||
25 | 25 | ||
26 | import ServiceSettings from './ServiceSettings'; | 26 | import ServiceSettings from './ServiceSettings'; |
27 | 27 | ||
28 | const Service = defineServiceModel(ServiceSettings).actions((self) => ({ | 28 | const Service = defineServiceModel(ServiceSettings).actions((self) => { |
29 | dispatch(serviceAction: ServiceAction): void { | 29 | function dispatch(serviceAction: ServiceAction): void { |
30 | getEnv(self).dispatchMainAction({ | 30 | getEnv(self).dispatchMainAction({ |
31 | action: 'dispatch-service-action', | 31 | action: 'dispatch-service-action', |
32 | serviceId: self.id, | 32 | serviceId: self.id, |
33 | serviceAction, | 33 | serviceAction, |
34 | }); | 34 | }); |
35 | }, | 35 | } |
36 | goBack(): void { | 36 | |
37 | this.dispatch({ | 37 | return { |
38 | action: 'back', | 38 | goBack(): void { |
39 | }); | 39 | dispatch({ |
40 | }, | 40 | action: 'back', |
41 | goForward(): void { | 41 | }); |
42 | this.dispatch({ | 42 | }, |
43 | action: 'forward', | 43 | goForward(): void { |
44 | }); | 44 | dispatch({ |
45 | }, | 45 | action: 'forward', |
46 | reload(ignoreCache = false): void { | 46 | }); |
47 | this.dispatch({ | 47 | }, |
48 | action: 'reload', | 48 | reload(ignoreCache = false): void { |
49 | ignoreCache, | 49 | dispatch({ |
50 | }); | 50 | action: 'reload', |
51 | }, | 51 | ignoreCache, |
52 | stop(): void { | 52 | }); |
53 | this.dispatch({ | 53 | }, |
54 | action: 'stop', | 54 | stop(): void { |
55 | }); | 55 | dispatch({ |
56 | }, | 56 | action: 'stop', |
57 | go(url: string): void { | 57 | }); |
58 | this.dispatch({ | 58 | }, |
59 | action: 'go', | 59 | go(url: string): void { |
60 | url, | 60 | dispatch({ |
61 | }); | 61 | action: 'go', |
62 | }, | 62 | url, |
63 | goHome(): void { | 63 | }); |
64 | this.dispatch({ | 64 | }, |
65 | action: 'go-home', | 65 | goHome(): void { |
66 | }); | 66 | dispatch({ |
67 | }, | 67 | action: 'go-home', |
68 | })); | 68 | }); |
69 | }, | ||
70 | temporarilyTrustCurrentCertificate(): void { | ||
71 | if (self.state.type !== 'certificateError') { | ||
72 | throw new Error('No certificate to accept'); | ||
73 | } | ||
74 | dispatch({ | ||
75 | action: 'temporarily-trust-current-certificate', | ||
76 | fingerprint: self.state.certificate.fingerprint, | ||
77 | }); | ||
78 | }, | ||
79 | }; | ||
80 | }); | ||
69 | 81 | ||
70 | /* | 82 | /* |
71 | eslint-disable-next-line @typescript-eslint/no-redeclare -- | 83 | eslint-disable-next-line @typescript-eslint/no-redeclare -- |