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