From 107504050e98f977f0cb37727c7030edc08864a9 Mon Sep 17 00:00:00 2001 From: Danny Morabito Date: Thu, 24 Apr 2025 19:37:50 +0200 Subject: [PATCH] bug: adding ccn instead of creating doesn't encrypt key --- index.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/index.ts b/index.ts index 104eaba..2182675 100644 --- a/index.ts +++ b/index.ts @@ -36,6 +36,7 @@ import { isValidJSON, parseATagQuery, } from './utils.ts'; +import { encryptUint8Array, encryptionKey } from './utils/encryption.ts'; import { getEveFilePath } from './utils/files.ts'; import { log, setupLogger } from './utils/logs.ts'; import { mixQuery, sql, sqlPartial } from './utils/queries.ts'; @@ -973,7 +974,11 @@ async function handleAddCCN( const ccnPublicKey = nostrTools.getPublicKey(privateKeyBytes); const ccnPrivPath = await getEveFilePath(`ccn_keys/${ccnPublicKey}`); - Deno.writeTextFileSync(ccnPrivPath, encodeBase64(privateKeyBytes)); + const encryptedPrivateKey = encryptUint8Array( + privateKeyBytes, + encryptionKey, + ); + Deno.writeTextFileSync(ccnPrivPath, encodeBase64(encryptedPrivateKey)); db.run('BEGIN TRANSACTION');