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

@upstash/qstash

Package Overview
Dependencies
Maintainers
5
Versions
229
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@upstash/qstash - npm Package Compare versions

Comparing version

to
2.0.0-canary.16

116

./dist/index.js

@@ -47,102 +47,2 @@ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } }var __defProp = Object.defineProperty;

// src/encoding/base64.ts
var base64abc = [
"A",
"B",
"C",
"D",
"E",
"F",
"G",
"H",
"I",
"J",
"K",
"L",
"M",
"N",
"O",
"P",
"Q",
"R",
"S",
"T",
"U",
"V",
"W",
"X",
"Y",
"Z",
"a",
"b",
"c",
"d",
"e",
"f",
"g",
"h",
"i",
"j",
"k",
"l",
"m",
"n",
"o",
"p",
"q",
"r",
"s",
"t",
"u",
"v",
"w",
"x",
"y",
"z",
"0",
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9",
"+",
"/"
];
function encode(data) {
const uint8 = typeof data === "string" ? new TextEncoder().encode(data) : data instanceof Uint8Array ? data : new Uint8Array(data);
let result = "";
let i;
const l = uint8.length;
for (i = 2; i < l; i += 3) {
result += base64abc[uint8[i - 2] >> 2];
result += base64abc[(uint8[i - 2] & 3) << 4 | uint8[i - 1] >> 4];
result += base64abc[(uint8[i - 1] & 15) << 2 | uint8[i] >> 6];
result += base64abc[uint8[i] & 63];
}
if (i === l + 1) {
result += base64abc[uint8[i - 2] >> 2];
result += base64abc[(uint8[i - 2] & 3) << 4];
result += "==";
}
if (i === l) {
result += base64abc[uint8[i - 2] >> 2];
result += base64abc[(uint8[i - 2] & 3) << 4 | uint8[i - 1] >> 4];
result += base64abc[(uint8[i - 1] & 15) << 2];
result += "=";
}
return result;
}
// src/encoding/base64url.ts
function convertBase64ToBase64url(b64) {
return b64.replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
}
function encode2(data) {
return convertBase64ToBase64url(encode(data));
}
// src/receiver.ts

@@ -185,5 +85,5 @@ var _jose = require('jose'); var jose = _interopRequireWildcard(_jose);

return __async(this, null, function* () {
var _a, _b;
const jwt = yield jose.jwtVerify(req.signature, new TextEncoder().encode(key), {
issuer: "Upstash"
issuer: "Upstash",
clockTolerance: req.clockTolerance
}).catch((e) => {

@@ -197,15 +97,7 @@ console.log("failed", JSON.stringify({ key, req }));

}
const now = Math.floor(Date.now() / 1e3);
if (now - ((_a = req.clockTolerance) != null ? _a : 0) > p.exp) {
console.log({ now, exp: p.exp });
throw new SignatureError("token has expired");
}
if (now + ((_b = req.clockTolerance) != null ? _b : 0) < p.nbf) {
throw new SignatureError("token is not yet valid");
}
const bodyHash = crypto.SHA256(req.body).toString(crypto.enc.Base64url);
const padding = new RegExp(/=+$/);
if (p.body.replace(padding, "") !== encode2(bodyHash).replace(padding, "")) {
if (p.body.replace(padding, "") !== bodyHash.replace(padding, "")) {
throw new SignatureError(
`body hash does not match, want: ${p.body}, got: ${encode2(bodyHash)}`
`body hash does not match, want: ${p.body}, got: ${bodyHash}`
);

@@ -212,0 +104,0 @@ }

@@ -47,102 +47,2 @@ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } }var __defProp = Object.defineProperty;

// src/encoding/base64.ts
var base64abc = [
"A",
"B",
"C",
"D",
"E",
"F",
"G",
"H",
"I",
"J",
"K",
"L",
"M",
"N",
"O",
"P",
"Q",
"R",
"S",
"T",
"U",
"V",
"W",
"X",
"Y",
"Z",
"a",
"b",
"c",
"d",
"e",
"f",
"g",
"h",
"i",
"j",
"k",
"l",
"m",
"n",
"o",
"p",
"q",
"r",
"s",
"t",
"u",
"v",
"w",
"x",
"y",
"z",
"0",
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9",
"+",
"/"
];
function encode(data) {
const uint8 = typeof data === "string" ? new TextEncoder().encode(data) : data instanceof Uint8Array ? data : new Uint8Array(data);
let result = "";
let i;
const l = uint8.length;
for (i = 2; i < l; i += 3) {
result += base64abc[uint8[i - 2] >> 2];
result += base64abc[(uint8[i - 2] & 3) << 4 | uint8[i - 1] >> 4];
result += base64abc[(uint8[i - 1] & 15) << 2 | uint8[i] >> 6];
result += base64abc[uint8[i] & 63];
}
if (i === l + 1) {
result += base64abc[uint8[i - 2] >> 2];
result += base64abc[(uint8[i - 2] & 3) << 4];
result += "==";
}
if (i === l) {
result += base64abc[uint8[i - 2] >> 2];
result += base64abc[(uint8[i - 2] & 3) << 4 | uint8[i - 1] >> 4];
result += base64abc[(uint8[i - 1] & 15) << 2];
result += "=";
}
return result;
}
// src/encoding/base64url.ts
function convertBase64ToBase64url(b64) {
return b64.replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
}
function encode2(data) {
return convertBase64ToBase64url(encode(data));
}
// src/receiver.ts

@@ -185,5 +85,5 @@ var _jose = require('jose'); var jose = _interopRequireWildcard(_jose);

return __async(this, null, function* () {
var _a, _b;
const jwt = yield jose.jwtVerify(req.signature, new TextEncoder().encode(key), {
issuer: "Upstash"
issuer: "Upstash",
clockTolerance: req.clockTolerance
}).catch((e) => {

@@ -197,15 +97,7 @@ console.log("failed", JSON.stringify({ key, req }));

}
const now = Math.floor(Date.now() / 1e3);
if (now - ((_a = req.clockTolerance) != null ? _a : 0) > p.exp) {
console.log({ now, exp: p.exp });
throw new SignatureError("token has expired");
}
if (now + ((_b = req.clockTolerance) != null ? _b : 0) < p.nbf) {
throw new SignatureError("token is not yet valid");
}
const bodyHash = crypto.SHA256(req.body).toString(crypto.enc.Base64url);
const padding = new RegExp(/=+$/);
if (p.body.replace(padding, "") !== encode2(bodyHash).replace(padding, "")) {
if (p.body.replace(padding, "") !== bodyHash.replace(padding, "")) {
throw new SignatureError(
`body hash does not match, want: ${p.body}, got: ${encode2(bodyHash)}`
`body hash does not match, want: ${p.body}, got: ${bodyHash}`
);

@@ -212,0 +104,0 @@ }

2

package.json
{
"name": "@upstash/qstash",
"version": "2.0.0-canary.15",
"version": "2.0.0-canary.16",
"description": "Official Typescript client for QStash",

@@ -5,0 +5,0 @@ "repository": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet