...
 
Commits (2)
{
"name": "passwords-client",
"version": "0.0.12",
"lockfileVersion": 2,
"version": "0.0.13",
"lockfileVersion": 1,
"requires": true,
"packages": {
"": {
"version": "0.0.12",
"license": "ISC",
"dependencies": {
"eventemitter3": "^3.1.2",
"libsodium-wrappers": "^0.7.8",
"url-parse": "^1.4.7"
}
},
"node_modules/eventemitter3": {
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-3.1.2.tgz",
"integrity": "sha512-tvtQIeLVHjDkJYnzf2dgVMxfuSGJeM/7UCG17TT4EumTfNtF+0nebF/4zWOIkCreAbtNqhGEboB6BWrwqNaw4Q=="
},
"node_modules/libsodium": {
"version": "0.7.9",
"resolved": "https://registry.npmjs.org/libsodium/-/libsodium-0.7.9.tgz",
"integrity": "sha512-gfeADtR4D/CM0oRUviKBViMGXZDgnFdMKMzHsvBdqLBHd9ySi6EtYnmuhHVDDYgYpAO8eU8hEY+F8vIUAPh08A=="
},
"node_modules/libsodium-wrappers": {
"version": "0.7.9",
"resolved": "https://registry.npmjs.org/libsodium-wrappers/-/libsodium-wrappers-0.7.9.tgz",
"integrity": "sha512-9HaAeBGk1nKTRFRHkt7nzxqCvnkWTjn1pdjKgcUnZxj0FyOP4CnhgFhMdrFfgNsukijBGyBLpP2m2uKT1vuWhQ==",
"dependencies": {
"libsodium": "^0.7.0"
}
},
"node_modules/querystringify": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/querystringify/-/querystringify-2.2.0.tgz",
"integrity": "sha512-FIqgj2EUvTa7R50u0rGsyTftzjYmv/a3hO345bZNrqabNqjtgiDMgmo4mkUjd+nzU5oF3dClKqFIPUKybUyqoQ=="
},
"node_modules/requires-port": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz",
"integrity": "sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8="
},
"node_modules/url-parse": {
"version": "1.5.1",
"resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.5.1.tgz",
"integrity": "sha512-HOfCOUJt7iSYzEx/UqgtwKRMC6EU91NFhsCHMv9oM03VJcVo2Qrp8T8kI9D7amFf1cu+/3CEhgb3rF9zL7k85Q==",
"dependencies": {
"querystringify": "^2.1.1",
"requires-port": "^1.0.0"
}
}
},
"dependencies": {
"eventemitter3": {
"version": "3.1.2",
......
{
"name": "passwords-client",
"version": "0.0.12",
"description": "JS client library for the Nextcloud Passwords app",
"version": "0.0.14",
"description": "JS client library for the Passwords app for Nextcloud",
"main": "src/main.js",
"author": "Marius Wieschollek",
"license": "ISC",
......@@ -17,7 +17,7 @@
},
"dependencies": {
"eventemitter3": "^3.1.2",
"libsodium-wrappers": "^0.7.8",
"url-parse": "^1.4.7"
"libsodium-wrappers": "^0.7.9",
"url-parse": "^1.5.1"
}
}
......@@ -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);
async getHash(value, algorithm = 'SHA-1', length = null) {
if(length === null) length = this.config.hashLength;
let hash = await 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)) {
......