@meistrari/auth-core 1.13.0 → 1.13.2

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
@@ -6,7 +6,7 @@ import * as better_auth_client from 'better-auth/client';
6
6
  import { BetterFetchOption } from 'better-auth/client';
7
7
  import * as jose from 'jose';
8
8
  import * as _better_auth_sso from '@better-auth/sso';
9
- export { ApiKey } from '@better-auth/api-key';
9
+ import { ApiKey as ApiKey$1 } from '@better-auth/api-key';
10
10
 
11
11
  declare const ac: {
12
12
  newRole<K extends "member" | "access" | "organization" | "invitation" | "team" | "ac">(statements: better_auth_plugins.Subset<K, {
@@ -203,6 +203,32 @@ type JWTTokenPayload = JWTPayload & {
203
203
  sessionKey: string;
204
204
  };
205
205
 
206
+ type ApiKeyMetadata = {
207
+ user: {
208
+ id: string;
209
+ email: string;
210
+ };
211
+ workspace: {
212
+ id: string;
213
+ title: string;
214
+ };
215
+ } & Record<string, unknown>;
216
+ type ApiKey = Omit<ApiKey$1, 'metadata' | 'name'> & {
217
+ name: string;
218
+ metadata: ApiKeyMetadata;
219
+ };
220
+ type ApiKeyWithoutSecret = Omit<ApiKey, 'key'>;
221
+ type CreateApiKeyPayload = {
222
+ name: string;
223
+ expiresIn?: number;
224
+ prefix?: string;
225
+ metadata?: ApiKeyMetadata;
226
+ };
227
+ type UpdateApiKeyPayload = {
228
+ id: string;
229
+ name: string;
230
+ };
231
+
206
232
  /**
207
233
  * Removes index signatures from a type
208
234
  * @template T - The type to remove index signatures from
@@ -304,35 +330,26 @@ declare function createAPIClient(apiUrl: string, fetchOptions?: BetterFetchOptio
304
330
  fetchOptions?: FetchOptions | undefined;
305
331
  }> | undefined, data_1?: FetchOptions | undefined) => Promise<better_auth_client.BetterFetchResponse<{
306
332
  id: string;
307
- name: string | null;
333
+ name: string;
308
334
  start: string | null;
309
335
  prefix: string | null;
310
336
  referenceId: string;
311
- configId: string | null;
337
+ configId: string;
312
338
  refillInterval: number | null;
313
339
  refillAmount: number | null;
314
340
  lastRefillAt: Date | null;
315
- enabled: boolean | null;
316
- rateLimitEnabled: boolean | null;
341
+ enabled: boolean;
342
+ rateLimitEnabled: boolean;
317
343
  rateLimitTimeWindow: number | null;
318
344
  rateLimitMax: number | null;
319
- requestCount: number | null;
345
+ requestCount: number;
320
346
  remaining: number | null;
321
347
  lastRequest: Date | null;
322
348
  expiresAt: Date | null;
323
349
  createdAt: Date;
324
350
  updatedAt: Date;
325
351
  permissions: string | null;
326
- metadata: ({
327
- user: {
328
- id: string;
329
- email: string;
330
- };
331
- workspace: {
332
- id: string;
333
- title: string;
334
- };
335
- } & Record<string, unknown>) | null;
352
+ metadata: any;
336
353
  }[], {
337
354
  code?: string | undefined;
338
355
  message?: string | undefined;
@@ -4893,27 +4910,6 @@ declare class SessionService {
4893
4910
  }>;
4894
4911
  }
4895
4912
 
4896
- type CreateApiKeyPayload = {
4897
- name?: string;
4898
- expiresIn?: number;
4899
- prefix?: string;
4900
- metadata?: ApiKeyMetadata;
4901
- };
4902
- type UpdateApiKeyPayload = {
4903
- id: string;
4904
- name?: string;
4905
- };
4906
- type ApiKeyMetadata = {
4907
- user: {
4908
- id: string;
4909
- email: string;
4910
- };
4911
- workspace: {
4912
- id: string;
4913
- title: string;
4914
- };
4915
- } & Record<string, unknown>;
4916
-
4917
4913
  /**
4918
4914
  * Service for managing API keys
4919
4915
  *
@@ -4928,142 +4924,16 @@ declare class ApiKeyService {
4928
4924
  * @param client - The API client for making API key requests
4929
4925
  */
4930
4926
  constructor(client: APIClient);
4931
- createApiKey(payload: CreateApiKeyPayload): Promise<{
4932
- key: string;
4933
- metadata: any;
4934
- permissions: any;
4935
- id: string;
4936
- configId: string;
4937
- name: string | null;
4938
- start: string | null;
4939
- prefix: string | null;
4940
- referenceId: string;
4941
- refillInterval: number | null;
4942
- refillAmount: number | null;
4943
- lastRefillAt: Date | null;
4944
- enabled: boolean;
4945
- rateLimitEnabled: boolean;
4946
- rateLimitTimeWindow: number | null;
4947
- rateLimitMax: number | null;
4948
- requestCount: number;
4949
- remaining: number | null;
4950
- lastRequest: Date | null;
4951
- expiresAt: Date | null;
4952
- createdAt: Date;
4953
- updatedAt: Date;
4954
- }>;
4955
- getApiKey(id: string): Promise<{
4956
- metadata: Record<string, any> | null;
4957
- permissions: {
4958
- [key: string]: string[];
4959
- } | null;
4960
- id: string;
4961
- configId: string;
4962
- name: string | null;
4963
- start: string | null;
4964
- prefix: string | null;
4965
- referenceId: string;
4966
- refillInterval: number | null;
4967
- refillAmount: number | null;
4968
- lastRefillAt: Date | null;
4969
- enabled: boolean;
4970
- rateLimitEnabled: boolean;
4971
- rateLimitTimeWindow: number | null;
4972
- rateLimitMax: number | null;
4973
- requestCount: number;
4974
- remaining: number | null;
4975
- lastRequest: Date | null;
4976
- expiresAt: Date | null;
4977
- createdAt: Date;
4978
- updatedAt: Date;
4979
- }>;
4927
+ createApiKey(payload: CreateApiKeyPayload): Promise<ApiKey>;
4928
+ getApiKey(id: string): Promise<ApiKeyWithoutSecret>;
4980
4929
  listApiKeys(): Promise<{
4981
- apiKeys: {
4982
- metadata: Record<string, any> | null;
4983
- permissions: {
4984
- [key: string]: string[];
4985
- } | null;
4986
- id: string;
4987
- configId: string;
4988
- name: string | null;
4989
- start: string | null;
4990
- prefix: string | null;
4991
- referenceId: string;
4992
- refillInterval: number | null;
4993
- refillAmount: number | null;
4994
- lastRefillAt: Date | null;
4995
- enabled: boolean;
4996
- rateLimitEnabled: boolean;
4997
- rateLimitTimeWindow: number | null;
4998
- rateLimitMax: number | null;
4999
- requestCount: number;
5000
- remaining: number | null;
5001
- lastRequest: Date | null;
5002
- expiresAt: Date | null;
5003
- createdAt: Date;
5004
- updatedAt: Date;
5005
- }[];
4930
+ apiKeys: ApiKeyWithoutSecret[];
5006
4931
  total: number;
5007
4932
  limit: number | undefined;
5008
4933
  offset: number | undefined;
5009
4934
  }>;
5010
- listOrganizationApiKeys(): Promise<{
5011
- id: string;
5012
- name: string | null;
5013
- start: string | null;
5014
- prefix: string | null;
5015
- referenceId: string;
5016
- configId: string | null;
5017
- refillInterval: number | null;
5018
- refillAmount: number | null;
5019
- lastRefillAt: Date | null;
5020
- enabled: boolean | null;
5021
- rateLimitEnabled: boolean | null;
5022
- rateLimitTimeWindow: number | null;
5023
- rateLimitMax: number | null;
5024
- requestCount: number | null;
5025
- remaining: number | null;
5026
- lastRequest: Date | null;
5027
- expiresAt: Date | null;
5028
- createdAt: Date;
5029
- updatedAt: Date;
5030
- permissions: string | null;
5031
- metadata: ({
5032
- user: {
5033
- id: string;
5034
- email: string;
5035
- };
5036
- workspace: {
5037
- id: string;
5038
- title: string;
5039
- };
5040
- } & Record<string, unknown>) | null;
5041
- }[]>;
5042
- updateApiKey(payload: UpdateApiKeyPayload): Promise<{
5043
- metadata: Record<string, any> | null;
5044
- permissions: {
5045
- [key: string]: string[];
5046
- } | null;
5047
- id: string;
5048
- configId: string;
5049
- name: string | null;
5050
- start: string | null;
5051
- prefix: string | null;
5052
- referenceId: string;
5053
- refillInterval: number | null;
5054
- refillAmount: number | null;
5055
- lastRefillAt: Date | null;
5056
- enabled: boolean;
5057
- rateLimitEnabled: boolean;
5058
- rateLimitTimeWindow: number | null;
5059
- rateLimitMax: number | null;
5060
- requestCount: number;
5061
- remaining: number | null;
5062
- lastRequest: Date | null;
5063
- expiresAt: Date | null;
5064
- createdAt: Date;
5065
- updatedAt: Date;
5066
- }>;
4935
+ listOrganizationApiKeys(): Promise<ApiKeyWithoutSecret[]>;
4936
+ updateApiKey(payload: UpdateApiKeyPayload): Promise<ApiKeyWithoutSecret>;
5067
4937
  deleteApiKey(id: string): Promise<{
5068
4938
  success: boolean;
5069
4939
  }>;
@@ -5200,4 +5070,4 @@ declare function validateToken(token: string, apiUrl: string): Promise<boolean>;
5200
5070
  declare function extractTokenPayload(token: string): JWTTokenPayload;
5201
5071
 
5202
5072
  export { ApplicationError, AuthClient, AuthorizationFlowError, EmailRequired, InvalidCallbackURL, InvalidSocialProvider, RefreshTokenExpiredError, Roles, UserNotLoggedInError, ac, createAPIClient, extractTokenPayload, isTokenExpired, memberAdditionalFields, organizationAdditionalFields, rolesAccessControl, userAdditionalFields, validateToken };
5203
- export type { APIClient, ApiKeyMetadata, Application, CompleteAuthorizationFlowResponse, CreateApiKeyPayload, CreateTeamPayload, FullOrganization, Invitation, InviteUserToOrganizationOptions, JWTTokenPayload, ListCandidateOrganizationsResponse, ListMembersOptions, Member, ExtendedOrganization as Organization, RemoveUserFromOrganizationOptions, Role, Session, SignInWithEmailAndPasswordOptions, SignInWithSamlOptions, SocialSignInOptions, StartAuthorizationFlowResponse, Team, TeamMember, UpdateApiKeyPayload, UpdateMemberRoleOptions, UpdateOrganizationPayload, UpdateTeamPayload, User, WhoAmIResponse };
5073
+ export type { APIClient, ApiKey, ApiKeyMetadata, ApiKeyWithoutSecret, Application, CompleteAuthorizationFlowResponse, CreateApiKeyPayload, CreateTeamPayload, FullOrganization, Invitation, InviteUserToOrganizationOptions, JWTTokenPayload, ListCandidateOrganizationsResponse, ListMembersOptions, Member, ExtendedOrganization as Organization, RemoveUserFromOrganizationOptions, Role, Session, SignInWithEmailAndPasswordOptions, SignInWithSamlOptions, SocialSignInOptions, StartAuthorizationFlowResponse, Team, TeamMember, UpdateApiKeyPayload, UpdateMemberRoleOptions, UpdateOrganizationPayload, UpdateTeamPayload, User, WhoAmIResponse };
package/dist/index.d.ts CHANGED
@@ -6,7 +6,7 @@ import * as better_auth_client from 'better-auth/client';
6
6
  import { BetterFetchOption } from 'better-auth/client';
7
7
  import * as jose from 'jose';
8
8
  import * as _better_auth_sso from '@better-auth/sso';
9
- export { ApiKey } from '@better-auth/api-key';
9
+ import { ApiKey as ApiKey$1 } from '@better-auth/api-key';
10
10
 
11
11
  declare const ac: {
12
12
  newRole<K extends "member" | "access" | "organization" | "invitation" | "team" | "ac">(statements: better_auth_plugins.Subset<K, {
@@ -203,6 +203,32 @@ type JWTTokenPayload = JWTPayload & {
203
203
  sessionKey: string;
204
204
  };
205
205
 
206
+ type ApiKeyMetadata = {
207
+ user: {
208
+ id: string;
209
+ email: string;
210
+ };
211
+ workspace: {
212
+ id: string;
213
+ title: string;
214
+ };
215
+ } & Record<string, unknown>;
216
+ type ApiKey = Omit<ApiKey$1, 'metadata' | 'name'> & {
217
+ name: string;
218
+ metadata: ApiKeyMetadata;
219
+ };
220
+ type ApiKeyWithoutSecret = Omit<ApiKey, 'key'>;
221
+ type CreateApiKeyPayload = {
222
+ name: string;
223
+ expiresIn?: number;
224
+ prefix?: string;
225
+ metadata?: ApiKeyMetadata;
226
+ };
227
+ type UpdateApiKeyPayload = {
228
+ id: string;
229
+ name: string;
230
+ };
231
+
206
232
  /**
207
233
  * Removes index signatures from a type
208
234
  * @template T - The type to remove index signatures from
@@ -304,35 +330,26 @@ declare function createAPIClient(apiUrl: string, fetchOptions?: BetterFetchOptio
304
330
  fetchOptions?: FetchOptions | undefined;
305
331
  }> | undefined, data_1?: FetchOptions | undefined) => Promise<better_auth_client.BetterFetchResponse<{
306
332
  id: string;
307
- name: string | null;
333
+ name: string;
308
334
  start: string | null;
309
335
  prefix: string | null;
310
336
  referenceId: string;
311
- configId: string | null;
337
+ configId: string;
312
338
  refillInterval: number | null;
313
339
  refillAmount: number | null;
314
340
  lastRefillAt: Date | null;
315
- enabled: boolean | null;
316
- rateLimitEnabled: boolean | null;
341
+ enabled: boolean;
342
+ rateLimitEnabled: boolean;
317
343
  rateLimitTimeWindow: number | null;
318
344
  rateLimitMax: number | null;
319
- requestCount: number | null;
345
+ requestCount: number;
320
346
  remaining: number | null;
321
347
  lastRequest: Date | null;
322
348
  expiresAt: Date | null;
323
349
  createdAt: Date;
324
350
  updatedAt: Date;
325
351
  permissions: string | null;
326
- metadata: ({
327
- user: {
328
- id: string;
329
- email: string;
330
- };
331
- workspace: {
332
- id: string;
333
- title: string;
334
- };
335
- } & Record<string, unknown>) | null;
352
+ metadata: any;
336
353
  }[], {
337
354
  code?: string | undefined;
338
355
  message?: string | undefined;
@@ -4893,27 +4910,6 @@ declare class SessionService {
4893
4910
  }>;
4894
4911
  }
4895
4912
 
4896
- type CreateApiKeyPayload = {
4897
- name?: string;
4898
- expiresIn?: number;
4899
- prefix?: string;
4900
- metadata?: ApiKeyMetadata;
4901
- };
4902
- type UpdateApiKeyPayload = {
4903
- id: string;
4904
- name?: string;
4905
- };
4906
- type ApiKeyMetadata = {
4907
- user: {
4908
- id: string;
4909
- email: string;
4910
- };
4911
- workspace: {
4912
- id: string;
4913
- title: string;
4914
- };
4915
- } & Record<string, unknown>;
4916
-
4917
4913
  /**
4918
4914
  * Service for managing API keys
4919
4915
  *
@@ -4928,142 +4924,16 @@ declare class ApiKeyService {
4928
4924
  * @param client - The API client for making API key requests
4929
4925
  */
4930
4926
  constructor(client: APIClient);
4931
- createApiKey(payload: CreateApiKeyPayload): Promise<{
4932
- key: string;
4933
- metadata: any;
4934
- permissions: any;
4935
- id: string;
4936
- configId: string;
4937
- name: string | null;
4938
- start: string | null;
4939
- prefix: string | null;
4940
- referenceId: string;
4941
- refillInterval: number | null;
4942
- refillAmount: number | null;
4943
- lastRefillAt: Date | null;
4944
- enabled: boolean;
4945
- rateLimitEnabled: boolean;
4946
- rateLimitTimeWindow: number | null;
4947
- rateLimitMax: number | null;
4948
- requestCount: number;
4949
- remaining: number | null;
4950
- lastRequest: Date | null;
4951
- expiresAt: Date | null;
4952
- createdAt: Date;
4953
- updatedAt: Date;
4954
- }>;
4955
- getApiKey(id: string): Promise<{
4956
- metadata: Record<string, any> | null;
4957
- permissions: {
4958
- [key: string]: string[];
4959
- } | null;
4960
- id: string;
4961
- configId: string;
4962
- name: string | null;
4963
- start: string | null;
4964
- prefix: string | null;
4965
- referenceId: string;
4966
- refillInterval: number | null;
4967
- refillAmount: number | null;
4968
- lastRefillAt: Date | null;
4969
- enabled: boolean;
4970
- rateLimitEnabled: boolean;
4971
- rateLimitTimeWindow: number | null;
4972
- rateLimitMax: number | null;
4973
- requestCount: number;
4974
- remaining: number | null;
4975
- lastRequest: Date | null;
4976
- expiresAt: Date | null;
4977
- createdAt: Date;
4978
- updatedAt: Date;
4979
- }>;
4927
+ createApiKey(payload: CreateApiKeyPayload): Promise<ApiKey>;
4928
+ getApiKey(id: string): Promise<ApiKeyWithoutSecret>;
4980
4929
  listApiKeys(): Promise<{
4981
- apiKeys: {
4982
- metadata: Record<string, any> | null;
4983
- permissions: {
4984
- [key: string]: string[];
4985
- } | null;
4986
- id: string;
4987
- configId: string;
4988
- name: string | null;
4989
- start: string | null;
4990
- prefix: string | null;
4991
- referenceId: string;
4992
- refillInterval: number | null;
4993
- refillAmount: number | null;
4994
- lastRefillAt: Date | null;
4995
- enabled: boolean;
4996
- rateLimitEnabled: boolean;
4997
- rateLimitTimeWindow: number | null;
4998
- rateLimitMax: number | null;
4999
- requestCount: number;
5000
- remaining: number | null;
5001
- lastRequest: Date | null;
5002
- expiresAt: Date | null;
5003
- createdAt: Date;
5004
- updatedAt: Date;
5005
- }[];
4930
+ apiKeys: ApiKeyWithoutSecret[];
5006
4931
  total: number;
5007
4932
  limit: number | undefined;
5008
4933
  offset: number | undefined;
5009
4934
  }>;
5010
- listOrganizationApiKeys(): Promise<{
5011
- id: string;
5012
- name: string | null;
5013
- start: string | null;
5014
- prefix: string | null;
5015
- referenceId: string;
5016
- configId: string | null;
5017
- refillInterval: number | null;
5018
- refillAmount: number | null;
5019
- lastRefillAt: Date | null;
5020
- enabled: boolean | null;
5021
- rateLimitEnabled: boolean | null;
5022
- rateLimitTimeWindow: number | null;
5023
- rateLimitMax: number | null;
5024
- requestCount: number | null;
5025
- remaining: number | null;
5026
- lastRequest: Date | null;
5027
- expiresAt: Date | null;
5028
- createdAt: Date;
5029
- updatedAt: Date;
5030
- permissions: string | null;
5031
- metadata: ({
5032
- user: {
5033
- id: string;
5034
- email: string;
5035
- };
5036
- workspace: {
5037
- id: string;
5038
- title: string;
5039
- };
5040
- } & Record<string, unknown>) | null;
5041
- }[]>;
5042
- updateApiKey(payload: UpdateApiKeyPayload): Promise<{
5043
- metadata: Record<string, any> | null;
5044
- permissions: {
5045
- [key: string]: string[];
5046
- } | null;
5047
- id: string;
5048
- configId: string;
5049
- name: string | null;
5050
- start: string | null;
5051
- prefix: string | null;
5052
- referenceId: string;
5053
- refillInterval: number | null;
5054
- refillAmount: number | null;
5055
- lastRefillAt: Date | null;
5056
- enabled: boolean;
5057
- rateLimitEnabled: boolean;
5058
- rateLimitTimeWindow: number | null;
5059
- rateLimitMax: number | null;
5060
- requestCount: number;
5061
- remaining: number | null;
5062
- lastRequest: Date | null;
5063
- expiresAt: Date | null;
5064
- createdAt: Date;
5065
- updatedAt: Date;
5066
- }>;
4935
+ listOrganizationApiKeys(): Promise<ApiKeyWithoutSecret[]>;
4936
+ updateApiKey(payload: UpdateApiKeyPayload): Promise<ApiKeyWithoutSecret>;
5067
4937
  deleteApiKey(id: string): Promise<{
5068
4938
  success: boolean;
5069
4939
  }>;
@@ -5200,4 +5070,4 @@ declare function validateToken(token: string, apiUrl: string): Promise<boolean>;
5200
5070
  declare function extractTokenPayload(token: string): JWTTokenPayload;
5201
5071
 
5202
5072
  export { ApplicationError, AuthClient, AuthorizationFlowError, EmailRequired, InvalidCallbackURL, InvalidSocialProvider, RefreshTokenExpiredError, Roles, UserNotLoggedInError, ac, createAPIClient, extractTokenPayload, isTokenExpired, memberAdditionalFields, organizationAdditionalFields, rolesAccessControl, userAdditionalFields, validateToken };
5203
- export type { APIClient, ApiKeyMetadata, Application, CompleteAuthorizationFlowResponse, CreateApiKeyPayload, CreateTeamPayload, FullOrganization, Invitation, InviteUserToOrganizationOptions, JWTTokenPayload, ListCandidateOrganizationsResponse, ListMembersOptions, Member, ExtendedOrganization as Organization, RemoveUserFromOrganizationOptions, Role, Session, SignInWithEmailAndPasswordOptions, SignInWithSamlOptions, SocialSignInOptions, StartAuthorizationFlowResponse, Team, TeamMember, UpdateApiKeyPayload, UpdateMemberRoleOptions, UpdateOrganizationPayload, UpdateTeamPayload, User, WhoAmIResponse };
5073
+ export type { APIClient, ApiKey, ApiKeyMetadata, ApiKeyWithoutSecret, Application, CompleteAuthorizationFlowResponse, CreateApiKeyPayload, CreateTeamPayload, FullOrganization, Invitation, InviteUserToOrganizationOptions, JWTTokenPayload, ListCandidateOrganizationsResponse, ListMembersOptions, Member, ExtendedOrganization as Organization, RemoveUserFromOrganizationOptions, Role, Session, SignInWithEmailAndPasswordOptions, SignInWithSamlOptions, SocialSignInOptions, StartAuthorizationFlowResponse, Team, TeamMember, UpdateApiKeyPayload, UpdateMemberRoleOptions, UpdateOrganizationPayload, UpdateTeamPayload, User, WhoAmIResponse };
package/dist/index.mjs CHANGED
@@ -1,13 +1,13 @@
1
1
  import { decodeJwt, createRemoteJWKSet, jwtVerify } from 'jose';
2
+ import { apiKeyClient } from '@better-auth/api-key/client';
2
3
  import { ssoClient } from '@better-auth/sso/client';
3
4
  import { createAuthClient } from 'better-auth/client';
4
5
  import { organizationClient, inferOrgAdditionalFields, twoFactorClient, jwtClient, adminClient, inferAdditionalFields } from 'better-auth/client/plugins';
5
6
  import { createAccessControl } from 'better-auth/plugins/access';
6
7
  import { defaultStatements } from 'better-auth/plugins/organization/access';
7
- import { apiKeyClient } from '@better-auth/api-key/client';
8
8
  export { APIError } from 'better-auth';
9
9
 
10
- const version = "1.13.0";
10
+ const version = "1.13.2";
11
11
 
12
12
  const statements = {
13
13
  ...defaultStatements,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meistrari/auth-core",
3
- "version": "1.13.0",
3
+ "version": "1.13.2",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {