@wasp.sh/wasp-cli-darwin-arm64-unknown 0.20.0

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 (410) hide show
  1. package/data/Cli/starters/README.md +22 -0
  2. package/data/Cli/starters/basic/README.md +35 -0
  3. package/data/Cli/starters/basic/eslint.config.js +24 -0
  4. package/data/Cli/starters/basic/main.wasp +100 -0
  5. package/data/Cli/starters/basic/package.json +29 -0
  6. package/data/Cli/starters/basic/postcss.config.js +6 -0
  7. package/data/Cli/starters/basic/schema.prisma +42 -0
  8. package/data/Cli/starters/basic/src/App.css +13 -0
  9. package/data/Cli/starters/basic/src/App.tsx +12 -0
  10. package/data/Cli/starters/basic/src/assets/logo.svg +1 -0
  11. package/data/Cli/starters/basic/src/auth/AuthLayout.tsx +10 -0
  12. package/data/Cli/starters/basic/src/auth/email/EmailVerificationPage.tsx +19 -0
  13. package/data/Cli/starters/basic/src/auth/email/LoginPage.tsx +27 -0
  14. package/data/Cli/starters/basic/src/auth/email/PasswordResetPage.tsx +19 -0
  15. package/data/Cli/starters/basic/src/auth/email/RequestPasswordResetPage.tsx +10 -0
  16. package/data/Cli/starters/basic/src/auth/email/SignupPage.tsx +34 -0
  17. package/data/Cli/starters/basic/src/auth/email/userSignupFields.ts +13 -0
  18. package/data/Cli/starters/basic/src/shared/components/Button.tsx +90 -0
  19. package/data/Cli/starters/basic/src/shared/components/Dialog.tsx +85 -0
  20. package/data/Cli/starters/basic/src/shared/components/Header.tsx +39 -0
  21. package/data/Cli/starters/basic/src/shared/components/Input.tsx +36 -0
  22. package/data/Cli/starters/basic/src/shared/components/Portal.tsx +26 -0
  23. package/data/Cli/starters/basic/src/tags/actions.ts +23 -0
  24. package/data/Cli/starters/basic/src/tags/components/ColorRadioButton.tsx +44 -0
  25. package/data/Cli/starters/basic/src/tags/components/ColorRadioButtons.tsx +59 -0
  26. package/data/Cli/starters/basic/src/tags/components/CreateTagDialog.tsx +50 -0
  27. package/data/Cli/starters/basic/src/tags/components/CreateTagForm.tsx +100 -0
  28. package/data/Cli/starters/basic/src/tags/components/TagLabel.tsx +55 -0
  29. package/data/Cli/starters/basic/src/tags/components/colors.ts +8 -0
  30. package/data/Cli/starters/basic/src/tags/queries.ts +14 -0
  31. package/data/Cli/starters/basic/src/tasks/TasksPage.tsx +19 -0
  32. package/data/Cli/starters/basic/src/tasks/actions.ts +71 -0
  33. package/data/Cli/starters/basic/src/tasks/components/CreateTaskForm.tsx +103 -0
  34. package/data/Cli/starters/basic/src/tasks/components/TaskList.tsx +68 -0
  35. package/data/Cli/starters/basic/src/tasks/components/TaskListItem.tsx +56 -0
  36. package/data/Cli/starters/basic/src/tasks/queries.ts +21 -0
  37. package/data/Cli/starters/basic/tailwind.config.js +30 -0
  38. package/data/Cli/starters/basic/vite.config.ts +7 -0
  39. package/data/Cli/starters/minimal/main.wasp +14 -0
  40. package/data/Cli/starters/minimal/package.json +18 -0
  41. package/data/Cli/starters/minimal/schema.prisma +10 -0
  42. package/data/Cli/starters/minimal/src/Main.css +103 -0
  43. package/data/Cli/starters/minimal/src/MainPage.tsx +37 -0
  44. package/data/Cli/starters/minimal/src/assets/logo.svg +1 -0
  45. package/data/Cli/starters/minimal/vite.config.ts +7 -0
  46. package/data/Cli/starters/skeleton/public/favicon.ico +0 -0
  47. package/data/Cli/starters/skeleton/src/vite-env.d.ts +7 -0
  48. package/data/Cli/starters/skeleton/tsconfig.json +28 -0
  49. package/data/Generator/templates/Dockerfile +78 -0
  50. package/data/Generator/templates/db/schema.prisma +24 -0
  51. package/data/Generator/templates/dockerignore +2 -0
  52. package/data/Generator/templates/react-app/README.md +21 -0
  53. package/data/Generator/templates/react-app/gitignore +23 -0
  54. package/data/Generator/templates/react-app/index.html +22 -0
  55. package/data/Generator/templates/react-app/netlify.toml +8 -0
  56. package/data/Generator/templates/react-app/npmrc +1 -0
  57. package/data/Generator/templates/react-app/package.json +31 -0
  58. package/data/Generator/templates/react-app/public/manifest.json +15 -0
  59. package/data/Generator/templates/react-app/src/auth/pages/OAuthCallback.tsx +93 -0
  60. package/data/Generator/templates/react-app/src/auth/pages/createAuthRequiredPage.jsx +40 -0
  61. package/data/Generator/templates/react-app/src/components/DefaultRootErrorBoundary.tsx +16 -0
  62. package/data/Generator/templates/react-app/src/components/FullPageWrapper.tsx +21 -0
  63. package/data/Generator/templates/react-app/src/components/Loader.module.css +37 -0
  64. package/data/Generator/templates/react-app/src/components/Loader.tsx +12 -0
  65. package/data/Generator/templates/react-app/src/components/Message.tsx +86 -0
  66. package/data/Generator/templates/react-app/src/index.tsx +47 -0
  67. package/data/Generator/templates/react-app/src/logo.png +0 -0
  68. package/data/Generator/templates/react-app/src/router.tsx +59 -0
  69. package/data/Generator/templates/react-app/src/test/vitest/setup.ts +8 -0
  70. package/data/Generator/templates/react-app/src/utils.js +3 -0
  71. package/data/Generator/templates/react-app/src/vite-env.d.ts +1 -0
  72. package/data/Generator/templates/react-app/tsconfig.app.json +28 -0
  73. package/data/Generator/templates/react-app/tsconfig.json +11 -0
  74. package/data/Generator/templates/react-app/tsconfig.vite.json +16 -0
  75. package/data/Generator/templates/react-app/vite/detectServerImports.ts +53 -0
  76. package/data/Generator/templates/react-app/vite/validateEnv.ts +45 -0
  77. package/data/Generator/templates/react-app/vite.config.ts +74 -0
  78. package/data/Generator/templates/sdk/wasp/api/events.ts +11 -0
  79. package/data/Generator/templates/sdk/wasp/api/index.ts +136 -0
  80. package/data/Generator/templates/sdk/wasp/auth/email/actions/login.ts +13 -0
  81. package/data/Generator/templates/sdk/wasp/auth/email/actions/passwordReset.ts +22 -0
  82. package/data/Generator/templates/sdk/wasp/auth/email/actions/signup.ts +20 -0
  83. package/data/Generator/templates/sdk/wasp/auth/email/actions/verifyEmail.ts +14 -0
  84. package/data/Generator/templates/sdk/wasp/auth/email/index.ts +5 -0
  85. package/data/Generator/templates/sdk/wasp/auth/forms/Auth.module.css +16 -0
  86. package/data/Generator/templates/sdk/wasp/auth/forms/Auth.tsx +94 -0
  87. package/data/Generator/templates/sdk/wasp/auth/forms/ForgotPassword.tsx +18 -0
  88. package/data/Generator/templates/sdk/wasp/auth/forms/Login.tsx +18 -0
  89. package/data/Generator/templates/sdk/wasp/auth/forms/ResetPassword.tsx +18 -0
  90. package/data/Generator/templates/sdk/wasp/auth/forms/Signup.tsx +24 -0
  91. package/data/Generator/templates/sdk/wasp/auth/forms/VerifyEmail.tsx +18 -0
  92. package/data/Generator/templates/sdk/wasp/auth/forms/internal/Form.module.css +99 -0
  93. package/data/Generator/templates/sdk/wasp/auth/forms/internal/Form.tsx +74 -0
  94. package/data/Generator/templates/sdk/wasp/auth/forms/internal/Message.module.css +22 -0
  95. package/data/Generator/templates/sdk/wasp/auth/forms/internal/Message.tsx +34 -0
  96. package/data/Generator/templates/sdk/wasp/auth/forms/internal/auth-styles.css +30 -0
  97. package/data/Generator/templates/sdk/wasp/auth/forms/internal/common/LoginSignupForm.module.css +55 -0
  98. package/data/Generator/templates/sdk/wasp/auth/forms/internal/common/LoginSignupForm.tsx +291 -0
  99. package/data/Generator/templates/sdk/wasp/auth/forms/internal/email/ForgotPasswordForm.tsx +52 -0
  100. package/data/Generator/templates/sdk/wasp/auth/forms/internal/email/ResetPasswordForm.tsx +82 -0
  101. package/data/Generator/templates/sdk/wasp/auth/forms/internal/email/VerifyEmailForm.tsx +43 -0
  102. package/data/Generator/templates/sdk/wasp/auth/forms/internal/email/useEmail.ts +33 -0
  103. package/data/Generator/templates/sdk/wasp/auth/forms/internal/social/SocialButton.module.css +33 -0
  104. package/data/Generator/templates/sdk/wasp/auth/forms/internal/social/SocialButton.tsx +14 -0
  105. package/data/Generator/templates/sdk/wasp/auth/forms/internal/social/SocialIcons.module.css +4 -0
  106. package/data/Generator/templates/sdk/wasp/auth/forms/internal/social/SocialIcons.tsx +74 -0
  107. package/data/Generator/templates/sdk/wasp/auth/forms/internal/usernameAndPassword/useUsernameAndPassword.ts +29 -0
  108. package/data/Generator/templates/sdk/wasp/auth/forms/internal/util.ts +16 -0
  109. package/data/Generator/templates/sdk/wasp/auth/forms/types.ts +77 -0
  110. package/data/Generator/templates/sdk/wasp/auth/helpers/_Provider.tsx +17 -0
  111. package/data/Generator/templates/sdk/wasp/auth/helpers/user.ts +15 -0
  112. package/data/Generator/templates/sdk/wasp/auth/index.ts +9 -0
  113. package/data/Generator/templates/sdk/wasp/auth/jwt.ts +22 -0
  114. package/data/Generator/templates/sdk/wasp/auth/logout.ts +18 -0
  115. package/data/Generator/templates/sdk/wasp/auth/lucia.ts +53 -0
  116. package/data/Generator/templates/sdk/wasp/auth/password.ts +36 -0
  117. package/data/Generator/templates/sdk/wasp/auth/providers/index.ts +9 -0
  118. package/data/Generator/templates/sdk/wasp/auth/providers/types.ts +68 -0
  119. package/data/Generator/templates/sdk/wasp/auth/session.ts +78 -0
  120. package/data/Generator/templates/sdk/wasp/auth/types.ts +2 -0
  121. package/data/Generator/templates/sdk/wasp/auth/useAuth.ts +37 -0
  122. package/data/Generator/templates/sdk/wasp/auth/user.ts +63 -0
  123. package/data/Generator/templates/sdk/wasp/auth/username/actions/login.ts +13 -0
  124. package/data/Generator/templates/sdk/wasp/auth/username/actions/signup.ts +20 -0
  125. package/data/Generator/templates/sdk/wasp/auth/username/index.ts +2 -0
  126. package/data/Generator/templates/sdk/wasp/auth/utils.ts +369 -0
  127. package/data/Generator/templates/sdk/wasp/auth/validation.ts +83 -0
  128. package/data/Generator/templates/sdk/wasp/client/auth/discord.ts +2 -0
  129. package/data/Generator/templates/sdk/wasp/client/auth/email.ts +5 -0
  130. package/data/Generator/templates/sdk/wasp/client/auth/github.ts +2 -0
  131. package/data/Generator/templates/sdk/wasp/client/auth/google.ts +2 -0
  132. package/data/Generator/templates/sdk/wasp/client/auth/index.ts +29 -0
  133. package/data/Generator/templates/sdk/wasp/client/auth/keycloak.ts +2 -0
  134. package/data/Generator/templates/sdk/wasp/client/auth/slack.ts +2 -0
  135. package/data/Generator/templates/sdk/wasp/client/auth/ui.ts +32 -0
  136. package/data/Generator/templates/sdk/wasp/client/auth/username.ts +2 -0
  137. package/data/Generator/templates/sdk/wasp/client/config.ts +15 -0
  138. package/data/Generator/templates/sdk/wasp/client/crud/_crud.ts +89 -0
  139. package/data/Generator/templates/sdk/wasp/client/crud/index.ts +4 -0
  140. package/data/Generator/templates/sdk/wasp/client/crud/operationsHelpers.ts +21 -0
  141. package/data/Generator/templates/sdk/wasp/client/env/schema.ts +22 -0
  142. package/data/Generator/templates/sdk/wasp/client/env.ts +5 -0
  143. package/data/Generator/templates/sdk/wasp/client/hooks.ts +19 -0
  144. package/data/Generator/templates/sdk/wasp/client/index.ts +17 -0
  145. package/data/Generator/templates/sdk/wasp/client/operations/actions/core.ts +49 -0
  146. package/data/Generator/templates/sdk/wasp/client/operations/actions/index.ts +13 -0
  147. package/data/Generator/templates/sdk/wasp/client/operations/hooks.ts +347 -0
  148. package/data/Generator/templates/sdk/wasp/client/operations/index.ts +22 -0
  149. package/data/Generator/templates/sdk/wasp/client/operations/internal/index.ts +22 -0
  150. package/data/Generator/templates/sdk/wasp/client/operations/internal/resources.js +83 -0
  151. package/data/Generator/templates/sdk/wasp/client/operations/internal/updateHandlersMap.js +37 -0
  152. package/data/Generator/templates/sdk/wasp/client/operations/queries/core.ts +91 -0
  153. package/data/Generator/templates/sdk/wasp/client/operations/queries/index.ts +16 -0
  154. package/data/Generator/templates/sdk/wasp/client/operations/queryClient.ts +34 -0
  155. package/data/Generator/templates/sdk/wasp/client/operations/rpc.ts +96 -0
  156. package/data/Generator/templates/sdk/wasp/client/router/Link.tsx +21 -0
  157. package/data/Generator/templates/sdk/wasp/client/router/index.ts +53 -0
  158. package/data/Generator/templates/sdk/wasp/client/router/linkHelpers.ts +48 -0
  159. package/data/Generator/templates/sdk/wasp/client/router/types.ts +98 -0
  160. package/data/Generator/templates/sdk/wasp/client/test/index.ts +1 -0
  161. package/data/Generator/templates/sdk/wasp/client/test/vitest/helpers.tsx +95 -0
  162. package/data/Generator/templates/sdk/wasp/client/webSocket/WebSocketProvider.tsx +77 -0
  163. package/data/Generator/templates/sdk/wasp/client/webSocket/index.ts +39 -0
  164. package/data/Generator/templates/sdk/wasp/core/auth.ts +40 -0
  165. package/data/Generator/templates/sdk/wasp/core/serialization/custom-register.ts +21 -0
  166. package/data/Generator/templates/sdk/wasp/core/serialization/index.ts +56 -0
  167. package/data/Generator/templates/sdk/wasp/core/serialization/prisma.ts +54 -0
  168. package/data/Generator/templates/sdk/wasp/core/storage.ts +50 -0
  169. package/data/Generator/templates/sdk/wasp/dev/index.ts +19 -0
  170. package/data/Generator/templates/sdk/wasp/entities/index.ts +28 -0
  171. package/data/Generator/templates/sdk/wasp/env/index.ts +9 -0
  172. package/data/Generator/templates/sdk/wasp/env/validation.ts +38 -0
  173. package/data/Generator/templates/sdk/wasp/package.json +152 -0
  174. package/data/Generator/templates/sdk/wasp/prisma-runtime-library.d.ts +17 -0
  175. package/data/Generator/templates/sdk/wasp/scripts/copy-assets.js +14 -0
  176. package/data/Generator/templates/sdk/wasp/server/HttpError.ts +30 -0
  177. package/data/Generator/templates/sdk/wasp/server/_types/index.ts +105 -0
  178. package/data/Generator/templates/sdk/wasp/server/_types/taggedEntities.ts +26 -0
  179. package/data/Generator/templates/sdk/wasp/server/api/index.ts +44 -0
  180. package/data/Generator/templates/sdk/wasp/server/auth/email/index.ts +20 -0
  181. package/data/Generator/templates/sdk/wasp/server/auth/email/utils.ts +104 -0
  182. package/data/Generator/templates/sdk/wasp/server/auth/hooks.ts +188 -0
  183. package/data/Generator/templates/sdk/wasp/server/auth/index.ts +49 -0
  184. package/data/Generator/templates/sdk/wasp/server/auth/oauth/index.ts +38 -0
  185. package/data/Generator/templates/sdk/wasp/server/auth/oauth/oneTimeCode.ts +50 -0
  186. package/data/Generator/templates/sdk/wasp/server/auth/oauth/provider.ts +20 -0
  187. package/data/Generator/templates/sdk/wasp/server/auth/oauth/providers/discord.ts +22 -0
  188. package/data/Generator/templates/sdk/wasp/server/auth/oauth/providers/github.ts +20 -0
  189. package/data/Generator/templates/sdk/wasp/server/auth/oauth/providers/google.ts +22 -0
  190. package/data/Generator/templates/sdk/wasp/server/auth/oauth/providers/keycloak.ts +23 -0
  191. package/data/Generator/templates/sdk/wasp/server/auth/oauth/providers/slack.ts +22 -0
  192. package/data/Generator/templates/sdk/wasp/server/auth/oauth/redirect.ts +43 -0
  193. package/data/Generator/templates/sdk/wasp/server/auth/user.ts +148 -0
  194. package/data/Generator/templates/sdk/wasp/server/auth/username.ts +1 -0
  195. package/data/Generator/templates/sdk/wasp/server/config.ts +47 -0
  196. package/data/Generator/templates/sdk/wasp/server/crud/_operationTypes.ts +134 -0
  197. package/data/Generator/templates/sdk/wasp/server/crud/index.ts +5 -0
  198. package/data/Generator/templates/sdk/wasp/server/dbClient.ts +35 -0
  199. package/data/Generator/templates/sdk/wasp/server/email/core/helpers.ts +40 -0
  200. package/data/Generator/templates/sdk/wasp/server/email/core/index.ts +17 -0
  201. package/data/Generator/templates/sdk/wasp/server/email/core/providers/dummy.ts +34 -0
  202. package/data/Generator/templates/sdk/wasp/server/email/core/providers/mailgun.ts +31 -0
  203. package/data/Generator/templates/sdk/wasp/server/email/core/providers/sendgrid.ts +44 -0
  204. package/data/Generator/templates/sdk/wasp/server/email/core/providers/smtp.ts +29 -0
  205. package/data/Generator/templates/sdk/wasp/server/email/core/types.ts +59 -0
  206. package/data/Generator/templates/sdk/wasp/server/email/index.ts +39 -0
  207. package/data/Generator/templates/sdk/wasp/server/env.ts +173 -0
  208. package/data/Generator/templates/sdk/wasp/server/index.ts +17 -0
  209. package/data/Generator/templates/sdk/wasp/server/jobs/_job.ts +39 -0
  210. package/data/Generator/templates/sdk/wasp/server/jobs/core/job.ts +28 -0
  211. package/data/Generator/templates/sdk/wasp/server/jobs/core/pgBoss/index.ts +3 -0
  212. package/data/Generator/templates/sdk/wasp/server/jobs/core/pgBoss/pgBoss.ts +76 -0
  213. package/data/Generator/templates/sdk/wasp/server/jobs/core/pgBoss/pgBossJob.ts +230 -0
  214. package/data/Generator/templates/sdk/wasp/server/jobs/core/pgBoss/types.ts +9 -0
  215. package/data/Generator/templates/sdk/wasp/server/jobs/index.ts +5 -0
  216. package/data/Generator/templates/sdk/wasp/server/middleware/globalMiddleware.ts +8 -0
  217. package/data/Generator/templates/sdk/wasp/server/middleware/index.ts +1 -0
  218. package/data/Generator/templates/sdk/wasp/server/operations/actions/index.ts +41 -0
  219. package/data/Generator/templates/sdk/wasp/server/operations/actions/types.ts +35 -0
  220. package/data/Generator/templates/sdk/wasp/server/operations/index.ts +13 -0
  221. package/data/Generator/templates/sdk/wasp/server/operations/queries/index.ts +42 -0
  222. package/data/Generator/templates/sdk/wasp/server/operations/queries/types.ts +36 -0
  223. package/data/Generator/templates/sdk/wasp/server/operations/wrappers.ts +242 -0
  224. package/data/Generator/templates/sdk/wasp/server/types/index.ts +11 -0
  225. package/data/Generator/templates/sdk/wasp/server/utils.ts +38 -0
  226. package/data/Generator/templates/sdk/wasp/server/webSocket/index.ts +57 -0
  227. package/data/Generator/templates/sdk/wasp/tsconfig.json +102 -0
  228. package/data/Generator/templates/sdk/wasp/universal/ansiColors.ts +14 -0
  229. package/data/Generator/templates/sdk/wasp/universal/predicates.ts +3 -0
  230. package/data/Generator/templates/sdk/wasp/universal/types.ts +74 -0
  231. package/data/Generator/templates/sdk/wasp/universal/url.ts +9 -0
  232. package/data/Generator/templates/sdk/wasp/universal/validators.ts +21 -0
  233. package/data/Generator/templates/sdk/wasp/vite-env.d.ts +1 -0
  234. package/data/Generator/templates/server/README.md +1 -0
  235. package/data/Generator/templates/server/gitignore +6 -0
  236. package/data/Generator/templates/server/nodemon.json +13 -0
  237. package/data/Generator/templates/server/npmrc +1 -0
  238. package/data/Generator/templates/server/package.json +27 -0
  239. package/data/Generator/templates/server/rollup.config.js +44 -0
  240. package/data/Generator/templates/server/src/actions/_action.ts +18 -0
  241. package/data/Generator/templates/server/src/app.js +36 -0
  242. package/data/Generator/templates/server/src/auth/hooks.ts +135 -0
  243. package/data/Generator/templates/server/src/auth/providers/config/discord.ts +69 -0
  244. package/data/Generator/templates/server/src/auth/providers/config/email.ts +96 -0
  245. package/data/Generator/templates/server/src/auth/providers/config/github.ts +78 -0
  246. package/data/Generator/templates/server/src/auth/providers/config/google.ts +65 -0
  247. package/data/Generator/templates/server/src/auth/providers/config/keycloak.ts +67 -0
  248. package/data/Generator/templates/server/src/auth/providers/config/slack.ts +65 -0
  249. package/data/Generator/templates/server/src/auth/providers/config/username.ts +33 -0
  250. package/data/Generator/templates/server/src/auth/providers/email/login.ts +66 -0
  251. package/data/Generator/templates/server/src/auth/providers/email/requestPasswordReset.ts +74 -0
  252. package/data/Generator/templates/server/src/auth/providers/email/resetPassword.ts +48 -0
  253. package/data/Generator/templates/server/src/auth/providers/email/signup.ts +165 -0
  254. package/data/Generator/templates/server/src/auth/providers/email/verifyEmail.ts +42 -0
  255. package/data/Generator/templates/server/src/auth/providers/index.ts +32 -0
  256. package/data/Generator/templates/server/src/auth/providers/oauth/config.ts +19 -0
  257. package/data/Generator/templates/server/src/auth/providers/oauth/cookies.ts +35 -0
  258. package/data/Generator/templates/server/src/auth/providers/oauth/handler.ts +130 -0
  259. package/data/Generator/templates/server/src/auth/providers/oauth/oneTimeCode.ts +39 -0
  260. package/data/Generator/templates/server/src/auth/providers/oauth/state.ts +144 -0
  261. package/data/Generator/templates/server/src/auth/providers/oauth/types.ts +7 -0
  262. package/data/Generator/templates/server/src/auth/providers/oauth/user.ts +139 -0
  263. package/data/Generator/templates/server/src/auth/providers/username/login.ts +64 -0
  264. package/data/Generator/templates/server/src/auth/providers/username/signup.ts +59 -0
  265. package/data/Generator/templates/server/src/crud/_operations.ts +184 -0
  266. package/data/Generator/templates/server/src/dbSeed.ts +37 -0
  267. package/data/Generator/templates/server/src/jobs/_job.ts +9 -0
  268. package/data/Generator/templates/server/src/jobs/core/allJobs.ts +8 -0
  269. package/data/Generator/templates/server/src/middleware/globalMiddleware.ts +45 -0
  270. package/data/Generator/templates/server/src/middleware/index.ts +1 -0
  271. package/data/Generator/templates/server/src/middleware/operations.ts +28 -0
  272. package/data/Generator/templates/server/src/queries/_query.ts +18 -0
  273. package/data/Generator/templates/server/src/routes/apis/index.ts +67 -0
  274. package/data/Generator/templates/server/src/routes/auth/index.js +16 -0
  275. package/data/Generator/templates/server/src/routes/auth/logout.ts +12 -0
  276. package/data/Generator/templates/server/src/routes/auth/me.ts +10 -0
  277. package/data/Generator/templates/server/src/routes/crud/_crud.ts +46 -0
  278. package/data/Generator/templates/server/src/routes/crud/index.ts +12 -0
  279. package/data/Generator/templates/server/src/routes/index.js +55 -0
  280. package/data/Generator/templates/server/src/routes/operations/_action.js +5 -0
  281. package/data/Generator/templates/server/src/routes/operations/_query.js +5 -0
  282. package/data/Generator/templates/server/src/routes/operations/index.js +18 -0
  283. package/data/Generator/templates/server/src/server.ts +76 -0
  284. package/data/Generator/templates/server/src/views/wrong-port.ts +123 -0
  285. package/data/Generator/templates/server/src/webSocket/initialization.ts +59 -0
  286. package/data/Generator/templates/server/tsconfig.json +41 -0
  287. package/data/Lsp/templates/ts/action.fn.ts +12 -0
  288. package/data/Lsp/templates/ts/operation.fn.js +7 -0
  289. package/data/Lsp/templates/ts/page.component.jsx +9 -0
  290. package/data/Lsp/templates/ts/query.fn.ts +12 -0
  291. package/data/packages/deploy/dist/common/brandedTypes.js +2 -0
  292. package/data/packages/deploy/dist/common/clientApp.js +26 -0
  293. package/data/packages/deploy/dist/common/commander.js +8 -0
  294. package/data/packages/deploy/dist/common/random.js +5 -0
  295. package/data/packages/deploy/dist/common/terminal.js +24 -0
  296. package/data/packages/deploy/dist/common/typeUtils.js +2 -0
  297. package/data/packages/deploy/dist/common/validation.js +14 -0
  298. package/data/packages/deploy/dist/common/waspBuild.js +21 -0
  299. package/data/packages/deploy/dist/common/waspProject.js +43 -0
  300. package/data/packages/deploy/dist/common/zx.js +10 -0
  301. package/data/packages/deploy/dist/index.js +30 -0
  302. package/data/packages/deploy/dist/providers/fly/CommonCmdOptions.js +2 -0
  303. package/data/packages/deploy/dist/providers/fly/CommonOps.js +36 -0
  304. package/data/packages/deploy/dist/providers/fly/DeploymentInstructions.js +12 -0
  305. package/data/packages/deploy/dist/providers/fly/commands/cmd/CmdCmdOptions.js +2 -0
  306. package/data/packages/deploy/dist/providers/fly/commands/cmd/cmd.js +29 -0
  307. package/data/packages/deploy/dist/providers/fly/commands/createDb/CreateDbCmdOptions.js +2 -0
  308. package/data/packages/deploy/dist/providers/fly/commands/createDb/createDb.js +55 -0
  309. package/data/packages/deploy/dist/providers/fly/commands/deploy/DeployCmdOptions.js +2 -0
  310. package/data/packages/deploy/dist/providers/fly/commands/deploy/deploy.js +88 -0
  311. package/data/packages/deploy/dist/providers/fly/commands/launch/LaunchCmdOptions.js +2 -0
  312. package/data/packages/deploy/dist/providers/fly/commands/launch/launch.js +17 -0
  313. package/data/packages/deploy/dist/providers/fly/commands/setup/SetupCmdOptions.js +2 -0
  314. package/data/packages/deploy/dist/providers/fly/commands/setup/setup.js +141 -0
  315. package/data/packages/deploy/dist/providers/fly/flyAppUrl.js +4 -0
  316. package/data/packages/deploy/dist/providers/fly/flyCli.js +74 -0
  317. package/data/packages/deploy/dist/providers/fly/index.js +121 -0
  318. package/data/packages/deploy/dist/providers/fly/jsonOutputSchemas.js +37 -0
  319. package/data/packages/deploy/dist/providers/fly/tomlFile.js +65 -0
  320. package/data/packages/deploy/dist/providers/railway/DeploymentInstructions.js +11 -0
  321. package/data/packages/deploy/dist/providers/railway/brandedTypes.js +2 -0
  322. package/data/packages/deploy/dist/providers/railway/commands/deploy/DeployCmdOptions.js +2 -0
  323. package/data/packages/deploy/dist/providers/railway/commands/deploy/client.js +22 -0
  324. package/data/packages/deploy/dist/providers/railway/commands/deploy/common.js +40 -0
  325. package/data/packages/deploy/dist/providers/railway/commands/deploy/index.js +57 -0
  326. package/data/packages/deploy/dist/providers/railway/commands/deploy/server.js +17 -0
  327. package/data/packages/deploy/dist/providers/railway/commands/launch/LaunchCmdOptions.js +2 -0
  328. package/data/packages/deploy/dist/providers/railway/commands/launch/launch.js +9 -0
  329. package/data/packages/deploy/dist/providers/railway/commands/setup/SetupCmdOptions.js +2 -0
  330. package/data/packages/deploy/dist/providers/railway/commands/setup/setup.js +146 -0
  331. package/data/packages/deploy/dist/providers/railway/index.js +83 -0
  332. package/data/packages/deploy/dist/providers/railway/jsonOutputSchemas.js +19 -0
  333. package/data/packages/deploy/dist/providers/railway/ports.js +6 -0
  334. package/data/packages/deploy/dist/providers/railway/railwayCli.js +85 -0
  335. package/data/packages/deploy/dist/providers/railway/railwayProject/RailwayProject.js +14 -0
  336. package/data/packages/deploy/dist/providers/railway/railwayProject/cli.js +80 -0
  337. package/data/packages/deploy/dist/providers/railway/railwayProject/index.js +48 -0
  338. package/data/packages/deploy/dist/providers/railway/railwayService/nameGenerator.js +24 -0
  339. package/data/packages/deploy/dist/providers/railway/railwayService/url.js +32 -0
  340. package/data/packages/deploy/package-lock.json +3536 -0
  341. package/data/packages/deploy/package.json +29 -0
  342. package/data/packages/prisma/dist/format.js +35 -0
  343. package/data/packages/prisma/dist/index.js +33 -0
  344. package/data/packages/prisma/package-lock.json +5101 -0
  345. package/data/packages/prisma/package.json +30 -0
  346. package/data/packages/studio/dist/index.js +48 -0
  347. package/data/packages/studio/dist/public/assets/Flow-b5112d3d.js +26 -0
  348. package/data/packages/studio/dist/public/assets/index-17ce6ed4.css +1 -0
  349. package/data/packages/studio/dist/public/assets/index-62a9d21a.js +120 -0
  350. package/data/packages/studio/dist/public/index.html +14 -0
  351. package/data/packages/studio/package-lock.json +1866 -0
  352. package/data/packages/studio/package.json +33 -0
  353. package/data/packages/ts-inspect/dist/exports.js +82 -0
  354. package/data/packages/ts-inspect/dist/index.js +28 -0
  355. package/data/packages/ts-inspect/package-lock.json +4947 -0
  356. package/data/packages/ts-inspect/package.json +31 -0
  357. package/data/packages/wasp-config/dist/__tests__/appAnalyzer.unit.test.d.ts +2 -0
  358. package/data/packages/wasp-config/dist/__tests__/appAnalyzer.unit.test.d.ts.map +1 -0
  359. package/data/packages/wasp-config/dist/__tests__/appAnalyzer.unit.test.js +59 -0
  360. package/data/packages/wasp-config/dist/__tests__/cli.unit.test.d.ts +2 -0
  361. package/data/packages/wasp-config/dist/__tests__/cli.unit.test.d.ts.map +1 -0
  362. package/data/packages/wasp-config/dist/__tests__/cli.unit.test.js +65 -0
  363. package/data/packages/wasp-config/dist/__tests__/mapTsAppSpecToAppSpecDecls.integration.test.d.ts +2 -0
  364. package/data/packages/wasp-config/dist/__tests__/mapTsAppSpecToAppSpecDecls.integration.test.d.ts.map +1 -0
  365. package/data/packages/wasp-config/dist/__tests__/mapTsAppSpecToAppSpecDecls.integration.test.js +126 -0
  366. package/data/packages/wasp-config/dist/__tests__/mapTsAppSpecToAppSpecDecls.unit.test.d.ts +2 -0
  367. package/data/packages/wasp-config/dist/__tests__/mapTsAppSpecToAppSpecDecls.unit.test.d.ts.map +1 -0
  368. package/data/packages/wasp-config/dist/__tests__/mapTsAppSpecToAppSpecDecls.unit.test.js +743 -0
  369. package/data/packages/wasp-config/dist/__tests__/testFixtures.d.ts +224 -0
  370. package/data/packages/wasp-config/dist/__tests__/testFixtures.d.ts.map +1 -0
  371. package/data/packages/wasp-config/dist/__tests__/testFixtures.js +656 -0
  372. package/data/packages/wasp-config/dist/__tests__/testFixtures.test-d.d.ts +2 -0
  373. package/data/packages/wasp-config/dist/__tests__/testFixtures.test-d.d.ts.map +1 -0
  374. package/data/packages/wasp-config/dist/__tests__/testFixtures.test-d.js +57 -0
  375. package/data/packages/wasp-config/dist/src/_private.d.ts +2 -0
  376. package/data/packages/wasp-config/dist/src/_private.d.ts.map +1 -0
  377. package/data/packages/wasp-config/dist/src/_private.js +1 -0
  378. package/data/packages/wasp-config/dist/src/appAnalyzer.d.ts +16 -0
  379. package/data/packages/wasp-config/dist/src/appAnalyzer.d.ts.map +1 -0
  380. package/data/packages/wasp-config/dist/src/appAnalyzer.js +34 -0
  381. package/data/packages/wasp-config/dist/src/appSpec.d.ts +223 -0
  382. package/data/packages/wasp-config/dist/src/appSpec.d.ts.map +1 -0
  383. package/data/packages/wasp-config/dist/src/appSpec.js +6 -0
  384. package/data/packages/wasp-config/dist/src/branded.d.ts +7 -0
  385. package/data/packages/wasp-config/dist/src/branded.d.ts.map +1 -0
  386. package/data/packages/wasp-config/dist/src/branded.js +1 -0
  387. package/data/packages/wasp-config/dist/src/cli.d.ts +6 -0
  388. package/data/packages/wasp-config/dist/src/cli.d.ts.map +1 -0
  389. package/data/packages/wasp-config/dist/src/cli.js +24 -0
  390. package/data/packages/wasp-config/dist/src/index.d.ts +8 -0
  391. package/data/packages/wasp-config/dist/src/index.d.ts.map +1 -0
  392. package/data/packages/wasp-config/dist/src/index.js +1 -0
  393. package/data/packages/wasp-config/dist/src/mapTsAppSpecToAppSpecDecls.d.ts +38 -0
  394. package/data/packages/wasp-config/dist/src/mapTsAppSpecToAppSpecDecls.d.ts.map +1 -0
  395. package/data/packages/wasp-config/dist/src/mapTsAppSpecToAppSpecDecls.js +294 -0
  396. package/data/packages/wasp-config/dist/src/publicApi/App.d.ts +24 -0
  397. package/data/packages/wasp-config/dist/src/publicApi/App.d.ts.map +1 -0
  398. package/data/packages/wasp-config/dist/src/publicApi/App.js +75 -0
  399. package/data/packages/wasp-config/dist/src/publicApi/tsAppSpec.d.ts +171 -0
  400. package/data/packages/wasp-config/dist/src/publicApi/tsAppSpec.d.ts.map +1 -0
  401. package/data/packages/wasp-config/dist/src/publicApi/tsAppSpec.js +1 -0
  402. package/data/packages/wasp-config/dist/src/run.d.ts +3 -0
  403. package/data/packages/wasp-config/dist/src/run.d.ts.map +1 -0
  404. package/data/packages/wasp-config/dist/src/run.js +18 -0
  405. package/data/packages/wasp-config/package-lock.json +3992 -0
  406. package/data/packages/wasp-config/package.json +39 -0
  407. package/main.js +9 -0
  408. package/package.json +1 -0
  409. package/readme.md +3 -0
  410. package/wasp-bin +0 -0
