|
1 | 1 | import type * as http from 'node:http'; |
2 | 2 | import type { AddressInfo } from 'node:net'; |
3 | 3 | import type { Request, Response } from 'express'; |
| 4 | +import express from 'express'; |
4 | 5 | import { verifyWebhookEventMiddleware } from '../index'; |
| 6 | +import { subtleCrypto } from '../util'; |
5 | 7 | import { WebhookEventType, WebhookType } from '../webhooks'; |
6 | 8 | import { |
7 | 9 | generateKeyPair, |
8 | 10 | sendExampleRequest, |
9 | 11 | signRequestWithKeyPair, |
10 | 12 | } from './utils/SharedTestUtils'; |
11 | 13 |
|
12 | | -import express from 'express'; |
13 | | -import { subtleCrypto } from '../util'; |
14 | | - |
15 | 14 | const expressApp = express(); |
16 | 15 |
|
17 | 16 | // Example webhook ping request body |
@@ -63,7 +62,7 @@ describe('verify webhook event middleware', () => { |
63 | 62 | next(); |
64 | 63 | }, |
65 | 64 | verifyWebhookEventMiddleware(rawPublicKey), |
66 | | - (req: Request, res: Response) => { |
| 65 | + (_req: Request, res: Response) => { |
67 | 66 | // This handler will be reached but the response has already been sent |
68 | 67 | // by the middleware with 204 status |
69 | 68 | if (!res.headersSent) { |
@@ -183,9 +182,7 @@ describe('verify webhook event middleware', () => { |
183 | 182 | exampleWebhookUrl, |
184 | 183 | { |
185 | 184 | 'x-signature-ed25519': signedRequest.signature, |
186 | | - 'x-signature-timestamp': String( |
187 | | - Math.round(new Date().getTime() / 1000) - 10000, |
188 | | - ), |
| 185 | + 'x-signature-timestamp': String(Math.round(Date.now() / 1000) - 10000), |
189 | 186 | 'content-type': 'application/json', |
190 | 187 | }, |
191 | 188 | signedRequest.body, |
@@ -266,7 +263,7 @@ describe('verify webhook event middleware', () => { |
266 | 263 | testApp.post( |
267 | 264 | '/webhook-test', |
268 | 265 | verifyWebhookEventMiddleware(rawPublicKey), |
269 | | - (req: Request, res: Response) => { |
| 266 | + (_req: Request, res: Response) => { |
270 | 267 | // This handler tries to send a response after middleware already sent one |
271 | 268 | try { |
272 | 269 | res.json({ shouldFail: true }); |
|
0 commit comments