@crvouga/mockingbird-service-firstpromoter 3.10.4 → 3.10.6

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,18 @@
1
1
  # Changelog — @crvouga/mockingbird-service-firstpromoter
2
2
 
3
+ ## 3.10.6 (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.5 (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
+
3
16
  ## 3.10.4 (2026-11-02)
4
17
 
5
18
  ### Fixes and improvements
@@ -473,6 +473,7 @@ var parsePath = (rawKey) => {
473
473
  return path;
474
474
  };
475
475
  var isIndex = (segment) => /^(0|[1-9][0-9]*)$/.test(segment);
476
+ var MAX_ARRAY_INDEX = 4294967294;
476
477
  var put = (target, key, value) => {
477
478
  if (key === "__proto__") {
478
479
  Object.defineProperty(target, key, {
@@ -535,8 +536,17 @@ var decodeFormPairs = (pairs) => {
535
536
  var densify = (value) => {
536
537
  if (typeof value === "string")
537
538
  return value;
538
- if (Array.isArray(value))
539
- return value.filter((item) => item !== void 0).map(densify);
539
+ if (Array.isArray(value)) {
540
+ const dense = [];
541
+ for (const key of Object.keys(value)) {
542
+ if (!isIndex(key) || Number(key) > MAX_ARRAY_INDEX)
543
+ continue;
544
+ const item = value[Number(key)];
545
+ if (item !== void 0)
546
+ dense.push(densify(item));
547
+ }
548
+ return dense;
549
+ }
540
550
  const out = {};
541
551
  for (const [key, item] of Object.entries(value))
542
552
  put(out, key, densify(item));
@@ -2634,6 +2644,46 @@ var createNamespaceControls = (options) => {
2634
2644
  };
2635
2645
  };
2636
2646
 
2647
+ // ../core/dist/signing.js
2648
+ var encoder = new TextEncoder();
2649
+ var toBase64 = (bytes) => {
2650
+ let binary = "";
2651
+ for (const byte of bytes instanceof Uint8Array ? bytes : new Uint8Array(bytes)) {
2652
+ binary += String.fromCharCode(byte);
2653
+ }
2654
+ return btoa(binary);
2655
+ };
2656
+ var fromBase64 = (value) => Uint8Array.from(atob(value), (char) => char.charCodeAt(0));
2657
+ var toHex = (bytes) => [...bytes instanceof Uint8Array ? bytes : new Uint8Array(bytes)].map((byte) => byte.toString(16).padStart(2, "0")).join("");
2658
+ var keyBytes = (key) => typeof key === "string" ? encoder.encode(key) : key;
2659
+ var hmac = async (algorithm, key, message, encoding = "hex") => {
2660
+ const imported = await crypto.subtle.importKey("raw", keyBytes(key), { name: "HMAC", hash: algorithm }, false, ["sign"]);
2661
+ const signed = await crypto.subtle.sign("HMAC", imported, typeof message === "string" ? encoder.encode(message) : message);
2662
+ return encoding === "hex" ? toHex(signed) : toBase64(signed);
2663
+ };
2664
+ var svixSecretBytes = (secret) => {
2665
+ const raw = secret.replace(/^f?whsec_/, "");
2666
+ try {
2667
+ return fromBase64(raw);
2668
+ } catch {
2669
+ throw new TypeError("webhook secret must be whsec_<base64> (as Svix issues it)");
2670
+ }
2671
+ };
2672
+ var signSvix = async (secret, messageId, timestampSeconds, body) => `v1,${await hmac("SHA-256", svixSecretBytes(secret), `${messageId}.${timestampSeconds}.${body}`, "base64")}`;
2673
+ var signTimestamped = async (secret, timestampSeconds, body) => `t=${timestampSeconds},v1=${await hmac("SHA-256", secret, `${timestampSeconds}.${body}`, "hex")}`;
2674
+ var signTwilio = async (authToken, url, params) => {
2675
+ const payload = url + Object.keys(params).sort().map((key) => `${key}${params[key]}`).join("");
2676
+ return hmac("SHA-1", authToken, payload, "base64");
2677
+ };
2678
+ var timingSafeEqual = (a, b) => {
2679
+ if (a.length !== b.length)
2680
+ return false;
2681
+ let diff = 0;
2682
+ for (let i = 0; i < a.length; i++)
2683
+ diff |= a.charCodeAt(i) ^ b.charCodeAt(i);
2684
+ return diff === 0;
2685
+ };
2686
+
2637
2687
  // ../core/dist/surface.js
2638
2688
  var defineMock = (runtime) => runtime;
2639
2689
  var ADMIN_ROUTE_REFERENCE = {
@@ -2752,6 +2802,10 @@ var assertAdminPrefixAvailable = (prefix, paths) => {
2752
2802
  }
2753
2803
  };
2754
2804
  var ADMIN_KEY_HEADER = CONTROL_HEADERS.adminKey;
2805
+ var hasAdminKey = (headers, adminKey) => {
2806
+ const sent = headers.get(ADMIN_KEY_HEADER);
2807
+ return sent !== null && timingSafeEqual(sent, adminKey);
2808
+ };
2755
2809
  var NAMESPACE_HEADER = CONTROL_HEADERS.namespace;
2756
2810
  var ADMIN_DOCS_URL = "https://mockingbird.chrisvouga.dev/docs/admin-controls";
2757
2811
  var ADMIN_CONTROL_PAGES = [
@@ -3225,7 +3279,7 @@ var createControlPlane = (context) => {
3225
3279
  }
3226
3280
  const path = url.pathname.slice(adminPrefix.length) || "/";
3227
3281
  const shell = request.method === "GET" && (path === "/ui" || path === "/ui/");
3228
- if (!shell && context.adminKey !== void 0 && request.headers.get(ADMIN_KEY_HEADER) !== context.adminKey) {
3282
+ if (!shell && context.adminKey !== void 0 && !hasAdminKey(request.headers, context.adminKey)) {
3229
3283
  return adminError(401, `missing or wrong ${ADMIN_KEY_HEADER}`);
3230
3284
  }
3231
3285
  for (const route of routes) {
@@ -4015,39 +4069,7 @@ var stateAdminRoutes = (routes) => {
4015
4069
  };
4016
4070
 
4017
4071
  // ../core/dist/version.js
4018
- var PACKAGE_VERSION = true ? "3.10.4" : UNRELEASED_VERSION;
4019
-
4020
- // ../core/dist/signing.js
4021
- var encoder = new TextEncoder();
4022
- var toBase64 = (bytes) => {
4023
- let binary = "";
4024
- for (const byte of bytes instanceof Uint8Array ? bytes : new Uint8Array(bytes)) {
4025
- binary += String.fromCharCode(byte);
4026
- }
4027
- return btoa(binary);
4028
- };
4029
- var fromBase64 = (value) => Uint8Array.from(atob(value), (char) => char.charCodeAt(0));
4030
- var toHex = (bytes) => [...bytes instanceof Uint8Array ? bytes : new Uint8Array(bytes)].map((byte) => byte.toString(16).padStart(2, "0")).join("");
4031
- var keyBytes = (key) => typeof key === "string" ? encoder.encode(key) : key;
4032
- var hmac = async (algorithm, key, message, encoding = "hex") => {
4033
- const imported = await crypto.subtle.importKey("raw", keyBytes(key), { name: "HMAC", hash: algorithm }, false, ["sign"]);
4034
- const signed = await crypto.subtle.sign("HMAC", imported, typeof message === "string" ? encoder.encode(message) : message);
4035
- return encoding === "hex" ? toHex(signed) : toBase64(signed);
4036
- };
4037
- var svixSecretBytes = (secret) => {
4038
- const raw = secret.replace(/^f?whsec_/, "");
4039
- try {
4040
- return fromBase64(raw);
4041
- } catch {
4042
- throw new TypeError("webhook secret must be whsec_<base64> (as Svix issues it)");
4043
- }
4044
- };
4045
- var signSvix = async (secret, messageId, timestampSeconds, body) => `v1,${await hmac("SHA-256", svixSecretBytes(secret), `${messageId}.${timestampSeconds}.${body}`, "base64")}`;
4046
- var signTimestamped = async (secret, timestampSeconds, body) => `t=${timestampSeconds},v1=${await hmac("SHA-256", secret, `${timestampSeconds}.${body}`, "hex")}`;
4047
- var signTwilio = async (authToken, url, params) => {
4048
- const payload = url + Object.keys(params).sort().map((key) => `${key}${params[key]}`).join("");
4049
- return hmac("SHA-1", authToken, payload, "base64");
4050
- };
4072
+ var PACKAGE_VERSION = true ? "3.10.6" : UNRELEASED_VERSION;
4051
4073
 
4052
4074
  // ../core/dist/webhooks.js
4053
4075
  var signers = {
@@ -5444,7 +5466,7 @@ var createRuntime = (options) => {
5444
5466
  throw error2;
5445
5467
  }
5446
5468
  const rewinds = at !== void 0 && selectedBranch === "main" && MUTATING_METHODS.has(request.method);
5447
- if ((requested || rewinds) && options.adminKey !== void 0 && request.headers.get(ADMIN_KEY_HEADER) !== options.adminKey)
5469
+ if ((requested || rewinds) && options.adminKey !== void 0 && !hasAdminKey(request.headers, options.adminKey))
5448
5470
  return refuse(401, `control headers need ${ADMIN_KEY_HEADER}`);
5449
5471
  controls.ensure(namespace);
5450
5472
  if (requested?.restore !== void 0 && !snapshotStore.get(namespace, requested.restore))
@@ -7087,4 +7109,4 @@ export {
7087
7109
  FIRSTPROMOTER_NAMESPACE,
7088
7110
  FirstPromoterAPI
7089
7111
  };
7090
- //# sourceMappingURL=chunk-WXQ6AZNY.js.map
7112
+ //# sourceMappingURL=chunk-35DUQ7H3.js.map