Files
jose/dist/webapi/lib/key_algorithm.js
T
2026-07-30 00:49:35 +02:00

17 lines
566 B
JavaScript

import { JOSENotSupported } from '../util/errors.js';
import { maybeJWSAlgorithm } from './jws_algorithms.js';
import { maybeJWEAlgorithm } from './jwe_algorithms.js';
function unsupportedAlgorithm() {
return new JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
}
export function keyAlgorithm(alg) {
if (typeof alg !== 'string') {
throw unsupportedAlgorithm();
}
const entry = maybeJWSAlgorithm(alg) ?? maybeJWEAlgorithm(alg);
if (!entry) {
throw unsupportedAlgorithm();
}
return entry;
}