Skip to content

[PoC] JWT-based project identification - #64

Merged
UZ9 merged 1 commit into
mainfrom
ryder/jwt-project-selection
Nov 16, 2025
Merged

UZ9 merged 1 commit into
mainfrom
ryder/jwt-project-selection

Conversation

@UZ9

@UZ9 UZ9 commented Nov 16, 2025

Copy link
Copy Markdown
Contributor

(Almost all auto-generated)

@UZ9
UZ9 merged commit 85e20ca into main Nov 16, 2025
2 checks passed
@greptile-apps

greptile-apps Bot commented Nov 16, 2025

Copy link
Copy Markdown
Contributor

Disclaimer: This comment was AI-generated and is not necessarily completely accurate. Please take code comments with a grain of salt.

Greptile Overview

Greptile Summary

This PR implements JWT-based project identification across the SDK by adding an optional ApiCredentials parameter to API methods, enabling user authentication via JWT tokens and explicit project ID specification through custom HTTP headers (X-User-JWT and X-Project-Id).

Key Changes:

  • Created new ApiCredentials interface for passing userJwt and projectId
  • Updated 6 analytics methods, 2 analytics config methods, 5 email methods, and 2 settings methods to accept optional credentials
  • Modified authApi.ts to conditionally apply API key authentication
  • Added new getStatistics method to email API

Issues Found:

  • updateAnalyticsConfig and deleteAnalyticsConfig in analyticsConfig.ts are missing the credentials parameter, creating API inconsistency
  • Unused queryParams variable in getStatistics method in email.ts
  • Inconsistent null checking patterns across files (some check !== null, others don't)

Confidence Score: 3/5

  • This PR has incomplete implementation with two methods missing credentials support
  • The implementation is mostly correct but incomplete - updateAnalyticsConfig and deleteAnalyticsConfig lack credentials parameter support, creating API inconsistency. The unused variable and inconsistent null checks are minor issues but the missing JWT support in critical methods could cause authentication failures.
  • Pay close attention to src/lib/analyticsConfig.ts - missing credentials support in update and delete methods

Important Files Changed

File Analysis

Filename Score Overview
src/lib/analytics.ts 4/5 Added optional credentials parameter to 6 methods for JWT-based project identification with custom headers
src/lib/analyticsConfig.ts 3/5 Added credentials parameter to 2 methods but updateAnalyticsConfig and deleteAnalyticsConfig lack JWT support
src/lib/email.ts 4/5 Added credentials parameter to 5 methods and new getStatistics method with JWT support

Sequence Diagram

sequenceDiagram
    participant Client
    participant SDK
    participant JunoAPI
    participant AuthService
    
    Note over Client,AuthService: JWT-based Project Identification Flow
    
    Client->>SDK: Call API method with credentials
    Note over Client,SDK: credentials = { userJwt, projectId }
    
    SDK->>SDK: Build headers object
    alt userJwt provided
        SDK->>SDK: Set X-User-JWT header
    end
    alt projectId provided
        SDK->>SDK: Set X-Project-Id header
    end
    
    SDK->>JunoAPI: HTTP Request with custom headers
    Note over SDK,JunoAPI: Authorization: Bearer {apiKey}<br/>X-User-JWT: {userJwt}<br/>X-Project-Id: {projectId}
    
    JunoAPI->>AuthService: Validate JWT (if provided)
    AuthService-->>JunoAPI: User validation result
    
    JunoAPI->>JunoAPI: Process request with project context
    JunoAPI-->>SDK: Response
    SDK-->>Client: Result
Loading

@greptile-apps greptile-apps Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Additional Comments (2)

  1. src/lib/analyticsConfig.ts, line 75-90 (link)

    logic: updateAnalyticsConfig missing credentials parameter unlike other methods

  2. src/lib/analyticsConfig.ts, line 92-105 (link)

    logic: deleteAnalyticsConfig missing credentials parameter unlike other methods

6 files reviewed, 4 comments

Edit Code Review Agent Settings | Greptile

Comment thread src/lib/analytics.ts
Comment thread src/lib/email.ts
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.

1 participant