@shopify/hydrogen 2026.4.8 → 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.8";
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.8";
1702
+ var LIB_VERSION = "2026.4.9";
1702
1703
 
1703
1704
  // src/utils/graphql.ts
1704
1705
  function minifyQuery(string) {
@@ -3670,21 +3671,19 @@ 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
+ );
3687
3685
  }
3686
+ return redirectPath;
3688
3687
  }
3689
3688
  function getSameOriginPath(target, origin) {
3690
3689
  if (!target) return void 0;
@@ -4035,9 +4034,11 @@ function createCustomerAccountClient({
4035
4034
  codeVerifier: verifier,
4036
4035
  state,
4037
4036
  nonce,
4038
- redirectPath: getRedirectUrl(request.url) || // The same HTTPS origin the OAuth `redirect_uri` uses, so an http
4039
- // `request.url` still matches the https pages customers browse.
4040
- getSameOriginPath(getHeader(request, "Referer"), httpsOrigin) || 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
+ )
4041
4042
  });
4042
4043
  loginUrl.searchParams.append("code_challenge", challenge);
4043
4044
  loginUrl.searchParams.append("code_challenge_method", "S256");
@@ -4192,7 +4193,9 @@ function createCustomerAccountClient({
4192
4193
  refreshToken: refresh_token,
4193
4194
  idToken: id_token
4194
4195
  });
4195
- return redirect(redirectPath || defaultRedirectPath);
4196
+ return redirect(
4197
+ getSameOriginPath(redirectPath, httpsOrigin) || defaultRedirectPath
4198
+ );
4196
4199
  },
4197
4200
  setBuyer,
4198
4201
  getBuyer,
@@ -5093,16 +5096,19 @@ var RichText = function(props) {
5093
5096
  {
5094
5097
  ...props,
5095
5098
  components: {
5096
- link: ({ node }) => /* @__PURE__ */ jsx(
5097
- Link,
5098
- {
5099
- to: node.url,
5100
- title: node.title,
5101
- target: node.target,
5102
- prefetch: "intent",
5103
- children: node.children
5104
- }
5105
- ),
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
+ },
5106
5112
  ...props.components
5107
5113
  }
5108
5114
  }
@@ -5187,12 +5193,12 @@ var graphiqlLoader = async function graphiqlLoader2({
5187
5193
 
5188
5194
  <link
5189
5195
  rel="stylesheet"
5190
- href="https://esm.sh/graphiql/dist/style.css"
5196
+ href="https://esm.sh/graphiql@5.4.0/dist/style.css"
5191
5197
  />
5192
5198
 
5193
5199
  <link
5194
5200
  rel="stylesheet"
5195
- href="https://esm.sh/@graphiql/plugin-explorer/dist/style.css"
5201
+ href="https://esm.sh/@graphiql/plugin-explorer@5.1.5/dist/style.css"
5196
5202
  />
5197
5203
  <script type="importmap">
5198
5204
  {
@@ -5204,10 +5210,10 @@ var graphiqlLoader = async function graphiqlLoader2({
5204
5210
 
5205
5211
  "graphql": "https://esm.sh/graphql@16.11.0",
5206
5212
 
5207
- "graphiql": "https://esm.sh/graphiql?standalone&external=react,react-dom,@graphiql/react,graphql",
5208
- "@graphiql/plugin-explorer": "https://esm.sh/@graphiql/plugin-explorer?standalone&external=react,@graphiql/react,graphql",
5209
- "@graphiql/react": "https://esm.sh/@graphiql/react?standalone&external=react,react-dom,graphql",
5210
- "@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"
5211
5217
  }
5212
5218
  }
5213
5219
  </script>
@@ -5222,9 +5228,9 @@ var graphiqlLoader = async function graphiqlLoader2({
5222
5228
  import {explorerPlugin} from '@graphiql/plugin-explorer';
5223
5229
  import {ToolbarButton} from '@graphiql/react';
5224
5230
 
5225
- import createJSONWorker from 'https://esm.sh/monaco-editor/esm/vs/language/json/json.worker.js?worker';
5226
- import createGraphQLWorker from 'https://esm.sh/monaco-graphql/esm/graphql.worker.js?worker';
5227
- 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';
5228
5234
  import {parse, print} from 'graphql';
5229
5235
 
5230
5236
  globalThis.MonacoEnvironment = {
@@ -5516,7 +5522,7 @@ async function storefrontRedirect(options) {
5516
5522
  matchQueryParams
5517
5523
  );
5518
5524
  }
5519
- const redirectTo = getRedirectUrl(request.url);
5525
+ const redirectTo = getRedirectPathFromSearchParams(request.url);
5520
5526
  if (redirectTo) {
5521
5527
  return createRedirectResponse(
5522
5528
  redirectTo,