@frigear-nu/account 0.4.0 → 0.5.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 +4 -3
- package/dist/module.json +1 -1
- package/dist/module.mjs +11 -0
- package/dist/runtime/app/components/Account/AccountMenu.vue +1 -5
- package/dist/runtime/app/pages/documents.vue +4 -3
- package/dist/runtime/app/utils/documents.d.ts +5 -2
- package/dist/runtime/app/utils/documents.js +2 -2
- package/package.json +11 -11
package/dist/module.d.mts
CHANGED
|
@@ -9,10 +9,11 @@ type AccountDocument = {
|
|
|
9
9
|
path: string;
|
|
10
10
|
icon?: string;
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
13
|
-
* user.
|
|
12
|
+
* The permission (`resource:action`) a user must hold to see the document listed. Omit to show it to every
|
|
13
|
+
* signed-in user. Needs `@frigear-nu/authorization`; without it a document with a permission is never listed. This only
|
|
14
|
+
* decides what is *listed*: a file in `public/` can still be fetched by anyone who knows its URL.
|
|
14
15
|
*/
|
|
15
|
-
|
|
16
|
+
permission?: string;
|
|
16
17
|
};
|
|
17
18
|
type PublicModuleOptions = {
|
|
18
19
|
pages: {
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -48,7 +48,18 @@ const module$1 = defineNuxtModule({
|
|
|
48
48
|
available: () => hasNuxtModule("@frigear-nu/menu", nuxt),
|
|
49
49
|
fallback: "undefined",
|
|
50
50
|
fallbackType: "undefined"
|
|
51
|
+
}, {
|
|
52
|
+
// `@frigear-nu/authorization` is optional: without it nothing can be checked, so permission-gated documents are hidden.
|
|
53
|
+
name: "useAuthorization",
|
|
54
|
+
available: () => hasNuxtModule("@frigear-nu/authorization", nuxt),
|
|
55
|
+
fallback: "undefined",
|
|
56
|
+
fallbackType: "undefined"
|
|
51
57
|
}]);
|
|
58
|
+
for (const document of settings.documents ?? []) {
|
|
59
|
+
if (document.roles !== void 0) {
|
|
60
|
+
throw new Error(`[@frigear-nu/account] \`account.settings.documents[].roles\` was removed (document "${document.id}"): use \`permission\` (a \`resource:action\` string) instead.`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
52
63
|
addImports([
|
|
53
64
|
{ name: "useAccount", from: resolver.resolve("./runtime/app/composables/useAccount") },
|
|
54
65
|
{ name: "useAccountNav", from: resolver.resolve("./runtime/app/composables/useAccountNav") }
|
|
@@ -48,11 +48,7 @@ const appearance = (label, value, icon) => ({
|
|
|
48
48
|
}
|
|
49
49
|
});
|
|
50
50
|
const items = computed(() => {
|
|
51
|
-
const visible = (dropdown.value ?? []).filter((item) =>
|
|
52
|
-
const roles = item.meta?.roles;
|
|
53
|
-
if (roles?.length && !(role.value && roles.includes(role.value))) return false;
|
|
54
|
-
return !item.to || item.external || item.method || !isHere(item.to);
|
|
55
|
-
});
|
|
51
|
+
const visible = (dropdown.value ?? []).filter((item) => !item.to || item.external || item.method || !isHere(item.to));
|
|
56
52
|
const last = (item) => (item.order ?? 0) >= 99;
|
|
57
53
|
return [
|
|
58
54
|
sessionUser.value ? [{ type: "label", label: displayName.value, slot: "account" }] : [],
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
<script setup>
|
|
2
2
|
import { documentLabel, visibleDocuments } from "../utils/documents";
|
|
3
|
-
import { computed, useModuleT, useNuxtApp, useRuntimeConfig
|
|
3
|
+
import { computed, useModuleT, useNuxtApp, useRuntimeConfig } from "#imports";
|
|
4
|
+
import { useAuthorization } from "#account/optional";
|
|
4
5
|
defineOptions({ name: "AccountDocumentsPage" });
|
|
5
6
|
const t = useModuleT("account.documents");
|
|
6
|
-
const
|
|
7
|
+
const authorization = typeof useAuthorization === "function" ? useAuthorization() : void 0;
|
|
7
8
|
const nuxtApp = useNuxtApp();
|
|
8
9
|
const locale = computed(() => nuxtApp.$i18n?.locale?.value ?? "en");
|
|
9
|
-
const documents = computed(() => visibleDocuments(useRuntimeConfig().public.account?.documents ?? [],
|
|
10
|
+
const documents = computed(() => visibleDocuments(useRuntimeConfig().public.account?.documents ?? [], authorization ? (permission) => authorization.can(permission) : void 0));
|
|
10
11
|
</script>
|
|
11
12
|
|
|
12
13
|
<template>
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import type { AccountDocument } from '../../../types.js';
|
|
2
2
|
/** Label in `locale`, falling back to `en`, then the first available value. */
|
|
3
3
|
export declare function documentLabel(document: AccountDocument, locale: string): string;
|
|
4
|
-
/**
|
|
5
|
-
|
|
4
|
+
/**
|
|
5
|
+
* The documents the viewer may see: everything without a `permission`, otherwise only those `can` allows. Without a `can`
|
|
6
|
+
* (no access layer installed) a document with a permission is hidden.
|
|
7
|
+
*/
|
|
8
|
+
export declare function visibleDocuments(documents: AccountDocument[], can?: (permission: string) => boolean): AccountDocument[];
|
|
@@ -2,6 +2,6 @@ export function documentLabel(document, locale) {
|
|
|
2
2
|
if (typeof document.label === "string") return document.label;
|
|
3
3
|
return document.label[locale] ?? document.label.en ?? Object.values(document.label)[0] ?? document.id;
|
|
4
4
|
}
|
|
5
|
-
export function visibleDocuments(documents,
|
|
6
|
-
return documents.filter((document) => !document.
|
|
5
|
+
export function visibleDocuments(documents, can) {
|
|
6
|
+
return documents.filter((document) => !document.permission || !!can?.(document.permission));
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@frigear-nu/account",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.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": {
|
|
@@ -24,10 +24,10 @@
|
|
|
24
24
|
"playground"
|
|
25
25
|
],
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@frigear-nu/auth": "^0.
|
|
28
|
-
"@frigear-nu/module-kit": "^1.3.
|
|
29
|
-
"@frigear-nu/ui": "^0.2.
|
|
30
|
-
"@frigear-nu/users": "^
|
|
27
|
+
"@frigear-nu/auth": "^0.5.0",
|
|
28
|
+
"@frigear-nu/module-kit": "^1.3.5",
|
|
29
|
+
"@frigear-nu/ui": "^0.2.6",
|
|
30
|
+
"@frigear-nu/users": "^3.0.0",
|
|
31
31
|
"@libsql/client": "^0.18.0",
|
|
32
32
|
"@nuxt/kit": "^4.6.4",
|
|
33
33
|
"@vueuse/core": "^15.0.0",
|
|
@@ -36,9 +36,9 @@
|
|
|
36
36
|
"zod": "^4.6.7"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
|
-
"@frigear-nu/authorization": "^0.
|
|
40
|
-
"@frigear-nu/menu": "^0.
|
|
41
|
-
"@frigear-nu/widget": "^0.
|
|
39
|
+
"@frigear-nu/authorization": "^0.5.0",
|
|
40
|
+
"@frigear-nu/menu": "^0.3.0",
|
|
41
|
+
"@frigear-nu/widget": "^0.3.0",
|
|
42
42
|
"@nuxt/ui": "^4.12.0",
|
|
43
43
|
"@nuxthub/core": "^0.10.12"
|
|
44
44
|
},
|
|
@@ -57,9 +57,9 @@
|
|
|
57
57
|
}
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
|
-
"@frigear-nu/authorization": "^0.
|
|
61
|
-
"@frigear-nu/menu": "^0.
|
|
62
|
-
"@frigear-nu/widget": "^0.
|
|
60
|
+
"@frigear-nu/authorization": "^0.5.0",
|
|
61
|
+
"@frigear-nu/menu": "^0.3.0",
|
|
62
|
+
"@frigear-nu/widget": "^0.3.0",
|
|
63
63
|
"@nuxt/devtools": "^4.1.0",
|
|
64
64
|
"@nuxt/eslint-config": "^1.17.0",
|
|
65
65
|
"@nuxt/module-builder": "^1.0.3",
|