@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.
@@ -8,6 +8,7 @@ var loadScript = require('@shopify/hydrogen-react/load-script');
8
8
  var graphqlClient = require('@shopify/graphql-client');
9
9
  var cookie = require('worktop/cookie');
10
10
  var cspBuilder = require('content-security-policy-builder');
11
+ var isSafeRichTextUrl = require('@shopify/hydrogen-react/is-safe-rich-text-url');
11
12
 
12
13
  var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
13
14
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
@@ -490,7 +491,7 @@ function getPrivacyBanner() {
490
491
  }
491
492
 
492
493
  // package.json
493
- var version = "2026.4.8";
494
+ var version = "2026.4.9";
494
495
 
495
496
  // src/analytics-manager/ShopifyAnalytics.tsx
496
497
  function getCustomerPrivacyRequired() {
@@ -1874,7 +1875,7 @@ function generateUUID() {
1874
1875
  }
1875
1876
 
1876
1877
  // src/version.ts
1877
- var LIB_VERSION = "2026.4.8";
1878
+ var LIB_VERSION = "2026.4.9";
1878
1879
 
1879
1880
  // src/utils/graphql.ts
1880
1881
  function minifyQuery(string) {
@@ -3846,21 +3847,19 @@ function toHexString(byteArray) {
3846
3847
  }
3847
3848
 
3848
3849
  // src/utils/get-redirect-url.ts
3849
- function getRedirectUrl(requestUrl) {
3850
+ function getRedirectPathFromSearchParams(requestUrl, origin) {
3850
3851
  if (!requestUrl) return;
3851
- const { pathname, search } = new URL(requestUrl);
3852
- const redirectFrom = pathname + search;
3853
- const searchParams = new URLSearchParams(search);
3854
- const redirectTo = searchParams.get("return_to") || searchParams.get("redirect");
3855
- if (redirectTo) {
3856
- if (isLocalPath(requestUrl, redirectTo)) {
3857
- return redirectTo;
3858
- } else {
3859
- console.warn(
3860
- `Cross-domain redirects are not supported. Tried to redirect from ${redirectFrom} to ${redirectTo}`
3861
- );
3862
- }
3852
+ const url = new URL(requestUrl);
3853
+ const param = url.searchParams.get("return_to") ? "return_to" : "redirect";
3854
+ const redirectTo = url.searchParams.get(param);
3855
+ if (!redirectTo) return;
3856
+ const redirectPath = getSameOriginPath(redirectTo, origin ?? url.origin);
3857
+ if (!redirectPath) {
3858
+ console.warn(
3859
+ `Ignoring ${param} because it isn't a same-origin path. Tried to redirect from ${url.pathname}${url.search} to ${redirectTo}`
3860
+ );
3863
3861
  }
3862
+ return redirectPath;
3864
3863
  }
3865
3864
  function getSameOriginPath(target, origin) {
3866
3865
  if (!target) return void 0;
@@ -4211,9 +4210,11 @@ function createCustomerAccountClient({
4211
4210
  codeVerifier: verifier,
4212
4211
  state,
4213
4212
  nonce,
4214
- redirectPath: getRedirectUrl(request.url) || // The same HTTPS origin the OAuth `redirect_uri` uses, so an http
4215
- // `request.url` still matches the https pages customers browse.
4216
- getSameOriginPath(getHeader(request, "Referer"), httpsOrigin) || defaultRedirectPath
4213
+ redirectPath: (
4214
+ // The same HTTPS origin the OAuth `redirect_uri` uses, so an http
4215
+ // `request.url` still matches the https pages customers browse.
4216
+ getRedirectPathFromSearchParams(request.url, httpsOrigin) || getSameOriginPath(getHeader(request, "Referer"), httpsOrigin) || defaultRedirectPath
4217
+ )
4217
4218
  });
4218
4219
  loginUrl.searchParams.append("code_challenge", challenge);
4219
4220
  loginUrl.searchParams.append("code_challenge_method", "S256");
@@ -4368,7 +4369,9 @@ function createCustomerAccountClient({
4368
4369
  refreshToken: refresh_token,
4369
4370
  idToken: id_token
4370
4371
  });
4371
- return redirect(redirectPath || defaultRedirectPath);
4372
+ return redirect(
4373
+ getSameOriginPath(redirectPath, httpsOrigin) || defaultRedirectPath
4374
+ );
4372
4375
  },
4373
4376
  setBuyer,
4374
4377
  getBuyer,
@@ -5269,16 +5272,19 @@ var RichText = function(props) {
5269
5272
  {
5270
5273
  ...props,
5271
5274
  components: {
5272
- link: ({ node }) => /* @__PURE__ */ jsxRuntime.jsx(
5273
- reactRouter.Link,
5274
- {
5275
- to: node.url,
5276
- title: node.title,
5277
- target: node.target,
5278
- prefetch: "intent",
5279
- children: node.children
5280
- }
5281
- ),
5275
+ link: ({ node }) => {
5276
+ if (!isSafeRichTextUrl.isSafeRichTextUrl(node.url)) return node.children;
5277
+ return /* @__PURE__ */ jsxRuntime.jsx(
5278
+ reactRouter.Link,
5279
+ {
5280
+ to: node.url,
5281
+ title: node.title,
5282
+ target: node.target,
5283
+ prefetch: "intent",
5284
+ children: node.children
5285
+ }
5286
+ );
5287
+ },
5282
5288
  ...props.components
5283
5289
  }
5284
5290
  }
@@ -5363,12 +5369,12 @@ var graphiqlLoader = async function graphiqlLoader2({
5363
5369
 
5364
5370
  <link
5365
5371
  rel="stylesheet"
5366
- href="https://esm.sh/graphiql/dist/style.css"
5372
+ href="https://esm.sh/graphiql@5.4.0/dist/style.css"
5367
5373
  />
5368
5374
 
5369
5375
  <link
5370
5376
  rel="stylesheet"
5371
- href="https://esm.sh/@graphiql/plugin-explorer/dist/style.css"
5377
+ href="https://esm.sh/@graphiql/plugin-explorer@5.1.5/dist/style.css"
5372
5378
  />
5373
5379
  <script type="importmap">
5374
5380
  {
@@ -5380,10 +5386,10 @@ var graphiqlLoader = async function graphiqlLoader2({
5380
5386
 
5381
5387
  "graphql": "https://esm.sh/graphql@16.11.0",
5382
5388
 
5383
- "graphiql": "https://esm.sh/graphiql?standalone&external=react,react-dom,@graphiql/react,graphql",
5384
- "@graphiql/plugin-explorer": "https://esm.sh/@graphiql/plugin-explorer?standalone&external=react,@graphiql/react,graphql",
5385
- "@graphiql/react": "https://esm.sh/@graphiql/react?standalone&external=react,react-dom,graphql",
5386
- "@graphiql/toolkit": "https://esm.sh/@graphiql/toolkit?standalone&external=graphql"
5389
+ "graphiql": "https://esm.sh/graphiql@5.4.0?standalone&external=react,react-dom,@graphiql/react,graphql",
5390
+ "@graphiql/plugin-explorer": "https://esm.sh/@graphiql/plugin-explorer@5.1.5?standalone&external=react,@graphiql/react,graphql",
5391
+ "@graphiql/react": "https://esm.sh/@graphiql/react@0.39.1?standalone&external=react,react-dom,graphql",
5392
+ "@graphiql/toolkit": "https://esm.sh/@graphiql/toolkit@0.12.1?standalone&external=graphql"
5387
5393
  }
5388
5394
  }
5389
5395
  </script>
@@ -5398,9 +5404,9 @@ var graphiqlLoader = async function graphiqlLoader2({
5398
5404
  import {explorerPlugin} from '@graphiql/plugin-explorer';
5399
5405
  import {ToolbarButton} from '@graphiql/react';
5400
5406
 
5401
- import createJSONWorker from 'https://esm.sh/monaco-editor/esm/vs/language/json/json.worker.js?worker';
5402
- import createGraphQLWorker from 'https://esm.sh/monaco-graphql/esm/graphql.worker.js?worker';
5403
- import createEditorWorker from 'https://esm.sh/monaco-editor/esm/vs/editor/editor.worker.js?worker';
5407
+ import createJSONWorker from 'https://esm.sh/monaco-editor@0.52.2/esm/vs/language/json/json.worker.js?worker';
5408
+ import createGraphQLWorker from 'https://esm.sh/monaco-graphql@1.9.0/esm/graphql.worker.js?worker';
5409
+ import createEditorWorker from 'https://esm.sh/monaco-editor@0.52.2/esm/vs/editor/editor.worker.js?worker';
5404
5410
  import {parse, print} from 'graphql';
5405
5411
 
5406
5412
  globalThis.MonacoEnvironment = {
@@ -5692,7 +5698,7 @@ async function storefrontRedirect(options) {
5692
5698
  matchQueryParams
5693
5699
  );
5694
5700
  }
5695
- const redirectTo = getRedirectUrl(request.url);
5701
+ const redirectTo = getRedirectPathFromSearchParams(request.url);
5696
5702
  if (redirectTo) {
5697
5703
  return createRedirectResponse(
5698
5704
  redirectTo,