@better-auth/infra 0.4.6 → 0.4.8
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 +13 -2
- package/dist/client.d.mts +3 -16
- package/dist/client.mjs +24 -46
- package/dist/{constants-CApB_fKA.mjs → constants-C8_UJzzu.mjs} +1 -1
- package/dist/{crypto-CfK70MTZ.mjs → crypto-DRS7yhmR.mjs} +11 -8
- package/dist/email.d.mts +5 -0
- package/dist/email.mjs +4 -3
- package/dist/{identify-client-options-Cim5Fztg.d.mts → identify-client-options-DgKA4Eq8.d.mts} +1 -1
- package/dist/index.d.mts +170 -165
- package/dist/index.mjs +57 -30
- package/dist/native.d.mts +1 -1
- package/dist/native.mjs +2 -2
- package/dist/{pow-retry-DkrUdqDd.mjs → pow-retry-Di0eUKbA.mjs} +1 -1
- package/dist/{types-sP9ucYj1.d.mts → types-BkUWsMpe.d.mts} +77 -212
- package/package.json +22 -10
package/CHANGELOG.md
CHANGED
|
@@ -5,7 +5,18 @@ 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.8] - 2026-09-09
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- **`apiOptions.headers` / `kvOptions.headers`** — Extra headers on dash, sentinel, email, and SMS HTTP clients. Built-in auth headers cannot be overridden.
|
|
13
|
+
|
|
14
|
+
## [0.4.7] - 2026-09-07
|
|
15
|
+
|
|
16
|
+
### Fixed
|
|
17
|
+
|
|
18
|
+
- **Sentinel types under `exactOptionalPropertyTypes`** — `sentinel()`, `sentinelClient()`, and `sentinelNativeClient()` type-check cleanly when consumers enable TypeScript `exactOptionalPropertyTypes`.
|
|
19
|
+
- **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
20
|
|
|
10
21
|
## [0.4.6] - 2026-09-07
|
|
11
22
|
|
|
@@ -224,4 +235,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
224
235
|
[0.3.1]: https://github.com/better-auth/infrastructure/compare/infra@v0.3.0...infra@v0.3.1
|
|
225
236
|
[0.3.0]: https://github.com/better-auth/infrastructure/compare/infra@v0.2.14...infra@v0.3.0
|
|
226
237
|
[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
|
|
238
|
+
[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-DgKA4Eq8.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-DRS7yhmR.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-Di0eUKbA.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
|
}
|
|
@@ -1,26 +1,29 @@
|
|
|
1
|
-
import { i as INFRA_USER_AGENT } from "./constants-
|
|
1
|
+
import { i as INFRA_USER_AGENT } from "./constants-C8_UJzzu.mjs";
|
|
2
2
|
import { createFetch } from "@better-fetch/fetch";
|
|
3
3
|
import { sha256 } from "@noble/hashes/sha2.js";
|
|
4
4
|
//#region src/fetch.ts
|
|
5
5
|
function createAPI(options, fetchOptions) {
|
|
6
6
|
return createFetch({
|
|
7
7
|
baseURL: options.apiUrl,
|
|
8
|
+
timeout: options.apiOptions.timeout,
|
|
9
|
+
...fetchOptions,
|
|
8
10
|
headers: {
|
|
11
|
+
...options.apiOptions.headers,
|
|
9
12
|
"user-agent": INFRA_USER_AGENT,
|
|
10
13
|
"x-api-key": options.apiKey
|
|
11
|
-
}
|
|
12
|
-
timeout: options.apiOptions.timeout,
|
|
13
|
-
...fetchOptions
|
|
14
|
+
}
|
|
14
15
|
});
|
|
15
16
|
}
|
|
16
17
|
function createKV(options, fetchOptions) {
|
|
17
|
-
const headers = { "user-agent": INFRA_USER_AGENT };
|
|
18
|
-
if (options.apiKey) headers["x-api-key"] = options.apiKey;
|
|
19
18
|
return createFetch({
|
|
20
19
|
baseURL: options.kvUrl,
|
|
21
|
-
headers,
|
|
22
20
|
timeout: options.timeout ?? 1e3,
|
|
23
|
-
...fetchOptions
|
|
21
|
+
...fetchOptions,
|
|
22
|
+
headers: {
|
|
23
|
+
...options.headers,
|
|
24
|
+
"user-agent": INFRA_USER_AGENT,
|
|
25
|
+
...options.apiKey ? { "x-api-key": options.apiKey } : {}
|
|
26
|
+
}
|
|
24
27
|
});
|
|
25
28
|
}
|
|
26
29
|
//#endregion
|
package/dist/email.d.mts
CHANGED
|
@@ -155,6 +155,11 @@ interface EmailConfig {
|
|
|
155
155
|
* @default 3000
|
|
156
156
|
*/
|
|
157
157
|
timeout?: number;
|
|
158
|
+
/**
|
|
159
|
+
* Extra headers on every email API request.
|
|
160
|
+
* Cannot override built-in headers (`user-agent`, `Authorization`).
|
|
161
|
+
*/
|
|
162
|
+
headers?: Record<string, string>;
|
|
158
163
|
};
|
|
159
164
|
/**
|
|
160
165
|
* Timeout for Dash email API HTTP requests (milliseconds).
|
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-C8_UJzzu.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";
|
|
@@ -37,11 +37,12 @@ function createEmailSender(config) {
|
|
|
37
37
|
if (!apiKey) logger.warn("[Dash] No API key provided for email sending. Set BETTER_AUTH_API_KEY environment variable or pass apiKey in config.");
|
|
38
38
|
const $api = createFetch({
|
|
39
39
|
baseURL: apiUrl,
|
|
40
|
+
timeout: config?.apiOptions?.timeout ?? config?.apiTimeout ?? 3e3,
|
|
40
41
|
headers: {
|
|
42
|
+
...config?.apiOptions?.headers,
|
|
41
43
|
"user-agent": INFRA_USER_AGENT,
|
|
42
44
|
Authorization: `Bearer ${apiKey}`
|
|
43
|
-
}
|
|
44
|
-
timeout: config?.apiOptions?.timeout ?? config?.apiTimeout ?? 3e3
|
|
45
|
+
}
|
|
45
46
|
});
|
|
46
47
|
/**
|
|
47
48
|
* Send an email using a template from Better Auth Infra
|
package/dist/{identify-client-options-Cim5Fztg.d.mts → identify-client-options-DgKA4Eq8.d.mts}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { g as KvRetryOptions } from "./types-BkUWsMpe.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
|