SIWE is a standardized approach for implementing authentication using an Ethereum crypto wallet.
This PoC is demonstrating the following functionality:
- user sign-up
- user sign-in (protected using nonce against replay attacks)
- JWT authenticated API endpoint for querying the user profile
This repository is a PoC demonstrating capabilities on a simplified React frontend and core functionality being the backend written in Nestjs. The backend is implemented using a functional coding style utilising the fp-ts package.
The repository is dockerized and uses a monorepo structure using the Nx tool.
From the root of the project, run the following commands:
cp .env.example .env
cp ./apps/api/.env.example ./apps/api/.env
docker compose up --build
Then navigate to http://localhost:4200
Serving of the project is done via Docker.
- Create
.envin the root of the project directory (feel free to just copy-paste the contents of the.env.example) - Create
./apps/api/.env(feel free to copy the contents of./apps/api/.env.examplefor development purposes only)- It's separated, so these are available only in the API container for security purposes (e.g., JWT secret).
- Run
docker compose up --build - Navigate to http://localhost:4200 in your browser
Developed on macOS Intel, so I can confirm only that one.
- MacOS (Intel) ✅
- MacOS (Apple Silicon) ❓
- Linux ❓
- Windows ❓
To run all the tests:
npm run test
To run lint for the whole project:
npm run lint
To format the whole project:
npm run format
When dependencies change, run the following:
docker compose down -vdocker compose up --build
To modify the package-lock.json so that the dependency works in containers run the following npm install sqlite3@5.0.0.
It may break after addition of other packages so feel free to npm install it again when you notice the error.
- Docker-Nx setup inspired by - https://www.codefeetime.com/post/using-docker-compose-with-nx-monorepo-for-multi-apps-development
- Important rules for
fp-tsTaskusage to improve code quality - https://dev.to/anthonyjoeseph/should-i-use-fp-ts-task-h52