MCPcopy Index your code
hub / github.com/nodejs/node / getKeyObjectAsymmetricKeyDetails

Function getKeyObjectAsymmetricKeyDetails

lib/internal/crypto/keys.js:940–968  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

938 * @returns {object}
939 */
940function 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
970function isKeyObject(obj) {
971 if (obj == null || typeof obj !== 'object')

Callers 1

asymmetricKeyDetailsMethod · 0.85

Calls 1

normalizeKeyDetailsFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…