@crvouga/mockingbird-service-customerio 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-customerio
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
@@ -2666,6 +2666,46 @@ var createNamespaceControls = (options) => {
2666
2666
  };
2667
2667
  };
2668
2668
 
2669
+ // ../core/dist/signing.js
2670
+ var encoder = new TextEncoder();
2671
+ var toBase64 = (bytes) => {
2672
+ let binary = "";
2673
+ for (const byte of bytes instanceof Uint8Array ? bytes : new Uint8Array(bytes)) {
2674
+ binary += String.fromCharCode(byte);
2675
+ }
2676
+ return btoa(binary);
2677
+ };
2678
+ var fromBase64 = (value) => Uint8Array.from(atob(value), (char) => char.charCodeAt(0));
2679
+ var toHex = (bytes) => [...bytes instanceof Uint8Array ? bytes : new Uint8Array(bytes)].map((byte) => byte.toString(16).padStart(2, "0")).join("");
2680
+ var keyBytes = (key) => typeof key === "string" ? encoder.encode(key) : key;
2681
+ var hmac = async (algorithm, key, message, encoding = "hex") => {
2682
+ const imported = await crypto.subtle.importKey("raw", keyBytes(key), { name: "HMAC", hash: algorithm }, false, ["sign"]);
2683
+ const signed = await crypto.subtle.sign("HMAC", imported, typeof message === "string" ? encoder.encode(message) : message);
2684
+ return encoding === "hex" ? toHex(signed) : toBase64(signed);
2685
+ };
2686
+ var svixSecretBytes = (secret) => {
2687
+ const raw = secret.replace(/^f?whsec_/, "");
2688
+ try {
2689
+ return fromBase64(raw);
2690
+ } catch {
2691
+ throw new TypeError("webhook secret must be whsec_<base64> (as Svix issues it)");
2692
+ }
2693
+ };
2694
+ var signSvix = async (secret, messageId, timestampSeconds, body) => `v1,${await hmac("SHA-256", svixSecretBytes(secret), `${messageId}.${timestampSeconds}.${body}`, "base64")}`;
2695
+ var signTimestamped = async (secret, timestampSeconds, body) => `t=${timestampSeconds},v1=${await hmac("SHA-256", secret, `${timestampSeconds}.${body}`, "hex")}`;
2696
+ var signTwilio = async (authToken, url, params) => {
2697
+ const payload = url + Object.keys(params).sort().map((key) => `${key}${params[key]}`).join("");
2698
+ return hmac("SHA-1", authToken, payload, "base64");
2699
+ };
2700
+ var timingSafeEqual = (a, b) => {
2701
+ if (a.length !== b.length)
2702
+ return false;
2703
+ let diff = 0;
2704
+ for (let i = 0; i < a.length; i++)
2705
+ diff |= a.charCodeAt(i) ^ b.charCodeAt(i);
2706
+ return diff === 0;
2707
+ };
2708
+
2669
2709
  // ../core/dist/surface.js
2670
2710
  var defineMock = (runtime) => runtime;
2671
2711
  var ADMIN_ROUTE_REFERENCE = {
@@ -2784,6 +2824,10 @@ var assertAdminPrefixAvailable = (prefix, paths) => {
2784
2824
  }
2785
2825
  };
2786
2826
  var ADMIN_KEY_HEADER = CONTROL_HEADERS.adminKey;
2827
+ var hasAdminKey = (headers, adminKey) => {
2828
+ const sent = headers.get(ADMIN_KEY_HEADER);
2829
+ return sent !== null && timingSafeEqual(sent, adminKey);
2830
+ };
2787
2831
  var NAMESPACE_HEADER = CONTROL_HEADERS.namespace;
2788
2832
  var ADMIN_DOCS_URL = "https://mockingbird.chrisvouga.dev/docs/admin-controls";
