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

Method toCryptoKey

lib/internal/crypto/keys.js:165–189  ·  view source on GitHub ↗
(algorithm, extractable, keyUsages)

Source from the content-addressed store, hash-verified

163 }
164
165 toCryptoKey(algorithm, extractable, keyUsages) {
166 webidl ??= require('internal/crypto/webidl');
167 algorithm = normalizeAlgorithm(webidl.converters.AlgorithmIdentifier(algorithm), 'importKey');
168 extractable = webidl.converters.boolean(extractable);
169 keyUsages = webidl.converters['sequence<KeyUsage>'](keyUsages);
170
171 const type = getKeyObjectType(this);
172 const handle = getKeyObjectHandle(this);
173 switch (type) {
174 case 'secret':
175 return toCryptoKeySecret(
176 handle,
177 algorithm,
178 extractable,
179 keyUsages);
180 case 'public':
181 // Fall through
182 case 'private':
183 return toCryptoKey(
184 handle,
185 algorithm,
186 extractable,
187 keyUsages);
188 }
189 }
190
191 static from(key) {
192 if (!isCryptoKey(key))

Calls 7

getKeyObjectTypeFunction · 0.85
getKeyObjectHandleFunction · 0.85
toCryptoKeySecretFunction · 0.85
toCryptoKeyFunction · 0.85
booleanMethod · 0.80
normalizeAlgorithmFunction · 0.70
requireFunction · 0.50

Tested by 1

testFunction · 0.64