better-auth-studio 1.0.79-beta.1 → 1.0.79-beta.11

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 (74) hide show
  1. package/README.md +86 -0
  2. package/dist/adapters/express.d.ts +7 -0
  3. package/dist/adapters/express.d.ts.map +1 -0
  4. package/dist/adapters/express.js +40 -0
  5. package/dist/adapters/express.js.map +1 -0
  6. package/dist/adapters/nextjs.d.ts +3 -0
  7. package/dist/adapters/nextjs.d.ts.map +1 -0
  8. package/dist/adapters/nextjs.js +54 -0
  9. package/dist/adapters/nextjs.js.map +1 -0
  10. package/dist/auth-adapter.d.ts.map +1 -1
  11. package/dist/auth-adapter.js +3 -2
  12. package/dist/auth-adapter.js.map +1 -1
  13. package/dist/cli/commands/init.d.ts +2 -0
  14. package/dist/cli/commands/init.d.ts.map +1 -0
  15. package/dist/cli/commands/init.js +140 -0
  16. package/dist/cli/commands/init.js.map +1 -0
  17. package/dist/cli.js +13 -0
  18. package/dist/cli.js.map +1 -1
  19. package/dist/config.d.ts.map +1 -1
  20. package/dist/config.js +3 -0
  21. package/dist/config.js.map +1 -1
  22. package/dist/core/handler.d.ts +7 -0
  23. package/dist/core/handler.d.ts.map +1 -0
  24. package/dist/core/handler.js +384 -0
  25. package/dist/core/handler.js.map +1 -0
  26. package/dist/index.d.ts +4 -0
  27. package/dist/index.d.ts.map +1 -0
  28. package/dist/index.js +3 -0
  29. package/dist/index.js.map +1 -0
  30. package/dist/public/assets/main-3NIBCudD.js +1155 -0
  31. package/dist/public/assets/main-DbXDm13A.css +1 -0
  32. package/dist/public/favicon.svg +6 -0
  33. package/dist/public/index.html +14 -0
  34. package/dist/public/logo.png +0 -0
  35. package/dist/public/vite.svg +5 -0
  36. package/dist/routes/api-router.d.ts +21 -0
  37. package/dist/routes/api-router.d.ts.map +1 -0
  38. package/dist/routes/api-router.js +14 -0
  39. package/dist/routes/api-router.js.map +1 -0
  40. package/dist/routes.d.ts +20 -1
  41. package/dist/routes.d.ts.map +1 -1
  42. package/dist/routes.js +681 -178
  43. package/dist/routes.js.map +1 -1
  44. package/dist/studio.d.ts.map +1 -1
  45. package/dist/studio.js +28 -2
  46. package/dist/studio.js.map +1 -1
  47. package/dist/types/handler.d.ts +58 -0
  48. package/dist/types/handler.d.ts.map +1 -0
  49. package/dist/types/handler.js +4 -0
  50. package/dist/types/handler.js.map +1 -0
  51. package/dist/utils/html-injector.d.ts +30 -0
  52. package/dist/utils/html-injector.d.ts.map +1 -0
  53. package/dist/utils/html-injector.js +61 -0
  54. package/dist/utils/html-injector.js.map +1 -0
  55. package/dist/utils/paths.d.ts +2 -0
  56. package/dist/utils/paths.d.ts.map +1 -0
  57. package/dist/utils/paths.js +12 -0
  58. package/dist/utils/paths.js.map +1 -0
  59. package/dist/utils/session.d.ts +21 -0
  60. package/dist/utils/session.d.ts.map +1 -0
  61. package/dist/utils/session.js +51 -0
  62. package/dist/utils/session.js.map +1 -0
  63. package/package.json +14 -5
  64. package/public/assets/main-3NIBCudD.js +1155 -0
  65. package/public/assets/main-DbXDm13A.css +1 -0
  66. package/public/favicon.svg +6 -0
  67. package/public/index.html +3 -3
  68. package/public/logo.png +0 -0
  69. package/public/vite.svg +5 -0
  70. package/scripts/download-geolite2.js +35 -0
  71. package/scripts/generate-default-db.js +462 -0
  72. package/scripts/postinstall.js +98 -0
  73. package/public/assets/main-Du6zwcd_.css +0 -1
  74. package/public/assets/main-S8anH3U1.js +0 -1145
