Skip to content

Commit

Permalink
chore(indexer): verify call with alchemy signing key (#318)
Browse files Browse the repository at this point in the history
  • Loading branch information
gaboesquivel committed Aug 21, 2024
1 parent 7c30f06 commit 5fc15b6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion apps/indexer/.env-sample
Original file line number Diff line number Diff line change
Expand Up @@ -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
ALCHEMY_ACTIVITY_SIGNING_KEY=xxx
4 changes: 3 additions & 1 deletion apps/indexer/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
5 changes: 4 additions & 1 deletion apps/indexer/src/routes/alchemy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
}

0 comments on commit 5fc15b6

Please sign in to comment.