Skip to content

crypto: remove incorrect constructor invocation

Rodrigo Muino Tomonari requested to merge github/fork/gc/patch-1 into master

This line is incorrectly trying to do throw new lazyDOMException, causing it to throw the wrong error.

Reproduction:

const { webcrypto } = require('crypto');

async function t() {
    	const { publicKey, privateKey } = await webcrypto.subtle.generateKey(
		{
			name: 'NODE-ED25519',
			namedCurve: 'NODE-ED25519'
		},
		true,
		['sign', 'verify']
	);
    const signature = await webcrypto.subtle.sign(
		{
			name: 'NODE-ED25519',
			hash: 'SHA-256'
		},
		privateKey,
		'-'
	);
}
t();
node:internal/crypto/ec:461
        throw new lazyDOMException(`Hash is not permitted for ${name}`);
              ^

TypeError: lazyDOMException is not a constructor
←[90m    at Object.ecdsaSignVerify (node:internal/crypto/ec:461:15)←[39m
←[90m    at signVerify (node:internal/crypto/webcrypto:609:10)←[39m
←[90m    at SubtleCrypto.sign (node:internal/crypto/webcrypto:623:10)←[39m
    at t (C:\dev\redacted\test.js:12:46)

Merge request reports

Loading