@frigear-nu/account 0.2.5 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/module.d.mts CHANGED
@@ -23,6 +23,8 @@ type PublicModuleOptions = {
23
23
  apiTokens?: string;
24
24
  };
25
25
  documents: AccountDocument[];
26
+ /** `@frigear-nu/oauth-server` is installed: the Security page lists the applications the user is signed in to. */
27
+ signedInApps?: boolean;
26
28
  };
27
29
  type ModuleOptions = {
28
30
  settings?: {
package/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@frigear-nu/account",
3
3
  "configKey": "account",
4
- "version": "0.2.5",
4
+ "version": "0.3.0",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.3",
7
7
  "unbuild": "unknown"
package/dist/module.mjs CHANGED
@@ -67,8 +67,12 @@ const module$1 = defineNuxtModule({
67
67
  }
68
68
  nuxt.options.runtimeConfig.public.account = {
69
69
  pages: { index: indexPath, profile: profilePath, security: securityPath, documents: documentsPath, apiTokens: apiTokensPath },
70
- documents: settings.documents ?? []
70
+ documents: settings.documents ?? [],
71
+ signedInApps: false
71
72
  };
73
+ nuxt.hook("modules:done", () => {
74
+ nuxt.options.runtimeConfig.public.account.signedInApps = hasNuxtModule("@frigear-nu/oauth-server", nuxt);
75
+ });
72
76
  addModulePages("@frigear-nu/account", resolver, [
73
77
  { name: "account-index", path: indexPath, file: "./runtime/app/pages/index.vue" },
74
78
  { name: "account-profile", path: profilePath, file: "./runtime/app/pages/profile.vue" },
@@ -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,115 @@
1
+ <script setup>
2
+ import { $fetch, computed, errorMessage, useCachedFetch, useConfirmDialog, useErrorToast, useFormat, useModuleT, useToast, useUserSession } from "#imports";
3
+ defineOptions({ name: "AccountSignedInApps" });
4
+ const SESSIONS = "/api/oauth-server/me/sessions";
5
+ const t = useModuleT("account.security.signedInApps");
6
+ const toast = useToast();
7
+ const showError = useErrorToast();
8
+ const confirm = useConfirmDialog();
9
+ const format = useFormat();
10
+ const { user } = useUserSession();
11
+ const { data, error, loading, refresh } = await useCachedFetch(SESSIONS, {
12
+ key: () => `account:signed-in-apps:${user.value?.id ?? "anonymous"}`,
13
+ ttl: 0,
14
+ watch: false
15
+ });
16
+ const sessions = computed(() => data.value ?? []);
17
+ async function signOut(session) {
18
+ const confirmed = await confirm({
19
+ title: t("signOutConfirm.title", "Sign out of {name}?", { name: session.application.name }),
20
+ description: t("signOutConfirm.description", "The application has to ask you to sign in again. Your account and its data are not affected."),
21
+ confirmText: t("signOut", "Sign out of app"),
22
+ destructive: true
23
+ });
24
+ if (!confirmed) return;
25
+ try {
26
+ await $fetch(`${SESSIONS}/${encodeURIComponent(session.id)}`, { method: "DELETE" });
27
+ toast.add({ title: t("signedOut", "Signed out."), description: session.application.name, color: "success", icon: "i-lucide-check" });
28
+ await refresh();
29
+ } catch (e) {
30
+ showError(e, t("signOutError", "Could not sign out of the application."));
31
+ }
32
+ }
33
+ async function signOutAll() {
34
+ const confirmed = await confirm({
35
+ title: t("signOutAllConfirm.title", "Sign out of every app?"),
36
+ description: t("signOutAllConfirm.description", "Every application listed here, on every device, has to ask you to sign in again. You stay signed in on this website."),
37
+ confirmText: t("signOutAll", "Sign out of all apps"),
38
+ destructive: true
39
+ });
40
+ if (!confirmed) return;
41
+ try {
42
+ await $fetch(SESSIONS, { method: "DELETE" });
43
+ toast.add({ title: t("signedOutAll", "Signed out of every app."), color: "success", icon: "i-lucide-check" });
44
+ await refresh();
45
+ } catch (e) {
46
+ showError(e, t("signOutAllError", "Could not sign out of the applications."));
47
+ }
48
+ }
49
+ const menu = (session) => [[
50
+ { label: t("signOut", "Sign out of app"), icon: "i-lucide-log-out", color: "error", onSelect: () => signOut(session) }
51
+ ]];
52
+ </script>
53
+
54
+ <template>
55
+ <SectionCard
56
+ :title="t('title', 'Signed-in apps')"
57
+ :description="t('description', 'Applications that signed in with your account. Changing your password or email signs them all out.')"
58
+ :loading="loading"
59
+ flush
60
+ >
61
+ <template
62
+ v-if="sessions.length"
63
+ #actions
64
+ >
65
+ <UButton
66
+ color="neutral"
67
+ variant="outline"
68
+ icon="i-lucide-log-out"
69
+ :label="t('signOutAll', 'Sign out of all apps')"
70
+ @click="signOutAll"
71
+ />
72
+ </template>
73
+ <ul
74
+ v-if="sessions.length"
75
+ class="divide-y divide-default"
76
+ >
77
+ <li
78
+ v-for="session in sessions"
79
+ :key="session.id"
80
+ class="flex items-center gap-3 px-4 py-3"
81
+ >
82
+ <UIcon
83
+ :name="session.application.icon || 'i-lucide-app-window'"
84
+ class="size-5 shrink-0 text-muted"
85
+ />
86
+ <div class="min-w-0 flex-1">
87
+ <p class="truncate text-sm font-medium text-highlighted">
88
+ {{ session.application.name }}
89
+ </p>
90
+ <p class="text-sm text-muted">
91
+ {{ t("activity", "Signed in {signedIn} \xB7 last active {lastActive}", { signedIn: format.date(session.signedInAt), lastActive: format.dateTime(session.lastActiveAt) }) }}
92
+ </p>
93
+ </div>
94
+ <RowMenu
95
+ :items="menu(session)"
96
+ :subject="session.application.name"
97
+ />
98
+ </li>
99
+ </ul>
100
+ <UEmpty
101
+ v-else-if="error"
102
+ variant="naked"
103
+ icon="i-lucide-circle-alert"
104
+ :title="t('loadError', 'Could not load your signed-in apps.')"
105
+ :description="errorMessage(error, '')"
106
+ :actions="[{ label: t('tryAgain', 'Try again'), icon: 'i-lucide-rotate-ccw', color: 'neutral', variant: 'outline', onClick: () => refresh() }]"
107
+ />
108
+ <UEmpty
109
+ v-else
110
+ variant="naked"
111
+ icon="i-lucide-app-window"
112
+ :title="t('empty', 'No applications are signed in with your account.')"
113
+ />
114
+ </SectionCard>
115
+ </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;
@@ -2,6 +2,7 @@
2
2
  import { z } from "zod";
3
3
  import { authApi } from "@frigear-nu/auth/api";
4
4
  import AccountPasskeySlideover from "../components/Account/AccountPasskeySlideover.vue";
5
+ import AccountSignedInApps from "../components/Account/AccountSignedInApps.vue";
5
6
  import { computed, errorMessage, reactive, useAccount, useAction, useCachedFetch, useConfirmDialog, useErrorToast, useFormat, useModuleT, useOverlay, usePasskeys, useRuntimeConfig, useToast, useUserSession } from "#imports";
6
7
  defineOptions({ name: "AccountSecurityPage" });
7
8
  const t = useModuleT("account.security");
@@ -13,6 +14,7 @@ const { user } = useUserSession();
13
14
  const { changePassword } = useAccount();
14
15
  const webAuthnEnabled = useRuntimeConfig().public.authentication?.webAuthn === true;
15
16
  const passkeys = webAuthnEnabled ? usePasskeys() : void 0;
17
+ const signedInApps = useRuntimeConfig().public.account?.signedInApps === true;
16
18
  const passwordSchema = z.object({
17
19
  currentPassword: z.string().min(1, t("changePassword.current.required", "Enter your current password.")),
18
20
  newPassword: z.string().min(8, t("changePassword.new.min", "Use at least 8 characters.")),
@@ -199,5 +201,7 @@ const passkeyMenu = (passkey) => [[
199
201
  :actions="[{ label: t('passkeys.add', 'Add passkey'), icon: 'i-lucide-plus', onClick: onAddPasskey }]"
200
202
  />
201
203
  </SectionCard>
204
+
205
+ <AccountSignedInApps v-if="signedInApps" />
202
206
  </div>
203
207
  </template>
@@ -135,6 +135,28 @@
135
135
  "removeError": "Kunne ikke fjerne passkey.",
136
136
  "loadError": "Kunne ikke hente dine passkeys.",
137
137
  "tryAgain": "Prøv igen"
138
+ },
139
+ "signedInApps": {
140
+ "title": "Apps, der er logget ind",
141
+ "description": "Applikationer, der er logget ind med din konto. Når du ændrer adgangskode eller e-mail, logges de alle ud.",
142
+ "activity": "Logget ind {signedIn} · sidst aktiv {lastActive}",
143
+ "signOut": "Log ud af app",
144
+ "signOutConfirm": {
145
+ "title": "Log ud af {name}?",
146
+ "description": "Applikationen skal bede dig logge ind igen. Din konto og dens data påvirkes ikke."
147
+ },
148
+ "signedOut": "Logget ud.",
149
+ "signOutError": "Kunne ikke logge ud af applikationen.",
150
+ "signOutAll": "Log ud af alle apps",
151
+ "signOutAllConfirm": {
152
+ "title": "Log ud af alle apps?",
153
+ "description": "Alle applikationer på listen, på alle enheder, skal bede dig logge ind igen. Du forbliver logget ind på dette website."
154
+ },
155
+ "signedOutAll": "Logget ud af alle apps.",
156
+ "signOutAllError": "Kunne ikke logge ud af applikationerne.",
157
+ "loadError": "Kunne ikke hente dine apps.",
158
+ "tryAgain": "Prøv igen",
159
+ "empty": "Ingen applikationer er logget ind med din konto."
138
160
  }
139
161
  },
140
162
  "apiTokens": {
@@ -165,10 +187,10 @@
165
187
  "required": "Vælg mindst én rettighed."
166
188
  },
167
189
  "expiry": {
168
- "label": "Udløber",
169
190
  "30": "30 dage",
170
191
  "90": "90 dage",
171
192
  "365": "1 år",
193
+ "label": "Udløber",
172
194
  "never": "Udløber aldrig"
173
195
  },
174
196
  "reveal": {
@@ -135,6 +135,28 @@
135
135
  "removeError": "Could not remove the passkey.",
136
136
  "loadError": "Could not load your passkeys.",
137
137
  "tryAgain": "Try again"
138
+ },
139
+ "signedInApps": {
140
+ "title": "Signed-in apps",
141
+ "description": "Applications that signed in with your account. Changing your password or email signs them all out.",
142
+ "activity": "Signed in {signedIn} · last active {lastActive}",
143
+ "signOut": "Sign out of app",
144
+ "signOutConfirm": {
145
+ "title": "Sign out of {name}?",
146
+ "description": "The application has to ask you to sign in again. Your account and its data are not affected."
147
+ },
148
+ "signedOut": "Signed out.",
149
+ "signOutError": "Could not sign out of the application.",
150
+ "signOutAll": "Sign out of all apps",
151
+ "signOutAllConfirm": {
152
+ "title": "Sign out of every app?",
153
+ "description": "Every application listed here, on every device, has to ask you to sign in again. You stay signed in on this website."
154
+ },
155
+ "signedOutAll": "Signed out of every app.",
156
+ "signOutAllError": "Could not sign out of the applications.",
157
+ "loadError": "Could not load your signed-in apps.",
158
+ "tryAgain": "Try again",
159
+ "empty": "No applications are signed in with your account."
138
160
  }
139
161
  },
140
162
  "apiTokens": {
@@ -165,10 +187,10 @@
165
187
  "required": "Pick at least one scope."
166
188
  },
167
189
  "expiry": {
168
- "label": "Expires",
169
190
  "30": "30 days",
170
191
  "90": "90 days",
171
192
  "365": "1 year",
193
+ "label": "Expires",
172
194
  "never": "No expiry"
173
195
  },
174
196
  "reveal": {
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@frigear-nu/account",
3
- "version": "0.2.5",
3
+ "version": "0.3.0",
4
4
  "description": "A module for managing the account area (profile, email, password, security) in the main frigear app.",
5
5
  "homepage": "https://docs.frigear.dev/modules/identity/account",
6
6
  "repository": {
7
7
  "type": "git",
8
- "url": "git+https://github.com/frigear-nu/frigear-nu.git",
8
+ "url": "git+https://github.com/Frigear-nu/frigear-nu.git",
9
9
  "directory": "packages/account"
10
10
  },
11
11
  "license": "MIT",
@@ -24,10 +24,10 @@
24
24
  "playground"
25
25
  ],
26
26
  "dependencies": {
27
- "@frigear-nu/module-kit": "^1.3.3",
28
- "@frigear-nu/auth": "^0.3.1",
29
- "@frigear-nu/ui": "^0.2.3",
30
- "@frigear-nu/users": "^1.2.5",
27
+ "@frigear-nu/module-kit": "^1.3.4",
28
+ "@frigear-nu/auth": "^0.3.4",
29
+ "@frigear-nu/ui": "^0.2.5",
30
+ "@frigear-nu/users": "^1.3.0",
31
31
  "@libsql/client": "^0.18.0",
32
32
  "@nuxt/kit": "^4.6.1",
33
33
  "@vueuse/core": "^15.0.0",
@@ -36,9 +36,9 @@
36
36
  "zod": "^4.6.5"
37
37
  },
38
38
  "peerDependencies": {
39
- "@frigear-nu/authorization": "^0.3.1",
40
- "@frigear-nu/menu": "^0.2.3",
41
- "@frigear-nu/widget": "^0.2.3",
39
+ "@frigear-nu/authorization": "^0.3.2",
40
+ "@frigear-nu/menu": "^0.2.4",
41
+ "@frigear-nu/widget": "^0.2.4",
42
42
  "@nuxt/ui": "^4.12.0",
43
43
  "@nuxthub/core": "^0.10.8"
44
44
  },
@@ -57,9 +57,9 @@
57
57
  }
58
58
  },
59
59
  "devDependencies": {
60
- "@frigear-nu/authorization": "^0.3.1",
61
- "@frigear-nu/menu": "^0.2.3",
62
- "@frigear-nu/widget": "^0.2.3",
60
+ "@frigear-nu/authorization": "^0.3.2",
61
+ "@frigear-nu/menu": "^0.2.4",
62
+ "@frigear-nu/widget": "^0.2.4",
63
63
  "@nuxt/devtools": "^3.4.2",
64
64
  "@nuxt/eslint-config": "^1.17.0",
65
65
  "@nuxt/module-builder": "^1.0.3",