@convex-dev/better-auth 0.9.7 → 0.9.9

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 (251) hide show
  1. package/dist/auth.d.ts.map +1 -0
  2. package/dist/{commonjs/auth.js → auth.js} +2 -2
  3. package/dist/auth.js.map +1 -0
  4. package/dist/client/adapter.d.ts +15 -0
  5. package/dist/client/adapter.d.ts.map +1 -0
  6. package/dist/{esm/client → client}/adapter.js +11 -2
  7. package/dist/client/adapter.js.map +1 -0
  8. package/dist/{commonjs/client → client}/adapterUtils.d.ts +15 -15
  9. package/dist/client/adapterUtils.d.ts.map +1 -0
  10. package/dist/{esm/client → client}/adapterUtils.js +1 -0
  11. package/dist/client/adapterUtils.js.map +1 -0
  12. package/dist/client/createSchema.d.ts.map +1 -0
  13. package/dist/client/createSchema.js.map +1 -0
  14. package/dist/{esm/client → client}/index.d.ts +23 -27
  15. package/dist/client/index.d.ts.map +1 -0
  16. package/dist/{esm/client → client}/index.js +23 -4
  17. package/dist/client/index.js.map +1 -0
  18. package/dist/client/plugins/index.d.ts.map +1 -0
  19. package/dist/client/plugins/index.js.map +1 -0
  20. package/dist/component/_generated/api.d.ts +36 -0
  21. package/dist/component/_generated/api.d.ts.map +1 -0
  22. package/{src → dist}/component/_generated/api.js +11 -3
  23. package/dist/component/_generated/api.js.map +1 -0
  24. package/dist/component/_generated/component.d.ts +794 -0
  25. package/dist/component/_generated/component.d.ts.map +1 -0
  26. package/dist/component/_generated/component.js +11 -0
  27. package/dist/component/_generated/component.js.map +1 -0
  28. package/dist/component/_generated/dataModel.d.ts +46 -0
  29. package/dist/component/_generated/dataModel.d.ts.map +1 -0
  30. package/dist/component/_generated/dataModel.js +11 -0
  31. package/dist/component/_generated/dataModel.js.map +1 -0
  32. package/{src → dist}/component/_generated/server.d.ts +10 -38
  33. package/dist/component/_generated/server.d.ts.map +1 -0
  34. package/dist/{commonjs/component → component}/_generated/server.js +9 -5
  35. package/dist/component/_generated/server.js.map +1 -0
  36. package/dist/{commonjs/component → component}/adapter.d.ts +11 -11
  37. package/dist/component/adapter.d.ts.map +1 -0
  38. package/dist/component/adapter.js.map +1 -0
  39. package/dist/{commonjs/component → component}/adapterTest.d.ts +2 -2
  40. package/dist/component/adapterTest.d.ts.map +1 -0
  41. package/dist/{commonjs/component → component}/adapterTest.js.map +1 -1
  42. package/dist/component/convex.config.d.ts.map +1 -0
  43. package/dist/component/convex.config.js.map +1 -0
  44. package/dist/{commonjs/component → component}/schema.d.ts +6 -28
  45. package/dist/component/schema.d.ts.map +1 -0
  46. package/dist/{esm/component → component}/schema.js +2 -10
  47. package/dist/component/schema.js.map +1 -0
  48. package/dist/{esm/nextjs → nextjs}/index.d.ts +2 -2
  49. package/dist/nextjs/index.d.ts.map +1 -0
  50. package/dist/{esm/nextjs → nextjs}/index.js +2 -1
  51. package/dist/nextjs/index.js.map +1 -0
  52. package/dist/plugins/convex/client.d.ts.map +1 -0
  53. package/dist/{commonjs/plugins → plugins}/convex/client.js +1 -0
  54. package/dist/plugins/convex/client.js.map +1 -0
  55. package/dist/{commonjs/plugins → plugins}/convex/index.d.ts +22 -4
  56. package/dist/plugins/convex/index.d.ts.map +1 -0
  57. package/dist/{esm/plugins → plugins}/convex/index.js +2 -0
  58. package/dist/plugins/convex/index.js.map +1 -0
  59. package/dist/{esm/plugins → plugins}/cross-domain/client.d.ts +3 -3
  60. package/dist/plugins/cross-domain/client.d.ts.map +1 -0
  61. package/dist/{esm/plugins → plugins}/cross-domain/client.js +1 -0
  62. package/dist/plugins/cross-domain/client.js.map +1 -0
  63. package/dist/{commonjs/plugins → plugins}/cross-domain/index.d.ts +22 -5
  64. package/dist/plugins/cross-domain/index.d.ts.map +1 -0
  65. package/dist/{esm/plugins → plugins}/cross-domain/index.js +1 -0
  66. package/dist/plugins/cross-domain/index.js.map +1 -0
  67. package/dist/plugins/index.d.ts.map +1 -0
  68. package/dist/plugins/index.js.map +1 -0
  69. package/dist/{esm/react → react}/index.d.ts +4 -4
  70. package/dist/react/index.d.ts.map +1 -0
  71. package/dist/{commonjs/react → react}/index.js +9 -3
  72. package/dist/react/index.js.map +1 -0
  73. package/dist/{esm/react-start → react-start}/index.d.ts +2 -2
  74. package/dist/react-start/index.d.ts.map +1 -0
  75. package/dist/{esm/react-start → react-start}/index.js +3 -0
  76. package/dist/react-start/index.js.map +1 -0
  77. package/dist/{commonjs/utils → utils}/index.d.ts +2 -2
  78. package/dist/utils/index.d.ts.map +1 -0
  79. package/dist/{commonjs/utils → utils}/index.js +2 -0
  80. package/dist/utils/index.js.map +1 -0
  81. package/package.json +74 -124
  82. package/src/auth.ts +3 -3
  83. package/src/client/adapter.test.ts +5 -5
  84. package/src/client/adapter.ts +33 -25
  85. package/src/client/adapterUtils.ts +14 -14
  86. package/src/client/index.ts +42 -56
  87. package/src/client/plugins/index.ts +2 -2
  88. package/src/component/_generated/api.ts +52 -0
  89. package/src/component/_generated/component.ts +2019 -0
  90. package/src/component/_generated/server.ts +161 -0
  91. package/src/component/adapter.ts +3 -3
  92. package/src/component/adapterTest.ts +4 -4
  93. package/src/component/schema.ts +7 -15
  94. package/src/nextjs/index.ts +5 -4
  95. package/src/plugins/convex/client.ts +2 -2
  96. package/src/plugins/convex/index.ts +2 -1
  97. package/src/plugins/cross-domain/client.ts +4 -4
  98. package/src/plugins/cross-domain/index.ts +1 -2
  99. package/src/plugins/index.ts +2 -2
  100. package/src/react/index.tsx +8 -7
  101. package/src/react-start/index.ts +7 -6
  102. package/src/test.ts +18 -0
  103. package/src/utils/index.ts +5 -5
  104. package/dist/commonjs/auth.d.ts.map +0 -1
  105. package/dist/commonjs/auth.js.map +0 -1
  106. package/dist/commonjs/client/adapter.d.ts +0 -15
  107. package/dist/commonjs/client/adapter.d.ts.map +0 -1
  108. package/dist/commonjs/client/adapter.js +0 -264
  109. package/dist/commonjs/client/adapter.js.map +0 -1
  110. package/dist/commonjs/client/adapterUtils.d.ts.map +0 -1
  111. package/dist/commonjs/client/adapterUtils.js +0 -437
  112. package/dist/commonjs/client/adapterUtils.js.map +0 -1
  113. package/dist/commonjs/client/createSchema.d.ts.map +0 -1
  114. package/dist/commonjs/client/createSchema.js.map +0 -1
  115. package/dist/commonjs/client/index.d.ts +0 -279
  116. package/dist/commonjs/client/index.d.ts.map +0 -1
  117. package/dist/commonjs/client/index.js +0 -462
  118. package/dist/commonjs/client/index.js.map +0 -1
  119. package/dist/commonjs/client/plugins/index.d.ts +0 -3
  120. package/dist/commonjs/client/plugins/index.d.ts.map +0 -1
  121. package/dist/commonjs/client/plugins/index.js +0 -3
  122. package/dist/commonjs/client/plugins/index.js.map +0 -1
  123. package/dist/commonjs/component/_generated/api.d.ts +0 -12
  124. package/dist/commonjs/component/_generated/api.d.ts.map +0 -1
  125. package/dist/commonjs/component/_generated/api.js +0 -22
  126. package/dist/commonjs/component/_generated/api.js.map +0 -1
  127. package/dist/commonjs/component/_generated/server.d.ts +0 -64
  128. package/dist/commonjs/component/_generated/server.d.ts.map +0 -1
  129. package/dist/commonjs/component/_generated/server.js.map +0 -1
  130. package/dist/commonjs/component/adapter.d.ts.map +0 -1
  131. package/dist/commonjs/component/adapter.js +0 -5
  132. package/dist/commonjs/component/adapter.js.map +0 -1
  133. package/dist/commonjs/component/adapterTest.d.ts.map +0 -1
  134. package/dist/commonjs/component/adapterTest.js +0 -68
  135. package/dist/commonjs/component/convex.config.d.ts.map +0 -1
  136. package/dist/commonjs/component/convex.config.js.map +0 -1
  137. package/dist/commonjs/component/schema.d.ts.map +0 -1
  138. package/dist/commonjs/component/schema.js +0 -147
  139. package/dist/commonjs/component/schema.js.map +0 -1
  140. package/dist/commonjs/nextjs/index.d.ts +0 -10
  141. package/dist/commonjs/nextjs/index.d.ts.map +0 -1
  142. package/dist/commonjs/nextjs/index.js +0 -44
  143. package/dist/commonjs/nextjs/index.js.map +0 -1
  144. package/dist/commonjs/package.json +0 -3
  145. package/dist/commonjs/plugins/convex/client.d.ts +0 -6
  146. package/dist/commonjs/plugins/convex/client.d.ts.map +0 -1
  147. package/dist/commonjs/plugins/convex/client.js.map +0 -1
  148. package/dist/commonjs/plugins/convex/index.d.ts.map +0 -1
  149. package/dist/commonjs/plugins/convex/index.js +0 -261
  150. package/dist/commonjs/plugins/convex/index.js.map +0 -1
  151. package/dist/commonjs/plugins/cross-domain/client.d.ts +0 -132
  152. package/dist/commonjs/plugins/cross-domain/client.d.ts.map +0 -1
  153. package/dist/commonjs/plugins/cross-domain/client.js +0 -176
  154. package/dist/commonjs/plugins/cross-domain/client.js.map +0 -1
  155. package/dist/commonjs/plugins/cross-domain/index.d.ts.map +0 -1
  156. package/dist/commonjs/plugins/cross-domain/index.js +0 -165
  157. package/dist/commonjs/plugins/cross-domain/index.js.map +0 -1
  158. package/dist/commonjs/plugins/index.d.ts +0 -3
  159. package/dist/commonjs/plugins/index.d.ts.map +0 -1
  160. package/dist/commonjs/plugins/index.js +0 -3
  161. package/dist/commonjs/plugins/index.js.map +0 -1
  162. package/dist/commonjs/react/index.d.ts +0 -30
  163. package/dist/commonjs/react/index.d.ts.map +0 -1
  164. package/dist/commonjs/react/index.js.map +0 -1
  165. package/dist/commonjs/react-start/index.d.ts +0 -43
  166. package/dist/commonjs/react-start/index.d.ts.map +0 -1
  167. package/dist/commonjs/react-start/index.js +0 -122
  168. package/dist/commonjs/react-start/index.js.map +0 -1
  169. package/dist/commonjs/utils/index.d.ts.map +0 -1
  170. package/dist/commonjs/utils/index.js.map +0 -1
  171. package/dist/esm/auth.d.ts +0 -4
  172. package/dist/esm/auth.d.ts.map +0 -1
  173. package/dist/esm/auth.js +0 -44
  174. package/dist/esm/auth.js.map +0 -1
  175. package/dist/esm/client/adapter.d.ts +0 -15
  176. package/dist/esm/client/adapter.d.ts.map +0 -1
  177. package/dist/esm/client/adapter.js.map +0 -1
  178. package/dist/esm/client/adapterUtils.d.ts +0 -66
  179. package/dist/esm/client/adapterUtils.d.ts.map +0 -1
  180. package/dist/esm/client/adapterUtils.js.map +0 -1
  181. package/dist/esm/client/createSchema.d.ts +0 -19
  182. package/dist/esm/client/createSchema.d.ts.map +0 -1
  183. package/dist/esm/client/createSchema.js +0 -108
  184. package/dist/esm/client/createSchema.js.map +0 -1
  185. package/dist/esm/client/index.d.ts.map +0 -1
  186. package/dist/esm/client/index.js.map +0 -1
  187. package/dist/esm/client/plugins/index.d.ts.map +0 -1
  188. package/dist/esm/client/plugins/index.js.map +0 -1
  189. package/dist/esm/component/_generated/api.d.ts +0 -12
  190. package/dist/esm/component/_generated/api.d.ts.map +0 -1
  191. package/dist/esm/component/_generated/api.js +0 -22
  192. package/dist/esm/component/_generated/api.js.map +0 -1
  193. package/dist/esm/component/_generated/server.d.ts +0 -64
  194. package/dist/esm/component/_generated/server.d.ts.map +0 -1
  195. package/dist/esm/component/_generated/server.js +0 -74
  196. package/dist/esm/component/_generated/server.js.map +0 -1
  197. package/dist/esm/component/adapter.d.ts +0 -130
  198. package/dist/esm/component/adapter.d.ts.map +0 -1
  199. package/dist/esm/component/adapter.js.map +0 -1
  200. package/dist/esm/component/adapterTest.d.ts +0 -17
  201. package/dist/esm/component/adapterTest.d.ts.map +0 -1
  202. package/dist/esm/component/adapterTest.js.map +0 -1
  203. package/dist/esm/component/convex.config.d.ts +0 -3
  204. package/dist/esm/component/convex.config.d.ts.map +0 -1
  205. package/dist/esm/component/convex.config.js +0 -4
  206. package/dist/esm/component/convex.config.js.map +0 -1
  207. package/dist/esm/component/schema.d.ts +0 -496
  208. package/dist/esm/component/schema.d.ts.map +0 -1
  209. package/dist/esm/component/schema.js.map +0 -1
  210. package/dist/esm/nextjs/index.d.ts.map +0 -1
  211. package/dist/esm/nextjs/index.js.map +0 -1
  212. package/dist/esm/package.json +0 -3
  213. package/dist/esm/plugins/convex/client.d.ts.map +0 -1
  214. package/dist/esm/plugins/convex/client.js +0 -7
  215. package/dist/esm/plugins/convex/client.js.map +0 -1
  216. package/dist/esm/plugins/convex/index.d.ts +0 -291
  217. package/dist/esm/plugins/convex/index.d.ts.map +0 -1
  218. package/dist/esm/plugins/convex/index.js.map +0 -1
  219. package/dist/esm/plugins/cross-domain/client.d.ts.map +0 -1
  220. package/dist/esm/plugins/cross-domain/client.js.map +0 -1
  221. package/dist/esm/plugins/cross-domain/index.d.ts +0 -89
  222. package/dist/esm/plugins/cross-domain/index.d.ts.map +0 -1
  223. package/dist/esm/plugins/cross-domain/index.js.map +0 -1
  224. package/dist/esm/plugins/index.d.ts.map +0 -1
  225. package/dist/esm/plugins/index.js.map +0 -1
  226. package/dist/esm/react/index.d.ts.map +0 -1
  227. package/dist/esm/react/index.js +0 -64
  228. package/dist/esm/react/index.js.map +0 -1
  229. package/dist/esm/react-start/index.d.ts.map +0 -1
  230. package/dist/esm/react-start/index.js.map +0 -1
  231. package/dist/esm/utils/index.d.ts +0 -14
  232. package/dist/esm/utils/index.d.ts.map +0 -1
  233. package/dist/esm/utils/index.js +0 -37
  234. package/dist/esm/utils/index.js.map +0 -1
  235. package/plugins/package.json +0 -5
  236. package/react/package.json +0 -5
  237. package/src/component/_generated/api.d.ts +0 -2145
  238. package/src/component/_generated/server.js +0 -90
  239. /package/dist/{commonjs/auth.d.ts → auth.d.ts} +0 -0
  240. /package/dist/{commonjs/client → client}/createSchema.d.ts +0 -0
  241. /package/dist/{commonjs/client → client}/createSchema.js +0 -0
  242. /package/dist/{esm/client → client}/plugins/index.d.ts +0 -0
  243. /package/dist/{esm/client → client}/plugins/index.js +0 -0
  244. /package/dist/{esm/component → component}/adapter.js +0 -0
  245. /package/dist/{esm/component → component}/adapterTest.js +0 -0
  246. /package/dist/{commonjs/component → component}/convex.config.d.ts +0 -0
  247. /package/dist/{commonjs/component → component}/convex.config.js +0 -0
  248. /package/dist/{esm/plugins → plugins}/convex/client.d.ts +0 -0
  249. /package/dist/{esm/plugins → plugins}/index.d.ts +0 -0
  250. /package/dist/{esm/plugins → plugins}/index.js +0 -0
  251. /package/src/component/_generated/{dataModel.d.ts → dataModel.ts} +0 -0
