@shopify/hydrogen 2026.10.0-preview.4 → 2026.10.0
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/cli/index.mjs +23 -12
- package/dist/client/client.d.mts +18 -15
- package/dist/client/client.mjs +8 -3
- package/dist/client/client.mjs.map +1 -1
- package/dist/client/errors.d.mts +35 -13
- package/dist/client/errors.mjs +23 -13
- package/dist/client/errors.mjs.map +1 -1
- package/dist/client/types.d.mts +140 -90
- package/dist/core/analytics/cart-tracker.d.mts +19 -10
- package/dist/core/analytics/cart-tracker.mjs +18 -10
- package/dist/core/analytics/cart-tracker.mjs.map +1 -1
- package/dist/core/analytics/events.d.mts +17 -11
- package/dist/core/analytics/events.mjs +13 -4
- package/dist/core/analytics/events.mjs.map +1 -1
- package/dist/core/analytics/types.d.mts +207 -118
- package/dist/core/analytics/utils/flatten-connection.d.mts +11 -9
- package/dist/core/analytics/utils/flatten-connection.mjs +7 -6
- package/dist/core/analytics/utils/flatten-connection.mjs.map +1 -1
- package/dist/core/cache/fetch-with-cache.d.mts +24 -4
- package/dist/core/cache/fetch-with-cache.mjs +17 -2
- package/dist/core/cache/fetch-with-cache.mjs.map +1 -1
- package/dist/core/cache/key.d.mts +2 -0
- package/dist/core/cache/key.mjs.map +1 -1
- package/dist/core/cache/run-with-cache.d.mts +56 -8
- package/dist/core/cache/run-with-cache.mjs +17 -6
- package/dist/core/cache/run-with-cache.mjs.map +1 -1
- package/dist/core/cache/store.d.mts +8 -6
- package/dist/core/cache/store.mjs.map +1 -1
- package/dist/core/cache/strategies.d.mts +27 -2
- package/dist/core/cache/strategies.mjs +6 -0
- package/dist/core/cache/strategies.mjs.map +1 -1
- package/dist/core/cart/actions.d.mts +37 -30
- package/dist/core/cart/actions.mjs +21 -9
- package/dist/core/cart/actions.mjs.map +1 -1
- package/dist/core/cart/attach-quantity-input.d.mts +8 -7
- package/dist/core/cart/attach-quantity-input.mjs +8 -7
- package/dist/core/cart/attach-quantity-input.mjs.map +1 -1
- package/dist/core/cart/buyer-identity-sync.d.mts +7 -6
- package/dist/core/cart/buyer-identity-sync.mjs.map +1 -1
- package/dist/core/cart/cart.d.mts +59 -46
- package/dist/core/cart/cart.mjs +46 -29
- package/dist/core/cart/cart.mjs.map +1 -1
- package/dist/core/cart/cookie.d.mts +8 -4
- package/dist/core/cart/cookie.mjs +8 -4
- package/dist/core/cart/cookie.mjs.map +1 -1
- package/dist/core/cart/form.d.mts +34 -20
- package/dist/core/cart/form.mjs +6 -4
- package/dist/core/cart/form.mjs.map +1 -1
- package/dist/core/cart/get-cart.d.mts +27 -15
- package/dist/core/cart/get-cart.mjs +13 -8
- package/dist/core/cart/get-cart.mjs.map +1 -1
- package/dist/core/cart/quantity.d.mts +16 -5
- package/dist/core/cart/quantity.mjs +16 -5
- package/dist/core/cart/quantity.mjs.map +1 -1
- package/dist/core/cart/queries.d.mts +25 -19
- package/dist/core/cart/queries.mjs +15 -1
- package/dist/core/cart/queries.mjs.map +1 -1
- package/dist/core/cart/server-handlers.d.mts +82 -45
- package/dist/core/cart/server-handlers.mjs +4 -0
- package/dist/core/cart/server-handlers.mjs.map +1 -1
- package/dist/core/cart/state.d.mts +110 -64
- package/dist/core/cart/state.mjs +24 -6
- package/dist/core/cart/state.mjs.map +1 -1
- package/dist/core/collection/collection.d.mts +52 -53
- package/dist/core/collection/collection.mjs +5 -3
- package/dist/core/collection/collection.mjs.map +1 -1
- package/dist/core/collection/reconciler.d.mts +23 -16
- package/dist/core/collection/reconciler.mjs +8 -4
- package/dist/core/collection/reconciler.mjs.map +1 -1
- package/dist/core/collection/state.d.mts +31 -26
- package/dist/core/collection/state.mjs +4 -3
- package/dist/core/collection/state.mjs.map +1 -1
- package/dist/core/collection/url.d.mts +70 -29
- package/dist/core/collection/url.mjs +63 -25
- package/dist/core/collection/url.mjs.map +1 -1
- package/dist/core/constants.d.mts +1 -0
- package/dist/core/constants.mjs +1 -0
- package/dist/core/constants.mjs.map +1 -1
- package/dist/core/logging/logging.d.mts +14 -8
- package/dist/core/logging/logging.mjs +15 -10
- package/dist/core/logging/logging.mjs.map +1 -1
- package/dist/core/logging/types.d.mts +28 -11
- package/dist/core/logging/types.mjs.map +1 -1
- package/dist/core/money/format.d.mts +6 -4
- package/dist/core/money/format.mjs +19 -9
- package/dist/core/money/format.mjs.map +1 -1
- package/dist/core/money/types.d.mts +41 -25
- package/dist/core/predictive-search/form.d.mts +37 -7
- package/dist/core/predictive-search/form.mjs +21 -3
- package/dist/core/predictive-search/form.mjs.map +1 -1
- package/dist/core/predictive-search/queries.d.mts +18 -30
- package/dist/core/predictive-search/queries.mjs +7 -3
- package/dist/core/predictive-search/queries.mjs.map +1 -1
- package/dist/core/predictive-search/search.d.mts +25 -27
- package/dist/core/predictive-search/search.mjs +20 -19
- package/dist/core/predictive-search/search.mjs.map +1 -1
- package/dist/core/predictive-search/server-handlers.d.mts +25 -26
- package/dist/core/predictive-search/server-handlers.mjs +4 -0
- package/dist/core/predictive-search/server-handlers.mjs.map +1 -1
- package/dist/core/predictive-search/store.d.mts +65 -24
- package/dist/core/predictive-search/store.mjs +12 -1
- package/dist/core/predictive-search/store.mjs.map +1 -1
- package/dist/core/predictive-search/url.d.mts +36 -37
- package/dist/core/predictive-search/url.mjs +14 -6
- package/dist/core/predictive-search/url.mjs.map +1 -1
- package/dist/core/product/form.d.mts +63 -16
- package/dist/core/product/form.mjs +8 -2
- package/dist/core/product/form.mjs.map +1 -1
- package/dist/core/product/options.d.mts +8 -10
- package/dist/core/product/options.mjs +8 -10
- package/dist/core/product/options.mjs.map +1 -1
- package/dist/core/product/product-form.d.mts +77 -29
- package/dist/core/product/product-form.mjs +32 -10
- package/dist/core/product/product-form.mjs.map +1 -1
- package/dist/core/product/state.d.mts +55 -32
- package/dist/core/product/url.d.mts +19 -13
- package/dist/core/product/url.mjs +10 -10
- package/dist/core/product/url.mjs.map +1 -1
- package/dist/core/request-context.d.mts +77 -19
- package/dist/core/request-context.mjs +5 -1
- package/dist/core/request-context.mjs.map +1 -1
- package/dist/core/request-routing/handle-shopify-redirects.d.mts +12 -4
- package/dist/core/request-routing/handle-shopify-redirects.mjs +9 -2
- package/dist/core/request-routing/handle-shopify-redirects.mjs.map +1 -1
- package/dist/core/request-routing/handle-shopify-routes.d.mts +5 -5
- package/dist/core/request-routing/handle-shopify-routes.mjs +7 -5
- package/dist/core/request-routing/handle-shopify-routes.mjs.map +1 -1
- package/dist/core/request-routing/interceptors/proxy.mjs +79 -43
- package/dist/core/request-routing/interceptors/proxy.mjs.map +1 -1
- package/dist/core/request-routing/interceptors/ucp-profile-proxy.mjs +69 -0
- package/dist/core/request-routing/interceptors/ucp-profile-proxy.mjs.map +1 -0
- package/dist/core/request-routing/interceptors/url-redirects.mjs +6 -1
- package/dist/core/request-routing/interceptors/url-redirects.mjs.map +1 -1
- package/dist/core/request-routing/interceptors/well-known.mjs +1 -1
- package/dist/core/request-routing/interceptors/well-known.mjs.map +1 -1
- package/dist/core/request-routing/registered-routes.d.mts +12 -0
- package/dist/core/request-routing/registered-routes.mjs +12 -0
- package/dist/core/request-routing/registered-routes.mjs.map +1 -1
- package/dist/core/request-routing/route-types.d.mts +43 -18
- package/dist/core/shop-pay/shop-pay.d.mts +71 -35
- package/dist/core/shop-pay/shop-pay.mjs +36 -10
- package/dist/core/shop-pay/shop-pay.mjs.map +1 -1
- package/dist/core/shopify-scripts/index.d.mts +15 -5
- package/dist/core/shopify-scripts/index.mjs +15 -5
- package/dist/core/shopify-scripts/index.mjs.map +1 -1
- package/dist/core/shopify-scripts/initialize.d.mts +12 -4
- package/dist/core/shopify-scripts/initialize.mjs +12 -4
- package/dist/core/shopify-scripts/initialize.mjs.map +1 -1
- package/dist/core/shopify-scripts/types.d.mts +58 -25
- package/dist/core/standard-routes/build.d.mts +11 -12
- package/dist/core/standard-routes/build.mjs +11 -12
- package/dist/core/standard-routes/build.mjs.map +1 -1
- package/dist/core/standard-routes/types.d.mts +30 -24
- package/dist/core/url.mjs +2 -1
- package/dist/core/url.mjs.map +1 -1
- package/dist/customer-account/client.d.mts +36 -69
- package/dist/customer-account/client.mjs +7 -8
- package/dist/customer-account/client.mjs.map +1 -1
- package/dist/customer-account/errors.d.mts +45 -36
- package/dist/customer-account/errors.mjs +21 -36
- package/dist/customer-account/errors.mjs.map +1 -1
- package/dist/customer-account/graphql.d.mts +11 -23
- package/dist/customer-account/graphql.mjs +3 -9
- package/dist/customer-account/graphql.mjs.map +1 -1
- package/dist/customer-account/session.d.mts +130 -100
- package/dist/customer-account/session.mjs +32 -10
- package/dist/customer-account/session.mjs.map +1 -1
- package/dist/customer-account/type-resolver.d.mts +7 -8
- package/dist/development/client/client.d.mts +18 -15
- package/dist/development/client/client.mjs +8 -3
- package/dist/development/client/client.mjs.map +1 -1
- package/dist/development/client/errors.d.mts +35 -13
- package/dist/development/client/errors.mjs +23 -13
- package/dist/development/client/errors.mjs.map +1 -1
- package/dist/development/client/types.d.mts +140 -90
- package/dist/development/core/analytics/cart-tracker.d.mts +19 -10
- package/dist/development/core/analytics/cart-tracker.mjs +18 -10
- package/dist/development/core/analytics/cart-tracker.mjs.map +1 -1
- package/dist/development/core/analytics/events.d.mts +17 -11
- package/dist/development/core/analytics/events.mjs +13 -4
- package/dist/development/core/analytics/events.mjs.map +1 -1
- package/dist/development/core/analytics/types.d.mts +207 -118
- package/dist/development/core/analytics/utils/flatten-connection.d.mts +11 -9
- package/dist/development/core/analytics/utils/flatten-connection.mjs +7 -6
- package/dist/development/core/analytics/utils/flatten-connection.mjs.map +1 -1
- package/dist/development/core/cache/fetch-with-cache.d.mts +24 -4
- package/dist/development/core/cache/fetch-with-cache.mjs +17 -2
- package/dist/development/core/cache/fetch-with-cache.mjs.map +1 -1
- package/dist/development/core/cache/key.d.mts +2 -0
- package/dist/development/core/cache/key.mjs.map +1 -1
- package/dist/development/core/cache/run-with-cache.d.mts +56 -8
- package/dist/development/core/cache/run-with-cache.mjs +17 -6
- package/dist/development/core/cache/run-with-cache.mjs.map +1 -1
- package/dist/development/core/cache/store.d.mts +8 -6
- package/dist/development/core/cache/store.mjs.map +1 -1
- package/dist/development/core/cache/strategies.d.mts +27 -2
- package/dist/development/core/cache/strategies.mjs +6 -0
- package/dist/development/core/cache/strategies.mjs.map +1 -1
- package/dist/development/core/cart/actions.d.mts +37 -30
- package/dist/development/core/cart/actions.mjs +21 -9
- package/dist/development/core/cart/actions.mjs.map +1 -1
- package/dist/development/core/cart/attach-quantity-input.d.mts +8 -7
- package/dist/development/core/cart/attach-quantity-input.mjs +8 -7
- package/dist/development/core/cart/attach-quantity-input.mjs.map +1 -1
- package/dist/development/core/cart/buyer-identity-sync.d.mts +6 -5
- package/dist/development/core/cart/buyer-identity-sync.mjs.map +1 -1
- package/dist/development/core/cart/cart.d.mts +59 -46
- package/dist/development/core/cart/cart.mjs +46 -29
- package/dist/development/core/cart/cart.mjs.map +1 -1
- package/dist/development/core/cart/cookie.d.mts +8 -4
- package/dist/development/core/cart/cookie.mjs +8 -4
- package/dist/development/core/cart/cookie.mjs.map +1 -1
- package/dist/development/core/cart/form.d.mts +34 -20
- package/dist/development/core/cart/form.mjs +6 -4
- package/dist/development/core/cart/form.mjs.map +1 -1
- package/dist/development/core/cart/get-cart.d.mts +27 -15
- package/dist/development/core/cart/get-cart.mjs +13 -8
- package/dist/development/core/cart/get-cart.mjs.map +1 -1
- package/dist/development/core/cart/quantity.d.mts +16 -5
- package/dist/development/core/cart/quantity.mjs +16 -5
- package/dist/development/core/cart/quantity.mjs.map +1 -1
- package/dist/development/core/cart/queries.d.mts +25 -19
- package/dist/development/core/cart/queries.mjs +15 -1
- package/dist/development/core/cart/queries.mjs.map +1 -1
- package/dist/development/core/cart/server-handlers.d.mts +82 -45
- package/dist/development/core/cart/server-handlers.mjs +4 -0
- package/dist/development/core/cart/server-handlers.mjs.map +1 -1
- package/dist/development/core/cart/state.d.mts +110 -64
- package/dist/development/core/cart/state.mjs +24 -6
- package/dist/development/core/cart/state.mjs.map +1 -1
- package/dist/development/core/collection/collection.d.mts +52 -53
- package/dist/development/core/collection/collection.mjs +5 -3
- package/dist/development/core/collection/collection.mjs.map +1 -1
- package/dist/development/core/collection/reconciler.d.mts +23 -16
- package/dist/development/core/collection/reconciler.mjs +8 -4
- package/dist/development/core/collection/reconciler.mjs.map +1 -1
- package/dist/development/core/collection/state.d.mts +31 -26
- package/dist/development/core/collection/state.mjs +4 -3
- package/dist/development/core/collection/state.mjs.map +1 -1
- package/dist/development/core/collection/url.d.mts +70 -29
- package/dist/development/core/collection/url.mjs +63 -25
- package/dist/development/core/collection/url.mjs.map +1 -1
- package/dist/development/core/constants.mjs.map +1 -1
- package/dist/development/core/logging/logging.d.mts +14 -8
- package/dist/development/core/logging/logging.mjs +15 -10
- package/dist/development/core/logging/logging.mjs.map +1 -1
- package/dist/development/core/logging/types.d.mts +28 -11
- package/dist/development/core/logging/types.mjs.map +1 -1
- package/dist/development/core/money/format.d.mts +6 -4
- package/dist/development/core/money/format.mjs +19 -9
- package/dist/development/core/money/format.mjs.map +1 -1
- package/dist/development/core/money/types.d.mts +41 -25
- package/dist/development/core/predictive-search/form.d.mts +37 -7
- package/dist/development/core/predictive-search/form.mjs +21 -3
- package/dist/development/core/predictive-search/form.mjs.map +1 -1
- package/dist/development/core/predictive-search/queries.d.mts +18 -30
- package/dist/development/core/predictive-search/queries.mjs +7 -3
- package/dist/development/core/predictive-search/queries.mjs.map +1 -1
- package/dist/development/core/predictive-search/search.d.mts +25 -27
- package/dist/development/core/predictive-search/search.mjs +20 -19
- package/dist/development/core/predictive-search/search.mjs.map +1 -1
- package/dist/development/core/predictive-search/server-handlers.d.mts +25 -26
- package/dist/development/core/predictive-search/server-handlers.mjs +4 -0
- package/dist/development/core/predictive-search/server-handlers.mjs.map +1 -1
- package/dist/development/core/predictive-search/store.d.mts +65 -24
- package/dist/development/core/predictive-search/store.mjs +12 -1
- package/dist/development/core/predictive-search/store.mjs.map +1 -1
- package/dist/development/core/predictive-search/url.d.mts +36 -37
- package/dist/development/core/predictive-search/url.mjs +14 -6
- package/dist/development/core/predictive-search/url.mjs.map +1 -1
- package/dist/development/core/product/form.d.mts +63 -16
- package/dist/development/core/product/form.mjs +8 -2
- package/dist/development/core/product/form.mjs.map +1 -1
- package/dist/development/core/product/options.d.mts +8 -10
- package/dist/development/core/product/options.mjs +8 -10
- package/dist/development/core/product/options.mjs.map +1 -1
- package/dist/development/core/product/product-form.d.mts +77 -29
- package/dist/development/core/product/product-form.mjs +32 -10
- package/dist/development/core/product/product-form.mjs.map +1 -1
- package/dist/development/core/product/state.d.mts +55 -32
- package/dist/development/core/product/url.d.mts +19 -13
- package/dist/development/core/product/url.mjs +10 -10
- package/dist/development/core/product/url.mjs.map +1 -1
- package/dist/development/core/request-context.d.mts +77 -19
- package/dist/development/core/request-context.mjs +5 -1
- package/dist/development/core/request-context.mjs.map +1 -1
- package/dist/development/core/request-routing/handle-shopify-redirects.d.mts +12 -4
- package/dist/development/core/request-routing/handle-shopify-redirects.mjs +9 -2
- package/dist/development/core/request-routing/handle-shopify-redirects.mjs.map +1 -1
- package/dist/development/core/request-routing/handle-shopify-routes.development.d.mts +9 -1
- package/dist/development/core/request-routing/handle-shopify-routes.development.mjs +7 -0
- package/dist/development/core/request-routing/handle-shopify-routes.development.mjs.map +1 -1
- package/dist/development/core/request-routing/handle-shopify-routes.mjs +7 -5
- package/dist/development/core/request-routing/handle-shopify-routes.mjs.map +1 -1
- package/dist/development/core/request-routing/interceptors/proxy.mjs +79 -43
- package/dist/development/core/request-routing/interceptors/proxy.mjs.map +1 -1
- package/dist/development/core/request-routing/interceptors/ucp-profile-proxy.mjs +69 -0
- package/dist/development/core/request-routing/interceptors/ucp-profile-proxy.mjs.map +1 -0
- package/dist/development/core/request-routing/interceptors/url-redirects.mjs +6 -1
- package/dist/development/core/request-routing/interceptors/url-redirects.mjs.map +1 -1
- package/dist/development/core/request-routing/interceptors/well-known.mjs +1 -1
- package/dist/development/core/request-routing/interceptors/well-known.mjs.map +1 -1
- package/dist/development/core/request-routing/registered-routes.d.mts +12 -0
- package/dist/development/core/request-routing/registered-routes.mjs +12 -0
- package/dist/development/core/request-routing/registered-routes.mjs.map +1 -1
- package/dist/development/core/request-routing/route-types.d.mts +43 -18
- package/dist/development/core/shop-pay/shop-pay.d.mts +71 -35
- package/dist/development/core/shop-pay/shop-pay.mjs +36 -10
- package/dist/development/core/shop-pay/shop-pay.mjs.map +1 -1
- package/dist/development/core/shopify-scripts/index.d.mts +15 -5
- package/dist/development/core/shopify-scripts/index.mjs +15 -5
- package/dist/development/core/shopify-scripts/index.mjs.map +1 -1
- package/dist/development/core/shopify-scripts/initialize.d.mts +12 -4
- package/dist/development/core/shopify-scripts/initialize.mjs +12 -4
- package/dist/development/core/shopify-scripts/initialize.mjs.map +1 -1
- package/dist/development/core/shopify-scripts/types.d.mts +58 -25
- package/dist/development/core/standard-routes/build.d.mts +11 -12
- package/dist/development/core/standard-routes/build.mjs +11 -12
- package/dist/development/core/standard-routes/build.mjs.map +1 -1
- package/dist/development/core/standard-routes/types.d.mts +30 -24
- package/dist/development/core/url.mjs +2 -1
- package/dist/development/core/url.mjs.map +1 -1
- package/dist/development/customer-account/session.d.mts +45 -54
- package/dist/development/customer-account/session.mjs +20 -4
- package/dist/development/customer-account/session.mjs.map +1 -1
- package/dist/development/globals.d.mts +20 -11
- package/dist/development/graphql/generated/storefront-api-types.d.mts +127 -1
- package/dist/development/graphql/graphql.d.mts +17 -16
- package/dist/development/graphql/graphql.mjs +7 -8
- package/dist/development/graphql/graphql.mjs.map +1 -1
- package/dist/development/graphql/type-resolver.d.mts +15 -8
- package/dist/development/react/cart.d.mts +78 -32
- package/dist/development/react/cart.mjs +56 -29
- package/dist/development/react/cart.mjs.map +1 -1
- package/dist/development/react/collection.d.mts +40 -22
- package/dist/development/react/collection.mjs +27 -7
- package/dist/development/react/collection.mjs.map +1 -1
- package/dist/development/react/predictive-search.d.mts +65 -50
- package/dist/development/react/predictive-search.mjs +23 -21
- package/dist/development/react/predictive-search.mjs.map +1 -1
- package/dist/development/react/product.d.mts +45 -16
- package/dist/development/react/product.mjs +13 -11
- package/dist/development/react/product.mjs.map +1 -1
- package/dist/development/react/shop-pay.d.mts +15 -0
- package/dist/development/react/shop-pay.mjs +9 -0
- package/dist/development/react/shop-pay.mjs.map +1 -1
- package/dist/development/react/shopify-scripts.d.mts +23 -2
- package/dist/development/react/shopify-scripts.mjs +9 -0
- package/dist/development/react/shopify-scripts.mjs.map +1 -1
- package/dist/development/vue/cart.d.mts +28 -23
- package/dist/development/vue/cart.mjs +42 -25
- package/dist/development/vue/cart.mjs.map +1 -1
- package/dist/development/vue/collection.d.mts +20 -12
- package/dist/development/vue/collection.mjs +15 -7
- package/dist/development/vue/collection.mjs.map +1 -1
- package/dist/development/vue/index.d.mts +2 -2
- package/dist/development/vue/index.mjs +2 -2
- package/dist/development/vue/predictive-search.d.mts +31 -36
- package/dist/development/vue/predictive-search.mjs +16 -22
- package/dist/development/vue/predictive-search.mjs.map +1 -1
- package/dist/development/vue/product.d.mts +16 -15
- package/dist/development/vue/product.mjs +11 -11
- package/dist/development/vue/product.mjs.map +1 -1
- package/dist/development/vue/shop-pay.d.mts +14 -17
- package/dist/development/vue/shop-pay.mjs +8 -0
- package/dist/development/vue/shop-pay.mjs.map +1 -1
- package/dist/development/vue/shopify-scripts.d.mts +11 -0
- package/dist/development/vue/shopify-scripts.mjs +6 -0
- package/dist/development/vue/shopify-scripts.mjs.map +1 -1
- package/dist/globals.d.mts +20 -11
- package/dist/graphql/generated/storefront-api-types.d.mts +127 -1
- package/dist/graphql/graphql.d.mts +17 -16
- package/dist/graphql/graphql.mjs +7 -8
- package/dist/graphql/graphql.mjs.map +1 -1
- package/dist/graphql/type-resolver.d.mts +15 -8
- package/dist/react/cart.d.mts +78 -32
- package/dist/react/cart.mjs +56 -29
- package/dist/react/cart.mjs.map +1 -1
- package/dist/react/collection.d.mts +40 -22
- package/dist/react/collection.mjs +27 -7
- package/dist/react/collection.mjs.map +1 -1
- package/dist/react/predictive-search.d.mts +65 -50
- package/dist/react/predictive-search.mjs +23 -21
- package/dist/react/predictive-search.mjs.map +1 -1
- package/dist/react/product.d.mts +45 -16
- package/dist/react/product.mjs +13 -11
- package/dist/react/product.mjs.map +1 -1
- package/dist/react/shop-pay.d.mts +15 -0
- package/dist/react/shop-pay.mjs +9 -0
- package/dist/react/shop-pay.mjs.map +1 -1
- package/dist/react/shopify-scripts.d.mts +23 -2
- package/dist/react/shopify-scripts.mjs +9 -0
- package/dist/react/shopify-scripts.mjs.map +1 -1
- package/dist/ts-plugin/index.cjs +6 -0
- package/dist/ts-plugin/index.cjs.map +1 -1
- package/dist/ts-plugin/index.d.cts +6 -0
- package/dist/vite/local-https.d.mts +51 -17
- package/dist/vite/local-https.mjs +26 -5
- package/dist/vite/local-https.mjs.map +1 -1
- package/dist/vue/cart.d.mts +28 -23
- package/dist/vue/cart.mjs +42 -25
- package/dist/vue/cart.mjs.map +1 -1
- package/dist/vue/collection.d.mts +20 -12
- package/dist/vue/collection.mjs +15 -7
- package/dist/vue/collection.mjs.map +1 -1
- package/dist/vue/index.d.mts +2 -2
- package/dist/vue/index.mjs +2 -2
- package/dist/vue/predictive-search.d.mts +31 -36
- package/dist/vue/predictive-search.mjs +16 -22
- package/dist/vue/predictive-search.mjs.map +1 -1
- package/dist/vue/product.d.mts +16 -15
- package/dist/vue/product.mjs +11 -11
- package/dist/vue/product.mjs.map +1 -1
- package/dist/vue/shop-pay.d.mts +14 -17
- package/dist/vue/shop-pay.mjs +8 -0
- package/dist/vue/shop-pay.mjs.map +1 -1
- package/dist/vue/shopify-scripts.d.mts +11 -0
- package/dist/vue/shopify-scripts.mjs +6 -0
- package/dist/vue/shopify-scripts.mjs.map +1 -1
- package/package.json +3 -1
- package/skills/hydrogen-analytics/SKILL.md +1 -1
- package/skills/hydrogen-cart-ui/SKILL.md +28 -2
- package/skills/hydrogen-collection-browser/SKILL.md +9 -1
- package/skills/hydrogen-collection-browser/references/nextjs.md +1 -1
- package/skills/hydrogen-collection-browser/references/nuxt.md +1 -1
- package/skills/hydrogen-collection-browser/references/react.md +151 -32
- package/skills/hydrogen-customer-account/SKILL.md +2 -0
- package/skills/hydrogen-request-handlers/SKILL.md +21 -11
- package/skills/hydrogen-setup/references/analytics.md +14 -8
- package/skills/hydrogen-setup/steps/1-inspect-app.md +2 -2
- package/skills/hydrogen-setup/steps/6-product-detail-page.md +21 -11
- package/skills/hydrogen-storefront-client/SKILL.md +1 -1
- package/skills/hydrogen-storefront-client/references/caching.md +2 -0
- package/skills/hydrogen-variant-form/SKILL.md +25 -7
- package/skills/hydrogen-variant-form/references/nextjs.md +39 -4
- package/skills/hydrogen-variant-form/references/nuxt.md +83 -42
- package/skills/hydrogen-variant-form/references/react.md +45 -9
|
@@ -3,162 +3,189 @@ import { CallableRouteHandler, ShopifyRouteErrorResult, ShopifyRouteHandlerConte
|
|
|
3
3
|
import { CartBuyerIdentitySyncSource } from "../core/cart/buyer-identity-sync.mjs";
|
|
4
4
|
|
|
5
5
|
//#region src/customer-account/session.d.ts
|
|
6
|
-
/**
|
|
6
|
+
/**
|
|
7
|
+
* OAuth callback route path: `"/account/authorize"`.
|
|
8
|
+
*
|
|
9
|
+
* @publicDocs
|
|
10
|
+
*/
|
|
7
11
|
declare const CUSTOMER_ACCOUNT_AUTHORIZE_PATH: "/account/authorize";
|
|
8
|
-
/**
|
|
12
|
+
/**
|
|
13
|
+
* Login route path: `"/account/login"`.
|
|
14
|
+
*
|
|
15
|
+
* @publicDocs
|
|
16
|
+
*/
|
|
9
17
|
declare const CUSTOMER_ACCOUNT_LOGIN_PATH: "/account/login";
|
|
10
|
-
/**
|
|
18
|
+
/**
|
|
19
|
+
* Logout route path: `"/account/logout"`.
|
|
20
|
+
*
|
|
21
|
+
* @publicDocs
|
|
22
|
+
*/
|
|
11
23
|
declare const CUSTOMER_ACCOUNT_LOGOUT_PATH: "/account/logout";
|
|
12
|
-
/**
|
|
24
|
+
/**
|
|
25
|
+
* Token refresh route path: `"/account/refresh"`.
|
|
26
|
+
*
|
|
27
|
+
* @publicDocs
|
|
28
|
+
*/
|
|
13
29
|
declare const CUSTOMER_ACCOUNT_REFRESH_PATH: "/account/refresh";
|
|
14
30
|
declare const CUSTOMER_SESSION_INTERNAL_BRAND: unique symbol;
|
|
15
|
-
/**
|
|
31
|
+
/**
|
|
32
|
+
* A value or a promise for that value. Session manager methods can return either.
|
|
33
|
+
*/
|
|
16
34
|
type Awaitable<T> = T | Promise<T>;
|
|
17
|
-
/**
|
|
35
|
+
/** The session storage that `isLoggedIn()` and `getAccessToken()` read. */
|
|
18
36
|
type ReadonlyCustomerSessionManager = {
|
|
19
|
-
getSessionItem(key: string): Awaitable<unknown>;
|
|
37
|
+
/** Returns the session value for a key. The customer session keeps its data under the `customerAccount` key. */getSessionItem(key: string): Awaitable<unknown>;
|
|
20
38
|
};
|
|
21
|
-
/**
|
|
39
|
+
/** The session storage that sign-in, the OAuth callback, token refresh, and logout write to. Commit the session to the response after you call `prepareLoginUrl()`, `handleOAuthCallback()`, `getOrRefreshAccessToken()`, or `logout()`. */
|
|
22
40
|
type WritableCustomerSessionManager = ShopifyRouteSessionManager;
|
|
23
|
-
/** Options for
|
|
41
|
+
/** Options for creating a customer session. */
|
|
24
42
|
type CreateCustomerSessionOptions = {
|
|
25
|
-
/** Numeric Shopify shop ID as a string
|
|
43
|
+
/** Numeric Shopify shop ID as a string of digits, such as `12345`. */shopId: string; /** The Customer Account API OAuth client ID. Must contain at least one non-whitespace character. */
|
|
26
44
|
customerAccountApiClientId: string;
|
|
27
45
|
/**
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
* `
|
|
31
|
-
* `issuer_mismatch` unless the proxy preserves the original issuer. Must use
|
|
32
|
-
* HTTPS; validated at construction.
|
|
46
|
+
* The base URL for Shopify's OAuth authorize, token, and logout endpoints. Defaults to `https://shopify.com/authentication/{shopId}`.
|
|
47
|
+
*
|
|
48
|
+
* The URL must use HTTPS, or creating the session throws. Sign-in fails with the `issuer_mismatch` code when the ID token's issuer differs from this URL.
|
|
33
49
|
*/
|
|
34
|
-
customerAccountApiUrl?: string; /**
|
|
35
|
-
fetch?: typeof globalThis.fetch; /**
|
|
50
|
+
customerAccountApiUrl?: string; /** A custom fetch implementation. Defaults to the global fetch. */
|
|
51
|
+
fetch?: typeof globalThis.fetch; /** The timeout for OAuth token requests in milliseconds. Must be a positive integer no greater than 2,147,483,647. Defaults to `30000`. */
|
|
36
52
|
defaultTimeoutInMs?: number;
|
|
37
53
|
};
|
|
38
|
-
/** Options for
|
|
54
|
+
/** Options for building a Shopify OAuth login URL. */
|
|
39
55
|
type PrepareLoginUrlOptions = {
|
|
40
56
|
/**
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
57
|
+
* Your storefront's origin for the OAuth redirect URL. Defaults to the origin that the session manager returns.
|
|
58
|
+
*
|
|
59
|
+
* The origin must use HTTPS, including on localhost. Use a public HTTPS tunnel for local sign-in.
|
|
44
60
|
*/
|
|
45
61
|
origin?: string;
|
|
46
62
|
/**
|
|
47
|
-
*
|
|
48
|
-
* Cross-origin values and values over 2 048 bytes fall back to the default, `"/account"`.
|
|
63
|
+
* The same-origin path or URL to send the customer to after sign-in, such as `/account/orders`. Defaults to `/account`. Cross-origin values and paths over 2,048 bytes fall back to the default.
|
|
49
64
|
*/
|
|
50
|
-
returnTo?: string; /**
|
|
51
|
-
locale?: string; /**
|
|
52
|
-
countryCode?: string; /**
|
|
53
|
-
loginHint?: string; /**
|
|
54
|
-
loginHintMode?: string; /**
|
|
65
|
+
returnTo?: string; /** The language for Shopify's login page, sent as the `locale` search param. */
|
|
66
|
+
locale?: string; /** The customer's country, sent as the `region_country` search param. */
|
|
67
|
+
countryCode?: string; /** A value that prefills Shopify's login page, such as the customer's email address, sent as the `login_hint` search param. */
|
|
68
|
+
loginHint?: string; /** How Shopify's login page uses the login hint, such as `submit`, sent as the `login_hint_mode` search param. Hydrogen sends the value only with `loginHint`. */
|
|
69
|
+
loginHintMode?: string; /** The authentication context class to request, sent as the `acr_values` search param. */
|
|
55
70
|
acrValues?: string;
|
|
56
71
|
};
|
|
57
72
|
/**
|
|
58
|
-
*
|
|
59
|
-
* and {@link CustomerSession.logout}. Falls back to the session manager's
|
|
60
|
-
* `getSessionOrigin()`.
|
|
73
|
+
* The storefront origin for a token refresh or logout.
|
|
61
74
|
*/
|
|
62
75
|
type RequestOriginOptions = {
|
|
63
|
-
/** HTTPS origin
|
|
76
|
+
/** Your storefront's HTTPS origin. Defaults to the origin that the session manager returns. A non-HTTPS origin throws. */origin?: string;
|
|
64
77
|
};
|
|
65
|
-
/** Options for
|
|
66
|
-
|
|
78
|
+
/** Options for logging the customer out. */
|
|
79
|
+
interface LogoutOptions extends RequestOriginOptions {
|
|
67
80
|
/**
|
|
68
|
-
* URL to
|
|
69
|
-
* Resolved as an absolute same-origin URL. Defaults to `"/"`.
|
|
81
|
+
* The URL to send the customer to after logout. A relative URL resolves against the origin. Defaults to the origin, and a cross-origin URL falls back to the origin.
|
|
70
82
|
*/
|
|
71
83
|
postLogoutRedirectUri?: string;
|
|
72
|
-
}
|
|
84
|
+
}
|
|
73
85
|
/**
|
|
74
|
-
*
|
|
75
|
-
*
|
|
86
|
+
* Signs customers in and out with Shopify customer accounts, and gives your server their Customer Account API access tokens. Use the session on the server only.
|
|
87
|
+
*
|
|
88
|
+
* Pass your session storage and the request context to each method. Each method makes the final response private and uncacheable.
|
|
89
|
+
*
|
|
90
|
+
* @publicDocs
|
|
76
91
|
*/
|
|
77
92
|
type CustomerSession = {
|
|
78
93
|
/**
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
94
|
+
* Returns `true` when the customer has a usable access token or a refresh token. The method never refreshes tokens.
|
|
95
|
+
*
|
|
96
|
+
* Use the result for UI state, such as an account link. Gate Customer Account API data on an access token from `getOrRefreshAccessToken()`.
|
|
82
97
|
*/
|
|
83
98
|
isLoggedIn(sessionManager: ReadonlyCustomerSessionManager, requestContext: ShopifyRequestContext): Promise<boolean>;
|
|
84
99
|
/**
|
|
85
|
-
* Returns
|
|
86
|
-
* is missing or expired. Never refreshes and never writes session state.
|
|
100
|
+
* Returns the customer's stored access token, or `undefined` when the token is missing or expired. The method never refreshes the token or writes to the session. Call `getOrRefreshAccessToken()` to refresh an expired token.
|
|
87
101
|
*/
|
|
88
102
|
getAccessToken(sessionManager: ReadonlyCustomerSessionManager, requestContext: ShopifyRequestContext): Promise<string | undefined>;
|
|
89
103
|
/**
|
|
90
|
-
* Returns a usable access token,
|
|
91
|
-
*
|
|
92
|
-
* Returns `undefined` when no refresh token
|
|
93
|
-
* the refresh fails transiently (the session is preserved for retry). A
|
|
94
|
-
* 400/401 from the token endpoint clears stored tokens. Never throws for
|
|
95
|
-
* refresh failures. Concurrent refresh requests for the same origin+token
|
|
96
|
-
* combination are deduplicated per `createCustomerSession` instance. Use only
|
|
97
|
-
* where the eventual response commits the session manager.
|
|
104
|
+
* Returns a usable access token for the customer. When the stored token is missing or expired, the session gets new tokens from Shopify and writes them to your session storage. Call the method only where you commit the session to the response.
|
|
105
|
+
*
|
|
106
|
+
* Returns `undefined` when the customer has no refresh token, or when a temporary refresh failure keeps the session for a retry. When Shopify rejects the refresh token with a `400` or `401` status, the session clears the stored tokens and returns `undefined`. Refresh failures never throw.
|
|
98
107
|
*/
|
|
99
108
|
getOrRefreshAccessToken(sessionManager: WritableCustomerSessionManager, requestContext: ShopifyRequestContext, options?: RequestOriginOptions): Promise<string | undefined>;
|
|
100
109
|
/**
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
*
|
|
110
|
+
* Starts customer sign-in and returns the URL of Shopify's login page. Commit the session to the response, then redirect the customer to the URL.
|
|
111
|
+
*
|
|
112
|
+
* The customer has 10 minutes to finish signing in. After that, the OAuth callback fails with the `missing_pending_login` code.
|
|
104
113
|
*/
|
|
105
114
|
prepareLoginUrl(sessionManager: WritableCustomerSessionManager, requestContext: ShopifyRequestContext, options: PrepareLoginUrlOptions): Promise<string>;
|
|
106
115
|
/**
|
|
107
|
-
* Completes
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
* pending login state on failure.
|
|
116
|
+
* Completes sign-in from Shopify's OAuth callback request, saves the customer's tokens to your session storage, and returns the path to send the customer to. Commit the session to the response after the call.
|
|
117
|
+
*
|
|
118
|
+
* The method throws `CustomerAccountOAuthError` when sign-in fails a check, and `CustomerAccountApiError` when the token request times out. After a failure, the customer needs to start sign-in again.
|
|
111
119
|
*
|
|
112
|
-
* @throws {CustomerAccountOAuthError}
|
|
113
|
-
*
|
|
114
|
-
* `token_exchange_failed`, `invalid_token_response`, or id_token claim mismatches).
|
|
115
|
-
* @throws {CustomerAccountApiError} On token-request timeout.
|
|
120
|
+
* @throws {CustomerAccountOAuthError} When the callback parameters, pending login, token exchange, token response, or ID token claims fail validation.
|
|
121
|
+
* @throws {CustomerAccountApiError} When the token request times out.
|
|
116
122
|
*/
|
|
117
123
|
handleOAuthCallback(sessionManager: WritableCustomerSessionManager, requestContext: ShopifyRequestContext, request: Request): Promise<string>;
|
|
118
124
|
/**
|
|
119
|
-
* Clears session
|
|
120
|
-
*
|
|
121
|
-
*
|
|
122
|
-
* logout, no IdP round-trip).
|
|
125
|
+
* Clears the customer's session data and returns the URL to send the customer to. Commit the session to the response after the call.
|
|
126
|
+
*
|
|
127
|
+
* When the session has an ID token, the URL points to Shopify's logout endpoint with the post-logout URL attached. Without an ID token, the method returns the post-logout URL.
|
|
123
128
|
*/
|
|
124
129
|
logout(sessionManager: WritableCustomerSessionManager, requestContext: ShopifyRequestContext, options?: LogoutOptions): Promise<string>;
|
|
125
130
|
};
|
|
126
131
|
/**
|
|
127
|
-
*
|
|
128
|
-
* Register these with `handleShopifyRoutes` to serve the Customer Account OAuth flow.
|
|
132
|
+
* The login, authorize, refresh, and logout routes for customer accounts. Add the object to the `handlers` option of `handleShopifyRoutes`.
|
|
129
133
|
*/
|
|
130
134
|
type CustomerAccountServerHandlers<TContext extends CustomerAccountRouteHandlerContext = CustomerAccountRouteHandlerContext> = {
|
|
131
|
-
/**
|
|
132
|
-
login: CallableRouteHandler<TContext, CustomerAccountRouteResult, typeof CUSTOMER_ACCOUNT_LOGIN_PATH, "GET">;
|
|
133
|
-
|
|
135
|
+
/** Completes sign-in at `/account/authorize`, the OAuth callback, and redirects the customer to the return path. Accepts `GET`. */authorize: CallableRouteHandler<TContext, CustomerAccountRouteResult, typeof CUSTOMER_ACCOUNT_AUTHORIZE_PATH, "GET">; /** Starts sign-in at `/account/login` and redirects the customer to Shopify's login page. Accepts `GET`. Pass `return_to`, `locale`, `acr_values`, `login_hint`, and `login_hint_mode` as search params. The route sends the request context's country to Shopify. */
|
|
136
|
+
login: CallableRouteHandler<TContext, CustomerAccountRouteResult, typeof CUSTOMER_ACCOUNT_LOGIN_PATH, "GET">;
|
|
137
|
+
/**
|
|
138
|
+
* Logs the customer out at `/account/logout`. Accepts `POST`. For CSRF protection, the route returns a `403` response unless the `Origin` or `Referer` header matches your storefront's origin.
|
|
139
|
+
*
|
|
140
|
+
* Through `handleShopifyRoutes`, a GET request to the logout path returns a `405` response. Log out with a `<form method="post" action="/account/logout">` and a submit button, which works without JavaScript.
|
|
141
|
+
*/
|
|
142
|
+
logout: CallableRouteHandler<TContext, CustomerAccountRouteResult, typeof CUSTOMER_ACCOUNT_LOGOUT_PATH, "POST">; /** Refreshes the access token at `/account/refresh` and redirects the customer to the same-origin `return_to` path, which defaults to `/account`. Accepts `GET`. */
|
|
134
143
|
refresh: CallableRouteHandler<TContext, CustomerAccountRouteResult, typeof CUSTOMER_ACCOUNT_REFRESH_PATH, "GET">;
|
|
135
144
|
};
|
|
136
|
-
/**
|
|
145
|
+
/**
|
|
146
|
+
* Customer account routes that also keep the cart's buyer identity in step with the signed-in customer. These routes need `storefrontClient` in the handler context.
|
|
147
|
+
*/
|
|
137
148
|
type CustomerAccountServerHandlersWithCartSync = CustomerAccountServerHandlers<ShopifyRouteHandlerContext>;
|
|
149
|
+
/** A customer session that `createCustomerSession` returns. Cart buyer identity sync requires this session. */
|
|
138
150
|
type CustomerSessionWithInternals = CustomerSession & {
|
|
139
151
|
readonly [CUSTOMER_SESSION_INTERNAL_BRAND]: true;
|
|
140
152
|
};
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
defaultPostLoginRedirectPathname?: string; /**
|
|
144
|
-
loginFailedRedirectPath?: string; /**
|
|
145
|
-
origin?: string | ((request: Request) => string); /** URL to
|
|
153
|
+
/** Options for the customer account routes. */
|
|
154
|
+
type CreateCustomerAccountServerHandlersBaseOptions = {
|
|
155
|
+
/** The path to send the customer to after sign-in when the login request has no same-origin `return_to` search param. Defaults to `/`. */defaultPostLoginRedirectPathname?: string; /** The same-origin path to send the customer to when sign-in fails with `CustomerAccountOAuthError`. Defaults to `/account?login=failed`. A cross-origin value falls back to `/account`. The authorize route rethrows other errors. */
|
|
156
|
+
loginFailedRedirectPath?: string; /** Your storefront's HTTPS origin, or a function that returns the origin for a request. Defaults to the origin that the session manager returns. */
|
|
157
|
+
origin?: string | ((request: Request) => string); /** The URL to send the customer to after logout. Defaults to `/`. A same-origin `return_to` search param on the logout request overrides this value. */
|
|
146
158
|
postLogoutRedirectUri?: string;
|
|
147
159
|
};
|
|
148
|
-
/** Options for
|
|
149
|
-
|
|
160
|
+
/** Options for the customer account routes without cart buyer identity sync. */
|
|
161
|
+
interface CustomerAccountServerHandlersOptionsWithoutCart extends CreateCustomerAccountServerHandlersBaseOptions {
|
|
162
|
+
/** The customer session from `createCustomerSession`. */
|
|
163
|
+
customerSession: CustomerSession;
|
|
164
|
+
/**
|
|
165
|
+
* The cart server handlers that `createCartServerHandlers` returns with its `customerSession` option. Pass the cart handlers to keep the cart's buyer identity in step with the signed-in customer.
|
|
166
|
+
*
|
|
167
|
+
* The authorize and refresh routes attach the customer to the cart. The logout route, and a refresh that ends the session, detach the customer from the cart. When a sync fails, the route logs the error and still redirects. When a detach fails, the route also expires the `cart` cookie. The sync needs `storefrontClient` in the handler context.
|
|
168
|
+
*
|
|
169
|
+
* Creating the handlers throws when the cart handlers lack the `customerSession` option, or when the customer session doesn't come from `createCustomerSession`.
|
|
170
|
+
*/
|
|
150
171
|
cartServerHandlers?: undefined;
|
|
151
|
-
}
|
|
172
|
+
}
|
|
173
|
+
/** Options for the customer account routes that keep the cart's buyer identity in step with the signed-in customer. */
|
|
174
|
+
interface CustomerAccountServerHandlersOptionsWithCart extends CreateCustomerAccountServerHandlersBaseOptions {
|
|
175
|
+
/** The customer session from `createCustomerSession`. */
|
|
176
|
+
customerSession: CustomerSessionWithInternals;
|
|
152
177
|
/**
|
|
153
|
-
*
|
|
154
|
-
*
|
|
155
|
-
*
|
|
156
|
-
*
|
|
157
|
-
*
|
|
158
|
-
* expires the cart cookie instead.
|
|
178
|
+
* The cart server handlers that `createCartServerHandlers` returns with its `customerSession` option. Pass the cart handlers to keep the cart's buyer identity in step with the signed-in customer.
|
|
179
|
+
*
|
|
180
|
+
* The authorize and refresh routes attach the customer to the cart. The logout route, and a refresh that ends the session, detach the customer from the cart. When a sync fails, the route logs the error and still redirects. When a detach fails, the route also expires the `cart` cookie. The sync needs `storefrontClient` in the handler context.
|
|
181
|
+
*
|
|
182
|
+
* Creating the handlers throws when the cart handlers lack the `customerSession` option, or when the customer session doesn't come from `createCustomerSession`.
|
|
159
183
|
*/
|
|
160
184
|
cartServerHandlers: CartBuyerIdentitySyncSource;
|
|
161
|
-
}
|
|
185
|
+
}
|
|
186
|
+
/** Options for the customer account routes, with optional cart buyer identity sync. */
|
|
187
|
+
type CreateCustomerAccountServerHandlersOptions = CustomerAccountServerHandlersOptionsWithoutCart | CustomerAccountServerHandlersOptionsWithCart;
|
|
188
|
+
/** A redirect, or a `403` error when a logout request comes from another origin. */
|
|
162
189
|
type CustomerAccountRouteResult = ShopifyRouteRedirectResult | ShopifyRouteErrorResult;
|
|
163
190
|
type CustomerAccountRouteHandlerContext = {
|
|
164
191
|
request: Request;
|
|
@@ -169,10 +196,9 @@ type CustomerAccountServerHandlersForOptions<TOptions> = TOptions extends {
|
|
|
169
196
|
cartServerHandlers: CartBuyerIdentitySyncSource;
|
|
170
197
|
} ? CustomerAccountServerHandlersWithCartSync : CustomerAccountServerHandlers;
|
|
171
198
|
/**
|
|
172
|
-
* Creates a
|
|
173
|
-
*
|
|
174
|
-
*
|
|
175
|
-
* `customerAccountApiUrl` (HTTPS), and timeout at construction.
|
|
199
|
+
* Creates a customer session that signs customers in and out with Shopify customer accounts and manages their access tokens. Use the session on the server only.
|
|
200
|
+
*
|
|
201
|
+
* The function throws when the shop ID, client ID, API URL, or timeout is invalid, when no fetch implementation is available, and when the function runs in a browser.
|
|
176
202
|
*
|
|
177
203
|
* @example
|
|
178
204
|
* ```ts
|
|
@@ -184,7 +210,10 @@ type CustomerAccountServerHandlersForOptions<TOptions> = TOptions extends {
|
|
|
184
210
|
* });
|
|
185
211
|
* ```
|
|
186
212
|
*
|
|
187
|
-
* @
|
|
213
|
+
* @param options - The shop ID, the OAuth client ID, the authentication base URL, a custom fetch, and the token request timeout.
|
|
214
|
+
* @returns A customer session with methods for sign-in, the OAuth callback, access tokens, and logout.
|
|
215
|
+
* @throws {Error} When called in a browser, when an option fails validation, or when no fetch is available.
|
|
216
|
+
* @publicDocs
|
|
188
217
|
*/
|
|
189
218
|
declare function createCustomerSession({
|
|
190
219
|
shopId,
|
|
@@ -194,13 +223,14 @@ declare function createCustomerSession({
|
|
|
194
223
|
defaultTimeoutInMs
|
|
195
224
|
}: CreateCustomerSessionOptions): CustomerSessionWithInternals;
|
|
196
225
|
/**
|
|
197
|
-
* Creates
|
|
198
|
-
*
|
|
199
|
-
*
|
|
200
|
-
*
|
|
201
|
-
*
|
|
202
|
-
*
|
|
203
|
-
*
|
|
226
|
+
* Creates the customer account routes under `/account` for sign-in, the OAuth callback, token refresh, and logout. Add the returned object to the `handlers` option of `handleShopifyRoutes`.
|
|
227
|
+
*
|
|
228
|
+
* The login route redirects to Shopify's login page. The authorize and refresh routes redirect back to a same-origin path in your app. The logout route redirects to Shopify's logout endpoint when the session has an ID token, and to the post-logout URL otherwise. Each redirect commits the session and sends `cache-control: no-store`.
|
|
229
|
+
*
|
|
230
|
+
* Link to these paths with full-page navigation, such as a plain `<a>` link or a `<form>`. Client-side navigation components can't follow these redirects.
|
|
231
|
+
*
|
|
232
|
+
* @returns The login, authorize, refresh, and logout routes.
|
|
233
|
+
* @publicDocs
|
|
204
234
|
*/
|
|
205
235
|
declare function createCustomerAccountServerHandlers<const TOptions extends CreateCustomerAccountServerHandlersOptions>(options: TOptions): CustomerAccountServerHandlersForOptions<TOptions>;
|
|
206
236
|
//#endregion
|
|
@@ -7,13 +7,29 @@ import { CustomerAccountApiError, CustomerAccountOAuthError } from "./errors.mjs
|
|
|
7
7
|
|
|
8
8
|
//#region src/customer-account/session.ts
|
|
9
9
|
const log = getLogger("customer-account");
|
|
10
|
-
/**
|
|
10
|
+
/**
|
|
11
|
+
* OAuth callback route path: `"/account/authorize"`.
|
|
12
|
+
*
|
|
13
|
+
* @publicDocs
|
|
14
|
+
*/
|
|
11
15
|
const CUSTOMER_ACCOUNT_AUTHORIZE_PATH = CUSTOMER_ACCOUNT_PATHS.authorize;
|
|
12
|
-
/**
|
|
16
|
+
/**
|
|
17
|
+
* Login route path: `"/account/login"`.
|
|
18
|
+
*
|
|
19
|
+
* @publicDocs
|
|
20
|
+
*/
|
|
13
21
|
const CUSTOMER_ACCOUNT_LOGIN_PATH = CUSTOMER_ACCOUNT_PATHS.login;
|
|
14
|
-
/**
|
|
22
|
+
/**
|
|
23
|
+
* Logout route path: `"/account/logout"`.
|
|
24
|
+
*
|
|
25
|
+
* @publicDocs
|
|
26
|
+
*/
|
|
15
27
|
const CUSTOMER_ACCOUNT_LOGOUT_PATH = CUSTOMER_ACCOUNT_PATHS.logout;
|
|
16
|
-
/**
|
|
28
|
+
/**
|
|
29
|
+
* Token refresh route path: `"/account/refresh"`.
|
|
30
|
+
*
|
|
31
|
+
* @publicDocs
|
|
32
|
+
*/
|
|
17
33
|
const CUSTOMER_ACCOUNT_REFRESH_PATH = CUSTOMER_ACCOUNT_PATHS.refresh;
|
|
18
34
|
const CUSTOMER_ACCOUNT_SESSION_KEY = "customerAccount";
|
|
19
35
|
const DEFAULT_LOGIN_RETURN_TO_PATH = "/account";
|
|
@@ -28,7 +44,7 @@ const AUTHORIZATION_CODE_GRANT_TYPE = "authorization_code";
|
|
|
28
44
|
const REFRESH_TOKEN_GRANT_TYPE = "refresh_token";
|
|
29
45
|
const CUSTOMER_ACCOUNT_SCOPE = "openid email customer-account-api:full";
|
|
30
46
|
const CODE_CHALLENGE_METHOD = "S256";
|
|
31
|
-
const USER_AGENT = `Hydrogen 2026.10.0
|
|
47
|
+
const USER_AGENT = `Hydrogen 2026.10.0`;
|
|
32
48
|
const EXPIRY_BUFFER_IN_SECONDS = 120;
|
|
33
49
|
const PENDING_LOGIN_TTL_IN_MINUTES = 10;
|
|
34
50
|
const SECONDS_PER_MINUTE = 60;
|
|
@@ -43,10 +59,9 @@ const CUSTOMER_SESSION_MUTATION_PERSONALIZATION_REASON = "customer-session-mutat
|
|
|
43
59
|
const CUSTOMER_SESSION_INTERNAL_BRAND = Symbol("hydrogen.customerSessionInternal");
|
|
44
60
|
const customerSessionInternals = /* @__PURE__ */ new WeakMap();
|
|
45
61
|
/**
|
|
46
|
-
* Creates a
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
* `customerAccountApiUrl` (HTTPS), and timeout at construction.
|
|
62
|
+
* Creates a customer session that signs customers in and out with Shopify customer accounts and manages their access tokens. Use the session on the server only.
|
|
63
|
+
*
|
|
64
|
+
* The function throws when the shop ID, client ID, API URL, or timeout is invalid, when no fetch implementation is available, and when the function runs in a browser.
|
|
50
65
|
*
|
|
51
66
|
* @example
|
|
52
67
|
* ```ts
|
|
@@ -58,7 +73,10 @@ const customerSessionInternals = /* @__PURE__ */ new WeakMap();
|
|
|
58
73
|
* });
|
|
59
74
|
* ```
|
|
60
75
|
*
|
|
61
|
-
* @
|
|
76
|
+
* @param options - The shop ID, the OAuth client ID, the authentication base URL, a custom fetch, and the token request timeout.
|
|
77
|
+
* @returns A customer session with methods for sign-in, the OAuth callback, access tokens, and logout.
|
|
78
|
+
* @throws {Error} When called in a browser, when an option fails validation, or when no fetch is available.
|
|
79
|
+
* @publicDocs
|
|
62
80
|
*/
|
|
63
81
|
function createCustomerSession({ shopId, customerAccountApiClientId, customerAccountApiUrl, fetch: customFetch, defaultTimeoutInMs = DEFAULT_TIMEOUT_IN_MS }) {
|
|
64
82
|
if (typeof document !== "undefined") throw new Error("Customer Account OAuth sessions cannot be used in a browser context. Use this helper from server or edge routes only.");
|
|
@@ -209,6 +227,10 @@ function createCustomerSession({ shopId, customerAccountApiClientId, customerAcc
|
|
|
209
227
|
async function getCustomerSessionRefreshResult(customerSession, sessionManager, requestContext, options = {}) {
|
|
210
228
|
return customerSessionInternals.get(customerSession)?.getOrRefreshAccessToken(sessionManager, requestContext, options);
|
|
211
229
|
}
|
|
230
|
+
/**
|
|
231
|
+
* @param options The customer session, the redirect paths, and optional cart handlers for the account routes.
|
|
232
|
+
* @returns The login, authorize, refresh, and logout routes.
|
|
233
|
+
*/
|
|
212
234
|
function createCustomerAccountServerHandlers(options) {
|
|
213
235
|
const { customerSession, defaultPostLoginRedirectPathname = DEFAULT_POST_LOGIN_REDIRECT_PATHNAME, loginFailedRedirectPath = FAILED_LOGIN_PATH, postLogoutRedirectUri = DEFAULT_POST_LOGOUT_REDIRECT_URI } = options;
|
|
214
236
|
const { origin: originOption } = options;
|