@meistrari/auth-core 1.2.1 → 1.4.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/index.mjs CHANGED
@@ -4,8 +4,9 @@ import { createAuthClient } from 'better-auth/client';
4
4
  import { organizationClient, twoFactorClient, jwtClient, apiKeyClient, adminClient, inferAdditionalFields } from 'better-auth/client/plugins';
5
5
  import { createAccessControl } from 'better-auth/plugins/access';
6
6
  import { defaultStatements } from 'better-auth/plugins/organization/access';
7
+ export { BetterFetchError as APIError } from '@better-fetch/fetch';
7
8
 
8
- const version = "1.2.1";
9
+ const version = "1.4.0";
9
10
 
10
11
  const statements = {
11
12
  ...defaultStatements,
@@ -99,7 +100,7 @@ function createAPIClient(apiUrl, fetchOptions = {}) {
99
100
  ...fetchOptions,
100
101
  credentials: "include",
101
102
  headers: {
102
- "User-Agent": userAgent,
103
+ "X-User-Agent": userAgent,
103
104
  ...fetchOptions.headers ?? {}
104
105
  },
105
106
  throw: true
@@ -339,6 +340,7 @@ class OrganizationService {
339
340
  *
340
341
  * @param teamId - The team ID
341
342
  * @param userId - The user ID to add
343
+ * @returns The added team member
342
344
  */
343
345
  async addTeamMember(teamId, userId) {
344
346
  return this.client.organization.addTeamMember({
@@ -556,6 +558,46 @@ class SessionService {
556
558
  }
557
559
  }
558
560
 
561
+ class ApiKeyService {
562
+ /**
563
+ * Creates a new ApiKeyService instance.
564
+ *
565
+ * @param client - The API client for making API key requests
566
+ */
567
+ constructor(client) {
568
+ this.client = client;
569
+ }
570
+ async createApiKey(payload) {
571
+ return this.client.apiKey.create({
572
+ name: payload.name,
573
+ expiresIn: payload.expiresIn,
574
+ prefix: payload.prefix,
575
+ metadata: payload.metadata
576
+ });
577
+ }
578
+ async getApiKey(id) {
579
+ return this.client.apiKey.get({
580
+ query: {
581
+ id
582
+ }
583
+ });
584
+ }
585
+ async listApiKeys() {
586
+ return this.client.apiKey.list();
587
+ }
588
+ async updateApiKey(payload) {
589
+ return this.client.apiKey.update({
590
+ keyId: payload.id,
591
+ name: payload.name
592
+ });
593
+ }
594
+ async deleteApiKey(id) {
595
+ return this.client.apiKey.delete({
596
+ keyId: id
597
+ });
598
+ }
599
+ }
600
+
559
601
  class AuthClient {
560
602
  client;
561
603
  /**
@@ -566,6 +608,10 @@ class AuthClient {
566
608
  * Organization management service for multi-tenant operations
567
609
  */
568
610
  organization;
611
+ /**
612
+ * API key management service for API key operations
613
+ */
614
+ apiKey;
569
615
  /**
570
616
  * Creates a new AuthClient instance.
571
617
  *
@@ -576,6 +622,7 @@ class AuthClient {
576
622
  this.client = createAPIClient(apiUrl, fetchOptions);
577
623
  this.session = new SessionService(this.client, apiUrl);
578
624
  this.organization = new OrganizationService(this.client);
625
+ this.apiKey = new ApiKeyService(this.client);
579
626
  }
580
627
  }
581
628
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meistrari/auth-core",
3
- "version": "1.2.1",
3
+ "version": "1.4.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -17,12 +17,12 @@
17
17
  "build": "unbuild"
18
18
  },
19
19
  "dependencies": {
20
- "@better-auth/sso": "1.4.1",
21
- "better-auth": "1.4.1",
20
+ "@better-auth/sso": "1.4.7",
21
+ "better-auth": "1.4.7",
22
22
  "jose": "6.1.0",
23
23
  "nanostores": "1.0.1",
24
- "@better-fetch/fetch": "1.1.18",
25
- "better-call": "1.1.0"
24
+ "@better-fetch/fetch": "1.1.21",
25
+ "better-call": "1.1.5"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@types/node": "latest",