Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/modules/http-auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ OnvifHttpAuth.prototype._createAuthReqHeaderValue = function(o) {
};

OnvifHttpAuth.prototype._createCnonce = function(digit) {
let nonce = new Buffer(digit);
let nonce = Buffer.alloc(digit);
for(let i=0; i<digit; i++){
nonce.writeUInt8(Math.floor(Math.random() * 256), i);
}
Expand Down Expand Up @@ -127,4 +127,4 @@ OnvifHttpAuth.prototype._parseAuthHeader = function(h) {
return o;
};

module.exports = new OnvifHttpAuth();
module.exports = new OnvifHttpAuth();
16 changes: 8 additions & 8 deletions lib/modules/soap.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ OnvifSoap.prototype._request = function(oxaddr, soap) {
'Content-Length': Buffer.byteLength(soap)
}
};

let req = mHttp.request(post_opts, (res) => {
res.setEncoding('utf8');
let xml = '';
Expand Down Expand Up @@ -154,20 +154,20 @@ OnvifSoap.prototype._request = function(oxaddr, soap) {
res = null;
});
});

req.setTimeout(this.HTTP_TIMEOUT);

req.on('timeout', () => {
req.abort();
});

req.on('error', (error) => {
req.removeAllListeners('error');
req.removeAllListeners('timeout');
req = null;
reject(new Error('Network Error: ' + (error ? error.message : '')));
});

req.write(soap, 'utf8');
req.end();
});
Expand Down Expand Up @@ -234,7 +234,7 @@ OnvifSoap.prototype._createSoapUserToken = function(diff, user, pass) {
let nonce_buffer = this._createNonce(16);
let nonce_base64 = nonce_buffer.toString('base64');
let shasum = mCrypto.createHash('sha1');
shasum.update(Buffer.concat([nonce_buffer, new Buffer(date), new Buffer(pass)]));
shasum.update(Buffer.concat([nonce_buffer, Buffer.from(date), Buffer.from(pass)]));
let digest = shasum.digest('base64');
let soap = '';
soap += '<Security s:mustUnderstand="1" xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">';
Expand All @@ -249,7 +249,7 @@ OnvifSoap.prototype._createSoapUserToken = function(diff, user, pass) {
};

OnvifSoap.prototype._createNonce = function(digit) {
let nonce = new Buffer(digit);
let nonce = Buffer.alloc(digit);
for(let i=0; i<digit; i++){
nonce.writeUInt8(Math.floor(Math.random() * 256), i);
}
Expand Down Expand Up @@ -320,4 +320,4 @@ OnvifSoap.prototype._getTypeOfValue = function(value) {
}
}

module.exports = new OnvifSoap();
module.exports = new OnvifSoap();