Skip to content

Add Device Grant flow Support - #140

Merged
brionmario merged 1 commit into
thunder-id:mainfrom
Yathusiga27:feature/device-grant
Oct 30, 2026
Merged

brionmario merged 1 commit into
thunder-id:mainfrom
Yathusiga27:feature/device-grant

Conversation

@Yathusiga27

@Yathusiga27 Yathusiga27 commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Purpose

Adds Device Grant verification, allowing users to enter a code from their device and complete the server-described authorization flow in the browser.

Approach

  • Adds a framework-agnostic Device Grant flow executor in @thunderid/javascript.
  • Renders server-described flow steps and supports prefilled verification codes.
  • Adds Device Grant stories to the playground.

Related Issues

Related PRs

  • N/A

Checklist

  • Followed the contribution guidelines.
  • Manual test round performed and verified.
  • Documentation provided. (Add links if there are any)
  • Tests provided. (Add links if there are any)
    • Unit Tests
    • Integration Tests
  • Breaking changes. (Fill if applicable)
    • Breaking changes section filled.
    • breaking change label added.
  • Cross-SDK parity. Exactly one of parity/prs-raised or parity/prs-not-needed added.
    • If parity/prs-raised, the port links are posted as a reply on the parity check's comment.

Security checks

  • Followed secure coding standards.
  • Confirmed that this PR doesn't commit any keys, passwords, tokens, usernames, or other secrets.

@coderabbitai

coderabbitai Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown

🔀 Cross-SDK feature parity

Does this change need to ship in the other ThunderID SDKs too? This check stays red until one of these labels answers that:

Label What it asserts
parity/prs-raised The ports exist in every other SDK this change reaches, or are recorded as not applying there.
parity/prs-not-needed Nothing to port: a fix, refactor, docs, CI, dependency bump, release, or a change specific to this platform.

Ports (DO NOT EDIT)

  • thunder-id/ios-sdks, iOS
  • thunder-id/android-sdks, Android
  • thunder-id/flutter-sdks, Flutter

No sibling SDKs accounted for on this thread yet.

Important

Reply to this comment with this block, filled in. The boxes above tick
themselves when you post it.

- thunder-id/ios-sdks: <paste the port link here>
- thunder-id/android-sdks: <paste the port link here>
- thunder-id/flutter-sdks: <paste the port link here>

A link can be a pull request or a tracked issue, written in full or as thunder-id/ios-sdks#123.
Where the change does not reach an SDK, replace the placeholder with N/A and a short
reason, as in - thunder-id/ios-sdks: N/A, the capability has no equivalent there.

The contract is in the SDK development specification.

@Yathusiga27
Yathusiga27 force-pushed the feature/device-grant branch 2 times, most recently from 488be89 to eca7963 Compare October 28, 2026 05:19
@Yathusiga27 Yathusiga27 changed the title Add Device Grant flow to React SDK Add Device Grant flow Oct 28, 2026
@Yathusiga27 Yathusiga27 changed the title Add Device Grant flow Add Device Grant flow Support Oct 28, 2026
}: DeviceGrantProps): ReactElement => {
const {applicationId, baseUrl, meta} = useThunderID();
const {t} = useTranslation(preferences?.i18n);
const userCodeComponents = useMemo<EmbeddedFlowComponent[]>(

@thiva-k thiva-k Oct 29, 2026 •

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.

The code prompt comes from the application's configured Device Grant flow and the server checks the code belongs to that application. Since the verification URI already carries the application id, shall we drop the SDK built code form and the start with only the user code? Same for Vue.

'flowType' in payload &&
payload.flowType === EmbeddedFlowType.DeviceGrant &&
'inputs' in payload &&
((typeof payload.applicationId === 'string' && payload.applicationId.trim().length > 0) ||

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.

Once the code only start is removed, lets make the application id required here and in the start payload type.

headers: HeadersInit | undefined,
allowAccessDenied: boolean,
): Promise<Record<string, unknown>> => {
const callbackUrl: string = new URL('/oauth2/auth/callback', endpoint).toString();

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.

This keeps only the origin for the callback URL, so a base URL with a path (e.g. behind a reverse proxy) breaks. Can't we reuse the callback handling in the sign in executor? It uses the base URL and already relays failures.

transition:
border-color 0.2s ease,
box-shadow 0.2s ease;
transition: border-color 0.2s ease;

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.

Why is the focus ring removed? This changes every text field in the SDK and removes the visible focus indicator. Lets revert this and the border radius change, they are unrelated to device grant.


/* Device Grant */
'deviceGrant.prompt.heading': 'Enter the code shown on your device',
'deviceGrant.prompt.description': 'Enter the verification code to continue.',

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.

deviceGrant.prompt.description and deviceGrant.errors.start aren't used anywhere. The prompt keys also go away once the SDK built form is removed. Check other locales too.

Signed-off-by: Yathusiga27 <yathu2708@gmail.com>
@brionmario brionmario added the parity/prs-pending Porting in the other SDKs are still pending and issues are created label Oct 30, 2026
@brionmario
brionmario merged commit 4d64803 into thunder-id:main Oct 30, 2026
6 of 8 checks passed
@brionmario

Copy link
Copy Markdown
Member

@Yathusiga27 Lets link the parity PRs once you have them ready.

lashinijay pushed a commit to lashinijay/thunderid that referenced this pull request Oct 30, 2026
Moves @thunderid/react to 1.11.1 and @thunderid/react-router to 1.10.1
(@thunderid/browser 1.9.1 and @thunderid/javascript 1.10.1 follow
transitively). These releases post the SSO sessions a flow's responses
return on the authorization callback (thunder-id/javascript-sdks#147), so a
sign-in through the Gate that asks for the device_sso scope now receives a
device secret (thunder-id#6227). They also bring Device Grant support
(thunder-id/javascript-sdks#140), an ouId prop on GroupMembers
(thunder-id/javascript-sdks#146), and granted permissions read from the
backend session in backend mode (thunder-id/javascript-sdks#148).

Refs thunder-id#6144

Signed-off-by: ImalshaD <plid475@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

parity/prs-pending Porting in the other SDKs are still pending and issues are created

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants