Socket
Socket
Sign inDemoInstall

grabzit

Package Overview
Dependencies
0
Maintainers
1
Versions
42
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.6 to 0.0.7

327

lib/grabzit.js

@@ -11,58 +11,60 @@ var crypto = require('crypto');

{
this.SUCCESS = 0;
this.PARAMETER_NO_URL = 100;
this.PARAMETER_INVALID_URL = 101;
this.PARAMETER_NON_EXISTANT_URL = 102;
this.PARAMETER_MISSING_APPLICATION_KEY = 103;
this.PARAMETER_UNRECOGNISED_APPLICATION_KEY = 104;
this.PARAMETER_MISSING_SIGNATURE = 105;
this.PARAMETER_INVALID_SIGNATURE = 106;
this.PARAMETER_INVALID_FORMAT = 107;
this.PARAMETER_INVALID_COUNTRY_CODE = 108;
this.PARAMETER_DUPLICATE_IDENTIFIER = 109;
this.PARAMETER_MATCHING_RECORD_NOT_FOUND = 110;
this.PARAMETER_INVALID_CALLBACK_URL = 111;
this.PARAMETER_NON_EXISTANT_CALLBACK_URL = 112;
this.PARAMETER_IMAGE_WIDTH_TOO_LARGE = 113;
this.PARAMETER_IMAGE_HEIGHT_TOO_LARGE = 114;
this.PARAMETER_BROWSER_WIDTH_TOO_LARGE = 115;
this.PARAMETER_BROWSER_HEIGHT_TOO_LARGE = 116;
this.PARAMETER_DELAY_TOO_LARGE = 117;
this.PARAMETER_INVALID_BACKGROUND = 118;
this.PARAMETER_INVALID_INCLUDE_LINKS = 119;
this.PARAMETER_INVALID_INCLUDE_OUTLINE = 120;
this.PARAMETER_INVALID_PAGE_SIZE = 121;
this.PARAMETER_INVALID_PAGE_ORIENTATION = 122;
this.PARAMETER_VERTICAL_MARGIN_TOO_LARGE = 123;
this.PARAMETER_HORIZONTAL_MARGIN_TOO_LARGE = 124;
this.PARAMETER_INVALID_COVER_URL = 125;
this.PARAMETER_NON_EXISTANT_COVER_URL = 126;
this.PARAMETER_MISSING_COOKIE_NAME = 127;
this.PARAMETER_MISSING_COOKIE_DOMAIN = 128;
this.PARAMETER_INVALID_COOKIE_NAME = 129;
this.PARAMETER_INVALID_COOKIE_DOMAIN = 130;
this.PARAMETER_INVALID_COOKIE_DELETE = 131;
this.PARAMETER_INVALID_COOKIE_HTTP = 132;
this.PARAMETER_INVALID_COOKIE_EXPIRY = 133;
this.PARAMETER_INVALID_CACHE_VALUE = 134;
this.PARAMETER_INVALID_DOWNLOAD_VALUE = 135;
this.PARAMETER_INVALID_SUPPRESS_VALUE = 136;
this.PARAMETER_MISSING_WATERMARK_IDENTIFIER = 137;
this.PARAMETER_INVALID_WATERMARK_IDENTIFIER = 138;
this.PARAMETER_INVALID_WATERMARK_XPOS = 139;
this.PARAMETER_INVALID_WATERMARK_YPOS = 140;
this.PARAMETER_MISSING_WATERMARK_FORMAT = 141;
this.PARAMETER_WATERMARK_TOO_LARGE = 142;
this.PARAMETER_MISSING_PARAMETERS = 143;
this.PARAMETER_QUALITY_TOO_LARGE = 144;
this.PARAMETER_QUALITY_TOO_SMALL = 145;
this.NETWORK_SERVER_OFFLINE = 200;
this.NETWORK_GENERAL_ERROR = 201;
this.NETWORK_DDOS_ATTACK = 202;
this.RENDERING_ERROR = 300;
this.RENDERING_MISSING_SCREENSHOT = 301;
this.GENERIC_ERROR = 400;
this.UPGRADE_REQUIRED = 500;
this.FILE_SAVE_ERROR = 600;
this.FILE_NON_EXISTANT_PATH = 601;
this.ERROR_CODES = {
SUCCESS: 0,
PARAMETER_NO_URL: 100,
PARAMETER_INVALID_URL: 101,
PARAMETER_NON_EXISTANT_URL: 102,
PARAMETER_MISSING_APPLICATION_KEY: 103,
PARAMETER_UNRECOGNISED_APPLICATION_KEY: 104,
PARAMETER_MISSING_SIGNATURE: 105,
PARAMETER_INVALID_SIGNATURE: 106,
PARAMETER_INVALID_FORMAT: 107,
PARAMETER_INVALID_COUNTRY_CODE: 108,
PARAMETER_DUPLICATE_IDENTIFIER: 109,
PARAMETER_MATCHING_RECORD_NOT_FOUND: 110,
PARAMETER_INVALID_CALLBACK_URL: 111,
PARAMETER_NON_EXISTANT_CALLBACK_URL: 112,
PARAMETER_IMAGE_WIDTH_TOO_LARGE: 113,
PARAMETER_IMAGE_HEIGHT_TOO_LARGE: 114,
PARAMETER_BROWSER_WIDTH_TOO_LARGE: 115,
PARAMETER_BROWSER_HEIGHT_TOO_LARGE: 116,
PARAMETER_DELAY_TOO_LARGE: 117,
PARAMETER_INVALID_BACKGROUND: 118,
PARAMETER_INVALID_INCLUDE_LINKS: 119,
PARAMETER_INVALID_INCLUDE_OUTLINE: 120,
PARAMETER_INVALID_PAGE_SIZE: 121,
PARAMETER_INVALID_PAGE_ORIENTATION: 122,
PARAMETER_VERTICAL_MARGIN_TOO_LARGE: 123,
PARAMETER_HORIZONTAL_MARGIN_TOO_LARGE: 124,
PARAMETER_INVALID_COVER_URL: 125,
PARAMETER_NON_EXISTANT_COVER_URL: 126,
PARAMETER_MISSING_COOKIE_NAME: 127,
PARAMETER_MISSING_COOKIE_DOMAIN: 128,
PARAMETER_INVALID_COOKIE_NAME: 129,
PARAMETER_INVALID_COOKIE_DOMAIN: 130,
PARAMETER_INVALID_COOKIE_DELETE: 131,
PARAMETER_INVALID_COOKIE_HTTP: 132,
PARAMETER_INVALID_COOKIE_EXPIRY: 133,
PARAMETER_INVALID_CACHE_VALUE: 134,
PARAMETER_INVALID_DOWNLOAD_VALUE: 135,
PARAMETER_INVALID_SUPPRESS_VALUE: 136,
PARAMETER_MISSING_WATERMARK_IDENTIFIER: 137,
PARAMETER_INVALID_WATERMARK_IDENTIFIER: 138,
PARAMETER_INVALID_WATERMARK_XPOS: 139,
PARAMETER_INVALID_WATERMARK_YPOS: 140,
PARAMETER_MISSING_WATERMARK_FORMAT: 141,
PARAMETER_WATERMARK_TOO_LARGE: 142,
PARAMETER_MISSING_PARAMETERS: 143,
PARAMETER_QUALITY_TOO_LARGE: 144,
PARAMETER_QUALITY_TOO_SMALL: 145,
NETWORK_SERVER_OFFLINE: 200,
NETWORK_GENERAL_ERROR: 201,
NETWORK_DDOS_ATTACK: 202,
RENDERING_ERROR: 300,
RENDERING_MISSING_SCREENSHOT: 301,
GENERIC_ERROR: 400,
UPGRADE_REQUIRED: 500,
FILE_SAVE_ERROR: 600,
FILE_NON_EXISTANT_PATH: 601
};

@@ -154,3 +156,3 @@ this.request = '';

function _getWaterMarks(applicationKey, applicationSecret, identifier, onComplete){
function _getWaterMarks(applicationKey, applicationSecret, identifier, oncomplete){
var sig = _createSignature(applicationSecret + '|' + identifier);

@@ -164,3 +166,3 @@

_get(this, 'getwatermarks.ashx?' + querystring.stringify(params), 'watermarks', onComplete);
_get(this, 'getwatermarks.ashx?' + querystring.stringify(params), 'watermarks', oncomplete);
}

@@ -221,3 +223,3 @@

function _get(self, url, type, onComplete){
function _get(self, url, type, oncomplete){
var options = {

@@ -243,3 +245,3 @@ host: 'grabz.it',

if (type != 'binary') {
if (onComplete != null) {
if (oncomplete != null) {
var error = _getError(res, data);

@@ -250,6 +252,6 @@ var obj = _convert(data, type);

}
onComplete(error, obj);
oncomplete(error, obj);
}
} else if (onComplete != null) {
onComplete(null, data);
} else if (oncomplete != null) {
oncomplete(null, data);
}

@@ -266,3 +268,3 @@ });

error.message = 'Potential DDOS Attack Detected. Please wait for your service to resume shortly. Also please slow the rate of requests you are sending to GrabzIt to ensure this does not happen in the future.';
error.code = self.NETWORK_DDOS_ATTACK;
error.code = self.ERROR_CODES.NETWORK_DDOS_ATTACK;

@@ -275,3 +277,3 @@ return error;

error.message = 'A network error occured when connecting to the GrabzIt servers.';
error.code = self.NETWORK_GENERAL_ERROR;
error.code = self.ERROR_CODES.NETWORK_GENERAL_ERROR;

@@ -294,2 +296,7 @@ return error;

/*
* Sets the parameters required to convert a web page into a PDF.
*
* For more detailed documentation please visit: http://grabz.it/api/nodejs/grabzitclient.aspx#setpdfoptions
*/
GrabzItClient.prototype.set_pdf_options = function (url, options) {

@@ -363,2 +370,7 @@ var defaults = {

/*
* Sets the parameters required to extract one or more tables from a web page.
*
* For more detailed documentation please visit: http://grabz.it/api/nodejs/grabzitclient.aspx#settableoptions
*/
GrabzItClient.prototype.set_table_options = function (url, options) {

@@ -398,2 +410,7 @@ var defaults = {

/*
* Sets the parameters required to take a screenshot of a web page.
*
* For more detailed documentation please visit: http://grabz.it/api/nodejs/grabzitclient.aspx#setimageoptions
*/
GrabzItClient.prototype.set_image_options = function (url, options) {

@@ -441,47 +458,47 @@ var defaults = {

GrabzItClient.prototype.save = function (options) {
var defaults = {
'callBackUrl': '',
'onComplete': null
};
/*
* Calls the GrabzIt web service to take the screenshot.
*
* For more detailed documentation please visit: http://grabz.it/api/nodejs/grabzitclient.aspx#save
*/
GrabzItClient.prototype.save = function (callBackUrl, oncomplete) {
if (callBackUrl == null) {
callBackUrl = '';
}
context = _extend(defaults, options);
onComplete = context['onComplete'];
if (this.signaturePartOne == '' && this.signaturePartTwo == '' && this.request == '') {
if (onComplete != null){
if (oncomplete != null) {
var error = new Error();
error.message = 'No screenshot parameters have been set.';
error.code = this.PARAMETER_MISSING_PARAMETERS;
onComplete(error, null);
error.code = this.ERROR_CODES.PARAMETER_MISSING_PARAMETERS;
oncomplete(error, null);
}
return;
}
}
this.requestParams.callback = context['callBackUrl'];
this.requestParams.callback = callBackUrl;
var sig = _createSignature(this.signaturePartOne+context['callBackUrl']+this.signaturePartTwo);
var sig = _createSignature(this.signaturePartOne + callBackUrl + this.signaturePartTwo);
var currentRequest = this.request + querystring.stringify(this.requestParams) + '&sig=' + sig;
_get(this, currentRequest, 'screenshot', onComplete);
_get(this, currentRequest, 'screenshot', oncomplete);
};
GrabzItClient.prototype.save_to = function (options) {
var defaults = {
'saveToFile': '',
'onComplete': null
};
/*
* Calls the GrabzIt web service to take the screenshot and saves it to the target path provided. If no target path is provided it returns the screenshot byte data.
*
* For more detailed documentation please visit: http://grabz.it/api/nodejs/grabzitclient.aspx#saveto
*/
GrabzItClient.prototype.save_to = function (saveToFile, oncomplete) {
if (saveToFile == null) {
saveToFile = '';
}
context = _extend(defaults, options);
saveToFile = context['saveToFile'];
onCompleteEvent = context['onComplete'];
var oncompleteEvent = oncomplete;
var self = this;
this.save({ 'onComplete': function (err, id) {
this.save(null, function (err, id) {
if (err != null) {
if (onCompleteEvent != null) {
onCompleteEvent(err, null);
if (oncompleteEvent != null) {
oncompleteEvent(err, null);
}

@@ -496,4 +513,4 @@ return;

if (onCompleteEvent != null) {
onCompleteEvent(err, null);
if (oncompleteEvent != null) {
oncompleteEvent(err, null);
}

@@ -506,8 +523,8 @@ return;

if (onCompleteEvent != null) {
if (oncompleteEvent != null) {
var error = new Error();
error.message = 'The screenshot did not complete with the error: ' + status.message;
error.code = this.RENDERING_ERROR;
error.code = this.ERROR_CODES.RENDERING_ERROR;
onCompleteEvent(error, null);
oncompleteEvent(error, null);
}

@@ -520,8 +537,8 @@ }

if (result == null || result == '') {
if (onCompleteEvent != null) {
if (oncompleteEvent != null) {
var error = new Error();
error.message = 'The screenshot could not be found on GrabzIt.';
error.code = this.RENDERING_MISSING_SCREENSHOT;
error.code = this.ERROR_CODES.RENDERING_MISSING_SCREENSHOT;
onCompleteEvent(error, null);
oncompleteEvent(error, null);

@@ -533,4 +550,4 @@ return;

if (saveToFile == '') {
if (onCompleteEvent != null) {
onCompleteEvent(null, result)
if (oncompleteEvent != null) {
oncompleteEvent(null, result)
}

@@ -540,4 +557,4 @@ }

file.writeFile(saveToFile, result, 'binary', function(err) {
if (onCompleteEvent != null) {
onCompleteEvent(err, null)
if (oncompleteEvent != null) {
oncompleteEvent(err, null)
}

@@ -549,15 +566,29 @@ });

}, 3000);
}
});
};
GrabzItClient.prototype.get_result = function (id, onComplete) {
_get(this, 'getfile.ashx?id=' + id, 'binary', onComplete)
/*
* This method returns the screenshot itself. If nothing is returned then something has gone wrong or the screenshot is not ready yet.
*
* For more detailed documentation please visit: http://grabz.it/api/nodejs/grabzitclient.aspx#getresult
*/
GrabzItClient.prototype.get_result = function (id, oncomplete) {
_get(this, 'getfile.ashx?id=' + id, 'binary', oncomplete)
};
GrabzItClient.prototype.get_status = function (id, onComplete) {
_get(this, 'getstatus.ashx?id=' + id, 'status', onComplete);
/*
* Get the current status of a GrabzIt screenshot.
*
* For more detailed documentation please visit: http://grabz.it/api/nodejs/grabzitclient.aspx#getstatus
*/
GrabzItClient.prototype.get_status = function (id, oncomplete) {
_get(this, 'getstatus.ashx?id=' + id, 'status', oncomplete);
};
GrabzItClient.prototype.get_cookies = function (domain, onComplete) {
/*
* Get all the cookies that GrabzIt is using for a particular domain. This may include your user set cookies as well.
*
* For more detailed documentation please visit: http://grabz.it/api/nodejs/grabzitclient.aspx#getcookies
*/
GrabzItClient.prototype.get_cookies = function (domain, oncomplete) {
var sig = _createSignature(this.applicationSecret+'|'+domain);

@@ -571,6 +602,11 @@

_get(this, 'getcookies.ashx?' + querystring.stringify(params), 'cookies', onComplete)
_get(this, 'getcookies.ashx?' + querystring.stringify(params), 'cookies', oncomplete)
};
GrabzItClient.prototype.set_cookie = function (name, domain, options, onComplete) {
/*
* Sets a new custom cookie on GrabzIt, if the custom cookie has the same name and domain as a global cookie the global cookie is overridden.
*
* For more detailed documentation please visit: http://grabz.it/api/nodejs/grabzitclient.aspx#setcookie
*/
GrabzItClient.prototype.set_cookie = function (name, domain, options, oncomplete) {

@@ -599,6 +635,11 @@ var defaults = {

_get(this, 'setcookie.ashx?' + querystring.stringify(params), 'result', onComplete);
_get(this, 'setcookie.ashx?' + querystring.stringify(params), 'result', oncomplete);
};
GrabzItClient.prototype.delete_cookie = function (name, domain, onComplete) {
/*
* Delete a custom cookie or block a global cookie from being used.
*
* For more detailed documentation please visit: http://grabz.it/api/nodejs/grabzitclient.aspx#deletecookie
*/
GrabzItClient.prototype.delete_cookie = function (name, domain, oncomplete) {

@@ -615,6 +656,11 @@ var sig = _createSignature(this.applicationSecret + '|' + name + '|' + domain + '|1');

_get(this, 'setcookie.ashx?' + querystring.stringify(params), 'result', onComplete);
_get(this, 'setcookie.ashx?' + querystring.stringify(params), 'result', oncomplete);
};
GrabzItClient.prototype.add_watermark = function (identifier, filePath, xpos, ypos, onComplete) {
/*
* Add a new custom watermark.
*
* For more detailed documentation please visit: http://grabz.it/api/nodejs/grabzitclient.aspx#addwatermark
*/
GrabzItClient.prototype.add_watermark = function (identifier, filePath, xpos, ypos, oncomplete) {

@@ -625,3 +671,3 @@ var self = this;

if (!exists) {
if (onComplete != null) {
if (oncomplete != null) {
var error = new Error();

@@ -631,3 +677,3 @@ error.message = 'File: ' + filePath + ' does not exist';

onComplete(error, null);
oncomplete(error, null);
}

@@ -676,3 +722,3 @@ return;

response.on('end', function () {
if (onComplete != null) {
if (oncomplete != null) {
var error = _getError(res, data);

@@ -684,3 +730,3 @@ var obj = _convert(data, 'result');

onComplete(error, obj);
oncomplete(error, obj);
}

@@ -697,3 +743,8 @@ });

GrabzItClient.prototype.delete_watermark = function (identifier, onComplete) {
/*
* Delete a custom watermark.
*
* For more detailed documentation please visit: http://grabz.it/api/nodejs/grabzitclient.aspx#deletewatermark
*/
GrabzItClient.prototype.delete_watermark = function (identifier, oncomplete) {
var sig = _createSignature(this.applicationSecret + '|' + identifier);

@@ -707,14 +758,24 @@

_get(this, 'deletewatermark.ashx?' + querystring.stringify(params), 'result', onComplete);
_get(this, 'deletewatermark.ashx?' + querystring.stringify(params), 'result', oncomplete);
};
GrabzItClient.prototype.get_watermarks = function (onComplete) {
_getWaterMarks(this.applicationKey, this.applicationSecret, '', onComplete);
/*
* Get your uploaded custom watermarks.
*
* For more detailed documentation please visit: http://grabz.it/api/nodejs/grabzitclient.aspx#getwatermarks
*/
GrabzItClient.prototype.get_watermarks = function (oncomplete) {
_getWaterMarks(this.applicationKey, this.applicationSecret, '', oncomplete);
}
GrabzItClient.prototype.get_watermark = function (identifier, onComplete) {
/*
* Get your uploaded custom watermark.
*
* For more detailed documentation please visit: http://grabz.it/api/nodejs/grabzitclient.aspx#getwatermark
*/
GrabzItClient.prototype.get_watermark = function (identifier, oncomplete) {
_getWaterMarks(this.applicationKey, this.applicationSecret, identifier, function (err, watermarks) {
if (err != null) {
if (onComplete != null) {
onComplete(err, null);
if (oncomplete != null) {
oncomplete(err, null);
}

@@ -724,4 +785,4 @@ return;

if (watermarks != null && watermarks.length == 1) {
if (onComplete != null) {
onComplete(null, watermarks[0]);
if (oncomplete != null) {
oncomplete(null, watermarks[0]);
}

@@ -731,4 +792,4 @@ return;

if (onComplete != null) {
onComplete(null, null);
if (oncomplete != null) {
oncomplete(null, null);
}

@@ -735,0 +796,0 @@ });

{
"name": "grabzit",
"description": "Automatically create screenshots of website for free, with GrabzIt. Screenshots can be output in a variety of formats including: JPEG, PNG, TIFF, BMP, PDF, CSV and XLSX.",
"version": "0.0.6",
"version": "0.0.7",
"main": "./lib/grabzit",

@@ -6,0 +6,0 @@ "keywords": [

@@ -1,2 +0,2 @@

GrabzIt 0.0.6 (Alpha)
GrabzIt 0.0.7 (Alpha)
=====================

@@ -15,3 +15,3 @@

client.set_image_options("http://www.google.com");
client.save({"callBackUrl":"http://www.mysite.com/handler"});
client.save(http://www.mysite.com/handler");

@@ -18,0 +18,0 @@ The handler then gets passed the following query string parameters:

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc