@crvouga/mockingbird-service-flex 4.0.5 → 4.0.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 +6 -0
- package/dist/{chunk-DP5H6NFG.js → chunk-3ESVXTZO.js} +48 -36
- package/dist/chunk-3ESVXTZO.js.map +7 -0
- package/dist/{chunk-7IBHJL2N.js → chunk-MVNUNHKW.js} +3 -3
- package/dist/cli.js +2 -2
- package/dist/index.js +1 -1
- package/dist/server.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-DP5H6NFG.js.map +0 -7
- /package/dist/{chunk-7IBHJL2N.js.map → chunk-MVNUNHKW.js.map} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog — @crvouga/mockingbird-service-flex
|
|
2
2
|
|
|
3
|
+
## 4.0.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
|
+
|
|
3
9
|
## 4.0.5 (2026-11-02)
|
|
4
10
|
|
|
5
11
|
### 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
|
|
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) {
|
|
@@ -4108,39 +4152,7 @@ var stateAdminRoutes = (routes) => {
|
|
|
4108
4152
|
};
|
|
4109
4153
|
|
|
4110
4154
|
// ../core/dist/version.js
|
|
4111
|
-
var PACKAGE_VERSION = true ? "4.0.
|
|
4112
|
-
|
|
4113
|
-
// ../core/dist/signing.js
|
|
4114
|
-
var encoder = new TextEncoder();
|
|
4115
|
-
var toBase64 = (bytes) => {
|
|
4116
|
-
let binary = "";
|
|
4117
|
-
for (const byte of bytes instanceof Uint8Array ? bytes : new Uint8Array(bytes)) {
|
|
4118
|
-
binary += String.fromCharCode(byte);
|
|
4119
|
-
}
|
|
4120
|
-
return btoa(binary);
|
|
4121
|
-
};
|
|
4122
|
-
var fromBase64 = (value) => Uint8Array.from(atob(value), (char) => char.charCodeAt(0));
|
|
4123
|
-
var toHex = (bytes) => [...bytes instanceof Uint8Array ? bytes : new Uint8Array(bytes)].map((byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
4124
|
-
var keyBytes = (key) => typeof key === "string" ? encoder.encode(key) : key;
|
|
4125
|
-
var hmac = async (algorithm, key, message, encoding = "hex") => {
|
|
4126
|
-
const imported = await crypto.subtle.importKey("raw", keyBytes(key), { name: "HMAC", hash: algorithm }, false, ["sign"]);
|
|
4127
|
-
const signed = await crypto.subtle.sign("HMAC", imported, typeof message === "string" ? encoder.encode(message) : message);
|
|
4128
|
-
return encoding === "hex" ? toHex(signed) : toBase64(signed);
|
|
4129
|
-
};
|
|
4130
|
-
var svixSecretBytes = (secret) => {
|
|
4131
|
-
const raw = secret.replace(/^f?whsec_/, "");
|
|
4132
|
-
try {
|
|
4133
|
-
return fromBase64(raw);
|
|
4134
|
-
} catch {
|
|
4135
|
-
throw new TypeError("webhook secret must be whsec_<base64> (as Svix issues it)");
|
|
4136
|
-
}
|
|
4137
|
-
};
|
|
4138
|
-
var signSvix = async (secret, messageId, timestampSeconds, body) => `v1,${await hmac("SHA-256", svixSecretBytes(secret), `${messageId}.${timestampSeconds}.${body}`, "base64")}`;
|
|
4139
|
-
var signTimestamped = async (secret, timestampSeconds, body) => `t=${timestampSeconds},v1=${await hmac("SHA-256", secret, `${timestampSeconds}.${body}`, "hex")}`;
|
|
4140
|
-
var signTwilio = async (authToken, url, params) => {
|
|
4141
|
-
const payload = url + Object.keys(params).sort().map((key) => `${key}${params[key]}`).join("");
|
|
4142
|
-
return hmac("SHA-1", authToken, payload, "base64");
|
|
4143
|
-
};
|
|
4155
|
+
var PACKAGE_VERSION = true ? "4.0.6" : UNRELEASED_VERSION;
|
|
4144
4156
|
|
|
4145
4157
|
// ../core/dist/webhooks.js
|
|
4146
4158
|
var signers = {
|
|
@@ -5537,7 +5549,7 @@ var createRuntime = (options) => {
|
|
|
5537
5549
|
throw error2;
|
|
5538
5550
|
}
|
|
5539
5551
|
const rewinds = at !== void 0 && selectedBranch === "main" && MUTATING_METHODS.has(request.method);
|
|
5540
|
-
if ((requested || rewinds) && options.adminKey !== void 0 && request.headers
|
|
5552
|
+
if ((requested || rewinds) && options.adminKey !== void 0 && !hasAdminKey(request.headers, options.adminKey))
|
|
5541
5553
|
return refuse(401, `control headers need ${ADMIN_KEY_HEADER}`);
|
|
5542
5554
|
controls.ensure(namespace);
|
|
5543
5555
|
if (requested?.restore !== void 0 && !snapshotStore.get(namespace, requested.restore))
|
|
@@ -8467,4 +8479,4 @@ export {
|
|
|
8467
8479
|
FlexAPI,
|
|
8468
8480
|
isNextActionType
|
|
8469
8481
|
};
|
|
8470
|
-
//# sourceMappingURL=chunk-
|
|
8482
|
+
//# sourceMappingURL=chunk-3ESVXTZO.js.map
|