mirror of
https://github.com/nodejs/node.git
synced 2026-10-28 10:15:07 +08:00
Check all JWK key_ops entries for duplicates before ignoring unknown usage names. Signed-off-by: Filip Skokan <panva.ip@gmail.com> Assisted-by: Codex PR-URL: https://github.com/nodejs/node/pull/66237 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Aviv Keller <me@aviv.sh>
21 lines
738 B
JavaScript
21 lines
738 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
if (!common.hasCrypto)
|
|
common.skip('missing crypto');
|
|
|
|
const assert = require('assert');
|
|
const { subtle } = globalThis.crypto;
|
|
|
|
(async () => {
|
|
const algorithm = { name: 'HMAC', hash: 'SHA-256' };
|
|
const jwk = { kty: 'oct', k: 'AAAAAAAAAAAAAAAAAAAAAA' };
|
|
await subtle.importKey('jwk', { ...jwk, key_ops: ['sign', 'future'] },
|
|
algorithm, false, ['sign']);
|
|
for (const key_ops of [['sign', 'sign'], ['sign', 'future', 'future']]) {
|
|
await assert.rejects(subtle.importKey('jwk', { ...jwk, key_ops },
|
|
algorithm, false, ['sign']),
|
|
{ name: 'DataError' });
|
|
}
|
|
})().then(common.mustCall());
|