@mux/ai 0.17.0 → 0.17.1

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.
@@ -162,6 +162,10 @@ var EnvSchema = z.object({
162
162
  "Override for Mux image base URL (defaults to https://image.mux.com).",
163
163
  "Mux image URL override"
164
164
  ),
165
+ MUX_STREAM_URL_OVERRIDE: optionalString(
166
+ "Override for Mux stream base URL (defaults to https://stream.mux.com).",
167
+ "Mux stream URL override"
168
+ ),
165
169
  // Test-only helpers (used by this repo's integration tests)
166
170
  MUX_TEST_ASSET_ID: optionalString("Mux asset ID used by integration tests.", "Mux test asset id"),
167
171
  MUX_TEST_ASSET_ID_CHAPTERS: optionalString("Mux asset ID used by integration tests for chapters.", "Mux test asset id for chapters"),
@@ -958,22 +962,24 @@ async function withRetry(fn, {
958
962
  throw lastError || new Error("Retry failed with unknown error");
959
963
  }
960
964
 
961
- // src/lib/mux-image-url.ts
965
+ // src/lib/mux-url.ts
962
966
  var DEFAULT_MUX_IMAGE_ORIGIN = "https://image.mux.com";
963
- function normalizeMuxImageOrigin(value) {
967
+ var DEFAULT_MUX_STREAM_ORIGIN = "https://stream.mux.com";
968
+ function normalizeOrigin(value, envVarName) {
964
969
  const trimmed = value.trim();
965
970
  const candidate = trimmed.includes("://") ? trimmed : `https://${trimmed}`;
971
+ const exampleHostname = envVarName === "MUX_IMAGE_URL_OVERRIDE" ? "image.example.mux.com" : "stream.example.mux.com";
966
972
  let parsed;
967
973
  try {
968
974
  parsed = new URL(candidate);
969
975
  } catch {
970
976
  throw new Error(
971
- `Invalid MUX_IMAGE_URL_OVERRIDE. Provide a hostname like "image.example.mux.com" (or a URL origin such as "https://image.example.mux.com").`
977
+ `Invalid ${envVarName}. Provide a hostname (e.g. "${exampleHostname}") or a URL origin (e.g. "https://${exampleHostname}").`
972
978
  );
973
979
  }
974
980
  if (parsed.username || parsed.password || parsed.search || parsed.hash || parsed.pathname && parsed.pathname !== "/") {
975
981
  throw new Error(
976
- "Invalid MUX_IMAGE_URL_OVERRIDE. Only a hostname/origin is allowed (no credentials, query params, hash fragments, or path)."
982
+ `Invalid ${envVarName}. Only a hostname/origin is allowed (no credentials, query params, hash fragments, or path).`
977
983
  );
978
984
  }
979
985
  return parsed.origin;
@@ -983,7 +989,14 @@ function getMuxImageOrigin() {
983
989
  if (!override) {
984
990
  return DEFAULT_MUX_IMAGE_ORIGIN;
985
991
  }
986
- return normalizeMuxImageOrigin(override);
992
+ return normalizeOrigin(override, "MUX_IMAGE_URL_OVERRIDE");
993
+ }
994
+ function getMuxStreamOrigin() {
995
+ const override = env_default.MUX_STREAM_URL_OVERRIDE;
996
+ if (!override) {
997
+ return DEFAULT_MUX_STREAM_ORIGIN;
998
+ }
999
+ return normalizeOrigin(override, "MUX_STREAM_URL_OVERRIDE");
987
1000
  }
988
1001
  function getMuxImageBaseUrl(playbackId, assetType) {
989
1002
  const origin = getMuxImageOrigin();
@@ -1513,7 +1526,7 @@ function concatenateVttSegments(segments, preamble = "WEBVTT") {
1513
1526
  }
1514
1527
  async function buildTranscriptUrl(playbackId, trackId, shouldSign = false, credentials) {
1515
1528
  "use step";
1516
- const baseUrl = `https://stream.mux.com/${playbackId}/text/${trackId}.vtt`;
1529
+ const baseUrl = `${getMuxStreamOrigin()}/${playbackId}/text/${trackId}.vtt`;
1517
1530
  if (shouldSign) {
1518
1531
  return signUrl(baseUrl, playbackId, "video", void 0, credentials);
1519
1532
  }
@@ -5414,7 +5427,7 @@ async function translateAudio(assetId, toLanguageCode, options = {}) {
5414
5427
  { type: "validation_error" }
5415
5428
  );
5416
5429
  }
5417
- let audioUrl = `https://stream.mux.com/${playbackId}/audio.m4a`;
5430
+ let audioUrl = `${getMuxStreamOrigin()}/${playbackId}/audio.m4a`;
5418
5431
  if (policy === "signed") {
5419
5432
  audioUrl = await signUrl(audioUrl, playbackId, "video", void 0, credentials);
5420
5433
  }