@robelest/convex-auth 0.0.1

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 (280) hide show
  1. package/README.md +6 -0
  2. package/dist/bin.cjs +27733 -0
  3. package/dist/client/index.d.ts +49 -0
  4. package/dist/client/index.d.ts.map +1 -0
  5. package/dist/client/index.js +283 -0
  6. package/dist/client/index.js.map +1 -0
  7. package/dist/component/_generated/api.d.ts +36 -0
  8. package/dist/component/_generated/api.d.ts.map +1 -0
  9. package/dist/component/_generated/api.js +31 -0
  10. package/dist/component/_generated/api.js.map +1 -0
  11. package/dist/component/_generated/component.d.ts +295 -0
  12. package/dist/component/_generated/component.d.ts.map +1 -0
  13. package/dist/component/_generated/component.js +11 -0
  14. package/dist/component/_generated/component.js.map +1 -0
  15. package/dist/component/_generated/dataModel.d.ts +46 -0
  16. package/dist/component/_generated/dataModel.d.ts.map +1 -0
  17. package/dist/component/_generated/dataModel.js +11 -0
  18. package/dist/component/_generated/dataModel.js.map +1 -0
  19. package/dist/component/_generated/server.d.ts +121 -0
  20. package/dist/component/_generated/server.d.ts.map +1 -0
  21. package/dist/component/_generated/server.js +78 -0
  22. package/dist/component/_generated/server.js.map +1 -0
  23. package/dist/component/convex.config.d.ts +3 -0
  24. package/dist/component/convex.config.d.ts.map +1 -0
  25. package/dist/component/convex.config.js +4 -0
  26. package/dist/component/convex.config.js.map +1 -0
  27. package/dist/component/index.d.ts +15 -0
  28. package/dist/component/index.d.ts.map +1 -0
  29. package/dist/component/index.js +13 -0
  30. package/dist/component/index.js.map +1 -0
  31. package/dist/component/public.d.ts +450 -0
  32. package/dist/component/public.d.ts.map +1 -0
  33. package/dist/component/public.js +528 -0
  34. package/dist/component/public.js.map +1 -0
  35. package/dist/component/schema.d.ts +107 -0
  36. package/dist/component/schema.d.ts.map +1 -0
  37. package/dist/component/schema.js +26 -0
  38. package/dist/component/schema.js.map +1 -0
  39. package/dist/providers/Anonymous.d.ts +50 -0
  40. package/dist/providers/Anonymous.d.ts.map +1 -0
  41. package/dist/providers/Anonymous.js +39 -0
  42. package/dist/providers/Anonymous.js.map +1 -0
  43. package/dist/providers/ConvexCredentials.d.ts +88 -0
  44. package/dist/providers/ConvexCredentials.d.ts.map +1 -0
  45. package/dist/providers/ConvexCredentials.js +37 -0
  46. package/dist/providers/ConvexCredentials.js.map +1 -0
  47. package/dist/providers/Email.d.ts +33 -0
  48. package/dist/providers/Email.d.ts.map +1 -0
  49. package/dist/providers/Email.js +50 -0
  50. package/dist/providers/Email.js.map +1 -0
  51. package/dist/providers/Password.d.ts +95 -0
  52. package/dist/providers/Password.d.ts.map +1 -0
  53. package/dist/providers/Password.js +174 -0
  54. package/dist/providers/Password.js.map +1 -0
  55. package/dist/providers/Phone.d.ts +22 -0
  56. package/dist/providers/Phone.d.ts.map +1 -0
  57. package/dist/providers/Phone.js +37 -0
  58. package/dist/providers/Phone.js.map +1 -0
  59. package/dist/server/convex_types.d.ts +17 -0
  60. package/dist/server/convex_types.d.ts.map +1 -0
  61. package/dist/server/convex_types.js +2 -0
  62. package/dist/server/convex_types.js.map +1 -0
  63. package/dist/server/cookies.d.ts +35 -0
  64. package/dist/server/cookies.d.ts.map +1 -0
  65. package/dist/server/cookies.js +34 -0
  66. package/dist/server/cookies.js.map +1 -0
  67. package/dist/server/implementation/db.d.ts +80 -0
  68. package/dist/server/implementation/db.d.ts.map +1 -0
  69. package/dist/server/implementation/db.js +59 -0
  70. package/dist/server/implementation/db.js.map +1 -0
  71. package/dist/server/implementation/index.d.ts +370 -0
  72. package/dist/server/implementation/index.d.ts.map +1 -0
  73. package/dist/server/implementation/index.js +521 -0
  74. package/dist/server/implementation/index.js.map +1 -0
  75. package/dist/server/implementation/mutations/createAccountFromCredentials.d.ts +33 -0
  76. package/dist/server/implementation/mutations/createAccountFromCredentials.d.ts.map +1 -0
  77. package/dist/server/implementation/mutations/createAccountFromCredentials.js +71 -0
  78. package/dist/server/implementation/mutations/createAccountFromCredentials.js.map +1 -0
  79. package/dist/server/implementation/mutations/createVerificationCode.d.ts +25 -0
  80. package/dist/server/implementation/mutations/createVerificationCode.d.ts.map +1 -0
  81. package/dist/server/implementation/mutations/createVerificationCode.js +84 -0
  82. package/dist/server/implementation/mutations/createVerificationCode.js.map +1 -0
  83. package/dist/server/implementation/mutations/index.d.ts +304 -0
  84. package/dist/server/implementation/mutations/index.d.ts.map +1 -0
  85. package/dist/server/implementation/mutations/index.js +108 -0
  86. package/dist/server/implementation/mutations/index.js.map +1 -0
  87. package/dist/server/implementation/mutations/invalidateSessions.d.ts +13 -0
  88. package/dist/server/implementation/mutations/invalidateSessions.d.ts.map +1 -0
  89. package/dist/server/implementation/mutations/invalidateSessions.js +35 -0
  90. package/dist/server/implementation/mutations/invalidateSessions.js.map +1 -0
  91. package/dist/server/implementation/mutations/modifyAccount.d.ts +23 -0
  92. package/dist/server/implementation/mutations/modifyAccount.d.ts.map +1 -0
  93. package/dist/server/implementation/mutations/modifyAccount.js +48 -0
  94. package/dist/server/implementation/mutations/modifyAccount.js.map +1 -0
  95. package/dist/server/implementation/mutations/refreshSession.d.ts +16 -0
  96. package/dist/server/implementation/mutations/refreshSession.d.ts.map +1 -0
  97. package/dist/server/implementation/mutations/refreshSession.js +116 -0
  98. package/dist/server/implementation/mutations/refreshSession.js.map +1 -0
  99. package/dist/server/implementation/mutations/retrieveAccountWithCredentials.d.ts +27 -0
  100. package/dist/server/implementation/mutations/retrieveAccountWithCredentials.d.ts.map +1 -0
  101. package/dist/server/implementation/mutations/retrieveAccountWithCredentials.js +55 -0
  102. package/dist/server/implementation/mutations/retrieveAccountWithCredentials.js.map +1 -0
  103. package/dist/server/implementation/mutations/signIn.d.ts +17 -0
  104. package/dist/server/implementation/mutations/signIn.d.ts.map +1 -0
  105. package/dist/server/implementation/mutations/signIn.js +26 -0
  106. package/dist/server/implementation/mutations/signIn.js.map +1 -0
  107. package/dist/server/implementation/mutations/signOut.d.ts +11 -0
  108. package/dist/server/implementation/mutations/signOut.d.ts.map +1 -0
  109. package/dist/server/implementation/mutations/signOut.js +24 -0
  110. package/dist/server/implementation/mutations/signOut.js.map +1 -0
  111. package/dist/server/implementation/mutations/userOAuth.d.ts +19 -0
  112. package/dist/server/implementation/mutations/userOAuth.d.ts.map +1 -0
  113. package/dist/server/implementation/mutations/userOAuth.js +84 -0
  114. package/dist/server/implementation/mutations/userOAuth.js.map +1 -0
  115. package/dist/server/implementation/mutations/verifier.d.ts +8 -0
  116. package/dist/server/implementation/mutations/verifier.d.ts.map +1 -0
  117. package/dist/server/implementation/mutations/verifier.js +19 -0
  118. package/dist/server/implementation/mutations/verifier.js.map +1 -0
  119. package/dist/server/implementation/mutations/verifierSignature.d.ts +15 -0
  120. package/dist/server/implementation/mutations/verifierSignature.d.ts.map +1 -0
  121. package/dist/server/implementation/mutations/verifierSignature.js +29 -0
  122. package/dist/server/implementation/mutations/verifierSignature.js.map +1 -0
  123. package/dist/server/implementation/mutations/verifyCodeAndSignIn.d.ts +21 -0
  124. package/dist/server/implementation/mutations/verifyCodeAndSignIn.d.ts.map +1 -0
  125. package/dist/server/implementation/mutations/verifyCodeAndSignIn.js +127 -0
  126. package/dist/server/implementation/mutations/verifyCodeAndSignIn.js.map +1 -0
  127. package/dist/server/implementation/provider.d.ts +6 -0
  128. package/dist/server/implementation/provider.d.ts.map +1 -0
  129. package/dist/server/implementation/provider.js +21 -0
  130. package/dist/server/implementation/provider.js.map +1 -0
  131. package/dist/server/implementation/rateLimit.d.ts +6 -0
  132. package/dist/server/implementation/rateLimit.d.ts.map +1 -0
  133. package/dist/server/implementation/rateLimit.js +76 -0
  134. package/dist/server/implementation/rateLimit.js.map +1 -0
  135. package/dist/server/implementation/redirects.d.ts +6 -0
  136. package/dist/server/implementation/redirects.d.ts.map +1 -0
  137. package/dist/server/implementation/redirects.js +40 -0
  138. package/dist/server/implementation/redirects.js.map +1 -0
  139. package/dist/server/implementation/refreshTokens.d.ts +40 -0
  140. package/dist/server/implementation/refreshTokens.d.ts.map +1 -0
  141. package/dist/server/implementation/refreshTokens.js +160 -0
  142. package/dist/server/implementation/refreshTokens.js.map +1 -0
  143. package/dist/server/implementation/sessions.d.ts +43 -0
  144. package/dist/server/implementation/sessions.d.ts.map +1 -0
  145. package/dist/server/implementation/sessions.js +94 -0
  146. package/dist/server/implementation/sessions.js.map +1 -0
  147. package/dist/server/implementation/signIn.d.ts +31 -0
  148. package/dist/server/implementation/signIn.d.ts.map +1 -0
  149. package/dist/server/implementation/signIn.js +148 -0
  150. package/dist/server/implementation/signIn.js.map +1 -0
  151. package/dist/server/implementation/tokens.d.ts +7 -0
  152. package/dist/server/implementation/tokens.d.ts.map +1 -0
  153. package/dist/server/implementation/tokens.js +18 -0
  154. package/dist/server/implementation/tokens.js.map +1 -0
  155. package/dist/server/implementation/types.d.ts +288 -0
  156. package/dist/server/implementation/types.d.ts.map +1 -0
  157. package/dist/server/implementation/types.js +182 -0
  158. package/dist/server/implementation/types.js.map +1 -0
  159. package/dist/server/implementation/users.d.ts +27 -0
  160. package/dist/server/implementation/users.d.ts.map +1 -0
  161. package/dist/server/implementation/users.js +181 -0
  162. package/dist/server/implementation/users.js.map +1 -0
  163. package/dist/server/implementation/utils.d.ts +17 -0
  164. package/dist/server/implementation/utils.d.ts.map +1 -0
  165. package/dist/server/implementation/utils.js +72 -0
  166. package/dist/server/implementation/utils.js.map +1 -0
  167. package/dist/server/index.d.ts +17 -0
  168. package/dist/server/index.d.ts.map +1 -0
  169. package/dist/server/index.js +54 -0
  170. package/dist/server/index.js.map +1 -0
  171. package/dist/server/oauth/authorizationUrl.d.ts +13 -0
  172. package/dist/server/oauth/authorizationUrl.d.ts.map +1 -0
  173. package/dist/server/oauth/authorizationUrl.js +91 -0
  174. package/dist/server/oauth/authorizationUrl.js.map +1 -0
  175. package/dist/server/oauth/callback.d.ts +19 -0
  176. package/dist/server/oauth/callback.d.ts.map +1 -0
  177. package/dist/server/oauth/callback.js +173 -0
  178. package/dist/server/oauth/callback.js.map +1 -0
  179. package/dist/server/oauth/checks.d.ts +52 -0
  180. package/dist/server/oauth/checks.d.ts.map +1 -0
  181. package/dist/server/oauth/checks.js +106 -0
  182. package/dist/server/oauth/checks.js.map +1 -0
  183. package/dist/server/oauth/convexAuth.d.ts +12 -0
  184. package/dist/server/oauth/convexAuth.d.ts.map +1 -0
  185. package/dist/server/oauth/convexAuth.js +137 -0
  186. package/dist/server/oauth/convexAuth.js.map +1 -0
  187. package/dist/server/oauth/lib/utils/customFetch.d.ts +9 -0
  188. package/dist/server/oauth/lib/utils/customFetch.d.ts.map +1 -0
  189. package/dist/server/oauth/lib/utils/customFetch.js +11 -0
  190. package/dist/server/oauth/lib/utils/customFetch.js.map +1 -0
  191. package/dist/server/oauth/lib/utils/providers.d.ts +3 -0
  192. package/dist/server/oauth/lib/utils/providers.d.ts.map +1 -0
  193. package/dist/server/oauth/lib/utils/providers.js +7 -0
  194. package/dist/server/oauth/lib/utils/providers.js.map +1 -0
  195. package/dist/server/oauth/providers/oauth.d.ts +43 -0
  196. package/dist/server/oauth/providers/oauth.d.ts.map +1 -0
  197. package/dist/server/oauth/providers/oauth.js +3 -0
  198. package/dist/server/oauth/providers/oauth.js.map +1 -0
  199. package/dist/server/oauth/types.d.ts +24 -0
  200. package/dist/server/oauth/types.d.ts.map +1 -0
  201. package/dist/server/oauth/types.js +5 -0
  202. package/dist/server/oauth/types.js.map +1 -0
  203. package/dist/server/provider_utils.d.ts +76 -0
  204. package/dist/server/provider_utils.d.ts.map +1 -0
  205. package/dist/server/provider_utils.js +177 -0
  206. package/dist/server/provider_utils.js.map +1 -0
  207. package/dist/server/types.d.ts +412 -0
  208. package/dist/server/types.d.ts.map +1 -0
  209. package/dist/server/types.js +2 -0
  210. package/dist/server/types.js.map +1 -0
  211. package/dist/server/utils.d.ts +3 -0
  212. package/dist/server/utils.d.ts.map +1 -0
  213. package/dist/server/utils.js +11 -0
  214. package/dist/server/utils.js.map +1 -0
  215. package/package.json +126 -0
  216. package/providers/Anonymous/package.json +6 -0
  217. package/providers/ConvexCredentials/package.json +6 -0
  218. package/providers/Email/package.json +6 -0
  219. package/providers/Password/package.json +6 -0
  220. package/providers/Phone/package.json +6 -0
  221. package/server/package.json +6 -0
  222. package/src/cli/command.ts +69 -0
  223. package/src/cli/generateKeys.ts +20 -0
  224. package/src/cli/index.ts +840 -0
  225. package/src/client/index.ts +415 -0
  226. package/src/component/_generated/api.ts +52 -0
  227. package/src/component/_generated/component.ts +586 -0
  228. package/src/component/_generated/dataModel.ts +60 -0
  229. package/src/component/_generated/server.ts +156 -0
  230. package/src/component/convex.config.ts +5 -0
  231. package/src/component/index.ts +40 -0
  232. package/src/component/public.ts +607 -0
  233. package/src/component/schema.ts +35 -0
  234. package/src/providers/Anonymous.ts +79 -0
  235. package/src/providers/ConvexCredentials.ts +108 -0
  236. package/src/providers/Email.ts +60 -0
  237. package/src/providers/Password.ts +253 -0
  238. package/src/providers/Phone.ts +46 -0
  239. package/src/server/convex_types.ts +55 -0
  240. package/src/server/cookies.ts +42 -0
  241. package/src/server/implementation/db.ts +125 -0
  242. package/src/server/implementation/index.ts +815 -0
  243. package/src/server/implementation/mutations/createAccountFromCredentials.ts +113 -0
  244. package/src/server/implementation/mutations/createVerificationCode.ts +139 -0
  245. package/src/server/implementation/mutations/index.ts +157 -0
  246. package/src/server/implementation/mutations/invalidateSessions.ts +47 -0
  247. package/src/server/implementation/mutations/modifyAccount.ts +65 -0
  248. package/src/server/implementation/mutations/refreshSession.ts +188 -0
  249. package/src/server/implementation/mutations/retrieveAccountWithCredentials.ts +87 -0
  250. package/src/server/implementation/mutations/signIn.ts +51 -0
  251. package/src/server/implementation/mutations/signOut.ts +38 -0
  252. package/src/server/implementation/mutations/userOAuth.ts +112 -0
  253. package/src/server/implementation/mutations/verifier.ts +29 -0
  254. package/src/server/implementation/mutations/verifierSignature.ts +44 -0
  255. package/src/server/implementation/mutations/verifyCodeAndSignIn.ts +205 -0
  256. package/src/server/implementation/provider.ts +38 -0
  257. package/src/server/implementation/rateLimit.ts +105 -0
  258. package/src/server/implementation/redirects.ts +58 -0
  259. package/src/server/implementation/refreshTokens.ts +221 -0
  260. package/src/server/implementation/sessions.ts +155 -0
  261. package/src/server/implementation/signIn.ts +253 -0
  262. package/src/server/implementation/tokens.ts +29 -0
  263. package/src/server/implementation/types.ts +220 -0
  264. package/src/server/implementation/users.ts +286 -0
  265. package/src/server/implementation/utils.ts +91 -0
  266. package/src/server/index.ts +74 -0
  267. package/src/server/oauth/NOTICE.txt +21 -0
  268. package/src/server/oauth/README.md +7 -0
  269. package/src/server/oauth/authorizationUrl.ts +113 -0
  270. package/src/server/oauth/callback.ts +243 -0
  271. package/src/server/oauth/checks.ts +136 -0
  272. package/src/server/oauth/convexAuth.ts +168 -0
  273. package/src/server/oauth/lib/utils/customFetch.ts +18 -0
  274. package/src/server/oauth/lib/utils/providers.ts +12 -0
  275. package/src/server/oauth/providers/oauth.ts +56 -0
  276. package/src/server/oauth/types.ts +60 -0
  277. package/src/server/provider_utils.ts +222 -0
  278. package/src/server/types.ts +470 -0
  279. package/src/server/utils.ts +12 -0
  280. package/src/test.ts +24 -0
