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

Method export

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

Source from the content-addressed store, hash-verified

277 }
278
279 export(options) {
280 switch (options?.format) {
281 case 'jwk':
282 return getKeyObjectHandle(this).exportJwk({}, false);
283 case 'raw-public': {
284 const handle = getKeyObjectHandle(this);
285 const asymmetricKeyType = getKeyObjectAsymmetricKeyType(this);
286 if (asymmetricKeyType === 'ec') {
287 const { type = 'uncompressed' } = options;
288 validateOneOf(type, 'options.type', ['compressed', 'uncompressed']);
289 const form = type === 'compressed' ?
290 POINT_CONVERSION_COMPRESSED : POINT_CONVERSION_UNCOMPRESSED;
291 return handle.exportECPublicRaw(form);
292 }
293 return handle.rawPublicKey();
294 }
295 default: {
296 const asymmetricKeyType = getKeyObjectAsymmetricKeyType(this);
297 const handle = getKeyObjectHandle(this);
298 const {
299 format,
300 type,
301 } = parsePublicKeyEncoding(options, asymmetricKeyType);
302 return handle.export(format, type);
303 }
304 }
305 }
306 }
307
308 class PrivateKeyObject extends AsymmetricKeyObject {

Callers

nothing calls this directly

Calls 4

getKeyObjectHandleFunction · 0.85
parsePublicKeyEncodingFunction · 0.85
exportMethod · 0.45

Tested by

no test coverage detected