use salt + md5 hash mode instead of plain text password

This commit is contained in:
Thomas Amland
2020-07-27 19:15:46 +02:00
parent 9feae7ed44
commit ec42ea82eb
7 changed files with 46 additions and 14 deletions
+6 -5
View File
@@ -16,7 +16,8 @@ export class API {
config.params = config.params || {};
config.baseURL = this.auth.server
config.params.u = this.auth.username;
config.params.p = this.auth.password;
config.params.s = this.auth.salt;
config.params.t = this.auth.hash;
config.params.c = "app";
config.params.f = "json";
config.params.v = "1.15.0";
@@ -255,12 +256,12 @@ export class API {
if (!item.coverArt) {
return undefined;
}
const { server, username, password } = this.auth;
return `${server}/rest/getCoverArt?id=${item.coverArt}&v=1.15.0&u=${username}&p=${password}&c=test&size=300`
const { server, username, salt, hash } = this.auth;
return `${server}/rest/getCoverArt?id=${item.coverArt}&v=1.15.0&u=${username}&s=${salt}&t=${hash}&c=test&size=300`
}
private getStreamUrl(id: any) {
const { server, username, password } = this.auth;
return `${server}/rest/stream?id=${id}&format=raw&v=1.15.0&u=${username}&p=${password}&c=test&size=300`
const { server, username, salt, hash } = this.auth;
return `${server}/rest/stream?id=${id}&format=raw&v=1.15.0&u=${username}&s=${salt}&t=${hash}&c=test&size=300`
}
}
+13
View File
@@ -0,0 +1,13 @@
import MD5 from 'md5-es';
export function randomString(): string {
let arr = new Uint8Array(16);
window.crypto.getRandomValues(arr);
const validChars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
arr = arr.map(x => validChars.charCodeAt(x % validChars.length));
return String.fromCharCode.apply(null, Array.from(arr));
}
export function md5(str: string): string {
return MD5.hash(str);
}