@meistrari/auth-nuxt 3.13.1 → 3.14.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,7 +1,7 @@
1
1
  {
2
2
  "name": "@meistrari/auth-nuxt",
3
3
  "configKey": "telaAuth",
4
- "version": "3.13.1",
4
+ "version": "3.14.0",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.1"
@@ -1,4 +1,4 @@
1
- import type { AdminOrganization, CreateAdminOrganizationOptions, GetAdminOrganizationOptions, ListAdminApplicationsOptions, ListAdminApplicationsResult, ListAdminOrganizationMembersOptions, ListAdminOrganizationMembersResult, ListAdminOrganizationsOptions, ListAdminOrganizationsResult, ListAdminUsersOptions, ListAdminUsersResult, UpdateAdminOrganizationOptions } from '@meistrari/auth-core';
1
+ import type { AdminApplicationRecord, AdminOrganization, CreateAdminApplicationOptions, 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.
@@ -12,6 +12,12 @@ export interface UseTelaAdminReturn {
12
12
  * @returns The application listing with entitlement details
13
13
  */
14
14
  listApplications: (options?: ListAdminApplicationsOptions) => Promise<ListAdminApplicationsResult>;
15
+ /**
16
+ * Creates an application as a global admin.
17
+ * @param options - Application name, URLs, logo, and authentication settings
18
+ * @returns The created application
19
+ */
20
+ createApplication: (options: CreateAdminApplicationOptions) => Promise<AdminApplicationRecord>;
15
21
  /**
16
22
  * Lists all organizations as a global admin, optionally with member and
17
23
  * application previews and totals when a preview size is requested.
@@ -1,8 +1,11 @@
1
1
  import { useCookie, useRuntimeConfig } from "#app";
2
2
  import { createNuxtAuthClient } from "../shared.js";
3
- function buildListApplicationsUrl(apiUrl, options = {}) {
3
+ function buildApplicationsUrl(apiUrl) {
4
4
  const base = apiUrl.endsWith("/") ? apiUrl : `${apiUrl}/`;
5
- const url = new URL("applications/", base);
5
+ return new URL("applications/", base);
6
+ }
7
+ function buildListApplicationsUrl(apiUrl, options = {}) {
8
+ const url = buildApplicationsUrl(apiUrl);
6
9
  if (options.limit !== void 0)
7
10
  url.searchParams.set("limit", String(options.limit));
8
11
  if (options.membersPreview !== void 0)
@@ -49,6 +52,27 @@ export function useTelaAdmin() {
49
52
  }
50
53
  return await response.json();
51
54
  }
55
+ async function createApplication(options) {
56
+ const token = useCookie(jwtCookieName).value;
57
+ const headers = new Headers({
58
+ "Accept": "application/json",
59
+ "Content-Type": "application/json"
60
+ });
61
+ if (token) {
62
+ headers.set("Authorization", `Bearer ${token}`);
63
+ }
64
+ const response = await fetch(buildApplicationsUrl(apiUrl), {
65
+ body: JSON.stringify(options),
66
+ credentials: "include",
67
+ headers,
68
+ method: "POST"
69
+ });
70
+ if (!response.ok) {
71
+ const message = await parseAdminResponseError(response);
72
+ throw new Error(`Failed to create application: ${message}`);
73
+ }
74
+ return await response.json();
75
+ }
52
76
  async function listOrganizations(options) {
53
77
  return await authClient.admin.listOrganizations(options);
54
78
  }
@@ -67,6 +91,7 @@ export function useTelaAdmin() {
67
91
  return {
68
92
  listUsers,
69
93
  listApplications,
94
+ createApplication,
70
95
  listOrganizations,
71
96
  getOrganization,
72
97
  listOrganizationMembers,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meistrari/auth-nuxt",
3
- "version": "3.13.1",
3
+ "version": "3.14.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.24.0",
39
+ "@meistrari/auth-core": "1.25.0",
40
40
  "jose": "6.1.3"
41
41
  },
42
42
  "peerDependencies": {