From a5849174fe02a1bd3827455246c073ce15a8c560 Mon Sep 17 00:00:00 2001 From: psiddharthdesign <107192927+psiddharthdesign@users.noreply.github.com> Date: Tue, 6 Aug 2024 02:05:42 +0530 Subject: [PATCH] fix / headers issue --- src/data/user/secretKey.ts | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/src/data/user/secretKey.ts b/src/data/user/secretKey.ts index 33acd3d8..d4505658 100644 --- a/src/data/user/secretKey.ts +++ b/src/data/user/secretKey.ts @@ -25,13 +25,6 @@ export async function getPublicKey( return data?.public_key || null; } -function stripKeyHeaders(key: string): string { - return key - .replace(/-----BEGIN (PUBLIC|PRIVATE) KEY-----/, '') - .replace(/-----END (PUBLIC|PRIVATE) KEY-----/, '') - .replace(/\n/g, ''); -} - export async function createKeyPair( organizationId: string, ): Promise> { @@ -51,14 +44,10 @@ export async function createKeyPair( }, }); - // Strip headers and footers - const strippedPublicKey = stripKeyHeaders(publicKey); - const strippedPrivateKey = stripKeyHeaders(privateKey); - - // Save stripped public key to the database + // Save public key with headers to the database const { error } = await supabase .from('organizations') - .update({ public_key: strippedPublicKey }) + .update({ public_key: publicKey }) .eq('id', organizationId); if (error) throw error; @@ -67,7 +56,7 @@ export async function createKeyPair( return { status: 'success', - data: { publicKey: strippedPublicKey, privateKey: strippedPrivateKey }, + data: { publicKey, privateKey }, }; } catch (error) { console.error('Error creating key pair:', error);