@meistrari/auth-nuxt 3.11.0 → 3.13.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.json +1 -1
- package/dist/module.mjs +5 -0
- package/dist/runtime/composables/admin.d.ts +7 -1
- package/dist/runtime/composables/admin.js +44 -0
- package/dist/runtime/composables/core-auth-client.d.ts +10 -0
- package/dist/runtime/composables/core-auth-client.js +12 -0
- package/package.json +2 -2
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -115,6 +115,11 @@ const module$1 = defineNuxtModule({
|
|
|
115
115
|
as: "useTelaOrganization",
|
|
116
116
|
from: resolver.resolve("runtime/composables/organization")
|
|
117
117
|
});
|
|
118
|
+
addImports({
|
|
119
|
+
name: "useCoreAuthClient",
|
|
120
|
+
as: "useCoreAuthClient",
|
|
121
|
+
from: resolver.resolve("runtime/composables/core-auth-client")
|
|
122
|
+
});
|
|
118
123
|
addImports({
|
|
119
124
|
name: "useTelaAdmin",
|
|
120
125
|
as: "useTelaAdmin",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AdminOrganization, CreateAdminOrganizationOptions, GetAdminOrganizationOptions, ListAdminOrganizationMembersOptions, ListAdminOrganizationMembersResult, ListAdminOrganizationsOptions, ListAdminOrganizationsResult, ListAdminUsersOptions, ListAdminUsersResult, UpdateAdminOrganizationOptions } from '@meistrari/auth-core';
|
|
1
|
+
import type { AdminOrganization, CreateAdminOrganizationOptions, GetAdminOrganizationOptions, ListAdminApplicationsOptions, ListAdminApplicationsResult, ListAdminOrganizationMembersOptions, ListAdminOrganizationMembersResult, ListAdminOrganizationsOptions, ListAdminOrganizationsResult, ListAdminUsersOptions, ListAdminUsersResult, UpdateAdminOrganizationOptions } from '@meistrari/auth-core';
|
|
2
2
|
export interface UseTelaAdminReturn {
|
|
3
3
|
/**
|
|
4
4
|
* Lists users from the Better Auth `user` table as a global admin.
|
|
@@ -6,6 +6,12 @@ export interface UseTelaAdminReturn {
|
|
|
6
6
|
* @returns The paginated user listing
|
|
7
7
|
*/
|
|
8
8
|
listUsers: (options?: ListAdminUsersOptions) => Promise<ListAdminUsersResult>;
|
|
9
|
+
/**
|
|
10
|
+
* Lists applications as a global admin, optionally filtered by organization.
|
|
11
|
+
* @param options - Pagination, ordering, organization filter, and search options
|
|
12
|
+
* @returns The application listing with entitlement details
|
|
13
|
+
*/
|
|
14
|
+
listApplications: (options?: ListAdminApplicationsOptions) => Promise<ListAdminApplicationsResult>;
|
|
9
15
|
/**
|
|
10
16
|
* Lists all organizations as a global admin, optionally with member and
|
|
11
17
|
* application previews and totals when a preview size is requested.
|
|
@@ -1,11 +1,54 @@
|
|
|
1
1
|
import { useCookie, useRuntimeConfig } from "#app";
|
|
2
2
|
import { createNuxtAuthClient } from "../shared.js";
|
|
3
|
+
function buildListApplicationsUrl(apiUrl, options = {}) {
|
|
4
|
+
const base = apiUrl.endsWith("/") ? apiUrl : `${apiUrl}/`;
|
|
5
|
+
const url = new URL("applications/", base);
|
|
6
|
+
if (options.limit !== void 0)
|
|
7
|
+
url.searchParams.set("limit", String(options.limit));
|
|
8
|
+
if (options.membersPreview !== void 0)
|
|
9
|
+
url.searchParams.set("membersPreview", String(options.membersPreview));
|
|
10
|
+
if (options.offset !== void 0)
|
|
11
|
+
url.searchParams.set("offset", String(options.offset));
|
|
12
|
+
if (options.orderBy)
|
|
13
|
+
url.searchParams.set("orderBy", options.orderBy);
|
|
14
|
+
if (options.orderDirection)
|
|
15
|
+
url.searchParams.set("orderDirection", options.orderDirection);
|
|
16
|
+
if (options.organizationId)
|
|
17
|
+
url.searchParams.set("organizationId", options.organizationId);
|
|
18
|
+
if (options.search)
|
|
19
|
+
url.searchParams.set("search", options.search);
|
|
20
|
+
return url;
|
|
21
|
+
}
|
|
22
|
+
async function parseAdminResponseError(response) {
|
|
23
|
+
try {
|
|
24
|
+
const body = await response.json();
|
|
25
|
+
return body.error ?? body.message ?? response.statusText;
|
|
26
|
+
} catch {
|
|
27
|
+
return response.statusText;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
3
30
|
export function useTelaAdmin() {
|
|
4
31
|
const { jwtCookieName, apiUrl } = useRuntimeConfig().public.telaAuth;
|
|
5
32
|
const authClient = createNuxtAuthClient(apiUrl, () => useCookie(jwtCookieName).value ?? null);
|
|
6
33
|
async function listUsers(options) {
|
|
7
34
|
return await authClient.admin.listUsers(options);
|
|
8
35
|
}
|
|
36
|
+
async function listApplications(options) {
|
|
37
|
+
const token = useCookie(jwtCookieName).value;
|
|
38
|
+
const headers = new Headers({ Accept: "application/json" });
|
|
39
|
+
if (token) {
|
|
40
|
+
headers.set("Authorization", `Bearer ${token}`);
|
|
41
|
+
}
|
|
42
|
+
const response = await fetch(buildListApplicationsUrl(apiUrl, options), {
|
|
43
|
+
credentials: "include",
|
|
44
|
+
headers
|
|
45
|
+
});
|
|
46
|
+
if (!response.ok) {
|
|
47
|
+
const message = await parseAdminResponseError(response);
|
|
48
|
+
throw new Error(`Failed to list applications: ${message}`);
|
|
49
|
+
}
|
|
50
|
+
return await response.json();
|
|
51
|
+
}
|
|
9
52
|
async function listOrganizations(options) {
|
|
10
53
|
return await authClient.admin.listOrganizations(options);
|
|
11
54
|
}
|
|
@@ -23,6 +66,7 @@ export function useTelaAdmin() {
|
|
|
23
66
|
}
|
|
24
67
|
return {
|
|
25
68
|
listUsers,
|
|
69
|
+
listApplications,
|
|
26
70
|
listOrganizations,
|
|
27
71
|
getOrganization,
|
|
28
72
|
listOrganizationMembers,
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { AuthClient } from '@meistrari/auth-core';
|
|
2
|
+
/**
|
|
3
|
+
* **DO NOT USE** this directly unless you're working on the internals of the Auth System.
|
|
4
|
+
*
|
|
5
|
+
* Allows access to the core AuthClient instance configured for use within a Nuxt application.
|
|
6
|
+
* This makes it possible to use SDKs features not directly exposed by the `@meistrari/auth-nuxt` package.
|
|
7
|
+
*
|
|
8
|
+
* @returns The configured core AuthClient instance
|
|
9
|
+
*/
|
|
10
|
+
export declare function useCoreAuthClient(): AuthClient;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { useCookie, useRuntimeConfig } from "#app";
|
|
2
|
+
import { createNuxtAuthClient } from "../shared.js";
|
|
3
|
+
let client;
|
|
4
|
+
export function useCoreAuthClient() {
|
|
5
|
+
const { application, apiUrl, jwtCookieName } = useRuntimeConfig().public.telaAuth;
|
|
6
|
+
if (application?.enabled) {
|
|
7
|
+
throw new Error("Core AuthClient is not available for applications");
|
|
8
|
+
}
|
|
9
|
+
const cookie = useCookie(jwtCookieName);
|
|
10
|
+
client ??= createNuxtAuthClient(apiUrl, () => cookie.value ?? null);
|
|
11
|
+
return client;
|
|
12
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meistrari/auth-nuxt",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.13.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"docs": "nuxt-module-build prepare && typedoc"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@meistrari/auth-core": "1.
|
|
39
|
+
"@meistrari/auth-core": "1.24.0",
|
|
40
40
|
"jose": "6.1.3"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|