@crvouga/mockingbird-service-resend 3.10.3 → 3.10.5

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,19 @@
1
1
  # Changelog — @crvouga/mockingbird-service-resend
2
2
 
3
+ ## 3.10.5 (2026-11-02)
4
+
5
+ ### Fixes and improvements
6
+
7
+ - compare the admin key in constant time ([2a43141](https://github.com/crvouga/mockingbird/commit/2a43141f50dab41e698c3bbce0c69bf65b40e24e))
8
+
9
+ ## 3.10.4 (2026-11-02)
10
+
11
+ ### Fixes and improvements
12
+
13
+ - stop walkSchema recursing forever on a self-referential $ref ([69464a9](https://github.com/crvouga/mockingbird/commit/69464a9d9e7f468c5e1095125108d4d3d5515431))
14
+ - densify sparse bracket arrays by their written indices ([84a28cb](https://github.com/crvouga/mockingbird/commit/84a28cb182e3d7df91102897f0fc11fca714ba5f))
15
+ - do not save idempotent results for requests that fail validation ([f2161aa](https://github.com/crvouga/mockingbird/commit/f2161aadeae30bcc586e26131da12a7030bdeb11))
16
+
3
17
  ## 3.10.3 (2026-11-02)
4
18
 
5
19
  ### Fixes and improvements
@@ -9,7 +9,7 @@ import {
9
9
  parseFaultHeader,
10
10
  resolveAdminPrefix,
11
11
  restoreClock
12
- } from "./chunk-YY6DKXNX.js";
12
+ } from "./chunk-V3STP2KC.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.3" });
3060
+ targets.set(name, { ...target, packageVersion: packageVersion ?? "3.10.5" });
3061
3061
  } catch (error) {
3062
3062
  throw new Error(`service ${name}: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
3063
3063
  }
@@ -5105,4 +5105,4 @@ export {
5105
5105
  createServer2 as createServer,
5106
5106
  serveTarget
5107
5107
  };
5108
- //# sourceMappingURL=chunk-AOODD3NU.js.map
5108
+ //# sourceMappingURL=chunk-HTACJU7L.js.map
@@ -813,6 +813,7 @@ var parsePath = (rawKey) => {
813
813
  return path;
814
814
  };
815
815
  var isIndex = (segment) => /^(0|[1-9][0-9]*)$/.test(segment);
816
+ var MAX_ARRAY_INDEX = 4294967294;
816
817
  var put = (target, key, value) => {
817
818
  if (key === "__proto__") {
818
819
  Object.defineProperty(target, key, {
@@ -875,8 +876,17 @@ var decodeFormPairs = (pairs) => {
875
876
  var densify = (value) => {
876
877
  if (typeof value === "string")
877
878
  return value;
878
- if (Array.isArray(value))
879
- return value.filter((item) => item !== void 0).map(densify);
879
+ if (Array.isArray(value)) {
880
+ const dense = [];
881
+ for (const key of Object.keys(value)) {
882
+ if (!isIndex(key) || Number(key) > MAX_ARRAY_INDEX)
883
+ continue;
884
+ const item = value[Number(key)];
885
+ if (item !== void 0)
886
+ dense.push(densify(item));
887
+ }
888
+ return dense;
889
+ }
880
890
  const out = {};
881
891
  for (const [key, item] of Object.entries(value))
882
892
  put(out, key, densify(item));
@@ -2664,6 +2674,46 @@ var createNamespaceControls = (options) => {
2664
2674
  };
2665
2675
  };
2666
2676
 
2677
+ // ../core/dist/signing.js
2678
+ var encoder = new TextEncoder();
2679
+ var toBase64 = (bytes) => {
2680
+ let binary = "";
2681
+ for (const byte of bytes instanceof Uint8Array ? bytes : new Uint8Array(bytes)) {
2682
+ binary += String.fromCharCode(byte);
2683
+ }
2684
+ return btoa(binary);
2685
+ };
2686
+ var fromBase64 = (value) => Uint8Array.from(atob(value), (char) => char.charCodeAt(0));
2687
+ var toHex = (bytes) => [...bytes instanceof Uint8Array ? bytes : new Uint8Array(bytes)].map((byte) => byte.toString(16).padStart(2, "0")).join("");
2688
+ var keyBytes = (key) => typeof key === "string" ? encoder.encode(key) : key;
2689
+ var hmac = async (algorithm, key, message, encoding = "hex") => {
2690
+ const imported = await crypto.subtle.importKey("raw", keyBytes(key), { name: "HMAC", hash: algorithm }, false, ["sign"]);
2691
+ const signed = await crypto.subtle.sign("HMAC", imported, typeof message === "string" ? encoder.encode(message) : message);
2692
+ return encoding === "hex" ? toHex(signed) : toBase64(signed);
2693
+ };
2694
+ var svixSecretBytes = (secret) => {
2695
+ const raw = secret.replace(/^f?whsec_/, "");
2696
+ try {
2697
+ return fromBase64(raw);
2698
+ } catch {
2699
+ throw new TypeError("webhook secret must be whsec_<base64> (as Svix issues it)");
2700
+ }
2701
+ };
2702
+ var signSvix = async (secret, messageId, timestampSeconds, body) => `v1,${await hmac("SHA-256", svixSecretBytes(secret), `${messageId}.${timestampSeconds}.${body}`, "base64")}`;
2703
+ var signTimestamped = async (secret, timestampSeconds, body) => `t=${timestampSeconds},v1=${await hmac("SHA-256", secret, `${timestampSeconds}.${body}`, "hex")}`;
2704
+ var signTwilio = async (authToken, url, params) => {
2705
+ const payload = url + Object.keys(params).sort().map((key) => `${key}${params[key]}`).join("");
2706
+ return hmac("SHA-1", authToken, payload, "base64");
2707
+ };
2708
+ var timingSafeEqual = (a, b) => {
2709
+ if (a.length !== b.length)
2710
+ return false;
2711
+ let diff = 0;
2712
+ for (let i = 0; i < a.length; i++)
2713
+ diff |= a.charCodeAt(i) ^ b.charCodeAt(i);
2714
+ return diff === 0;
2715
+ };
2716
+
2667
2717
  // ../core/dist/surface.js
2668
2718
  var defineMock = (runtime) => runtime;
2669
2719
  var ADMIN_ROUTE_REFERENCE = {
@@ -2782,6 +2832,10 @@ var assertAdminPrefixAvailable = (prefix, paths) => {
2782
2832
  }
2783
2833
  };
2784
2834
  var ADMIN_KEY_HEADER = CONTROL_HEADERS.adminKey;
2835
+ var hasAdminKey = (headers, adminKey) => {
2836
+ const sent = headers.get(ADMIN_KEY_HEADER);
2837
+ return sent !== null && timingSafeEqual(sent, adminKey);
2838
+ };
2785
2839
  var NAMESPACE_HEADER = CONTROL_HEADERS.namespace;
2786
2840
  var ADMIN_DOCS_URL = "https://mockingbird.chrisvouga.dev/docs/admin-controls";
2787
2841
  var ADMIN_CONTROL_PAGES = [
@@ -3255,7 +3309,7 @@ var createControlPlane = (context) => {
3255
3309
  }
3256
3310
  const path = url.pathname.slice(adminPrefix.length) || "/";
3257
3311
  const shell = request.method === "GET" && (path === "/ui" || path === "/ui/");
3258
- if (!shell && context.adminKey !== void 0 && request.headers.get(ADMIN_KEY_HEADER) !== context.adminKey) {
3312
+ if (!shell && context.adminKey !== void 0 && !hasAdminKey(request.headers, context.adminKey)) {
3259
3313
  return adminError(401, `missing or wrong ${ADMIN_KEY_HEADER}`);
3260
3314
  }
3261
3315
  for (const route of routes) {
@@ -3353,7 +3407,8 @@ var IdempotencyStore = class {
3353
3407
  /**
3354
3408
  * Run `handler` once per `key`. `fingerprint` identifies the request's parameters (e.g.
3355
3409
  * the method, path and canonical body). Only `replayable` responses are stored (default:
3356
- * every status below 500, as Stripe does), so a transient failure can be retried.
3410
+ * every status below 500), so a transient failure can be retried. `replayable` also sees the
3411
+ * response, for vendors that decide from more than the status.
3357
3412
  */
3358
3413
  async run(key, fingerprint, errors, handler, replayable = (status) => status < 500) {
3359
3414
  const slot = `${this.namespace}\0${key}`;
@@ -3375,7 +3430,7 @@ var IdempotencyStore = class {
3375
3430
  }));
3376
3431
  try {
3377
3432
  const response = await handler();
3378
- if (!replayable(response.status))
3433
+ if (!replayable(response.status, response))
3379
3434
  return response;
3380
3435
  const body = await response.clone().text();
3381
3436
  this.responses.insert(key, {
@@ -4185,39 +4240,7 @@ var stateAdminRoutes = (routes) => {
4185
4240
  };
4186
4241
 
4187
4242
  // ../core/dist/version.js
4188
- var PACKAGE_VERSION = true ? "3.10.3" : UNRELEASED_VERSION;
4189
-
4190
- // ../core/dist/signing.js
4191
- var encoder = new TextEncoder();
4192
- var toBase64 = (bytes) => {
4193
- let binary = "";
4194
- for (const byte of bytes instanceof Uint8Array ? bytes : new Uint8Array(bytes)) {
4195
- binary += String.fromCharCode(byte);
4196
- }
4197
- return btoa(binary);
4198
- };
4199
- var fromBase64 = (value) => Uint8Array.from(atob(value), (char) => char.charCodeAt(0));
4200
- var toHex = (bytes) => [...bytes instanceof Uint8Array ? bytes : new Uint8Array(bytes)].map((byte) => byte.toString(16).padStart(2, "0")).join("");
4201
- var keyBytes = (key) => typeof key === "string" ? encoder.encode(key) : key;
4202
- var hmac = async (algorithm, key, message, encoding = "hex") => {
4203
- const imported = await crypto.subtle.importKey("raw", keyBytes(key), { name: "HMAC", hash: algorithm }, false, ["sign"]);
4204
- const signed = await crypto.subtle.sign("HMAC", imported, typeof message === "string" ? encoder.encode(message) : message);
4205
- return encoding === "hex" ? toHex(signed) : toBase64(signed);
4206
- };
4207
- var svixSecretBytes = (secret) => {
4208
- const raw = secret.replace(/^f?whsec_/, "");
4209
- try {
4210
- return fromBase64(raw);
4211
- } catch {
4212
- throw new TypeError("webhook secret must be whsec_<base64> (as Svix issues it)");
4213
- }
4214
- };
4215
- var signSvix = async (secret, messageId, timestampSeconds, body) => `v1,${await hmac("SHA-256", svixSecretBytes(secret), `${messageId}.${timestampSeconds}.${body}`, "base64")}`;
4216
- var signTimestamped = async (secret, timestampSeconds, body) => `t=${timestampSeconds},v1=${await hmac("SHA-256", secret, `${timestampSeconds}.${body}`, "hex")}`;
4217
- var signTwilio = async (authToken, url, params) => {
4218
- const payload = url + Object.keys(params).sort().map((key) => `${key}${params[key]}`).join("");
4219
- return hmac("SHA-1", authToken, payload, "base64");
4220
- };
4243
+ var PACKAGE_VERSION = true ? "3.10.5" : UNRELEASED_VERSION;
4221
4244
 
4222
4245
  // ../core/dist/webhooks.js
4223
4246
  var signers = {
@@ -5614,7 +5637,7 @@ var createRuntime = (options) => {
5614
5637
  throw error2;
5615
5638
  }
5616
5639
  const rewinds = at !== void 0 && selectedBranch === "main" && MUTATING_METHODS.has(request.method);
5617
- if ((requested || rewinds) && options.adminKey !== void 0 && request.headers.get(ADMIN_KEY_HEADER) !== options.adminKey)
5640
+ if ((requested || rewinds) && options.adminKey !== void 0 && !hasAdminKey(request.headers, options.adminKey))
5618
5641
  return refuse(401, `control headers need ${ADMIN_KEY_HEADER}`);
5619
5642
  controls.ensure(namespace);
5620
5643
  if (requested?.restore !== void 0 && !snapshotStore.get(namespace, requested.restore))
@@ -8810,4 +8833,4 @@ export {
8810
8833
  * Copyright (c) 2021 - present, Yusuke Wada and Hono contributors
8811
8834
  * MIT license: see THIRD_PARTY_NOTICES.md in the repository and npm packages.
8812
8835
  */
8813
- //# sourceMappingURL=chunk-YY6DKXNX.js.map
8836
+ //# sourceMappingURL=chunk-V3STP2KC.js.map