@frigear-nu/account 0.6.2 → 0.6.4

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.
Files changed (37) hide show
  1. package/dist/module.json +1 -1
  2. package/dist/module.mjs +16 -16
  3. package/dist/runtime/app/components/Account/AccountAvatarField.d.vue.ts +3 -0
  4. package/dist/runtime/app/components/Account/AccountAvatarField.vue +112 -0
  5. package/dist/runtime/app/components/Account/AccountAvatarField.vue.d.ts +3 -0
  6. package/dist/runtime/app/components/Account/AccountMenu.d.vue.ts +1 -1
  7. package/dist/runtime/app/components/Account/AccountMenu.vue +8 -10
  8. package/dist/runtime/app/components/Account/AccountMenu.vue.d.ts +1 -1
  9. package/dist/runtime/app/components/Account/AccountSignedInApps.vue +3 -1
  10. package/dist/runtime/app/composables/index.d.ts +2 -0
  11. package/dist/runtime/app/composables/index.js +1 -0
  12. package/dist/runtime/app/composables/useAccount.d.ts +6 -0
  13. package/dist/runtime/app/composables/useAccount.js +15 -1
  14. package/dist/runtime/app/composables/useAccountAreas.d.ts +21 -0
  15. package/dist/runtime/app/composables/useAccountAreas.js +12 -0
  16. package/dist/runtime/app/middleware/preload.js +6 -0
  17. package/dist/runtime/app/pages/api-tokens.vue +31 -28
  18. package/dist/runtime/app/pages/index.vue +9 -0
  19. package/dist/runtime/app/pages/profile.vue +122 -23
  20. package/dist/runtime/app/pages/security.vue +2 -1
  21. package/dist/runtime/app/plugins/preload.client.js +5 -0
  22. package/dist/runtime/app/utils/avatar-image.d.ts +34 -0
  23. package/dist/runtime/app/utils/avatar-image.js +61 -0
  24. package/dist/runtime/app/utils/mcp-connect.d.ts +27 -0
  25. package/dist/runtime/app/utils/mcp-connect.js +70 -0
  26. package/dist/runtime/app/utils/profile.d.ts +9 -3
  27. package/dist/runtime/app/utils/profile.js +3 -1
  28. package/dist/runtime/i18n/lang/da.json +72 -9
  29. package/dist/runtime/i18n/lang/en.json +71 -8
  30. package/dist/runtime/menus.js +1 -2
  31. package/dist/runtime/utils/areas.d.ts +7 -0
  32. package/dist/runtime/utils/areas.js +4 -0
  33. package/package.json +15 -11
  34. package/dist/runtime/app/middleware/bootstrap.js +0 -6
  35. package/dist/runtime/app/plugins/bootstrap.client.js +0 -5
  36. /package/dist/runtime/app/middleware/{bootstrap.d.ts → preload.d.ts} +0 -0
  37. /package/dist/runtime/app/plugins/{bootstrap.client.d.ts → preload.client.d.ts} +0 -0
package/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@frigear-nu/account",
3
3
  "configKey": "account",
4
- "version": "0.6.2",
4
+ "version": "0.6.4",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.4",
7
7
  "unbuild": "unknown"
package/dist/module.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { defineNuxtModule, createResolver, hasNuxtModule, addImports, addTypeTemplate, addRouteMiddleware, addPlugin, addComponentsDir } from '@nuxt/kit';
2
- import { registerModule, inlineModuleRuntime, registerTailwindSource, registerLocales, addOptionalImports, resolvePagePath, addModulePages, defineVirtualRegistry, getBootstrapProviders, addOptionalMenuSource } from '@frigear-nu/module-kit/utils';
2
+ import { registerModule, inlineModuleRuntime, registerTailwindSource, registerLocales, addOptionalImports, resolvePagePath, addModulePages, servePreloadArea, defineVirtualRegistry, getPreloadProviders, addOptionalMenuSource, serverModuleDependencies } from '@frigear-nu/module-kit/utils';
3
3
  import { localizedRoutePatterns, guardPages } from '@frigear-nu/auth/utils';
