-
-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: allow to change signature hash algorithm
The default hash algorithm of JSignPdf is SHA1 and with this change was defined SHA256 as default hash algorithm and make possible choose between the allowed algorithms: SHA1, SHA256, SHA384, SHA512, RIPEMD160. Signed-off-by: Vitor Mattos <[email protected]>
- Loading branch information
1 parent
6ed4c7f
commit 708edff
Showing
3 changed files
with
91 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
<!-- | ||
- SPDX-FileCopyrightText: 2024 LibreCode coop and LibreCode contributors | ||
- SPDX-License-Identifier: AGPL-3.0-or-later | ||
--> | ||
|
||
<template> | ||
<NcSettingsSection :name="name" :description="description"> | ||
<NcSelect :key="idKey" | ||
v-model="selected" | ||
label="displayname" | ||
:no-wrap="false" | ||
:aria-label-combobox="description" | ||
:close-on-select="false" | ||
:disabled="loading" | ||
:loading="loading" | ||
required | ||
:options="hashes" | ||
:show-no-options="false" | ||
@update:modelValue="saveSignatureHash" /> | ||
</NcSettingsSection> | ||
</template> | ||
|
||
<script> | ||
import axios from '@nextcloud/axios' | ||
import { translate as t } from '@nextcloud/l10n' | ||
import { confirmPassword } from '@nextcloud/password-confirmation' | ||
import { generateOcsUrl } from '@nextcloud/router' | ||
|
||
import NcSelect from '@nextcloud/vue/dist/Components/NcSelect.js' | ||
import NcSettingsSection from '@nextcloud/vue/dist/Components/NcSettingsSection.js' | ||
|
||
import '@nextcloud/password-confirmation/dist/style.css' | ||
|
||
export default { | ||
name: 'SignatureHashAlgorithm', | ||
components: { | ||
NcSettingsSection, | ||
NcSelect, | ||
}, | ||
|
||
data: () => ({ | ||
name: t('libresign', 'Signature hash algorithm'), | ||
description: t('libresign', 'Hash algorithm used for signature.'), | ||
selected: [], | ||
hashes: ['SHA1', 'SHA256', 'SHA384', 'SHA512', 'RIPEMD160'], | ||
loading: false, | ||
idKey: 0, | ||
}), | ||
|
||
mounted() { | ||
this.getData() | ||
}, | ||
|
||
methods: { | ||
async getData() { | ||
this.loading = true | ||
const response = await axios.get( | ||
generateOcsUrl('/apps/provisioning_api/api/v1/config/apps/libresign/signature_hash_algorithm'), | ||
) | ||
this.selected = this.hashes.includes(response.data.ocs.data.data) | ||
? response.data.ocs.data.data | ||
: 'SHA256' | ||
this.loading = false | ||
}, | ||
|
||
async saveSignatureHash() { | ||
await confirmPassword() | ||
|
||
const selected = this.hashes.includes(this.selected) ? this.selected : 'SHA256' | ||
OCP.AppConfig.setValue('libresign', 'signature_hash_algorithm', selected) | ||
this.idKey += 1 | ||
}, | ||
}, | ||
|
||
} | ||
</script> |