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
211
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 2.0.0-canary.16 to 2.0.0-canary.17

64

./dist/index.js

@@ -88,4 +88,3 @@ "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;

}).catch((e) => {
console.log("failed", JSON.stringify({ key, req }));
throw e;
throw new SignatureError(e.message);
});

@@ -439,2 +438,3 @@ const p = jwt.payload;

// src/nextjs.ts
var _server = require('next/server');
function verifyNextjsServerlessSignature(handler, config) {

@@ -461,3 +461,6 @@ var _a, _b;

if (!signature) {
throw new Error("`Upstash-Signature` header is missing");
res.status(400);
res.send("`Upstash-Signature` header is missing");
res.end();
return;
}

@@ -492,3 +495,4 @@ if (typeof signature !== "string") {

res.send("Invalid signature");
return res.end();
res.end();
return;
}

@@ -507,2 +511,51 @@ try {

}
function verifyNextjsEdgeSignature(handler, config) {
var _a, _b;
const currentSigningKey = (_a = config == null ? void 0 : config.currentSigningKey) != null ? _a : process.env.QSTASH_CURRENT_SIGNING_KEY;
if (!currentSigningKey) {
throw new Error(
"currentSigningKey is required, either in the config or as env variable QSTASH_CURRENT_SIGNING_KEY"
);
}
const nextSigningKey = (_b = config == null ? void 0 : config.nextSigningKey) != null ? _b : process.env.QSTASH_NEXT_SIGNING_KEY;
if (!nextSigningKey) {
throw new Error(
"nextSigningKey is required, either in the config or as env variable QSTASH_NEXT_SIGNING_KEY"
);
}
const receiver = new Receiver({
currentSigningKey,
nextSigningKey
});
return (req, nfe) => __async(this, null, function* () {
const signature = req.headers["upstash-signature"];
if (!signature) {
return new (0, _server.NextResponse)(new TextEncoder().encode("`Upstash-Signature` header is missing"), { status: 403 });
}
if (typeof signature !== "string") {
throw new Error("`Upstash-Signature` header is not a string");
}
const body = yield req.text();
const isValid = yield receiver.verify({
signature,
body,
clockTolerance: config == null ? void 0 : config.clockTolerance
});
if (!isValid) {
throw new Error("TODO: andreas");
}
let parsedBody = void 0;
try {
if (req.headers.get("content-type") === "application/json") {
parsedBody = JSON.parse(body);
} else {
parsedBody = body;
}
} catch (e) {
parsedBody = body;
}
const copy = new (0, _server.NextRequest)(__spreadProps(__spreadValues({}, req), { body: parsedBody }));
return handler(copy, nfe);
});
}

@@ -517,3 +570,4 @@

exports.Client = Client; exports.Messages = Messages; exports.QstashError = QstashError; exports.Receiver = Receiver; exports.Schedules = Schedules; exports.SignatureError = SignatureError; exports.Topics = Topics; exports.verifyNextjsServerlessSignature = verifyNextjsServerlessSignature;
exports.Client = Client; exports.Messages = Messages; exports.QstashError = QstashError; exports.Receiver = Receiver; exports.Schedules = Schedules; exports.SignatureError = SignatureError; exports.Topics = Topics; exports.verifyNextjsEdgeSignature = verifyNextjsEdgeSignature; exports.verifyNextjsServerlessSignature = verifyNextjsServerlessSignature;
//# sourceMappingURL=index.js.map

4

dist/index.d.ts
import { NextApiHandler } from 'next';
import { NextRequest, NextFetchEvent, NextResponse } from 'next/server';

@@ -505,3 +506,4 @@ /**

declare function verifyNextjsServerlessSignature(handler: NextApiHandler, config?: VerifySignaturConfig): NextApiHandler;
declare function verifyNextjsEdgeSignature(handler: (req: NextRequest, nfe: NextFetchEvent) => NextResponse | Promise<NextResponse>, config?: VerifySignaturConfig): (req: NextRequest, nfe: NextFetchEvent) => Promise<NextResponse<unknown>>;
export { AddEndpointsRequest, Client, CreateScheduleRequest, Endpoint, Event, EventsRequest, GetEventsResponse, Messages, PublishJsonRequest, PublishRequest, QstashError, Receiver, ReceiverConfig, RemoveEndpointsRequest, Schedule, Schedules, SignatureError, State, Topic, Topics, VerifyRequest, VerifySignaturConfig, WithCursor, verifyNextjsServerlessSignature };
export { AddEndpointsRequest, Client, CreateScheduleRequest, Endpoint, Event, EventsRequest, GetEventsResponse, Messages, PublishJsonRequest, PublishRequest, QstashError, Receiver, ReceiverConfig, RemoveEndpointsRequest, Schedule, Schedules, SignatureError, State, Topic, Topics, VerifyRequest, VerifySignaturConfig, WithCursor, verifyNextjsEdgeSignature, verifyNextjsServerlessSignature };

@@ -88,4 +88,3 @@ "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;

}).catch((e) => {
console.log("failed", JSON.stringify({ key, req }));
throw e;
throw new SignatureError(e.message);
});

@@ -439,2 +438,3 @@ const p = jwt.payload;

// src/nextjs.ts
var _server = require('next/server');
function verifyNextjsServerlessSignature(handler, config) {

@@ -461,3 +461,6 @@ var _a, _b;

if (!signature) {
throw new Error("`Upstash-Signature` header is missing");
res.status(400);
res.send("`Upstash-Signature` header is missing");
res.end();
return;
}

@@ -492,3 +495,4 @@ if (typeof signature !== "string") {

res.send("Invalid signature");
return res.end();
res.end();
return;
}

@@ -507,2 +511,51 @@ try {

}
function verifyNextjsEdgeSignature(handler, config) {
var _a, _b;
const currentSigningKey = (_a = config == null ? void 0 : config.currentSigningKey) != null ? _a : process.env.QSTASH_CURRENT_SIGNING_KEY;
if (!currentSigningKey) {
throw new Error(
"currentSigningKey is required, either in the config or as env variable QSTASH_CURRENT_SIGNING_KEY"
);
}
const nextSigningKey = (_b = config == null ? void 0 : config.nextSigningKey) != null ? _b : process.env.QSTASH_NEXT_SIGNING_KEY;
if (!nextSigningKey) {
throw new Error(
"nextSigningKey is required, either in the config or as env variable QSTASH_NEXT_SIGNING_KEY"
);
}
const receiver = new Receiver({
currentSigningKey,
nextSigningKey
});
return (req, nfe) => __async(this, null, function* () {
const signature = req.headers["upstash-signature"];
if (!signature) {
return new (0, _server.NextResponse)(new TextEncoder().encode("`Upstash-Signature` header is missing"), { status: 403 });
}
if (typeof signature !== "string") {
throw new Error("`Upstash-Signature` header is not a string");
}
const body = yield req.text();
const isValid = yield receiver.verify({
signature,
body,
clockTolerance: config == null ? void 0 : config.clockTolerance
});
if (!isValid) {
throw new Error("TODO: andreas");
}
let parsedBody = void 0;
try {
if (req.headers.get("content-type") === "application/json") {
parsedBody = JSON.parse(body);
} else {
parsedBody = body;
}
} catch (e) {
parsedBody = body;
}
const copy = new (0, _server.NextRequest)(__spreadProps(__spreadValues({}, req), { body: parsedBody }));
return handler(copy, nfe);
});
}

@@ -517,3 +570,4 @@

exports.Client = Client; exports.Messages = Messages; exports.QstashError = QstashError; exports.Receiver = Receiver; exports.Schedules = Schedules; exports.SignatureError = SignatureError; exports.Topics = Topics; exports.verifyNextjsServerlessSignature = verifyNextjsServerlessSignature;
exports.Client = Client; exports.Messages = Messages; exports.QstashError = QstashError; exports.Receiver = Receiver; exports.Schedules = Schedules; exports.SignatureError = SignatureError; exports.Topics = Topics; exports.verifyNextjsEdgeSignature = verifyNextjsEdgeSignature; exports.verifyNextjsServerlessSignature = verifyNextjsServerlessSignature;
//# sourceMappingURL=index.js.map
{
"name": "@upstash/qstash",
"version": "2.0.0-canary.16",
"version": "2.0.0-canary.17",
"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

Sorry, the diff of this file is not supported yet

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