@@ -0,0 +1,74 @@
1
+ import '../auth-styles.css'
2
+ import styles from './SocialIcons.module.css'
3
+
4
+ // PRIVATE API
5
+ export const Google = () => (
6
+ <svg
7
+ className={styles.icon}
8
+ aria-hidden="true"
9
+ fill="currentColor"
10
+ viewBox="0 0 24 24"
11
+ >
12
+ <g id="brand" stroke="none" strokeWidth="1" fill="none" fillRule="evenodd">
13
+ <g id="google" fill="#000000" fillRule="nonzero">
14
+ <path
15
+ d="M11.99,13.9 L11.99,10.18 L21.35,10.18 C21.49,10.81 21.6,11.4 21.6,12.23 C21.6,17.94 17.77,22 12,22 C6.48,22 2,17.52 2,12 C2,6.48 6.48,2 12,2 C14.7,2 16.96,2.99 18.69,4.61 L15.85,7.37 C15.13,6.69 13.87,5.89 12,5.89 C8.69,5.89 5.99,8.64 5.99,12.01 C5.99,15.38 8.69,18.13 12,18.13 C15.83,18.13 17.24,15.48 17.5,13.91 L11.99,13.91 L11.99,13.9 Z"
16
+ id="Shape"
17
+ ></path>
18
+ </g>
19
+ </g>
20
+ </svg>
21
+ )
22
+
23
+ export const Keycloak = () => (
24
+ <svg
25
+ className={styles.icon}
26
+ aria-hidden="true"
27
+ fill="currentColor"
28
+ viewBox="0 0 559 466"
29
+ >
30
+ <g id="brand" transform="matrix(1,0,0,1,-233.075,-279.1)" fill="#000000" fillRule="nonzero">
31
+ <path
32
+ d="M786.2,395.5L705.6,395.5C704.1,395.5 702.6,394.7 701.9,393.4L637.2,281.2C636.4,279.9 635,279.1 633.4,279.1L369.4,279.1C367.9,279.1 366.4,279.9 365.7,281.2L298.4,397.6L233.6,509.8C232.9,511.1 232.9,512.7 233.6,514.1L298.4,626.3L365.6,742.8C366.3,744.1 367.8,745 369.3,744.9L633.4,744.9C634.9,744.9 636.4,744.1 637.2,742.8L702,630.6C702.7,629.3 704.2,628.4 705.7,628.5L786.3,628.5C789,628.5 791.1,626.3 791.1,623.7L791.1,400.4C791,397.7 788.8,395.5 786.2,395.5ZM477.5,630.6L457.2,665.6C456.9,666.1 456.4,666.6 455.9,666.9C455.3,667.2 454.7,667.4 454,667.4L413.7,667.4C412.3,667.4 411,666.7 410.4,665.4L350.3,561.1L344.4,550.8L322.8,513.9C322.5,513.4 322.3,512.8 322.4,512.1C322.4,511.5 322.6,510.8 322.9,510.3L344.6,472.7L410.5,358.7C411.2,357.5 412.5,356.7 413.8,356.7L454,356.7C454.7,356.7 455.4,356.9 456.1,357.2C456.6,357.5 457.1,357.9 457.4,358.5L477.7,393.7C478.3,394.9 478.2,396.4 477.5,397.5L412.4,510.3C412.1,510.8 412,511.4 412,511.9C412,512.5 412.2,513 412.4,513.5L477.5,626.2C478.4,627.7 478.3,629.3 477.5,630.6ZM679.6,513.9L658,550.8L652.1,561.1L592,665.4C591.3,666.6 590.1,667.4 588.7,667.4L548.4,667.4C547.7,667.4 547.1,667.2 546.5,666.9C546,666.6 545.5,666.2 545.2,665.6L524.9,630.6C524,629.3 524,627.7 524.8,626.4L589.9,513.7C590.2,513.2 590.3,512.6 590.3,512.1C590.3,511.5 590.1,511 589.9,510.5L524.8,397.7C524.1,396.5 524,395.1 524.6,393.9L544.9,358.7C545.2,358.2 545.7,357.7 546.2,357.4C546.8,357 547.5,356.9 548.3,356.9L588.7,356.9C590.1,356.9 591.4,357.6 592,358.9L657.9,472.9L679.6,510.5C679.9,511.1 680.1,511.7 680.1,512.3C680.1,512.7 679.9,513.3 679.6,513.9Z"
33
+ />
34
+ </g>
35
+ </svg>
36
+ )
37
+
38
+ // PRIVATE API
39
+ export const GitHub = () => (
40
+ <svg
41
+ className={styles.icon}
42
+ aria-hidden="true"
43
+ fill="currentColor"
44
+ viewBox="0 0 20 20"
45
+ >
46
+ <path
47
+ fillRule="evenodd"
48
+ d="M10 0C4.477 0 0 4.484 0 10.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0110 4.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.942.359.31.678.921.678 1.856 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0020 10.017C20 4.484 15.522 0 10 0z"
49
+ clipRule="evenodd"
50
+ />
51
+ </svg>
52
+ )
53
+
54
+ export const Discord = () => (
55
+ <svg
56
+ className={styles.icon}
57
+ aria-hidden="true"
58
+ fill="currentColor"
59
+ viewBox="0 0 16 16"
60
+ >
61
+ <path d="M13.545 2.907a13.227 13.227 0 00-3.257-1.011.05.05 0 00-.052.025c-.141.25-.297.577-.406.833a12.19 12.19 0 00-3.658 0 8.258 8.258 0 00-.412-.833.051.051 0 00-.052-.025c-1.125.194-2.22.534-3.257 1.011a.041.041 0 00-.021.018C.356 6.024-.213 9.047.066 12.032c.001.014.01.028.021.037a13.276 13.276 0 003.995 2.02.05.05 0 00.056-.019c.308-.42.582-.863.818-1.329a.05.05 0 00-.01-.059.051.051 0 00-.018-.011 8.875 8.875 0 01-1.248-.595.05.05 0 01-.02-.066.051.051 0 01.015-.019c.084-.063.168-.129.248-.195a.05.05 0 01.051-.007c2.619 1.196 5.454 1.196 8.041 0a.052.052 0 01.053.007c.08.066.164.132.248.195a.051.051 0 01-.004.085 8.254 8.254 0 01-1.249.594.05.05 0 00-.03.03.052.052 0 00.003.041c.24.465.515.909.817 1.329a.05.05 0 00.056.019 13.235 13.235 0 004.001-2.02.049.049 0 00.021-.037c.334-3.451-.559-6.449-2.366-9.106a.034.034 0 00-.02-.019zm-8.198 7.307c-.789 0-1.438-.724-1.438-1.612 0-.889.637-1.613 1.438-1.613.807 0 1.45.73 1.438 1.613 0 .888-.637 1.612-1.438 1.612zm5.316 0c-.788 0-1.438-.724-1.438-1.612 0-.889.637-1.613 1.438-1.613.807 0 1.451.73 1.438 1.613 0 .888-.631 1.612-1.438 1.612z" />
62
+ </svg>
63
+ )
64
+
65
+ export const Slack = () => (
66
+ <svg
67
+ className={styles.icon}
68
+ aria-hidden="true"
69
+ fill="currentColor"
70
+ viewBox="0 0 24 24"
71
+ >
72
+ <path d="M13 10C13 11.1046 13.8954 12 15 12C16.1046 12 17 11.1046 17 10V5C17 3.89543 16.1046 3 15 3C13.8954 3 13 3.89543 13 5V10ZM5 8C3.89543 8 3 8.89543 3 10C3 11.1046 3.89543 12 5 12H10C11.1046 12 12 11.1046 12 10C12 8.89543 11.1046 8 10 8H5ZM15 13C13.8954 13 13 13.8954 13 15C13 16.1046 13.8954 17 15 17H20C21.1046 17 22 16.1046 22 15C22 13.8954 21.1046 13 20 13H15ZM10 22C8.89543 22 8 21.1046 8 20L8 15C8 13.8954 8.89543 13 10 13C11.1046 13 12 13.8954 12 15V20C12 21.1046 11.1046 22 10 22ZM8 5C8 3.89543 8.89543 3 10 3C11.1046 3 12 3.89543 12 5V7H10C8.89543 7 8 6.10457 8 5ZM3 15C3 16.1046 3.89543 17 5 17C6.10457 17 7 16.1046 7 15V13H5C3.89543 13 3 13.8954 3 15ZM17 20C17 21.1046 16.1046 22 15 22C13.8954 22 13 21.1046 13 20V18H15C16.1046 18 17 18.8954 17 20ZM22 10C22 8.89543 21.1046 8 20 8C18.8954 8 18 8.89543 18 10V12H20C21.1046 12 22 11.1046 22 10Z" />
73
+ </svg>
74
+ )
@@ -0,0 +1,29 @@
1
+ import { login, signup } from '../../../username'
2
+
3
+ // PRIVATE API
4
+ export function useUsernameAndPassword({
5
+ onError,
6
+ onSuccess,
7
+ isLogin,
8
+ }: {
9
+ onError: (error: Error) => void
10
+ onSuccess: () => void
11
+ isLogin: boolean
12
+ }) {
13
+ async function handleSubmit(data) {
14
+ try {
15
+ if (!isLogin) {
16
+ await signup(data)
17
+ }
18
+ await login(data)
19
+
20
+ onSuccess()
21
+ } catch (err: unknown) {
22
+ onError(err as Error)
23
+ }
24
+ }
25
+
26
+ return {
27
+ handleSubmit,
28
+ }
29
+ }
@@ -0,0 +1,16 @@
1
+ import { CSSProperties } from "react"
2
+
3
+ export const clsx = (...classes: (string | undefined)[]) => {
4
+ return classes.filter(Boolean).join(" ");
5
+ };
6
+
7
+ export const tokenObjToCSSVars = (
8
+ prefix: string,
9
+ tokenObj: Record<string, string | number>,
10
+ ): CSSProperties =>
11
+ Object.fromEntries(
12
+ Object.entries(tokenObj).map(([key, value]) => [
13
+ `--${prefix}-${key}`,
14
+ value,
15
+ ]),
16
+ );
@@ -0,0 +1,77 @@
1
+ {{={= =}=}}
2
+ import { UseFormReturn, RegisterOptions } from 'react-hook-form'
3
+ import type { LoginSignupFormFields } from './internal/common/LoginSignupForm'
4
+
5
+ // PRIVATE API
6
+ export enum State {
7
+ Login = 'login',
8
+ Signup = 'signup',
9
+ {=# isEmailAuthEnabled =}
10
+ ForgotPassword = 'forgot-password',
11
+ ResetPassword = 'reset-password',
12
+ VerifyEmail = 'verify-email',
13
+ {=/ isEmailAuthEnabled =}
14
+ }
15
+
16
+ // PUBLIC API
17
+ export type CustomizationOptions = {
18
+ logo?: string
19
+ socialLayout?: 'horizontal' | 'vertical'
20
+ appearance?: {
21
+ // ATTENTION: Keep this list in sync with the one at `./internal/auth-styles.css`
22
+ colors?: {
23
+ waspYellow?: string,
24
+ gray700?: string,
25
+ gray600?: string,
26
+ gray500?: string,
27
+ gray400?: string,
28
+ red?: string,
29
+ darkRed?: string,
30
+ green?: string,
31
+
32
+ brand?: string,
33
+ brandAccent?: string,
34
+ errorBackground?: string,
35
+ errorText?: string,
36
+ successBackground?: string,
37
+ successText?: string,
38
+
39
+ submitButtonText?: string,
40
+
41
+ formErrorText?: string,
42
+ },
43
+ fontSizes?: {
44
+ sm?: string,
45
+ },
46
+ }
47
+ }
48
+
49
+ // PRIVATE API
50
+ export type ErrorMessage = {
51
+ title: string
52
+ description?: string
53
+ }
54
+
55
+ // PRIVATE API
56
+ export type FormState = {
57
+ isLoading: boolean
58
+ }
59
+
60
+ // PRIVATE API
61
+ export type AdditionalSignupFieldRenderFn = (
62
+ hookForm: UseFormReturn<LoginSignupFormFields>,
63
+ formState: FormState
64
+ ) => React.ReactNode
65
+
66
+ // PRIVATE API
67
+ export type AdditionalSignupField = {
68
+ name: string
69
+ label: string
70
+ type: 'input' | 'textarea'
71
+ validations?: RegisterOptions<LoginSignupFormFields>
72
+ }
73
+
74
+ // PRIVATE API
75
+ export type AdditionalSignupFields =
76
+ | (AdditionalSignupField | AdditionalSignupFieldRenderFn)[]
77
+ | AdditionalSignupFieldRenderFn
@@ -0,0 +1,17 @@
1
+ {{={= =}=}}
2
+
3
+ import { config } from 'wasp/client'
4
+ import { SocialButton } from '../forms/internal/social/SocialButton'
5
+ import * as SocialIcons from '../forms/internal/social/SocialIcons'
6
+
7
+ // PUBLIC API
8
+ export const signInUrl: string = `${config.apiUrl}{= signInPath =}`
9
+
10
+ // PUBLIC API
11
+ export function SignInButton(): React.JSX.Element {
12
+ return (
13
+ <SocialButton href={signInUrl}>
14
+ <SocialIcons.{= displayName =} />
15
+ </SocialButton>
16
+ )
17
+ }
@@ -0,0 +1,15 @@
1
+ import { setSessionId } from 'wasp/client/api'
2
+ import { invalidateAndRemoveQueries } from '../../client/operations/internal/resources.js'
3
+
4
+ // PRIVATE API
5
+ export async function initSession(sessionId: string): Promise<void> {
6
+ setSessionId(sessionId)
7
+ // We need to invalidate queries after login in order to get the correct user
8
+ // data in the React components (using `useAuth`).
9
+ // Redirects after login won't work properly without this.
10
+
11
+ // TODO(filip): We are currently removing all the queries, but we should
12
+ // remove only non-public, user-dependent queries - public queries are
13
+ // expected not to change in respect to the currently logged in user.
14
+ await invalidateAndRemoveQueries()
15
+ }
@@ -0,0 +1,9 @@
1
+ // PUBLIC API
2
+ export {
3
+ getEmail,
4
+ getUsername,
5
+ getFirstProviderUserId,
6
+ } from './user.js'
7
+
8
+ // PUBLIC API
9
+ export { type AuthUser } from '../server/auth/user.js'
@@ -0,0 +1,22 @@
1
+ import * as jwt from 'oslo/jwt'
2
+ import { config } from 'wasp/server'
3
+
4
+ const JWT_SECRET = new TextEncoder().encode(config.auth.jwtSecret)
5
+ const JWT_ALGORITHM = 'HS256'
6
+
7
+ // PRIVATE API
8
+ export function createJWT(
9
+ data: Parameters<typeof jwt.createJWT>[2],
10
+ options: Parameters<typeof jwt.createJWT>[3],
11
+ ): Promise<string> {
12
+ return jwt.createJWT(JWT_ALGORITHM, JWT_SECRET, data, options)
13
+ }
14
+
15
+ // PRIVATE API
16
+ export async function validateJWT<Payload>(token: string): Promise<Payload> {
17
+ const { payload } = await jwt.validateJWT(JWT_ALGORITHM, JWT_SECRET, token)
18
+ return payload as Payload
19
+ }
20
+
21
+ // PRIVATE API
22
+ export { TimeSpan } from 'oslo'
@@ -0,0 +1,18 @@
1
+ import { api, removeLocalUserData } from 'wasp/client/api'
2
+ import { invalidateAndRemoveQueries } from '../client/operations/internal/resources.js'
3
+
4
+ // PUBLIC API
5
+ export default async function logout(): Promise<void> {
6
+ try {
7
+ await api.post('/auth/logout')
8
+ } finally {
9
+ // Even if the logout request fails, we still want to remove the local user data
10
+ // in case the logout failed because of a network error and the user walked away
11
+ // from the computer.
12
+ removeLocalUserData()
13
+
14
+ // TODO(filip): We are currently invalidating and removing all the queries, but
15
+ // we should remove only the non-public, user-dependent ones.
16
+ await invalidateAndRemoveQueries()
17
+ }
18
+ }
@@ -0,0 +1,53 @@
1
+ {{={= =}=}}
2
+ import { Lucia } from "lucia";
3
+ import { PrismaAdapter } from "@lucia-auth/adapter-prisma";
4
+ import { prisma } from 'wasp/server'
5
+ import { type {= userEntityUpper =} } from "wasp/entities"
6
+
7
+ const prismaAdapter = new PrismaAdapter(
8
+ prisma.{= sessionEntityLower =},
9
+ prisma.{= authEntityLower =},
10
+ );
11
+
12
+ // PRIVATE API
13
+ /**
14
+ * We are using Lucia for session management.
15
+ *
16
+ * Some details:
17
+ * 1. We are using the Prisma adapter for Lucia.
18
+ * 2. We are not using cookies for session management. Instead, we are using
19
+ * the Authorization header to send the session token.
20
+ * 3. Our `Session` entity is connected to the `Auth` entity.
21
+ * 4. We are exposing the `userId` field from the `Auth` entity to
22
+ * make fetching the User easier.
23
+ */
24
+ export const auth = new Lucia<{}, {
25
+ userId: {= userEntityUpper =}['id']
26
+ }>(prismaAdapter, {
27
+ // Since we are not using cookies, we don't need to set any cookie options.
28
+ // But in the future, if we decide to use cookies, we can set them here.
29
+
30
+ // sessionCookie: {
31
+ // name: "session",
32
+ // expires: true,
33
+ // attributes: {
34
+ // secure: !config.isDevelopment,
35
+ // sameSite: "lax",
36
+ // },
37
+ // },
38
+ getUserAttributes({ userId }) {
39
+ return {
40
+ userId,
41
+ };
42
+ },
43
+ });
44
+
45
+ declare module "lucia" {
46
+ interface Register {
47
+ Lucia: typeof auth;
48
+ DatabaseSessionAttributes: {};
49
+ DatabaseUserAttributes: {
50
+ userId: {= userEntityUpper =}['id']
51
+ };
52
+ }
53
+ }
@@ -0,0 +1,36 @@
1
+ import { hash, verify, Version, type Options } from "@node-rs/argon2";
2
+
3
+ // The options are the same as the ones used in the oslo/password library
4
+ const hashingOptions: Options = {
5
+ memoryCost: 19456,
6
+ timeCost: 2,
7
+ outputLen: 32,
8
+ parallelism: 1,
9
+ version: Version.V0x13,
10
+ };
11
+
12
+ // PRIVATE API
13
+ export async function hashPassword(password: string): Promise<string> {
14
+ return hash(normalizePassword(password), hashingOptions);
15
+ }
16
+
17
+ // PRIVATE API
18
+ export async function verifyPassword(
19
+ hashedPassword: string,
20
+ password: string
21
+ ): Promise<void> {
22
+ const validPassword = await verify(
23
+ hashedPassword,
24
+ normalizePassword(password),
25
+ hashingOptions
26
+ );
27
+ if (!validPassword) {
28
+ throw new Error("Invalid password");
29
+ }
30
+ }
31
+
32
+ // We are normalising the password to ensure that the password is always hashed in the same way
33
+ // We have the same normalising process as oslo/password did in the past
34
+ function normalizePassword(password: string): string {
35
+ return password.normalize("NFKC");
36
+ }
@@ -0,0 +1,9 @@
1
+ {{={= =}=}}
2
+
3
+ {=# emailUserSignupFields.isDefined =}
4
+ export type { UserEmailSignupFields } from './types';
5
+ {=/ emailUserSignupFields.isDefined =}
6
+
7
+ {=# usernameAndPasswordUserSignupFields.isDefined =}
8
+ export type { UserUsernameAndPasswordSignupFields } from './types';
9
+ {=/ usernameAndPasswordUserSignupFields.isDefined =}
@@ -0,0 +1,68 @@
1
+ {{={= =}=}}
2
+ import type { Router, Request } from 'express'
3
+ import type { Prisma } from '@prisma/client'
4
+ import type { Expand, Exact } from 'wasp/universal/types'
5
+ import type { ProviderName } from '../utils'
6
+
7
+ // PUBLIC API
8
+ export function defineUserSignupFields<T extends UserSignupFields>(
9
+ fields: Exact<UserSignupFields, T>
10
+ ): T {
11
+ return fields
12
+ }
13
+
14
+ {=# emailUserSignupFields.isDefined =}
15
+ {=& emailUserSignupFields.importStatement =}
16
+ // PUBLIC API
17
+ export type UserEmailSignupFields = InferUserSignupFields<typeof {= emailUserSignupFields.importIdentifier =}>;
18
+ {=/ emailUserSignupFields.isDefined =}
19
+
20
+ {=# usernameAndPasswordUserSignupFields.isDefined =}
21
+ {=& usernameAndPasswordUserSignupFields.importStatement =}
22
+ // PUBLIC API
23
+ export type UserUsernameAndPasswordSignupFields = InferUserSignupFields<typeof {= usernameAndPasswordUserSignupFields.importIdentifier =}>;
24
+ {=/ usernameAndPasswordUserSignupFields.isDefined =}
25
+
26
+ /**
27
+ * Extracts the result types from a UserSignupFields object.
28
+ *
29
+ * This type transforms an object containing field getter functions
30
+ * into an object with the same keys but whose values are the return types
31
+ * of those functions.
32
+ */
33
+ type InferUserSignupFields<T extends UserSignupFields> = {
34
+ [K in keyof T]: T[K] extends FieldGetter<PossibleUserFieldValues>
35
+ ? ReturnType<T[K]>
36
+ : never
37
+ }
38
+
39
+ type UserEntityCreateInput = Prisma.{= userEntityUpper =}CreateInput
40
+
41
+ // PRIVATE API
42
+ export type ProviderConfig = {
43
+ // Unique provider identifier, used as part of URL paths
44
+ id: ProviderName;
45
+ displayName: string;
46
+ // Every provider must have a setupRouter method which returns the Express router.
47
+ // In this function we are flexibile to do what ever is necessary to make the provider work.
48
+ createRouter(provider: ProviderConfig): Router;
49
+ };
50
+
51
+ // PRIVATE API
52
+ export type RequestWithWasp = Request & { wasp?: { [key: string]: any } }
53
+
54
+ // PRIVATE API
55
+ export type PossibleUserFields = Expand<Partial<UserEntityCreateInput>>
56
+
57
+ // PRIVATE API
58
+ export type UserSignupFields = {
59
+ [key in keyof PossibleUserFields]: FieldGetter<
60
+ PossibleUserFields[key]
61
+ >
62
+ }
63
+
64
+ type FieldGetter<T extends PossibleUserFieldValues> = (
65
+ data: { [key: string]: unknown }
66
+ ) => Promise<T | undefined> | T | undefined
67
+
68
+ type PossibleUserFieldValues = PossibleUserFields[keyof PossibleUserFields]
@@ -0,0 +1,78 @@
1
+ {{={= =}=}}
2
+ import { Request as ExpressRequest } from "express";
3
+
4
+ import { type {= userEntityUpper =} } from '../entities/index.js';
5
+ import { type AuthUserData } from '../server/auth/user.js';
6
+
7
+ import { auth } from "./lucia.js";
8
+ import type { Session } from "lucia";
9
+ import { createInvalidCredentialsError } from "./utils.js";
10
+
11
+ import { prisma } from 'wasp/server';
12
+ import { createAuthUserData } from "../server/auth/user.js";
13
+
14
+ // PRIVATE API
15
+ // Creates a new session for the `authId` in the database
16
+ export async function createSession(authId: string): Promise<Session> {
17
+ return auth.createSession(authId, {});
18
+ }
19
+
20
+ type SessionAndUser = {
21
+ session: Session;
22
+ user: AuthUserData;
23
+ }
24
+
25
+ // PRIVATE API
26
+ export async function getSessionAndUserFromBearerToken(req: ExpressRequest): Promise<SessionAndUser | null> {
27
+ const authorizationHeader = req.headers["authorization"];
28
+
29
+ if (typeof authorizationHeader !== "string") {
30
+ return null;
31
+ }
32
+
33
+ const sessionId = auth.readBearerToken(authorizationHeader);
34
+ if (!sessionId) {
35
+ return null;
36
+ }
37
+
38
+ return getSessionAndUserFromSessionId(sessionId);
39
+ }
40
+
41
+ // PRIVATE API
42
+ export async function getSessionAndUserFromSessionId(sessionId: string): Promise<SessionAndUser | null> {
43
+ const { session, user: authEntity } = await auth.validateSession(sessionId);
44
+
45
+ if (!session || !authEntity) {
46
+ return null;
47
+ }
48
+
49
+ return {
50
+ session,
51
+ user: await getAuthUserData(authEntity.userId)
52
+ }
53
+ }
54
+
55
+ async function getAuthUserData(userId: {= userEntityUpper =}['id']): Promise<AuthUserData> {
56
+ const user = await prisma.{= userEntityLower =}
57
+ .findUnique({
58
+ where: { id: userId },
59
+ include: {
60
+ {= authFieldOnUserEntityName =}: {
61
+ include: {
62
+ {= identitiesFieldOnAuthEntityName =}: true
63
+ }
64
+ }
65
+ }
66
+ })
67
+
68
+ if (!user) {
69
+ throw createInvalidCredentialsError()
70
+ }
71
+
72
+ return createAuthUserData(user);
73
+ }
74
+
75
+ // PRIVATE API
76
+ export function invalidateSession(sessionId: string): Promise<void> {
77
+ return auth.invalidateSession(sessionId);
78
+ }
@@ -0,0 +1,2 @@
1
+ // todo(filip): turn into a proper import/path
2
+ export type { ProviderName } from 'wasp/server/_types'
@@ -0,0 +1,37 @@
1
+ {{={= =}=}}
2
+ import { deserialize } from 'wasp/core/serialization'
3
+ import { useQuery, buildAndRegisterQuery } from 'wasp/client/operations'
4
+ import type { QueryFunction, Query } from 'wasp/client/operations/rpc'
5
+ import { api, handleApiError } from 'wasp/client/api'
6
+ import { HttpMethod } from 'wasp/client'
7
+ import type { AuthUser, AuthUserData } from '../server/auth/user.js'
8
+ import { makeAuthUserIfPossible } from '../auth/user.js'
9
+ import { UseQueryResult } from '@tanstack/react-query'
10
+
11
+ // PUBLIC API
12
+ export const getMe: Query<void, AuthUser | null> = createUserGetter()
13
+
14
+ // PUBLIC API
15
+ export default function useAuth(): UseQueryResult<AuthUser | null> {
16
+ return useQuery(getMe)
17
+ }
18
+
19
+ function createUserGetter(): Query<void, AuthUser | null> {
20
+ const getMeRelativePath = 'auth/me'
21
+ const getMeRoute = { method: HttpMethod.Get, path: `/${getMeRelativePath}` }
22
+ const getMe: QueryFunction<void, AuthUser | null> = async () => {
23
+ try {
24
+ const response = await api.get(getMeRoute.path)
25
+ const userData = deserialize<AuthUserData | null>(response.data)
26
+ return makeAuthUserIfPossible(userData)
27
+ } catch (error) {
28
+ throw handleApiError(error)
29
+ }
30
+ }
31
+
32
+ return buildAndRegisterQuery(getMe, {
33
+ queryCacheKey: [getMeRelativePath],
34
+ queryRoute: getMeRoute,
35
+ entitiesUsed: {=& entitiesGetMeDependsOn =},
36
+ })
37
+ }
@@ -0,0 +1,63 @@
1
+ import { type ProviderName } from '../server/_types/index.js'
2
+ import type {
3
+ AuthUserData,
4
+ AuthUser,
5
+ UserEntityWithAuth,
6
+ } from '../server/auth/user.js'
7
+ import { isNotNull } from '../universal/predicates.js'
8
+
9
+ /**
10
+ * We split the user.ts code into two files to avoid some server-only
11
+ * code (Oslo's hashing functions) being imported on the client.
12
+ */
13
+
14
+ // PUBLIC API
15
+ export function getEmail(user: UserEntityWithAuth): string | null {
16
+ return findUserIdentity(user, "email")?.providerUserId ?? null;
17
+ }
18
+
19
+ // PUBLIC API
20
+ export function getUsername(user: UserEntityWithAuth): string | null {
21
+ return findUserIdentity(user, "username")?.providerUserId ?? null;
22
+ }
23
+
24
+ // PUBLIC API
25
+ export function getFirstProviderUserId(user?: UserEntityWithAuth): string | null {
26
+ if (!user || !user.auth || !user.auth.identities || user.auth.identities.length === 0) {
27
+ return null;
28
+ }
29
+
30
+ return user.auth.identities[0].providerUserId ?? null;
31
+ }
32
+
33
+ // PRIVATE API (used in SDK and server)
34
+ export type { AuthUserData, AuthUser } from '../server/auth/user.js'
35
+
36
+ // PRIVATE API (used in SDK and server)
37
+ export function makeAuthUserIfPossible(user: null): null
38
+ export function makeAuthUserIfPossible(user: AuthUserData): AuthUser
39
+ export function makeAuthUserIfPossible(user: AuthUserData | null): AuthUser | null
40
+ export function makeAuthUserIfPossible(
41
+ user: AuthUserData | null,
42
+ ): AuthUser | null {
43
+ return user ? makeAuthUser(user) : null
44
+ }
45
+
46
+ function makeAuthUser(data: AuthUserData): AuthUser {
47
+ return {
48
+ ...data,
49
+ getFirstProviderUserId: () => {
50
+ const identities = Object.values(data.identities).filter(isNotNull);
51
+ return identities.length > 0 ? identities[0].id : null;
52
+ },
53
+ };
54
+ }
55
+
56
+ function findUserIdentity(user: UserEntityWithAuth, providerName: ProviderName): NonNullable<UserEntityWithAuth['auth']>['identities'][number] | null {
57
+ if (!user.auth) {
58
+ return null;
59
+ }
60
+ return user.auth.identities.find(
61
+ (identity) => identity.providerName === providerName
62
+ ) ?? null;
63
+ }
@@ -0,0 +1,13 @@
1
+ {{={= =}=}}
2
+ import { api, handleApiError } from 'wasp/client/api'
3
+ import { initSession } from '../../helpers/user'
4
+
5
+ export async function login(data: { username: string, password: string }): Promise<void> {
6
+ try {
7
+ const response = await api.post('{= loginPath =}', data)
8
+
9
+ await initSession(response.data.sessionId)
10
+ } catch (error) {
11
+ throw handleApiError(error)
12
+ }
13
+ }