Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
e969e39
Test
Alex07147 Dec 15, 2025
954c6b7
Merge branch 'Development' of https://github.com/FitBuddy-AI/FitBuddy…
Alex07147 Dec 15, 2025
a718ee6
Attempting to merge local branch with global branch
Alex07147 Dec 15, 2025
1fa5c4d
Test
Alex07147 Dec 15, 2025
657c6d4
fix: Enhance rate limiter by using ipKeyGenerator for better IP handl…
we09532 Dec 15, 2025
5660ac7
feat: Implement intro overlay handling in Header, Footer, and Welcome…
we09532 Dec 16, 2025
dcbee9e
Refactor blog components and enhance blog post structure
we09532 Dec 16, 2025
65ae474
refactor: Remove in-memory refresh token store and enhance BlogListPa…
we09532 Dec 16, 2025
e29f988
fix: Remove redundant closing tag in BlogListPage component
we09532 Dec 16, 2025
cb71493
feat: Add development-only auth endpoint and in-memory refresh token …
we09532 Dec 16, 2025
e9f8bd6
Potential fix for code scanning alert no. 26: Workflow does not conta…
we09532 Dec 16, 2025
6c02867
feat: Implement server-side proxy for questionnaire payloads and upda…
we09532 Dec 16, 2025
71e2206
Update api/auth/index.ts
we09532 Dec 16, 2025
219666a
Update api/auth/index.ts
we09532 Dec 16, 2025
4ccc344
Update src/components/BlogPage.tsx
we09532 Dec 16, 2025
b5d9719
Update sql/migrations/003_refresh_tokens_rls.sql
we09532 Dec 16, 2025
a23bfe0
Update src/services/localStorage.ts
we09532 Dec 16, 2025
3db18da
Update api/auth/index.ts
we09532 Dec 16, 2025
13cec66
Update src/services/localStorage.ts
we09532 Dec 16, 2025
589ca1a
Update src/services/localStorage.ts
we09532 Dec 16, 2025
0e31f43
Update src/services/localStorage.ts
we09532 Dec 16, 2025
f68a477
Update src/App.tsx
we09532 Dec 16, 2025
976e7ba
refactor: authentication session handling to include refresh token su…
we09532 Dec 17, 2025
3428758
feat: add rate limiter for auth endpoints to enhance security
we09532 Dec 17, 2025
8a85cac
Update sql/migrations/002_create_refresh_tokens.sql
we09532 Dec 17, 2025
a299b97
Potential fix for code scanning alert no. 27: Server-side request for…
we09532 Dec 17, 2025
bb3ea5c
Update src/services/authService.ts
we09532 Dec 17, 2025
24d9fc4
Update api/auth/index.ts
we09532 Dec 17, 2025
321d591
feat: implement encryption for refresh tokens in development environment
we09532 Dec 17, 2025
5efaf45
Merge branch 'Development' of https://github.com/FitBuddyAI-System/Fi…
we09532 Dec 17, 2025
109e77d
refactor: streamline Supabase client initialization in authServer.js
we09532 Dec 17, 2025
d43220a
Update src/services/localStorage.ts
we09532 Dec 17, 2025
7c19a9b
Update src/services/aiService.ts
we09532 Dec 17, 2025
543d5a1
Update api/auth/index.ts
we09532 Dec 17, 2025
7bff366
Update src/services/aiService.ts
we09532 Dec 17, 2025
7a8c133
Update api/auth/index.ts
we09532 Dec 17, 2025
565486b
Update api/auth/index.ts
we09532 Dec 17, 2025
1925699
Update src/App.tsx
we09532 Dec 17, 2025
efa4683
Update scripts/cleanup_refresh_tokens.js
we09532 Dec 17, 2025
a6133e8
refactor: define BackupPayload type for user data backup functions
we09532 Dec 17, 2025
628fc71
Merge branch 'Development' of https://github.com/FitBuddyAI-System/Fi…
we09532 Dec 17, 2025
402d810
Update api/auth/index.ts
we09532 Dec 17, 2025
cb52c6d
fix: improve comment clarity on session removal for unpersisted rotat…
we09532 Dec 17, 2025
870cf66
Update api/auth/index.ts
we09532 Dec 17, 2025
22b1259
Update api/auth/index.ts
we09532 Dec 17, 2025
055ad2b
Update api/auth/index.ts
we09532 Dec 17, 2025
aa52099
Update api/auth/index.ts
we09532 Dec 17, 2025
cce776a
Update api/auth/index.ts
we09532 Dec 17, 2025
1d3fa3f
Update api/auth/index.ts
we09532 Dec 17, 2025
9442d9a
Update src/services/authService.ts
we09532 Dec 17, 2025
eb72c5f
Update src/services/localStorage.ts
we09532 Dec 17, 2025
f3ac52d
refactor: define RefreshTokenRow type and use environment variables f…
we09532 Dec 17, 2025
dce0ef2
Merge branch 'Development' of https://github.com/FitBuddyAI-System/Fi…
we09532 Dec 17, 2025
dacd939
refactor: normalize environment variable handling and improve error h…
we09532 Dec 18, 2025
375a26d
Merge branch 'main' into Development
we09532 Dec 18, 2025
f55862f
refactor: enhance URL validation and sanitization to prevent SSRF vul…
we09532 Dec 18, 2025
783f703
refactor: restrict webhook targets to server-configured URLs to mitig…
we09532 Dec 18, 2025
6edb4e3
Update api/auth/index.ts
we09532 Dec 18, 2025
6f8af13
Update src/services/cloudBackupService.ts
we09532 Dec 18, 2025
7382383
Update src/App.tsx
we09532 Dec 18, 2025
6c52315
Update src/services/authService.ts
we09532 Dec 18, 2025
5e48430
Update src/services/authService.ts
we09532 Dec 18, 2025
bdcbc36
Update src/server/authServer.js
we09532 Dec 18, 2025
e453fa2
Update src/services/authService.ts
we09532 Dec 18, 2025
07345ae
Update src/server/authServer.js
we09532 Dec 18, 2025
a6912a8
Update scripts/cleanup_refresh_tokens.js
we09532 Dec 18, 2025
066da83
Update api/auth/index.ts
we09532 Dec 18, 2025
4632223
Update src/services/cloudBackupService.ts
we09532 Dec 18, 2025
26c7247
Update src/services/authService.ts
we09532 Dec 18, 2025
ed7fe8d
Update src/server/authServer.js
we09532 Dec 18, 2025
47202b4
Update src/server/authServer.js
we09532 Dec 18, 2025
83f23f8
Update src/server/authServer.js
we09532 Dec 18, 2025
e898b4a
Update src/server/userDataStore.js
we09532 Dec 18, 2025
9ca007a
Enhance refresh token management and cleanup processes
we09532 Dec 19, 2025
f3f00e3
Merge branch 'Development' of https://github.com/FitBuddyAI-System/Fi…
we09532 Dec 19, 2025
9ab9e54
Update src/server/authServer.js
we09532 Dec 19, 2025
03fe344
Update src/server/authServer.js
we09532 Dec 19, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,18 @@ When working on this project, prioritize user experience, type safety, and maint
## Compatibility Policy
- **Do NOT add compatibility helpers or legacy mapping code:** Fail fast on missing columns or schema mismatches. Avoid adding server-side compatibility shims that map legacy `fitbuddyai_*` keys to new columns. These helpers create code bloat and hidden behavior; prefer explicit schema changes and migrations.
- **Do NOT use local-file fallbacks or silent dev fallbacks in server code:** This project is production-first. Server code must require Supabase (or the configured production datastore) and fail loudly if it is not available. Do not add behavior that reads or writes local JSON files as a runtime fallback — that hides configuration problems and leads to inconsistent production behavior.


