From 49ff61d56857e508e4a4adebf0aa757ab784bc51 Mon Sep 17 00:00:00 2001 From: Jeff Galbraith Date: Tue, 16 Jul 2019 13:34:02 -0600 Subject: [PATCH] chore: build dist --- dist/camera.js | 116 ++++++++++++++++----------------- dist/modules/access.js | 12 ++-- dist/modules/accessrules.js | 12 ++-- dist/modules/action.js | 12 ++-- dist/modules/analytics.js | 26 ++++---- dist/modules/core.js | 86 ++++++++++++------------ dist/modules/credential.js | 12 ++-- dist/modules/deviceio.js | 12 ++-- dist/modules/discovery.js | 48 +++++++------- dist/modules/display.js | 12 ++-- dist/modules/door.js | 12 ++-- dist/modules/events.js | 28 ++++---- dist/modules/imaging.js | 12 ++-- dist/modules/media.js | 36 +++++----- dist/modules/media2.js | 18 ++--- dist/modules/ptz.js | 52 +++++++-------- dist/modules/receiver.js | 12 ++-- dist/modules/recording.js | 12 ++-- dist/modules/replay.js | 12 ++-- dist/modules/schedule.js | 12 ++-- dist/modules/search.js | 12 ++-- dist/modules/security.js | 12 ++-- dist/modules/thermal.js | 12 ++-- dist/modules/videoanalytics.js | 12 ++-- dist/onvif-nvt.js | 10 +-- dist/utils/save-xml.js | 6 +- dist/utils/snapshot.js | 10 +-- dist/utils/soap.js | 94 +++++++++++++------------- dist/utils/util.js | 22 +++---- 29 files changed, 372 insertions(+), 372 deletions(-) diff --git a/dist/camera.js b/dist/camera.js index 0e07fe8b..c5f11945 100644 --- a/dist/camera.js +++ b/dist/camera.js @@ -43,7 +43,7 @@ class Camera { switch (name) { case 'access': if (!this.access) { - let Access = require('./modules/access'); + const Access = require('./modules/access'); this.access = new Access(); } @@ -52,7 +52,7 @@ class Camera { case 'accessrules': if (!this.accessrules) { - let AccessRules = require('./modules/accessrules'); + const AccessRules = require('./modules/accessrules'); this.accessrules = new AccessRules(); } @@ -61,7 +61,7 @@ class Camera { case 'action': if (!this.action) { - let Action = require('./modules/action'); + const Action = require('./modules/action'); this.action = new Action(); } @@ -70,7 +70,7 @@ class Camera { case 'analytics': if (!this.analytics) { - let Analytics = require('./modules/analytics'); + const Analytics = require('./modules/analytics'); this.analytics = new Analytics(); } @@ -79,7 +79,7 @@ class Camera { case 'core': if (!this.core) { - let Core = require('./modules/core'); + const Core = require('./modules/core'); this.core = new Core(); this.core.init(this.serviceAddress, this.username, this.password); @@ -89,7 +89,7 @@ class Camera { case 'credential': if (!this.credential) { - let Credential = require('./modules/credential'); + const Credential = require('./modules/credential'); this.credential = new Credential(); } @@ -98,7 +98,7 @@ class Camera { case 'deviceio': if (!this.deviceio) { - let DeviceIO = require('./modules/deviceio'); + const DeviceIO = require('./modules/deviceio'); this.deviceio = new DeviceIO(); } @@ -107,7 +107,7 @@ class Camera { case 'display': if (!this.display) { - let Display = require('./modules/display'); + const Display = require('./modules/display'); this.display = new Display(); } @@ -116,7 +116,7 @@ class Camera { case 'door': if (!this.door) { - let Door = require('./modules/door'); + const Door = require('./modules/door'); this.door = new Door(); } @@ -125,7 +125,7 @@ class Camera { case 'events': if (!this.events) { - let Events = require('./modules/events'); + const Events = require('./modules/events'); this.events = new Events(); } @@ -134,7 +134,7 @@ class Camera { case 'imaging': if (!this.imaging) { - let Imaging = require('./modules/imaging'); + const Imaging = require('./modules/imaging'); this.imaging = new Imaging(); } @@ -143,7 +143,7 @@ class Camera { case 'media': if (!this.media) { - let Media = require('./modules/media'); + const Media = require('./modules/media'); this.media = new Media(); this.media.init(this.timeDiff, this.serviceAddress, this.username, this.password); @@ -153,7 +153,7 @@ class Camera { case 'media2': if (!this.media2) { - let Media2 = require('./modules/media2'); + const Media2 = require('./modules/media2'); this.media2 = new Media2(); } @@ -162,7 +162,7 @@ class Camera { case 'ptz': if (!this.ptz) { - let Ptz = require('./modules/ptz'); + const Ptz = require('./modules/ptz'); this.ptz = new Ptz(); } @@ -171,7 +171,7 @@ class Camera { case 'receiver': if (!this.receiver) { - let Receiver = require('./modules/receiver'); + const Receiver = require('./modules/receiver'); this.receiver = new Receiver(); } @@ -180,7 +180,7 @@ class Camera { case 'recording': if (!this.recording) { - let Recording = require('./modules/recording'); + const Recording = require('./modules/recording'); this.recording = new Recording(); } @@ -189,7 +189,7 @@ class Camera { case 'replay': if (!this.replay) { - let Replay = require('./modules/replay'); + const Replay = require('./modules/replay'); this.replay = new Replay(); } @@ -198,7 +198,7 @@ class Camera { case 'schedule': if (!this.schedule) { - let Schedule = require('./modules/schedule'); + const Schedule = require('./modules/schedule'); this.schedule = new Schedule(); } @@ -207,7 +207,7 @@ class Camera { case 'search': if (!this.search) { - let Search = require('./modules/search'); + const Search = require('./modules/search'); this.search = new Search(); } @@ -216,7 +216,7 @@ class Camera { case 'security': if (!this.security) { - let Security = require('./modules/security'); + const Security = require('./modules/security'); this.security = new Security(); } @@ -225,13 +225,13 @@ class Camera { case 'snapshot': if (!this.snapshot) { - let Snapshot = require('./utils/snapshot'); + const Snapshot = require('./utils/snapshot'); this.snapshot = new Snapshot(); - let defaultProfile = this.getDefaultProfile(); + const defaultProfile = this.getDefaultProfile(); if (defaultProfile) { - let snapshotUri = defaultProfile.SnapshotUri.Uri; + const snapshotUri = defaultProfile.SnapshotUri.Uri; this.snapshot.init(snapshotUri, this.username, this.password); } } @@ -240,7 +240,7 @@ class Camera { case 'thermal': if (!this.thermal) { - let Thermal = require('./modules/thermal'); + const Thermal = require('./modules/thermal'); this.thermal = new Thermal(); } @@ -249,7 +249,7 @@ class Camera { case 'videoanalytics': if (!this.videoanalytics) { - let VideoAnalytics = require('./modules/videoanalytics'); + const VideoAnalytics = require('./modules/videoanalytics'); this.videoanalytics = new VideoAnalytics(); } @@ -302,7 +302,7 @@ class Camera { }).then(() => { return this.coreGetScopes(); }).then(() => { - let info = this.getInformation(); + const info = this.getInformation(); resolve(info); }).catch(error => { reject(error); @@ -325,7 +325,7 @@ class Camera { } getInformation() { - let o = this.deviceInformation; + const o = this.deviceInformation; if (o) { return JSON.parse(JSON.stringify(o)); @@ -353,11 +353,11 @@ class Camera { coreGetServices() { return new Promise((resolve, reject) => { this.core.getServices(true).then(results => { - let response = results.data.GetServicesResponse; - let services = response.Service; + const response = results.data.GetServicesResponse; + const services = response.Service; services.forEach(service => { this.checkForProxy(service); - let namespace = service.Namespace; + const namespace = service.Namespace; if (namespace === 'http://www.onvif.org/ver10/device/wsdl') { this.core.version = service.Version; @@ -414,7 +414,7 @@ class Camera { } checkForProxy(service) { - let xaddrPath = new URL(service.XAddr); + const xaddrPath = new URL(service.XAddr); if (xaddrPath.hostname === this.serviceAddress.hostname) { return; @@ -426,7 +426,7 @@ class Camera { coreGetCapabilities() { return new Promise((resolve, reject) => { this.core.getCapabilities().then(results => { - let c = results['data']['GetCapabilitiesResponse']['Capabilities']; + const c = results['data']['GetCapabilitiesResponse']['Capabilities']; if (!c) { reject(new Error('Failed to initialize the device: No capabilities were found.')); @@ -434,7 +434,7 @@ class Camera { } if ('Analytics' in c) { - let analytics = c['Analytics']; + const analytics = c['Analytics']; this.checkForProxy(analytics); if (analytics && 'XAddr' in analytics) { @@ -442,7 +442,7 @@ class Camera { this.add('analytics'); if (this.analytics) { - let serviceAddress = new URL(analytics['XAddr']); + const serviceAddress = new URL(analytics['XAddr']); this.analytics.init(this.timeDiff, serviceAddress, this.username, this.password); } } @@ -460,7 +460,7 @@ class Camera { } if ('Events' in c) { - let events = c['Events']; + const events = c['Events']; this.checkForProxy(events); if (events && 'XAddr' in events) { @@ -468,7 +468,7 @@ class Camera { this.add('events'); if (this.events) { - let serviceAddress = new URL(events['XAddr']); + const serviceAddress = new URL(events['XAddr']); this.events.init(this.timeDiff, serviceAddress, this.username, this.password); } } @@ -486,7 +486,7 @@ class Camera { } if ('Imaging' in c) { - let imaging = c['Imaging']; + const imaging = c['Imaging']; this.checkForProxy(imaging); if (imaging && 'XAddr' in imaging) { @@ -494,7 +494,7 @@ class Camera { this.add('imaging'); if (this.imaging) { - let serviceAddress = new URL(imaging['XAddr']); + const serviceAddress = new URL(imaging['XAddr']); this.imaging.init(this.timeDiff, serviceAddress, this.username, this.password); } } @@ -502,7 +502,7 @@ class Camera { } if ('Media' in c) { - let media = c['Media']; + const media = c['Media']; this.checkForProxy(media); if (media && 'XAddr' in media) { @@ -510,7 +510,7 @@ class Camera { this.add('media'); if (this.media) { - let serviceAddress = new URL(media['XAddr']); + const serviceAddress = new URL(media['XAddr']); this.media.init(this.timeDiff, serviceAddress, this.username, this.password); } } @@ -518,7 +518,7 @@ class Camera { } if ('PTZ' in c) { - let ptz = c['PTZ']; + const ptz = c['PTZ']; this.checkForProxy(ptz); if (ptz && 'XAddr' in ptz) { @@ -526,7 +526,7 @@ class Camera { this.add('ptz'); if (this.ptz) { - let serviceAddress = new URL(ptz['XAddr']); + const serviceAddress = new URL(ptz['XAddr']); this.ptz.init(this.timeDiff, serviceAddress, this.username, this.password); } } @@ -556,13 +556,13 @@ class Camera { coreGetScopes() { return new Promise((resolve, reject) => { this.core.getScopes().then(results => { - let scopes = results['data']['GetScopesResponse']['Scopes']; + const scopes = results['data']['GetScopesResponse']['Scopes']; this.deviceInformation.Ptz = false; scopes.forEach(scope => { - let s = scope['ScopeItem']; + const s = scope['ScopeItem']; if (s.indexOf('onvif://www.onvif.org/hardware/') === 0) { - let hardware = s.split('/').pop(); + const hardware = s.split('/').pop(); this.deviceInformation.Hardware = hardware; } else if (s.indexOf('onvif://www.onvif.org/type/Streaming') === 0) { this.deviceInformation.Streaming = true; @@ -585,10 +585,10 @@ class Camera { } else if (s.indexOf('onvif://www.onvif.org/Profile/T') === 0) { this.deviceInformation.ProfileT = true; } else if (s.indexOf('onvif://www.onvif.org/location/country/') === 0) { - let country = s.split('/').pop(); + const country = s.split('/').pop(); this.deviceInformation.Country = country; } else if (s.indexOf('onvif://www.onvif.org/location/city/') === 0) { - let city = s.split('/').pop(); + const city = s.split('/').pop(); this.deviceInformation.City = city; } else if (s.indexOf('onvif://www.onvif.org/name/') === 0) { let name = s.split('/').pop(); @@ -607,14 +607,14 @@ class Camera { mediaGetProfiles() { return new Promise((resolve, reject) => { this.media.getProfiles().then(results => { - let profiles = results['data']['GetProfilesResponse']['Profiles']; + const profiles = results['data']['GetProfilesResponse']['Profiles']; if (!profiles) { reject(new Error('Failed to initialize the device: The targeted device does not any media profiles.')); return; } - let profileList = this.parseProfiles(profiles); + const profileList = this.parseProfiles(profiles); this.profileList = this.profileList.concat(profileList); resolve(); }).catch(error => { @@ -625,7 +625,7 @@ class Camera { } parseProfiles(profiles) { - let profileList = []; + const profileList = []; profiles.forEach(profile => { profileList.push(profile); @@ -646,18 +646,18 @@ class Camera { mediaGetStreamURI() { return new Promise((resolve, reject) => { - let protocols = ['UDP', 'HTTP', 'RTSP']; + const protocols = ['UDP', 'HTTP', 'RTSP']; let profileIndex = 0; let protocolIndex = 0; - let getStreamUri = () => { - let profile = this.profileList[profileIndex]; + const getStreamUri = () => { + const profile = this.profileList[profileIndex]; if (profile) { - let protocol = protocols[protocolIndex]; + const protocol = protocols[protocolIndex]; if (protocol) { - let token = profile['$']['token']; + const token = profile['$']['token']; this.media.getStreamUri('RTP-Unicast', protocol, token).then(results => { profile.StreamUri = results['data']['GetStreamUriResponse']['MediaUri']; ++protocolIndex; @@ -685,13 +685,13 @@ class Camera { return new Promise((resolve, reject) => { let profileIndex = 0; - let getSnapshotUri = () => { - let profile = this.profileList[profileIndex]; + const getSnapshotUri = () => { + const profile = this.profileList[profileIndex]; if (profile) { this.media.getSnapshotUri(profile['$']['token']).then(results => { try { - let service = {}; + const service = {}; service.XAddr = results['data']['GetSnapshotUriResponse']['MediaUri']['Uri']; this.checkForProxy(service); profile.SnapshotUri = results['data']['GetSnapshotUriResponse']['MediaUri']; diff --git a/dist/modules/access.js b/dist/modules/access.js index 5db4a673..8f05c3b9 100644 --- a/dist/modules/access.js +++ b/dist/modules/access.js @@ -18,12 +18,12 @@ class Access { } createRequest(body) { - let soapEnvelope = this.soap.createRequest({ - 'body': body, - 'xmlns': this.namespaceAttributes, - 'diff': this.timeDiff, - 'username': this.username, - 'password': this.password + const soapEnvelope = this.soap.createRequest({ + body: body, + xmlns: this.namespaceAttributes, + diff: this.timeDiff, + username: this.username, + password: this.password }); return soapEnvelope; } diff --git a/dist/modules/accessrules.js b/dist/modules/accessrules.js index 4a3e511d..d57383c6 100644 --- a/dist/modules/accessrules.js +++ b/dist/modules/accessrules.js @@ -18,12 +18,12 @@ class AccessRules { } createRequest(body) { - let soapEnvelope = this.soap.createRequest({ - 'body': body, - 'xmlns': this.namespaceAttributes, - 'diff': this.timeDiff, - 'username': this.username, - 'password': this.password + const soapEnvelope = this.soap.createRequest({ + body: body, + xmlns: this.namespaceAttributes, + diff: this.timeDiff, + username: this.username, + password: this.password }); return soapEnvelope; } diff --git a/dist/modules/action.js b/dist/modules/action.js index 84027af0..da7374b6 100644 --- a/dist/modules/action.js +++ b/dist/modules/action.js @@ -18,12 +18,12 @@ class Action { } createRequest(body) { - let soapEnvelope = this.soap.createRequest({ - 'body': body, - 'xmlns': this.namespaceAttributes, - 'diff': this.timeDiff, - 'username': this.username, - 'password': this.password + const soapEnvelope = this.soap.createRequest({ + body: body, + xmlns: this.namespaceAttributes, + diff: this.timeDiff, + username: this.username, + password: this.password }); return soapEnvelope; } diff --git a/dist/modules/analytics.js b/dist/modules/analytics.js index 1d5c65ad..cc3b0fe8 100644 --- a/dist/modules/analytics.js +++ b/dist/modules/analytics.js @@ -20,18 +20,18 @@ class Analytics { } createRequest(body) { - let soapEnvelope = this.soap.createRequest({ - 'body': body, - 'xmlns': this.namespaceAttributes, - 'diff': this.timeDiff, - 'username': this.username, - 'password': this.password + const soapEnvelope = this.soap.createRequest({ + body: body, + xmlns: this.namespaceAttributes, + diff: this.timeDiff, + username: this.username, + password: this.password }); return soapEnvelope; } buildRequest(methodName, xml, callback) { - let promise = new Promise((resolve, reject) => { + const promise = new Promise((resolve, reject) => { let errMsg = ''; if (typeof callback !== 'undefined' && callback !== null) { @@ -61,7 +61,7 @@ class Analytics { soapBody += ``; } - let soapEnvelope = this.createRequest(soapBody); + const soapEnvelope = this.createRequest(soapBody); this.soap.makeRequest('analytics', this.serviceAddress, methodName, soapEnvelope).then(results => { resolve(results); }).catch(error => { @@ -81,7 +81,7 @@ class Analytics { } requestWithConfigurationToken(methodName, configurationToken, xml, callback) { - let promise = new Promise((resolve, reject) => { + const promise = new Promise((resolve, reject) => { let errMsg = ''; if (typeof callback !== 'undefined' && callback !== null) { @@ -133,12 +133,12 @@ class Analytics { } deleteAnalyticsModules(configurationToken, analyticsModuleName, callback) { - let soapBody = '' + analyticsModuleName + ''; + const soapBody = '' + analyticsModuleName + ''; return this.requestWithConfigurationToken('DeleteAnalyticsModules', configurationToken, soapBody, callback); } getAnalyticsModuleOptions(configurationToken, type, callback) { - let soapBody = '' + type + ''; + const soapBody = '' + type + ''; return this.requestWithConfigurationToken('GetAnalyticsModuleOptions', configurationToken, soapBody, callback); } @@ -163,12 +163,12 @@ class Analytics { } deleteRules(configurationToken, ruleName, callback) { - let soapBody = '' + ruleName + ''; + const soapBody = '' + ruleName + ''; return this.requestWithConfigurationToken('DeleteRules', configurationToken, soapBody, callback); } getRuleOptions(configurationToken, ruleType, callback) { - let soapBody = '' + ruleType + ''; + const soapBody = '' + ruleType + ''; return this.requestWithConfigurationToken('GetRuleOptions', configurationToken, soapBody, callback); } diff --git a/dist/modules/core.js b/dist/modules/core.js index 18b91481..c891b37b 100644 --- a/dist/modules/core.js +++ b/dist/modules/core.js @@ -19,18 +19,18 @@ class Core { } createRequest(body) { - let soapEnvelope = this.soap.createRequest({ - 'body': body, - 'xmlns': this.namespaceAttributes, - 'diff': this.timeDiff, - 'username': this.username, - 'password': this.password + const soapEnvelope = this.soap.createRequest({ + body: body, + xmlns: this.namespaceAttributes, + diff: this.timeDiff, + username: this.username, + password: this.password }); return soapEnvelope; } buildRequest(methodName, xml, callback) { - let promise = new Promise((resolve, reject) => { + const promise = new Promise((resolve, reject) => { let errMsg = ''; if (typeof callback !== 'undefined' && callback !== null) { @@ -60,7 +60,7 @@ class Core { soapBody += ``; } - let soapEnvelope = this.createRequest(soapBody); + const soapEnvelope = this.createRequest(soapBody); this.soap.makeRequest('core', this.serviceAddress, methodName, soapEnvelope).then(results => { resolve(results); }).catch(error => { @@ -88,7 +88,7 @@ class Core { } getServices(includeCapability, callback) { - let promise = new Promise((resolve, reject) => { + const promise = new Promise((resolve, reject) => { let errMsg = ''; if (typeof callback !== 'undefined' && callback !== null) { @@ -134,7 +134,7 @@ class Core { } getCapabilities(callback) { - let promise = new Promise((resolve, reject) => { + const promise = new Promise((resolve, reject) => { let errMsg = ''; if (typeof callback !== 'undefined' && callback !== null) { @@ -170,7 +170,7 @@ class Core { setHostname(name, callback) { name = name || ''; - let promise = new Promise((resolve, reject) => { + const promise = new Promise((resolve, reject) => { let errMsg = ''; if (typeof callback !== 'undefined' && callback !== null) { @@ -201,7 +201,7 @@ class Core { } setHostnameFromDHCP(fromDHCP, callback) { - let promise = new Promise((resolve, reject) => { + const promise = new Promise((resolve, reject) => { let errMsg = ''; if (typeof callback !== 'undefined' && callback !== null) { @@ -237,7 +237,7 @@ class Core { } getDNS(callback) { - let promise = new Promise((resolve, reject) => { + const promise = new Promise((resolve, reject) => { let errMsg = ''; if (typeof callback !== 'undefined' && callback !== null) { @@ -249,7 +249,7 @@ class Core { this.buildRequest('GetDNS').then(result => { try { - let di = result['data']['DNSInformation']; + const di = result['data']['DNSInformation']; if (!di['SearchDomain']) { di['SearchDomain'] = []; @@ -284,7 +284,7 @@ class Core { } setDNS(fromDHCP, searchDomain, DNSManual, callback) { - let promise = new Promise((resolve, reject) => { + const promise = new Promise((resolve, reject) => { let errMsg = ''; if (typeof callback !== 'undefined' && callback !== null) { @@ -320,14 +320,14 @@ class Core { } for (let i = 0; i < DNSManual.length; i++) { - let d = DNSManual[i]; + const d = DNSManual[i]; if (errMsg = Util.isInvalidValue(d, 'object')) { reject(new Error(`A "DNSManual" property for setDNS is invalid(${JSON.stringify(d)}): ` + errMsg)); return; } - let type = d['type']; + const type = d['type']; if (errMsg = Util.isInvalidValue(type, 'string')) { reject(new Error('The "type" property for setDNS is invalid: ' + errMsg)); @@ -402,7 +402,7 @@ class Core { } setNTP(fromDHCP, NTPManual, callback) { - let promise = new Promise((resolve, reject) => { + const promise = new Promise((resolve, reject) => { let errMsg = ''; if (typeof callback !== 'undefined' && callback !== null) { @@ -424,14 +424,14 @@ class Core { } for (let i = 0; i < NTPManual.length; i++) { - let d = NTPManual[i]; + const d = NTPManual[i]; if (errMsg = Util.isInvalidValue(d, 'object')) { reject(new Error(`A "NTPManual" property for setNTP is invalid(${JSON.stringify(d)}): ` + errMsg)); return; } - let type = d['type']; + const type = d['type']; if (errMsg = Util.isInvalidValue(type, 'string')) { reject(new Error('The "type" property for setNTP is invalid: ' + errMsg)); @@ -500,7 +500,7 @@ class Core { } setDynamicDNS(type, name, ttl, callback) { - let promise = new Promise((resolve, reject) => { + const promise = new Promise((resolve, reject) => { let errMsg = ''; if (typeof callback !== 'undefined' && callback !== null) { @@ -545,7 +545,7 @@ class Core { } soapBody += ''; - let soapEnvelope = this.createRequest(soapBody); + const soapEnvelope = this.createRequest(soapBody); return this.soap.makeRequest('core', this.serviceAddress, 'SetDynamicDNS', soapEnvelope).then(result => { resolve(result); }).catch(error => { @@ -631,7 +631,7 @@ class Core { } getDot11Status(interfaceToken, callback) { - let promise = new Promise((resolve, reject) => { + const promise = new Promise((resolve, reject) => { let errMsg = ''; if (typeof callback !== 'undefined' && callback !== null) { @@ -667,7 +667,7 @@ class Core { } scanAvailableDot11Networks(interfaceToken, callback) { - let promise = new Promise((resolve, reject) => { + const promise = new Promise((resolve, reject) => { let errMsg = ''; if (typeof callback !== 'undefined' && callback !== null) { @@ -727,7 +727,7 @@ class Core { } getSystemDateAndTime(callback) { - let promise = new Promise((resolve, reject) => { + const promise = new Promise((resolve, reject) => { let errMsg = ''; if (typeof callback !== 'undefined' && callback !== null) { @@ -738,11 +738,11 @@ class Core { } this.buildRequest('GetSystemDateAndTime').then(results => { - let parsed = this.parseGetSystemDateAndTime(results['data']); + const parsed = this.parseGetSystemDateAndTime(results['data']); if (parsed && parsed['date']) { - let deviceTime = parsed['date'].getTime(); - let localTime = new Date().getTime(); + const deviceTime = parsed['date'].getTime(); + const localTime = new Date().getTime(); this.timeDiff = deviceTime - localTime; } @@ -764,38 +764,38 @@ class Core { } parseGetSystemDateAndTime(sdt) { - let s0 = sdt; + const s0 = sdt; if (!s0) { return null; } - let s1 = s0['GetSystemDateAndTimeResponse']; + const s1 = s0['GetSystemDateAndTimeResponse']; if (!s1) { return null; } - let s2 = s1['SystemDateAndTime']; + const s2 = s1['SystemDateAndTime']; if (!s2) { return null; } - let type = s2['DateTimeType'] || ''; + const type = s2['DateTimeType'] || ''; let dst = null; if (s2['DaylightSavings']) { dst = s2['DaylightSavings'] === 'true'; } - let tz = s2['TimeZone'] && s2['TimeZone']['TZ'] ? s2['TimeZone']['TZ'] : ''; + const tz = s2['TimeZone'] && s2['TimeZone']['TZ'] ? s2['TimeZone']['TZ'] : ''; let date = null; if (s2['UTCDateTime']) { - let udt = s2['UTCDateTime']; - let t = udt['Time']; - let d = udt['Date']; + const udt = s2['UTCDateTime']; + const t = udt['Time']; + const d = udt['Date']; if (t && d && t['Hour'] && t['Minute'] && t['Second'] && d['Year'] && d['Month'] && d['Day']) { date = new Date(); @@ -808,11 +808,11 @@ class Core { } } - let res = { - 'type': type, - 'dst': dst, - 'tz': tz, - 'date': date + const res = { + type: type, + dst: dst, + tz: tz, + date: date }; return res; } @@ -842,7 +842,7 @@ class Core { } getSystemLog(logType, callback) { - let promise = new Promise((resolve, reject) => { + const promise = new Promise((resolve, reject) => { let errMsg = ''; if (typeof callback !== 'undefined' && callback !== null) { @@ -1003,7 +1003,7 @@ class Core { } getDot1XConfiguration(dot1XConfigurationToken, callback) { - let promise = new Promise((resolve, reject) => { + const promise = new Promise((resolve, reject) => { let errMsg = ''; if (typeof callback !== 'undefined' && callback !== null) { diff --git a/dist/modules/credential.js b/dist/modules/credential.js index 445cc6d3..70211833 100644 --- a/dist/modules/credential.js +++ b/dist/modules/credential.js @@ -18,12 +18,12 @@ class Credential { } createRequest(body) { - let soapEnvelope = this.soap.createRequest({ - 'body': body, - 'xmlns': this.namespaceAttributes, - 'diff': this.timeDiff, - 'username': this.username, - 'password': this.password + const soapEnvelope = this.soap.createRequest({ + body: body, + xmlns: this.namespaceAttributes, + diff: this.timeDiff, + username: this.username, + password: this.password }); return soapEnvelope; } diff --git a/dist/modules/deviceio.js b/dist/modules/deviceio.js index 3ef3dfc9..9d301b7a 100644 --- a/dist/modules/deviceio.js +++ b/dist/modules/deviceio.js @@ -18,12 +18,12 @@ class DeviceIO { } createRequest(body) { - let soapEnvelope = this.soap.createRequest({ - 'body': body, - 'xmlns': this.namespaceAttributes, - 'diff': this.timeDiff, - 'username': this.username, - 'password': this.password + const soapEnvelope = this.soap.createRequest({ + body: body, + xmlns: this.namespaceAttributes, + diff: this.timeDiff, + username: this.username, + password: this.password }); return soapEnvelope; } diff --git a/dist/modules/discovery.js b/dist/modules/discovery.js index d2d06626..49d44d74 100644 --- a/dist/modules/discovery.js +++ b/dist/modules/discovery.js @@ -18,7 +18,7 @@ class Discovery { } startProbe(callback) { - let promise = new Promise((resolve, reject) => { + const promise = new Promise((resolve, reject) => { let errMsg = ''; if (typeof callback !== 'undefined' && callback !== null) { @@ -52,7 +52,7 @@ class Discovery { this._discoveryWaitTimer = setTimeout(() => { this.stopProbe().then(() => { - let deviceList = []; + const deviceList = []; Object.keys(this._devices).forEach(urn => { deviceList.push(this._devices[urn]); }); @@ -86,7 +86,7 @@ class Discovery { this._discoveryWaitTimer = null; } - let promise = new Promise((resolve, reject) => { + const promise = new Promise((resolve, reject) => { let errMsg = ''; if (typeof callback !== 'undefined' && callback !== null) { @@ -141,14 +141,14 @@ class Discovery { soapTemplate += ''; soapTemplate = soapTemplate.replace(/\>\s+\<'); soapTemplate = soapTemplate.replace(/\s+/, ' '); - let soapSet = []; + const soapSet = []; ['NetworkVideoTransmitter', 'Device', 'NetworkVideoDisplay'].forEach(type => { let s = soapTemplate; s = s.replace('__type__', type); s = s.replace('__uuid__', Util.createUuidV4()); soapSet.push(s); }); - let soapList = []; + const soapList = []; for (let i = 0; i < this._DISCOVERY_RETRY_MAX; i++) { soapSet.forEach(s => { @@ -156,13 +156,13 @@ class Discovery { }); } - let promise = new Promise((resolve, reject) => { - let send = () => { + const promise = new Promise((resolve, reject) => { + const send = () => { if (this._udp) { - let soapEnvelope = soapList.shift(); + const soapEnvelope = soapList.shift(); if (soapEnvelope) { - let buf = Buffer.from(soapEnvelope, 'utf8'); + const buf = Buffer.from(soapEnvelope, 'utf8'); this._udp.send(buf, 0, buf.length, this._PORT, this._MULTICAST_ADDRESS, (error, bytes) => { if (error) { @@ -187,9 +187,9 @@ class Discovery { } parseResult(results, deviceInfo) { - let parsed = results.parsed; + const parsed = results.parsed; let urn = ''; - let address = deviceInfo.address; + const address = deviceInfo.address; let service = ''; let xaddrs = []; let scopes = []; @@ -198,20 +198,20 @@ class Discovery { try { if ('Body' in parsed) { - let body = parsed['Body']; + const body = parsed['Body']; if ('ProbeMatches' in body) { - let probeMatches = body['ProbeMatches']; + const probeMatches = body['ProbeMatches']; if (probeMatches !== undefined) { if ('ProbeMatch' in probeMatches) { - let probeMatch = probeMatches['ProbeMatch']; + const probeMatch = probeMatches['ProbeMatch']; urn = probeMatch['EndpointReference']['Address']; xaddrs = probeMatch['XAddrs'].split(/\s+/); if (xaddrs.length > 1) { xaddrs.forEach(addr => { - let index = addr.indexOf(deviceInfo.address); + const index = addr.indexOf(deviceInfo.address); if (index !== -1) { service = addr; @@ -258,15 +258,15 @@ class Discovery { } }); probe = { - 'urn': urn, - 'name': name, - 'address': address, - 'service': service, - 'hardware': hardware, - 'location': location, - 'types': types, - 'xaddrs': xaddrs, - 'scopes': scopes + urn: urn, + name: name, + address: address, + service: service, + hardware: hardware, + location: location, + types: types, + xaddrs: xaddrs, + scopes: scopes }; this._devices[urn] = probe; } diff --git a/dist/modules/display.js b/dist/modules/display.js index de88e2d4..6bac53a0 100644 --- a/dist/modules/display.js +++ b/dist/modules/display.js @@ -18,12 +18,12 @@ class Display { } createRequest(body) { - let soapEnvelope = this.soap.createRequest({ - 'body': body, - 'xmlns': this.namespaceAttributes, - 'diff': this.timeDiff, - 'username': this.username, - 'password': this.password + const soapEnvelope = this.soap.createRequest({ + body: body, + xmlns: this.namespaceAttributes, + diff: this.timeDiff, + username: this.username, + password: this.password }); return soapEnvelope; } diff --git a/dist/modules/door.js b/dist/modules/door.js index ed9b8ddf..1a1919d1 100644 --- a/dist/modules/door.js +++ b/dist/modules/door.js @@ -18,12 +18,12 @@ class Door { } createRequest(body) { - let soapEnvelope = this.soap.createRequest({ - 'body': body, - 'xmlns': this.namespaceAttributes, - 'diff': this.timeDiff, - 'username': this.username, - 'password': this.password + const soapEnvelope = this.soap.createRequest({ + body: body, + xmlns: this.namespaceAttributes, + diff: this.timeDiff, + username: this.username, + password: this.password }); return soapEnvelope; } diff --git a/dist/modules/events.js b/dist/modules/events.js index 17c59580..7441f1b5 100644 --- a/dist/modules/events.js +++ b/dist/modules/events.js @@ -26,24 +26,24 @@ class Events extends EventEmitter { } createRequest(body, subscriptionId) { - let request = { - 'body': body, - 'xmlns': this.namespaceAttributes, - 'diff': this.timeDiff, - 'username': this.username, - 'password': this.password + const request = { + body: body, + xmlns: this.namespaceAttributes, + diff: this.timeDiff, + username: this.username, + password: this.password }; if (subscriptionId) { request.subscriptionId = subscriptionId; } - let soapEnvelope = this.soap.createRequest(request); + const soapEnvelope = this.soap.createRequest(request); return soapEnvelope; } buildRequest(methodName, xml, subscriptionId, callback) { - let promise = new Promise((resolve, reject) => { + const promise = new Promise((resolve, reject) => { let errMsg = ''; if (typeof callback !== 'undefined' && callback !== null) { @@ -75,7 +75,7 @@ class Events extends EventEmitter { soapBody += ``; } - let soapEnvelope = this.createRequest(soapBody, subscriptionId); + const soapEnvelope = this.createRequest(soapBody, subscriptionId); let serviceAddress = this.serviceAddress; if (methodName === 'PullMessages') { @@ -105,7 +105,7 @@ class Events extends EventEmitter { timeout = timeout || 'PT1M'; messageLimit = messageLimit || 1; - let getAll = () => { + const getAll = () => { this._getMessages(timeout, messageLimit).then(results => { this.emit('messages', results); console.log(results); @@ -142,8 +142,8 @@ class Events extends EventEmitter { return new Promise((resolve, reject) => { this.createPullPointSubscription().then(results => { console.log('CreatePullPointSubscription successful'); - let response = results.data.CreatePullPointSubscriptionResponse; - let reference = response.SubscriptionReference; + const response = results.data.CreatePullPointSubscriptionResponse; + const reference = response.SubscriptionReference; let subscriptionId = {}; if (reference.ReferenceParameters) { @@ -169,7 +169,7 @@ class Events extends EventEmitter { } createPullPointSubscription(filter, initialTerminationTime, subscriptionPolicy, callback) { - let promise = new Promise((resolve, reject) => { + const promise = new Promise((resolve, reject) => { let errMsg = ''; if (typeof filter !== 'undefined' && filter !== null) { @@ -234,7 +234,7 @@ class Events extends EventEmitter { } pullMessages(subscriptionId, timeout, messageLimit, callback) { - let promise = new Promise((resolve, reject) => { + const promise = new Promise((resolve, reject) => { let errMsg = ''; if (errMsg = Util.isInvalidValue(timeout, 'string')) { diff --git a/dist/modules/imaging.js b/dist/modules/imaging.js index b2bc0245..343a6076 100644 --- a/dist/modules/imaging.js +++ b/dist/modules/imaging.js @@ -18,12 +18,12 @@ class Imaging { } createRequest(body) { - let soapEnvelope = this.soap.createRequest({ - 'body': body, - 'xmlns': this.namespaceAttributes, - 'diff': this.timeDiff, - 'username': this.username, - 'password': this.password + const soapEnvelope = this.soap.createRequest({ + body: body, + xmlns: this.namespaceAttributes, + diff: this.timeDiff, + username: this.username, + password: this.password }); return soapEnvelope; } diff --git a/dist/modules/media.js b/dist/modules/media.js index e844d858..7a750cb9 100644 --- a/dist/modules/media.js +++ b/dist/modules/media.js @@ -20,18 +20,18 @@ class Media { } createRequest(body) { - let soapEnvelope = this.soap.createRequest({ - 'body': body, - 'xmlns': this.namespaceAttributes, - 'diff': this.timeDiff, - 'username': this.username, - 'password': this.password + const soapEnvelope = this.soap.createRequest({ + body: body, + xmlns: this.namespaceAttributes, + diff: this.timeDiff, + username: this.username, + password: this.password }); return soapEnvelope; } buildRequest(methodName, xml, callback) { - let promise = new Promise((resolve, reject) => { + const promise = new Promise((resolve, reject) => { let errMsg = ''; if (typeof callback !== 'undefined' && callback !== null) { @@ -61,7 +61,7 @@ class Media { soapBody += ``; } - let soapEnvelope = this.createRequest(soapBody); + const soapEnvelope = this.createRequest(soapBody); this.soap.makeRequest('media', this.serviceAddress, methodName, soapEnvelope).then(results => { resolve(results); }).catch(error => { @@ -81,7 +81,7 @@ class Media { } requestWithProfileToken(methodName, profileToken, callback) { - let promise = new Promise((resolve, reject) => { + const promise = new Promise((resolve, reject) => { let errMsg = ''; if (typeof callback !== 'undefined' && callback !== null) { @@ -117,7 +117,7 @@ class Media { } requestWithConfigurationToken(methodName, configurationToken, callback) { - let promise = new Promise((resolve, reject) => { + const promise = new Promise((resolve, reject) => { let errMsg = ''; if (typeof callback !== 'undefined' && callback !== null) { @@ -153,7 +153,7 @@ class Media { } requestWithOptionalTokens(methodName, profileToken, configurationToken, callback) { - let promise = new Promise((resolve, reject) => { + const promise = new Promise((resolve, reject) => { let errMsg = ''; if (typeof callback !== 'undefined' && callback !== null) { @@ -206,7 +206,7 @@ class Media { } addConfiguration(methodName, profileToken, configurationToken, callback) { - let promise = new Promise((resolve, reject) => { + const promise = new Promise((resolve, reject) => { let errMsg = ''; if (typeof callback !== 'undefined' && callback !== null) { @@ -248,7 +248,7 @@ class Media { } createProfile(name, token, callback) { - let promise = new Promise((resolve, reject) => { + const promise = new Promise((resolve, reject) => { let errMsg = ''; if (typeof callback !== 'undefined' && callback !== null) { @@ -568,7 +568,7 @@ class Media { } getStreamUri(streamType, protocolType, profileToken, callback) { - let promise = new Promise((resolve, reject) => { + const promise = new Promise((resolve, reject) => { let errMsg = ''; if (typeof callback !== 'undefined' && callback !== null) { @@ -642,7 +642,7 @@ class Media { } getVideoSourceModes(videoSourceToken, callback) { - let promise = new Promise((resolve, reject) => { + const promise = new Promise((resolve, reject) => { let errMsg = ''; if (typeof callback !== 'undefined' && callback !== null) { @@ -690,7 +690,7 @@ class Media { } deleteOSD(OSDToken, callback) { - let promise = new Promise((resolve, reject) => { + const promise = new Promise((resolve, reject) => { let errMsg = ''; if (typeof callback !== 'undefined' && callback !== null) { @@ -726,7 +726,7 @@ class Media { } getOSDs(configurationToken, callback) { - let promise = new Promise((resolve, reject) => { + const promise = new Promise((resolve, reject) => { let errMsg = ''; if (typeof callback !== 'undefined' && callback !== null) { @@ -768,7 +768,7 @@ class Media { } getOSD(OSDToken, callback) { - let promise = new Promise((resolve, reject) => { + const promise = new Promise((resolve, reject) => { let errMsg = ''; if (typeof callback !== 'undefined' && callback !== null) { diff --git a/dist/modules/media2.js b/dist/modules/media2.js index 29da1a6e..13fe52de 100644 --- a/dist/modules/media2.js +++ b/dist/modules/media2.js @@ -18,12 +18,12 @@ class Media2 { } createRequest(body) { - let soapEnvelope = this.soap.createRequest({ - 'body': body, - 'xmlns': this.namespaceAttributes, - 'diff': this.timeDiff, - 'username': this.username, - 'password': this.password + const soapEnvelope = this.soap.createRequest({ + body: body, + xmlns: this.namespaceAttributes, + diff: this.timeDiff, + username: this.username, + password: this.password }); return soapEnvelope; } @@ -36,8 +36,8 @@ class Media2 { getProfiles() { return new Promise((resolve, reject) => { - let soapBody = ''; - let soapEnvelope = this.createRequest(soapBody); + const soapBody = ''; + const soapEnvelope = this.createRequest(soapBody); console.log(soapEnvelope); return this.soap.makeRequest('media2', this.serviceAddress, 'GetProfiles', soapEnvelope).then(results => { resolve(results); @@ -101,7 +101,7 @@ class Media2 { soapBody += ''; soapBody += '' + profileToken + ''; soapBody += ''; - let soapEnvelope = this.createRequest(soapBody); + const soapEnvelope = this.createRequest(soapBody); return this.soap.makeRequest('media2', this.serviceAddress, 'GetSnapshotUri', soapEnvelope).then(results => { resolve(results); }).catch(error => { diff --git a/dist/modules/ptz.js b/dist/modules/ptz.js index 822b9c7a..9608a640 100644 --- a/dist/modules/ptz.js +++ b/dist/modules/ptz.js @@ -25,18 +25,18 @@ class Ptz { } createRequest(body) { - let soapEnvelope = this.soap.createRequest({ - 'body': body, - 'xmlns': this.namespaceAttributes, - 'diff': this.timeDiff, - 'username': this.username, - 'password': this.password + const soapEnvelope = this.soap.createRequest({ + body: body, + xmlns: this.namespaceAttributes, + diff: this.timeDiff, + username: this.username, + password: this.password }); return soapEnvelope; } buildRequest(methodName, xml, callback) { - let promise = new Promise((resolve, reject) => { + const promise = new Promise((resolve, reject) => { let errMsg = ''; if (typeof callback !== 'undefined' && callback !== null) { @@ -66,7 +66,7 @@ class Ptz { soapBody += ``; } - let soapEnvelope = this.createRequest(soapBody); + const soapEnvelope = this.createRequest(soapBody); this.soap.makeRequest('ptz', this.serviceAddress, methodName, soapEnvelope).then(results => { resolve(results); }).catch(error => { @@ -106,7 +106,7 @@ class Ptz { } getNode(nodeToken, callback) { - let promise = new Promise((resolve, reject) => { + const promise = new Promise((resolve, reject) => { let errMsg = ''; if (typeof callback !== 'undefined' && callback !== null) { @@ -146,7 +146,7 @@ class Ptz { } getConfiguration(configurationToken, callback) { - let promise = new Promise((resolve, reject) => { + const promise = new Promise((resolve, reject) => { let errMsg = ''; if (typeof callback !== 'undefined' && callback !== null) { @@ -182,7 +182,7 @@ class Ptz { } getConfigurationOptions(configurationToken, callback) { - let promise = new Promise((resolve, reject) => { + const promise = new Promise((resolve, reject) => { let errMsg = ''; if (typeof callback !== 'undefined' && callback !== null) { @@ -218,7 +218,7 @@ class Ptz { } setConfiguration(configurationToken, ptzConfigurationOptions, forcePersistence, callback) { - let promise = new Promise((resolve, reject) => { + const promise = new Promise((resolve, reject) => { let errMsg = ''; if (typeof callback !== 'undefined' && callback !== null) { @@ -260,7 +260,7 @@ class Ptz { } getCompatibleConfigurations(profileToken, callback) { - let promise = new Promise((resolve, reject) => { + const promise = new Promise((resolve, reject) => { profileToken = profileToken || this.defaultProfileToken; let errMsg = ''; @@ -297,7 +297,7 @@ class Ptz { } absoluteMove(profileToken, position, speed, callback) { - let promise = new Promise((resolve, reject) => { + const promise = new Promise((resolve, reject) => { profileToken = profileToken || this.defaultProfileToken; let errMsg = ''; @@ -352,7 +352,7 @@ class Ptz { } relativeMove(profileToken, translation, speed, callback) { - let promise = new Promise((resolve, reject) => { + const promise = new Promise((resolve, reject) => { profileToken = profileToken || this.defaultProfileToken; let errMsg = ''; @@ -412,7 +412,7 @@ class Ptz { } continuousMove(profileToken, velocity, timeout, callback) { - let promise = new Promise((resolve, reject) => { + const promise = new Promise((resolve, reject) => { profileToken = profileToken || this.defaultProfileToken; let errMsg = ''; @@ -472,7 +472,7 @@ class Ptz { } geoMove(profileToken, geoLocation, speed, areaWidth, areaHeight, callback) { - let promise = new Promise((resolve, reject) => { + const promise = new Promise((resolve, reject) => { profileToken = profileToken || this.defaultProfileToken; let errMsg = ''; @@ -579,7 +579,7 @@ class Ptz { } stop(profileToken, panTilt, zoom, callback) { - let promise = new Promise((resolve, reject) => { + const promise = new Promise((resolve, reject) => { profileToken = profileToken || this.defaultProfileToken; let errMsg = ''; @@ -639,7 +639,7 @@ class Ptz { } getStatus(profileToken, callback) { - let promise = new Promise((resolve, reject) => { + const promise = new Promise((resolve, reject) => { profileToken = profileToken || this.defaultProfileToken; let errMsg = ''; @@ -676,7 +676,7 @@ class Ptz { } setPreset(profileToken, presetToken, presetName, callback) { - let promise = new Promise((resolve, reject) => { + const promise = new Promise((resolve, reject) => { profileToken = profileToken || this.defaultProfileToken; let errMsg = ''; @@ -741,7 +741,7 @@ class Ptz { } getPresets(profileToken, callback) { - let promise = new Promise((resolve, reject) => { + const promise = new Promise((resolve, reject) => { profileToken = profileToken || this.defaultProfileToken; let errMsg = ''; @@ -778,7 +778,7 @@ class Ptz { } gotoPreset(profileToken, presetToken, speed, callback) { - let promise = new Promise((resolve, reject) => { + const promise = new Promise((resolve, reject) => { profileToken = profileToken || this.defaultProfileToken; let errMsg = ''; @@ -833,7 +833,7 @@ class Ptz { } removePreset(profileToken, presetToken, callback) { - let promise = new Promise((resolve, reject) => { + const promise = new Promise((resolve, reject) => { profileToken = profileToken || this.defaultProfileToken; let errMsg = ''; @@ -876,7 +876,7 @@ class Ptz { } gotoHomePosition(profileToken, speed, callback) { - let promise = new Promise((resolve, reject) => { + const promise = new Promise((resolve, reject) => { profileToken = profileToken || this.defaultProfileToken; let errMsg = ''; @@ -925,7 +925,7 @@ class Ptz { } setHomePosition(profileToken, callback) { - let promise = new Promise((resolve, reject) => { + const promise = new Promise((resolve, reject) => { profileToken = profileToken || this.defaultProfileToken; let errMsg = ''; @@ -962,7 +962,7 @@ class Ptz { } sendAuxiliaryCommand(profileToken, auxiliaryData, callback) { - let promise = new Promise((resolve, reject) => { + const promise = new Promise((resolve, reject) => { profileToken = profileToken || this.defaultProfileToken; let errMsg = ''; diff --git a/dist/modules/receiver.js b/dist/modules/receiver.js index a1b077b2..95098e97 100644 --- a/dist/modules/receiver.js +++ b/dist/modules/receiver.js @@ -18,12 +18,12 @@ class Receiver { } createRequest(body) { - let soapEnvelope = this.soap.createRequest({ - 'body': body, - 'xmlns': this.namespaceAttributes, - 'diff': this.timeDiff, - 'username': this.username, - 'password': this.password + const soapEnvelope = this.soap.createRequest({ + body: body, + xmlns: this.namespaceAttributes, + diff: this.timeDiff, + username: this.username, + password: this.password }); return soapEnvelope; } diff --git a/dist/modules/recording.js b/dist/modules/recording.js index 8f5b0193..68db512b 100644 --- a/dist/modules/recording.js +++ b/dist/modules/recording.js @@ -18,12 +18,12 @@ class Recording { } createRequest(body) { - let soapEnvelope = this.soap.createRequest({ - 'body': body, - 'xmlns': this.namespaceAttributes, - 'diff': this.timeDiff, - 'username': this.username, - 'password': this.password + const soapEnvelope = this.soap.createRequest({ + body: body, + xmlns: this.namespaceAttributes, + diff: this.timeDiff, + username: this.username, + password: this.password }); return soapEnvelope; } diff --git a/dist/modules/replay.js b/dist/modules/replay.js index 69c859d7..4f589048 100644 --- a/dist/modules/replay.js +++ b/dist/modules/replay.js @@ -18,12 +18,12 @@ class Replay { } createRequest(body) { - let soapEnvelope = this.soap.createRequest({ - 'body': body, - 'xmlns': this.namespaceAttributes, - 'diff': this.timeDiff, - 'username': this.username, - 'password': this.password + const soapEnvelope = this.soap.createRequest({ + body: body, + xmlns: this.namespaceAttributes, + diff: this.timeDiff, + username: this.username, + password: this.password }); return soapEnvelope; } diff --git a/dist/modules/schedule.js b/dist/modules/schedule.js index c456b190..7cb0bc4c 100644 --- a/dist/modules/schedule.js +++ b/dist/modules/schedule.js @@ -18,12 +18,12 @@ class Schedule { } createRequest(body) { - let soapEnvelope = this.soap.createRequest({ - 'body': body, - 'xmlns': this.namespaceAttributes, - 'diff': this.timeDiff, - 'username': this.username, - 'password': this.password + const soapEnvelope = this.soap.createRequest({ + body: body, + xmlns: this.namespaceAttributes, + diff: this.timeDiff, + username: this.username, + password: this.password }); return soapEnvelope; } diff --git a/dist/modules/search.js b/dist/modules/search.js index a61c8167..52512318 100644 --- a/dist/modules/search.js +++ b/dist/modules/search.js @@ -18,12 +18,12 @@ class Search { } createRequest(body) { - let soapEnvelope = this.soap.createRequest({ - 'body': body, - 'xmlns': this.namespaceAttributes, - 'diff': this.timeDiff, - 'username': this.username, - 'password': this.password + const soapEnvelope = this.soap.createRequest({ + body: body, + xmlns: this.namespaceAttributes, + diff: this.timeDiff, + username: this.username, + password: this.password }); return soapEnvelope; } diff --git a/dist/modules/security.js b/dist/modules/security.js index 5df415b2..1cd8fdf9 100644 --- a/dist/modules/security.js +++ b/dist/modules/security.js @@ -18,12 +18,12 @@ class Security { } createRequest(body) { - let soapEnvelope = this.soap.createRequest({ - 'body': body, - 'xmlns': this.namespaceAttributes, - 'diff': this.timeDiff, - 'username': this.username, - 'password': this.password + const soapEnvelope = this.soap.createRequest({ + body: body, + xmlns: this.namespaceAttributes, + diff: this.timeDiff, + username: this.username, + password: this.password }); return soapEnvelope; } diff --git a/dist/modules/thermal.js b/dist/modules/thermal.js index a10f7c90..344290e6 100644 --- a/dist/modules/thermal.js +++ b/dist/modules/thermal.js @@ -18,12 +18,12 @@ class Thermal { } createRequest(body) { - let soapEnvelope = this.soapSoap.createRequest({ - 'body': body, - 'xmlns': this.namespaceAttributes, - 'diff': this.timeDiff, - 'username': this.username, - 'password': this.password + const soapEnvelope = this.soapSoap.createRequest({ + body: body, + xmlns: this.namespaceAttributes, + diff: this.timeDiff, + username: this.username, + password: this.password }); return soapEnvelope; } diff --git a/dist/modules/videoanalytics.js b/dist/modules/videoanalytics.js index dc5b7414..90c6f691 100644 --- a/dist/modules/videoanalytics.js +++ b/dist/modules/videoanalytics.js @@ -18,12 +18,12 @@ class VideoAnalytics { } createRequest(body) { - let soapEnvelope = this.soap.createRequest({ - 'body': body, - 'xmlns': this.namespaceAttributes, - 'diff': this.timeDiff, - 'username': this.username, - 'password': this.password + const soapEnvelope = this.soap.createRequest({ + body: body, + xmlns: this.namespaceAttributes, + diff: this.timeDiff, + username: this.username, + password: this.password }); return soapEnvelope; } diff --git a/dist/onvif-nvt.js b/dist/onvif-nvt.js index d518c665..6702fc34 100644 --- a/dist/onvif-nvt.js +++ b/dist/onvif-nvt.js @@ -9,7 +9,7 @@ class OnvifManager { add(name) { switch (name) { case 'discovery': - let Discovery = require('./modules/discovery'); + const Discovery = require('./modules/discovery'); this.discovery = new Discovery(); break; @@ -20,7 +20,7 @@ class OnvifManager { } connect(address, port, username, password, servicePath, callback) { - let promise = new Promise((resolve, reject) => { + const promise = new Promise((resolve, reject) => { let errMsg = ''; if (errMsg = Util.isInvalidValue(address, 'string')) { @@ -28,7 +28,7 @@ class OnvifManager { return; } - let c = this.cameras[address]; + const c = this.cameras[address]; if (c) { resolve(c); @@ -37,9 +37,9 @@ class OnvifManager { port = port || 80; - let Camera = require('./camera'); + const Camera = require('./camera'); - let camera = new Camera(); + const camera = new Camera(); return camera.connect(address, port, username, password, servicePath).then(results => { this.cameras[address] = camera; resolve(camera); diff --git a/dist/utils/save-xml.js b/dist/utils/save-xml.js index e46d1f00..38936d43 100644 --- a/dist/utils/save-xml.js +++ b/dist/utils/save-xml.js @@ -11,14 +11,14 @@ let path = Path.resolve(__dirname, '../../test/data/xml'); function saveXml(service, methodName, xml) { if (writable) { - let prettyXml = pd.xml(xml); - let folderPath = path + `/${service}`; + const prettyXml = pd.xml(xml); + const folderPath = path + `/${service}`; if (!Fs.existsSync(folderPath)) { Fs.mkdirSync(folderPath); } - let filePath = folderPath + `/${methodName}.xml`; + const filePath = folderPath + `/${methodName}.xml`; Fs.writeFileSync(filePath, prettyXml); } } diff --git a/dist/utils/snapshot.js b/dist/utils/snapshot.js index b24b7657..e745ed68 100644 --- a/dist/utils/snapshot.js +++ b/dist/utils/snapshot.js @@ -16,16 +16,16 @@ class Snapshot { } getSnapshot(callback) { - let promise = new Promise((resolve, reject) => { + const promise = new Promise((resolve, reject) => { Request({ method: 'GET', uri: this.snapshotUri, gzip: true, encoding: 'binary', - 'auth': { - 'user': this.username, - 'pass': this.password, - 'sendImmediately': false + auth: { + user: this.username, + pass: this.password, + sendImmediately: false } }, (error, response, body) => { if (error) { diff --git a/dist/utils/soap.js b/dist/utils/soap.js index 7ec0977c..708c2247 100644 --- a/dist/utils/soap.js +++ b/dist/utils/soap.js @@ -16,8 +16,8 @@ class Soap { } parse(soap) { - let promise = new Promise((resolve, reject) => { - let prefix = soap.substring(0, 2); + const promise = new Promise((resolve, reject) => { + const prefix = soap.substring(0, 2); if (prefix === '--') { resolve({ @@ -25,12 +25,12 @@ class Soap { soap }); } else { - let opts = { - 'explicitRoot': false, - 'explicitArray': false, - 'ignoreAttrs': false, - 'tagNameProcessors': [function (name) { - let m = name.match(/^([^\:]+)\:([^\:]+)$/); + const opts = { + explicitRoot: false, + explicitArray: false, + ignoreAttrs: false, + tagNameProcessors: [function (name) { + const m = name.match(/^([^\:]+)\:([^\:]+)$/); return m ? m[2] : name; }] }; @@ -65,7 +65,7 @@ class Soap { if (params['xmlns'] && Array.isArray(params['xmlns'])) { params['xmlns'].forEach(ns => { - let index = soap.indexOf(ns); + const index = soap.indexOf(ns); if (index < 0) { soap += ' ' + ns; @@ -77,7 +77,7 @@ class Soap { soap += ''; if (params.subscriptionId) { - let address = this.getAddress(params.subscriptionId); + const address = this.getAddress(params.subscriptionId); if (address) { soap += ''; @@ -104,7 +104,7 @@ class Soap { } makeRequest(service, serviceAddress, methodName, soapEnvelope, params) { - let promise = new Promise((resolve, reject) => { + const promise = new Promise((resolve, reject) => { Save.saveXml(service, methodName + '.Request', soapEnvelope); let xml = ''; return this.runRequest(service, serviceAddress, methodName, soapEnvelope).then(results => { @@ -117,27 +117,27 @@ class Soap { return; } - let fault = this.getFault(results['parsed']); + const fault = this.getFault(results['parsed']); if (fault) { Save.saveXml(service, methodName + '.Error', xml); - let err = new Error(`${methodName}`); + const err = new Error(`${methodName}`); err.fault = fault; err.soap = xml; reject(err); } else { - let parsed = this.parseResponse(methodName, results['parsed']); + const parsed = this.parseResponse(methodName, results['parsed']); if (parsed) { - let res = { - 'soap': xml, - 'schemas': results['parsed']['$'] ? results['parsed']['$'] : '', - 'data': parsed + const res = { + soap: xml, + schemas: results['parsed']['$'] ? results['parsed']['$'] : '', + data: parsed }; Save.saveXml(service, methodName + '.Response', xml); resolve(res); } else { - let err = new Error(methodName + ':The device seems to not support the ' + methodName + '() method.'); + const err = new Error(methodName + ':The device seems to not support the ' + methodName + '() method.'); reject(err); } } @@ -167,10 +167,10 @@ class Soap { throw new Error(`File does not exist for test: ${filePath}`); } - let xml = Fs.readFileSync(filePath, 'utf8'); + const xml = Fs.readFileSync(filePath, 'utf8'); resolve(xml); } else { - let options = { + const options = { method: 'POST', uri: serviceAddress.href, encoding: 'utf8', @@ -202,13 +202,13 @@ class Soap { } parseResponse(methodName, response) { - let s0 = response['Body']; + const s0 = response['Body']; if (!s0) { return null; } - let responseName = methodName + 'Response'; + const responseName = methodName + 'Response'; if (responseName in s0) { return s0; @@ -221,10 +221,10 @@ class Soap { let fault = ''; if ('Fault' in results['Body']) { - let bodyFault = results['Body']['Fault']; - let r1 = this.parseForReason(bodyFault); - let c1 = this.parseForCode(bodyFault); - let d1 = this.parseForDetail(bodyFault); + const bodyFault = results['Body']['Fault']; + const r1 = this.parseForReason(bodyFault); + const c1 = this.parseForCode(bodyFault); + const d1 = this.parseForDetail(bodyFault); fault = {}; fault.reason = r1; fault.code = c1; @@ -238,16 +238,16 @@ class Soap { let code = ''; if ('Code' in fault) { - let faultCode = fault['Code']; + const faultCode = fault['Code']; if ('Value' in faultCode) { - let faultValue = faultCode['Value']; + const faultValue = faultCode['Value']; if ('Subcode' in faultCode) { - let faultSubcode = faultCode['Subcode']; + const faultSubcode = faultCode['Subcode']; if ('Value' in faultSubcode) { - let faultSubcodeValue = faultSubcode['Value']; + const faultSubcodeValue = faultSubcode['Value']; code = faultValue + '|' + faultSubcodeValue; } else { code = faultSubcode; @@ -265,10 +265,10 @@ class Soap { let detail = ''; if ('Detail' in fault) { - let faultDetail = fault['Detail']; + const faultDetail = fault['Detail']; if ('Text' in faultDetail) { - let faultText = faultDetail['Text']; + const faultText = faultDetail['Text']; if (typeof faultText === 'string') { detail = faultText; @@ -285,10 +285,10 @@ class Soap { let reason = ''; if ('Reason' in fault) { - let faultReason = fault['Reason']; + const faultReason = fault['Reason']; if ('Text' in faultReason) { - let faultText = faultReason['Text']; + const faultText = faultReason['Text']; if (typeof faultText === 'string') { reason = faultText; @@ -312,13 +312,13 @@ class Soap { pass = ''; } - let created = new Date(Date.now() + diff).toISOString(); - let expires = new Date(Date.now() + diff + 10000).toISOString(); - let nonceBuffer = this.createNonce(16); - let nonceBase64 = nonceBuffer.toString('base64'); - let shasum = Crypto.createHash('sha1'); + const created = new Date(Date.now() + diff).toISOString(); + const expires = new Date(Date.now() + diff + 10000).toISOString(); + const nonceBuffer = this.createNonce(16); + const nonceBase64 = nonceBuffer.toString('base64'); + const shasum = Crypto.createHash('sha1'); shasum.update(Buffer.concat([nonceBuffer, Buffer.from(created), Buffer.from(pass)])); - let digest = shasum.digest('base64'); + const digest = shasum.digest('base64'); let soap = ''; soap += ''; soap += ' '; @@ -336,7 +336,7 @@ class Soap { } createNonce(digit) { - let nonce = Buffer.alloc(digit); + const nonce = Buffer.alloc(digit); for (let i = 0; i < digit; i++) { nonce.writeUInt8(Math.floor(Math.random() * 256), i); @@ -358,16 +358,16 @@ class Soap { getCustomSubscriptionIdXml(subscriptionId) { if (subscriptionId) { if (subscriptionId._) { - let id = subscriptionId._; + const id = subscriptionId._; let xml = null; if (subscriptionId.$) { - let keys = Object.keys(subscriptionId.$); - let tag = keys[0]; - let url = subscriptionId.$[tag]; + const keys = Object.keys(subscriptionId.$); + const tag = keys[0]; + const url = subscriptionId.$[tag]; if (id && tag && url) { - let tags = tag.split(':'); + const tags = tag.split(':'); xml = '' + id + ''; console.log(xml); } diff --git a/dist/utils/util.js b/dist/utils/util.js index d76ab5a6..775df1a1 100644 --- a/dist/utils/util.js +++ b/dist/utils/util.js @@ -5,11 +5,11 @@ const Crypto = require('crypto'); const Xml2js = require('xml2js'); function createUuidV4() { - let clist = Crypto.randomBytes(16).toString('hex').toLowerCase().split(''); + const clist = Crypto.randomBytes(16).toString('hex').toLowerCase().split(''); clist[12] = '4'; clist[16] = (parseInt(clist[16], 16) & 3 | 8).toString(16); - let m = clist.join('').match(/^(.{8})(.{4})(.{4})(.{4})(.{12})/); - let uuid = [m[1], m[2], m[3], m[4], m[5]].join('-'); + const m = clist.join('').match(/^(.{8})(.{4})(.{4})(.{4})(.{12})/); + const uuid = [m[1], m[2], m[3], m[4], m[5]].join('-'); return uuid; } @@ -24,7 +24,7 @@ function getTypeOfValue(value) { return 'array'; } - let t = typeof value; + const t = typeof value; if (t === 'boolean') { return 'boolean'; @@ -70,12 +70,12 @@ function isXml(xml) { return false; } - let opts = { - 'explicitRoot': false, - 'explicitArray': false, - 'ignoreAttrs': false, - 'tagNameProcessors': [function (name) { - let m = name.match(/^([^\:]+)\:([^\:]+)$/); + const opts = { + explicitRoot: false, + explicitArray: false, + ignoreAttrs: false, + tagNameProcessors: [function (name) { + const m = name.match(/^([^\:]+)\:([^\:]+)$/); return m ? m[2] : name; }] }; @@ -92,7 +92,7 @@ function isXml(xml) { } function isInvalidValue(value, type, allowEmpty) { - let vt = getTypeOfValue(value); + const vt = getTypeOfValue(value); if (type === 'xml') { if (!isXml(value)) {