Skip to content

feat(plugins): Add Notion OAuth plugin support - #82

Merged
dcramer merged 6 commits into
mainfrom
claude/remove-dead-code-refresh-5xq7n
Mar 9, 2026
Merged

dcramer merged 6 commits into
mainfrom
claude/remove-dead-code-refresh-5xq7n

Conversation

@dcramer

@dcramer dcramer commented Mar 9, 2026

Copy link
Copy Markdown
Member

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]

dcramer and others added 6 commits March 9, 2026 11:26
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
@vercel

vercel Bot commented Mar 9, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
junior-docs Ready Ready Preview, Comment Mar 9, 2026 9:40pm

Request Review

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;

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.

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.

@dcramer
dcramer merged commit 8de1ecf into main Mar 9, 2026
10 checks passed
@dcramer
dcramer deleted the claude/remove-dead-code-refresh-5xq7n branch March 9, 2026 22:31

This branch was successfully deployed

1 active deployment
Preview — 835a6d5a Deployed Mar 9, 2026 by vercel[bot]
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.

Add first-class Notion plugin with generalized oauth-bearer support

2 participants