Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

@lendi/auth

Package Overview
Dependencies
Maintainers
77
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

@lendi/auth

A reusable authentication package that handles OTP (One-Time Password) functionality using Auth0 and Twilio

latest
npmnpm
Version
0.0.9
Version published
Maintainers
77
Created
Source

@lendi/auth

A reusable authentication package that handles OTP (One-Time Password) functionality using Auth0 and Twilio.

Features

  • Send authentication codes via SMS
  • Verify codes with additional user data
  • Session management and error handling
  • Brand/type/environment-based Auth0 config (matches lala-react)

Installation

yarn add @lendi/auth

Usage

import { AuthService } from '@lendi/auth';

// 1. Initialize the service with your brand, type, and environment
const auth = new AuthService({
  brand: 'Aussie',
  type: 'Customer',
  environment: 'Development',
  // Optionally override:
  // audience, scope, redirectUri, retry, debug
});

// 2. Send authentication code
await auth.sendCode({ phoneNumber: '+61412345678' });

// 3. Verify code (with optional user data)
const result = await auth.verifyCode({
  phone: '+61412345678',
  code: '123456',
  email: 'john@example.com',    // Optional
  firstName: 'John',            // Optional
  leadId: 'lead-123'            // Optional
});
if (result.valid) {
  console.log('Authentication successful!');
  console.log('Token:', result.token);
}

// 4. Check authentication status and token
const status = auth.getStatus();
const token = auth.getToken();

// 5. Logout
auth.logout();
  • The correct clientID, domain, audience, and redirectUri will be set automatically based on your brand, type, and environment.
  • You can override any value if needed.

Auth0 Config Mapping

Auth0 configuration (clientID, domain, audience, callback URL) is automatically mapped based on the brand, type, and environment you provide. You do not need to manually specify these values unless you want to override them for a specific use case.

API

  • sendCode({ phoneNumber })
  • verifyCode({ phone, code, email?, leadId?, firstName? })
  • getToken()
  • getStatus()
  • logout()
  • getSessionState()

getSessionState()

Returns an object with the current session state, including:

{
  brand: Brand;
  type: Type;
  environment: Environment;
  status: AuthStatus;
  error?: AuthError;
  expiry?: number;
  token?: string;
  identity?: {
    id: string;
    existingUser?: boolean;
    authId?: string;
  };
}

Session Storage

  • Uses lendi_auth (session state) and lendi_me (user info) keys in sessionStorage.
  • The session state structure matches the original implementation, with version as a string, correct identity fields, and no ownerId or storeId.
  • User info (lendi_me) includes { firstName, phone, email, version }.

License

LENDI

FAQs

Package last updated on 19 Jun 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts