@meistrari/auth-core 1.7.0 → 1.7.1

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/index.d.mts CHANGED
@@ -2706,7 +2706,7 @@ declare function createAPIClient(apiUrl: string, fetchOptions?: BetterFetchOptio
2706
2706
  data: CompleteAuthorizationFlowResponse;
2707
2707
  error: null;
2708
2708
  }>;
2709
- refreshAccessToken: (refreshToken?: string) => Promise<{
2709
+ refreshAccessToken: (refreshToken: string) => Promise<{
2710
2710
  data: null;
2711
2711
  error: {
2712
2712
  message?: string | undefined;
@@ -2717,7 +2717,7 @@ declare function createAPIClient(apiUrl: string, fetchOptions?: BetterFetchOptio
2717
2717
  data: CompleteAuthorizationFlowResponse;
2718
2718
  error: null;
2719
2719
  }>;
2720
- whoAmI: (accessToken?: string) => Promise<{
2720
+ whoAmI: (accessToken: string) => Promise<{
2721
2721
  data: null;
2722
2722
  error: {
2723
2723
  message?: string | undefined;
@@ -2728,7 +2728,7 @@ declare function createAPIClient(apiUrl: string, fetchOptions?: BetterFetchOptio
2728
2728
  data: WhoAmIResponse;
2729
2729
  error: null;
2730
2730
  }>;
2731
- switchOrganization: (organizationId: string, accessToken?: string) => Promise<{
2731
+ switchOrganization: (organizationId: string, accessToken: string) => Promise<{
2732
2732
  data: null;
2733
2733
  error: {
2734
2734
  message?: string | undefined;
@@ -5669,7 +5669,7 @@ declare const stub: {
5669
5669
  data: CompleteAuthorizationFlowResponse;
5670
5670
  error: null;
5671
5671
  }>;
5672
- refreshAccessToken: (refreshToken?: string) => Promise<{
5672
+ refreshAccessToken: (refreshToken: string) => Promise<{
5673
5673
  data: null;
5674
5674
  error: {
5675
5675
  message?: string | undefined;
@@ -5680,7 +5680,7 @@ declare const stub: {
5680
5680
  data: CompleteAuthorizationFlowResponse;
5681
5681
  error: null;
5682
5682
  }>;
5683
- whoAmI: (accessToken?: string) => Promise<{
5683
+ whoAmI: (accessToken: string) => Promise<{
5684
5684
  data: null;
5685
5685
  error: {
5686
5686
  message?: string | undefined;
@@ -5691,7 +5691,7 @@ declare const stub: {
5691
5691
  data: WhoAmIResponse;
5692
5692
  error: null;
5693
5693
  }>;
5694
- switchOrganization: (organizationId: string, accessToken?: string) => Promise<{
5694
+ switchOrganization: (organizationId: string, accessToken: string) => Promise<{
5695
5695
  data: null;
5696
5696
  error: {
5697
5697
  message?: string | undefined;
@@ -6247,14 +6247,14 @@ declare class ApplicationService {
6247
6247
  * @throws {RefreshTokenExpiredError} When the refresh token has expired or is invalid
6248
6248
  * @throws {ApplicationError} For other API errors
6249
6249
  */
6250
- refreshAccessToken(): Promise<CompleteAuthorizationFlowResponse>;
6250
+ refreshAccessToken(refreshToken: string): Promise<CompleteAuthorizationFlowResponse>;
6251
6251
  /**
6252
6252
  * Gets the current user and organization for a specific application.
6253
6253
  *
6254
6254
  * @param accessToken - The access token to use for the who am I request
6255
6255
  * @returns The current user and organization
6256
6256
  */
6257
- whoAmI(accessToken?: string): Promise<WhoAmIResponse>;
6257
+ whoAmI(accessToken: string): Promise<WhoAmIResponse>;
6258
6258
  /**
6259
6259
  * Switches the active organization for the authenticated user.
6260
6260
  *
@@ -6266,7 +6266,7 @@ declare class ApplicationService {
6266
6266
  * @param accessToken - Optional access token for authentication (uses cookie if not provided)
6267
6267
  * @returns New authentication tokens and user/organization details
6268
6268
  */
6269
- switchOrganization(organizationId: string, accessToken?: string): Promise<CompleteAuthorizationFlowResponse>;
6269
+ switchOrganization(organizationId: string, accessToken: string): Promise<CompleteAuthorizationFlowResponse>;
6270
6270
  }
6271
6271
 
6272
6272
  type UpdateOrganizationPayload = Partial<Pick<ExtendedOrganization, 'name' | 'logo' | 'settings'>>;
package/dist/index.d.ts CHANGED
@@ -2706,7 +2706,7 @@ declare function createAPIClient(apiUrl: string, fetchOptions?: BetterFetchOptio
2706
2706
  data: CompleteAuthorizationFlowResponse;
2707
2707
  error: null;
2708
2708
  }>;
2709
- refreshAccessToken: (refreshToken?: string) => Promise<{
2709
+ refreshAccessToken: (refreshToken: string) => Promise<{
2710
2710
  data: null;
2711
2711
  error: {
2712
2712
  message?: string | undefined;
@@ -2717,7 +2717,7 @@ declare function createAPIClient(apiUrl: string, fetchOptions?: BetterFetchOptio
2717
2717
  data: CompleteAuthorizationFlowResponse;
2718
2718
  error: null;
2719
2719
  }>;
2720
- whoAmI: (accessToken?: string) => Promise<{
2720
+ whoAmI: (accessToken: string) => Promise<{
2721
2721
  data: null;
2722
2722
  error: {
2723
2723
  message?: string | undefined;
@@ -2728,7 +2728,7 @@ declare function createAPIClient(apiUrl: string, fetchOptions?: BetterFetchOptio
2728
2728
  data: WhoAmIResponse;
2729
2729
  error: null;
2730
2730
  }>;
2731
- switchOrganization: (organizationId: string, accessToken?: string) => Promise<{
2731
+ switchOrganization: (organizationId: string, accessToken: string) => Promise<{
2732
2732
  data: null;
2733
2733
  error: {
2734
2734
  message?: string | undefined;
@@ -5669,7 +5669,7 @@ declare const stub: {
5669
5669
  data: CompleteAuthorizationFlowResponse;
5670
5670
  error: null;
5671
5671
  }>;
5672
- refreshAccessToken: (refreshToken?: string) => Promise<{
5672
+ refreshAccessToken: (refreshToken: string) => Promise<{
5673
5673
  data: null;
5674
5674
  error: {
5675
5675
  message?: string | undefined;
@@ -5680,7 +5680,7 @@ declare const stub: {
5680
5680
  data: CompleteAuthorizationFlowResponse;
5681
5681
  error: null;
5682
5682
  }>;
5683
- whoAmI: (accessToken?: string) => Promise<{
5683
+ whoAmI: (accessToken: string) => Promise<{
5684
5684
  data: null;
5685
5685
  error: {
5686
5686
  message?: string | undefined;
@@ -5691,7 +5691,7 @@ declare const stub: {
5691
5691
  data: WhoAmIResponse;
5692
5692
  error: null;
5693
5693
  }>;
5694
- switchOrganization: (organizationId: string, accessToken?: string) => Promise<{
5694
+ switchOrganization: (organizationId: string, accessToken: string) => Promise<{
5695
5695
  data: null;
5696
5696
  error: {
5697
5697
  message?: string | undefined;
@@ -6247,14 +6247,14 @@ declare class ApplicationService {
6247
6247
  * @throws {RefreshTokenExpiredError} When the refresh token has expired or is invalid
6248
6248
  * @throws {ApplicationError} For other API errors
6249
6249
  */
6250
- refreshAccessToken(): Promise<CompleteAuthorizationFlowResponse>;
6250
+ refreshAccessToken(refreshToken: string): Promise<CompleteAuthorizationFlowResponse>;
6251
6251
  /**
6252
6252
  * Gets the current user and organization for a specific application.
6253
6253
  *
6254
6254
  * @param accessToken - The access token to use for the who am I request
6255
6255
  * @returns The current user and organization
6256
6256
  */
6257
- whoAmI(accessToken?: string): Promise<WhoAmIResponse>;
6257
+ whoAmI(accessToken: string): Promise<WhoAmIResponse>;
6258
6258
  /**
6259
6259
  * Switches the active organization for the authenticated user.
6260
6260
  *
@@ -6266,7 +6266,7 @@ declare class ApplicationService {
6266
6266
  * @param accessToken - Optional access token for authentication (uses cookie if not provided)
6267
6267
  * @returns New authentication tokens and user/organization details
6268
6268
  */
6269
- switchOrganization(organizationId: string, accessToken?: string): Promise<CompleteAuthorizationFlowResponse>;
6269
+ switchOrganization(organizationId: string, accessToken: string): Promise<CompleteAuthorizationFlowResponse>;
6270
6270
  }
6271
6271
 
6272
6272
  type UpdateOrganizationPayload = Partial<Pick<ExtendedOrganization, 'name' | 'logo' | 'settings'>>;
package/dist/index.mjs CHANGED
@@ -6,7 +6,7 @@ import { createAccessControl } from 'better-auth/plugins/access';
6
6
  import { defaultStatements } from 'better-auth/plugins/organization/access';
7
7
  export { BetterFetchError as APIError } from '@better-fetch/fetch';
8
8
 
9
- const version = "1.7.0";
9
+ const version = "1.7.1";
10
10
 
11
11
  const statements = {
12
12
  ...defaultStatements,
@@ -98,9 +98,7 @@ function applicationsPluginClient() {
98
98
  },
99
99
  refreshAccessToken: async (refreshToken) => {
100
100
  const headers = new Headers();
101
- if (refreshToken) {
102
- headers.set("Cookie", `tela-refresh-token=${refreshToken}`);
103
- }
101
+ headers.set("x-tela-refresh-token", refreshToken);
104
102
  return await $fetch("/applications/token/refresh", {
105
103
  method: "POST",
106
104
  headers
@@ -108,9 +106,7 @@ function applicationsPluginClient() {
108
106
  },
109
107
  whoAmI: async (accessToken) => {
110
108
  const headers = new Headers();
111
- if (accessToken) {
112
- headers.set("Cookie", `tela-access-token=${accessToken}`);
113
- }
109
+ headers.set("x-tela-access-token", accessToken);
114
110
  return await $fetch("/applications/whoami", {
115
111
  method: "GET",
116
112
  headers
@@ -118,9 +114,7 @@ function applicationsPluginClient() {
118
114
  },
119
115
  switchOrganization: async (organizationId, accessToken) => {
120
116
  const headers = new Headers();
121
- if (accessToken) {
122
- headers.set("Cookie", `tela-access-token=${accessToken}`);
123
- }
117
+ headers.set("x-tela-access-token", accessToken);
124
118
  return await $fetch("/applications/switch-organization", {
125
119
  method: "POST",
126
120
  headers,
@@ -283,8 +277,8 @@ class ApplicationService {
283
277
  * @throws {RefreshTokenExpiredError} When the refresh token has expired or is invalid
284
278
  * @throws {ApplicationError} For other API errors
285
279
  */
286
- async refreshAccessToken() {
287
- const response = await this.client.applications.refreshAccessToken();
280
+ async refreshAccessToken(refreshToken) {
281
+ const response = await this.client.applications.refreshAccessToken(refreshToken);
288
282
  if (!response.data) {
289
283
  const error = response.error;
290
284
  const status = error?.status;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meistrari/auth-core",
3
- "version": "1.7.0",
3
+ "version": "1.7.1",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {