mirror of
https://github.com/nodejs/node.git
synced 2026-11-27 17:52:27 -05:00
crypto: add causes to applicable webcrypto's OperationError
PR-URL: https://github.com/nodejs/node/pull/44890 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
This commit is contained in:
1 parent
803fbfb168
commit
99a2c16040
6 files changed
+6
-12
No files matched your search
@@ -241,11 +241,10 @@ async function aesGenerateKey(algorithm, extractable, keyUsages) {
|
||||
}
|
||||
|
||||
const key = await generateKey('aes', { length }).catch((err) => {
|
||||
// TODO(@panva): add err as cause to DOMException
|
||||
throw lazyDOMException(
|
||||
'The operation failed for an operation-specific reason' +
|
||||
`[${err.message}]`,
|
||||
'OperationError');
|
||||
{ name: 'OperationError', cause: err });
|
||||
});
|
||||
|
||||
return new InternalCryptoKey(
|
||||
|
||||
@@ -150,10 +150,9 @@ async function cfrgGenerateKey(algorithm, extractable, keyUsages) {
|
||||
}
|
||||
|
||||
const keyPair = await generateKeyPair(genKeyType).catch((err) => {
|
||||
// TODO(@panva): add err as cause to DOMException
|
||||
throw lazyDOMException(
|
||||
'The operation failed for an operation-specific reason',
|
||||
'OperationError');
|
||||
{ name: 'OperationError', cause: err });
|
||||
});
|
||||
|
||||
let publicUsages;
|
||||
|
||||
@@ -112,10 +112,9 @@ async function ecGenerateKey(algorithm, extractable, keyUsages) {
|
||||
}
|
||||
|
||||
const keypair = await generateKeyPair('ec', { namedCurve }).catch((err) => {
|
||||
// TODO(@panva): add err as cause to DOMException
|
||||
throw lazyDOMException(
|
||||
'The operation failed for an operation-specific reason',
|
||||
'OperationError');
|
||||
{ name: 'OperationError', cause: err });
|
||||
});
|
||||
|
||||
let publicUsages;
|
||||
|
||||
@@ -66,10 +66,9 @@ async function hmacGenerateKey(algorithm, extractable, keyUsages) {
|
||||
}
|
||||
|
||||
const key = await generateKey('hmac', { length }).catch((err) => {
|
||||
// TODO(@panva): add err as cause to DOMException
|
||||
throw lazyDOMException(
|
||||
'The operation failed for an operation-specific reason',
|
||||
'OperationError');
|
||||
{ name: 'OperationError', cause: err });
|
||||
});
|
||||
|
||||
return new InternalCryptoKey(
|
||||
|
||||
@@ -178,10 +178,9 @@ async function rsaKeyGenerate(
|
||||
modulusLength,
|
||||
publicExponent: publicExponentConverted,
|
||||
}).catch((err) => {
|
||||
// TODO(@panva): add err as cause to DOMException
|
||||
throw lazyDOMException(
|
||||
'The operation failed for an operation-specific reason',
|
||||
'OperationError');
|
||||
{ name: 'OperationError', cause: err });
|
||||
});
|
||||
|
||||
const keyAlgorithm = {
|
||||
|
||||
@@ -279,10 +279,9 @@ const validateByteSource = hideStackFrames((val, name) => {
|
||||
|
||||
function onDone(resolve, reject, err, result) {
|
||||
if (err) {
|
||||
// TODO(@panva): add err as cause to DOMException
|
||||
return reject(lazyDOMException(
|
||||
'The operation failed for an operation-specific reason',
|
||||
'OperationError'));
|
||||
{ name: 'OperationError', cause: err }));
|
||||
}
|
||||
resolve(result);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user