@@ -0,0 +1,462 @@
1
+ #!/usr/bin/env node
2
+
3
+ const fs = require('node:fs');
4
+ const path = require('node:path');
5
+
6
+ // Comprehensive IP ranges covering most of the internet
7
+ const IP_RANGES = [
8
+ // North America
9
+ {
10
+ country: 'United States',
11
+ countryCode: 'US',
12
+ city: 'New York',
13
+ region: 'New York',
14
+ ranges: [
15
+ { min: '8.0.0.0', max: '8.255.255.255' },
16
+ { min: '24.0.0.0', max: '24.255.255.255' },
17
+ { min: '32.0.0.0', max: '32.255.255.255' },
18
+ { min: '40.0.0.0', max: '40.255.255.255' },
19
+ { min: '50.0.0.0', max: '50.255.255.255' },
20
+ { min: '64.0.0.0', max: '64.255.255.255' },
21
+ { min: '66.0.0.0', max: '66.255.255.255' },
22
+ { min: '68.0.0.0', max: '68.255.255.255' },
23
+ { min: '70.0.0.0', max: '70.255.255.255' },
24
+ { min: '72.0.0.0', max: '72.255.255.255' },
25
+ { min: '74.0.0.0', max: '74.255.255.255' },
26
+ { min: '76.0.0.0', max: '76.255.255.255' },
27
+ { min: '98.0.0.0', max: '98.255.255.255' },
28
+ { min: '104.0.0.0', max: '104.255.255.255' },
29
+ { min: '108.0.0.0', max: '108.255.255.255' },
30
+ { min: '173.0.0.0', max: '173.255.255.255' },
31
+ { min: '174.0.0.0', max: '174.255.255.255' },
32
+ { min: '184.0.0.0', max: '184.255.255.255' },
33
+ { min: '192.0.0.0', max: '192.255.255.255' },
34
+ { min: '198.0.0.0', max: '198.255.255.255' },
35
+ { min: '204.0.0.0', max: '204.255.255.255' },
36
+ { min: '208.0.0.0', max: '208.255.255.255' },
37
+ ],
38
+ },
39
+ {
40
+ country: 'Canada',
41
+ countryCode: 'CA',
42
+ city: 'Toronto',
43
+ region: 'Ontario',
44
+ ranges: [
45
+ { min: '24.0.0.0', max: '24.255.255.255' },
46
+ { min: '70.0.0.0', max: '70.255.255.255' },
47
+ { min: '142.0.0.0', max: '142.255.255.255' },
48
+ { min: '162.0.0.0', max: '162.255.255.255' },
49
+ { min: '174.0.0.0', max: '174.255.255.255' },
50
+ { min: '184.0.0.0', max: '184.255.255.255' },
51
+ { min: '199.0.0.0', max: '199.255.255.255' },
52
+ { min: '205.0.0.0', max: '205.255.255.255' },
53
+ ],
54
+ },
55
+
56
+ // Europe
57
+ {
58
+ country: 'United Kingdom',
59
+ countryCode: 'GB',
60
+ city: 'London',
61
+ region: 'England',
62
+ ranges: [
63
+ { min: '2.0.0.0', max: '2.255.255.255' },
64
+ { min: '5.0.0.0', max: '5.255.255.255' },
65
+ { min: '25.0.0.0', max: '25.255.255.255' },
66
+ { min: '31.0.0.0', max: '31.255.255.255' },
67
+ { min: '46.0.0.0', max: '46.255.255.255' },
68
+ { min: '51.0.0.0', max: '51.255.255.255' },
69
+ { min: '77.0.0.0', max: '77.255.255.255' },
70
+ { min: '80.0.0.0', max: '80.255.255.255' },
71
+ { min: '81.0.0.0', max: '81.255.255.255' },
72
+ { min: '82.0.0.0', max: '82.255.255.255' },
73
+ { min: '86.0.0.0', max: '86.255.255.255' },
74
+ { min: '87.0.0.0', max: '87.255.255.255' },
75
+ { min: '88.0.0.0', max: '88.255.255.255' },
76
+ { min: '89.0.0.0', max: '89.255.255.255' },
77
+ { min: '90.0.0.0', max: '90.255.255.255' },
78
+ { min: '91.0.0.0', max: '91.255.255.255' },
79
+ { min: '92.0.0.0', max: '92.255.255.255' },
80
+ { min: '93.0.0.0', max: '93.255.255.255' },
81
+ { min: '94.0.0.0', max: '94.255.255.255' },
82
+ { min: '95.0.0.0', max: '95.255.255.255' },
83
+ ],
84
+ },
85
+ {
86
+ country: 'Germany',
87
+ countryCode: 'DE',
88
+ city: 'Berlin',
89
+ region: 'Berlin',
90
+ ranges: [
91
+ { min: '46.0.0.0', max: '46.255.255.255' },
92
+ { min: '62.0.0.0', max: '62.255.255.255' },
93
+ { min: '78.0.0.0', max: '78.255.255.255' },
94
+ { min: '80.0.0.0', max: '80.255.255.255' },
95
+ { min: '85.0.0.0', max: '85.255.255.255' },
96
+ { min: '88.0.0.0', max: '88.255.255.255' },
97
+ { min: '91.0.0.0', max: '91.255.255.255' },
98
+ { min: '134.0.0.0', max: '134.255.255.255' },
99
+ { min: '136.0.0.0', max: '136.255.255.255' },
100
+ { min: '141.0.0.0', max: '141.255.255.255' },
101
+ { min: '145.0.0.0', max: '145.255.255.255' },
102
+ { min: '149.0.0.0', max: '149.255.255.255' },
103
+ { min: '178.0.0.0', max: '178.255.255.255' },
104
+ { min: '188.0.0.0', max: '188.255.255.255' },
105
+ { min: '195.0.0.0', max: '195.255.255.255' },
106
+ { min: '212.0.0.0', max: '212.255.255.255' },
107
+ { min: '217.0.0.0', max: '217.255.255.255' },
108
+ ],
109
+ },
110
+ {
111
+ country: 'France',
112
+ countryCode: 'FR',
113
+ city: 'Paris',
114
+ region: 'Île-de-France',
115
+ ranges: [
116
+ { min: '37.0.0.0', max: '37.255.255.255' },
117
+ { min: '62.0.0.0', max: '62.255.255.255' },
118
+ { min: '78.0.0.0', max: '78.255.255.255' },
119
+ { min: '80.0.0.0', max: '80.255.255.255' },
120
+ { min: '81.0.0.0', max: '81.255.255.255' },
121
+ { min: '82.0.0.0', max: '82.255.255.255' },
122
+ { min: '83.0.0.0', max: '83.255.255.255' },
123
+ { min: '84.0.0.0', max: '84.255.255.255' },
124
+ { min: '85.0.0.0', max: '85.255.255.255' },
125
+ { min: '86.0.0.0', max: '86.255.255.255' },
126
+ { min: '87.0.0.0', max: '87.255.255.255' },
127
+ { min: '88.0.0.0', max: '88.255.255.255' },
128
+ { min: '89.0.0.0', max: '89.255.255.255' },
129
+ { min: '90.0.0.0', max: '90.255.255.255' },
130
+ { min: '91.0.0.0', max: '91.255.255.255' },
131
+ { min: '92.0.0.0', max: '92.255.255.255' },
132
+ { min: '93.0.0.0', max: '93.255.255.255' },
133
+ { min: '94.0.0.0', max: '94.255.255.255' },
134
+ { min: '95.0.0.0', max: '95.255.255.255' },
135
+ { min: '109.0.0.0', max: '109.255.255.255' },
136
+ { min: '134.0.0.0', max: '134.255.255.255' },
137
+ { min: '136.0.0.0', max: '136.255.255.255' },
138
+ { min: '141.0.0.0', max: '141.255.255.255' },
139
+ { min: '145.0.0.0', max: '145.255.255.255' },
140
+ { min: '149.0.0.0', max: '149.255.255.255' },
141
+ { min: '178.0.0.0', max: '178.255.255.255' },
142
+ { min: '188.0.0.0', max: '188.255.255.255' },
143
+ { min: '195.0.0.0', max: '195.255.255.255' },
144
+ { min: '212.0.0.0', max: '212.255.255.255' },
145
+ { min: '217.0.0.0', max: '217.255.255.255' },
146
+ ],
147
+ },
148
+
149
+ // Asia
150
+ {
151
+ country: 'Japan',
152
+ countryCode: 'JP',
153
+ city: 'Tokyo',
154
+ region: 'Tokyo',
155
+ ranges: [
156
+ { min: '126.0.0.0', max: '126.255.255.255' },
157
+ { min: '210.0.0.0', max: '210.255.255.255' },
158
+ { min: '218.0.0.0', max: '218.255.255.255' },
159
+ { min: '219.0.0.0', max: '219.255.255.255' },
160
+ { min: '220.0.0.0', max: '220.255.255.255' },
161
+ { min: '221.0.0.0', max: '221.255.255.255' },
162
+ { min: '222.0.0.0', max: '222.255.255.255' },
163
+ { min: '223.0.0.0', max: '223.255.255.255' },
164
+ ],
165
+ },
166
+ {
167
+ country: 'China',
168
+ countryCode: 'CN',
169
+ city: 'Beijing',
170
+ region: 'Beijing',
171
+ ranges: [
172
+ { min: '1.0.0.0', max: '1.255.255.255' },
173
+ { min: '14.0.0.0', max: '14.255.255.255' },
174
+ { min: '27.0.0.0', max: '27.255.255.255' },
175
+ { min: '36.0.0.0', max: '36.255.255.255' },
176
+ { min: '39.0.0.0', max: '39.255.255.255' },
177
+ { min: '42.0.0.0', max: '42.255.255.255' },
178
+ { min: '49.0.0.0', max: '49.255.255.255' },
179
+ { min: '58.0.0.0', max: '58.255.255.255' },
180
+ { min: '59.0.0.0', max: '59.255.255.255' },
181
+ { min: '60.0.0.0', max: '60.255.255.255' },
182
+ { min: '61.0.0.0', max: '61.255.255.255' },
183
+ { min: '101.0.0.0', max: '101.255.255.255' },
184
+ { min: '103.0.0.0', max: '103.255.255.255' },
185
+ { min: '106.0.0.0', max: '106.255.255.255' },
186
+ { min: '110.0.0.0', max: '110.255.255.255' },
187
+ { min: '111.0.0.0', max: '111.255.255.255' },
188
+ { min: '112.0.0.0', max: '112.255.255.255' },
189
+ { min: '113.0.0.0', max: '113.255.255.255' },
190
+ { min: '114.0.0.0', max: '114.255.255.255' },
191
+ { min: '115.0.0.0', max: '115.255.255.255' },
192
+ { min: '116.0.0.0', max: '116.255.255.255' },
193
+ { min: '117.0.0.0', max: '117.255.255.255' },
194
+ { min: '118.0.0.0', max: '118.255.255.255' },
195
+ { min: '119.0.0.0', max: '119.255.255.255' },
196
+ { min: '120.0.0.0', max: '120.255.255.255' },
197
+ { min: '121.0.0.0', max: '121.255.255.255' },
198
+ { min: '122.0.0.0', max: '122.255.255.255' },
199
+ { min: '123.0.0.0', max: '123.255.255.255' },
200
+ { min: '124.0.0.0', max: '124.255.255.255' },
201
+ { min: '125.0.0.0', max: '125.255.255.255' },
202
+ { min: '171.0.0.0', max: '171.255.255.255' },
203
+ { min: '175.0.0.0', max: '175.255.255.255' },
204
+ { min: '180.0.0.0', max: '180.255.255.255' },
205
+ { min: '182.0.0.0', max: '182.255.255.255' },
206
+ { min: '183.0.0.0', max: '183.255.255.255' },
207
+ { min: '202.0.0.0', max: '202.255.255.255' },
208
+ { min: '203.0.0.0', max: '203.255.255.255' },
209
+ { min: '210.0.0.0', max: '210.255.255.255' },
210
+ { min: '211.0.0.0', max: '211.255.255.255' },
211
+ { min: '218.0.0.0', max: '218.255.255.255' },
212
+ { min: '219.0.0.0', max: '219.255.255.255' },
213
+ { min: '220.0.0.0', max: '220.255.255.255' },
214
+ { min: '221.0.0.0', max: '221.255.255.255' },
215
+ { min: '222.0.0.0', max: '222.255.255.255' },
216
+ { min: '223.0.0.0', max: '223.255.255.255' },
217
+ ],
218
+ },
219
+ {
220
+ country: 'India',
221
+ countryCode: 'IN',
222
+ city: 'Mumbai',
223
+ region: 'Maharashtra',
224
+ ranges: [
225
+ { min: '103.0.0.0', max: '103.255.255.255' },
226
+ { min: '117.0.0.0', max: '117.255.255.255' },
227
+ { min: '122.0.0.0', max: '122.255.255.255' },
228
+ { min: '180.0.0.0', max: '180.255.255.255' },
229
+ { min: '182.0.0.0', max: '182.255.255.255' },
230
+ { min: '183.0.0.0', max: '183.255.255.255' },
231
+ { min: '202.0.0.0', max: '202.255.255.255' },
232
+ { min: '203.0.0.0', max: '203.255.255.255' },
233
+ { min: '210.0.0.0', max: '210.255.255.255' },
234
+ { min: '211.0.0.0', max: '211.255.255.255' },
235
+ { min: '218.0.0.0', max: '218.255.255.255' },
236
+ { min: '219.0.0.0', max: '219.255.255.255' },
237
+ { min: '220.0.0.0', max: '220.255.255.255' },
238
+ { min: '221.0.0.0', max: '221.255.255.255' },
239
+ { min: '222.0.0.0', max: '222.255.255.255' },
240
+ { min: '223.0.0.0', max: '223.255.255.255' },
241
+ ],
242
+ },
243
+
244
+ // Oceania
245
+ {
246
+ country: 'Australia',
247
+ countryCode: 'AU',
248
+ city: 'Sydney',
249
+ region: 'New South Wales',
250
+ ranges: [
251
+ { min: '1.0.0.0', max: '1.255.255.255' },
252
+ { min: '14.0.0.0', max: '14.255.255.255' },
253
+ { min: '27.0.0.0', max: '27.255.255.255' },
254
+ { min: '36.0.0.0', max: '36.255.255.255' },
255
+ { min: '39.0.0.0', max: '39.255.255.255' },
256
+ { min: '42.0.0.0', max: '42.255.255.255' },
257
+ { min: '49.0.0.0', max: '49.255.255.255' },
258
+ { min: '58.0.0.0', max: '58.255.255.255' },
259
+ { min: '59.0.0.0', max: '59.255.255.255' },
260
+ { min: '60.0.0.0', max: '60.255.255.255' },
261
+ { min: '61.0.0.0', max: '61.255.255.255' },
262
+ { min: '101.0.0.0', max: '101.255.255.255' },
263
+ { min: '103.0.0.0', max: '103.255.255.255' },
264
+ { min: '106.0.0.0', max: '106.255.255.255' },
265
+ { min: '110.0.0.0', max: '110.255.255.255' },
266
+ { min: '111.0.0.0', max: '111.255.255.255' },
267
+ { min: '112.0.0.0', max: '112.255.255.255' },
268
+ { min: '113.0.0.0', max: '113.255.255.255' },
269
+ { min: '114.0.0.0', max: '114.255.255.255' },
270
+ { min: '115.0.0.0', max: '115.255.255.255' },
271
+ { min: '116.0.0.0', max: '116.255.255.255' },
272
+ { min: '117.0.0.0', max: '117.255.255.255' },
273
+ { min: '118.0.0.0', max: '118.255.255.255' },
274
+ { min: '119.0.0.0', max: '119.255.255.255' },
275
+ { min: '120.0.0.0', max: '120.255.255.255' },
276
+ { min: '121.0.0.0', max: '121.255.255.255' },
277
+ { min: '122.0.0.0', max: '122.255.255.255' },
278
+ { min: '123.0.0.0', max: '123.255.255.255' },
279
+ { min: '124.0.0.0', max: '124.255.255.255' },
280
+ { min: '125.0.0.0', max: '125.255.255.255' },
281
+ { min: '171.0.0.0', max: '171.255.255.255' },
282
+ { min: '175.0.0.0', max: '175.255.255.255' },
283
+ { min: '180.0.0.0', max: '180.255.255.255' },
284
+ { min: '182.0.0.0', max: '182.255.255.255' },
285
+ { min: '183.0.0.0', max: '183.255.255.255' },
286
+ { min: '202.0.0.0', max: '202.255.255.255' },
287
+ { min: '203.0.0.0', max: '203.255.255.255' },
288
+ { min: '210.0.0.0', max: '210.255.255.255' },
289
+ { min: '211.0.0.0', max: '211.255.255.255' },
290
+ { min: '218.0.0.0', max: '218.255.255.255' },
291
+ { min: '219.0.0.0', max: '219.255.255.255' },
292
+ { min: '220.0.0.0', max: '220.255.255.255' },
293
+ { min: '221.0.0.0', max: '221.255.255.255' },
294
+ { min: '222.0.0.0', max: '222.255.255.255' },
295
+ { min: '223.0.0.0', max: '223.255.255.255' },
296
+ ],
297
+ },
298
+
299
+ // South America
300
+ {
301
+ country: 'Brazil',
302
+ countryCode: 'BR',
303
+ city: 'São Paulo',
304
+ region: 'São Paulo',
305
+ ranges: [
306
+ { min: '177.0.0.0', max: '177.255.255.255' },
307
+ { min: '201.0.0.0', max: '201.255.255.255' },
308
+ { min: '186.0.0.0', max: '186.255.255.255' },
309
+ { min: '189.0.0.0', max: '189.255.255.255' },
310
+ { min: '200.0.0.0', max: '200.255.255.255' },
311
+ ],
312
+ },
313
+
314
+ // Africa
315
+ {
316
+ country: 'South Africa',
317
+ countryCode: 'ZA',
318
+ city: 'Cape Town',
319
+ region: 'Western Cape',
320
+ ranges: [
321
+ { min: '41.0.0.0', max: '41.255.255.255' },
322
+ { min: '102.0.0.0', max: '102.255.255.255' },
323
+ { min: '105.0.0.0', max: '105.255.255.255' },
324
+ { min: '196.0.0.0', max: '196.255.255.255' },
325
+ { min: '197.0.0.0', max: '197.255.255.255' },
326
+ ],
327
+ },
328
+
329
+ // Russia
330
+ {
331
+ country: 'Russia',
332
+ countryCode: 'RU',
333
+ city: 'Moscow',
334
+ region: 'Moscow',
335
+ ranges: [
336
+ { min: '5.0.0.0', max: '5.255.255.255' },
337
+ { min: '31.0.0.0', max: '31.255.255.255' },
338
+ { min: '37.0.0.0', max: '37.255.255.255' },
339
+ { min: '46.0.0.0', max: '46.255.255.255' },
340
+ { min: '62.0.0.0', max: '62.255.255.255' },
341
+ { min: '77.0.0.0', max: '77.255.255.255' },
342
+ { min: '78.0.0.0', max: '78.255.255.255' },
343
+ { min: '80.0.0.0', max: '80.255.255.255' },
344
+ { min: '81.0.0.0', max: '81.255.255.255' },
345
+ { min: '82.0.0.0', max: '82.255.255.255' },
346
+ { min: '83.0.0.0', max: '83.255.255.255' },
347
+ { min: '84.0.0.0', max: '84.255.255.255' },
348
+ { min: '85.0.0.0', max: '85.255.255.255' },
349
+ { min: '86.0.0.0', max: '86.255.255.255' },
350
+ { min: '87.0.0.0', max: '87.255.255.255' },
351
+ { min: '88.0.0.0', max: '88.255.255.255' },
352
+ { min: '89.0.0.0', max: '89.255.255.255' },
353
+ { min: '90.0.0.0', max: '90.255.255.255' },
354
+ { min: '91.0.0.0', max: '91.255.255.255' },
355
+ { min: '92.0.0.0', max: '92.255.255.255' },
356
+ { min: '93.0.0.0', max: '93.255.255.255' },
357
+ { min: '94.0.0.0', max: '94.255.255.255' },
358
+ { min: '95.0.0.0', max: '95.255.255.255' },
359
+ { min: '109.0.0.0', max: '109.255.255.255' },
360
+ { min: '134.0.0.0', max: '134.255.255.255' },
361
+ { min: '136.0.0.0', max: '136.255.255.255' },
362
+ { min: '141.0.0.0', max: '141.255.255.255' },
363
+ { min: '145.0.0.0', max: '145.255.255.255' },
364
+ { min: '149.0.0.0', max: '149.255.255.255' },
365
+ { min: '178.0.0.0', max: '178.255.255.255' },
366
+ { min: '188.0.0.0', max: '188.255.255.255' },
367
+ { min: '195.0.0.0', max: '195.255.255.255' },
368
+ { min: '212.0.0.0', max: '212.255.255.255' },
369
+ { min: '217.0.0.0', max: '217.255.255.255' },
370
+ ],
371
+ },
372
+ ];
373
+
374
+ // Convert IP to number for range checking
375
+ function ipToNumber(ip) {
376
+ return ip.split('.').reduce((acc, part) => (acc << 8) + parseInt(part, 10), 0) >>> 0;
377
+ }
378
+
379
+ // Check if IP is in range
380
+ function isIPInRange(ip, minIP, maxIP) {
381
+ const ipNum = ipToNumber(ip);
382
+ const minNum = ipToNumber(minIP);
383
+ const maxNum = ipToNumber(maxIP);
384
+ return ipNum >= minNum && ipNum <= maxNum;
385
+ }
386
+
387
+ // Find location for IP
388
+ function findLocationForIP(ip) {
389
+ for (const countryData of IP_RANGES) {
390
+ for (const range of countryData.ranges) {
391
+ if (isIPInRange(ip, range.min, range.max)) {
392
+ return {
393
+ country: countryData.country,
394
+ countryCode: countryData.countryCode,
395
+ city: countryData.city,
396
+ region: countryData.region,
397
+ };
398
+ }
399
+ }
400
+ }
401
+
402
+ // Default fallback
403
+ return {
404
+ country: 'Unknown',
405
+ countryCode: '',
406
+ city: 'Unknown',
407
+ region: 'Unknown',
408
+ };
409
+ }
410
+
411
+ // Generate a simple database file (JSON format for now)
412
+ function generateDatabase() {
413
+ const database = {
414
+ version: '1.0.0',
415
+ generated: new Date().toISOString(),
416
+ description: 'Default IP geolocation database for Better Auth Studio',
417
+ coverage: 'Major IP ranges worldwide',
418
+ ranges: IP_RANGES,
419
+ totalRanges: IP_RANGES.reduce((sum, country) => sum + country.ranges.length, 0),
420
+ countries: IP_RANGES.length,
421
+ };
422
+
423
+ const outputPath = path.join(__dirname, '..', 'data', 'default-geo.json');
424
+ const outputDir = path.dirname(outputPath);
425
+
426
+ // Create directory if it doesn't exist
427
+ if (!fs.existsSync(outputDir)) {
428
+ fs.mkdirSync(outputDir, { recursive: true });
429
+ }
430
+
431
+ fs.writeFileSync(outputPath, JSON.stringify(database, null, 2));
432
+
433
+ return outputPath;
434
+ }
435
+
436
+ // Test the database with some sample IPs
437
+ function testDatabase() {
438
+ const testIPs = [
439
+ '8.8.8.8', // Google DNS (US)
440
+ '1.1.1.1', // Cloudflare (US)
441
+ '208.67.222.222', // OpenDNS (US)
442
+ '46.4.0.1', // Germany
443
+ '5.5.5.5', // UK
444
+ '126.0.0.1', // Japan
445
+ '103.0.0.1', // India
446
+ '1.0.0.1', // Australia
447
+ '177.0.0.1', // Brazil
448
+ '41.0.0.1', // South Africa
449
+ ];
450
+
451
+ testIPs.forEach((ip) => {
452
+ const _location = findLocationForIP(ip);
453
+ });
454
+ }
455
+
456
+ // Main execution
457
+ if (require.main === module) {
458
+ generateDatabase();
459
+ testDatabase();
460
+ }
461
+
462
+ module.exports = { IP_RANGES, findLocationForIP, generateDatabase };
@@ -0,0 +1,98 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Postinstall script to ensure public directory exists
5
+ * This runs after npm/pnpm install to handle edge cases where
6
+ * the public directory isn't extracted properly (e.g., Vercel with pnpm)
7
+ */
8
+
9
+ import fs from 'fs';
10
+ import path from 'path';
11
+ import { fileURLToPath } from 'url';
12
+
13
+ const __filename = fileURLToPath(import.meta.url);
14
+ const __dirname = path.dirname(__filename);
15
+
16
+ // Find the package root
17
+ const packageRoot = path.resolve(__dirname, '..');
18
+ const distDir = path.join(packageRoot, 'dist');
19
+ const publicInDist = path.join(distDir, 'public');
20
+ const publicInRoot = path.join(packageRoot, 'public');
21
+
22
+ console.log('[better-auth-studio] Running postinstall...');
23
+ console.log('[better-auth-studio] Package root:', packageRoot);
24
+
25
+ // List what's actually in the package
26
+ try {
27
+ const packageContents = fs.readdirSync(packageRoot);
28
+ console.log('[better-auth-studio] Package contents:', packageContents.join(', '));
29
+
30
+ if (fs.existsSync(distDir)) {
31
+ const distContents = fs.readdirSync(distDir);
32
+ console.log('[better-auth-studio] dist/ contents:', distContents.join(', '));
33
+ } else {
34
+ console.log('[better-auth-studio] dist/ directory does not exist');
35
+ }
36
+ } catch (err) {
37
+ console.warn('[better-auth-studio] Could not list package contents:', err.message);
38
+ }
39
+
40
+ // Check if either public directory exists
41
+ const hasPublicInDist =
42
+ fs.existsSync(publicInDist) && fs.existsSync(path.join(publicInDist, 'index.html'));
43
+ const hasPublicInRoot =
44
+ fs.existsSync(publicInRoot) && fs.existsSync(path.join(publicInRoot, 'index.html'));
45
+
46
+ console.log('[better-auth-studio] Checking public directories...');
47
+ console.log('[better-auth-studio] - dist/public exists:', hasPublicInDist);
48
+ console.log('[better-auth-studio] - public/ exists:', hasPublicInRoot);
49
+
50
+ if (hasPublicInDist || hasPublicInRoot) {
51
+ console.log('[better-auth-studio] ✓ Public directory found');
52
+
53
+ // Ensure both locations have the public files for maximum compatibility
54
+ if (hasPublicInRoot && !hasPublicInDist) {
55
+ try {
56
+ if (!fs.existsSync(distDir)) {
57
+ fs.mkdirSync(distDir, { recursive: true });
58
+ }
59
+ copyRecursive(publicInRoot, publicInDist);
60
+ console.log('[better-auth-studio] ✓ Copied public/ to dist/public/');
61
+ } catch (err) {
62
+ console.warn('[better-auth-studio] Warning: Could not copy to dist/public:', err.message);
63
+ }
64
+ } else if (hasPublicInDist && !hasPublicInRoot) {
65
+ try {
66
+ copyRecursive(publicInDist, publicInRoot);
67
+ console.log('[better-auth-studio] ✓ Copied dist/public/ to public/');
68
+ } catch (err) {
69
+ console.warn('[better-auth-studio] Warning: Could not copy to public:', err.message);
70
+ }
71
+ }
72
+ } else {
73
+ console.warn(
74
+ '[better-auth-studio] ⚠ Warning: Public directory not found. Studio UI may not work correctly.'
75
+ );
76
+ console.warn(
77
+ '[better-auth-studio] Please report this issue at: https://github.com/better-auth/better-auth-studio/issues'
78
+ );
79
+ }
80
+
81
+ function copyRecursive(src, dest) {
82
+ if (!fs.existsSync(dest)) {
83
+ fs.mkdirSync(dest, { recursive: true });
84
+ }
85
+
86
+ const entries = fs.readdirSync(src, { withFileTypes: true });
87
+
88
+ for (const entry of entries) {
89
+ const srcPath = path.join(src, entry.name);
90
+ const destPath = path.join(dest, entry.name);
91
+
92
+ if (entry.isDirectory()) {
93
+ copyRecursive(srcPath, destPath);
94
+ } else {
95
+ fs.copyFileSync(srcPath, destPath);
96
+ }
97
+ }
98
+ }