* Returns the KeyObject's cached asymmetric key details, bypassing the * public `asymmetricKeyDetails` getter (which returns a cloned copy). * The value is derived lazily from the cached KeyObjectHandle. * @param {PublicKeyObject|PrivateKeyObject} key * @returns {object}
(key)
| 938 | * @returns {object} |
| 939 | */ |
| 940 | function getKeyObjectAsymmetricKeyDetails(key) { |
| 941 | const slots = getKeyObjectSlots(key); |
| 942 | if (slots[kKeyObjectSlotType] === kKeyTypeSecret) |
| 943 | throw new ERR_INVALID_THIS('AsymmetricKeyObject'); |
| 944 | |
| 945 | let cached = slots[kKeyObjectSlotAsymmetricKeyDetails]; |
| 946 | if (cached === undefined) { |
| 947 | let asymmetricKeyType = slots[kKeyObjectSlotAsymmetricKeyType]; |
| 948 | if (asymmetricKeyType === undefined) { |
| 949 | asymmetricKeyType = slots[kKeyObjectSlotHandle].getAsymmetricKeyType(); |
| 950 | slots[kKeyObjectSlotAsymmetricKeyType] = asymmetricKeyType; |
| 951 | } |
| 952 | switch (asymmetricKeyType) { |
| 953 | case 'rsa': |
| 954 | case 'rsa-pss': |
| 955 | case 'dsa': |
| 956 | case 'ec': |
| 957 | cached = normalizeKeyDetails( |
| 958 | slots[kKeyObjectSlotHandle].keyDetail({ __proto__: null }), |
| 959 | ); |
| 960 | break; |
| 961 | default: |
| 962 | cached = kEmptyObject; |
| 963 | break; |
| 964 | } |
| 965 | slots[kKeyObjectSlotAsymmetricKeyDetails] = cached; |
| 966 | } |
| 967 | return cached; |
| 968 | } |
| 969 | |
| 970 | function isKeyObject(obj) { |
| 971 | if (obj == null || typeof obj !== 'object') |
no test coverage detected
searching dependent graphs…