feat(nextjs): add Thunder V2 platform compatibility#521
Conversation
…patibility - Disable PKCE only for confidential clients (enablePKCE: !clientSecret) - Handle AsgardeoAuthException in OAuth callback action (not an Error subclass) - Forward platform config from NEXT_PUBLIC_ASGARDEO_PLATFORM env var
📝 WalkthroughWalkthroughThis PR adds Thunder V2 platform compatibility to the Asgardeo JavaScript SDKs by enabling platform-aware component routing in the Next.js SDK. The platform configuration flows from environment variables through config decorators and provider layers to sign-in/sign-up components, which conditionally render V2 or legacy components based on the resolved platform. The React package now exports V2 components and FlowMeta infrastructure for consumption. ChangesThunder V2 Platform Support
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/nextjs/src/client/components/presentation/SignUp/SignUp.tsx`:
- Around line 35-37: The SignUpProps type currently weakens children to any and
the JSDoc incorrectly documents onSuccess/onComplete; change the children
signature to children?: (props: SignUpRenderProps) => ReactElement (replacing
any) in the SignUpProps declaration, remove the two "as any" casts where
children is passed through (the casts currently masking the type mismatch), and
update the component JSDoc/example to remove onSuccess and onComplete (or
alternatively expose them via BaseSignUpProps if you intend them to be public)
so the docs match the actual public API.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 09bf3808-6a77-452c-9b93-80b29f876569
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (10)
.changeset/nextjs-thunder-v2-support.mdpackages/nextjs/src/AsgardeoNextClient.tspackages/nextjs/src/client/components/presentation/SignIn/SignIn.tsxpackages/nextjs/src/client/components/presentation/SignUp/SignUp.tsxpackages/nextjs/src/client/contexts/Asgardeo/AsgardeoProvider.tsxpackages/nextjs/src/server/AsgardeoProvider.tsxpackages/nextjs/src/server/actions/handleOAuthCallbackAction.tspackages/nextjs/src/utils/decorateConfigWithNextEnv.tspackages/react/src/index.tssamples/teamspace-nextjs/middleware.ts
| export type SignUpProps = Pick<BaseSignUpProps, 'className' | 'afterSignUpUrl' | 'onError' | 'variant' | 'size'> & { | ||
| children?: (props: any) => ReactElement; | ||
| }; |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Verify whether current repo callsites use callbacks now excluded by narrowed SignUpProps.
rg -nP --type=tsx -C2 '<SignUp[^>]*(onSuccess|onComplete|onInitialize|onSubmit)\s*='
# Inspect current exported SignUpProps definition.
rg -n -C3 'export type SignUpProps' packages/nextjs/src/client/components/presentation/SignUp/SignUp.tsxRepository: asgardeo/javascript
Length of output: 91
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# First, locate and inspect the SignUp.tsx file
fd -t f "SignUp.tsx" packages/nextjs
# Get the file size
wc -l packages/nextjs/src/client/components/presentation/SignUp/SignUp.tsx
# Read the specific lines mentioned in the review
echo "=== Lines 35-37 (SignUpProps definition) ==="
sed -n '35,37p' packages/nextjs/src/client/components/presentation/SignUp/SignUp.tsx
echo "=== Lines 75-77 ==="
sed -n '75,77p' packages/nextjs/src/client/components/presentation/SignUp/SignUp.tsx
echo "=== Lines 116-127 ==="
sed -n '116,127p' packages/nextjs/src/client/components/presentation/SignUp/SignUp.tsx
echo "=== Lines 141-144 ==="
sed -n '141,144p' packages/nextjs/src/client/components/presentation/SignUp/SignUp.tsx
# Search for SignUpRenderProps definition
echo "=== Search for SignUpRenderProps ==="
rg -n "SignUpRenderProps" packages/nextjs/src/client/components/presentation/SignUp/
# Search for BaseSignUpProps definition to see all available props
echo "=== Search for BaseSignUpProps ==="
rg -n "export.*BaseSignUpProps" packages/nextjs/src/client/components/presentation/SignUp/Repository: asgardeo/javascript
Length of output: 1290
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Search for BaseSignUpProps definition - might be in node_modules or imported
echo "=== Searching for BaseSignUpProps definition in react package ==="
fd -t f "index" packages/nextjs/node_modules/@asgardeo/react/dist/ | head -5
# Let's look at the actual type exports from `@asgardeo/react`
echo "=== Checking `@asgardeo/react` exports ==="
find packages/nextjs/node_modules/@asgardeo/react -name "*.d.ts" -o -name "index.ts" | head -10
# Search for usages of <SignUp component in the codebase (excluding SignUpV2)
echo "=== Searching for <SignUp usage patterns ==="
rg -n "<SignUp\b" packages/nextjs/src --type ts -A2 | head -50
# Also check examples or tests that might use SignUp
echo "=== Checking for SignUp usage in examples/tests ==="
rg -n "SignUp" packages/nextjs/examples 2>/dev/null || echo "No examples directory or no matches"
# Check if ...rest is actually passed down and what callbacks it might contain
echo "=== Full context around line 75-77 where rest is extracted ==="
sed -n '70,95p' packages/nextjs/src/client/components/presentation/SignUp/SignUp.tsxRepository: asgardeo/javascript
Length of output: 285
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Search for actual <SignUp usage in the codebase
echo "=== Searching for <SignUp usage in source code ==="
rg -n "<SignUp\b" packages/nextjs/src -A3 | head -80
# Get the full function signature to see what rest contains
echo "=== Full function context around parameter destructuring ==="
sed -n '70,100p' packages/nextjs/src/client/components/presentation/SignUp/SignUp.tsx
# Check if there's documentation or types file
echo "=== Looking for type definitions in the file ==="
sed -n '1,40p' packages/nextjs/src/client/components/presentation/SignUp/SignUp.tsx
# Search for any usage of the excluded callbacks in the whole packages/nextjs directory
echo "=== Searching for onSuccess, onComplete, onInitialize, onSubmit with SignUp ==="
rg -n "(onSuccess|onComplete|onInitialize|onSubmit)" packages/nextjs/src --type ts | grep -i signup || echo "No matches found"Repository: asgardeo/javascript
Length of output: 3247
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Search for imports of SignUp from packages/nextjs
echo "=== Searching for imports of SignUp component ==="
rg -n "from.*SignUp" packages/nextjs/src --type ts | grep -v "BaseSignUp\|SignUpV2\|SignUpRenderProps" | head -20
# Search in example files
echo "=== Checking example/demo files ==="
find packages/nextjs -type f \( -name "*.tsx" -o -name "*.ts" \) -path "*/example*" -o -path "*/demo*" | head -20
# Check where SignUp is exported from
echo "=== Checking barrel exports ==="
rg -n "SignUp" packages/nextjs/src/client/components/index.ts || echo "Not found"
rg -n "SignUp" packages/nextjs/src/index.ts || echo "Not found"
# Get the full context where onInitialize and onSubmit are used
echo "=== Context around lines 134-135 where callbacks are passed ==="
sed -n '87,140p' packages/nextjs/src/client/components/presentation/SignUp/SignUp.tsx
# Look for handleOnSubmit definition
echo "=== Looking for handleOnSubmit definition ==="
rg -n "handleOnSubmit" packages/nextjs/src/client/components/presentation/SignUp/SignUp.tsx -B5 -A5Repository: asgardeo/javascript
Length of output: 3027
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Get the full JSDoc section for the SignUp component
echo "=== Full JSDoc/comments for SignUp component ==="
sed -n '39,70p' packages/nextjs/src/client/components/presentation/SignUp/SignUp.tsx
# Search for tests related to SignUp
echo "=== Searching for SignUp tests ==="
find packages/nextjs -type f \( -name "*.test.tsx" -o -name "*.test.ts" -o -name "*.spec.tsx" -o -name "*.spec.ts" \) | xargs grep -l "SignUp" 2>/dev/null || echo "No tests found mentioning SignUp"
# Check what callbacks BaseSignUp actually accepts by looking at imports/usage
echo "=== Full usage context of BaseSignUp ==="
sed -n '130,148p' packages/nextjs/src/client/components/presentation/SignUp/SignUp.tsx
# Check rest parameter - what's actually being passed
echo "=== Complete function parameters ==="
sed -n '73,78p' packages/nextjs/src/client/components/presentation/SignUp/SignUp.tsxRepository: asgardeo/javascript
Length of output: 1690
Fix JSDoc and restore type safety for children prop.
The JSDoc example documents onSuccess and onComplete callbacks (lines 49-57), but these are not exposed in SignUpProps nor implemented in the component—they're only shown in misleading documentation. The narrowed Pick<BaseSignUpProps, ...> appears intentional, as the component handles initialization and submission internally via hardcoded callbacks passed to BaseSignUp.
However, the any type for the children prop (lines 36, 126, 143) unnecessarily drops type safety. Use SignUpRenderProps instead:
Proposed fix
export type SignUpProps = Pick<BaseSignUpProps, 'className' | 'afterSignUpUrl' | 'onError' | 'variant' | 'size'> & {
- children?: (props: any) => ReactElement;
+ children?: (props: SignUpRenderProps) => ReactElement;
};Then remove the as any casts at lines 126 and 143:
- {children as any}
+ {children}The JSDoc example should also be corrected to remove onSuccess and onComplete callbacks, or those callbacks should be properly implemented and exposed if they are intended to be part of the public API.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| export type SignUpProps = Pick<BaseSignUpProps, 'className' | 'afterSignUpUrl' | 'onError' | 'variant' | 'size'> & { | |
| children?: (props: any) => ReactElement; | |
| }; | |
| export type SignUpProps = Pick<BaseSignUpProps, 'className' | 'afterSignUpUrl' | 'onError' | 'variant' | 'size'> & { | |
| children?: (props: SignUpRenderProps) => ReactElement; | |
| }; |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@packages/nextjs/src/client/components/presentation/SignUp/SignUp.tsx` around
lines 35 - 37, The SignUpProps type currently weakens children to any and the
JSDoc incorrectly documents onSuccess/onComplete; change the children signature
to children?: (props: SignUpRenderProps) => ReactElement (replacing any) in the
SignUpProps declaration, remove the two "as any" casts where children is passed
through (the casts currently masking the type mismatch), and update the
component JSDoc/example to remove onSuccess and onComplete (or alternatively
expose them via BaseSignUpProps if you intend them to be public) so the docs
match the actual public API.
Purpose
Add Thunder V2 (AsgardeoV2) platform support to the
@asgardeo/nextjsSDK, enabling Next.js applications to authenticate against Thunder instances.Key changes:
SignInandSignUpcomponents delegate to V2 variants (SignInV2,SignUpV2) whenplatform="AsgardeoV2"is configuredFlowMetaProviderfor V2 embedded authentication flowsenablePKCEis now conditionally enabled based on client type — public clients (noclientSecret) get PKCE auto-enabled, confidential clients keep it disabledNEXT_PUBLIC_ASGARDEO_PLATFORMenvironment variable for convenience configurationhandleOAuthCallbackActionnow correctly extracts error messages fromAsgardeoAuthException(which does not extendError)@asgardeo/nextjs/serverto@asgardeo/nextjs/middlewareRelated Issues
Related PRs
Checklist
Security checks
Summary by CodeRabbit
Release Notes
New Features
Bug Fixes