@sfxcode/nuxt-ui-mongocamp 1.5.5 → 1.5.6

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.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "compatibility": {
5
5
  "nuxt": ">=3.16.0"
6
6
  },
7
- "version": "1.5.5",
7
+ "version": "1.5.6",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "1.0.4",
10
10
  "unbuild": "3.6.1"
@@ -17,13 +17,13 @@ declare const __VLS_template: () => {
17
17
  };
18
18
  type __VLS_Slots = ReturnType<typeof __VLS_template>['__VLS_Slots'];
19
19
  declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
20
- open: () => any;
21
20
  clear: () => any;
21
+ open: () => any;
22
22
  confirm: () => any;
23
23
  selectAll: () => any;
24
24
  }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
25
- onOpen?: (() => any) | undefined;
26
25
  onClear?: (() => any) | undefined;
26
+ onOpen?: (() => any) | undefined;
27
27
  onConfirm?: (() => any) | undefined;
28
28
  onSelectAll?: (() => any) | undefined;
29
29
  }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
@@ -17,13 +17,13 @@ declare const __VLS_template: () => {
17
17
  };
18
18
  type __VLS_Slots = ReturnType<typeof __VLS_template>['__VLS_Slots'];
19
19
  declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
20
- open: () => any;
21
20
  clear: () => any;
21
+ open: () => any;
22
22
  confirm: () => any;
23
23
  selectAll: () => any;
24
24
  }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
25
- onOpen?: (() => any) | undefined;
26
25
  onClear?: (() => any) | undefined;
26
+ onOpen?: (() => any) | undefined;
27
27
  onConfirm?: (() => any) | undefined;
28
28
  onSelectAll?: (() => any) | undefined;
29
29
  }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
@@ -7,17 +7,17 @@ type __VLS_ModelProps = {
7
7
  };
8
8
  type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
9
9
  declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
10
- "update:open": (value: boolean) => any;
11
10
  done: (payload: {
12
11
  target: string;
13
12
  copied: number;
14
13
  }) => any;
14
+ "update:open": (value: boolean) => any;
15
15
  }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
16
- "onUpdate:open"?: ((value: boolean) => any) | undefined;
17
16
  onDone?: ((payload: {
18
17
  target: string;
19
18
  copied: number;
20
19
  }) => any) | undefined;
20
+ "onUpdate:open"?: ((value: boolean) => any) | undefined;
21
21
  }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
22
22
  declare const _default: typeof __VLS_export;
23
23
  export default _default;
@@ -7,17 +7,17 @@ type __VLS_ModelProps = {
7
7
  };
8
8
  type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
9
9
  declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
10
- "update:open": (value: boolean) => any;
11
10
  done: (payload: {
12
11
  target: string;
13
12
  copied: number;
14
13
  }) => any;
14
+ "update:open": (value: boolean) => any;
15
15
  }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
16
- "onUpdate:open"?: ((value: boolean) => any) | undefined;
17
16
  onDone?: ((payload: {
18
17
  target: string;
19
18
  copied: number;
20
19
  }) => any) | undefined;
20
+ "onUpdate:open"?: ((value: boolean) => any) | undefined;
21
21
  }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
22
22
  declare const _default: typeof __VLS_export;
23
23
  export default _default;
@@ -6,17 +6,17 @@ type __VLS_ModelProps = {
6
6
  };
7
7
  type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
8
8
  declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
9
- "update:open": (value: boolean) => any;
10
9
  done: (payload: {
11
10
  source: string;
12
11
  target: string;
13
12
  }) => any;
13
+ "update:open": (value: boolean) => any;
14
14
  }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
15
- "onUpdate:open"?: ((value: boolean) => any) | undefined;
16
15
  onDone?: ((payload: {
17
16
  source: string;
18
17
  target: string;
19
18
  }) => any) | undefined;
19
+ "onUpdate:open"?: ((value: boolean) => any) | undefined;
20
20
  }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
21
21
  declare const _default: typeof __VLS_export;
22
22
  export default _default;
@@ -6,17 +6,17 @@ type __VLS_ModelProps = {
6
6
  };
7
7
  type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
8
8
  declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
9
- "update:open": (value: boolean) => any;
10
9
  done: (payload: {
11
10
  source: string;
12
11
  target: string;
13
12
  }) => any;
13
+ "update:open": (value: boolean) => any;
14
14
  }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
15
- "onUpdate:open"?: ((value: boolean) => any) | undefined;
16
15
  onDone?: ((payload: {
17
16
  source: string;
18
17
  target: string;
19
18
  }) => any) | undefined;
19
+ "onUpdate:open"?: ((value: boolean) => any) | undefined;
20
20
  }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
21
21
  declare const _default: typeof __VLS_export;
22
22
  export default _default;
@@ -19,11 +19,11 @@ type __VLS_ModelProps = {
19
19
  };
20
20
  type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
21
21
  declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
22
- "update:open": (value: boolean) => any;
23
22
  select: (entry: PaletteEntry) => any;
23
+ "update:open": (value: boolean) => any;
24
24
  }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
25
- "onUpdate:open"?: ((value: boolean) => any) | undefined;
26
25
  onSelect?: ((entry: PaletteEntry) => any) | undefined;
26
+ "onUpdate:open"?: ((value: boolean) => any) | undefined;
27
27
  }>, {
28
28
  shortcut: string;
29
29
  cacheMs: number;
@@ -19,11 +19,11 @@ type __VLS_ModelProps = {
19
19
  };
20
20
  type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
21
21
  declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
22
- "update:open": (value: boolean) => any;
23
22
  select: (entry: PaletteEntry) => any;
23
+ "update:open": (value: boolean) => any;
24
24
  }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
25
- "onUpdate:open"?: ((value: boolean) => any) | undefined;
26
25
  onSelect?: ((entry: PaletteEntry) => any) | undefined;
26
+ "onUpdate:open"?: ((value: boolean) => any) | undefined;
27
27
  }>, {
28
28
  shortcut: string;
29
29
  cacheMs: number;
@@ -2,15 +2,15 @@ import type { Grant, JsonSchema, JsonValueBoolean, Role, SchemaAnalysis, UserPro
2
2
  declare const _default: () => {
3
3
  listUsers: (filter?: string) => Promise<UserProfile[]>;
4
4
  addUser: (userId: string, password: string, apiKey?: string, roles?: string[]) => Promise<UserProfile>;
5
- deleteUser: (userId: string) => Promise<JsonValueBoolean>;
5
+ deleteUser: (userId: string) => Promise<any>;
6
6
  updateUserRoles: (userId: string, roles: string[]) => Promise<UserProfile>;
7
- updateUserPassword: (userId: string, password: string) => Promise<JsonValueBoolean>;
7
+ updateUserPassword: (userId: string, password: string) => Promise<any>;
8
8
  listRoles: (filter?: string) => Promise<Role[]>;
9
9
  addRole: (name: string, isAdmin?: boolean, collectionGrants?: Grant[]) => Promise<Role>;
10
10
  updateRole: (roleName: string, isAdmin: boolean, collectionGrants?: Grant[]) => Promise<Role>;
11
- deleteRole: (roleName: string) => Promise<JsonValueBoolean>;
11
+ deleteRole: (roleName: string) => Promise<any>;
12
12
  listCollections: () => Promise<string[]>;
13
- clearCollection: (collectionName: string) => Promise<JsonValueBoolean>;
13
+ clearCollection: (collectionName: string) => Promise<any>;
14
14
  deleteCollection: (collectionName: string) => Promise<JsonValueBoolean>;
15
15
  getJsonSchema: (collectionName: string) => Promise<JsonSchema>;
16
16
  getSchemaAnalysis: (collectionName: string, documents: number, depth?: number) => Promise<SchemaAnalysis>;
@@ -1,13 +1 @@
1
- export declare function useMongocampClientApi(): {
2
- adminApi: import("@sfxcode/nuxt-mongocamp-server").AdminApi;
3
- applicationApi: import("@sfxcode/nuxt-mongocamp-server").ApplicationApi;
4
- authApi: import("@sfxcode/nuxt-mongocamp-server").AuthApi;
5
- bucketApi: import("@sfxcode/nuxt-mongocamp-server").BucketApi;
6
- collectionApi: import("@sfxcode/nuxt-mongocamp-server").CollectionApi;
7
- databaseApi: import("@sfxcode/nuxt-mongocamp-server").DatabaseApi;
8
- documentApi: import("@sfxcode/nuxt-mongocamp-server").DocumentApi;
9
- fileApi: import("@sfxcode/nuxt-mongocamp-server").FileApi;
10
- indexApi: import("@sfxcode/nuxt-mongocamp-server").IndexApi;
11
- systemApi: import("@sfxcode/nuxt-mongocamp-server").SystemApi;
12
- jobApi: import("@sfxcode/nuxt-mongocamp-server").JobsApi;
13
- };
1
+ export declare function useMongocampClientApi(): any;
@@ -4,9 +4,11 @@
4
4
  *
5
5
  * `load()` asks the server (`GET /auth/permissions`, server 1.7.0), which resolves roles, grants and the signed-in
6
6
  * user's rights itself — and also works in server proxy mode, where there is no profile. `canRead` / `canWrite` /
7
- * `canAdminister` stay synchronous: they answer from what was loaded, and until then from the grants of the session profile
8
- * (admin, proxy mode, a profile without a grant list and GridFS bucket members answer "yes" — fail-open). A failing
9
- * `load()` changes nothing. Administrators are never asked: everything is allowed.
7
+ * `canAdminister` stay synchronous: they answer from what was loaded. After a full `load()` (no argument) a collection the
8
+ * server did not list has no grant ("no"); before any answer, or when it failed, they answer "yes" (fail-open — the server
9
+ * refuses). Admin, proxy mode, no profile and GridFS bucket members are "yes" too. **Grants are never read from the
10
+ * session** — neither from the token (server 1.9: only `user`/`isAdmin` are in it) nor from the stored profile, which the
11
+ * session cookie must not carry (4 KB cookie limit). Administrators are never asked: everything is allowed.
10
12
  */
11
13
  export declare function useMongocampPermissions(): {
12
14
  canRead: (collectionName: string) => boolean;
@@ -1,24 +1,22 @@
1
1
  import { useMongocampClientApi, useMongocampStorage, useState } from "#imports";
2
- import { permissionFromGrants } from "../utils/grantMatching.js";
2
+ import { isBucketMemberCollection } from "../utils/collectionProtection.js";
3
3
  import { useMongocampProxyMode } from "./useMongocampProxyMode.js";
4
4
  const REQUEST_TIMEOUT_MS = 15e3;
5
5
  export function useMongocampPermissions() {
6
6
  const state = useMongocampStorage();
7
- const cache = useState("mongocamp-permissions", () => ({ user: "", byName: {} }));
7
+ const cache = useState("mongocamp-permissions", () => ({ user: "", byName: {}, complete: false }));
8
8
  const isProxyMode = useMongocampProxyMode();
9
9
  const currentUser = () => state.value?.profile?.user ?? "";
10
10
  const key = (name) => name.trim().toLowerCase();
11
- function fromServer(collectionName) {
12
- if (cache.value.user !== currentUser()) return void 0;
13
- return cache.value.byName[key(collectionName)];
14
- }
11
+ const ownCache = () => cache.value.user === currentUser();
15
12
  function allowed(collectionName, permission) {
16
- const answered = fromServer(collectionName);
13
+ const answered = ownCache() ? cache.value.byName[key(collectionName)] : void 0;
17
14
  if (answered) return answered[permission];
18
15
  if (isProxyMode) return true;
19
16
  const profile = state.value?.profile;
20
17
  if (!profile || profile.isAdmin) return true;
21
- return permissionFromGrants(profile.grants, collectionName, permission) ?? true;
18
+ if (isBucketMemberCollection(collectionName)) return true;
19
+ return !(ownCache() && cache.value.complete);
22
20
  }
23
21
  const canRead = (collectionName) => allowed(collectionName, "read");
24
22
  const canWrite = (collectionName) => allowed(collectionName, "write");
@@ -32,9 +30,10 @@ export function useMongocampPermissions() {
32
30
  const { authApi } = useMongocampClientApi();
33
31
  const rows = await authApi.userPermissions(collectionName ? { collection: collectionName } : {}, { signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS) });
34
32
  const user = currentUser();
35
- const byName = cache.value.user === user ? { ...cache.value.byName } : {};
33
+ const same = cache.value.user === user;
34
+ const byName = same ? { ...cache.value.byName } : {};
36
35
  for (const row of rows) byName[key(row.name)] = { read: row.read, write: row.write, administrate: row.administrate };
37
- cache.value = { user, byName };
36
+ cache.value = { user, byName, complete: !collectionName || same && cache.value.complete };
38
37
  } catch {
39
38
  }
40
39
  }
@@ -1,10 +1,10 @@
1
1
  export declare function useMongocampRoles(): {
2
- isLoggedIn: import("vue").ComputedRef<boolean>;
3
- isAdmin: import("vue").ComputedRef<boolean>;
4
- isManager: import("vue").ComputedRef<boolean>;
2
+ isLoggedIn: any;
3
+ isAdmin: import("vue").ComputedRef<any>;
4
+ isManager: import("vue").ComputedRef<any>;
5
5
  isProxyMode: boolean;
6
- canSeeAdmin: import("vue").ComputedRef<boolean>;
7
- canSeeManagement: import("vue").ComputedRef<boolean>;
6
+ canSeeAdmin: import("vue").ComputedRef<any>;
7
+ canSeeManagement: import("vue").ComputedRef<any>;
8
8
  notAllowedPath: string;
9
9
  logoutRedirectPath: string;
10
10
  logoutPath: string;
@@ -1,6 +1,2 @@
1
- declare const _default: import("nuxt/app").Plugin<{
2
- mongocampVersion: import("vue").Ref<import("@sfxcode/nuxt-mongocamp-server").Version | undefined, import("@sfxcode/nuxt-mongocamp-server").Version | undefined>;
3
- }> & import("nuxt/app").ObjectPlugin<{
4
- mongocampVersion: import("vue").Ref<import("@sfxcode/nuxt-mongocamp-server").Version | undefined, import("@sfxcode/nuxt-mongocamp-server").Version | undefined>;
5
- }>;
1
+ declare const _default: any;
6
2
  export default _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sfxcode/nuxt-ui-mongocamp",
3
- "version": "1.5.5",
3
+ "version": "1.5.6",
4
4
  "description": "A Nuxt module that wraps @sfxcode/nuxt-mongocamp-server with ready-made UI components, composables, and a runtime plugin",
5
5
  "repository": "sfxcode/nuxt-ui-mongocamp",
6
6
  "homepage": "https://sfxcode.github.io/nuxt-ui-mongocamp/",
@@ -66,7 +66,7 @@
66
66
  "@internationalized/date": "^3.12.4",
67
67
  "@nuxt/ui": "^4.12.0",
68
68
  "@nuxtjs/i18n": "^10.6.0",
69
- "@sfxcode/nuxt-mongocamp-server": "^1.9.1",
69
+ "@sfxcode/nuxt-mongocamp-server": "^1.9.2",
70
70
  "@sfxcode/nuxt-ui-formkit": "^1.4.2",
71
71
  "@tanstack/charts": "^1.5.0",
72
72
  "@tanstack/vue-table": "^8.21.3",
@@ -76,8 +76,8 @@
76
76
  "unocss-nuxt-ui": "^1.3.0"
77
77
  },
78
78
  "devDependencies": {
79
- "@iconify-json/lucide": "^1.2.154",
80
- "@nuxt/devtools": "^4.1.0",
79
+ "@iconify-json/lucide": "^1.2.155",
80
+ "@nuxt/devtools": "^4.2.0",
81
81
  "@nuxt/eslint-config": "^1.17.0",
82
82
  "@nuxt/kit": "^4.6.4",
83
83
  "@nuxt/module-builder": "^1.0.4",
@@ -86,7 +86,7 @@
86
86
  "@playwright/test": "^1.65.1",
87
87
  "@types/node": "latest",
88
88
  "@unhead/vue": "^3.4.3",
89
- "@vue/test-utils": "^2.5.1",
89
+ "@vue/test-utils": "^2.6.0",
90
90
  "changelogen": "^0.6.2",
91
91
  "eslint": "^10.15.0",
92
92
  "happy-dom": "^21.0.4",