Skip to content

About

Zero-dependency SMART on FHIR standalone-launch demo app with PKCE, state validation, and an offline mock EHR for full-flow testing

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

smart-launch

A zero-dependency SMART on FHIR standalone-launch demo app. One command starts both the app and an in-process mock EHR, so the complete OAuth2 + PKCE flow runs offline: authorize redirect, state validation, code exchange, patient-context FHIR calls, and a rendered clinical summary.

What it demonstrates

  • SMART standalone launch against any R4 server with SMART discovery (.well-known/smart-configuration)
  • PKCE (RFC 7636, S256) on every authorization code, verified end to end
  • state parameter validation that blocks login CSRF
  • Authorization codes are single-use; replays are rejected
  • Tokens live in memory only, sessions in an HttpOnly cookie, nothing logged
  • SMART v2 scopes (patient/Patient.rs, patient/Observation.rs, ...)
  • Real error states: cancelled launch, failed patient fetch, unknown routes

Run (mock mode, zero setup)

Requires Node.js 23.6+. No dependencies, no build step.

node src/app.ts
# smart-launch running in mock mode at http://127.0.0.1:8410
# mock EHR (FHIR ISS): http://127.0.0.1:<ephemeral>/mock/fhir

Open the printed URL, click "Launch against the EHR", and walk the whole flow.

Run against a real SMART server

export SMART_MODE=real
export SMART_ISS=https://your-fhir-server/r4
export SMART_CLIENT_ID=my-client
export SMART_CLIENT_SECRET=...            # confidential clients only
export SMART_REDIRECT_URI=http://localhost:8410/callback
node src/app.ts

Works with any server that supports standalone launch and PKCE (public HAPI FHIR sandboxes, SMART health-it launch environments, hospital test environments).

Tests

node --test

Six end-to-end tests drive real HTTP sockets against the mock EHR, including the negative paths (forged state, code replay, no-session access).

Why this exists

Most SMART samples hide the flow inside a SDK. This one spells it out with plain fetch and node:http, which makes it a readable reference for implementing SMART launches against hospital FHIR endpoints, and a sandbox for testing the edge cases that matter in clinical settings.

License

MIT

About

Zero-dependency SMART on FHIR standalone-launch demo app with PKCE, state validation, and an offline mock EHR for full-flow testing

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages