@crvouga/mockingbird-service-mailosaur 3.3.0 → 3.4.0

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.
@@ -1430,7 +1430,7 @@ var assertSnapshotDocument = (value, label = "snapshot") => {
1430
1430
  });
1431
1431
  }
1432
1432
  if (value.clock !== void 0) {
1433
- if (!isRecord2(value.clock) || typeof value.clock.now !== "number" || typeof value.clock.frozen !== "boolean")
1433
+ if (!isRecord2(value.clock) || typeof value.clock.now !== "number" || !Number.isFinite(value.clock.now) || typeof value.clock.frozen !== "boolean")
1434
1434
  throw new ControlError(`${label}.clock: expected {now, frozen}`);
1435
1435
  }
1436
1436
  return value;
@@ -3321,6 +3321,91 @@ var createMetrics = (partition = true) => {
3321
3321
  };
3322
3322
  };
3323
3323
 
3324
+ // ../core/dist/outbound.js
3325
+ function ownedTransport(policy) {
3326
+ if (!["offline", "allowlist"].includes(policy.mode) || policy.origins?.some((origin) => {
3327
+ try {
3328
+ return new URL(origin).origin !== origin;
3329
+ } catch {
3330
+ return true;
3331
+ }
3332
+ }))
3333
+ throw new Error("invalid outbound transport policy");
3334
+ const reject = (namespace, reason) => {
3335
+ try {
3336
+ policy.onReject?.({ namespace, policy: policy.mode, reason });
3337
+ } catch {
3338
+ }
3339
+ throw new Error(`outbound policy ${policy.mode}: ${reason}`);
3340
+ };
3341
+ return async (request, namespace, send) => {
3342
+ if (policy.mode === "offline")
3343
+ return reject(namespace, "delivery disabled");
3344
+ const allowed = (url2) => ["http:", "https:"].includes(url2.protocol) && !url2.username && !url2.password && (policy.origins ?? []).includes(url2.origin);
3345
+ let url = new URL(request.url);
3346
+ if (!allowed(url))
3347
+ return reject(namespace, "destination not allowed");
3348
+ const max = policy.maxBodyBytes ?? 1024 * 1024;
3349
+ const chunks = [];
3350
+ let size = 0;
3351
+ const reader = request.body?.getReader();
3352
+ if (reader)
3353
+ try {
3354
+ for (; ; ) {
3355
+ const item = await reader.read();
3356
+ if (item.done)
3357
+ break;
3358
+ size += item.value.length;
3359
+ if (size > max)
3360
+ return reject(namespace, "body limit exceeded");
3361
+ chunks.push(item.value);
3362
+ }
3363
+ } finally {
3364
+ void reader.cancel().catch(() => {
3365
+ });
3366
+ reader.releaseLock();
3367
+ }
3368
+ const body = new Uint8Array(size);
3369
+ let offset = 0;
3370
+ for (const chunk of chunks) {
3371
+ body.set(chunk, offset);
3372
+ offset += chunk.length;
3373
+ }
3374
+ let method = request.method, headers = new Headers(request.headers);
3375
+ for (let redirects = 0; ; redirects++) {
3376
+ if (!allowed(url))
3377
+ return reject(namespace, "redirect destination not allowed");
3378
+ const response = await send(new Request(url, {
3379
+ method,
3380
+ headers,
3381
+ ...method !== "GET" && method !== "HEAD" ? { body } : {},
3382
+ redirect: "manual",
3383
+ signal: request.signal
3384
+ }));
3385
+ if (![301, 302, 303, 307, 308].includes(response.status))
3386
+ return response;
3387
+ const location = response.headers.get("location");
3388
+ if (!location)
3389
+ return response;
3390
+ await response.body?.cancel();
3391
+ if (redirects >= (policy.maxRedirects ?? 5))
3392
+ return reject(namespace, "redirect limit exceeded");
3393
+ const next = new URL(location, url);
3394
+ if (next.origin !== url.origin) {
3395
+ headers = new Headers(headers);
3396
+ for (const key of ["authorization", "cookie", "proxy-authorization"])
3397
+ headers.delete(key);
3398
+ }
3399
+ if (response.status === 303 || (response.status === 301 || response.status === 302) && method === "POST") {
3400
+ method = "GET";
3401
+ headers.delete("content-length");
3402
+ headers.delete("content-type");
3403
+ }
3404
+ url = next;
3405
+ }
3406
+ };
3407
+ }
3408
+
3324
3409
  // ../core/dist/outbox.js
3325
3410
  var OutboxStore = class {
3326
3411
  items;
@@ -3960,7 +4045,7 @@ var stateAdminRoutes = (routes) => {
3960
4045
  };
3961
4046
 
3962
4047
  // ../core/dist/version.js
3963
- var PACKAGE_VERSION = true ? "3.3.0" : UNRELEASED_VERSION;
4048
+ var PACKAGE_VERSION = true ? "3.4.0" : UNRELEASED_VERSION;
3964
4049
 
3965
4050
  // ../core/dist/signing.js
3966
4051
  var encoder = new TextEncoder();
@@ -4544,7 +4629,8 @@ var createRuntime = (options) => {
4544
4629
  ...point.rngState !== void 0 ? { rng: { state: point.rngState, ...streams } } : {},
4545
4630
  ...rules ? { faults: rules } : {},
4546
4631
  ...waits ? { latency: waits } : {},
4547
- ...settings?.virtualTime !== void 0 ? { virtualTime: settings.virtualTime } : {}
4632
+ ...settings?.virtualTime !== void 0 ? { virtualTime: settings.virtualTime } : {},
4633
+ ...point.webhooks !== void 0 ? { webhooks: options.webhooks?.exportSnapshot(point.webhooks) } : {}
4548
4634
  };
4549
4635
  };
4550
4636
  const position = (value, label) => {
@@ -4629,7 +4715,8 @@ var createRuntime = (options) => {
4629
4715
  records: stored,
4630
4716
  ...document2.clock ? { clock: { now: document2.clock.now, frozen: document2.clock.frozen } } : {},
4631
4717
  ...document2.rng?.state !== void 0 ? { rngState: position(document2.rng.state, "snapshot.rng.state") } : {},
4632
- controls: held
4718
+ controls: held,
4719
+ ...document2.webhooks !== void 0 ? { webhooks: options.webhooks?.importSnapshot(namespace, document2.webhooks) } : {}
4633
4720
  };
4634
4721
  };
4635
4722
  const kept = /* @__PURE__ */ new Map();
@@ -4763,6 +4850,20 @@ var createRuntime = (options) => {
4763
4850
  restoreAll(namespace, point);
4764
4851
  timelines.delete(namespace);
4765
4852
  },
4853
+ fleetExport(handle) {
4854
+ const point = typeof handle === "object" && handle !== null ? fleetPoints.get(handle) : void 0;
4855
+ if (!point)
4856
+ throw new Error("invalid fleet checkpoint");
4857
+ return toDocument(point);
4858
+ },
4859
+ fleetImport(namespace, document2) {
4860
+ const handle = {};
4861
+ fleetPoints.set(handle, {
4862
+ namespace,
4863
+ ...fromDocument(namespace, assertSnapshotDocument(document2))
4864
+ });
4865
+ return handle;
4866
+ },
4766
4867
  applyPreset: (name2, namespace = DEFAULT_NAMESPACE, overrides = {}) => controls.addFault(namespace, { ...overrides, preset: name2 }),
4767
4868
  instance,
4768
4869
  namespaces: () => [...publicNamespaces].sort(),
@@ -5827,9 +5928,11 @@ export {
5827
5928
  createClock,
5828
5929
  restoreClock,
5829
5930
  parseDuration,
5931
+ normalizeControls,
5830
5932
  normalizeBootControls,
5831
5933
  parseFaultHeader,
5832
5934
  resolveAdminPrefix,
5935
+ ownedTransport,
5833
5936
  findCodes,
5834
5937
  htmlContent,
5835
5938
  textContent,
@@ -5847,4 +5950,4 @@ export {
5847
5950
  matchesCriteria,
5848
5951
  MailosaurAPI
5849
5952
  };
5850
- //# sourceMappingURL=chunk-IZY7O4Q5.js.map
5953
+ //# sourceMappingURL=chunk-U3FYDM4L.js.map