@better-auth/api-key 1.6.19 → 1.6.21
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,5 +1,6 @@
|
|
|
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-CW4oPs_X.mjs";
|
|
2
2
|
import { createAuthEndpoint, createAuthMiddleware } from "@better-auth/core/api";
|
|
3
|
+
import { getIp } from "@better-auth/core/utils/ip";
|
|
3
4
|
import { base64Url } from "@better-auth/utils/base64";
|
|
4
5
|
import { createHash } from "@better-auth/utils/hash";
|
|
5
6
|
import { BetterAuthError } from "better-auth";
|
|
@@ -11,8 +12,6 @@ import { generateId } from "@better-auth/core/utils/id";
|
|
|
11
12
|
import { safeJSONParse } from "@better-auth/core/utils/json";
|
|
12
13
|
import * as z from "zod";
|
|
13
14
|
import { mapConcurrent } from "@better-auth/core/utils/async";
|
|
14
|
-
import { isDevelopment, isTest } from "@better-auth/core/env";
|
|
15
|
-
import { isValidIP, normalizeIP } from "@better-auth/core/utils/ip";
|
|
16
15
|
import { role } from "better-auth/plugins/access";
|
|
17
16
|
import { parseJSON } from "better-auth/client";
|
|
18
17
|
//#region src/adapter.ts
|
|
@@ -577,21 +576,6 @@ const getDate = (span, unit = "ms") => {
|
|
|
577
576
|
function isAPIError(error) {
|
|
578
577
|
return error instanceof APIError || error instanceof APIError$1 || error?.name === "APIError";
|
|
579
578
|
}
|
|
580
|
-
const LOCALHOST_IP = "127.0.0.1";
|
|
581
|
-
function getIp(req, options) {
|
|
582
|
-
if (options.advanced?.ipAddress?.disableIpTracking) return null;
|
|
583
|
-
const headers = "headers" in req ? req.headers : req;
|
|
584
|
-
const ipHeaders = options.advanced?.ipAddress?.ipAddressHeaders || ["x-forwarded-for"];
|
|
585
|
-
for (const key of ipHeaders) {
|
|
586
|
-
const value = "get" in headers ? headers.get(key) : headers[key];
|
|
587
|
-
if (typeof value === "string") {
|
|
588
|
-
const ip = value.split(",")[0].trim();
|
|
589
|
-
if (isValidIP(ip)) return normalizeIP(ip, { ipv6Subnet: options.advanced?.ipAddress?.ipv6Subnet });
|
|
590
|
-
}
|
|
591
|
-
}
|
|
592
|
-
if (isTest() || isDevelopment()) return LOCALHOST_IP;
|
|
593
|
-
return null;
|
|
594
|
-
}
|
|
595
579
|
//#endregion
|
|
596
580
|
//#region src/routes/create-api-key.ts
|
|
597
581
|
const createApiKeyBodySchema = z.object({
|
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.21",
|
|
4
4
|
"description": "API Key plugin for Better Auth.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -61,14 +61,14 @@
|
|
|
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.21",
|
|
65
|
+
"better-auth": "1.6.21"
|
|
66
66
|
},
|
|
67
67
|
"peerDependencies": {
|
|
68
68
|
"@better-auth/utils": "0.4.2",
|
|
69
|
-
"better-call": "1.3.
|
|
70
|
-
"@better-auth/core": "^1.6.
|
|
71
|
-
"better-auth": "^1.6.
|
|
69
|
+
"better-call": "1.3.7",
|
|
70
|
+
"@better-auth/core": "^1.6.21",
|
|
71
|
+
"better-auth": "^1.6.21"
|
|
72
72
|
},
|
|
73
73
|
"scripts": {
|
|
74
74
|
"build": "tsdown",
|