@better-auth/core 1.4.16 → 1.4.17

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.
@@ -1,5 +1,5 @@
1
1
 
2
- > @better-auth/core@1.4.16 build /home/runner/work/better-auth/better-auth/packages/core
2
+ > @better-auth/core@1.4.17 build /home/runner/work/better-auth/better-auth/packages/core
3
3
  > tsdown
4
4
 
5
5
  ℹ tsdown v0.17.2 powered by rolldown v1.0.0-beta.53
@@ -100,7 +100,7 @@
100
100
  ℹ dist/error/index.d.mts  0.27 kB │ gzip: 0.21 kB
101
101
  ℹ dist/async_hooks/index.d.mts  0.24 kB │ gzip: 0.16 kB
102
102
  ℹ dist/async_hooks/pure.index.d.mts  0.22 kB │ gzip: 0.16 kB
103
- ℹ dist/types/init-options.d.mts 39.01 kB │ gzip: 8.77 kB
103
+ ℹ dist/types/init-options.d.mts 39.00 kB │ gzip: 8.77 kB
104
104
  ℹ dist/types/context.d.mts  9.09 kB │ gzip: 2.66 kB
105
105
  ℹ dist/social-providers/zoom.d.mts  6.71 kB │ gzip: 2.29 kB
106
106
  ℹ dist/oauth2/oauth-provider.d.mts  5.92 kB │ gzip: 1.67 kB
@@ -138,7 +138,7 @@
138
138
  ℹ dist/social-providers/kick.d.mts  1.62 kB │ gzip: 0.59 kB
139
139
  ℹ dist/social-providers/linkedin.d.mts  1.61 kB │ gzip: 0.60 kB
140
140
  ℹ dist/social-providers/linear.d.mts  1.60 kB │ gzip: 0.59 kB
141
- ℹ dist/utils/ip.d.mts  1.58 kB │ gzip: 0.69 kB
141
+ ℹ dist/utils/ip.d.mts  1.58 kB │ gzip: 0.68 kB
142
142
  ℹ dist/oauth2/validate-authorization-code.d.mts  1.57 kB │ gzip: 0.49 kB
143
143
  ℹ dist/social-providers/notion.d.mts  1.56 kB │ gzip: 0.59 kB
144
144
  ℹ dist/social-providers/reddit.d.mts  1.54 kB │ gzip: 0.57 kB
@@ -180,5 +180,5 @@
180
180
  ℹ dist/utils/json.d.mts  0.13 kB │ gzip: 0.13 kB
181
181
  ℹ dist/utils/id.d.mts  0.12 kB │ gzip: 0.12 kB
182
182
  ℹ dist/env/color-depth.d.mts  0.12 kB │ gzip: 0.11 kB
183
- ℹ 173 files, total: 448.95 kB
184
- ✔ Build complete in 6430ms
183
+ ℹ 173 files, total: 448.94 kB
184
+ ✔ Build complete in 7089ms
@@ -2,7 +2,7 @@
2
2
  const symbol = Symbol.for("better-auth:global");
3
3
  let bind = null;
4
4
  const __context = {};
5
- const __betterAuthVersion = "1.4.16";
5
+ const __betterAuthVersion = "1.4.17";
6
6
  /**
7
7
  * We store context instance in the globalThis.
8
8
  *
@@ -138,7 +138,7 @@ type BetterAuthAdvancedOptions = {
138
138
  * Note: This only affects IPv6 addresses. IPv4 addresses are always
139
139
  * rate limited individually.
140
140
  *
141
- * @default 128 (individual address)
141
+ * @default 64 (/64 subnet)
142
142
  */
143
143
  ipv6Subnet?: 128 | 64 | 48 | 32 | undefined;
144
144
  } | undefined;
@@ -30,7 +30,7 @@ declare function isValidIP(ip: string): boolean;
30
30
  *
31
31
  * @example
32
32
  * normalizeIP("2001:DB8::1")
33
- * // -> "2001:0db8:0000:0000:0000:0000:0000:0001"
33
+ * // -> "2001:0db8:0000:0000:0000:0000:0000:0000"
34
34
  *
35
35
  * @example
36
36
  * normalizeIP("::ffff:192.0.2.1")
