Skip to content

Conversation

@paustint
Copy link
Contributor

@paustint paustint commented Dec 27, 2025

This pull request implements several security and maintainability improvements to the authentication flow for both the desktop app and web extension, focusing on token management, validation, and logging. The changes include migrating stored tokens to an encrypted format, reworking token reuse logic, improving error handling, and modernizing the way device and token information is passed in API requests. Additionally, logging is standardized across controllers for better observability.

Authentication and Token Management Improvements

  • Migrated stored tokens for both desktop and web extension to use encrypted format, including automatic upgrading of legacy plaintext tokens on access, and storing a hash for efficient lookup. (web-extension.db.ts, jwt-token-encryption.service usage) [1] [2]
  • Updated token reuse logic: when a valid token exists (within a refresh buffer), it is decrypted and reused instead of issuing a new one, reducing unnecessary token churn. (desktop-app.controller.ts, web-extension.controller.ts) [1] [2]
  • Token validation and logout endpoints now prefer device and token information from headers, with body fields marked as deprecated for backward compatibility. (routeDefinition in both controllers) [1] [2] [3] [4]

API Response and Logging Enhancements

  • Enhanced API responses for token verification to optionally include the user profile, and improved error logging to include user and device context. (desktop-app.controller.ts, web-extension.controller.ts) [1] [2]
  • Standardized logging by replacing console.error with the shared logger utility in asset download endpoints. (desktop-assets.controller.ts) [1] [2] [3]

Code Quality and Maintainability

  • Refactored imports and controller logic for clarity, including extracting shared utilities and marking deprecated request patterns. (desktop-app.controller.ts, web-extension.controller.ts) [1] [2] [3] [4]
  • Added user activity tracking for token issuance actions for both desktop and web extension logins. (desktop-app.controller.ts, web-extension.controller.ts) [1] [2]

These changes significantly improve the security, reliability, and maintainability of authentication flows for client applications.

@paustint paustint marked this pull request as ready for review December 27, 2025 20:53
Copilot AI review requested due to automatic review settings December 27, 2025 20:53
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds team dashboard functionality for desktop users by redirecting to the web version, fixes user profile data mapping issues, and modifies the JWT token authentication flow to always re-issue tokens while preventing duplicate requests on page refresh.

Key Changes:

  • Desktop users now open team dashboard in external browser instead of navigating within the app
  • JWT tokens are re-issued on every authentication request instead of reusing existing valid tokens
  • Page refresh protection added via localStorage to prevent duplicate token generation

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
libs/shared/ui-core/src/app/HeaderNavbar.tsx Opens team dashboard link in external browser for desktop users
libs/desktop-types/src/lib/desktop-app.types.ts Expands user profile schema to include additional fields (userId, emailVerified, picture, billingAccount, entitlements, teamMembership)
libs/auth/acl/src/lib/acl.ts Adds Team read permission for desktop billing/admin users
apps/landing/hooks/desktop-auth.hooks.ts Implements localStorage-based check to prevent re-authentication on page refresh
apps/jetstream-desktop/src/services/persistence.service.ts Fixes swapped email/name mapping and adds picture and teamMembership to user profile
apps/jetstream-desktop/src/browser/browser.ts Changes hostname check to host check for better port handling in external link detection
apps/api/src/app/controllers/desktop-app.controller.ts Removes token reuse logic and always issues new JWT tokens

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 25 out of 25 changed files in this pull request and generated 7 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 28 out of 28 changed files in this pull request and generated 6 comments.

Comments suppressed due to low confidence (1)

apps/api/src/app/routes/openapi.routes.ts:581

  • The path should be '/desktop-app/auth/logout' not '/desktop-app/logout' to match the actual route definition. The actual route is defined as '/auth/logout' under the '/desktop-app' prefix.
      '/desktop-app/logout': {
        delete: { ...getRequest({ ...desktopController.logout.validators, tags: ['desktop'] }) },
      },

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 28 out of 28 changed files in this pull request and generated 6 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 35 out of 35 changed files in this pull request and generated 21 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Allow access to the team dashboard from the desktop app
If allowed, a link to the web-app is shown in the menu
@paustint paustint force-pushed the feat/desktop-team-dashboard branch from e18b7f7 to c25beaa Compare January 1, 2026 14:39
@paustint paustint force-pushed the feat/desktop-team-dashboard branch from c25beaa to a0c3ec0 Compare January 1, 2026 17:17
@socket-security
Copy link

socket-security bot commented Jan 1, 2026

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedreact@​19.2.01001008497100
Addedprism-react-renderer@​2.4.19910010086100
Addedtypescript@​5.9.31001009010090
Addedreact-dom@​19.2.01001009298100

View full report

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 48 out of 49 changed files in this pull request and generated 7 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

JWT tokens are used for desktop/web-extension to ensure access
These tokens provide access to history data, but nothing else,
they were stored unencrypted in the DB

The code supports both encrypted and unencrypted tokens,
so existing tokens will continue to work, but new tokens
will be encrypted before being stored in the DB
Tokens are encrypted as they are used if in plaintext form

Fixed openapi specifications
Ensure all external clients (desktop/web extension) utilize authorization header instead of the body

Update external auth to pull from body as a fallback for backwards compatibility

Fix logout response handling
@paustint paustint force-pushed the feat/desktop-team-dashboard branch from d18eb0a to f1e355c Compare January 1, 2026 18:41
@paustint paustint merged commit 36bcc78 into main Jan 2, 2026
9 of 10 checks passed
@paustint paustint deleted the feat/desktop-team-dashboard branch January 2, 2026 14:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants