import { describe, expect, test } from 'vitest' import { generateKeypair } from './generate-keypair.js' /** * Although this case is testing library code under the hood, it is helpful * out of documentation reasons. */ describe('The generateKeyPair function', () => { test('should be able to generate a keypair', async () => { const keypair = await generateKeypair() // // Public Key // expect(keypair.publicKey.algorithm).toMatchInlineSnapshot(` { "name": "Ed25519", } `) expect(keypair.publicKey.usages).toMatchInlineSnapshot(` [ "verify", ] `) expect(keypair.publicKey.type).toMatchInlineSnapshot(`"public"`) expect(keypair.publicKey.extractable).toBe(true) // // Private Key // expect(keypair.privateKey.algorithm).toMatchInlineSnapshot(` { "name": "Ed25519", } `) expect(keypair.privateKey.usages).toMatchInlineSnapshot(` [ "sign", ] `) 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) }) })