Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/App.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(<App />);
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(<App />);
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`;
Expand Down
9 changes: 9 additions & 0 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<typeof Descope>['theme'];

Expand Down Expand Up @@ -289,6 +297,7 @@ const App = () => {
const flowProps = {
flowId,
debug,
sendSessionToken,
locale,
tenant: tenantId,
theme,
Expand Down