hooklens 0.2.0 → 1.0.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 +23 -125
- package/dist/index.js +488 -204
- package/dist/index.js.map +1 -1
- package/package.json +5 -1
package/README.md
CHANGED
|
@@ -1,155 +1,53 @@
|
|
|
1
1
|
<div align="center">
|
|
2
2
|
|
|
3
|
+
<img src="./docs/public/logo.svg" alt="HookLens logo" width="88" height="88">
|
|
4
|
+
|
|
3
5
|
# HookLens
|
|
4
6
|
|
|
5
7
|
**Inspect, verify, and replay webhooks from your terminal.**
|
|
6
8
|
|
|
9
|
+
Figure out why webhook signature verification failed before your framework hides the evidence.
|
|
10
|
+
|
|
11
|
+
[Documentation](https://ilia01.github.io/hooklens/) · [npm](https://www.npmjs.com/package/hooklens) · [Latest release](https://github.com/Ilia01/hooklens/releases/latest) · [Contributing](./CONTRIBUTING.md)
|
|
12
|
+
|
|
7
13
|
[](LICENSE)
|
|
8
14
|
[](https://github.com/Ilia01/hooklens/actions/workflows/ci.yml)
|
|
9
15
|
|
|
10
16
|
</div>
|
|
11
17
|
|
|
12
|
-
> [!WARNING]
|
|
13
|
-
> HookLens is under active development. Expect changes as more providers and debugging workflows are added.
|
|
14
|
-
|
|
15
18
|
---
|
|
16
19
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
HookLens sits between the webhook provider and your local server. It captures the raw request, verifies the signature, and tells you _why_ it failed -- not just "invalid signature" but the actual reason. Then it stores the event so you can replay it whenever you want.
|
|
20
|
-
|
|
21
|
-
## How it works
|
|
22
|
-
|
|
23
|
-
```bash
|
|
24
|
-
hooklens listen --verify stripe --secret whsec_xxx --forward-to http://localhost:3000/webhook
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
When a webhook arrives, HookLens:
|
|
28
|
-
|
|
29
|
-
1. Captures the raw body before any framework parses it
|
|
30
|
-
2. Verifies the provider signature and prints PASS or FAIL with a reason
|
|
31
|
-
3. Stores the event locally for replay
|
|
32
|
-
4. Forwards it to your app
|
|
33
|
-
|
|
34
|
-
Something break? Check what came in and replay it:
|
|
35
|
-
|
|
36
|
-
```bash
|
|
37
|
-
hooklens list
|
|
38
|
-
hooklens replay evt_abc123 --to http://localhost:3000/webhook
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
> [!IMPORTANT]
|
|
42
|
-
> HookLens is **not** a tunnel. You still need [ngrok](https://ngrok.com), [Cloudflare Tunnel](https://developers.cloudflare.com/cloudflare-one/connections/connect-networks/), or a similar tool to expose your local server to the internet. HookLens handles what happens after the request arrives.
|
|
43
|
-
|
|
44
|
-
## Why signature verification breaks
|
|
45
|
-
|
|
46
|
-
This is the problem HookLens exists to solve.
|
|
47
|
-
|
|
48
|
-
Webhook providers (Stripe, Paddle, GitHub, etc.) sign every request using the raw body. Your server is supposed to recompute that signature and compare. Simple in theory, but:
|
|
49
|
-
|
|
50
|
-
- **Express** parses the body into JSON before your route handler sees it. When you `JSON.stringify()` it back, key ordering or whitespace changes. Different string = different hash = verification fails.
|
|
51
|
-
- **Next.js** and **Fastify** do the same thing in different ways.
|
|
52
|
-
- The error you get? `"Webhook signature verification failed."` -- thanks for nothing.
|
|
53
|
-
|
|
54
|
-
HookLens intercepts the request at the HTTP level using `node:http` directly, before any framework touches the body. It verifies against the actual bytes that arrived over the wire, and when it fails, it tells you which of the 5 possible failure modes you hit:
|
|
55
|
-
|
|
56
|
-
| Failure | What HookLens tells you |
|
|
57
|
-
| ----------------- | ----------------------------------------------------------------------------------------------------- |
|
|
58
|
-
| Missing header | `stripe-signature header not found. Is this actually from Stripe?` |
|
|
59
|
-
| Wrong secret | `Signature mismatch. Check your webhook secret matches the Stripe dashboard.` |
|
|
60
|
-
| Expired timestamp | `Timestamp is 47 minutes old. Event expired or your clock is drifting.` |
|
|
61
|
-
| Body mutated | `Signature mismatch with correct secret. Body was likely parsed and re-serialized by your framework.` |
|
|
62
|
-
| Malformed header | `stripe-signature header is malformed. Expected format: t=timestamp,v1=signature` |
|
|
20
|
+
HookLens is an open-source CLI for local webhook debugging. It captures the raw request before your framework mutates it, verifies the signature, stores the event locally, and lets you replay or forward it while you fix your app.
|
|
63
21
|
|
|
64
22
|
## Install
|
|
65
23
|
|
|
66
|
-
**Requires Node.js 24 or newer
|
|
24
|
+
**Requires Node.js 24 or newer**.
|
|
67
25
|
|
|
68
26
|
```bash
|
|
69
27
|
npm install -g hooklens
|
|
70
28
|
```
|
|
71
29
|
|
|
72
|
-
##
|
|
30
|
+
## Quick links
|
|
73
31
|
|
|
74
|
-
|
|
32
|
+
- [Getting Started](https://ilia01.github.io/hooklens/getting-started)
|
|
33
|
+
- [Commands](https://ilia01.github.io/hooklens/commands/)
|
|
34
|
+
- [Verification](https://ilia01.github.io/hooklens/verification/)
|
|
35
|
+
- [Forwarding](https://ilia01.github.io/hooklens/forwarding)
|
|
36
|
+
- [Architecture](https://ilia01.github.io/hooklens/architecture)
|
|
75
37
|
|
|
76
|
-
|
|
77
|
-
git clone https://github.com/Ilia01/hooklens.git
|
|
78
|
-
cd hooklens
|
|
79
|
-
npm install
|
|
80
|
-
npm run build
|
|
81
|
-
npm link
|
|
82
|
-
```
|
|
38
|
+
## Current provider support
|
|
83
39
|
|
|
84
|
-
|
|
40
|
+
- Stripe
|
|
41
|
+
- GitHub
|
|
85
42
|
|
|
86
|
-
|
|
87
|
-
| ---------------------- | ------------------------ |
|
|
88
|
-
| `hooklens listen` | Start receiving webhooks |
|
|
89
|
-
| `hooklens list` | Show stored events |
|
|
90
|
-
| `hooklens replay <id>` | Resend a stored event |
|
|
43
|
+
## What it helps with
|
|
91
44
|
|
|
92
|
-
|
|
45
|
+
- Raw body mutation before signature verification
|
|
46
|
+
- Missing or malformed webhook signature headers
|
|
47
|
+
- Replaying captured events after middleware or secret changes
|
|
48
|
+
- Forwarding webhook traffic to a local target while keeping capture history
|
|
93
49
|
|
|
94
|
-
|
|
95
|
-
hooklens listen --port 4400 --verify stripe --secret whsec_xxx --forward-to http://localhost:3000/webhook
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
| Flag | Default | Description |
|
|
99
|
-
| --------------------- | ------- | ------------------------------------- |
|
|
100
|
-
| `-p, --port <port>` | `4400` | Port to listen on |
|
|
101
|
-
| `--verify <provider>` | -- | Verify signatures (`stripe`) |
|
|
102
|
-
| `--secret <secret>` | -- | Webhook signing secret |
|
|
103
|
-
| `--forward-to <url>` | -- | Forward received webhooks to this URL |
|
|
104
|
-
|
|
105
|
-
### `hooklens list`
|
|
106
|
-
|
|
107
|
-
```bash
|
|
108
|
-
hooklens list --limit 10
|
|
109
|
-
```
|
|
110
|
-
|
|
111
|
-
| Flag | Default | Description |
|
|
112
|
-
| --------------------- | ------- | ------------------------ |
|
|
113
|
-
| `-n, --limit <count>` | `20` | Number of events to show |
|
|
114
|
-
|
|
115
|
-
### `hooklens replay`
|
|
116
|
-
|
|
117
|
-
```bash
|
|
118
|
-
hooklens replay evt_abc123 --to http://localhost:3000/webhook
|
|
119
|
-
```
|
|
120
|
-
|
|
121
|
-
| Flag | Default | Description |
|
|
122
|
-
| ------------ | ------------------------------- | ------------------------------- |
|
|
123
|
-
| `--to <url>` | `http://localhost:3000/webhook` | Target URL to send the event to |
|
|
124
|
-
|
|
125
|
-
## Supported providers
|
|
126
|
-
|
|
127
|
-
- **Stripe** -- full signature verification with detailed failure messages
|
|
128
|
-
|
|
129
|
-
More providers will be added based on demand. [Open an issue](https://github.com/Ilia01/hooklens/issues) to request one.
|
|
130
|
-
|
|
131
|
-
## Contributing
|
|
132
|
-
|
|
133
|
-
Want to add a provider, fix a bug, or improve something? Here's how to get set up:
|
|
134
|
-
|
|
135
|
-
```bash
|
|
136
|
-
git clone https://github.com/Ilia01/hooklens.git
|
|
137
|
-
cd hooklens
|
|
138
|
-
npm install
|
|
139
|
-
npm run dev
|
|
140
|
-
```
|
|
141
|
-
|
|
142
|
-
`npm run dev` watches for changes and rebuilds automatically. You can test your changes by running `hooklens` commands directly against the local build.
|
|
143
|
-
|
|
144
|
-
Please open an issue before starting work on anything significant so we can discuss the approach.
|
|
145
|
-
|
|
146
|
-
When you're ready to submit, make sure CI will be happy:
|
|
147
|
-
|
|
148
|
-
```bash
|
|
149
|
-
npm test
|
|
150
|
-
npm run typecheck
|
|
151
|
-
npm run lint
|
|
152
|
-
```
|
|
50
|
+
Detailed command usage, verification behavior, forwarding notes, and contributor guidance live in the docs and [CONTRIBUTING.md](./CONTRIBUTING.md).
|
|
153
51
|
|
|
154
52
|
## License
|
|
155
53
|
|