Add encrypted captcha answer, move AES utils

This commit is contained in:
Alex Gleason
2024-10-03 19:36:44 -05:00
parent f83ad0dbce
commit 8d1b1b8abc
10 changed files with 75 additions and 60 deletions

View File

@@ -7,7 +7,8 @@ import { Conf } from '@/config.ts';
import { ConnectSigner } from '@/signers/ConnectSigner.ts';
import { ReadOnlySigner } from '@/signers/ReadOnlySigner.ts';
import { Storages } from '@/storages.ts';
import { decryptSecretKey, getTokenHash } from '@/utils/auth.ts';
import { aesDecrypt } from '@/utils/aes.ts';
import { getTokenHash } from '@/utils/auth.ts';
/** We only accept "Bearer" type. */
const BEARER_REGEX = new RegExp(`^Bearer (${nip19.BECH32_REGEX.source})$`);
@@ -31,7 +32,7 @@ export const signerMiddleware: AppMiddleware = async (c, next) => {
.where('token_hash', '=', tokenHash)
.executeTakeFirstOrThrow();
const nep46Seckey = await decryptSecretKey(Conf.seckey, nip46_sk_enc);
const nep46Seckey = await aesDecrypt(Conf.seckey, nip46_sk_enc);
c.set('signer', new ConnectSigner(pubkey, new NSecSigner(nep46Seckey), nip46_relays));
} catch {