@merkaly/nuxt 0.7.0 → 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 +1 -0
- package/dist/module.json +1 -1
- package/dist/module.mjs +2 -1
- package/dist/runtime/components/input/InputAddress.d.vue.ts +1 -1
- package/dist/runtime/components/input/InputAddress.vue.d.ts +1 -1
- package/dist/runtime/plugins/api.global.js +10 -3
- package/dist/runtime/plugins/auth0.client.js +9 -5
- package/package.json +2 -2
package/dist/module.d.mts
CHANGED
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -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
|
-
|
|
8
|
-
|
|
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
|
-
|
|
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",
|
|
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.7.
|
|
3
|
+
"version": "0.7.1",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/merkaly-io/nuxt.git"
|
|
@@ -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.
|
|
63
|
+
"vue": "^3.5.38",
|
|
64
64
|
"vue-router": "^5.1.0",
|
|
65
65
|
"vue-select": "4.0.0-beta.6"
|
|
66
66
|
},
|