Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

urlbox-next

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

urlbox-next - npm Package Compare versions

Comparing version 3.0.5 to 3.1.5

dist/index.js.map

0

dist/index.d.ts

@@ -0,0 +0,0 @@ export interface UrlboxOptions {

@@ -1,8 +0,85 @@

'use strict'
if (process.env.NODE_ENV === 'production') {
module.exports = require('./urlbox-next.cjs.production.min.js')
} else {
module.exports = require('./urlbox-next.cjs.development.js')
"use strict";
// const includes = require("lodash.includes");
// const qs = require("qs");
import qs from "qs";
import hmacSha256 from "crypto-js/hmac-sha256";
// const hmacSha1 = require("crypto-js/hmac-sha1");
// const DEFAULT_PREFIX = "https://api.urlbox.io/s";
var DEFAULT_PREFIX = "https://api.urlbox.io/v1/";
var DEFAULT_OPTIONS = {
// format: "png"
};
export default function (key, secret, prefix) {
if (prefix === void 0) { prefix = DEFAULT_PREFIX; }
if (!key) {
throw new Error("Please provide your urlbox API key");
}
if (!secret) {
throw new Error("Please provide your urlbox secret key");
}
return {
buildUrl: function (options) {
options = validateOptions(options);
console.log("got options", options);
var query = toQueryString(options);
console.log("got query", query);
if (secret) {
var token = generateToken(query, secret);
console.log("got token", token);
return "".concat(prefix).concat(key, "/").concat(token, "/").concat(options.format || "png", "?").concat(query);
}
else {
// tokenless URL
return "".concat(prefix).concat(key, "/").concat(options.format || "png", "?").concat(query);
}
},
buildUrls: function (options) {
options = validateOptions(options);
var query = toQueryString(options);
var token = generateToken(query, secret);
// console.log("got token", token);
return {
unauthenticated: "".concat(prefix).concat(key, "/").concat(options.format || "png", "?").concat(query),
authenticated: "".concat(prefix).concat(key, "/").concat(token, "/").concat(options.format || "png", "?").concat(query),
postJSON: "curl -X POST https://api.urlbox.io/v1/render -H \"Authorization: Bearer ".concat(secret, "\" -H \"Content-Type: application/json\" -d '").concat(JSON.stringify(options), "'"),
postForm: "curl ".concat(prefix, "render"),
};
},
};
}
var generateToken = function (queryString, secret) {
return hmacSha256(queryString, secret);
};
var toQueryString = function (options) {
var filterFunc = function (key, value) {
if (key === "format" || key === "token" || key === "key" || !value) {
return;
}
return value;
};
var fixedEncodeURIComponent = function (str) {
var result = encodeURIComponent(str).replace(/[!'()*]/g, function (c) { return "%" + c.charCodeAt(0).toString(16).toUpperCase(); });
return result;
};
return qs.stringify(options, {
encoder: fixedEncodeURIComponent,
filter: filterFunc,
arrayFormat: "repeat",
});
};
var validateOptions = function (options) {
if (!options) {
throw new Error("no options object passed");
}
// console.log("In validate", options.url !== null && options.url !== undefined)
if (options.url !== null &&
options.url !== undefined &&
typeof options.url !== "string") {
throw new Error("url should be of type string (something like google.com)");
}
if (options.url === null || options.html === null) {
throw new Error("url or html option is required");
}
return Object.assign({}, DEFAULT_OPTIONS, options);
};
//# sourceMappingURL=index.js.map

39

package.json
{
"version": "3.0.5",
"version": "3.1.5",
"license": "MIT",

@@ -15,42 +15,15 @@ "main": "dist/index.js",

"scripts": {
"start": "tsdx watch",
"build": "tsdx build",
"test": "tsdx test",
"lint": "tsdx lint",
"prepare": "tsdx build",
"size": "size-limit",
"analyze": "size-limit --why"
"dev": "tsc --watch",
"build": "tsc -b tsconfig.json"
},
"husky": {
"hooks": {
"pre-commit": "tsdx lint"
}
},
"name": "urlbox-next",
"author": "Chris",
"module": "dist/urlbox-next.esm.js",
"size-limit": [
{
"path": "dist/urlbox-next.cjs.production.min.js",
"limit": "10 KB"
},
{
"path": "dist/urlbox-next.esm.js",
"limit": "10 KB"
}
],
"devDependencies": {
"@size-limit/preset-small-lib": "^4.10.1",
"@types/crypto-js": "^4.1.0",
"husky": "^5.2.0",
"size-limit": "^4.10.1",
"tsdx": "^0.14.1",
"tslib": "^2.1.0",
"typescript": "^4.2.3"
"@types/crypto-js": "^4.1.2",
"typescript": "^5.2.2"
},
"dependencies": {
"crypto-js": "4.1.1",
"mixpanel": "^0.13.0",
"qs": "6.10.1"
"qs": "6.11.2"
}
}
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