FitBuddyAI Copilot Guidelines

- This repository is production-grade and must be treated as such.
- Do NOT add placeholder comments or TODOs that indicate unfinished production work.
- Do NOT add comments that state "this is a placeholder" or similar developer-only notes.
- When the user requests a fix, implement the code change; do not respond by
only adding explanatory comments in the code instead of performing the
requested fix.
- All code added should be runnable, properly tested, and follow existing project patterns.
- If a dev-only helper is required, clearly gate it behind NODE_ENV checks and provide a corresponding test or cleanup plan.
- Sensitive configuration must be stored in environment variables; do not hard-code secrets.

Rationale: This project is deployed to production environments and security, clarity, and maintainability are required. Keep contributions focused and production-ready.
26 changes: 26 additions & 0 deletions .github/workflows/refresh-token-cleanup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Refresh Token Cleanup
permissions:
contents: read

on:
schedule:
- cron: '0 3 * * *' # every day at 03:00 UTC
workflow_dispatch: {}

jobs:
cleanup:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '18'
- name: Install deps
run: npm ci
- name: Run cleanup script
env:
SUPABASE_URL: ${{ secrets.SUPABASE_URL }}
SUPABASE_KEY: ${{ secrets.SUPABASE_SERVICE_ROLE_KEY }}
run: node scripts/cleanup_refresh_tokens.js 30
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,19 @@ If automation is failing or you prefer manual control, change the preview link y
SUPABASE_SERVICE_ROLE_KEY=your-supabase-service-role-key
JWT_SECRET=your-secure-jwt-secret-here
ADMIN_API_TOKEN=your-admin-api-token

# Encryption keys for server-side refresh-token storage (required for dev)
# Preferred: provide multiple keys for rotation in order (newest first):
# REFRESH_TOKEN_ENC_KEYS=<keyId1>=<secret1>,<keyId2>=<secret2>
# Example:
# REFRESH_TOKEN_ENC_KEYS=k2=NEW_SECRET,k1=OLD_SECRET
# Legacy single-key option (not recommended for rotation):
# REFRESH_TOKEN_ENC_KEY=your-secret
# REFRESH_TOKEN_ENC_KEY_ID=k1
Comment on lines +154 to +161
Copy link

Copilot AI Dec 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The README update documents the encryption key configuration for refresh tokens (lines 154-161), which is good. However, it shows example key rotation syntax:

REFRESH_TOKEN_ENC_KEYS=k2=NEW_SECRET,k1=OLD_SECRET

This format suggests that k2 is the new key and should be listed first. However, the documentation doesn't explicitly state which key is used for new encryptions (the first one in the list vs. the last one). Based on the code in api/auth/index.ts (line 51), the first entry in ENC_KEYS[0] is the current key used for new encryptions.

Consider making this more explicit in the example by adding a comment like:

# List keys newest-first; the first key is used for new encryptions
REFRESH_TOKEN_ENC_KEYS=k2=NEW_SECRET,k1=OLD_SECRET

Or document the rotation process: "To rotate keys, prepend the new key to the list and remove old keys after all tokens have migrated."

Copilot uses AI. Check for mistakes.
```

Note: The dev auth server requires `REFRESH_TOKEN_ENC_KEY` (or `REFRESH_TOKEN_ENC_KEYS`) to be set and will fail to start without it. In production, set the same variables in your deployment environment. Use the multi-key `REFRESH_TOKEN_ENC_KEYS` format to rotate keys safely: add the new key first, leave old keys present until tokens have migrated, then remove old keys.

4. **Generate Secure JWT Secret**
```bash
node -e "console.log(require('crypto').randomBytes(64).toString('hex'))"
Expand Down
Loading