feat: Vonage API
This commit is contained in:
parent
84ceeda611
commit
3b19caf3a7
8 changed files with 1116 additions and 71 deletions
|
|
@ -49,6 +49,7 @@ const ALL_ACCOUNTS = [
|
||||||
{ code: 'mock-id-verify', display: 'Mock ID verifier', class: ID_VERIFIER, dev: true },
|
{ code: 'mock-id-verify', display: 'Mock ID verifier', class: ID_VERIFIER, dev: true },
|
||||||
{ code: 'twilio', display: 'Twilio', class: SMS },
|
{ code: 'twilio', display: 'Twilio', class: SMS },
|
||||||
{ code: 'telnyx', display: 'Telnyx', class: SMS },
|
{ code: 'telnyx', display: 'Telnyx', class: SMS },
|
||||||
|
{ code: 'vonage', display: 'Vonage', class: SMS },
|
||||||
{ code: 'mailgun', display: 'Mailgun', class: EMAIL },
|
{ code: 'mailgun', display: 'Mailgun', class: EMAIL },
|
||||||
{ code: 'none', display: 'None', class: ZERO_CONF, cryptos: ALL_CRYPTOS },
|
{ code: 'none', display: 'None', class: ZERO_CONF, cryptos: ALL_CRYPTOS },
|
||||||
{ code: 'blockcypher', display: 'Blockcypher', class: ZERO_CONF, cryptos: [BTC] },
|
{ code: 'blockcypher', display: 'Blockcypher', class: ZERO_CONF, cryptos: [BTC] },
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,8 @@ const SECRET_FIELDS = [
|
||||||
'cex.privateKey',
|
'cex.privateKey',
|
||||||
'binance.privateKey',
|
'binance.privateKey',
|
||||||
'twilio.authToken',
|
'twilio.authToken',
|
||||||
'telnyx.apiKey'
|
'telnyx.apiKey',
|
||||||
|
'vonage.apiSecret'
|
||||||
]
|
]
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
31
lib/plugins/sms/vonage/vonage.js
Normal file
31
lib/plugins/sms/vonage/vonage.js
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
const { Auth } = require('@vonage/auth')
|
||||||
|
const { SMS } = require('@vonage/sms')
|
||||||
|
|
||||||
|
const NAME = 'Vonage'
|
||||||
|
|
||||||
|
function sendMessage (account, rec) {
|
||||||
|
const credentials = new Auth({
|
||||||
|
apiKey: account.apiKey,
|
||||||
|
apiSecret: account.apiSecret
|
||||||
|
})
|
||||||
|
|
||||||
|
const from = account.fromNumber
|
||||||
|
const text = rec.sms.body
|
||||||
|
const to = rec.sms.toNumber || account.toNumber
|
||||||
|
|
||||||
|
const smsClient = new SMS(credentials)
|
||||||
|
smsClient.send({ from, text, to })
|
||||||
|
.catch(err => {
|
||||||
|
throw new Error(`Vonage error: ${err.message}`)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function getLookup () {
|
||||||
|
throw new Error('Vonage error: lookup not supported')
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
NAME,
|
||||||
|
sendMessage,
|
||||||
|
getLookup
|
||||||
|
}
|
||||||
|
|
@ -11,6 +11,7 @@ import kraken from './kraken'
|
||||||
import mailgun from './mailgun'
|
import mailgun from './mailgun'
|
||||||
import telnyx from './telnyx'
|
import telnyx from './telnyx'
|
||||||
import twilio from './twilio'
|
import twilio from './twilio'
|
||||||
|
import vonage from './vonage'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
[bitgo.code]: bitgo,
|
[bitgo.code]: bitgo,
|
||||||
|
|
@ -21,6 +22,7 @@ export default {
|
||||||
[kraken.code]: kraken,
|
[kraken.code]: kraken,
|
||||||
[mailgun.code]: mailgun,
|
[mailgun.code]: mailgun,
|
||||||
[telnyx.code]: telnyx,
|
[telnyx.code]: telnyx,
|
||||||
|
[vonage.code]: vonage,
|
||||||
[twilio.code]: twilio,
|
[twilio.code]: twilio,
|
||||||
[binanceus.code]: binanceus,
|
[binanceus.code]: binanceus,
|
||||||
[cex.code]: cex,
|
[cex.code]: cex,
|
||||||
|
|
|
||||||
52
new-lamassu-admin/src/pages/Services/schemas/vonage.js
Normal file
52
new-lamassu-admin/src/pages/Services/schemas/vonage.js
Normal file
|
|
@ -0,0 +1,52 @@
|
||||||
|
import * as Yup from 'yup'
|
||||||
|
|
||||||
|
import SecretInputFormik from 'src/components/inputs/formik/SecretInput'
|
||||||
|
import TextInputFormik from 'src/components/inputs/formik/TextInput'
|
||||||
|
|
||||||
|
import { secretTest } from './helper'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
code: 'vonage',
|
||||||
|
name: 'Vonage',
|
||||||
|
title: 'Vonage (SMS)',
|
||||||
|
elements: [
|
||||||
|
{
|
||||||
|
code: 'apiKey',
|
||||||
|
display: 'API Key',
|
||||||
|
component: TextInputFormik
|
||||||
|
},
|
||||||
|
{
|
||||||
|
code: 'apiSecret',
|
||||||
|
display: 'API Secret',
|
||||||
|
component: SecretInputFormik
|
||||||
|
},
|
||||||
|
{
|
||||||
|
code: 'fromNumber',
|
||||||
|
display: 'Vonage Number (international format)',
|
||||||
|
component: TextInputFormik,
|
||||||
|
face: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
code: 'toNumber',
|
||||||
|
display: 'Notifications Number (international format)',
|
||||||
|
component: TextInputFormik,
|
||||||
|
face: true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
getValidationSchema: account => {
|
||||||
|
return Yup.object().shape({
|
||||||
|
apiKey: Yup.string('The API key must be a string')
|
||||||
|
.max(200, 'The API key is too long')
|
||||||
|
.required('The Vonage number is required'),
|
||||||
|
apiSecret: Yup.string('The API key must be a string')
|
||||||
|
.max(200, 'The API secret is too long')
|
||||||
|
.test(secretTest(account?.apiKey, 'API secret')),
|
||||||
|
fromNumber: Yup.string('The Vonage number must be a string')
|
||||||
|
.max(100, 'The Vonage number is too long')
|
||||||
|
.required('The Vonage number is required'),
|
||||||
|
toNumber: Yup.string('The notifications number must be a string')
|
||||||
|
.max(100, 'The notifications number is too long')
|
||||||
|
.required('The notifications number is required')
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
1086
package-lock.json
generated
1086
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
|
@ -11,6 +11,8 @@
|
||||||
"@graphql-tools/merge": "^6.2.5",
|
"@graphql-tools/merge": "^6.2.5",
|
||||||
"@lamassu/coins": "1.3.0",
|
"@lamassu/coins": "1.3.0",
|
||||||
"@simplewebauthn/server": "^3.0.0",
|
"@simplewebauthn/server": "^3.0.0",
|
||||||
|
"@vonage/auth": "^1.5.0",
|
||||||
|
"@vonage/sms": "^1.7.0",
|
||||||
"apollo-server-express": "2.25.1",
|
"apollo-server-express": "2.25.1",
|
||||||
"argon2": "0.28.2",
|
"argon2": "0.28.2",
|
||||||
"axios": "0.21.1",
|
"axios": "0.21.1",
|
||||||
|
|
|
||||||
10
shell.nix
10
shell.nix
|
|
@ -1,16 +1,16 @@
|
||||||
with import (fetchTarball {
|
with import (fetchTarball {
|
||||||
name = "nixpkgs-19.03";
|
name = "8ad5e8";
|
||||||
url = https://github.com/NixOS/nixpkgs/archive/0b8799ecaaf0dc6b4c11583a3c96ca5b40fcfdfb.tar.gz;
|
url = https://github.com/NixOS/nixpkgs/archive/8ad5e8132c5dcf977e308e7bf5517cc6cc0bf7d8.tar.gz;
|
||||||
sha256 = "11m4aig6cv0zi3gbq2xn9by29cfvnsxgzf9qsvz67qr0yq29ryyz";
|
sha256 = "17v6wigks04x1d63a2wcd7cc4z9ca6qr0f4xvw1pdw83f8a3c0nj";
|
||||||
}) {};
|
}) {};
|
||||||
|
|
||||||
stdenv.mkDerivation {
|
stdenv.mkDerivation {
|
||||||
name = "node";
|
name = "node";
|
||||||
buildInputs = [
|
buildInputs = [
|
||||||
nodejs-14_x
|
nodejs-14_x
|
||||||
python2Full
|
python3
|
||||||
openssl
|
openssl
|
||||||
postgresql_9_6
|
postgresql
|
||||||
];
|
];
|
||||||
shellHook = ''
|
shellHook = ''
|
||||||
export PATH="$PWD/node_modules/.bin/:$PATH"
|
export PATH="$PWD/node_modules/.bin/:$PATH"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue