@dhaneshpurohit/mockstar 0.4.0 → 0.5.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/CHANGELOG.md CHANGED
@@ -1,3 +1,18 @@
1
+ # [0.5.0](https://github.com/dhanesh/mockstar/compare/v0.4.1...v0.5.0) (2026-11-23)
2
+
3
+
4
+ ### Features
5
+
6
+ * **templating:** per-request deterministic faker; pin faker; review follow-ups ([444405d](https://github.com/dhanesh/mockstar/commit/444405d47ce49671a40eaa8c9e1f6a72f7dde11c)), closes [#52](https://github.com/dhanesh/mockstar/issues/52) [#50](https://github.com/dhanesh/mockstar/issues/50)
7
+ * **templating:** upgrade faker to 10, make deterministic dateIso stable, allowlist faker helpers ([1b168c2](https://github.com/dhanesh/mockstar/commit/1b168c285127cea34dd4dcdb3d26d85a15e21d05)), closes [#50](https://github.com/dhanesh/mockstar/issues/50)
8
+
9
+ ## [0.4.1](https://github.com/dhanesh/mockstar/compare/v0.4.0...v0.4.1) (2026-11-23)
10
+
11
+
12
+ ### Bug Fixes
13
+
14
+ * **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)
15
+
1
16
  # [0.4.0](https://github.com/dhanesh/mockstar/compare/v0.3.0...v0.4.0) (2026-09-09)
2
17
 
3
18
 
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`. See [docs/SDET.md](./docs/SDET.md)
20
- + the [`examples/sdet-*`](./examples) directories.
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
- ## Quick start
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
@@ -87,7 +108,7 @@ Any string value inside `response.body` or `response.headers` can contain `{{
87
108
  | `{{faker.integer(min, max)}}` | Random integer in `[min, max]` |
88
109
  | `{{faker.pick(["a","b","c"])}}` | Random element from the array |
89
110
  | `{{faker.boolean}}` | `true` or `false` |
90
- | `{{faker.dateIso}}` | Random recent date as ISO 8601 string |
111
+ | `{{faker.dateIso}}` | Random recent date as ISO 8601 string (in deterministic mode: a fixed date in the 24 h before 2026-01-01T00:00:00Z) |
91
112
 
92
113
  ### Provider-shape IDs
93
114
 
@@ -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, Stripe-style `${ts}.${rawBody}` payload, secrets via `{{ env.X }}` or `file:/path` (inline rejected at config-load) |
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