Skip to content

Commit 87bd51b

Browse files
Chore: Merge branch dev.
Chore: Merge branch dev.
2 parents dadd335 + 777e650 commit 87bd51b

File tree

17 files changed

+585
-94
lines changed

17 files changed

+585
-94
lines changed

README.md

Lines changed: 74 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<h1 align="center" id="header">
2-
React Native CRUD
2+
React Native Basic Auth
33
</h1>
44
<p align="center">
55
<img src="https://img.shields.io/badge/React_Native-20232A?style=for-the-badge&logo=react&logoColor=61DAFB" alt="React Native">
@@ -13,9 +13,11 @@
1313
<img src="https://img.shields.io/badge/Bun-000000?style=for-the-badge&logo=bun&logoColor=white" alt="Bun">
1414
</p>
1515
<p align="center">
16-
A full-featured CRUD application built with React Native, Expo Router, NativeWind, Drizzle ORM, and SQLite. Create, read, update, and delete records with a clean, production-ready mobile interface.
16+
A <strong>starter boilerplate</strong> for authentication in React Native, built with Expo Router, NativeWind, Drizzle ORM, and SQLite. Includes sign up, sign in, sign out, forgot password, and reset password flows — designed as a solid foundation to build on, not a production-ready solution out of the box.
1717
</p>
1818

