diff --git a/lib/routes/pubscholar/utils.ts b/lib/routes/pubscholar/utils.ts index b8760209a..4fa71fac0 100644 --- a/lib/routes/pubscholar/utils.ts +++ b/lib/routes/pubscholar/utils.ts @@ -23,6 +23,18 @@ const generateNonce = (length: number): string => { return nonce.slice(0, length); }; +/** + * Part of fingerprint2.js shim from uBlock Origin + * Taken from https://github.com/gorhill/uBlock/blob/master/src/web_accessible_resources/fingerprint2.js + * @param len + * @returns + */ +const hex32 = (len) => + Math.floor(Math.random() * Number.MAX_SAFE_INTEGER) + .toString(16) + .slice(-len) + .padStart(len, '0'); + export const getSignedHeaders = () => { const nonce = generateNonce(6); const timestamp = Date.now().toString(); @@ -31,6 +43,7 @@ export const getSignedHeaders = () => { nonce, timestamp, signature, + 'x-finger': `${hex32(8)}${hex32(8)}${hex32(8)}${hex32(8)}`, }; };