@better-auth/infra 0.3.6 → 0.4.0

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/native.d.mts CHANGED
@@ -1,12 +1,17 @@
1
- import { a as DashGetAuditLogsInput, i as DashGetAllAuditLogsInput, n as DashAuditLogsResponse, o as dashClient, r as DashClientOptions, t as DashAuditLog } from "./dash-client-DXuu2ctl.mjs";
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-RI-JiXQx.mjs";
2
2
  import { BetterAuthClientPlugin } from "better-auth";
3
3
 
4
4
  //#region src/sentinel/native/client.d.ts
5
5
  interface SentinelNativeClientOptions {
6
6
  identifyUrl?: string;
7
7
  /**
8
- * Timeout for KV identify and related HTTP requests (milliseconds).
8
+ * Identify HTTP client options.
9
+ */
10
+ identifyOptions?: IdentifyClientOptions;
11
+ /**
12
+ * Timeout for identify and related HTTP requests (milliseconds).
9
13
  * @default 1000
14
+ * @deprecated Use `identifyOptions.timeout` instead.
10
15
  */
11
16
  kvTimeout?: number;
12
17
  autoSolveChallenge?: boolean;
package/dist/native.mjs CHANGED
@@ -1,11 +1,11 @@
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";
1
+ import { o as createKV, t as bytesToHex } from "./crypto-CAdWFWEz.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-DZhZiYd_.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 durable-kv bot scoring.
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");
@@ -230,20 +230,10 @@ const sentinelNativeClient = (options) => {
230
230
  identifyUrl: options?.identifyUrl,
231
231
  envKvUrl: env.BETTER_AUTH_KV_URL
232
232
  }),
233
- kvTimeout: options?.kvTimeout
233
+ timeout: options?.identifyOptions?.timeout ?? options?.kvTimeout
234
234
  }, {
235
235
  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
- }
236
+ retry: resolveIdentifyClientRetry(options?.identifyOptions?.retry)
247
237
  }),
248
238
  getOrCreateVisitorId: () => getOrCreateVisitorId(options?.storage)
249
239
  });
@@ -1,4 +1,4 @@
1
- import { i as randomBytes, n as hash, t as bytesToHex } from "./crypto-Deqoay7H.mjs";
1
+ import { i as randomBytes, n as hash, t as bytesToHex } from "./crypto-CAdWFWEz.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) {
@@ -167,4 +182,4 @@ function createPowRetryTimeout(timeoutMs) {
167
182
  };
168
183
  }
169
184
  //#endregion
170
- export { resolveSentinelClientIdentifyUrl as a, dashClient as c, solvePoWChallenge as i, decodePoWChallenge as n, generateRequestId as o, encodePoWSolution as r, identify as s, createPowRetryTimeout as t };
185
+ 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-rc.4+.
4
+ * Load it at runtime so catalog typecheck against rc.1 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 };