@scayle/storefront-nuxt 7.46.1 → 7.48.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,23 @@
1
1
  # @scayle/storefront-nuxt
2
2
 
3
+ ## 7.48.0
4
+
5
+ ### Minor Changes
6
+
7
+ - We added support for Identity Provider (IDP), enhancing our authentication and identity management capabilities.
8
+
9
+ ### Patch Changes
10
+
11
+ - Fix runtime crash when using md5 for appKeys
12
+ - Updated dependencies
13
+ - @scayle/storefront-core@7.34.0
14
+
15
+ ## 7.47.0
16
+
17
+ ### Minor Changes
18
+
19
+ - Create a shared logger instance per-server instead of per-request
20
+
3
21
  ## 7.46.1
4
22
 
5
23
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- export { g as AdditionalShopConfig, A as AppKeys, f as AuthenticationConfig, B as BapiConfig, b as CacheConfig, k as CheckoutEvent, C as CheckoutShopConfig, M as ModuleOptions, O as OauthConfig, P as PublicShopConfig, e as RedirectsConfig, R as RedisConfig, a as SessionConfig, h as ShopConfig, i as ShopConfigIndexed, d as StorageConfig, c as StorageEntity, S as StorageProvider, j as StorefrontConfig } from './shared/storefront-nuxt.5af220a0.mjs';
1
+ export { g as AdditionalShopConfig, A as AppKeys, f as AuthenticationConfig, B as BapiConfig, b as CacheConfig, k as CheckoutEvent, C as CheckoutShopConfig, M as ModuleOptions, O as OauthConfig, P as PublicShopConfig, e as RedirectsConfig, R as RedisConfig, a as SessionConfig, h as ShopConfig, i as ShopConfigIndexed, d as StorageConfig, c as StorageEntity, S as StorageProvider, j as StorefrontConfig } from './shared/storefront-nuxt.8b6c06b3.mjs';
2
2
  export { rpcCall } from './rpc.mjs';
3
3
  export * from '@scayle/storefront-core';
4
4
  export { LogLevel } from '@scayle/storefront-core';
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { g as AdditionalShopConfig, A as AppKeys, f as AuthenticationConfig, B as BapiConfig, b as CacheConfig, k as CheckoutEvent, C as CheckoutShopConfig, M as ModuleOptions, O as OauthConfig, P as PublicShopConfig, e as RedirectsConfig, R as RedisConfig, a as SessionConfig, h as ShopConfig, i as ShopConfigIndexed, d as StorageConfig, c as StorageEntity, S as StorageProvider, j as StorefrontConfig } from './shared/storefront-nuxt.5af220a0.js';
1
+ export { g as AdditionalShopConfig, A as AppKeys, f as AuthenticationConfig, B as BapiConfig, b as CacheConfig, k as CheckoutEvent, C as CheckoutShopConfig, M as ModuleOptions, O as OauthConfig, P as PublicShopConfig, e as RedirectsConfig, R as RedisConfig, a as SessionConfig, h as ShopConfig, i as ShopConfigIndexed, d as StorageConfig, c as StorageEntity, S as StorageProvider, j as StorefrontConfig } from './shared/storefront-nuxt.8b6c06b3.js';
2
2
  export { rpcCall } from './rpc.js';
3
3
  export * from '@scayle/storefront-core';
4
4
  export { LogLevel } from '@scayle/storefront-core';
package/dist/module.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as _nuxt_schema from '@nuxt/schema';
2
- import { M as ModuleOptions } from './shared/storefront-nuxt.5af220a0.mjs';
3
- export { g as AdditionalShopConfig, A as AppKeys, f as AuthenticationConfig, B as BapiConfig, b as CacheConfig, k as CheckoutEvent, C as CheckoutShopConfig, O as OauthConfig, P as PublicShopConfig, e as RedirectsConfig, R as RedisConfig, a as SessionConfig, h as ShopConfig, i as ShopConfigIndexed, d as StorageConfig, c as StorageEntity, S as StorageProvider, j as StorefrontConfig } from './shared/storefront-nuxt.5af220a0.mjs';
2
+ import { M as ModuleOptions } from './shared/storefront-nuxt.8b6c06b3.mjs';
3
+ export { g as AdditionalShopConfig, A as AppKeys, f as AuthenticationConfig, B as BapiConfig, b as CacheConfig, k as CheckoutEvent, C as CheckoutShopConfig, O as OauthConfig, P as PublicShopConfig, e as RedirectsConfig, R as RedisConfig, a as SessionConfig, h as ShopConfig, i as ShopConfigIndexed, d as StorageConfig, c as StorageEntity, S as StorageProvider, j as StorefrontConfig } from './shared/storefront-nuxt.8b6c06b3.mjs';
4
4
  export { LogLevel } from '@scayle/storefront-core';
5
5
  import '@scayle/unstorage-compression-driver';
6
6
  import 'unstorage';
package/dist/module.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as _nuxt_schema from '@nuxt/schema';
2
- import { M as ModuleOptions } from './shared/storefront-nuxt.5af220a0.js';
3
- export { g as AdditionalShopConfig, A as AppKeys, f as AuthenticationConfig, B as BapiConfig, b as CacheConfig, k as CheckoutEvent, C as CheckoutShopConfig, O as OauthConfig, P as PublicShopConfig, e as RedirectsConfig, R as RedisConfig, a as SessionConfig, h as ShopConfig, i as ShopConfigIndexed, d as StorageConfig, c as StorageEntity, S as StorageProvider, j as StorefrontConfig } from './shared/storefront-nuxt.5af220a0.js';
2
+ import { M as ModuleOptions } from './shared/storefront-nuxt.8b6c06b3.js';
3
+ export { g as AdditionalShopConfig, A as AppKeys, f as AuthenticationConfig, B as BapiConfig, b as CacheConfig, k as CheckoutEvent, C as CheckoutShopConfig, O as OauthConfig, P as PublicShopConfig, e as RedirectsConfig, R as RedisConfig, a as SessionConfig, h as ShopConfig, i as ShopConfigIndexed, d as StorageConfig, c as StorageEntity, S as StorageProvider, j as StorefrontConfig } from './shared/storefront-nuxt.8b6c06b3.js';
4
4
  export { LogLevel } from '@scayle/storefront-core';
5
5
  import '@scayle/unstorage-compression-driver';
6
6
  import 'unstorage';
package/dist/module.json CHANGED
@@ -4,5 +4,5 @@
4
4
  "compatibility": {
5
5
  "nuxt": "^3.7.0"
6
6
  },
7
- "version": "7.46.0"
7
+ "version": "7.47.0"
8
8
  }
package/dist/module.mjs CHANGED
@@ -39,9 +39,10 @@ export default {
39
39
  ${usesCompression ? "compression" : ""}
40
40
  }`;
41
41
  }
42
+ const PACKAGE_NAME = "@scayle/storefront-nuxt";
42
43
  const module = defineNuxtModule({
43
44
  meta: {
44
- name: "@scayle/storefront-nuxt",
45
+ name: PACKAGE_NAME,
45
46
  configKey: "storefront",
46
47
  compatibility: {
47
48
  nuxt: "^3.7.0"
@@ -81,6 +82,11 @@ const module = defineNuxtModule({
81
82
  clientId: "",
82
83
  clientSecret: ""
83
84
  },
85
+ idp: {
86
+ enabled: false,
87
+ idpKeys: [],
88
+ idpRedirectURL: ""
89
+ },
84
90
  appKeys: {
85
91
  wishlistKey: "wishlist_{shopId}_{userId}",
86
92
  basketKey: "basket_{shopId}_{userId}",
@@ -104,7 +110,7 @@ const module = defineNuxtModule({
104
110
  config.optimizeDeps = config.optimizeDeps || {};
105
111
  config.optimizeDeps.include = config.optimizeDeps.include || [];
106
112
  config.optimizeDeps.include.push(
107
- "@scayle/storefront-nuxt",
113
+ PACKAGE_NAME,
108
114
  "@scayle/storefront-core",
109
115
  "@aboutyou/backbone",
110
116
  "slugify"
@@ -160,7 +166,7 @@ const module = defineNuxtModule({
160
166
  filename: "types/storefront-bootstrap.d.ts",
161
167
  getContents: () => `// Auto-generated
162
168
  import type { RuntimeConfig } from '@nuxt/schema'
163
- import type { RpcContext, Cache } from '@scayle/storefront-core'
169
+ import type { RpcContext, Cache, Log } from '@scayle/storefront-core'
164
170
  import type { PublicShopConfig } from '@scayle/storefront-nuxt';
