@crvouga/mockingbird-service-flex 4.0.5 → 4.0.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 +12 -0
- package/dist/{chunk-7IBHJL2N.js → chunk-7LXOATGK.js} +3 -3
- package/dist/{chunk-DP5H6NFG.js → chunk-Q2G2RMGH.js} +49 -36
- package/dist/chunk-Q2G2RMGH.js.map +7 -0
- 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-7LXOATGK.js.map} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Changelog — @crvouga/mockingbird-service-flex
|
|
2
2
|
|
|
3
|
+
## 4.0.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
|
+
## 4.0.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
|
## 4.0.5 (2026-11-02)
|
|
4
16
|
|
|
5
17
|
### Fixes and improvements
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
parseFaultHeader,
|
|
10
10
|
resolveAdminPrefix,
|
|
11
11
|
restoreClock
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-Q2G2RMGH.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 ?? "4.0.
|
|
3060
|
+
targets.set(name, { ...target, packageVersion: packageVersion ?? "4.0.7" });
|
|
3061
3061
|
} catch (error) {
|
|
3062
3062
|
throw new Error(`service ${name}: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
|
|
3063
3063
|
}
|
|
@@ -5062,4 +5062,4 @@ export {
|
|
|
5062
5062
|
createServer2 as createServer,
|
|
5063
5063
|
serveTarget
|
|
5064
5064
|
};
|
|
5065
|
-
//# sourceMappingURL=chunk-
|
|
5065
|
+
//# sourceMappingURL=chunk-7LXOATGK.js.map
|
|
@@ -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) {
|
|
@@ -3357,6 +3401,7 @@ var IdempotencyStore = class {
|
|
|
3357
3401
|
* the method, path and canonical body). Only `replayable` responses are stored (default:
|
|
3358
3402
|
* every status below 500), so a transient failure can be retried. `replayable` also sees the
|
|
3359
3403
|
* response, for vendors that decide from more than the status.
|
|
3404
|
+
* Stripe also saves endpoint-produced 500 responses.
|
|
3360
3405
|
*/
|
|
3361
3406
|
async run(key, fingerprint, errors, handler, replayable = (status) => status < 500) {
|
|
3362
3407
|
const slot = `${this.namespace}\0${key}`;
|
|
@@ -4108,39 +4153,7 @@ var stateAdminRoutes = (routes) => {
|
|
|
4108
4153
|
};
|
|
4109
4154
|
|
|
4110
4155
|
// ../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
|
-
};
|
|
4156
|
+
var PACKAGE_VERSION = true ? "4.0.7" : UNRELEASED_VERSION;
|
|
4144
4157
|
|
|
4145
4158
|
// ../core/dist/webhooks.js
|
|
4146
4159
|
var signers = {
|
|
@@ -5537,7 +5550,7 @@ var createRuntime = (options) => {
|
|
|
5537
5550
|
throw error2;
|
|
5538
5551
|
}
|
|
5539
5552
|
const rewinds = at !== void 0 && selectedBranch === "main" && MUTATING_METHODS.has(request.method);
|
|
5540
|
-
if ((requested || rewinds) && options.adminKey !== void 0 && request.headers
|
|
5553
|
+
if ((requested || rewinds) && options.adminKey !== void 0 && !hasAdminKey(request.headers, options.adminKey))
|
|
5541
5554
|
return refuse(401, `control headers need ${ADMIN_KEY_HEADER}`);
|
|
5542
5555
|
controls.ensure(namespace);
|
|
5543
5556
|
if (requested?.restore !== void 0 && !snapshotStore.get(namespace, requested.restore))
|
|
@@ -8467,4 +8480,4 @@ export {
|
|
|
8467
8480
|
FlexAPI,
|
|
8468
8481
|
isNextActionType
|
|
8469
8482
|
};
|
|
8470
|
-
//# sourceMappingURL=chunk-
|
|
8483
|
+
//# sourceMappingURL=chunk-Q2G2RMGH.js.map
|