@better-auth/infra 0.4.6 → 0.4.7
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 -2
- package/dist/client.d.mts +3 -16
- package/dist/client.mjs +24 -46
- package/dist/{constants-CApB_fKA.mjs → constants-BypXAAvQ.mjs} +1 -1
- package/dist/{crypto-CfK70MTZ.mjs → crypto-C9Iqqv8l.mjs} +1 -1
- package/dist/email.mjs +1 -1
- package/dist/{identify-client-options-Cim5Fztg.d.mts → identify-client-options-Be9mAljS.d.mts} +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +4 -4
- package/dist/native.d.mts +1 -1
- package/dist/native.mjs +2 -2
- package/dist/{pow-retry-DkrUdqDd.mjs → pow-retry-Bk5otjQT.mjs} +1 -1
- package/dist/{types-sP9ucYj1.d.mts → types-Ba7NK8JV.d.mts} +10 -16
- package/package.json +5 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,7 +5,12 @@ 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/).
|
|
7
7
|
|
|
8
|
-
## [
|
|
8
|
+
## [0.4.7] - 2026-09-07
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
|
|
12
|
+
- **Sentinel types under `exactOptionalPropertyTypes`** — `sentinel()`, `sentinelClient()`, and `sentinelNativeClient()` type-check cleanly when consumers enable TypeScript `exactOptionalPropertyTypes`.
|
|
13
|
+
- **Sentinel audio fingerprint** — `sentinelClient()` now builds the audio component with `OfflineAudioContext` (and `webkitOfflineAudioContext`) instead of a live `AudioContext` + `ScriptProcessor`. Avoids autoplay/suspended-context and output-route failures in restricted browsers while keeping the same soft confidence signal on identify.
|
|
9
14
|
|
|
10
15
|
## [0.4.6] - 2026-09-07
|
|
11
16
|
|
|
@@ -224,4 +229,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
224
229
|
[0.3.1]: https://github.com/better-auth/infrastructure/compare/infra@v0.3.0...infra@v0.3.1
|
|
225
230
|
[0.3.0]: https://github.com/better-auth/infrastructure/compare/infra@v0.2.14...infra@v0.3.0
|
|
226
231
|
[0.2.14]: https://github.com/better-auth/better-auth-infra/compare/@better-auth/infra@0.2.13...@better-auth/infra@0.2.14
|
|
227
|
-
[0.2.13]: https://github.com/better-auth/better-auth-infra/compare/@better-auth/infra@0.2.12...@better-auth/infra@0.2.13
|
|
232
|
+
[0.2.13]: https://github.com/better-auth/better-auth-infra/compare/@better-auth/infra@0.2.12...@better-auth/infra@0.2.13
|
package/dist/client.d.mts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { a as DashGetAllAuditLogsInput, i as DashClientOptions, n as DashAuditLog, o as DashGetAuditLogsInput, r as DashAuditLogsResponse, s as dashClient, t as IdentifyClientOptions } from "./identify-client-options-
|
|
1
|
+
import { a as DashGetAllAuditLogsInput, i as DashClientOptions, n as DashAuditLog, o as DashGetAuditLogsInput, r as DashAuditLogsResponse, s as dashClient, t as IdentifyClientOptions } from "./identify-client-options-Be9mAljS.mjs";
|
|
2
|
+
import { BetterFetchPlugin } from "@better-fetch/fetch";
|
|
2
3
|
//#region src/sentinel/client.d.ts
|
|
3
4
|
interface SentinelClientOptions {
|
|
4
5
|
/**
|
|
@@ -35,21 +36,7 @@ interface SentinelClientOptions {
|
|
|
35
36
|
}
|
|
36
37
|
declare const sentinelClient: (options?: SentinelClientOptions) => {
|
|
37
38
|
id: "sentinel";
|
|
38
|
-
fetchPlugins:
|
|
39
|
-
id: string;
|
|
40
|
-
name: string;
|
|
41
|
-
hooks: {
|
|
42
|
-
onRequest<T extends Record<string, any>>(context: import("@better-fetch/fetch").RequestContext<T>): Promise<import("@better-fetch/fetch").RequestContext<T>>;
|
|
43
|
-
onResponse?: undefined;
|
|
44
|
-
};
|
|
45
|
-
} | {
|
|
46
|
-
id: string;
|
|
47
|
-
name: string;
|
|
48
|
-
hooks: {
|
|
49
|
-
onResponse(context: import("@better-fetch/fetch").ResponseContext): Promise<import("@better-fetch/fetch").ResponseContext>;
|
|
50
|
-
onRequest<T extends Record<string, any>>(context: import("@better-fetch/fetch").RequestContext<T>): Promise<import("@better-fetch/fetch").RequestContext<T>>;
|
|
51
|
-
};
|
|
52
|
-
})[];
|
|
39
|
+
fetchPlugins: BetterFetchPlugin[];
|
|
53
40
|
};
|
|
54
41
|
//#endregion
|
|
55
42
|
export { type DashAuditLog, type DashAuditLogsResponse, type DashClientOptions, type DashGetAllAuditLogsInput, type DashGetAuditLogsInput, type SentinelClientOptions, dashClient, sentinelClient };
|
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 identify, i as solvePoWChallenge, l as dashClient, n as decodePoWChallenge, o as resolveIdentifyClientRetry, r as encodePoWSolution, s as generateRequestId, t as createPowRetryTimeout } from "./pow-retry-
|
|
1
|
+
import { n as hash, o as createKV } from "./crypto-C9Iqqv8l.mjs";
|
|
2
|
+
import { a as resolveSentinelClientIdentifyUrl, c as identify, i as solvePoWChallenge, l as dashClient, n as decodePoWChallenge, o as resolveIdentifyClientRetry, r as encodePoWSolution, s as generateRequestId, t as createPowRetryTimeout } from "./pow-retry-Bk5otjQT.mjs";
|
|
3
3
|
import { env } from "@better-auth/core/env";
|
|
4
4
|
//#region src/sentinel/fingerprint.ts
|
|
5
5
|
function murmurhash3(str, seed = 0) {
|
|
@@ -123,54 +123,32 @@ function getWebGLFingerprint() {
|
|
|
123
123
|
}
|
|
124
124
|
async function getAudioFingerprint() {
|
|
125
125
|
try {
|
|
126
|
-
const
|
|
127
|
-
if (!
|
|
128
|
-
const context = new
|
|
126
|
+
const OfflineAudioContextClass = window.OfflineAudioContext || window.webkitOfflineAudioContext;
|
|
127
|
+
if (!OfflineAudioContextClass) return null;
|
|
128
|
+
const context = new OfflineAudioContextClass(1, 4096, 44100);
|
|
129
129
|
const oscillator = context.createOscillator();
|
|
130
|
-
const
|
|
131
|
-
const gain = context.createGain();
|
|
132
|
-
const scriptProcessor = context.createScriptProcessor(4096, 1, 1);
|
|
133
|
-
gain.gain.value = 0;
|
|
130
|
+
const compressor = context.createDynamicsCompressor();
|
|
134
131
|
oscillator.type = "triangle";
|
|
135
132
|
oscillator.frequency.setValueAtTime(1e4, context.currentTime);
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
133
|
+
compressor.threshold.setValueAtTime(-50, context.currentTime);
|
|
134
|
+
compressor.knee.setValueAtTime(40, context.currentTime);
|
|
135
|
+
compressor.ratio.setValueAtTime(12, context.currentTime);
|
|
136
|
+
compressor.attack.setValueAtTime(0, context.currentTime);
|
|
137
|
+
compressor.release.setValueAtTime(.25, context.currentTime);
|
|
138
|
+
oscillator.connect(compressor);
|
|
139
|
+
compressor.connect(context.destination);
|
|
140
140
|
oscillator.start(0);
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
try {
|
|
153
|
-
if (context.state !== "closed") context.close();
|
|
154
|
-
} catch {}
|
|
155
|
-
};
|
|
156
|
-
return new Promise((resolve) => {
|
|
157
|
-
scriptProcessor.onaudioprocess = (e) => {
|
|
158
|
-
if (resolved) return;
|
|
159
|
-
const output = e.inputBuffer.getChannelData(0);
|
|
160
|
-
let sum = 0;
|
|
161
|
-
for (let i = 0; i < output.length; i++) {
|
|
162
|
-
const val = output[i];
|
|
163
|
-
if (val !== void 0) sum += Math.abs(val);
|
|
164
|
-
}
|
|
165
|
-
cleanup();
|
|
166
|
-
resolve(sum);
|
|
167
|
-
};
|
|
168
|
-
setTimeout(() => {
|
|
169
|
-
if (resolved) return;
|
|
170
|
-
cleanup();
|
|
171
|
-
resolve(null);
|
|
172
|
-
}, 1e3);
|
|
173
|
-
});
|
|
141
|
+
const buffer = await Promise.race([context.startRendering(), new Promise((resolve) => {
|
|
142
|
+
setTimeout(() => resolve(null), 1e3);
|
|
143
|
+
})]);
|
|
144
|
+
if (!buffer) return null;
|
|
145
|
+
const output = buffer.getChannelData(0);
|
|
146
|
+
let sum = 0;
|
|
147
|
+
for (let i = 0; i < output.length; i++) {
|
|
148
|
+
const val = output[i];
|
|
149
|
+
if (val !== void 0) sum += Math.abs(val);
|
|
150
|
+
}
|
|
151
|
+
return sum;
|
|
174
152
|
} catch {
|
|
175
153
|
return null;
|
|
176
154
|
}
|
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-BypXAAvQ.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/{identify-client-options-Cim5Fztg.d.mts → identify-client-options-Be9mAljS.d.mts}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { m as KvRetryOptions } from "./types-
|
|
1
|
+
import { m as KvRetryOptions } from "./types-Ba7NK8JV.mjs";
|
|
2
2
|
import { BetterAuthClientOptions, ClientStore } from "better-auth";
|
|
3
3
|
import { BetterFetch } from "@better-fetch/fetch";
|
|
4
4
|
//#region src/dash-client.d.ts
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as ImpossibleTravelResult, D as SecurityVerdict, E as SecurityOptions, O as StaleUserResult, S as CredentialStuffingResult, T as SecurityEventType, _ as LocationDataContext, a as DashOptionsInternal, b as sentinel, c as EndpointOptions, d as InfraPluginConnectionOptionsInternal, f as KvOptions, g as LocationData, h as KvRetryOptionsResolved, i as DashOptions, k as ThresholdConfig, l as InfraEndpointContext, m as KvRetryOptions, n as ApiOptions, o as DashOptionsResolved, p as KvOptionsResolved, r as ApiOptionsResolved, s as Endpoint, t as APIError, u as InfraPluginConnectionOptions, v as SentinelOptions, w as SecurityEvent, x as CompromisedPasswordResult, y as SentinelOptionsInternal } from "./types-
|
|
1
|
+
import { C as ImpossibleTravelResult, D as SecurityVerdict, E as SecurityOptions, O as StaleUserResult, S as CredentialStuffingResult, T as SecurityEventType, _ as LocationDataContext, a as DashOptionsInternal, b as sentinel, c as EndpointOptions, d as InfraPluginConnectionOptionsInternal, f as KvOptions, g as LocationData, h as KvRetryOptionsResolved, i as DashOptions, k as ThresholdConfig, l as InfraEndpointContext, m as KvRetryOptions, n as ApiOptions, o as DashOptionsResolved, p as KvOptionsResolved, r as ApiOptionsResolved, s as Endpoint, t as APIError, u as InfraPluginConnectionOptions, v as SentinelOptions, w as SecurityEvent, x as CompromisedPasswordResult, y as SentinelOptionsInternal } from "./types-Ba7NK8JV.mjs";
|
|
2
2
|
import { EMAIL_TEMPLATES, EmailConfig, EmailTemplateId, EmailTemplateVariables, SendBulkEmailsOptions, SendBulkEmailsResult, SendEmailOptions, SendEmailResult, createEmailSender, sendBulkEmails, sendEmail } from "./email.mjs";
|
|
3
3
|
import { Account, AuthContext, GenericEndpointContext, Session, User } from "better-auth";
|
|
4
4
|
import z from "zod";
|
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, n as hash$1, 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-BypXAAvQ.mjs";
|
|
2
|
+
import { a as createAPI, n as hash$1, o as createKV, r as hmacSha256Hex } from "./crypto-C9Iqqv8l.mjs";
|
|
3
3
|
import { EMAIL_TEMPLATES, createEmailSender, sendBulkEmails, sendEmail } from "./email.mjs";
|
|
4
4
|
import { getCurrentAdapter, getCurrentAuthContext, getCurrentDBAdapterAsyncLocalStorage, runWithTransaction } from "@better-auth/core/context";
|
|
5
5
|
import { APIError, generateId, getAuthTables, logger } from "better-auth";
|
|
@@ -2576,8 +2576,8 @@ const sentinel = (options) => {
|
|
|
2576
2576
|
customRules
|
|
2577
2577
|
} },
|
|
2578
2578
|
options: {
|
|
2579
|
-
emailValidation: opts.security
|
|
2580
|
-
emailNormalization: opts.security
|
|
2579
|
+
...opts.security?.emailValidation !== void 0 ? { emailValidation: opts.security.emailValidation } : {},
|
|
2580
|
+
...opts.security?.emailNormalization !== void 0 ? { emailNormalization: opts.security.emailNormalization } : {},
|
|
2581
2581
|
rateLimit: { customRules },
|
|
2582
2582
|
databaseHooks: {
|
|
2583
2583
|
user: {
|
package/dist/native.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as DashGetAllAuditLogsInput, i as DashClientOptions, n as DashAuditLog, o as DashGetAuditLogsInput, r as DashAuditLogsResponse, s as dashClient, t as IdentifyClientOptions } from "./identify-client-options-
|
|
1
|
+
import { a as DashGetAllAuditLogsInput, i as DashClientOptions, n as DashAuditLog, o as DashGetAuditLogsInput, r as DashAuditLogsResponse, s as dashClient, t as IdentifyClientOptions } from "./identify-client-options-Be9mAljS.mjs";
|
|
2
2
|
import { BetterAuthClientPlugin } from "better-auth";
|
|
3
3
|
//#region src/sentinel/native/client.d.ts
|
|
4
4
|
interface SentinelNativeClientOptions {
|
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 identify, i as solvePoWChallenge, l as dashClient, n as decodePoWChallenge, o as resolveIdentifyClientRetry, r as encodePoWSolution, t as createPowRetryTimeout } from "./pow-retry-
|
|
1
|
+
import { o as createKV, t as bytesToHex } from "./crypto-C9Iqqv8l.mjs";
|
|
2
|
+
import { a as resolveSentinelClientIdentifyUrl, c as identify, i as solvePoWChallenge, l as dashClient, n as decodePoWChallenge, o as resolveIdentifyClientRetry, r as encodePoWSolution, t as createPowRetryTimeout } from "./pow-retry-Bk5otjQT.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-C9Iqqv8l.mjs";
|
|
2
2
|
//#region src/dash-client.ts
|
|
3
3
|
function resolveDashUserId(input, options) {
|
|
4
4
|
return input.userId || options?.resolveUserId?.({
|
|
@@ -170,28 +170,13 @@ declare const sentinel: (options?: SentinelOptions) => {
|
|
|
170
170
|
init(ctx: import("better-auth").AuthContext): {
|
|
171
171
|
context: {
|
|
172
172
|
rateLimit: {
|
|
173
|
-
customRules: {
|
|
174
|
-
[key: string]: false | BetterAuthRateLimitRule | ((request: Request, currentRule: BetterAuthRateLimitRule) => import("@better-auth/core").Awaitable<false | BetterAuthRateLimitRule>);
|
|
175
|
-
};
|
|
176
173
|
enabled: boolean;
|
|
177
174
|
window: number;
|
|
178
175
|
max: number;
|
|
179
176
|
storage: "memory" | "database" | "secondary-storage";
|
|
180
|
-
|
|
181
|
-
fields?: Partial<Record<"key" | "count" | "lastRequest", string>> | undefined;
|
|
182
|
-
customStorage?: import("better-auth").BetterAuthRateLimitStorage | undefined;
|
|
183
|
-
};
|
|
177
|
+
} & Omit<import("better-auth").BetterAuthRateLimitOptions, "window" | "enabled" | "max" | "storage">;
|
|
184
178
|
};
|
|
185
179
|
options: {
|
|
186
|
-
emailValidation: {
|
|
187
|
-
enabled?: boolean;
|
|
188
|
-
strictness?: "low" | "medium" | "high";
|
|
189
|
-
action?: SecurityAction;
|
|
190
|
-
domainAllowlist?: string[];
|
|
191
|
-
} | undefined;
|
|
192
|
-
emailNormalization: {
|
|
193
|
-
enabled?: boolean;
|
|
194
|
-
} | undefined;
|
|
195
180
|
rateLimit: {
|
|
196
181
|
customRules: {
|
|
197
182
|
[key: string]: false | BetterAuthRateLimitRule | ((request: Request, currentRule: BetterAuthRateLimitRule) => import("@better-auth/core").Awaitable<false | BetterAuthRateLimitRule>);
|
|
@@ -276,6 +261,15 @@ declare const sentinel: (options?: SentinelOptions) => {
|
|
|
276
261
|
};
|
|
277
262
|
};
|
|
278
263
|
};
|
|
264
|
+
emailNormalization?: {
|
|
265
|
+
enabled?: boolean;
|
|
266
|
+
} | undefined;
|
|
267
|
+
emailValidation?: {
|
|
268
|
+
enabled?: boolean;
|
|
269
|
+
strictness?: "low" | "medium" | "high";
|
|
270
|
+
action?: SecurityAction;
|
|
271
|
+
domainAllowlist?: string[];
|
|
272
|
+
} | undefined;
|
|
279
273
|
};
|
|
280
274
|
};
|
|
281
275
|
hooks: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@better-auth/infra",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.7",
|
|
4
4
|
"description": "Dashboard and analytics plugin for Better Auth",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.mjs",
|
|
@@ -17,21 +17,25 @@
|
|
|
17
17
|
},
|
|
18
18
|
"exports": {
|
|
19
19
|
".": {
|
|
20
|
+
"@infra/source": "./src/index.ts",
|
|
20
21
|
"types": "./dist/index.d.mts",
|
|
21
22
|
"import": "./dist/index.mjs",
|
|
22
23
|
"default": "./dist/index.mjs"
|
|
23
24
|
},
|
|
24
25
|
"./client": {
|
|
26
|
+
"@infra/source": "./src/client.ts",
|
|
25
27
|
"types": "./dist/client.d.mts",
|
|
26
28
|
"import": "./dist/client.mjs",
|
|
27
29
|
"default": "./dist/client.mjs"
|
|
28
30
|
},
|
|
29
31
|
"./email": {
|
|
32
|
+
"@infra/source": "./src/email.ts",
|
|
30
33
|
"types": "./dist/email.d.mts",
|
|
31
34
|
"import": "./dist/email.mjs",
|
|
32
35
|
"default": "./dist/email.mjs"
|
|
33
36
|
},
|
|
34
37
|
"./native": {
|
|
38
|
+
"@infra/source": "./src/native.ts",
|
|
35
39
|
"types": "./dist/native.d.mts",
|
|
36
40
|
"import": "./dist/native.mjs",
|
|
37
41
|
"default": "./dist/native.mjs"
|