Amazon Ergo 1.0 · Heavy
oauth-credential-sync-and-app-integration-enhancements-cal-com
cal.com · TypeScript · M · 100–299 lines · 6 files
The generalist plus 9 specialist lens agents in parallel, then the same verify and dedup steps. Judge: Claude Opus 5.5.
- Gold bugs found
- 9 of 19
- Comments published
- 12
- Comments matching a bug
- 9
- Comments not matching
- 3
- Cost of this PR
- $4.948
Published comments (12)
Zoom token refresh sends the wrong app slug — Credential sync can target the wrong app or fail because it resolves the `"zoomvideo"` slug, while `zoomvideo/_metadata.ts` and the callback use `"zoom"`. Pass `"zoom"` to `refreshOAuthTokens`.
Salesforce connection keeps using the stale access token after refresh — Persisting the refresh does not update the connection returned to callers, which keeps sending the expired token. Assign `accessTokenParsed.data.access_token` and `accessTokenParsed.data.instance_url` to `credentialKey` before constructing `jsforce.Connection`.
App metadata lookup fails when slug differs from dirName — Valid apps whose slug differs from `dirName` return 404 because `appStoreMetadata[app.slug]` indexes `dirName` keys. Resolve metadata by `metadata.slug` or the app's `dirName` instead.
Credential sharing returns a raw fetch Response to token callers — Google, Zoho, and HubSpot refreshes throw or read empty token fields whenever credential sharing is enabled because callers receive a `Response` instead of parsed JSON. Return `await response.json()` from `refreshOAuthTokens` to match the non-sharing contract. **Also found in:** - `packages/app-store/googlecalendar/lib/CalendarService.ts:86-96`
Placeholder refresh token can overwrite the stored token — Office365 and Zoom persist the mutated object, replacing a valid refresh token with a sentinel and breaking subsequent refreshes. When `refresh_token` is absent, keep the existing stored value instead of modifying `refreshTokenResponse.data`.
Missing refresh token is replaced with a literal placeholder — The real credential is destroyed on the first refresh, so later token requests fail. Skip the assignment when `refreshTokenResponse.data.refresh_token` is missing and retain the previously stored token during persistence.
Placeholder refresh token overwrites stored credentials — Sharing mode reduces the response to `access_token`, and Microsoft may omit `refresh_token` in normal mode, so Office365 and Zoom overwrite valid credentials and fail on the next refresh. Preserve the stored token when merging `tokenResponse.data` or `parsedToken.data`.
credentialId passed as userId to refreshOAuthTokens — The sync endpoint can return the wrong user's token or fail because `credentialId` is sent as `calcomUserId`. Pass the credential's `userId` to `refreshOAuthTokens`, looking it up with `prisma.credential.findUniqueOrThrow` if needed.
credential.key stores SafeParse result wrapper instead of token data — The next refresh fails schema validation because `credential.key` contains the SafeParse wrapper, nesting `access_token` and `refresh_token` under `data`. Persist `parseRefreshTokenResponse(...).data` instead.
Webhook secret uses a timing-unsafe string comparison — Timing differences can reveal `CALCOM_WEBHOOK_SECRET` to an attacker. Validate the header as a single string, then compare equal-length buffers with `crypto.timingSafeEqual` instead of `!==`.
Malformed decrypted credentials can leak secret material in errors — `JSON.parse` errors can include fragments of the decrypted payload, leaking secret material into logs and development responses. Wrap `symmetricDecrypt` and parsing in `try/catch`, returning a generic 400 without the underlying error.
Credential-sharing token schema strips expiry fields — Callers persist credential-sharing tokens without `expiry_date`, `expires_in`, or other fields because the computed Zod keys collapse and unknown keys are stripped. Use `.passthrough()`/`.catchall(...)` with explicit expiry handling, or correct the comments.