Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.mdns.eu/nextcloud/passwords-client.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMarius David Wieschollek <passwords.public@mdns.eu>2021-06-18 15:45:27 +0300
committerMarius David Wieschollek <passwords.public@mdns.eu>2021-06-18 15:45:27 +0300
commit248c1b4e36bbbd73b73ddc886dd9366dd6727124 (patch)
tree97fb13ff8ac488ea61f261ca9cef1c4a1bfdb8ed /src
parentecb2d1a2550b7ad73149fb225b2c97e50c01688f (diff)
parent1264cb8b09e58eefe3faa3392deed5165c8190a7 (diff)
Merge branch 'testing' into stable
Diffstat (limited to 'src')
-rw-r--r--src/Classes/EnhancedApi.js17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/Classes/EnhancedApi.js b/src/Classes/EnhancedApi.js
index 1de0963..ce1fbff 100644
--- a/src/Classes/EnhancedApi.js
+++ b/src/Classes/EnhancedApi.js
@@ -43,6 +43,7 @@ export default class EnhancedApi extends SimpleApi {
if(!config.folderIcon) config.folderIcon = `${config.baseUrl}core/img/filetypes/folder.svg`;
if(!config.apiUrl) config.apiUrl = `${config.baseUrl}index.php/apps/passwords/`;
+ if(!config.hashLength) config.hashLength = 40;
if(!config.encryption) config.encryption = new Encryption();
if(!config.cseMode || ['none', 'CSEv1r1'].indexOf(config.cseMode) === -1) config.cseMode = 'none';
@@ -70,10 +71,18 @@ export default class EnhancedApi extends SimpleApi {
*
* @param value
* @param algorithm
+ * @param [length=40]
* @returns {Promise<string>}
*/
- getHash(value, algorithm = 'SHA-1') {
- return this.config.encryption.getHash(value, algorithm);
+ getHash(value, algorithm = 'SHA-1', length = null) {
+ if(length === null) length = this._config.hashLength;
+ let hash = this.config.encryption.getHash(value, algorithm);
+
+ if(length !== 40) {
+ return hash.substr(0, length);
+ }
+
+ return hash;
}
/**
@@ -165,7 +174,7 @@ export default class EnhancedApi extends SimpleApi {
}
if(!object.hasOwnProperty('_encrypted')) object._encrypted = false;
- object.hash = await this.config.encryption.getHash(data.password);
+ object.hash = await this.getHash(data.password);
if(!object.label) this._generatePasswordTitle(object);
if(this.config.encryption.enabled && object.cseType !== 'none') {
@@ -196,7 +205,7 @@ export default class EnhancedApi extends SimpleApi {
}
if(!object.hasOwnProperty('_encrypted')) object._encrypted = false;
- object.hash = await this.config.encryption.getHash(data.password);
+ object.hash = await this.getHash(data.password);
if(!object.label) this._generatePasswordTitle(object);
if(this.config.encryption.enabled && object.cseType !== 'none' && (!data.hasOwnProperty('shared') || !data.shared)) {