soap 0.20.0 → 0.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.editorconfig +23 -23
- package/.jshintrc +29 -29
- package/.travis.yml +22 -22
- package/CONTRIBUTING.md +52 -58
- package/History.md +52 -2
- package/LICENSE +7 -7
- package/PUBLISHING.md +28 -28
- package/Readme.md +1062 -931
- package/coverage/coverage.json +1 -0
- package/coverage/lcov-report/base.css +212 -0
- package/coverage/lcov-report/index.html +119 -0
- package/coverage/lcov-report/node-soap/index.html +93 -0
- package/coverage/lcov-report/node-soap/index.js.html +74 -0
- package/coverage/lcov-report/node-soap/lib/client.js.html +1001 -0
- package/coverage/lcov-report/node-soap/lib/http.js.html +416 -0
- package/coverage/lcov-report/node-soap/lib/index.html +171 -0
- package/coverage/lcov-report/node-soap/lib/nscontext.js.html +734 -0
- package/coverage/lcov-report/node-soap/lib/security/BasicAuthSecurity.js.html +137 -0
- package/coverage/lcov-report/node-soap/lib/security/BearerSecurity.js.html +134 -0
- package/coverage/lcov-report/node-soap/lib/security/ClientSSLSecurity.js.html +296 -0
- package/coverage/lcov-report/node-soap/lib/security/ClientSSLSecurityPFX.js.html +218 -0
- package/coverage/lcov-report/node-soap/lib/security/WSSecurity.js.html +278 -0
- package/coverage/lcov-report/node-soap/lib/security/index.html +158 -0
- package/coverage/lcov-report/node-soap/lib/security/index.js.html +92 -0
- package/coverage/lcov-report/node-soap/lib/server.js.html +1139 -0
- package/coverage/lcov-report/node-soap/lib/soap.js.html +314 -0
- package/coverage/lcov-report/node-soap/lib/utils.js.html +161 -0
- package/coverage/lcov-report/node-soap/lib/wsdl.js.html +6275 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +1 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +158 -0
- package/coverage/lcov.info +3325 -0
- package/index.js +3 -3
- package/lib/client.js +434 -425
- package/lib/http.js +129 -129
- package/lib/nscontext.js +223 -223
- package/lib/security/BasicAuthSecurity.js +24 -24
- package/lib/security/BearerSecurity.js +23 -23
- package/lib/security/ClientSSLSecurity.js +82 -65
- package/lib/security/ClientSSLSecurityPFX.js +51 -51
- package/lib/security/WSSecurity.js +90 -90
- package/lib/security/WSSecurityCert.js +78 -78
- package/lib/security/index.js +10 -10
- package/lib/security/templates/wsse-security-header.ejs +12 -12
- package/lib/security/templates/wsse-security-token.ejs +3 -3
- package/lib/server.js +474 -444
- package/lib/soap.d.ts +220 -0
- package/lib/soap.js +110 -110
- package/lib/utils.js +30 -30
- package/lib/wsdl.js +2272 -2234
- package/package.json +8 -8
- package/soap-stub.js +148 -148
- package/.npmignore +0 -2
package/lib/soap.d.ts
ADDED
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
|
|
3
|
+
import { EventEmitter } from 'events';
|
|
4
|
+
import * as BluebirdPromise from 'bluebird';
|
|
5
|
+
|
|
6
|
+
export interface ISoapMethod {
|
|
7
|
+
(args: any, callback: (err: any, result: any, raw: any, soapHeader: any) => void, options?: any, extraHeaders?: any): void;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface ISoapServiceMethod {
|
|
11
|
+
(args:any, callback?: (data: any) => void, headers?: any, req?: any): any;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// SOAP Fault 1.1 & 1.2
|
|
15
|
+
export type ISoapFault = ISoapFault12 | ISoapFault11;
|
|
16
|
+
|
|
17
|
+
// SOAP Fault 1.1
|
|
18
|
+
export interface ISoapFault11 {
|
|
19
|
+
Fault: {
|
|
20
|
+
faultcode: number | string;
|
|
21
|
+
faultstring: string;
|
|
22
|
+
detail?: string;
|
|
23
|
+
statusCode?: number;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// SOAP Fault 1.2
|
|
28
|
+
// 1.2 also supports additional, optional elements:
|
|
29
|
+
// Role, Node, Detail. Should be added when soap module implements them
|
|
30
|
+
// https://www.w3.org/TR/soap12/#soapfault
|
|
31
|
+
export interface ISoapFault12 {
|
|
32
|
+
Fault: {
|
|
33
|
+
Code: { Value: string; Subcode?: { Value: string; }; };
|
|
34
|
+
Reason: { Text: string; };
|
|
35
|
+
statusCode?: number;
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface ISecurity {
|
|
40
|
+
addOptions(options: any): void;
|
|
41
|
+
toXML(): string;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface IServicePort {
|
|
45
|
+
[methodName: string]: ISoapServiceMethod;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export interface IService {
|
|
49
|
+
[portName: string]: IServicePort;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export interface IServices {
|
|
53
|
+
[serviceName: string]: IService;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export interface IXmlAttribute {
|
|
57
|
+
name: string;
|
|
58
|
+
value: string;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export interface IWsdlBaseOptions {
|
|
62
|
+
attributesKey?: string;
|
|
63
|
+
valueKey?: string;
|
|
64
|
+
xmlKey?: string;
|
|
65
|
+
overrideRootElement?: { namespace: string; xmlnsAttributes?: IXmlAttribute[]; };
|
|
66
|
+
ignoredNamespaces?: boolean | string[] | { namespaces?: string[]; override?: boolean; };
|
|
67
|
+
ignoreBaseNameSpaces?: boolean;
|
|
68
|
+
escapeXML?: boolean;
|
|
69
|
+
returnFault?: boolean;
|
|
70
|
+
handleNilAsNull?: boolean;
|
|
71
|
+
wsdl_headers?: { [key: string]: any };
|
|
72
|
+
wsdl_options?: { [key: string]: any };
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export interface IOptions extends IWsdlBaseOptions {
|
|
76
|
+
disableCache?: boolean;
|
|
77
|
+
endpoint?: string;
|
|
78
|
+
envelopeKey?: string;
|
|
79
|
+
httpClient?: HttpClient;
|
|
80
|
+
request?: (options: any, callback?: (error: any, res: any, body: any) => void) => void;
|
|
81
|
+
stream?: boolean;
|
|
82
|
+
// wsdl options that only work for client
|
|
83
|
+
forceSoap12Headers?: boolean;
|
|
84
|
+
customDeserializer?: any;
|
|
85
|
+
[key: string]: any;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export interface IOneWayOptions {
|
|
89
|
+
responseCode?: number;
|
|
90
|
+
emptyBody?: boolean;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export interface IServerOptions extends IWsdlBaseOptions {
|
|
94
|
+
path: string;
|
|
95
|
+
services: IServices;
|
|
96
|
+
xml?: string;
|
|
97
|
+
uri?: string;
|
|
98
|
+
suppressStack?: boolean;
|
|
99
|
+
oneWay?: IOneWayOptions;
|
|
100
|
+
[key: string]: any;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export class WSDL {
|
|
104
|
+
constructor(definition: any, uri: string, options?: IOptions);
|
|
105
|
+
ignoredNamespaces: string[];
|
|
106
|
+
ignoreBaseNameSpaces: boolean;
|
|
107
|
+
valueKey: string;
|
|
108
|
+
xmlKey: string;
|
|
109
|
+
xmlnsInEnvelope: string;
|
|
110
|
+
onReady(callback: (err:Error) => void): void;
|
|
111
|
+
processIncludes(callback: (err:Error) => void): void;
|
|
112
|
+
describeServices(): { [k: string]: any };
|
|
113
|
+
toXML(): string;
|
|
114
|
+
xmlToObject(xml: any, callback?: (err:Error, result:any) => void): any;
|
|
115
|
+
findSchemaObject(nsURI: string, qname: string): any;
|
|
116
|
+
objectToDocumentXML(name: string, params: any, nsPrefix?: string, nsURI?: string, type?: string): any;
|
|
117
|
+
objectToRpcXML(name: string, params: any, nsPrefix?: string, nsURI?: string, isParts?: any): string;
|
|
118
|
+
isIgnoredNameSpace(ns: string): boolean;
|
|
119
|
+
filterOutIgnoredNameSpace(ns: string): string;
|
|
120
|
+
objectToXML(obj: any, name: string, nsPrefix?: any, nsURI?: string, isFirst?: boolean, xmlnsAttr?: any, schemaObject?: any, nsContext?: any): string;
|
|
121
|
+
processAttributes(child: any, nsContext: any): string;
|
|
122
|
+
findSchemaType(name: any, nsURI: any): any;
|
|
123
|
+
findChildSchemaObject(parameterTypeObj: any, childName: any, backtrace?: any): any;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export class Client extends EventEmitter {
|
|
127
|
+
constructor(wsdl: WSDL, endpoint?: string, options?: IOptions);
|
|
128
|
+
addBodyAttribute(bodyAttribute: any, name?: string, namespace?: string, xmlns?: string): void;
|
|
129
|
+
addHttpHeader(name: string, value: any): void;
|
|
130
|
+
addSoapHeader(soapHeader: any, name?: string, namespace?: any, xmlns?: string): number;
|
|
131
|
+
changeSoapHeader(index: number, soapHeader: any, name?: string, namespace?: string, xmlns?: string): void;
|
|
132
|
+
clearBodyAttributes(): void;
|
|
133
|
+
clearHttpHeaders(): void;
|
|
134
|
+
clearSoapHeaders(): void;
|
|
135
|
+
describe(): any;
|
|
136
|
+
getBodyAttributes(): any[];
|
|
137
|
+
getHttpHeaders(): { [k:string]: string };
|
|
138
|
+
getSoapHeaders(): string[];
|
|
139
|
+
setEndpoint(endpoint: string): void;
|
|
140
|
+
setSOAPAction(action: string): void;
|
|
141
|
+
setSecurity(security: ISecurity): void;
|
|
142
|
+
wsdl: WSDL;
|
|
143
|
+
[method: string]: ISoapMethod | WSDL | Function;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export function createClient(url: string, callback: (err: any, client: Client) => void): void;
|
|
147
|
+
export function createClient(url: string, options: IOptions, callback: (err: any, client: Client) => void): void;
|
|
148
|
+
export function createClientAsync(url: string, options?: IOptions, endpoint?: string): BluebirdPromise<Client>;
|
|
149
|
+
|
|
150
|
+
export class Server extends EventEmitter {
|
|
151
|
+
constructor(server: any, path: string, services: IServices, wsdl: WSDL, options: IServerOptions);
|
|
152
|
+
path: string;
|
|
153
|
+
services: IServices;
|
|
154
|
+
wsdl: WSDL;
|
|
155
|
+
addSoapHeader(soapHeader: any, name?: string, namespace?: any, xmlns?: string): number;
|
|
156
|
+
changeSoapHeader(index: any, soapHeader: any, name?: any, namespace?: any, xmlns?: any): void;
|
|
157
|
+
getSoapHeaders(): string[];
|
|
158
|
+
clearSoapHeaders(): void;
|
|
159
|
+
log(type: string, data: any): any;
|
|
160
|
+
authorizeConnection(req: any): boolean;
|
|
161
|
+
authenticate(security: ISecurity): boolean;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export function listen(server: any, path: string, service: any, wsdl: string): Server;
|
|
165
|
+
export function listen(server: any, options: IServerOptions): Server;
|
|
166
|
+
|
|
167
|
+
export class HttpClient {
|
|
168
|
+
constructor(options?: IOptions);
|
|
169
|
+
buildRequest(rurl: string, data: any | string, exheaders?: { [key: string]: any }, exoptions?: { [key: string]: any }): any;
|
|
170
|
+
handleResponse(req: any, res: any, body: any | string): any | string;
|
|
171
|
+
request(rurl: string, data: any | string, callback: (err: any, res: any, body: any | string) => void, exheaders?: { [key: string]: any }, exoptions?: { [key: string]: any }): any;
|
|
172
|
+
requestStream(rurl: string, data: any | string, exheaders?: { [key: string]: any }, exoptions?: { [key: string]: any }): any;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
export class BasicAuthSecurity implements ISecurity {
|
|
176
|
+
constructor(username: string, password: string, defaults?: any);
|
|
177
|
+
addHeaders(headers: any): void;
|
|
178
|
+
addOptions(options: any): void;
|
|
179
|
+
toXML(): string;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
export class BearerSecurity implements ISecurity {
|
|
183
|
+
constructor(token: string, defaults?: any);
|
|
184
|
+
addHeaders(headers: any): void;
|
|
185
|
+
addOptions(options: any): void;
|
|
186
|
+
toXML(): string;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
export class WSSecurity implements ISecurity {
|
|
190
|
+
constructor(username: string, password: string, options?: any);
|
|
191
|
+
addOptions(options: any): void;
|
|
192
|
+
toXML(): string;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
export class WSSecurityCert implements ISecurity {
|
|
196
|
+
constructor(privatePEM: any, publicP12PEM: any, password: any);
|
|
197
|
+
addOptions(options: any): void;
|
|
198
|
+
toXML(): string;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
export class ClientSSLSecurity implements ISecurity {
|
|
202
|
+
constructor(key: string | Buffer, cert: string | Buffer, ca?: string | any[] | Buffer, defaults?: any);
|
|
203
|
+
constructor(key: string | Buffer, cert: string | Buffer, defaults?: any);
|
|
204
|
+
addOptions(options: any): void;
|
|
205
|
+
toXML(): string;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
export class ClientSSLSecurityPFX implements ISecurity {
|
|
209
|
+
constructor(pfx: string | Buffer, passphrase: string, defaults?: any);
|
|
210
|
+
constructor(pfx: string | Buffer, defaults?: any);
|
|
211
|
+
addOptions(options: any): void;
|
|
212
|
+
toXML(): string;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
export function passwordDigest(nonce: string, created: string, password: string): string;
|
|
216
|
+
|
|
217
|
+
// Below are added for backwards compatibility for previous @types/soap users.
|
|
218
|
+
export interface Security extends ISecurity {}
|
|
219
|
+
export interface SoapMethod extends ISoapMethod {}
|
|
220
|
+
export interface Option extends IOptions {}
|
package/lib/soap.js
CHANGED
|
@@ -1,110 +1,110 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2011 Vinay Pulim <vinay@milewise.com>
|
|
3
|
-
* MIT Licensed
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
"use strict";
|
|
7
|
-
|
|
8
|
-
var Client = require('./client').Client,
|
|
9
|
-
Server = require('./server').Server,
|
|
10
|
-
HttpClient = require('./http'),
|
|
11
|
-
security = require('./security'),
|
|
12
|
-
passwordDigest = require('./utils').passwordDigest,
|
|
13
|
-
BluebirdPromise = require('bluebird'),
|
|
14
|
-
wsdl = require('./wsdl'),
|
|
15
|
-
WSDL = require('./wsdl').WSDL;
|
|
16
|
-
|
|
17
|
-
function createCache() {
|
|
18
|
-
var cache = {};
|
|
19
|
-
return function (key, load, callback) {
|
|
20
|
-
if (!cache[key]) {
|
|
21
|
-
load(function (err, result) {
|
|
22
|
-
if (err) {
|
|
23
|
-
return callback(err);
|
|
24
|
-
}
|
|
25
|
-
cache[key] = result;
|
|
26
|
-
callback(null, result);
|
|
27
|
-
});
|
|
28
|
-
} else {
|
|
29
|
-
process.nextTick(function () {
|
|
30
|
-
callback(null, cache[key]);
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
var getFromCache = createCache();
|
|
36
|
-
|
|
37
|
-
function _requestWSDL(url, options, callback) {
|
|
38
|
-
if (typeof options === 'function') {
|
|
39
|
-
callback = options;
|
|
40
|
-
options = {};
|
|
41
|
-
}
|
|
42
|
-
var openWsdl = wsdl.open_wsdl.bind(null, url, options);
|
|
43
|
-
|
|
44
|
-
if (options.disableCache === true) {
|
|
45
|
-
openWsdl(callback);
|
|
46
|
-
} else {
|
|
47
|
-
getFromCache(url, openWsdl, callback);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
function createClient(url, options, callback, endpoint) {
|
|
52
|
-
if (typeof options === 'function') {
|
|
53
|
-
endpoint = callback;
|
|
54
|
-
callback = options;
|
|
55
|
-
options = {};
|
|
56
|
-
}
|
|
57
|
-
endpoint = options.endpoint || endpoint;
|
|
58
|
-
_requestWSDL(url, options, function(err, wsdl) {
|
|
59
|
-
callback(err, wsdl && new Client(wsdl, endpoint, options));
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
function createClientAsync(url, options, endpoint) {
|
|
64
|
-
if (typeof options === 'undefined') {
|
|
65
|
-
options = {};
|
|
66
|
-
}
|
|
67
|
-
return new BluebirdPromise(function(resolve, reject) {
|
|
68
|
-
createClient(url, options, function(err, client) {
|
|
69
|
-
if (err) {
|
|
70
|
-
reject(err);
|
|
71
|
-
}
|
|
72
|
-
resolve(client);
|
|
73
|
-
}, endpoint);
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
function listen(server, pathOrOptions, services, xml) {
|
|
78
|
-
var options = {},
|
|
79
|
-
path = pathOrOptions,
|
|
80
|
-
uri =
|
|
81
|
-
|
|
82
|
-
if (typeof pathOrOptions === 'object') {
|
|
83
|
-
options = pathOrOptions;
|
|
84
|
-
path = options.path;
|
|
85
|
-
services = options.services;
|
|
86
|
-
xml = options.xml;
|
|
87
|
-
uri = options.uri;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
var wsdl = new WSDL(xml || services, uri, options);
|
|
91
|
-
return new Server(server, path, services, wsdl, options);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
exports.security = security;
|
|
95
|
-
exports.BasicAuthSecurity = security.BasicAuthSecurity;
|
|
96
|
-
exports.WSSecurity = security.WSSecurity;
|
|
97
|
-
exports.WSSecurityCert = security.WSSecurityCert;
|
|
98
|
-
exports.ClientSSLSecurity = security.ClientSSLSecurity;
|
|
99
|
-
exports.ClientSSLSecurityPFX = security.ClientSSLSecurityPFX;
|
|
100
|
-
exports.BearerSecurity = security.BearerSecurity;
|
|
101
|
-
exports.createClient = createClient;
|
|
102
|
-
exports.createClientAsync = createClientAsync;
|
|
103
|
-
exports.passwordDigest = passwordDigest;
|
|
104
|
-
exports.listen = listen;
|
|
105
|
-
exports.WSDL = WSDL;
|
|
106
|
-
|
|
107
|
-
// Export Client and Server to allow customization
|
|
108
|
-
exports.Server = Server;
|
|
109
|
-
exports.Client = Client;
|
|
110
|
-
exports.HttpClient = HttpClient;
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2011 Vinay Pulim <vinay@milewise.com>
|
|
3
|
+
* MIT Licensed
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
"use strict";
|
|
7
|
+
|
|
8
|
+
var Client = require('./client').Client,
|
|
9
|
+
Server = require('./server').Server,
|
|
10
|
+
HttpClient = require('./http'),
|
|
11
|
+
security = require('./security'),
|
|
12
|
+
passwordDigest = require('./utils').passwordDigest,
|
|
13
|
+
BluebirdPromise = require('bluebird'),
|
|
14
|
+
wsdl = require('./wsdl'),
|
|
15
|
+
WSDL = require('./wsdl').WSDL;
|
|
16
|
+
|
|
17
|
+
function createCache() {
|
|
18
|
+
var cache = {};
|
|
19
|
+
return function (key, load, callback) {
|
|
20
|
+
if (!cache[key]) {
|
|
21
|
+
load(function (err, result) {
|
|
22
|
+
if (err) {
|
|
23
|
+
return callback(err);
|
|
24
|
+
}
|
|
25
|
+
cache[key] = result;
|
|
26
|
+
callback(null, result);
|
|
27
|
+
});
|
|
28
|
+
} else {
|
|
29
|
+
process.nextTick(function () {
|
|
30
|
+
callback(null, cache[key]);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
var getFromCache = createCache();
|
|
36
|
+
|
|
37
|
+
function _requestWSDL(url, options, callback) {
|
|
38
|
+
if (typeof options === 'function') {
|
|
39
|
+
callback = options;
|
|
40
|
+
options = {};
|
|
41
|
+
}
|
|
42
|
+
var openWsdl = wsdl.open_wsdl.bind(null, url, options);
|
|
43
|
+
|
|
44
|
+
if (options.disableCache === true) {
|
|
45
|
+
openWsdl(callback);
|
|
46
|
+
} else {
|
|
47
|
+
getFromCache(url, openWsdl, callback);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function createClient(url, options, callback, endpoint) {
|
|
52
|
+
if (typeof options === 'function') {
|
|
53
|
+
endpoint = callback;
|
|
54
|
+
callback = options;
|
|
55
|
+
options = {};
|
|
56
|
+
}
|
|
57
|
+
endpoint = options.endpoint || endpoint;
|
|
58
|
+
_requestWSDL(url, options, function(err, wsdl) {
|
|
59
|
+
callback(err, wsdl && new Client(wsdl, endpoint, options));
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function createClientAsync(url, options, endpoint) {
|
|
64
|
+
if (typeof options === 'undefined') {
|
|
65
|
+
options = {};
|
|
66
|
+
}
|
|
67
|
+
return new BluebirdPromise(function(resolve, reject) {
|
|
68
|
+
createClient(url, options, function(err, client) {
|
|
69
|
+
if (err) {
|
|
70
|
+
reject(err);
|
|
71
|
+
}
|
|
72
|
+
resolve(client);
|
|
73
|
+
}, endpoint);
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function listen(server, pathOrOptions, services, xml) {
|
|
78
|
+
var options = {},
|
|
79
|
+
path = pathOrOptions,
|
|
80
|
+
uri = "";
|
|
81
|
+
|
|
82
|
+
if (typeof pathOrOptions === 'object') {
|
|
83
|
+
options = pathOrOptions;
|
|
84
|
+
path = options.path;
|
|
85
|
+
services = options.services;
|
|
86
|
+
xml = options.xml;
|
|
87
|
+
uri = options.uri;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
var wsdl = new WSDL(xml || services, uri, options);
|
|
91
|
+
return new Server(server, path, services, wsdl, options);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
exports.security = security;
|
|
95
|
+
exports.BasicAuthSecurity = security.BasicAuthSecurity;
|
|
96
|
+
exports.WSSecurity = security.WSSecurity;
|
|
97
|
+
exports.WSSecurityCert = security.WSSecurityCert;
|
|
98
|
+
exports.ClientSSLSecurity = security.ClientSSLSecurity;
|
|
99
|
+
exports.ClientSSLSecurityPFX = security.ClientSSLSecurityPFX;
|
|
100
|
+
exports.BearerSecurity = security.BearerSecurity;
|
|
101
|
+
exports.createClient = createClient;
|
|
102
|
+
exports.createClientAsync = createClientAsync;
|
|
103
|
+
exports.passwordDigest = passwordDigest;
|
|
104
|
+
exports.listen = listen;
|
|
105
|
+
exports.WSDL = WSDL;
|
|
106
|
+
|
|
107
|
+
// Export Client and Server to allow customization
|
|
108
|
+
exports.Server = Server;
|
|
109
|
+
exports.Client = Client;
|
|
110
|
+
exports.HttpClient = HttpClient;
|
package/lib/utils.js
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
"use strict";
|
|
3
|
-
var crypto = require('crypto');
|
|
4
|
-
exports.passwordDigest = function passwordDigest(nonce, created, password) {
|
|
5
|
-
// digest = base64 ( sha1 ( nonce + created + password ) )
|
|
6
|
-
var pwHash = crypto.createHash('sha1');
|
|
7
|
-
var rawNonce = new Buffer(nonce || '', 'base64').toString('binary');
|
|
8
|
-
pwHash.update(rawNonce + created + password);
|
|
9
|
-
return pwHash.digest('base64');
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
var TNS_PREFIX = '__tns__'; // Prefix for targetNamespace
|
|
14
|
-
|
|
15
|
-
exports.TNS_PREFIX = TNS_PREFIX;
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Find a key from an object based on the value
|
|
19
|
-
* @param {Object} Namespace prefix/uri mapping
|
|
20
|
-
* @param {*} nsURI value
|
|
21
|
-
* @returns {String} The matching key
|
|
22
|
-
*/
|
|
23
|
-
exports.findPrefix = function(xmlnsMapping, nsURI) {
|
|
24
|
-
for (var n in xmlnsMapping) {
|
|
25
|
-
if (n === TNS_PREFIX) continue;
|
|
26
|
-
if (xmlnsMapping[n] === nsURI) {
|
|
27
|
-
return n;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
};
|
|
1
|
+
|
|
2
|
+
"use strict";
|
|
3
|
+
var crypto = require('crypto');
|
|
4
|
+
exports.passwordDigest = function passwordDigest(nonce, created, password) {
|
|
5
|
+
// digest = base64 ( sha1 ( nonce + created + password ) )
|
|
6
|
+
var pwHash = crypto.createHash('sha1');
|
|
7
|
+
var rawNonce = new Buffer(nonce || '', 'base64').toString('binary');
|
|
8
|
+
pwHash.update(rawNonce + created + password);
|
|
9
|
+
return pwHash.digest('base64');
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
var TNS_PREFIX = '__tns__'; // Prefix for targetNamespace
|
|
14
|
+
|
|
15
|
+
exports.TNS_PREFIX = TNS_PREFIX;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Find a key from an object based on the value
|
|
19
|
+
* @param {Object} Namespace prefix/uri mapping
|
|
20
|
+
* @param {*} nsURI value
|
|
21
|
+
* @returns {String} The matching key
|
|
22
|
+
*/
|
|
23
|
+
exports.findPrefix = function(xmlnsMapping, nsURI) {
|
|
24
|
+
for (var n in xmlnsMapping) {
|
|
25
|
+
if (n === TNS_PREFIX) continue;
|
|
26
|
+
if (xmlnsMapping[n] === nsURI) {
|
|
27
|
+
return n;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
};
|