@mux/ai 0.7.5 → 0.7.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/dist/index.d.ts CHANGED
@@ -9,7 +9,7 @@ import '@ai-sdk/anthropic';
9
9
  import '@ai-sdk/google';
10
10
  import '@ai-sdk/openai';
11
11
 
12
- var version = "0.7.5";
12
+ var version = "0.7.6";
13
13
 
14
14
  /**
15
15
  * A function that returns workflow credentials, either synchronously or asynchronously.
package/dist/index.js CHANGED
@@ -5,7 +5,7 @@ var __export = (target, all) => {
5
5
  };
6
6
 
7
7
  // package.json
8
- var version = "0.7.5";
8
+ var version = "0.7.6";
9
9
 
10
10
  // src/env.ts
11
11
  import { z } from "zod";
@@ -30,6 +30,10 @@ var EnvSchema = z.object({
30
30
  ),
31
31
  MUX_SIGNING_KEY: optionalString("Mux signing key ID for signed playback URLs.", "Used to sign playback URLs"),
32
32
  MUX_PRIVATE_KEY: optionalString("Mux signing private key for signed playback URLs.", "Used to sign playback URLs"),
33
+ MUX_IMAGE_URL_OVERRIDE: optionalString(
34
+ "Override for Mux image base URL (defaults to https://image.mux.com).",
35
+ "Mux image URL override"
36
+ ),
33
37
  // Test-only helpers (used by this repo's integration tests)
34
38
  MUX_TEST_ASSET_ID: optionalString("Mux asset ID used by integration tests.", "Mux test asset id"),
35
39
  MUX_TEST_ASSET_ID_CHAPTERS: optionalString("Mux asset ID used by integration tests for chapters.", "Mux test asset id for chapters"),
@@ -1032,6 +1036,44 @@ async function fetchHotspots(identifierType, id, options) {
1032
1036
  return transformHotspotResponse(response);
1033
1037
  }
1034
1038
 
1039
+ // src/lib/mux-image-url.ts
1040
+ var DEFAULT_MUX_IMAGE_ORIGIN = "https://image.mux.com";
1041
+ function normalizeMuxImageOrigin(value) {
1042
+ const trimmed = value.trim();
1043
+ const candidate = trimmed.includes("://") ? trimmed : `https://${trimmed}`;
1044
+ let parsed;
1045
+ try {
1046
+ parsed = new URL(candidate);
1047
+ } catch {
1048
+ throw new Error(
1049
+ `Invalid MUX_IMAGE_URL_OVERRIDE. Provide a hostname like "image.example.mux.com" (or a URL origin such as "https://image.example.mux.com").`
1050
+ );
1051
+ }
1052
+ if (parsed.username || parsed.password || parsed.search || parsed.hash || parsed.pathname && parsed.pathname !== "/") {
1053
+ throw new Error(
1054
+ "Invalid MUX_IMAGE_URL_OVERRIDE. Only a hostname/origin is allowed (no credentials, query params, hash fragments, or path)."
1055
+ );
1056
+ }
1057
+ return parsed.origin;
1058
+ }
1059
+ function getMuxImageOrigin() {
1060
+ const override = env_default.MUX_IMAGE_URL_OVERRIDE;
1061
+ if (!override) {
1062
+ return DEFAULT_MUX_IMAGE_ORIGIN;
1063
+ }
1064
+ return normalizeMuxImageOrigin(override);
1065
+ }
1066
+ function getMuxImageBaseUrl(playbackId, assetType) {
1067
+ const origin = getMuxImageOrigin();
1068
+ return `${origin}/${playbackId}/${assetType}.png`;
1069
+ }
1070
+ function getMuxStoryboardBaseUrl(playbackId) {
1071
+ return getMuxImageBaseUrl(playbackId, "storyboard");
1072
+ }
1073
+ function getMuxThumbnailBaseUrl(playbackId) {
1074
+ return getMuxImageBaseUrl(playbackId, "thumbnail");
1075
+ }
1076
+
1035
1077
  // src/lib/url-signing.ts
1036
1078
  async function createSigningClient(context) {
1037
1079
  const { default: MuxClient } = await import("@mux/mux-node");
@@ -1073,7 +1115,7 @@ async function signUrl(url, playbackId, type = "video", params, credentials) {
1073
1115
  var DEFAULT_STORYBOARD_WIDTH = 640;
1074
1116
  async function getStoryboardUrl(playbackId, width = DEFAULT_STORYBOARD_WIDTH, shouldSign = false, credentials) {
1075
1117
  "use step";
1076
- const baseUrl = `https://image.mux.com/${playbackId}/storyboard.png`;
1118
+ const baseUrl = getMuxStoryboardBaseUrl(playbackId);
1077
1119
  if (shouldSign) {
1078
1120
  return signUrl(baseUrl, playbackId, "storyboard", { width }, credentials);
1079
1121
  }
@@ -1192,7 +1234,7 @@ async function getThumbnailUrls(playbackId, duration, options = {}) {
1192
1234
  }
1193
1235
  timestamps = newTimestamps;
1194
1236
  }
1195
- const baseUrl = `https://image.mux.com/${playbackId}/thumbnail.png`;
1237
+ const baseUrl = getMuxThumbnailBaseUrl(playbackId);
1196
1238
  const urlPromises = timestamps.map(async (time) => {
1197
1239
  if (shouldSign) {
1198
1240
  return signUrl(baseUrl, playbackId, "thumbnail", { time, width }, credentials);
@@ -2866,7 +2908,7 @@ async function requestHiveModeration(imageUrls, maxConcurrent = 5, submissionMod
2866
2908
  async function getThumbnailUrlsFromTimestamps(playbackId, timestampsMs, options) {
2867
2909
  "use step";
2868
2910
  const { width, shouldSign, credentials } = options;
2869
- const baseUrl = `https://image.mux.com/${playbackId}/thumbnail.png`;
2911
+ const baseUrl = getMuxThumbnailBaseUrl(playbackId);
2870
2912
  const urlPromises = timestampsMs.map(async (tsMs) => {
2871
2913
  const time = Number((tsMs / 1e3).toFixed(2));
2872
2914
  if (shouldSign) {