@samva/webhooks 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -6,19 +6,20 @@ Crypto-compatible runtimes.
|
|
|
6
6
|
```ts
|
|
7
7
|
import { verifyRequest } from "@samva/webhooks";
|
|
8
8
|
|
|
9
|
-
const
|
|
9
|
+
const verified = await verifyRequest(request, process.env.SAMVA_WEBHOOK_SECRET!);
|
|
10
|
+
await persistAndHandleOnce(verified.id, verified.event);
|
|
10
11
|
```
|
|
11
12
|
|
|
12
13
|
Verification reads the exact request body, validates the Standard Webhooks signature and replay
|
|
13
|
-
window, and returns
|
|
14
|
-
secret on the server.
|
|
14
|
+
window, and returns `{ id, event }`. `verified.id` matches the `webhook-id` header. Preserve the raw
|
|
15
|
+
request body and keep the signing secret on the server.
|
|
15
16
|
|
|
16
17
|
Effect applications can use the optional Effect entrypoint:
|
|
17
18
|
|
|
18
19
|
```ts
|
|
19
20
|
import * as Webhooks from "@samva/webhooks/effect";
|
|
20
21
|
|
|
21
|
-
const
|
|
22
|
+
const verified = yield * Webhooks.verifyRequest(request, secret);
|
|
22
23
|
```
|
|
23
24
|
|
|
24
25
|
Install the exact optional peer `effect@4.0.0-beta.102` when using that entrypoint.
|