@crvouga/mockingbird-service-turnstile 1.9.3 → 1.9.4

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,11 @@
1
1
  # Changelog — @crvouga/mockingbird-service-turnstile
2
2
 
3
+ ## 1.9.4 (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
+
3
9
  ## 1.9.3 (2026-11-02)
4
10
 
5
11
  ### Fixes and improvements
@@ -2401,6 +2401,17 @@ var createNamespaceControls = (options) => {
2401
2401
  };
2402
2402
  };
2403
2403
 
2404
+ // ../core/dist/signing.js
2405
+ var encoder = new TextEncoder();
2406
+ var timingSafeEqual = (a, b) => {
2407
+ if (a.length !== b.length)
2408
+ return false;
2409
+ let diff = 0;
2410
+ for (let i = 0; i < a.length; i++)
2411
+ diff |= a.charCodeAt(i) ^ b.charCodeAt(i);
2412
+ return diff === 0;
2413
+ };
2414
+
2404
2415
  // ../core/dist/surface.js
2405
2416
  var defineMock = (runtime) => runtime;
2406
2417
  var ADMIN_ROUTE_REFERENCE = {
@@ -2519,6 +2530,10 @@ var assertAdminPrefixAvailable = (prefix, paths) => {
2519
2530
  }
2520
2531
  };
2521
2532
  var ADMIN_KEY_HEADER = CONTROL_HEADERS.adminKey;
2533
+ var hasAdminKey = (headers, adminKey) => {
2534
+ const sent = headers.get(ADMIN_KEY_HEADER);
2535
+ return sent !== null && timingSafeEqual(sent, adminKey);
2536
+ };
2522
2537
  var NAMESPACE_HEADER = CONTROL_HEADERS.namespace;
2523
2538
  var ADMIN_DOCS_URL = "https://mockingbird.chrisvouga.dev/docs/admin-controls";
2524
2539
  var ADMIN_CONTROL_PAGES = [
@@ -2992,7 +3007,7 @@ var createControlPlane = (context) => {
2992
3007
  }
2993
3008
  const path = url.pathname.slice(adminPrefix.length) || "/";
2994
3009
  const shell = request.method === "GET" && (path === "/ui" || path === "/ui/");
2995
- if (!shell && context.adminKey !== void 0 && request.headers.get(ADMIN_KEY_HEADER) !== context.adminKey) {
3010
+ if (!shell && context.adminKey !== void 0 && !hasAdminKey(request.headers, context.adminKey)) {
2996
3011
  return adminError(401, `missing or wrong ${ADMIN_KEY_HEADER}`);
2997
3012
  }
2998
3013
  for (const route of routes) {
@@ -3805,7 +3820,7 @@ var stateAdminRoutes = (routes) => {
3805
3820
  };
3806
3821
 
3807
3822
  // ../core/dist/version.js
3808
- var PACKAGE_VERSION = true ? "1.9.3" : UNRELEASED_VERSION;
3823
+ var PACKAGE_VERSION = true ? "1.9.4" : UNRELEASED_VERSION;
3809
3824
 
3810
3825
  // ../core/dist/webhooks.js
3811
3826
  var json4 = (status, body) => new Response(JSON.stringify(body), {
@@ -4784,7 +4799,7 @@ var createRuntime = (options) => {
4784
4799
  throw error;
4785
4800
  }
4786
4801
  const rewinds = at !== void 0 && selectedBranch === "main" && MUTATING_METHODS.has(request.method);
4787
- if ((requested || rewinds) && options.adminKey !== void 0 && request.headers.get(ADMIN_KEY_HEADER) !== options.adminKey)
4802
+ if ((requested || rewinds) && options.adminKey !== void 0 && !hasAdminKey(request.headers, options.adminKey))
4788
4803
  return refuse(401, `control headers need ${ADMIN_KEY_HEADER}`);
4789
4804
  controls.ensure(namespace);
4790
4805
  if (requested?.restore !== void 0 && !snapshotStore.get(namespace, requested.restore))
@@ -5266,4 +5281,4 @@ export {
5266
5281
  TURNSTILE_NAMESPACE,
5267
5282
  TurnstileAPI
5268
5283
  };
5269
- //# sourceMappingURL=chunk-DVMNRVLU.js.map
5284
+ //# sourceMappingURL=chunk-6TMYVLRP.js.map