Comparing version 0.4.0 to 0.4.1
@@ -9,3 +9,3 @@ /*jslint | ||
(function () { | ||
var http = require('http'), | ||
var https = require('https'), | ||
EventEmitter = require('events').EventEmitter, | ||
@@ -20,4 +20,4 @@ Util = require('util'), | ||
return { | ||
host: host || 'blitz.io', | ||
port: port || 80, | ||
host: host || 'www.blitz.io', | ||
port: port || 443, | ||
method: 'POST', | ||
@@ -67,3 +67,3 @@ headers: { | ||
options.headers['content-length'] = jsonData.length; | ||
request = http.request(options, function (response) { | ||
request = https.request(options, function (response) { | ||
responseHandler(response, function (jsonData) { | ||
@@ -89,3 +89,3 @@ // only emmited on complete | ||
options.method = 'GET'; | ||
request = http.request(options, function (response) { | ||
request = https.request(options, function (response) { | ||
responseHandler(response, function (jsonData) { | ||
@@ -110,3 +110,3 @@ // only emmited on complete | ||
options.method = 'GET'; | ||
request = http.request(options, function (response) { | ||
request = https.request(options, function (response) { | ||
responseHandler(response, function (jsonData) { | ||
@@ -131,3 +131,3 @@ // only emmited on complete | ||
options.method = 'PUT'; | ||
request = http.request(options, function (response) { | ||
request = https.request(options, function (response) { | ||
responseHandler(response, function (jsonData) { | ||
@@ -152,3 +152,3 @@ // only emmited on complete | ||
options.method = 'GET'; | ||
request = http.request(options, function (response) { | ||
request = https.request(options, function (response) { | ||
responseHandler(response, function (jsonData) { | ||
@@ -170,3 +170,3 @@ callback(jsonData); | ||
options.headers['content-length'] = jsonData.length; | ||
request = http.request(options, function (response) { | ||
request = https.request(options, function (response) { | ||
responseHandler(response, function (jsonData) { | ||
@@ -173,0 +173,0 @@ // only emmited on complete |
{ | ||
"author": "Guilherme Hermeto <gui.hermeto@gmail.com>", | ||
"author": "Guilherme Hermeto <guilherme.hermeto@spirent.com>", | ||
"name": "blitz", | ||
"description": "Blitz node.js client API", | ||
"version": "0.4.0", | ||
"version": "0.4.1", | ||
"homepage": "http://blitz.io", | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/ghermeto/blitz-node.git" | ||
"url": "git://github.com/blitz-io/blitz-node.git" | ||
}, | ||
@@ -11,0 +11,0 @@ "main": "./lib/blitz.js", |
@@ -1,2 +0,4 @@ | ||
var http = require('http'), | ||
var https = require('https'), | ||
path = require('path'), | ||
fs = require('fs'), | ||
mockServer = null, | ||
@@ -104,68 +106,74 @@ about = { | ||
module.exports.mockServer = http.createServer(function (request, response) { | ||
if (request.url === '/api/1/curl/execute') { | ||
var data = ''; | ||
request.addListener('data', function(chunk) {data += chunk;}); | ||
request.addListener('end', function() { | ||
var parsedData = JSON.parse(data); | ||
if (parsedData.steps[0].timeout) { | ||
response.writeHead(404); | ||
module.exports.mockServer = https.createServer( | ||
{ | ||
key: fs.readFileSync(path.resolve(__dirname, 'mock-server-key.pem')), | ||
cert: fs.readFileSync(path.resolve(__dirname, 'mock-server-cert.pem')) | ||
}, | ||
function (request, response) { | ||
if (request.url === '/api/1/curl/execute') { | ||
var data = ''; | ||
request.addListener('data', function(chunk) {data += chunk;}); | ||
request.addListener('end', function() { | ||
var parsedData = JSON.parse(data); | ||
if (parsedData.steps[0].timeout) { | ||
response.writeHead(404); | ||
} | ||
else { | ||
var id = 'a123'; | ||
if (parsedData.steps[0].user) { | ||
id = parsedData.steps[0].user; | ||
} | ||
response.writeHead(200, {'content-type': 'application/json'}); | ||
response.write(JSON.stringify({ok: true, job_id: id})); | ||
} | ||
response.end(); | ||
}); | ||
} | ||
else if (request.url === '/login/api') { | ||
response.writeHead(200, {'content-type': 'application/json'}); | ||
if(request.headers['x-api-user'] === process.env['BLITZ_API_USER'] && | ||
request.headers['x-api-key'] === 'key') { | ||
response.end(JSON.stringify({ok: true, api_key: '123'})); | ||
} | ||
else { | ||
var id = 'a123'; | ||
if (parsedData.steps[0].user) { | ||
id = parsedData.steps[0].user; | ||
} | ||
response.writeHead(200, {'content-type': 'application/json'}); | ||
response.write(JSON.stringify({ok: true, job_id: id})); | ||
response.end(JSON.stringify({error: 'login', reason: 'test'})); | ||
} | ||
response.end(); | ||
}); | ||
} | ||
else if (request.url === '/login/api') { | ||
response.writeHead(200, {'content-type': 'application/json'}); | ||
if(request.headers['x-api-user'] === process.env['BLITZ_API_USER'] && | ||
request.headers['x-api-key'] === 'key') { | ||
response.end(JSON.stringify({ok: true, api_key: '123'})); | ||
} | ||
else { | ||
response.end(JSON.stringify({error: 'login', reason: 'test'})); | ||
else if (request.url === '/api/1/parse') { | ||
response.writeHead(200, {'content-type': 'application/json'}); | ||
if(process.env['BLITZ_API_USER'] === 'user') { | ||
response.end(JSON.stringify(parseSprint)); | ||
} | ||
else if (process.env['BLITZ_API_USER'] === 'user2') { | ||
response.end(JSON.stringify(parseRush)); | ||
} | ||
else { | ||
response.end(JSON.stringify({error: 'parse', reason: 'test'})); | ||
} | ||
} | ||
} | ||
else if (request.url === '/api/1/parse') { | ||
response.writeHead(200, {'content-type': 'application/json'}); | ||
if(process.env['BLITZ_API_USER'] === 'user') { | ||
response.end(JSON.stringify(parseSprint)); | ||
else if (request.url === '/api/1/jobs/a123/status') { | ||
status.status = 'completed'; | ||
response.writeHead(200, {'content-type': 'application/json'}); | ||
response.end(JSON.stringify(status)); | ||
} | ||
else if (process.env['BLITZ_API_USER'] === 'user2') { | ||
response.end(JSON.stringify(parseRush)); | ||
else if (request.url === '/api/1/jobs/b123/status') { | ||
status._id = 'b123'; | ||
status.status = 'running'; | ||
response.writeHead(200, {'content-type': 'application/json'}); | ||
response.end(JSON.stringify(status)); | ||
} | ||
else { | ||
response.end(JSON.stringify({error: 'parse', reason: 'test'})); | ||
else if (request.url === '/api/1/jobs/c123/status') { | ||
timeline.status = 'completed'; | ||
response.writeHead(200, {'content-type': 'application/json'}); | ||
response.end(JSON.stringify(timeline)); | ||
} | ||
else if (request.url === '/api/1/account/about') { | ||
response.writeHead(200, {'content-type': 'application/json'}); | ||
response.end(JSON.stringify(about)); | ||
} | ||
response.writeHead(404); | ||
} | ||
else if (request.url === '/api/1/jobs/a123/status') { | ||
status.status = 'completed'; | ||
response.writeHead(200, {'content-type': 'application/json'}); | ||
response.end(JSON.stringify(status)); | ||
} | ||
else if (request.url === '/api/1/jobs/b123/status') { | ||
status._id = 'b123'; | ||
status.status = 'running'; | ||
response.writeHead(200, {'content-type': 'application/json'}); | ||
response.end(JSON.stringify(status)); | ||
} | ||
else if (request.url === '/api/1/jobs/c123/status') { | ||
timeline.status = 'completed'; | ||
response.writeHead(200, {'content-type': 'application/json'}); | ||
response.end(JSON.stringify(timeline)); | ||
} | ||
else if (request.url === '/api/1/account/about') { | ||
response.writeHead(200, {'content-type': 'application/json'}); | ||
response.end(JSON.stringify(about)); | ||
} | ||
response.writeHead(404); | ||
}); | ||
); | ||
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
95549
20
2191
12