@krutai/auth 0.1.3 → 0.1.4
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/AI_REFERENCE.md +96 -148
- package/README.md +14 -5
- package/dist/index.d.mts +3 -42
- package/dist/index.d.ts +3 -42
- package/dist/index.js +20 -66
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +4 -61
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -2
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { validateApiKeyFormat, validateApiKeyWithService } from 'krutai';
|
|
2
|
+
export { ApiKeyValidationError, createApiKeyChecker, validateApiKeyFormat, validateApiKeyWithService } from 'krutai';
|
|
3
|
+
|
|
1
4
|
var __defProp = Object.defineProperty;
|
|
2
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
3
6
|
var __esm = (fn, res) => function __init() {
|
|
@@ -51489,64 +51492,6 @@ var betterAuth = (options) => {
|
|
|
51489
51492
|
init_env();
|
|
51490
51493
|
init_error();
|
|
51491
51494
|
init_utils();
|
|
51492
|
-
|
|
51493
|
-
// src/validator.ts
|
|
51494
|
-
var ApiKeyValidationError = class extends Error {
|
|
51495
|
-
constructor(message2) {
|
|
51496
|
-
super(message2);
|
|
51497
|
-
this.name = "ApiKeyValidationError";
|
|
51498
|
-
}
|
|
51499
|
-
};
|
|
51500
|
-
function validateApiKeyFormat(apiKey) {
|
|
51501
|
-
if (!apiKey || typeof apiKey !== "string") {
|
|
51502
|
-
throw new ApiKeyValidationError("API key must be a non-empty string");
|
|
51503
|
-
}
|
|
51504
|
-
if (apiKey.trim().length === 0) {
|
|
51505
|
-
throw new ApiKeyValidationError("API key cannot be empty or whitespace");
|
|
51506
|
-
}
|
|
51507
|
-
if (apiKey.length < 10) {
|
|
51508
|
-
throw new ApiKeyValidationError("API key must be at least 10 characters long");
|
|
51509
|
-
}
|
|
51510
|
-
}
|
|
51511
|
-
async function validateApiKeyWithService(apiKey) {
|
|
51512
|
-
validateApiKeyFormat(apiKey);
|
|
51513
|
-
try {
|
|
51514
|
-
return true;
|
|
51515
|
-
} catch (error49) {
|
|
51516
|
-
throw new ApiKeyValidationError(
|
|
51517
|
-
`Failed to validate API key: ${error49 instanceof Error ? error49.message : "Unknown error"}`
|
|
51518
|
-
);
|
|
51519
|
-
}
|
|
51520
|
-
}
|
|
51521
|
-
function createApiKeyChecker(apiKey) {
|
|
51522
|
-
let isValid = null;
|
|
51523
|
-
let validationPromise = null;
|
|
51524
|
-
return {
|
|
51525
|
-
/**
|
|
51526
|
-
* Validates the API key (cached after first call)
|
|
51527
|
-
*/
|
|
51528
|
-
async validate() {
|
|
51529
|
-
if (isValid !== null) {
|
|
51530
|
-
return isValid;
|
|
51531
|
-
}
|
|
51532
|
-
if (validationPromise) {
|
|
51533
|
-
return validationPromise;
|
|
51534
|
-
}
|
|
51535
|
-
validationPromise = validateApiKeyWithService(apiKey);
|
|
51536
|
-
isValid = await validationPromise;
|
|
51537
|
-
return isValid;
|
|
51538
|
-
},
|
|
51539
|
-
/**
|
|
51540
|
-
* Resets the validation cache
|
|
51541
|
-
*/
|
|
51542
|
-
reset() {
|
|
51543
|
-
isValid = null;
|
|
51544
|
-
validationPromise = null;
|
|
51545
|
-
}
|
|
51546
|
-
};
|
|
51547
|
-
}
|
|
51548
|
-
|
|
51549
|
-
// src/client.ts
|
|
51550
51495
|
var KrutAuth = class {
|
|
51551
51496
|
/**
|
|
51552
51497
|
* Creates a new KrutAuth instance
|
|
@@ -51639,8 +51584,6 @@ var KrutAuth = class {
|
|
|
51639
51584
|
return auth;
|
|
51640
51585
|
}
|
|
51641
51586
|
};
|
|
51642
|
-
|
|
51643
|
-
// src/index.ts
|
|
51644
51587
|
var VERSION = "0.1.2";
|
|
51645
51588
|
/*! Bundled license information:
|
|
51646
51589
|
|
|
@@ -51651,6 +51594,6 @@ var VERSION = "0.1.2";
|
|
|
51651
51594
|
(*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) *)
|
|
51652
51595
|
*/
|
|
51653
51596
|
|
|
51654
|
-
export {
|
|
51597
|
+
export { KrutAuth, VERSION, betterAuth };
|
|
51655
51598
|
//# sourceMappingURL=index.mjs.map
|
|
51656
51599
|
//# sourceMappingURL=index.mjs.map
|