Repository navigation
Post the flow's SSO sessions on the authorization callback #147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
brionmario
merged 1 commit into
thunder-id:main
from
ImalshaD:post-session-data-on-callback
Oct 30, 2026
+272
−5
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| // Copyright 2026 The ThunderID Authors | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| import {EmbeddedFlowSessionData} from '../../models/embedded-flow'; | ||
|
|
||
| /** | ||
| * The part of a flow step response that reports SSO sessions. | ||
| */ | ||
| interface FlowSessionUpdate { | ||
| clearedSessions?: string[]; | ||
| sessionData?: EmbeddedFlowSessionData[]; | ||
| } | ||
|
|
||
| // The SSO sessions each authorization request's flow responses returned, held in memory until the | ||
| // callback posts them. A session can start on any step, not only the last, so every response is read. | ||
| // They are never persisted, so a reload in the middle of the flow drops them. | ||
| const collectedSessions = new Map<string, Map<string, EmbeddedFlowSessionData>>(); | ||
|
|
||
| /** | ||
| * Holds the sessions a flow step started under its authorization request, and drops the ones it ended. | ||
| */ | ||
| export const collectFlowSessions = (authId: string, step: FlowSessionUpdate): void => { | ||
| if (!step.sessionData?.length && !step.clearedSessions?.length) { | ||
| return; | ||
| } | ||
| const held: Map<string, EmbeddedFlowSessionData> = | ||
| collectedSessions.get(authId) ?? new Map<string, EmbeddedFlowSessionData>(); | ||
| step.sessionData?.forEach(({flowIdentifier, sessionHandle}: EmbeddedFlowSessionData) => { | ||
| held.set(flowIdentifier, {flowIdentifier, sessionHandle}); | ||
| }); | ||
| step.clearedSessions?.forEach((flowIdentifier: string) => held.delete(flowIdentifier)); | ||
| collectedSessions.set(authId, held); | ||
| }; | ||
|
|
||
| /** | ||
| * Returns the sessions held for an authorization request and forgets them. | ||
| */ | ||
| export const takeFlowSessions = (authId: string): EmbeddedFlowSessionData[] => { | ||
| const held: Map<string, EmbeddedFlowSessionData> | undefined = collectedSessions.get(authId); | ||
| collectedSessions.delete(authId); | ||
|
|
||
| return held ? [...held.values()] : []; | ||
| }; | ||
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
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
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@coderabbitai Check whether this can cause any issues when the code is run on a SSR app.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Length of output: 5677
🏁 Script executed:
Length of output: 54630
🏁 Script executed:
Length of output: 18676
@brionmarioYes—if the embedded flow runs on the server withauthId, this module-levelMapcan cause issues. Importing the module during SSR does not itself cause a browser-API error.I checked the collection logic and both flow executors.
flowSessions.ts, Line 17, theMapbelongs to the loaded module, not an HTTP request or SDK client. All requests in that server instance share it. DistinctauthIdvalues separate entries, but the key has no server or tenant namespace. This alone does not prove cross-user leakage.takeFlowSessions(). Abandoned flows and some error paths leave session handles in memory without expiry or a size limit. A browser reload does not clear the server’s map, despite the comment at Line 16.There is also a retry issue that is not specific to SSR: both executors call
takeFlowSessions()before the callback succeeds. If the callback fails, the collected sessions have already been deleted.Current Nuxt behavior: the inspected server-side
signIn()call inpackages/nuxt/src/runtime/server/ThunderIDNuxtClient.ts, Line 121, does not passauthId. That path does not populate this map. The exported core APIs still permit server callers to passauthId.Recommendation: make the collection explicit and scoped to the authorization flow. If flows span server requests or instances, use a protected server-side store with tenant/server namespacing, expiry, and terminal cleanup. A request-local map alone will not preserve a multi-request flow. If collection is intended only for browser execution, enforce that boundary explicitly.
This assessment is based on source inspection. I did not run runtime tests.
You are interacting with an AI system.