Skip to content

miajupiter/sms-auth

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.