@merkaly/nuxt 0.6.7 → 0.7.1

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/module.d.mts CHANGED
@@ -22,6 +22,7 @@ interface MerkalyModuleOptions {
22
22
  logoutUrl?: string;
23
23
  params?: Omit<ClientAuthorizationParams, 'redirect_uri'>;
24
24
  requiresAuth: boolean;
25
+ requiresTenant: boolean;
25
26
  };
26
27
  i18n?: {
27
28
  defaultLocale: string;
package/dist/module.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "compatibility": {
5
5
  "nuxt": ">=3.14.0"
6
6
  },
7
- "version": "0.6.7",
7
+ "version": "0.7.1",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "1.0.2",
10
10
  "unbuild": "3.6.1"
package/dist/module.mjs CHANGED
@@ -22,7 +22,8 @@ const defaultOptions = {
22
22
  domain: "",
23
23
  logoutUrl: "/",
24
24
  params: {},
25
- requiresAuth: false
25
+ requiresAuth: false,
26
+ requiresTenant: false
26
27
  },
27
28
  i18n: {
28
29
  defaultLocale: "en-US",
@@ -81,8 +81,8 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
81
81
  }>, {
82
82
  mode: PlaceTypes;
83
83
  disabled: boolean;
84
- placeholder: string;
85
84
  countries: string[];
85
+ placeholder: string;
86
86
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
87
87
  declare const _default: typeof __VLS_export;
88
88
  export default _default;
@@ -81,8 +81,8 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
81
81
  }>, {
82
82
  mode: PlaceTypes;
83
83
  disabled: boolean;
84
- placeholder: string;
85
84
  countries: string[];
85
+ placeholder: string;
86
86
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
87
87
  declare const _default: typeof __VLS_export;
88
88
  export default _default;
@@ -1,11 +1,18 @@
1
- import { defineNuxtPlugin } from "#app";
1
+ import { defineNuxtPlugin, useRuntimeConfig } from "#app";
2
2
  import { useAuth, useTenant } from "#imports";
3
3
  const GLOBAL_API_HEADER = "x-merkaly-global";
4
4
  export default defineNuxtPlugin(({ provide }) => provide("api", async (url, options = {}) => {
5
5
  const { token } = useAuth();
6
6
  const { tenant } = useTenant();
7
- if (!tenant.value && !options.global) {
8
- throw new Error(`Missing tenant context for: ${url}`);
7
+ const { public: { merkaly } } = useRuntimeConfig();
8
+ if (!tenant.value && !options.global && merkaly.auth0.requiresTenant) {
9
+ throw new Error(
10
+ `[api] Tenant context is required but not set for: ${url}
11
+ This surface has requiresTenant: true. Possible causes:
12
+ 1. The request fired before the auth boot sequence completed (race condition).
13
+ 2. setTenant() was never called in this surface's auth plugin.
14
+ 3. The adapter should use { global: true } to bypass tenant enforcement.`
15
+ );
9
16
  }
10
17
  await $fetch(url, {
11
18
  baseURL: "/api",
@@ -16,7 +16,14 @@ export default defineNuxtPlugin(async ({ callHook, hook }) => {
16
16
  const self0 = Object.assign(Object.create(Object.getPrototypeOf(auth0)), auth0);
17
17
  auth0.getUser = () => self0.getUser().then((result) => user.value = result).catch((reason) => console.error("[Auth0] getUser failed", reason));
18
18
  auth0.getTokenSilently = (options = {}) => self0.getTokenSilently(defu({ authorizationParams: { audience: $config.merkaly.auth0.audience } }, options)).then((result) => token.value = result).catch((err) => console.warn("[Auth0] getTokenSilently failed \u2013 fallback, user logged in?", err));
19
- auth0.handleRedirectCallback = () => self0.handleRedirectCallback().then(({ appState }) => Promise.allSettled([auth0.getUser(), auth0.getTokenSilently()]).then(() => void navigateTo(appState?.target || "/"))).catch(() => navigateTo("/"));
19
+ const initTenantContext = async () => {
20
+ await callHook("merkaly:tenant", user.value);
21
+ await callHook("merkaly:auth", user.value);
22
+ };
23
+ auth0.handleRedirectCallback = () => self0.handleRedirectCallback().then(({ appState }) => Promise.allSettled([auth0.getUser(), auth0.getTokenSilently()]).then(async () => {
24
+ await initTenantContext();
25
+ void navigateTo(appState?.target || "/");
26
+ })).catch(() => navigateTo("/"));
20
27
  auth0.loginWithRedirect = (options = {}) => self0.loginWithRedirect(defu(options, {
21
28
  authorizationParams: {
22
29
  audience: $config.merkaly.auth0.audience,
@@ -54,10 +61,7 @@ export default defineNuxtPlugin(async ({ callHook, hook }) => {
54
61
  };
55
62
  const isAuthCallback = window.location.pathname === callbackPath;
56
63
  if (!isAuthCallback) {
57
- await Promise.allSettled([auth0.getUser(), auth0.getTokenSilently()]).then(() => hook("app:created", async () => {
58
- await callHook("merkaly:tenant", user.value);
59
- await callHook("merkaly:auth", user.value);
60
- })).catch(() => void 0);
64
+ await Promise.allSettled([auth0.getUser(), auth0.getTokenSilently()]).then(() => hook("app:created", initTenantContext)).catch(() => void 0);
61
65
  }
62
66
  isLoading.value = false;
63
67
  return { provide: { auth0 } };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@merkaly/nuxt",
3
- "version": "0.6.7",
3
+ "version": "0.7.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/merkaly-io/nuxt.git"
@@ -31,8 +31,8 @@
31
31
  "@auth0/auth0-spa-js": "^2.21.1",
32
32
  "@bootstrap-vue-next/nuxt": "^0.45.5",
33
33
  "@nuxt/devtools": "^3.2.4",
34
- "@nuxt/eslint": "1.15.1",
35
- "@nuxt/eslint-config": "^1.15.2",
34
+ "@nuxt/eslint": "1.16.0",
35
+ "@nuxt/eslint-config": "^1.16.0",
36
36
  "@nuxt/fonts": "0.14.0",
37
37
  "@nuxt/image": "^2.0.0",
38
38
  "@nuxt/kit": "^4.4.8",
@@ -50,7 +50,7 @@
50
50
  "change-case": "^5.4.4",
51
51
  "class-transformer": "^0.5.1",
52
52
  "class-validator": "^0.15.1",
53
- "eslint": "^9.39.4",
53
+ "eslint": "^10.4.1",
54
54
  "filesize": "^11.0.17",
55
55
  "gsap": "^3.15.0",
56
56
  "notivue": "^2.4.5",
@@ -60,7 +60,7 @@
60
60
  "typescript": "~5.9.3",
61
61
  "v-money3": "^3.26.1",
62
62
  "vite-svg-loader": "^5.1.1",
63
- "vue": "^3.5.35",
63
+ "vue": "^3.5.38",
64
64
  "vue-router": "^5.1.0",
65
65
  "vue-select": "4.0.0-beta.6"
66
66
  },