GeezerVison is showing github.com — lib: refactor SubtleCrypto experimental warnings · nodejs/node@b85c8ce
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: lib/internal/crypto/cfrg.js -5Lines changed: 0 additions & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -27,7 +27,6 @@ const { | 27 | 27 | } = require('internal/crypto/util'); | 28 | 28 |
| 29 | 29 | const { | 30 | | - emitExperimentalWarning, | 31 | 30 | lazyDOMException, | 32 | 31 | promisify, | 33 | 32 | } = require('internal/util'); | @@ -105,7 +104,6 @@ function createCFRGRawKey(name, keyData, isPublic) { | 105 | 104 |
| 106 | 105 | async function cfrgGenerateKey(algorithm, extractable, keyUsages) { | 107 | 106 | const { name } = algorithm; | 108 | | - emitExperimentalWarning(`The ${name} Web Crypto API algorithm`); | 109 | 107 |
| 110 | 108 | const usageSet = new SafeSet(keyUsages); | 111 | 109 | switch (name) { | @@ -187,7 +185,6 @@ async function cfrgGenerateKey(algorithm, extractable, keyUsages) { | 187 | 185 | } | 188 | 186 |
| 189 | 187 | function cfrgExportKey(key, format) { | 190 | | - emitExperimentalWarning(`The ${key.algorithm.name} Web Crypto API algorithm`); | 191 | 188 | return jobPromise(() => new ECKeyExportJob( | 192 | 189 | kCryptoJobAsync, | 193 | 190 | format, | @@ -202,7 +199,6 @@ async function cfrgImportKey( | 202 | 199 | keyUsages) { | 203 | 200 |
| 204 | 201 | const { name } = algorithm; | 205 | | - emitExperimentalWarning(`The ${name} Web Crypto API algorithm`); | 206 | 202 | let keyObject; | 207 | 203 | const usagesSet = new SafeSet(keyUsages); | 208 | 204 | switch (format) { | @@ -319,7 +315,6 @@ async function cfrgImportKey( | 319 | 315 | } | 320 | 316 |
| 321 | 317 | function eddsaSignVerify(key, data, { name, context }, signature) { | 322 | | - emitExperimentalWarning(`The ${name} Web Crypto API algorithm`); | 323 | 318 | const mode = signature === undefined ? kSignJobModeSign : kSignJobModeVerify; | 324 | 319 | const type = mode === kSignJobModeSign ? 'private' : 'public'; | 325 | 320 |
| |
Collapse file Copy file name to clipboardExpand all lines: lib/internal/crypto/util.js +44-14Lines changed: 44 additions & 14 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -11,6 +11,8 @@ const { | 11 | 11 | DataViewPrototypeGetByteOffset, | 12 | 12 | FunctionPrototypeBind, | 13 | 13 | Number, | | 14 | + ObjectDefineProperty, | | 15 | + ObjectEntries, | 14 | 16 | ObjectKeys, | 15 | 17 | ObjectPrototypeHasOwnProperty, | 16 | 18 | Promise, | @@ -63,6 +65,7 @@ const { Buffer } = require('buffer'); | 63 | 65 |
| 64 | 66 | const { | 65 | 67 | cachedResult, | | 68 | + emitExperimentalWarning, | 66 | 69 | filterDuplicateStrings, | 67 | 70 | lazyDOMException, | 68 | 71 | } = require('internal/util'); | @@ -195,26 +198,18 @@ const kSupportedAlgorithms = { | 195 | 198 | 'AES-GCM': 'AesKeyGenParams', | 196 | 199 | 'AES-KW': 'AesKeyGenParams', | 197 | 200 | 'HMAC': 'HmacKeyGenParams', | 198 | | - 'X25519': null, | 199 | | - 'Ed25519': null, | 200 | | - 'X448': null, | 201 | | - 'Ed448': null, | 202 | 201 | }, | 203 | 202 | 'sign': { | 204 | 203 | 'RSASSA-PKCS1-v1_5': null, | 205 | 204 | 'RSA-PSS': 'RsaPssParams', | 206 | 205 | 'ECDSA': 'EcdsaParams', | 207 | 206 | 'HMAC': null, | 208 | | - 'Ed25519': null, | 209 | | - 'Ed448': 'Ed448Params', | 210 | 207 | }, | 211 | 208 | 'verify': { | 212 | 209 | 'RSASSA-PKCS1-v1_5': null, | 213 | 210 | 'RSA-PSS': 'RsaPssParams', | 214 | 211 | 'ECDSA': 'EcdsaParams', | 215 | 212 | 'HMAC': null, | 216 | | - 'Ed25519': null, | 217 | | - 'Ed448': 'Ed448Params', | 218 | 213 | }, | 219 | 214 | 'importKey': { | 220 | 215 | 'RSASSA-PKCS1-v1_5': 'RsaHashedImportParams', | @@ -229,17 +224,11 @@ const kSupportedAlgorithms = { | 229 | 224 | 'AES-CBC': null, | 230 | 225 | 'AES-GCM': null, | 231 | 226 | 'AES-KW': null, | 232 | | - 'Ed25519': null, | 233 | | - 'X25519': null, | 234 | | - 'Ed448': null, | 235 | | - 'X448': null, | 236 | 227 | }, | 237 | 228 | 'deriveBits': { | 238 | 229 | 'HKDF': 'HkdfParams', | 239 | 230 | 'PBKDF2': 'Pbkdf2Params', | 240 | 231 | 'ECDH': 'EcdhKeyDeriveParams', | 241 | | - 'X25519': 'EcdhKeyDeriveParams', | 242 | | - 'X448': 'EcdhKeyDeriveParams', | 243 | 232 | }, | 244 | 233 | 'encrypt': { | 245 | 234 | 'RSA-OAEP': 'RsaOaepParams', | @@ -270,6 +259,47 @@ const kSupportedAlgorithms = { | 270 | 259 | }, | 271 | 260 | }; | 272 | 261 |
| | 262 | +const experimentalAlgorithms = ObjectEntries({ | | 263 | + 'X25519': { | | 264 | + generateKey: null, | | 265 | + importKey: null, | | 266 | + deriveBits: 'EcdhKeyDeriveParams', | | 267 | + }, | | 268 | + 'Ed25519': { | | 269 | + generateKey: null, | | 270 | + sign: null, | | 271 | + verify: null, | | 272 | + importKey: null, | | 273 | + }, | | 274 | + 'X448': { | | 275 | + generateKey: null, | | 276 | + importKey: null, | | 277 | + deriveBits: 'EcdhKeyDeriveParams', | | 278 | + }, | | 279 | + 'Ed448': { | | 280 | + generateKey: null, | | 281 | + sign: 'Ed448Params', | | 282 | + verify: 'Ed448Params', | | 283 | + importKey: null, | | 284 | + }, | | 285 | +}); | | 286 | + | | 287 | +for (let i = 0; i < experimentalAlgorithms.length; i++) { | | 288 | + const name = experimentalAlgorithms[i][0]; | | 289 | + const ops = ObjectEntries(experimentalAlgorithms[i][1]); | | 290 | + for (let j = 0; j < ops.length; j++) { | | 291 | + const { 0: op, 1: dict } = ops[j]; | | 292 | + ObjectDefineProperty(kSupportedAlgorithms[op], name, { | | 293 | + get() { | | 294 | + emitExperimentalWarning(`The ${name} Web Crypto API algorithm`); | | 295 | + return dict; | | 296 | + }, | | 297 | + __proto__: null, | | 298 | + enumerable: true, | | 299 | + }); | | 300 | + } | | 301 | +} | | 302 | + | 273 | 303 | const simpleAlgorithmDictionaries = { | 274 | 304 | AesGcmParams: { iv: 'BufferSource', additionalData: 'BufferSource' }, | 275 | 305 | RsaHashedKeyGenParams: { hash: 'HashAlgorithmIdentifier' }, | |
|