-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Revert "fix(salesforce): updated to more flexible oauth that allows production, developer, and custom domain salesforce orgs (#2441) (#2444)" #2453
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Greptile Summary
Important Files Changed
Confidence score: 1/5
Sequence DiagramsequenceDiagram
participant User
participant SimStudio as "SimStudio App"
participant DB as "Database"
participant SalesforceAuth as "Salesforce OAuth"
participant SalesforceAPI as "Salesforce API"
User->>SimStudio: "Initiate OAuth connection"
SimStudio->>SalesforceAuth: "Redirect to authorization endpoint"
User->>SalesforceAuth: "Authorize application"
SalesforceAuth->>SimStudio: "Return authorization code"
SimStudio->>SalesforceAuth: "Exchange code for tokens"
SalesforceAuth->>SimStudio: "Return access token, refresh token, ID token"
SimStudio->>DB: "Store OAuth credentials"
User->>SimStudio: "Execute Salesforce tool"
SimStudio->>DB: "Retrieve stored credentials"
alt Token expired
SimStudio->>SalesforceAuth: "Refresh token request"
SalesforceAuth->>SimStudio: "Return new access token"
SimStudio->>DB: "Update stored tokens"
end
SimStudio->>SimStudio: "Extract instance URL from ID token"
SimStudio->>SalesforceAPI: "API request with access token"
SalesforceAPI->>SimStudio: "Return API response"
SimStudio->>User: "Return processed results"
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Additional Comments (2)
-
apps/sim/app/api/auth/oauth2/callback/salesforce/route.tslogic: Complete removal of Salesforce OAuth callback handler will break all Salesforce authentication flows. The
/api/auth/oauth2/callback/salesforceendpoint will return 404, causing OAuth failures. Is there a replacement callback handler being implemented, or should this revert to a previous working version instead of complete deletion? -
apps/sim/tools/salesforce/utils.ts, line 46 (link)style: Using
anytype instead of proper TypeScript typingContext Used: Context from
dashboard- TypeScript conventions and type safety (source)
12 files reviewed, 5 comments
| if (!instanceUrl && params.idToken) { | ||
| try { | ||
| const base64Url = params.idToken.split('.')[1] | ||
| const base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/') | ||
| const jsonPayload = decodeURIComponent( | ||
| atob(base64) | ||
| .split('') | ||
| .map((c) => `%${(`00${c.charCodeAt(0).toString(16)}`).slice(-2)}`) | ||
| .join('') | ||
| ) | ||
| const decoded = JSON.parse(jsonPayload) | ||
|
|
||
| if (decoded.profile) { | ||
| const match = decoded.profile.match(/^(https:\/\/[^/]+)/) | ||
| if (match) { | ||
| instanceUrl = match[1] | ||
| } | ||
| } else if (decoded.sub) { | ||
| const match = decoded.sub.match(/^(https:\/\/[^/]+)/) | ||
| if (match && match[1] !== 'https://login.salesforce.com') { | ||
| instanceUrl = match[1] | ||
| } | ||
| } | ||
| } catch (error) { | ||
| logger.error('Failed to decode Salesforce idToken', { error }) | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: JWT token parsing logic now duplicated across multiple Salesforce tools. Should this logic be extracted to a shared utility to avoid duplication across other Salesforce tools?
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/sim/tools/salesforce/update_account.ts
Line: 157:183
Comment:
**style:** JWT token parsing logic now duplicated across multiple Salesforce tools. Should this logic be extracted to a shared utility to avoid duplication across other Salesforce tools?
<sub>Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!</sub>
How can I resolve this? If you propose a fix, please make it concise.| const base64Url = params.idToken.split('.')[1] | ||
| const base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/') | ||
| const jsonPayload = decodeURIComponent( | ||
| atob(base64) | ||
| .split('') | ||
| .map((c) => `%${(`00${c.charCodeAt(0).toString(16)}`).slice(-2)}`) | ||
| .join('') | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: Complex JWT decoding logic should be extracted to a utility function for reuse across Salesforce tools
Context Used: Context from dashboard - Core architecture principles for the Sim app (source). Was there a specific issue with the centralized getInstanceUrl utility that required this reversion?
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/sim/tools/salesforce/create_account.ts
Line: 153:160
Comment:
**style:** Complex JWT decoding logic should be extracted to a utility function for reuse across Salesforce tools
**Context Used:** Context from `dashboard` - Core architecture principles for the Sim app ([source](https://app.greptile.com/review/custom-context?memory=2d6e479d-8e35-4102-a11d-13cf026616dd)). Was there a specific issue with the centralized `getInstanceUrl` utility that required this reversion?
<sub>Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!</sub>
How can I resolve this? If you propose a fix, please make it concise.| if (!instanceUrl && params.idToken) { | ||
| try { | ||
| const base64Url = params.idToken.split('.')[1] | ||
| const base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/') | ||
| const jsonPayload = decodeURIComponent( | ||
| atob(base64) | ||
| .split('') | ||
| .map((c) => `%${(`00${c.charCodeAt(0).toString(16)}`).slice(-2)}`) | ||
| .join('') | ||
| ) | ||
| const decoded = JSON.parse(jsonPayload) | ||
|
|
||
| if (decoded.profile) { | ||
| const match = decoded.profile.match(/^(https:\/\/[^/]+)/) | ||
| if (match) { | ||
| instanceUrl = match[1] | ||
| } | ||
| } else if (decoded.sub) { | ||
| const match = decoded.sub.match(/^(https:\/\/[^/]+)/) | ||
| if (match && match[1] !== 'https://login.salesforce.com') { | ||
| instanceUrl = match[1] | ||
| } | ||
| } | ||
| } catch (error) { | ||
| logger.error('Failed to decode Salesforce idToken', { error }) | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: This complex JWT parsing logic appears to be duplicated across multiple Salesforce tools. Consider extracting to a shared utility function to improve maintainability.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/sim/tools/salesforce/get_accounts.ts
Line: 67:93
Comment:
**style:** This complex JWT parsing logic appears to be duplicated across multiple Salesforce tools. Consider extracting to a shared utility function to improve maintainability.
<sub>Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!</sub>
How can I resolve this? If you propose a fix, please make it concise.
This reverts commit 9da19e8.