Socket
Socket
Sign inDemoInstall

soap

Package Overview
Dependencies
Maintainers
3
Versions
95
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

soap - npm Package Compare versions

Comparing version 0.40.0 to 0.41.0

7

History.md

@@ -0,1 +1,8 @@

0.41.0 / 2021-08-20
===================
* [ENHANCEMENT] Support for soap attachments in response. (#1148)
* [FIX] Correctly add the https agent to axios (#1154)
* [FIX] prefer SOAPAction header over the body name to get the actual method name (#1152)
* [MAINTENANCE] Moving to github actions
0.40.0 / 2021-07-06

@@ -2,0 +9,0 @@ ===================

3

lib/client.d.ts
/// <reference types="node" />
import { EventEmitter } from 'events';
import { IncomingHttpHeaders } from 'http';
import { IHeaders, IOptions, ISecurity } from './types';
import { IHeaders, IMTOMAttachments, IOptions, ISecurity } from './types';
import { WSDL } from './wsdl';

@@ -34,2 +34,3 @@ export interface ISoapError extends Error {

lastElapsedTime?: number;
lastResponseAttachments: IMTOMAttachments;
private wsdl;

@@ -36,0 +37,0 @@ private httpClient;

@@ -172,3 +172,3 @@ "use strict";

return new Promise(function (resolve, reject) {
var callback = function (err, result, rawResponse, soapHeader, rawRequest) {
var callback = function (err, result, rawResponse, soapHeader, rawRequest, mtomAttachments) {
if (err) {

@@ -178,3 +178,3 @@ reject(err);

else {
resolve([result, rawResponse, soapHeader, rawRequest]);
resolve([result, rawResponse, soapHeader, rawRequest, mtomAttachments]);
}

@@ -205,4 +205,4 @@ };

}
_this_1._invoke(method, args, location, function (error, result, rawResponse, soapHeader, rawRequest) {
callback(error, result, rawResponse, soapHeader, rawRequest);
_this_1._invoke(method, args, location, function (error, result, rawResponse, soapHeader, rawRequest, mtomAttachments) {
callback(error, result, rawResponse, soapHeader, rawRequest, mtomAttachments);
}, options, extraHeaders);

@@ -254,3 +254,3 @@ };

// one-way, no output expected
return callback(null, null, body, obj.Header, xml);
return callback(null, null, body, obj.Header, xml, response.mtomResponseAttachments);
}

@@ -288,3 +288,3 @@ // If it's not HTML and Soap Body is empty

}
callback(null, result, body, obj.Header, xml);
callback(null, result, body, obj.Header, xml, response.mtomResponseAttachments);
};

@@ -310,3 +310,3 @@ var parseSync = function (body, response) {

_this_1.emit('soapError', error, eid);
return callback(error, response, body, undefined, xml);
return callback(error, response, body, undefined, xml, response.mtomResponseAttachments);
}

@@ -483,2 +483,3 @@ return finish(obj, body, response);

_this_1.lastElapsedTime = response.headers.date;
_this_1.lastResponseAttachments = response.mtomResponseAttachments;
// Added mostly for testability, but possibly useful for debugging

@@ -485,0 +486,0 @@ _this_1.lastRequestHeaders = response.config && response.config.headers;

@@ -20,2 +20,3 @@ /// <reference types="node" />

private _request;
private options;
constructor(options?: IOptions);

@@ -22,0 +23,0 @@ /**

@@ -21,5 +21,7 @@ "use strict";

var axios_ntlm_1 = require("axios-ntlm");
var contentTypeParser = require("content-type-parser");
var debugBuilder = require("debug");
var url = require("url");
var uuid_1 = require("uuid");
var utils_1 = require("./utils");
var debug = debugBuilder('node-soap');

@@ -37,2 +39,3 @@ var VERSION = require('../package.json').version;

options = options || {};
this.options = options;
this._request = options.request || req["default"].create();

@@ -147,3 +150,3 @@ }

HttpClient.prototype.request = function (rurl, data, callback, exheaders, exoptions, caller) {
var _this = this;
var _this_1 = this;
var options = this.buildRequest(rurl, data, exheaders, exoptions);

@@ -160,6 +163,36 @@ var req;

else {
if (this.options.parseReponseAttachments) {
options.responseType = 'arraybuffer';
options.responseEncoding = 'binary';
}
req = this._request(options);
}
var _this = this;
req.then(function (res) {
res.data = _this.handleResponse(req, res, res.data);
var body;
if (_this.options.parseReponseAttachments) {
var isMultipartResp = res.headers['content-type'] && res.headers['content-type'].toLowerCase().indexOf('multipart/related') > -1;
if (isMultipartResp) {
var boundary = void 0;
var parsedContentType = contentTypeParser(res.headers['content-type']);
if (parsedContentType && parsedContentType.parameterList) {
boundary = (parsedContentType.parameterList.find(function (item) { return item.key === 'boundary'; }) || {}).value;
}
if (!boundary) {
return callback(new Error('Missing boundary from content-type'));
}
var multipartResponse = utils_1.parseMTOMResp(res.data, boundary);
// first part is the soap response
var firstPart = multipartResponse.parts.shift();
if (!firstPart || !firstPart.body) {
return callback(new Error('Cannot parse multipart response'));
}
body = firstPart.body.toString('utf8');
res.mtomResponseAttachments = multipartResponse;
}
else {
body = res.data.toString('utf8');
}
}
res.data = _this_1.handleResponse(req, res, body || res.data);
callback(null, res, res.data);

@@ -173,7 +206,7 @@ return res;

HttpClient.prototype.requestStream = function (rurl, data, exheaders, exoptions, caller) {
var _this = this;
var _this_1 = this;
var options = this.buildRequest(rurl, data, exheaders, exoptions);
options.responseType = 'stream';
var req = this._request(options).then(function (res) {
res.data = _this.handleResponse(req, res, res.data);
res.data = _this_1.handleResponse(req, res, res.data);
return res;

@@ -180,0 +213,0 @@ });

@@ -76,3 +76,3 @@ "use strict";

}
options.agent = httpsAgent;
options.httpsAgent = httpsAgent;
};

@@ -79,0 +79,0 @@ return ClientSSLSecurity;

@@ -48,3 +48,3 @@ "use strict";

_.merge(options, this.defaults);
options.agent = new https.Agent(options);
options.httpsAgent = new https.Agent(options);
};

@@ -51,0 +51,0 @@ return ClientSSLSecurityPFX;

@@ -48,3 +48,5 @@ /// <reference types="node" />

private _requestListener;
private _getSoapAction;
private _process;
private _getMethodNameBySoapAction;
private _executeMethod;

@@ -51,0 +53,0 @@ private _envelope;

@@ -241,2 +241,8 @@ "use strict";

};
Server.prototype._getSoapAction = function (req) {
var soapAction = req.headers.soapaction;
return (soapAction.indexOf('"') === 0)
? soapAction.slice(1, -1)
: soapAction;
};
Server.prototype._process = function (input, req, res, cb) {

@@ -308,2 +314,3 @@ var _this_1 = this;

portName: portName,
soapAction: _this_1._getSoapAction(req),
methodName: methodName,

@@ -327,2 +334,3 @@ outputName: methodName + 'Response',

portName: portName,
soapAction: _this_1._getSoapAction(req),
methodName: pair.methodName,

@@ -410,2 +418,9 @@ outputName: pair.outputName,

};
Server.prototype._getMethodNameBySoapAction = function (binding, soapAction) {
for (var methodName in binding.methods) {
if (binding.methods[methodName].soapAction === soapAction) {
return methodName;
}
}
};
Server.prototype._executeMethod = function (options, req, res, callback, includeTimestamp) {

@@ -419,3 +434,6 @@ var _this_1 = this;

var portName = options.portName;
var methodName = options.methodName;
var binding = this.wsdl.definitions.services[serviceName].ports[portName].binding;
var methodName = options.soapAction
? this._getMethodNameBySoapAction(binding, options.soapAction)
: options.methodName;
var outputName = options.outputName;

@@ -465,3 +483,3 @@ var args = options.args;

else {
var element = _this_1.wsdl.definitions.services[serviceName].ports[portName].binding.methods[methodName].output;
var element = binding.methods[methodName].output;
body = _this_1.wsdl.objectToDocumentXML(outputName, result, element.targetNSAlias, element.targetNamespace);

@@ -471,3 +489,3 @@ }

};
if (!this.wsdl.definitions.services[serviceName].ports[portName].binding.methods[methodName].output) {
if (!binding.methods[methodName].output) {
// no output defined = one-way operation so return empty response

@@ -474,0 +492,0 @@ handled = true;

@@ -16,4 +16,4 @@ /// <reference types="node" />

export declare type ISoapMethod = SoapMethod;
export declare type SoapMethod = (args: any, callback: (err: any, result: any, rawResponse: any, soapHeader: any, rawRequest: any) => void, options?: any, extraHeaders?: any) => void;
export declare type SoapMethodAsync = (args: any, options?: any, extraHeaders?: any) => Promise<[any, any, any, any]>;
export declare type SoapMethod = (args: any, callback: (err: any, result: any, rawResponse: any, soapHeader: any, rawRequest: any, mtomAttachments?: IMTOMAttachments) => void, options?: any, extraHeaders?: any, mtomAttachments?: IMTOMAttachments) => void;
export declare type SoapMethodAsync = (args: any, options?: any, extraHeaders?: any) => Promise<[any, any, any, any, IMTOMAttachments?]>;
export declare type ISoapServiceMethod = (args: any, callback?: (data: any) => void, headers?: any, req?: any, res?: any, sender?: any) => any;

@@ -118,2 +118,4 @@ export interface ISoapFaultError {

overridePromiseSuffix?: string;
/** handle MTOM soapAttachments in response */
parseReponseAttachments?: boolean;
}

@@ -136,1 +138,9 @@ export interface IOneWayOptions {

}
export interface IMTOMAttachments {
parts: Array<{
body: Buffer;
headers: {
[key: string]: string;
};
}>;
}

@@ -0,1 +1,3 @@

/// <reference types="node" />
import { IMTOMAttachments } from './types';
export declare function passwordDigest(nonce: string, created: string, password: string): string;

@@ -18,1 +20,2 @@ export declare const TNS_PREFIX = "__tns__";

export declare function xmlEscape(obj: any): any;
export declare function parseMTOMResp(payload: Buffer, boundary: string): IMTOMAttachments;
"use strict";
exports.__esModule = true;
exports.xmlEscape = exports.splitQName = exports.findPrefix = exports.TNS_PREFIX = exports.passwordDigest = void 0;
exports.parseMTOMResp = exports.xmlEscape = exports.splitQName = exports.findPrefix = exports.TNS_PREFIX = exports.passwordDigest = void 0;
var crypto = require("crypto");
var multipart_parser_js_1 = require("formidable/lib/multipart_parser.js");
function passwordDigest(nonce, created, password) {

@@ -64,2 +65,41 @@ // digest = base64 ( sha1 ( nonce + created + password ) )

exports.xmlEscape = xmlEscape;
function parseMTOMResp(payload, boundary) {
var resp = {
parts: []
};
var headerName = '';
var headerValue = '';
var data;
var partIndex = 0;
var parser = new multipart_parser_js_1.MultipartParser();
parser.initWithBoundary(boundary);
parser.onPartBegin = function () {
resp.parts[partIndex] = {
body: null,
headers: {}
};
data = Buffer.from('');
};
parser.onHeaderField = function (b, start, end) {
headerName = b.slice(start, end).toString();
};
parser.onHeaderValue = function (b, start, end) {
headerValue = b.slice(start, end).toString();
};
parser.onHeaderEnd = function () {
resp.parts[partIndex].headers[headerName.toLowerCase()] = headerValue;
};
parser.onHeadersEnd = function () { };
parser.onPartData = function (b, start, end) {
data = Buffer.concat([data, b.slice(start, end)]);
};
parser.onPartEnd = function () {
resp.parts[partIndex].body = data;
partIndex++;
};
parser.onEnd = function () { };
parser.write(payload);
return resp;
}
exports.parseMTOMResp = parseMTOMResp;
//# sourceMappingURL=utils.js.map
{
"name": "soap",
"version": "0.40.0",
"version": "0.41.0",
"description": "A minimal node SOAP client",

@@ -12,4 +12,7 @@ "engines": {

"axios-ntlm": "^1.1.6",
"content-type-parser": "^1.0.2",
"debug": "^4.3.1",
"formidable": "^1.2.2",
"get-stream": "^6.0.1",
"httpntlm": "^1.5.2",
"lodash": "^4.17.21",

@@ -16,0 +19,0 @@ "sax": ">=0.6",

@@ -154,4 +154,5 @@ # Soap [![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Coveralls Status][coveralls-image]][coveralls-url] [![Gitter chat][gitter-image]][gitter-url]

- returnSaxStream: enables the library to return the sax stream, transferring to the end user the responsibility of parsing the XML. It can be used only in combination with *stream* argument set to `true`. Default: `false`
- parseReponseAttachments: Treat response as multipart/related response with MTOM attachment. Reach attachments on the `lastResponseAttachments` property of SoapClient. Default: `false`
Note: for versions of node >0.10.X, you may need to specify `{connection: 'keep-alive'}` in SOAP headers to avoid truncation of longer chunked responses.
Note: for versions of node >0.10.X, you may need to specify `{connection: 'keep-alive'}` in SOAP headers to avoid truncation of longer chunked responses.

@@ -158,0 +159,0 @@ ### soap.listen(*server*, *path*, *services*, *wsdl*, *callback*) - create a new SOAP server that listens on *path* and provides *services*.

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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