@meistrari/auth-nuxt 3.13.0 → 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/README.md CHANGED
@@ -7,7 +7,7 @@ A Nuxt module for authentication, organization management, and API key capabilit
7
7
  This SDK supports two authentication models:
8
8
 
9
9
  - **Application Authentication (recommended)**: Use this for product applications that need end-user authentication and authorization scoped to a specific application. See [Application Authentication Guide](./docs/APPLICATION_AUTH.md).
10
- - **First-Party Authentication**: Use this only for trusted first-party tools that interact directly with the Auth API in an administrative way, such as the Auth Dashboard and Backoffice. See [First-Party Authentication Guide](./docs/FIRST_PARTY_AUTH.md).
10
+ - **First-Party Authentication**: Use this only for trusted first-party tools that interact directly with the Auth API in an administrative way, such as the Accounts Dashboard and Backoffice. See [First-Party Authentication Guide](./docs/FIRST_PARTY_AUTH.md).
11
11
 
12
12
  ## Installation
13
13
 
package/dist/module.d.mts CHANGED
@@ -33,7 +33,7 @@ interface ModuleOptions {
33
33
  application?: {
34
34
  /** Whether to enable application authentication */
35
35
  enabled: boolean;
36
- /** Auth Dashboard URL */
36
+ /** Accounts Dashboard URL */
37
37
  dashboardUrl: string;
38
38
  /** The ID of the application to authenticate with */
39
39
  applicationId: string;
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.0",
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,
@@ -10,7 +10,7 @@ export interface UseTelaApplicationAuthReturn {
10
10
  *
11
11
  * Calls the server route to generate state and challenge. The server stores the
12
12
  * verifier securely and returns only the challenge and state to the client.
13
- * Then redirects to the auth dashboard login page.
13
+ * Then redirects to the accounts dashboard login page.
14
14
  *
15
15
  * @throws {AuthorizationFlowError} If called on the server
16
16
  */
@@ -87,7 +87,7 @@ export interface UseTelaApplicationAuthReturn {
87
87
  * from the returned state.
88
88
  *
89
89
  * @returns An object containing authentication state and methods
90
- * @throws {Error} If auth dashboard URL is not configured
90
+ * @throws {Error} If accounts dashboard URL is not configured
91
91
  *
92
92
  * @example
93
93
  * ```ts
@@ -15,7 +15,7 @@ export function useTelaApplicationAuth() {
15
15
  const state = useApplicationSessionState();
16
16
  if (!appConfig.application?.dashboardUrl) {
17
17
  throw new Error(
18
- "[Tela Auth SDK] Auth dashboard URL is not configured, but it is required to use application authentication."
18
+ "[Tela Auth SDK] Accounts dashboard URL is not configured, but it is required to use application authentication."
19
19
  );
20
20
  }
21
21
  if (!appConfig.application?.applicationId) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meistrari/auth-nuxt",
3
- "version": "3.13.0",
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": {