recoder-code
Version:
Complete AI-powered development platform with ML model training, plugin registry, real-time collaboration, monitoring, infrastructure automation, and enterprise deployment capabilities
20 lines (17 loc) • 445 B
JavaScript
import * as webcrypto from 'lib0/webcrypto'
/**
* @param {CryptoKey} key
*/
export const exportKeyJwk = async key => {
const jwk = await webcrypto.subtle.exportKey('jwk', key)
jwk.key_ops = key.usages
return jwk
}
/**
* Only suited for exporting public keys.
*
* @param {CryptoKey} key
* @return {Promise<Uint8Array>}
*/
export const exportKeyRaw = key =>
webcrypto.subtle.exportKey('raw', key).then(key => new Uint8Array(key))