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

Method export

lib/internal/crypto/keys.js:313–344  ·  view source on GitHub ↗
(options)

Source from the content-addressed store, hash-verified

311 }
312
313 export(options) {
314 if (options?.passphrase !== undefined &&
315 options.format !== 'pem' && options.format !== 'der') {
316 throw new ERR_CRYPTO_INCOMPATIBLE_KEY_OPTIONS(
317 options.format, 'does not support encryption');
318 }
319 switch (options?.format) {
320 case 'jwk':
321 return getKeyObjectHandle(this).exportJwk({}, false);
322 case 'raw-private': {
323 const handle = getKeyObjectHandle(this);
324 const asymmetricKeyType = getKeyObjectAsymmetricKeyType(this);
325 if (asymmetricKeyType === 'ec') {
326 return handle.exportECPrivateRaw();
327 }
328 return handle.rawPrivateKey();
329 }
330 case 'raw-seed':
331 return getKeyObjectHandle(this).rawSeed();
332 default: {
333 const asymmetricKeyType = getKeyObjectAsymmetricKeyType(this);
334 const handle = getKeyObjectHandle(this);
335 const {
336 format,
337 type,
338 cipher,
339 passphrase,
340 } = parsePrivateKeyEncoding(options, asymmetricKeyType);
341 return handle.export(format, type, cipher, passphrase);
342 }
343 }
344 }
345 }
346
347 return [KeyObject, SecretKeyObject, PublicKeyObject, PrivateKeyObject];

Callers

nothing calls this directly

Calls 4

getKeyObjectHandleFunction · 0.85
parsePrivateKeyEncodingFunction · 0.85
exportMethod · 0.45

Tested by

no test coverage detected