@frigear-nu/account 0.6.3 → 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 (36) hide show
  1. package/dist/module.json +1 -1
  2. package/dist/module.mjs +12 -10
  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 +2 -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/profile.vue +36 -14
  19. package/dist/runtime/app/pages/security.vue +2 -1
  20. package/dist/runtime/app/plugins/preload.client.js +5 -0
  21. package/dist/runtime/app/utils/avatar-image.d.ts +34 -0
  22. package/dist/runtime/app/utils/avatar-image.js +61 -0
  23. package/dist/runtime/app/utils/mcp-connect.d.ts +27 -0
  24. package/dist/runtime/app/utils/mcp-connect.js +70 -0
  25. package/dist/runtime/app/utils/profile.d.ts +5 -4
  26. package/dist/runtime/app/utils/profile.js +1 -1
  27. package/dist/runtime/i18n/lang/da.json +48 -9
  28. package/dist/runtime/i18n/lang/en.json +47 -8
  29. package/dist/runtime/menus.js +1 -2
  30. package/dist/runtime/utils/areas.d.ts +7 -0
  31. package/dist/runtime/utils/areas.js +4 -0
  32. package/package.json +15 -11
  33. package/dist/runtime/app/middleware/bootstrap.js +0 -6
  34. package/dist/runtime/app/plugins/bootstrap.client.js +0 -5
  35. /package/dist/runtime/app/middleware/{bootstrap.d.ts → preload.d.ts} +0 -0
  36. /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.3",
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, serverModuleDependencies } 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) {
@@ -61,7 +61,8 @@ const module$1 = defineNuxtModule({
61
61
  }
62
62
  addImports([
63
63
  { name: "useAccount", from: resolver.resolve("./runtime/app/composables/useAccount") },
64
- { 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") }
65
66
  ]);
66
67
  const profilePath = resolvePagePath(settings.pages?.profile, "/account/profile");
67
68
  const securityPath = resolvePagePath(settings.pages?.security, "/account/security");
@@ -107,27 +108,28 @@ const module$1 = defineNuxtModule({
107
108
  } else {
108
109
  console.warn("[@frigear-nu/account] @frigear-nu/authorization is not installed: the account pages are not guarded. Install it and guard `/account/**` yourself.");
109
110
  }
111
+ servePreloadArea(nuxt, { area: "account" });
110
112
  defineVirtualRegistry(nuxt, {
111
- filename: "account/bootstrap.mjs",
112
- alias: "#account/bootstrap",
113
- 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),
114
116
  contents: (keys) => `export const keys = ${JSON.stringify(keys)}
115
117
  `
116
118
  });
117
119
  addTypeTemplate({
118
- filename: "types/account-bootstrap.d.ts",
119
- getContents: () => `declare module '#account/bootstrap' {
120
+ filename: "types/account-preload.d.ts",
121
+ getContents: () => `declare module '#account/preload' {
120
122
  export const keys: string[]
121
123
  }
122
124
  export {}
123
125
  `
124
126
  });
125
- addRouteMiddleware({ name: "account-bootstrap", path: resolver.resolve("./runtime/app/middleware/bootstrap") });
126
- 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" });
127
129
  const areaRules = nuxt.options.routeRules ||= {};
128
130
  for (const pattern of areaPatterns) {
129
131
  const rule = areaRules[pattern] ?? {};
130
- areaRules[pattern] = { ...rule, appMiddleware: withAppMiddleware(rule.appMiddleware, "account-bootstrap") };
132
+ areaRules[pattern] = { ...rule, appMiddleware: withAppMiddleware(rule.appMiddleware, "account-preload") };
131
133
  }
132
134
  addOptionalMenuSource(nuxt, { file: resolver.resolve("./runtime/menus"), menu: "account" });
133
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";
@@ -20,6 +20,8 @@ export declare const useAccount: () => {
20
20
  newPassword: string;
21
21
  confirmNewPassword: string;
22
22
  }) => Promise<ProfileDto>;
23
+ uploadAvatar: (file: Blob) => Promise<ProfileDto>;
24
+ removeAvatar: () => Promise<unknown>;
23
25
  pending: import("vue").Ref<boolean, boolean>;
24
26
  error: import("vue").Ref<string | null, string | null>;
25
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>
@@ -1,38 +1,45 @@
1
1
  <script setup>
2
2
  import { z } from "zod";
3
3
  import { USER_NICKNAME_MAX_LENGTH, USER_PEOPLE_NUMBER_MAX_LENGTH, USER_PHONE_MAX_LENGTH, USER_PHONE_PATTERN } from "@frigear-nu/users/api";
4
+ import { phoneIssue } from "@frigear-nu/ui/phone";
4
5
  import AccountChangeEmailSlideover from "../components/Account/AccountChangeEmailSlideover.vue";
5
6
  import { PROFILE_NO_LOCALE as NO_LOCALE, profileChanges } from "../utils/profile";
6
- import { computed, reactive, ref, useAccount, useAction, useModuleT, useNuxtApp, useOverlay, useRoute, useToast, useUserSession, watch } from "#imports";
7
+ import { computed, reactive, ref, resolveComponent, useAccount, useAction, useModuleT, useNuxtApp, useOverlay, useRoute, useRuntimeConfig, useToast, useUserSession, watch } from "#imports";
7
8
  defineOptions({ name: "AccountProfilePage" });
8
9
  const t = useModuleT("account.profile");
10
+ const WidgetArea = resolveComponent("WidgetArea");
11
+ const widgetArea = typeof WidgetArea === "string" ? void 0 : WidgetArea;
9
12
  const toast = useToast();
10
13
  const route = useRoute();
11
14
  const { user } = useUserSession();
12
15
  const { updateProfileDetails } = useAccount();
16
+ const avatarUpload = useRuntimeConfig().public.users?.avatarUpload === true;
13
17
  const { $i18n } = useNuxtApp();
14
18
  const localeItems = computed(() => {
15
19
  const locales = ($i18n?.locales.value ?? []).map((locale) => typeof locale === "string" ? { value: locale, label: locale } : { value: locale.code, label: locale.name || locale.code });
16
20
  return locales.length ? [{ value: NO_LOCALE, label: t("locale.none", "Not set") }, ...locales] : [];
17
21
  });
18
- const schema = z.object({
22
+ const baseSchema = z.object({
19
23
  name: z.string().trim().min(1, t("name.required", "Please enter your name.")),
20
24
  nickname: z.string().trim().max(USER_NICKNAME_MAX_LENGTH, t("nickname.tooLong", "Use at most {max} characters.", { max: USER_NICKNAME_MAX_LENGTH })).optional(),
21
- // The server's rule: an http(s) URL of at most 2048 characters (empty clears the avatar).
25
+ // The server's rule, imported from `@frigear-nu/users`, and a full international number (`PhoneInput` writes
26
+ // `+4512345678`); empty clears it. A number stored before the country selector passes until it is changed.
27
+ phone: z.string().trim().max(USER_PHONE_MAX_LENGTH).regex(USER_PHONE_PATTERN, t("phone.invalid", "Enter a valid phone number.")).refine((value) => !value || value === saved.value.phone || !phoneIssue(value), t("phone.invalid", "Enter a valid phone number.")).optional(),
28
+ peopleNumber: z.string().trim().max(USER_PEOPLE_NUMBER_MAX_LENGTH, t("peopleNumber.tooLong", "Use at most {max} characters.", { max: USER_PEOPLE_NUMBER_MAX_LENGTH })).optional()
29
+ });
30
+ const schema = avatarUpload ? baseSchema : baseSchema.extend({
22
31
  avatar: z.union([
23
32
  z.literal(""),
24
33
  z.url({ protocol: /^https?$/, message: t("avatar.invalid", "Enter a valid URL.") }).max(2048, t("avatar.invalid", "Enter a valid URL."))
25
- ]).optional(),
26
- // The server's rule, imported from `@frigear-nu/users`: digits, spaces and `+-().`; empty clears it.
27
- phone: z.string().trim().max(USER_PHONE_MAX_LENGTH).regex(USER_PHONE_PATTERN, t("phone.invalid", "Enter a phone number of digits, spaces and + - ( ).")).optional(),
28
- peopleNumber: z.string().trim().max(USER_PEOPLE_NUMBER_MAX_LENGTH, t("peopleNumber.tooLong", "Use at most {max} characters.", { max: USER_PEOPLE_NUMBER_MAX_LENGTH })).optional()
34
+ ]).optional()
29
35
  });
30
36
  const sessionField = (key) => user.value?.[key];
31
37
  const sessionText = (key) => {
32
38
  const value = sessionField(key);
33
39
  return typeof value === "string" ? value : "";
34
40
  };
35
- const FIELDS = ["name", "nickname", "avatar", "phone", "peopleNumber", "locale"];
41
+ const ALL_FIELDS = ["name", "nickname", "avatar", "phone", "peopleNumber", "locale"];
42
+ const FIELDS = avatarUpload ? ALL_FIELDS.filter((key) => key !== "avatar") : ALL_FIELDS;
36
43
  const saved = computed(() => ({
37
44
  name: user.value?.name ?? "",
38
45
  nickname: sessionText("nickname"),
@@ -54,7 +61,7 @@ function onSubmitProfile(event) {
54
61
  const body = profileChanges({
55
62
  ...event.data,
56
63
  nickname: event.data.nickname ?? "",
57
- avatar: event.data.avatar ?? "",
64
+ avatar: avatarUpload ? void 0 : event.data.avatar ?? "",
58
65
  phone: event.data.phone ?? "",
59
66
  peopleNumber: event.data.peopleNumber ?? "",
60
67
  locale: state.locale
@@ -131,6 +138,13 @@ async function onChangeEmail() {
131
138
  class="flex flex-col divide-y divide-default"
132
139
  @submit="onSubmitProfile"
133
140
  >
141
+ <FormRow
142
+ v-if="avatarUpload"
143
+ :label="t('avatar.label', 'Avatar')"
144
+ :description="t('avatar.hint', 'Saved as soon as you choose a photo.')"
145
+ >
146
+ <AccountAvatarField />
147
+ </FormRow>
134
148
  <FormRow
135
149
  name="name"
136
150
  :label="t('name.label', 'Name')"
@@ -155,6 +169,7 @@ async function onChangeEmail() {
155
169
  />
156
170
  </FormRow>
157
171
  <FormRow
172
+ v-if="!avatarUpload"
158
173
  name="avatar"
159
174
  :label="t('avatar.label', 'Avatar')"
160
175
  :description="t('avatar.description', 'Link to a square image.')"
@@ -180,11 +195,10 @@ async function onChangeEmail() {
180
195
  :label="t('phone.label', 'Phone')"
181
196
  :description="t('phone.description', 'For text messages. Only staff who need it can see it.')"
182
197
  >
183
- <UInput
184
- v-model="state.phone"
185
- type="tel"
186
- autocomplete="tel"
187
- class="w-full"
198
+ <PhoneInput
199
+ :model-value="state.phone"
200
+ :country-label="t('phone.country', 'Country')"
201
+ @update:model-value="state.phone = $event ?? ''"
188
202
  />
189
203
  </FormRow>
190
204
  <FormRow
@@ -280,5 +294,13 @@ async function onChangeEmail() {
280
294
  </div>
281
295
  </template>
282
296
  </SectionCard>
297
+
298
+ <component
299
+ :is="widgetArea"
300
+ v-if="widgetArea"
301
+ name="account.profile"
302
+ :context="{ user }"
303
+ grid-class="flex flex-col gap-4"
304
+ />
283
305
  </div>
284
306
  </template>
@@ -152,9 +152,10 @@ const passkeyMenu = (passkey) => [[
152
152
  flush
153
153
  >
154
154
  <template #actions>
155
- <UButton
155
+ <TooltipButton
156
156
  icon="i-lucide-plus"
157
157
  :label="t('passkeys.add', 'Add passkey')"
158
+ :tooltip="t('passkeys.addHint', 'Register this device so you can sign in without a password')"
158
159
  @click="onAddPasskey"
159
160
  />
160
161
  </template>
@@ -0,0 +1,5 @@
1
+ import { defineNuxtPlugin, resetPreload, useUserSession, watch } from "#imports";
2
+ export default defineNuxtPlugin(() => {
3
+ const { user } = useUserSession();
4
+ watch(() => user.value?.id ?? null, () => resetPreload("account"));
5
+ });
@@ -0,0 +1,34 @@
1
+ /** The side of the stored avatar, in pixels. */
2
+ export declare const AVATAR_SIZE = 512;
3
+ /** Files above this are refused before decoding, so a huge photo never freezes the tab. */
4
+ export declare const AVATAR_MAX_SOURCE_BYTES: number;
5
+ /** The `accept` of the file input: the formats every browser decodes first, then any image. */
6
+ export declare const AVATAR_ACCEPT = "image/png,image/jpeg,image/webp,image/*";
7
+ /** Why a chosen file cannot become an avatar. */
8
+ export type AvatarFileProblem = 'wrong_type' | 'too_large';
9
+ /** Thrown by {@link squareAvatar}; `problem` says why. */
10
+ export declare class AvatarImageError extends Error {
11
+ readonly problem: AvatarFileProblem;
12
+ constructor(problem: AvatarFileProblem);
13
+ }
14
+ /** Checks a chosen file before it is decoded: an image of at most `maxBytes`. */
15
+ export declare function avatarFileProblem(file: Pick<File, 'type' | 'size'>, maxBytes?: number): AvatarFileProblem | null;
16
+ /**
17
+ * The problem behind a failed upload, from the server's `data.code` (`unsupported_media_type`, `file_too_large`) or
18
+ * else its status (415, 413), so the page can say it in the user's language; `null` for any other error.
19
+ */
20
+ export declare function avatarUploadProblem(error: unknown): AvatarFileProblem | null;
21
+ /** The largest centred square of a `width` x `height` image: where to cut it (`sx`, `sy`) and its side. */
22
+ export declare function centreSquare(width: number, height: number): {
23
+ sx: number;
24
+ sy: number;
25
+ side: number;
26
+ };
27
+ /** The side of the output: `size`, or the image's own side when it is smaller (never scaled up). */
28
+ export declare function avatarOutputSide(side: number, size?: number): number;
29
+ /**
30
+ * Decodes `file`, cuts the centred square, scales it to `size` pixels and encodes it as WebP (quality 0.85), or as JPEG
31
+ * when the browser produced something else (Safari answers a WebP request with PNG). Throws {@link AvatarImageError}
32
+ * for a file that is not an image, is too large, or cannot be decoded.
33
+ */
34
+ export declare function squareAvatar(file: File, size?: number): Promise<File>;
@@ -0,0 +1,61 @@
1
+ export const AVATAR_SIZE = 512;
2
+ export const AVATAR_MAX_SOURCE_BYTES = 20 * 1024 * 1024;
3
+ export const AVATAR_ACCEPT = "image/png,image/jpeg,image/webp,image/*";
4
+ export class AvatarImageError extends Error {
5
+ constructor(problem) {
6
+ super(problem);
7
+ this.problem = problem;
8
+ this.name = "AvatarImageError";
9
+ }
10
+ }
11
+ export function avatarFileProblem(file, maxBytes = AVATAR_MAX_SOURCE_BYTES) {
12
+ if (!file.type.startsWith("image/")) return "wrong_type";
13
+ if (file.size > maxBytes) return "too_large";
14
+ return null;
15
+ }
16
+ export function avatarUploadProblem(error) {
17
+ if (error instanceof AvatarImageError) return error.problem;
18
+ if (!error || typeof error !== "object") return null;
19
+ const { statusCode, status, data } = error;
20
+ const code = data?.data?.code;
21
+ const httpStatus = statusCode ?? status;
22
+ if (code === "unsupported_media_type" || httpStatus === 415) return "wrong_type";
23
+ if (code === "file_too_large" || httpStatus === 413) return "too_large";
24
+ return null;
25
+ }
26
+ export function centreSquare(width, height) {
27
+ const side = Math.min(width, height);
28
+ return { sx: Math.floor((width - side) / 2), sy: Math.floor((height - side) / 2), side };
29
+ }
30
+ export function avatarOutputSide(side, size = AVATAR_SIZE) {
31
+ return Math.max(1, Math.min(side, size));
32
+ }
33
+ const encode = (canvas, type, quality) => new Promise((resolve) => canvas.toBlob(resolve, type, quality));
34
+ export async function squareAvatar(file, size = AVATAR_SIZE) {
35
+ const problem = avatarFileProblem(file);
36
+ if (problem) throw new AvatarImageError(problem);
37
+ let bitmap;
38
+ try {
39
+ bitmap = await createImageBitmap(file);
40
+ } catch {
41
+ throw new AvatarImageError("wrong_type");
42
+ }
43
+ try {
44
+ const { sx, sy, side } = centreSquare(bitmap.width, bitmap.height);
45
+ const out = avatarOutputSide(side, size);
46
+ const canvas = document.createElement("canvas");
47
+ canvas.width = out;
48
+ canvas.height = out;
49
+ const context = canvas.getContext("2d");
50
+ if (!context) throw new AvatarImageError("wrong_type");
51
+ context.imageSmoothingQuality = "high";
52
+ context.drawImage(bitmap, sx, sy, side, side, 0, 0, out, out);
53
+ let blob = await encode(canvas, "image/webp", 0.85);
54
+ if (blob?.type !== "image/webp") blob = await encode(canvas, "image/jpeg", 0.85);
55
+ if (!blob) throw new AvatarImageError("wrong_type");
56
+ const ext = blob.type === "image/webp" ? "webp" : "jpg";
57
+ return new File([blob], `avatar.${ext}`, { type: blob.type });
58
+ } finally {
59
+ bitmap.close();
60
+ }
61
+ }
@@ -0,0 +1,27 @@
1
+ type Translate = (key: string, fallback: string, params?: Record<string, string | number>) => string;
2
+ export interface McpConnectTab {
3
+ label: string;
4
+ value: string;
5
+ steps: string;
6
+ code: string;
7
+ extraSteps?: string;
8
+ extraCode?: string;
9
+ }
10
+ export interface McpConnectOptions {
11
+ /** The absolute MCP URL, e.g. `https://example.org/mcp`. */
12
+ url: string;
13
+ /** Whether clients sign in with OAuth there (`runtimeConfig.public.mcpModules.oauth`). */
14
+ oauth: boolean;
15
+ /** The API token to fill in, or a placeholder. */
16
+ token: string;
17
+ /** `useModuleT('account.apiTokens')`. */
18
+ t: Translate;
19
+ }
20
+ /** The name the snippets give the server in the client. */
21
+ export declare const MCP_SERVER_NAME = "frigear";
22
+ /**
23
+ * The tabs of the connect card. With OAuth every client adds the URL and signs the user in (Claude Code keeps the API
24
+ * token as an alternative); without it only clients that can send an `Authorization` header are listed, with the token.
25
+ */
26
+ export declare function mcpConnectTabs({ url, oauth, token, t }: McpConnectOptions): McpConnectTab[];
27
+ export {};
@@ -0,0 +1,70 @@
1
+ export const MCP_SERVER_NAME = "frigear";
2
+ const json = (value) => JSON.stringify(value, null, 2);
3
+ export function mcpConnectTabs({ url, oauth, token, t }) {
4
+ const bearer = `Bearer ${token}`;
5
+ const tokenCommand = `claude mcp add --transport http ${MCP_SERVER_NAME} ${url} --header "Authorization: ${bearer}"`;
6
+ if (!oauth) {
7
+ return [
8
+ {
9
+ label: "Claude Code",
10
+ value: "claude-code",
11
+ steps: t("connect.token.claudeCode", "Claude Code: run this command with an API token from this page."),
12
+ code: tokenCommand
13
+ },
14
+ {
15
+ label: "VS Code",
16
+ value: "vscode",
17
+ steps: t("connect.token.vscode", "VS Code: add this to .vscode/mcp.json, with an API token from this page."),
18
+ code: json({ servers: { [MCP_SERVER_NAME]: { type: "http", url, headers: { Authorization: bearer } } } })
19
+ },
20
+ {
21
+ label: "Cursor",
22
+ value: "cursor",
23
+ steps: t("connect.token.cursor", "Cursor: add this to .cursor/mcp.json (or ~/.cursor/mcp.json), with an API token from this page."),
24
+ code: json({ mcpServers: { [MCP_SERVER_NAME]: { url, headers: { Authorization: bearer } } } })
25
+ },
26
+ {
27
+ label: t("connect.token.otherLabel", "Other clients"),
28
+ value: "other",
29
+ steps: t("connect.token.other", 'Other clients: connect to the URL below and send an API token from this page as the header "Authorization: Bearer TOKEN".'),
30
+ code: url
31
+ }
32
+ ];
33
+ }
34
+ return [
35
+ {
36
+ label: "Claude",
37
+ value: "claude",
38
+ steps: t("connect.claude.steps", "Claude.ai and Claude Desktop: open Settings \u2192 Connectors \u2192 Add custom connector, paste the URL below, then choose Connect and sign in. No token needed."),
39
+ code: url
40
+ },
41
+ {
42
+ label: "ChatGPT",
43
+ value: "chatgpt",
44
+ steps: t("connect.chatgpt.steps", "ChatGPT: turn on Developer mode under Settings \u2192 Apps & Connectors \u2192 Advanced settings, then create a connector with the URL below and OAuth authentication, and sign in. No token needed."),
45
+ code: url
46
+ },
47
+ {
48
+ label: "Claude Code",
49
+ value: "claude-code",
50
+ steps: t("connect.claudeCode.steps", "Claude Code: run this command, then run /mcp in Claude Code, pick {name} and choose Authenticate to sign in.", { name: MCP_SERVER_NAME }),
51
+ code: `claude mcp add --transport http ${MCP_SERVER_NAME} ${url}`,
52
+ extraSteps: t("connect.claudeCode.token", "Or use an API token from this page instead of signing in:"),
53
+ extraCode: tokenCommand
54
+ },
55
+ {
56
+ label: "VS Code",
57
+ value: "vscode",
58
+ steps: t("connect.vscode.steps", "VS Code: run MCP: Add Server, choose HTTP and paste the URL below, then sign in when VS Code asks."),
59
+ code: url,
60
+ extraSteps: t("connect.vscode.file", "Or add it to .vscode/mcp.json:"),
61
+ extraCode: json({ servers: { [MCP_SERVER_NAME]: { type: "http", url } } })
62
+ },
63
+ {
64
+ label: "Cursor",
65
+ value: "cursor",
66
+ steps: t("connect.cursor.steps", "Cursor: add this to .cursor/mcp.json (or ~/.cursor/mcp.json), then choose Login next to {name} under Settings \u2192 MCP.", { name: MCP_SERVER_NAME }),
67
+ code: json({ mcpServers: { [MCP_SERVER_NAME]: { url } } })
68
+ }
69
+ ];
70
+ }
@@ -3,7 +3,8 @@ export declare const PROFILE_NO_LOCALE = "-";
3
3
  export interface ProfileFormValues {
4
4
  name: string;
5
5
  nickname: string;
6
- avatar: string;
6
+ /** Left out when the avatar is uploaded on its own (`users.avatarUpload`): the body then keeps the stored one. */
7
+ avatar?: string;
7
8
  phone: string;
8
9
  /** The user's id in an external system (`users.peopleNumber`). */
9
10
  peopleNumber: string;
@@ -19,9 +20,9 @@ export declare function profileChanges(values: ProfileFormValues, saved: Pick<Pr
19
20
  localeChoice: boolean;
20
21
  }): {
21
22
  locale?: string | null | undefined;
22
- name: string;
23
- nickname: string | null;
24
- avatar: string | null;
25
23
  phone: string | null;
26
24
  peopleNumber: string | null;
25
+ avatar?: string | null | undefined;
26
+ name: string;
27
+ nickname: string | null;
27
28
  };
@@ -4,7 +4,7 @@ export function profileChanges(values, saved, options) {
4
4
  return {
5
5
  name: values.name,
6
6
  nickname: values.nickname.trim() || null,
7
- avatar: values.avatar || null,
7
+ ...values.avatar === void 0 ? {} : { avatar: values.avatar || null },
8
8
  phone: values.phone || null,
9
9
  peopleNumber: values.peopleNumber.trim() || null,
10
10
  ...localeChanged ? { locale: values.locale === PROFILE_NO_LOCALE ? null : values.locale } : {}
@@ -71,10 +71,25 @@
71
71
  "invalid": "Indtast en gyldig e-mailadresse."
72
72
  },
73
73
  "avatar": {
74
- "label": "Avatar",
74
+ "label": "Profilbillede",
75
75
  "description": "Link til et kvadratisk billede.",
76
76
  "url": "Avatar URL",
77
- "invalid": "Indtast en gyldig URL."
77
+ "invalid": "Indtast en gyldig URL.",
78
+ "hint": "Gemmes, så snart du vælger et billede.",
79
+ "upload": "Upload billede",
80
+ "change": "Skift billede",
81
+ "remove": "Fjern billede",
82
+ "removeHint": "Dine initialer vises i stedet, for alle",
83
+ "removeConfirm": {
84
+ "title": "Fjern dit billede?",
85
+ "description": "Dit billede fjernes for alle. Dine initialer vises i stedet."
86
+ },
87
+ "saved": "Billede gemt",
88
+ "removed": "Billede fjernet",
89
+ "saveFailed": "Kunne ikke gemme dit billede.",
90
+ "removeFailed": "Kunne ikke fjerne dit billede.",
91
+ "wrongType": "Vælg et billede, fx en PNG-, JPEG- eller WebP-fil.",
92
+ "tooLarge": "Billedet er for stort. Vælg et under {size}."
78
93
  },
79
94
  "save": "Gem profil",
80
95
  "saved": "Profil opdateret",
@@ -82,7 +97,8 @@
82
97
  "phone": {
83
98
  "label": "Telefon",
84
99
  "description": "Til sms'er. Kun personale, der har brug for det, kan se det.",
85
- "invalid": "Angiv et telefonnummer med cifre, mellemrum og + - ( )."
100
+ "invalid": "Angiv et gyldigt telefonnummer.",
101
+ "country": "Land"
86
102
  },
87
103
  "locale": {
88
104
  "label": "Sprog",
@@ -149,6 +165,7 @@
149
165
  "passkeys": {
150
166
  "title": "Passkeys",
151
167
  "add": "Tilføj passkey",
168
+ "addHint": "Registrér denne enhed, så du kan logge ind uden adgangskode",
152
169
  "description": "Log ind med fingeraftryk, ansigt eller enhedens pinkode i stedet for et password.",
153
170
  "unnamed": "Passkey",
154
171
  "created": "Tilføjet {date}",
@@ -183,6 +200,7 @@
183
200
  "signedOut": "Logget ud.",
184
201
  "signOutError": "Kunne ikke logge ud af applikationen.",
185
202
  "signOutAll": "Log ud af alle apps",
203
+ "signOutAllHint": "Alle apps på listen skal bede dig logge ind igen",
186
204
  "signOutAllConfirm": {
187
205
  "title": "Log ud af alle apps?",
188
206
  "description": "Alle applikationer på listen, på alle enheder, skal bede dig logge ind igen. Du forbliver logget ind på dette website."
@@ -201,11 +219,12 @@
201
219
  "copy": "Kopiér nøgle",
202
220
  "copied": "Nøglen er kopieret.",
203
221
  "copiedSnippet": "Kopieret.",
204
- "copySnippet": "Kopiér kommando",
222
+ "copySnippetHint": "Kopiér kommandoen til udklipsholderen",
205
223
  "create": {
206
224
  "title": "Opret API-nøgle",
207
225
  "description": "Nøgler lader scripts og værktøjer som MCP-klienter handle på dine vegne. Giv hver nøgle kun de rettigheder, den har brug for.",
208
- "submit": "Opret API-nøgle"
226
+ "submit": "Opret API-nøgle",
227
+ "submitHint": "Lav en nøgle til scripts og værktøjer; den vises kun én gang"
209
228
  },
210
229
  "createError": "Kunne ikke oprette nøglen.",
211
230
  "created": "Nøglen er oprettet",
@@ -237,13 +256,33 @@
237
256
  "connect": {
238
257
  "title": "Forbind til MCP",
239
258
  "description": "Brug din konto fra en AI-assistent. Din API-nøgle indsættes kun i kommandoerne lige efter, du har oprettet den.",
259
+ "descriptionOAuth": "Brug din konto fra en AI-assistent: tilføj URL'en i appen, og log ind. Du skal kun bruge en API-nøgle til klienter, der ikke kan logge ind, og den indsættes i kommandoerne lige efter, du har oprettet den.",
240
260
  "claude": {
241
- "steps": "Claude.ai og Claude Desktop: åbn Indstillinger → Connectors → Tilføj brugerdefineret connector, indsæt URL'en nedenfor og log ind, når du bliver bedt om det. Ingen nøgle nødvendig.",
242
- "cli": "Claude Code (bruger en API-nøgle):"
261
+ "steps": "Claude.ai og Claude Desktop: åbn Indstillinger → Connectors → Tilføj brugerdefineret connector, indsæt URL'en nedenfor, vælg Forbind og log ind. Ingen nøgle nødvendig."
243
262
  },
244
263
  "chatgpt": {
245
- "steps": "ChatGPT: åbn Indstillinger → Connectors → Avanceret, slå udviklertilstand til, og opret en connector med URL'en nedenfor. Vælg OAuth og log ind, når du bliver bedt om det. Ingen nøgle nødvendig."
246
- }
264
+ "steps": "ChatGPT: slå udviklertilstand til under Indstillinger → Apps og connectors → Avancerede indstillinger, opret en connector med URL'en nedenfor og OAuth-godkendelse, og log ind. Ingen nøgle nødvendig."
265
+ },
266
+ "claudeCode": {
267
+ "steps": "Claude Code: kør denne kommando, kør derefter /mcp i Claude Code, vælg {name} og vælg Authenticate for at logge ind.",
268
+ "token": "Eller brug en API-nøgle fra denne side i stedet for at logge ind:"
269
+ },
270
+ "vscode": {
271
+ "steps": "VS Code: kør MCP: Add Server, vælg HTTP og indsæt URL'en nedenfor, og log ind, når VS Code beder om det.",
272
+ "file": "Eller tilføj den i .vscode/mcp.json:"
273
+ },
274
+ "cursor": {
275
+ "steps": "Cursor: tilføj dette i .cursor/mcp.json (eller ~/.cursor/mcp.json), og vælg derefter Login ud for {name} under Settings → MCP."
276
+ },
277
+ "token": {
278
+ "claudeCode": "Claude Code: kør denne kommando med en API-nøgle fra denne side.",
279
+ "vscode": "VS Code: tilføj dette i .vscode/mcp.json med en API-nøgle fra denne side.",
280
+ "cursor": "Cursor: tilføj dette i .cursor/mcp.json (eller ~/.cursor/mcp.json) med en API-nøgle fra denne side.",
281
+ "otherLabel": "Andre klienter",
282
+ "other": "Andre klienter: forbind til URL'en nedenfor, og send en API-nøgle fra denne side som headeren \"Authorization: Bearer NØGLE\"."
283
+ },
284
+ "signedInApps": "Apps, du forbinder ved at logge ind, vises under Apps, der er logget ind, på siden Sikkerhed, hvor du kan logge dem ud.",
285
+ "signedInAppsLink": "Åbn apps, der er logget ind"
247
286
  },
248
287
  "list": {
249
288
  "title": "Dine nøgler",
@@ -74,7 +74,22 @@
74
74
  "label": "Avatar",
75
75
  "description": "Link to a square image.",
76
76
  "url": "Avatar URL",
77
- "invalid": "Enter a valid URL."
77
+ "invalid": "Enter a valid URL.",
78
+ "hint": "Saved as soon as you choose a photo.",
79
+ "upload": "Upload photo",
80
+ "change": "Change photo",
81
+ "remove": "Remove photo",
82
+ "removeHint": "Your initials are shown instead, for everyone",
83
+ "removeConfirm": {
84
+ "title": "Remove your photo?",
85
+ "description": "Your photo is removed for everyone. Your initials are shown instead."
86
+ },
87
+ "saved": "Photo saved",
88
+ "removed": "Photo removed",
89
+ "saveFailed": "Could not save your photo.",
90
+ "removeFailed": "Could not remove your photo.",
91
+ "wrongType": "Choose an image, such as a PNG, JPEG or WebP file.",
92
+ "tooLarge": "The image is too large. Choose one under {size}."
78
93
  },
79
94
  "save": "Save profile",
80
95
  "saved": "Profile updated",
@@ -82,7 +97,8 @@
82
97
  "phone": {
83
98
  "label": "Phone",
84
99
  "description": "For text messages. Only staff who need it can see it.",
85
- "invalid": "Enter a phone number of digits, spaces and + - ( )."
100
+ "invalid": "Enter a valid phone number.",
101
+ "country": "Country"
86
102
  },
87
103
  "locale": {
88
104
  "label": "Language",
@@ -149,6 +165,7 @@
149
165
  "passkeys": {
150
166
  "title": "Passkeys",
151
167
  "add": "Add passkey",
168
+ "addHint": "Register this device so you can sign in without a password",
152
169
  "description": "Sign in with your fingerprint, face or device PIN instead of a password.",
153
170
  "unnamed": "Passkey",
154
171
  "created": "Added {date}",
@@ -183,6 +200,7 @@
183
200
  "signedOut": "Signed out.",
184
201
  "signOutError": "Could not sign out of the application.",
185
202
  "signOutAll": "Sign out of all apps",
203
+ "signOutAllHint": "Every app listed here has to ask you to sign in again",
186
204
  "signOutAllConfirm": {
187
205
  "title": "Sign out of every app?",
188
206
  "description": "Every application listed here, on every device, has to ask you to sign in again. You stay signed in on this website."
@@ -201,11 +219,12 @@
201
219
  "copy": "Copy token",
202
220
  "copied": "Token copied.",
203
221
  "copiedSnippet": "Copied.",
204
- "copySnippet": "Copy command",
222
+ "copySnippetHint": "Copy this command to your clipboard",
205
223
  "create": {
206
224
  "title": "Create API token",
207
225
  "description": "Tokens let scripts and tools such as MCP clients act as you. Give each one only the scopes it needs.",
208
- "submit": "Create API token"
226
+ "submit": "Create API token",
227
+ "submitHint": "Make a token for scripts and tools; it is shown only once"
209
228
  },
210
229
  "createError": "Could not create the token.",
211
230
  "created": "Token created",
@@ -237,13 +256,33 @@
237
256
  "connect": {
238
257
  "title": "Connect to MCP",
239
258
  "description": "Use your account from an AI assistant. Your API token is only filled into the commands right after you create it.",
259
+ "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.",
240
260
  "claude": {
241
- "steps": "Claude.ai and Claude Desktop: open Settings → Connectors → Add custom connector, paste the URL below and sign in when asked. No token needed.",
242
- "cli": "Claude Code (uses an API token):"
261
+ "steps": "Claude.ai and Claude Desktop: open Settings → Connectors → Add custom connector, paste the URL below, then choose Connect and sign in. No token needed."
243
262
  },
244
263
  "chatgpt": {
245
- "steps": "ChatGPT: open Settings → Connectors → Advanced, turn on Developer mode, then create a connector with the URL below. Choose OAuth and sign in when asked. No token needed."
246
- }
264
+ "steps": "ChatGPT: turn on Developer mode under Settings → Apps & Connectors → Advanced settings, then create a connector with the URL below and OAuth authentication, and sign in. No token needed."
265
+ },
266
+ "claudeCode": {
267
+ "steps": "Claude Code: run this command, then run /mcp in Claude Code, pick {name} and choose Authenticate to sign in.",
268
+ "token": "Or use an API token from this page instead of signing in:"
269
+ },
270
+ "vscode": {
271
+ "steps": "VS Code: run MCP: Add Server, choose HTTP and paste the URL below, then sign in when VS Code asks.",
272
+ "file": "Or add it to .vscode/mcp.json:"
273
+ },
274
+ "cursor": {
275
+ "steps": "Cursor: add this to .cursor/mcp.json (or ~/.cursor/mcp.json), then choose Login next to {name} under Settings → MCP."
276
+ },
277
+ "token": {
278
+ "claudeCode": "Claude Code: run this command with an API token from this page.",
279
+ "vscode": "VS Code: add this to .vscode/mcp.json, with an API token from this page.",
280
+ "cursor": "Cursor: add this to .cursor/mcp.json (or ~/.cursor/mcp.json), with an API token from this page.",
281
+ "otherLabel": "Other clients",
282
+ "other": "Other clients: connect to the URL below and send an API token from this page as the header \"Authorization: Bearer TOKEN\"."
283
+ },
284
+ "signedInApps": "Apps you connect by signing in are listed under Signed-in apps on the Security page, where you can sign them out.",
285
+ "signedInAppsLink": "Open signed-in apps"
247
286
  },
248
287
  "list": {
249
288
  "title": "Your tokens",
@@ -9,7 +9,7 @@ export default defineMenuSource(() => {
9
9
  labelKey: "account.menu.account.label",
10
10
  description: "Your account.",
11
11
  descriptionKey: "account.menu.account.description",
12
- icon: "i-lucide-layout-dashboard",
12
+ icon: "i-lucide-user-round-cog",
13
13
  to: config.pages.index,
14
14
  order: -99
15
15
  });
@@ -36,7 +36,6 @@ export default defineMenuSource(() => {
36
36
  order: 10
37
37
  });
38
38
  extendMenuItem("account", profileItem);
39
- extendMenuItem("account.dropdown", profileItem);
40
39
  }
41
40
  if (config?.pages?.security) {
42
41
  extendMenuItem("account", {
@@ -0,0 +1,7 @@
1
+ /**
2
+ * The area a path belongs to: the area whose path is the path itself or a parent of it, the longest one when several
3
+ * match (`/account/profile` belongs to `/account`, not to `/`). Both sides are expected without a locale prefix.
4
+ */
5
+ export declare function matchArea<T extends {
6
+ to: string;
7
+ }>(areas: T[], path: string): T | undefined;
@@ -0,0 +1,4 @@
1
+ export function matchArea(areas, path) {
2
+ const contains = (to) => path === to || to !== "/" && path.startsWith(`${to.replace(/\/$/, "")}/`);
3
+ return areas.filter((area) => contains(area.to)).sort((a, b) => b.to.length - a.to.length)[0];
4
+ }
package/package.json CHANGED
@@ -1,7 +1,11 @@
1
1
  {
2
2
  "name": "@frigear-nu/account",
3
- "version": "0.6.3",
3
+ "version": "0.6.4",
4
4
  "description": "A module for managing the account area (profile, email, password, security) in the main frigear app.",
5
+ "keywords": [
6
+ "frigear-module",
7
+ "nuxt-module"
8
+ ],
5
9
  "homepage": "https://docs.frigear.dev/modules/identity/account",
6
10
  "repository": {
7
11
  "type": "git",
@@ -24,10 +28,10 @@
24
28
  "playground"
25
29
  ],
26
30
  "dependencies": {
27
- "@frigear-nu/auth": "^0.6.8",
28
- "@frigear-nu/module-kit": "^1.3.12",
29
- "@frigear-nu/ui": "^0.2.11",
30
- "@frigear-nu/users": "^3.1.5",
31
+ "@frigear-nu/auth": "^0.6.9",
32
+ "@frigear-nu/module-kit": "^1.3.13",
33
+ "@frigear-nu/ui": "^0.2.12",
34
+ "@frigear-nu/users": "^3.1.6",
31
35
  "@libsql/client": "^0.18.0",
32
36
  "@nuxt/kit": "^4.6.4",
33
37
  "@vueuse/core": "^15.0.0",
@@ -36,9 +40,9 @@
36
40
  "zod": "^4.6.7"
37
41
  },
38
42
  "peerDependencies": {
39
- "@frigear-nu/authorization": "^0.6.6",
40
- "@frigear-nu/menu": "^0.4.1",
41
- "@frigear-nu/widget": "^0.4.3",
43
+ "@frigear-nu/authorization": "^0.6.7",
44
+ "@frigear-nu/menu": "^0.4.2",
45
+ "@frigear-nu/widget": "^0.4.4",
42
46
  "@nuxt/ui": "^4.12.0",
43
47
  "@nuxthub/core": "^0.10.12"
44
48
  },
@@ -57,9 +61,9 @@
57
61
  }
58
62
  },
59
63
  "devDependencies": {
60
- "@frigear-nu/authorization": "^0.6.6",
61
- "@frigear-nu/menu": "^0.4.1",
62
- "@frigear-nu/widget": "^0.4.3",
64
+ "@frigear-nu/authorization": "^0.6.7",
65
+ "@frigear-nu/menu": "^0.4.2",
66
+ "@frigear-nu/widget": "^0.4.4",
63
67
  "@nuxt/devtools": "^4.2.0",
64
68
  "@nuxt/eslint-config": "^1.17.0",
65
69
  "@nuxt/module-builder": "^1.0.4",
@@ -1,6 +0,0 @@
1
- import { keys } from "#account/bootstrap";
2
- import { defineNuxtRouteMiddleware, loadBootstrap, useUserSession } from "#imports";
3
- export default defineNuxtRouteMiddleware(async () => {
4
- if (!keys.length || !useUserSession().loggedIn.value) return;
5
- await loadBootstrap("account");
6
- });
@@ -1,5 +0,0 @@
1
- import { defineNuxtPlugin, resetBootstrap, useUserSession, watch } from "#imports";
2
- export default defineNuxtPlugin(() => {
3
- const { user } = useUserSession();
4
- watch(() => user.value?.id ?? null, () => resetBootstrap("account"));
5
- });