165
171
  declare module 'h3' {
166
172
  interface H3EventContext {
@@ -168,6 +174,7 @@ const module = defineNuxtModule({
168
174
  $cache: Cache
169
175
  $currentShop: PublicShopConfig,
170
176
  $availableShops: PublicShopConfig[]
177
+ $log: Log
171
178
  }
172
179
  }
173
180
  declare module '@scayle/storefront-core' {
@@ -178,6 +185,7 @@ const module = defineNuxtModule({
178
185
  nuxt.hook("prepare:types", ({ references }) => {
179
186
  references.push({ path: template.dst });
180
187
  });
188
+ addServerPlugin(resolve("./runtime/nitro/plugins/nitroLogger"));
181
189
  addServerPlugin(
182
190
  resolve("./runtime/nitro/plugins/nitroRuntimeStorageConfig")
183
191
  );
@@ -198,6 +206,7 @@ const module = defineNuxtModule({
198
206
  "server/middleware/redirects",
199
207
  "server/middleware/cache",
200
208
  "server/utils/cacheStorage",
209
+ "nitro/plugins/nitroLogger",
201
210
  "nitro/plugins/nitroRuntimeStorageConfig",
202
211
  "nitro/plugins/nitroSetXPoweredByHeader"
203
212
  ];
@@ -231,6 +240,12 @@ const module = defineNuxtModule({
231
240
  addImportsDir(resolve("runtime/composables/storefront"));
232
241
  addImportsDir(resolve("runtime/composables/core"));
233
242
  addImportsDir(resolve("runtime/utils"));
243
+ nuxt.options.build.transpile = [
244
+ ...nuxt.options.build?.transpile || [],
245
+ PACKAGE_NAME,
246
+ "@scayle/storefront-core",
247
+ "crypto-js"
248
+ ];
234
249
  }
235
250
  });
236
251
 
package/dist/rpc.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { RpcMethodName, RpcMethodParameters, RpcMethodReturnType, RpcContext } from '@scayle/storefront-core';
2
2
  import { NuxtApp } from 'nuxt/app';
3
- import { P as PublicShopConfig } from './shared/storefront-nuxt.5af220a0.mjs';
3
+ import { P as PublicShopConfig } from './shared/storefront-nuxt.8b6c06b3.mjs';
4
4
  import '@scayle/unstorage-compression-driver';
5
5
  import 'unstorage';
6
6
 
package/dist/rpc.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { RpcMethodName, RpcMethodParameters, RpcMethodReturnType, RpcContext } from '@scayle/storefront-core';
2
2
  import { NuxtApp } from 'nuxt/app';
3
- import { P as PublicShopConfig } from './shared/storefront-nuxt.5af220a0.js';
3
+ import { P as PublicShopConfig } from './shared/storefront-nuxt.8b6c06b3.js';
4
4
  import '@scayle/unstorage-compression-driver';
5
5
  import 'unstorage';
6
6
 
package/dist/rpc.mjs CHANGED
@@ -8,7 +8,7 @@ const rpcCall = (nuxtApp, method, shop) => {
8
8
  payload: params
9
9
  },
10
10
  headers: {
11
- "x-shop-id": String(shop.shopId)
11
+ "x-shop-id": shop.shopId.toString()
12
12
  }
13
13
  });
14
14
  return data;
@@ -0,0 +1,12 @@
1
+ export declare const useIDP: () => Promise<{
2
+ data: import("vue").Ref<{
3
+ [k: string]: string;
4
+ }>;
5
+ fetching: import("vue").Ref<boolean>;
6
+ fetch: () => Promise<void>;
7
+ error: import("vue").Ref<import("nuxt/app").NuxtError | undefined>;
8
+ status: import("vue").Ref<import("../core/useRpc").Status>;
9
+ handleIDPLoginCallback: (params: string) => Promise<{
10
+ message: string;
11
+ }>;
12
+ }>;
@@ -0,0 +1,26 @@
1
+ import { useNuxtApp } from "nuxt/app";
2
+ import { useRpc } from "../core/useRpc.mjs";
3
+ import { rpcCall } from "./../../rpc/rpcCall.mjs";
4
+ import { useCurrentShop } from "./useCurrentShop.mjs";
5
+ import { toValue } from "#imports";
6
+ export const useIDP = async () => {
7
+ const nuxtApp = useNuxtApp();
8
+ const shop = useCurrentShop();
9
+ const { data, fetching, fetch, error, status } = await useRpc(
10
+ "getExternalIdpRedirect",
11
+ "getExternalIdpRedirect"
12
+ );
13
+ const handleIDPLoginCallback = rpcCall(
14
+ nuxtApp,
15
+ "handleIDPLoginCallback",
16
+ toValue(shop)
17
+ );
18
+ return {
19
+ data,
20
+ fetching,
21
+ fetch,
22
+ error,
23
+ status,
24
+ handleIDPLoginCallback
25
+ };
26
+ };
@@ -1,7 +1,7 @@
1
1
  import { useNuxtApp } from "nuxt/app";
2
2
  export function useLog(subSpace) {
3
3
  const log = useNuxtApp().$log;
4
- if (subSpace) {
4
+ if (subSpace && log) {
5
5
  return log.space(subSpace);
6
6
  }
7
7
  return log;
@@ -8,6 +8,7 @@ export const buildContext = async (context) => {
8
8
  const { $cache, $shopConfig, $storefront, $log, session, config } = context;
9
9
  const bapiConfig = $shopConfig.bapi ?? $storefront.bapi;
10
10
  const appKeys = $shopConfig.appKeys ?? $storefront.appKeys;
11
+ const idpConfig = $shopConfig.idp ?? $storefront.idp;
11
12
  return {
12
13
  cached: new Cached($cache, $log, "", $storefront.cache?.enabled ?? true).execute,
13
14
  bapiClient: initBapi({
@@ -45,6 +46,7 @@ export const buildContext = async (context) => {
45
46
  clientSecret: $storefront.oauth.clientSecret,
46
47
  apiHost: $storefront.oauth.apiHost
47
48
  },
49
+ idp: idpConfig,
48
50
  log: $log,
49
51
  get user() {
50
52
  return session.data?.user ?? void 0;
@@ -0,0 +1,8 @@
1
+ import type { Log } from '@scayle/storefront-core';
2
+ declare module 'h3' {
3
+ interface H3EventContext {
4
+ $log: Log;
5
+ }
6
+ }
7
+ declare const _default: any;
8
+ export default _default;
@@ -0,0 +1,15 @@
1
+ import { createConsola } from "consola";
2
+ import createLog from "../../createLog.mjs";
3
+ import { defineNitroPlugin, useRuntimeConfig } from "#imports";
4
+ export default defineNitroPlugin((nitroApp) => {
5
+ const config = useRuntimeConfig();
6
+ const log = createLog(
7
+ createConsola,
8
+ config.storefront.log.name,
9
+ config.storefront.log.level
10
+ );
11
+ log.info(`Logger instance created. Level: ${config.storefront.log.level}`);
12
+ nitroApp.hooks.hook("request", (event) => {
13
+ event.context.$log = log;
14
+ });
15
+ });
@@ -1,9 +1,10 @@
1
1
  import { defineNuxtPlugin } from "nuxt/app";
2
2
  export default defineNuxtPlugin((nuxtApp) => {
3
3
  if (!nuxtApp.ssrContext) {
4
+ console.log("ssrContext is missing. Could not create log");
4
5
  return;
5
6
  }
6
- const log = nuxtApp.ssrContext.event.context.$rpcContext.log;
7
+ const log = nuxtApp.ssrContext.event.context.$log;
7
8
  const coreLog = log.space("sfc");
8
9
  coreLog.debug("Attached server-side logger");
9
10
  return {
@@ -8,7 +8,7 @@ export const rpcCall = (nuxtApp, method, shop) => {
8
8
  payload: params
9
9
  },
10
10
  headers: {
11
- "x-shop-id": String(shop.shopId)
11
+ "x-shop-id": shop.shopId.toString()
12
12
  }
13
13
  });
14
14
  return data;
@@ -1,10 +1,8 @@
1
1
  import { defineEventHandler, getRequestURL } from "h3";
2
- import { createConsola } from "consola";
3
2
  import { createRemoteJWKSet, decodeJwt } from "jose";
4
3
  import { randomUUID } from "uncrypto";
5
4
  import { useSession } from "@scayle/h3-session";
6
5
  import { buildContext } from "../../context.mjs";
7
- import createLog from "../../createLog.mjs";
8
6
  import { useCacheStorage, useSessionStorage } from "../utils/cacheStorage.mjs";
9
7
  import {
10
8
  convertStoresToList,
@@ -42,7 +40,8 @@ async function handleOauth(event, storefrontConfig, log) {
42
40
  });
43
41
  await useOauth(event, JWKS);
44
42
  }
45
- async function bootstrap(event, log, url, $shopConfig, $storefrontConfig, apiBasePath, config) {
43
+ async function bootstrap(event, url, $shopConfig, $storefrontConfig, apiBasePath, config) {
44
+ const log = event.context.$log;
46
45
  const bootstrapLog = log.space("bootstrap");
47
46
  bootstrapLog.debug("Bootstrapping request: " + url.toString());
48
47
  const $cache = useCacheStorage(
@@ -130,15 +129,10 @@ export default defineEventHandler(async (event) => {
130
129
  }
131
130
  const $shopConfig = getShopConfig(event, config);
132
131
  const apiBasePath = ($storefrontConfig.shopSelector === "path" && $shopConfig.path ? `/${$shopConfig.path}` : "") + ($shopConfig.apiBasePath || $storefrontConfig.apiBasePath || "/api");
133
- const log = createLog(
134
- createConsola,
135
- $storefrontConfig.log.name,
136
- $storefrontConfig.log.level
137
- );
132
+ const log = event.context.$log;
138
133
  if (!event.context.$rpcContext) {
139
134
  await bootstrap(
140
135
  event,
141
- log,
142
136
  url,
143
137
  $shopConfig,
144
138
  $storefrontConfig,
@@ -1,4 +1,4 @@
1
- import { LogLevel, HashAlgorithm, WithParams, ShopUser } from '@scayle/storefront-core';
1
+ import { LogLevel, HashAlgorithm, IDPConfig, WithParams, ShopUser } from '@scayle/storefront-core';
2
2
  import { CompressionEncodings } from '@scayle/unstorage-compression-driver';
3
3
  import { BuiltinDriverName, BuiltinDriverOptions } from 'unstorage';
4
4
 
@@ -126,11 +126,13 @@ interface ShopConfig extends AdditionalShopConfig {
126
126
  bapi?: BapiConfig;
127
127
  appKeys?: AppKeys;
128
128
  storage?: StorageConfig;
129
+ idp?: IDPConfig;
129
130
  }
130
131
  type ShopConfigIndexed = Record<string, ShopConfig>;
131
132
  interface PublicShopConfig extends Pick<ShopConfig, 'shopId' | 'domain' | 'path' | 'locale' | 'currency' | 'currencyFractionDigits'> {
132
133
  checkout: Pick<CheckoutShopConfig, 'host'>;
133
134
  apiBasePath: string;
135
+ idp?: IDPConfig;
134
136
  }
135
137
  interface StorefrontConfig {
136
138
  session?: SessionConfig;
@@ -145,6 +147,7 @@ interface StorefrontConfig {
145
147
  cache?: CacheConfig;
146
148
  publicShopData?: (keyof AdditionalShopConfig)[];
147
149
  withParams?: WithParams;
150
+ idp?: IDPConfig;
148
151
  }
149
152
  type ModuleOptions = StorefrontConfig & {
150
153
  shopSelector: 'domain' | 'path';
@@ -1,4 +1,4 @@
1
- import { LogLevel, HashAlgorithm, WithParams, ShopUser } from '@scayle/storefront-core';
1
+ import { LogLevel, HashAlgorithm, IDPConfig, WithParams, ShopUser } from '@scayle/storefront-core';
2
2
  import { CompressionEncodings } from '@scayle/unstorage-compression-driver';
3
3
  import { BuiltinDriverName, BuiltinDriverOptions } from 'unstorage';
4
4
 
@@ -126,11 +126,13 @@ interface ShopConfig extends AdditionalShopConfig {
126
126
  bapi?: BapiConfig;
127
127
  appKeys?: AppKeys;
128
128
  storage?: StorageConfig;
129
+ idp?: IDPConfig;
129
130
  }
130
131
  type ShopConfigIndexed = Record<string, ShopConfig>;
131
132
  interface PublicShopConfig extends Pick<ShopConfig, 'shopId' | 'domain' | 'path' | 'locale' | 'currency' | 'currencyFractionDigits'> {
132
133
  checkout: Pick<CheckoutShopConfig, 'host'>;
133
134
  apiBasePath: string;
135
+ idp?: IDPConfig;
134
136
  }
135
137
  interface StorefrontConfig {
136
138
  session?: SessionConfig;
@@ -145,6 +147,7 @@ interface StorefrontConfig {
145
147
  cache?: CacheConfig;
146
148
  publicShopData?: (keyof AdditionalShopConfig)[];
147
149
  withParams?: WithParams;
150
+ idp?: IDPConfig;
148
151
  }
149
152
  type ModuleOptions = StorefrontConfig & {
150
153
  shopSelector: 'domain' | 'path';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@scayle/storefront-nuxt",
3
3
  "type": "module",
4
- "version": "7.46.1",
4
+ "version": "7.48.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.8.2",
64
64
  "@scayle/h3-session": "0.3.4",
65
- "@scayle/storefront-core": "7.33.0",
65
+ "@scayle/storefront-core": "7.34.0",
66
66
  "@scayle/unstorage-compression-driver": "0.1.1",
67
67
  "@vueuse/core": "10.7.0",
68
68
  "consola": "3.2.3",
@@ -93,7 +93,7 @@
93
93
  "prettier": "3.0.0",
94
94
  "publint": "0.2.6",
95
95
  "vitest": "1.1.0",
96
- "vue-tsc": "1.8.25"
96
+ "vue-tsc": "1.8.26"
97
97
  },
98
98
  "peerDependencies": {
99
99
  "nuxt": ">=3.8.1",