@better-auth/api-key 1.6.9 → 1.6.11
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/client.mjs
CHANGED
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as API_KEY_ERROR_CODES, t as PACKAGE_VERSION } from "./version-
|
|
1
|
+
import { n as API_KEY_ERROR_CODES, t as PACKAGE_VERSION } from "./version-CwRZx9_C.mjs";
|
|
2
2
|
import { createAuthEndpoint, createAuthMiddleware } from "@better-auth/core/api";
|
|
3
3
|
import { base64Url } from "@better-auth/utils/base64";
|
|
4
4
|
import { createHash } from "@better-auth/utils/hash";
|
|
@@ -1635,6 +1635,7 @@ function isRateLimited(apiKey, opts) {
|
|
|
1635
1635
|
async function validateApiKey({ hashedKey, ctx, opts, schema, permissions }) {
|
|
1636
1636
|
const apiKey = await getApiKey$1(ctx, hashedKey, opts);
|
|
1637
1637
|
if (!apiKey) throw APIError$1.from("UNAUTHORIZED", API_KEY_ERROR_CODES.INVALID_API_KEY);
|
|
1638
|
+
if (apiKey.configId !== (opts.configId ?? "default")) throw APIError$1.from("UNAUTHORIZED", API_KEY_ERROR_CODES.INVALID_API_KEY);
|
|
1638
1639
|
if (apiKey.enabled === false) throw APIError$1.from("UNAUTHORIZED", API_KEY_ERROR_CODES.KEY_DISABLED);
|
|
1639
1640
|
if (apiKey.expiresAt) {
|
|
1640
1641
|
if (Date.now() > new Date(apiKey.expiresAt).getTime()) {
|
|
@@ -1711,7 +1712,7 @@ async function validateApiKey({ hashedKey, ctx, opts, schema, permissions }) {
|
|
|
1711
1712
|
else remaining--;
|
|
1712
1713
|
}
|
|
1713
1714
|
const { message, success, update, tryAgainIn } = isRateLimited(apiKey, opts);
|
|
1714
|
-
if (success === false) throw new APIError$1("
|
|
1715
|
+
if (success === false) throw new APIError$1("TOO_MANY_REQUESTS", {
|
|
1715
1716
|
message: message ?? void 0,
|
|
1716
1717
|
code: "RATE_LIMITED",
|
|
1717
1718
|
details: { tryAgainIn }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@better-auth/api-key",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.11",
|
|
4
4
|
"description": "API Key plugin for Better Auth.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -61,13 +61,13 @@
|
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
63
|
"tsdown": "0.21.1",
|
|
64
|
-
"@better-auth/core": "1.6.
|
|
65
|
-
"better-auth": "1.6.
|
|
64
|
+
"@better-auth/core": "1.6.11",
|
|
65
|
+
"better-auth": "1.6.11"
|
|
66
66
|
},
|
|
67
67
|
"peerDependencies": {
|
|
68
68
|
"@better-auth/utils": "0.4.0",
|
|
69
|
-
"@better-auth/core": "^1.6.
|
|
70
|
-
"better-auth": "^1.6.
|
|
69
|
+
"@better-auth/core": "^1.6.11",
|
|
70
|
+
"better-auth": "^1.6.11"
|
|
71
71
|
},
|
|
72
72
|
"scripts": {
|
|
73
73
|
"build": "tsdown",
|