bluemix-secure-gateway
Advanced tools
Comparing version 2.0.1 to 3.0.0
// | ||
// Copyright (c) IBM Corporation 2015 | ||
// | ||
// | ||
// Permission is hereby granted, free of charge, to any person | ||
@@ -12,6 +12,6 @@ // obtaining a copy of this software and associated documentation | ||
// conditions: | ||
// | ||
// | ||
// The above copyright notice and this permission notice shall be | ||
// included in all copies or substantial portions of the Software. | ||
// | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
@@ -25,3 +25,3 @@ // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES | ||
// OTHER DEALINGS IN THE SOFTWARE. | ||
// | ||
// | ||
var request = require ('request').defaults ({ | ||
@@ -70,3 +70,3 @@ strictSSL: false, | ||
_basepath = serviceInfo.url; | ||
} else { | ||
} else { | ||
_basepath = "https://sgmanager.ng.bluemix.net"; | ||
@@ -125,2 +125,24 @@ } | ||
var _getInstallerList = function(callback) { | ||
var _basepath = _getBasePath (this, callback), | ||
path = '/getClientList'; | ||
var req_opts = { | ||
method: 'GET', | ||
uri: _basepath + apiVersion + path, | ||
headers: {"Authorization" : "Bearer " + options.securityToken}, | ||
qs: {} | ||
}; | ||
request(req_opts, function (error, response, body) { | ||
if(error){ | ||
callback(error, null); | ||
}else if(response.statusCode != 200){ | ||
callback(body, null); | ||
}else{ | ||
callback(null, body); | ||
} | ||
}); | ||
} | ||
var _createGateway = function(options, callback){ | ||
@@ -138,3 +160,3 @@ if(!options.desc){ | ||
self = this; | ||
var req_opts = { | ||
@@ -195,2 +217,34 @@ method: 'POST', | ||
var _getMultipleGateways = function(idArray, callback) { | ||
var _orgID = _getOrgID (this, callback), | ||
_spaceID = _getSpaceID (this, callback), | ||
_basepath = _getBasePath (this, callback), | ||
authHeader = _getAuthHeader (this, callback), | ||
path = '/multiDescribe?org_id=' + _orgID + "&space_id=" + _spaceID; | ||
var req_opts = { | ||
method: 'GET', | ||
uri: _basepath + apiVersion + path, | ||
headers: {"Authorization" : authHeader}, | ||
qs: {}, | ||
json:true, | ||
body:{id_list:idArray} | ||
}; | ||
var self = this; | ||
request(req_opts, function (error, response, body) { | ||
if(error){ | ||
callback(error, null); | ||
}else if(response.statusCode != 200){ | ||
callback(body, null); | ||
}else{ | ||
var retVal = []; | ||
body.forEach(function(config){ | ||
retVal.push(new configObject(config, self)); | ||
}); | ||
callback(null, retVal); | ||
} | ||
}); | ||
} | ||
var _listGateways = function(options, callback){ | ||
@@ -202,3 +256,3 @@ var _orgID = _getOrgID (this, callback), | ||
path = '/sgconfig?org_id=' + _orgID + "&space_id=" + _spaceID; | ||
if(typeof(options) === "function"){ | ||
@@ -212,3 +266,3 @@ callback = options; | ||
} | ||
var req_opts = { | ||
@@ -248,3 +302,3 @@ method: 'GET', | ||
_basepath = _getBasePath (this.parent, callback); | ||
var req_opts = { | ||
@@ -268,2 +322,29 @@ method: 'DELETE', | ||
configObject.prototype.regenAuthorization = function(callback) { | ||
var _body = {}, | ||
path = '/sgconfig/' + this._id + '/genAuth', | ||
_basepath = _getBasePath (this.parent, callback), | ||
req_opts = { | ||
method: 'PUT', | ||
uri: _basepath + apiVersion + path, | ||
headers: {"Authorization" : "Bearer " + this.jwt}, | ||
qs: {}, | ||
json:true, | ||
body: _body | ||
}, | ||
self = this; | ||
request(req_opts, function (error, response, body) { | ||
if(error){ | ||
callback(error, null); | ||
}else if(response.statusCode != 200){ | ||
callback(body, null); | ||
}else{ | ||
for(var key in body){ | ||
self[key] = body[key]; | ||
} | ||
callback(null, self); | ||
} | ||
}); | ||
} | ||
configObject.prototype.updateGateway = function(options, callback){ | ||
@@ -279,3 +360,3 @@ | ||
} | ||
if(options.desc){ | ||
@@ -290,2 +371,6 @@ _body.desc = options.desc; | ||
} | ||
if(options.regen_token != null) { | ||
_body.regen_token = options.regen_token; | ||
if (_body.regen_token) _body.token_exp = (options.token_exp ? options.token_exp : 90); | ||
} | ||
@@ -395,3 +480,3 @@ var req_opts = { | ||
configObject.prototype.deleteDestination = function(options, callback){ | ||
configObject.prototype.deleteDestination = function(options, callback){ | ||
if(!options.id){ | ||
@@ -404,3 +489,3 @@ callback("Missing required property id"); | ||
_basepath = _getBasePath (this.parent, callback); | ||
var req_opts = { | ||
@@ -425,3 +510,3 @@ method: 'DELETE', | ||
configObject.prototype.listDestinations = function(options, callback){ | ||
var path = "/sgconfig/" + this._id + "/destinations", | ||
@@ -434,3 +519,3 @@ _basepath = _getBasePath (this.parent, callback); | ||
} | ||
if(options.enabled != null){ | ||
@@ -443,3 +528,3 @@ if(options.enabled){ | ||
} | ||
var req_opts = { | ||
@@ -451,3 +536,3 @@ method: 'GET', | ||
json:true | ||
}; | ||
}; | ||
@@ -474,2 +559,35 @@ request(req_opts, function (error, response, body) { | ||
configObject.prototype.getMultipleDestinations = function (idArray, callback) { | ||
var path = "/sgconfig/" + this._id + "/multiDescribe", | ||
_basepath = _getBasePath (this.parent, callback); | ||
var req_opts = { | ||
method: 'POST', | ||
uri: _basepath + apiVersion + path, | ||
headers: {"Authorization" : "Bearer " + this.jwt}, | ||
qs: {}, | ||
json:true, | ||
body: {id_list: idArray} | ||
}; | ||
request(req_opts, function (error, response, body) { | ||
if(error){ | ||
callback(error, null); | ||
}else if(response.statusCode != 200){ | ||
callback(body, null); | ||
}else{ | ||
body.forEach(function(ep){ | ||
if(appInfo != {}){ | ||
ep.currentHost = ep.hostname; | ||
ep.currentPort = ep.port; | ||
} else{ | ||
ep.currentHost = ep.connection_info.OnPremHost; | ||
ep.currentPort = ep.connection_info.OnPremPort; | ||
} | ||
}); | ||
callback(null, body); | ||
} | ||
}); | ||
} | ||
configObject.prototype.updateDestination = function(options, callback){ | ||
@@ -484,7 +602,7 @@ if(!options.id){ | ||
_basepath = _getBasePath (this.parent, callback); | ||
if(options.desc){ | ||
if(options.desc != null){ | ||
_body.desc = options.desc; | ||
} | ||
if(options.enabled!=null){ | ||
if(options.enabled != null){ | ||
_body.enabled = options.enabled.toString(); | ||
@@ -494,2 +612,4 @@ } | ||
_body.TLS = options.tls; | ||
} else if(options.TLS != null) { | ||
_body.TLS = options.TLS; | ||
} | ||
@@ -511,3 +631,18 @@ if(options.protocol != null){ | ||
} | ||
if(options.ip != null){ | ||
_body.ip = options.ip; | ||
} | ||
if(options.port != null) { | ||
_body.port = options.port | ||
} | ||
if(options.clientPort != null) { | ||
_body.clientPort = options.clientPort; | ||
} | ||
if(options.client_tls != null) { | ||
_body.client_tls = options.client_tls; | ||
} | ||
if(options.private != null) { | ||
_body.private = options.private; | ||
} | ||
var req_opts = { | ||
@@ -540,3 +675,3 @@ method: 'PUT', | ||
configObject.prototype.uploadDestinationCert = function(options, callback){ | ||
configObject.prototype.uploadDestinationCert = function(options, callback){ | ||
if(!options.id){ | ||
@@ -549,2 +684,6 @@ callback("Missing required property id"); | ||
} | ||
if (options.client_cert_filepath) { | ||
if (!Array.isArray(options.client_cert_filepath)) options.client_cert_filepath = [options.client_cert_filepath]; | ||
if (options.client_cert_filepath.length > 6) callback("Only 6 files are allowed for client_cert_filepath") | ||
} | ||
@@ -555,3 +694,3 @@ var path = '/sgconfig/' + this._id + "/destinations/" + options.id + "/cert", | ||
var req = request.put ({ | ||
uri : _basepath + apiVersion + path, | ||
uri : _basepath + apiVersion + path, | ||
headers: {"Authorization" : "Bearer " + this.jwt} | ||
@@ -572,3 +711,5 @@ }, function (error, resp, body) { | ||
if(options.client_cert_filepath){ | ||
form.append("client_cert", fs.createReadStream(options.client_cert_filepath)) | ||
options.client_cert_filepath.forEach(function(path) { | ||
form.append("client_cert", fs.createReadStream(path)); | ||
}); | ||
} | ||
@@ -581,5 +722,2 @@ } | ||
return; | ||
} else if(!options.filepath){ | ||
callback("Missing required property filepath"); | ||
return; | ||
} | ||
@@ -589,3 +727,5 @@ | ||
_basepath = _getBasePath (this.parent, callback); | ||
if (!options.filepath) path += '?noZip=true'; | ||
var req_opts = { | ||
@@ -597,16 +737,100 @@ method: 'GET', | ||
}; | ||
var r = request(req_opts); | ||
r.on('response', function (res) { | ||
res.pipe(fs.createWriteStream(options.filepath)); | ||
if (options.filepath) { | ||
var r = request(req_opts); | ||
r.on('response', function (res) { | ||
res.pipe(fs.createWriteStream(options.filepath).on('finish', function() {callback(null);})); | ||
}); | ||
r.on('error', function(err){ | ||
callback(err); | ||
}); | ||
} else { | ||
request(req_opts, function(err, response, body) { | ||
if(err){ | ||
callback(err, null); | ||
}else if(response.statusCode != 200){ | ||
callback(body, null); | ||
}else{ | ||
callback(null, JSON.parse(body)); | ||
} | ||
}); | ||
} | ||
} | ||
configObject.prototype.downloadCertsByName = function(options, callback){ | ||
if(!options.id){ | ||
callback("Missing required property id"); | ||
return; | ||
} else if (!options.filenames) { | ||
callback("Missing required property filenames"); | ||
return; | ||
} | ||
var path = '/sgconfig/' + this._id + "/destinations/" + options.id + "/certList", | ||
_basepath = _getBasePath (this.parent, callback); | ||
if (!options.filepath) path += '?noZip=true'; | ||
var req_opts = { | ||
method: 'GET', | ||
uri: _basepath + apiVersion + path, | ||
headers: {"Authorization" : "Bearer " + this.jwt}, | ||
qs: {filename: options.filenames} | ||
}; | ||
if (options.filepath) { | ||
var r = request(req_opts); | ||
r.on('response', function (res) { | ||
res.pipe(fs.createWriteStream(options.filepath).on('finish', function() {callback(null);})); | ||
}); | ||
r.on('error', function(err){ | ||
callback(err); | ||
}); | ||
} else { | ||
request(req_opts, function(err, response, body) { | ||
if(err){ | ||
callback(err, null); | ||
}else if(response.statusCode != 200){ | ||
callback(body, null); | ||
}else{ | ||
callback(null, JSON.parse(body)); | ||
} | ||
}); | ||
} | ||
} | ||
configObject.prototype.deleteDestinationCerts = function(options, callback) { | ||
if(!options.id){ | ||
callback("Missing required property id"); | ||
return; | ||
} else if (!options.filenames) { | ||
callback("Missing required property filenames"); | ||
return; | ||
} | ||
var path = '/sgconfig/' + this._id + "/destinations/" + options.id + "/cert", | ||
_basepath = _getBasePath (this.parent, callback); | ||
var req_opts = { | ||
method: 'DELETE', | ||
uri: _basepath + apiVersion + path, | ||
headers: {"Authorization" : "Bearer " + this.jwt}, | ||
qs: {}, | ||
json: true, | ||
body: {filename: options.filenames} | ||
}; | ||
request(req_opts, function(err, response, body) { | ||
if(err){ | ||
callback(err, null); | ||
}else if(response.statusCode != 200){ | ||
callback(body, null); | ||
}else{ | ||
callback(null, body); | ||
} | ||
}); | ||
r.on('complete', function(){ | ||
callback(null); | ||
}); | ||
r.on('error', function(error){ | ||
callback(error); | ||
}); | ||
} | ||
@@ -622,3 +846,5 @@ | ||
_basepath = _getBasePath (this.parent, callback); | ||
if (options.client != null && options.client) path += '?client=true'; | ||
var req_opts = { | ||
@@ -630,3 +856,3 @@ method: 'PUT', | ||
}; | ||
request(req_opts, function (error, response, body) { | ||
@@ -643,2 +869,135 @@ if(error){ | ||
configObject.prototype.addIPTableRule = function(destination_id, options, callback) { | ||
var path = '/sgconfig/' + this._id + "/destinations/" + destination_id + "/ipTableRule", | ||
_basepath = _getBasePath (this.parent, callback); | ||
if (!Array.isArray(options)) options = [options]; | ||
var err = false; | ||
options.forEach(function(opt) { | ||
if (opt.src && opt.src_range) err = true; | ||
}); | ||
if (err) { | ||
callback("Options object cannot contain both src and src_range"); | ||
return; | ||
} | ||
var req_opts = { | ||
method: 'PUT', | ||
uri: _basepath + apiVersion + path, | ||
headers: {"Authorization" : "Bearer " + this.jwt}, | ||
qs: {}, | ||
json: true, | ||
body: options | ||
}; | ||
request(req_opts, function (error, response, body) { | ||
if(error){ | ||
callback(error); | ||
}else if(response.statusCode != 200){ | ||
callback(body); | ||
}else{ | ||
callback(null); | ||
} | ||
}); | ||
} | ||
configObject.prototype.removeIPTableRule = function(destination_id, options, callback) { | ||
if (options.src && options.src_range) { | ||
callback("Options object cannot contain both src and src_range"); | ||
return; | ||
} | ||
var path = '/sgconfig/' + this._id + "/destinations/" + destination_id + "/ipTableRule", | ||
_basepath = _getBasePath (this.parent, callback); | ||
if (options.all != null && options.all) path += '?all=true'; | ||
var req_opts = { | ||
method: 'DELETE', | ||
uri: _basepath + apiVersion + path, | ||
headers: {"Authorization" : "Bearer " + this.jwt}, | ||
qs: {}, | ||
json: true, | ||
body: options | ||
}; | ||
request(req_opts, function (error, response, body) { | ||
if(error){ | ||
callback(error); | ||
}else if(response.statusCode != 200){ | ||
callback(body); | ||
}else{ | ||
callback(null); | ||
} | ||
}); | ||
} | ||
configObject.prototype.getClientList = function(callback) { | ||
var path = '/sgconfig/' + this._id +'/clients', | ||
_basepath = _getBasePath (this.parent, callback); | ||
var options = { | ||
method: 'GET', | ||
uri: _basepath + apiVersion + path, | ||
headers: {"Authorization" : "Bearer " + this.jwt}, | ||
qs: {}, | ||
}; | ||
request(options, function (error, response, body) { | ||
if(error){ | ||
callback(error, null); | ||
}else if(response.statusCode != 200){ | ||
callback(body, null); | ||
}else{ | ||
callback(null, JSON.parse(body)); | ||
} | ||
}); | ||
} | ||
configObject.prototype.getClientStatus = function(clientID, callback) { | ||
var path = '/sgconfig/' + this._id +'/clients/' + clientID, | ||
_basepath = _getBasePath (this.parent, callback); | ||
var options = { | ||
method: 'GET', | ||
uri: _basepath + apiVersion + path, | ||
headers: {"Authorization" : "Bearer " + this.jwt}, | ||
qs: {}, | ||
}; | ||
request(options, function (error, response, body) { | ||
if(error){ | ||
callback(error, null); | ||
}else if(response.statusCode != 200){ | ||
callback(body, null); | ||
}else{ | ||
callback(null, body); | ||
} | ||
}); | ||
} | ||
configObject.prototype.disconnectClients = function(clientIDs, callback) { | ||
if (!Array.isArray(clientIDs)) clientIDs = [clientIDs]; | ||
var path = '/sgconfig/' + this._id +'/clients', | ||
_basepath = _getBasePath (this.parent, callback); | ||
var options = { | ||
method: 'DELETE', | ||
uri: _basepath + apiVersion + path, | ||
headers: {"Authorization" : "Bearer " + this.jwt}, | ||
json: true, | ||
qs: {}, | ||
body: {deleteList : clientIDs} | ||
}; | ||
request(options, function (error, response, body) { | ||
if(error){ | ||
callback(error); | ||
}else if(response.statusCode != 200){ | ||
callback(body); | ||
}else{ | ||
callback(null); | ||
} | ||
}); | ||
} | ||
//Stat functions | ||
@@ -648,3 +1007,3 @@ configObject.prototype.getStats = function(callback){ | ||
_basepath = _getBasePath (this.parent, callback); | ||
var options = { | ||
@@ -656,3 +1015,3 @@ method: 'GET', | ||
}; | ||
request(options, function (error, response, body) { | ||
@@ -671,3 +1030,5 @@ if(error){ | ||
module.exports.listGateways = _listGateways; | ||
module.exports.getMultipleGateways = _getMultipleGateways; | ||
module.exports.createGateway = _createGateway; | ||
module.exports.getInstallerList = _getInstallerList; | ||
module.exports.defaults = _defaults; |
{ | ||
"name": "bluemix-secure-gateway", | ||
"version": "2.0.1", | ||
"version": "3.0.0", | ||
"dependencies": { | ||
@@ -8,26 +8,3 @@ "request": ">=2.40.0" | ||
"main": "./main.js", | ||
"license": "MIT", | ||
"description": "The Secure Gateway SDK for Bluemix contains a set of javascript wrapper APIs for Secure Gateway REST calls to the Bluemix Secure Gateway service.", | ||
"_id": "bluemix-secure-gateway@1.0.0", | ||
"scripts": {}, | ||
"_shasum": "d41ccdde6821cd983583a9546ea7118cc4d1b974", | ||
"_from": "bluemix-secure-gateway@*", | ||
"_npmVersion": "1.4.28", | ||
"_npmUser": { | ||
"name": "bluemixsecuregateway", | ||
"email": "cisandbx@us.ibm.com" | ||
}, | ||
"maintainers": [ | ||
{ | ||
"name": "bluemixsecuregateway", | ||
"email": "cisandbx@us.ibm.com" | ||
} | ||
], | ||
"dist": { | ||
"shasum": "d41ccdde6821cd983583a9546ea7118cc4d1b974", | ||
"tarball": "http://registry.npmjs.org/bluemix-secure-gateway/-/bluemix-secure-gateway-1.0.0.tgz" | ||
}, | ||
"directories": {}, | ||
"_resolved": "https://registry.npmjs.org/bluemix-secure-gateway/-/bluemix-secure-gateway-1.0.0.tgz", | ||
"readmeFilename": "README.md" | ||
"license": "MIT" | ||
} |
160
README.md
@@ -21,3 +21,3 @@ # bluemix-secure-gateway | ||
Once the SDK has been initialized, we can set the defaults for an environment. Default options that can be set include: | ||
* `basepath` - The basepath of the Secure Gateway Service REST API . This defaults to "https://sgmanager.ng.bluemix.net", the basepath of the Secure Gateway Service in the us-south region. The basepath for the REST API in the UK region is "https://sgmanager.eu-gb.bluemix.net" | ||
* `basepath` - The basepath of the Secure Gateway Service REST API . This defaults to "https://sgmanager.ng.bluemix.net", the basepath of the Secure Gateway Service in the us-south region. The basepath for the REST API in the UK region is "https://sgmanager.eu-gb.bluemix.net". The basepath for the REST API in the AU region is "https://sgmanager.au-syd.bluemix.net". | ||
* `orgID` - The Bluemix Organization ID for the Secure Gateway Service being accessed. This is only required if creating or listing gateways. | ||
@@ -34,3 +34,3 @@ * `spaceID` - The Bluemix Space ID for the Secure Gateway Service being accessed. This is only required if creating, describing, or listing gateways. | ||
'password': <Bluemix password> | ||
}) | ||
}) | ||
``` | ||
@@ -46,8 +46,9 @@ | ||
Options: | ||
* `desc` - A description of this gateway. Must be a String. | ||
* `enf_tok_sec` - Whether to require the security token when connecting the client. Must be a boolean. | ||
* `desc` - (Required) A description of this gateway. Must be a String. | ||
* `enf_tok_sec` - Whether to require the security token when connecting the client. Must be a boolean. Defaults to true. | ||
* `token_exp` - Number of days until the associated security token expires. Defaults to 90 (enter 0 for never expiring). | ||
On success, a gateway object is returned. Use the destination functions on this gateway to manage the destinations under this gateway. | ||
### Describing and Listing Gateways | ||
### Describe a Gateway | ||
@@ -61,2 +62,6 @@ ```javascript | ||
Returns a gateway object on success. | ||
### Listing Gateways | ||
```javascript | ||
@@ -68,4 +73,21 @@ env.listGateways (options, function(error, array)) | ||
Returns a list of gateways on success | ||
Returns an array of all gateways associated with the org and space on success. | ||
### Getting Multiple Gateways | ||
```javascript | ||
env.getMultipleGateways (idArray, function(error, array)) | ||
``` | ||
`idArray` should contain the IDs of the gateways you want returned. | ||
Returns an array of the requested gateways. | ||
### Regenerating Gateway Authorization | ||
```javascript | ||
gateway.regenAuthorization(function(error, gateway)) | ||
``` | ||
Returns the updated gateway object. | ||
### Updating a Gateway | ||
@@ -81,2 +103,4 @@ | ||
* `enf_tok_sec` - Whether to require the security token when connecting the client. Must be a boolean. | ||
* `regen_token` - Whether to regenerate the associated security token. Defaults to false. Must be a boolean. | ||
* `token_exp` - Number of days until the associated security token expires. Defaults to 90. Ignored if regen_token is false or not provided. | ||
@@ -103,7 +127,10 @@ ### Deleting a Gateway | ||
* `desc` - (Required) A description of the destination. This must a be a String. | ||
* `ip` - (Required) The on-prem hostname or ip of the destination. | ||
* `port` - (Required) The on-prem port of the destination | ||
* `ip` - (Required) The hostname or ip of the destination. | ||
* `port` - (Required) The port of the destination | ||
* `clientPort` - This will be a cloud destination. This is the port the client will listen on for an incoming connection. | ||
* `protocol` - The protocol of the destination, one of TCP, TLS, HTTP, or HTTPS. The default is TCP. | ||
* `TLS` - One of serverside, mutualauth, or none. Defaults to none. Is only compatible with the TLS protocol. | ||
* `enable_client_tls` - Enable TLS between the client and the final destination. Expected to be a Boolean. Defaults to false. | ||
* `enable_client_tls` - Enable TLS for the final outbound connection to the destination. Expected to be a Boolean. Defaults to false. | ||
* `client_tls` - Either mutualauth or none. Is only compatible with enable_client_tls true. Defaults to none. | ||
* `private` - Whether iptable rules will be enforced on the cloud host:port connection point. Not supported for cloud destinations. Must be a boolean. Defaults to false. | ||
@@ -116,9 +143,13 @@ ### Updating a Destination | ||
Options: | ||
* `id` - (Required) ID if the destination to update | ||
* `desc` - A description of the destination. This must a be a String. | ||
* `enabled` - Enable or disable the destination. Should be a Boolean. | ||
* `ip` - The on-prem hostname or ip of the destination. | ||
* `port` - The on-prem port of the destination | ||
* `ip` - The hostname or ip of the destination. | ||
* `port` - The port of the destination. | ||
* `clientPort` - The port the client will listen on for an incoming connection for cloud destinations. If sent to an on-premises destination, an error will be returned. | ||
* `protocol` - The protocol of the destination, one of TCP, TLS, HTTP, or HTTPS. The default is TCP. | ||
* `TLS` - One of serverside, mutualauth, or none. Defaults to none. Is only compatible with the TLS protocol. | ||
* `enable_client_tls` - Enable TLS between the client and the final destination. Expected to be a Boolean. Defaults to false. | ||
* `enable_client_tls` - Enable TLS between the client and the final destination. Expected to be a Boolean. | ||
* `client_tls` - Either mutualauth or none. Is only compatible with enable_client_tls true. | ||
* `private` - Whether iptable rules will be enforced on the cloud host:port connection point. Not supported for cloud destinations. | ||
@@ -134,2 +165,4 @@ ### Listing Destinations | ||
Returns all destinations associated with the gateway | ||
### Describe A Destination | ||
@@ -144,2 +177,12 @@ | ||
### Get Multiple Destinations | ||
```javascript | ||
gateway.getMultipleDestinations(idArray, function(err, array_of_destinations)) | ||
``` | ||
`idArray` should contain the IDs of the destinations you want returned. | ||
Returns an array containing the requested destinations | ||
### Delete a Destination | ||
@@ -156,11 +199,40 @@ | ||
```javascript | ||
gateway.uploadDestinationCert(options, function(err)) | ||
```javascript | ||
gateway.uploadDestinationCert(options, function(err, desetination)) | ||
``` | ||
Options: | ||
* `id` - ID of the destination these certificates belong to. | ||
* `server_cert_filepath` - Filepath of the server cert to be uploaded | ||
* `client_cert_filepath` - Filepath of the client cert to be uploaded | ||
* `client_cert_filepath` - Single filepath or an array of up to 6 filepaths of the client certs to be uploaded | ||
### Download Destination Certs and Keys | ||
```javascript | ||
gateway.downloadDestinationCerts(options, function(err[, array_of_objects])) | ||
``` | ||
Options: | ||
* `id` - ID of the destination whose certs are to be downloaded | ||
* `filepath` - Filepath where the zip file should be saved. If none provided, response will be an array of objects {name, contents} instead of a zip | ||
### Download Specific Destination Certificates | ||
```javascript | ||
gateway.downloadCertsByName(options, function(err[, array_of_objects])) | ||
``` | ||
Options: | ||
* `id` - ID of the destination these certificates belong to. | ||
* `filenames` - String of filenames separated by spaces or an array of filenames | ||
* `filepath` - Filepath where the zip file should be saved. If none provided, response will be an array of objects {name, contents} instead of a zip | ||
### Delete Destination Certificates | ||
```javascript | ||
gateway.deleteDestinationCerts(options, function(err, destination)) | ||
``` | ||
Options: | ||
* `id` - ID of the destination these certificates belong to. | ||
* `filenames` - String of filenames separated by spaces or an array of filenames | ||
### Auto Generate Destination Certificate/Private Key | ||
@@ -171,18 +243,62 @@ | ||
``` | ||
Options: | ||
* `id` - ID of the destination to generate cert and key for | ||
* `client` - Whether the generated cert and key are for destination-side TLS Mutual Auth (determined by destination properties `enable_client_tls` and `client_tls`) or for server side TLS Mutual Auth (determined by destination properties `protocol` and `TLS`). False will generate for server side TLS Mutual Auth, true will generate for destination-side TLS Mutual Auth. Should be a boolean. Default to false. | ||
This generates a cert and key for a TLS: Mutual Auth destination. | ||
This generates a cert and key for a TLS: Mutual Auth destination on either destination side or server side. | ||
### Download Destination Certs and Keys | ||
### Add IP Table Rule | ||
```javascript | ||
gateway.downloadDestinationCerts(options, function(err)) | ||
gateway.addIPTableRule(destination_id, options, function(err)) | ||
``` | ||
Destination must be set to private in order to add and enforce iptable rules. If you want to set multiple rules at once, you can send an array of options. | ||
Options: | ||
* `id` - ID of the destination whose certs are to be downloaded | ||
* `filepath` - Filepath where the zip file should be saved. | ||
* `src` - IP to allow to connect. If no src or src_range provided, all IPs will be allowed for this rule. | ||
* `src_range` - Range of IPs (using the form `1.1.1.1-2.2.2.2`) to allow (src and src_range cannot be sent in the same object). | ||
* `spt` - Port or range of ports to allow (using the form `5000:5005` for a range). If none provided, all ports will be allowed for this rule. | ||
* `app` - Desired ID to associate with the rule. If used, any other rule given the same ID will overwrite this one | ||
### Remove IP Table Rule | ||
```javascript | ||
gateway.removeIPTableRule(destination_id, options, function(err)) | ||
``` | ||
Destination must be set to private in order to add and enforce iptable rules. Rules may be removed all at once or one at a time (via individual calls). If removing individually, these values should match exactly what was provided when adding them. | ||
Options: | ||
* `src` - IP to match for removal. | ||
* `src_range` - Range of IPs (using the form `1.1.1.1-2.2.2.2`) to allow match for removal (src and src_range cannot be sent in the same object). | ||
* `spt` - Port or range of ports to match for removal (using the form `5000:5005` for a range). | ||
* `all` - Must be a boolean. If true, will remove all iptable rules associed with the destination. Defaults to false. | ||
## Managing Clients | ||
### Get Connected Clients | ||
```javascript | ||
gateway.getClientList(function(err, client_id_array)) | ||
``` | ||
Returns an array of objects {id, version} that are currently connected to the gateway. | ||
### Get Client status | ||
```javascript | ||
gateway.getClientStatus(client_id, function(err, status)) | ||
``` | ||
Returns `Connected` or `Disconnected` for the specified client ID. | ||
### Disconnect Clients | ||
Note: This is only supported for clients >= v1.4.2 | ||
```javascript | ||
gateway.disconnectClients(client_id_array, function(err)) | ||
``` | ||
## Client Installer Information | ||
### Get Client Installer Information | ||
```javascript | ||
env.getInstallerList(function(err, array_of_descriptions)) | ||
``` | ||
Returns an array of objects {description, url} for each installer we currently offer. |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
43399
0
886
293
5
1