New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

screenshotone-api-sdk

Package Overview
Dependencies
Maintainers
1
Versions
57
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

screenshotone-api-sdk - npm Package Compare versions

Comparing version 1.0.9 to 1.0.10

275

dist/main.js

@@ -1,38 +0,54 @@

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.TakeOptions = exports.Client = void 0;
const crypto = __importStar(require("crypto"));
const big_js_1 = __importDefault(require("big.js"));
const node_fetch_1 = __importDefault(require("node-fetch"));
import * as crypto from 'crypto';
import Big from 'big.js';
import fetch from 'node-fetch';
/**
* Represents an API client for the screenshotone.com API.
*/
class Client {
constructor(accessKey, secretKey) {
var Client = /** @class */ (function () {
function Client(accessKey, secretKey) {
this.API_BASE_URL = "https://api.screenshotone.com";

@@ -43,28 +59,39 @@ this.API_TAKE_PATH = "/take";

}
generateTakeURL(options) {
const query = options.toQuery();
Client.prototype.generateTakeURL = function (options) {
var query = options.toQuery();
query.append("access_key", this.accessKey);
let queryString = query.toString();
const signature = crypto.createHmac("sha256", this.secretKey)
var queryString = query.toString();
var signature = crypto.createHmac("sha256", this.secretKey)
.update(queryString, 'utf-8')
.digest('hex');
queryString += '&signature=' + signature;
return `${this.API_BASE_URL}${this.API_TAKE_PATH}?${queryString}`;
}
async take(options) {
const url = this.generateTakeURL(options);
const response = await (0, node_fetch_1.default)(url);
if (response.ok) {
return await response.blob();
}
throw new Error(`failed to take screenshot, response returned ${response.status} ${response.statusText}`);
}
}
exports.Client = Client;
return "".concat(this.API_BASE_URL).concat(this.API_TAKE_PATH, "?").concat(queryString);
};
Client.prototype.take = function (options) {
return __awaiter(this, void 0, void 0, function () {
var url, response;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = this.generateTakeURL(options);
return [4 /*yield*/, fetch(url)];
case 1:
response = _a.sent();
if (!response.ok) return [3 /*break*/, 3];
return [4 /*yield*/, response.blob()];
case 2: return [2 /*return*/, _a.sent()];
case 3: throw new Error("failed to take screenshot, response returned ".concat(response.status, " ").concat(response.statusText));
}
});
});
};
return Client;
}());
export { Client };
/**
* Represents options for taking screenshots.
*/
class TakeOptions {
constructor(url) {
const query = new URLSearchParams();
var TakeOptions = /** @class */ (function () {
function TakeOptions(url) {
var query = new URLSearchParams();
query.append("url", url);

@@ -76,10 +103,15 @@ this.query = query;

*/
static url(url) {
TakeOptions.url = function (url) {
return new TakeOptions(url);
}
put(key, ...values) {
for (const value of values) {
};
TakeOptions.prototype.put = function (key) {
var values = [];
for (var _i = 1; _i < arguments.length; _i++) {
values[_i - 1] = arguments[_i];
}
for (var _a = 0, values_1 = values; _a < values_1.length; _a++) {
var value = values_1[_a];
this.query.append(key, value);
}
}
};
;

@@ -89,20 +121,20 @@ /**

*/
fullPage(fullPage) {
TakeOptions.prototype.fullPage = function (fullPage) {
this.put("full_page", fullPage ? "true" : "false");
return this;
}
};
/**
* Sets response format, one of: "png", "jpeg", "webp" or "jpg".
*/
format(format) {
TakeOptions.prototype.format = function (format) {
this.put("format", format);
return this;
}
};
/**
* Renders image with the specified quality. Available for the next formats: "jpeg" ("jpg"), "webp".
*/
imageQuality(imageQuality) {
TakeOptions.prototype.imageQuality = function (imageQuality) {
this.put("image_quality", imageQuality.toString());
return this;
}
};
/**

@@ -112,27 +144,27 @@ * Renders a transparent background for the image. Works only if the site has not defined background color.

*/
omitBackground(omitBackground) {
TakeOptions.prototype.omitBackground = function (omitBackground) {
this.put("omit_background", omitBackground ? "true" : "false");
return this;
}
};
/**
* Sets the width of the browser viewport (pixels).
*/
viewportWidth(viewportWidth) {
TakeOptions.prototype.viewportWidth = function (viewportWidth) {
this.put("viewport_width", viewportWidth.toString());
return this;
}
};
/**
* Sets the height of the browser viewport (pixels).
*/
viewportHeight(viewportHeight) {
TakeOptions.prototype.viewportHeight = function (viewportHeight) {
this.put("viewport_height", viewportHeight.toString());
return this;
}
};
/**
* Sets the device scale factor. Acceptable value is one of: 1, 2 or 3.
*/
deviceScaleFactor(deviceScaleFactor) {
TakeOptions.prototype.deviceScaleFactor = function (deviceScaleFactor) {
this.put("device_scale_factor", deviceScaleFactor.toString());
return this;
}
};
/**

@@ -142,41 +174,45 @@ * Sets geolocation latitude for the request.

*/
geolocationLatitude(latitude) {
this.put("geolocation_latitude", new big_js_1.default(latitude).toFixed(20).replace(/0+$/, ""));
TakeOptions.prototype.geolocationLatitude = function (latitude) {
this.put("geolocation_latitude", new Big(latitude).toFixed(20).replace(/0+$/, ""));
return this;
}
};
/**
* Sets geolocation longitude for the request. Both latitude and longitude are required if one of them is set.
*/
geolocationLongitude(longitude) {
this.put("geolocation_longitude", new big_js_1.default(longitude).toFixed(20).replace(/0+$/, ""));
TakeOptions.prototype.geolocationLongitude = function (longitude) {
this.put("geolocation_longitude", new Big(longitude).toFixed(20).replace(/0+$/, ""));
return this;
}
};
/**
* Sets the geolocation accuracy in meters.
*/
geolocationAccuracy(accuracy) {
TakeOptions.prototype.geolocationAccuracy = function (accuracy) {
this.put("geolocation_accuracy", accuracy.toString());
return this;
}
};
/**
* Blocks ads.
*/
blockAds(blockAds) {
TakeOptions.prototype.blockAds = function (blockAds) {
this.put("block_ads", blockAds ? "true" : "false");
return this;
}
};
/**
* Blocks trackers.
*/
blockTrackers(blockTrackers) {
TakeOptions.prototype.blockTrackers = function (blockTrackers) {
this.put("block_trackers", blockTrackers ? "true" : "false");
return this;
}
};
/**
* Blocks requests by specifying URL, domain, or even a simple pattern.
*/
blockRequests(...blockRequests) {
this.put("block_requests", ...blockRequests);
TakeOptions.prototype.blockRequests = function () {
var blockRequests = [];
for (var _i = 0; _i < arguments.length; _i++) {
blockRequests[_i] = arguments[_i];
}
this.put.apply(this, __spreadArray(["block_requests"], blockRequests, false));
return this;
}
};
/**

@@ -186,55 +222,67 @@ * Blocks loading resources by type. Available resource types are: "document", "stylesheet", "image", "media",

*/
blockResources(...blockResources) {
this.put("block_resources", ...blockResources);
TakeOptions.prototype.blockResources = function () {
var blockResources = [];
for (var _i = 0; _i < arguments.length; _i++) {
blockResources[_i] = arguments[_i];
}
this.put.apply(this, __spreadArray(["block_resources"], blockResources, false));
return this;
}
};
/**
* Enables caching.
*/
cache(cache) {
TakeOptions.prototype.cache = function (cache) {
this.put("cache", cache ? "true" : "false");
return this;
}
};
/**
* Sets cache TTL.
*/
cacheTtl(cacheTTL) {
TakeOptions.prototype.cacheTtl = function (cacheTTL) {
this.put("cache_ttl", cacheTTL.toString());
return this;
}
};
/**
* Sets cache key.
*/
cacheKey(cacheKey) {
TakeOptions.prototype.cacheKey = function (cacheKey) {
this.put("cache_key", cacheKey);
return this;
}
};
/**
* Sets a user agent for the request.
*/
userAgent(userAgent) {
TakeOptions.prototype.userAgent = function (userAgent) {
this.put("user_agent", userAgent);
return this;
}
};
/**
* Sets an authorization header for the request.
*/
authorization(authorization) {
TakeOptions.prototype.authorization = function (authorization) {
this.put("authorization", authorization);
return this;
}
};
/**
* Set cookies for the request.
*/
cookies(...cookies) {
this.put("cookies", ...cookies);
TakeOptions.prototype.cookies = function () {
var cookies = [];
for (var _i = 0; _i < arguments.length; _i++) {
cookies[_i] = arguments[_i];
}
this.put.apply(this, __spreadArray(["cookies"], cookies, false));
return this;
}
};
/**
* Sets extra headers for the request.
*/
headers(...headers) {
this.put("headers", ...headers);
TakeOptions.prototype.headers = function () {
var headers = [];
for (var _i = 0; _i < arguments.length; _i++) {
headers[_i] = arguments[_i];
}
this.put.apply(this, __spreadArray(["headers"], headers, false));
return this;
}
};
/**

@@ -246,25 +294,26 @@ * TimeZone sets time zone for the request.

*/
timeZone(timeZone) {
TakeOptions.prototype.timeZone = function (timeZone) {
this.put("time_zone", timeZone);
return this;
}
};
/**
* Sets delay.
*/
delay(delay) {
TakeOptions.prototype.delay = function (delay) {
this.put("delay", delay.toString());
return this;
}
};
/**
* Sets timeout.
*/
timeout(timeout) {
TakeOptions.prototype.timeout = function (timeout) {
this.put("timeout", timeout.toString());
return this;
}
toQuery() {
};
TakeOptions.prototype.toQuery = function () {
return new URLSearchParams(this.query.toString());
}
}
exports.TakeOptions = TakeOptions;
};
return TakeOptions;
}());
export { TakeOptions };
//# sourceMappingURL=main.js.map
{
"name": "screenshotone-api-sdk",
"homepage": "https://screenshotone.com",
"version": "1.0.9",
"version": "1.0.10",
"description": "Use ScreenshotOne.com API to generate screenshots of any website.",

@@ -31,4 +31,5 @@ "repository": {

"main": "dist/main.js",
"types": "dist/@types/index",
"typings": "dist/@types/index",
"type": "module",
"types": "dist/@types/main.d.ts",
"typings": "dist/@types/main.d.ts",
"devDependencies": {

@@ -35,0 +36,0 @@ "typescript": "^4.7.3",

{
"compilerOptions": {
"lib": ["es2021"],
"target": "es2020",
"module": "es2015",
"moduleResolution": "node",
"module": "commonjs",
"esModuleInterop": true,

@@ -8,0 +6,0 @@ "outDir": "./dist",

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