@meistrari/auth-nuxt 3.23.1 → 3.25.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
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AdminApplicationRecord, AdminApplicationEntitlementRecord, AdminOrganization, AdminOrganizationSummary, AdminOrganizationTeamRecord, AdminUser, AdminUserAccess, CreateAdminApplicationEntitlementOptions, CreateAdminApplicationOptions, CreateAdminOrganizationOptions, CreateAdminOrganizationTeamOptions, GetAdminOrganizationOptions, GetAdminOrganizationsSummaryOptions, InviteAdminOrganizationUsersOptions, InviteAdminOrganizationUsersResult, ListAdminApplicationsOptions, ListAdminApplicationsResult, ListAdminOrganizationMembersOptions, ListAdminOrganizationMembersResult, ListAdminOrganizationsOptions, ListAdminOrganizationsResult, ListAdminOrganizationTeamsOptions, ListAdminOrganizationTeamsResult, ListAdminUsersOptions, ListAdminUsersResult, AdminMember, RemoveAdminMemberOptions, ResendAdminInviteOptions, SetAdminUserApplicationRoleOptions, SetAdminUserTeamOptions, UpdateAdminMemberRoleOptions, UpdateAdminOrganizationOptions } from '@meistrari/auth-core';
|
|
1
|
+
import type { AdminApplicationRecord, AdminApplicationRole, AdminApplicationEntitlementRecord, AdminEntitlementWithRules, AdminOrganization, AdminOrganizationSummary, AdminOrganizationTeamRecord, AdminUser, AdminUserAccess, CreateAdminApplicationEntitlementOptions, CreateAdminApplicationOptions, CreateAdminApplicationRoleOptions, CreateAdminOrganizationOptions, CreateAdminOrganizationTeamOptions, GetAdminOrganizationOptions, GetAdminOrganizationsSummaryOptions, InviteAdminOrganizationUsersOptions, InviteAdminOrganizationUsersResult, ListAdminApplicationsOptions, ListAdminApplicationsResult, ListAdminOrganizationMembersOptions, ListAdminOrganizationMembersResult, ListAdminOrganizationsOptions, ListAdminOrganizationsResult, ListAdminOrganizationTeamsOptions, ListAdminOrganizationTeamsResult, ListAdminUsersOptions, ListAdminUsersResult, AdminMember, RemoveAdminMemberOptions, ResendAdminInviteOptions, SetAdminEntitlementRulesOptions, SetAdminUserApplicationRoleOptions, SetAdminUserTeamOptions, UpdateAdminEntitlementOptions, UpdateAdminApplicationRoleOptions, UpdateAdminMemberRoleOptions, UpdateAdminOrganizationOptions } from '@meistrari/auth-core';
|
|
2
2
|
export interface UseTelaAdminReturn {
|
|
3
3
|
/**
|
|
4
4
|
* Lists users as a global admin, optionally with organization previews
|
|
@@ -32,6 +32,14 @@ export interface UseTelaAdminReturn {
|
|
|
32
32
|
* @returns The updated application
|
|
33
33
|
*/
|
|
34
34
|
updateApplication: (applicationId: string, options: CreateAdminApplicationOptions) => Promise<AdminApplicationRecord>;
|
|
35
|
+
/** Lists application-scoped role definitions. */
|
|
36
|
+
listApplicationRoles: (applicationId: string) => Promise<AdminApplicationRole[]>;
|
|
37
|
+
/** Creates an application-scoped role definition. */
|
|
38
|
+
createApplicationRole: (applicationId: string, options: CreateAdminApplicationRoleOptions) => Promise<AdminApplicationRole>;
|
|
39
|
+
/** Updates an application-scoped role definition. */
|
|
40
|
+
updateApplicationRole: (applicationId: string, currentName: string, options: UpdateAdminApplicationRoleOptions) => Promise<AdminApplicationRole>;
|
|
41
|
+
/** Deletes an application-scoped role definition. */
|
|
42
|
+
deleteApplicationRole: (applicationId: string, name: string) => Promise<AdminApplicationRole>;
|
|
35
43
|
/**
|
|
36
44
|
* Enables an organization for an application as a global admin.
|
|
37
45
|
* @param applicationId - ID of the application to update
|
|
@@ -39,6 +47,32 @@ export interface UseTelaAdminReturn {
|
|
|
39
47
|
* @returns The created entitlement
|
|
40
48
|
*/
|
|
41
49
|
createApplicationEntitlement: (applicationId: string, options: CreateAdminApplicationEntitlementOptions) => Promise<AdminApplicationEntitlementRecord>;
|
|
50
|
+
/**
|
|
51
|
+
* Fetches a single entitlement together with its ordered access rules.
|
|
52
|
+
* @param entitlementId - ID of the entitlement to fetch
|
|
53
|
+
* @returns The entitlement and its rules
|
|
54
|
+
*/
|
|
55
|
+
getEntitlement: (entitlementId: string) => Promise<AdminEntitlementWithRules>;
|
|
56
|
+
/**
|
|
57
|
+
* Replaces all access rules on an entitlement in a single call.
|
|
58
|
+
* @param entitlementId - ID of the entitlement whose rules are replaced
|
|
59
|
+
* @param options - The full set of rules to persist
|
|
60
|
+
* @returns The entitlement with the saved rules
|
|
61
|
+
*/
|
|
62
|
+
setEntitlementRules: (entitlementId: string, options: SetAdminEntitlementRulesOptions) => Promise<AdminEntitlementWithRules>;
|
|
63
|
+
/**
|
|
64
|
+
* Enables or disables an entitlement.
|
|
65
|
+
* @param entitlementId - ID of the entitlement to update
|
|
66
|
+
* @param options - The desired enabled state
|
|
67
|
+
* @returns The updated entitlement
|
|
68
|
+
*/
|
|
69
|
+
updateEntitlement: (entitlementId: string, options: UpdateAdminEntitlementOptions) => Promise<AdminApplicationEntitlementRecord>;
|
|
70
|
+
/**
|
|
71
|
+
* Deletes an entitlement and all of its access rules.
|
|
72
|
+
* @param entitlementId - ID of the entitlement to delete
|
|
73
|
+
* @returns The deleted entitlement
|
|
74
|
+
*/
|
|
75
|
+
deleteEntitlement: (entitlementId: string) => Promise<AdminApplicationEntitlementRecord>;
|
|
42
76
|
/**
|
|
43
77
|
* Lists all organizations as a global admin, optionally with member and
|
|
44
78
|
* application previews and totals when a preview size is requested.
|
|
@@ -161,6 +195,9 @@ export interface UseTelaAdminReturn {
|
|
|
161
195
|
* Composable for global admin operations.
|
|
162
196
|
*
|
|
163
197
|
* All operations require the authenticated user to hold the global admin role.
|
|
198
|
+
* The admin API authenticates first-party callers with the session cookie, so
|
|
199
|
+
* this client never attaches the JWT: the API reads a bearer token only as an
|
|
200
|
+
* internal API key and rejects anything else.
|
|
164
201
|
*
|
|
165
202
|
* @returns An object containing admin management functions.
|
|
166
203
|
*/
|
|
@@ -1,44 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useRuntimeConfig } from "#app";
|
|
2
2
|
import { createNuxtAuthClient } from "../shared.js";
|
|
3
|
-
function buildApplicationsUrl(apiUrl) {
|
|
4
|
-
const base = apiUrl.endsWith("/") ? apiUrl : `${apiUrl}/`;
|
|
5
|
-
return new URL("applications/", base);
|
|
6
|
-
}
|
|
7
|
-
function buildApplicationUrl(apiUrl, applicationId) {
|
|
8
|
-
return new URL(encodeURIComponent(applicationId), buildApplicationsUrl(apiUrl));
|
|
9
|
-
}
|
|
10
|
-
function buildApplicationEntitlementsUrl(apiUrl, applicationId) {
|
|
11
|
-
return new URL("entitlements", `${buildApplicationUrl(apiUrl, applicationId).toString()}/`);
|
|
12
|
-
}
|
|
13
|
-
function buildListApplicationsUrl(apiUrl, options = {}) {
|
|
14
|
-
const url = buildApplicationsUrl(apiUrl);
|
|
15
|
-
if (options.limit !== void 0)
|
|
16
|
-
url.searchParams.set("limit", String(options.limit));
|
|
17
|
-
if (options.membersPreview !== void 0)
|
|
18
|
-
url.searchParams.set("membersPreview", String(options.membersPreview));
|
|
19
|
-
if (options.offset !== void 0)
|
|
20
|
-
url.searchParams.set("offset", String(options.offset));
|
|
21
|
-
if (options.orderBy)
|
|
22
|
-
url.searchParams.set("orderBy", options.orderBy);
|
|
23
|
-
if (options.orderDirection)
|
|
24
|
-
url.searchParams.set("orderDirection", options.orderDirection);
|
|
25
|
-
if (options.organizationId)
|
|
26
|
-
url.searchParams.set("organizationId", options.organizationId);
|
|
27
|
-
if (options.search)
|
|
28
|
-
url.searchParams.set("search", options.search);
|
|
29
|
-
return url;
|
|
30
|
-
}
|
|
31
|
-
async function parseAdminResponseError(response) {
|
|
32
|
-
try {
|
|
33
|
-
const body = await response.json();
|
|
34
|
-
return body.error ?? body.message ?? response.statusText;
|
|
35
|
-
} catch {
|
|
36
|
-
return response.statusText;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
3
|
export function useTelaAdmin() {
|
|
40
|
-
const {
|
|
41
|
-
const authClient = createNuxtAuthClient(apiUrl, () =>
|
|
4
|
+
const { apiUrl } = useRuntimeConfig().public.telaAuth;
|
|
5
|
+
const authClient = createNuxtAuthClient(apiUrl, () => null);
|
|
42
6
|
async function listUsers(options) {
|
|
43
7
|
return await authClient.admin.listUsers(options);
|
|
44
8
|
}
|
|
@@ -46,83 +10,28 @@ export function useTelaAdmin() {
|
|
|
46
10
|
return await authClient.admin.getUser(userId);
|
|
47
11
|
}
|
|
48
12
|
async function listApplications(options) {
|
|
49
|
-
|
|
50
|
-
const headers = new Headers({ Accept: "application/json" });
|
|
51
|
-
if (token) {
|
|
52
|
-
headers.set("Authorization", `Bearer ${token}`);
|
|
53
|
-
}
|
|
54
|
-
const response = await fetch(buildListApplicationsUrl(apiUrl, options), {
|
|
55
|
-
credentials: "include",
|
|
56
|
-
headers
|
|
57
|
-
});
|
|
58
|
-
if (!response.ok) {
|
|
59
|
-
const message = await parseAdminResponseError(response);
|
|
60
|
-
throw new Error(`Failed to list applications: ${message}`);
|
|
61
|
-
}
|
|
62
|
-
return await response.json();
|
|
13
|
+
return await authClient.admin.listApplications(options);
|
|
63
14
|
}
|
|
64
15
|
async function createApplication(options) {
|
|
65
|
-
|
|
66
|
-
const headers = new Headers({
|
|
67
|
-
"Accept": "application/json",
|
|
68
|
-
"Content-Type": "application/json"
|
|
69
|
-
});
|
|
70
|
-
if (token) {
|
|
71
|
-
headers.set("Authorization", `Bearer ${token}`);
|
|
72
|
-
}
|
|
73
|
-
const response = await fetch(buildApplicationsUrl(apiUrl), {
|
|
74
|
-
body: JSON.stringify(options),
|
|
75
|
-
credentials: "include",
|
|
76
|
-
headers,
|
|
77
|
-
method: "POST"
|
|
78
|
-
});
|
|
79
|
-
if (!response.ok) {
|
|
80
|
-
const message = await parseAdminResponseError(response);
|
|
81
|
-
throw new Error(`Failed to create application: ${message}`);
|
|
82
|
-
}
|
|
83
|
-
return await response.json();
|
|
16
|
+
return await authClient.admin.createApplication(options);
|
|
84
17
|
}
|
|
85
18
|
async function updateApplication(applicationId, options) {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
});
|
|
100
|
-
if (!response.ok) {
|
|
101
|
-
const message = await parseAdminResponseError(response);
|
|
102
|
-
throw new Error(`Failed to update application: ${message}`);
|
|
103
|
-
}
|
|
104
|
-
return await response.json();
|
|
19
|
+
return await authClient.admin.updateApplication(applicationId, options);
|
|
20
|
+
}
|
|
21
|
+
async function listApplicationRoles(applicationId) {
|
|
22
|
+
return await authClient.admin.listApplicationRoles(applicationId);
|
|
23
|
+
}
|
|
24
|
+
async function createApplicationRole(applicationId, options) {
|
|
25
|
+
return await authClient.admin.createApplicationRole(applicationId, options);
|
|
26
|
+
}
|
|
27
|
+
async function updateApplicationRole(applicationId, currentName, options) {
|
|
28
|
+
return await authClient.admin.updateApplicationRole(applicationId, currentName, options);
|
|
29
|
+
}
|
|
30
|
+
async function deleteApplicationRole(applicationId, name) {
|
|
31
|
+
return await authClient.admin.deleteApplicationRole(applicationId, name);
|
|
105
32
|
}
|
|
106
33
|
async function createApplicationEntitlement(applicationId, options) {
|
|
107
|
-
|
|
108
|
-
const headers = new Headers({
|
|
109
|
-
"Accept": "application/json",
|
|
110
|
-
"Content-Type": "application/json"
|
|
111
|
-
});
|
|
112
|
-
if (token) {
|
|
113
|
-
headers.set("Authorization", `Bearer ${token}`);
|
|
114
|
-
}
|
|
115
|
-
const response = await fetch(buildApplicationEntitlementsUrl(apiUrl, applicationId), {
|
|
116
|
-
body: JSON.stringify(options),
|
|
117
|
-
credentials: "include",
|
|
118
|
-
headers,
|
|
119
|
-
method: "POST"
|
|
120
|
-
});
|
|
121
|
-
if (!response.ok) {
|
|
122
|
-
const message = await parseAdminResponseError(response);
|
|
123
|
-
throw new Error(`Failed to add organization to application: ${message}`);
|
|
124
|
-
}
|
|
125
|
-
return await response.json();
|
|
34
|
+
return await authClient.admin.createApplicationEntitlement(applicationId, options);
|
|
126
35
|
}
|
|
127
36
|
async function listOrganizations(options) {
|
|
128
37
|
return await authClient.admin.listOrganizations(options);
|
|
@@ -145,6 +54,18 @@ export function useTelaAdmin() {
|
|
|
145
54
|
async function getUserAccess(userId) {
|
|
146
55
|
return await authClient.admin.getUserAccess(userId);
|
|
147
56
|
}
|
|
57
|
+
async function getEntitlement(entitlementId) {
|
|
58
|
+
return await authClient.admin.getEntitlement(entitlementId);
|
|
59
|
+
}
|
|
60
|
+
async function setEntitlementRules(entitlementId, options) {
|
|
61
|
+
return await authClient.admin.setEntitlementRules(entitlementId, options);
|
|
62
|
+
}
|
|
63
|
+
async function updateEntitlement(entitlementId, options) {
|
|
64
|
+
return await authClient.admin.updateEntitlement(entitlementId, options);
|
|
65
|
+
}
|
|
66
|
+
async function deleteEntitlement(entitlementId) {
|
|
67
|
+
return await authClient.admin.deleteEntitlement(entitlementId);
|
|
68
|
+
}
|
|
148
69
|
async function createOrganization(options) {
|
|
149
70
|
return await authClient.admin.createOrganization(options);
|
|
150
71
|
}
|
|
@@ -187,7 +108,15 @@ export function useTelaAdmin() {
|
|
|
187
108
|
listApplications,
|
|
188
109
|
createApplication,
|
|
189
110
|
updateApplication,
|
|
111
|
+
listApplicationRoles,
|
|
112
|
+
createApplicationRole,
|
|
113
|
+
updateApplicationRole,
|
|
114
|
+
deleteApplicationRole,
|
|
190
115
|
createApplicationEntitlement,
|
|
116
|
+
getEntitlement,
|
|
117
|
+
setEntitlementRules,
|
|
118
|
+
updateEntitlement,
|
|
119
|
+
deleteEntitlement,
|
|
191
120
|
listOrganizations,
|
|
192
121
|
getOrganization,
|
|
193
122
|
getOrganizationsSummary,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meistrari/auth-nuxt",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.25.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.35.0",
|
|
40
40
|
"jose": "6.1.3"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|