mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-02-03 00:33:49 +03:00
fix: decoding steamdb api key
This commit is contained in:
parent
ef035e46f8
commit
cdd9908775
@ -14,21 +14,28 @@ export interface AlgoliaSearchParams {
|
||||
}
|
||||
|
||||
export const getSteamDBAlgoliaCredentials = async () => {
|
||||
const searchParams = new URLSearchParams({
|
||||
t: new Date().getTime().toString(),
|
||||
});
|
||||
|
||||
const js = await requestWebPage(
|
||||
"https://steamdb.info/static/js/instantsearch.js"
|
||||
`https://steamdb.info/static/js/instantsearch.js?${searchParams.toString()}`,
|
||||
);
|
||||
|
||||
const algoliaCredentialsRegExp = new RegExp(
|
||||
/algoliasearch\("(.*?)","(.*?)"\);/
|
||||
/algoliasearch\("(.*?)",atob\("(.*?)"\)\);/,
|
||||
);
|
||||
|
||||
const [, applicationId, apiKey] = algoliaCredentialsRegExp.exec(js);
|
||||
const [, applicationId, encodedApiKey] = algoliaCredentialsRegExp.exec(js);
|
||||
|
||||
return { applicationId, apiKey };
|
||||
return {
|
||||
applicationId,
|
||||
apiKey: Buffer.from(encodedApiKey, "base64").toString("utf-8"),
|
||||
};
|
||||
};
|
||||
|
||||
export const searchAlgolia = async <T>(
|
||||
params: AlgoliaSearchParams
|
||||
params: AlgoliaSearchParams,
|
||||
): Promise<AlgoliaResponse<T>> => {
|
||||
const algoliaCredentials = stateManager.getValue("steamDBAlgoliaCredentials");
|
||||
|
||||
@ -48,7 +55,7 @@ export const searchAlgolia = async <T>(
|
||||
}?${searchParams.toString()}`,
|
||||
{
|
||||
headers: params.headers,
|
||||
}
|
||||
},
|
||||
)
|
||||
.then((response) => response.data);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user