mirror of
https://github.com/nodejs/node.git
synced 2025-05-01 17:03:34 +00:00
crypto: remove non-standard webcrypto.Crypto.prototype.CryptoKey
`CryptoKey` is already available on the global object. PR-URL: https://github.com/nodejs/node/pull/42083 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Filip Skokan <panva.ip@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com>
This commit is contained in:
parent
6de2673a9f
commit
2849283c4c
@ -5,6 +5,7 @@ const {
|
||||
JSONParse,
|
||||
JSONStringify,
|
||||
ObjectDefineProperties,
|
||||
ObjectDefineProperty,
|
||||
ReflectApply,
|
||||
ReflectConstruct,
|
||||
SafeSet,
|
||||
@ -28,6 +29,10 @@ const {
|
||||
validateString,
|
||||
} = require('internal/validators');
|
||||
|
||||
const {
|
||||
getOptionValue,
|
||||
} = require('internal/options');
|
||||
|
||||
const { TextDecoder, TextEncoder } = require('internal/encoding');
|
||||
|
||||
const {
|
||||
@ -792,15 +797,20 @@ ObjectDefineProperties(
|
||||
writable: true,
|
||||
value: randomUUID,
|
||||
},
|
||||
CryptoKey: {
|
||||
__proto__: null,
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: CryptoKey,
|
||||
}
|
||||
});
|
||||
|
||||
if (getOptionValue('--no-experimental-global-webcrypto')) {
|
||||
// For backward compatibility, keep exposing CryptoKey in the Crypto prototype
|
||||
// when using the flag.
|
||||
ObjectDefineProperty(Crypto.prototype, 'CryptoKey', {
|
||||
__proto__: null,
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: CryptoKey,
|
||||
});
|
||||
}
|
||||
|
||||
ObjectDefineProperties(
|
||||
SubtleCrypto.prototype, {
|
||||
[SymbolToStringTag]: {
|
||||
|
@ -15,7 +15,7 @@ const crypto = require('crypto').webcrypto;
|
||||
{ name: 'AES-GCM' },
|
||||
false,
|
||||
[ 'encrypt', 'decrypt' ]);
|
||||
assert(k instanceof crypto.CryptoKey);
|
||||
assert(k instanceof CryptoKey);
|
||||
|
||||
const e = await crypto.subtle.encrypt({
|
||||
name: 'AES-GCM',
|
||||
|
@ -9,7 +9,7 @@ if (!common.hasCrypto)
|
||||
const assert = require('assert');
|
||||
const { types: { isCryptoKey } } = require('util');
|
||||
const {
|
||||
webcrypto: { subtle, CryptoKey },
|
||||
webcrypto: { subtle },
|
||||
createSecretKey,
|
||||
KeyObject,
|
||||
} = require('crypto');
|
||||
|
Loading…
Reference in New Issue
Block a user