diff options
Diffstat (limited to 'packages/main/src/stores/Profile.ts')
-rw-r--r-- | packages/main/src/stores/Profile.ts | 46 |
1 files changed, 32 insertions, 14 deletions
diff --git a/packages/main/src/stores/Profile.ts b/packages/main/src/stores/Profile.ts index 0fd486e..73f4f0b 100644 --- a/packages/main/src/stores/Profile.ts +++ b/packages/main/src/stores/Profile.ts | |||
@@ -18,22 +18,40 @@ | |||
18 | * SPDX-License-Identifier: AGPL-3.0-only | 18 | * SPDX-License-Identifier: AGPL-3.0-only |
19 | */ | 19 | */ |
20 | 20 | ||
21 | import { Profile as ProfileBase } from '@sophie/shared'; | 21 | import { |
22 | import { getSnapshot, Instance } from 'mobx-state-tree'; | 22 | type Certificate, |
23 | type CertificateSnapshotIn, | ||
24 | Profile as ProfileBase, | ||
25 | } from '@sophie/shared'; | ||
26 | import { getSnapshot, type Instance } from 'mobx-state-tree'; | ||
23 | 27 | ||
24 | import overrideProps from '../utils/overrideProps'; | 28 | import type ProfileConfig from './config/ProfileConfig.js'; |
25 | 29 | ||
26 | import ProfileSettings from './ProfileSettings'; | 30 | const Profile = ProfileBase.volatile( |
27 | import type ProfileConfig from './config/ProfileConfig'; | 31 | (): { |
28 | 32 | temporarilyTrustedCertificates: string[]; | |
29 | const Profile = overrideProps(ProfileBase, { | 33 | } => ({ |
30 | settings: ProfileSettings, | 34 | temporarilyTrustedCertificates: [], |
31 | }).views((self) => ({ | 35 | }), |
32 | get config(): ProfileConfig { | 36 | ) |
33 | const { id, settings } = self; | 37 | .views((self) => ({ |
34 | return { ...getSnapshot(settings), id }; | 38 | get config(): ProfileConfig { |
35 | }, | 39 | const { id, settings } = self; |
36 | })); | 40 | return { ...getSnapshot(settings), id }; |
41 | }, | ||
42 | isCertificateTemporarilyTrusted( | ||
43 | certificate: CertificateSnapshotIn, | ||
44 | ): boolean { | ||
45 | return self.temporarilyTrustedCertificates.includes( | ||
46 | certificate.fingerprint, | ||
47 | ); | ||
48 | }, | ||
49 | })) | ||
50 | .actions((self) => ({ | ||
51 | temporarilyTrustCertificate(certificate: Certificate): void { | ||
52 | self.temporarilyTrustedCertificates.push(certificate.fingerprint); | ||
53 | }, | ||
54 | })); | ||
37 | 55 | ||
38 | /* | 56 | /* |
39 | eslint-disable-next-line @typescript-eslint/no-redeclare -- | 57 | eslint-disable-next-line @typescript-eslint/no-redeclare -- |