@wasp.sh/wasp-cli-darwin-arm64-unknown 0.23.0 → 0.24.0-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/data/Cli/starters/basic/main.wasp.ts +60 -0
- package/data/Cli/starters/basic/package.json +4 -1
- package/data/Cli/starters/basic/prettier.config.mjs +9 -0
- package/data/Cli/starters/basic/src/tags/tags.wasp.ts +8 -0
- package/data/Cli/starters/basic/src/tasks/task.wasp.ts +16 -0
- package/data/Cli/starters/minimal/main.wasp.ts +12 -0
- package/data/Cli/starters/minimal/package.json +4 -1
- package/data/Cli/starters/skeleton/AGENTS.md +23 -0
- package/data/Cli/starters/skeleton/CLAUDE.md +23 -0
- package/data/Cli/starters/skeleton/tsconfig.json +5 -26
- package/data/Cli/starters/{ts-minimal → skeleton}/tsconfig.src.json +2 -1
- package/data/Cli/starters/{ts-minimal → skeleton}/tsconfig.wasp.json +5 -2
- package/data/Generator/libs/auth/{wasp.sh-lib-auth-0.23.0.tgz → wasp.sh-lib-auth-0.24.0.tgz} +0 -0
- package/data/Generator/libs/vite-ssr/{wasp.sh-lib-vite-ssr-0.23.0.tgz → wasp.sh-lib-vite-ssr-0.24.0.tgz} +0 -0
- package/data/Generator/templates/sdk/wasp/api/index.ts +51 -47
- package/data/Generator/templates/sdk/wasp/auth/email/actions/login.ts +5 -2
- package/data/Generator/templates/sdk/wasp/auth/email/actions/passwordReset.ts +9 -4
- package/data/Generator/templates/sdk/wasp/auth/email/actions/signup.ts +5 -2
- package/data/Generator/templates/sdk/wasp/auth/email/actions/verifyEmail.ts +5 -2
- package/data/Generator/templates/sdk/wasp/auth/responseSchemas.ts +10 -0
- package/data/Generator/templates/sdk/wasp/auth/useAuth.ts +2 -2
- package/data/Generator/templates/sdk/wasp/auth/username/actions/login.ts +5 -3
- package/data/Generator/templates/sdk/wasp/auth/username/actions/signup.ts +3 -2
- package/data/Generator/templates/sdk/wasp/client/app/layout.tsx +13 -20
- package/data/Generator/templates/sdk/wasp/client/app/pages/OAuthCallback.tsx +12 -11
- package/data/Generator/templates/sdk/wasp/client/env/schema.ts +8 -8
- package/data/Generator/templates/sdk/wasp/client/env.ts +2 -2
- package/data/Generator/templates/sdk/wasp/client/operations/internal/index.ts +4 -2
- package/data/Generator/templates/sdk/wasp/client/router/NavLink.tsx +21 -0
- package/data/Generator/templates/sdk/wasp/client/router/index.ts +2 -0
- package/data/Generator/templates/sdk/wasp/client/vite/plugins/typescriptCheck.ts +8 -4
- package/data/Generator/templates/sdk/wasp/client/vite/plugins/validateEnv.ts +72 -44
- package/data/Generator/templates/sdk/wasp/client/vite/plugins/wasp.ts +1 -1
- package/data/Generator/templates/sdk/wasp/tsconfig.json +3 -0
- package/data/Generator/templates/types/spec/register.ts +14 -0
- package/data/packages/deploy/dist/providers/railway/commands/setup/setup.js +9 -0
- package/data/packages/deploy/dist/providers/railway/jsonOutputSchemas.js +47 -0
- package/data/packages/deploy/dist/providers/railway/railwayService/deployment.js +45 -0
- package/data/packages/deploy/package-lock.json +2 -2
- package/data/packages/deploy/package.json +1 -1
- package/data/packages/prisma/package-lock.json +2 -2
- package/data/packages/prisma/package.json +1 -2
- package/data/packages/spec/dist/__tests__/cli.unit.test.js +128 -0
- package/data/packages/spec/dist/__tests__/legacy/appAnalyzer.unit.test.d.ts.map +1 -0
- package/data/packages/{wasp-config/dist/__tests__ → spec/dist/__tests__/legacy}/appAnalyzer.unit.test.js +3 -3
- package/data/packages/spec/dist/__tests__/legacy/mapTsAppSpecToAppSpecDecls.integration.test.d.ts.map +1 -0
- package/data/packages/{wasp-config/dist/__tests__ → spec/dist/__tests__/legacy}/mapTsAppSpecToAppSpecDecls.integration.test.js +2 -2
- package/data/packages/spec/dist/__tests__/legacy/mapTsAppSpecToAppSpecDecls.unit.test.d.ts.map +1 -0
- package/data/packages/{wasp-config/dist/__tests__ → spec/dist/__tests__/legacy}/mapTsAppSpecToAppSpecDecls.unit.test.js +4 -18
- package/data/packages/{wasp-config/dist/__tests__ → spec/dist/__tests__/legacy}/testFixtures.d.ts +4 -4
- package/data/packages/spec/dist/__tests__/legacy/testFixtures.d.ts.map +1 -0
- package/data/packages/{wasp-config/dist/__tests__ → spec/dist/__tests__/legacy}/testFixtures.js +2 -2
- package/data/packages/spec/dist/__tests__/legacy/testFixtures.test-d.d.ts.map +1 -0
- package/data/packages/spec/dist/__tests__/spec/appAnalyzer.unit.test.d.ts +2 -0
- package/data/packages/spec/dist/__tests__/spec/appAnalyzer.unit.test.d.ts.map +1 -0
- package/data/packages/spec/dist/__tests__/spec/appAnalyzer.unit.test.js +68 -0
- package/data/packages/spec/dist/__tests__/spec/mapApp.unit.test.d.ts +2 -0
- package/data/packages/spec/dist/__tests__/spec/mapApp.unit.test.d.ts.map +1 -0
- package/data/packages/spec/dist/__tests__/spec/mapApp.unit.test.js +814 -0
- package/data/packages/spec/dist/__tests__/spec/refObject.test-d.d.ts +2 -0
- package/data/packages/spec/dist/__tests__/spec/refObject.test-d.d.ts.map +1 -0
- package/data/packages/spec/dist/__tests__/spec/refObject.test-d.js +148 -0
- package/data/packages/spec/dist/__tests__/spec/refObject.unit.test.d.ts +2 -0
- package/data/packages/spec/dist/__tests__/spec/refObject.unit.test.d.ts.map +1 -0
- package/data/packages/spec/dist/__tests__/spec/refObject.unit.test.js +49 -0
- package/data/packages/spec/dist/__tests__/spec/refObjectPath.unit.test.d.ts +2 -0
- package/data/packages/spec/dist/__tests__/spec/refObjectPath.unit.test.d.ts.map +1 -0
- package/data/packages/spec/dist/__tests__/spec/refObjectPath.unit.test.js +204 -0
- package/data/packages/spec/dist/__tests__/spec/testFixtures.d.ts +85 -0
- package/data/packages/spec/dist/__tests__/spec/testFixtures.d.ts.map +1 -0
- package/data/packages/spec/dist/__tests__/spec/testFixtures.js +473 -0
- package/data/packages/spec/dist/__tests__/spec/tsAppSpec.test-d.d.ts +2 -0
- package/data/packages/spec/dist/__tests__/spec/tsAppSpec.test-d.d.ts.map +1 -0
- package/data/packages/spec/dist/__tests__/spec/tsAppSpec.test-d.js +44 -0
- package/data/packages/spec/dist/__tests__/spec-pipeline/pipeline.integration.test.d.ts +2 -0
- package/data/packages/spec/dist/__tests__/spec-pipeline/pipeline.integration.test.d.ts.map +1 -0
- package/data/packages/spec/dist/__tests__/spec-pipeline/pipeline.integration.test.js +218 -0
- package/data/packages/spec/dist/__tests__/spec-pipeline/transformWaspTsSpecFile/imports.unit.test.d.ts +2 -0
- package/data/packages/spec/dist/__tests__/spec-pipeline/transformWaspTsSpecFile/imports.unit.test.d.ts.map +1 -0
- package/data/packages/spec/dist/__tests__/spec-pipeline/transformWaspTsSpecFile/imports.unit.test.js +174 -0
- package/data/packages/spec/dist/__tests__/spec-pipeline/transformWaspTsSpecFile/refHelper.unit.test.d.ts +2 -0
- package/data/packages/spec/dist/__tests__/spec-pipeline/transformWaspTsSpecFile/refHelper.unit.test.d.ts.map +1 -0
- package/data/packages/spec/dist/__tests__/spec-pipeline/transformWaspTsSpecFile/refHelper.unit.test.js +119 -0
- package/data/packages/{wasp-config → spec}/dist/src/appSpec.d.ts +11 -4
- package/data/packages/spec/dist/src/appSpec.d.ts.map +1 -0
- package/data/packages/{wasp-config → spec}/dist/src/cli.d.ts +3 -1
- package/data/packages/spec/dist/src/cli.d.ts.map +1 -0
- package/data/packages/spec/dist/src/cli.js +28 -0
- package/data/packages/spec/dist/src/index.d.ts +2 -0
- package/data/packages/spec/dist/src/index.d.ts.map +1 -0
- package/data/packages/spec/dist/src/index.js +1 -0
- package/data/packages/spec/dist/src/internal.d.ts +2 -0
- package/data/packages/spec/dist/src/internal.d.ts.map +1 -0
- package/data/packages/spec/dist/src/internal.js +1 -0
- package/data/packages/spec/dist/src/legacy/_private.d.ts.map +1 -0
- package/data/packages/{wasp-config/dist/src → spec/dist/src/legacy}/appAnalyzer.d.ts +1 -1
- package/data/packages/spec/dist/src/legacy/appAnalyzer.d.ts.map +1 -0
- package/data/packages/{wasp-config/dist/src → spec/dist/src/legacy}/mapTsAppSpecToAppSpecDecls.d.ts +1 -1
- package/data/packages/spec/dist/src/legacy/mapTsAppSpecToAppSpecDecls.d.ts.map +1 -0
- package/data/packages/{wasp-config/dist/src → spec/dist/src/legacy}/mapTsAppSpecToAppSpecDecls.js +3 -6
- package/data/packages/spec/dist/src/legacy/publicApi/App.d.ts.map +1 -0
- package/data/packages/{wasp-config/dist/src → spec/dist/src/legacy}/publicApi/tsAppSpec.d.ts +3 -3
- package/data/packages/spec/dist/src/legacy/publicApi/tsAppSpec.d.ts.map +1 -0
- package/data/packages/spec/dist/src/run.js +28 -0
- package/data/packages/spec/dist/src/spec/appAnalyzer.d.ts +8 -0
- package/data/packages/spec/dist/src/spec/appAnalyzer.d.ts.map +1 -0
- package/data/packages/spec/dist/src/spec/appAnalyzer.js +35 -0
- package/data/packages/spec/dist/src/spec/mapApp.d.ts +54 -0
- package/data/packages/spec/dist/src/spec/mapApp.d.ts.map +1 -0
- package/data/packages/spec/dist/src/spec/mapApp.js +336 -0
- package/data/packages/spec/dist/src/spec/publicApi/constructors.d.ts +296 -0
- package/data/packages/spec/dist/src/spec/publicApi/constructors.d.ts.map +1 -0
- package/data/packages/spec/dist/src/spec/publicApi/constructors.js +277 -0
- package/data/packages/spec/dist/src/spec/publicApi/index.d.ts +5 -0
- package/data/packages/spec/dist/src/spec/publicApi/index.d.ts.map +1 -0
- package/data/packages/spec/dist/src/spec/publicApi/index.js +2 -0
- package/data/packages/spec/dist/src/spec/publicApi/register.d.ts +9 -0
- package/data/packages/spec/dist/src/spec/publicApi/register.d.ts.map +1 -0
- package/data/packages/spec/dist/src/spec/publicApi/register.js +1 -0
- package/data/packages/spec/dist/src/spec/publicApi/waspSpec.d.ts +872 -0
- package/data/packages/spec/dist/src/spec/publicApi/waspSpec.d.ts.map +1 -0
- package/data/packages/spec/dist/src/spec/publicApi/waspSpec.js +1 -0
- package/data/packages/spec/dist/src/spec/refObject.d.ts +95 -0
- package/data/packages/spec/dist/src/spec/refObject.d.ts.map +1 -0
- package/data/packages/spec/dist/src/spec/refObject.js +119 -0
- package/data/packages/spec/dist/src/spec/refObjectPath.d.ts +18 -0
- package/data/packages/spec/dist/src/spec/refObjectPath.d.ts.map +1 -0
- package/data/packages/spec/dist/src/spec/refObjectPath.js +79 -0
- package/data/packages/spec/dist/src/spec/specUserError.d.ts +9 -0
- package/data/packages/spec/dist/src/spec/specUserError.d.ts.map +1 -0
- package/data/packages/spec/dist/src/spec/specUserError.js +8 -0
- package/data/packages/spec/dist/src/spec-pipeline/common.d.ts +2 -0
- package/data/packages/spec/dist/src/spec-pipeline/common.d.ts.map +1 -0
- package/data/packages/spec/dist/src/spec-pipeline/common.js +1 -0
- package/data/packages/spec/dist/src/spec-pipeline/loadWaspTsSpec.d.ts +5 -0
- package/data/packages/spec/dist/src/spec-pipeline/loadWaspTsSpec.d.ts.map +1 -0
- package/data/packages/spec/dist/src/spec-pipeline/loadWaspTsSpec.js +46 -0
- package/data/packages/spec/dist/src/spec-pipeline/transformWaspTsSpecFilesPlugin/imports/apply.d.ts +4 -0
- package/data/packages/spec/dist/src/spec-pipeline/transformWaspTsSpecFilesPlugin/imports/apply.d.ts.map +1 -0
- package/data/packages/spec/dist/src/spec-pipeline/transformWaspTsSpecFilesPlugin/imports/apply.js +34 -0
- package/data/packages/spec/dist/src/spec-pipeline/transformWaspTsSpecFilesPlugin/imports/check.d.ts +3 -0
- package/data/packages/spec/dist/src/spec-pipeline/transformWaspTsSpecFilesPlugin/imports/check.d.ts.map +1 -0
- package/data/packages/spec/dist/src/spec-pipeline/transformWaspTsSpecFilesPlugin/imports/check.js +14 -0
- package/data/packages/spec/dist/src/spec-pipeline/transformWaspTsSpecFilesPlugin/imports/index.d.ts +5 -0
- package/data/packages/spec/dist/src/spec-pipeline/transformWaspTsSpecFilesPlugin/imports/index.d.ts.map +1 -0
- package/data/packages/spec/dist/src/spec-pipeline/transformWaspTsSpecFilesPlugin/imports/index.js +40 -0
- package/data/packages/spec/dist/src/spec-pipeline/transformWaspTsSpecFilesPlugin/imports/plan.d.ts +26 -0
- package/data/packages/spec/dist/src/spec-pipeline/transformWaspTsSpecFilesPlugin/imports/plan.d.ts.map +1 -0
- package/data/packages/spec/dist/src/spec-pipeline/transformWaspTsSpecFilesPlugin/imports/plan.js +57 -0
- package/data/packages/spec/dist/src/spec-pipeline/transformWaspTsSpecFilesPlugin/index.d.ts +3 -0
- package/data/packages/spec/dist/src/spec-pipeline/transformWaspTsSpecFilesPlugin/index.d.ts.map +1 -0
- package/data/packages/spec/dist/src/spec-pipeline/transformWaspTsSpecFilesPlugin/index.js +8 -0
- package/data/packages/spec/dist/src/spec-pipeline/transformWaspTsSpecFilesPlugin/refHelper/apply.d.ts +4 -0
- package/data/packages/spec/dist/src/spec-pipeline/transformWaspTsSpecFilesPlugin/refHelper/apply.d.ts.map +1 -0
- package/data/packages/spec/dist/src/spec-pipeline/transformWaspTsSpecFilesPlugin/refHelper/apply.js +18 -0
- package/data/packages/spec/dist/src/spec-pipeline/transformWaspTsSpecFilesPlugin/refHelper/check.d.ts +3 -0
- package/data/packages/spec/dist/src/spec-pipeline/transformWaspTsSpecFilesPlugin/refHelper/check.d.ts.map +1 -0
- package/data/packages/spec/dist/src/spec-pipeline/transformWaspTsSpecFilesPlugin/refHelper/check.js +13 -0
- package/data/packages/spec/dist/src/spec-pipeline/transformWaspTsSpecFilesPlugin/refHelper/index.d.ts +5 -0
- package/data/packages/spec/dist/src/spec-pipeline/transformWaspTsSpecFilesPlugin/refHelper/index.d.ts.map +1 -0
- package/data/packages/spec/dist/src/spec-pipeline/transformWaspTsSpecFilesPlugin/refHelper/index.js +40 -0
- package/data/packages/spec/dist/src/spec-pipeline/transformWaspTsSpecFilesPlugin/refHelper/plan.d.ts +19 -0
- package/data/packages/spec/dist/src/spec-pipeline/transformWaspTsSpecFilesPlugin/refHelper/plan.d.ts.map +1 -0
- package/data/packages/spec/dist/src/spec-pipeline/transformWaspTsSpecFilesPlugin/refHelper/plan.js +60 -0
- package/data/packages/spec/dist/src/spec-pipeline/transformWaspTsSpecFilesPlugin/util.d.ts +10 -0
- package/data/packages/spec/dist/src/spec-pipeline/transformWaspTsSpecFilesPlugin/util.d.ts.map +1 -0
- package/data/packages/spec/dist/src/spec-pipeline/transformWaspTsSpecFilesPlugin/util.js +53 -0
- package/data/packages/spec/dist/src/spec-pipeline/typecheckPlugin/index.d.ts +5 -0
- package/data/packages/spec/dist/src/spec-pipeline/typecheckPlugin/index.d.ts.map +1 -0
- package/data/packages/spec/dist/src/spec-pipeline/typecheckPlugin/index.js +38 -0
- package/data/packages/spec/dist/src/spec-pipeline/typecheckPlugin/project.d.ts +9 -0
- package/data/packages/spec/dist/src/spec-pipeline/typecheckPlugin/project.d.ts.map +1 -0
- package/data/packages/spec/dist/src/spec-pipeline/typecheckPlugin/project.js +66 -0
- package/data/packages/spec/dist/src/typeUtils.d.ts +3 -0
- package/data/packages/spec/dist/src/typeUtils.d.ts.map +1 -0
- package/data/packages/spec/dist/src/typeUtils.js +1 -0
- package/data/packages/{wasp-config → spec}/package-lock.json +921 -1475
- package/data/packages/spec/package.json +48 -0
- package/data/packages/studio/package-lock.json +2 -2
- package/data/packages/studio/package.json +1 -1
- package/data/packages/ts-inspect/package-lock.json +2 -2
- package/data/packages/ts-inspect/package.json +1 -1
- package/package.json +1 -1
- package/wasp-bin +0 -0
- package/data/Cli/starters/basic/.prettierrc +0 -3
- package/data/Cli/starters/basic/main.wasp +0 -100
- package/data/Cli/starters/minimal/main.wasp +0 -14
- package/data/Cli/starters/ts-minimal/main.wasp.ts +0 -15
- package/data/Cli/starters/ts-minimal/package.json +0 -18
- package/data/Cli/starters/ts-minimal/schema.prisma +0 -10
- package/data/Cli/starters/ts-minimal/src/Main.css +0 -103
- package/data/Cli/starters/ts-minimal/src/MainPage.tsx +0 -37
- package/data/Cli/starters/ts-minimal/src/assets/logo.svg +0 -1
- package/data/Cli/starters/ts-minimal/tsconfig.json +0 -7
- package/data/Cli/starters/ts-minimal/vite.config.ts +0 -9
- package/data/packages/wasp-config/dist/__tests__/appAnalyzer.unit.test.d.ts.map +0 -1
- package/data/packages/wasp-config/dist/__tests__/cli.unit.test.js +0 -65
- package/data/packages/wasp-config/dist/__tests__/mapTsAppSpecToAppSpecDecls.integration.test.d.ts.map +0 -1
- package/data/packages/wasp-config/dist/__tests__/mapTsAppSpecToAppSpecDecls.unit.test.d.ts.map +0 -1
- package/data/packages/wasp-config/dist/__tests__/testFixtures.d.ts.map +0 -1
- package/data/packages/wasp-config/dist/__tests__/testFixtures.test-d.d.ts.map +0 -1
- package/data/packages/wasp-config/dist/src/_private.d.ts.map +0 -1
- package/data/packages/wasp-config/dist/src/appAnalyzer.d.ts.map +0 -1
- package/data/packages/wasp-config/dist/src/appSpec.d.ts.map +0 -1
- package/data/packages/wasp-config/dist/src/cli.d.ts.map +0 -1
- package/data/packages/wasp-config/dist/src/cli.js +0 -24
- package/data/packages/wasp-config/dist/src/index.d.ts +0 -8
- package/data/packages/wasp-config/dist/src/index.d.ts.map +0 -1
- package/data/packages/wasp-config/dist/src/index.js +0 -1
- package/data/packages/wasp-config/dist/src/mapTsAppSpecToAppSpecDecls.d.ts.map +0 -1
- package/data/packages/wasp-config/dist/src/publicApi/App.d.ts.map +0 -1
- package/data/packages/wasp-config/dist/src/publicApi/tsAppSpec.d.ts.map +0 -1
- package/data/packages/wasp-config/dist/src/run.js +0 -18
- package/data/packages/wasp-config/package.json +0 -40
- /package/data/packages/{wasp-config → spec}/dist/__tests__/cli.unit.test.d.ts +0 -0
- /package/data/packages/{wasp-config → spec}/dist/__tests__/cli.unit.test.d.ts.map +0 -0
- /package/data/packages/{wasp-config/dist/__tests__ → spec/dist/__tests__/legacy}/appAnalyzer.unit.test.d.ts +0 -0
- /package/data/packages/{wasp-config/dist/__tests__ → spec/dist/__tests__/legacy}/mapTsAppSpecToAppSpecDecls.integration.test.d.ts +0 -0
- /package/data/packages/{wasp-config/dist/__tests__ → spec/dist/__tests__/legacy}/mapTsAppSpecToAppSpecDecls.unit.test.d.ts +0 -0
- /package/data/packages/{wasp-config/dist/__tests__ → spec/dist/__tests__/legacy}/testFixtures.test-d.d.ts +0 -0
- /package/data/packages/{wasp-config/dist/__tests__ → spec/dist/__tests__/legacy}/testFixtures.test-d.js +0 -0
- /package/data/packages/{wasp-config → spec}/dist/src/appSpec.js +0 -0
- /package/data/packages/{wasp-config → spec}/dist/src/branded.d.ts +0 -0
- /package/data/packages/{wasp-config → spec}/dist/src/branded.d.ts.map +0 -0
- /package/data/packages/{wasp-config → spec}/dist/src/branded.js +0 -0
- /package/data/packages/{wasp-config/dist/src → spec/dist/src/legacy}/_private.d.ts +0 -0
- /package/data/packages/{wasp-config/dist/src → spec/dist/src/legacy}/_private.js +0 -0
- /package/data/packages/{wasp-config/dist/src → spec/dist/src/legacy}/appAnalyzer.js +0 -0
- /package/data/packages/{wasp-config/dist/src → spec/dist/src/legacy}/publicApi/App.d.ts +0 -0
- /package/data/packages/{wasp-config/dist/src → spec/dist/src/legacy}/publicApi/App.js +0 -0
- /package/data/packages/{wasp-config/dist/src → spec/dist/src/legacy}/publicApi/tsAppSpec.js +0 -0
- /package/data/packages/{wasp-config → spec}/dist/src/run.d.ts +0 -0
- /package/data/packages/{wasp-config → spec}/dist/src/run.d.ts.map +0 -0
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { app, page, route } from "@wasp.sh/spec";
|
|
2
|
+
import { App } from "./src/App" with { type: "ref" };
|
|
3
|
+
import { EmailVerificationPage } from "./src/auth/email/EmailVerificationPage" with { type: "ref" };
|
|
4
|
+
import { LoginPage } from "./src/auth/email/LoginPage" with { type: "ref" };
|
|
5
|
+
import { PasswordResetPage } from "./src/auth/email/PasswordResetPage" with { type: "ref" };
|
|
6
|
+
import { RequestPasswordResetPage } from "./src/auth/email/RequestPasswordResetPage" with { type: "ref" };
|
|
7
|
+
import { SignupPage } from "./src/auth/email/SignupPage" with { type: "ref" };
|
|
8
|
+
import { userSignupFields } from "./src/auth/email/userSignupFields" with { type: "ref" };
|
|
9
|
+
import { tagsSpec } from "./src/tags/tags.wasp";
|
|
10
|
+
import { tasksSpec } from "./src/tasks/task.wasp";
|
|
11
|
+
|
|
12
|
+
export default app({
|
|
13
|
+
name: "__waspAppName__",
|
|
14
|
+
title: "__waspProjectName__",
|
|
15
|
+
wasp: { version: "__waspVersion__" },
|
|
16
|
+
head: ["<link rel='icon' href='/favicon.ico' />"],
|
|
17
|
+
auth: {
|
|
18
|
+
userEntity: "User",
|
|
19
|
+
methods: {
|
|
20
|
+
email: {
|
|
21
|
+
fromField: {
|
|
22
|
+
name: "Basic App",
|
|
23
|
+
email: "hello@example.com",
|
|
24
|
+
},
|
|
25
|
+
userSignupFields,
|
|
26
|
+
emailVerification: {
|
|
27
|
+
clientRoute: "EmailVerificationRoute",
|
|
28
|
+
},
|
|
29
|
+
passwordReset: {
|
|
30
|
+
clientRoute: "PasswordResetRoute",
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
onAuthSucceededRedirectTo: "/",
|
|
35
|
+
onAuthFailedRedirectTo: "/login",
|
|
36
|
+
},
|
|
37
|
+
emailSender: {
|
|
38
|
+
provider: "Dummy",
|
|
39
|
+
},
|
|
40
|
+
client: {
|
|
41
|
+
rootComponent: App,
|
|
42
|
+
},
|
|
43
|
+
spec: [
|
|
44
|
+
tasksSpec,
|
|
45
|
+
tagsSpec,
|
|
46
|
+
route("LoginRoute", "/login", page(LoginPage)),
|
|
47
|
+
route("SignupRoute", "/signup", page(SignupPage)),
|
|
48
|
+
route(
|
|
49
|
+
"RequestPasswordResetRoute",
|
|
50
|
+
"/request-password-reset",
|
|
51
|
+
page(RequestPasswordResetPage),
|
|
52
|
+
),
|
|
53
|
+
route("PasswordResetRoute", "/password-reset", page(PasswordResetPage)),
|
|
54
|
+
route(
|
|
55
|
+
"EmailVerificationRoute",
|
|
56
|
+
"/email-verification",
|
|
57
|
+
page(EmailVerificationPage),
|
|
58
|
+
),
|
|
59
|
+
],
|
|
60
|
+
});
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
},
|
|
16
16
|
"devDependencies": {
|
|
17
17
|
"@eslint/js": "^9.27.0",
|
|
18
|
+
"@types/node": "^24.0.0",
|
|
18
19
|
"@types/react": "^19.2.7",
|
|
19
20
|
"@types/react-dom": "^19.2.3",
|
|
20
21
|
"@tailwindcss/vite": "^4.1.18",
|
|
@@ -27,6 +28,8 @@
|
|
|
27
28
|
"prisma": "5.19.1",
|
|
28
29
|
"typescript": "5.9.3",
|
|
29
30
|
"typescript-eslint": "^8.32.1",
|
|
30
|
-
"vite": "^7.0.6"
|
|
31
|
+
"vite": "^7.0.6",
|
|
32
|
+
"vitest": "^4.0.16",
|
|
33
|
+
"@wasp.sh/spec": "__waspSpecPackageSpecifier__"
|
|
31
34
|
}
|
|
32
35
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type Spec, action, query } from "@wasp.sh/spec";
|
|
2
|
+
import { createTag } from "./actions" with { type: "ref" };
|
|
3
|
+
import { getTags } from "./queries" with { type: "ref" };
|
|
4
|
+
|
|
5
|
+
export const tagsSpec: Spec = [
|
|
6
|
+
query(getTags, { entities: ["Tag"] }),
|
|
7
|
+
action(createTag, { entities: ["Tag"] }),
|
|
8
|
+
];
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type Spec, action, page, query, route } from "@wasp.sh/spec";
|
|
2
|
+
import {
|
|
3
|
+
createTask,
|
|
4
|
+
deleteCompletedTasks,
|
|
5
|
+
updateTaskStatus,
|
|
6
|
+
} from "./actions" with { type: "ref" };
|
|
7
|
+
import { getTasks } from "./queries" with { type: "ref" };
|
|
8
|
+
import { TasksPage } from "./TasksPage" with { type: "ref" };
|
|
9
|
+
|
|
10
|
+
export const tasksSpec: Spec = [
|
|
11
|
+
route("TasksRoute", "/", page(TasksPage, { authRequired: true })),
|
|
12
|
+
query(getTasks, { entities: ["Task", "Tag"] }),
|
|
13
|
+
action(createTask, { entities: ["Task"] }),
|
|
14
|
+
action(updateTaskStatus, { entities: ["Task"] }),
|
|
15
|
+
action(deleteCompletedTasks, { entities: ["Task"] }),
|
|
16
|
+
];
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { app, page, route } from "@wasp.sh/spec";
|
|
2
|
+
import { MainPage } from "./src/MainPage" with { type: "ref" };
|
|
3
|
+
|
|
4
|
+
export default app({
|
|
5
|
+
name: "__waspAppName__",
|
|
6
|
+
title: "__waspProjectName__",
|
|
7
|
+
wasp: { version: "__waspVersion__" },
|
|
8
|
+
head: ["<link rel='icon' href='/favicon.ico' />"],
|
|
9
|
+
spec: [
|
|
10
|
+
route("RootRoute", "/", page(MainPage)),
|
|
11
|
+
],
|
|
12
|
+
});
|
|
@@ -8,10 +8,13 @@
|
|
|
8
8
|
"react-router": "^7.12.0"
|
|
9
9
|
},
|
|
10
10
|
"devDependencies": {
|
|
11
|
+
"@types/node": "^24.0.0",
|
|
11
12
|
"@types/react": "^19.2.7",
|
|
12
13
|
"@types/react-dom": "^19.2.3",
|
|
13
14
|
"prisma": "5.19.1",
|
|
14
15
|
"typescript": "5.9.3",
|
|
15
|
-
"vite": "^7.0.6"
|
|
16
|
+
"vite": "^7.0.6",
|
|
17
|
+
"vitest": "^4.0.16",
|
|
18
|
+
"@wasp.sh/spec": "__waspSpecPackageSpecifier__"
|
|
16
19
|
}
|
|
17
20
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
## Wasp
|
|
2
|
+
|
|
3
|
+
This project uses the Wasp framework.
|
|
4
|
+
|
|
5
|
+
### Docs
|
|
6
|
+
|
|
7
|
+
- Find docs via the index at https://wasp.sh/llms.txt
|
|
8
|
+
- Pick the docs map matching the Wasp version in `main.wasp.ts`.
|
|
9
|
+
- Prefer raw Markdown URLs from the docs map over guessing `wasp.sh/docs` URLs.
|
|
10
|
+
- If this file conflicts with versioned Wasp docs, trust the docs and tell the user this file may be stale.
|
|
11
|
+
|
|
12
|
+
### Wasp TypeScript Spec
|
|
13
|
+
|
|
14
|
+
- `main.wasp.ts` contains the Wasp version and the Wasp app specification.
|
|
15
|
+
- When it references app components/functions, import them from `src/` with `with { type: "ref" }`.
|
|
16
|
+
- `route(name, ...)` and `crud(name, ...)` take an explicit name.
|
|
17
|
+
- Other constructors take no name argument; the declaration's name is the imported identifier. For example, `job(sendReminder, { ... })` declares a job named `sendReminder`.
|
|
18
|
+
- `@wasp.sh/spec` is generated by Wasp, don't install it from npm.
|
|
19
|
+
|
|
20
|
+
### Verification
|
|
21
|
+
|
|
22
|
+
- Run `wasp compile` to check if app is valid.
|
|
23
|
+
- Do not run `tsc` directly for validation.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
## Wasp
|
|
2
|
+
|
|
3
|
+
This project uses the Wasp framework.
|
|
4
|
+
|
|
5
|
+
### Docs
|
|
6
|
+
|
|
7
|
+
- Find docs via the index at https://wasp.sh/llms.txt
|
|
8
|
+
- Pick the docs map matching the Wasp version in `main.wasp.ts`.
|
|
9
|
+
- Prefer raw Markdown URLs from the docs map over guessing `wasp.sh/docs` URLs.
|
|
10
|
+
- If this file conflicts with versioned Wasp docs, trust the docs and tell the user this file may be stale.
|
|
11
|
+
|
|
12
|
+
### Wasp TypeScript Spec
|
|
13
|
+
|
|
14
|
+
- `main.wasp.ts` contains the Wasp version and the Wasp app specification.
|
|
15
|
+
- When it references app components/functions, import them from `src/` with `with { type: "ref" }`.
|
|
16
|
+
- `route(name, ...)` and `crud(name, ...)` take an explicit name.
|
|
17
|
+
- Other constructors take no name argument; the declaration's name is the imported identifier. For example, `job(sendReminder, { ... })` declares a job named `sendReminder`.
|
|
18
|
+
- `@wasp.sh/spec` is generated by Wasp, don't install it from npm.
|
|
19
|
+
|
|
20
|
+
### Verification
|
|
21
|
+
|
|
22
|
+
- Run `wasp compile` to check if app is valid.
|
|
23
|
+
- Do not run `tsc` directly for validation.
|
|
@@ -1,28 +1,7 @@
|
|
|
1
|
-
// =============================== IMPORTANT =================================
|
|
2
|
-
// This file is mainly used for Wasp IDE support.
|
|
3
|
-
//
|
|
4
|
-
// Wasp will compile your code with slightly different (less strict) compilerOptions.
|
|
5
|
-
// You can increase the configuration's strictness (e.g., by adding
|
|
6
|
-
// "noUncheckedIndexedAccess": true), but you shouldn't reduce it (e.g., by
|
|
7
|
-
// adding "strict": false). Just keep in mind that this will only affect your
|
|
8
|
-
// IDE support, not the actual compilation.
|
|
9
|
-
//
|
|
10
|
-
// Full TypeScript configurability is coming very soon :)
|
|
11
1
|
{
|
|
12
|
-
"
|
|
13
|
-
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
|
|
17
|
-
"jsx": "preserve",
|
|
18
|
-
"strict": true,
|
|
19
|
-
"esModuleInterop": true,
|
|
20
|
-
"isolatedModules": true,
|
|
21
|
-
"moduleDetection": "force",
|
|
22
|
-
"lib": ["dom", "dom.iterable", "esnext"],
|
|
23
|
-
"skipLibCheck": true,
|
|
24
|
-
"allowJs": true,
|
|
25
|
-
"outDir": ".wasp/out/user"
|
|
26
|
-
},
|
|
27
|
-
"include": ["src"]
|
|
2
|
+
"files": [],
|
|
3
|
+
"references": [
|
|
4
|
+
{ "path": "./tsconfig.src.json" },
|
|
5
|
+
{ "path": "./tsconfig.wasp.json" }
|
|
6
|
+
]
|
|
28
7
|
}
|
|
@@ -7,9 +7,12 @@
|
|
|
7
7
|
"strict": true,
|
|
8
8
|
"noUnusedLocals": true,
|
|
9
9
|
"noUnusedParameters": true,
|
|
10
|
-
"module": "
|
|
10
|
+
"module": "esnext",
|
|
11
|
+
"moduleResolution": "bundler",
|
|
12
|
+
"jsx": "preserve",
|
|
13
|
+
"allowJs": true,
|
|
11
14
|
"noEmit": true,
|
|
12
15
|
"lib": ["ES2023"]
|
|
13
16
|
},
|
|
14
|
-
"include": ["
|
|
17
|
+
"include": ["**/*.wasp.ts", ".wasp/out/types/spec"]
|
|
15
18
|
}
|
package/data/Generator/libs/auth/{wasp.sh-lib-auth-0.23.0.tgz → wasp.sh-lib-auth-0.24.0.tgz}
RENAMED
|
Binary file
|
|
Binary file
|
|
@@ -1,14 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import ky, { isHTTPError } from 'ky'
|
|
3
2
|
import { config } from 'wasp/client'
|
|
4
3
|
import { storage } from 'wasp/core/storage'
|
|
5
4
|
import { apiEventsEmitter } from './events.js'
|
|
6
5
|
|
|
7
|
-
// PUBLIC API
|
|
8
|
-
export const api: AxiosInstance = axios.create({
|
|
9
|
-
baseURL: config.apiUrl,
|
|
10
|
-
})
|
|
11
|
-
|
|
12
6
|
const WASP_APP_AUTH_SESSION_ID_NAME = 'sessionId'
|
|
13
7
|
|
|
14
8
|
// PRIVATE API (sdk)
|
|
@@ -36,43 +30,53 @@ export function removeLocalUserData(): void {
|
|
|
36
30
|
apiEventsEmitter.emit('sessionId.clear')
|
|
37
31
|
}
|
|
38
32
|
|
|
33
|
+
// PUBLIC API
|
|
39
34
|
/**
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
* (1) Request Interceptor:
|
|
43
|
-
* If a session ID exists, it is added to the request as an `Authorization`
|
|
44
|
-
* header for the server to use.
|
|
35
|
+
* A ky instance configured for the Wasp API server.
|
|
45
36
|
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
* - It only clears the local session ID if the two session IDs match.
|
|
52
|
-
*
|
|
53
|
-
* This prevents a race condition like this:
|
|
54
|
-
* 1. Request A is sent with old session ID X.
|
|
55
|
-
* 2. User logs out and logs back in, obtaining new session ID Y.
|
|
56
|
-
* 3. Request A finally fails with a 401 (because ID X is invalid).
|
|
57
|
-
* Without the check, the interceptor would clear the *current* valid session ID Y.
|
|
58
|
-
* The check ensures we only clear the session if the *request that failed* used
|
|
59
|
-
* the *same session ID that's currently stored*.
|
|
37
|
+
* Automatically prepends the API base URL, adds authentication headers,
|
|
38
|
+
* and handles session invalidation on 401 responses. Non-2xx responses
|
|
39
|
+
* cause ky to throw an `HTTPError`; pass it through `handleApiError` to
|
|
40
|
+
* get a `WaspHttpError` carrying the server's status code, message, and
|
|
41
|
+
* response body.
|
|
60
42
|
*/
|
|
61
|
-
api.
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
43
|
+
export const api = ky.extend({
|
|
44
|
+
prefix: config.apiUrl,
|
|
45
|
+
hooks: {
|
|
46
|
+
beforeRequest: [
|
|
47
|
+
({ request }) => {
|
|
48
|
+
const sessionId = getSessionId()
|
|
49
|
+
if (sessionId !== null) {
|
|
50
|
+
request.headers.set('Authorization', `Bearer ${sessionId}`)
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
afterResponse: [
|
|
55
|
+
({ request, response }) => {
|
|
56
|
+
if (response.status === 401) {
|
|
57
|
+
// Before clearing the session ID from local storage due to a 401 error,
|
|
58
|
+
// compare the session ID stored in the *failed request's* headers
|
|
59
|
+
// with the *current* session ID in local storage.
|
|
60
|
+
// Only clear the local session ID if the two session IDs match.
|
|
61
|
+
//
|
|
62
|
+
// This prevents a race condition like this:
|
|
63
|
+
// 1. Request A is sent with old session ID X.
|
|
64
|
+
// 2. User logs out and logs back in, obtaining new session ID Y.
|
|
65
|
+
// 3. Request A finally fails with a 401 (because ID X is invalid).
|
|
66
|
+
// Without the check, we would clear the *current* valid session ID Y.
|
|
67
|
+
// The check ensures we only clear the session if the *request that failed*
|
|
68
|
+
// used the *same session ID that's currently stored*.
|
|
69
|
+
const failingSessionId = getSessionIdFromAuthorizationHeader(
|
|
70
|
+
request.headers.get('Authorization')
|
|
71
|
+
)
|
|
72
|
+
const currentSessionId = getSessionId()
|
|
73
|
+
if (failingSessionId === currentSessionId) {
|
|
74
|
+
clearSessionId()
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
],
|
|
79
|
+
},
|
|
76
80
|
})
|
|
77
81
|
|
|
78
82
|
// This makes sure that the following handler won't try to run in a non-browser
|
|
@@ -96,12 +100,12 @@ if (typeof window !== 'undefined') {
|
|
|
96
100
|
|
|
97
101
|
// PRIVATE API (sdk)
|
|
98
102
|
/**
|
|
99
|
-
* Takes an error returned by the app's API (as
|
|
103
|
+
* Takes an error returned by the app's API (as thrown by ky), and transforms it into a more
|
|
100
104
|
* standard format to be further used by the client. It is also assumed that given API
|
|
101
105
|
* error has been formatted as implemented by HttpError on the server.
|
|
102
106
|
*/
|
|
103
|
-
export function handleApiError
|
|
104
|
-
if (error
|
|
107
|
+
export function handleApiError(error: unknown): unknown {
|
|
108
|
+
if (isHTTPError(error)) {
|
|
105
109
|
// If error came from HTTP response, we capture most informative message
|
|
106
110
|
// and also add .statusCode information to it.
|
|
107
111
|
// If error had JSON response, we assume it is of format { message, data } and
|
|
@@ -109,7 +113,7 @@ export function handleApiError<T extends AxiosError<{ message?: string, data?: u
|
|
|
109
113
|
// TODO: We might want to use HttpError here instead of just Error, since
|
|
110
114
|
// HttpError is also used on server to throw errors like these.
|
|
111
115
|
// That would require copying HttpError code to web-app also and using it here.
|
|
112
|
-
const responseJson = error.
|
|
116
|
+
const responseJson = error.data as { message?: string; data?: unknown } | undefined
|
|
113
117
|
const responseStatusCode = error.response.status
|
|
114
118
|
return new WaspHttpError(responseStatusCode, responseJson?.message ?? error.message, responseJson)
|
|
115
119
|
} else {
|
|
@@ -123,14 +127,14 @@ class WaspHttpError extends Error {
|
|
|
123
127
|
|
|
124
128
|
data: unknown
|
|
125
129
|
|
|
126
|
-
constructor
|
|
130
|
+
constructor(statusCode: number, message: string, data: unknown) {
|
|
127
131
|
super(message)
|
|
128
132
|
this.statusCode = statusCode
|
|
129
133
|
this.data = data
|
|
130
134
|
}
|
|
131
135
|
}
|
|
132
136
|
|
|
133
|
-
function getSessionIdFromAuthorizationHeader(header: string |
|
|
137
|
+
function getSessionIdFromAuthorizationHeader(header: string | null): string | null {
|
|
134
138
|
const prefix = 'Bearer '
|
|
135
139
|
if (header && header.startsWith(prefix)) {
|
|
136
140
|
return header.substring(prefix.length)
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
{{={= =}=}}
|
|
2
2
|
import { api, handleApiError } from 'wasp/client/api';
|
|
3
3
|
import { initSession } from '../../helpers/user';
|
|
4
|
+
import { SessionResponseSchema } from '../../responseSchemas';
|
|
4
5
|
|
|
5
6
|
// PUBLIC API
|
|
6
7
|
export async function login(data: { email: string; password: string }): Promise<void> {
|
|
7
8
|
try {
|
|
8
|
-
const
|
|
9
|
-
|
|
9
|
+
const { sessionId } = await api.post('{= loginPath =}', {
|
|
10
|
+
json: data,
|
|
11
|
+
}).json(SessionResponseSchema);
|
|
12
|
+
await initSession(sessionId);
|
|
10
13
|
} catch (e) {
|
|
11
14
|
throw handleApiError(e);
|
|
12
15
|
}
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
{{={= =}=}}
|
|
2
2
|
import { api, handleApiError } from 'wasp/client/api';
|
|
3
|
+
import { SuccessResponseSchema } from '../../responseSchemas';
|
|
3
4
|
|
|
4
5
|
// PUBLIC API
|
|
5
6
|
export async function requestPasswordReset(data: { email: string; }): Promise<{ success: boolean }> {
|
|
6
7
|
try {
|
|
7
|
-
const
|
|
8
|
-
|
|
8
|
+
const { success } = await api.post('{= requestPasswordResetPath =}', {
|
|
9
|
+
json: data,
|
|
10
|
+
}).json(SuccessResponseSchema);
|
|
11
|
+
return { success };
|
|
9
12
|
} catch (e) {
|
|
10
13
|
throw handleApiError(e);
|
|
11
14
|
}
|
|
@@ -14,8 +17,10 @@ export async function requestPasswordReset(data: { email: string; }): Promise<{
|
|
|
14
17
|
// PUBLIC API
|
|
15
18
|
export async function resetPassword(data: { token: string; password: string; }): Promise<{ success: boolean }> {
|
|
16
19
|
try {
|
|
17
|
-
const
|
|
18
|
-
|
|
20
|
+
const { success } = await api.post('{= resetPasswordPath =}', {
|
|
21
|
+
json: data,
|
|
22
|
+
}).json(SuccessResponseSchema);
|
|
23
|
+
return { success };
|
|
19
24
|
} catch (e) {
|
|
20
25
|
throw handleApiError(e);
|
|
21
26
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
{{={= =}=}}
|
|
2
2
|
import { api, handleApiError } from 'wasp/client/api';
|
|
3
|
+
import { SuccessResponseSchema } from '../../responseSchemas';
|
|
3
4
|
{=# emailUserSignupFields.isDefined =}
|
|
4
5
|
import { type UserEmailSignupFields } from '../../providers'
|
|
5
6
|
{=/ emailUserSignupFields.isDefined =}
|
|
@@ -12,8 +13,10 @@ type EmailSignupData = {
|
|
|
12
13
|
// PUBLIC API
|
|
13
14
|
export async function signup(data: EmailSignupData): Promise<{ success: boolean }> {
|
|
14
15
|
try {
|
|
15
|
-
const
|
|
16
|
-
|
|
16
|
+
const { success } = await api.post('{= signupPath =}', {
|
|
17
|
+
json: data,
|
|
18
|
+
}).json(SuccessResponseSchema);
|
|
19
|
+
return { success };
|
|
17
20
|
} catch (e) {
|
|
18
21
|
throw handleApiError(e);
|
|
19
22
|
}
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
{{={= =}=}}
|
|
2
2
|
import { api, handleApiError } from 'wasp/client/api'
|
|
3
|
+
import { SuccessResponseSchema } from '../../responseSchemas'
|
|
3
4
|
|
|
4
5
|
// PUBLIC API
|
|
5
6
|
export async function verifyEmail(data: {
|
|
6
7
|
token: string
|
|
7
8
|
}): Promise<{ success: boolean; reason?: string }> {
|
|
8
9
|
try {
|
|
9
|
-
const
|
|
10
|
-
|
|
10
|
+
const { success, reason } = await api.post('{= verifyEmailPath =}', {
|
|
11
|
+
json: data,
|
|
12
|
+
}).json(SuccessResponseSchema)
|
|
13
|
+
return { success, reason }
|
|
11
14
|
} catch (e) {
|
|
12
15
|
throw handleApiError(e)
|
|
13
16
|
}
|
|
@@ -21,8 +21,8 @@ function createUserGetter(): Query<void, AuthUser | null> {
|
|
|
21
21
|
const getMeRoute = { method: HttpMethod.Get, path: `/${getMeRelativePath}` }
|
|
22
22
|
const getMe: QueryFunction<void, AuthUser | null> = async () => {
|
|
23
23
|
try {
|
|
24
|
-
const
|
|
25
|
-
const userData = deserialize<AuthUserData | null>(
|
|
24
|
+
const json = await api.get(getMeRoute.path).json()
|
|
25
|
+
const userData = deserialize<AuthUserData | null>(json as any)
|
|
26
26
|
return makeAuthUserIfPossible(userData)
|
|
27
27
|
} catch (error) {
|
|
28
28
|
throw handleApiError(error)
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
{{={= =}=}}
|
|
2
2
|
import { api, handleApiError } from 'wasp/client/api'
|
|
3
3
|
import { initSession } from '../../helpers/user'
|
|
4
|
+
import { SessionResponseSchema } from '../../responseSchemas'
|
|
4
5
|
|
|
5
6
|
export async function login(data: { username: string, password: string }): Promise<void> {
|
|
6
7
|
try {
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
const { sessionId } = await api.post('{= loginPath =}', {
|
|
9
|
+
json: data,
|
|
10
|
+
}).json(SessionResponseSchema)
|
|
11
|
+
await initSession(sessionId)
|
|
10
12
|
} catch (error) {
|
|
11
13
|
throw handleApiError(error)
|
|
12
14
|
}
|
|
@@ -12,9 +12,10 @@ type UsernameSignupData = {
|
|
|
12
12
|
// PUBLIC API
|
|
13
13
|
export async function signup(data: UsernameSignupData): Promise<void> {
|
|
14
14
|
try {
|
|
15
|
-
await api.post('{= signupPath =}',
|
|
15
|
+
await api.post('{= signupPath =}', {
|
|
16
|
+
json: data,
|
|
17
|
+
})
|
|
16
18
|
} catch (error) {
|
|
17
19
|
throw handleApiError(error)
|
|
18
20
|
}
|
|
19
21
|
}
|
|
20
|
-
|
|
@@ -50,18 +50,6 @@ export function Layout({
|
|
|
50
50
|
{=& head =}
|
|
51
51
|
|
|
52
52
|
<title>{= title =}</title>
|
|
53
|
-
</head>
|
|
54
|
-
<body>
|
|
55
|
-
<noscript>You need to enable JavaScript to run this app.</noscript>
|
|
56
|
-
|
|
57
|
-
{
|
|
58
|
-
// We don't really need to wrap the app in a div nor name it "root",
|
|
59
|
-
// but we keep it for backwards compatibility with older Wasp
|
|
60
|
-
// versions.
|
|
61
|
-
}
|
|
62
|
-
<div id="root">
|
|
63
|
-
{shouldRenderChildren ? children : null}
|
|
64
|
-
</div>
|
|
65
53
|
|
|
66
54
|
{
|
|
67
55
|
// We pass that argument in SSR builds and not in client builds.
|
|
@@ -75,16 +63,21 @@ export function Layout({
|
|
|
75
63
|
// we just add the script ourselves in the regular way.
|
|
76
64
|
//
|
|
77
65
|
// https://react.dev/reference/react-dom/static/prerenderToNodeStream
|
|
78
|
-
<script
|
|
79
|
-
type="module"
|
|
80
|
-
src={clientEntrySrc}
|
|
81
|
-
// We make it `async` to decouple the tag's position from its
|
|
82
|
-
// execution phase. This way Vite can move it anywhere in the
|
|
83
|
-
// document to optimize loading performance.
|
|
84
|
-
async
|
|
85
|
-
/>
|
|
66
|
+
<script type="module" src={clientEntrySrc} />
|
|
86
67
|
) : null
|
|
87
68
|
}
|
|
69
|
+
</head>
|
|
70
|
+
<body>
|
|
71
|
+
<noscript>You need to enable JavaScript to run this app.</noscript>
|
|
72
|
+
|
|
73
|
+
{
|
|
74
|
+
// We don't really need to wrap the app in a div nor name it "root",
|
|
75
|
+
// but we keep it for backwards compatibility with older Wasp
|
|
76
|
+
// versions.
|
|
77
|
+
}
|
|
78
|
+
<div id="root">
|
|
79
|
+
{shouldRenderChildren ? children : null}
|
|
80
|
+
</div>
|
|
88
81
|
</body>
|
|
89
82
|
</html>
|
|
90
83
|
</StrictMode>
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
{{={= =}=}}
|
|
2
2
|
import { useState } from "react";
|
|
3
|
-
import { type AxiosResponse } from "axios";
|
|
4
3
|
import { Navigate, useLocation } from 'react-router'
|
|
5
4
|
import { useAuth } from "../../auth";
|
|
6
5
|
import { api } from "../../../api";
|
|
@@ -54,12 +53,12 @@ function useOAuthCallbackHandler() {
|
|
|
54
53
|
}
|
|
55
54
|
|
|
56
55
|
const code = location.hash.slice(1);
|
|
57
|
-
const
|
|
58
|
-
if (!
|
|
56
|
+
const data = await exchangeOAuthCodeForToken({ code });
|
|
57
|
+
if (!isDataWithSessionId(data)) {
|
|
59
58
|
setError("Unable to login with the OAuth provider.");
|
|
60
59
|
return;
|
|
61
60
|
}
|
|
62
|
-
await initSession(
|
|
61
|
+
await initSession(data.sessionId);
|
|
63
62
|
} catch (e: unknown) {
|
|
64
63
|
console.error(e);
|
|
65
64
|
setError("Unable to login with the OAuth provider.");
|
|
@@ -82,13 +81,15 @@ function useOAuthCallbackHandler() {
|
|
|
82
81
|
|
|
83
82
|
async function exchangeOAuthCodeForToken(data: {
|
|
84
83
|
code: string
|
|
85
|
-
}): Promise<
|
|
86
|
-
return api.post('/auth/exchange-code',
|
|
84
|
+
}): Promise<unknown> {
|
|
85
|
+
return api.post('/auth/exchange-code', {
|
|
86
|
+
json: data,
|
|
87
|
+
}).json()
|
|
87
88
|
}
|
|
88
89
|
|
|
89
|
-
function
|
|
90
|
-
|
|
91
|
-
):
|
|
92
|
-
const
|
|
93
|
-
return !!
|
|
90
|
+
function isDataWithSessionId(
|
|
91
|
+
data: unknown
|
|
92
|
+
): data is { sessionId: string } {
|
|
93
|
+
const obj = data as any;
|
|
94
|
+
return !!obj && typeof obj.sessionId === 'string'
|
|
94
95
|
}
|