@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,94 @@
1
+ import { LOG_LEVELS, TOKEN_SUB_CLAIM_DIVIDER, logWithLevel, maybeRedact, stringToNumber, } from "./utils.js";
2
+ import { generateToken } from "./tokens.js";
3
+ import { createRefreshToken, formatRefreshToken, deleteAllRefreshTokens, } from "./refreshTokens.js";
4
+ import { createAuthDb } from "./db.js";
5
+ const DEFAULT_SESSION_TOTAL_DURATION_MS = 1000 * 60 * 60 * 24 * 30; // 30 days
6
+ export async function maybeGenerateTokensForSession(ctx, config, userId, sessionId, generateTokens) {
7
+ return {
8
+ userId,
9
+ sessionId,
10
+ tokens: generateTokens
11
+ ? await generateTokensForSession(ctx, config, {
12
+ userId,
13
+ sessionId,
14
+ issuedRefreshTokenId: null,
15
+ parentRefreshTokenId: null,
16
+ })
17
+ : null,
18
+ };
19
+ }
20
+ export async function createNewAndDeleteExistingSession(ctx, config, userId) {
21
+ const authDb = config.component !== undefined ? createAuthDb(ctx, config.component) : null;
22
+ const existingSessionId = await getAuthSessionId(ctx);
23
+ if (existingSessionId !== null) {
24
+ const existingSession = authDb !== null
25
+ ? await authDb.sessions.getById(existingSessionId)
26
+ : await ctx.db.get(existingSessionId);
27
+ if (existingSession !== null) {
28
+ await deleteSession(ctx, existingSession, config);
29
+ }
30
+ }
31
+ return await createSession(ctx, userId, config);
32
+ }
33
+ export async function generateTokensForSession(ctx, config, args) {
34
+ const ids = { userId: args.userId, sessionId: args.sessionId };
35
+ const refreshTokenId = args.issuedRefreshTokenId ??
36
+ (await createRefreshToken(ctx, config, args.sessionId, args.parentRefreshTokenId));
37
+ const result = {
38
+ token: await generateToken(ids, config),
39
+ refreshToken: formatRefreshToken(refreshTokenId, args.sessionId),
40
+ };
41
+ logWithLevel(LOG_LEVELS.DEBUG, `Generated token ${maybeRedact(result.token)} and refresh token ${maybeRedact(refreshTokenId)} for session ${maybeRedact(args.sessionId)}`);
42
+ return result;
43
+ }
44
+ async function createSession(ctx, userId, config) {
45
+ const expirationTime = Date.now() +
46
+ (config.session?.totalDurationMs ??
47
+ stringToNumber(process.env.AUTH_SESSION_TOTAL_DURATION_MS) ??
48
+ DEFAULT_SESSION_TOTAL_DURATION_MS);
49
+ if (config.component !== undefined) {
50
+ return (await createAuthDb(ctx, config.component).sessions.create(userId, expirationTime));
51
+ }
52
+ return await ctx.db.insert("session", { expirationTime, userId });
53
+ }
54
+ export async function deleteSession(ctx, session, config) {
55
+ if (config.component !== undefined) {
56
+ await createAuthDb(ctx, config.component).sessions.delete(session._id);
57
+ }
58
+ else {
59
+ await ctx.db.delete(session._id);
60
+ }
61
+ await deleteAllRefreshTokens(ctx, session._id, config);
62
+ }
63
+ /**
64
+ * Return the current session ID.
65
+ *
66
+ * ```ts filename="convex/myFunctions.tsx"
67
+ * import { mutation } from "./_generated/server";
68
+ * import { getAuthSessionId } from "@robelest/convex-auth/component";
69
+ *
70
+ * export const doSomething = mutation({
71
+ * args: {/* ... *\/},
72
+ * handler: async (ctx, args) => {
73
+ * const sessionId = await getAuthSessionId(ctx);
74
+ * if (sessionId === null) {
75
+ * throw new Error("Client is not authenticated!")
76
+ * }
77
+ * const session = await ctx.db.get(sessionId);
78
+ * // ...
79
+ * },
80
+ * });
81
+ * ```
82
+ *
83
+ * @param ctx query, mutation or action `ctx`
84
+ * @returns the session ID or `null` if the client isn't authenticated
85
+ */
86
+ export async function getAuthSessionId(ctx) {
87
+ const identity = await ctx.auth.getUserIdentity();
88
+ if (identity === null) {
89
+ return null;
90
+ }
91
+ const [, sessionId] = identity.subject.split(TOKEN_SUB_CLAIM_DIVIDER);
92
+ return sessionId;
93
+ }
94
+ //# sourceMappingURL=sessions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sessions.js","sourceRoot":"","sources":["../../../src/server/implementation/sessions.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,UAAU,EACV,uBAAuB,EACvB,YAAY,EACZ,WAAW,EACX,cAAc,GACf,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,sBAAsB,GACvB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,MAAM,iCAAiC,GAAG,IAAI,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,UAAU;AAE9E,MAAM,CAAC,KAAK,UAAU,6BAA6B,CACjD,GAAgB,EAChB,MAAwB,EACxB,MAAyB,EACzB,SAA+B,EAC/B,cAAuB;IAEvB,OAAO;QACL,MAAM;QACN,SAAS;QACT,MAAM,EAAE,cAAc;YACpB,CAAC,CAAC,MAAM,wBAAwB,CAAC,GAAG,EAAE,MAAM,EAAE;gBAC1C,MAAM;gBACN,SAAS;gBACT,oBAAoB,EAAE,IAAI;gBAC1B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AAC,CAAC;IACnC,CAAC;IACD,MAAM,sBAAsB,CAAC,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;AACzD,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,GAAmB;IACxD,MAAM,QAAQ,GAAG,MAAM,GAAG,CAAC,IAAI,CAAC,eAAe,EAAE,CAAC;IAClD,IAAI,QAAQ,KAAK,IAAI,EAAE,CAAC;QACtB,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAM,CAAC,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,uBAAuB,CAAC,CAAC;IACtE,OAAO,SAAiC,CAAC;AAC3C,CAAC"}
@@ -0,0 +1,31 @@
1
+ import { GenericId } from "convex/values";
2
+ import { AuthProviderMaterializedConfig, GenericActionCtxWithAuthConfig } from "../types.js";
3
+ import { AuthDataModel, SessionInfo, Tokens } from "./types.js";
4
+ type EnrichedActionCtx = GenericActionCtxWithAuthConfig<AuthDataModel>;
5
+ export declare function signInImpl(ctx: EnrichedActionCtx, provider: AuthProviderMaterializedConfig | null, args: {
6
+ accountId?: GenericId<"account">;
7
+ params?: Record<string, any>;
8
+ verifier?: string;
9
+ refreshToken?: string;
10
+ calledBy?: string;
11
+ }, options: {
12
+ generateTokens: boolean;
13
+ allowExtraProviders: boolean;
14
+ }): Promise<{
15
+ kind: "signedIn";
16
+ signedIn: SessionInfo | null;
17
+ } | {
18
+ kind: "refreshTokens";
19
+ signedIn: {
20
+ tokens: Tokens;
21
+ };
22
+ } | {
23
+ kind: "started";
24
+ started: true;
25
+ } | {
26
+ kind: "redirect";
27
+ redirect: string;
28
+ verifier: string;
29
+ }>;
30
+ export {};
31
+ //# sourceMappingURL=signIn.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signIn.d.ts","sourceRoot":"","sources":["../../../src/server/implementation/signIn.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EACL,8BAA8B,EAG9B,8BAA8B,EAE/B,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,aAAa,EACb,WAAW,EAEX,MAAM,EACP,MAAM,YAAY,CAAC;AAepB,KAAK,iBAAiB,GAAG,8BAA8B,CAAC,aAAa,CAAC,CAAC;AAEvE,wBAAsB,UAAU,CAC9B,GAAG,EAAE,iBAAiB,EACtB,QAAQ,EAAE,8BAA8B,GAAG,IAAI,EAC/C,IAAI,EAAE;IACJ,SAAS,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IACjC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC7B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,EACD,OAAO,EAAE;IACP,cAAc,EAAE,OAAO,CAAC;IACxB,mBAAmB,EAAE,OAAO,CAAC;CAC9B,GACA,OAAO,CACN;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,QAAQ,EAAE,WAAW,GAAG,IAAI,CAAA;CAAE,GAElD;IAAE,IAAI,EAAE,eAAe,CAAC;IAAC,QAAQ,EAAE;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,GAEvD;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,OAAO,EAAE,IAAI,CAAA;CAAE,GAElC;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAC3D,CAsCA"}
@@ -0,0 +1,148 @@
1
+ import { callCreateVerificationCode, callRefreshSession, callSignIn, callVerifier, callVerifyCodeAndSignIn, } from "./mutations/index.js";
2
+ import { redirectAbsoluteUrl, setURLSearchParam } from "./redirects.js";
3
+ import { requireEnv } from "../utils.js";
4
+ import { generateRandomString } from "./utils.js";
5
+ const DEFAULT_EMAIL_VERIFICATION_CODE_DURATION_S = 60 * 60 * 24; // 24 hours
6
+ export async function signInImpl(ctx, provider, args, options) {
7
+ if (provider === null && args.refreshToken) {
8
+ const tokens = (await callRefreshSession(ctx, {
9
+ refreshToken: args.refreshToken,
10
+ }));
11
+ return { kind: "refreshTokens", signedIn: { tokens } };
12
+ }
13
+ if (provider === null && args.params?.code !== undefined) {
14
+ const result = await callVerifyCodeAndSignIn(ctx, {
15
+ params: args.params,
16
+ verifier: args.verifier,
17
+ generateTokens: true,
18
+ allowExtraProviders: options.allowExtraProviders,
19
+ });
20
+ return {
21
+ kind: "signedIn",
22
+ signedIn: result,
23
+ };
24
+ }
25
+ if (provider === null) {
26
+ throw new Error("Cannot sign in: Missing `provider`, `params.code` or `refreshToken`");
27
+ }
28
+ if (provider.type === "email" || provider.type === "phone") {
29
+ return handleEmailAndPhoneProvider(ctx, provider, args, options);
30
+ }
31
+ if (provider.type === "credentials") {
32
+ return handleCredentials(ctx, provider, args, options);
33
+ }
34
+ if (provider.type === "oauth" || provider.type === "oidc") {
35
+ return handleOAuthProvider(ctx, provider, args, options);
36
+ }
37
+ const _typecheck = provider;
38
+ throw new Error(`Provider type ${provider.type} is not supported yet`);
39
+ }
40
+ async function handleEmailAndPhoneProvider(ctx, provider, args, options) {
41
+ if (args.params?.code !== undefined) {
42
+ const result = await callVerifyCodeAndSignIn(ctx, {
43
+ params: args.params,
44
+ provider: provider.id,
45
+ generateTokens: options.generateTokens,
46
+ allowExtraProviders: options.allowExtraProviders,
47
+ });
48
+ if (result === null) {
49
+ throw new Error("Could not verify code");
50
+ }
51
+ return {
52
+ kind: "signedIn",
53
+ signedIn: result,
54
+ };
55
+ }
56
+ const alphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
57
+ const code = provider.generateVerificationToken
58
+ ? await provider.generateVerificationToken()
59
+ : generateRandomString(32, alphabet);
60
+ const expirationTime = Date.now() +
61
+ (provider.maxAge ?? DEFAULT_EMAIL_VERIFICATION_CODE_DURATION_S) * 1000;
62
+ const identifier = await callCreateVerificationCode(ctx, {
63
+ provider: provider.id,
64
+ accountId: args.accountId,
65
+ email: args.params?.email,
66
+ phone: args.params?.phone,
67
+ code,
68
+ expirationTime,
69
+ allowExtraProviders: options.allowExtraProviders,
70
+ });
71
+ const destination = await redirectAbsoluteUrl(ctx.auth.config, (args.params ?? {}));
72
+ const verificationArgs = {
73
+ identifier,
74
+ url: setURLSearchParam(destination, "code", code),
75
+ token: code,
76
+ expires: new Date(expirationTime),
77
+ };
78
+ if (provider.type === "email") {
79
+ await provider.sendVerificationRequest({
80
+ ...verificationArgs,
81
+ provider: {
82
+ ...provider,
83
+ from:
84
+ // Simplifies demo configuration of Resend
85
+ provider.from === "Auth.js <no-reply@authjs.dev>" &&
86
+ provider.id === "resend"
87
+ ? "My App <onboarding@resend.dev>"
88
+ : provider.from,
89
+ },
90
+ request: new Request("http://localhost"), // TODO: Document
91
+ theme: ctx.auth.config.theme,
92
+ },
93
+ // @ts-expect-error Figure out typing for email providers so they can
94
+ // access ctx.
95
+ ctx);
96
+ }
97
+ else if (provider.type === "phone") {
98
+ await provider.sendVerificationRequest({ ...verificationArgs, provider }, ctx);
99
+ }
100
+ return { kind: "started", started: true };
101
+ }
102
+ async function handleCredentials(ctx, provider, args, options) {
103
+ const result = await provider.authorize(args.params ?? {}, ctx);
104
+ if (result === null) {
105
+ return { kind: "signedIn", signedIn: null };
106
+ }
107
+ const idsAndTokens = await callSignIn(ctx, {
108
+ userId: result.userId,
109
+ sessionId: result.sessionId,
110
+ generateTokens: options.generateTokens,
111
+ });
112
+ return {
113
+ kind: "signedIn",
114
+ signedIn: idsAndTokens,
115
+ };
116
+ }
117
+ async function handleOAuthProvider(ctx, provider, args, options) {
118
+ // We have this action because:
119
+ // 1. We remember the current sessionId if any, so we can link accounts
120
+ // 2. The client doesn't need to know the HTTP Actions URL
121
+ // of the backend (this simplifies using local backend)
122
+ // 3. The client doesn't need to know which provider is of which type,
123
+ // and hence which provider requires client-side redirect
124
+ // 4. On mobile the client can complete the flow manually
125
+ if (args.params?.code !== undefined) {
126
+ const result = await callVerifyCodeAndSignIn(ctx, {
127
+ params: args.params,
128
+ verifier: args.verifier,
129
+ generateTokens: true,
130
+ allowExtraProviders: options.allowExtraProviders,
131
+ });
132
+ return {
133
+ kind: "signedIn",
134
+ signedIn: result,
135
+ };
136
+ }
137
+ const redirect = new URL((process.env.CUSTOM_AUTH_SITE_URL ?? requireEnv("CONVEX_SITE_URL")) + `/api/auth/signin/${provider.id}`);
138
+ const verifier = await callVerifier(ctx);
139
+ redirect.searchParams.set("code", verifier);
140
+ if (args.params?.redirectTo !== undefined) {
141
+ if (typeof args.params.redirectTo !== "string") {
142
+ throw new Error(`Expected \`redirectTo\` to be a string, got ${args.params.redirectTo}`);
143
+ }
144
+ redirect.searchParams.set("redirectTo", args.params.redirectTo);
145
+ }
146
+ return { kind: "redirect", redirect: redirect.toString(), verifier };
147
+ }
148
+ //# sourceMappingURL=signIn.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signIn.js","sourceRoot":"","sources":["../../../src/server/implementation/signIn.ts"],"names":[],"mappings":"AAcA,OAAO,EACL,0BAA0B,EAC1B,kBAAkB,EAClB,UAAU,EACV,YAAY,EACZ,uBAAuB,GACxB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACxE,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAElD,MAAM,0CAA0C,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,WAAW;AAI5E,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,GAAsB,EACtB,QAA+C,EAC/C,IAMC,EACD,OAGC;IAUD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CAAC,iBAAiB,CAAC,CAAC,GAAG,oBAAoB,QAAQ,CAAC,EAAE,EAAE,CACxG,CAAC;IACF,MAAM,QAAQ,GAAG,MAAM,YAAY,CAAC,GAAG,CAAC,CAAC;IACzC,QAAQ,CAAC,YAAY,CAAC,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAC5C,IAAI,IAAI,CAAC,MAAM,EAAE,UAAU,KAAK,SAAS,EAAE,CAAC;QAC1C,IAAI,OAAO,IAAI,CAAC,MAAM,CAAC,UAAU,KAAK,QAAQ,EAAE,CAAC;YAC/C,MAAM,IAAI,KAAK,CACb,+CAA+C,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,CACxE,CAAC;QACJ,CAAC;QACD,QAAQ,CAAC,YAAY,CAAC,GAAG,CAAC,YAAY,EAAE,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IAClE,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,CAAC,QAAQ,EAAE,EAAE,QAAQ,EAAE,CAAC;AACvE,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { GenericId } from "convex/values";
2
+ import { ConvexAuthConfig } from "../types.js";
3
+ export declare function generateToken(args: {
4
+ userId: GenericId<"user">;
5
+ sessionId: GenericId<"session">;
6
+ }, config: ConvexAuthConfig): Promise<string>;
7
+ //# sourceMappingURL=tokens.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tokens.d.ts","sourceRoot":"","sources":["../../../src/server/implementation/tokens.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAO/C,wBAAsB,aAAa,CACjC,IAAI,EAAE;IACJ,MAAM,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC;IAC1B,SAAS,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;CACjC,EACD,MAAM,EAAE,gBAAgB,mBAezB"}
@@ -0,0 +1,18 @@
1
+ import { SignJWT, importPKCS8 } from "jose";
2
+ import { requireEnv } from "../utils.js";
3
+ import { TOKEN_SUB_CLAIM_DIVIDER } from "./utils.js";
4
+ const DEFAULT_JWT_DURATION_MS = 1000 * 60 * 60; // 1 hour
5
+ export async function generateToken(args, config) {
6
+ const privateKey = await importPKCS8(requireEnv("JWT_PRIVATE_KEY"), "RS256");
7
+ const expirationTime = new Date(Date.now() + (config.jwt?.durationMs ?? DEFAULT_JWT_DURATION_MS));
8
+ return await new SignJWT({
9
+ sub: args.userId + TOKEN_SUB_CLAIM_DIVIDER + args.sessionId,
10
+ })
11
+ .setProtectedHeader({ alg: "RS256" })
12
+ .setIssuedAt()
13
+ .setIssuer(requireEnv("CONVEX_SITE_URL"))
14
+ .setAudience("convex")
15
+ .setExpirationTime(expirationTime)
16
+ .sign(privateKey);
17
+ }
18
+ //# sourceMappingURL=tokens.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tokens.js","sourceRoot":"","sources":["../../../src/server/implementation/tokens.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,MAAM,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAErD,MAAM,uBAAuB,GAAG,IAAI,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,SAAS;AAEzD,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,IAGC,EACD,MAAwB;IAExB,MAAM,UAAU,GAAG,MAAM,WAAW,CAAC,UAAU,CAAC,iBAAiB,CAAC,EAAE,OAAO,CAAC,CAAC;IAC7E,MAAM,cAAc,GAAG,IAAI,IAAI,CAC7B,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,EAAE,UAAU,IAAI,uBAAuB,CAAC,CACjE,CAAC;IACF,OAAO,MAAM,IAAI,OAAO,CAAC;QACvB,GAAG,EAAE,IAAI,CAAC,MAAM,GAAG,uBAAuB,GAAG,IAAI,CAAC,SAAS;KAC5D,CAAC;SACC,kBAAkB,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,CAAC;SACpC,WAAW,EAAE;SACb,SAAS,CAAC,UAAU,CAAC,iBAAiB,CAAC,CAAC;SACxC,WAAW,CAAC,QAAQ,CAAC;SACrB,iBAAiB,CAAC,cAAc,CAAC;SACjC,IAAI,CAAC,UAAU,CAAC,CAAC;AACtB,CAAC"}
@@ -0,0 +1,288 @@
1
+ import { DataModelFromSchemaDefinition, GenericActionCtx, GenericMutationCtx, GenericQueryCtx, TableNamesInDataModel, defineSchema } from "convex/server";
2
+ import { GenericId } from "convex/values";
3
+ import { GenericDoc } from "../convex_types.js";
4
+ /**
5
+ * The table definitions required by the library.
6
+ *
7
+ * Your schema must include these so that the indexes
8
+ * are set up:
9
+ *
10
+ *
11
+ * ```ts filename="convex/schema.ts"
12
+ * import { defineSchema } from "convex/server";
13
+ * import { authTables } from "@robelest/convex-auth/component";
14
+ *
15
+ * const schema = defineSchema({
16
+ * ...authTables,
17
+ * });
18
+ *
19
+ * export default schema;
20
+ * ```
21
+ *
22
+ * You can inline the table definitions into your schema
23
+ * and extend them with additional optional and required
24
+ * fields. See https://labs.convex.dev/auth/setup/schema
25
+ * for more details.
26
+ */
27
+ export declare const authTables: {
28
+ /**
29
+ * Users.
30
+ */
31
+ user: import("convex/server").TableDefinition<import("convex/values").VObject<{
32
+ name?: string | undefined;
33
+ email?: string | undefined;
34
+ phone?: string | undefined;
35
+ image?: string | undefined;
36
+ emailVerificationTime?: number | undefined;
37
+ phoneVerificationTime?: number | undefined;
38
+ isAnonymous?: boolean | undefined;
39
+ }, {
40
+ name: import("convex/values").VString<string | undefined, "optional">;
41
+ image: import("convex/values").VString<string | undefined, "optional">;
42
+ email: import("convex/values").VString<string | undefined, "optional">;
43
+ emailVerificationTime: import("convex/values").VFloat64<number | undefined, "optional">;
44
+ phone: import("convex/values").VString<string | undefined, "optional">;
45
+ phoneVerificationTime: import("convex/values").VFloat64<number | undefined, "optional">;
46
+ isAnonymous: import("convex/values").VBoolean<boolean | undefined, "optional">;
47
+ }, "required", "name" | "email" | "phone" | "image" | "emailVerificationTime" | "phoneVerificationTime" | "isAnonymous">, {
48
+ email: ["email", "_creationTime"];
49
+ phone: ["phone", "_creationTime"];
50
+ }, {}, {}>;
51
+ /**
52
+ * Sessions.
53
+ * A single user can have multiple active sessions.
54
+ * See [Session document lifecycle](https://labs.convex.dev/auth/advanced#session-document-lifecycle).
55
+ */
56
+ session: import("convex/server").TableDefinition<import("convex/values").VObject<{
57
+ userId: GenericId<"user">;
58
+ expirationTime: number;
59
+ }, {
60
+ userId: import("convex/values").VId<GenericId<"user">, "required">;
61
+ expirationTime: import("convex/values").VFloat64<number, "required">;
62
+ }, "required", "userId" | "expirationTime">, {
63
+ userId: ["userId", "_creationTime"];
64
+ }, {}, {}>;
65
+ /**
66
+ * Accounts. An account corresponds to
67
+ * a single authentication provider.
68
+ * A single user can have multiple accounts linked.
69
+ */
70
+ account: import("convex/server").TableDefinition<import("convex/values").VObject<{
71
+ secret?: string | undefined;
72
+ emailVerified?: string | undefined;
73
+ phoneVerified?: string | undefined;
74
+ userId: GenericId<"user">;
75
+ provider: string;
76
+ providerAccountId: string;
77
+ }, {
78
+ userId: import("convex/values").VId<GenericId<"user">, "required">;
79
+ provider: import("convex/values").VString<string, "required">;
80
+ providerAccountId: import("convex/values").VString<string, "required">;
81
+ secret: import("convex/values").VString<string | undefined, "optional">;
82
+ emailVerified: import("convex/values").VString<string | undefined, "optional">;
83
+ phoneVerified: import("convex/values").VString<string | undefined, "optional">;
84
+ }, "required", "secret" | "userId" | "provider" | "providerAccountId" | "emailVerified" | "phoneVerified">, {
85
+ userIdAndProvider: ["userId", "provider", "_creationTime"];
86
+ providerAndAccountId: ["provider", "providerAccountId", "_creationTime"];
87
+ }, {}, {}>;
88
+ /**
89
+ * Refresh tokens.
90
+ * Refresh tokens are generally meant to be used once, to be exchanged for another
91
+ * refresh token and a JWT access token, but with a few exceptions:
92
+ * - The "active refresh token" is the most recently created refresh token that has
93
+ * not been used yet. The parent of the active refresh token can always be used to
94
+ * obtain the active refresh token.
95
+ * - A refresh token can be used within a 10 second window ("reuse window") to
96
+ * obtain a new refresh token.
97
+ * - On any invalid use of a refresh token, the token itself and all its descendants
98
+ * are invalidated.
99
+ */
100
+ token: import("convex/server").TableDefinition<import("convex/values").VObject<{
101
+ firstUsedTime?: number | undefined;
102
+ parentRefreshTokenId?: GenericId<"token"> | undefined;
103
+ expirationTime: number;
104
+ sessionId: GenericId<"session">;
105
+ }, {
106
+ sessionId: import("convex/values").VId<GenericId<"session">, "required">;
107
+ expirationTime: import("convex/values").VFloat64<number, "required">;
108
+ firstUsedTime: import("convex/values").VFloat64<number | undefined, "optional">;
109
+ parentRefreshTokenId: import("convex/values").VId<GenericId<"token"> | undefined, "optional">;
110
+ }, "required", "expirationTime" | "sessionId" | "firstUsedTime" | "parentRefreshTokenId">, {
111
+ sessionId: ["sessionId", "_creationTime"];
112
+ sessionIdAndParentRefreshTokenId: ["sessionId", "parentRefreshTokenId", "_creationTime"];
113
+ }, {}, {}>;
114
+ /**
115
+ * Verification codes:
116
+ * - OTP tokens
117
+ * - magic link tokens
118
+ * - OAuth codes
119
+ */
120
+ verification: import("convex/server").TableDefinition<import("convex/values").VObject<{
121
+ emailVerified?: string | undefined;
122
+ phoneVerified?: string | undefined;
123
+ verifier?: string | undefined;
124
+ expirationTime: number;
125
+ provider: string;
126
+ accountId: GenericId<"account">;
127
+ code: string;
128
+ }, {
129
+ accountId: import("convex/values").VId<GenericId<"account">, "required">;
130
+ provider: import("convex/values").VString<string, "required">;
131
+ code: import("convex/values").VString<string, "required">;
132
+ expirationTime: import("convex/values").VFloat64<number, "required">;
133
+ verifier: import("convex/values").VString<string | undefined, "optional">;
134
+ emailVerified: import("convex/values").VString<string | undefined, "optional">;
135
+ phoneVerified: import("convex/values").VString<string | undefined, "optional">;
136
+ }, "required", "expirationTime" | "provider" | "emailVerified" | "phoneVerified" | "accountId" | "code" | "verifier">, {
137
+ accountId: ["accountId", "_creationTime"];
138
+ code: ["code", "_creationTime"];
139
+ }, {}, {}>;
140
+ /**
141
+ * PKCE verifiers for OAuth.
142
+ */
143
+ verifier: import("convex/server").TableDefinition<import("convex/values").VObject<{
144
+ sessionId?: GenericId<"session"> | undefined;
145
+ signature?: string | undefined;
146
+ }, {
147
+ sessionId: import("convex/values").VId<GenericId<"session"> | undefined, "optional">;
148
+ signature: import("convex/values").VString<string | undefined, "optional">;
149
+ }, "required", "sessionId" | "signature">, {
150
+ signature: ["signature", "_creationTime"];
151
+ }, {}, {}>;
152
+ /**
153
+ * Rate limits for OTP and password sign-in.
154
+ */
155
+ limit: import("convex/server").TableDefinition<import("convex/values").VObject<{
156
+ identifier: string;
157
+ lastAttemptTime: number;
158
+ attemptsLeft: number;
159
+ }, {
160
+ identifier: import("convex/values").VString<string, "required">;
161
+ lastAttemptTime: import("convex/values").VFloat64<number, "required">;
162
+ attemptsLeft: import("convex/values").VFloat64<number, "required">;
163
+ }, "required", "identifier" | "lastAttemptTime" | "attemptsLeft">, {
164
+ identifier: ["identifier", "_creationTime"];
165
+ }, {}, {}>;
166
+ organization: import("convex/server").TableDefinition<import("convex/values").VObject<{
167
+ slug?: string | undefined;
168
+ ownerUserId?: GenericId<"user"> | undefined;
169
+ parentOrganizationId?: GenericId<"organization"> | undefined;
170
+ metadata?: any;
171
+ name: string;
172
+ }, {
173
+ name: import("convex/values").VString<string, "required">;
174
+ slug: import("convex/values").VString<string | undefined, "optional">;
175
+ ownerUserId: import("convex/values").VId<GenericId<"user"> | undefined, "optional">;
176
+ parentOrganizationId: import("convex/values").VId<GenericId<"organization"> | undefined, "optional">;
177
+ metadata: import("convex/values").VAny<any, "optional", string>;
178
+ }, "required", "name" | "slug" | "ownerUserId" | "parentOrganizationId" | "metadata" | `metadata.${string}`>, {
179
+ slug: ["slug", "_creationTime"];
180
+ ownerUserId: ["ownerUserId", "_creationTime"];
181
+ parentOrganizationId: ["parentOrganizationId", "_creationTime"];
182
+ }, {}, {}>;
183
+ team: import("convex/server").TableDefinition<import("convex/values").VObject<{
184
+ slug?: string | undefined;
185
+ metadata?: any;
186
+ parentTeamId?: GenericId<"team"> | undefined;
187
+ name: string;
188
+ organizationId: GenericId<"organization">;
189
+ }, {
190
+ organizationId: import("convex/values").VId<GenericId<"organization">, "required">;
191
+ name: import("convex/values").VString<string, "required">;
192
+ slug: import("convex/values").VString<string | undefined, "optional">;
193
+ parentTeamId: import("convex/values").VId<GenericId<"team"> | undefined, "optional">;
194
+ metadata: import("convex/values").VAny<any, "optional", string>;
195
+ }, "required", "name" | "slug" | "metadata" | `metadata.${string}` | "organizationId" | "parentTeamId">, {
196
+ organizationId: ["organizationId", "_creationTime"];
197
+ organizationIdAndSlug: ["organizationId", "slug", "_creationTime"];
198
+ parentTeamId: ["parentTeamId", "_creationTime"];
199
+ }, {}, {}>;
200
+ teamRelation: import("convex/server").TableDefinition<import("convex/values").VObject<{
201
+ relation?: string | undefined;
202
+ organizationId: GenericId<"organization">;
203
+ parentTeamId: GenericId<"team">;
204
+ childTeamId: GenericId<"team">;
205
+ }, {
206
+ organizationId: import("convex/values").VId<GenericId<"organization">, "required">;
207
+ parentTeamId: import("convex/values").VId<GenericId<"team">, "required">;
208
+ childTeamId: import("convex/values").VId<GenericId<"team">, "required">;
209
+ relation: import("convex/values").VString<string | undefined, "optional">;
210
+ }, "required", "organizationId" | "parentTeamId" | "childTeamId" | "relation">, {
211
+ organizationId: ["organizationId", "_creationTime"];
212
+ organizationIdAndParentTeamId: ["organizationId", "parentTeamId", "_creationTime"];
213
+ organizationIdAndChildTeamId: ["organizationId", "childTeamId", "_creationTime"];
214
+ }, {}, {}>;
215
+ member: import("convex/server").TableDefinition<import("convex/values").VObject<{
216
+ metadata?: any;
217
+ teamId?: GenericId<"team"> | undefined;
218
+ role?: string | undefined;
219
+ status?: string | undefined;
220
+ userId: GenericId<"user">;
221
+ organizationId: GenericId<"organization">;
222
+ }, {
223
+ organizationId: import("convex/values").VId<GenericId<"organization">, "required">;
224
+ userId: import("convex/values").VId<GenericId<"user">, "required">;
225
+ teamId: import("convex/values").VId<GenericId<"team"> | undefined, "optional">;
226
+ role: import("convex/values").VString<string | undefined, "optional">;
227
+ status: import("convex/values").VString<string | undefined, "optional">;
228
+ metadata: import("convex/values").VAny<any, "optional", string>;
229
+ }, "required", "userId" | "metadata" | `metadata.${string}` | "organizationId" | "teamId" | "role" | "status">, {
230
+ organizationId: ["organizationId", "_creationTime"];
231
+ organizationIdAndUserId: ["organizationId", "userId", "_creationTime"];
232
+ teamId: ["teamId", "_creationTime"];
233
+ userId: ["userId", "_creationTime"];
234
+ }, {}, {}>;
235
+ invite: import("convex/server").TableDefinition<import("convex/values").VObject<{
236
+ metadata?: any;
237
+ organizationId?: GenericId<"organization"> | undefined;
238
+ teamId?: GenericId<"team"> | undefined;
239
+ role?: string | undefined;
240
+ acceptedByUserId?: GenericId<"user"> | undefined;
241
+ acceptedTime?: number | undefined;
242
+ email: string;
243
+ status: "pending" | "accepted" | "revoked" | "expired";
244
+ invitedByUserId: GenericId<"user">;
245
+ tokenHash: string;
246
+ expiresTime: number;
247
+ }, {
248
+ organizationId: import("convex/values").VId<GenericId<"organization"> | undefined, "optional">;
249
+ teamId: import("convex/values").VId<GenericId<"team"> | undefined, "optional">;
250
+ invitedByUserId: import("convex/values").VId<GenericId<"user">, "required">;
251
+ email: import("convex/values").VString<string, "required">;
252
+ tokenHash: import("convex/values").VString<string, "required">;
253
+ role: import("convex/values").VString<string | undefined, "optional">;
254
+ status: import("convex/values").VUnion<"pending" | "accepted" | "revoked" | "expired", [import("convex/values").VLiteral<"pending", "required">, import("convex/values").VLiteral<"accepted", "required">, import("convex/values").VLiteral<"revoked", "required">, import("convex/values").VLiteral<"expired", "required">], "required", never>;
255
+ expiresTime: import("convex/values").VFloat64<number, "required">;
256
+ acceptedByUserId: import("convex/values").VId<GenericId<"user"> | undefined, "optional">;
257
+ acceptedTime: import("convex/values").VFloat64<number | undefined, "optional">;
258
+ metadata: import("convex/values").VAny<any, "optional", string>;
259
+ }, "required", "email" | "metadata" | `metadata.${string}` | "organizationId" | "teamId" | "role" | "status" | "invitedByUserId" | "tokenHash" | "expiresTime" | "acceptedByUserId" | "acceptedTime">, {
260
+ tokenHash: ["tokenHash", "_creationTime"];
261
+ emailAndStatus: ["email", "status", "_creationTime"];
262
+ invitedByUserIdAndStatus: ["invitedByUserId", "status", "_creationTime"];
263
+ organizationId: ["organizationId", "_creationTime"];
264
+ organizationIdAndStatus: ["organizationId", "status", "_creationTime"];
265
+ }, {}, {}>;
266
+ };
267
+ type DefaultSchema = ReturnType<typeof defineSchema<typeof authTables>>;
268
+ export type AuthDataModel = DataModelFromSchemaDefinition<DefaultSchema>;
269
+ export type ActionCtx = GenericActionCtx<AuthDataModel>;
270
+ export type MutationCtx = GenericMutationCtx<AuthDataModel>;
271
+ export type QueryCtx = GenericQueryCtx<AuthDataModel>;
272
+ export type Doc<T extends TableNamesInDataModel<AuthDataModel>> = GenericDoc<AuthDataModel, T>;
273
+ export type Tokens = {
274
+ token: string;
275
+ refreshToken: string;
276
+ };
277
+ export type SessionInfo = {
278
+ userId: GenericId<"user">;
279
+ sessionId: GenericId<"session">;
280
+ tokens: Tokens | null;
281
+ };
282
+ export type SessionInfoWithTokens = {
283
+ userId: GenericId<"user">;
284
+ sessionId: GenericId<"session">;
285
+ tokens: Tokens;
286
+ };
287
+ export {};
288
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/server/implementation/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,6BAA6B,EAC7B,gBAAgB,EAChB,kBAAkB,EAClB,eAAe,EACf,qBAAqB,EACrB,YAAY,EAEb,MAAM,eAAe,CAAC;AACvB,OAA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