@learncard/network-brain-client 2.5.53 → 2.5.54

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.
@@ -25849,6 +25849,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
25849
25849
  requiredEnvironmentString: /* @__PURE__ */ __name(() => requiredEnvironmentString, "requiredEnvironmentString"),
25850
25850
  resizeAndChangeQuality: /* @__PURE__ */ __name(() => resizeAndChangeQuality4, "resizeAndChangeQuality"),
25851
25851
  resolveStorageReadResult: /* @__PURE__ */ __name(() => resolveStorageReadResult, "resolveStorageReadResult"),
25852
+ sanitizeImageUrl: /* @__PURE__ */ __name(() => sanitizeImageUrl, "sanitizeImageUrl"),
25852
25853
  setBitstringStatusListBit: /* @__PURE__ */ __name(() => setBitstringStatusListBit, "setBitstringStatusListBit"),
25853
25854
  stripSdJwtReservedClaims: /* @__PURE__ */ __name(() => stripSdJwtReservedClaims, "stripSdJwtReservedClaims"),
25854
25855
  synthesizeDidJwk: /* @__PURE__ */ __name(() => synthesizeDidJwk, "synthesizeDidJwk"),
@@ -26049,11 +26050,21 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
26049
26050
  return fix ? fixSrcSetString3(srcSet) : srcSet;
26050
26051
  }, "generateSrcSet");
26051
26052
  var Providers = { filestack: filestack_helpers_exports, unsplash: unsplash_helpers_exports, discord: discord_helpers_exports };
26053
+ var isHostnameMatch = /* @__PURE__ */ __name2((hostname, target) => {
26054
+ return hostname === target || hostname.endsWith(`.${target}`);
26055
+ }, "isHostnameMatch");
26052
26056
  var getProvider = /* @__PURE__ */ __name2((url) => {
26053
- if (url?.includes("cdn.filestackcontent.com")) return "filestack";
26054
- if (url?.includes("images.unsplash.com")) return "unsplash";
26055
- if (url?.includes("cdn.discordapp.com")) return "discord";
26056
- return null;
26057
+ if (!url) return null;
26058
+ try {
26059
+ const normalizedUrl = url.startsWith("//") ? `https:${url}` : url;
26060
+ const { hostname } = new URL(normalizedUrl);
26061
+ if (isHostnameMatch(hostname, "cdn.filestackcontent.com")) return "filestack";
26062
+ if (isHostnameMatch(hostname, "images.unsplash.com")) return "unsplash";
26063
+ if (isHostnameMatch(hostname, "cdn.discordapp.com")) return "discord";
26064
+ return null;
26065
+ } catch {
26066
+ return null;
26067
+ }
26057
26068
  }, "getProvider");
26058
26069
  var changeQuality4 = /* @__PURE__ */ __name2((url, quality) => {
26059
26070
  const provider = getProvider(url);
@@ -26083,6 +26094,28 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
26083
26094
  return accumulator;
26084
26095
  }, []);
26085
26096
  }, "getUrlsFromSrcSet");
26097
+ var sanitizeImageUrl = /* @__PURE__ */ __name2((url, options = {}) => {
26098
+ if (!url) return void 0;
26099
+ const { allowBlobUrls = false, allowDataUrls = false } = options;
26100
+ try {
26101
+ const parsed = new URL(url);
26102
+ if (parsed.protocol === "https:" || parsed.protocol === "http:") {
26103
+ return parsed.href;
26104
+ }
26105
+ if (allowBlobUrls && parsed.protocol === "blob:") {
26106
+ return parsed.href;
26107
+ }
26108
+ if (allowDataUrls && parsed.protocol === "data:") {
26109
+ if (url.startsWith("data:image/")) {
26110
+ return url;
26111
+ }
26112
+ return void 0;
26113
+ }
26114
+ return void 0;
26115
+ } catch {
26116
+ return void 0;
26117
+ }
26118
+ }, "sanitizeImageUrl");
26086
26119
  var isNotMaybe = /* @__PURE__ */ __name2((value) => value !== void 0 && value !== null, "isNotMaybe");
26087
26120
  var filterMaybes = /* @__PURE__ */ __name2((array) => array?.filter(isNotMaybe) ?? [], "filterMaybes");
26088
26121
  var capitalizeFirstLetter = /* @__PURE__ */ __name2((string) => {
@@ -26788,8 +26821,13 @@ var callbackLink = /* @__PURE__ */ __name((callback) => {
26788
26821
  if (attempts > 5 || error.data?.httpStatus !== 401) {
26789
26822
  return observer.error(error);
26790
26823
  }
26791
- await callback();
26792
- attempt();
26824
+ try {
26825
+ await callback();
26826
+ } catch {
26827
+ if (!isDone) observer.error(error);
26828
+ return;
26829
+ }
26830
+ if (!isDone) attempt();
26793
26831
  }, "error"),
26794
26832
  next: /* @__PURE__ */ __name((result) => observer.next(result), "next"),
26795
26833
  complete: /* @__PURE__ */ __name(() => {