2789
2833
  var ADMIN_CONTROL_PAGES = [
@@ -3257,7 +3301,7 @@ var createControlPlane = (context) => {
3257
3301
  }
3258
3302
  const path = url.pathname.slice(adminPrefix.length) || "/";
3259
3303
  const shell = request.method === "GET" && (path === "/ui" || path === "/ui/");
3260
- if (!shell && context.adminKey !== void 0 && request.headers.get(ADMIN_KEY_HEADER) !== context.adminKey) {
3304
+ if (!shell && context.adminKey !== void 0 && !hasAdminKey(request.headers, context.adminKey)) {
3261
3305
  return adminError(401, `missing or wrong ${ADMIN_KEY_HEADER}`);
3262
3306
  }
3263
3307
  for (const route of routes) {
@@ -4145,39 +4189,7 @@ var stateAdminRoutes = (routes) => {
4145
4189
  };
4146
4190
 
4147
4191
  // ../core/dist/version.js
4148
- var PACKAGE_VERSION = true ? "3.10.5" : UNRELEASED_VERSION;
4149
-
4150
- // ../core/dist/signing.js
4151
- var encoder = new TextEncoder();
4152
- var toBase64 = (bytes) => {
4153
- let binary = "";
4154
- for (const byte of bytes instanceof Uint8Array ? bytes : new Uint8Array(bytes)) {
4155
- binary += String.fromCharCode(byte);
4156
- }
4157
- return btoa(binary);
4158
- };
4159
- var fromBase64 = (value) => Uint8Array.from(atob(value), (char) => char.charCodeAt(0));
4160
- var toHex = (bytes) => [...bytes instanceof Uint8Array ? bytes : new Uint8Array(bytes)].map((byte) => byte.toString(16).padStart(2, "0")).join("");
4161
- var keyBytes = (key) => typeof key === "string" ? encoder.encode(key) : key;
4162
- var hmac = async (algorithm, key, message, encoding = "hex") => {
4163
- const imported = await crypto.subtle.importKey("raw", keyBytes(key), { name: "HMAC", hash: algorithm }, false, ["sign"]);
4164
- const signed = await crypto.subtle.sign("HMAC", imported, typeof message === "string" ? encoder.encode(message) : message);
4165
- return encoding === "hex" ? toHex(signed) : toBase64(signed);
4166
- };
4167
- var svixSecretBytes = (secret) => {
4168
- const raw = secret.replace(/^f?whsec_/, "");
4169
- try {
4170
- return fromBase64(raw);
4171
- } catch {
4172
- throw new TypeError("webhook secret must be whsec_<base64> (as Svix issues it)");
4173
- }
4174
- };
4175
- var signSvix = async (secret, messageId, timestampSeconds, body) => `v1,${await hmac("SHA-256", svixSecretBytes(secret), `${messageId}.${timestampSeconds}.${body}`, "base64")}`;
4176
- var signTimestamped = async (secret, timestampSeconds, body) => `t=${timestampSeconds},v1=${await hmac("SHA-256", secret, `${timestampSeconds}.${body}`, "hex")}`;
4177
- var signTwilio = async (authToken, url, params) => {
4178
- const payload = url + Object.keys(params).sort().map((key) => `${key}${params[key]}`).join("");
4179
- return hmac("SHA-1", authToken, payload, "base64");
4180
- };
4192
+ var PACKAGE_VERSION = true ? "3.10.7" : UNRELEASED_VERSION;
4181
4193
 
4182
4194
  // ../core/dist/webhooks.js
4183
4195
  var signers = {
@@ -5574,7 +5586,7 @@ var createRuntime = (options) => {
5574
5586
  throw error;
5575
5587
  }
5576
5588
  const rewinds = at !== void 0 && selectedBranch === "main" && MUTATING_METHODS.has(request.method);
5577
- if ((requested || rewinds) && options.adminKey !== void 0 && request.headers.get(ADMIN_KEY_HEADER) !== options.adminKey)
5589
+ if ((requested || rewinds) && options.adminKey !== void 0 && !hasAdminKey(request.headers, options.adminKey))
5578
5590
  return refuse(401, `control headers need ${ADMIN_KEY_HEADER}`);
5579
5591
  controls.ensure(namespace);
5580
5592
  if (requested?.restore !== void 0 && !snapshotStore.get(namespace, requested.restore))
@@ -6960,4 +6972,4 @@ export {
6960
6972
  customerIoCredential,
6961
6973
  CustomerIoAPI
6962
6974
  };
6963
- //# sourceMappingURL=chunk-P3OCQHGM.js.map
6975
+ //# sourceMappingURL=chunk-MJKTRTZ4.js.map