@scayle/storefront-nuxt 7.62.4 → 7.63.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/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # @scayle/storefront-nuxt
2
2
 
3
+ ## 7.63.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Add support for dynamically adding query parameters to the IDP redirect callback URLs to be read back when the user returns from the IDP.
8
+
9
+ ```ts
10
+ const { data: externalIDPRedirects } = await useIDP({
11
+ queryParams: { redirectTo: '/account' },
12
+ })
13
+ ```
14
+
15
+ Please note that `code` and `state` are not supported as these are used by the SCAYLE Authentication API.
16
+
17
+ ### Patch Changes
18
+
19
+ - Avoid querying for redirects on pages matching the `/__nuxt_error` pattern.
20
+ - Updated dependencies
21
+ - @scayle/storefront-core@7.48.0
22
+
3
23
  ## 7.62.4
4
24
 
5
25
  ### Patch Changes
@@ -650,8 +670,8 @@ There is an `unwrap` function exported by this package (>=7.55.0) that can be us
650
670
 
651
671
  ### Minor Changes
652
672
 
653
- - - Add promotion data to the `addItemToBasket` method
654
- - - Add `usePromotions`, `useCurrentPromotions` & `usePromotionsByIds` composables
673
+ - Add promotion data to the `addItemToBasket` method
674
+ - Add `usePromotions`, `useCurrentPromotions` & `usePromotionsByIds` composables
655
675
 
656
676
  ### Patch Changes
657
677
 
@@ -1150,8 +1170,8 @@ There is an `unwrap` function exported by this package (>=7.55.0) that can be us
1150
1170
 
1151
1171
  ### Minor Changes
1152
1172
 
1153
- - - Add possibility to define the session config on application and store level.
1154
- - Add possibility to configure the `domain` attribute of the session cookie
1173
+ - Add possibility to define the session config on application and store level.
1174
+ - Add possibility to configure the `domain` attribute of the session cookie
1155
1175
 
1156
1176
  ## 7.0.0
1157
1177
 
package/dist/module.json CHANGED
@@ -4,5 +4,5 @@
4
4
  "compatibility": {
5
5
  "nuxt": "^3.9.0"
6
6
  },
7
- "version": "7.62.3"
7
+ "version": "7.62.4"
8
8
  }
@@ -1,4 +1,4 @@
1
- declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<boolean | string[] | import("@scayle/storefront-core").ShopUser | import("@scayle/storefront-core").Product | import("@scayle/storefront-core").BasketResponseData<import("@scayle/storefront-core").Product, import("@scayle/storefront-core").Variant> | {
1
+ declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<boolean | void | string[] | import("@scayle/storefront-core").ShopUser | import("@scayle/storefront-core").Product | import("@scayle/storefront-core").BasketResponseData<import("@scayle/storefront-core").Product, import("@scayle/storefront-core").Variant> | {
2
2
  type: "failure";
3
3
  statusCode: number;
4
4
  basket: import("@scayle/storefront-core").BasketResponseData<import("@scayle/storefront-core").Product, import("@scayle/storefront-core").Variant>;
@@ -37,5 +37,5 @@ declare const _default: import("h3").EventHandler<import("h3").EventHandlerReque
37
37
  [k: string]: string;
38
38
  } | {
39
39
  message: string;
40
- } | null | undefined>>;
40
+ } | null>>;
41
41
  export default _default;
