mirror of
https://github.com/nodejs/node.git
synced 2026-10-28 10:15:07 +08:00
crypto: remove select Web Crypto warnings
Remove ExperimentalWarning from algorithms and methods that are on their way to an unflagged browser implementation. Signed-off-by: Filip Skokan <panva.ip@gmail.com> PR-URL: https://github.com/nodejs/node/pull/66312 Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
1 parent
28194a3037
commit
773bdd175d
3 files changed
+14
-20
No files matched your search
+12
-11
@@ -575,26 +575,19 @@ function getConditionalAlgorithms() {
|
||||
};
|
||||
}
|
||||
|
||||
// Experimental algorithms
|
||||
const experimentalAlgorithms = [
|
||||
// Experimental algorithms that emit warnings.
|
||||
const experimentalAlgorithmsWithWarnings = [
|
||||
'AES-OCB',
|
||||
'Argon2d',
|
||||
'Argon2i',
|
||||
'Argon2id',
|
||||
'ChaCha20-Poly1305',
|
||||
'cSHAKE128',
|
||||
'cSHAKE256',
|
||||
'Ed448',
|
||||
'KMAC128',
|
||||
'KMAC256',
|
||||
'ML-DSA-44',
|
||||
'ML-DSA-65',
|
||||
'ML-DSA-87',
|
||||
'ML-KEM-512',
|
||||
'ML-KEM-768',
|
||||
'ML-KEM-1024',
|
||||
'MLKEM768-P256',
|
||||
'MLKEM768-X25519',
|
||||
'MLKEM1024-P384',
|
||||
'SHA3-256',
|
||||
'SHA3-384',
|
||||
@@ -604,6 +597,14 @@ const experimentalAlgorithms = [
|
||||
'KT128',
|
||||
'KT256',
|
||||
'X448',
|
||||
// Ships unflagged in Chromium >= 155
|
||||
// 'ChaCha20-Poly1305'
|
||||
// 'ML-DSA-44'
|
||||
// 'ML-DSA-65'
|
||||
// 'ML-DSA-87'
|
||||
// 'ML-KEM-768'
|
||||
// 'ML-KEM-1024'
|
||||
// 'MLKEM768-X25519'
|
||||
];
|
||||
|
||||
// Transform the algorithm definitions into the operation-keyed structure
|
||||
@@ -632,8 +633,8 @@ function createSupportedAlgorithms(algorithmDefs) {
|
||||
nameMap[operation] ||= new SafeMap();
|
||||
nameMap[operation].set(StringPrototypeToUpperCase(algorithmName), algorithmName);
|
||||
|
||||
// Add experimental warnings for experimental algorithms
|
||||
if (ArrayPrototypeIncludes(experimentalAlgorithms, algorithmName)) {
|
||||
// Add warnings for select experimental algorithms
|
||||
if (ArrayPrototypeIncludes(experimentalAlgorithmsWithWarnings, algorithmName)) {
|
||||
ObjectDefineProperty(result[operation], algorithmName, {
|
||||
get() {
|
||||
emitExperimentalWarning(`The ${algorithmName} Web Crypto API algorithm`);
|
||||
|
||||
@@ -74,7 +74,6 @@ const {
|
||||
} = require('internal/crypto/util');
|
||||
|
||||
const {
|
||||
emitExperimentalWarning,
|
||||
kEnumerableProperty,
|
||||
lazyDOMException,
|
||||
setOwnProperty,
|
||||
@@ -1473,7 +1472,6 @@ function getPublicKey(key, keyUsages) {
|
||||
}
|
||||
|
||||
function getPublicKeyImpl(key, keyUsages) {
|
||||
emitExperimentalWarning('The getPublicKey Web Crypto API method');
|
||||
const prefix = prepareSubtleMethod(this, 'getPublicKey', arguments.length, 2);
|
||||
let i = 0;
|
||||
key = convertSubtleArgument(prefix, 'CryptoKey', key, i++);
|
||||
@@ -1501,7 +1499,6 @@ function encapsulateBits(encapsulationAlgorithm, encapsulationKey) {
|
||||
}
|
||||
|
||||
function encapsulateBitsImpl(encapsulationAlgorithm, encapsulationKey) {
|
||||
emitExperimentalWarning('The encapsulateBits Web Crypto API method');
|
||||
const prefix = prepareSubtleMethod(
|
||||
this, 'encapsulateBits', arguments.length, 2);
|
||||
let i = 0;
|
||||
@@ -1563,7 +1560,6 @@ function encapsulateKeyImpl(
|
||||
sharedKeyAlgorithm,
|
||||
extractable,
|
||||
keyUsages) {
|
||||
emitExperimentalWarning('The encapsulateKey Web Crypto API method');
|
||||
const prefix = prepareSubtleMethod(
|
||||
this, 'encapsulateKey', arguments.length, 5);
|
||||
let i = 0;
|
||||
@@ -1642,7 +1638,6 @@ function decapsulateBits(decapsulationAlgorithm, decapsulationKey, ciphertext) {
|
||||
}
|
||||
|
||||
function decapsulateBitsImpl(decapsulationAlgorithm, decapsulationKey, ciphertext) {
|
||||
emitExperimentalWarning('The decapsulateBits Web Crypto API method');
|
||||
const prefix = prepareSubtleMethod(
|
||||
this, 'decapsulateBits', arguments.length, 3);
|
||||
let i = 0;
|
||||
@@ -1707,7 +1702,6 @@ function decapsulateKeyImpl(
|
||||
sharedKeyAlgorithm,
|
||||
extractable,
|
||||
keyUsages) {
|
||||
emitExperimentalWarning('The decapsulateKey Web Crypto API method');
|
||||
const prefix = prepareSubtleMethod(
|
||||
this, 'decapsulateKey', arguments.length, 6);
|
||||
let i = 0;
|
||||
@@ -1785,7 +1779,6 @@ class SubtleCrypto {
|
||||
|
||||
// Implements https://wicg.github.io/webcrypto-modern-algos/#SubtleCrypto-method-supports
|
||||
static supports(operation, algorithm, lengthOrAdditionalAlgorithm = null) {
|
||||
emitExperimentalWarning('The supports Web Crypto API method');
|
||||
webidl ??= require('internal/crypto/webidl');
|
||||
const prefix = "Failed to execute 'supports' on 'SubtleCrypto'";
|
||||
webidl.requiredArguments(arguments.length, 2, { prefix });
|
||||
|
||||
@@ -20,8 +20,8 @@ const TypedArrayPrototype = Object.getPrototypeOf(Uint8Array.prototype);
|
||||
const data = new TextEncoder().encode('prototype pollution');
|
||||
const modulusLength = getFips() === 1 ? 2048 : 1024;
|
||||
|
||||
// Avoids SubtleCrypto.supports(), which warns and invokes the registry's
|
||||
// experimental-algorithm getters.
|
||||
// Avoids SubtleCrypto.supports(), which can invoke the registry's
|
||||
// experimental-algorithm warning getters.
|
||||
function supports(operation, name) {
|
||||
return Object.hasOwn(kSupportedAlgorithms[operation] ?? {}, name);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user