@shopify/hydrogen 2026.4.7 → 2026.4.9

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.
@@ -7,6 +7,7 @@ import { loadScript } from '@shopify/hydrogen-react/load-script';
7
7
  import { createGraphQLClient } from '@shopify/graphql-client';
8
8
  import { parse, stringify } from 'worktop/cookie';
9
9
  import cspBuilder from 'content-security-policy-builder';
10
+ import { isSafeRichTextUrl } from '@shopify/hydrogen-react/is-safe-rich-text-url';
10
11
 
11
12
  // src/analytics-manager/AnalyticsProvider.tsx
12
13
  function AnalyticsView(props) {
@@ -314,7 +315,7 @@ function getPrivacyBanner() {
314
315
  }
315
316
 
316
317
  // package.json
317
- var version = "2026.4.7";
318
+ var version = "2026.4.9";
318
319
 
319
320
  // src/analytics-manager/ShopifyAnalytics.tsx
320
321
  function getCustomerPrivacyRequired() {
@@ -1698,7 +1699,7 @@ function generateUUID() {
1698
1699
  }
1699
1700
 
1700
1701
  // src/version.ts
1701
- var LIB_VERSION = "2026.4.7";
1702
+ var LIB_VERSION = "2026.4.9";
1702
1703
 
1703
1704
  // src/utils/graphql.ts
1704
1705
  function minifyQuery(string) {
@@ -3382,7 +3383,7 @@ function useOptimisticCart(cart) {
3382
3383
  }
3383
3384
 
3384
3385
  // src/changelogHandler.ts
3385
- var DEFAULT_GITHUB_CHANGELOG_URL = "https://raw.githubusercontent.com/Shopify/hydrogen/main/docs/changelog.json";
3386
+ var DEFAULT_GITHUB_CHANGELOG_URL = "https://raw.githubusercontent.com/Shopify/hydrogen/2026-04/docs/changelog.json";
3386
3387
  async function changelogHandler({
3387
3388
  request,
3388
3389
  changelogUrl
@@ -3670,20 +3671,29 @@ function toHexString(byteArray) {
3670
3671
  }
3671
3672
 
3672
3673
  // src/utils/get-redirect-url.ts
3673
- function getRedirectUrl(requestUrl) {
3674
+ function getRedirectPathFromSearchParams(requestUrl, origin) {
3674
3675
  if (!requestUrl) return;
3675
- const { pathname, search } = new URL(requestUrl);
3676
- const redirectFrom = pathname + search;
3677
- const searchParams = new URLSearchParams(search);
3678
- const redirectTo = searchParams.get("return_to") || searchParams.get("redirect");
3679
- if (redirectTo) {
3680
- if (isLocalPath(requestUrl, redirectTo)) {
3681
- return redirectTo;
3682
- } else {
3683
- console.warn(
3684
- `Cross-domain redirects are not supported. Tried to redirect from ${redirectFrom} to ${redirectTo}`
3685
- );
3686
- }
3676
+ const url = new URL(requestUrl);
3677
+ const param = url.searchParams.get("return_to") ? "return_to" : "redirect";
3678
+ const redirectTo = url.searchParams.get(param);
3679
+ if (!redirectTo) return;
3680
+ const redirectPath = getSameOriginPath(redirectTo, origin ?? url.origin);
3681
+ if (!redirectPath) {
3682
+ console.warn(
3683
+ `Ignoring ${param} because it isn't a same-origin path. Tried to redirect from ${url.pathname}${url.search} to ${redirectTo}`
3684
+ );
3685
+ }
3686
+ return redirectPath;
3687
+ }
3688
+ function getSameOriginPath(target, origin) {
3689
+ if (!target) return void 0;
3690
+ try {
3691
+ const url = target.startsWith("/") ? new URL(target, origin) : new URL(target);
3692
+ if (url.origin !== origin) return void 0;
3693
+ const path = `${url.pathname}${url.search}${url.hash}`;
3694
+ return path.startsWith("//") ? void 0 : path;
3695
+ } catch {
3696
+ return void 0;
3687
3697
  }
3688
3698
  }
3689
3699
  function isLocalPath(requestUrl, redirectUrl) {
@@ -4024,7 +4034,11 @@ function createCustomerAccountClient({
4024
4034
  codeVerifier: verifier,
4025
4035
  state,
4026
4036
  nonce,
4027
- redirectPath: getRedirectUrl(request.url) || getHeader(request, "Referer") || defaultRedirectPath
4037
+ redirectPath: (
4038
+ // The same HTTPS origin the OAuth `redirect_uri` uses, so an http
4039
+ // `request.url` still matches the https pages customers browse.
4040
+ getRedirectPathFromSearchParams(request.url, httpsOrigin) || getSameOriginPath(getHeader(request, "Referer"), httpsOrigin) || defaultRedirectPath
4041
+ )
4028
4042
  });
4029
4043
  loginUrl.searchParams.append("code_challenge", challenge);
4030
4044
  loginUrl.searchParams.append("code_challenge_method", "S256");
@@ -4179,7 +4193,9 @@ function createCustomerAccountClient({
4179
4193
  refreshToken: refresh_token,
4180
4194
  idToken: id_token
4181
4195
  });
4182
- return redirect(redirectPath || defaultRedirectPath);
4196
+ return redirect(
4197
+ getSameOriginPath(redirectPath, httpsOrigin) || defaultRedirectPath
4198
+ );
4183
4199
  },
4184
4200
  setBuyer,
4185
4201
  getBuyer,
@@ -5080,16 +5096,19 @@ var RichText = function(props) {
5080
5096
  {
5081
5097
  ...props,
5082
5098
  components: {
5083
- link: ({ node }) => /* @__PURE__ */ jsx(
5084
- Link,
5085
- {
5086
- to: node.url,
5087
- title: node.title,
5088
- target: node.target,
5089
- prefetch: "intent",
5090
- children: node.children
5091
- }
5092
- ),
5099
+ link: ({ node }) => {
5100
+ if (!isSafeRichTextUrl(node.url)) return node.children;
5101
+ return /* @__PURE__ */ jsx(
5102
+ Link,
5103
+ {
5104
+ to: node.url,
5105
+ title: node.title,
5106
+ target: node.target,
5107
+ prefetch: "intent",
5108
+ children: node.children
5109
+ }
5110
+ );
5111
+ },
5093
5112
  ...props.components
5094
5113
  }
5095
5114
  }
@@ -5174,12 +5193,12 @@ var graphiqlLoader = async function graphiqlLoader2({
5174
5193
 
5175
5194
  <link
5176
5195
  rel="stylesheet"
5177
- href="https://esm.sh/graphiql/dist/style.css"
5196
+ href="https://esm.sh/graphiql@5.4.0/dist/style.css"
5178
5197
  />
5179
5198
 
5180
5199
  <link
5181
5200
  rel="stylesheet"
5182
- href="https://esm.sh/@graphiql/plugin-explorer/dist/style.css"
5201
+ href="https://esm.sh/@graphiql/plugin-explorer@5.1.5/dist/style.css"
5183
5202
  />
5184
5203
  <script type="importmap">
5185
5204
  {
@@ -5191,10 +5210,10 @@ var graphiqlLoader = async function graphiqlLoader2({
5191
5210
 
5192
5211
  "graphql": "https://esm.sh/graphql@16.11.0",
5193
5212
 
5194
- "graphiql": "https://esm.sh/graphiql?standalone&external=react,react-dom,@graphiql/react,graphql",
5195
- "@graphiql/plugin-explorer": "https://esm.sh/@graphiql/plugin-explorer?standalone&external=react,@graphiql/react,graphql",
5196
- "@graphiql/react": "https://esm.sh/@graphiql/react?standalone&external=react,react-dom,graphql",
5197
- "@graphiql/toolkit": "https://esm.sh/@graphiql/toolkit?standalone&external=graphql"
5213
+ "graphiql": "https://esm.sh/graphiql@5.4.0?standalone&external=react,react-dom,@graphiql/react,graphql",
5214
+ "@graphiql/plugin-explorer": "https://esm.sh/@graphiql/plugin-explorer@5.1.5?standalone&external=react,@graphiql/react,graphql",
5215
+ "@graphiql/react": "https://esm.sh/@graphiql/react@0.39.1?standalone&external=react,react-dom,graphql",
5216
+ "@graphiql/toolkit": "https://esm.sh/@graphiql/toolkit@0.12.1?standalone&external=graphql"
5198
5217
  }
5199
5218
  }
5200
5219
  </script>
@@ -5209,9 +5228,9 @@ var graphiqlLoader = async function graphiqlLoader2({
5209
5228
  import {explorerPlugin} from '@graphiql/plugin-explorer';
5210
5229
  import {ToolbarButton} from '@graphiql/react';
5211
5230
 
5212
- import createJSONWorker from 'https://esm.sh/monaco-editor/esm/vs/language/json/json.worker.js?worker';
5213
- import createGraphQLWorker from 'https://esm.sh/monaco-graphql/esm/graphql.worker.js?worker';
5214
- import createEditorWorker from 'https://esm.sh/monaco-editor/esm/vs/editor/editor.worker.js?worker';
5231
+ import createJSONWorker from 'https://esm.sh/monaco-editor@0.52.2/esm/vs/language/json/json.worker.js?worker';
5232
+ import createGraphQLWorker from 'https://esm.sh/monaco-graphql@1.9.0/esm/graphql.worker.js?worker';
5233
+ import createEditorWorker from 'https://esm.sh/monaco-editor@0.52.2/esm/vs/editor/editor.worker.js?worker';
5215
5234
  import {parse, print} from 'graphql';
5216
5235
 
5217
5236
  globalThis.MonacoEnvironment = {
@@ -5503,7 +5522,7 @@ async function storefrontRedirect(options) {
5503
5522
  matchQueryParams
5504
5523
  );
5505
5524
  }
5506
- const redirectTo = getRedirectUrl(request.url);
5525
+ const redirectTo = getRedirectPathFromSearchParams(request.url);
5507
5526
  if (redirectTo) {
5508
5527
  return createRedirectResponse(
5509
5528
  redirectTo,