added boskrypt support for 2 connectors

master
cheetah 2 years ago
parent e0c410e1d9
commit 43115476f8

@ -1,5 +1,6 @@
const Connector = require("./Connector") const Connector = require("./Connector")
const config = require('../../config.json') const config = require('../../config.json')
const boskrypt = require('../../boskrypt')
const md5 = require('md5') const md5 = require('md5')
const axios = require('axios') const axios = require('axios')
// [ "ecityruf", "123456789" ] // [ "ecityruf", "123456789" ]
@ -13,13 +14,28 @@ class eCityrufConnector extends Connector {
async transmitMessage(msg, params) { async transmitMessage(msg, params) {
const UUID = this.name+':'+md5(JSON.stringify([this.name,...params])) const UUID = this.name+':'+md5(JSON.stringify([this.name,...params]))
if (params.length !== 1) return false 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({ const cityrufRequest = require('querystring').stringify({
service: 1, service: 1,
class: 7, class: 7,
language: 'en', language: 'en',
action: 'SendMessage', action: 'SendMessage',
number: params[ 0 ], number: params[ 0 ],
message: msg.payload, message: payloadBuffer.toString('ascii'),
lengthAlert: '', lengthAlert: '',
}) })
console.log(cityrufRequest) console.log(cityrufRequest)

@ -17,6 +17,19 @@ class eCityrufConnector extends Connector {
const serviceName = target.split('#')[ 0 ], identifier = target.split('#')[ 1 ] const serviceName = target.split('#')[ 0 ], identifier = target.split('#')[ 1 ]
// eCityruf#8907737 // 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 = '' let jwtToken = '', msgTrackID = ''
// login // login
axios.post('https://api.emessage.de/auth/login', { axios.post('https://api.emessage.de/auth/login', {
@ -30,7 +43,7 @@ class eCityrufConnector extends Connector {
}) })
.then(() => { // send Message Request .then(() => { // send Message Request
return axios.post('https://api.emessage.de/rs/eSendMessages', { return axios.post('https://api.emessage.de/rs/eSendMessages', {
messageText: msg.payload, messageText: payloadBuffer.toString('ascii'),
recipients: [{ serviceName, identifier }] recipients: [{ serviceName, identifier }]
}, { }, {
headers: { headers: {

Loading…
Cancel
Save