Skip to content

Commit 9dff32a

Browse files
committed
Moving JSON parse into try catch
1 parent d65b4df commit 9dff32a

File tree

1 file changed

+12
-12
lines changed
  • packages/bitcore-node/src/routes/api

1 file changed

+12
-12
lines changed

packages/bitcore-node/src/routes/api/wallet.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,19 +45,19 @@ const authenticate: RequestHandler = async (req: PreAuthRequest, res: Response,
4545
} catch (err) {
4646
return res.status(500).send('Problem authenticating wallet');
4747
}
48-
49-
if (req.is('application/octet-stream')) {
50-
req.body = JSON.parse(req.body.toString());
51-
}
52-
if (!wallet) {
53-
return res.status(404).send('Wallet not found');
54-
}
55-
Object.assign(req, { wallet });
56-
const walletConfig = Config.for('api').wallets;
57-
if (walletConfig && walletConfig.allowUnauthenticatedCalls) {
58-
return next();
59-
}
6048
try {
49+
if (req.is('application/octet-stream')) {
50+
req.body = JSON.parse(req.body.toString());
51+
}
52+
if (!wallet) {
53+
return res.status(404).send('Wallet not found');
54+
}
55+
Object.assign(req, { wallet });
56+
const walletConfig = Config.for('api').wallets;
57+
if (walletConfig && walletConfig.allowUnauthenticatedCalls) {
58+
return next();
59+
}
60+
6161
const validRequestSignature = verifyRequestSignature({
6262
message: [req.method, req.originalUrl, JSON.stringify(req.body)].join('|'),
6363
pubKey: wallet.pubKey,

0 commit comments

Comments
 (0)