Repository navigation
feat(plugins): Add Notion OAuth plugin support - #82
Merged
Merged
Conversation
Generalize oauth-bearer token exchanges so plugins can add provider-specific authorize params, token auth, and token headers without special-casing providers in core. Add @sentry/junior-notion, package discovery/docs wiring, and tests so Junior can connect per-user Notion accounts and read workspace content with the required API headers. Fixes #75 Co-Authored-By: GPT-5 Codex <[email protected]>
Explain where to create the Notion integration, which capability the plugin needs, and which provider-side settings must match Junior. This makes the public docs and package README usable without reading the implementation or the issue thread. Refs #75 Co-Authored-By: GPT-5 Codex <[email protected]>
Use a shared NOTION_TOKEN-backed integration instead of per-user Notion oauth for the Notion plugin. This keeps the generic oauth-bearer improvements in core for future plugins, but simplifies the Notion package, user-facing skill behavior, and setup docs to match the actual single-workspace integration model. Refs #75 Co-Authored-By: GPT-5 Codex <[email protected]>
Treat bearer plugins without an oauth block as shared-token providers and remove the extra Notion placeholder override. This keeps the internal-integration path aligned with the manifest contract instead of encoding OAuth assumptions in the plugin package. Move jr-rpc OAuth Slack delivery coverage onto the MSW integration harness and register @sentry/junior-notion in apps/example so the consumer app exercises the same packaged plugin surface used in practice. Refs #75 Co-Authored-By: GPT-5 Codex <[email protected]>
Move OAuth link setup and private Slack delivery into a focused shared module so slash commands and callback handlers no longer depend on the jr-rpc shell surface. This reduces interface bloat in jr-rpc, keeps plugin OAuth types with the plugin manifest types, and trims helper-only exports that were not part of the runtime contract. Refs #75 Co-Authored-By: GPT-5 Codex <[email protected]>
The catch block is only reachable inside the `stored.expiresAt !== undefined` guard, so the `stored.expiresAt === undefined` branch was always false. Simplify to just check `stored.expiresAt > Date.now()`. Co-Authored-By: claude-opus-4-6 <[email protected]> https://claude.ai/code/session_017tC1xoLsFx57EFgHzvVHoi
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Comment on lines
+70
to
+77
| export function parseOAuthTokenResponse(data: Record<string, unknown>): { | ||
| accessToken: string; | ||
| refreshToken: string; | ||
| expiresAt?: number; | ||
| } { | ||
| const accessToken = requireNonEmptyTokenField(data, "access_token"); | ||
| const refreshToken = requireNonEmptyTokenField(data, "refresh_token"); | ||
| const expiresIn = data.expires_in; |
Contributor
There was a problem hiding this comment.
Bug: The parseOAuthTokenResponse function incorrectly requires a refresh_token, which is optional in the OAuth 2.0 spec. This will break integrations with providers that do not issue them.
Severity: MEDIUM
Suggested Fix
Make the refreshToken field optional in the StoredTokens interface. Update the parsing logic in parseOAuthTokenResponse to handle cases where the refresh_token is absent from the token response. The token refresh logic should only be attempted if a refreshToken exists.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.
Location: packages/junior/src/chat/plugins/oauth-request.ts#L70-L77
Potential issue: The `parseOAuthTokenResponse` function unconditionally requires a
`refresh_token` by calling `requireNonEmptyTokenField(data, "refresh_token")`. However,
the OAuth 2.0 specification states that refresh tokens are optional. This will cause the
initial token exchange to fail for any provider that does not return a `refresh_token`,
preventing users from connecting their accounts. While the currently used Sentry
provider is unaffected, this latent bug will break integration with other valid OAuth
providers in the future.
Did we get this right? 👍 / 👎 to inform future reviews.
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Generalize oauth-bearer token exchanges so plugins can add
provider-specific authorize params, token auth, and token headers
without special-casing providers in core.
Add @sentry/junior-notion, package discovery/docs wiring, and tests so
Junior can connect per-user Notion accounts and read workspace content
with the required API headers.
Fixes #75
Co-Authored-By: GPT-5 Codex [email protected]