added boskrypt support for 2 connectors

master
cheetah 2 years ago
parent e0c410e1d9
commit 43115476f8

@ -1,5 +1,6 @@
const Connector = require("./Connector")
const config = require('../../config.json')
const boskrypt = require('../../boskrypt')
const md5 = require('md5')
const axios = require('axios')
// [ "ecityruf", "123456789" ]
@ -13,13 +14,28 @@ class eCityrufConnector extends Connector {
async transmitMessage(msg, params) {
const UUID = this.name+':'+md5(JSON.stringify([this.name,...params]))
if (params.length !== 1) return false
const $device = msg.routingParams.device
let payloadBuffer = Buffer.from(msg.payload)
const boskryptSupport = require("../DeviceRegistry").Devices[ $device ].supportBOSkrypt || false
if (boskryptSupport && !!config.pagers[ $device ] && config.pagers[ $device ].boskrypt.enabled) {
//payloadBuffer
const keyTable = config.pagers[ $device ].boskrypt.keys
const FunkrufNummer = "em-"+params[ 0 ]
if (!!keyTable[ FunkrufNummer ]) {
payloadBuffer = Buffer.from(boskrypt.encrypt(payloadBuffer, keyTable[ FunkrufNummer ], 0))
}
}
const cityrufRequest = require('querystring').stringify({
service: 1,
class: 7,
language: 'en',
action: 'SendMessage',
number: params[ 0 ],
message: msg.payload,
message: payloadBuffer.toString('ascii'),
lengthAlert: '',
})
console.log(cityrufRequest)

@ -17,6 +17,19 @@ class eCityrufConnector extends Connector {
const serviceName = target.split('#')[ 0 ], identifier = target.split('#')[ 1 ]
// eCityruf#8907737
const $device = msg.routingParams.device
let payloadBuffer = Buffer.from(msg.payload)
const boskryptSupport = require("../DeviceRegistry").Devices[ $device ].supportBOSkrypt || false
if (boskryptSupport && !!config.pagers[ $device ] && config.pagers[ $device ].boskrypt.enabled) {
//payloadBuffer
const keyTable = config.pagers[ $device ].boskrypt.keys
const FunkrufNummer = "em-"+identifier
if (!!keyTable[ FunkrufNummer ]) {
payloadBuffer = Buffer.from(boskrypt.encrypt(payloadBuffer, keyTable[ FunkrufNummer ], 0))
}
}
let jwtToken = '', msgTrackID = ''
// login
axios.post('https://api.emessage.de/auth/login', {
@ -30,7 +43,7 @@ class eCityrufConnector extends Connector {
})
.then(() => { // send Message Request
return axios.post('https://api.emessage.de/rs/eSendMessages', {
messageText: msg.payload,
messageText: payloadBuffer.toString('ascii'),
recipients: [{ serviceName, identifier }]
}, {
headers: {

Loading…
Cancel
Save