@dhaneshpurohit/mockstar 0.3.0 → 0.4.1
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/CHANGELOG.md +34 -0
- package/README.md +43 -4
- package/dist/cli.js +1214 -875
- package/dist/core/config/schema.d.ts +197 -165
- package/dist/core/config/schema.d.ts.map +1 -1
- package/dist/core/http/body-cap.d.ts +37 -0
- package/dist/core/http/body-cap.d.ts.map +1 -0
- package/dist/core/http/rate-limit.d.ts +55 -0
- package/dist/core/http/rate-limit.d.ts.map +1 -0
- package/dist/core/matching/discriminators.d.ts +25 -0
- package/dist/core/matching/discriminators.d.ts.map +1 -1
- package/dist/core/matching/index.d.ts +3 -1
- package/dist/core/matching/index.d.ts.map +1 -1
- package/dist/features/openapi/converter.d.ts.map +1 -1
- package/dist/features/pass-through.d.ts +7 -0
- package/dist/features/pass-through.d.ts.map +1 -1
- package/dist/features/proxy/cli.d.ts +11 -0
- package/dist/features/proxy/cli.d.ts.map +1 -1
- package/dist/features/proxy/dns.d.ts +21 -3
- package/dist/features/proxy/dns.d.ts.map +1 -1
- package/dist/features/proxy/index.d.ts +1 -1
- package/dist/features/proxy/index.d.ts.map +1 -1
- package/dist/features/proxy/port-bind.d.ts +18 -1
- package/dist/features/proxy/port-bind.d.ts.map +1 -1
- package/dist/features/proxy/sni-gate.d.ts +4 -3
- package/dist/features/proxy/sni-gate.d.ts.map +1 -1
- package/dist/features/url-validator.d.ts +48 -0
- package/dist/features/url-validator.d.ts.map +1 -1
- package/dist/features/webhooks/event-registry.d.ts +7 -0
- package/dist/features/webhooks/event-registry.d.ts.map +1 -1
- package/dist/features/webhooks/journal.d.ts +23 -0
- package/dist/features/webhooks/journal.d.ts.map +1 -1
- package/dist/features/webhooks/queue.d.ts +18 -0
- package/dist/features/webhooks/queue.d.ts.map +1 -1
- package/dist/features/webhooks/types.d.ts +15 -2
- package/dist/features/webhooks/types.d.ts.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1048 -826
- package/dist/server.d.ts +17 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/version.d.ts +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,37 @@
|
|
|
1
|
+
## [0.4.1](https://github.com/dhanesh/mockstar/compare/v0.4.0...v0.4.1) (2026-11-23)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **deps:** bump hono to clear CVE-2026-54290 and apk-upgrade the runner base ([1bb7bc9](https://github.com/dhanesh/mockstar/commit/1bb7bc9e55d68b5679fe11ae777c7bb340ae712d)), closes [#50](https://github.com/dhanesh/mockstar/issues/50)
|
|
7
|
+
|
|
8
|
+
# [0.4.0](https://github.com/dhanesh/mockstar/compare/v0.3.0...v0.4.0) (2026-09-09)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* **ci:** install the tier1 proxy via a packaged binary, not the [#39](https://github.com/dhanesh/mockstar/issues/39) opt-in ([ff99834](https://github.com/dhanesh/mockstar/commit/ff99834ab6f2ffa838d8609315e390e19a9ebae9))
|
|
14
|
+
* **matching:** apply ReDoS guard to MatchPredicate, precompile discriminator regexes ([485b916](https://github.com/dhanesh/mockstar/commit/485b9167e73e46c8854181f1167653d7e23aaef4)), closes [#41](https://github.com/dhanesh/mockstar/issues/41)
|
|
15
|
+
* **openapi:** honour NXX response range keys, stop scanning example data for $ref ([62a2910](https://github.com/dhanesh/mockstar/commit/62a2910970645afff5bd2b6cbb1026638ee828ae)), closes [#43](https://github.com/dhanesh/mockstar/issues/43)
|
|
16
|
+
* **proxy:** add opt-in escape hatch for the [#39](https://github.com/dhanesh/mockstar/issues/39) interpreter refusal ([9b7521c](https://github.com/dhanesh/mockstar/commit/9b7521c6e895abd44d331d21d2f54d70a49a0867))
|
|
17
|
+
* **proxy:** fall back to piped tee when mv can't replace a bind-mounted target ([2841183](https://github.com/dhanesh/mockstar/commit/284118383ddbefa9b3e612f93c094e579ca7f6f9)), closes [#32](https://github.com/dhanesh/mockstar/issues/32) [#32](https://github.com/dhanesh/mockstar/issues/32) [#32](https://github.com/dhanesh/mockstar/issues/32) [#32](https://github.com/dhanesh/mockstar/issues/32)
|
|
18
|
+
* **proxy:** stop /etc/hosts uninstall from truncating the target file ([1341210](https://github.com/dhanesh/mockstar/commit/1341210061a0881472b76fe7aef320c5dd94c526)), closes [#32](https://github.com/dhanesh/mockstar/issues/32)
|
|
19
|
+
* **scripts:** stop Postman importer from dropping {{var}} path segments ([08a6376](https://github.com/dhanesh/mockstar/commit/08a6376b693bf238a8bfc16947dcf92c1dc15bf0)), closes [#42](https://github.com/dhanesh/mockstar/issues/42)
|
|
20
|
+
* **security:** correct SSRF guard IPv6 over/under-blocking (S6) ([a7daf63](https://github.com/dhanesh/mockstar/commit/a7daf6311ae35a609789fd6e4a7ff9b2bc6dab78)), closes [#36](https://github.com/dhanesh/mockstar/issues/36)
|
|
21
|
+
* **security:** redact secret-bearing webhook URLs before journaling ([#38](https://github.com/dhanesh/mockstar/issues/38)) ([7cf13de](https://github.com/dhanesh/mockstar/commit/7cf13de2229bdf774ec3f19d4c5143ce9a3f6fb8)), closes [#37](https://github.com/dhanesh/mockstar/issues/37)
|
|
22
|
+
* **security:** refuse to setcap the interpreter, not the mockstar binary (T7) ([e6ac0b1](https://github.com/dhanesh/mockstar/commit/e6ac0b145b5df3bf45100e370333702c9749fb61)), closes [#39](https://github.com/dhanesh/mockstar/issues/39)
|
|
23
|
+
* **security:** revalidate SSRF guard on every redirect hop ([#37](https://github.com/dhanesh/mockstar/issues/37)) ([9029955](https://github.com/dhanesh/mockstar/commit/9029955565bb463d4d5f070e47f8f821fc5165b2))
|
|
24
|
+
* **server:** bucket journal/metrics/log entries for unknown tenants (S5) ([fd91f31](https://github.com/dhanesh/mockstar/commit/fd91f31b531e0ff8504d9257d9fe956568d529fd)), closes [#34](https://github.com/dhanesh/mockstar/issues/34)
|
|
25
|
+
* **server:** close the chunked-body S5 cap gap on pass-through routes ([08d9ab3](https://github.com/dhanesh/mockstar/commit/08d9ab3e52eccbe95f7fb633f879e87fcb126836)), closes [#33](https://github.com/dhanesh/mockstar/issues/33) [#33](https://github.com/dhanesh/mockstar/issues/33) [#33](https://github.com/dhanesh/mockstar/issues/33)
|
|
26
|
+
* **server:** enforce body-size cap on the stream, not Content-Length (S5) ([eedfc64](https://github.com/dhanesh/mockstar/commit/eedfc64cb1a69e27cf47da76f7e1b76bd210d075)), closes [#33](https://github.com/dhanesh/mockstar/issues/33)
|
|
27
|
+
* **webhooks:** stop() cancels retry/await timers so launch().stop() never hangs ([3a51f3d](https://github.com/dhanesh/mockstar/commit/3a51f3d57b1286263bcef01eacff7624c41dbcad)), closes [#40](https://github.com/dhanesh/mockstar/issues/40)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
### Features
|
|
31
|
+
|
|
32
|
+
* **server:** enforce per-tenant requestsPerSecond rate cap (S5, 429 half) ([f3dab6e](https://github.com/dhanesh/mockstar/commit/f3dab6e660406d6ee22b6a51ef7bfea6e180d23b)), closes [#34](https://github.com/dhanesh/mockstar/issues/34) [#34](https://github.com/dhanesh/mockstar/issues/34) [#35](https://github.com/dhanesh/mockstar/issues/35)
|
|
33
|
+
* **webhooks:** journal non-final failed attempts as 'retrying', not 'success' ([8d2954b](https://github.com/dhanesh/mockstar/commit/8d2954b42fff0888059a425bd87eaa232fc0304d)), closes [#44](https://github.com/dhanesh/mockstar/issues/44) [#44](https://github.com/dhanesh/mockstar/issues/44) [#44](https://github.com/dhanesh/mockstar/issues/44)
|
|
34
|
+
|
|
1
35
|
# [0.3.0](https://github.com/dhanesh/mockstar/compare/v0.2.2...v0.3.0) (2026-09-04)
|
|
2
36
|
|
|
3
37
|
|
package/README.md
CHANGED
|
@@ -16,8 +16,15 @@
|
|
|
16
16
|
## For SDETs
|
|
17
17
|
|
|
18
18
|
Mockstar ships a library embed (`import { launch } from '@dhaneshpurohit/mockstar'`) supported
|
|
19
|
-
across Jest 30, Jest 29, Vitest, and `bun test`.
|
|
20
|
-
|
|
19
|
+
across Jest 30, Jest 29, Vitest, and `bun test`. `launch()` binds no port — tests talk to the
|
|
20
|
+
server in-process — and `stop()` releases every watcher and timer, so a suite that calls it
|
|
21
|
+
per file exits cleanly instead of hanging.
|
|
22
|
+
|
|
23
|
+
The package root also exports the webhook signing helpers, so a test can verify a delivery the
|
|
24
|
+
same way a real receiver would: `signPayload`, `verifySignature`, `withinReplayWindow`,
|
|
25
|
+
`LEGACY_SCHEME`, and the `SigningScheme` / `DigestEncoding` types.
|
|
26
|
+
|
|
27
|
+
See [docs/SDET.md](./docs/SDET.md) + the [`examples/sdet-*`](./examples) directories.
|
|
21
28
|
|
|
22
29
|
## Contributing
|
|
23
30
|
|
|
@@ -32,7 +39,21 @@ Mockstar targets three personas equally:
|
|
|
32
39
|
|
|
33
40
|
> Built on [Hono](https://hono.dev/) on [Bun](https://bun.sh/). Targets p99 < 5ms for static mock responses. See [DECISIONS.md](./docs/DECISIONS.md) for the constraint-first design record.
|
|
34
41
|
|
|
35
|
-
##
|
|
42
|
+
## Install
|
|
43
|
+
|
|
44
|
+
Website: <https://dhanesh.github.io/mockstar/>
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
brew install dhanesh/tap/mockstar # macOS + Linux, standalone binary
|
|
48
|
+
mockstar init . && mockstar serve ./mocks
|
|
49
|
+
|
|
50
|
+
brew services start mockstar # optional: serve $(brew --prefix)/var/mockstar/mocks in the background
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Also available via `bunx @dhaneshpurohit/mockstar`, the `ghcr.io/dhanesh/mockstar` image, and
|
|
54
|
+
per-platform binaries on the [releases page](https://github.com/dhanesh/mockstar/releases/latest).
|
|
55
|
+
|
|
56
|
+
## Quick start (from source)
|
|
36
57
|
|
|
37
58
|
```bash
|
|
38
59
|
bun install
|
|
@@ -134,12 +155,30 @@ Capabilities at a glance:
|
|
|
134
155
|
|---|---|
|
|
135
156
|
| **Configuration channels** | Per-route `url`, `{{ env.NAME }}` interpolation, admin API, opt-in `X-Mockstar-Webhook-Url` request header (gated by `--allow-webhook-url-header`) |
|
|
136
157
|
| **Delivery contract** | At-least-once within queue + circuit bounds, exponential backoff with jitter (default `[1s, 2s, 4s, 8s, 16s]`), idempotent `X-Mockstar-Delivery-Id` header |
|
|
137
|
-
| **Signing** | Opt-in HMAC-SHA256,
|
|
158
|
+
| **Signing** | Opt-in HMAC-SHA256 with a **configurable wire format** — `signedPayload` (bytes signed) and `signatureTemplate` (header value) are independent, plus `digestEncoding: hex \| base64`. Ships verified shapes for GitHub, Slack, Stripe, Shopify and Razorpay. Secrets via `{{ env.X }}` or `file:/path` (inline rejected at config-load) |
|
|
159
|
+
| **Request caps** | Per-tenant `maxBodyBytes` (413, enforced on the byte stream so chunked encoding can't bypass it) and `requestsPerSecond` (429 + `Retry-After`, token bucket so bursts aren't punished; default 10,000/s) |
|
|
138
160
|
| **Reliability** | Per-webhook circuit breaker, drop-oldest queue cap, per-attempt `AbortSignal.timeout`, optional `expectResponse: { status, body }` body assertion |
|
|
139
161
|
| **Observability** | `/__admin/tenants/:t/webhooks` list (secrets redacted), `/webhooks/journal` history, `POST /webhooks/await?id=…` for sync test assertions, `POST /webhooks/:id/replay` for recovery |
|
|
140
162
|
| **Metrics** | `webhook_delivery_total{outcome}`, `webhook_delivery_latency_us`, `webhook_queue_depth`, `webhook_queue_dropped_total`, `webhook_circuit_state` |
|
|
141
163
|
| **Distribution** | In-process (no Redis); single-binary and SDET-embed friendly |
|
|
142
164
|
|
|
165
|
+
### Provider-accurate signatures
|
|
166
|
+
|
|
167
|
+
The signed bytes and the header value vary independently across providers, so both are templates rather than a fixed format. Every row below is covered by a test that verifies the delivered header using receiver code taken from that provider's own documentation:
|
|
168
|
+
|
|
169
|
+
| Provider | `signedPayload` | `signatureTemplate` | `digestEncoding` | `signatureHeader` |
|
|
170
|
+
|---|---|---|---|---|
|
|
171
|
+
| mockstar (default) | `{timestamp}.{body}` | `{algorithm}={signature}` | `hex` | `x-mockstar-signature` |
|
|
172
|
+
| GitHub | `{body}` | `{algorithm}={signature}` | `hex` | `x-hub-signature-256` |
|
|
173
|
+
| Slack | `v0:{timestampSeconds}:{body}` | `v0={signature}` | `hex` | `x-slack-signature` |
|
|
174
|
+
| Stripe | `{timestampSeconds}.{body}` | `t={timestampSeconds},v1={signature}` | `hex` | `stripe-signature` |
|
|
175
|
+
| Shopify | `{body}` | `{signature}` | `base64` | `x-shopify-hmac-sha256` |
|
|
176
|
+
| Razorpay | `{body}` | `{signature}` | `hex` | `x-razorpay-signature` |
|
|
177
|
+
|
|
178
|
+
Placeholders are single-brace (`{body}`), deliberately distinct from the `{{ }}` response-template engine — `{{ }}` in a signing template is rejected at config-load rather than silently mis-signing. Set `timestampHeader: null` to suppress the standalone timestamp header for schemes that carry it inside the signature (Stripe).
|
|
179
|
+
|
|
180
|
+
Journal rows record one entry per attempt with outcome `success`, `retrying`, `failed`, `dropped` or `circuit-open` — a retried-but-not-yet-terminal attempt reads `retrying`, so asserting `outcome === "success"` means the delivery actually succeeded. Delivered URLs are redacted to their origin before journaling, since a provider webhook URL is often itself a credential.
|
|
181
|
+
|
|
143
182
|
Full guide, decisions log, and security model: [docs/webhooks/README.md](./docs/webhooks/README.md), [docs/webhooks/DECISIONS.md](./docs/webhooks/DECISIONS.md), [docs/webhooks/SECURITY.md](./docs/webhooks/SECURITY.md). Worked example loadable via `bun run dev`: [examples/mocks/default/webhooks-example.json](./examples/mocks/default/webhooks-example.json).
|
|
144
183
|
|
|
145
184
|
## What's in v1, what's deferred
|