npm.io
1.1.6 • Published 3 years ago

sms-auth

Licence
MIT
Version
1.1.6
Deps
1
Size
9 kB
Vulns
0
Weekly
0
Stars
1

Sms Send AuthCode

npm download GitHub Hits

Note: This package supports only Verimor Sms service.

Table of contents

Install

From npm source

npm install sms-auth

From github

npm install https://github.com/miajupiter/sms-auth.git

API Functions

Send Authentication Code
const sms=require('sms-auth')

const messageTemplate='This is your auth code:{authCode}'
const username='' // sms service username
const password='' // sms service password
const recipient='target phone number'

sms.sendAuthCode(username, password, recipient, messageTemplate)
  .then(resp=>console.log(resp))
  .catch(err=>console.error(err))

Output:

// Random generated auth code sent to target phone number
474639  
Send SMS
const sms=require('sms-auth')

sms.sendSms({
    url:'https://sms.verimor.com.tr/v2/send.json',
    method:'POST',
    data:{
      username: '',
      password: '',
      messages:[{
        msg:'Hello, world.',dest:'<phone number>'
      }]
    }
  })
  .then(resp=>console.log(resp))
  .catch(err=>console.error(err))

Output:

HttpStatus: 200 OK

{ status: 200, data: 318438489 }
Generating auth code
const sms=require('sms-auth')

const authCode = sms.generateAuthCode()

console.log(authCode)

Output:

// Generate auth code
474639
Is valid phone number?
const sms=require('sms-auth')

const phoneNumber = '101111111111'

console.log(`Is '${phoneNumber}' valid phone number?\nResult:`, sms.validPhoneNumber())

Output:

Is '101111111111' valid phone number?

Result: false

License - MIT License

Copyright (c) 2023-Now MiaJupiter Technology Inc.. All rights reserved. We are proud to be Open Source. For full details about the license, please check the LICENSE file in the root directory of the source repository.

Keywords