Files
klz-cables.com/.pnpm-store/v10/files/76/e461e1e6277c10aa7f3f989341582d6c1baccb8f4859a2b8b29f4609768223a0d35d58172b34a0e9896266933110744a8c101b457403c93ec81e8c62f30168
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

29 lines
988 B
Plaintext

import { KeyObject, createSecretKey } from 'node:crypto';
import { isCryptoKey } from './webcrypto.js';
import { checkSigCryptoKey } from '../lib/crypto_key.js';
import invalidKeyInput from '../lib/invalid_key_input.js';
import { types } from './is_key_like.js';
import * as jwk from '../lib/is_jwk.js';
export default function getSignVerifyKey(alg, key, usage) {
if (key instanceof Uint8Array) {
if (!alg.startsWith('HS')) {
throw new TypeError(invalidKeyInput(key, ...types));
}
return createSecretKey(key);
}
if (key instanceof KeyObject) {
return key;
}
if (isCryptoKey(key)) {
checkSigCryptoKey(key, alg, usage);
return KeyObject.from(key);
}
if (jwk.isJWK(key)) {
if (alg.startsWith('HS')) {
return createSecretKey(Buffer.from(key.k, 'base64url'));
}
return key;
}
throw new TypeError(invalidKeyInput(key, ...types, 'Uint8Array', 'JSON Web Key'));
}