4
4
 
5
5
  function withAppMiddleware(existing, name) {
@@ -12,10 +12,8 @@ const module$1 = defineNuxtModule({
12
12
  defaults: {
13
13
  settings: { pages: {} }
14
14
  },
15
- moduleDependencies: {
16
- "@nuxthub/core": {
17
- version: ">=0.10"
18
- },
15
+ moduleDependencies: (nuxt) => ({
16
+ ...serverModuleDependencies(nuxt, { "@nuxthub/core": { version: ">=0.10" } }),
19
17
  "@frigear-nu/module-kit": {
20
18
  version: ">=0.0.1"
21
19
  },
@@ -30,12 +28,12 @@ const module$1 = defineNuxtModule({
30
28
  version: ">=0.0.1",
31
29
  optional: true
32
30
  },
33
- // The overview renders the `account.overview` widget area when it is installed.
31
+ // The overview renders the `account.overview` and `account.overview.end` widget areas when it is installed.
34
32
  "@frigear-nu/widget": {
35
33
  version: ">=0.0.0",
36
34
  optional: true
37
35
  }
38
- },
36
+ }),
39
37
  async setup(options, nuxt) {
40
38
  registerModule("@frigear-nu/account", nuxt);
41
39
  const resolver = createResolver(import.meta.url);
@@ -63,7 +61,8 @@ const module$1 = defineNuxtModule({
63
61
  }
64
62
  addImports([
65
63
  { name: "useAccount", from: resolver.resolve("./runtime/app/composables/useAccount") },
66
- { name: "useAccountNav", from: resolver.resolve("./runtime/app/composables/useAccountNav") }
64
+ { name: "useAccountNav", from: resolver.resolve("./runtime/app/composables/useAccountNav") },
65
+ { name: "useAccountAreas", from: resolver.resolve("./runtime/app/composables/useAccountAreas") }
67
66
  ]);
68
67
  const profilePath = resolvePagePath(settings.pages?.profile, "/account/profile");
69
68
  const securityPath = resolvePagePath(settings.pages?.security, "/account/security");
@@ -109,27 +108,28 @@ const module$1 = defineNuxtModule({
109
108
  } else {
110
109
  console.warn("[@frigear-nu/account] @frigear-nu/authorization is not installed: the account pages are not guarded. Install it and guard `/account/**` yourself.");
111
110
  }
111
+ servePreloadArea(nuxt, { area: "account" });
112
112
  defineVirtualRegistry(nuxt, {
113
- filename: "account/bootstrap.mjs",
114
- alias: "#account/bootstrap",
115
- collect: () => getBootstrapProviders(nuxt, "account").map((provider) => provider.key),
113
+ filename: "account/preload.mjs",
114
+ alias: "#account/preload",
115
+ collect: () => getPreloadProviders(nuxt, "account").map((provider) => provider.key),
116
116
  contents: (keys) => `export const keys = ${JSON.stringify(keys)}
117
117
  `
118
118
  });
119
119
  addTypeTemplate({
120
- filename: "types/account-bootstrap.d.ts",
121
- getContents: () => `declare module '#account/bootstrap' {
120
+ filename: "types/account-preload.d.ts",
121
+ getContents: () => `declare module '#account/preload' {
122
122
  export const keys: string[]
123
123
  }
124
124
  export {}
125
125
  `
126
126
  });
127
- addRouteMiddleware({ name: "account-bootstrap", path: resolver.resolve("./runtime/app/middleware/bootstrap") });
128
- addPlugin({ src: resolver.resolve("./runtime/app/plugins/bootstrap.client"), mode: "client" });
127
+ addRouteMiddleware({ name: "account-preload", path: resolver.resolve("./runtime/app/middleware/preload") });
128
+ addPlugin({ src: resolver.resolve("./runtime/app/plugins/preload.client"), mode: "client" });
129
129
  const areaRules = nuxt.options.routeRules ||= {};
130
130
  for (const pattern of areaPatterns) {
131
131
  const rule = areaRules[pattern] ?? {};
132
- areaRules[pattern] = { ...rule, appMiddleware: withAppMiddleware(rule.appMiddleware, "account-bootstrap") };
132
+ areaRules[pattern] = { ...rule, appMiddleware: withAppMiddleware(rule.appMiddleware, "account-preload") };
133
133
  }
134
134
  addOptionalMenuSource(nuxt, { file: resolver.resolve("./runtime/menus"), menu: "account" });
135
135
  addComponentsDir({
@@ -0,0 +1,3 @@
1
+ declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
2
+ declare const _default: typeof __VLS_export;
3
+ export default _default;
@@ -0,0 +1,112 @@
1
+ <script setup>
2
+ import { AVATAR_ACCEPT, AVATAR_MAX_SOURCE_BYTES, avatarUploadProblem, squareAvatar } from "../../utils/avatar-image";
3
+ import { computed, ref, useAccount, useAction, useConfirmDialog, useModuleT, useTemplateRef, useUserSession } from "#imports";
4
+ defineOptions({ name: "AccountAvatarField" });
5
+ const t = useModuleT("account.profile.avatar");
6
+ const { user } = useUserSession();
7
+ const { uploadAvatar, removeAvatar } = useAccount();
8
+ const confirm = useConfirmDialog();
9
+ const uploadAction = useAction();
10
+ const removeAction = useAction();
11
+ const fileInput = useTemplateRef("fileInput");
12
+ const dragging = ref(false);
13
+ const sessionUser = computed(() => user.value);
14
+ const avatar = computed(() => sessionUser.value?.avatar || void 0);
15
+ const name = computed(() => sessionUser.value?.name ?? "");
16
+ const busy = computed(() => uploadAction.busy.value || removeAction.busy.value);
17
+ function problemText(problem) {
18
+ return problem === "too_large" ? t("tooLarge", "The image is too large. Choose one under {size}.", { size: `${Math.round(AVATAR_MAX_SOURCE_BYTES / 1024 / 1024)} MB` }) : t("wrongType", "Choose an image, such as a PNG, JPEG or WebP file.");
19
+ }
20
+ async function save(file) {
21
+ await uploadAction.run(async () => {
22
+ try {
23
+ return await uploadAvatar(await squareAvatar(file));
24
+ } catch (error) {
25
+ const problem = avatarUploadProblem(error);
26
+ throw problem ? new Error(problemText(problem)) : error;
27
+ }
28
+ }, { success: t("saved", "Photo saved"), error: t("saveFailed", "Could not save your photo.") });
29
+ }
30
+ function onFile(event) {
31
+ const input = event.target;
32
+ const file = input.files?.[0];
33
+ input.value = "";
34
+ if (file) void save(file);
35
+ }
36
+ function onDrop(event) {
37
+ dragging.value = false;
38
+ const file = event.dataTransfer?.files?.[0];
39
+ if (file && !busy.value) void save(file);
40
+ }
41
+ async function onRemove() {
42
+ const confirmed = await confirm({
43
+ title: t("removeConfirm.title", "Remove your photo?"),
44
+ description: t("removeConfirm.description", "Your photo is removed for everyone. Your initials are shown instead."),
45
+ confirmText: t("remove", "Remove photo"),
46
+ destructive: true
47
+ });
48
+ if (!confirmed) return;
49
+ await removeAction.run(() => removeAvatar(), { success: t("removed", "Photo removed"), error: t("removeFailed", "Could not remove your photo.") });
50
+ }
51
+ </script>
52
+
53
+ <template>
54
+ <div class="flex flex-wrap items-center gap-4">
55
+ <div
56
+ class="relative rounded-full transition"
57
+ :class="dragging ? 'ring-2 ring-primary' : ''"
58
+ data-testid="account-avatar-drop"
59
+ @dragenter.prevent="dragging = true"
60
+ @dragover.prevent="dragging = true"
61
+ @dragleave.prevent="dragging = false"
62
+ @drop.prevent="onDrop"
63
+ >
64
+ <UAvatar
65
+ :src="avatar"
66
+ :alt="name"
67
+ size="3xl"
68
+ />
69
+ <div
70
+ v-if="busy"
71
+ class="absolute inset-0 flex items-center justify-center rounded-full bg-default/70"
72
+ >
73
+ <UIcon
74
+ name="i-lucide-loader-circle"
75
+ class="size-6 animate-spin text-muted"
76
+ />
77
+ </div>
78
+ </div>
79
+ <input
80
+ ref="fileInput"
81
+ type="file"
82
+ class="hidden"
83
+ :accept="AVATAR_ACCEPT"
84
+ data-testid="account-avatar-input"
85
+ @change="onFile"
86
+ >
87
+ <div class="flex flex-wrap gap-2">
88
+ <UButton
89
+ type="button"
90
+ icon="i-lucide-image-up"
91
+ color="neutral"
92
+ variant="outline"
93
+ :loading="uploadAction.busy.value"
94
+ :disabled="busy"
95
+ :label="avatar ? t('change', 'Change photo') : t('upload', 'Upload photo')"
96
+ @click="fileInput?.click()"
97
+ />
98
+ <TooltipButton
99
+ v-if="avatar"
100
+ type="button"
101
+ icon="i-lucide-trash-2"
102
+ color="neutral"
103
+ variant="outline"
104
+ :loading="removeAction.busy.value"
105
+ :disabled="busy"
106
+ :label="t('remove', 'Remove photo')"
107
+ :tooltip="t('removeHint', 'Your initials are shown instead, for everyone')"
108
+ @click="onRemove"
109
+ />
110
+ </div>
111
+ </div>
112
+ </template>
@@ -0,0 +1,3 @@
1
+ declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
2
+ declare const _default: typeof __VLS_export;
3
+ export default _default;
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * The signed-in user's menu: who is signed in, the `account.dropdown` menu (account, admin, sign out), and the
3
- * colour mode under Appearance. The entry for the area you are in is left out. `block` renders it as a full-width
3
+ * colour mode under Appearance. Every area stays listed, the one you are in highlighted (`useAccountAreas`). `block` renders it as a full-width
4
4
  * row for a sidebar footer (the admin shell), `collapsed` shrinks that row to the avatar.
5
5
  */
6
6
  type __VLS_Props = {
@@ -1,15 +1,15 @@
1
1
  <script setup>
2
- import { $fetch, computed, navigateTo, ref, useColorMode, useErrorToast, useLocaleLink, useModuleT, useRoute, useUserSession } from "#imports";
2
+ import { $fetch, computed, navigateTo, ref, useColorMode, useErrorToast, useLocaleLink, useModuleT, useUserSession } from "#imports";
3
3
  import { useMenu } from "#account/optional";
4
+ import { useAccountAreas } from "../../composables/useAccountAreas";
4
5
  const props = defineProps({
5
6
  block: { type: Boolean, required: false },
6
7
  collapsed: { type: Boolean, required: false }
7
8
  });
8
9
  const t = useModuleT("account");
9
10
  const { user } = useUserSession();
10
- const route = useRoute();
11
11
  const colorMode = useColorMode();
12
- const { localize, strip } = useLocaleLink();
12
+ const { localize } = useLocaleLink();
13
13
  const showError = useErrorToast();
14
14
  const dropdown = typeof useMenu === "function" ? useMenu("account.dropdown").data : ref([]);
15
15
  const sessionUser = computed(() => user.value);
@@ -17,11 +17,7 @@ const displayName = computed(() => sessionUser.value?.name || sessionUser.value?
17
17
  const avatar = computed(() => ({ src: sessionUser.value?.avatar || void 0, alt: displayName.value }));
18
18
  const role = computed(() => sessionUser.value?.role || void 0);
19
19
  const roleLabel = computed(() => role.value && role.value !== "user" ? role.value.charAt(0).toUpperCase() + role.value.slice(1) : void 0);
20
- const isHere = (to) => {
21
- const target = strip(to);
22
- const current = strip(route.path);
23
- return current === target || target !== "/" && current.startsWith(`${target}/`);
24
- };
20
+ const { current } = useAccountAreas();
25
21
  const runAction = async (item) => {
26
22
  try {
27
23
  await $fetch(item.to, { method: "POST" });
@@ -36,7 +32,9 @@ const toItem = (item) => item.method && item.to ? { label: item.label, icon: ite
36
32
  icon: item.icon,
37
33
  to: item.to && !item.external ? localize(item.to) : item.to,
38
34
  external: item.external,
39
- replace: item.external
35
+ replace: item.external,
36
+ // Still a link (from a sub-page it leads back to the area's start), highlighted.
37
+ ...item.id && item.id === current.value?.id ? { active: true } : {}
40
38
  };
41
39
  const appearance = (label, value, icon) => ({
42
40
  label,
@@ -48,7 +46,7 @@ const appearance = (label, value, icon) => ({
48
46
  }
49
47
  });
50
48
  const items = computed(() => {
51
- const visible = (dropdown.value ?? []).filter((item) => !item.to || item.external || item.method || !isHere(item.to));
49
+ const visible = dropdown.value ?? [];
52
50
  const last = (item) => (item.order ?? 0) >= 99;
53
51
  return [
54
52
  sessionUser.value ? [{ type: "label", label: displayName.value, slot: "account" }] : [],
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * The signed-in user's menu: who is signed in, the `account.dropdown` menu (account, admin, sign out), and the
3
- * colour mode under Appearance. The entry for the area you are in is left out. `block` renders it as a full-width
3
+ * colour mode under Appearance. Every area stays listed, the one you are in highlighted (`useAccountAreas`). `block` renders it as a full-width
4
4
  * row for a sidebar footer (the admin shell), `collapsed` shrinks that row to the avatar.
5
5
  */
6
6
  type __VLS_Props = {
@@ -57,6 +57,7 @@ const menu = (session) => [[
57
57
 
58
58
  <template>
59
59
  <SectionCard
60
+ id="signed-in-apps"
60
61
  :title="t('title', 'Signed-in apps')"
61
62
  :description="t('description', 'Apps you signed in to with your account. Signing out of an app ends its access on every device. Changing your password or email signs them all out.')"
62
63
  :loading="loading"
@@ -66,11 +67,12 @@ const menu = (session) => [[
66
67
  v-if="sessions.length"
67
68
  #actions
68
69
  >
69
- <UButton
70
+ <TooltipButton
70
71
  color="neutral"
71
72
  variant="outline"
72
73
  icon="i-lucide-log-out"
73
74
  :label="t('signOutAll', 'Sign out of all apps')"
75
+ :tooltip="t('signOutAllHint', 'Every app listed here has to ask you to sign in again')"
74
76
  @click="signOutAll"
75
77
  />
76
78
  </template>
@@ -1,3 +1,5 @@
1
1
  export { useAccount } from './useAccount.js';
2
2
  export { useAccountNav } from './useAccountNav.js';
3
3
  export type { AccountNavItem } from './useAccountNav.js';
4
+ export { useAccountAreas } from './useAccountAreas.js';
5
+ export type { AccountArea } from './useAccountAreas.js';
@@ -1,2 +1,3 @@
1
1
  export { useAccount } from "./useAccount.js";
2
2
  export { useAccountNav } from "./useAccountNav.js";
3
+ export { useAccountAreas } from "./useAccountAreas.js";
@@ -2,8 +2,12 @@ import type { ProfileDto } from '@frigear-nu/users/api';
2
2
  export declare const useAccount: () => {
3
3
  updateProfileDetails: (payload: {
4
4
  name?: string;
5
+ nickname?: string | null;
5
6
  avatar?: string | null;
6
7
  phone?: string | null;
8
+ peopleNumber?: string | null;
9
+ photoOptOut?: boolean;
10
+ tagOptOut?: boolean;
7
11
  locale?: string | null;
8
12
  }) => Promise<ProfileDto>;
9
13
  changeEmailAddress: (payload: {
@@ -16,6 +20,8 @@ export declare const useAccount: () => {
16
20
  newPassword: string;
17
21
  confirmNewPassword: string;
18
22
  }) => Promise<ProfileDto>;
23
+ uploadAvatar: (file: Blob) => Promise<ProfileDto>;
24
+ removeAvatar: () => Promise<unknown>;
19
25
  pending: import("vue").Ref<boolean, boolean>;
20
26
  error: import("vue").Ref<string | null, string | null>;
21
27
  };
@@ -35,5 +35,19 @@ export const useAccount = () => {
35
35
  "Failed to change your password."
36
36
  );
37
37
  }
38
- return { updateProfileDetails, changeEmailAddress, changePassword, pending, error };
38
+ function uploadAvatar(file) {
39
+ const body = new FormData();
40
+ body.append("file", file);
41
+ return withRequest(
42
+ () => $fetch(usersApi.me.avatar, { method: "PUT", body }),
43
+ "Failed to upload your photo."
44
+ );
45
+ }
46
+ function removeAvatar() {
47
+ return withRequest(
48
+ () => $fetch(usersApi.me.avatar, { method: "DELETE" }),
49
+ "Failed to remove your photo."
50
+ );
51
+ }
52
+ return { updateProfileDetails, changeEmailAddress, changePassword, uploadAvatar, removeAvatar, pending, error };
39
53
  };
@@ -0,0 +1,21 @@
1
+ /** A signed-in area (dashboard, account, admin, ...): a link entry of the `account.dropdown` menu. */
2
+ export interface AccountArea {
3
+ id: string;
4
+ label: string;
5
+ icon?: string;
6
+ /** Without the locale prefix: pass it through `useLocaleLink().localize` to link to it. */
7
+ to: string;
8
+ /** The route is in this area. */
9
+ active: boolean;
10
+ }
11
+ /**
12
+ * The signed-in areas the user can switch between: the link entries of the `account.dropdown` menu (actions such as
13
+ * sign out and external links are left out), with `active` on the area the route is in. Entries with a `permission`
14
+ * the user lacks are already dropped by the menu. Empty without `@frigear-nu/menu`.
15
+ */
16
+ export declare function useAccountAreas(): {
17
+ areas: import("vue").ComputedRef<AccountArea[]>;
18
+ current: import("vue").ComputedRef<{
19
+ to: string;
20
+ } | undefined>;
21
+ };
@@ -0,0 +1,12 @@
1
+ import { computed, ref, useLocaleLink, useRoute } from "#imports";
2
+ import { useMenu } from "#account/optional";
3
+ import { matchArea } from "../../utils/areas.js";
4
+ export function useAccountAreas() {
5
+ const route = useRoute();
6
+ const { strip } = useLocaleLink();
7
+ const dropdown = typeof useMenu === "function" ? useMenu("account.dropdown").data : ref([]);
8
+ const links = computed(() => (dropdown.value ?? []).filter((item) => !!item.to && !item.method && !item.external).map((item) => ({ id: item.id ?? item.to, label: item.label, icon: item.icon, to: strip(item.to) })));
9
+ const current = computed(() => matchArea(links.value, strip(route.path)));
10
+ const areas = computed(() => links.value.map((area) => ({ ...area, active: area.id === current.value?.id })));
11
+ return { areas, current };
12
+ }
@@ -0,0 +1,6 @@
1
+ import { keys } from "#account/preload";
2
+ import { defineNuxtRouteMiddleware, loadPreload } from "#imports";
3
+ export default defineNuxtRouteMiddleware(async () => {
4
+ if (!keys.length) return;
5
+ await loadPreload("account");
6
+ });
@@ -1,7 +1,8 @@
1
1
  <script setup>
2
2
  import { authApi } from "@frigear-nu/auth/api";
3
3
  import AccountApiTokenSlideover from "../components/Account/AccountApiTokenSlideover.vue";
4
- import { $fetch, computed, ref, tableUi, useCachedFetch, useConfirmDialog, useCopyToClipboard, useErrorToast, useFormat, useModuleT, useOverlay, useRequestURL, useRuntimeConfig, useToast } from "#imports";
4
+ import { mcpConnectTabs } from "../utils/mcp-connect";
5
+ import { $fetch, computed, ref, tableUi, useCachedFetch, useConfirmDialog, useCopyToClipboard, useErrorToast, useFormat, useLocaleLink, useModuleT, useOverlay, useRequestURL, useRuntimeConfig, useToast } from "#imports";
5
6
  defineOptions({ name: "AccountApiTokensPage" });
6
7
  const t = useModuleT("account.apiTokens");
7
8
  const toast = useToast();
@@ -48,29 +49,18 @@ const columns = computed(() => [
48
49
  { id: "actions", meta: { class: { td: "w-px text-right" } } }
49
50
  ]);
50
51
  const tokenStatusColors = { ok: "success", expired: "warning" };
51
- const mcpEnabled = useRuntimeConfig().public.users?.mcp === true;
52
- const activeConnect = ref("claude");
53
- const mcpUrl = `${useRequestURL().origin}/mcp`;
52
+ const publicConfig = useRuntimeConfig().public;
53
+ const mcpConfig = publicConfig.mcpModules;
54
+ const mcpEnabled = publicConfig.users?.mcp === true;
55
+ const mcpOAuth = mcpConfig?.oauth === true;
56
+ const mcpUrl = `${useRequestURL().origin}${mcpConfig?.route || "/mcp"}`;
57
+ const { localize } = useLocaleLink();
58
+ const securityPath = publicConfig.account?.pages?.security;
59
+ const signedInAppsLink = mcpOAuth && publicConfig.account?.signedInApps && securityPath ? `${localize(securityPath)}#signed-in-apps` : void 0;
54
60
  const tokenPlaceholder = "<your-api-token>";
55
61
  const shownToken = computed(() => revealed.value?.token ?? tokenPlaceholder);
56
- const connectTabs = computed(() => [
57
- {
58
- label: "Claude",
59
- value: "claude",
60
- steps: t("connect.claude.steps", "Claude.ai and Claude Desktop: open Settings \u2192 Connectors \u2192 Add custom connector, paste the URL below and sign in when asked. No token needed."),
61
- code: mcpUrl,
62
- extraSteps: t("connect.claude.cli", "Claude Code (uses an API token):"),
63
- extraCode: `claude mcp add --transport http frigear ${mcpUrl} --header "Authorization: Bearer ${shownToken.value}"`
64
- },
65
- {
66
- label: "ChatGPT",
67
- value: "chatgpt",
68
- steps: t("connect.chatgpt.steps", "ChatGPT: open Settings \u2192 Connectors \u2192 Advanced, turn on Developer mode, then create a connector with the URL below. Choose OAuth and sign in when asked. No token needed."),
69
- code: mcpUrl,
70
- extraSteps: void 0,
71
- extraCode: void 0
72
- }
73
- ]);
62
+ const connectTabs = computed(() => mcpConnectTabs({ url: mcpUrl, oauth: mcpOAuth, token: shownToken.value, t }));
63
+ const activeConnect = ref(connectTabs.value[0]?.value ?? "");
74
64
  const activeTab = computed(() => connectTabs.value.find((tab) => tab.value === activeConnect.value) ?? connectTabs.value[0]);
75
65
  </script>
76
66
 
@@ -78,9 +68,10 @@ const activeTab = computed(() => connectTabs.value.find((tab) => tab.value === a
78
68
  <div class="flex flex-col gap-4">
79
69
  <AccountHeader>
80
70
  <template #actions>
81
- <UButton
71
+ <TooltipButton
82
72
  icon="i-lucide-plus"
83
73
  :label="t('create.submit', 'Create API token')"
74
+ :tooltip="t('create.submitHint', 'Make a token for scripts and tools; it is shown only once')"
84
75
  @click="onCreate"
85
76
  />
86
77
  </template>
@@ -189,7 +180,7 @@ const activeTab = computed(() => connectTabs.value.find((tab) => tab.value === a
189
180
  <SectionCard
190
181
  v-if="mcpEnabled"
191
182
  :title="t('connect.title', 'Connect to MCP')"
192
- :description="t('connect.description', 'Use your account from an AI assistant. Your API token is only filled into the commands right after you create it.')"
183
+ :description="mcpOAuth ? t('connect.descriptionOAuth', 'Use your account from an AI assistant: add the URL in the app, then sign in. An API token is only needed for clients that cannot sign in, and is filled into the commands right after you create it.') : t('connect.description', 'Use your account from an AI assistant. Your API token is only filled into the commands right after you create it.')"
193
184
  >
194
185
  <div class="flex min-w-0 flex-col gap-3">
195
186
  <PageTabs
@@ -202,13 +193,13 @@ const activeTab = computed(() => connectTabs.value.find((tab) => tab.value === a
202
193
  </p>
203
194
  <div class="relative min-w-0">
204
195
  <pre class="max-w-full whitespace-pre-wrap break-all rounded-md bg-elevated p-3 pr-12 text-sm"><code>{{ activeTab.code }}</code></pre>
205
- <UButton
196
+ <TooltipButton
206
197
  class="absolute right-2 top-2"
207
198
  color="neutral"
208
199
  variant="ghost"
209
200
  size="xs"
210
201
  icon="i-lucide-copy"
211
- :aria-label="t('copySnippet', 'Copy command')"
202
+ :tooltip="t('copySnippetHint', 'Copy this command to your clipboard')"
212
203
  @click="copy(activeTab.code, t('copiedSnippet', 'Copied.'))"
213
204
  />
214
205
  </div>
@@ -218,18 +209,30 @@ const activeTab = computed(() => connectTabs.value.find((tab) => tab.value === a
218
209
  </p>
219
210
  <div class="relative min-w-0">
220
211
  <pre class="max-w-full whitespace-pre-wrap break-all rounded-md bg-elevated p-3 pr-12 text-sm"><code>{{ activeTab.extraCode }}</code></pre>
221
- <UButton
212
+ <TooltipButton
222
213
  class="absolute right-2 top-2"
223
214
  color="neutral"
224
215
  variant="ghost"
225
216
  size="xs"
226
217
  icon="i-lucide-copy"
227
- :aria-label="t('copySnippet', 'Copy command')"
218
+ :tooltip="t('copySnippetHint', 'Copy this command to your clipboard')"
228
219
  @click="copy(activeTab.extraCode, t('copiedSnippet', 'Copied.'))"
229
220
  />
230
221
  </div>
231
222
  </template>
232
223
  </template>
224
+ <p
225
+ v-if="signedInAppsLink"
226
+ class="text-sm text-muted"
227
+ >
228
+ {{ t("connect.signedInApps", "Apps you connect by signing in are listed under Signed-in apps on the Security page, where you can sign them out.") }}
229
+ <ULink
230
+ :to="signedInAppsLink"
231
+ class="text-primary"
232
+ >
233
+ {{ t("connect.signedInAppsLink", "Open signed-in apps") }}
234
+ </ULink>
235
+ </p>
233
236
  </div>
234
237
  </SectionCard>
235
238
  </div>
@@ -74,5 +74,14 @@ const profile = computed(() => {
74
74
  </NuxtLink>
75
75
  </li>
76
76
  </ListCard>
77
+
78
+ <!-- Last on the page, below the links: e.g. an app's sign-out. -->
79
+ <component
80
+ :is="widgetArea"
81
+ v-if="widgetArea"
82
+ name="account.overview.end"
83
+ :context="{ user }"
84
+ grid-class="grid gap-4"
85
+ />
77
86
  </div>
78
87
  </template>