| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,6 +4,7 @@ const { | |||
| 4 | 4 | ArrayFrom, | |
| 5 | 5 | ArrayPrototypeSlice, | |
| 6 | 6 | ObjectDefineProperty, | |
| 7 | + ObjectDefineProperties, | ||
| 7 | 8 | ObjectSetPrototypeOf, | |
| 8 | 9 | Symbol, | |
| 9 | 10 | Uint8Array, | |
@@ -38,6 +39,7 @@ const { | |||
| 38 | 39 | ERR_ILLEGAL_CONSTRUCTOR, | |
| 39 | 40 | ERR_INVALID_ARG_TYPE, | |
| 40 | 41 | ERR_INVALID_ARG_VALUE, | |
| 42 | + ERR_INVALID_THIS, | ||
| 41 | 43 | } | |
| 42 | 44 | } = require('internal/errors'); | |
| 43 | 45 | ||
@@ -61,6 +63,7 @@ const { | |||
| 61 | 63 | ||
| 62 | 64 | const { | |
| 63 | 65 | customInspectSymbol: kInspect, | |
| 66 | + kEnumerableProperty, | ||
| 64 | 67 | } = require('internal/util'); | |
| 65 | 68 | ||
| 66 | 69 | const { inspect } = require('internal/util/inspect'); | |
@@ -657,18 +660,26 @@ class CryptoKey extends JSTransferable { | |||
| 657 | 660 | } | |
| 658 | 661 | ||
| 659 | 662 | get type() { | |
| 663 | + if (!(this instanceof CryptoKey)) | ||
| 664 | + throw new ERR_INVALID_THIS('CryptoKey'); | ||
| 660 | 665 | return this[kKeyObject].type; | |
| 661 | 666 | } | |
| 662 | 667 | ||
| 663 | 668 | get extractable() { | |
| 669 | + if (!(this instanceof CryptoKey)) | ||
| 670 | + throw new ERR_INVALID_THIS('CryptoKey'); | ||
| 664 | 671 | return this[kExtractable]; | |
| 665 | 672 | } | |
| 666 | 673 | ||
| 667 | 674 | get algorithm() { | |
| 675 | + if (!(this instanceof CryptoKey)) | ||
| 676 | + throw new ERR_INVALID_THIS('CryptoKey'); | ||
| 668 | 677 | return this[kAlgorithm]; | |
| 669 | 678 | } | |
| 670 | 679 | ||
| 671 | 680 | get usages() { | |
| 681 | + if (!(this instanceof CryptoKey)) | ||
| 682 | + throw new ERR_INVALID_THIS('CryptoKey'); | ||
| 672 | 683 | return ArrayFrom(this[kKeyUsages]); | |
| 673 | 684 | } | |
| 674 | 685 | ||
@@ -697,6 +708,13 @@ class CryptoKey extends JSTransferable { | |||
| 697 | 708 | } | |
| 698 | 709 | } | |
| 699 | 710 | ||
| 711 | + ObjectDefineProperties(CryptoKey.prototype, { | ||
| 712 | + type: kEnumerableProperty, | ||
| 713 | + extractable: kEnumerableProperty, | ||
| 714 | + algorithm: kEnumerableProperty, | ||
| 715 | + usages: kEnumerableProperty, | ||
| 716 | + }); | ||
| 717 | + | ||
| 700 | 718 | // All internal code must use new InternalCryptoKey to create | |
| 701 | 719 | // CryptoKey instances. The CryptoKey class is exposed to end | |
| 702 | 720 | // user code but is not permitted to be constructed directly. | |
| Back | FazBrowse Home | New Git URL |
0 commit comments