New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@electorrent/xmlrpc

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@electorrent/xmlrpc - npm Package Compare versions

Comparing version 1.3.2 to 1.4.0

82

lib/client.js

@@ -7,2 +7,3 @@ var http = require('http')

, Cookies = require('./cookies')
, www_auth = require('www-authenticate')

@@ -57,9 +58,7 @@ /**

if (options.headers.Authorization == null &&
options.basic_auth != null &&
options.basic_auth.user != null &&
options.basic_auth.pass != null)
{
var auth = options.basic_auth.user + ':' + options.basic_auth.pass
options.headers['Authorization'] = 'Basic ' + new Buffer(auth).toString('base64')
this.username = options.username
this.password = options.password
if (this.username === undefined && this.password === undefined) {
this.auth = false
}

@@ -101,3 +100,15 @@

*/
Client.prototype.methodCall = function methodCall(method, params, callback) {
Client.prototype.methodCall = function methodCall(method, params, callback, retry) {
if (this.auth === undefined) {
this.authenticate(function(err) {
if (err) {
callback(err)
} else {
this.methodCall(method, params, callback)
}
}.bind(this))
return
}
var options = this.options

@@ -107,9 +118,18 @@ var xml = Serializer.serializeMethodCall(method, params, options.encoding)

// Authenticate request using authenticator
if (this.auth !== false) {
this.auth.authenticate_request_options(options)
if (this.auth.err) {
return callback(this.auth.err)
}
}
options.headers['Content-Length'] = Buffer.byteLength(xml, 'utf8')
this.headersProcessors.composeRequest(options.headers)
var request = transport.request(options, function(response) {
if (this.auth !== false) {
this.auth.get_challenge(response)
}
var body = []
response.on('data', function (chunk) { body.push(chunk) })
function __enrichError (err) {

@@ -122,2 +142,13 @@ Object.defineProperty(err, 'req', { value: request })

if (response.statusCode == 401) {
if (retry === false) {
return callback(__enrichError(new Error("Unauthorized")))
} else {
return this.methodCall(method, params, callback, false)
}
}
var body = []
response.on('data', function (chunk) { body.push(chunk) })
if (response.statusCode == 404) {

@@ -141,2 +172,5 @@ callback(__enrichError(new Error('Not Found')))

request.on('error', callback)
request.on('timeout', function() {
request.abort()
})
request.write(xml, 'utf8')

@@ -182,3 +216,27 @@ request.end()

/**
* Authenticates the client using basic auth of digest auth.
*
* @param {Function} callback - function(error) { ... }
*/
Client.prototype.authenticate = function(callback) {
var options = this.options
var transport = this.isSecure ? https : http
var request = transport.request(options, function(response) {
var auth = www_auth.authenticator(this.username, this.password)
auth.get_challenge(response)
this.auth = auth
callback()
}.bind(this))
request.on('error', callback)
request.on('timeout', function() {
request.abort()
})
request.end()
}
module.exports = Client

6

package.json

@@ -10,7 +10,7 @@ {

],
"version": "1.3.2",
"version": "1.4.0",
"homepage": "https://github.com/tympanix/node-xmlrpc",
"author": "Brandon Alexander <baalexander@gmail.com> (https://github.com/baalexander)",
"contributors": [
"tympanix <tympanix@gmail.com>"
"tympanix <tympanix@gmail.com>"
],

@@ -30,3 +30,3 @@ "repository": {

"sax": "1.2.x",
"urllib": "^2.29.1",
"www-authenticate": "^0.6.2",
"xmlbuilder": "8.2.x"

@@ -33,0 +33,0 @@ },

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc