@crvouga/mockingbird-service-aha 3.10.5 → 3.10.7

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,5 +1,17 @@
1
1
  # Changelog — @crvouga/mockingbird-service-aha
2
2
 
3
+ ## 3.10.7 (2026-11-02)
4
+
5
+ ### Fixes and improvements
6
+
7
+ - save and replay a 500 the endpoint produced under an Idempotency-Key ([789bbcc](https://github.com/crvouga/mockingbird/commit/789bbcccb792cddaf27f4f6db6d2fcf2da1d07fe))
8
+
9
+ ## 3.10.6 (2026-11-02)
10
+
11
+ ### Fixes and improvements
12
+
13
+ - compare the admin key in constant time ([2a43141](https://github.com/crvouga/mockingbird/commit/2a43141f50dab41e698c3bbce0c69bf65b40e24e))
14
+
3
15
  ## 3.10.5 (2026-11-02)
4
16
 
5
17
  ### Fixes and improvements
@@ -9,7 +9,7 @@ import {
9
9
  parseFaultHeader,
10
10
  resolveAdminPrefix,
11
11
  restoreClock
12
- } from "./chunk-Z7OP6ANU.js";
12
+ } from "./chunk-DEBGYVU4.js";
13
13
 
14
14
  // ../../adapters/node/dist/cli.js
15
15
  import { readFile as readFile5 } from "node:fs/promises";
@@ -3057,7 +3057,7 @@ async function preflightFleet(config, options) {
3057
3057
  break;
3058
3058
  }
3059
3059
  }
3060
- targets.set(name, { ...target, packageVersion: packageVersion ?? "3.10.5" });
3060
+ targets.set(name, { ...target, packageVersion: packageVersion ?? "3.10.7" });
3061
3061
  } catch (error) {
3062
3062
  throw new Error(`service ${name}: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
3063
3063
  }
@@ -5080,4 +5080,4 @@ export {
5080
5080
  createServer2 as createServer,
5081
5081
  serveTarget
5082
5082
  };
5083
- //# sourceMappingURL=chunk-ADYZRHXX.js.map
5083
+ //# sourceMappingURL=chunk-73ZN7WML.js.map
@@ -2676,6 +2676,46 @@ var createNamespaceControls = (options) => {
2676
2676
  };
2677
2677
  };
2678
2678
 
2679
+ // ../core/dist/signing.js
2680
+ var encoder = new TextEncoder();
2681
+ var toBase64 = (bytes) => {
2682
+ let binary = "";
2683
+ for (const byte of bytes instanceof Uint8Array ? bytes : new Uint8Array(bytes)) {
2684
+ binary += String.fromCharCode(byte);
2685
+ }
2686
+ return btoa(binary);
2687
+ };
2688
+ var fromBase64 = (value) => Uint8Array.from(atob(value), (char) => char.charCodeAt(0));
2689
+ var toHex = (bytes) => [...bytes instanceof Uint8Array ? bytes : new Uint8Array(bytes)].map((byte) => byte.toString(16).padStart(2, "0")).join("");
2690
+ var keyBytes = (key2) => typeof key2 === "string" ? encoder.encode(key2) : key2;
2691
+ var hmac = async (algorithm, key2, message, encoding = "hex") => {
2692
+ const imported = await crypto.subtle.importKey("raw", keyBytes(key2), { name: "HMAC", hash: algorithm }, false, ["sign"]);
2693
+ const signed = await crypto.subtle.sign("HMAC", imported, typeof message === "string" ? encoder.encode(message) : message);
2694
+ return encoding === "hex" ? toHex(signed) : toBase64(signed);
2695
+ };
2696
+ var svixSecretBytes = (secret) => {
2697
+ const raw = secret.replace(/^f?whsec_/, "");
2698
+ try {
2699
+ return fromBase64(raw);
2700
+ } catch {
2701
+ throw new TypeError("webhook secret must be whsec_<base64> (as Svix issues it)");
2702
+ }
2703
+ };
2704
+ var signSvix = async (secret, messageId, timestampSeconds, body) => `v1,${await hmac("SHA-256", svixSecretBytes(secret), `${messageId}.${timestampSeconds}.${body}`, "base64")}`;
2705
+ var signTimestamped = async (secret, timestampSeconds, body) => `t=${timestampSeconds},v1=${await hmac("SHA-256", secret, `${timestampSeconds}.${body}`, "hex")}`;
2706
+ var signTwilio = async (authToken, url, params) => {
2707
+ const payload = url + Object.keys(params).sort().map((key2) => `${key2}${params[key2]}`).join("");
2708
+ return hmac("SHA-1", authToken, payload, "base64");
2709
+ };
2710
+ var timingSafeEqual = (a, b) => {
2711
+ if (a.length !== b.length)
2712
+ return false;
2713
+ let diff = 0;
2714
+ for (let i = 0; i < a.length; i++)
2715
+ diff |= a.charCodeAt(i) ^ b.charCodeAt(i);
2716
+ return diff === 0;
2717
+ };
2718
+
2679
2719
  // ../core/dist/surface.js
2680
2720
  var defineMock = (runtime) => runtime;
2681
2721
  var ADMIN_ROUTE_REFERENCE = {
@@ -2794,6 +2834,10 @@ var assertAdminPrefixAvailable = (prefix, paths) => {
2794
2834
  }
2795
2835
  };
2796
2836
  var ADMIN_KEY_HEADER = CONTROL_HEADERS.adminKey;
2837
+ var hasAdminKey = (headers, adminKey) => {
2838
+ const sent = headers.get(ADMIN_KEY_HEADER);
2839
+ return sent !== null && timingSafeEqual(sent, adminKey);
2840
+ };
2797
2841
  var NAMESPACE_HEADER = CONTROL_HEADERS.namespace;
2798
2842
  var ADMIN_DOCS_URL = "https://mockingbird.chrisvouga.dev/docs/admin-controls";
2799
2843
  var ADMIN_CONTROL_PAGES = [
@@ -3267,7 +3311,7 @@ var createControlPlane = (context) => {
3267
3311
  }
3268
3312
  const path = url.pathname.slice(adminPrefix.length) || "/";
3269
3313
  const shell = request.method === "GET" && (path === "/ui" || path === "/ui/");
3270
- if (!shell && context.adminKey !== void 0 && request.headers.get(ADMIN_KEY_HEADER) !== context.adminKey) {
3314
+ if (!shell && context.adminKey !== void 0 && !hasAdminKey(request.headers, context.adminKey)) {
3271
3315
  return adminError(401, `missing or wrong ${ADMIN_KEY_HEADER}`);
3272
3316
  }
3273
3317
  for (const route of routes) {
@@ -3360,6 +3404,7 @@ var IdempotencyStore = class {
3360
3404
  * the method, path and canonical body). Only `replayable` responses are stored (default:
3361
3405
  * every status below 500), so a transient failure can be retried. `replayable` also sees the
3362
3406
  * response, for vendors that decide from more than the status.
3407
+ * Stripe also saves endpoint-produced 500 responses.
3363
3408
  */
3364
3409
  async run(key2, fingerprint, errors, handler, replayable = (status) => status < 500) {
3365
3410
  const slot = `${this.namespace}\0${key2}`;
@@ -4111,47 +4156,7 @@ var stateAdminRoutes = (routes) => {
4111
4156
  };
4112
4157
 
4113
4158
  // ../core/dist/version.js
4114
- var PACKAGE_VERSION = true ? "3.10.5" : UNRELEASED_VERSION;
4115
-
4116
- // ../core/dist/signing.js
4117
- var encoder = new TextEncoder();
4118
- var toBase64 = (bytes) => {
4119
- let binary = "";
4120
- for (const byte of bytes instanceof Uint8Array ? bytes : new Uint8Array(bytes)) {
4121
- binary += String.fromCharCode(byte);
4122
- }
4123
- return btoa(binary);
4124
- };
4125
- var fromBase64 = (value) => Uint8Array.from(atob(value), (char) => char.charCodeAt(0));
4126
- var toHex = (bytes) => [...bytes instanceof Uint8Array ? bytes : new Uint8Array(bytes)].map((byte) => byte.toString(16).padStart(2, "0")).join("");
4127
- var keyBytes = (key2) => typeof key2 === "string" ? encoder.encode(key2) : key2;
4128
- var hmac = async (algorithm, key2, message, encoding = "hex") => {
4129
- const imported = await crypto.subtle.importKey("raw", keyBytes(key2), { name: "HMAC", hash: algorithm }, false, ["sign"]);
4130
- const signed = await crypto.subtle.sign("HMAC", imported, typeof message === "string" ? encoder.encode(message) : message);
4131
- return encoding === "hex" ? toHex(signed) : toBase64(signed);
4132
- };
4133
- var svixSecretBytes = (secret) => {
4134
- const raw = secret.replace(/^f?whsec_/, "");
4135
- try {
4136
- return fromBase64(raw);
4137
- } catch {
4138
- throw new TypeError("webhook secret must be whsec_<base64> (as Svix issues it)");
4139
- }
4140
- };
4141
- var signSvix = async (secret, messageId, timestampSeconds, body) => `v1,${await hmac("SHA-256", svixSecretBytes(secret), `${messageId}.${timestampSeconds}.${body}`, "base64")}`;
4142
- var signTimestamped = async (secret, timestampSeconds, body) => `t=${timestampSeconds},v1=${await hmac("SHA-256", secret, `${timestampSeconds}.${body}`, "hex")}`;
4143
- var signTwilio = async (authToken, url, params) => {
4144
- const payload = url + Object.keys(params).sort().map((key2) => `${key2}${params[key2]}`).join("");
4145
- return hmac("SHA-1", authToken, payload, "base64");
4146
- };
4147
- var timingSafeEqual = (a, b) => {
4148
- if (a.length !== b.length)
4149
- return false;
4150
- let diff = 0;
4151
- for (let i = 0; i < a.length; i++)
4152
- diff |= a.charCodeAt(i) ^ b.charCodeAt(i);
4153
- return diff === 0;
4154
- };
4159
+ var PACKAGE_VERSION = true ? "3.10.7" : UNRELEASED_VERSION;
4155
4160
 
4156
4161
  // ../core/dist/webhooks.js
4157
4162
  var signers = {
@@ -5548,7 +5553,7 @@ var createRuntime = (options) => {
5548
5553
  throw error2;
5549
5554
  }
5550
5555
  const rewinds = at !== void 0 && selectedBranch === "main" && MUTATING_METHODS.has(request.method);
5551
- if ((requested || rewinds) && options.adminKey !== void 0 && request.headers.get(ADMIN_KEY_HEADER) !== options.adminKey)
5556
+ if ((requested || rewinds) && options.adminKey !== void 0 && !hasAdminKey(request.headers, options.adminKey))
5552
5557
  return refuse(401, `control headers need ${ADMIN_KEY_HEADER}`);
5553
5558
  controls.ensure(namespace);
5554
5559
  if (requested?.restore !== void 0 && !snapshotStore.get(namespace, requested.restore))
@@ -6544,4 +6549,4 @@ export {
6544
6549
  apiKeyCredential,
6545
6550
  AhaAPI
6546
6551
  };
6547
- //# sourceMappingURL=chunk-Z7OP6ANU.js.map
6552
+ //# sourceMappingURL=chunk-DEBGYVU4.js.map