@@ -0,0 +1,161 @@
1
+ /* eslint-disable */
2
+ /**
3
+ * Generated utilities for implementing server-side Convex query and mutation functions.
4
+ *
5
+ * THIS CODE IS AUTOMATICALLY GENERATED.
6
+ *
7
+ * To regenerate, run `npx convex dev`.
8
+ * @module
9
+ */
10
+
11
+ import type {
12
+ ActionBuilder,
13
+ HttpActionBuilder,
14
+ MutationBuilder,
15
+ QueryBuilder,
16
+ GenericActionCtx,
17
+ GenericMutationCtx,
18
+ GenericQueryCtx,
19
+ GenericDatabaseReader,
20
+ GenericDatabaseWriter,
21
+ } from "convex/server";
22
+ import {
23
+ actionGeneric,
24
+ httpActionGeneric,
25
+ queryGeneric,
26
+ mutationGeneric,
27
+ internalActionGeneric,
28
+ internalMutationGeneric,
29
+ internalQueryGeneric,
30
+ } from "convex/server";
31
+ import type { DataModel } from "./dataModel.js";
32
+
33
+ /**
34
+ * Define a query in this Convex app's public API.
35
+ *
36
+ * This function will be allowed to read your Convex database and will be accessible from the client.
37
+ *
38
+ * @param func - The query function. It receives a {@link QueryCtx} as its first argument.
39
+ * @returns The wrapped query. Include this as an `export` to name it and make it accessible.
40
+ */
41
+ export const query: QueryBuilder<DataModel, "public"> = queryGeneric;
42
+
43
+ /**
44
+ * Define a query that is only accessible from other Convex functions (but not from the client).
45
+ *
46
+ * This function will be allowed to read from your Convex database. It will not be accessible from the client.
47
+ *
48
+ * @param func - The query function. It receives a {@link QueryCtx} as its first argument.
49
+ * @returns The wrapped query. Include this as an `export` to name it and make it accessible.
50
+ */
51
+ export const internalQuery: QueryBuilder<DataModel, "internal"> =
52
+ internalQueryGeneric;
53
+
54
+ /**
55
+ * Define a mutation in this Convex app's public API.
56
+ *
57
+ * This function will be allowed to modify your Convex database and will be accessible from the client.
58
+ *
59
+ * @param func - The mutation function. It receives a {@link MutationCtx} as its first argument.
60
+ * @returns The wrapped mutation. Include this as an `export` to name it and make it accessible.
61
+ */
62
+ export const mutation: MutationBuilder<DataModel, "public"> = mutationGeneric;
63
+
64
+ /**
65
+ * Define a mutation that is only accessible from other Convex functions (but not from the client).
66
+ *
67
+ * This function will be allowed to modify your Convex database. It will not be accessible from the client.
68
+ *
69
+ * @param func - The mutation function. It receives a {@link MutationCtx} as its first argument.
70
+ * @returns The wrapped mutation. Include this as an `export` to name it and make it accessible.
71
+ */
72
+ export const internalMutation: MutationBuilder<DataModel, "internal"> =
73
+ internalMutationGeneric;
74
+
75
+ /**
76
+ * Define an action in this Convex app's public API.
77
+ *
78
+ * An action is a function which can execute any JavaScript code, including non-deterministic
79
+ * code and code with side-effects, like calling third-party services.
80
+ * They can be run in Convex's JavaScript environment or in Node.js using the "use node" directive.
81
+ * They can interact with the database indirectly by calling queries and mutations using the {@link ActionCtx}.
82
+ *
83
+ * @param func - The action. It receives an {@link ActionCtx} as its first argument.
84
+ * @returns The wrapped action. Include this as an `export` to name it and make it accessible.
85
+ */
86
+ export const action: ActionBuilder<DataModel, "public"> = actionGeneric;
87
+
88
+ /**
89
+ * Define an action that is only accessible from other Convex functions (but not from the client).
90
+ *
91
+ * @param func - The function. It receives an {@link ActionCtx} as its first argument.
92
+ * @returns The wrapped function. Include this as an `export` to name it and make it accessible.
93
+ */
94
+ export const internalAction: ActionBuilder<DataModel, "internal"> =
95
+ internalActionGeneric;
96
+
97
+ /**
98
+ * Define an HTTP action.
99
+ *
100
+ * The wrapped function will be used to respond to HTTP requests received
101
+ * by a Convex deployment if the requests matches the path and method where
102
+ * this action is routed. Be sure to route your httpAction in `convex/http.js`.
103
+ *
104
+ * @param func - The function. It receives an {@link ActionCtx} as its first argument
105
+ * and a Fetch API `Request` object as its second.
106
+ * @returns The wrapped function. Import this function from `convex/http.js` and route it to hook it up.
107
+ */
108
+ export const httpAction: HttpActionBuilder = httpActionGeneric;
109
+
110
+ type GenericCtx =
111
+ | GenericActionCtx<DataModel>
112
+ | GenericMutationCtx<DataModel>
113
+ | GenericQueryCtx<DataModel>;
114
+
115
+ /**
116
+ * A set of services for use within Convex query functions.
117
+ *
118
+ * The query context is passed as the first argument to any Convex query
119
+ * function run on the server.
120
+ *
121
+ * If you're using code generation, use the `QueryCtx` type in `convex/_generated/server.d.ts` instead.
122
+ */
123
+ export type QueryCtx = GenericQueryCtx<DataModel>;
124
+
125
+ /**
126
+ * A set of services for use within Convex mutation functions.
127
+ *
128
+ * The mutation context is passed as the first argument to any Convex mutation
129
+ * function run on the server.
130
+ *
131
+ * If you're using code generation, use the `MutationCtx` type in `convex/_generated/server.d.ts` instead.
132
+ */
133
+ export type MutationCtx = GenericMutationCtx<DataModel>;
134
+
135
+ /**
136
+ * A set of services for use within Convex action functions.
137
+ *
138
+ * The action context is passed as the first argument to any Convex action
139
+ * function run on the server.
140
+ */
141
+ export type ActionCtx = GenericActionCtx<DataModel>;
142
+
143
+ /**
144
+ * An interface to read from the database within Convex query functions.
145
+ *
146
+ * The two entry points are {@link DatabaseReader.get}, which fetches a single
147
+ * document by its {@link Id}, or {@link DatabaseReader.query}, which starts
148
+ * building a query.
149
+ */
150
+ export type DatabaseReader = GenericDatabaseReader<DataModel>;
151
+
152
+ /**
153
+ * An interface to read from and write to the database within Convex mutation
154
+ * functions.
155
+ *
156
+ * Convex guarantees that all writes within a single mutation are
157
+ * executed atomically, so you never have to worry about partial writes leaving
158
+ * your data in an inconsistent state. See [the Convex Guide](https://docs.convex.dev/understanding/convex-fundamentals/functions#atomicity-and-optimistic-concurrency-control)
159
+ * for the guarantees Convex provides your functions.
160
+ */
161
+ export type DatabaseWriter = GenericDatabaseWriter<DataModel>;
@@ -1,6 +1,6 @@
1
- import { createApi } from "../client";
2
- import { auth } from "../auth";
3
- import schema from "./schema";
1
+ import { createApi } from "../client/index.js";
2
+ import { auth } from "../auth.js";
3
+ import schema from "./schema.js";
4
4
 
