[PR #5066] [MERGED] refactor(backend): enhance auth strategies with type safety and better error handling #5038

Closed
opened 2026-03-17 02:31:22 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/hoppscotch/hoppscotch/pull/5066
Author: @Krishprajapati15
Created: 5/11/2025
Status: Merged
Merged: 6/25/2025
Merged by: @jamesgeorge007

Base: nextHead: main


📝 Commits (4)

  • bdc82ae refactor(auth): enhance GithubStrategy with type safety, error handling, and secure validation
  • f1e2f4a refactor(auth): apply robust type safety and error handling to all strategies
  • d73e0f3 refactor: improve email validation and unused done()
  • a45dcb5 chore: remove unnecessary Promise return types

📊 Changes

6 files changed (+74 additions, -41 deletions)

View changed files

📝 packages/hoppscotch-backend/src/auth/strategies/github.strategy.ts (+22 -12)
📝 packages/hoppscotch-backend/src/auth/strategies/google.strategy.ts (+20 -14)
📝 packages/hoppscotch-backend/src/auth/strategies/jwt.strategy.ts (+1 -1)
📝 packages/hoppscotch-backend/src/auth/strategies/microsoft.strategy.ts (+22 -12)
📝 packages/hoppscotch-backend/src/auth/strategies/rt-jwt.strategy.ts (+2 -2)
📝 packages/hoppscotch-backend/src/errors.ts (+7 -0)

📄 Description

refactor(auth): enhance GithubStrategy with type safety, error handling, and secure validation

  • Added explicit typing for accessToken, refreshToken, and profile
  • Introduced defensive checks for missing GitHub email
  • Wrapped logic in try-catch for robust error handling
  • Ensured use of Passport's done() callback
  • Improved future safety with optional chaining and explicit string config values

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/hoppscotch/hoppscotch/pull/5066 **Author:** [@Krishprajapati15](https://github.com/Krishprajapati15) **Created:** 5/11/2025 **Status:** ✅ Merged **Merged:** 6/25/2025 **Merged by:** [@jamesgeorge007](https://github.com/jamesgeorge007) **Base:** `next` ← **Head:** `main` --- ### 📝 Commits (4) - [`bdc82ae`](https://github.com/hoppscotch/hoppscotch/commit/bdc82aeb3c4dfc27cf168483351afa7446e9f3c1) refactor(auth): enhance GithubStrategy with type safety, error handling, and secure validation - [`f1e2f4a`](https://github.com/hoppscotch/hoppscotch/commit/f1e2f4a196a31ae83e91863f8b4ca9383a09d650) refactor(auth): apply robust type safety and error handling to all strategies - [`d73e0f3`](https://github.com/hoppscotch/hoppscotch/commit/d73e0f35ab67f01acadbb7e75e8981ef4168b03d) refactor: improve email validation and unused done() - [`a45dcb5`](https://github.com/hoppscotch/hoppscotch/commit/a45dcb57b911a591019fa35d79e0a5bdab8d7ff5) chore: remove unnecessary Promise<any> return types ### 📊 Changes **6 files changed** (+74 additions, -41 deletions) <details> <summary>View changed files</summary> 📝 `packages/hoppscotch-backend/src/auth/strategies/github.strategy.ts` (+22 -12) 📝 `packages/hoppscotch-backend/src/auth/strategies/google.strategy.ts` (+20 -14) 📝 `packages/hoppscotch-backend/src/auth/strategies/jwt.strategy.ts` (+1 -1) 📝 `packages/hoppscotch-backend/src/auth/strategies/microsoft.strategy.ts` (+22 -12) 📝 `packages/hoppscotch-backend/src/auth/strategies/rt-jwt.strategy.ts` (+2 -2) 📝 `packages/hoppscotch-backend/src/errors.ts` (+7 -0) </details> ### 📄 Description refactor(auth): enhance GithubStrategy with type safety, error handling, and secure validation - Added explicit typing for accessToken, refreshToken, and profile - Introduced defensive checks for missing GitHub email - Wrapped logic in try-catch for robust error handling - Ensured use of Passport's `done()` callback - Improved future safety with optional chaining and explicit string config values --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-17 02:31:22 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/hoppscotch#5038
No description provided.