mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 21:19:50 +01:00
3ef38c4bd7
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>
20 lines
521 B
JavaScript
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' });
|
|
}
|