5
5
  export const {
6
6
  create,
@@ -1,7 +1,7 @@
1
- import { convexAdapter, GenericCtx } from "../client";
2
- import { api } from "./_generated/api";
3
- import { mutation, query } from "./_generated/server";
4
- import {
1
+ import { convexAdapter, type GenericCtx } from "../client/index.js";
2
+ import { api } from "./_generated/api.js";
3
+ import { mutation, query } from "./_generated/server.js";
4
+ import type {
5
5
  GenericDataModel,
6
6
  GenericMutationCtx,
7
7
  GenericQueryCtx,
@@ -21,7 +21,7 @@ export const tables = {
21
21
  phoneNumberVerified: v.optional(v.union(v.null(), v.boolean())),
22
22
  userId: v.optional(v.union(v.null(), v.string())),
23
23
  })
24
- .index("email_name", ["email","name"])
24
+ .index("email_name", ["email", "name"])
25
25
  .index("name", ["name"])
26
26
  .index("userId", ["userId"])
27
27
  .index("username", ["username"])
@@ -36,7 +36,7 @@ export const tables = {
36
36
  userId: v.string(),
37
37
  })
38
38
  .index("expiresAt", ["expiresAt"])
39
- .index("expiresAt_userId", ["expiresAt","userId"])
39
+ .index("expiresAt_userId", ["expiresAt", "userId"])
40
40
  .index("token", ["token"])
41
41
  .index("userId", ["userId"]),
42
42
  account: defineTable({
@@ -54,8 +54,8 @@ export const tables = {
54
54
  updatedAt: v.number(),
55
55
  })
56
56
  .index("accountId", ["accountId"])
57
- .index("accountId_providerId", ["accountId","providerId"])
58
- .index("providerId_userId", ["providerId","userId"])
57
+ .index("accountId_providerId", ["accountId", "providerId"])
58
+ .index("providerId_userId", ["providerId", "userId"])
59
59
  .index("userId", ["userId"]),
60
60
  verification: defineTable({
61
61
  identifier: v.string(),
@@ -70,8 +70,7 @@ export const tables = {
70
70
  secret: v.string(),
71
71
  backupCodes: v.string(),
72
72
  userId: v.string(),
73
- })
74
- .index("userId", ["userId"]),
73
+ }).index("userId", ["userId"]),
75
74
  passkey: defineTable({
76
75
  name: v.optional(v.union(v.null(), v.string())),
77
76
  publicKey: v.string(),
@@ -124,7 +123,7 @@ export const tables = {
124
123
  updatedAt: v.optional(v.union(v.null(), v.number())),
125
124
  consentGiven: v.optional(v.union(v.null(), v.boolean())),
126
125
  })
127
- .index("clientId_userId", ["clientId","userId"])
126
+ .index("clientId_userId", ["clientId", "userId"])
128
127
  .index("userId", ["userId"]),
129
128
  jwks: defineTable({
130
129
  publicKey: v.string(),
@@ -135,14 +134,7 @@ export const tables = {
135
134
  key: v.optional(v.union(v.null(), v.string())),
136
135
  count: v.optional(v.union(v.null(), v.number())),
137
136
  lastRequest: v.optional(v.union(v.null(), v.number())),
138
- })
139
- .index("key", ["key"]),
140
- ratelimit: defineTable({
141
- key: v.string(),
142
- count: v.number(),
143
- lastRequest: v.number(),
144
- })
145
- .index("key", ["key"]),
137
+ }).index("key", ["key"]),
146
138
  };
147
139
 
148
140
  const schema = defineSchema(tables);
@@ -1,13 +1,13 @@
1
1
  import { createCookieGetter } from "better-auth/cookies";
2
- import { JWT_COOKIE_NAME } from "../plugins/convex";
3
- import { CreateAuth, getStaticAuth } from "../client";
4
- import { GenericDataModel } from "convex/server";
2
+ import { JWT_COOKIE_NAME } from "../plugins/convex/index.js";
3
+ import { type CreateAuth, getStaticAuth } from "../client/index.js";
4
+ import type { GenericDataModel } from "convex/server";
5
5
 
6
6
  export const getToken = async <DataModel extends GenericDataModel>(
7
7
  createAuth: CreateAuth<DataModel>
8
8
  ) => {
9
9
  const options = getStaticAuth(createAuth).options;
10
- const { cookies } = await import("next/headers");
10
+ const { cookies } = await import("next/headers.js");
11
11
  const cookieStore = await cookies();
12
12
  const createCookie = createCookieGetter(options);
13
13
  const cookie = createCookie(JWT_COOKIE_NAME);
@@ -46,6 +46,7 @@ const handler = (request: Request, opts?: { convexSiteUrl?: string }) => {
46
46
  const nextUrl = `${convexSiteUrl}${requestUrl.pathname}${requestUrl.search}`;
47
47
  const newRequest = new Request(nextUrl, request);
48
48
  newRequest.headers.set("accept-encoding", "application/json");
49
+ newRequest.headers.set("host", convexSiteUrl);
49
50
  return fetch(newRequest, { method: request.method, redirect: "manual" });
50
51
  };
51
52
 
@@ -1,5 +1,5 @@
1
- import { BetterAuthClientPlugin } from "better-auth/client";
2
- import { convex } from ".";
1
+ import type { BetterAuthClientPlugin } from "better-auth/client";
2
+ import { convex } from "./index.js";
3
3
 
4
4
  export const convexClient = () => {
5
5
  return {
@@ -1,6 +1,6 @@
1
+ import { type BetterAuthPlugin } from "better-auth";
1
2
  import { createAuthMiddleware, sessionMiddleware } from "better-auth/api";
2
3
  import {
3
- BetterAuthPlugin,
4
4
  createAuthEndpoint,
5
5
  jwt as jwtPlugin,
6
6
  bearer as bearerPlugin,
@@ -127,6 +127,7 @@ export const convex = (
127
127
  maxAge: jwtExpirationSeconds,
128
128
  });
129
129
  ctx.setCookie(jwtCookie.name, token, jwtCookie.attributes);
130
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
130
131
  } catch (_err) {
131
132
  // no-op, some sign-in calls (eg., when redirecting to 2fa)
132
133
  // 401 here
@@ -1,6 +1,6 @@
1
- import type { BetterAuthClientPlugin, Store } from "better-auth";
2
- import { BetterFetchOption } from "@better-fetch/fetch";
3
- import { crossDomain } from ".";
1
+ import type { BetterAuthClientPlugin, ClientStore } from "better-auth";
2
+ import type { BetterFetchOption } from "@better-fetch/fetch";
3
+ import { crossDomain } from "./index.js";
4
4
 
5
5
  interface CookieAttributes {
6
6
  value: string;
@@ -96,7 +96,7 @@ export const crossDomainClient = (
96
96
  disableCache?: boolean;
97
97
  } = {}
98
98
  ) => {
99
- let store: Store | null = null;
99
+ let store: ClientStore | null = null;
100
100
  const cookieName = `${opts?.storagePrefix || "better-auth"}_cookie`;
101
101
  const localCacheName = `${opts?.storagePrefix || "better-auth"}_session_data`;
102
102
  const storage =
@@ -1,8 +1,7 @@
1
- import { HookEndpointContext } from "better-auth";
1
+ import { type BetterAuthPlugin, type HookEndpointContext } from "better-auth";
2
2
  import { setSessionCookie } from "better-auth/cookies";
3
3
  import { generateRandomString } from "better-auth/crypto";
4
4
  import {
5
- BetterAuthPlugin,
6
5
  createAuthEndpoint,
7
6
  createAuthMiddleware,
8
7
  oneTimeToken as oneTimeTokenPlugin,
@@ -1,2 +1,2 @@
1
- export * from "./convex";
2
- export * from "./cross-domain";
1
+ export * from "./convex/index.js";
2
+ export * from "./cross-domain/index.js";
@@ -1,11 +1,11 @@
1
1
  import { useEffect } from "react";
2
2
 
3
- import { ReactNode, useCallback, useMemo } from "react";
4
- import { AuthTokenFetcher } from "convex/browser";
3
+ import { type ReactNode, useCallback, useMemo } from "react";
4
+ import { type AuthTokenFetcher } from "convex/browser";
5
5
  import { ConvexProviderWithAuth } from "convex/react";
6
- import { BetterAuthClientPlugin, ClientOptions } from "better-auth";
6
+ import { type BetterAuthClientPlugin } from "better-auth";
7
7
  import { createAuthClient } from "better-auth/react";
8
- import { convexClient, crossDomainClient } from "../client/plugins";
8
+ import { convexClient, crossDomainClient } from "../client/plugins/index.js";
9
9
 
10
10
  type CrossDomainClient = ReturnType<typeof crossDomainClient>;
11
11
  type ConvexClient = ReturnType<typeof convexClient>;
@@ -19,7 +19,7 @@ type AuthClientWithPlugins<
19
19
  Plugins extends PluginsWithCrossDomain | PluginsWithoutCrossDomain,
20
20
  > = ReturnType<
21
21
  typeof createAuthClient<
22
- ClientOptions & {
22
+ BetterAuthClientPlugin & {
23
23
  plugins: Plugins;
24
24
  }
25
25
  >
@@ -53,7 +53,6 @@ export function ConvexBetterAuthProvider({
53
53
  const useBetterAuth = useUseAuthFromBetterAuth(authClient);
54
54
 
55
55
  useEffect(() => {
56
- // eslint-disable-next-line @typescript-eslint/no-floating-promises
57
56
  (async () => {
58
57
  const url = new URL(window.location?.href);
59
58
  const token = url.searchParams.get("ott");
@@ -93,7 +92,7 @@ function useUseAuthFromBetterAuth(authClient: AuthClient) {
93
92
  function useAuthFromBetterAuth() {
94
93
  const { data: session, isPending: isSessionPending } =
95
94
  authClient.useSession();
96
- const sessionId = session?.session.id;
95
+ const sessionId = session?.session?.id;
97
96
  const fetchAccessToken = useCallback(
98
97
  async () => {
99
98
  try {
@@ -105,6 +104,7 @@ function useUseAuthFromBetterAuth(authClient: AuthClient) {
105
104
  },
106
105
  // Build a new fetchAccessToken to trigger setAuth() whenever the
107
106
  // session changes.
107
+ // eslint-disable-next-line react-hooks/exhaustive-deps
108
108
  [sessionId]
109
109
  );
110
110
  return useMemo(
@@ -113,6 +113,7 @@ function useUseAuthFromBetterAuth(authClient: AuthClient) {
113
113
  isAuthenticated: session !== null,
114
114
  fetchAccessToken,
115
115
  }),
116
+ // eslint-disable-next-line react-hooks/exhaustive-deps
116
117
  [isSessionPending, sessionId, fetchAccessToken]
117
118
  );
118
119
  },
@@ -3,14 +3,14 @@ import { createCookieGetter } from "better-auth/cookies";
3
3
  import { betterFetch } from "@better-fetch/fetch";
4
4
  import * as jose from "jose";
5
5
  import {
6
- FunctionReference,
7
- FunctionReturnType,
8
- GenericActionCtx,
9
- GenericDataModel,
6
+ type FunctionReference,
7
+ type FunctionReturnType,
8
+ type GenericActionCtx,
9
+ type GenericDataModel,
10
10
  } from "convex/server";
11
- import { JWT_COOKIE_NAME } from "../plugins/convex";
11
+ import { JWT_COOKIE_NAME } from "../plugins/convex/index.js";
12
12
  import { ConvexHttpClient } from "convex/browser";
13
- import { CreateAuth, getStaticAuth } from "../client";
13
+ import { type CreateAuth, getStaticAuth } from "../client/index.js";
14
14
 
15
15
  export const getCookieName = <DataModel extends GenericDataModel>(
16
16
  createAuth: CreateAuth<DataModel>
@@ -183,6 +183,7 @@ export const reactStartHandler = (
183
183
  const nextUrl = `${convexSiteUrl}${requestUrl.pathname}${requestUrl.search}`;
184
184
  const headers = new Headers(request.headers);
185
185
  headers.set("accept-encoding", "application/json");
186
+ headers.set("host", convexSiteUrl);
186
187
  return fetch(nextUrl, {
187
188
  method: request.method,
188
189
  headers,
package/src/test.ts ADDED
@@ -0,0 +1,18 @@
1
+ /// <reference types="vite/client" />
2
+ import type { TestConvex } from "convex-test";
3
+ import type { GenericSchema, SchemaDefinition } from "convex/server";
4
+ import schema from "./component/schema.js";
5
+ const modules = import.meta.glob("./component/**/*.ts");
6
+
7
+ /**
8
+ * Register the component with the test convex instance.
9
+ * @param t - The test convex instance, e.g. from calling `convexTest`.
10
+ * @param name - The name of the component, as registered in convex.config.ts.
11
+ */
12
+ export function register(
13
+ t: TestConvex<SchemaDefinition<GenericSchema, boolean>>,
14
+ name: string = "migrations"
15
+ ) {
16
+ t.registerComponent(name, schema, modules);
17
+ }
18
+ export default { register, schema, modules };
@@ -1,10 +1,10 @@
1
1
  import {
2
- GenericActionCtx,
3
- GenericDataModel,
4
- GenericMutationCtx,
5
- GenericQueryCtx,
2
+ type GenericActionCtx,
3
+ type GenericDataModel,
4
+ type GenericMutationCtx,
5
+ type GenericQueryCtx,
6
6
  } from "convex/server";
7
- import { GenericCtx } from "../client";
7
+ import { type GenericCtx } from "../client/index.js";
8
8
 
9
9
  export type RunMutationCtx<DataModel extends GenericDataModel> = (
10
10
  | GenericMutationCtx<DataModel>
@@ -1 +0,0 @@
1
- {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAqB,MAAM,aAAa,CAAC;AAuD5D,QAAA,MAAM,MAAM,EAA0B,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC;AACpE,OAAO,EAAE,MAAM,IAAI,IAAI,EAAE,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAqB,MAAM,aAAa,CAAC;AAC5D,OAAO,EACL,SAAS,EACT,MAAM,EACN,QAAQ,EACR,YAAY,EACZ,GAAG,EACH,SAAS,EACT,YAAY,EACZ,MAAM,EACN,YAAY,EACZ,WAAW,EACX,SAAS,EACT,QAAQ,GACT,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,iDAAiD;AACjD,MAAM,OAAO,GAAG;IACd,MAAM,EAAE;QACN,QAAQ,EAAE,IAAI;KACf;IACD,QAAQ,EAAE,aAAa,CAAC,EAAS,EAAE,EAAS,CAAC;IAC7C,SAAS,EAAE;QACT,OAAO,EAAE,UAAU;KACpB;IACD,OAAO,EAAE;QACP,SAAS,EAAE;QACX,SAAS,EAAE;QACX,QAAQ,EAAE;QACV,WAAW,EAAE;QACb,SAAS,CAAC,EAAE,aAAa,EAAE,KAAK,IAAI,EAAE,GAAE,CAAC,EAAE,CAAC;QAC5C,QAAQ,CAAC,EAAE,mBAAmB,EAAE,KAAK,IAAI,EAAE,GAAE,CAAC,EAAE,CAAC;QACjD,OAAO,EAAE;QACT,YAAY,CAAC;YACX,MAAM,EAAE;gBACN;oBACE,QAAQ,EAAE,EAAE;oBACZ,YAAY,EAAE,EAAE;oBAChB,UAAU,EAAE,EAAE;iBACf;aACF;SACF,CAAC;QACF,MAAM,EAAE;QACR,YAAY,CAAC;YACX,SAAS,EAAE,QAAQ;SACpB,CAAC;QACF,MAAM,EAAE;QACR,YAAY,EAAE;QACd,GAAG,EAAE;QACL,MAAM,EAAE;KACT;CACmB,CAAC,CAAC,+CAA+C;AACvE,MAAM,MAAM,GAAG,UAAU,CAAC,OAAO,CAAkC,CAAC;AACpE,OAAO,EAAE,MAAM,IAAI,IAAI,EAAE,CAAC"}
@@ -1,15 +0,0 @@
1
- import { DBAdapterDebugLogOption } from "better-auth/adapters";
2
- import { GenericActionCtx, GenericDataModel, SchemaDefinition } from "convex/server";
3
- import { SetOptional } from "type-fest";
4
- import { AuthFunctions, GenericCtx, Triggers, UseApi } from ".";
5
- import defaultSchema from "../component/schema";
6
- import { api as componentApi } from "../component/_generated/api";
7
- export declare const convexAdapter: <DataModel extends GenericDataModel, Ctx extends GenericCtx<DataModel> = GenericActionCtx<DataModel>, Schema extends SchemaDefinition<any, any> = typeof defaultSchema>(ctx: Ctx, api: {
8
- adapter: SetOptional<UseApi<typeof componentApi>["adapter"], "migrationRemoveUserId">;
9
- adapterTest?: UseApi<typeof componentApi>["adapterTest"];
10
- }, config?: {
11
- debugLogs?: DBAdapterDebugLogOption;
12
- authFunctions?: AuthFunctions;
13
- triggers?: Triggers<DataModel, Schema>;
14
- }) => import("better-auth/adapters").AdapterFactory;
15
- //# sourceMappingURL=adapter.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../../src/client/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,uBAAuB,EACxB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAGL,gBAAgB,EAChB,gBAAgB,EAGhB,gBAAgB,EACjB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,GAAG,CAAC;AAChE,OAAO,aAAa,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,GAAG,IAAI,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAiFlE,eAAO,MAAM,aAAa,GACxB,SAAS,SAAS,gBAAgB,EAClC,GAAG,SAAS,UAAU,CAAC,SAAS,CAAC,GAAG,gBAAgB,CAAC,SAAS,CAAC,EAC/D,MAAM,SAAS,gBAAgB,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,OAAO,aAAa,EAEhE,KAAK,GAAG,EACR,KAAK;IACH,OAAO,EAAE,WAAW,CAClB,MAAM,CAAC,OAAO,YAAY,CAAC,CAAC,SAAS,CAAC,EACtC,uBAAuB,CACxB,CAAC;IACF,WAAW,CAAC,EAAE,MAAM,CAAC,OAAO,YAAY,CAAC,CAAC,aAAa,CAAC,CAAC;CAC1D,EACD,SAAQ;IACN,SAAS,CAAC,EAAE,uBAAuB,CAAC;IACpC,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,QAAQ,CAAC,EAAE,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;CACnC,kDA6OP,CAAC"}