0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-21 21:19:50 +01:00
nodejs/test/parallel/test-webcrypto-util.js
Filip Skokan 3ef38c4bd7
crypto: use WebIDL converters in WebCryptoAPI
WebCryptoAPI functions' arguments are now coersed and validated as per
their WebIDL definitions like in other Web Crypto API implementations.
This further improves interoperability with other implementations of
Web Crypto API.

PR-URL: https://github.com/nodejs/node/pull/46067
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
2023-01-17 08:57:58 +00:00

20 lines
521 B
JavaScript

// Flags: --expose-internals
'use strict';
const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');
const assert = require('assert');
const {
normalizeAlgorithm,
} = require('internal/crypto/util');
{
// Check that normalizeAlgorithm does not mutate object inputs.
const algorithm = { name: 'ECDSA', hash: 'SHA-256' };
assert.strictEqual(normalizeAlgorithm(algorithm, 'sign') !== algorithm, true);
assert.deepStrictEqual(algorithm, { name: 'ECDSA', hash: 'SHA-256' });
}