Repository navigation
PHR-4064 Add Login with Descope to the TypeScript sample app - #231
Conversation
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.
There was a problem hiding this comment.
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
Edit Gecko PR Settings | Reviewed commit: ea5cc98
… flatten sign-in handling
There was a problem hiding this comment.
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
authenticatethunk's newdescopeTokensbranch. The tokens are not returned into persisted Redux state, and the memory-onlyAuthProviderstorage writes no cookies or localStorage. authenticateSdkWithTokens. TheInvalidTokenErroris 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/bootstrapcall (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
left a comment
There was a problem hiding this comment.
Nice!
NIT: A screenshot/demo in the PR description showing it working would be great next time.
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_IDandVITE_DESCOPE_AUTH_DOMAINare optional fallbacks.src/sdk/bWellSdk.ts:authenticateSdkWithTokenspasses the Descope session token tosetAuthTokensas both the access and ID token.src/store/userSlice.ts:authenticateaccepts 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.jsonand 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
InvalidTokenErrorbecause 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 --noEmitpasses.Notes for reviewers
/admin/bootstrapendpoint, which is not documented for external use. If that is a concern for a public sample, theVITE_DESCOPE_*fallbacks still work without it.setAuthTokens) would be a separate SDK change.Testing steps