@better-auth/core 1.5.0-beta.11 → 1.5.0-beta.12

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 (57) hide show
  1. package/.turbo/turbo-build.log +38 -38
  2. package/dist/api/index.d.mts +6 -6
  3. package/dist/context/global.mjs +1 -1
  4. package/dist/db/get-tables.mjs +6 -6
  5. package/dist/db/get-tables.mjs.map +1 -1
  6. package/dist/db/schema/user.d.mts +1 -1
  7. package/dist/db/schema/user.mjs +1 -1
  8. package/dist/db/schema/user.mjs.map +1 -1
  9. package/dist/index.d.mts +2 -2
  10. package/dist/oauth2/client-credentials-token.d.mts +24 -3
  11. package/dist/oauth2/client-credentials-token.mjs +14 -2
  12. package/dist/oauth2/client-credentials-token.mjs.map +1 -1
  13. package/dist/oauth2/create-authorization-url.d.mts +3 -1
  14. package/dist/oauth2/create-authorization-url.mjs +1 -0
  15. package/dist/oauth2/create-authorization-url.mjs.map +1 -1
  16. package/dist/oauth2/index.d.mts +4 -4
  17. package/dist/oauth2/index.mjs +4 -4
  18. package/dist/oauth2/refresh-access-token.d.mts +23 -2
  19. package/dist/oauth2/refresh-access-token.mjs +15 -2
  20. package/dist/oauth2/refresh-access-token.mjs.map +1 -1
  21. package/dist/oauth2/validate-authorization-code.d.mts +35 -3
  22. package/dist/oauth2/validate-authorization-code.mjs +24 -13
  23. package/dist/oauth2/validate-authorization-code.mjs.map +1 -1
  24. package/dist/social-providers/apple.d.mts +3 -3
  25. package/dist/social-providers/apple.mjs +3 -7
  26. package/dist/social-providers/apple.mjs.map +1 -1
  27. package/dist/social-providers/discord.mjs +1 -1
  28. package/dist/social-providers/discord.mjs.map +1 -1
  29. package/dist/social-providers/index.d.mts +7 -4
  30. package/dist/social-providers/index.mjs +2 -2
  31. package/dist/social-providers/index.mjs.map +1 -1
  32. package/dist/social-providers/microsoft-entra-id.d.mts +3 -1
  33. package/dist/social-providers/microsoft-entra-id.mjs +35 -2
  34. package/dist/social-providers/microsoft-entra-id.mjs.map +1 -1
  35. package/dist/social-providers/roblox.mjs +1 -1
  36. package/dist/social-providers/roblox.mjs.map +1 -1
  37. package/dist/social-providers/slack.mjs +1 -1
  38. package/dist/social-providers/slack.mjs.map +1 -1
  39. package/dist/types/helper.d.mts +2 -1
  40. package/dist/types/index.d.mts +1 -1
  41. package/package.json +3 -3
  42. package/src/db/get-tables.ts +6 -6
  43. package/src/db/schema/user.ts +1 -1
  44. package/src/oauth2/client-credentials-token.ts +26 -2
  45. package/src/oauth2/create-authorization-url.ts +3 -1
  46. package/src/oauth2/index.ts +3 -0
  47. package/src/oauth2/refresh-access-token.ts +29 -2
  48. package/src/oauth2/validate-authorization-code.ts +55 -24
  49. package/src/oauth2/validate-token.test.ts +117 -50
  50. package/src/social-providers/apple.ts +8 -11
  51. package/src/social-providers/discord.ts +1 -1
  52. package/src/social-providers/index.ts +6 -5
  53. package/src/social-providers/microsoft-entra-id.ts +84 -1
  54. package/src/social-providers/roblox.ts +1 -1
  55. package/src/social-providers/slack.ts +1 -1
  56. package/src/types/context.ts +8 -7
  57. package/src/types/helper.ts +1 -0
@@ -1,5 +1,5 @@
1
1
 
2
- > @better-auth/core@1.5.0-beta.11 build /home/runner/work/better-auth/better-auth/packages/core
2
+ > @better-auth/core@1.5.0-beta.12 build /home/runner/work/better-auth/better-auth/packages/core
3
3
  > tsdown
4
4
 
5
5
  ℹ tsdown v0.20.1 powered by rolldown v1.0.0-rc.1
@@ -8,12 +8,12 @@
8
8
  ℹ tsconfig: tsconfig.json
9
9
  ℹ Build start
10
10
  ℹ dist/utils/ip.mjs  3.84 kB │ gzip: 1.31 kB
11
- ℹ dist/social-providers/index.mjs  2.35 kB │ gzip: 0.75 kB
11
+ ℹ dist/social-providers/index.mjs  2.40 kB │ gzip: 0.76 kB
12
12
  ℹ dist/api/index.mjs  1.30 kB │ gzip: 0.50 kB
13
13
  ℹ dist/utils/url.mjs  1.18 kB │ gzip: 0.54 kB
14
14
  ℹ dist/async_hooks/index.mjs  1.07 kB │ gzip: 0.56 kB
15
+ ℹ dist/oauth2/index.mjs  1.04 kB │ gzip: 0.28 kB
15
16
  ℹ dist/async_hooks/pure.index.mjs  1.03 kB │ gzip: 0.52 kB
16
- ℹ dist/oauth2/index.mjs  0.87 kB │ gzip: 0.27 kB
17
17
  ℹ dist/context/index.mjs  0.85 kB │ gzip: 0.25 kB
18
18
  ℹ dist/error/index.mjs  0.72 kB │ gzip: 0.36 kB
19
19
  ℹ dist/db/adapter/index.mjs  0.68 kB │ gzip: 0.22 kB
@@ -28,11 +28,11 @@
28
28
  ℹ dist/index.mjs  0.01 kB │ gzip: 0.03 kB
29
29
  ℹ dist/db/adapter/factory.mjs.map 63.56 kB │ gzip: 12.81 kB
30
30
  ℹ dist/db/adapter/factory.mjs 29.06 kB │ gzip: 5.70 kB
31
+ ℹ dist/social-providers/microsoft-entra-id.mjs.map 14.07 kB │ gzip: 4.62 kB
31
32
  ℹ dist/db/get-tables.mjs.map 13.13 kB │ gzip: 2.40 kB
32
33
  ℹ dist/social-providers/cognito.mjs.map 11.61 kB │ gzip: 3.68 kB
33
- ℹ dist/social-providers/microsoft-entra-id.mjs.map 10.94 kB │ gzip: 3.64 kB
34
34
  ℹ dist/social-providers/paypal.mjs.map 10.55 kB │ gzip: 3.07 kB
35
- ℹ dist/social-providers/apple.mjs.map  9.56 kB │ gzip: 3.37 kB
35
+ ℹ dist/social-providers/apple.mjs.map  9.37 kB │ gzip: 3.34 kB
36
36
  ℹ dist/social-providers/zoom.mjs.map  9.36 kB │ gzip: 3.22 kB
37
37
  ℹ dist/oauth2/verify.mjs.map  8.91 kB │ gzip: 2.97 kB
38
38
  ℹ dist/social-providers/twitter.mjs.map  8.44 kB │ gzip: 2.57 kB
@@ -45,16 +45,18 @@
45
45
  ℹ dist/db/get-tables.mjs  7.13 kB │ gzip: 1.36 kB
46
46
  ℹ dist/social-providers/line.mjs.map  6.99 kB │ gzip: 2.26 kB
47
47
  ℹ dist/social-providers/github.mjs.map  6.79 kB │ gzip: 2.17 kB
48
+ ℹ dist/oauth2/validate-authorization-code.mjs.map  6.75 kB │ gzip: 1.99 kB
48
49
  ℹ dist/social-providers/salesforce.mjs.map  6.52 kB │ gzip: 2.16 kB
49
50
  ℹ dist/db/adapter/get-id-field.mjs.map  6.45 kB │ gzip: 2.14 kB
50
51
  ℹ dist/env/color-depth.mjs.map  6.21 kB │ gzip: 2.31 kB
51
- ℹ dist/oauth2/validate-authorization-code.mjs.map  6.03 kB │ gzip: 1.99 kB
52
52
  ℹ dist/social-providers/gitlab.mjs.map  6.00 kB │ gzip: 2.11 kB
53
53
  ℹ dist/social-providers/cognito.mjs  5.94 kB │ gzip: 1.95 kB
54
+ ℹ dist/oauth2/refresh-access-token.mjs.map  5.61 kB │ gzip: 1.83 kB
54
55
  ℹ dist/env/logger.mjs.map  5.39 kB │ gzip: 1.90 kB
55
56
  ℹ dist/context/transaction.mjs.map  5.24 kB │ gzip: 1.59 kB
56
57
  ℹ dist/social-providers/atlassian.mjs.map  5.16 kB │ gzip: 1.76 kB
57
- ℹ dist/social-providers/slack.mjs.map  5.10 kB │ gzip: 1.63 kB
58
+ ℹ dist/social-providers/microsoft-entra-id.mjs  5.10 kB │ gzip: 1.84 kB
59
+ ℹ dist/social-providers/slack.mjs.map  5.10 kB │ gzip: 1.62 kB
58
60
  ℹ dist/social-providers/paypal.mjs  5.06 kB │ gzip: 1.50 kB
59
61
  ℹ dist/social-providers/paybin.mjs.map  4.94 kB │ gzip: 1.75 kB
60
62
  ℹ dist/social-providers/vk.mjs.map  4.94 kB │ gzip: 1.70 kB
@@ -62,7 +64,7 @@
62
64
  ℹ dist/social-providers/reddit.mjs.map  4.86 kB │ gzip: 1.75 kB
63
65
  ℹ dist/social-providers/roblox.mjs.map  4.84 kB │ gzip: 1.75 kB
64
66
  ℹ dist/social-providers/figma.mjs.map  4.78 kB │ gzip: 1.68 kB
65
- ℹ dist/oauth2/refresh-access-token.mjs.map  4.74 kB │ gzip: 1.69 kB
67
+ ℹ dist/oauth2/client-credentials-token.mjs.map  4.73 kB │ gzip: 1.59 kB
66
68
  ℹ dist/social-providers/polar.mjs.map  4.64 kB │ gzip: 1.57 kB
67
69
  ℹ dist/social-providers/huggingface.mjs.map  4.62 kB │ gzip: 1.55 kB
68
70
  ℹ dist/social-providers/linear.mjs.map  4.60 kB │ gzip: 1.60 kB
@@ -70,25 +72,23 @@
70
72
  ℹ dist/social-providers/naver.mjs.map  4.35 kB │ gzip: 1.56 kB
71
73
  ℹ dist/social-providers/notion.mjs.map  4.29 kB │ gzip: 1.53 kB
72
74
  ℹ dist/social-providers/twitch.mjs.map  4.20 kB │ gzip: 1.48 kB
75
+ ℹ dist/oauth2/create-authorization-url.mjs.map  4.16 kB │ gzip: 1.45 kB
73
76
  ℹ dist/error/codes.mjs.map  4.06 kB │ gzip: 1.62 kB
74
77
  ℹ dist/social-providers/linkedin.mjs.map  4.05 kB │ gzip: 1.45 kB
75
78
  ℹ dist/social-providers/kick.mjs.map  3.98 kB │ gzip: 1.42 kB
76
- ℹ dist/oauth2/create-authorization-url.mjs.map  3.97 kB │ gzip: 1.39 kB
77
- ℹ dist/oauth2/client-credentials-token.mjs.map  3.91 kB │ gzip: 1.45 kB
79
+ ℹ dist/social-providers/index.mjs.map  3.87 kB │ gzip: 1.07 kB
78
80
  ℹ dist/context/request-state.mjs.map  3.86 kB │ gzip: 1.46 kB
79
- ℹ dist/social-providers/apple.mjs  3.81 kB │ gzip: 1.38 kB
80
- ℹ dist/social-providers/index.mjs.map  3.79 kB │ gzip: 1.04 kB
81
81
  ℹ dist/social-providers/spotify.mjs.map  3.79 kB │ gzip: 1.34 kB
82
82
  ℹ dist/social-providers/google.mjs  3.79 kB │ gzip: 1.41 kB
83
83
  ℹ dist/oauth2/verify.mjs  3.78 kB │ gzip: 1.34 kB
84
+ ℹ dist/social-providers/apple.mjs  3.68 kB │ gzip: 1.35 kB
84
85
  ℹ dist/api/index.mjs.map  3.61 kB │ gzip: 1.14 kB
85
86
  ℹ dist/social-providers/line.mjs  3.60 kB │ gzip: 1.23 kB
86
87
  ℹ dist/social-providers/facebook.mjs  3.60 kB │ gzip: 1.27 kB
87
88
  ℹ dist/social-providers/salesforce.mjs  3.54 kB │ gzip: 1.14 kB
88
89
  ℹ dist/social-providers/vercel.mjs.map  3.52 kB │ gzip: 1.31 kB
89
- ℹ dist/social-providers/microsoft-entra-id.mjs  3.51 kB │ gzip: 1.25 kB
90
90
  ℹ dist/social-providers/github.mjs  3.17 kB │ gzip: 1.07 kB
91
- ℹ dist/oauth2/validate-authorization-code.mjs  2.86 kB │ gzip: 1.06 kB
91
+ ℹ dist/oauth2/validate-authorization-code.mjs  3.10 kB │ gzip: 1.06 kB
92
92
  ℹ dist/error/codes.mjs  2.82 kB │ gzip: 1.17 kB
93
93
  ℹ dist/social-providers/figma.mjs  2.81 kB │ gzip: 1.02 kB
94
94
  ℹ dist/social-providers/atlassian.mjs  2.79 kB │ gzip: 1.01 kB
@@ -99,10 +99,11 @@
99
99
  ℹ dist/social-providers/paybin.mjs  2.68 kB │ gzip: 0.99 kB
100
100
  ℹ dist/social-providers/gitlab.mjs  2.68 kB │ gzip: 0.99 kB
101
101
  ℹ dist/social-providers/reddit.mjs  2.67 kB │ gzip: 1.03 kB
102
- ℹ dist/social-providers/discord.mjs  2.66 kB │ gzip: 1.07 kB
102
+ ℹ dist/social-providers/discord.mjs  2.65 kB │ gzip: 1.07 kB
103
103
  ℹ dist/db/adapter/get-id-field.mjs  2.63 kB │ gzip: 0.99 kB
104
104
  ℹ dist/context/transaction.mjs  2.63 kB │ gzip: 0.85 kB
105
105
  ℹ dist/social-providers/vk.mjs  2.62 kB │ gzip: 0.96 kB
106
+ ℹ dist/oauth2/refresh-access-token.mjs  2.60 kB │ gzip: 0.95 kB
106
107
  ℹ dist/env/env-impl.mjs  2.56 kB │ gzip: 0.89 kB
107
108
  ℹ dist/env/logger.mjs  2.46 kB │ gzip: 0.96 kB
108
109
  ℹ dist/social-providers/linear.mjs  2.45 kB │ gzip: 0.92 kB
@@ -116,19 +117,18 @@
116
117
  ℹ dist/social-providers/tiktok.mjs  2.30 kB │ gzip: 0.90 kB
117
118
  ℹ dist/social-providers/slack.mjs  2.29 kB │ gzip: 0.86 kB
118
119
  ℹ dist/social-providers/huggingface.mjs  2.27 kB │ gzip: 0.81 kB
120
+ ℹ dist/oauth2/client-credentials-token.mjs  2.25 kB │ gzip: 0.87 kB
119
121
  ℹ dist/social-providers/twitch.mjs  2.24 kB │ gzip: 0.80 kB
120
122
  ℹ dist/social-providers/linkedin.mjs  2.23 kB │ gzip: 0.82 kB
121
123
  ℹ dist/social-providers/polar.mjs  2.22 kB │ gzip: 0.81 kB
122
124
  ℹ dist/social-providers/roblox.mjs  2.21 kB │ gzip: 0.89 kB
123
- ℹ dist/oauth2/refresh-access-token.mjs  2.20 kB │ gzip: 0.87 kB
124
125
  ℹ dist/context/global.mjs.map  2.19 kB │ gzip: 0.96 kB
125
126
  ℹ dist/social-providers/spotify.mjs  2.17 kB │ gzip: 0.80 kB
126
127
  ℹ dist/social-providers/naver.mjs  2.14 kB │ gzip: 0.81 kB
127
128
  ℹ dist/social-providers/kick.mjs  2.11 kB │ gzip: 0.79 kB
129
+ ℹ dist/oauth2/create-authorization-url.mjs  1.99 kB │ gzip: 0.78 kB
128
130
  ℹ dist/social-providers/vercel.mjs  1.94 kB │ gzip: 0.76 kB
129
- ℹ dist/oauth2/create-authorization-url.mjs  1.92 kB │ gzip: 0.75 kB
130
131
  ℹ dist/oauth2/utils.mjs.map  1.91 kB │ gzip: 0.91 kB
131
- ℹ dist/oauth2/client-credentials-token.mjs  1.89 kB │ gzip: 0.79 kB
132
132
  ℹ dist/db/schema/account.mjs.map  1.88 kB │ gzip: 0.72 kB
133
133
  ℹ dist/async_hooks/pure.index.mjs.map  1.83 kB │ gzip: 0.88 kB
134
134
  ℹ dist/utils/url.mjs.map  1.82 kB │ gzip: 0.80 kB
@@ -143,7 +143,7 @@
143
143
  ℹ dist/context/endpoint-context.mjs  1.35 kB │ gzip: 0.55 kB
144
144
  ℹ dist/db/adapter/get-field-attributes.mjs  1.31 kB │ gzip: 0.49 kB
145
145
  ℹ dist/db/schema/session.mjs.map  1.26 kB │ gzip: 0.56 kB
146
- ℹ dist/db/schema/user.mjs.map  1.25 kB │ gzip: 0.59 kB
146
+ ℹ dist/db/schema/user.mjs.map  1.23 kB │ gzip: 0.59 kB
147
147
  ℹ dist/utils/db.mjs.map  1.19 kB │ gzip: 0.66 kB
148
148
  ℹ dist/db/adapter/utils.mjs  1.19 kB │ gzip: 0.48 kB
149
149
  ℹ dist/db/schema/rate-limit.mjs.map  1.19 kB │ gzip: 0.54 kB
@@ -157,19 +157,19 @@
157
157
  ℹ dist/db/schema/account.mjs  0.56 kB │ gzip: 0.26 kB
158
158
  ℹ dist/db/schema/shared.mjs.map  0.47 kB │ gzip: 0.29 kB
159
159
  ℹ dist/utils/id.mjs.map  0.39 kB │ gzip: 0.29 kB
160
- ℹ dist/db/schema/user.mjs  0.38 kB │ gzip: 0.26 kB
160
+ ℹ dist/db/schema/user.mjs  0.36 kB │ gzip: 0.26 kB
161
161
  ℹ dist/db/schema/session.mjs  0.36 kB │ gzip: 0.23 kB
162
162
  ℹ dist/db/schema/verification.mjs  0.31 kB │ gzip: 0.21 kB
163
163
  ℹ dist/db/schema/shared.mjs  0.31 kB │ gzip: 0.21 kB
164
164
  ℹ dist/utils/string.mjs.map  0.31 kB │ gzip: 0.25 kB
165
165
  ℹ dist/db/schema/rate-limit.mjs  0.25 kB │ gzip: 0.19 kB
166
- ℹ dist/social-providers/index.d.mts 45.63 kB │ gzip: 3.11 kB
166
+ ℹ dist/social-providers/index.d.mts 45.86 kB │ gzip: 3.16 kB
167
167
  ℹ dist/db/adapter/index.d.mts 15.14 kB │ gzip: 3.61 kB
168
- ℹ dist/api/index.d.mts 10.49 kB │ gzip: 1.56 kB
168
+ ℹ dist/api/index.d.mts 10.37 kB │ gzip: 1.56 kB
169
169
  ℹ dist/db/index.d.mts  1.68 kB │ gzip: 0.45 kB
170
170
  ℹ dist/utils/ip.d.mts  1.61 kB │ gzip: 0.71 kB
171
- ℹ dist/index.d.mts  1.56 kB │ gzip: 0.41 kB
172
- ℹ dist/oauth2/index.d.mts  1.05 kB │ gzip: 0.32 kB
171
+ ℹ dist/index.d.mts  1.59 kB │ gzip: 0.42 kB
172
+ ℹ dist/oauth2/index.d.mts  1.22 kB │ gzip: 0.34 kB
173
173
  ℹ dist/utils/error-codes.d.mts  1.03 kB │ gzip: 0.50 kB
174
174
  ℹ dist/context/index.d.mts  0.97 kB │ gzip: 0.28 kB
175
175
  ℹ dist/utils/url.d.mts  0.88 kB │ gzip: 0.42 kB
@@ -187,12 +187,12 @@
187
187
  ℹ dist/db/type.d.mts  7.55 kB │ gzip: 1.89 kB
188
188
  ℹ dist/social-providers/zoom.d.mts  6.29 kB │ gzip: 2.20 kB
189
189
  ℹ dist/oauth2/oauth-provider.d.mts  5.97 kB │ gzip: 1.69 kB
190
- ℹ dist/social-providers/microsoft-entra-id.d.mts  5.64 kB │ gzip: 1.98 kB
190
+ ℹ dist/social-providers/microsoft-entra-id.d.mts  5.88 kB │ gzip: 2.07 kB
191
191
  ℹ dist/social-providers/tiktok.d.mts  5.38 kB │ gzip: 1.36 kB
192
192
  ℹ dist/social-providers/kakao.d.mts  4.95 kB │ gzip: 1.29 kB
193
193
  ℹ dist/social-providers/twitter.d.mts  4.83 kB │ gzip: 1.45 kB
194
194
  ℹ dist/db/adapter/types.d.mts  4.15 kB │ gzip: 1.28 kB
195
- ℹ dist/social-providers/apple.d.mts  3.93 kB │ gzip: 1.54 kB
195
+ ℹ dist/social-providers/apple.d.mts  3.89 kB │ gzip: 1.52 kB
196
196
  ℹ dist/types/plugin.d.mts  3.81 kB │ gzip: 1.38 kB
197
197
  ℹ dist/types/plugin-client.d.mts  3.80 kB │ gzip: 1.47 kB
198
198
  ℹ dist/social-providers/discord.d.mts  3.76 kB │ gzip: 1.26 kB
@@ -200,6 +200,7 @@
200
200
  ℹ dist/social-providers/paypal.d.mts  3.39 kB │ gzip: 1.02 kB
201
201
  ℹ dist/social-providers/gitlab.d.mts  2.99 kB │ gzip: 0.94 kB
202
202
  ℹ dist/social-providers/line.d.mts  2.65 kB │ gzip: 0.82 kB
203
+ ℹ dist/oauth2/validate-authorization-code.d.mts  2.54 kB │ gzip: 0.64 kB
203
204
  ℹ dist/social-providers/google.d.mts  2.52 kB │ gzip: 0.90 kB
204
205
  ℹ dist/social-providers/github.d.mts  2.43 kB │ gzip: 0.81 kB
205
206
  ℹ dist/social-providers/slack.d.mts  2.42 kB │ gzip: 0.74 kB
@@ -220,9 +221,10 @@
220
221
  ℹ dist/social-providers/kick.d.mts  1.66 kB │ gzip: 0.61 kB
221
222
  ℹ dist/social-providers/linkedin.d.mts  1.65 kB │ gzip: 0.62 kB
222
223
  ℹ dist/social-providers/linear.d.mts  1.64 kB │ gzip: 0.61 kB
223
- ℹ dist/oauth2/validate-authorization-code.d.mts  1.63 kB │ gzip: 0.51 kB
224
224
  ℹ dist/social-providers/notion.d.mts  1.60 kB │ gzip: 0.61 kB
225
+ ℹ dist/oauth2/refresh-access-token.d.mts  1.58 kB │ gzip: 0.49 kB
225
226
  ℹ dist/social-providers/reddit.d.mts  1.58 kB │ gzip: 0.59 kB
227
+ ℹ dist/oauth2/client-credentials-token.d.mts  1.56 kB │ gzip: 0.48 kB
226
228
  ℹ dist/social-providers/spotify.d.mts  1.55 kB │ gzip: 0.58 kB
227
229
  ℹ dist/social-providers/vercel.d.mts  1.50 kB │ gzip: 0.57 kB
228
230
  ℹ dist/social-providers/figma.d.mts  1.50 kB │ gzip: 0.57 kB
@@ -230,19 +232,17 @@
230
232
  ℹ dist/context/request-state.d.mts  1.40 kB │ gzip: 0.61 kB
231
233
  ℹ dist/env/env-impl.d.mts  1.31 kB │ gzip: 0.50 kB
232
234
  ℹ dist/context/transaction.d.mts  1.25 kB │ gzip: 0.53 kB
235
+ ℹ dist/oauth2/create-authorization-url.d.mts  1.21 kB │ gzip: 0.46 kB
233
236
  ℹ dist/db/schema/session.d.mts  1.21 kB │ gzip: 0.52 kB
234
- ℹ dist/db/schema/user.d.mts  1.17 kB │ gzip: 0.52 kB
235
237
  ℹ dist/db/schema/verification.d.mts  1.15 kB │ gzip: 0.48 kB
236
- ℹ dist/oauth2/create-authorization-url.d.mts  1.11 kB │ gzip: 0.43 kB
238
+ ℹ dist/db/schema/user.d.mts  1.14 kB │ gzip: 0.52 kB
237
239
  ℹ dist/db/adapter/get-id-field.d.mts  1.09 kB │ gzip: 0.49 kB
238
240
  ℹ dist/db/adapter/factory.d.mts  1.06 kB │ gzip: 0.39 kB
239
241
  ℹ dist/context/endpoint-context.d.mts  1.04 kB │ gzip: 0.45 kB
240
- ℹ dist/oauth2/refresh-access-token.d.mts  0.98 kB │ gzip: 0.39 kB
241
- ℹ dist/oauth2/client-credentials-token.d.mts  0.97 kB │ gzip: 0.39 kB
242
+ ℹ dist/types/index.d.mts  0.97 kB │ gzip: 0.38 kB
242
243
  ℹ dist/db/schema/rate-limit.d.mts  0.95 kB │ gzip: 0.43 kB
243
- ℹ dist/types/index.d.mts  0.95 kB │ gzip: 0.38 kB
244
244
  ℹ dist/db/adapter/get-field-attributes.d.mts  0.78 kB │ gzip: 0.36 kB
245
- ℹ dist/types/helper.d.mts  0.63 kB │ gzip: 0.35 kB
245
+ ℹ dist/types/helper.d.mts  0.70 kB │ gzip: 0.37 kB
246
246
  ℹ dist/db/adapter/get-default-field-name.d.mts  0.43 kB │ gzip: 0.26 kB
247
247
  ℹ dist/types/cookie.d.mts  0.42 kB │ gzip: 0.22 kB
248
248
  ℹ dist/db/adapter/get-field-name.d.mts  0.41 kB │ gzip: 0.26 kB
@@ -255,11 +255,11 @@
255
255
  ℹ dist/db/schema/shared.d.mts  0.29 kB │ gzip: 0.21 kB
256
256
  ℹ dist/context/global.d.mts  0.23 kB │ gzip: 0.18 kB
257
257
  ℹ dist/env/color-depth.d.mts  0.16 kB │ gzip: 0.14 kB
258
- ℹ 248 files, total: 869.08 kB
258
+ ℹ 248 files, total: 880.17 kB
259
259
  [PLUGIN_TIMINGS] Warning: Your build spent significant time in plugins. Here is a breakdown:
260
- - rolldown-plugin-dts:generate (41%)
261
- - rolldown-plugin-dts:fake-js (32%)
262
- - rolldown-plugin-dts:resolver (18%)
260
+ - rolldown-plugin-dts:generate (39%)
261
+ - rolldown-plugin-dts:fake-js (36%)
262
+ - rolldown-plugin-dts:resolver (24%)
263
263
  See https://rolldown.rs/options/checks#plugintimings for more details.
264
264
 
265
- ✔ Build complete in 5294ms
265
+ ✔ Build complete in 5343ms
@@ -43,7 +43,7 @@ declare const createAuthMiddleware: {
43
43
  updatedAt: Date;
44
44
  email: string;
45
45
  emailVerified: boolean;
46
- name?: string | null | undefined;
46
+ name: string;
47
47
  image?: string | null | undefined;
48
48
  } & Record<string, any>;
49
49
  } | null;
@@ -64,7 +64,7 @@ declare const createAuthMiddleware: {
64
64
  updatedAt: Date;
65
65
  email: string;
66
66
  emailVerified: boolean;
67
- name?: string | null | undefined;
67
+ name: string;
68
68
  image?: string | null | undefined;
69
69
  } & Record<string, any>;
70
70
  } | null;
@@ -85,7 +85,7 @@ declare const createAuthMiddleware: {
85
85
  updatedAt: Date;
86
86
  email: string;
87
87
  emailVerified: boolean;
88
- name?: string | null | undefined;
88
+ name: string;
89
89
  image?: string | null | undefined;
90
90
  } & Record<string, any>;
91
91
  } | null) => void;
@@ -170,7 +170,7 @@ declare const createAuthMiddleware: {
170
170
  updatedAt: Date;
171
171
  email: string;
172
172
  emailVerified: boolean;
173
- name?: string | null | undefined;
173
+ name: string;
174
174
  image?: string | null | undefined;
175
175
  } & Record<string, any>;
176
176
  } | null;
@@ -191,7 +191,7 @@ declare const createAuthMiddleware: {
191
191
  updatedAt: Date;
192
192
  email: string;
193
193
  emailVerified: boolean;
194
- name?: string | null | undefined;
194
+ name: string;
195
195
  image?: string | null | undefined;
196
196
  } & Record<string, any>;
197
197
  } | null;
@@ -212,7 +212,7 @@ declare const createAuthMiddleware: {
212
212
  updatedAt: Date;
213
213
  email: string;
214
214
  emailVerified: boolean;
215
- name?: string | null | undefined;
215
+ name: string;
216
216
  image?: string | null | undefined;
217
217
  } & Record<string, any>;
218
218
  } | null) => void;
