Skip to content

Commit

Permalink
fix: lastfm authorize on new secure store
Browse files Browse the repository at this point in the history
  • Loading branch information
Venipa committed Nov 11, 2024
1 parent e14f688 commit f56cb8a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
5 changes: 3 additions & 2 deletions src/main/lib/lastfm/client.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { createHash } from "crypto";
import { enc, MD5 } from "crypto-js";
import got, { Got, Method } from "got";
import fetch from "node-fetch";
export class LastFMClient {
Expand Down Expand Up @@ -73,7 +74,7 @@ export class LastFMClient {
requestSourceData += this.key.secret;
searchParams.set(
"api_sig",
createHash("md5").update(requestSourceData, "utf8").digest("hex"),
MD5(requestSourceData).toString(enc.Hex)
);
}
searchParams.set("format", "json");
Expand All @@ -84,7 +85,7 @@ export class LastFMClient {
"user-agent": "ytmd (github.com/Venipa/ytmdesktop2)",
},
})
.then((r) => r.json() as Promise<T>)
.then((r) => r.ok ? r.json() as Promise<T> : Promise.reject(r))
.catch((err) => {
this.lastError = err;
return Promise.reject(err);
Expand Down
6 changes: 1 addition & 5 deletions src/main/lib/secureStore/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,7 @@ class SecureStore {
}
set(key: string, value: string) {
return new Promise<string | null>(async (resolve, reject) => {
store.set({
credentials: {
[key]: value,
},
});
store.set(`credentials.${key}`, value);
return resolve(value);
});
}
Expand Down

0 comments on commit f56cb8a

Please sign in to comment.