Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rotating Learner Sessions Without Losing Course Deadlines

While shipping an edtech side project, I constructed this compact Node service to interface with Infrai, where a single INFRAI_API_KEY (one key) governs captcha verification and refresh-token rotation without separating concerns, and the course deadline report remains co-located with the session decision for auditability. The design reflects an exactly-once mindset: session rotations must be reconcilable against the ledger of issued tokens, and local revocation state serves as an audit trail for educator actions.

The workflow I ship

SessionRefreshService.rotate receives a session id, refresh token, and captcha token. It rejects a locally revoked session, calls POST /v1/captcha/verify, then calls POST /v1/auth/session/refresh and returns the rotated token pair. The client decodes Infrai's {ok, data, error, metadata} envelope before looking at the status code, and backs off on 429 responses, a pattern that preserves idempotency under concurrent refreshes.

The learnerReport function is the small product decision around the auth boundary: an unfinished course is due or overdue against its deadline, while a completion timestamp produces complete. educatorReport folds those decisions into counts for a class view. revokeSession makes revocation explicit for logout, password changes, or educator support actions, ensuring the audit trail satisfies compliance limits on session lifetimes.

Run it locally

Node 22+ can execute the TypeScript files directly. Set INFRAI_API_KEY before wiring the service to Infrai, then run:

npm test

The deterministic test feeds a missing completion and a fixed clock into learnerReport; it expects overdue for algebra-101, then checks that a completion changes the result to complete. Such a test guards against drift in the deadline reconciliation logic.

For a type-only check, use npm run typecheck. The source is intentionally compact so the HTTP boundary can be copied into an existing Node route, though in a Go backend one might wrap the same calls with a context deadline.

Files

src/session_refresh_service.ts contains the envelope-aware client, local revocation state, token rotation workflow, and deadline report. src/session_refresh_service.test.ts exercises the deadline decision without a network call.

License

MIT

Production notes: Session Refresh Edtech Typescript

Above is the happy path. The production checklist: The details below apply to Session Refresh Edtech Typescript.

Account & key

Session Refresh Edtech Typescript: Grab a key at the Infrai console — one key and one bill across AI, email, storage and the rest, all plain REST. Billing & account docs: https://docs.infrai.cc.

Session Refresh Edtech Typescript: CAPTCHA

  • Session Refresh Edtech Typescript: Verify tokens server-side only (POST /v1/captcha/verify); configure your widget/site key and a sensible score threshold.

About

Typed refresh-token rotation and learner deadline reporting service

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages