File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -897,9 +897,10 @@ const {
897897 return [ CryptoKey , InternalCryptoKey ] ;
898898} ) ;
899899
900- // The helpers below return a CryptoKey's raw internal slot value,
900+ // The helpers below return a CryptoKey's internal slot value,
901901// populating the per-instance cache on first access via a single
902- // native call. The public `algorithm` / `usages` getters on
902+ // native call. The public `type` getter converts the native enum to
903+ // the Web Crypto string. The public `algorithm` / `usages` getters on
903904// `CryptoKey.prototype` further clone their slot before returning.
904905
905906/**
@@ -908,7 +909,16 @@ const {
908909 * @returns {'secret' | 'public' | 'private' }
909910 */
910911function getCryptoKeyType ( key ) {
911- return getSlots ( key ) [ kSlotType ] ;
912+ switch ( getSlots ( key ) [ kSlotType ] ) {
913+ case kKeyTypeSecret : return 'secret' ;
914+ case kKeyTypePublic : return 'public' ;
915+ case kKeyTypePrivate : return 'private' ;
916+ default : {
917+ // It is not possible to get here because all possible cases are handled above.
918+ const assert = require ( 'internal/assert' ) ;
919+ assert . fail ( 'Unreachable code' ) ;
920+ }
921+ }
912922}
913923
914924/**
You can’t perform that action at this time.
0 commit comments