From ef08a899a293a94814d629f557607e3d060f45fd Mon Sep 17 00:00:00 2001 From: Tobias Hagemann Date: Tue, 9 Jan 2024 15:24:36 +0100 Subject: [PATCH 01/11] updated vs code settings [ci skip] --- frontend/.vscode/settings.json | 6 +++--- hub.code-workspace | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/frontend/.vscode/settings.json b/frontend/.vscode/settings.json index 7bb2c663..1c096d3b 100644 --- a/frontend/.vscode/settings.json +++ b/frontend/.vscode/settings.json @@ -1,8 +1,8 @@ { "[typescript]": { "editor.codeActionsOnSave": { - "source.organizeImports": true, - "source.fixAll.tslint": true + "source.organizeImports": "explicit", + "source.fixAll.tslint": "explicit" }, "editor.foldingStrategy": "indentation", "editor.formatOnSave": true, @@ -27,4 +27,4 @@ "mochaExplorer.files": "test/**/*.spec.ts", "mochaExplorer.require": "ts-node/register", "eslint.validate": ["typescript", "javascript", "vue"] -} \ No newline at end of file +} diff --git a/hub.code-workspace b/hub.code-workspace index 352227a7..52e7f4e2 100644 --- a/hub.code-workspace +++ b/hub.code-workspace @@ -27,8 +27,8 @@ "typescript.referencesCodeLens.enabled": true, "typescript.implementationsCodeLens.enabled": true, "editor.codeActionsOnSave": { - "source.organizeImports": true, - "source.fixAll.eslint": true + "source.organizeImports": "explicit", + "source.fixAll.eslint": "explicit" } } -} \ No newline at end of file +} From 4b81e241d018bd3c01bd5e4cd1de2d48d4b66ce5 Mon Sep 17 00:00:00 2001 From: Tobias Hagemann Date: Tue, 9 Jan 2024 15:25:02 +0100 Subject: [PATCH 02/11] reformatted VaultDetails --- frontend/src/components/VaultDetails.vue | 30 +++++++++++------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/frontend/src/components/VaultDetails.vue b/frontend/src/components/VaultDetails.vue index 9e3258e9..7af50134 100644 --- a/frontend/src/components/VaultDetails.vue +++ b/frontend/src/components/VaultDetails.vue @@ -165,7 +165,6 @@ {{ t('vaultDetails.recoverVault') }} - @@ -260,21 +259,20 @@ async function fetchData() { } async function fetchOwnerData() { - try { - const vaultKeyJwe = await backend.vaults.accessToken(props.vaultId, true); - vaultKeys.value = await loadVaultKeys(vaultKeyJwe); - (await backend.vaults.getMembers(props.vaultId)).forEach(member => members.value.set(member.id, member)); - usersRequiringAccessGrant.value = await backend.vaults.getUsersRequiringAccessGrant(props.vaultId); - vaultRecoveryRequired.value = false; - } catch(error) { - if (error instanceof ForbiddenError) { - vaultRecoveryRequired.value = true; - } else { - console.error('Retrieving ownership failed.', error); - onFetchError.value = error instanceof Error ? error : new Error('Unknown Error'); - } + try { + const vaultKeyJwe = await backend.vaults.accessToken(props.vaultId, true); + vaultKeys.value = await loadVaultKeys(vaultKeyJwe); + (await backend.vaults.getMembers(props.vaultId)).forEach(member => members.value.set(member.id, member)); + usersRequiringAccessGrant.value = await backend.vaults.getUsersRequiringAccessGrant(props.vaultId); + vaultRecoveryRequired.value = false; + } catch (error) { + if (error instanceof ForbiddenError) { + vaultRecoveryRequired.value = true; + } else { + console.error('Retrieving ownership failed.', error); + onFetchError.value = error instanceof Error ? error : new Error('Unknown Error'); } - + } } async function loadVaultKeys(vaultKeyJwe: string): Promise { @@ -421,7 +419,7 @@ function refreshVault(updatedVault: VaultDto) { } async function reloadView() { - await fetchOwnerData() + await fetchOwnerData(); vaultRecoveryRequired.value = false; } From d0c3d47b8848155823f3eb174c16632f5a93eac6 Mon Sep 17 00:00:00 2001 From: Tobias Hagemann Date: Tue, 9 Jan 2024 15:37:01 +0100 Subject: [PATCH 03/11] fixed linter errors with undefined browserKeys --- frontend/src/components/DeviceList.vue | 4 ++-- frontend/src/components/ManageSetupCode.vue | 3 +++ frontend/src/components/RegenerateSetupCodeDialog.vue | 3 +++ frontend/src/components/VaultDetails.vue | 3 +++ 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/frontend/src/components/DeviceList.vue b/frontend/src/components/DeviceList.vue index e2801392..f916ca49 100644 --- a/frontend/src/components/DeviceList.vue +++ b/frontend/src/components/DeviceList.vue @@ -124,7 +124,7 @@ async function determineMyDevice() { throw new Error('User not initialized.'); } const browserKeys = await BrowserKeys.load(me.value.id); - const browserId = await browserKeys.id(); + const browserId = await browserKeys?.id(); myDevice.value = me.value.devices.find(d => d.id == browserId); } @@ -138,7 +138,7 @@ async function determineMyDevice() { // /* decrypt user key on this browser: */ // const userPublicKey = crypto.subtle.importKey('spki', base64.parse(me.value.publicKey), UserKeys.KEY_DESIGNATION, false, []); // const browserKeys = await BrowserKeys.load(me.value.id); -// const browserId = await browserKeys.id(); +// const browserId = await browserKeys?.id(); // const browser = me.value.devices.find(d => d.id === browserId); // if (!browser || !browser.userPrivateKey) { // throw new Error('Browser not validated.'); diff --git a/frontend/src/components/ManageSetupCode.vue b/frontend/src/components/ManageSetupCode.vue index 032f3a37..9837cf48 100644 --- a/frontend/src/components/ManageSetupCode.vue +++ b/frontend/src/components/ManageSetupCode.vue @@ -75,6 +75,9 @@ async function fetchData() { throw new Error('User not initialized.'); } const browserKeys = await BrowserKeys.load(me.id); + if (browserKeys == null) { + throw new Error('Browser keys not found.'); + } const browserId = await browserKeys.id(); const myDevice = me.devices.find(d => d.id == browserId); if (myDevice == null) { diff --git a/frontend/src/components/RegenerateSetupCodeDialog.vue b/frontend/src/components/RegenerateSetupCodeDialog.vue index 331152a0..fce75f43 100644 --- a/frontend/src/components/RegenerateSetupCodeDialog.vue +++ b/frontend/src/components/RegenerateSetupCodeDialog.vue @@ -156,6 +156,9 @@ async function regenerateSetupCode() { throw new Error('User not initialized.'); } const browserKeys = await BrowserKeys.load(me.id); + if (browserKeys == null) { + throw new Error('Browser keys not found.'); + } const browserId = await browserKeys.id(); const myDevice = me.devices.find(d => d.id == browserId); if (myDevice == null) { diff --git a/frontend/src/components/VaultDetails.vue b/frontend/src/components/VaultDetails.vue index 7af50134..31e3a185 100644 --- a/frontend/src/components/VaultDetails.vue +++ b/frontend/src/components/VaultDetails.vue @@ -280,6 +280,9 @@ async function loadVaultKeys(vaultKeyJwe: string): Promise { throw new Error('User not initialized.'); } const browserKeys = await BrowserKeys.load(me.value.id); + if (browserKeys == null) { + throw new Error('Browser keys not found.'); + } const browserId = await browserKeys.id(); const myDevice = me.value.devices.find(d => d.id == browserId); if (myDevice == null) { From 3b3bf8f34afbd0e9cda989177c2ceb05672ffb40 Mon Sep 17 00:00:00 2001 From: Tobias Hagemann Date: Tue, 9 Jan 2024 15:47:32 +0100 Subject: [PATCH 04/11] added workaround for unfixable linter error in miscreant dependency --- frontend/tsconfig.json | 1 + 1 file changed, 1 insertion(+) diff --git a/frontend/tsconfig.json b/frontend/tsconfig.json index c6a256cd..a6b58cc1 100644 --- a/frontend/tsconfig.json +++ b/frontend/tsconfig.json @@ -10,6 +10,7 @@ "esModuleInterop": true, "lib": ["esnext", "dom"], "noUnusedLocals": true, + "useUnknownInCatchVariables": false, // Workaround for `node_modules/miscreant/src/providers/webcrypto.ts:21:11 - error TS18046: 'e' is of type 'unknown'.` }, "ts-node": { "compilerOptions": { From 7c057d4012c5708f0512cd218fe2122f53f6a386 Mon Sep 17 00:00:00 2001 From: Tobias Hagemann Date: Tue, 9 Jan 2024 15:50:11 +0100 Subject: [PATCH 05/11] re-enabled linter check in dist script --- frontend/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/package.json b/frontend/package.json index 13fcab4c..eadcd83f 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -12,7 +12,7 @@ "lint": "eslint -c .eslintrc.js", "test": "nyc --reporter lcov mocha -r ts-node/register test/**/*.spec.ts", "serve": "vite preview", - "dist": "vite build --sourcemap --outDir=\"../backend/src/main/resources/META-INF/resources\" --emptyOutDir" + "dist": "vue-tsc --noEmit && vite build --sourcemap --outDir=\"../backend/src/main/resources/META-INF/resources\" --emptyOutDir" }, "directories": { "src": "./src", From 5e0271fe5faf20fd38643e7dd19ed06025817e72 Mon Sep 17 00:00:00 2001 From: Tobias Hagemann Date: Tue, 9 Jan 2024 17:39:08 +0100 Subject: [PATCH 06/11] updated frontend README [ci skip] --- frontend/README.md | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/frontend/README.md b/frontend/README.md index f5342b7d..c85e4c59 100644 --- a/frontend/README.md +++ b/frontend/README.md @@ -1,11 +1,25 @@ -# Vue 3 + Typescript + Vite +# Cryptomator Frontend -This template should help get you started developing with Vue 3 and Typescript in Vite. The template uses Vue 3 `