@better-auth/api-key 1.5.6 → 1.5.7-beta.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/dist/client.d.mts +2 -2
- package/dist/client.mjs +2 -3
- package/dist/client.mjs.map +1 -1
- package/dist/{error-codes-vwTWW2ez.mjs → error-codes-C8MQDPqn.mjs} +2 -3
- package/dist/{error-codes-vwTWW2ez.mjs.map → error-codes-C8MQDPqn.mjs.map} +1 -1
- package/dist/index-WXH3i1Uh.d.mts +1268 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +3 -17
- package/dist/index.mjs.map +1 -1
- package/dist/{types-CCe5L05Y.d.mts → types-BR70O3Q3.d.mts} +1 -1
- package/dist/types.d.mts +1 -1
- package/dist/types.mjs +1 -1
- package/package.json +6 -6
- package/dist/index-CLXIQyX5.d.mts +0 -1300
package/dist/index.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { n as ApiKeyConfigurationOptions, r as ApiKeyOptions, t as ApiKey } from "./types-
|
|
2
|
-
import { i as API_KEY_ERROR_CODES, n as apiKey, r as defaultKeyHasher, t as API_KEY_TABLE_NAME } from "./index-
|
|
1
|
+
import { n as ApiKeyConfigurationOptions, r as ApiKeyOptions, t as ApiKey } from "./types-BR70O3Q3.mjs";
|
|
2
|
+
import { i as API_KEY_ERROR_CODES, n as apiKey, r as defaultKeyHasher, t as API_KEY_TABLE_NAME } from "./index-WXH3i1Uh.mjs";
|
|
3
3
|
export { API_KEY_ERROR_CODES, API_KEY_TABLE_NAME, ApiKey, ApiKeyConfigurationOptions, ApiKeyOptions, apiKey, defaultKeyHasher };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as API_KEY_ERROR_CODES } from "./error-codes-
|
|
1
|
+
import { t as API_KEY_ERROR_CODES } from "./error-codes-C8MQDPqn.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";
|
|
@@ -14,7 +14,6 @@ import { isDevelopment, isTest } from "@better-auth/core/env";
|
|
|
14
14
|
import { isValidIP, normalizeIP } from "@better-auth/core/utils/ip";
|
|
15
15
|
import { role } from "better-auth/plugins/access";
|
|
16
16
|
import { parseJSON } from "better-auth/client";
|
|
17
|
-
|
|
18
17
|
//#region src/adapter.ts
|
|
19
18
|
/**
|
|
20
19
|
* Parses double-stringified metadata synchronously without updating the database.
|
|
@@ -477,7 +476,6 @@ async function listApiKeys$1(ctx, referenceId, opts, paginationOpts) {
|
|
|
477
476
|
total
|
|
478
477
|
};
|
|
479
478
|
}
|
|
480
|
-
|
|
481
479
|
//#endregion
|
|
482
480
|
//#region src/org-authorization.ts
|
|
483
481
|
/**
|
|
@@ -549,7 +547,6 @@ async function checkPermission(ctx, role, organizationId, action, orgOptions) {
|
|
|
549
547
|
return false;
|
|
550
548
|
}
|
|
551
549
|
}
|
|
552
|
-
|
|
553
550
|
//#endregion
|
|
554
551
|
//#region src/utils.ts
|
|
555
552
|
const getDate = (span, unit = "ms") => {
|
|
@@ -573,7 +570,6 @@ function getIp(req, options) {
|
|
|
573
570
|
if (isTest() || isDevelopment()) return LOCALHOST_IP;
|
|
574
571
|
return null;
|
|
575
572
|
}
|
|
576
|
-
|
|
577
573
|
//#endregion
|
|
578
574
|
//#region src/routes/create-api-key.ts
|
|
579
575
|
const createApiKeyBodySchema = z.object({
|
|
@@ -839,7 +835,7 @@ function createApiKey({ defaultKeyGenerator, configurations, schema, deleteAllEx
|
|
|
839
835
|
});
|
|
840
836
|
await setApiKey(ctx, apiKey, opts);
|
|
841
837
|
} else if (opts.storage === "secondary-storage") {
|
|
842
|
-
const id = ctx.context.generateId({ model:
|
|
838
|
+
const id = ctx.context.generateId({ model: "apikey" }) || generateId();
|
|
843
839
|
apiKey = {
|
|
844
840
|
...data,
|
|
845
841
|
id
|
|
@@ -857,7 +853,6 @@ function createApiKey({ defaultKeyGenerator, configurations, schema, deleteAllEx
|
|
|
857
853
|
});
|
|
858
854
|
});
|
|
859
855
|
}
|
|
860
|
-
|
|
861
856
|
//#endregion
|
|
862
857
|
//#region src/routes/delete-all-expired-api-keys.ts
|
|
863
858
|
function deleteAllExpiredApiKeysEndpoint({ deleteAllExpiredApiKeys }) {
|
|
@@ -877,7 +872,6 @@ function deleteAllExpiredApiKeysEndpoint({ deleteAllExpiredApiKeys }) {
|
|
|
877
872
|
});
|
|
878
873
|
});
|
|
879
874
|
}
|
|
880
|
-
|
|
881
875
|
//#endregion
|
|
882
876
|
//#region src/routes/delete-api-key.ts
|
|
883
877
|
const deleteApiKeyBodySchema = z.object({
|
|
@@ -948,7 +942,6 @@ function deleteApiKey({ configurations, schema, deleteAllExpiredApiKeys }) {
|
|
|
948
942
|
return ctx.json({ success: true });
|
|
949
943
|
});
|
|
950
944
|
}
|
|
951
|
-
|
|
952
945
|
//#endregion
|
|
953
946
|
//#region src/routes/get-api-key.ts
|
|
954
947
|
const getApiKeyQuerySchema = z.object({
|
|
@@ -1101,7 +1094,6 @@ function getApiKey({ configurations, schema, deleteAllExpiredApiKeys }) {
|
|
|
1101
1094
|
});
|
|
1102
1095
|
});
|
|
1103
1096
|
}
|
|
1104
|
-
|
|
1105
1097
|
//#endregion
|
|
1106
1098
|
//#region src/routes/list-api-keys.ts
|
|
1107
1099
|
/**
|
|
@@ -1337,7 +1329,6 @@ function listApiKeys({ configurations, schema, deleteAllExpiredApiKeys }) {
|
|
|
1337
1329
|
});
|
|
1338
1330
|
});
|
|
1339
1331
|
}
|
|
1340
|
-
|
|
1341
1332
|
//#endregion
|
|
1342
1333
|
//#region src/routes/update-api-key.ts
|
|
1343
1334
|
const updateApiKeyBodySchema = z.object({
|
|
@@ -1577,7 +1568,6 @@ function updateApiKey({ configurations, schema, deleteAllExpiredApiKeys }) {
|
|
|
1577
1568
|
});
|
|
1578
1569
|
});
|
|
1579
1570
|
}
|
|
1580
|
-
|
|
1581
1571
|
//#endregion
|
|
1582
1572
|
//#region src/rate-limit.ts
|
|
1583
1573
|
/**
|
|
@@ -1646,7 +1636,6 @@ function isRateLimited(apiKey, opts) {
|
|
|
1646
1636
|
}
|
|
1647
1637
|
};
|
|
1648
1638
|
}
|
|
1649
|
-
|
|
1650
1639
|
//#endregion
|
|
1651
1640
|
//#region src/routes/verify-api-key.ts
|
|
1652
1641
|
async function validateApiKey({ hashedKey, ctx, opts, schema, permissions }) {
|
|
@@ -1859,7 +1848,6 @@ function verifyApiKey({ configurations, schema, deleteAllExpiredApiKeys }) {
|
|
|
1859
1848
|
});
|
|
1860
1849
|
});
|
|
1861
1850
|
}
|
|
1862
|
-
|
|
1863
1851
|
//#endregion
|
|
1864
1852
|
//#region src/routes/index.ts
|
|
1865
1853
|
function resolveConfiguration(authContext, configurations, configId) {
|
|
@@ -1951,7 +1939,6 @@ function createApiKeyRoutes({ defaultKeyGenerator, configurations, schema }) {
|
|
|
1951
1939
|
deleteAllExpiredApiKeys: deleteAllExpiredApiKeysEndpoint({ deleteAllExpiredApiKeys })
|
|
1952
1940
|
};
|
|
1953
1941
|
}
|
|
1954
|
-
|
|
1955
1942
|
//#endregion
|
|
1956
1943
|
//#region src/schema.ts
|
|
1957
1944
|
const apiKeySchema = ({ defaultRateLimitMax, defaultTimeWindow }) => ({ apikey: { fields: {
|
|
@@ -2079,7 +2066,6 @@ const apiKeySchema = ({ defaultRateLimitMax, defaultTimeWindow }) => ({ apikey:
|
|
|
2079
2066
|
}
|
|
2080
2067
|
}
|
|
2081
2068
|
} } });
|
|
2082
|
-
|
|
2083
2069
|
//#endregion
|
|
2084
2070
|
//#region src/index.ts
|
|
2085
2071
|
const defaultKeyHasher = async (key) => {
|
|
@@ -2225,7 +2211,7 @@ function apiKey(_configurations, _options) {
|
|
|
2225
2211
|
schema
|
|
2226
2212
|
};
|
|
2227
2213
|
}
|
|
2228
|
-
|
|
2229
2214
|
//#endregion
|
|
2230
2215
|
export { API_KEY_ERROR_CODES, API_KEY_TABLE_NAME, apiKey, defaultKeyHasher };
|
|
2216
|
+
|
|
2231
2217
|
//# sourceMappingURL=index.mjs.map
|