Skip to content

PHR-4064 Add Login with Descope to the TypeScript sample app - #231

Merged
SakshamTyagii merged 2 commits into
mainfrom
TS-PHR-4064
Nov 16, 2026
Merged

SakshamTyagii merged 2 commits into
mainfrom
TS-PHR-4064

Conversation

@tschneit717

@tschneit717 tschneit717 commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor
Screen.Recording.2026-11-13.at.4.37.24.PM.mov

Jira: PHR-4064 (unblocks PHR-3955)

What

Adds a "Login with Descope" email and password form to the TypeScript React sample app, for clients that use Descope as their identity provider. The existing SDK username and password login only works for clients still on Cognito, so it is relabeled "Login with Cognito" (element IDs unchanged, so the e2e tests are unaffected).

  • src/components/DescopeLogin.tsx (new): email and password form that signs in with @descope/react-sdk. Renders only when a Descope project is known. Tokens stay in memory (no cookies or storage).
  • src/sdk/clientRecord.ts (new): reads the Descope project and auth domain from the client's identity provider configuration (the identity gateway bootstrap record) using the client key, with a 10 second timeout. VITE_DESCOPE_PROJECT_ID and VITE_DESCOPE_AUTH_DOMAIN are optional fallbacks.
  • src/sdk/bWellSdk.ts: authenticateSdkWithTokens passes the Descope session token to setAuthTokens as both the access and ID token.
  • src/store/userSlice.ts: authenticate accepts the Descope tokens as a new branch and never stores them in persisted state.
  • src/pages/Initialize.tsx: renders the form and renames the Cognito login.
  • package.json and lockfile: adds @descope/react-sdk.

Refresh token

Descope keeps the refresh token in an HttpOnly cookie, so a browser only gets the session token. SDK v1 accepts that. SDK v2 (the version this sample uses) finishes installing the session and then reports InvalidTokenError because there is no refresh token, so the sample treats that one error as success when no refresh token was supplied. The same code works on v1 and v2. When the session token expires the user signs in again.

Verification

  • tsc --noEmit passes.
  • I confirmed on the installed v2 beta, with a stubbed network, that the SDK sends authorized requests after that error.
  • Not yet verified end to end against a real Descope client: that the graph accepts the Descope session token and returns data (for example on the Conditions page). That is why this is a draft.
  • No tests were run or added.

Notes for reviewers

  • The sample calls the identity gateway's /admin/bootstrap endpoint, which is not documented for external use. If that is a concern for a public sample, the VITE_DESCOPE_* fallbacks still work without it.
  • A proper v2 fix (accepting a missing refresh token in setAuthTokens) would be a separate SDK change.

Testing steps

  1. log in using the wellsense key in dev: eyJyIjoiM3R5MHc2aTFmNzZvbzA5YzViIiwiZW52IjoiZGV2Iiwia2lkIjoid2VsbHNlbnNlLWRldiJ9
  2. scroll down to the log in with user, use the account: lakshya.jindal+vanessa@bwell.com / Password@1
  3. Verify the log in text appears, and navigate to a category and confirm data is showing

Add an email and password sign-in for clients that use Descope. The Descope
project and auth domain are read from the client's identity provider
configuration using the client key, with optional VITE_DESCOPE_* fallbacks.
The Descope session token is passed to the SDK with setAuthTokens, and tokens
stay in memory only.

Descope keeps the refresh token in an HttpOnly cookie, so browsers have only
the session token. SDK v2 reports InvalidTokenError after installing the
session when there is no refresh token, so that one error is treated as
success when no refresh token was supplied. The same code works on SDK v1.

Relabel the existing username and password login as Login with Cognito.

@gecko-security gecko-security Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gecko PR Review

No vulnerabilities found, LGTM.

Summary

This PR adds Descope-based "Login with Descope" to the bWell TypeScript React example app. bwell-typescript-react/.env.example introduces VITE_DESCOPE_PROJECT_ID and VITE_DESCOPE_AUTH_DOMAIN, and bwell-typescript-react/package-lock.json adds @descope/react-sdk ^2.30.10 with its transitive Descope and Redux packages. The wiki context is empty and the diff is truncated, so the review is limited to these visible changes. The login component, SDK, store, and page files are changed but their diffs were not provided, so their behavior is unverified.

Important Files Changed

4 important files out of 8 changed

File Path Why it matters
bwell-typescript-react/package-lock.json It adds a new auth SDK (@descope/react-sdk 2.30.10) and a large set of transitive @descope/* packages, so the new dependency tree needs supply-chain and integrity review before merge.
bwell-typescript-react/.env.example It adds VITE_DESCOPE_PROJECT_ID and VITE_DESCOPE_AUTH_DOMAIN, and because Vite inlines VITE_-prefixed variables into the client bundle, these values are public and must never hold secrets.
bwell-typescript-react/src/components/DescopeLogin.tsx As the new "Login with Descope" entry point, it should be checked for how the project ID and auth domain are read and how the resulting session or token is handled, though its diff was not provided.
bwell-typescript-react/src/sdk/bWellSdk.ts Because it is the bWell SDK integration point, any change to how Descope-issued credentials flow into it should be verified to avoid exposing or mis-scoping tokens, though its diff was not provided.

Omitted 4 lower-signal changed files.

Sequence Diagram

sequenceDiagram
  participant Reviewer
  participant PR as Changed Files
  Reviewer->>PR: Inspect changed files and control flow
  Reviewer->>Reviewer: Validate security assumptions
Loading

Edit Gecko PR Settings | Reviewed commit: ea5cc98

@tschneit717
tschneit717 marked this pull request as ready for review November 13, 2026 20:21
@tschneit717
tschneit717 requested review from a team as code owners November 13, 2026 20:21

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reviewed this PR and didn't find any bugs. It adds a new login path and a new third-party auth dependency, and it treats an SDK auth error as success, so a human look would still be worthwhile, especially since it's a draft that hasn't been tested end to end.

What was reviewed:

  • The authenticate thunk's new descopeTokens branch. The tokens are not returned into persisted Redux state, and the memory-only AuthProvider storage writes no cookies or localStorage.
  • authenticateSdkWithTokens. The InvalidTokenError is ignored only when no refresh token was given. Whether that's acceptable depends on SDK v2 behaviour, which someone should confirm.
  • clientRecord.ts: how the gateway URL is built from the client key's env, the 10s timeout, and the undocumented /admin/bootstrap call (the PR already flags this).
  • Ruled out: the form staying stale after switching to a Cognito client in DescopeLogin.tsx. On investigation this did not hold up as a bug.
Extended reasoning...

The change adds Descope email/password login to the TypeScript React sample app: a new component, a bootstrap-config fetch, a token handoff to setAuthTokens, a new thunk branch, and the @ descope/react-sdk dependency with about 300 lockfile lines. That puts it on authentication, since it handles session JWTs and sends the client key to an identity gateway endpoint. It also deliberately turns an InvalidTokenError failure into success, a design choice that depends on SDK version behaviour. The author says it is a draft with no end-to-end verification and no tests. A security bot left a COMMENTED review whose content isn't visible here, so approval isn't appropriate.

This review covers commit ea5cc98, which is no longer the latest commit on this pull request; later commits are not covered by it.

@kblestarge kblestarge left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!
NIT: A screenshot/demo in the PR description showing it working would be great next time.

@SakshamTyagii SakshamTyagii left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

approved

@SakshamTyagii
SakshamTyagii merged commit 1dabd6d into main Nov 16, 2026
2 checks passed
@SakshamTyagii
SakshamTyagii deleted the TS-PHR-4064 branch November 16, 2026 16:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants