@better-auth/infra 0.2.1 → 0.2.2

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.
Files changed (2) hide show
  1. package/dist/index.mjs +21 -16
  2. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -958,8 +958,8 @@ function createIdentificationMiddleware(options) {
958
958
  return;
959
959
  }
960
960
  const ipAddress = getClientIpFromRequest(ctx.request, ipConfig?.ipAddressHeaders || null);
961
- const countryCode = getCountryCodeFromRequest(ctx.request);
962
- if (ipAddress || countryCode) {
961
+ if (ipAddress) {
962
+ const countryCode = getCountryCodeFromRequest(ctx.request);
963
963
  ctx.context.location = {
964
964
  ipAddress,
965
965
  countryCode
@@ -2746,7 +2746,7 @@ const jwtValidateMiddleware = (options) => createAuthMiddleware(async (ctx) => {
2746
2746
  });
2747
2747
  //#endregion
2748
2748
  //#region src/version.ts
2749
- const PLUGIN_VERSION = "0.2.1";
2749
+ const PLUGIN_VERSION = "0.2.2";
2750
2750
  //#endregion
2751
2751
  //#region src/routes/auth/config.ts
2752
2752
  const PLUGIN_OPTIONS_EXCLUDE_KEYS = { stripe: new Set(["stripeClient"]) };
@@ -2758,23 +2758,28 @@ function isPlainSerializable(value) {
2758
2758
  if (constructor && constructor.name !== "Object" && constructor.name !== "Array") return false;
2759
2759
  return true;
2760
2760
  }
2761
- function sanitizePluginOptions(pluginId, options, seen = /* @__PURE__ */ new WeakSet()) {
2761
+ function sanitizePluginOptions(pluginId, options, visiting = /* @__PURE__ */ new WeakSet()) {
2762
2762
  if (options === null || options === void 0) return options;
2763
2763
  if (typeof options === "function") return void 0;
2764
2764
  if (typeof options !== "object") return options;
2765
- if (seen.has(options)) return void 0;
2766
- seen.add(options);
2767
- const excludeKeys = PLUGIN_OPTIONS_EXCLUDE_KEYS[pluginId];
2768
- if (Array.isArray(options)) return options.map((item) => sanitizePluginOptions(pluginId, item, seen)).filter((item) => item !== void 0);
2769
- const result = {};
2770
- for (const [key, value] of Object.entries(options)) {
2771
- if (excludeKeys?.has(key)) continue;
2772
- if (typeof value === "function") continue;
2773
- if (value !== null && typeof value === "object" && !isPlainSerializable(value)) continue;
2774
- const sanitized = sanitizePluginOptions(pluginId, value, seen);
2775
- if (sanitized !== void 0) result[key] = sanitized;
2765
+ const obj = options;
2766
+ if (visiting.has(obj)) return void 0;
2767
+ visiting.add(obj);
2768
+ try {
2769
+ const excludeKeys = PLUGIN_OPTIONS_EXCLUDE_KEYS[pluginId];
2770
+ if (Array.isArray(options)) return options.map((item) => sanitizePluginOptions(pluginId, item, visiting)).filter((item) => item !== void 0);
2771
+ const result = {};
2772
+ for (const [key, value] of Object.entries(options)) {
2773
+ if (excludeKeys?.has(key)) continue;
2774
+ if (typeof value === "function") continue;
2775
+ if (value !== null && typeof value === "object" && !isPlainSerializable(value)) continue;
2776
+ const sanitized = sanitizePluginOptions(pluginId, value, visiting);
2777
+ if (sanitized !== void 0) result[key] = sanitized;
2778
+ }
2779
+ return result;
2780
+ } finally {
2781
+ visiting.delete(obj);
2776
2782
  }
2777
- return result;
2778
2783
  }
2779
2784
  function estimateEntropy(str) {
2780
2785
  const unique = new Set(str).size;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@better-auth/infra",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "Dashboard and analytics plugin for Better Auth",
5
5
  "type": "module",
6
6
  "main": "dist/index.mjs",