19+
> ⚠️ **This is a starting point.** Before shipping to production, review the [Security Considerations](#security-considerations) section below. Several intentional simplifications were made to keep this boilerplate approachable.
20+
1921
---
2022

2123
<h2 id="stack">
@@ -30,15 +32,75 @@
3032

3133
---
3234

35+
<h2 id="security-considerations">
36+
Security Considerations
37+
</h2>
38+
39+
This project is intentionally simplified. Before using it as a base for a real-world app, you should address the following:
40+
41+
### Password Hashing
42+
43+
Currently, passwords are hashed using `Crypto.CryptoDigestAlgorithm.SHA256` via `expo-crypto`. **SHA-256 is not suitable for password hashing in production** — it is fast by design, which makes brute-force attacks trivial.
44+
45+
> The `argon2` npm package is **not compatible with React Native** as it relies on Node.js native bindings (C++). Use one of the alternatives below instead.
46+
47+
**Option 1 — `react-native-argon2`** (recommended, requires `expo prebuild` — exits Expo Go):
48+
49+
```bash
50+
bun add react-native-argon2
51+
bun run prebuild
52+
```
53+
54+
```ts
55+
import Argon2 from "react-native-argon2";
56+
57+
async function hashPassword(password: string, salt: string): Promise<string> {
58+
const { rawHash } = await Argon2.hash(password, salt, { mode: "argon2id" });
59+
return rawHash;
60+
}
61+
```
62+
63+
**Option 2 — `expo-crypto` with SHA-512 + salt** (no eject required, stays in Expo Go):
64+
65+
```ts
66+
import * as Crypto from "expo-crypto";
67+
68+
async function hashPassword(password: string, salt: string): Promise<string> {
69+
return Crypto.digestStringAsync(
70+
Crypto.CryptoDigestAlgorithm.SHA512,
71+
salt + password,
72+
);
73+
}
74+
```
75+
76+
> SHA-512 is still not ideal for password hashing, but significantly better than SHA-256 when combined with a unique per-user salt stored alongside the hash.
77+
78+
**Option 3 — Backend authentication** (most secure for production):
79+
Move auth entirely to a server (Node.js, Go, etc.) where Argon2id runs natively, and have the app communicate via HTTPS. Services like [Supabase](https://supabase.com) or [Firebase Auth](https://firebase.google.com/products/auth) handle this out of the box.
80+
81+
> Argon2id is the current recommendation from [OWASP](https://cheatsheetseries.owasp.org/cheatsheets/Password_Storage_Cheat_Sheet.html) and [RFC 9106](https://www.rfc-editor.org/rfc/rfc9106).
82+
83+
### Other Areas to Improve Before Production
84+
85+
- **Password reset tokens** — currently passed via route params (visible in navigation). Consider storing them only server-side or using a deeper link strategy.
86+
- **Session management** — sessions are stored in SQLite with no expiry. Add a `expiresAt` column and invalidate stale sessions.
87+
- **Input validation** — add stricter password rules (min length, complexity) via Zod schemas.
88+
- **Rate limiting** — no protection against brute-force login attempts exists in a local-first setup; consider adding attempt counters.
89+
- **Token expiry** — reset tokens expire after 15 minutes by default; adjust as needed for your use case.
90+
- **No email verification** — there is no email confirmation step on sign up.
91+
- **Local-only** — this project uses SQLite with no backend. For multi-device or server-side auth, you will need to integrate a backend (e.g., Supabase, Firebase, or a custom API).
92+
93+
---
94+
3395
<h2 id="installation">
3496
Installation & Setup
3597
</h2>
3698

3799
### 1. Clone the Repository
38100

39101
```bash
40-
git clone https://github.com/Victor-Zarzar/react-native-crud
41-
cd react-native-crud
102+
git clone https://github.com/Victor-Zarzar/react-native-basic-auth
103+
cd react-native-basic-auth
42104
```
43105

44106
### 2. Install Dependencies
@@ -80,6 +142,7 @@ Open the app:
80142
| `bun run ios` | Start on iOS Simulator |
81143
| `bun run web` | Start on Web |
82144
| `bun run db:generate` | Generate Drizzle ORM migration files |
145+
| `bun run upgrade-deps` | Fix and align dependencies with Expo SDK |
83146
| `bun run prebuild` | Rebuild native directories with Expo Prebuild |
84147
| `bun run ios:native` | Run native iOS build |
85148
| `bun run android:native` | Run native Android build |
@@ -100,9 +163,9 @@ Open the app:
100163
- **Expo Router** – File-based routing
101164
- **TypeScript** – Type-safe development
102165
- **NativeWind** – Tailwind CSS for React Native
103-
- **SQLite (Expo SQLite)** – Local persistent storage for CRUD operations
166+
- **SQLite (Expo SQLite)** – Local persistent storage
104167
- **Drizzle ORM** – Type-safe ORM for SQLite with migration support
105-
- **Expo Crypto** – Cryptographic utilities for secure ID generation and hashing
168+
- **Expo Crypto** – Cryptographic utilities (SHA-256 for dev; replace with Argon2id for prod)
106169
- **React Native Reusables** – Accessible UI component system
107170

108171
---
@@ -111,11 +174,11 @@ Open the app:
111174
Key Features
112175
</h2>
113176

114-
- Full CRUD operationsCreate, Read, Update, and Delete records
177+
- Complete auth flowSign Up, Sign In, Sign Out, Forgot Password, Reset Password
115178
- Local data persistence with SQLite via Expo SQLite
116179
- Type-safe database queries with Drizzle ORM
117180
- Drizzle Studio integration via `expo-drizzle-studio-plugin` for database inspection during development
118-
- Secure ID generation with Expo Crypto
181+
- Password hashing with Expo Crypto (SHA-256 — see [Security Considerations](#security-considerations) for production upgrade path)
119182
- Production-ready scalable structure
120183
- File-based routing with Expo Router
121184
- Dark mode support
@@ -146,7 +209,7 @@ Before starting, ensure you have:
146209
</h2>
147210

148211
```
149-
react-native-crud/
212+
react-native-basic-auth/
150213
├── .expo/ # Expo cache and config
151214
├── .github/ # GitHub Actions & workflows
152215
├── assets/ # Images and fonts
@@ -251,7 +314,7 @@ With the development server running (`bun run dev`), press `Shift + M` in the te
251314
</br>
252315

253316
<p align="center">
254-
<img src="https://github.com/user-attachments/assets/05dce4c2-72cd-46c9-afb9-d04146848ea2" width="1000" height="600" alt="SQL Drizze Studio">
317+
<img src="https://github.com/user-attachments/assets/05dce4c2-72cd-46c9-afb9-d04146848ea2" width="1000" height="600" alt="SQL Drizzle Studio">
255318
</p>
256319

257320
</br>
@@ -316,6 +379,6 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
316379

317380
Victor Zarzar - [@Victor-Zarzar](https://github.com/Victor-Zarzar)
318381

319-
Project Link: [https://github.com/Victor-Zarzar/react-native-crud](https://github.com/Victor-Zarzar/react-native-crud)
382+
Project Link: [https://github.com/Victor-Zarzar/react-native-basic-auth](https://github.com/Victor-Zarzar/react-native-basic-auth)
320383

321384
---

0 commit comments

Comments
 (0)