fix(route/pubscholar): add x-finger (#20052)
This commit is contained in:
parent
3ea7e1ccc1
commit
dd100ccf3d
|
|
@ -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)}`,
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue