diff --git a/frontend/src/common/backend.ts b/frontend/src/common/backend.ts index ba839901..e4777412 100644 --- a/frontend/src/common/backend.ts +++ b/frontend/src/common/backend.ts @@ -252,7 +252,7 @@ class UserService { class TrustService { public async trustUser(userId: string, signature: string): Promise { - return axiosAuth.put(`/users/trusted/${userId}`, signature); + return axiosAuth.put(`/users/trusted/${userId}`, signature, { headers: { 'Content-Type': 'text/plain' } }); } public async get(userId: string): Promise { return axiosAuth.get(`/users/trusted/${userId}`).then(response => response.data) diff --git a/frontend/src/components/TrustDetails.vue b/frontend/src/components/TrustDetails.vue index 551e2733..540b5b2d 100644 --- a/frontend/src/components/TrustDetails.vue +++ b/frontend/src/components/TrustDetails.vue @@ -16,7 +16,7 @@

Trust Level {{ trustLevel }}

-
@@ -42,7 +42,7 @@ enum State { const { t } = useI18n({ useScope: 'global' }); const props = defineProps<{ - userId: string + trustedUser: UserDto }>(); const state = ref(State.Loading); @@ -56,7 +56,7 @@ onMounted(fetchData); async function fetchData() { try { me.value = await userdata.me; - trust.value = await backend.trust.get(props.userId); + trust.value = await backend.trust.get(props.trustedUser.id); state.value = State.ShowTrust; } catch (error) { console.error('Fetching data failed.', error); @@ -65,9 +65,10 @@ async function fetchData() { } function computeTrustLevel() { - if (me.value?.id === props.userId) { + if (me.value?.id === props.trustedUser.id) { return 0; // Self } else if (trust.value) { + // TODO: check signature return trust.value.signatureChain.length; } else { return -1; // Unverified @@ -75,20 +76,20 @@ function computeTrustLevel() { } async function sign() { + if (!props.trustedUser.ecdsaPublicKey) { + throw new Error('No public key to sign'); + } const userKeys = await userdata.decryptUserKeysWithBrowser(); const signature = await JWT.build({ alg: 'ES384', typ: 'JWT', b64: true, iss: me.value?.id, - sub: props.userId, + sub: props.trustedUser.id, iat: Math.floor(Date.now() / 1000) - }, props.userId, userKeys.ecdsaKeyPair.privateKey); - // backend.trust.trustUser(props.userId, signature); - - // TODO: remove debug output (for verifification onbly) - console.log('Signature: ', signature); - console.log('Signer\'s Public Key: ', await crypto.subtle.exportKey('jwk', userKeys.ecdsaKeyPair.publicKey)); + }, props.trustedUser.ecdsaPublicKey, userKeys.ecdsaKeyPair.privateKey); + await backend.trust.trustUser(props.trustedUser.id, signature); + trust.value = await backend.trust.get(props.trustedUser.id); }; \ No newline at end of file diff --git a/frontend/src/components/VaultDetails.vue b/frontend/src/components/VaultDetails.vue index f10f0dad..31f6d8ba 100644 --- a/frontend/src/components/VaultDetails.vue +++ b/frontend/src/components/VaultDetails.vue @@ -47,7 +47,7 @@

{{ member.name }}

- +
{{ t('vaultDetails.sharedWith.badge.owner') }}