package/dist/utils/ip.mjs CHANGED
@@ -85,7 +85,7 @@ function normalizeIPv6(ipv6, subnetPrefix) {
85
85
  *
86
86
  * @example
87
87
  * normalizeIP("2001:DB8::1")
88
- * // -> "2001:0db8:0000:0000:0000:0000:0000:0001"
88
+ * // -> "2001:0db8:0000:0000:0000:0000:0000:0000"
89
89
  *
90
90
  * @example
91
91
  * normalizeIP("::ffff:192.0.2.1")
@@ -100,7 +100,7 @@ function normalizeIP(ip, options = {}) {
100
100
  if (!isIPv6(ip)) return ip.toLowerCase();
101
101
  const ipv4 = extractIPv4FromMapped(ip);
102
102
  if (ipv4) return ipv4.toLowerCase();
103
- return normalizeIPv6(ip, options.ipv6Subnet || 128);
103
+ return normalizeIPv6(ip, options.ipv6Subnet || 64);
104
104
  }
105
105
  /**
106
106
  * Creates a rate limit key from IP and path
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@better-auth/core",
3
- "version": "1.4.16",
3
+ "version": "1.4.17",
4
4
  "description": "The most comprehensive authentication framework for TypeScript.",
5
5
  "type": "module",
6
6
  "repository": {
@@ -122,7 +122,7 @@
122
122
  },
123
123
  "dependencies": {
124
124
  "@standard-schema/spec": "^1.0.0",
125
- "zod": "^4.1.12"
125
+ "zod": "^4.3.5"
126
126
  },
127
127
  "peerDependencies": {
128
128
  "@better-auth/utils": "0.3.0",
@@ -158,7 +158,7 @@ export type BetterAuthAdvancedOptions = {
158
158
  * Note: This only affects IPv6 addresses. IPv4 addresses are always
159
159
  * rate limited individually.
160
160
  *
161
- * @default 128 (individual address)
161
+ * @default 64 (/64 subnet)
162
162
  */
163
163
  ipv6Subnet?: 128 | 64 | 48 | 32 | undefined;
164
164
  }
