AI Draft
AI-assisted draft. Use this page as a quick map of the package, then harden anything important in the human guide.
Summary
Section titled “Summary”@lastshotlabs/slingshot-auth is Slingshot’s authentication and identity plugin. It owns the auth runtime, session and token flows, adapter bootstrap, route families for account and login behavior, and the security middleware that has to run early in the request pipeline.
This package is intentionally more than a route bundle. It is also the package that publishes auth-related boundary contracts back into core so the rest of the system can ask for userAuth, session-backed user resolution, rate limiting, fingerprinting, and built-in email templates without importing auth internals.
Main Responsibilities
Section titled “Main Responsibilities”- Boot the auth runtime from config, infrastructure, and security inputs.
- Mount register, login, account, session, refresh, MFA, magic-link, step-up, SAML, and optional OAuth routes.
- Provide built-in auth middleware such as
userAuth,requireRole, identify, bearer auth, CSRF, and MFA setup enforcement. - Register boundary adapters and templates into the core registrar during plugin setup.
- Expose lower-level helpers for custom flows, testing, and standalone use.
Package Shape
Section titled “Package Shape”The package has four main layers:
src/plugin.tscoordinates lifecycle phases and registrar publishing.src/bootstrap.tsassembles the runtime and adapter graph.src/lib/contains the reusable auth mechanics such as JWTs, sessions, OAuth helpers, fingerprinting, and email templating.src/routes/mounts the public route families only when the relevant features are enabled.
Typical Integration Story
Section titled “Typical Integration Story”In the full framework:
createAuthPlugin()validates config.setupMiddleware()bootstraps the runtime and registers auth capabilities with core.setupRoutes()mounts only the enabled route groups.setupPost()publishes user resolution and template state for other packages.
In standalone mode:
setup()runs middleware and route setup directly for plain Hono apps.- The caller must provide runtime pieces such as password and sqlite support through config.
Common Cross-Package Touch Points
Section titled “Common Cross-Package Touch Points”slingshot-corefor contracts and registries.slingshot-mailfor delivery of auth templates.slingshot-oauthfor optional OAuth route mounting when providers are configured.slingshot-admin,slingshot-m2m,slingshot-scim, and other packages that consume auth state or auth-owned contracts.
Reading Order
Section titled “Reading Order”src/plugin.tssrc/bootstrap.tssrc/types/config.tssrc/lib/session.tsandsrc/lib/jwt.tssrc/routes/
Good Follow-Ups
Section titled “Good Follow-Ups”- Use the human guide for the security and boundary invariants.
- Use the generated docs for the export inventory.
- Read
/api/slingshot-auth/when you need a specific helper or type name.