Skip to content

Commit c88c005

Browse files
committed
javascript info
1 parent 7c095e8 commit c88c005

File tree

8 files changed

+129
-0
lines changed

8 files changed

+129
-0
lines changed

docs/payments/donations/button.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,22 @@ let verified = await verify({
204204

205205
if(!verified){ throw('Request was not authentic!') }
206206
```
207+
:::info
208+
Always validate the unmodified raw request body. Many JavaScript frameworks automatically parse and alter the payload when using `req.body`, which can cause signature verification to fail. Ensure you access the raw, unprocessed data to guarantee accurate signature recovery:
209+
```javascript
210+
app.use(express.json({
211+
verify: (req, res, buf, encoding) => {
212+
req.rawBody = buf.toString(encoding);
213+
}
214+
}));
215+
216+
let verified = await verify({
217+
signature: req.headers['x-signature'],
218+
data: req.rawBody,
219+
publicKey,
220+
});
221+
```
222+
:::
207223

208224
</TabItem>
209225

docs/payments/donations/link.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,22 @@ let verified = await verify({
153153

154154
if(!verified){ throw('Request was not authentic!') }
155155
```
156+
:::info
157+
Always validate the unmodified raw request body. Many JavaScript frameworks automatically parse and alter the payload when using `req.body`, which can cause signature verification to fail. Ensure you access the raw, unprocessed data to guarantee accurate signature recovery:
158+
```javascript
159+
app.use(express.json({
160+
verify: (req, res, buf, encoding) => {
161+
req.rawBody = buf.toString(encoding);
162+
}
163+
}));
164+
165+
let verified = await verify({
166+
signature: req.headers['x-signature'],
167+
data: req.rawBody,
168+
publicKey,
169+
});
170+
```
171+
:::
156172

157173
</TabItem>
158174

docs/payments/donations/widget.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,22 @@ let verified = await verify({
325325

326326
if(!verified){ throw('Request was not authentic!') }
327327
```
328+
:::info
329+
Always validate the unmodified raw request body. Many JavaScript frameworks automatically parse and alter the payload when using `req.body`, which can cause signature verification to fail. Ensure you access the raw, unprocessed data to guarantee accurate signature recovery:
330+
```javascript
331+
app.use(express.json({
332+
verify: (req, res, buf, encoding) => {
333+
req.rawBody = buf.toString(encoding);
334+
}
335+
}));
336+
337+
let verified = await verify({
338+
signature: req.headers['x-signature'],
339+
data: req.rawBody,
340+
publicKey,
341+
});
342+
```
343+
:::
328344

329345
</TabItem>
330346

docs/payments/integrate/button.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,22 @@ let verified = await verify({
221221

222222
if(!verified){ throw('Request was not authentic!') }
223223
```
224+
:::info
225+
Always validate the unmodified raw request body. Many JavaScript frameworks automatically parse and alter the payload when using `req.body`, which can cause signature verification to fail. Ensure you access the raw, unprocessed data to guarantee accurate signature recovery:
226+
```javascript
227+
app.use(express.json({
228+
verify: (req, res, buf, encoding) => {
229+
req.rawBody = buf.toString(encoding);
230+
}
231+
}));
232+
233+
let verified = await verify({
234+
signature: req.headers['x-signature'],
235+
data: req.rawBody,
236+
publicKey,
237+
});
238+
```
239+
:::
224240

225241
</TabItem>
226242

docs/payments/integrate/link.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,22 @@ let verified = await verify({
374374

375375
if(!verified){ throw('Request was not authentic!') }
376376
```
377+
:::info
378+
Always validate the unmodified raw request body. Many JavaScript frameworks automatically parse and alter the payload when using `req.body`, which can cause signature verification to fail. Ensure you access the raw, unprocessed data to guarantee accurate signature recovery:
379+
```javascript
380+
app.use(express.json({
381+
verify: (req, res, buf, encoding) => {
382+
req.rawBody = buf.toString(encoding);
383+
}
384+
}));
385+
386+
let verified = await verify({
387+
signature: req.headers['x-signature'],
388+
data: req.rawBody,
389+
publicKey,
390+
});
391+
```
392+
:::
377393

378394
</TabItem>
379395

docs/payments/tips/button.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,23 @@ let verified = await verify({
205205
if(!verified){ throw('Request was not authentic!') }
206206
```
207207

208+
:::info
209+
Always validate the unmodified raw request body. Many JavaScript frameworks automatically parse and alter the payload when using `req.body`, which can cause signature verification to fail. Ensure you access the raw, unprocessed data to guarantee accurate signature recovery:
210+
```javascript
211+
app.use(express.json({
212+
verify: (req, res, buf, encoding) => {
213+
req.rawBody = buf.toString(encoding);
214+
}
215+
}));
216+
217+
let verified = await verify({
218+
signature: req.headers['x-signature'],
219+
data: req.rawBody,
220+
publicKey,
221+
});
222+
```
223+
:::
224+
208225
</TabItem>
209226

210227
<TabItem value="java" label="Java" default>

docs/payments/tips/link.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,22 @@ let verified = await verify({
147147

148148
if(!verified){ throw('Request was not authentic!') }
149149
```
150+
:::info
151+
Always validate the unmodified raw request body. Many JavaScript frameworks automatically parse and alter the payload when using `req.body`, which can cause signature verification to fail. Ensure you access the raw, unprocessed data to guarantee accurate signature recovery:
152+
```javascript
153+
app.use(express.json({
154+
verify: (req, res, buf, encoding) => {
155+
req.rawBody = buf.toString(encoding);
156+
}
157+
}));
158+
159+
let verified = await verify({
160+
signature: req.headers['x-signature'],
161+
data: req.rawBody,
162+
publicKey,
163+
});
164+
```
165+
:::
150166

151167
</TabItem>
152168

docs/payments/tips/widget.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,22 @@ let verified = await verify({
325325

326326
if(!verified){ throw('Request was not authentic!') }
327327
```
328+
:::info
329+
Always validate the unmodified raw request body. Many JavaScript frameworks automatically parse and alter the payload when using `req.body`, which can cause signature verification to fail. Ensure you access the raw, unprocessed data to guarantee accurate signature recovery:
330+
```javascript
331+
app.use(express.json({
332+
verify: (req, res, buf, encoding) => {
333+
req.rawBody = buf.toString(encoding);
334+
}
335+
}));
336+
337+
let verified = await verify({
338+
signature: req.headers['x-signature'],
339+
data: req.rawBody,
340+
publicKey,
341+
});
342+
```
343+
:::
328344

329345
</TabItem>
330346

0 commit comments

Comments
 (0)