Skip to content

Commit 170428a

Browse files
committed
Update README
1 parent 1354d0b commit 170428a

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

README.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ Useful for securing webhooks.
77
On the webhook sender:
88

99
```ts
10-
import { sign } from "secure-webhooks"
10+
import { symmetric } from "secure-webhooks"
1111

1212
const secret = "some shared secret"
1313
const payload = "...";
1414

15-
const signature = sign(payload, secret);
15+
const signature = symmetric.sign(payload, secret);
1616

1717
sendToWebhookReceiver({
1818
body: payload,
@@ -26,12 +26,12 @@ sendToWebhookReceiver({
2626
On the webhook receiver:
2727

2828
```ts
29-
import { verify } from "secure-webhooks"
29+
import { symmetric } from "secure-webhooks"
3030

3131
const secret = "some shared secret" // the same as above
3232

3333
app.post("/webhook-endpoint", (req, res) => {
34-
const isTrustWorthy = verify(
34+
const isTrustWorthy = symmetric.verify(
3535
req.body, // 👈 needs to be exactly the same as above, make sure to disable any body parsing for this route
3636
secret,
3737
req.headers["x-webhook-signature"]
@@ -44,4 +44,10 @@ app.post("/webhook-endpoint", (req, res) => {
4444

4545
...
4646
})
47-
```
47+
```
48+
49+
Same works with asymmetric mode:
50+
51+
```ts
52+
import { asymmetric } from "secure-webhooks"
53+
```

0 commit comments

Comments
 (0)