import { describe, test, expect } from 'vitest' import { generateKeypair } from './generate-keypair.js' describe('The generateKeypair function', () => { test('to generate an encryption keypair', async () => { const keypair = await generateKeypair() // // Public Key // expect(keypair.publicKey.algorithm).toMatchInlineSnapshot(` { "hash": { "name": "SHA-512", }, "modulusLength": 4096, "name": "RSA-OAEP", "publicExponent": Uint8Array [ 1, 0, 1, ], } `) expect(keypair.publicKey.usages).toMatchInlineSnapshot(` [ "encrypt", "wrapKey", ] `) expect(keypair.publicKey.type).toMatchInlineSnapshot(`"public"`) expect(keypair.publicKey.extractable).toBe(true) // // Private Key // expect(keypair.privateKey.algorithm).toMatchInlineSnapshot(` { "hash": { "name": "SHA-512", }, "modulusLength": 4096, "name": "RSA-OAEP", "publicExponent": Uint8Array [ 1, 0, 1, ], } `) expect(keypair.privateKey.usages).toMatchInlineSnapshot(` [ "decrypt", "unwrapKey", ] `) expect(keypair.privateKey.type).toMatchInlineSnapshot(`"private"`) // The private key is extractable as well as otherwise we wouldn't be able to serialize it as a JWT expect(keypair.privateKey.extractable).toBe(true) }) })