@better-auth/infra 0.3.5 → 0.3.6
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/CHANGELOG.md +7 -0
- package/dist/client.mjs +2 -2
- package/dist/{constants-COVOGExF.mjs → constants-CQiIiY9L.mjs} +1 -1
- package/dist/{crypto-DvC9lT5e.mjs → crypto-Deqoay7H.mjs} +1 -1
- package/dist/email.mjs +1 -1
- package/dist/index.d.mts +11 -11
- package/dist/index.mjs +22 -37
- package/dist/native.mjs +2 -2
- package/dist/{pow-retry-DEaL-FIC.mjs → pow-retry-DXiVsZkt.mjs} +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -5,8 +5,15 @@ All notable changes to `@better-auth/infra` are documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [0.3.6] - 2026-07-09
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
|
|
12
|
+
- **Activity tracking writes** — `lastActiveAt` updates now run through Better Auth background tasks (`runInBackgroundOrAwait`) instead of blocking the request or using fire-and-forget promises, so activity tracking no longer delays responses when a background runner is available.
|
|
13
|
+
|
|
8
14
|
## [0.3.5] - 2026-07-06
|
|
9
15
|
|
|
16
|
+
|
|
10
17
|
### Added
|
|
11
18
|
|
|
12
19
|
- **`GET /dash/users` partial fetches** — Endpoint was optimized to load only the requested fields (sessions or accounts) instead of all fields.
|
package/dist/client.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { n as hash, o as createKV } from "./crypto-
|
|
2
|
-
import { a as resolveSentinelClientIdentifyUrl, c as dashClient, i as solvePoWChallenge, n as decodePoWChallenge, o as generateRequestId, r as encodePoWSolution, s as identify, t as createPowRetryTimeout } from "./pow-retry-
|
|
1
|
+
import { n as hash, o as createKV } from "./crypto-Deqoay7H.mjs";
|
|
2
|
+
import { a as resolveSentinelClientIdentifyUrl, c as dashClient, i as solvePoWChallenge, n as decodePoWChallenge, o as generateRequestId, r as encodePoWSolution, s as identify, t as createPowRetryTimeout } from "./pow-retry-DXiVsZkt.mjs";
|
|
3
3
|
import { env } from "@better-auth/core/env";
|
|
4
4
|
//#region src/sentinel/fingerprint.ts
|
|
5
5
|
function murmurhash3(str, seed = 0) {
|
package/dist/email.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as INFRA_USER_AGENT, n as INFRA_API_URL } from "./constants-
|
|
1
|
+
import { i as INFRA_USER_AGENT, n as INFRA_API_URL } from "./constants-CQiIiY9L.mjs";
|
|
2
2
|
import { logger } from "better-auth";
|
|
3
3
|
import { env } from "@better-auth/core/env";
|
|
4
4
|
import { createFetch } from "@better-fetch/fetch";
|
package/dist/index.d.mts
CHANGED
|
@@ -1245,7 +1245,7 @@ declare const dash: <O extends DashOptions>(options?: O) => {
|
|
|
1245
1245
|
emailVerified: boolean;
|
|
1246
1246
|
name: string;
|
|
1247
1247
|
image?: string | null | undefined;
|
|
1248
|
-
} & Record<string, unknown>, _ctx:
|
|
1248
|
+
} & Record<string, unknown>, _ctx: GenericEndpointContext | null): Promise<void>;
|
|
1249
1249
|
};
|
|
1250
1250
|
update: {
|
|
1251
1251
|
after(user: {
|
|
@@ -1256,7 +1256,7 @@ declare const dash: <O extends DashOptions>(options?: O) => {
|
|
|
1256
1256
|
emailVerified: boolean;
|
|
1257
1257
|
name: string;
|
|
1258
1258
|
image?: string | null | undefined;
|
|
1259
|
-
} & Record<string, unknown>, _ctx:
|
|
1259
|
+
} & Record<string, unknown>, _ctx: GenericEndpointContext | null): Promise<void>;
|
|
1260
1260
|
};
|
|
1261
1261
|
delete: {
|
|
1262
1262
|
after(user: {
|
|
@@ -1267,7 +1267,7 @@ declare const dash: <O extends DashOptions>(options?: O) => {
|
|
|
1267
1267
|
emailVerified: boolean;
|
|
1268
1268
|
name: string;
|
|
1269
1269
|
image?: string | null | undefined;
|
|
1270
|
-
} & Record<string, unknown>, _ctx:
|
|
1270
|
+
} & Record<string, unknown>, _ctx: GenericEndpointContext | null): Promise<void>;
|
|
1271
1271
|
};
|
|
1272
1272
|
};
|
|
1273
1273
|
session: {
|
|
@@ -1281,7 +1281,7 @@ declare const dash: <O extends DashOptions>(options?: O) => {
|
|
|
1281
1281
|
token: string;
|
|
1282
1282
|
ipAddress?: string | null | undefined;
|
|
1283
1283
|
userAgent?: string | null | undefined;
|
|
1284
|
-
} & Record<string, unknown>, _ctx:
|
|
1284
|
+
} & Record<string, unknown>, _ctx: GenericEndpointContext | null): Promise<{
|
|
1285
1285
|
data: {
|
|
1286
1286
|
loginMethod: string | null;
|
|
1287
1287
|
};
|
|
@@ -1295,7 +1295,7 @@ declare const dash: <O extends DashOptions>(options?: O) => {
|
|
|
1295
1295
|
token: string;
|
|
1296
1296
|
ipAddress?: string | null | undefined;
|
|
1297
1297
|
userAgent?: string | null | undefined;
|
|
1298
|
-
} & Record<string, unknown>, _ctx:
|
|
1298
|
+
} & Record<string, unknown>, _ctx: GenericEndpointContext | null): Promise<void>;
|
|
1299
1299
|
};
|
|
1300
1300
|
delete: {
|
|
1301
1301
|
after(session: {
|
|
@@ -1307,7 +1307,7 @@ declare const dash: <O extends DashOptions>(options?: O) => {
|
|
|
1307
1307
|
token: string;
|
|
1308
1308
|
ipAddress?: string | null | undefined;
|
|
1309
1309
|
userAgent?: string | null | undefined;
|
|
1310
|
-
} & Record<string, unknown>, _ctx:
|
|
1310
|
+
} & Record<string, unknown>, _ctx: GenericEndpointContext | null): Promise<void>;
|
|
1311
1311
|
};
|
|
1312
1312
|
};
|
|
1313
1313
|
account: {
|
|
@@ -1326,7 +1326,7 @@ declare const dash: <O extends DashOptions>(options?: O) => {
|
|
|
1326
1326
|
refreshTokenExpiresAt?: Date | null | undefined;
|
|
1327
1327
|
scope?: string | null | undefined;
|
|
1328
1328
|
password?: string | null | undefined;
|
|
1329
|
-
}, _ctx:
|
|
1329
|
+
}, _ctx: GenericEndpointContext | null): Promise<void>;
|
|
1330
1330
|
};
|
|
1331
1331
|
update: {
|
|
1332
1332
|
after(account: {
|
|
@@ -1343,7 +1343,7 @@ declare const dash: <O extends DashOptions>(options?: O) => {
|
|
|
1343
1343
|
refreshTokenExpiresAt?: Date | null | undefined;
|
|
1344
1344
|
scope?: string | null | undefined;
|
|
1345
1345
|
password?: string | null | undefined;
|
|
1346
|
-
} & Record<string, unknown>, _ctx:
|
|
1346
|
+
} & Record<string, unknown>, _ctx: GenericEndpointContext | null): Promise<void>;
|
|
1347
1347
|
};
|
|
1348
1348
|
delete: {
|
|
1349
1349
|
after(account: {
|
|
@@ -1360,7 +1360,7 @@ declare const dash: <O extends DashOptions>(options?: O) => {
|
|
|
1360
1360
|
refreshTokenExpiresAt?: Date | null | undefined;
|
|
1361
1361
|
scope?: string | null | undefined;
|
|
1362
1362
|
password?: string | null | undefined;
|
|
1363
|
-
} & Record<string, unknown>, _ctx:
|
|
1363
|
+
} & Record<string, unknown>, _ctx: GenericEndpointContext | null): Promise<void>;
|
|
1364
1364
|
};
|
|
1365
1365
|
};
|
|
1366
1366
|
verification: {
|
|
@@ -1372,7 +1372,7 @@ declare const dash: <O extends DashOptions>(options?: O) => {
|
|
|
1372
1372
|
value: string;
|
|
1373
1373
|
expiresAt: Date;
|
|
1374
1374
|
identifier: string;
|
|
1375
|
-
} & Record<string, unknown>, _ctx:
|
|
1375
|
+
} & Record<string, unknown>, _ctx: GenericEndpointContext | null): Promise<void>;
|
|
1376
1376
|
};
|
|
1377
1377
|
delete: {
|
|
1378
1378
|
after(verification: {
|
|
@@ -1382,7 +1382,7 @@ declare const dash: <O extends DashOptions>(options?: O) => {
|
|
|
1382
1382
|
value: string;
|
|
1383
1383
|
expiresAt: Date;
|
|
1384
1384
|
identifier: string;
|
|
1385
|
-
} & Record<string, unknown>, ctx:
|
|
1385
|
+
} & Record<string, unknown>, ctx: GenericEndpointContext | null): Promise<void>;
|
|
1386
1386
|
};
|
|
1387
1387
|
};
|
|
1388
1388
|
};
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { i as INFRA_USER_AGENT, n as INFRA_API_URL, o as PLUGIN_VERSION, r as INFRA_KV_URL } from "./constants-
|
|
2
|
-
import { a as createAPI, o as createKV, r as hmacSha256Hex } from "./crypto-
|
|
1
|
+
import { i as INFRA_USER_AGENT, n as INFRA_API_URL, o as PLUGIN_VERSION, r as INFRA_KV_URL } from "./constants-CQiIiY9L.mjs";
|
|
2
|
+
import { a as createAPI, o as createKV, r as hmacSha256Hex } from "./crypto-Deqoay7H.mjs";
|
|
3
3
|
import { EMAIL_TEMPLATES, createEmailSender, sendBulkEmails, sendEmail } from "./email.mjs";
|
|
4
4
|
import { getCurrentAuthContext } from "@better-auth/core/context";
|
|
5
5
|
import { APIError, generateId, getAuthTables, logger } from "better-auth";
|
|
@@ -7585,19 +7585,12 @@ const getUserDetails = (options) => {
|
|
|
7585
7585
|
shouldUpdateLastActiveAt = true;
|
|
7586
7586
|
}
|
|
7587
7587
|
}
|
|
7588
|
-
if (shouldUpdateLastActiveAt && lastActiveAt) {
|
|
7589
|
-
|
|
7590
|
-
|
|
7591
|
-
|
|
7592
|
-
|
|
7593
|
-
|
|
7594
|
-
});
|
|
7595
|
-
} catch (error) {
|
|
7596
|
-
ctx.context.logger.error("[Dash] Failed to update user lastActiveAt:", error);
|
|
7597
|
-
}
|
|
7598
|
-
};
|
|
7599
|
-
updateActivity();
|
|
7600
|
-
}
|
|
7588
|
+
if (shouldUpdateLastActiveAt && lastActiveAt) await ctx.context.runInBackgroundOrAwait(ctx.context.internalAdapter.updateUser(userId, {
|
|
7589
|
+
lastActiveAt,
|
|
7590
|
+
updatedAt: /* @__PURE__ */ new Date()
|
|
7591
|
+
}).catch((error) => {
|
|
7592
|
+
ctx.context.logger.error("[Dash] Failed to update user lastActiveAt:", error);
|
|
7593
|
+
}));
|
|
7601
7594
|
}
|
|
7602
7595
|
const { session: _joinedSessions, ...userWithoutSessions } = user;
|
|
7603
7596
|
return {
|
|
@@ -8514,6 +8507,18 @@ const dash = (options) => {
|
|
|
8514
8507
|
};
|
|
8515
8508
|
const $kv = createKV(opts);
|
|
8516
8509
|
const activityUpdateInterval = opts.activityTracking?.updateInterval ?? 3e5;
|
|
8510
|
+
const scheduleLastActiveUpdate = async (ctx, userId) => {
|
|
8511
|
+
await ctx.context.runInBackgroundOrAwait(ctx.context.adapter.updateMany({
|
|
8512
|
+
model: "user",
|
|
8513
|
+
where: [{
|
|
8514
|
+
field: "id",
|
|
8515
|
+
value: userId
|
|
8516
|
+
}],
|
|
8517
|
+
update: { lastActiveAt: /* @__PURE__ */ new Date() }
|
|
8518
|
+
}).catch((error) => {
|
|
8519
|
+
logger.warn("[Dash] Failed to update user activity", error);
|
|
8520
|
+
}));
|
|
8521
|
+
};
|
|
8517
8522
|
const { tracker } = initTrackEvents($api);
|
|
8518
8523
|
const { trackUserSignedUp, trackUserProfileUpdated, trackUserProfileImageUpdated, trackUserEmailVerified, trackUserBanned, trackUserUnBanned, trackUserDeleted } = initUserEvents(tracker);
|
|
8519
8524
|
const { trackEmailVerificationSent, trackEmailSignInAttempt, trackUserSignedIn, trackUserSignedOut, trackSessionCreated, trackSocialSignInAttempt, trackSocialSignInRedirectionAttempt, trackUserImpersonated, trackUserImpersonationStop, trackSessionRevoked, trackSessionRevokedAll } = initSessionEvents(tracker);
|
|
@@ -8700,18 +8705,7 @@ const dash = (options) => {
|
|
|
8700
8705
|
const knownImpersonator = resolveUserFromContext(session.impersonatedBy, ctx);
|
|
8701
8706
|
trackUserImpersonated(enrichedSession, trigger, ctx, location, eventUser, knownImpersonator);
|
|
8702
8707
|
}
|
|
8703
|
-
if (opts.activityTracking?.enabled)
|
|
8704
|
-
await ctx.context.adapter.updateMany({
|
|
8705
|
-
model: "user",
|
|
8706
|
-
where: [{
|
|
8707
|
-
field: "id",
|
|
8708
|
-
value: session.userId
|
|
8709
|
-
}],
|
|
8710
|
-
update: { lastActiveAt: /* @__PURE__ */ new Date() }
|
|
8711
|
-
});
|
|
8712
|
-
} catch (error) {
|
|
8713
|
-
logger.warn("[Dash] Failed to update user activity", error);
|
|
8714
|
-
}
|
|
8708
|
+
if (opts.activityTracking?.enabled) await scheduleLastActiveUpdate(ctx, session.userId);
|
|
8715
8709
|
}
|
|
8716
8710
|
},
|
|
8717
8711
|
delete: { async after(session, _ctx) {
|
|
@@ -8852,16 +8846,7 @@ const dash = (options) => {
|
|
|
8852
8846
|
if (lastUpdate) {
|
|
8853
8847
|
if (now - new Date(lastUpdate).getTime() < activityUpdateInterval) return;
|
|
8854
8848
|
}
|
|
8855
|
-
ctx
|
|
8856
|
-
model: "user",
|
|
8857
|
-
where: [{
|
|
8858
|
-
field: "id",
|
|
8859
|
-
value: userId
|
|
8860
|
-
}],
|
|
8861
|
-
update: { lastActiveAt: /* @__PURE__ */ new Date() }
|
|
8862
|
-
}).catch((error) => {
|
|
8863
|
-
logger.warn("[Dash] Failed to update user activity", error);
|
|
8864
|
-
});
|
|
8849
|
+
await scheduleLastActiveUpdate(ctx, userId);
|
|
8865
8850
|
}),
|
|
8866
8851
|
matcher: (ctx) => ctx.request?.method !== "GET"
|
|
8867
8852
|
}]
|
package/dist/native.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { o as createKV, t as bytesToHex } from "./crypto-
|
|
2
|
-
import { a as resolveSentinelClientIdentifyUrl, c as dashClient, i as solvePoWChallenge, n as decodePoWChallenge, r as encodePoWSolution, s as identify, t as createPowRetryTimeout } from "./pow-retry-
|
|
1
|
+
import { o as createKV, t as bytesToHex } from "./crypto-Deqoay7H.mjs";
|
|
2
|
+
import { a as resolveSentinelClientIdentifyUrl, c as dashClient, i as solvePoWChallenge, n as decodePoWChallenge, r as encodePoWSolution, s as identify, t as createPowRetryTimeout } from "./pow-retry-DXiVsZkt.mjs";
|
|
3
3
|
import { env } from "@better-auth/core/env";
|
|
4
4
|
import { Dimensions, InteractionManager, PixelRatio, Platform } from "react-native";
|
|
5
5
|
//#region src/sentinel/native/components.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as randomBytes, n as hash, t as bytesToHex } from "./crypto-
|
|
1
|
+
import { i as randomBytes, n as hash, t as bytesToHex } from "./crypto-Deqoay7H.mjs";
|
|
2
2
|
//#region src/dash-client.ts
|
|
3
3
|
function resolveDashUserId(input, options) {
|
|
4
4
|
return input.userId || options?.resolveUserId?.({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@better-auth/infra",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.6",
|
|
4
4
|
"description": "Dashboard and analytics plugin for Better Auth",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.mjs",
|
|
@@ -62,13 +62,13 @@
|
|
|
62
62
|
},
|
|
63
63
|
"homepage": "https://better-auth.com",
|
|
64
64
|
"devDependencies": {
|
|
65
|
-
"@better-auth/scim": "1.7.0-rc.
|
|
66
|
-
"@better-auth/sso": "1.7.0-rc.
|
|
65
|
+
"@better-auth/scim": "1.7.0-rc.1",
|
|
66
|
+
"@better-auth/sso": "1.7.0-rc.1",
|
|
67
67
|
"@infra/mocks": "0.0.0",
|
|
68
68
|
"@infra/utils": "0.0.0",
|
|
69
69
|
"@types/bun": "latest",
|
|
70
70
|
"@types/node": "^24.12.0",
|
|
71
|
-
"better-auth": "1.7.0-rc.
|
|
71
|
+
"better-auth": "1.7.0-rc.1",
|
|
72
72
|
"expo-crypto": "^14.0.2",
|
|
73
73
|
"happy-dom": "^20.9.0",
|
|
74
74
|
"msw": "^2.14.6",
|