Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 1a8aa50

Browse filesBrowse files
panvajuanarbol
authored andcommitted
crypto: fix CryptoKey WebIDL conformance
PR-URL: #45855 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
1 parent c643645 commit 1a8aa50
Copy full SHA for 1a8aa50

File tree

Expand file treeCollapse file tree

1 file changed

+18
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+18
-0
lines changed
Open diff view settings
Collapse file

‎lib/internal/crypto/keys.js‎

Copy file name to clipboardExpand all lines: lib/internal/crypto/keys.js
+18Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const {
44
ArrayFrom,
55
ArrayPrototypeSlice,
66
ObjectDefineProperty,
7+
ObjectDefineProperties,
78
ObjectSetPrototypeOf,
89
Symbol,
910
Uint8Array,
@@ -38,6 +39,7 @@ const {
3839
ERR_ILLEGAL_CONSTRUCTOR,
3940
ERR_INVALID_ARG_TYPE,
4041
ERR_INVALID_ARG_VALUE,
42+
ERR_INVALID_THIS,
4143
}
4244
} = require('internal/errors');
4345

@@ -61,6 +63,7 @@ const {
6163

6264
const {
6365
customInspectSymbol: kInspect,
66+
kEnumerableProperty,
6467
} = require('internal/util');
6568

6669
const { inspect } = require('internal/util/inspect');
@@ -657,18 +660,26 @@ class CryptoKey extends JSTransferable {
657660
}
658661

659662
get type() {
663+
if (!(this instanceof CryptoKey))
664+
throw new ERR_INVALID_THIS('CryptoKey');
660665
return this[kKeyObject].type;
661666
}
662667

663668
get extractable() {
669+
if (!(this instanceof CryptoKey))
670+
throw new ERR_INVALID_THIS('CryptoKey');
664671
return this[kExtractable];
665672
}
666673

667674
get algorithm() {
675+
if (!(this instanceof CryptoKey))
676+
throw new ERR_INVALID_THIS('CryptoKey');
668677
return this[kAlgorithm];
669678
}
670679

671680
get usages() {
681+
if (!(this instanceof CryptoKey))
682+
throw new ERR_INVALID_THIS('CryptoKey');
672683
return ArrayFrom(this[kKeyUsages]);
673684
}
674685

@@ -697,6 +708,13 @@ class CryptoKey extends JSTransferable {
697708
}
698709
}
699710

711+
ObjectDefineProperties(CryptoKey.prototype, {
712+
type: kEnumerableProperty,
713+
extractable: kEnumerableProperty,
714+
algorithm: kEnumerableProperty,
715+
usages: kEnumerableProperty,
716+
});
717+
700718
// All internal code must use new InternalCryptoKey to create
701719
// CryptoKey instances. The CryptoKey class is exposed to end
702720
// user code but is not permitted to be constructed directly.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.