From 5fc15b6212ee59b4d855afea26e617db13ae94e0 Mon Sep 17 00:00:00 2001 From: Gabo Esquivel Date: Wed, 21 Aug 2024 16:22:13 -0600 Subject: [PATCH] chore(indexer): verify call with alchemy signing key (#318) --- apps/indexer/.env-sample | 2 +- apps/indexer/src/config.ts | 4 +++- apps/indexer/src/routes/alchemy.ts | 5 ++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/apps/indexer/.env-sample b/apps/indexer/.env-sample index 4720e19cf..0cd94f8ad 100644 --- a/apps/indexer/.env-sample +++ b/apps/indexer/.env-sample @@ -4,4 +4,4 @@ SEPOLIA_RPC=https://eth-sepolia.g.alchemy.com/v2/xxx ISSUER_KEY=xxx ISSUER_ADDRESS=0x DFUSE_API_KEY=server_xxx -ALCHEMY_SECRET_KEY=xxx \ No newline at end of file +ALCHEMY_ACTIVITY_SIGNING_KEY=xxx \ No newline at end of file diff --git a/apps/indexer/src/config.ts b/apps/indexer/src/config.ts index e1ea1d17b..b553a7af1 100644 --- a/apps/indexer/src/config.ts +++ b/apps/indexer/src/config.ts @@ -15,7 +15,9 @@ export const appConfig = { issuerKey: process.env.ISSUER_KEY || '', issuerAddress: (process.env.ISSUER_ADDRESS || '') as Address, issuerAccount: privateKeyToAccount(`0x${process.env.ISSUER_KEY}`), - alchemySecretKey: process.env.ALCHEMY_SECRET_KEY || '', + alchemy: { + activitySigningKey: process.env.ALCHEMY_ACTIVITY_SIGNING_KEY || '', + }, }, ...smartsaleEnv.test, } diff --git a/apps/indexer/src/routes/alchemy.ts b/apps/indexer/src/routes/alchemy.ts index 64fa35d49..8b481cefc 100644 --- a/apps/indexer/src/routes/alchemy.ts +++ b/apps/indexer/src/routes/alchemy.ts @@ -20,7 +20,10 @@ export function alchemyWebhook(req: Request, res: Response) { function validateAlchemySignature(req: Request): boolean { const alchemySignature = req.headers['x-alchemy-signature'] as string const payload = JSON.stringify(req.body) - const hmac = crypto.createHmac('sha256', appConfig.evm.alchemySecretKey) + const hmac = crypto.createHmac( + 'sha256', + appConfig.evm.alchemy.activitySigningKey, + ) hmac.update(payload) return alchemySignature === hmac.digest('hex') }