@@ -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.5.0-beta.11";
5
+ const __betterAuthVersion = "1.5.0-beta.12";
6
6
  /**
7
7
  * We store context instance in the globalThis.
8
8
  *
@@ -130,6 +130,12 @@ const getAuthTables = (options) => {
130
130
  user: {
131
131
  modelName: options.user?.modelName || "user",
132
132
  fields: {
133
+ name: {
134
+ type: "string",
135
+ required: true,
136
+ fieldName: options.user?.fields?.name || "name",
137
+ sortable: true
138
+ },
133
139
  email: {
134
140
  type: "string",
135
141
  unique: true,
@@ -144,12 +150,6 @@ const getAuthTables = (options) => {
144
150
  fieldName: options.user?.fields?.emailVerified || "emailVerified",
145
151
  input: false
146
152
  },
147
- name: {
148
- type: "string",
149
- required: false,
150
- fieldName: options.user?.fields?.name || "name",
151
- sortable: true
152
- },
153
153
  image: {
154
154
  type: "string",
155
155
  required: false,
@@ -1 +1 @@
1
- {"version":3,"file":"get-tables.mjs","names":[],"sources":["../../src/db/get-tables.ts"],"sourcesContent":["import type { BetterAuthOptions } from \"../types\";\nimport type { BetterAuthDBSchema, DBFieldAttribute } from \"./type\";\n\nexport const getAuthTables = (\n\toptions: BetterAuthOptions,\n): BetterAuthDBSchema => {\n\tconst pluginSchema = (options.plugins ?? []).reduce(\n\t\t(acc, plugin) => {\n\t\t\tconst schema = plugin.schema;\n\t\t\tif (!schema) return acc;\n\t\t\tfor (const [key, value] of Object.entries(schema)) {\n\t\t\t\tacc[key] = {\n\t\t\t\t\tfields: {\n\t\t\t\t\t\t...acc[key]?.fields,\n\t\t\t\t\t\t...value.fields,\n\t\t\t\t\t},\n\t\t\t\t\tmodelName: value.modelName || key,\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn acc;\n\t\t},\n\t\t{} as Record<\n\t\t\tstring,\n\t\t\t{ fields: Record<string, DBFieldAttribute>; modelName: string }\n\t\t>,\n\t);\n\n\tconst shouldAddRateLimitTable = options.rateLimit?.storage === \"database\";\n\tconst rateLimitTable = {\n\t\trateLimit: {\n\t\t\tmodelName: options.rateLimit?.modelName || \"rateLimit\",\n\t\t\tfields: {\n\t\t\t\tkey: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t\tunique: true,\n\t\t\t\t\trequired: true,\n\t\t\t\t\tfieldName: options.rateLimit?.fields?.key || \"key\",\n\t\t\t\t},\n\t\t\t\tcount: {\n\t\t\t\t\ttype: \"number\",\n\t\t\t\t\trequired: true,\n\t\t\t\t\tfieldName: options.rateLimit?.fields?.count || \"count\",\n\t\t\t\t},\n\t\t\t\tlastRequest: {\n\t\t\t\t\ttype: \"number\",\n\t\t\t\t\tbigint: true,\n\t\t\t\t\trequired: true,\n\t\t\t\t\tfieldName: options.rateLimit?.fields?.lastRequest || \"lastRequest\",\n\t\t\t\t\tdefaultValue: () => Date.now(),\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t} satisfies BetterAuthDBSchema;\n\n\tconst { user, session, account, verification, ...pluginTables } =\n\t\tpluginSchema;\n\n\tconst verificationTable = {\n\t\tverification: {\n\t\t\tmodelName: options.verification?.modelName || \"verification\",\n\t\t\tfields: {\n\t\t\t\tidentifier: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t\trequired: true,\n\t\t\t\t\tfieldName: options.verification?.fields?.identifier || \"identifier\",\n\t\t\t\t\tindex: true,\n\t\t\t\t},\n\t\t\t\tvalue: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t\trequired: true,\n\t\t\t\t\tfieldName: options.verification?.fields?.value || \"value\",\n\t\t\t\t},\n\t\t\t\texpiresAt: {\n\t\t\t\t\ttype: \"date\",\n\t\t\t\t\trequired: true,\n\t\t\t\t\tfieldName: options.verification?.fields?.expiresAt || \"expiresAt\",\n\t\t\t\t},\n\t\t\t\tcreatedAt: {\n\t\t\t\t\ttype: \"date\",\n\t\t\t\t\trequired: true,\n\t\t\t\t\tdefaultValue: () => new Date(),\n\t\t\t\t\tfieldName: options.verification?.fields?.createdAt || \"createdAt\",\n\t\t\t\t},\n\t\t\t\tupdatedAt: {\n\t\t\t\t\ttype: \"date\",\n\t\t\t\t\trequired: true,\n\t\t\t\t\tdefaultValue: () => new Date(),\n\t\t\t\t\tonUpdate: () => new Date(),\n\t\t\t\t\tfieldName: options.verification?.fields?.updatedAt || \"updatedAt\",\n\t\t\t\t},\n\t\t\t\t...verification?.fields,\n\t\t\t\t...options.verification?.additionalFields,\n\t\t\t},\n\t\t\torder: 4,\n\t\t},\n\t} satisfies BetterAuthDBSchema;\n\n\tconst sessionTable = {\n\t\tsession: {\n\t\t\tmodelName: options.session?.modelName || \"session\",\n\t\t\tfields: {\n\t\t\t\texpiresAt: {\n\t\t\t\t\ttype: \"date\",\n\t\t\t\t\trequired: true,\n\t\t\t\t\tfieldName: options.session?.fields?.expiresAt || \"expiresAt\",\n\t\t\t\t},\n\t\t\t\ttoken: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t\trequired: true,\n\t\t\t\t\tfieldName: options.session?.fields?.token || \"token\",\n\t\t\t\t\tunique: true,\n\t\t\t\t},\n\t\t\t\tcreatedAt: {\n\t\t\t\t\ttype: \"date\",\n\t\t\t\t\trequired: true,\n\t\t\t\t\tfieldName: options.session?.fields?.createdAt || \"createdAt\",\n\t\t\t\t\tdefaultValue: () => new Date(),\n\t\t\t\t},\n\t\t\t\tupdatedAt: {\n\t\t\t\t\ttype: \"date\",\n\t\t\t\t\trequired: true,\n\t\t\t\t\tfieldName: options.session?.fields?.updatedAt || \"updatedAt\",\n\t\t\t\t\tonUpdate: () => new Date(),\n\t\t\t\t},\n\t\t\t\tipAddress: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t\trequired: false,\n\t\t\t\t\tfieldName: options.session?.fields?.ipAddress || \"ipAddress\",\n\t\t\t\t},\n\t\t\t\tuserAgent: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t\trequired: false,\n\t\t\t\t\tfieldName: options.session?.fields?.userAgent || \"userAgent\",\n\t\t\t\t},\n\t\t\t\tuserId: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t\tfieldName: options.session?.fields?.userId || \"userId\",\n\t\t\t\t\treferences: {\n\t\t\t\t\t\tmodel: options.user?.modelName || \"user\",\n\t\t\t\t\t\tfield: \"id\",\n\t\t\t\t\t\tonDelete: \"cascade\",\n\t\t\t\t\t},\n\t\t\t\t\trequired: true,\n\t\t\t\t\tindex: true,\n\t\t\t\t},\n\t\t\t\t...session?.fields,\n\t\t\t\t...options.session?.additionalFields,\n\t\t\t},\n\t\t\torder: 2,\n\t\t},\n\t} satisfies BetterAuthDBSchema;\n\n\treturn {\n\t\tuser: {\n\t\t\tmodelName: options.user?.modelName || \"user\",\n\t\t\tfields: {\n\t\t\t\temail: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t\tunique: true,\n\t\t\t\t\trequired: true,\n\t\t\t\t\tfieldName: options.user?.fields?.email || \"email\",\n\t\t\t\t\tsortable: true,\n\t\t\t\t},\n\t\t\t\temailVerified: {\n\t\t\t\t\ttype: \"boolean\",\n\t\t\t\t\tdefaultValue: false,\n\t\t\t\t\trequired: true,\n\t\t\t\t\tfieldName: options.user?.fields?.emailVerified || \"emailVerified\",\n\t\t\t\t\tinput: false,\n\t\t\t\t},\n\t\t\t\tname: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t\trequired: false,\n\t\t\t\t\tfieldName: options.user?.fields?.name || \"name\",\n\t\t\t\t\tsortable: true,\n\t\t\t\t},\n\t\t\t\timage: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t\trequired: false,\n\t\t\t\t\tfieldName: options.user?.fields?.image || \"image\",\n\t\t\t\t},\n\t\t\t\tcreatedAt: {\n\t\t\t\t\ttype: \"date\",\n\t\t\t\t\tdefaultValue: () => new Date(),\n\t\t\t\t\trequired: true,\n\t\t\t\t\tfieldName: options.user?.fields?.createdAt || \"createdAt\",\n\t\t\t\t},\n\t\t\t\tupdatedAt: {\n\t\t\t\t\ttype: \"date\",\n\t\t\t\t\tdefaultValue: () => new Date(),\n\t\t\t\t\tonUpdate: () => new Date(),\n\t\t\t\t\trequired: true,\n\t\t\t\t\tfieldName: options.user?.fields?.updatedAt || \"updatedAt\",\n\t\t\t\t},\n\t\t\t\t...user?.fields,\n\t\t\t\t...options.user?.additionalFields,\n\t\t\t},\n\t\t\torder: 1,\n\t\t},\n\t\t//only add session table if it's not stored in secondary storage\n\t\t...(!options.secondaryStorage || options.session?.storeSessionInDatabase\n\t\t\t? sessionTable\n\t\t\t: {}),\n\t\taccount: {\n\t\t\tmodelName: options.account?.modelName || \"account\",\n\t\t\tfields: {\n\t\t\t\taccountId: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t\trequired: true,\n\t\t\t\t\tfieldName: options.account?.fields?.accountId || \"accountId\",\n\t\t\t\t},\n\t\t\t\tproviderId: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t\trequired: true,\n\t\t\t\t\tfieldName: options.account?.fields?.providerId || \"providerId\",\n\t\t\t\t},\n\t\t\t\tuserId: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t\treferences: {\n\t\t\t\t\t\tmodel: options.user?.modelName || \"user\",\n\t\t\t\t\t\tfield: \"id\",\n\t\t\t\t\t\tonDelete: \"cascade\",\n\t\t\t\t\t},\n\t\t\t\t\trequired: true,\n\t\t\t\t\tfieldName: options.account?.fields?.userId || \"userId\",\n\t\t\t\t\tindex: true,\n\t\t\t\t},\n\t\t\t\taccessToken: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t\trequired: false,\n\t\t\t\t\treturned: false,\n\t\t\t\t\tfieldName: options.account?.fields?.accessToken || \"accessToken\",\n\t\t\t\t},\n\t\t\t\trefreshToken: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t\trequired: false,\n\t\t\t\t\treturned: false,\n\t\t\t\t\tfieldName: options.account?.fields?.refreshToken || \"refreshToken\",\n\t\t\t\t},\n\t\t\t\tidToken: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t\trequired: false,\n\t\t\t\t\treturned: false,\n\t\t\t\t\tfieldName: options.account?.fields?.idToken || \"idToken\",\n\t\t\t\t},\n\t\t\t\taccessTokenExpiresAt: {\n\t\t\t\t\ttype: \"date\",\n\t\t\t\t\trequired: false,\n\t\t\t\t\treturned: false,\n\t\t\t\t\tfieldName:\n\t\t\t\t\t\toptions.account?.fields?.accessTokenExpiresAt ||\n\t\t\t\t\t\t\"accessTokenExpiresAt\",\n\t\t\t\t},\n\t\t\t\trefreshTokenExpiresAt: {\n\t\t\t\t\ttype: \"date\",\n\t\t\t\t\trequired: false,\n\t\t\t\t\treturned: false,\n\t\t\t\t\tfieldName:\n\t\t\t\t\t\toptions.account?.fields?.refreshTokenExpiresAt ||\n\t\t\t\t\t\t\"refreshTokenExpiresAt\",\n\t\t\t\t},\n\t\t\t\tscope: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t\trequired: false,\n\t\t\t\t\tfieldName: options.account?.fields?.scope || \"scope\",\n\t\t\t\t},\n\t\t\t\tpassword: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t\trequired: false,\n\t\t\t\t\treturned: false,\n\t\t\t\t\tfieldName: options.account?.fields?.password || \"password\",\n\t\t\t\t},\n\t\t\t\tcreatedAt: {\n\t\t\t\t\ttype: \"date\",\n\t\t\t\t\trequired: true,\n\t\t\t\t\tfieldName: options.account?.fields?.createdAt || \"createdAt\",\n\t\t\t\t\tdefaultValue: () => new Date(),\n\t\t\t\t},\n\t\t\t\tupdatedAt: {\n\t\t\t\t\ttype: \"date\",\n\t\t\t\t\trequired: true,\n\t\t\t\t\tfieldName: options.account?.fields?.updatedAt || \"updatedAt\",\n\t\t\t\t\tonUpdate: () => new Date(),\n\t\t\t\t},\n\t\t\t\t...account?.fields,\n\t\t\t\t...options.account?.additionalFields,\n\t\t\t},\n\t\t\torder: 3,\n\t\t},\n\t\t...(!options.secondaryStorage || options.verification?.storeInDatabase\n\t\t\t? verificationTable\n\t\t\t: {}),\n\t\t...pluginTables,\n\t\t...(shouldAddRateLimitTable ? rateLimitTable : {}),\n\t} satisfies BetterAuthDBSchema;\n};\n"],"mappings":";AAGA,MAAa,iBACZ,YACwB;CACxB,MAAM,gBAAgB,QAAQ,WAAW,EAAE,EAAE,QAC3C,KAAK,WAAW;EAChB,MAAM,SAAS,OAAO;AACtB,MAAI,CAAC,OAAQ,QAAO;AACpB,OAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,OAAO,CAChD,KAAI,OAAO;GACV,QAAQ;IACP,GAAG,IAAI,MAAM;IACb,GAAG,MAAM;IACT;GACD,WAAW,MAAM,aAAa;GAC9B;AAEF,SAAO;IAER,EAAE,CAIF;CAED,MAAM,0BAA0B,QAAQ,WAAW,YAAY;CAC/D,MAAM,iBAAiB,EACtB,WAAW;EACV,WAAW,QAAQ,WAAW,aAAa;EAC3C,QAAQ;GACP,KAAK;IACJ,MAAM;IACN,QAAQ;IACR,UAAU;IACV,WAAW,QAAQ,WAAW,QAAQ,OAAO;IAC7C;GACD,OAAO;IACN,MAAM;IACN,UAAU;IACV,WAAW,QAAQ,WAAW,QAAQ,SAAS;IAC/C;GACD,aAAa;IACZ,MAAM;IACN,QAAQ;IACR,UAAU;IACV,WAAW,QAAQ,WAAW,QAAQ,eAAe;IACrD,oBAAoB,KAAK,KAAK;IAC9B;GACD;EACD,EACD;CAED,MAAM,EAAE,MAAM,SAAS,SAAS,cAAc,GAAG,iBAChD;CAED,MAAM,oBAAoB,EACzB,cAAc;EACb,WAAW,QAAQ,cAAc,aAAa;EAC9C,QAAQ;GACP,YAAY;IACX,MAAM;IACN,UAAU;IACV,WAAW,QAAQ,cAAc,QAAQ,c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a;KACZ,MAAM;KACN,UAAU;KACV,UAAU;KACV,WAAW,QAAQ,SAAS,QAAQ,eAAe;KACnD;IACD,cAAc;KACb,MAAM;KACN,UAAU;KACV,UAAU;KACV,WAAW,QAAQ,SAAS,QAAQ,gBAAgB;KACpD;IACD,SAAS;KACR,MAAM;KACN,UAAU;KACV,UAAU;KACV,WAAW,QAAQ,SAAS,QAAQ,WAAW;KAC/C;IACD,sBAAsB;KACrB,MAAM;KACN,UAAU;KACV,UAAU;KACV,WACC,QAAQ,SAAS,QAAQ,wBACzB;KACD;IACD,uBAAuB;KACtB,MAAM;KACN,UAAU;KACV,UAAU;KACV,WACC,QAAQ,SAAS,QAAQ,yBACzB;KACD;IACD,OAAO;KACN,MAAM;KACN,UAAU;KACV,WAAW,QAAQ,SAAS,QAAQ,SAAS;KAC7C;IACD,UAAU;KACT,MAAM;KACN,UAAU;KACV,UAAU;KACV,WAAW,QAAQ,SAAS,QAAQ,YAAY;KAChD;IACD,WAAW;KACV,MAAM;KACN,UAAU;KACV,WAAW,QAAQ,SAAS,QAAQ,aAAa;KACjD,oCAAoB,IAAI,MAAM;KAC9B;IACD,WAAW;KACV,MAAM;KACN,UAAU;KACV,WAAW,QAAQ,SAAS,QAAQ,aAAa;KACjD,gCAAgB,IAAI,MAAM;KAC1B;IACD,GAAG,SAAS;IACZ,GAAG,QAAQ,SAAS;IACpB;GACD,OAAO;GACP;EACD,GAAI,CAAC,QAAQ,oBAAoB,QAAQ,cAAc,kBACpD,oBACA,EAAE;EACL,GAAG;EACH,GAAI,0BAA0B,iBAAiB,EAAE;EACjD"}
1
+ {"version":3,"file":"get-tables.mjs","names":[],"sources":["../../src/db/get-tables.ts"],"sourcesContent":["import type { BetterAuthOptions } from \"../types\";\nimport type { BetterAuthDBSchema, DBFieldAttribute } from \"./type\";\n\nexport const getAuthTables = (\n\toptions: BetterAuthOptions,\n): BetterAuthDBSchema => {\n\tconst pluginSchema = (options.plugins ?? []).reduce(\n\t\t(acc, plugin) => {\n\t\t\tconst schema = plugin.schema;\n\t\t\tif (!schema) return acc;\n\t\t\tfor (const [key, value] of Object.entries(schema)) {\n\t\t\t\tacc[key] = {\n\t\t\t\t\tfields: {\n\t\t\t\t\t\t...acc[key]?.fields,\n\t\t\t\t\t\t...value.fields,\n\t\t\t\t\t},\n\t\t\t\t\tmodelName: value.modelName || key,\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn acc;\n\t\t},\n\t\t{} as Record<\n\t\t\tstring,\n\t\t\t{ fields: Record<string, DBFieldAttribute>; modelName: string }\n\t\t>,\n\t);\n\n\tconst shouldAddRateLimitTable = options.rateLimit?.storage === \"database\";\n\tconst rateLimitTable = {\n\t\trateLimit: {\n\t\t\tmodelName: options.rateLimit?.modelName || \"rateLimit\",\n\t\t\tfields: {\n\t\t\t\tkey: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t\tunique: true,\n\t\t\t\t\trequired: true,\n\t\t\t\t\tfieldName: options.rateLimit?.fields?.key || \"key\",\n\t\t\t\t},\n\t\t\t\tcount: {\n\t\t\t\t\ttype: \"number\",\n\t\t\t\t\trequired: true,\n\t\t\t\t\tfieldName: options.rateLimit?.fields?.count || \"count\",\n\t\t\t\t},\n\t\t\t\tlastRequest: {\n\t\t\t\t\ttype: \"number\",\n\t\t\t\t\tbigint: true,\n\t\t\t\t\trequired: true,\n\t\t\t\t\tfieldName: options.rateLimit?.fields?.lastRequest || \"lastRequest\",\n\t\t\t\t\tdefaultValue: () => Date.now(),\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t} satisfies BetterAuthDBSchema;\n\n\tconst { user, session, account, verification, ...pluginTables } =\n\t\tpluginSchema;\n\n\tconst verificationTable = {\n\t\tverification: {\n\t\t\tmodelName: options.verification?.modelName || \"verification\",\n\t\t\tfields: {\n\t\t\t\tidentifier: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t\trequired: true,\n\t\t\t\t\tfieldName: options.verification?.fields?.identifier || \"identifier\",\n\t\t\t\t\tindex: true,\n\t\t\t\t},\n\t\t\t\tvalue: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t\trequired: true,\n\t\t\t\t\tfieldName: options.verification?.fields?.value || \"value\",\n\t\t\t\t},\n\t\t\t\texpiresAt: {\n\t\t\t\t\ttype: \"date\",\n\t\t\t\t\trequired: true,\n\t\t\t\t\tfieldName: options.verification?.fields?.expiresAt || \"expiresAt\",\n\t\t\t\t},\n\t\t\t\tcreatedAt: {\n\t\t\t\t\ttype: \"date\",\n\t\t\t\t\trequired: true,\n\t\t\t\t\tdefaultValue: () => new Date(),\n\t\t\t\t\tfieldName: options.verification?.fields?.createdAt || \"createdAt\",\n\t\t\t\t},\n\t\t\t\tupdatedAt: {\n\t\t\t\t\ttype: \"date\",\n\t\t\t\t\trequired: true,\n\t\t\t\t\tdefaultValue: () => new Date(),\n\t\t\t\t\tonUpdate: () => new Date(),\n\t\t\t\t\tfieldName: options.verification?.fields?.updatedAt || \"updatedAt\",\n\t\t\t\t},\n\t\t\t\t...verification?.fields,\n\t\t\t\t...options.verification?.additionalFields,\n\t\t\t},\n\t\t\torder: 4,\n\t\t},\n\t} satisfies BetterAuthDBSchema;\n\n\tconst sessionTable = {\n\t\tsession: {\n\t\t\tmodelName: options.session?.modelName || \"session\",\n\t\t\tfields: {\n\t\t\t\texpiresAt: {\n\t\t\t\t\ttype: \"date\",\n\t\t\t\t\trequired: true,\n\t\t\t\t\tfieldName: options.session?.fields?.expiresAt || \"expiresAt\",\n\t\t\t\t},\n\t\t\t\ttoken: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t\trequired: true,\n\t\t\t\t\tfieldName: options.session?.fields?.token || \"token\",\n\t\t\t\t\tunique: true,\n\t\t\t\t},\n\t\t\t\tcreatedAt: {\n\t\t\t\t\ttype: \"date\",\n\t\t\t\t\trequired: true,\n\t\t\t\t\tfieldName: options.session?.fields?.createdAt || \"createdAt\",\n\t\t\t\t\tdefaultValue: () => new Date(),\n\t\t\t\t},\n\t\t\t\tupdatedAt: {\n\t\t\t\t\ttype: \"date\",\n\t\t\t\t\trequired: true,\n\t\t\t\t\tfieldName: options.session?.fields?.updatedAt || \"updatedAt\",\n\t\t\t\t\tonUpdate: () => new Date(),\n\t\t\t\t},\n\t\t\t\tipAddress: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t\trequired: false,\n\t\t\t\t\tfieldName: options.session?.fields?.ipAddress || \"ipAddress\",\n\t\t\t\t},\n\t\t\t\tuserAgent: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t\trequired: false,\n\t\t\t\t\tfieldName: options.session?.fields?.userAgent || \"userAgent\",\n\t\t\t\t},\n\t\t\t\tuserId: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t\tfieldName: options.session?.fields?.userId || \"userId\",\n\t\t\t\t\treferences: {\n\t\t\t\t\t\tmodel: options.user?.modelName || \"user\",\n\t\t\t\t\t\tfield: \"id\",\n\t\t\t\t\t\tonDelete: \"cascade\",\n\t\t\t\t\t},\n\t\t\t\t\trequired: true,\n\t\t\t\t\tindex: true,\n\t\t\t\t},\n\t\t\t\t...session?.fields,\n\t\t\t\t...options.session?.additionalFields,\n\t\t\t},\n\t\t\torder: 2,\n\t\t},\n\t} satisfies BetterAuthDBSchema;\n\n\treturn {\n\t\tuser: {\n\t\t\tmodelName: options.user?.modelName || \"user\",\n\t\t\tfields: {\n\t\t\t\tname: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t\trequired: true,\n\t\t\t\t\tfieldName: options.user?.fields?.name || \"name\",\n\t\t\t\t\tsortable: true,\n\t\t\t\t},\n\t\t\t\temail: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t\tunique: true,\n\t\t\t\t\trequired: true,\n\t\t\t\t\tfieldName: options.user?.fields?.email || \"email\",\n\t\t\t\t\tsortable: true,\n\t\t\t\t},\n\t\t\t\temailVerified: {\n\t\t\t\t\ttype: \"boolean\",\n\t\t\t\t\tdefaultValue: false,\n\t\t\t\t\trequired: true,\n\t\t\t\t\tfieldName: options.user?.fields?.emailVerified || \"emailVerified\",\n\t\t\t\t\tinput: false,\n\t\t\t\t},\n\t\t\t\timage: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t\trequired: false,\n\t\t\t\t\tfieldName: options.user?.fields?.image || \"image\",\n\t\t\t\t},\n\t\t\t\tcreatedAt: {\n\t\t\t\t\ttype: \"date\",\n\t\t\t\t\tdefaultValue: () => new Date(),\n\t\t\t\t\trequired: true,\n\t\t\t\t\tfieldName: options.user?.fields?.createdAt || \"createdAt\",\n\t\t\t\t},\n\t\t\t\tupdatedAt: {\n\t\t\t\t\ttype: \"date\",\n\t\t\t\t\tdefaultValue: () => new Date(),\n\t\t\t\t\tonUpdate: () => new Date(),\n\t\t\t\t\trequired: true,\n\t\t\t\t\tfieldName: options.user?.fields?.updatedAt || \"updatedAt\",\n\t\t\t\t},\n\t\t\t\t...user?.fields,\n\t\t\t\t...options.user?.additionalFields,\n\t\t\t},\n\t\t\torder: 1,\n\t\t},\n\t\t//only add session table if it's not stored in secondary storage\n\t\t...(!options.secondaryStorage || options.session?.storeSessionInDatabase\n\t\t\t? sessionTable\n\t\t\t: {}),\n\t\taccount: {\n\t\t\tmodelName: options.account?.modelName || \"account\",\n\t\t\tfields: {\n\t\t\t\taccountId: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t\trequired: true,\n\t\t\t\t\tfieldName: options.account?.fields?.accountId || \"accountId\",\n\t\t\t\t},\n\t\t\t\tproviderId: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t\trequired: true,\n\t\t\t\t\tfieldName: options.account?.fields?.providerId || \"providerId\",\n\t\t\t\t},\n\t\t\t\tuserId: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t\treferences: {\n\t\t\t\t\t\tmodel: options.user?.modelName || \"user\",\n\t\t\t\t\t\tfield: \"id\",\n\t\t\t\t\t\tonDelete: \"cascade\",\n\t\t\t\t\t},\n\t\t\t\t\trequired: true,\n\t\t\t\t\tfieldName: options.account?.fields?.userId || \"userId\",\n\t\t\t\t\tindex: true,\n\t\t\t\t},\n\t\t\t\taccessToken: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t\trequired: false,\n\t\t\t\t\treturned: false,\n\t\t\t\t\tfieldName: options.account?.fields?.accessToken || \"accessToken\",\n\t\t\t\t},\n\t\t\t\trefreshToken: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t\trequired: false,\n\t\t\t\t\treturned: false,\n\t\t\t\t\tfieldName: options.account?.fields?.refreshToken || \"refreshToken\",\n\t\t\t\t},\n\t\t\t\tidToken: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t\trequired: false,\n\t\t\t\t\treturned: false,\n\t\t\t\t\tfieldName: options.account?.fields?.idToken || \"idToken\",\n\t\t\t\t},\n\t\t\t\taccessTokenExpiresAt: {\n\t\t\t\t\ttype: \"date\",\n\t\t\t\t\trequired: false,\n\t\t\t\t\treturned: false,\n\t\t\t\t\tfieldName:\n\t\t\t\t\t\toptions.account?.fields?.accessTokenExpiresAt ||\n\t\t\t\t\t\t\"accessTokenExpiresAt\",\n\t\t\t\t},\n\t\t\t\trefreshTokenExpiresAt: {\n\t\t\t\t\ttype: \"date\",\n\t\t\t\t\trequired: false,\n\t\t\t\t\treturned: false,\n\t\t\t\t\tfieldName:\n\t\t\t\t\t\toptions.account?.fields?.refreshTokenExpiresAt ||\n\t\t\t\t\t\t\"refreshTokenExpiresAt\",\n\t\t\t\t},\n\t\t\t\tscope: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t\trequired: false,\n\t\t\t\t\tfieldName: options.account?.fields?.scope || \"scope\",\n\t\t\t\t},\n\t\t\t\tpassword: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t\trequired: false,\n\t\t\t\t\treturned: false,\n\t\t\t\t\tfieldName: options.account?.fields?.password || \"password\",\n\t\t\t\t},\n\t\t\t\tcreatedAt: {\n\t\t\t\t\ttype: \"date\",\n\t\t\t\t\trequired: true,\n\t\t\t\t\tfieldName: options.account?.fields?.createdAt || \"createdAt\",\n\t\t\t\t\tdefaultValue: () => new Date(),\n\t\t\t\t},\n\t\t\t\tupdatedAt: {\n\t\t\t\t\ttype: \"date\",\n\t\t\t\t\trequired: true,\n\t\t\t\t\tfieldName: options.account?.fields?.updatedAt || \"updatedAt\",\n\t\t\t\t\tonUpdate: () => new Date(),\n\t\t\t\t},\n\t\t\t\t...account?.fields,\n\t\t\t\t...options.account?.additionalFields,\n\t\t\t},\n\t\t\torder: 3,\n\t\t},\n\t\t...(!options.secondaryStorage || options.verification?.storeInDatabase\n\t\t\t? verificationTable\n\t\t\t: {}),\n\t\t...pluginTables,\n\t\t...(shouldAddRateLimitTable ? rateLimitTable : {}),\n\t} satisfies BetterAuthDBSchema;\n};\n"],"mappings":";AAGA,MAAa,iBACZ,YACwB;CACxB,MAAM,gBAAgB,QAAQ,WAAW,EAAE,EAAE,QAC3C,KAAK,WAAW;EAChB,MAAM,SAAS,OAAO;AACtB,MAAI,CAAC,OAAQ,QAAO;AACpB,OAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,OAAO,CAChD,KAAI,OAAO;GACV,QAAQ;IACP,GAAG,IAAI,MAAM;IACb,GAAG,MAAM;IACT;GACD,WAAW,MAAM,aAAa;GAC9B;AAEF,SAAO;IAER,EAAE,CAIF;CAED,MAAM,0BAA0B,QAAQ,WAAW,YAAY;CAC/D,MAAM,iBAAiB,EACtB,WAAW;EACV,WAAW,QAAQ,WAAW,aAAa;EAC3C,QAAQ;GACP,KAAK;IACJ,MAAM;IACN,QAAQ;IACR,UAAU;IACV,WAAW,QAAQ,WAAW,QAAQ,OAAO;IAC7C;GACD,OAAO;IACN,MAAM;IACN,UAAU;IACV,WAAW,QAAQ,WAAW,QAAQ,SAAS;IAC/C;GACD,aAAa;IACZ,MAAM;IACN,QAAQ;IACR,UAAU;IACV,WAAW,QAAQ,WAAW,QAAQ,eAAe;IACrD,oBAAoB,KAAK,KAAK;IAC9B;GACD;EAC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11
  updatedAt: z.ZodDefault<z.ZodDate>;
12
12
  email: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
13
13
  emailVerified: z.ZodDefault<z.ZodBoolean>;
14
- name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
14
+ name: z.ZodString;
15
15
  image: z.ZodOptional<z.ZodNullable<z.ZodString>>;
16
16
  }, z.core.$strip>;
17
17
  type BaseUser = z.infer<typeof userSchema>;
@@ -5,7 +5,7 @@ import * as z from "zod";
5
5
  const userSchema = coreSchema.extend({
6
6
  email: z.string().transform((val) => val.toLowerCase()),
7
7
  emailVerified: z.boolean().default(false),
8
- name: z.string().nullish(),
8
+ name: z.string(),
9
9
  image: z.string().nullish()
10
10
  });
11
11
 
@@ -1 +1 @@
1
- {"version":3,"file":"user.mjs","names":[],"sources":["../../../src/db/schema/user.ts"],"sourcesContent":["import * as z from \"zod\";\nimport type { BetterAuthOptions, Prettify } from \"../../types\";\nimport type {\n\tInferDBFieldsFromOptions,\n\tInferDBFieldsFromPlugins,\n} from \"../type\";\nimport { coreSchema } from \"./shared\";\n\nexport const userSchema = coreSchema.extend({\n\temail: z.string().transform((val) => val.toLowerCase()),\n\temailVerified: z.boolean().default(false),\n\tname: z.string().nullish(),\n\timage: z.string().nullish(),\n});\n\nexport type BaseUser = z.infer<typeof userSchema>;\n\n/**\n * User schema type used by better-auth, note that it's possible that user could have additional fields\n */\nexport type User<\n\tDBOptions extends BetterAuthOptions[\"user\"] = BetterAuthOptions[\"user\"],\n\tPlugins extends BetterAuthOptions[\"plugins\"] = BetterAuthOptions[\"plugins\"],\n> = Prettify<\n\tBaseUser &\n\t\tInferDBFieldsFromOptions<DBOptions> &\n\t\tInferDBFieldsFromPlugins<\"user\", Plugins>\n>;\n"],"mappings":";;;;AAQA,MAAa,aAAa,WAAW,OAAO;CAC3C,OAAO,EAAE,QAAQ,CAAC,WAAW,QAAQ,IAAI,aAAa,CAAC;CACvD,eAAe,EAAE,SAAS,CAAC,QAAQ,MAAM;CACzC,MAAM,EAAE,QAAQ,CAAC,SAAS;CAC1B,OAAO,EAAE,QAAQ,CAAC,SAAS;CAC3B,CAAC"}
1
+ {"version":3,"file":"user.mjs","names":[],"sources":["../../../src/db/schema/user.ts"],"sourcesContent":["import * as z from \"zod\";\nimport type { BetterAuthOptions, Prettify } from \"../../types\";\nimport type {\n\tInferDBFieldsFromOptions,\n\tInferDBFieldsFromPlugins,\n} from \"../type\";\nimport { coreSchema } from \"./shared\";\n\nexport const userSchema = coreSchema.extend({\n\temail: z.string().transform((val) => val.toLowerCase()),\n\temailVerified: z.boolean().default(false),\n\tname: z.string(),\n\timage: z.string().nullish(),\n});\n\nexport type BaseUser = z.infer<typeof userSchema>;\n\n/**\n * User schema type used by better-auth, note that it's possible that user could have additional fields\n */\nexport type User<\n\tDBOptions extends BetterAuthOptions[\"user\"] = BetterAuthOptions[\"user\"],\n\tPlugins extends BetterAuthOptions[\"plugins\"] = BetterAuthOptions[\"plugins\"],\n> = Prettify<\n\tBaseUser &\n\t\tInferDBFieldsFromOptions<DBOptions> &\n\t\tInferDBFieldsFromPlugins<\"user\", Plugins>\n>;\n"],"mappings":";;;;AAQA,MAAa,aAAa,WAAW,OAAO;CAC3C,OAAO,EAAE,QAAQ,CAAC,WAAW,QAAQ,IAAI,aAAa,CAAC;CACvD,eAAe,EAAE,SAAS,CAAC,QAAQ,MAAM;CACzC,MAAM,EAAE,QAAQ;CAChB,OAAO,EAAE,QAAQ,CAAC,SAAS;CAC3B,CAAC"}
package/dist/index.d.mts CHANGED
@@ -1,8 +1,8 @@
1
- import { Awaitable, LiteralString, LiteralUnion, Prettify, Primitive, UnionToIntersection } from "./types/helper.mjs";
1
+ import { Awaitable, AwaitableFunction, LiteralString, LiteralUnion, Prettify, Primitive, UnionToIntersection } from "./types/helper.mjs";
2
2
  import { BetterAuthPlugin, BetterAuthPluginErrorCodePart, HookEndpointContext } from "./types/plugin.mjs";
