@better-auth/core 1.5.0-beta.5 → 1.5.0-beta.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +26 -22
- package/dist/api/index.d.mts +10 -20
- package/dist/context/endpoint-context.mjs +7 -3
- package/dist/context/global.d.mts +7 -0
- package/dist/context/global.mjs +37 -0
- package/dist/context/index.d.mts +2 -1
- package/dist/context/index.mjs +2 -20
- package/dist/context/request-state.mjs +7 -3
- package/dist/context/transaction.d.mts +1 -1
- package/dist/context/transaction.mjs +7 -3
- package/dist/db/adapter/factory.mjs +13 -13
- package/dist/db/adapter/get-default-model-name.mjs +1 -1
- package/dist/db/adapter/get-id-field.d.mts +1 -1
- package/dist/db/adapter/get-id-field.mjs +2 -2
- package/dist/error/index.d.mts +3 -1
- package/dist/error/index.mjs +2 -3
- package/dist/index.d.mts +4 -4
- package/dist/social-providers/apple.mjs +3 -1
- package/dist/social-providers/gitlab.mjs +1 -1
- package/dist/types/context.d.mts +17 -16
- package/dist/types/cookie.d.mts +9 -17
- package/dist/types/index.d.mts +3 -3
- package/dist/types/init-options.d.mts +17 -29
- package/dist/utils/url.d.mts +20 -0
- package/dist/utils/url.mjs +32 -0
- package/package.json +1 -1
- package/src/context/endpoint-context.ts +7 -6
- package/src/context/global.ts +57 -0
- package/src/context/index.ts +1 -29
- package/src/context/request-state.ts +7 -6
- package/src/context/transaction.ts +7 -7
- package/src/db/adapter/factory.ts +13 -13
- package/src/db/adapter/get-default-model-name.ts +1 -1
- package/src/db/adapter/get-id-field.ts +2 -2
- package/src/error/index.ts +2 -3
- package/src/social-providers/apple.ts +12 -3
- package/src/social-providers/gitlab.ts +1 -1
- package/src/types/context.ts +137 -131
- package/src/types/cookie.ts +6 -4
- package/src/types/index.ts +4 -1
- package/src/types/init-options.ts +26 -32
- package/src/utils/url.ts +43 -0
- package/tsdown.config.ts +8 -0
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
|
|
2
|
-
> @better-auth/core@1.5.0-beta.
|
|
2
|
+
> @better-auth/core@1.5.0-beta.7 build /home/runner/work/better-auth/better-auth/packages/core
|
|
3
3
|
> tsdown
|
|
4
4
|
|
|
5
5
|
[34mℹ[39m tsdown [2mv0.19.0[22m powered by rolldown [2mv1.0.0-beta.59[22m
|
|
6
6
|
[34mℹ[39m config file: [4m/home/runner/work/better-auth/better-auth/packages/core/tsdown.config.ts[24m
|
|
7
|
-
[34mℹ[39m entry: [34msrc/index.ts, src/api/index.ts, src/async_hooks/index.ts, src/async_hooks/pure.index.ts, src/context/index.ts, src/db/index.ts, src/env/index.ts, src/error/index.ts, src/oauth2/index.ts, src/social-providers/index.ts, src/utils/deprecate.ts, src/utils/error-codes.ts, src/utils/id.ts, src/utils/json.ts, src/utils/string.ts, src/db/adapter/index.ts[39m
|
|
7
|
+
[34mℹ[39m entry: [34msrc/index.ts, src/api/index.ts, src/async_hooks/index.ts, src/async_hooks/pure.index.ts, src/context/index.ts, src/db/index.ts, src/env/index.ts, src/error/index.ts, src/oauth2/index.ts, src/social-providers/index.ts, src/utils/deprecate.ts, src/utils/error-codes.ts, src/utils/id.ts, src/utils/json.ts, src/utils/string.ts, src/utils/url.ts, src/db/adapter/index.ts[39m
|
|
8
8
|
[34mℹ[39m tsconfig: [34mtsconfig.json[39m
|
|
9
9
|
[34mℹ[39m Build start
|
|
10
10
|
[34mℹ[39m [2mdist/[22m[1msocial-providers/index.mjs[22m [2m 2.32 kB[22m [2m│ gzip: 0.72 kB[22m
|
|
11
|
-
[34mℹ[39m [2mdist/[22m[1mcontext/index.mjs[22m [2m 1.70 kB[22m [2m│ gzip: 0.68 kB[22m
|
|
12
11
|
[34mℹ[39m [2mdist/[22m[1mapi/index.mjs[22m [2m 1.27 kB[22m [2m│ gzip: 0.48 kB[22m
|
|
12
|
+
[34mℹ[39m [2mdist/[22m[1mutils/url.mjs[22m [2m 1.14 kB[22m [2m│ gzip: 0.51 kB[22m
|
|
13
13
|
[34mℹ[39m [2mdist/[22m[1masync_hooks/index.mjs[22m [2m 1.03 kB[22m [2m│ gzip: 0.54 kB[22m
|
|
14
14
|
[34mℹ[39m [2mdist/[22m[1masync_hooks/pure.index.mjs[22m [2m 0.99 kB[22m [2m│ gzip: 0.49 kB[22m
|
|
15
15
|
[34mℹ[39m [2mdist/[22m[1moauth2/index.mjs[22m [2m 0.87 kB[22m [2m│ gzip: 0.27 kB[22m
|
|
16
|
+
[34mℹ[39m [2mdist/[22m[1mcontext/index.mjs[22m [2m 0.79 kB[22m [2m│ gzip: 0.23 kB[22m
|
|
16
17
|
[34mℹ[39m [2mdist/[22m[1mdb/adapter/index.mjs[22m [2m 0.71 kB[22m [2m│ gzip: 0.22 kB[22m
|
|
17
|
-
[34mℹ[39m [2mdist/[22m[1merror/index.mjs[22m [2m 0.
|
|
18
|
+
[34mℹ[39m [2mdist/[22m[1merror/index.mjs[22m [2m 0.69 kB[22m [2m│ gzip: 0.33 kB[22m
|
|
18
19
|
[34mℹ[39m [2mdist/[22m[1mutils/json.mjs[22m [2m 0.59 kB[22m [2m│ gzip: 0.35 kB[22m
|
|
19
20
|
[34mℹ[39m [2mdist/[22m[1mdb/index.mjs[22m [2m 0.50 kB[22m [2m│ gzip: 0.18 kB[22m
|
|
20
21
|
[34mℹ[39m [2mdist/[22m[1menv/index.mjs[22m [2m 0.43 kB[22m [2m│ gzip: 0.21 kB[22m
|
|
@@ -23,13 +24,13 @@
|
|
|
23
24
|
[34mℹ[39m [2mdist/[22m[1mutils/id.mjs[22m [2m 0.24 kB[22m [2m│ gzip: 0.18 kB[22m
|
|
24
25
|
[34mℹ[39m [2mdist/[22m[1mutils/string.mjs[22m [2m 0.17 kB[22m [2m│ gzip: 0.14 kB[22m
|
|
25
26
|
[34mℹ[39m [2mdist/[22m[1mindex.mjs[22m [2m 0.01 kB[22m [2m│ gzip: 0.03 kB[22m
|
|
26
|
-
[34mℹ[39m [2mdist/[22mdb/adapter/factory.mjs [2m30.
|
|
27
|
+
[34mℹ[39m [2mdist/[22mdb/adapter/factory.mjs [2m30.11 kB[22m [2m│ gzip: 5.99 kB[22m
|
|
27
28
|
[34mℹ[39m [2mdist/[22mdb/get-tables.mjs [2m 6.76 kB[22m [2m│ gzip: 1.29 kB[22m
|
|
28
29
|
[34mℹ[39m [2mdist/[22msocial-providers/cognito.mjs [2m 5.90 kB[22m [2m│ gzip: 1.93 kB[22m
|
|
29
30
|
[34mℹ[39m [2mdist/[22msocial-providers/paypal.mjs [2m 5.03 kB[22m [2m│ gzip: 1.48 kB[22m
|
|
31
|
+
[34mℹ[39m [2mdist/[22msocial-providers/apple.mjs [2m 3.77 kB[22m [2m│ gzip: 1.36 kB[22m
|
|
30
32
|
[34mℹ[39m [2mdist/[22msocial-providers/google.mjs [2m 3.75 kB[22m [2m│ gzip: 1.38 kB[22m
|
|
31
33
|
[34mℹ[39m [2mdist/[22moauth2/verify.mjs [2m 3.74 kB[22m [2m│ gzip: 1.32 kB[22m
|
|
32
|
-
[34mℹ[39m [2mdist/[22msocial-providers/apple.mjs [2m 3.72 kB[22m [2m│ gzip: 1.34 kB[22m
|
|
33
34
|
[34mℹ[39m [2mdist/[22msocial-providers/facebook.mjs [2m 3.57 kB[22m [2m│ gzip: 1.27 kB[22m
|
|
34
35
|
[34mℹ[39m [2mdist/[22msocial-providers/line.mjs [2m 3.57 kB[22m [2m│ gzip: 1.20 kB[22m
|
|
35
36
|
[34mℹ[39m [2mdist/[22msocial-providers/salesforce.mjs [2m 3.50 kB[22m [2m│ gzip: 1.12 kB[22m
|
|
@@ -40,7 +41,7 @@
|
|
|
40
41
|
[34mℹ[39m [2mdist/[22menv/color-depth.mjs [2m 2.72 kB[22m [2m│ gzip: 0.99 kB[22m
|
|
41
42
|
[34mℹ[39m [2mdist/[22msocial-providers/figma.mjs [2m 2.71 kB[22m [2m│ gzip: 0.98 kB[22m
|
|
42
43
|
[34mℹ[39m [2mdist/[22msocial-providers/paybin.mjs [2m 2.65 kB[22m [2m│ gzip: 0.97 kB[22m
|
|
43
|
-
[34mℹ[39m [2mdist/[22msocial-providers/gitlab.mjs [2m 2.
|
|
44
|
+
[34mℹ[39m [2mdist/[22msocial-providers/gitlab.mjs [2m 2.65 kB[22m [2m│ gzip: 0.96 kB[22m
|
|
44
45
|
[34mℹ[39m [2mdist/[22mdb/adapter/get-id-field.mjs [2m 2.63 kB[22m [2m│ gzip: 0.98 kB[22m
|
|
45
46
|
[34mℹ[39m [2mdist/[22msocial-providers/reddit.mjs [2m 2.63 kB[22m [2m│ gzip: 1.01 kB[22m
|
|
46
47
|
[34mℹ[39m [2mdist/[22msocial-providers/discord.mjs [2m 2.62 kB[22m [2m│ gzip: 1.04 kB[22m
|
|
@@ -68,15 +69,16 @@
|
|
|
68
69
|
[34mℹ[39m [2mdist/[22msocial-providers/vercel.mjs [2m 1.91 kB[22m [2m│ gzip: 0.74 kB[22m
|
|
69
70
|
[34mℹ[39m [2mdist/[22moauth2/create-authorization-url.mjs [2m 1.86 kB[22m [2m│ gzip: 0.73 kB[22m
|
|
70
71
|
[34mℹ[39m [2mdist/[22moauth2/client-credentials-token.mjs [2m 1.83 kB[22m [2m│ gzip: 0.77 kB[22m
|
|
71
|
-
[34mℹ[39m [2mdist/[22mcontext/request-state.mjs [2m 1.
|
|
72
|
-
[34mℹ[39m [2mdist/[22mcontext/transaction.mjs [2m 1.
|
|
72
|
+
[34mℹ[39m [2mdist/[22mcontext/request-state.mjs [2m 1.63 kB[22m [2m│ gzip: 0.59 kB[22m
|
|
73
|
+
[34mℹ[39m [2mdist/[22mcontext/transaction.mjs [2m 1.60 kB[22m [2m│ gzip: 0.55 kB[22m
|
|
73
74
|
[34mℹ[39m [2mdist/[22mdb/adapter/get-default-field-name.mjs [2m 1.41 kB[22m [2m│ gzip: 0.66 kB[22m
|
|
74
|
-
[34mℹ[39m [2mdist/[22mdb/adapter/get-default-model-name.mjs [2m 1.
|
|
75
|
+
[34mℹ[39m [2mdist/[22mdb/adapter/get-default-model-name.mjs [2m 1.40 kB[22m [2m│ gzip: 0.65 kB[22m
|
|
76
|
+
[34mℹ[39m [2mdist/[22mcontext/endpoint-context.mjs [2m 1.31 kB[22m [2m│ gzip: 0.53 kB[22m
|
|
75
77
|
[34mℹ[39m [2mdist/[22mdb/adapter/get-field-attributes.mjs [2m 1.26 kB[22m [2m│ gzip: 0.46 kB[22m
|
|
76
78
|
[34mℹ[39m [2mdist/[22mdb/adapter/utils.mjs [2m 1.15 kB[22m [2m│ gzip: 0.46 kB[22m
|
|
77
|
-
[34mℹ[39m [2mdist/[22mcontext/endpoint-context.mjs [2m 1.11 kB[22m [2m│ gzip: 0.48 kB[22m
|
|
78
79
|
[34mℹ[39m [2mdist/[22mdb/adapter/get-field-name.mjs [2m 1.07 kB[22m [2m│ gzip: 0.47 kB[22m
|
|
79
80
|
[34mℹ[39m [2mdist/[22moauth2/utils.mjs [2m 0.98 kB[22m [2m│ gzip: 0.50 kB[22m
|
|
81
|
+
[34mℹ[39m [2mdist/[22mcontext/global.mjs [2m 0.96 kB[22m [2m│ gzip: 0.48 kB[22m
|
|
80
82
|
[34mℹ[39m [2mdist/[22mdb/adapter/get-model-name.mjs [2m 0.89 kB[22m [2m│ gzip: 0.42 kB[22m
|
|
81
83
|
[34mℹ[39m [2mdist/[22mdb/schema/account.mjs [2m 0.52 kB[22m [2m│ gzip: 0.24 kB[22m
|
|
82
84
|
[34mℹ[39m [2mdist/[22mdb/schema/user.mjs [2m 0.33 kB[22m [2m│ gzip: 0.23 kB[22m
|
|
@@ -86,13 +88,14 @@
|
|
|
86
88
|
[34mℹ[39m [2mdist/[22mdb/schema/rate-limit.mjs [2m 0.21 kB[22m [2m│ gzip: 0.17 kB[22m
|
|
87
89
|
[34mℹ[39m [2mdist/[22m[32m[1msocial-providers/index.d.mts[22m[39m [2m45.59 kB[22m [2m│ gzip: 3.09 kB[22m
|
|
88
90
|
[34mℹ[39m [2mdist/[22m[32m[1mdb/adapter/index.d.mts[22m[39m [2m15.17 kB[22m [2m│ gzip: 3.60 kB[22m
|
|
89
|
-
[34mℹ[39m [2mdist/[22m[32m[1mapi/index.d.mts[22m[39m [2m 7.
|
|
90
|
-
[34mℹ[39m [2mdist/[22m[32m[1mindex.d.mts[22m[39m [2m 1.
|
|
91
|
+
[34mℹ[39m [2mdist/[22m[32m[1mapi/index.d.mts[22m[39m [2m 7.54 kB[22m [2m│ gzip: 1.45 kB[22m
|
|
92
|
+
[34mℹ[39m [2mdist/[22m[32m[1mindex.d.mts[22m[39m [2m 1.36 kB[22m [2m│ gzip: 0.38 kB[22m
|
|
91
93
|
[34mℹ[39m [2mdist/[22m[32m[1moauth2/index.d.mts[22m[39m [2m 1.05 kB[22m [2m│ gzip: 0.32 kB[22m
|
|
92
94
|
[34mℹ[39m [2mdist/[22m[32m[1mdb/index.d.mts[22m[39m [2m 1.04 kB[22m [2m│ gzip: 0.34 kB[22m
|
|
95
|
+
[34mℹ[39m [2mdist/[22m[32m[1mcontext/index.d.mts[22m[39m [2m 0.92 kB[22m [2m│ gzip: 0.27 kB[22m
|
|
93
96
|
[34mℹ[39m [2mdist/[22m[32m[1mutils/error-codes.d.mts[22m[39m [2m 0.89 kB[22m [2m│ gzip: 0.45 kB[22m
|
|
94
|
-
[34mℹ[39m [2mdist/[22m[32m[
|
|
95
|
-
[34mℹ[39m [2mdist/[22m[32m[1merror/index.d.mts[22m[39m [2m 0.
|
|
97
|
+
[34mℹ[39m [2mdist/[22m[32m[1mutils/url.d.mts[22m[39m [2m 0.84 kB[22m [2m│ gzip: 0.40 kB[22m
|
|
98
|
+
[34mℹ[39m [2mdist/[22m[32m[1merror/index.d.mts[22m[39m [2m 0.75 kB[22m [2m│ gzip: 0.34 kB[22m
|
|
96
99
|
[34mℹ[39m [2mdist/[22m[32m[1menv/index.d.mts[22m[39m [2m 0.58 kB[22m [2m│ gzip: 0.27 kB[22m
|
|
97
100
|
[34mℹ[39m [2mdist/[22m[32m[1mutils/deprecate.d.mts[22m[39m [2m 0.30 kB[22m [2m│ gzip: 0.22 kB[22m
|
|
98
101
|
[34mℹ[39m [2mdist/[22m[32m[1masync_hooks/index.d.mts[22m[39m [2m 0.24 kB[22m [2m│ gzip: 0.16 kB[22m
|
|
@@ -100,8 +103,8 @@
|
|
|
100
103
|
[34mℹ[39m [2mdist/[22m[32m[1mutils/string.d.mts[22m[39m [2m 0.14 kB[22m [2m│ gzip: 0.12 kB[22m
|
|
101
104
|
[34mℹ[39m [2mdist/[22m[32m[1mutils/json.d.mts[22m[39m [2m 0.13 kB[22m [2m│ gzip: 0.13 kB[22m
|
|
102
105
|
[34mℹ[39m [2mdist/[22m[32m[1mutils/id.d.mts[22m[39m [2m 0.12 kB[22m [2m│ gzip: 0.12 kB[22m
|
|
103
|
-
[34mℹ[39m [2mdist/[22m[32mtypes/init-options.d.mts[39m [2m38.
|
|
104
|
-
[34mℹ[39m [2mdist/[22m[32mtypes/context.d.mts[39m [
|
|
106
|
+
[34mℹ[39m [2mdist/[22m[32mtypes/init-options.d.mts[39m [2m38.16 kB[22m [2m│ gzip: 8.49 kB[22m
|
|
107
|
+
[34mℹ[39m [2mdist/[22m[32mtypes/context.d.mts[39m [2m10.12 kB[22m [2m│ gzip: 2.96 kB[22m
|
|
105
108
|
[34mℹ[39m [2mdist/[22m[32msocial-providers/zoom.d.mts[39m [2m 6.71 kB[22m [2m│ gzip: 2.29 kB[22m
|
|
106
109
|
[34mℹ[39m [2mdist/[22m[32moauth2/oauth-provider.d.mts[39m [2m 5.92 kB[22m [2m│ gzip: 1.67 kB[22m
|
|
107
110
|
[34mℹ[39m [2mdist/[22m[32msocial-providers/microsoft-entra-id.d.mts[39m [2m 5.59 kB[22m [2m│ gzip: 1.96 kB[22m
|
|
@@ -153,14 +156,14 @@
|
|
|
153
156
|
[34mℹ[39m [2mdist/[22m[32moauth2/refresh-access-token.d.mts[39m [2m 1.01 kB[22m [2m│ gzip: 0.41 kB[22m
|
|
154
157
|
[34mℹ[39m [2mdist/[22m[32mcontext/endpoint-context.d.mts[39m [2m 0.99 kB[22m [2m│ gzip: 0.43 kB[22m
|
|
155
158
|
[34mℹ[39m [2mdist/[22m[32moauth2/client-credentials-token.d.mts[39m [2m 0.91 kB[22m [2m│ gzip: 0.36 kB[22m
|
|
156
|
-
[34mℹ[39m [2mdist/[22m[32mcontext/transaction.d.mts[39m [2m 0.
|
|
157
|
-
[34mℹ[39m [2mdist/[22m[32mtypes/index.d.mts[39m [2m 0.
|
|
159
|
+
[34mℹ[39m [2mdist/[22m[32mcontext/transaction.d.mts[39m [2m 0.86 kB[22m [2m│ gzip: 0.38 kB[22m
|
|
160
|
+
[34mℹ[39m [2mdist/[22m[32mtypes/index.d.mts[39m [2m 0.86 kB[22m [2m│ gzip: 0.34 kB[22m
|
|
158
161
|
[34mℹ[39m [2mdist/[22m[32mdb/schema/session.d.mts[39m [2m 0.75 kB[22m [2m│ gzip: 0.40 kB[22m
|
|
159
162
|
[34mℹ[39m [2mdist/[22m[32mdb/adapter/get-field-attributes.d.mts[39m [2m 0.72 kB[22m [2m│ gzip: 0.34 kB[22m
|
|
160
163
|
[34mℹ[39m [2mdist/[22m[32mdb/schema/user.d.mts[39m [2m 0.71 kB[22m [2m│ gzip: 0.40 kB[22m
|
|
161
164
|
[34mℹ[39m [2mdist/[22m[32mdb/schema/verification.d.mts[39m [2m 0.66 kB[22m [2m│ gzip: 0.36 kB[22m
|
|
162
165
|
[34mℹ[39m [2mdist/[22m[32mtypes/helper.d.mts[39m [2m 0.45 kB[22m [2m│ gzip: 0.27 kB[22m
|
|
163
|
-
[34mℹ[39m [2mdist/[22m[32mtypes/cookie.d.mts[39m [2m 0.
|
|
166
|
+
[34mℹ[39m [2mdist/[22m[32mtypes/cookie.d.mts[39m [2m 0.38 kB[22m [2m│ gzip: 0.20 kB[22m
|
|
164
167
|
[34mℹ[39m [2mdist/[22m[32mdb/adapter/get-default-field-name.d.mts[39m [2m 0.38 kB[22m [2m│ gzip: 0.24 kB[22m
|
|
165
168
|
[34mℹ[39m [2mdist/[22m[32mdb/schema/rate-limit.d.mts[39m [2m 0.37 kB[22m [2m│ gzip: 0.25 kB[22m
|
|
166
169
|
[34mℹ[39m [2mdist/[22m[32mdb/adapter/get-field-name.d.mts[39m [2m 0.36 kB[22m [2m│ gzip: 0.23 kB[22m
|
|
@@ -171,6 +174,7 @@
|
|
|
171
174
|
[34mℹ[39m [2mdist/[22m[32mdb/adapter/get-model-name.d.mts[39m [2m 0.30 kB[22m [2m│ gzip: 0.21 kB[22m
|
|
172
175
|
[34mℹ[39m [2mdist/[22m[32mdb/get-tables.d.mts[39m [2m 0.29 kB[22m [2m│ gzip: 0.18 kB[22m
|
|
173
176
|
[34mℹ[39m [2mdist/[22m[32mdb/schema/shared.d.mts[39m [2m 0.25 kB[22m [2m│ gzip: 0.18 kB[22m
|
|
177
|
+
[34mℹ[39m [2mdist/[22m[32mcontext/global.d.mts[39m [2m 0.20 kB[22m [2m│ gzip: 0.16 kB[22m
|
|
174
178
|
[34mℹ[39m [2mdist/[22m[32menv/color-depth.d.mts[39m [2m 0.12 kB[22m [2m│ gzip: 0.11 kB[22m
|
|
175
|
-
[34mℹ[39m
|
|
176
|
-
[32m✔[39m Build complete in [
|
|
179
|
+
[34mℹ[39m 169 files, total: 446.70 kB
|
|
180
|
+
[32m✔[39m Build complete in [32m5631ms[39m
|
package/dist/api/index.d.mts
CHANGED
|
@@ -6,9 +6,9 @@ import { DBAdapter } from "../db/adapter/index.mjs";
|
|
|
6
6
|
import { createLogger } from "../env/logger.mjs";
|
|
7
7
|
import { OAuthProvider } from "../oauth2/oauth-provider.mjs";
|
|
8
8
|
import "../oauth2/index.mjs";
|
|
9
|
-
import { BetterAuthCookies } from "../types/cookie.mjs";
|
|
9
|
+
import { BetterAuthCookie, BetterAuthCookies } from "../types/cookie.mjs";
|
|
10
10
|
import { BetterAuthOptions, BetterAuthRateLimitOptions } from "../types/init-options.mjs";
|
|
11
|
-
import { AuthContext, GenericEndpointContext, InternalAdapter, PluginContext } from "../types/context.mjs";
|
|
11
|
+
import { AuthContext, GenericEndpointContext, InfoContext, InternalAdapter, PluginContext } from "../types/context.mjs";
|
|
12
12
|
import "../types/index.mjs";
|
|
13
13
|
import "../index.mjs";
|
|
14
14
|
import * as better_call0 from "better-call";
|
|
@@ -20,10 +20,8 @@ declare const createAuthMiddleware: {
|
|
|
20
20
|
<Options extends better_call0.MiddlewareOptions, R>(options: Options, handler: (ctx: better_call0.MiddlewareContext<Options, {
|
|
21
21
|
returned?: unknown | undefined;
|
|
22
22
|
responseHeaders?: Headers | undefined;
|
|
23
|
-
} & PluginContext & {
|
|
23
|
+
} & PluginContext & InfoContext & {
|
|
24
24
|
options: BetterAuthOptions;
|
|
25
|
-
appName: string;
|
|
26
|
-
baseURL: string;
|
|
27
25
|
trustedOrigins: string[];
|
|
28
26
|
isTrustedOrigin: (url: string, settings?: {
|
|
29
27
|
allowRelativePaths: boolean;
|
|
@@ -52,13 +50,10 @@ declare const createAuthMiddleware: {
|
|
|
52
50
|
window: number;
|
|
53
51
|
max: number;
|
|
54
52
|
storage: "memory" | "database" | "secondary-storage";
|
|
55
|
-
} & BetterAuthRateLimitOptions
|
|
53
|
+
} & Omit<BetterAuthRateLimitOptions, "enabled" | "window" | "max" | "storage">;
|
|
56
54
|
adapter: DBAdapter<BetterAuthOptions>;
|
|
57
55
|
internalAdapter: InternalAdapter<BetterAuthOptions>;
|
|
58
|
-
createAuthCookie: (cookieName: string, overrideAttributes?: Partial<better_call0.CookieOptions> | undefined) =>
|
|
59
|
-
name: string;
|
|
60
|
-
attributes: better_call0.CookieOptions;
|
|
61
|
-
};
|
|
56
|
+
createAuthCookie: (cookieName: string, overrideAttributes?: Partial<better_call0.CookieOptions> | undefined) => BetterAuthCookie;
|
|
62
57
|
secret: string;
|
|
63
58
|
sessionConfig: {
|
|
64
59
|
updateAge: number;
|
|
@@ -93,7 +88,7 @@ declare const createAuthMiddleware: {
|
|
|
93
88
|
anonymousId?: string | undefined;
|
|
94
89
|
payload: Record<string, any>;
|
|
95
90
|
}) => Promise<void>;
|
|
96
|
-
skipOriginCheck: boolean;
|
|
91
|
+
skipOriginCheck: boolean | string[];
|
|
97
92
|
skipCSRFCheck: boolean;
|
|
98
93
|
runInBackground: (promise: Promise<void>) => void;
|
|
99
94
|
runInBackgroundOrAwait: (promise: Promise<unknown> | Promise<void> | void | unknown) => Promise<unknown>;
|
|
@@ -101,10 +96,8 @@ declare const createAuthMiddleware: {
|
|
|
101
96
|
<Options extends better_call0.MiddlewareOptions, R_1>(handler: (ctx: better_call0.MiddlewareContext<Options, {
|
|
102
97
|
returned?: unknown | undefined;
|
|
103
98
|
responseHeaders?: Headers | undefined;
|
|
104
|
-
} & PluginContext & {
|
|
99
|
+
} & PluginContext & InfoContext & {
|
|
105
100
|
options: BetterAuthOptions;
|
|
106
|
-
appName: string;
|
|
107
|
-
baseURL: string;
|
|
108
101
|
trustedOrigins: string[];
|
|
109
102
|
isTrustedOrigin: (url: string, settings?: {
|
|
110
103
|
allowRelativePaths: boolean;
|
|
@@ -133,13 +126,10 @@ declare const createAuthMiddleware: {
|
|
|
133
126
|
window: number;
|
|
134
127
|
max: number;
|
|
135
128
|
storage: "memory" | "database" | "secondary-storage";
|
|
136
|
-
} & BetterAuthRateLimitOptions
|
|
129
|
+
} & Omit<BetterAuthRateLimitOptions, "enabled" | "window" | "max" | "storage">;
|
|
137
130
|
adapter: DBAdapter<BetterAuthOptions>;
|
|
138
131
|
internalAdapter: InternalAdapter<BetterAuthOptions>;
|
|
139
|
-
createAuthCookie: (cookieName: string, overrideAttributes?: Partial<better_call0.CookieOptions> | undefined) =>
|
|
140
|
-
name: string;
|
|
141
|
-
attributes: better_call0.CookieOptions;
|
|
142
|
-
};
|
|
132
|
+
createAuthCookie: (cookieName: string, overrideAttributes?: Partial<better_call0.CookieOptions> | undefined) => BetterAuthCookie;
|
|
143
133
|
secret: string;
|
|
144
134
|
sessionConfig: {
|
|
145
135
|
updateAge: number;
|
|
@@ -174,7 +164,7 @@ declare const createAuthMiddleware: {
|
|
|
174
164
|
anonymousId?: string | undefined;
|
|
175
165
|
payload: Record<string, any>;
|
|
176
166
|
}) => Promise<void>;
|
|
177
|
-
skipOriginCheck: boolean;
|
|
167
|
+
skipOriginCheck: boolean | string[];
|
|
178
168
|
skipCSRFCheck: boolean;
|
|
179
169
|
runInBackground: (promise: Promise<void>) => void;
|
|
180
170
|
runInBackgroundOrAwait: (promise: Promise<unknown> | Promise<void> | void | unknown) => Promise<unknown>;
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
+
import { __getBetterAuthGlobal } from "./global.mjs";
|
|
1
2
|
import { getAsyncLocalStorage } from "@better-auth/core/async_hooks";
|
|
2
3
|
|
|
3
4
|
//#region src/context/endpoint-context.ts
|
|
4
|
-
let currentContextAsyncStorage = null;
|
|
5
5
|
const ensureAsyncStorage = async () => {
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
const betterAuthGlobal = __getBetterAuthGlobal();
|
|
7
|
+
if (!betterAuthGlobal.context.endpointContextAsyncStorage) {
|
|
8
|
+
const AsyncLocalStorage$1 = await getAsyncLocalStorage();
|
|
9
|
+
betterAuthGlobal.context.endpointContextAsyncStorage = new AsyncLocalStorage$1();
|
|
10
|
+
}
|
|
11
|
+
return betterAuthGlobal.context.endpointContextAsyncStorage;
|
|
8
12
|
};
|
|
9
13
|
/**
|
|
10
14
|
* This is for internal use only. Most users should use `getCurrentAuthContext` instead.
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
//#region src/context/global.ts
|
|
2
|
+
const symbol = Symbol.for("better-auth:global");
|
|
3
|
+
let bind = null;
|
|
4
|
+
const __context = {};
|
|
5
|
+
const __betterAuthVersion = "1.5.0-beta.7";
|
|
6
|
+
/**
|
|
7
|
+
* We store context instance in the globalThis.
|
|
8
|
+
*
|
|
9
|
+
* The reason we do this is that some bundlers, web framework, or package managers might
|
|
10
|
+
* create multiple copies of BetterAuth in the same process intentionally or unintentionally.
|
|
11
|
+
*
|
|
12
|
+
* For example, yarn v1, Next.js, SSR, Vite...
|
|
13
|
+
*
|
|
14
|
+
* @internal
|
|
15
|
+
*/
|
|
16
|
+
function __getBetterAuthGlobal() {
|
|
17
|
+
if (!globalThis[symbol]) {
|
|
18
|
+
globalThis[symbol] = {
|
|
19
|
+
version: __betterAuthVersion,
|
|
20
|
+
epoch: 1,
|
|
21
|
+
context: __context
|
|
22
|
+
};
|
|
23
|
+
bind = globalThis[symbol];
|
|
24
|
+
}
|
|
25
|
+
bind = globalThis[symbol];
|
|
26
|
+
if (bind.version !== __betterAuthVersion) {
|
|
27
|
+
bind.version = __betterAuthVersion;
|
|
28
|
+
bind.epoch++;
|
|
29
|
+
}
|
|
30
|
+
return globalThis[symbol];
|
|
31
|
+
}
|
|
32
|
+
function getBetterAuthVersion() {
|
|
33
|
+
return __getBetterAuthGlobal().version;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
//#endregion
|
|
37
|
+
export { __getBetterAuthGlobal, getBetterAuthVersion };
|
package/dist/context/index.d.mts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AuthEndpointContext, getCurrentAuthContext, getCurrentAuthContextAsyncLocalStorage, runWithEndpointContext } from "./endpoint-context.mjs";
|
|
2
|
+
import { getBetterAuthVersion } from "./global.mjs";
|
|
2
3
|
import { RequestState, RequestStateWeakMap, defineRequestState, getCurrentRequestState, getRequestStateAsyncLocalStorage, hasRequestState, runWithRequestState } from "./request-state.mjs";
|
|
3
4
|
import { getCurrentAdapter, getCurrentDBAdapterAsyncLocalStorage, runWithAdapter, runWithTransaction } from "./transaction.mjs";
|
|
4
|
-
export { type AuthEndpointContext, type RequestState, type RequestStateWeakMap, defineRequestState, getCurrentAdapter, getCurrentAuthContext, getCurrentAuthContextAsyncLocalStorage, getCurrentDBAdapterAsyncLocalStorage, getCurrentRequestState, getRequestStateAsyncLocalStorage, hasRequestState, runWithAdapter, runWithEndpointContext, runWithRequestState, runWithTransaction };
|
|
5
|
+
export { type AuthEndpointContext, type RequestState, type RequestStateWeakMap, defineRequestState, getBetterAuthVersion, getCurrentAdapter, getCurrentAuthContext, getCurrentAuthContextAsyncLocalStorage, getCurrentDBAdapterAsyncLocalStorage, getCurrentRequestState, getRequestStateAsyncLocalStorage, hasRequestState, runWithAdapter, runWithEndpointContext, runWithRequestState, runWithTransaction };
|
package/dist/context/index.mjs
CHANGED
|
@@ -1,24 +1,6 @@
|
|
|
1
|
+
import { getBetterAuthVersion } from "./global.mjs";
|
|
1
2
|
import { getCurrentAuthContext, getCurrentAuthContextAsyncLocalStorage, runWithEndpointContext } from "./endpoint-context.mjs";
|
|
2
3
|
import { defineRequestState, getCurrentRequestState, getRequestStateAsyncLocalStorage, hasRequestState, runWithRequestState } from "./request-state.mjs";
|
|
3
4
|
import { getCurrentAdapter, getCurrentDBAdapterAsyncLocalStorage, runWithAdapter, runWithTransaction } from "./transaction.mjs";
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
const glo = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : {};
|
|
7
|
-
const importIdentifier = "__ $BETTER_AUTH$ __";
|
|
8
|
-
if (glo[importIdentifier] === true)
|
|
9
|
-
/**
|
|
10
|
-
* Dear reader of this message. Please take this seriously.
|
|
11
|
-
*
|
|
12
|
-
* If you see this message, make sure that you only import one version of Better Auth. In many cases,
|
|
13
|
-
* your package manager installs two versions of Better Auth that are used by different packages within your project.
|
|
14
|
-
*
|
|
15
|
-
* This often leads to issues that are hard to debug. We often need to ensure async local storage instance,
|
|
16
|
-
* If you imported different versions of Better Auth, it is impossible for us to
|
|
17
|
-
* do status synchronization per request anymore - which might break the states.
|
|
18
|
-
*
|
|
19
|
-
*/
|
|
20
|
-
console.error("Better Auth was already imported. This breaks async local storage instance and will lead to issues!");
|
|
21
|
-
glo[importIdentifier] = true;
|
|
22
|
-
|
|
23
|
-
//#endregion
|
|
24
|
-
export { defineRequestState, getCurrentAdapter, getCurrentAuthContext, getCurrentAuthContextAsyncLocalStorage, getCurrentDBAdapterAsyncLocalStorage, getCurrentRequestState, getRequestStateAsyncLocalStorage, hasRequestState, runWithAdapter, runWithEndpointContext, runWithRequestState, runWithTransaction };
|
|
6
|
+
export { defineRequestState, getBetterAuthVersion, getCurrentAdapter, getCurrentAuthContext, getCurrentAuthContextAsyncLocalStorage, getCurrentDBAdapterAsyncLocalStorage, getCurrentRequestState, getRequestStateAsyncLocalStorage, hasRequestState, runWithAdapter, runWithEndpointContext, runWithRequestState, runWithTransaction };
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
+
import { __getBetterAuthGlobal } from "./global.mjs";
|
|
1
2
|
import { getAsyncLocalStorage } from "@better-auth/core/async_hooks";
|
|
2
3
|
|
|
3
4
|
//#region src/context/request-state.ts
|
|
4
|
-
let requestStateAsyncStorage = null;
|
|
5
5
|
const ensureAsyncStorage = async () => {
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
const betterAuthGlobal = __getBetterAuthGlobal();
|
|
7
|
+
if (!betterAuthGlobal.context.requestStateAsyncStorage) {
|
|
8
|
+
const AsyncLocalStorage$1 = await getAsyncLocalStorage();
|
|
9
|
+
betterAuthGlobal.context.requestStateAsyncStorage = new AsyncLocalStorage$1();
|
|
10
|
+
}
|
|
11
|
+
return betterAuthGlobal.context.requestStateAsyncStorage;
|
|
8
12
|
};
|
|
9
13
|
async function getRequestStateAsyncLocalStorage() {
|
|
10
14
|
return ensureAsyncStorage();
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
+
import { __getBetterAuthGlobal } from "./global.mjs";
|
|
1
2
|
import { getAsyncLocalStorage } from "@better-auth/core/async_hooks";
|
|
2
3
|
|
|
3
4
|
//#region src/context/transaction.ts
|
|
4
|
-
let currentAdapterAsyncStorage = null;
|
|
5
5
|
const ensureAsyncStorage = async () => {
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
const betterAuthGlobal = __getBetterAuthGlobal();
|
|
7
|
+
if (!betterAuthGlobal.context.adapterAsyncStorage) {
|
|
8
|
+
const AsyncLocalStorage$1 = await getAsyncLocalStorage();
|
|
9
|
+
betterAuthGlobal.context.adapterAsyncStorage = new AsyncLocalStorage$1();
|
|
10
|
+
}
|
|
11
|
+
return betterAuthGlobal.context.adapterAsyncStorage;
|
|
8
12
|
};
|
|
9
13
|
/**
|
|
10
14
|
* This is for internal use only. Most users should use `getCurrentAdapter` instead.
|
|
@@ -108,7 +108,7 @@ const createAdapterFactory = ({ adapter: customAdapter, config: cfg }) => (optio
|
|
|
108
108
|
for (const field in fields) {
|
|
109
109
|
let value = data[field];
|
|
110
110
|
const fieldAttributes = fields[field];
|
|
111
|
-
|
|
111
|
+
const newFieldName = newMappedKeys[field] || fields[field].fieldName || field;
|
|
112
112
|
if (value === void 0 && (fieldAttributes.defaultValue === void 0 && !fieldAttributes.transform?.input && !(action === "update" && fieldAttributes.onUpdate) || action === "update" && !fieldAttributes.onUpdate)) continue;
|
|
113
113
|
if (fieldAttributes && fieldAttributes.type === "date" && !(value instanceof Date) && typeof value === "string") try {
|
|
114
114
|
value = new Date(value);
|
|
@@ -154,7 +154,7 @@ const createAdapterFactory = ({ adapter: customAdapter, config: cfg }) => (optio
|
|
|
154
154
|
const originalKey = field.fieldName || key;
|
|
155
155
|
let newValue = data$1[Object.entries(newMappedKeys).find(([_, v]) => v === originalKey)?.[0] || originalKey];
|
|
156
156
|
if (field.transform?.output) newValue = await field.transform.output(newValue);
|
|
157
|
-
|
|
157
|
+
const newFieldName = newMappedKeys[key] || key;
|
|
158
158
|
if (originalKey === "id" || field.references?.field === "id") {
|
|
159
159
|
if (typeof newValue !== "undefined" && newValue !== null) newValue = String(newValue);
|
|
160
160
|
} else if (config.supportsJSON === false && typeof newValue === "string" && field.type === "json") newValue = safeJSONParse(newValue);
|
|
@@ -177,7 +177,7 @@ const createAdapterFactory = ({ adapter: customAdapter, config: cfg }) => (optio
|
|
|
177
177
|
};
|
|
178
178
|
if (!join || Object.keys(join).length === 0) return await transformSingleOutput(data, unsafe_model, select);
|
|
179
179
|
unsafe_model = getDefaultModelName(unsafe_model);
|
|
180
|
-
|
|
180
|
+
const transformedData = await transformSingleOutput(data, unsafe_model, select);
|
|
181
181
|
const requiredModels = Object.entries(join).map(([model, joinConfig]) => ({
|
|
182
182
|
modelName: getModelName(model),
|
|
183
183
|
defaultModelName: getDefaultModelName(model),
|
|
@@ -196,7 +196,7 @@ const createAdapterFactory = ({ adapter: customAdapter, config: cfg }) => (optio
|
|
|
196
196
|
})();
|
|
197
197
|
if (joinedData === void 0 || joinedData === null) joinedData = joinConfig.relation === "one-to-one" ? null : [];
|
|
198
198
|
if (joinConfig.relation === "one-to-many" && !Array.isArray(joinedData)) joinedData = [joinedData];
|
|
199
|
-
|
|
199
|
+
const transformed = [];
|
|
200
200
|
if (Array.isArray(joinedData)) for (const item of joinedData) {
|
|
201
201
|
const transformedItem = await transformSingleOutput(item, modelName, []);
|
|
202
202
|
transformed.push(transformedItem);
|
|
@@ -392,7 +392,7 @@ const createAdapterFactory = ({ adapter: customAdapter, config: cfg }) => (optio
|
|
|
392
392
|
},
|
|
393
393
|
create: async ({ data: unsafeData, model: unsafeModel, select, forceAllowId = false }) => {
|
|
394
394
|
transactionId++;
|
|
395
|
-
|
|
395
|
+
const thisTransactionId = transactionId;
|
|
396
396
|
const model = getModelName(unsafeModel);
|
|
397
397
|
unsafeModel = getDefaultModelName(unsafeModel);
|
|
398
398
|
if ("id" in unsafeData && typeof unsafeData.id !== "undefined" && !forceAllowId) {
|
|
@@ -429,7 +429,7 @@ const createAdapterFactory = ({ adapter: customAdapter, config: cfg }) => (optio
|
|
|
429
429
|
},
|
|
430
430
|
update: async ({ model: unsafeModel, where: unsafeWhere, update: unsafeData }) => {
|
|
431
431
|
transactionId++;
|
|
432
|
-
|
|
432
|
+
const thisTransactionId = transactionId;
|
|
433
433
|
unsafeModel = getDefaultModelName(unsafeModel);
|
|
434
434
|
const model = getModelName(unsafeModel);
|
|
435
435
|
const where = transformWhereClause({
|
|
@@ -466,7 +466,7 @@ const createAdapterFactory = ({ adapter: customAdapter, config: cfg }) => (optio
|
|
|
466
466
|
},
|
|
467
467
|
updateMany: async ({ model: unsafeModel, where: unsafeWhere, update: unsafeData }) => {
|
|
468
468
|
transactionId++;
|
|
469
|
-
|
|
469
|
+
const thisTransactionId = transactionId;
|
|
470
470
|
const model = getModelName(unsafeModel);
|
|
471
471
|
const where = transformWhereClause({
|
|
472
472
|
model: unsafeModel,
|
|
@@ -501,7 +501,7 @@ const createAdapterFactory = ({ adapter: customAdapter, config: cfg }) => (optio
|
|
|
501
501
|
},
|
|
502
502
|
findOne: async ({ model: unsafeModel, where: unsafeWhere, select, join: unsafeJoin }) => {
|
|
503
503
|
transactionId++;
|
|
504
|
-
|
|
504
|
+
const thisTransactionId = transactionId;
|
|
505
505
|
const model = getModelName(unsafeModel);
|
|
506
506
|
const where = transformWhereClause({
|
|
507
507
|
model: unsafeModel,
|
|
@@ -545,7 +545,7 @@ const createAdapterFactory = ({ adapter: customAdapter, config: cfg }) => (optio
|
|
|
545
545
|
},
|
|
546
546
|
findMany: async ({ model: unsafeModel, where: unsafeWhere, limit: unsafeLimit, sortBy, offset, join: unsafeJoin }) => {
|
|
547
547
|
transactionId++;
|
|
548
|
-
|
|
548
|
+
const thisTransactionId = transactionId;
|
|
549
549
|
const limit = unsafeLimit ?? options.advanced?.database?.defaultFindManyLimit ?? 100;
|
|
550
550
|
const model = getModelName(unsafeModel);
|
|
551
551
|
const where = transformWhereClause({
|
|
@@ -593,7 +593,7 @@ const createAdapterFactory = ({ adapter: customAdapter, config: cfg }) => (optio
|
|
|
593
593
|
},
|
|
594
594
|
delete: async ({ model: unsafeModel, where: unsafeWhere }) => {
|
|
595
595
|
transactionId++;
|
|
596
|
-
|
|
596
|
+
const thisTransactionId = transactionId;
|
|
597
597
|
const model = getModelName(unsafeModel);
|
|
598
598
|
const where = transformWhereClause({
|
|
599
599
|
model: unsafeModel,
|
|
@@ -613,7 +613,7 @@ const createAdapterFactory = ({ adapter: customAdapter, config: cfg }) => (optio
|
|
|
613
613
|
},
|
|
614
614
|
deleteMany: async ({ model: unsafeModel, where: unsafeWhere }) => {
|
|
615
615
|
transactionId++;
|
|
616
|
-
|
|
616
|
+
const thisTransactionId = transactionId;
|
|
617
617
|
const model = getModelName(unsafeModel);
|
|
618
618
|
const where = transformWhereClause({
|
|
619
619
|
model: unsafeModel,
|
|
@@ -637,7 +637,7 @@ const createAdapterFactory = ({ adapter: customAdapter, config: cfg }) => (optio
|
|
|
637
637
|
},
|
|
638
638
|
count: async ({ model: unsafeModel, where: unsafeWhere }) => {
|
|
639
639
|
transactionId++;
|
|
640
|
-
|
|
640
|
+
const thisTransactionId = transactionId;
|
|
641
641
|
const model = getModelName(unsafeModel);
|
|
642
642
|
const where = transformWhereClause({
|
|
643
643
|
model: unsafeModel,
|
|
@@ -703,7 +703,7 @@ const createAdapterFactory = ({ adapter: customAdapter, config: cfg }) => (optio
|
|
|
703
703
|
const separator = `─`.repeat(80);
|
|
704
704
|
const logs = debugLogs.filter((log$1) => log$1.instance === uniqueAdapterFactoryInstanceId);
|
|
705
705
|
if (logs.length === 0) return;
|
|
706
|
-
|
|
706
|
+
const log = logs.reverse().map((log$1) => {
|
|
707
707
|
log$1.args[0] = `\n${log$1.args[0]}`;
|
|
708
708
|
return [...log$1.args, "\n"];
|
|
709
709
|
}).reduce((prev, curr) => {
|
|
@@ -15,7 +15,7 @@ const initGetDefaultModelName = ({ usePlural, schema }) => {
|
|
|
15
15
|
*/
|
|
16
16
|
const getDefaultModelName = (model) => {
|
|
17
17
|
if (usePlural && model.charAt(model.length - 1) === "s") {
|
|
18
|
-
|
|
18
|
+
const pluralessModel = model.slice(0, -1);
|
|
19
19
|
let m$1 = schema[pluralessModel] ? pluralessModel : void 0;
|
|
20
20
|
if (!m$1) m$1 = Object.entries(schema).find(([_, f]) => f.modelName === pluralessModel)?.[0];
|
|
21
21
|
if (m$1) return m$1;
|
|
@@ -28,7 +28,7 @@ declare const initGetIdField: ({
|
|
|
28
28
|
forceAllowId?: boolean;
|
|
29
29
|
}) => {
|
|
30
30
|
transform: {
|
|
31
|
-
input: (value: DBPrimitive) => string | number | true | Date | Record<string, unknown> |
|
|
31
|
+
input: (value: DBPrimitive) => string | number | true | unknown[] | Date | Record<string, unknown> | undefined;
|
|
32
32
|
output: (value: DBPrimitive) => string | undefined;
|
|
33
33
|
};
|
|
34
34
|
defaultValue?: (() => string | false | undefined) | undefined;
|
|
@@ -12,7 +12,7 @@ const initGetIdField = ({ usePlural, schema, disableIdGeneration, options, custo
|
|
|
12
12
|
const idField = ({ customModelName, forceAllowId }) => {
|
|
13
13
|
const useNumberId = options.advanced?.database?.useNumberId || options.advanced?.database?.generateId === "serial";
|
|
14
14
|
const useUUIDs = options.advanced?.database?.generateId === "uuid";
|
|
15
|
-
|
|
15
|
+
const shouldGenerateId = (() => {
|
|
16
16
|
if (disableIdGeneration) return false;
|
|
17
17
|
else if (useNumberId && !forceAllowId) return false;
|
|
18
18
|
else if (useUUIDs) return !supportsUUIDs;
|
|
@@ -24,7 +24,7 @@ const initGetIdField = ({ usePlural, schema, disableIdGeneration, options, custo
|
|
|
24
24
|
required: shouldGenerateId ? true : false,
|
|
25
25
|
...shouldGenerateId ? { defaultValue() {
|
|
26
26
|
if (disableIdGeneration) return void 0;
|
|
27
|
-
|
|
27
|
+
const generateId$1 = options.advanced?.database?.generateId;
|
|
28
28
|
if (generateId$1 === false || useNumberId) return void 0;
|
|
29
29
|
if (typeof generateId$1 === "function") return generateId$1({ model });
|
|
30
30
|
if (customIdGenerator) return customIdGenerator({ model });
|
package/dist/error/index.d.mts
CHANGED
|
@@ -3,7 +3,9 @@ import { APIError as APIError$1 } from "better-call/error";
|
|
|
3
3
|
|
|
4
4
|
//#region src/error/index.d.ts
|
|
5
5
|
declare class BetterAuthError extends Error {
|
|
6
|
-
constructor(message: string,
|
|
6
|
+
constructor(message: string, options?: {
|
|
7
|
+
cause?: unknown | undefined;
|
|
8
|
+
});
|
|
7
9
|
}
|
|
8
10
|
declare class APIError extends APIError$1 {
|
|
9
11
|
constructor(...args: ConstructorParameters<typeof APIError$1>);
|
package/dist/error/index.mjs
CHANGED
|
@@ -3,11 +3,10 @@ import { APIError as APIError$1 } from "better-call/error";
|
|
|
3
3
|
|
|
4
4
|
//#region src/error/index.ts
|
|
5
5
|
var BetterAuthError = class extends Error {
|
|
6
|
-
constructor(message,
|
|
7
|
-
super(message);
|
|
6
|
+
constructor(message, options) {
|
|
7
|
+
super(message, options);
|
|
8
8
|
this.name = "BetterAuthError";
|
|
9
9
|
this.message = message;
|
|
10
|
-
this.cause = cause;
|
|
11
10
|
this.stack = "";
|
|
12
11
|
}
|
|
13
12
|
};
|
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Awaitable, LiteralString, LiteralUnion, Prettify, Primitive } from "./types/helper.mjs";
|
|
2
|
-
import { BetterAuthCookies } from "./types/cookie.mjs";
|
|
2
|
+
import { BetterAuthCookie, BetterAuthCookies } from "./types/cookie.mjs";
|
|
3
3
|
import { BetterAuthPlugin, HookEndpointContext } from "./types/plugin.mjs";
|
|
4
|
-
import { BetterAuthAdvancedOptions, BetterAuthOptions, BetterAuthRateLimitOptions, GenerateIdFn } from "./types/init-options.mjs";
|
|
5
|
-
import { AuthContext, BetterAuthPluginRegistry, BetterAuthPluginRegistryIdentifier, GenericEndpointContext, InternalAdapter, PluginContext } from "./types/context.mjs";
|
|
4
|
+
import { BetterAuthAdvancedOptions, BetterAuthOptions, BetterAuthRateLimitOptions, BetterAuthRateLimitRule, BetterAuthRateLimitStorage, GenerateIdFn } from "./types/init-options.mjs";
|
|
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, BetterAuthCookies, BetterAuthOptions, BetterAuthPlugin, BetterAuthPluginRegistry, BetterAuthPluginRegistryIdentifier, BetterAuthRateLimitOptions, ClientAtomListener, ClientFetchOption, ClientStore, GenerateIdFn, GenericEndpointContext, HookEndpointContext, InternalAdapter, LiteralString, LiteralUnion, PluginContext, Prettify, Primitive, StandardSchemaV1 };
|
|
8
|
+
export { AuthContext, Awaitable, BetterAuthAdvancedOptions, BetterAuthClientOptions, BetterAuthClientPlugin, BetterAuthCookie, BetterAuthCookies, BetterAuthOptions, BetterAuthPlugin, BetterAuthPluginRegistry, BetterAuthPluginRegistryIdentifier, BetterAuthRateLimitOptions, BetterAuthRateLimitRule, BetterAuthRateLimitStorage, ClientAtomListener, ClientFetchOption, ClientStore, GenerateIdFn, GenericEndpointContext, HookEndpointContext, InfoContext, InternalAdapter, LiteralString, LiteralUnion, PluginContext, Prettify, Primitive, StandardSchemaV1 };
|
|
@@ -69,7 +69,9 @@ const apple = (options) => {
|
|
|
69
69
|
if (!token.idToken) return null;
|
|
70
70
|
const profile = decodeJwt(token.idToken);
|
|
71
71
|
if (!profile) return null;
|
|
72
|
-
|
|
72
|
+
let name;
|
|
73
|
+
if (token.user?.name) name = `${token.user.name.firstName || ""} ${token.user.name.lastName || ""}`.trim() || " ";
|
|
74
|
+
else name = profile.name || " ";
|
|
73
75
|
const emailVerified = typeof profile.email_verified === "boolean" ? profile.email_verified : profile.email_verified === "true";
|
|
74
76
|
const enrichedProfile = {
|
|
75
77
|
...profile,
|
|
@@ -9,7 +9,7 @@ const cleanDoubleSlashes = (input = "") => {
|
|
|
9
9
|
return input.split("://").map((str) => str.replace(/\/{2,}/g, "/")).join("://");
|
|
10
10
|
};
|
|
11
11
|
const issuerToEndpoints = (issuer) => {
|
|
12
|
-
|
|
12
|
+
const baseUrl = issuer || "https://gitlab.com";
|
|
13
13
|
return {
|
|
14
14
|
authorizationEndpoint: cleanDoubleSlashes(`${baseUrl}/oauth/authorize`),
|
|
15
15
|
tokenEndpoint: cleanDoubleSlashes(`${baseUrl}/oauth/token`),
|