1.1.4 • Published 1 month ago

send-sms-otp v1.1.4

Weekly downloads
-
License
ISC
Repository
github
Last release
1 month ago

send-sms-otp

A simple package to streamline the process of sending SMS messages and managing OTP (One-Time Password) functionality. This package utilizes D7 Networks, so you'll need a valid token for authentication.

If otpLength is not included, the OTP code process will be ignored. However, you can still generate OTP codes by just providing the length, and it will be generated, saved, and managed automatically. The OTP code is saved in temporary memory for seamless verification.

Features

  • SMS Messaging: Effortlessly send SMS messages with customizable content.
  • OTP Generation and Verification: Generate OTP codes and verify them hassle-free.
  • Automatic Management: OTP codes are automatically generated, saved, and managed when otpLength is specified.
  • D7Networks Integration: Utilizes D7Networks for secure and reliable communication.
  • Easy Integration: The package offers an easy-to-use interface, ensuring a smooth and quick setup within your.

Installation

npm install send-sms-otp

Usage

import { sendMessage, verifyOTP } from "send-sms-otp";

// Sending SMS
sendMessage({
  token: "your-d7networks-token",
  phoneNumber: "+964123456789",
  otpLength: 4,
  message: "Hello world!",
  expiresIn: 5,
  environment: "development",
});

// Verifying OTP
verifyOTP("+964123456789", "1234", "development");

API

sendMessage(options)

Sends an SMS message to the specified phone number.

OptionDescriptionTypeDefaultExampleRequired
tokenD7Networks tokenstring-"your-d7networks-token"Yes
phoneNumberReceiver's mobile numberstring-"+964123456789"Yes
otpLengthLength of OTP code digitsnumber04No
messageMessage to be sentstringnull"Hello world!"No
expiresInOTP code lifetime in minutesnumber105No
environmentCoding environment for logs commentsstring"development""production"No

verifyOTP(phoneNumber, otpCode, environment)

Verifies the provided OTP code for the given phone number.

OptionDescriptionTypeExampleRequired
phoneNumberReceiver's mobile numberstring"+964123456789"Yes
otpCodeOTP code to be verifiedstring"1234"Yes
environmentCoding environment for logs informationstring"development"No

Feel free to contribute and report issues on GitHub.

Support

If you find this package helpful, consider buying me a coffee!

1.1.4

1 month ago

1.1.3

1 month ago

1.1.2

1 month ago

1.1.1

3 months ago

1.1.0

3 months ago

1.0.9

3 months ago

1.0.8

3 months ago

1.0.7

3 months ago

1.0.6

3 months ago

1.0.5

3 months ago

1.0.4

3 months ago

1.0.3

3 months ago

1.0.2

3 months ago

1.0.1

3 months ago

1.0.0

3 months ago