Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async exportKey(key: SigningCryptoKey): Promise {
let buffer: ArrayBuffer;
if (key instanceof BrowserPublicCryptoKey) {
buffer = await crypto.subtle.exportKey('spki', key.publicKey);
return formatPublicPEMKey(buffer);
} else if (key instanceof BrowserPrivateCryptoKey) {
buffer = await crypto.subtle.exportKey('pkcs8', key.privateKey);
return formatPrivatePEMKey(buffer);
}
throw this._unknownKey();
}