gmobile-voice-otp
TypeScript icon, indicating that this package has built-in type declarations

0.1.2 • Public • Published

Send Gmobile OTP

Basic use

const client = new GmobileVoiceOTPClient(baseURL, privateKey, publicKey, userCode);

// random id
const transId = v4();
const res = await client.createVoiceOTP({
    callee: '0987654321',
    otp: '123456',
    transId,
});

Generate signature and verify

const client = new GmobileVoiceOTPClient(baseURL, privateKey, publicKey, userCode);

const input = 'callee=0975096810&trans_id=235123511261236&otp=123456'
const signature = client.createSignature(input);

const verify = client.verifySignature(input, signature); // return true/false

How to create private key

ssh-keygen -b 2048 -m PEM -N '' -f ./key

then convert public key key.pub to PKCS8 format

ssh-keygen -f key.pub -e -m PKCS8 > ./key.pubx

provide generated public key to Gmobile

Features

  • [x] Generate signature
  • [x] Verify signature
  • [x] Send Voice OTP
  • [x] Get detail of task

And coming up

  • [ ] Get balance
  • [ ] Verify callback api

Development and testing

cp test/sandbox.tmp.ts test/sandbox.ts

Update private key, public key, then run commands to test

npm run test

Package Sidebar

Install

npm i gmobile-voice-otp

Weekly Downloads

3

Version

0.1.2

License

MIT

Unpacked Size

19.2 kB

Total Files

9

Last publish

Collaborators

  • trucdev