From 1184eb13f0bbe4768bf3dbd6cd31adf10c6c8dfe Mon Sep 17 00:00:00 2001 From: Kristóf Marussy Date: Fri, 22 Apr 2022 00:53:48 +0200 Subject: feat: Certificate viewer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Show certificates with an interface modeled after firefox's certificate viewer so that they can be inspected before trusting. The current implementation assumes that each certificate has a unique fingerprint (collisions are astronomically unlikely). Signed-off-by: Kristóf Marussy --- .../src/infrastructure/electron/impl/electronShell.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'packages/main/src/infrastructure/electron/impl') diff --git a/packages/main/src/infrastructure/electron/impl/electronShell.ts b/packages/main/src/infrastructure/electron/impl/electronShell.ts index be1cbe3..f7f7001 100644 --- a/packages/main/src/infrastructure/electron/impl/electronShell.ts +++ b/packages/main/src/infrastructure/electron/impl/electronShell.ts @@ -18,7 +18,9 @@ * SPDX-License-Identifier: AGPL-3.0-only */ -import { app, shell } from 'electron'; +import { writeFile } from 'node:fs/promises'; + +import { app, dialog, shell } from 'electron'; import { getLogger } from 'loglevel'; import type MainEnv from '../../../stores/MainEnv'; @@ -34,6 +36,17 @@ const electronShell: MainEnv = { openAboutDialog(): void { app.showAboutPanel(); }, + async saveTextFile(filename: string, value: string): Promise { + const result = await dialog.showSaveDialog({ + defaultPath: filename, + }); + if (result.canceled || result.filePath === undefined) { + log.debug('Saving file', filename, 'canceled'); + return; + } + await writeFile(result.filePath, value, 'utf8'); + log.debug('Saved file', filename, 'to', result.filePath); + }, }; export default electronShell; -- cgit v1.2.3-70-g09d2