@@ -1,4 +1,6 @@
1
- export declare const useIDP: () => Promise<{
1
+ import { type MaybeRefOrGetter } from 'vue';
2
+ import type { RpcMethodParameters } from '@scayle/storefront-core';
3
+ export declare const useIDP: (params?: MaybeRefOrGetter<RpcMethodParameters<'getExternalIdpRedirect'>>) => Promise<{
2
4
  data: import("vue").Ref<{
3
5
  [k: string]: string;
4
6
  } | undefined>;
@@ -3,12 +3,13 @@ import { useRpc } from "../core/useRpc.mjs";
3
3
  import { rpcCall } from "./../../rpc/rpcCall.mjs";
4
4
  import { useCurrentShop } from "./useCurrentShop.mjs";
5
5
  import { toValue } from "#imports";
6
- export const useIDP = async () => {
6
+ export const useIDP = async (params = {}) => {
7
7
  const nuxtApp = useNuxtApp();
8
8
  const shop = useCurrentShop();
9
9
  const { data, fetching, fetch, error, status } = await useRpc(
10
10
  "getExternalIdpRedirect",
11
- "getExternalIdpRedirect"
11
+ `getExternalIdpRedirect-${JSON.stringify(toValue(params))}`,
12
+ params
12
13
  );
13
14
  const handleIDPLoginCallback = rpcCall(
14
15
  nuxtApp,
@@ -18,7 +18,7 @@ export declare function useBasket({ params, key, }?: UseBasketOptions): Promise<
18
18
  count: import("vue").ComputedRef<number | undefined>;
19
19
  countWithoutSoldOutItems: import("vue").ComputedRef<number | undefined>;
20
20
  addItem: ({ variantId, promotionId, quantity, existingItemHandling, displayData, customData, itemGroup, }: AddOrUpdateItemType & {
21
- existingItemHandling?: 0 | 1 | 2 | 3 | undefined;
21
+ existingItemHandling?: ExistingItemHandling;
22
22
  }) => Promise<void>;
23
23
  addItems: (items: AddOrUpdateItemType[], existingItemHandling?: 1) => Promise<void>;
24
24
  removeItem: (item: {
@@ -105,14 +105,12 @@ async function bootstrap(event, $shopConfig, $storefrontConfig, apiBasePath, con
105
105
  }
106
106
  function getBootstrapPath(event) {
107
107
  const url = getRequestURL(event);
108
- if (url.pathname === "/__nuxt_error") {
109
- return url.searchParams.get("url") ?? url.pathname;
110
- }
111
- return url.pathname;
108
+ const path = url.pathname === "/__nuxt_error" ? url.searchParams.get("url") ?? url.pathname : url.pathname;
109
+ return { path, originalPath: url.pathname };
112
110
  }
113
111
  export default defineEventHandler(async (event) => {
114
112
  try {
115
- const path = getBootstrapPath(event);
113
+ const { path, originalPath } = getBootstrapPath(event);
116
114
  if (path.startsWith("/__nuxt")) {
117
115
  return;
118
116
  }
@@ -133,7 +131,7 @@ export default defineEventHandler(async (event) => {
133
131
  config
134
132
  );
135
133
  }
136
- if ($storefrontConfig.redirects?.enabled && !path.startsWith(apiBasePath)) {
134
+ if ($storefrontConfig.redirects?.enabled && !path.startsWith(apiBasePath) && originalPath !== "/__nuxt_error") {
137
135
  await useRedirects(event);
138
136
  }
139
137
  } catch (e) {
@@ -18,7 +18,9 @@ async function fetchRedirectWithCache(sourceUrl, bapiClient, redirectCache, log)
18
18
  try {
19
19
  bapiResult = await bapiClient.redirects.post(sourceUrl);
20
20
  } catch (error) {
21
- log.error(`Error: Failed to fetch redirects ... ${error}`);
21
+ log.error(
22
+ `Error: Failed to fetch redirects ... ${error} for sourceURL: ${sourceUrl}`
23
+ );
22
24
  return null;
23
25
  }
24
26
  const isValidRedirect = (redirect) => {
@@ -67,17 +69,17 @@ export async function useRedirects(event) {
67
69
  log.info(`There are multiple valid redirects for: ${url.toString()}`);
68
70
  }
69
71
  const redirect = relativeRedirect ?? absoluteRedirect;
72
+ if (!redirect) {
73
+ log.debug(`There are no valid redirects for: ${url.toString()}`);
74
+ return;
75
+ }
70
76
  try {
71
- if (redirect?.target) {
72
- log.debug(`Redirecting to ${redirect.target}`);
73
- await sendRedirect(
74
- event,
75
- getTargetLocation(url, redirect.target, queryParamWhitelist),
76
- redirect.statusCode
77
- );
78
- } else {
79
- log.debug(`No redirect found`);
80
- }
77
+ log.debug(`Redirecting to ${redirect.target}`);
78
+ await sendRedirect(
79
+ event,
80
+ getTargetLocation(url, redirect.target, queryParamWhitelist),
81
+ redirect.statusCode
82
+ );
81
83
  } catch (error) {
82
84
  log.error(`Error: Failed to execute redirect ... ${error}`);
83
85
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@scayle/storefront-nuxt",
3
3
  "type": "module",
4
- "version": "7.62.4",
4
+ "version": "7.63.0",
5
5
  "description": "Nuxt integration for the SCAYLE Commerce Engine and Storefront API",
6
6
  "author": "SCAYLE Commerce Engine",
7
7
  "license": "MIT",
@@ -62,7 +62,7 @@
62
62
  "dependencies": {
63
63
  "@nuxt/kit": "3.11.1",
64
64
  "@scayle/h3-session": "0.3.5",
65
- "@scayle/storefront-core": "7.47.0",
65
+ "@scayle/storefront-core": "7.48.0",
66
66
  "@scayle/unstorage-compression-driver": "0.1.2",
67
67
  "@vueuse/core": "10.9.0",
68
68
  "consola": "3.2.3",
@@ -85,7 +85,7 @@
85
85
  "@scayle/eslint-config-storefront": "3.2.6",
86
86
  "@scayle/eslint-plugin-vue-composable": "0.1.1",
87
87
  "@scayle/prettier-config-storefront": "2.0.2",
88
- "@types/node": "20.12.3",
88
+ "@types/node": "20.12.5",
89
89
  "eslint": "8.57.0",
90
90
  "eslint-formatter-gitlab": "5.1.0",
91
91
  "h3": "1.11.1",
@@ -109,6 +109,6 @@
109
109
  "@nuxt/schema": "3.11.1"
110
110
  },
111
111
  "volta": {
112
- "node": "20.12.0"
112
+ "node": "20.12.1"
113
113
  }
114
114
  }