@better-auth/infra 0.2.8 → 0.2.10
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 +4 -5
- package/dist/client.mjs +5 -3
- package/dist/{dash-client-B6U89e1S.d.mts → dash-client-CZzJyRrV.d.mts} +1 -3
- package/dist/index.d.mts +583 -563
- package/dist/index.mjs +393 -81
- package/dist/native.d.mts +1 -1
- package/dist/native.mjs +5 -3
- package/dist/{pow-retry-BTL4g3RP.mjs → pow-retry-D2RRftJr.mjs} +34 -1
- package/package.json +13 -12
package/dist/native.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as DashGetAuditLogsInput, i as DashGetAllAuditLogsInput, n as DashAuditLogsResponse, o as dashClient, r as DashClientOptions, t as DashAuditLog } from "./dash-client-
|
|
1
|
+
import { a as DashGetAuditLogsInput, i as DashGetAllAuditLogsInput, n as DashAuditLogsResponse, o as dashClient, r as DashClientOptions, t as DashAuditLog } from "./dash-client-CZzJyRrV.mjs";
|
|
2
2
|
import { BetterAuthClientPlugin } from "better-auth";
|
|
3
3
|
|
|
4
4
|
//#region src/sentinel/native/client.d.ts
|
package/dist/native.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "./constants-CvriWQVc.mjs";
|
|
2
2
|
import { n as createKV } from "./fetch-DiAhoiKA.mjs";
|
|
3
|
-
import {
|
|
3
|
+
import { a as resolveSentinelClientIdentifyUrl, c as bytesToHex, i as solvePoWChallenge, n as decodePoWChallenge, r as encodePoWSolution, s as identify, t as createPowRetryTimeout, u as dashClient } from "./pow-retry-D2RRftJr.mjs";
|
|
4
4
|
import { env } from "@better-auth/core/env";
|
|
5
5
|
import { Dimensions, InteractionManager, PixelRatio, Platform } from "react-native";
|
|
6
6
|
//#region src/sentinel/native/components.ts
|
|
@@ -190,7 +190,6 @@ async function getOrCreateVisitorId(storage) {
|
|
|
190
190
|
}
|
|
191
191
|
//#endregion
|
|
192
192
|
//#region src/sentinel/native/client.ts
|
|
193
|
-
const DEFAULT_IDENTIFY_URL = "https://kv.better-auth.com";
|
|
194
193
|
function scheduleIdentify(send) {
|
|
195
194
|
const run = () => {
|
|
196
195
|
try {
|
|
@@ -213,7 +212,10 @@ const sentinelNativeClient = (options) => {
|
|
|
213
212
|
const autoSolve = options?.autoSolveChallenge !== false;
|
|
214
213
|
const runtime = createNativeFingerprintRuntime({
|
|
215
214
|
$kv: createKV({
|
|
216
|
-
kvUrl:
|
|
215
|
+
kvUrl: resolveSentinelClientIdentifyUrl({
|
|
216
|
+
identifyUrl: options?.identifyUrl,
|
|
217
|
+
envKvUrl: env.BETTER_AUTH_KV_URL
|
|
218
|
+
}),
|
|
217
219
|
kvTimeout: options?.kvTimeout
|
|
218
220
|
}),
|
|
219
221
|
getOrCreateVisitorId: () => getOrCreateVisitorId(options?.storage)
|
|
@@ -72,6 +72,39 @@ async function identify($kv, payload) {
|
|
|
72
72
|
});
|
|
73
73
|
}
|
|
74
74
|
//#endregion
|
|
75
|
+
//#region src/sentinel/identify-url.ts
|
|
76
|
+
const DEFAULT_IDENTIFY_URL = "https://kv.better-auth.com";
|
|
77
|
+
function normalizeIdentifyUrl(url) {
|
|
78
|
+
return url.replace(/\/$/, "");
|
|
79
|
+
}
|
|
80
|
+
/** True when the URL targets project-scoped ingestion, e.g. .../projects/{orgId}. */
|
|
81
|
+
function isProjectScopedIdentifyUrl(url) {
|
|
82
|
+
return /\/projects\/[^/]+$/.test(normalizeIdentifyUrl(url));
|
|
83
|
+
}
|
|
84
|
+
const DEFAULT_GLOBAL_INGESTION_WARNING = "[Sentinel] Default global identify ingestion is active but not recommended. Get your ingestion url from your project settings page (e.g. https://kv.better-auth.com/projects/{id}) and configure sentinelClient({ identifyUrl }) with it.";
|
|
85
|
+
const CONFIGURED_GLOBAL_INGESTION_WARNING = "[Sentinel] Global identify ingestion is configured but not recommended. Get your ingestion url from your project settings page (e.g. https://kv.better-auth.com/projects/{id}) and configure sentinelClient({ identifyUrl }) with it.";
|
|
86
|
+
function warnOnGlobalIdentifyIngestion(url, message) {
|
|
87
|
+
if (isProjectScopedIdentifyUrl(url)) return;
|
|
88
|
+
console.warn(message);
|
|
89
|
+
}
|
|
90
|
+
function resolveSentinelClientIdentifyUrl(options) {
|
|
91
|
+
const explicit = options?.identifyUrl?.trim();
|
|
92
|
+
if (explicit) {
|
|
93
|
+
const url = normalizeIdentifyUrl(explicit);
|
|
94
|
+
warnOnGlobalIdentifyIngestion(url, CONFIGURED_GLOBAL_INGESTION_WARNING);
|
|
95
|
+
return url;
|
|
96
|
+
}
|
|
97
|
+
const fromEnv = options?.envKvUrl?.trim();
|
|
98
|
+
if (fromEnv) {
|
|
99
|
+
const url = normalizeIdentifyUrl(fromEnv);
|
|
100
|
+
warnOnGlobalIdentifyIngestion(url, CONFIGURED_GLOBAL_INGESTION_WARNING);
|
|
101
|
+
return url;
|
|
102
|
+
}
|
|
103
|
+
const url = DEFAULT_IDENTIFY_URL;
|
|
104
|
+
warnOnGlobalIdentifyIngestion(url, DEFAULT_GLOBAL_INGESTION_WARNING);
|
|
105
|
+
return url;
|
|
106
|
+
}
|
|
107
|
+
//#endregion
|
|
75
108
|
//#region src/sentinel/pow.ts
|
|
76
109
|
function hasLeadingZeroBits(hash, bits) {
|
|
77
110
|
const fullHexChars = Math.floor(bits / 4);
|
|
@@ -148,4 +181,4 @@ function createPowRetryTimeout(timeoutMs) {
|
|
|
148
181
|
};
|
|
149
182
|
}
|
|
150
183
|
//#endregion
|
|
151
|
-
export {
|
|
184
|
+
export { resolveSentinelClientIdentifyUrl as a, bytesToHex as c, solvePoWChallenge as i, hash as l, decodePoWChallenge as n, generateRequestId as o, encodePoWSolution as r, identify as s, createPowRetryTimeout as t, dashClient as u };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@better-auth/infra",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.10",
|
|
4
4
|
"description": "Dashboard and analytics plugin for Better Auth",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.mjs",
|
|
@@ -61,24 +61,25 @@
|
|
|
61
61
|
},
|
|
62
62
|
"homepage": "https://better-auth.com",
|
|
63
63
|
"devDependencies": {
|
|
64
|
-
"@better-auth/scim": "
|
|
65
|
-
"@better-auth/sso": "
|
|
66
|
-
"@infra/mocks": "
|
|
64
|
+
"@better-auth/scim": "1.6.11",
|
|
65
|
+
"@better-auth/sso": "1.6.11",
|
|
66
|
+
"@infra/mocks": "0.0.0",
|
|
67
|
+
"@infra/utils": "0.0.0",
|
|
67
68
|
"@types/bun": "latest",
|
|
68
|
-
"@types/node": "
|
|
69
|
-
"better-auth": "
|
|
69
|
+
"@types/node": "^24.12.0",
|
|
70
|
+
"better-auth": "1.6.11",
|
|
70
71
|
"expo-crypto": "^14.0.2",
|
|
71
72
|
"happy-dom": "^20.9.0",
|
|
72
|
-
"msw": "^2.14.
|
|
73
|
-
"tsdown": "^0.
|
|
74
|
-
"typescript": "
|
|
75
|
-
"zod": "
|
|
73
|
+
"msw": "^2.14.6",
|
|
74
|
+
"tsdown": "^0.22.0",
|
|
75
|
+
"typescript": "^5.9.2",
|
|
76
|
+
"zod": "^4.3.6"
|
|
76
77
|
},
|
|
77
78
|
"dependencies": {
|
|
78
79
|
"@better-fetch/fetch": "^1.1.21",
|
|
79
|
-
"better-call": "^1.3.
|
|
80
|
+
"better-call": "^1.3.2",
|
|
80
81
|
"jose": "^6.1.0",
|
|
81
|
-
"libphonenumber-js": "^1.13.
|
|
82
|
+
"libphonenumber-js": "^1.13.2"
|
|
82
83
|
},
|
|
83
84
|
"peerDependencies": {
|
|
84
85
|
"better-auth": ">=1.4.0",
|