@better-auth/infra 0.3.7 → 0.4.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/CHANGELOG.md +31 -0
- package/README.md +16 -1
- package/dist/client.d.mts +7 -3
- package/dist/client.mjs +11 -19
- package/dist/{constants-AfApXLhx.mjs → constants-CtvGRrlI.mjs} +1 -1
- package/dist/{crypto--3ycICW4.mjs → crypto-CV91nSbp.mjs} +23 -8
- package/dist/email.d.mts +11 -0
- package/dist/email.mjs +2 -2
- package/dist/{dash-client-DXuu2ctl.d.mts → identify-client-options-CgijjwVT.d.mts} +16 -2
- package/dist/index.d.mts +258 -571
- package/dist/index.mjs +2583 -709
- package/dist/native.d.mts +7 -3
- package/dist/native.mjs +10 -19
- package/dist/{pow-retry-Dy1D-TKx.mjs → pow-retry-7sPi32Ow.mjs} +19 -3
- package/dist/saml-policy-DQR0MBLk.mjs +12 -0
- package/dist/types-Ddk4r5x9.d.mts +672 -0
- package/package.json +7 -5
package/dist/native.d.mts
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
|
-
import { a as
|
|
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-CgijjwVT.mjs";
|
|
2
2
|
import { BetterAuthClientPlugin } from "better-auth";
|
|
3
|
-
|
|
4
3
|
//#region src/sentinel/native/client.d.ts
|
|
5
4
|
interface SentinelNativeClientOptions {
|
|
6
5
|
identifyUrl?: string;
|
|
7
6
|
/**
|
|
8
|
-
*
|
|
7
|
+
* Identify HTTP client options.
|
|
8
|
+
*/
|
|
9
|
+
identifyOptions?: IdentifyClientOptions;
|
|
10
|
+
/**
|
|
11
|
+
* Timeout for identify and related HTTP requests (milliseconds).
|
|
9
12
|
* @default 1000
|
|
13
|
+
* @deprecated Use `identifyOptions.timeout` instead.
|
|
10
14
|
*/
|
|
11
15
|
kvTimeout?: number;
|
|
12
16
|
autoSolveChallenge?: boolean;
|
package/dist/native.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { o as createKV, t as bytesToHex } from "./crypto
|
|
2
|
-
import { a as resolveSentinelClientIdentifyUrl, c as
|
|
1
|
+
import { o as createKV, t as bytesToHex } from "./crypto-CV91nSbp.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-7sPi32Ow.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
|
|
6
6
|
/**
|
|
7
7
|
* Default first-party component payload for React Native / Expo.
|
|
8
|
-
* Avoids browser-style entropy; sets `clientRuntime` for
|
|
8
|
+
* Avoids browser-style entropy; sets `clientRuntime` for identify bot scoring.
|
|
9
9
|
*/
|
|
10
10
|
async function defaultCollectNativeComponents() {
|
|
11
11
|
const windowDims = Dimensions.get("window");
|
|
@@ -224,26 +224,17 @@ function scheduleIdentify(send) {
|
|
|
224
224
|
}
|
|
225
225
|
const sentinelNativeClient = (options) => {
|
|
226
226
|
const autoSolve = options?.autoSolveChallenge !== false;
|
|
227
|
+
const identifyUrl = resolveSentinelClientIdentifyUrl({
|
|
228
|
+
identifyUrl: options?.identifyUrl,
|
|
229
|
+
envKvUrl: env.BETTER_AUTH_KV_URL
|
|
230
|
+
});
|
|
227
231
|
const runtime = createNativeFingerprintRuntime({
|
|
228
232
|
$kv: createKV({
|
|
229
|
-
kvUrl:
|
|
230
|
-
|
|
231
|
-
envKvUrl: env.BETTER_AUTH_KV_URL
|
|
232
|
-
}),
|
|
233
|
-
kvTimeout: options?.kvTimeout
|
|
233
|
+
kvUrl: identifyUrl,
|
|
234
|
+
timeout: options?.identifyOptions?.timeout ?? options?.kvTimeout
|
|
234
235
|
}, {
|
|
235
236
|
throw: true,
|
|
236
|
-
retry:
|
|
237
|
-
type: "exponential",
|
|
238
|
-
attempts: 2,
|
|
239
|
-
baseDelay: 400,
|
|
240
|
-
maxDelay: 600,
|
|
241
|
-
shouldRetry(response) {
|
|
242
|
-
if (response === null) return true;
|
|
243
|
-
if (response.status === 429) return true;
|
|
244
|
-
return response.status >= 500;
|
|
245
|
-
}
|
|
246
|
-
}
|
|
237
|
+
retry: resolveIdentifyClientRetry(options?.identifyOptions?.retry)
|
|
247
238
|
}),
|
|
248
239
|
getOrCreateVisitorId: () => getOrCreateVisitorId(options?.storage)
|
|
249
240
|
});
|
|
@@ -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-CV91nSbp.mjs";
|
|
2
2
|
//#region src/dash-client.ts
|
|
3
3
|
function resolveDashUserId(input, options) {
|
|
4
4
|
return input.userId || options?.resolveUserId?.({
|
|
@@ -58,6 +58,21 @@ async function identify($kv, payload) {
|
|
|
58
58
|
});
|
|
59
59
|
}
|
|
60
60
|
//#endregion
|
|
61
|
+
//#region src/sentinel/identify-client-options.ts
|
|
62
|
+
function resolveIdentifyClientRetry(retry) {
|
|
63
|
+
return {
|
|
64
|
+
type: "exponential",
|
|
65
|
+
attempts: retry?.attempts ?? 2,
|
|
66
|
+
baseDelay: retry?.baseDelay ?? 400,
|
|
67
|
+
maxDelay: retry?.maxDelay ?? 600,
|
|
68
|
+
shouldRetry(response) {
|
|
69
|
+
if (response === null) return true;
|
|
70
|
+
if (response.status === 429) return true;
|
|
71
|
+
return response.status >= 500;
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
//#endregion
|
|
61
76
|
//#region src/sentinel/identify-url.ts
|
|
62
77
|
const DEFAULT_IDENTIFY_URL = "https://kv.better-auth.com";
|
|
63
78
|
function normalizeIdentifyUrl(url) {
|
|
@@ -105,7 +120,8 @@ async function solvePoWChallenge(challenge) {
|
|
|
105
120
|
const { nonce, difficulty } = challenge;
|
|
106
121
|
let counter = 0;
|
|
107
122
|
while (true) {
|
|
108
|
-
|
|
123
|
+
const input = `${nonce}:${counter}`;
|
|
124
|
+
if (hasLeadingZeroBits(await hash(input), difficulty)) return {
|
|
109
125
|
nonce,
|
|
110
126
|
counter
|
|
111
127
|
};
|
|
@@ -167,4 +183,4 @@ function createPowRetryTimeout(timeoutMs) {
|
|
|
167
183
|
};
|
|
168
184
|
}
|
|
169
185
|
//#endregion
|
|
170
|
-
export { resolveSentinelClientIdentifyUrl as a,
|
|
186
|
+
export { resolveSentinelClientIdentifyUrl as a, identify as c, solvePoWChallenge as i, dashClient as l, decodePoWChallenge as n, resolveIdentifyClientRetry as o, encodePoWSolution as r, generateRequestId as s, createPowRetryTimeout as t };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//#region src/directory-sync/saml-policy.ts
|
|
2
|
+
/**
|
|
3
|
+
* `deriveSAMLServiceProviderPolicy` ships in `@better-auth/sso` 1.7.0+.
|
|
4
|
+
* Load it at runtime so typecheck against older matrix versions still succeeds.
|
|
5
|
+
*/
|
|
6
|
+
async function requiresSignedSAMLAssertions(config) {
|
|
7
|
+
const sso = await import("@better-auth/sso");
|
|
8
|
+
if (typeof sso.deriveSAMLServiceProviderPolicy === "function") return sso.deriveSAMLServiceProviderPolicy(config).wantAssertionsSigned;
|
|
9
|
+
return config.wantAssertionsSigned === true;
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { requiresSignedSAMLAssertions };
|