From 49d0079e46b11f86a9956cfe6dcc000569824470 Mon Sep 17 00:00:00 2001 From: Shibo Lyu Date: Thu, 10 Oct 2024 15:26:23 +0800 Subject: [PATCH] feat(crypto): allow generating non extractable keypair with additional usage --- crypto/keypair.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/crypto/keypair.ts b/crypto/keypair.ts index 3784819..fd15669 100644 --- a/crypto/keypair.ts +++ b/crypto/keypair.ts @@ -28,13 +28,17 @@ export class BlahKeyPair { this.privateKey = privateKey; } - static async generate(): Promise { + static async generate( + extractable: boolean = true, + additionalUsage: KeyUsage[] = [], + ): Promise { const { publicKey, privateKey } = await crypto.subtle.generateKey( "Ed25519", - true, + extractable, [ "sign", "verify", + ...additionalUsage, ], ) as CryptoKeyPair; const publicIdentity = await BlahPublicKey.fromPublicKey(publicKey);