@perseidesjs/auth-otp enables OTP (One-Time Password) authentication in your Medusa applications, enhancing security and providing an alternative to traditional password-based authentication.

Prerequisites

Before using the plugin, ensure you have:

  • Medusa v2.3.0 or later (plugins were introduced in this version)
  • A Medusa application already set up and running
  • An NPM token from Perseides (provided after purchase), you can buy a license “here”

Understanding Auth-OTP

Traditional password-based authentication has several limitations:

  • Users forget passwords
  • Password reuse leads to security vulnerabilities
  • Account recovery processes can be cumbersome

OTP authentication generates a unique, time-limited code for each authentication attempt. This plugin implements OTP functionality through well-defined workflows within the Medusa framework, enabling passwordless authentication flows.

Setting Up Your NPM Token

The @perseidesjs/auth-otp plugin is a private package, requiring special access configuration. Create or update the .yarnrc.yml file in your project’s root directory:

nodeLinker: node-modules

npmScopes:
  perseidesjs:
    npmRegistryServer: "https://registry.npmjs.org"
    npmAuthToken: ${NPM_TOKEN}

Replace ${NPM_TOKEN} with the actual token provided to you after purchase.

Never share your NPM token with anyone, it’s a private key and should be treated as such.

Installation

With our token configured, we can now install the plugin:

yarn add @perseidesjs/auth-otp

Add the plugin to your Medusa application in the medusa-config.ts file:

import { loadEnv, defineConfig } from '@medusajs/framework/utils'

loadEnv(process.env.NODE_ENV || 'development', process.cwd())

module.exports = defineConfig({
  plugins: [
    "@perseidesjs/auth-otp"
  ],
  // ... other configuration
})

Next Steps

Ready to use the plugin? Let’s dive into the “Basic usage”.