mirror of https://github.com/nodejs/node.git
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,
|
JSONParse,
|
||||||
JSONStringify,
|
JSONStringify,
|
||||||
ObjectDefineProperties,
|
ObjectDefineProperties,
|
||||||
|
ObjectDefineProperty,
|
||||||
ReflectApply,
|
ReflectApply,
|
||||||
ReflectConstruct,
|
ReflectConstruct,
|
||||||
SafeSet,
|
SafeSet,
|
||||||
|
@ -28,6 +29,10 @@ const {
|
||||||
validateString,
|
validateString,
|
||||||
} = require('internal/validators');
|
} = require('internal/validators');
|
||||||
|
|
||||||
|
const {
|
||||||
|
getOptionValue,
|
||||||
|
} = require('internal/options');
|
||||||
|
|
||||||
const { TextDecoder, TextEncoder } = require('internal/encoding');
|
const { TextDecoder, TextEncoder } = require('internal/encoding');
|
||||||
|
|
||||||
const {
|
const {
|
||||||
|
@ -792,15 +797,20 @@ ObjectDefineProperties(
|
||||||
writable: true,
|
writable: true,
|
||||||
value: randomUUID,
|
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(
|
ObjectDefineProperties(
|
||||||
SubtleCrypto.prototype, {
|
SubtleCrypto.prototype, {
|
||||||
[SymbolToStringTag]: {
|
[SymbolToStringTag]: {
|
||||||
|
|
|
@ -15,7 +15,7 @@ const crypto = require('crypto').webcrypto;
|
||||||
{ name: 'AES-GCM' },
|
{ name: 'AES-GCM' },
|
||||||
false,
|
false,
|
||||||
[ 'encrypt', 'decrypt' ]);
|
[ 'encrypt', 'decrypt' ]);
|
||||||
assert(k instanceof crypto.CryptoKey);
|
assert(k instanceof CryptoKey);
|
||||||
|
|
||||||
const e = await crypto.subtle.encrypt({
|
const e = await crypto.subtle.encrypt({
|
||||||
name: 'AES-GCM',
|
name: 'AES-GCM',
|
||||||
|
|
|
@ -9,7 +9,7 @@ if (!common.hasCrypto)
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const { types: { isCryptoKey } } = require('util');
|
const { types: { isCryptoKey } } = require('util');
|
||||||
const {
|
const {
|
||||||
webcrypto: { subtle, CryptoKey },
|
webcrypto: { subtle },
|
||||||
createSecretKey,
|
createSecretKey,
|
||||||
KeyObject,
|
KeyObject,
|
||||||
} = require('crypto');
|
} = require('crypto');
|
||||||
|
|
Loading…
Reference in New Issue