diff --git a/src/App.test.tsx b/src/App.test.tsx
index c66164fe6..432a2c71f 100644
--- a/src/App.test.tsx
+++ b/src/App.test.tsx
@@ -173,6 +173,28 @@ describe('App component', () => {
);
});
+ test('that send_session_token search param enables sendSessionToken', async () => {
+ window.location.pathname = `/${packageJson.homepage}/${validProjectId}`;
+ window.location.search = `?flow=${flowId}&send_session_token=true`;
+ render();
+ await waitFor(() =>
+ expect(mockDescope).toHaveBeenCalledWith(
+ expect.objectContaining({ flowId, sendSessionToken: true })
+ )
+ );
+ });
+
+ test('that sendSessionToken is off by default', async () => {
+ window.location.pathname = `/${packageJson.homepage}/${validProjectId}`;
+ window.location.search = `?flow=${flowId}`;
+ render();
+ await waitFor(() =>
+ expect(mockDescope).toHaveBeenCalledWith(
+ expect.objectContaining({ flowId, sendSessionToken: undefined })
+ )
+ );
+ });
+
test('sets the document title from the title search param', async () => {
window.location.pathname = `/${packageJson.homepage}/${validProjectId}`;
window.location.search = `?title=My%20Custom%20Title`;
diff --git a/src/App.tsx b/src/App.tsx
index b22fcaa3d..c00f4f890 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -219,6 +219,14 @@ const App = () => {
? false
: undefined;
+ // opt-in: send the current session JWT on flow start/next requests, exposing
+ // its validated claims to the flow via the sessionJwtClaims context key
+ const sendSessionToken =
+ urlParams.get('send_session_token') === 'true' ||
+ env.DESCOPE_SEND_SESSION_TOKEN === 'true'
+ ? true
+ : undefined;
+
const theme = (urlParams.get('theme') ||
env.DESCOPE_FLOW_THEME) as React.ComponentProps['theme'];
@@ -289,6 +297,7 @@ const App = () => {
const flowProps = {
flowId,
debug,
+ sendSessionToken,
locale,
tenant: tenantId,
theme,