3
3
  import { BetterAuthAdvancedOptions, BetterAuthDBOptions, BetterAuthOptions, BetterAuthRateLimitOptions, BetterAuthRateLimitRule, BetterAuthRateLimitStorage, GenerateIdFn, StoreIdentifierOption } from "./types/init-options.mjs";
4
4
  import { BetterAuthCookie, BetterAuthCookies } from "./types/cookie.mjs";
5
5
  import { AuthContext, BetterAuthPluginRegistry, BetterAuthPluginRegistryIdentifier, GenericEndpointContext, InfoContext, InternalAdapter, PluginContext } from "./types/context.mjs";
6
6
  import { BetterAuthClientOptions, BetterAuthClientPlugin, ClientAtomListener, ClientFetchOption, ClientStore } from "./types/plugin-client.mjs";
7
7
  import { StandardSchemaV1 } from "./types/index.mjs";
8
- export { AuthContext, Awaitable, BetterAuthAdvancedOptions, BetterAuthClientOptions, BetterAuthClientPlugin, BetterAuthCookie, BetterAuthCookies, BetterAuthDBOptions, BetterAuthOptions, BetterAuthPlugin, BetterAuthPluginErrorCodePart, BetterAuthPluginRegistry, BetterAuthPluginRegistryIdentifier, BetterAuthRateLimitOptions, BetterAuthRateLimitRule, BetterAuthRateLimitStorage, ClientAtomListener, ClientFetchOption, ClientStore, GenerateIdFn, GenericEndpointContext, HookEndpointContext, InfoContext, InternalAdapter, LiteralString, LiteralUnion, PluginContext, Prettify, Primitive, StandardSchemaV1, StoreIdentifierOption, UnionToIntersection };
8
+ export { AuthContext, Awaitable, AwaitableFunction, BetterAuthAdvancedOptions, BetterAuthClientOptions, BetterAuthClientPlugin, BetterAuthCookie, BetterAuthCookies, BetterAuthDBOptions, BetterAuthOptions, BetterAuthPlugin, BetterAuthPluginErrorCodePart, BetterAuthPluginRegistry, BetterAuthPluginRegistryIdentifier, BetterAuthRateLimitOptions, BetterAuthRateLimitRule, BetterAuthRateLimitStorage, ClientAtomListener, ClientFetchOption, ClientStore, GenerateIdFn, GenericEndpointContext, HookEndpointContext, InfoContext, InternalAdapter, LiteralString, LiteralUnion, PluginContext, Prettify, Primitive, StandardSchemaV1, StoreIdentifierOption, UnionToIntersection };
@@ -1,6 +1,27 @@
1
+ import { AwaitableFunction } from "../types/helper.mjs";
2
+ import "../types/index.mjs";
1
3
  import { OAuth2Tokens, ProviderOptions } from "./oauth-provider.mjs";
2
4
 
3
5
  //#region src/oauth2/client-credentials-token.d.ts
6
+ declare function clientCredentialsTokenRequest({
7
+ options,
8
+ scope,
9
+ authentication,
10
+ resource
11
+ }: {
12
+ options: AwaitableFunction<ProviderOptions & {
13
+ clientSecret: string;
14
+ }>;
15
+ scope?: string | undefined;
16
+ authentication?: ("basic" | "post") | undefined;
17
+ resource?: (string | string[]) | undefined;
18
+ }): Promise<{
19
+ body: URLSearchParams;
20
+ headers: Record<string, any>;
21
+ }>;
22
+ /**
23
+ * @deprecated use async'd clientCredentialsTokenRequest instead
24
+ */
4
25
  declare function createClientCredentialsTokenRequest({
5
26
  options,
6
27
  scope,
@@ -24,14 +45,14 @@ declare function clientCredentialsToken({
24
45
  authentication,
25
46
  resource
26
47
  }: {
27
- options: ProviderOptions & {
48
+ options: AwaitableFunction<ProviderOptions & {
28
49
  clientSecret: string;
29
- };
50
+ }>;
30
51
  tokenEndpoint: string;
31
52
  scope: string;
32
53
  authentication?: ("basic" | "post") | undefined;
33
54
  resource?: (string | string[]) | undefined;
34
55
  }): Promise<OAuth2Tokens>;
35
56
  //#endregion
36
- export { clientCredentialsToken, createClientCredentialsTokenRequest };
57
+ export { clientCredentialsToken, clientCredentialsTokenRequest, createClientCredentialsTokenRequest };
37
58
  //# sourceMappingURL=client-credentials-token.d.mts.map
@@ -2,6 +2,18 @@ import { base64Url } from "@better-auth/utils/base64";
2
2
  import { betterFetch } from "@better-fetch/fetch";
3
3
 
4
4
  //#region src/oauth2/client-credentials-token.ts
5
+ async function clientCredentialsTokenRequest({ options, scope, authentication, resource }) {
6
+ options = typeof options === "function" ? await options() : options;
7
+ return createClientCredentialsTokenRequest({
8
+ options,
9
+ scope,
10
+ authentication,
11
+ resource
12
+ });
13
+ }
14
+ /**
15
+ * @deprecated use async'd clientCredentialsTokenRequest instead
16
+ */
5
17
  function createClientCredentialsTokenRequest({ options, scope, authentication, resource }) {
6
18
  const body = new URLSearchParams();
7
19
  const headers = {
@@ -26,7 +38,7 @@ function createClientCredentialsTokenRequest({ options, scope, authentication, r
26
38
  };
27
39
  }
28
40
  async function clientCredentialsToken({ options, tokenEndpoint, scope, authentication, resource }) {
29
- const { body, headers } = createClientCredentialsTokenRequest({
41
+ const { body, headers } = await clientCredentialsTokenRequest({
30
42
  options,
31
43
  scope,
32
44
  authentication,
@@ -51,5 +63,5 @@ async function clientCredentialsToken({ options, tokenEndpoint, scope, authentic
51
63
  }
52
64
 
53
65
  //#endregion
54
- export { clientCredentialsToken, createClientCredentialsTokenRequest };
66
+ export { clientCredentialsToken, clientCredentialsTokenRequest, createClientCredentialsTokenRequest };
55
67
  //# sourceMappingURL=client-credentials-token.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"client-credentials-token.mjs","names":[],"sources":["../../src/oauth2/client-credentials-token.ts"],"sourcesContent":["import { base64Url } from \"@better-auth/utils/base64\";\nimport { betterFetch } from \"@better-fetch/fetch\";\nimport type { OAuth2Tokens, ProviderOptions } from \"./oauth-provider\";\n\nexport function createClientCredentialsTokenRequest({\n\toptions,\n\tscope,\n\tauthentication,\n\tresource,\n}: {\n\toptions: ProviderOptions & { clientSecret: string };\n\tscope?: string | undefined;\n\tauthentication?: (\"basic\" | \"post\") | undefined;\n\tresource?: (string | string[]) | undefined;\n}) {\n\tconst body = new URLSearchParams();\n\tconst headers: Record<string, any> = {\n\t\t\"content-type\": \"application/x-www-form-urlencoded\",\n\t\taccept: \"application/json\",\n\t};\n\n\tbody.set(\"grant_type\", \"client_credentials\");\n\tscope && body.set(\"scope\", scope);\n\tif (resource) {\n\t\tif (typeof resource === \"string\") {\n\t\t\tbody.append(\"resource\", resource);\n\t\t} else {\n\t\t\tfor (const _resource of resource) {\n\t\t\t\tbody.append(\"resource\", _resource);\n\t\t\t}\n\t\t}\n\t}\n\tif (authentication === \"basic\") {\n\t\tconst primaryClientId = Array.isArray(options.clientId)\n\t\t\t? options.clientId[0]\n\t\t\t: options.clientId;\n\t\tconst encodedCredentials = base64Url.encode(\n\t\t\t`${primaryClientId}:${options.clientSecret}`,\n\t\t);\n\t\theaders[\"authorization\"] = `Basic ${encodedCredentials}`;\n\t} else {\n\t\tconst primaryClientId = Array.isArray(options.clientId)\n\t\t\t? options.clientId[0]\n\t\t\t: options.clientId;\n\t\tbody.set(\"client_id\", primaryClientId);\n\t\tbody.set(\"client_secret\", options.clientSecret);\n\t}\n\n\treturn {\n\t\tbody,\n\t\theaders,\n\t};\n}\n\nexport async function clientCredentialsToken({\n\toptions,\n\ttokenEndpoint,\n\tscope,\n\tauthentication,\n\tresource,\n}: {\n\toptions: ProviderOptions & { clientSecret: string };\n\ttokenEndpoint: string;\n\tscope: string;\n\tauthentication?: (\"basic\" | \"post\") | undefined;\n\tresource?: (string | string[]) | undefined;\n}): Promise<OAuth2Tokens> {\n\tconst { body, headers } = createClientCredentialsTokenRequest({\n\t\toptions,\n\t\tscope,\n\t\tauthentication,\n\t\tresource,\n\t});\n\n\tconst { data, error } = await betterFetch<{\n\t\taccess_token: string;\n\t\texpires_in?: number | undefined;\n\t\ttoken_type?: string | undefined;\n\t\tscope?: string | undefined;\n\t}>(tokenEndpoint, {\n\t\tmethod: \"POST\",\n\t\tbody,\n\t\theaders,\n\t});\n\tif (error) {\n\t\tthrow error;\n\t}\n\tconst tokens: OAuth2Tokens = {\n\t\taccessToken: data.access_token,\n\t\ttokenType: data.token_type,\n\t\tscopes: data.scope?.split(\" \"),\n\t};\n\n\tif (data.expires_in) {\n\t\tconst now = new Date();\n\t\ttokens.accessTokenExpiresAt = new Date(\n\t\t\tnow.getTime() + data.expires_in * 1000,\n\t\t);\n\t}\n\n\treturn tokens;\n}\n"],"mappings":";;;;AAIA,SAAgB,oCAAoC,EACnD,SACA,OACA,gBACA,YAME;CACF,MAAM,OAAO,IAAI,iBAAiB;CAClC,MAAM,UAA+B;EACpC,gBAAgB;EAChB,QAAQ;EACR;AAED,MAAK,IAAI,cAAc,qBAAqB;AAC5C,UAAS,KAAK,IAAI,SAAS,MAAM;AACjC,KAAI,SACH,KAAI,OAAO,aAAa,SACvB,MAAK,OAAO,YAAY,SAAS;KAEjC,MAAK,MAAM,aAAa,SACvB,MAAK,OAAO,YAAY,UAAU;AAIrC,KAAI,mBAAmB,SAAS;EAC/B,MAAM,kBAAkB,MAAM,QAAQ,QAAQ,SAAS,GACpD,QAAQ,SAAS,KACjB,QAAQ;AAIX,UAAQ,mBAAmB,SAHA,UAAU,OACpC,GAAG,gBAAgB,GAAG,QAAQ,eAC9B;QAEK;EACN,MAAM,kBAAkB,MAAM,QAAQ,QAAQ,SAAS,GACpD,QAAQ,SAAS,KACjB,QAAQ;AACX,OAAK,IAAI,aAAa,gBAAgB;AACtC,OAAK,IAAI,iBAAiB,QAAQ,aAAa;;AAGhD,QAAO;EACN;EACA;EACA;;AAGF,eAAsB,uBAAuB,EAC5C,SACA,eACA,OACA,gBACA,YAOyB;CACzB,MAAM,EAAE,MAAM,YAAY,oCAAoC;EAC7D;EACA;EACA;EACA;EACA,CAAC;CAEF,MAAM,EAAE,MAAM,UAAU,MAAM,YAK3B,eAAe;EACjB,QAAQ;EACR;EACA;EACA,CAAC;AACF,KAAI,MACH,OAAM;CAEP,MAAM,SAAuB;EAC5B,aAAa,KAAK;EAClB,WAAW,KAAK;EAChB,QAAQ,KAAK,OAAO,MAAM,IAAI;EAC9B;AAED,KAAI,KAAK,YAAY;EACpB,MAAM,sBAAM,IAAI,MAAM;AACtB,SAAO,uBAAuB,IAAI,KACjC,IAAI,SAAS,GAAG,KAAK,aAAa,IAClC;;AAGF,QAAO"}
1
+ {"version":3,"file":"client-credentials-token.mjs","names":[],"sources":["../../src/oauth2/client-credentials-token.ts"],"sourcesContent":["import { base64Url } from \"@better-auth/utils/base64\";\nimport { betterFetch } from \"@better-fetch/fetch\";\nimport type { AwaitableFunction } from \"../types\";\nimport type { OAuth2Tokens, ProviderOptions } from \"./oauth-provider\";\n\nexport async function clientCredentialsTokenRequest({\n\toptions,\n\tscope,\n\tauthentication,\n\tresource,\n}: {\n\toptions: AwaitableFunction<ProviderOptions & { clientSecret: string }>;\n\tscope?: string | undefined;\n\tauthentication?: (\"basic\" | \"post\") | undefined;\n\tresource?: (string | string[]) | undefined;\n}) {\n\toptions = typeof options === \"function\" ? await options() : options;\n\treturn createClientCredentialsTokenRequest({\n\t\toptions,\n\t\tscope,\n\t\tauthentication,\n\t\tresource,\n\t});\n}\n\n/**\n * @deprecated use async'd clientCredentialsTokenRequest instead\n */\nexport function createClientCredentialsTokenRequest({\n\toptions,\n\tscope,\n\tauthentication,\n\tresource,\n}: {\n\toptions: ProviderOptions & { clientSecret: string };\n\tscope?: string | undefined;\n\tauthentication?: (\"basic\" | \"post\") | undefined;\n\tresource?: (string | string[]) | undefined;\n}) {\n\tconst body = new URLSearchParams();\n\tconst headers: Record<string, any> = {\n\t\t\"content-type\": \"application/x-www-form-urlencoded\",\n\t\taccept: \"application/json\",\n\t};\n\n\tbody.set(\"grant_type\", \"client_credentials\");\n\tscope && body.set(\"scope\", scope);\n\tif (resource) {\n\t\tif (typeof resource === \"string\") {\n\t\t\tbody.append(\"resource\", resource);\n\t\t} else {\n\t\t\tfor (const _resource of resource) {\n\t\t\t\tbody.append(\"resource\", _resource);\n\t\t\t}\n\t\t}\n\t}\n\tif (authentication === \"basic\") {\n\t\tconst primaryClientId = Array.isArray(options.clientId)\n\t\t\t? options.clientId[0]\n\t\t\t: options.clientId;\n\t\tconst encodedCredentials = base64Url.encode(\n\t\t\t`${primaryClientId}:${options.clientSecret}`,\n\t\t);\n\t\theaders[\"authorization\"] = `Basic ${encodedCredentials}`;\n\t} else {\n\t\tconst primaryClientId = Array.isArray(options.clientId)\n\t\t\t? options.clientId[0]\n\t\t\t: options.clientId;\n\t\tbody.set(\"client_id\", primaryClientId);\n\t\tbody.set(\"client_secret\", options.clientSecret);\n\t}\n\n\treturn {\n\t\tbody,\n\t\theaders,\n\t};\n}\n\nexport async function clientCredentialsToken({\n\toptions,\n\ttokenEndpoint,\n\tscope,\n\tauthentication,\n\tresource,\n}: {\n\toptions: AwaitableFunction<ProviderOptions & { clientSecret: string }>;\n\ttokenEndpoint: string;\n\tscope: string;\n\tauthentication?: (\"basic\" | \"post\") | undefined;\n\tresource?: (string | string[]) | undefined;\n}): Promise<OAuth2Tokens> {\n\tconst { body, headers } = await clientCredentialsTokenRequest({\n\t\toptions,\n\t\tscope,\n\t\tauthentication,\n\t\tresource,\n\t});\n\n\tconst { data, error } = await betterFetch<{\n\t\taccess_token: string;\n\t\texpires_in?: number | undefined;\n\t\ttoken_type?: string | undefined;\n\t\tscope?: string | undefined;\n\t}>(tokenEndpoint, {\n\t\tmethod: \"POST\",\n\t\tbody,\n\t\theaders,\n\t});\n\tif (error) {\n\t\tthrow error;\n\t}\n\tconst tokens: OAuth2Tokens = {\n\t\taccessToken: data.access_token,\n\t\ttokenType: data.token_type,\n\t\tscopes: data.scope?.split(\" \"),\n\t};\n\n\tif (data.expires_in) {\n\t\tconst now = new Date();\n\t\ttokens.accessTokenExpiresAt = new Date(\n\t\t\tnow.getTime() + data.expires_in * 1000,\n\t\t);\n\t}\n\n\treturn tokens;\n}\n"],"mappings":";;;;AAKA,eAAsB,8BAA8B,EACnD,SACA,OACA,gBACA,YAME;AACF,WAAU,OAAO,YAAY,aAAa,MAAM,SAAS,GAAG;AAC5D,QAAO,oCAAoC;EAC1C;EACA;EACA;EACA;EACA,CAAC;;;;;AAMH,SAAgB,oCAAoC,EACnD,SACA,OACA,gBACA,YAME;CACF,MAAM,OAAO,IAAI,iBAAiB;CAClC,MAAM,UAA+B;EACpC,gBAAgB;EAChB,QAAQ;EACR;AAED,MAAK,IAAI,cAAc,qBAAqB;AAC5C,UAAS,KAAK,IAAI,SAAS,MAAM;AACjC,KAAI,SACH,KAAI,OAAO,aAAa,SACvB,MAAK,OAAO,YAAY,SAAS;KAEjC,MAAK,MAAM,aAAa,SACvB,MAAK,OAAO,YAAY,UAAU;AAIrC,KAAI,mBAAmB,SAAS;EAC/B,MAAM,kBAAkB,MAAM,QAAQ,QAAQ,SAAS,GACpD,QAAQ,SAAS,KACjB,QAAQ;AAIX,UAAQ,mBAAmB,SAHA,UAAU,OACpC,GAAG,gBAAgB,GAAG,QAAQ,eAC9B;QAEK;EACN,MAAM,kBAAkB,MAAM,QAAQ,QAAQ,SAAS,GACpD,QAAQ,SAAS,KACjB,QAAQ;AACX,OAAK,IAAI,aAAa,gBAAgB;AACtC,OAAK,IAAI,iBAAiB,QAAQ,aAAa;;AAGhD,QAAO;EACN;EACA;EACA;;AAGF,eAAsB,uBAAuB,EAC5C,SACA,eACA,OACA,gBACA,YAOyB;CACzB,MAAM,EAAE,MAAM,YAAY,MAAM,8BAA8B;EAC7D;EACA;EACA;EACA;EACA,CAAC;CAEF,MAAM,EAAE,MAAM,UAAU,MAAM,YAK3B,eAAe;EACjB,QAAQ;EACR;EACA;EACA,CAAC;AACF,KAAI,MACH,OAAM;CAEP,MAAM,SAAuB;EAC5B,aAAa,KAAK;EAClB,WAAW,KAAK;EAChB,QAAQ,KAAK,OAAO,MAAM,IAAI;EAC9B;AAED,KAAI,KAAK,YAAY;EACpB,MAAM,sBAAM,IAAI,MAAM;AACtB,SAAO,uBAAuB,IAAI,KACjC,IAAI,SAAS,GAAG,KAAK,aAAa,IAClC;;AAGF,QAAO"}
@@ -1,3 +1,5 @@
1
+ import { AwaitableFunction } from "../types/helper.mjs";
2
+ import "../types/index.mjs";
1
3
  import { ProviderOptions } from "./oauth-provider.mjs";
2
4
  import "./index.mjs";
3
5
 
@@ -23,7 +25,7 @@ declare function createAuthorizationURL({
23
25
  scopeJoiner
24
26
  }: {
25
27
  id: string;
26
- options: ProviderOptions;
28
+ options: AwaitableFunction<ProviderOptions>;
27
29
  redirectURI: string;
28
30
  authorizationEndpoint: string;
29
31
  state: string;
@@ -2,6 +2,7 @@ import { generateCodeChallenge } from "./utils.mjs";
2
2
 
3
3
  //#region src/oauth2/create-authorization-url.ts
4
4
  async function createAuthorizationURL({ id, options, authorizationEndpoint, state, codeVerifier, scopes, claims, redirectURI, duration, prompt, accessType, responseType, display, loginHint, hd, responseMode, additionalParams, scopeJoiner }) {
5
+ options = typeof options === "function" ? await options() : options;
5
6
  const url = new URL(options.authorizationEndpoint || authorizationEndpoint);
6
7
  url.searchParams.set("response_type", responseType || "code");
7
8
  const primaryClientId = Array.isArray(options.clientId) ? options.clientId[0] : options.clientId;
@@ -1 +1 @@
1
- {"version":3,"file":"create-authorization-url.mjs","names":[],"sources":["../../src/oauth2/create-authorization-url.ts"],"sourcesContent":["import type { ProviderOptions } from \"./index\";\nimport { generateCodeChallenge } from \"./utils\";\n\nexport async function createAuthorizationURL({\n\tid,\n\toptions,\n\tauthorizationEndpoint,\n\tstate,\n\tcodeVerifier,\n\tscopes,\n\tclaims,\n\tredirectURI,\n\tduration,\n\tprompt,\n\taccessType,\n\tresponseType,\n\tdisplay,\n\tloginHint,\n\thd,\n\tresponseMode,\n\tadditionalParams,\n\tscopeJoiner,\n}: {\n\tid: string;\n\toptions: ProviderOptions;\n\tredirectURI: string;\n\tauthorizationEndpoint: string;\n\tstate: string;\n\tcodeVerifier?: string | undefined;\n\tscopes?: string[] | undefined;\n\tclaims?: string[] | undefined;\n\tduration?: string | undefined;\n\tprompt?: string | undefined;\n\taccessType?: string | undefined;\n\tresponseType?: string | undefined;\n\tdisplay?: string | undefined;\n\tloginHint?: string | undefined;\n\thd?: string | undefined;\n\tresponseMode?: string | undefined;\n\tadditionalParams?: Record<string, string> | undefined;\n\tscopeJoiner?: string | undefined;\n}) {\n\tconst url = new URL(options.authorizationEndpoint || authorizationEndpoint);\n\turl.searchParams.set(\"response_type\", responseType || \"code\");\n\tconst primaryClientId = Array.isArray(options.clientId)\n\t\t? options.clientId[0]\n\t\t: options.clientId;\n\turl.searchParams.set(\"client_id\", primaryClientId);\n\turl.searchParams.set(\"state\", state);\n\tif (scopes) {\n\t\turl.searchParams.set(\"scope\", scopes.join(scopeJoiner || \" \"));\n\t}\n\turl.searchParams.set(\"redirect_uri\", options.redirectURI || redirectURI);\n\tduration && url.searchParams.set(\"duration\", duration);\n\tdisplay && url.searchParams.set(\"display\", display);\n\tloginHint && url.searchParams.set(\"login_hint\", loginHint);\n\tprompt && url.searchParams.set(\"prompt\", prompt);\n\thd && url.searchParams.set(\"hd\", hd);\n\taccessType && url.searchParams.set(\"access_type\", accessType);\n\tresponseMode && url.searchParams.set(\"response_mode\", responseMode);\n\tif (codeVerifier) {\n\t\tconst codeChallenge = await generateCodeChallenge(codeVerifier);\n\t\turl.searchParams.set(\"code_challenge_method\", \"S256\");\n\t\turl.searchParams.set(\"code_challenge\", codeChallenge);\n\t}\n\tif (claims) {\n\t\tconst claimsObj = claims.reduce(\n\t\t\t(acc, claim) => {\n\t\t\t\tacc[claim] = null;\n\t\t\t\treturn acc;\n\t\t\t},\n\t\t\t{} as Record<string, null>,\n\t\t);\n\t\turl.searchParams.set(\n\t\t\t\"claims\",\n\t\t\tJSON.stringify({\n\t\t\t\tid_token: { email: null, email_verified: null, ...claimsObj },\n\t\t\t}),\n\t\t);\n\t}\n\tif (additionalParams) {\n\t\tObject.entries(additionalParams).forEach(([key, value]) => {\n\t\t\turl.searchParams.set(key, value);\n\t\t});\n\t}\n\treturn url;\n}\n"],"mappings":";;;AAGA,eAAsB,uBAAuB,EAC5C,IACA,SACA,uBACA,OACA,cACA,QACA,QACA,aACA,UACA,QACA,YACA,cACA,SACA,WACA,IACA,cACA,kBACA,eAoBE;CACF,MAAM,MAAM,IAAI,IAAI,QAAQ,yBAAyB,sBAAsB;AAC3E,KAAI,aAAa,IAAI,iBAAiB,gBAAgB,OAAO;CAC7D,MAAM,kBAAkB,MAAM,QAAQ,QAAQ,SAAS,GACpD,QAAQ,SAAS,KACjB,QAAQ;AACX,KAAI,aAAa,IAAI,aAAa,gBAAgB;AAClD,KAAI,aAAa,IAAI,SAAS,MAAM;AACpC,KAAI,OACH,KAAI,aAAa,IAAI,SAAS,OAAO,KAAK,eAAe,IAAI,CAAC;AAE/D,KAAI,aAAa,IAAI,gBAAgB,QAAQ,eAAe,YAAY;AACxE,aAAY,IAAI,aAAa,IAAI,YAAY,SAAS;AACtD,YAAW,IAAI,aAAa,IAAI,WAAW,QAAQ;AACnD,cAAa,IAAI,aAAa,IAAI,cAAc,UAAU;AAC1D,WAAU,IAAI,aAAa,IAAI,UAAU,OAAO;AAChD,OAAM,IAAI,aAAa,IAAI,MAAM,GAAG;AACpC,eAAc,IAAI,aAAa,IAAI,eAAe,WAAW;AAC7D,iBAAgB,IAAI,aAAa,IAAI,iBAAiB,aAAa;AACnE,KAAI,cAAc;EACjB,MAAM,gBAAgB,MAAM,sBAAsB,aAAa;AAC/D,MAAI,aAAa,IAAI,yBAAyB,OAAO;AACrD,MAAI,aAAa,IAAI,kBAAkB,cAAc;;AAEtD,KAAI,QAAQ;EACX,MAAM,YAAY,OAAO,QACvB,KAAK,UAAU;AACf,OAAI,SAAS;AACb,UAAO;KAER,EAAE,CACF;AACD,MAAI,aAAa,IAChB,UACA,KAAK,UAAU,EACd,UAAU;GAAE,OAAO;GAAM,gBAAgB;GAAM,GAAG;GAAW,EAC7D,CAAC,CACF;;AAEF,KAAI,iBACH,QAAO,QAAQ,iBAAiB,CAAC,SAAS,CAAC,KAAK,WAAW;AAC1D,MAAI,aAAa,IAAI,KAAK,MAAM;GAC/B;AAEH,QAAO"}
1
+ {"version":3,"file":"create-authorization-url.mjs","names":[],"sources":["../../src/oauth2/create-authorization-url.ts"],"sourcesContent":["import type { AwaitableFunction } from \"../types\";\nimport type { ProviderOptions } from \"./index\";\nimport { generateCodeChallenge } from \"./utils\";\n\nexport async function createAuthorizationURL({\n\tid,\n\toptions,\n\tauthorizationEndpoint,\n\tstate,\n\tcodeVerifier,\n\tscopes,\n\tclaims,\n\tredirectURI,\n\tduration,\n\tprompt,\n\taccessType,\n\tresponseType,\n\tdisplay,\n\tloginHint,\n\thd,\n\tresponseMode,\n\tadditionalParams,\n\tscopeJoiner,\n}: {\n\tid: string;\n\toptions: AwaitableFunction<ProviderOptions>;\n\tredirectURI: string;\n\tauthorizationEndpoint: string;\n\tstate: string;\n\tcodeVerifier?: string | undefined;\n\tscopes?: string[] | undefined;\n\tclaims?: string[] | undefined;\n\tduration?: string | undefined;\n\tprompt?: string | undefined;\n\taccessType?: string | undefined;\n\tresponseType?: string | undefined;\n\tdisplay?: string | undefined;\n\tloginHint?: string | undefined;\n\thd?: string | undefined;\n\tresponseMode?: string | undefined;\n\tadditionalParams?: Record<string, string> | undefined;\n\tscopeJoiner?: string | undefined;\n}) {\n\toptions = typeof options === \"function\" ? await options() : options;\n\tconst url = new URL(options.authorizationEndpoint || authorizationEndpoint);\n\turl.searchParams.set(\"response_type\", responseType || \"code\");\n\tconst primaryClientId = Array.isArray(options.clientId)\n\t\t? options.clientId[0]\n\t\t: options.clientId;\n\turl.searchParams.set(\"client_id\", primaryClientId);\n\turl.searchParams.set(\"state\", state);\n\tif (scopes) {\n\t\turl.searchParams.set(\"scope\", scopes.join(scopeJoiner || \" \"));\n\t}\n\turl.searchParams.set(\"redirect_uri\", options.redirectURI || redirectURI);\n\tduration && url.searchParams.set(\"duration\", duration);\n\tdisplay && url.searchParams.set(\"display\", display);\n\tloginHint && url.searchParams.set(\"login_hint\", loginHint);\n\tprompt && url.searchParams.set(\"prompt\", prompt);\n\thd && url.searchParams.set(\"hd\", hd);\n\taccessType && url.searchParams.set(\"access_type\", accessType);\n\tresponseMode && url.searchParams.set(\"response_mode\", responseMode);\n\tif (codeVerifier) {\n\t\tconst codeChallenge = await generateCodeChallenge(codeVerifier);\n\t\turl.searchParams.set(\"code_challenge_method\", \"S256\");\n\t\turl.searchParams.set(\"code_challenge\", codeChallenge);\n\t}\n\tif (claims) {\n\t\tconst claimsObj = claims.reduce(\n\t\t\t(acc, claim) => {\n\t\t\t\tacc[claim] = null;\n\t\t\t\treturn acc;\n\t\t\t},\n\t\t\t{} as Record<string, null>,\n\t\t);\n\t\turl.searchParams.set(\n\t\t\t\"claims\",\n\t\t\tJSON.stringify({\n\t\t\t\tid_token: { email: null, email_verified: null, ...claimsObj },\n\t\t\t}),\n\t\t);\n\t}\n\tif (additionalParams) {\n\t\tObject.entries(additionalParams).forEach(([key, value]) => {\n\t\t\turl.searchParams.set(key, value);\n\t\t});\n\t}\n\treturn url;\n}\n"],"mappings":";;;AAIA,eAAsB,uBAAuB,EAC5C,IACA,SACA,uBACA,OACA,cACA,QACA,QACA,aACA,UACA,QACA,YACA,cACA,SACA,WACA,IACA,cACA,kBACA,eAoBE;AACF,WAAU,OAAO,YAAY,aAAa,MAAM,SAAS,GAAG;CAC5D,MAAM,MAAM,IAAI,IAAI,QAAQ,yBAAyB,sBAAsB;AAC3E,KAAI,aAAa,IAAI,iBAAiB,gBAAgB,OAAO;CAC7D,MAAM,kBAAkB,MAAM,QAAQ,QAAQ,SAAS,GACpD,QAAQ,SAAS,KACjB,QAAQ;AACX,KAAI,aAAa,IAAI,aAAa,gBAAgB;AAClD,KAAI,aAAa,IAAI,SAAS,MAAM;AACpC,KAAI,OACH,KAAI,aAAa,IAAI,SAAS,OAAO,KAAK,eAAe,IAAI,CAAC;AAE/D,KAAI,aAAa,IAAI,gBAAgB,QAAQ,eAAe,YAAY;AACxE,aAAY,IAAI,aAAa,IAAI,YAAY,SAAS;AACtD,YAAW,IAAI,aAAa,IAAI,WAAW,QAAQ;AACnD,cAAa,IAAI,aAAa,IAAI,cAAc,UAAU;AAC1D,WAAU,IAAI,aAAa,IAAI,UAAU,OAAO;AAChD,OAAM,IAAI,aAAa,IAAI,MAAM,GAAG;AACpC,eAAc,IAAI,aAAa,IAAI,eAAe,WAAW;AAC7D,iBAAgB,IAAI,aAAa,IAAI,iBAAiB,aAAa;AACnE,KAAI,cAAc;EACjB,MAAM,gBAAgB,MAAM,sBAAsB,aAAa;AAC/D,MAAI,aAAa,IAAI,yBAAyB,OAAO;AACrD,MAAI,aAAa,IAAI,kBAAkB,cAAc;;AAEtD,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