Files
klz-cables.com/.pnpm-store/v10/files/e1/f7b434749dc136c528725bff804a602b598cac9b0867a04bb9daa89239e99bad3c86236c11de86d371fe1c5e8c7086b8183754e2bf0941a07983c71c4aa6ed
Marc Mintel 5397309103
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
fix(products): fix breadcrumbs and product filtering (backport from main)
2026-02-24 16:04:21 +01:00

30 lines
883 B
Plaintext

import * as crypto from 'node:crypto';
import { promisify } from 'node:util';
import nodeDigest from './dsa_digest.js';
import nodeKey from './node_key.js';
import sign from './sign.js';
import getVerifyKey from './get_sign_verify_key.js';
const oneShotVerify = promisify(crypto.verify);
const verify = async (alg, key, signature, data) => {
const k = getVerifyKey(alg, key, 'verify');
if (alg.startsWith('HS')) {
const expected = await sign(alg, k, data);
const actual = signature;
try {
return crypto.timingSafeEqual(actual, expected);
}
catch {
return false;
}
}
const algorithm = nodeDigest(alg);
const keyInput = nodeKey(alg, k);
try {
return await oneShotVerify(algorithm, data, keyInput, signature);
}
catch {
return false;
}
};
export default verify;