@@ -0,0 +1,412 @@
1
+ import { Provider as AuthjsProviderConfig, CredentialsConfig, EmailConfig as AuthjsEmailConfig, OAuth2Config, OIDCConfig } from "@auth/core/providers";
2
+ import { Theme } from "@auth/core/types";
3
+ import { AnyDataModel, FunctionReference, GenericActionCtx, GenericDataModel, GenericMutationCtx } from "convex/server";
4
+ import { GenericId, Value } from "convex/values";
5
+ import { ConvexCredentialsUserConfig } from "../providers/ConvexCredentials.js";
6
+ import { GenericDoc } from "./convex_types.js";
7
+ /**
8
+ * The config for the Convex Auth library, passed to `convexAuth`.
9
+ */
10
+ export type ConvexAuthConfig = {
11
+ /**
12
+ * A list of authentication provider configs.
13
+ *
14
+ * You can import existing configs from
15
+ * - `@auth/core/providers/<provider-name>`
16
+ * - `@robelest/convex-auth/providers/<provider-name>`
17
+ */
18
+ providers: AuthProviderConfig[];
19
+ /**
20
+ * Optional auth component reference from `components.auth`.
21
+ *
22
+ * When provided, core auth storage operations are executed through
23
+ * the component API boundary instead of direct table access.
24
+ */
25
+ component?: AuthComponentApi;
26
+ /**
27
+ * Theme used for emails.
28
+ * See [Auth.js theme docs](https://authjs.dev/reference/core/types#theme).
29
+ */
30
+ theme?: Theme;
31
+ /**
32
+ * Session configuration.
33
+ */
34
+ session?: {
35
+ /**
36
+ * How long can a user session last without the user reauthenticating.
37
+ *
38
+ * Defaults to 30 days.
39
+ */
40
+ totalDurationMs?: number;
41
+ /**
42
+ * How long can a user session last without the user being active.
43
+ *
44
+ * Defaults to 30 days.
45
+ */
46
+ inactiveDurationMs?: number;
47
+ };
48
+ /**
49
+ * JWT configuration.
50
+ */
51
+ jwt?: {
52
+ /**
53
+ * How long is the JWT valid for after it is signed initially.
54
+ *
55
+ * Defaults to 1 hour.
56
+ */
57
+ durationMs?: number;
58
+ };
59
+ /**
60
+ * Sign-in configuration.
61
+ */
62
+ signIn?: {
63
+ /**
64
+ * How many times can the user fail to provide the correct credentials
65
+ * (password, OTP) per hour.
66
+ *
67
+ * Defaults to 10 times per hour (that is 10 failed attempts, and then
68
+ * allow another one every 6 minutes).
69
+ */
70
+ maxFailedAttempsPerHour?: number;
71
+ };
72
+ callbacks?: {
73
+ /**
74
+ * Control which URLs are allowed as a destination after OAuth sign-in
75
+ * and for magic links:
76
+ *
77
+ * ```ts
78
+ * import GitHub from "@auth/core/providers/github";
79
+ * import { convexAuth } from "@robelest/convex-auth/component";
80
+ *
81
+ * export const { auth, signIn, signOut, store } = convexAuth({
82
+ * providers: [GitHub],
83
+ * callbacks: {
84
+ * async redirect({ redirectTo }) {
85
+ * // Check that `redirectTo` is valid
86
+ * // and return the relative or absolute URL
87
+ * // to redirect to.
88
+ * },
89
+ * },
90
+ * });
91
+ * ```
92
+ *
93
+ * Convex Auth performs redirect only during OAuth sign-in. By default,
94
+ * it redirects back to the URL specified via the `SITE_URL` environment
95
+ * variable. Similarly magic links link to `SITE_URL`.
96
+ *
97
+ * You can customize that behavior by providing a `redirectTo` param
98
+ * to the `signIn` function:
99
+ *
100
+ * ```ts
101
+ * signIn("google", { redirectTo: "/dashboard" })
102
+ * ```
103
+ *
104
+ * You can even redirect to a different site.
105
+ *
106
+ * This callback, if specified, is then called with the provided
107
+ * `redirectTo` param. Otherwise, only query params, relative paths
108
+ * and URLs starting with `SITE_URL` are allowed.
109
+ */
110
+ redirect?: (params: {
111
+ /**
112
+ * The param value passed to the `signIn` function.
113
+ */
114
+ redirectTo: string;
115
+ }) => Promise<string>;
116
+ /**
117
+ * Completely control account linking via this callback.
118
+ *
119
+ * This callback is called during the sign-in process,
120
+ * before account creation and token generation.
121
+ * If specified, this callback is responsible for creating
122
+ * or updating the user document.
123
+ *
124
+ * For "credentials" providers, the callback is only called
125
+ * when `createAccount` is called.
126
+ */
127
+ createOrUpdateUser?: (ctx: GenericMutationCtx<AnyDataModel>, args: {
128
+ /**
129
+ * If this is a sign-in to an existing account,
130
+ * this is the existing user ID linked to that account.
131
+ */
132
+ existingUserId: GenericId<"user"> | null;
133
+ /**
134
+ * The provider type or "verification" if this callback is called
135
+ * after an email or phone token verification.
136
+ */
137
+ type: "oauth" | "credentials" | "email" | "phone" | "verification";
138
+ /**
139
+ * The provider used for the sign-in, or the provider
140
+ * tied to the account which is having the email or phone verified.
141
+ */
142
+ provider: AuthProviderMaterializedConfig;
143
+ /**
144
+ * - The profile returned by the OAuth provider's `profile` method.
145
+ * - The profile passed to `createAccount` from a ConvexCredentials
146
+ * config.
147
+ * - The email address to which an email will be sent.
148
+ * - The phone number to which a text will be sent.
149
+ */
150
+ profile: Record<string, unknown> & {
151
+ email?: string;
152
+ phone?: string;
153
+ emailVerified?: boolean;
154
+ phoneVerified?: boolean;
155
+ };
156
+ /**
157
+ * The `shouldLink` argument passed to `createAccount`.
158
+ */
159
+ shouldLink?: boolean;
160
+ }) => Promise<GenericId<"user">>;
161
+ /**
162
+ * Perform additional writes after a user is created.
163
+ *
164
+ * This callback is called during the sign-in process,
165
+ * after the user is created or updated,
166
+ * before account creation and token generation.
167
+ *
168
+ * **This callback is only called if `createOrUpdateUser`
169
+ * is not specified.** If `createOrUpdateUser` is specified,
170
+ * you can perform any additional writes in that callback.
171
+ *
172
+ * For "credentials" providers, the callback is only called
173
+ * when `createAccount` is called.
174
+ */
175
+ afterUserCreatedOrUpdated?: (ctx: GenericMutationCtx<AnyDataModel>, args: {
176
+ /**
177
+ * The ID of the user that is being signed in.
178
+ */
179
+ userId: GenericId<"user">;
180
+ /**
181
+ * If this is a sign-in to an existing account,
182
+ * this is the existing user ID linked to that account.
183
+ */
184
+ existingUserId: GenericId<"user"> | null;
185
+ /**
186
+ * The provider type or "verification" if this callback is called
187
+ * after an email or phone token verification.
188
+ */
189
+ type: "oauth" | "credentials" | "email" | "phone" | "verification";
190
+ /**
191
+ * The provider used for the sign-in, or the provider
192
+ * tied to the account which is having the email or phone verified.
193
+ */
194
+ provider: AuthProviderMaterializedConfig;
195
+ /**
196
+ * - The profile returned by the OAuth provider's `profile` method.
197
+ * - The profile passed to `createAccount` from a ConvexCredentials
198
+ * config.
199
+ * - The email address to which an email will be sent.
200
+ * - The phone number to which a text will be sent.
201
+ */
202
+ profile: Record<string, unknown> & {
203
+ email?: string;
204
+ phone?: string;
205
+ emailVerified?: boolean;
206
+ phoneVerified?: boolean;
207
+ };
208
+ /**
209
+ * The `shouldLink` argument passed to `createAccount`.
210
+ */
211
+ shouldLink?: boolean;
212
+ }) => Promise<void>;
213
+ };
214
+ };
215
+ /**
216
+ * Same as Auth.js provider configs, but adds phone provider
217
+ * for verification via SMS or another phone-number-connected messaging
218
+ * service.
219
+ */
220
+ export type AuthProviderConfig = Exclude<AuthjsProviderConfig, CredentialsConfig | ((...args: any) => CredentialsConfig)> | ConvexCredentialsConfig | ((...args: any) => ConvexCredentialsConfig) | PhoneConfig | ((...args: any) => PhoneConfig);
221
+ /**
222
+ * Extends the standard Auth.js email provider config
223
+ * to allow additional checks during token verification.
224
+ */
225
+ export interface EmailConfig<DataModel extends GenericDataModel = GenericDataModel> extends AuthjsEmailConfig {
226
+ /**
227
+ * Before the token is verified, check other
228
+ * provided parameters.
229
+ *
230
+ * Used to make sure tha OTPs are accompanied
231
+ * with the correct email address.
232
+ */
233
+ authorize?: (
234
+ /**
235
+ * The values passed to the `signIn` function.
236
+ */
237
+ params: Record<string, Value | undefined>, account: GenericDoc<DataModel, "account">) => Promise<void>;
238
+ }
239
+ /**
240
+ * Configurable options for an email provider config.
241
+ */
242
+ export type EmailUserConfig<DataModel extends GenericDataModel = GenericDataModel> = Omit<Partial<EmailConfig<DataModel>>, "options" | "type">;
243
+ /**
244
+ * Same as email provider config, but verifies
245
+ * phone number instead of the email address.
246
+ */
247
+ export interface PhoneConfig<DataModel extends GenericDataModel = GenericDataModel> {
248
+ id: string;
249
+ type: "phone";
250
+ /**
251
+ * Token expiration in seconds.
252
+ */
253
+ maxAge: number;
254
+ /**
255
+ * Send the phone number verification request.
256
+ */
257
+ sendVerificationRequest: (params: {
258
+ identifier: string;
259
+ url: string;
260
+ expires: Date;
261
+ provider: PhoneConfig;
262
+ token: string;
263
+ }, ctx: GenericActionCtxWithAuthConfig<DataModel>) => Promise<void>;
264
+ /**
265
+ * Defaults to `process.env.AUTH_<PROVIDER_ID>_KEY`.
266
+ */
267
+ apiKey?: string;
268
+ /**
269
+ * Override this to generate a custom token.
270
+ * Note that the tokens are assumed to be cryptographically secure.
271
+ * Any tokens shorter than 24 characters are assumed to not
272
+ * be secure enough on their own, and require providing
273
+ * the original `phone` used in the initial `signIn` call.
274
+ * @returns
275
+ */
276
+ generateVerificationToken?: () => Promise<string>;
277
+ /**
278
+ * Normalize the phone number.
279
+ * @param identifier Passed as `phone` in params of `signIn`.
280
+ * @returns The phone number used in `sendVerificationRequest`.
281
+ */
282
+ normalizeIdentifier?: (identifier: string) => string;
283
+ /**
284
+ * Before the token is verified, check other
285
+ * provided parameters.
286
+ *
287
+ * Used to make sure tha OTPs are accompanied
288
+ * with the correct phone number.
289
+ */
290
+ authorize?: (
291
+ /**
292
+ * The values passed to the `signIn` function.
293
+ */
294
+ params: Record<string, Value | undefined>, account: GenericDoc<DataModel, "account">) => Promise<void>;
295
+ options: PhoneUserConfig<DataModel>;
296
+ }
297
+ /**
298
+ * Configurable options for a phone provider config.
299
+ */
300
+ export type PhoneUserConfig<DataModel extends GenericDataModel = GenericDataModel> = Omit<Partial<PhoneConfig<DataModel>>, "options" | "type">;
301
+ /**
302
+ * Similar to Auth.js Credentials config.
303
+ */
304
+ export type ConvexCredentialsConfig = ConvexCredentialsUserConfig<any> & {
305
+ type: "credentials";
306
+ id: string;
307
+ };
308
+ /**
309
+ * Your `ActionCtx` enriched with `ctx.auth.config` field with
310
+ * the config passed to `convexAuth`.
311
+ */
312
+ export type GenericActionCtxWithAuthConfig<DataModel extends GenericDataModel> = GenericActionCtx<DataModel> & {
313
+ auth: {
314
+ config: ConvexAuthMaterializedConfig;
315
+ };
316
+ };
317
+ /**
318
+ * The config for the Convex Auth library, passed to `convexAuth`,
319
+ * with defaults and initialized providers.
320
+ *
321
+ * See {@link ConvexAuthConfig}
322
+ */
323
+ export type ConvexAuthMaterializedConfig = {
324
+ providers: AuthProviderMaterializedConfig[];
325
+ theme: Theme;
326
+ } & Pick<ConvexAuthConfig, "component" | "session" | "jwt" | "signIn" | "callbacks">;
327
+ /**
328
+ * Materialized Auth.js provider config.
329
+ */
330
+ export type AuthProviderMaterializedConfig = OIDCConfig<any> | OAuth2Config<any> | EmailConfig | PhoneConfig | ConvexCredentialsConfig;
331
+ /**
332
+ * Component function references required by core auth runtime.
333
+ */
334
+ export type AuthComponentApi = {
335
+ public: {
336
+ userGetById: FunctionReference<"query", "internal">;
337
+ userFindByVerifiedEmail: FunctionReference<"query", "internal">;
338
+ userFindByVerifiedPhone: FunctionReference<"query", "internal">;
339
+ userInsert: FunctionReference<"mutation", "internal">;
340
+ userUpsert: FunctionReference<"mutation", "internal">;
341
+ userPatch: FunctionReference<"mutation", "internal">;
342
+ accountGet: FunctionReference<"query", "internal">;
343
+ accountGetById: FunctionReference<"query", "internal">;
344
+ accountInsert: FunctionReference<"mutation", "internal">;
345
+ accountPatch: FunctionReference<"mutation", "internal">;
346
+ accountDelete: FunctionReference<"mutation", "internal">;
347
+ sessionCreate: FunctionReference<"mutation", "internal">;
348
+ sessionGetById: FunctionReference<"query", "internal">;
349
+ sessionDelete: FunctionReference<"mutation", "internal">;
350
+ sessionListByUser: FunctionReference<"query", "internal">;
351
+ verifierCreate: FunctionReference<"mutation", "internal">;
352
+ verifierGetById: FunctionReference<"query", "internal">;
353
+ verifierGetBySignature: FunctionReference<"query", "internal">;
354
+ verifierPatch: FunctionReference<"mutation", "internal">;
355
+ verifierDelete: FunctionReference<"mutation", "internal">;
356
+ verificationCodeGetByAccountId: FunctionReference<"query", "internal">;
357
+ verificationCodeGetByCode: FunctionReference<"query", "internal">;
358
+ verificationCodeCreate: FunctionReference<"mutation", "internal">;
359
+ verificationCodeDelete: FunctionReference<"mutation", "internal">;
360
+ verificationGetByAccountId?: FunctionReference<"query", "internal">;
361
+ verificationGetByCode?: FunctionReference<"query", "internal">;
362
+ verificationCreate?: FunctionReference<"mutation", "internal">;
363
+ verificationDelete?: FunctionReference<"mutation", "internal">;
364
+ refreshTokenCreate: FunctionReference<"mutation", "internal">;
365
+ refreshTokenGetById: FunctionReference<"query", "internal">;
366
+ refreshTokenPatch: FunctionReference<"mutation", "internal">;
367
+ refreshTokenGetChildren: FunctionReference<"query", "internal">;
368
+ refreshTokenListBySession: FunctionReference<"query", "internal">;
369
+ refreshTokenDeleteAll: FunctionReference<"mutation", "internal">;
370
+ refreshTokenGetActive: FunctionReference<"query", "internal">;
371
+ tokenCreate?: FunctionReference<"mutation", "internal">;
372
+ tokenGetById?: FunctionReference<"query", "internal">;
373
+ tokenPatch?: FunctionReference<"mutation", "internal">;
374
+ tokenGetChildren?: FunctionReference<"query", "internal">;
375
+ tokenListBySession?: FunctionReference<"query", "internal">;
376
+ tokenDeleteAll?: FunctionReference<"mutation", "internal">;
377
+ tokenGetActive?: FunctionReference<"query", "internal">;
378
+ rateLimitGet: FunctionReference<"query", "internal">;
379
+ rateLimitCreate: FunctionReference<"mutation", "internal">;
380
+ rateLimitPatch: FunctionReference<"mutation", "internal">;
381
+ rateLimitDelete: FunctionReference<"mutation", "internal">;
382
+ limitGet?: FunctionReference<"query", "internal">;
383
+ limitCreate?: FunctionReference<"mutation", "internal">;
384
+ limitPatch?: FunctionReference<"mutation", "internal">;
385
+ limitDelete?: FunctionReference<"mutation", "internal">;
386
+ organizationCreate?: FunctionReference<"mutation", "internal">;
387
+ organizationGet?: FunctionReference<"query", "internal">;
388
+ organizationList?: FunctionReference<"query", "internal">;
389
+ organizationUpdate?: FunctionReference<"mutation", "internal">;
390
+ organizationDelete?: FunctionReference<"mutation", "internal">;
391
+ teamCreate?: FunctionReference<"mutation", "internal">;
392
+ teamGet?: FunctionReference<"query", "internal">;
393
+ teamListByOrganization?: FunctionReference<"query", "internal">;
394
+ teamUpdate?: FunctionReference<"mutation", "internal">;
395
+ teamDelete?: FunctionReference<"mutation", "internal">;
396
+ teamRelationCreate?: FunctionReference<"mutation", "internal">;
397
+ teamRelationGet?: FunctionReference<"query", "internal">;
398
+ teamRelationListByParent?: FunctionReference<"query", "internal">;
399
+ teamRelationDelete?: FunctionReference<"mutation", "internal">;
400
+ memberAdd?: FunctionReference<"mutation", "internal">;
401
+ memberRemove?: FunctionReference<"mutation", "internal">;
402
+ memberList?: FunctionReference<"query", "internal">;
403
+ memberRoleSet?: FunctionReference<"mutation", "internal">;
404
+ memberRoleGet?: FunctionReference<"query", "internal">;
405
+ inviteCreate?: FunctionReference<"mutation", "internal">;
406
+ inviteGet?: FunctionReference<"query", "internal">;
407
+ inviteList?: FunctionReference<"query", "internal">;
408
+ inviteAccept?: FunctionReference<"mutation", "internal">;
409
+ inviteRevoke?: FunctionReference<"mutation", "internal">;
410
+ };
411
+ };
412
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/server/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,IAAI,oBAAoB,EAChC,iBAAiB,EACjB,WAAW,IAAI,iBAAiB,EAChC,YAAY,EACZ,UAAU,EACX,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,EAChB,kBAAkB,EACnB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,2BAA2B,EAAE,MAAM,mCAAmC,CAAC;AAChF,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B;;;;;;OAMG;IACH,SAAS,EAAE,kBAAkB,EAAE,CAAC;IAChC;;;;;OAKG;IACH,SAAS,CAAC,EAAE,gBAAgB,CAAC;IAC7B;;;OAGG;IACH,KAAK,CAAC,EAAE,KAAK,CAAC;IACd;;OAEG;IACH,OAAO,CAAC,EAAE;QACR;;;;WAIG;QACH,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB;;;;WAIG;QACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;KAC7B,CAAC;IACF;;OAEG;IACH,GAAG,CAAC,EAAE;QACJ;;;;WAIG;QACH,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,CAAC;IACF;;OAEG;IACH,MAAM,CAAC,EAAE;QACP;;;;;;WAMG;QACH,uBAAuB,CAAC,EAAE,MAAM,CAAC;KAClC,CAAC;IACF,SAAS,CAAC,EAAE;QACV;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;WAoCG;QACH,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE;YAClB;;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pD,aAAa,CAAC,EAAE,iBAAiB,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;QAC1D,aAAa,CAAC,EAAE,iBAAiB,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;QACvD,YAAY,CAAC,EAAE,iBAAiB,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;QACzD,SAAS,CAAC,EAAE,iBAAiB,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;QACnD,UAAU,CAAC,EAAE,iBAAiB,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;QACpD,YAAY,CAAC,EAAE,iBAAiB,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;QACzD,YAAY,CAAC,EAAE,iBAAiB,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;KAC1D,CAAC;CACH,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/server/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ export declare function requireEnv(name: string): string;
2
+ export declare function isLocalHost(host?: string): boolean;
3
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/server/utils.ts"],"names":[],"mappings":"AAAA,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,UAMtC;AAED,wBAAgB,WAAW,CAAC,IAAI,CAAC,EAAE,MAAM,WAGxC"}
@@ -0,0 +1,11 @@
1
+ export function requireEnv(name) {
2
+ const value = process.env[name];
3
+ if (value === undefined) {
4
+ throw new Error(`Missing environment variable \`${name}\``);
5
+ }
6
+ return value;
7
+ }
8
+ export function isLocalHost(host) {
9
+ return /(localhost|127\.0\.0\.1):\d+/.test(host ?? "");
10
+ }
11
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/server/utils.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,UAAU,CAAC,IAAY;IACrC,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAChC,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CAAC,kCAAkC,IAAI,IAAI,CAAC,CAAC;IAC9D,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,IAAa;IACvC,OAAO,8BAA8B,CAAC,IAAI,CAC1C,IAAI,IAAI,EAAE,CAAC,CAAC;AACd,CAAC"}
package/package.json ADDED
@@ -0,0 +1,126 @@
1
+ {
2
+ "name": "@robelest/convex-auth",
3
+ "version": "0.0.1",
4
+ "description": "Authentication for Convex",
5
+ "keywords": [
6
+ "authentication",
7
+ "authorization",
8
+ "auth",
9
+ "login",
10
+ "sign",
11
+ "convex"
12
+ ],
13
+ "homepage": "https://labs.convex.dev/auth",
14
+ "bugs": "https://github.com/robelest/convex-auth/issues",
15
+ "repository": "https://github.com/robelest/convex-auth",
16
+ "license": "Apache-2.0",
17
+ "author": "xixixao",
18
+ "files": [
19
+ "dist",
20
+ "providers",
21
+ "server",
22
+ "src"
23
+ ],
24
+ "type": "module",
25
+ "bin": "./dist/bin.cjs",
26
+ "sideEffects": false,
27
+ "scripts": {
28
+ "build:bin": "esbuild src/cli/index.ts --bundle --platform=node --format=cjs --outfile=dist/bin.cjs",
29
+ "build:server": "tsc --project tsconfig.server.json",
30
+ "build:client": "tsc --project tsconfig.client.json",
31
+ "build:component": "tsc --project tsconfig.component.json",
32
+ "build": "rm -rf dist && bun run build:bin && bun run build:server && bun run build:client && bun run build:component",
33
+ "docs": "bun run --cwd ../../docs dev",
34
+ "lint": "tsc && bun run --cwd ../.. lint",
35
+ "spellcheck": "cspell \"docs/pages/**/*.md*\"",
36
+ "prepare": "bun run build",
37
+ "prepublishOnly": "bun run lint && bun run build && bun run test:once",
38
+ "publish:example": "node publishExample.mjs",
39
+ "test": "bun run --cwd ../../examples/vite test",
40
+ "test:once": "bun run --cwd ../../examples/vite test:once",
41
+ "convex:dev": "bunx convex dev",
42
+ "convex:codegen": "bunx convex codegen && bun run convex:codegen:component",
43
+ "convex:codegen:component": "bunx convex codegen --component-dir ./src/component",
44
+ "convex:dashboard": "bunx convex dashboard",
45
+ "convex:run": "bunx convex run"
46
+ },
47
+ "exports": {
48
+ "./_generated/component.js": {
49
+ "types": "./dist/component/_generated/component.d.ts"
50
+ },
51
+ "./test": "./src/test.ts",
52
+ "./client": {
53
+ "types": "./dist/client/index.d.ts",
54
+ "import": "./dist/client/index.js"
55
+ },
56
+ "./server": {
57
+ "types": "./dist/server/index.d.ts",
58
+ "import": "./dist/server/index.js"
59
+ },
60
+ "./component": {
61
+ "types": "./dist/component/index.d.ts",
62
+ "import": "./dist/component/index.js"
63
+ },
64
+ "./convex.config": {
65
+ "types": "./dist/component/convex.config.d.ts",
66
+ "default": "./dist/component/convex.config.js"
67
+ },
68
+ "./convex.config.js": {
69
+ "types": "./dist/component/convex.config.d.ts",
70
+ "default": "./dist/component/convex.config.js"
71
+ },
72
+ "./providers/*": {
73
+ "types": "./dist/providers/*.d.ts",
74
+ "import": "./dist/providers/*.js"
75
+ }
76
+ },
77
+ "dependencies": {
78
+ "@oslojs/crypto": "^1.0.1",
79
+ "@oslojs/encoding": "^1.1.0",
80
+ "cookie": "^1.1.1",
81
+ "jose": "^6.1.3",
82
+ "jwt-decode": "^4.0.0",
83
+ "lucia": "^3.2.2",
84
+ "oauth4webapi": "^3.8.4",
85
+ "path-to-regexp": "^6.3.0"
86
+ },
87
+ "peerDependencies": {
88
+ "@auth/core": "^0.37.0",
89
+ "convex": "^1.31.7"
90
+ },
91
+ "@comment devDependencies": [
92
+ "The dependencies of the CLI are also in devDependencies, built into",
93
+ "a bundle."
94
+ ],
95
+ "devDependencies": {
96
+ "@auth/core": "0.37.3",
97
+ "@convex-dev/resend": "^0.2.3",
98
+ "@commander-js/extra-typings": "^14.0.0",
99
+ "@edge-runtime/vm": "^5.0.0",
100
+ "@types/inquirer": "^9.0.9",
101
+ "@types/node": "25.2.2",
102
+ "@types/react": "^19.2.13",
103
+ "@typescript-eslint/eslint-plugin": "^8.55.0",
104
+ "chalk": "^5.6.2",
105
+ "convex": "^1.31.7",
106
+ "convex-test": "^0.0.41",
107
+ "cspell": "^9.6.4",
108
+ "dotenv": "^17.2.4",
109
+ "esbuild": "^0.27.3",
110
+ "eslint": "^9.39.0",
111
+ "inquirer": "^13.2.2",
112
+ "next": "^16.1.6",
113
+ "npm-run-all": "^4.1.5",
114
+ "react-dom": "^19.2.4",
115
+ "shelljs": "^0.10.0",
116
+ "tsup": "^8.5.1",
117
+ "twilio": "^5.2.0",
118
+ "typescript": "^5.9.3",
119
+ "valibot": "^1.2.0",
120
+ "vitest": "^4.0.18"
121
+ },
122
+ "overrides": {
123
+ "@auth/core": "0.37.3",
124
+ "path-to-regexp": "^6.3.0"
125
+ }
126
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "type": "module",
3
+ "main": "../../dist/providers/Anonymous/index.js",
4
+ "module": "../../dist/providers/Anonymous/index.js",
5
+ "types": "../../dist/providers/Anonymous/index.d.ts"
6
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "type": "module",
3
+ "main": "../../dist/providers/ConvexCredentials/index.js",
4
+ "module": "../../dist/providers/ConvexCredentials/index.js",
5
+ "types": "../../dist/providers/ConvexCredentials/index.d.ts"
6
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "type": "module",
3
+ "main": "../../dist/providers/Email/index.js",
4
+ "module": "../../dist/providers/Email/index.js",
5
+ "types": "../../dist/providers/Email/index.d.ts"
6
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "type": "module",
3
+ "main": "../../dist/providers/Password/index.js",
4
+ "module": "../../dist/providers/Password/index.js",
5
+ "types": "../../dist/providers/Password/index.d.ts"
6
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "type": "module",
3
+ "main": "../../dist/providers/Phone/index.js",
4
+ "module": "../../dist/providers/Phone/index.js",
5
+ "types": "../../dist/providers/Phone/index.d.ts"
6
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "type": "module",
3
+ "main": "../dist/server/index.js",
4
+ "module": "../dist/server/index.js",
5
+ "types": "../dist/server/index.d.ts"
6
+ }