@krutai/auth 0.1.0 → 0.1.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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @krutai/auth
2
2
 
3
- Authentication package for KrutAI powered by [Better Auth](https://www.better-auth.com/).
3
+ Authentication package for KrutAI powered by [Krut AI](https://www.krut.ai/).
4
4
 
5
5
  ## Features
6
6
 
@@ -16,6 +16,8 @@ Authentication package for KrutAI powered by [Better Auth](https://www.better-au
16
16
  npm install @krutai/auth
17
17
  ```
18
18
 
19
+ > **Note:** Installing `@krutai/auth` automatically installs the parent `krutai` package, which provides centralized API key validation for all KrutAI packages.
20
+
19
21
  ## Quick Start
20
22
 
21
23
  ### Basic Usage
@@ -127,9 +129,35 @@ const apiKey = auth.getApiKey();
127
129
 
128
130
  **Returns:** `string`
129
131
 
132
+ ## Architecture
133
+
134
+ ### Dependency on Parent Package
135
+
136
+ `@krutai/auth` depends on the parent `krutai` package for API key validation:
137
+
138
+ ```
139
+ @krutai/auth
140
+ └── krutai (parent)
141
+ └── Provides: validateApiKeyFormat, validateApiKeyWithService, etc.
142
+ ```
143
+
144
+ **Benefits:**
145
+ - ✅ All `@krutai/*` packages use the same validation logic from `krutai`
146
+ - ✅ No code duplication across packages
147
+ - ✅ Consistent API key handling
148
+ - ✅ Centralized validation updates benefit all packages
149
+
150
+ You can also use the validation utilities directly:
151
+
152
+ ```typescript
153
+ import { validateApiKeyFormat, ApiKeyValidationError } from '@krutai/auth';
154
+ // or
155
+ import { validateApiKeyFormat, ApiKeyValidationError } from 'krutai';
156
+ ```
157
+
130
158
  ## Error Handling
131
159
 
132
- The package throws `ApiKeyValidationError` when:
160
+ The package throws `ApiKeyValidationError` (from parent `krutai` package) when:
133
161
 
134
162
  - API key is not provided
135
163
  - API key is empty or invalid format
package/dist/index.d.mts CHANGED
@@ -1,6 +1,7 @@
1
1
  import * as better_auth from 'better-auth';
2
2
  import { BetterAuthOptions, betterAuth } from 'better-auth';
3
3
  export { BetterAuthOptions } from 'better-auth';
4
+ export { ApiKeyValidationError, createApiKeyChecker, validateApiKeyFormat, validateApiKeyWithService } from 'krutai';
4
5
 
5
6
  /**
6
7
  * Configuration options for KrutAuth
@@ -121,26 +122,6 @@ declare class KrutAuth {
121
122
  getSession(): Promise<better_auth.Auth<better_auth.BetterAuthOptions>>;
122
123
  }
123
124
 
124
- /**
125
- * Custom error class for API key validation failures
126
- */
127
- declare class ApiKeyValidationError extends Error {
128
- constructor(message: string);
129
- }
130
- /**
131
- * Validates the format of an API key
132
- * @param apiKey - The API key to validate
133
- * @throws {ApiKeyValidationError} If the API key is invalid
134
- */
135
- declare function validateApiKeyFormat(apiKey: string | undefined): void;
136
- /**
137
- * Validates an API key against a backend service (optional)
138
- * This is a placeholder for actual API validation logic
139
- * @param _apiKey - The API key to validate (currently unused in mock implementation)
140
- * @returns Promise that resolves if valid, rejects if invalid
141
- */
142
- declare function validateApiKeyWithService(_apiKey: string): Promise<boolean>;
143
-
144
125
  /**
145
126
  * @krutai/auth - Authentication package for KrutAI
146
127
  *
@@ -150,6 +131,6 @@ declare function validateApiKeyWithService(_apiKey: string): Promise<boolean>;
150
131
  * @packageDocumentation
151
132
  */
152
133
 
153
- declare const VERSION = "0.1.0";
134
+ declare const VERSION = "0.1.1";
154
135
 
155
- export { ApiKeyValidationError, type AuthSession, KrutAuth, type KrutAuthConfig, VERSION, validateApiKeyFormat, validateApiKeyWithService };
136
+ export { type AuthSession, KrutAuth, type KrutAuthConfig, VERSION };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import * as better_auth from 'better-auth';
2
2
  import { BetterAuthOptions, betterAuth } from 'better-auth';
3
3
  export { BetterAuthOptions } from 'better-auth';
4
+ export { ApiKeyValidationError, createApiKeyChecker, validateApiKeyFormat, validateApiKeyWithService } from 'krutai';
4
5
 
5
6
  /**
6
7
  * Configuration options for KrutAuth
@@ -121,26 +122,6 @@ declare class KrutAuth {
121
122
  getSession(): Promise<better_auth.Auth<better_auth.BetterAuthOptions>>;
122
123
  }
123
124
 
124
- /**
125
- * Custom error class for API key validation failures
126
- */
127
- declare class ApiKeyValidationError extends Error {
128
- constructor(message: string);
129
- }
130
- /**
131
- * Validates the format of an API key
132
- * @param apiKey - The API key to validate
133
- * @throws {ApiKeyValidationError} If the API key is invalid
134
- */
135
- declare function validateApiKeyFormat(apiKey: string | undefined): void;
136
- /**
137
- * Validates an API key against a backend service (optional)
138
- * This is a placeholder for actual API validation logic
139
- * @param _apiKey - The API key to validate (currently unused in mock implementation)
140
- * @returns Promise that resolves if valid, rejects if invalid
141
- */
142
- declare function validateApiKeyWithService(_apiKey: string): Promise<boolean>;
143
-
144
125
  /**
145
126
  * @krutai/auth - Authentication package for KrutAI
146
127
  *
@@ -150,6 +131,6 @@ declare function validateApiKeyWithService(_apiKey: string): Promise<boolean>;
150
131
  * @packageDocumentation
151
132
  */
152
133
 
153
- declare const VERSION = "0.1.0";
134
+ declare const VERSION = "0.1.1";
154
135
 
155
- export { ApiKeyValidationError, type AuthSession, KrutAuth, type KrutAuthConfig, VERSION, validateApiKeyFormat, validateApiKeyWithService };
136
+ export { type AuthSession, KrutAuth, type KrutAuthConfig, VERSION };
package/dist/index.js CHANGED
@@ -1,38 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var betterAuth = require('better-auth');
4
-
5
- // src/client.ts
6
-
7
- // src/validator.ts
8
- var ApiKeyValidationError = class _ApiKeyValidationError extends Error {
9
- constructor(message) {
10
- super(message);
11
- this.name = "ApiKeyValidationError";
12
- Object.setPrototypeOf(this, _ApiKeyValidationError.prototype);
13
- }
14
- };
15
- function validateApiKeyFormat(apiKey) {
16
- if (!apiKey) {
17
- throw new ApiKeyValidationError(
18
- "API key is required. Please provide a valid API key to use @krutai/auth."
19
- );
20
- }
21
- if (typeof apiKey !== "string") {
22
- throw new ApiKeyValidationError("API key must be a string.");
23
- }
24
- if (apiKey.trim().length === 0) {
25
- throw new ApiKeyValidationError("API key cannot be empty.");
26
- }
27
- if (apiKey.length < 10) {
28
- throw new ApiKeyValidationError(
29
- "API key appears to be invalid. Please check your API key."
30
- );
31
- }
32
- }
33
- async function validateApiKeyWithService(_apiKey) {
34
- return Promise.resolve(true);
35
- }
4
+ var krutai = require('krutai');
36
5
 
37
6
  // src/client.ts
38
7
  var KrutAuth = class {
@@ -43,7 +12,7 @@ var KrutAuth = class {
43
12
  */
44
13
  constructor(config) {
45
14
  this.config = config;
46
- validateApiKeyFormat(config.apiKey);
15
+ krutai.validateApiKeyFormat(config.apiKey);
47
16
  this.apiKey = config.apiKey;
48
17
  if (config.validateOnInit === false) {
49
18
  this.initializeBetterAuth();
@@ -62,7 +31,7 @@ var KrutAuth = class {
62
31
  return;
63
32
  }
64
33
  if (this.config.validateOnInit !== false) {
65
- await validateApiKeyWithService(this.apiKey);
34
+ await krutai.validateApiKeyWithService(this.apiKey);
66
35
  }
67
36
  this.initializeBetterAuth();
68
37
  this.initialized = true;
@@ -128,14 +97,25 @@ var KrutAuth = class {
128
97
  return auth;
129
98
  }
130
99
  };
100
+ var VERSION = "0.1.1";
131
101
 
132
- // src/index.ts
133
- var VERSION = "0.1.0";
134
-
135
- exports.ApiKeyValidationError = ApiKeyValidationError;
102
+ Object.defineProperty(exports, "ApiKeyValidationError", {
103
+ enumerable: true,
104
+ get: function () { return krutai.ApiKeyValidationError; }
105
+ });
106
+ Object.defineProperty(exports, "createApiKeyChecker", {
107
+ enumerable: true,
108
+ get: function () { return krutai.createApiKeyChecker; }
109
+ });
110
+ Object.defineProperty(exports, "validateApiKeyFormat", {
111
+ enumerable: true,
112
+ get: function () { return krutai.validateApiKeyFormat; }
113
+ });
114
+ Object.defineProperty(exports, "validateApiKeyWithService", {
115
+ enumerable: true,
116
+ get: function () { return krutai.validateApiKeyWithService; }
117
+ });
136
118
  exports.KrutAuth = KrutAuth;
137
119
  exports.VERSION = VERSION;
138
- exports.validateApiKeyFormat = validateApiKeyFormat;
139
- exports.validateApiKeyWithService = validateApiKeyWithService;
140
120
  //# sourceMappingURL=index.js.map
141
121
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/validator.ts","../src/client.ts","../src/index.ts"],"names":["betterAuth"],"mappings":";;;;;;;AAGO,IAAM,qBAAA,GAAN,MAAM,sBAAA,SAA8B,KAAA,CAAM;AAAA,EAC7C,YAAY,OAAA,EAAiB;AACzB,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,IAAA,GAAO,uBAAA;AACZ,IAAA,MAAA,CAAO,cAAA,CAAe,IAAA,EAAM,sBAAA,CAAsB,SAAS,CAAA;AAAA,EAC/D;AACJ;AAOO,SAAS,qBAAqB,MAAA,EAAkC;AACnE,EAAA,IAAI,CAAC,MAAA,EAAQ;AACT,IAAA,MAAM,IAAI,qBAAA;AAAA,MACN;AAAA,KACJ;AAAA,EACJ;AAEA,EAAA,IAAI,OAAO,WAAW,QAAA,EAAU;AAC5B,IAAA,MAAM,IAAI,sBAAsB,2BAA2B,CAAA;AAAA,EAC/D;AAEA,EAAA,IAAI,MAAA,CAAO,IAAA,EAAK,CAAE,MAAA,KAAW,CAAA,EAAG;AAC5B,IAAA,MAAM,IAAI,sBAAsB,0BAA0B,CAAA;AAAA,EAC9D;AAGA,EAAA,IAAI,MAAA,CAAO,SAAS,EAAA,EAAI;AACpB,IAAA,MAAM,IAAI,qBAAA;AAAA,MACN;AAAA,KACJ;AAAA,EACJ;AACJ;AAQA,eAAsB,0BAClB,OAAA,EACgB;AAchB,EAAA,OAAO,OAAA,CAAQ,QAAQ,IAAI,CAAA;AAC/B;;;AC/BO,IAAM,WAAN,MAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUlB,YAAoB,MAAA,EAAwB;AAAxB,IAAA,IAAA,CAAA,MAAA,GAAA,MAAA;AAEhB,IAAA,oBAAA,CAAqB,OAAO,MAAM,CAAA;AAClC,I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M,IAAA,GAAO,KAAK,aAAA,EAAc;AAGhC,IAAA,OAAO,IAAA;AAAA,EACX;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,OAAA,GAAU;AACZ,IAAA,MAAM,IAAA,GAAO,KAAK,aAAA,EAAc;AAChC,IAAA,OAAO,IAAA;AAAA,EACX;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,UAAA,GAAa;AACf,IAAA,MAAM,IAAA,GAAO,KAAK,aAAA,EAAc;AAChC,IAAA,OAAO,IAAA;AAAA,EACX;AACJ;;;ACpHO,IAAM,OAAA,GAAU","file":"index.js","sourcesContent":["/**\n * Custom error class for API key validation failures\n */\nexport class ApiKeyValidationError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'ApiKeyValidationError';\n Object.setPrototypeOf(this, ApiKeyValidationError.prototype);\n }\n}\n\n/**\n * Validates the format of an API key\n * @param apiKey - The API key to validate\n * @throws {ApiKeyValidationError} If the API key is invalid\n */\nexport function validateApiKeyFormat(apiKey: string | undefined): void {\n if (!apiKey) {\n throw new ApiKeyValidationError(\n 'API key is required. Please provide a valid API key to use @krutai/auth.'\n );\n }\n\n if (typeof apiKey !== 'string') {\n throw new ApiKeyValidationError('API key must be a string.');\n }\n\n if (apiKey.trim().length === 0) {\n throw new ApiKeyValidationError('API key cannot be empty.');\n }\n\n // Basic format validation - adjust based on your API key format\n if (apiKey.length < 10) {\n throw new ApiKeyValidationError(\n 'API key appears to be invalid. Please check your API key.'\n );\n }\n}\n\n/**\n * Validates an API key against a backend service (optional)\n * This is a placeholder for actual API validation logic\n * @param _apiKey - The API key to validate (currently unused in mock implementation)\n * @returns Promise that resolves if valid, rejects if invalid\n */\nexport async function validateApiKeyWithService(\n _apiKey: string\n): Promise<boolean> {\n // TODO: Implement actual API validation against your backend\n // For now, this is a mock implementation\n\n // Example implementation:\n // const response = await fetch('https://api.krutai.com/validate', {\n // headers: { 'Authorization': `Bearer ${_apiKey}` }\n // });\n // if (!response.ok) {\n // throw new ApiKeyValidationError('Invalid API key');\n // }\n // return true;\n\n // Mock validation - accepts any key that passes format validation\n return Promise.resolve(true);\n}\n","import { betterAuth } from 'better-auth';\nimport type { KrutAuthConfig } from './types';\nimport {\n validateApiKeyFormat,\n validateApiKeyWithService,\n} from './validator';\n\n/**\n * KrutAuth - Authentication client for KrutAI\n * \n * This class wraps Better Auth and adds API key validation\n * to ensure only authorized users can access authentication features.\n * \n * @example\n * ```typescript\n * import { KrutAuth } from '@krutai/auth';\n * \n * const auth = new KrutAuth({\n * apiKey: 'your-api-key-here',\n * betterAuthOptions: {\n * // Better Auth configuration\n * }\n * });\n * \n * // Initialize the client (validates API key)\n * await auth.initialize();\n * \n * // Use authentication features\n * const betterAuth = auth.getBetterAuth();\n * ```\n */\nexport class KrutAuth {\n private apiKey: string;\n private betterAuthInstance: ReturnType<typeof betterAuth> | null = null;\n private initialized = false;\n\n /**\n * Creates a new KrutAuth instance\n * @param config - Configuration options\n * @throws {ApiKeyValidationError} If API key is invalid\n */\n constructor(private config: KrutAuthConfig) {\n // Validate API key format immediately\n validateApiKeyFormat(config.apiKey);\n this.apiKey = config.apiKey;\n\n // Initialize if validation is not required on init\n if (config.validateOnInit === false) {\n this.initializeBetterAuth();\n }\n }\n\n /**\n * Initialize the authentication client\n * Validates the API key and sets up Better Auth\n * @throws {ApiKeyValidationError} If API key validation fails\n */\n async initialize(): Promise<void> {\n if (this.initialized) {\n return;\n }\n\n // Validate API key with service if needed\n if (this.config.validateOnInit !== false) {\n await validateApiKeyWithService(this.apiKey);\n }\n\n this.initializeBetterAuth();\n this.initialized = true;\n }\n\n /**\n * Initialize Better Auth instance\n * @private\n */\n private initializeBetterAuth(): void {\n this.betterAuthInstance = betterAuth({\n ...this.config.betterAuthOptions,\n // Add any custom configuration here\n });\n }\n\n /**\n * Get the Better Auth instance\n * @throws {Error} If not initialized\n */\n getBetterAuth(): ReturnType<typeof betterAuth> {\n if (!this.betterAuthInstance) {\n throw new Error(\n 'KrutAuth not initialized. Call initialize() first or set validateOnInit to false.'\n );\n }\n return this.betterAuthInstance;\n }\n\n /**\n * Check if the client is initialized\n */\n isInitialized(): boolean {\n return this.initialized;\n }\n\n /**\n * Get the API key (useful for making authenticated requests)\n * @returns The API key\n */\n getApiKey(): string {\n return this.apiKey;\n }\n\n /**\n * Sign in a user\n * This is a convenience method that wraps Better Auth\n * You can access the full Better Auth API via getBetterAuth()\n */\n async signIn() {\n const auth = this.getBetterAuth();\n // Return the Better Auth instance for further operations\n // Users can call methods on it directly\n return auth;\n }\n\n /**\n * Sign out the current user\n * You can access the full Better Auth API via getBetterAuth()\n */\n async signOut() {\n const auth = this.getBetterAuth();\n return auth;\n }\n\n /**\n * Get the current session\n * You can access the full Better Auth API via getBetterAuth()\n */\n async getSession() {\n const auth = this.getBetterAuth();\n return auth;\n }\n}\n","/**\n * @krutai/auth - Authentication package for KrutAI\n * \n * This package provides authentication functionality powered by Better Auth\n * with API key validation to ensure secure access.\n * \n * @packageDocumentation\n */\n\n// Export main client\nexport { KrutAuth } from './client';\n\n// Export types\nexport type { KrutAuthConfig, AuthSession, BetterAuthOptions } from './types';\n\n// Export validator utilities\nexport {\n validateApiKeyFormat,\n validateApiKeyWithService,\n ApiKeyValidationError,\n} from './validator';\n\n// Package metadata\nexport const VERSION = '0.1.0';\n"]}
1
+ {"version":3,"sources":["../src/client.ts","../src/index.ts"],"names":["validateApiKeyFormat","validateApiKeyWithService","betterAuth"],"mappings":";;;;;;AAgCO,IAAM,WAAN,MAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUlB,YAAoB,MAAA,EAAwB;AAAxB,IAAA,IAAA,CAAA,MAAA,GAAA,MAAA;AAEhB,IAAAA,2BAAA,CAAqB,OAAO,MAAM,CAAA;AAClC,IAAA,IAAA,CAAK,SAAS,MAAA,CAAO,MAAA;AAGrB,IAAA,IAAI,MAAA,CAAO,mBAAmB,KAAA,EAAO;AACjC,MAAA,IAAA,CAAK,oBAAA,EAAqB;AAAA,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AAM,IAAA,GAAO,KAAK,aAAA,EAAc;AAChC,IAAA,OAAO,IAAA;AAAA,EACX;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,UAAA,GAAa;AACf,IAAA,MAAM,IAAA,GAAO,KAAK,aAAA,EAAc;AAChC,IAAA,OAAO,IAAA;AAAA,EACX;AACJ;ACpHO,IAAM,OAAA,GAAU","file":"index.js","sourcesContent":["import { betterAuth } from 'better-auth';\nimport type { KrutAuthConfig } from './types';\n// Import validation from parent krutai package\nimport {\n validateApiKeyFormat,\n validateApiKeyWithService,\n} from 'krutai';\n\n/**\n * KrutAuth - Authentication client for KrutAI\n * \n * This class wraps Better Auth and adds API key validation\n * to ensure only authorized users can access authentication features.\n * \n * @example\n * ```typescript\n * import { KrutAuth } from '@krutai/auth';\n * \n * const auth = new KrutAuth({\n * apiKey: 'your-api-key-here',\n * betterAuthOptions: {\n * // Better Auth configuration\n * }\n * });\n * \n * // Initialize the client (validates API key)\n * await auth.initialize();\n * \n * // Use authentication features\n * const betterAuth = auth.getBetterAuth();\n * ```\n */\nexport class KrutAuth {\n private apiKey: string;\n private betterAuthInstance: ReturnType<typeof betterAuth> | null = null;\n private initialized = false;\n\n /**\n * Creates a new KrutAuth instance\n * @param config - Configuration options\n * @throws {ApiKeyValidationError} If API key is invalid\n */\n constructor(private config: KrutAuthConfig) {\n // Validate API key format immediately\n validateApiKeyFormat(config.apiKey);\n this.apiKey = config.apiKey;\n\n // Initialize if validation is not required on init\n if (config.validateOnInit === false) {\n this.initializeBetterAuth();\n }\n }\n\n /**\n * Initialize the authentication client\n * Validates the API key and sets up Better Auth\n * @throws {ApiKeyValidationError} If API key validation fails\n */\n async initialize(): Promise<void> {\n if (this.initialized) {\n return;\n }\n\n // Validate API key with service if needed\n if (this.config.validateOnInit !== false) {\n await validateApiKeyWithService(this.apiKey);\n }\n\n this.initializeBetterAuth();\n this.initialized = true;\n }\n\n /**\n * Initialize Better Auth instance\n * @private\n */\n private initializeBetterAuth(): void {\n this.betterAuthInstance = betterAuth({\n ...this.config.betterAuthOptions,\n // Add any custom configuration here\n });\n }\n\n /**\n * Get the Better Auth instance\n * @throws {Error} If not initialized\n */\n getBetterAuth(): ReturnType<typeof betterAuth> {\n if (!this.betterAuthInstance) {\n throw new Error(\n 'KrutAuth not initialized. Call initialize() first or set validateOnInit to false.'\n );\n }\n return this.betterAuthInstance;\n }\n\n /**\n * Check if the client is initialized\n */\n isInitialized(): boolean {\n return this.initialized;\n }\n\n /**\n * Get the API key (useful for making authenticated requests)\n * @returns The API key\n */\n getApiKey(): string {\n return this.apiKey;\n }\n\n /**\n * Sign in a user\n * This is a convenience method that wraps Better Auth\n * You can access the full Better Auth API via getBetterAuth()\n */\n async signIn() {\n const auth = this.getBetterAuth();\n // Return the Better Auth instance for further operations\n // Users can call methods on it directly\n return auth;\n }\n\n /**\n * Sign out the current user\n * You can access the full Better Auth API via getBetterAuth()\n */\n async signOut() {\n const auth = this.getBetterAuth();\n return auth;\n }\n\n /**\n * Get the current session\n * You can access the full Better Auth API via getBetterAuth()\n */\n async getSession() {\n const auth = this.getBetterAuth();\n return auth;\n }\n}\n","/**\n * @krutai/auth - Authentication package for KrutAI\n * \n * This package provides authentication functionality powered by Better Auth\n * with API key validation to ensure secure access.\n * \n * @packageDocumentation\n */\n\n// Export main client\nexport { KrutAuth } from './client';\n\n// Export types\nexport type { KrutAuthConfig, AuthSession, BetterAuthOptions } from './types';\n\n// Re-export validator utilities from parent krutai package\nexport {\n validateApiKeyFormat,\n validateApiKeyWithService,\n createApiKeyChecker,\n ApiKeyValidationError,\n} from 'krutai';\n\n// Package metadata\nexport const VERSION = '0.1.1';\n"]}
package/dist/index.mjs CHANGED
@@ -1,36 +1,6 @@
1
1
  import { betterAuth } from 'better-auth';
2
-
3
- // src/client.ts
4
-
5
- // src/validator.ts
6
- var ApiKeyValidationError = class _ApiKeyValidationError extends Error {
7
- constructor(message) {
8
- super(message);
9
- this.name = "ApiKeyValidationError";
10
- Object.setPrototypeOf(this, _ApiKeyValidationError.prototype);
11
- }
12
- };
13
- function validateApiKeyFormat(apiKey) {
14
- if (!apiKey) {
15
- throw new ApiKeyValidationError(
16
- "API key is required. Please provide a valid API key to use @krutai/auth."
17
- );
18
- }
19
- if (typeof apiKey !== "string") {
20
- throw new ApiKeyValidationError("API key must be a string.");
21
- }
22
- if (apiKey.trim().length === 0) {
23
- throw new ApiKeyValidationError("API key cannot be empty.");
24
- }
25
- if (apiKey.length < 10) {
26
- throw new ApiKeyValidationError(
27
- "API key appears to be invalid. Please check your API key."
28
- );
29
- }
30
- }
31
- async function validateApiKeyWithService(_apiKey) {
32
- return Promise.resolve(true);
33
- }
2
+ import { validateApiKeyFormat, validateApiKeyWithService } from 'krutai';
3
+ export { ApiKeyValidationError, createApiKeyChecker, validateApiKeyFormat, validateApiKeyWithService } from 'krutai';
34
4
 
35
5
  // src/client.ts
36
6
  var KrutAuth = class {
@@ -126,10 +96,8 @@ var KrutAuth = class {
126
96
  return auth;
127
97
  }
128
98
  };
99
+ var VERSION = "0.1.1";
129
100
 
130
- // src/index.ts
131
- var VERSION = "0.1.0";
132
-
133
- export { ApiKeyValidationError, KrutAuth, VERSION, validateApiKeyFormat, validateApiKeyWithService };
101
+ export { KrutAuth, VERSION };
134
102
  //# sourceMappingURL=index.mjs.map
135
103
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/validator.ts","../src/client.ts","../src/index.ts"],"names":[],"mappings":";;;;;AAGO,IAAM,qBAAA,GAAN,MAAM,sBAAA,SAA8B,KAAA,CAAM;AAAA,EAC7C,YAAY,OAAA,EAAiB;AACzB,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,IAAA,GAAO,uBAAA;AACZ,IAAA,MAAA,CAAO,cAAA,CAAe,IAAA,EAAM,sBAAA,CAAsB,SAAS,CAAA;AAAA,EAC/D;AACJ;AAOO,SAAS,qBAAqB,MAAA,EAAkC;AACnE,EAAA,IAAI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A,CAAK,oBAAA,EAAqB;AAC1B,IAAA,IAAA,CAAK,WAAA,GAAc,IAAA;AAAA,EACvB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMQ,oBAAA,GAA6B;AACjC,IAAA,IAAA,CAAK,qBAAqB,UAAA,CAAW;AAAA,MACjC,GAAG,KAAK,MAAA,CAAO;AAAA;AAAA,KAElB,CAAA;AAAA,EACL;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,aAAA,GAA+C;AAC3C,IAAA,IAAI,CAAC,KAAK,kBAAA,EAAoB;AAC1B,MAAA,MAAM,IAAI,KAAA;AAAA,QACN;AAAA,OACJ;AAAA,IACJ;AACA,IAAA,OAAO,IAAA,CAAK,kBAAA;AAAA,EAChB;AAAA;AAAA;AAAA;AAAA,EAKA,aAAA,GAAyB;AACrB,IAAA,OAAO,IAAA,CAAK,WAAA;AAAA,EAChB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,SAAA,GAAoB;AAChB,IAAA,OAAO,IAAA,CAAK,MAAA;AAAA,EAChB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,MAAA,GAAS;AACX,IAAA,MAAM,IAAA,GAAO,KAAK,aAAA,EAAc;AAGhC,IAAA,OAAO,IAAA;AAAA,EACX;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,OAAA,GAAU;AACZ,IAAA,MAAM,IAAA,GAAO,KAAK,aAAA,EAAc;AAChC,IAAA,OAAO,IAAA;AAAA,EACX;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,UAAA,GAAa;AACf,IAAA,MAAM,IAAA,GAAO,KAAK,aAAA,EAAc;AAChC,IAAA,OAAO,IAAA;AAAA,EACX;AACJ;;;ACpHO,IAAM,OAAA,GAAU","file":"index.mjs","sourcesContent":["/**\n * Custom error class for API key validation failures\n */\nexport class ApiKeyValidationError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'ApiKeyValidationError';\n Object.setPrototypeOf(this, ApiKeyValidationError.prototype);\n }\n}\n\n/**\n * Validates the format of an API key\n * @param apiKey - The API key to validate\n * @throws {ApiKeyValidationError} If the API key is invalid\n */\nexport function validateApiKeyFormat(apiKey: string | undefined): void {\n if (!apiKey) {\n throw new ApiKeyValidationError(\n 'API key is required. Please provide a valid API key to use @krutai/auth.'\n );\n }\n\n if (typeof apiKey !== 'string') {\n throw new ApiKeyValidationError('API key must be a string.');\n }\n\n if (apiKey.trim().length === 0) {\n throw new ApiKeyValidationError('API key cannot be empty.');\n }\n\n // Basic format validation - adjust based on your API key format\n if (apiKey.length < 10) {\n throw new ApiKeyValidationError(\n 'API key appears to be invalid. Please check your API key.'\n );\n }\n}\n\n/**\n * Validates an API key against a backend service (optional)\n * This is a placeholder for actual API validation logic\n * @param _apiKey - The API key to validate (currently unused in mock implementation)\n * @returns Promise that resolves if valid, rejects if invalid\n */\nexport async function validateApiKeyWithService(\n _apiKey: string\n): Promise<boolean> {\n // TODO: Implement actual API validation against your backend\n // For now, this is a mock implementation\n\n // Example implementation:\n // const response = await fetch('https://api.krutai.com/validate', {\n // headers: { 'Authorization': `Bearer ${_apiKey}` }\n // });\n // if (!response.ok) {\n // throw new ApiKeyValidationError('Invalid API key');\n // }\n // return true;\n\n // Mock validation - accepts any key that passes format validation\n return Promise.resolve(true);\n}\n","import { betterAuth } from 'better-auth';\nimport type { KrutAuthConfig } from './types';\nimport {\n validateApiKeyFormat,\n validateApiKeyWithService,\n} from './validator';\n\n/**\n * KrutAuth - Authentication client for KrutAI\n * \n * This class wraps Better Auth and adds API key validation\n * to ensure only authorized users can access authentication features.\n * \n * @example\n * ```typescript\n * import { KrutAuth } from '@krutai/auth';\n * \n * const auth = new KrutAuth({\n * apiKey: 'your-api-key-here',\n * betterAuthOptions: {\n * // Better Auth configuration\n * }\n * });\n * \n * // Initialize the client (validates API key)\n * await auth.initialize();\n * \n * // Use authentication features\n * const betterAuth = auth.getBetterAuth();\n * ```\n */\nexport class KrutAuth {\n private apiKey: string;\n private betterAuthInstance: ReturnType<typeof betterAuth> | null = null;\n private initialized = false;\n\n /**\n * Creates a new KrutAuth instance\n * @param config - Configuration options\n * @throws {ApiKeyValidationError} If API key is invalid\n */\n constructor(private config: KrutAuthConfig) {\n // Validate API key format immediately\n validateApiKeyFormat(config.apiKey);\n this.apiKey = config.apiKey;\n\n // Initialize if validation is not required on init\n if (config.validateOnInit === false) {\n this.initializeBetterAuth();\n }\n }\n\n /**\n * Initialize the authentication client\n * Validates the API key and sets up Better Auth\n * @throws {ApiKeyValidationError} If API key validation fails\n */\n async initialize(): Promise<void> {\n if (this.initialized) {\n return;\n }\n\n // Validate API key with service if needed\n if (this.config.validateOnInit !== false) {\n await validateApiKeyWithService(this.apiKey);\n }\n\n this.initializeBetterAuth();\n this.initialized = true;\n }\n\n /**\n * Initialize Better Auth instance\n * @private\n */\n private initializeBetterAuth(): void {\n this.betterAuthInstance = betterAuth({\n ...this.config.betterAuthOptions,\n // Add any custom configuration here\n });\n }\n\n /**\n * Get the Better Auth instance\n * @throws {Error} If not initialized\n */\n getBetterAuth(): ReturnType<typeof betterAuth> {\n if (!this.betterAuthInstance) {\n throw new Error(\n 'KrutAuth not initialized. Call initialize() first or set validateOnInit to false.'\n );\n }\n return this.betterAuthInstance;\n }\n\n /**\n * Check if the client is initialized\n */\n isInitialized(): boolean {\n return this.initialized;\n }\n\n /**\n * Get the API key (useful for making authenticated requests)\n * @returns The API key\n */\n getApiKey(): string {\n return this.apiKey;\n }\n\n /**\n * Sign in a user\n * This is a convenience method that wraps Better Auth\n * You can access the full Better Auth API via getBetterAuth()\n */\n async signIn() {\n const auth = this.getBetterAuth();\n // Return the Better Auth instance for further operations\n // Users can call methods on it directly\n return auth;\n }\n\n /**\n * Sign out the current user\n * You can access the full Better Auth API via getBetterAuth()\n */\n async signOut() {\n const auth = this.getBetterAuth();\n return auth;\n }\n\n /**\n * Get the current session\n * You can access the full Better Auth API via getBetterAuth()\n */\n async getSession() {\n const auth = this.getBetterAuth();\n return auth;\n }\n}\n","/**\n * @krutai/auth - Authentication package for KrutAI\n * \n * This package provides authentication functionality powered by Better Auth\n * with API key validation to ensure secure access.\n * \n * @packageDocumentation\n */\n\n// Export main client\nexport { KrutAuth } from './client';\n\n// Export types\nexport type { KrutAuthConfig, AuthSession, BetterAuthOptions } from './types';\n\n// Export validator utilities\nexport {\n validateApiKeyFormat,\n validateApiKeyWithService,\n ApiKeyValidationError,\n} from './validator';\n\n// Package metadata\nexport const VERSION = '0.1.0';\n"]}
1
+ {"version":3,"sources":["../src/client.ts","../src/index.ts"],"names":[],"mappings":";;;;;AAgCO,IAAM,WAAN,MAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUlB,YAAoB,MAAA,EAAwB;AAAxB,IAAA,IAAA,CAAA,MAAA,GAAA,MAAA;AAEhB,IAAA,oBAAA,CAAqB,OAAO,MAAM,CAAA;AAClC,IAAA,IAAA,CAAK,SAAS,MAAA,CAAO,MAAA;AAGrB,IAAA,IAAI,MAAA,CAAO,mBAAmB,KAAA,EAAO;AACjC,MAAA,IAAA,CAAK,oBAAA,EAAqB;AAAA,IAC9B;AAAA,EACJ;AAAA,EAlBQ,MAAA;AAAA,EACA,kBAAA,GAA2D,IAAA;AAAA,EAC3D,WAAA,GAAc,KAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAuBtB,MAAM,UAAA,GAA4B;AAC9B,IAAA,IAAI,KAAK,WAAA,EAAa;AAClB,MAAA;AAAA,IACJ;AAGA,IAAA,IAAI,IAAA,CAAK,MAAA,CAAO,cAAA,KAAmB,KAAA,EAAO;AACtC,MAAA,MAAM,yBAAA,CAA0B,KAAK,MAAM,CAAA;AAAA,IAC/C;AAEA,IAAA,IAAA,CAAK,oBAAA,EAAqB;AAC1B,IAAA,IAAA,CAAK,WAAA,GAAc,IAAA;AAAA,EACvB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMQ,oBAAA,GAA6B;AACjC,IAAA,IAAA,CAAK,qBAAqB,UAAA,CAAW;AAAA,MACjC,GAAG,KAAK,MAAA,CAAO;AAAA;AAAA,KAElB,CAAA;AAAA,EACL;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,aAAA,GAA+C;AAC3C,IAAA,IAAI,CAAC,KAAK,kBAAA,EAAoB;AAC1B,MAAA,MAAM,IAAI,KAAA;AAAA,QACN;AAAA,OACJ;AAAA,IACJ;AACA,IAAA,OAAO,IAAA,CAAK,kBAAA;AAAA,EAChB;AAAA;AAAA;AAAA;AAAA,EAKA,aAAA,GAAyB;AACrB,IAAA,OAAO,IAAA,CAAK,WAAA;AAAA,EAChB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,SAAA,GAAoB;AAChB,IAAA,OAAO,IAAA,CAAK,MAAA;AAAA,EAChB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,MAAA,GAAS;AACX,IAAA,MAAM,IAAA,GAAO,KAAK,aAAA,EAAc;AAGhC,IAAA,OAAO,IAAA;AAAA,EACX;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,OAAA,GAAU;AACZ,IAAA,MAAM,IAAA,GAAO,KAAK,aAAA,EAAc;AAChC,IAAA,OAAO,IAAA;AAAA,EACX;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,UAAA,GAAa;AACf,IAAA,MAAM,IAAA,GAAO,KAAK,aAAA,EAAc;AAChC,IAAA,OAAO,IAAA;AAAA,EACX;AACJ;ACpHO,IAAM,OAAA,GAAU","file":"index.mjs","sourcesContent":["import { betterAuth } from 'better-auth';\nimport type { KrutAuthConfig } from './types';\n// Import validation from parent krutai package\nimport {\n validateApiKeyFormat,\n validateApiKeyWithService,\n} from 'krutai';\n\n/**\n * KrutAuth - Authentication client for KrutAI\n * \n * This class wraps Better Auth and adds API key validation\n * to ensure only authorized users can access authentication features.\n * \n * @example\n * ```typescript\n * import { KrutAuth } from '@krutai/auth';\n * \n * const auth = new KrutAuth({\n * apiKey: 'your-api-key-here',\n * betterAuthOptions: {\n * // Better Auth configuration\n * }\n * });\n * \n * // Initialize the client (validates API key)\n * await auth.initialize();\n * \n * // Use authentication features\n * const betterAuth = auth.getBetterAuth();\n * ```\n */\nexport class KrutAuth {\n private apiKey: string;\n private betterAuthInstance: ReturnType<typeof betterAuth> | null = null;\n private initialized = false;\n\n /**\n * Creates a new KrutAuth instance\n * @param config - Configuration options\n * @throws {ApiKeyValidationError} If API key is invalid\n */\n constructor(private config: KrutAuthConfig) {\n // Validate API key format immediately\n validateApiKeyFormat(config.apiKey);\n this.apiKey = config.apiKey;\n\n // Initialize if validation is not required on init\n if (config.validateOnInit === false) {\n this.initializeBetterAuth();\n }\n }\n\n /**\n * Initialize the authentication client\n * Validates the API key and sets up Better Auth\n * @throws {ApiKeyValidationError} If API key validation fails\n */\n async initialize(): Promise<void> {\n if (this.initialized) {\n return;\n }\n\n // Validate API key with service if needed\n if (this.config.validateOnInit !== false) {\n await validateApiKeyWithService(this.apiKey);\n }\n\n this.initializeBetterAuth();\n this.initialized = true;\n }\n\n /**\n * Initialize Better Auth instance\n * @private\n */\n private initializeBetterAuth(): void {\n this.betterAuthInstance = betterAuth({\n ...this.config.betterAuthOptions,\n // Add any custom configuration here\n });\n }\n\n /**\n * Get the Better Auth instance\n * @throws {Error} If not initialized\n */\n getBetterAuth(): ReturnType<typeof betterAuth> {\n if (!this.betterAuthInstance) {\n throw new Error(\n 'KrutAuth not initialized. Call initialize() first or set validateOnInit to false.'\n );\n }\n return this.betterAuthInstance;\n }\n\n /**\n * Check if the client is initialized\n */\n isInitialized(): boolean {\n return this.initialized;\n }\n\n /**\n * Get the API key (useful for making authenticated requests)\n * @returns The API key\n */\n getApiKey(): string {\n return this.apiKey;\n }\n\n /**\n * Sign in a user\n * This is a convenience method that wraps Better Auth\n * You can access the full Better Auth API via getBetterAuth()\n */\n async signIn() {\n const auth = this.getBetterAuth();\n // Return the Better Auth instance for further operations\n // Users can call methods on it directly\n return auth;\n }\n\n /**\n * Sign out the current user\n * You can access the full Better Auth API via getBetterAuth()\n */\n async signOut() {\n const auth = this.getBetterAuth();\n return auth;\n }\n\n /**\n * Get the current session\n * You can access the full Better Auth API via getBetterAuth()\n */\n async getSession() {\n const auth = this.getBetterAuth();\n return auth;\n }\n}\n","/**\n * @krutai/auth - Authentication package for KrutAI\n * \n * This package provides authentication functionality powered by Better Auth\n * with API key validation to ensure secure access.\n * \n * @packageDocumentation\n */\n\n// Export main client\nexport { KrutAuth } from './client';\n\n// Export types\nexport type { KrutAuthConfig, AuthSession, BetterAuthOptions } from './types';\n\n// Re-export validator utilities from parent krutai package\nexport {\n validateApiKeyFormat,\n validateApiKeyWithService,\n createApiKeyChecker,\n ApiKeyValidationError,\n} from 'krutai';\n\n// Package metadata\nexport const VERSION = '0.1.1';\n"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@krutai/auth",
3
- "version": "0.1.0",
4
- "description": "Authentication package for KrutAI powered by Better Auth",
3
+ "version": "0.1.1",
4
+ "description": "Authentication package for KrutAI powered by Krut AI",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
7
7
  "types": "./dist/index.d.ts",
@@ -32,6 +32,7 @@
32
32
  "author": "",
33
33
  "license": "MIT",
34
34
  "dependencies": {
35
+ "krutai": "^0.1.1",
35
36
  "better-auth": "^1.1.7"
36
37
  },
37
38
  "devDependencies": {