typings
This commit is contained in:
parent
c577880aac
commit
6e2101c74c
1 changed files with 7 additions and 3 deletions
|
|
@ -131,6 +131,7 @@ const Event = require('../event-constants')
|
|||
* @typedef {object} SimpleSocket
|
||||
* @prop {(eventName: string, data: Emission) => void} emit
|
||||
* @prop {(eventName: string, handler: (data: any) => void) => void} on
|
||||
* @prop {{ query: { 'x-shockwallet-device-id': string }}} handshake
|
||||
*/
|
||||
|
||||
/* eslint-disable init-declarations */
|
||||
|
|
@ -342,16 +343,18 @@ class Mediator {
|
|||
*/
|
||||
on: (eventName, cb) => {
|
||||
const deviceId = socket.handshake.query['x-shockwallet-device-id']
|
||||
socket.on(eventName, data => {
|
||||
socket.on(eventName, _data => {
|
||||
try {
|
||||
if (Encryption.isNonEncrypted(eventName)) {
|
||||
return cb(data)
|
||||
}
|
||||
|
||||
if (!data) {
|
||||
return cb(data)
|
||||
if (!_data) {
|
||||
return cb(_data)
|
||||
}
|
||||
|
||||
let data = _data
|
||||
|
||||
if (!deviceId) {
|
||||
const error = {
|
||||
field: 'deviceId',
|
||||
|
|
@ -396,6 +399,7 @@ class Mediator {
|
|||
}
|
||||
})
|
||||
},
|
||||
/** @type {SimpleSocket['emit']} */
|
||||
emit: (eventName, data) => {
|
||||
try {
|
||||
if (Encryption.isNonEncrypted(eventName)) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue