How perseidesjs/auth-otp works
Project type and purpose
• This is a Medusa 2.x plugin written in TypeScript that adds OTP (One-Time Password)–based authentication to a Medusa backend.
• The README and file structure confirm it’s a backend-only plugin, exposing HTTP routes under src/api and encapsulating OTP generation and verification workflows.
File structure
• Top-level files:
• .github, CI/CD workflows, package.json, tsconfig.json – typical for an NPM package.
• src/ – main code.
• integration-tests/ – automated tests.
• Under src/:
• api/ – HTTP route definitions for OTP operations: generate, pre-register, verify.
• providers/otp/ – abstraction and implementation of the OTP service (e.g. sending SMS or email).
• workflows/ – business logic orchestrating multiple steps: fetching actors, validating, storing, sending OTP, verifying.
• utils/ and types/ – shared helpers and TypeScript types.
• middlewares.ts – Express-style middleware for Medusa routes.
• No “frontend” or UI code – it plugs into the Medusa server process.
README for additional insights
• Confirms plugin purpose: “Implement seamlessly OTP-based authentication for Medusa 2.x.”
Detail without overthinking
• Break out every folder as a component if it clarifies responsibilities (e.g., separate “Validators” under Middleware).
• Both “happy path” and error/validation flows if space permits.