@@ -34,20 +34,22 @@ describe("IP Normalization", () => {
34
34
 
35
35
  describe("IPv6 Normalization", () => {
36
36
  it("should normalize compressed IPv6 to full form", () => {
37
- expect(normalizeIP("2001:db8::1")).toBe(
37
+ expect(normalizeIP("2001:db8::1", { ipv6Subnet: 128 })).toBe(
38
38
  "2001:0db8:0000:0000:0000:0000:0000:0001",
39
39
  );
40
- expect(normalizeIP("::1")).toBe(
40
+ expect(normalizeIP("::1", { ipv6Subnet: 128 })).toBe(
41
41
  "0000:0000:0000:0000:0000:0000:0000:0001",
42
42
  );
43
- expect(normalizeIP("::")).toBe("0000:0000:0000:0000:0000:0000:0000:0000");
43
+ expect(normalizeIP("::", { ipv6Subnet: 128 })).toBe(
44
+ "0000:0000:0000:0000:0000:0000:0000:0000",
45
+ );
44
46
  });
45
47
 
46
48
  it("should normalize uppercase to lowercase", () => {
47
- expect(normalizeIP("2001:DB8::1")).toBe(
49
+ expect(normalizeIP("2001:DB8::1", { ipv6Subnet: 128 })).toBe(
48
50
  "2001:0db8:0000:0000:0000:0000:0000:0001",
49
51
  );
50
- expect(normalizeIP("2001:0DB8:ABCD:EF00::1")).toBe(
52
+ expect(normalizeIP("2001:0DB8:ABCD:EF00::1", { ipv6Subnet: 128 })).toBe(
51
53
  "2001:0db8:abcd:ef00:0000:0000:0000:0001",
52
54
  );
53
55
  });
@@ -55,16 +57,22 @@ describe("IP Normalization", () => {
55
57
  it("should handle various IPv6 formats consistently", () => {
56
58
  // All these represent the same address
57
59
  const normalized = "2001:0db8:0000:0000:0000:0000:0000:0001";
58
- expect(normalizeIP("2001:db8::1")).toBe(normalized);
59
- expect(normalizeIP("2001:0db8:0:0:0:0:0:1")).toBe(normalized);
60
- expect(normalizeIP("2001:db8:0::1")).toBe(normalized);
61
- expect(normalizeIP("2001:0db8::0:0:0:1")).toBe(normalized);
60
+ expect(normalizeIP("2001:db8::1", { ipv6Subnet: 128 })).toBe(normalized);
61
+ expect(normalizeIP("2001:0db8:0:0:0:0:0:1", { ipv6Subnet: 128 })).toBe(
62
+ normalized,
63
+ );
64
+ expect(normalizeIP("2001:db8:0::1", { ipv6Subnet: 128 })).toBe(
65
+ normalized,
66
+ );
67
+ expect(normalizeIP("2001:0db8::0:0:0:1", { ipv6Subnet: 128 })).toBe(
68
+ normalized,
69
+ );
62
70
  });
63
71
 
64
72
  it("should handle IPv6 with :: at different positions", () => {
65
- expect(normalizeIP("2001:db8:85a3::8a2e:370:7334")).toBe(
66
- "2001:0db8:85a3:0000:0000:8a2e:0370:7334",
67
- );
73
+ expect(
74
+ normalizeIP("2001:db8:85a3::8a2e:370:7334", { ipv6Subnet: 128 }),
75
+ ).toBe("2001:0db8:85a3:0000:0000:8a2e:0370:7334");
68
76
  expect(normalizeIP("::ffff:192.0.2.1")).not.toContain("::");
69
77
  });
70
78
  });
@@ -131,11 +139,11 @@ describe("IP Normalization", () => {
131
139
  expect(ip1).toBe(ip2);
132
140
  });
133
141
 
134
- it("should handle /128 (full address) by default", () => {
142
+ it("should handle /64 subnet by default", () => {
135
143
  const ip1 = normalizeIP("2001:db8::1");
136
- const ip2 = normalizeIP("2001:db8::1", { ipv6Subnet: 128 });
144
+ const ip2 = normalizeIP("2001:db8::1", { ipv6Subnet: 64 });
137
145
  expect(ip1).toBe(ip2);
138
- expect(ip1).toBe("2001:0db8:0000:0000:0000:0000:0000:0001");
146
+ expect(ip1).toBe("2001:0db8:0000:0000:0000:0000:0000:0000");
139
147
  });
140
148
 
141
149
  it("should not affect IPv4 addresses when ipv6Subnet is set", () => {
@@ -179,7 +187,9 @@ describe("IP Normalization", () => {
179
187
  "2001:db8::0:1",
180
188
  ];
181
189
 
182
- const normalized = representations.map((ip) => normalizeIP(ip));
190
+ const normalized = representations.map((ip) =>
191
+ normalizeIP(ip, { ipv6Subnet: 128 }),
192
+ );
183
193
  // All should normalize to the same value
184
194
  const uniqueValues = new Set(normalized);
185
195
  expect(uniqueValues.size).toBe(1);
@@ -223,19 +233,21 @@ describe("IP Normalization", () => {
223
233
  describe("Edge Cases", () => {
224
234
  it("should handle localhost addresses", () => {
225
235
  expect(normalizeIP("127.0.0.1")).toBe("127.0.0.1");
226
- expect(normalizeIP("::1")).toBe(
236
+ expect(normalizeIP("::1", { ipv6Subnet: 128 })).toBe(
227
237
  "0000:0000:0000:0000:0000:0000:0000:0001",
228
238
  );
229
239
  });
230
240
 
231
241
  it("should handle all-zeros address", () => {
232
242
  expect(normalizeIP("0.0.0.0")).toBe("0.0.0.0");
233
- expect(normalizeIP("::")).toBe("0000:0000:0000:0000:0000:0000:0000:0000");
243
+ expect(normalizeIP("::", { ipv6Subnet: 128 })).toBe(
244
+ "0000:0000:0000:0000:0000:0000:0000:0000",
245
+ );
234
246
  });
235
247
 
236
248
  it("should handle link-local addresses", () => {
237
249
  expect(normalizeIP("169.254.0.1")).toBe("169.254.0.1");
238
- expect(normalizeIP("fe80::1")).toBe(
250
+ expect(normalizeIP("fe80::1", { ipv6Subnet: 128 })).toBe(
239
251
  "fe80:0000:0000:0000:0000:0000:0000:0001",
240
252
  );
241
253
  });
package/src/utils/ip.ts CHANGED
@@ -160,7 +160,7 @@ function normalizeIPv6(
160
160
  *
161
161
  * @example
162
162
  * normalizeIP("2001:DB8::1")
163
- * // -> "2001:0db8:0000:0000:0000:0000:0000:0001"
163
+ * // -> "2001:0db8:0000:0000:0000:0000:0000:0000"
164
164
  *
165
165
  * @example
166
166
  * normalizeIP("::ffff:192.0.2.1")
@@ -192,7 +192,7 @@ export function normalizeIP(
192
192
  }
193
193
 
194
194
  // Normalize IPv6
195
- const subnetPrefix = options.ipv6Subnet || 128;
195
+ const subnetPrefix = options.ipv6Subnet || 64;
196
196
  return normalizeIPv6(ip, subnetPrefix);
197
197
  }
198
198