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
6
Versions
217
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 0.0.0-ci.8e51c7bcbaeb288246729b2deca55d9338f7b474-20231114113647 to 0.0.0-ci.91df1d0db7459c9baa9dc99b2e0ac44907d6be4f-20240508125439

dist/chunk-77ATZ7AW.js

87

dist/index.d.ts

@@ -0,1 +1,3 @@

import { BodyInit, HeadersInit } from 'undici';
/**

@@ -194,4 +196,53 @@ * Necessary to verify the signature of a request.

delete(dlqMessageId: string): Promise<void>;
/**
* Remove multiple messages from the dlq using their `dlqId`s
*/
deleteMany(req: {
dlqIds: string[];
}): Promise<{
deleted: number;
}>;
}
type QueueResponse = {
createdAt: number;
updatedAt: number;
name: string;
parallelism: number;
lag: number;
};
type UpsertQueueRequest = {
parallelism: number;
};
type EnqueueRequest = PublishRequest;
declare class Queue {
private readonly http;
private readonly queueName;
constructor(http: Requester, queueName?: string);
/**
* Create or update the queue
*/
upsert(req: UpsertQueueRequest): Promise<void>;
/**
* Get the queue details
*/
get(): Promise<QueueResponse>;
/**
* List queues
*/
list(): Promise<QueueResponse[]>;
/**
* Delete the queue
*/
delete(): Promise<void>;
/**
* Enqueue a message to a queue.
*/
enqueue(req: EnqueueRequest): Promise<PublishResponse<PublishRequest>>;
/**
* Enqueue a message to a queue, serializing the body to JSON.
*/
enqueueJSON<TBody = unknown>(req: PublishRequest<TBody>): Promise<PublishResponse<PublishRequest<TBody>>>;
}
type Schedule = {

@@ -465,5 +516,6 @@ scheduleId: string;

*
* Configure how many times you would like the delivery to be retried
* Configure how many times you would like the delivery to be retried up to the maxRetries limit
* defined in your plan.
*
* @default The maximum retry quota associated with your account.
* @default 3
*/

@@ -515,3 +567,15 @@ retries?: number;

cursor?: number;
filter?: EventsRequestFilter;
};
type EventsRequestFilter = {
messageId?: string;
state?: State;
url?: string;
topicName?: string;
scheduleId?: string;
queueName?: string;
fromDate?: number;
toDate?: number;
count?: number;
};
type GetEventsResponse = {

@@ -521,2 +585,5 @@ cursor?: number;

};
type QueueRequest = {
queueName?: string;
};
declare class Client {

@@ -549,2 +616,8 @@ http: Requester;

get schedules(): Schedules;
/**
* Access the queue API.
*
* Create, read, update or delete queues.
*/
queue(req?: QueueRequest): Queue;
publish<TRequest extends PublishRequest>(req: TRequest): Promise<PublishResponse<TRequest>>;

@@ -557,2 +630,10 @@ /**

/**
* Batch publish messages to QStash.
*/
batch(req: PublishRequest[]): Promise<PublishResponse<PublishRequest>[]>;
/**
* Batch publish messages to QStash, serializing each body to JSON.
*/
batchJSON<TBody = unknown, TRequest extends PublishRequest<TBody> = PublishRequest<TBody>>(req: TRequest[]): Promise<PublishResponse<TRequest>[]>;
/**
* Retrieve your logs.

@@ -598,2 +679,2 @@ *

export { AddEndpointsRequest, Client, CreateScheduleRequest, Endpoint, Event, EventsRequest, GetEventsResponse, Message, Messages, PublishJsonRequest, PublishRequest, QstashError, QstashRatelimitError, Receiver, ReceiverConfig, RemoveEndpointsRequest, Schedule, Schedules, SignatureError, State, Topic, Topics, VerifyRequest, WithCursor };
export { type AddEndpointsRequest, Client, type CreateScheduleRequest, type Endpoint, type Event, type EventsRequest, type GetEventsResponse, type Message, Messages, type PublishJsonRequest, type PublishRequest, type PublishResponse, type PublishToTopicResponse, type PublishToUrlResponse, QstashError, QstashRatelimitError, type QueueRequest, Receiver, type ReceiverConfig, type RemoveEndpointsRequest, type Schedule, Schedules, SignatureError, type State, type Topic, Topics, type VerifyRequest, type WithCursor };

602

dist/index.js

@@ -1,11 +0,9 @@

"use strict";Object.defineProperty(exports, "__esModule", {value: true});
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
var _chunk77ATZ7AWjs = require('./chunk-77ATZ7AW.js');
var _chunkEROSIHWEjs = require('./chunk-EROSIHWE.js');
// src/client/dlq.ts
var DLQ = class {
constructor(http) {

@@ -17,9 +15,7 @@ this.http = http;

*/
listMessages(opts) {
return _chunkEROSIHWEjs.__async.call(void 0, this, null, function* () {
return yield this.http.request({
method: "GET",
path: ["v2", "dlq"],
query: { cursor: opts == null ? void 0 : opts.cursor }
});
async listMessages(opts) {
return await this.http.request({
method: "GET",
path: ["v2", "dlq"],
query: { cursor: _optionalChain([opts, 'optionalAccess', _ => _.cursor]) }
});

@@ -30,12 +26,21 @@ }

*/
delete(dlqMessageId) {
return _chunkEROSIHWEjs.__async.call(void 0, this, null, function* () {
return yield this.http.request({
method: "DELETE",
path: ["v2", "dlq", dlqMessageId],
parseResponseAsJson: false
// there is no response
});
async delete(dlqMessageId) {
return await this.http.request({
method: "DELETE",
path: ["v2", "dlq", dlqMessageId],
parseResponseAsJson: false
// there is no response
});
}
/**
* Remove multiple messages from the dlq using their `dlqId`s
*/
async deleteMany(req) {
return await this.http.request({
method: "DELETE",
path: ["v2", "dlq"],
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ dlqIds: req.dlqIds })
});
}
};

@@ -58,7 +63,10 @@

var HttpClient = class {
constructor(config) {
var _a, _b, _c;
this.baseUrl = config.baseUrl.replace(/\/$/, "");
this.authorization = config.authorization;
if (typeof (config == null ? void 0 : config.retry) === "boolean" && (config == null ? void 0 : config.retry) === false) {
if (typeof _optionalChain([config, 'optionalAccess', _2 => _2.retry]) === "boolean" && _optionalChain([config, 'optionalAccess', _3 => _3.retry]) === false) {
this.retry = {

@@ -70,57 +78,55 @@ attempts: 1,

this.retry = {
attempts: ((_a = config.retry) == null ? void 0 : _a.retries) ? config.retry.retries + 1 : 5,
backoff: (_c = (_b = config.retry) == null ? void 0 : _b.backoff) != null ? _c : (retryCount) => Math.exp(retryCount) * 50
attempts: _optionalChain([config, 'access', _4 => _4.retry, 'optionalAccess', _5 => _5.retries]) ? config.retry.retries + 1 : 5,
backoff: _nullishCoalesce(_optionalChain([config, 'access', _6 => _6.retry, 'optionalAccess', _7 => _7.backoff]), () => ( ((retryCount) => Math.exp(retryCount) * 50)))
};
}
}
request(req) {
return _chunkEROSIHWEjs.__async.call(void 0, this, null, function* () {
var _a;
const headers = new Headers(req.headers);
headers.set("Authorization", this.authorization);
const requestOptions = {
method: req.method,
headers,
body: req.body,
keepalive: req.keepalive
};
const url = new URL([this.baseUrl, ...(_a = req.path) != null ? _a : []].join("/"));
if (req.query) {
for (const [key, value] of Object.entries(req.query)) {
if (typeof value !== "undefined") {
url.searchParams.set(key, value.toString());
}
async request(req) {
const headers = new Headers(req.headers);
headers.set("Authorization", this.authorization);
const requestOptions = {
method: req.method,
headers,
body: req.body,
keepalive: req.keepalive
};
const url = new URL([this.baseUrl, ..._nullishCoalesce(req.path, () => ( []))].join("/"));
if (req.query) {
for (const [key, value] of Object.entries(req.query)) {
if (typeof value !== "undefined") {
url.searchParams.set(key, value.toString());
}
}
let res = null;
let error = null;
for (let i = 0; i < this.retry.attempts; i++) {
try {
res = yield fetch(url.toString(), requestOptions);
break;
} catch (err) {
error = err;
yield new Promise((r) => setTimeout(r, this.retry.backoff(i)));
}
}
let res = null;
let error = null;
for (let i = 0; i < this.retry.attempts; i++) {
try {
res = await fetch(url.toString(), requestOptions);
break;
} catch (err) {
error = err;
await new Promise((r) => setTimeout(r, this.retry.backoff(i)));
}
if (!res) {
throw error != null ? error : new Error("Exhausted all retries");
}
if (res.status === 429) {
throw new QstashRatelimitError({
limit: res.headers.get("Burst-RateLimit-Limit"),
remaining: res.headers.get("Burst-RateLimit-Remaining"),
reset: res.headers.get("Burst-RateLimit-Reset")
});
}
if (res.status < 200 || res.status >= 300) {
const body = yield res.text();
throw new QstashError(body.length > 0 ? body : `Error: status=${res.status}`);
}
if (req.parseResponseAsJson === false) {
return void 0;
} else {
return yield res.json();
}
});
}
if (!res) {
throw _nullishCoalesce(error, () => ( new Error("Exhausted all retries")));
}
if (res.status === 429) {
throw new QstashRatelimitError({
limit: res.headers.get("Burst-RateLimit-Limit"),
remaining: res.headers.get("Burst-RateLimit-Remaining"),
reset: res.headers.get("Burst-RateLimit-Reset")
});
}
if (res.status < 200 || res.status >= 300) {
const body = await res.text();
throw new QstashError(
body.length > 0 ? body : `Error: status=${res.status}`
);
}
if (req.parseResponseAsJson === false) {
return void 0;
}
return await res.json();
}

@@ -131,2 +137,3 @@ };

var Messages = class {
constructor(http) {

@@ -138,8 +145,6 @@ this.http = http;

*/
get(messageId) {
return _chunkEROSIHWEjs.__async.call(void 0, this, null, function* () {
return yield this.http.request({
method: "GET",
path: ["v2", "messages", messageId]
});
async get(messageId) {
return await this.http.request({
method: "GET",
path: ["v2", "messages", messageId]
});

@@ -150,9 +155,7 @@ }

*/
delete(messageId) {
return _chunkEROSIHWEjs.__async.call(void 0, this, null, function* () {
return yield this.http.request({
method: "DELETE",
path: ["v2", "messages", messageId],
parseResponseAsJson: false
});
async delete(messageId) {
return await this.http.request({
method: "DELETE",
path: ["v2", "messages", messageId],
parseResponseAsJson: false
});

@@ -162,4 +165,148 @@ }

// src/client/utils.ts
var _undici = require('undici');
function prefixHeaders(headers) {
const isIgnoredHeader = (header) => {
const lowerCaseHeader = header.toLowerCase();
return lowerCaseHeader.startsWith("content-type") || lowerCaseHeader.startsWith("upstash-");
};
const keysToBePrefixed = Array.from(headers.keys()).filter(
(key) => !isIgnoredHeader(key)
);
for (const key of keysToBePrefixed) {
const value = headers.get(key);
if (value !== null) {
headers.set(`Upstash-Forward-${key}`, value);
}
headers.delete(key);
}
return headers;
}
function processHeaders(req) {
const headers = prefixHeaders(new (0, _undici.Headers)(req.headers));
headers.set("Upstash-Method", _nullishCoalesce(req.method, () => ( "POST")));
if (typeof req.delay !== "undefined") {
headers.set("Upstash-Delay", `${req.delay.toFixed()}s`);
}
if (typeof req.notBefore !== "undefined") {
headers.set("Upstash-Not-Before", req.notBefore.toFixed());
}
if (typeof req.deduplicationId !== "undefined") {
headers.set("Upstash-Deduplication-Id", req.deduplicationId);
}
if (typeof req.contentBasedDeduplication !== "undefined") {
headers.set("Upstash-Content-Based-Deduplication", "true");
}
if (typeof req.retries !== "undefined") {
headers.set("Upstash-Retries", req.retries.toFixed());
}
if (typeof req.callback !== "undefined") {
headers.set("Upstash-Callback", req.callback);
}
if (typeof req.failureCallback !== "undefined") {
headers.set("Upstash-Failure-Callback", req.failureCallback);
}
return headers;
}
// src/client/queue.ts
var Queue = class {
constructor(http, queueName) {
this.http = http;
this.queueName = queueName;
}
/**
* Create or update the queue
*/
async upsert(req) {
if (!this.queueName) {
throw new Error("Please provide a queue name to the Queue constructor");
}
const body = {
queueName: this.queueName,
parallelism: req.parallelism
};
await this.http.request({
method: "POST",
path: ["v2", "queues"],
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify(body),
parseResponseAsJson: false
});
}
/**
* Get the queue details
*/
async get() {
if (!this.queueName) {
throw new Error("Please provide a queue name to the Queue constructor");
}
return await this.http.request({
method: "GET",
path: ["v2", "queues", this.queueName]
});
}
/**
* List queues
*/
async list() {
return await this.http.request({
method: "GET",
path: ["v2", "queues"]
});
}
/**
* Delete the queue
*/
async delete() {
if (!this.queueName) {
throw new Error("Please provide a queue name to the Queue constructor");
}
await this.http.request({
method: "DELETE",
path: ["v2", "queues", this.queueName],
parseResponseAsJson: false
});
}
/**
* Enqueue a message to a queue.
*/
async enqueue(req) {
if (!this.queueName) {
throw new Error("Please provide a queue name to the Queue constructor");
}
const headers = processHeaders(req);
const destination = _nullishCoalesce(req.url, () => ( req.topic));
const res = await this.http.request({
path: ["v2", "enqueue", this.queueName, destination],
body: req.body,
headers,
method: "POST"
});
return res;
}
/**
* Enqueue a message to a queue, serializing the body to JSON.
*/
async enqueueJSON(req) {
const headers = prefixHeaders(new (0, _undici.Headers)(req.headers));
headers.set("Content-Type", "application/json");
const res = await this.enqueue({
...req,
body: JSON.stringify(req.body),
headers
});
return res;
}
};
// src/client/schedules.ts
var Schedules = class {
constructor(http) {

@@ -171,30 +318,28 @@ this.http = http;

*/
create(req) {
return _chunkEROSIHWEjs.__async.call(void 0, this, null, function* () {
const headers = new Headers(req.headers);
if (!headers.has("Content-Type")) {
headers.set("Content-Type", "application/json");
}
headers.set("Upstash-Cron", req.cron);
if (typeof req.method !== "undefined") {
headers.set("Upstash-Method", req.method);
}
if (typeof req.delay !== "undefined") {
headers.set("Upstash-Delay", `${req.delay.toFixed()}s`);
}
if (typeof req.retries !== "undefined") {
headers.set("Upstash-Retries", req.retries.toFixed());
}
if (typeof req.callback !== "undefined") {
headers.set("Upstash-Callback", req.callback);
}
if (typeof req.failureCallback !== "undefined") {
headers.set("Upstash-Failure-Callback", req.failureCallback);
}
return yield this.http.request({
method: "POST",
headers,
path: ["v2", "schedules", req.destination],
body: req.body
});
async create(req) {
const headers = prefixHeaders(new (0, _undici.Headers)(req.headers));
if (!headers.has("Content-Type")) {
headers.set("Content-Type", "application/json");
}
headers.set("Upstash-Cron", req.cron);
if (typeof req.method !== "undefined") {
headers.set("Upstash-Method", req.method);
}
if (typeof req.delay !== "undefined") {
headers.set("Upstash-Delay", `${req.delay.toFixed()}s`);
}
if (typeof req.retries !== "undefined") {
headers.set("Upstash-Retries", req.retries.toFixed());
}
if (typeof req.callback !== "undefined") {
headers.set("Upstash-Callback", req.callback);
}
if (typeof req.failureCallback !== "undefined") {
headers.set("Upstash-Failure-Callback", req.failureCallback);
}
return await this.http.request({
method: "POST",
headers,
path: ["v2", "schedules", req.destination],
body: req.body
});

@@ -205,8 +350,6 @@ }

*/
get(scheduleId) {
return _chunkEROSIHWEjs.__async.call(void 0, this, null, function* () {
return yield this.http.request({
method: "GET",
path: ["v2", "schedules", scheduleId]
});
async get(scheduleId) {
return await this.http.request({
method: "GET",
path: ["v2", "schedules", scheduleId]
});

@@ -217,8 +360,6 @@ }

*/
list() {
return _chunkEROSIHWEjs.__async.call(void 0, this, null, function* () {
return yield this.http.request({
method: "GET",
path: ["v2", "schedules"]
});
async list() {
return await this.http.request({
method: "GET",
path: ["v2", "schedules"]
});

@@ -229,9 +370,7 @@ }

*/
delete(scheduleId) {
return _chunkEROSIHWEjs.__async.call(void 0, this, null, function* () {
return yield this.http.request({
method: "DELETE",
path: ["v2", "schedules", scheduleId],
parseResponseAsJson: false
});
async delete(scheduleId) {
return await this.http.request({
method: "DELETE",
path: ["v2", "schedules", scheduleId],
parseResponseAsJson: false
});

@@ -243,2 +382,3 @@ }

var Topics = class {
constructor(http) {

@@ -250,11 +390,9 @@ this.http = http;

*/
addEndpoints(req) {
return _chunkEROSIHWEjs.__async.call(void 0, this, null, function* () {
yield this.http.request({
method: "POST",
path: ["v2", "topics", req.name, "endpoints"],
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ endpoints: req.endpoints }),
parseResponseAsJson: false
});
async addEndpoints(req) {
await this.http.request({
method: "POST",
path: ["v2", "topics", req.name, "endpoints"],
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ endpoints: req.endpoints }),
parseResponseAsJson: false
});

@@ -265,11 +403,9 @@ }

*/
removeEndpoints(req) {
return _chunkEROSIHWEjs.__async.call(void 0, this, null, function* () {
yield this.http.request({
method: "DELETE",
path: ["v2", "topics", req.name, "endpoints"],
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ endpoints: req.endpoints }),
parseResponseAsJson: false
});
async removeEndpoints(req) {
await this.http.request({
method: "DELETE",
path: ["v2", "topics", req.name, "endpoints"],
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ endpoints: req.endpoints }),
parseResponseAsJson: false
});

@@ -280,8 +416,6 @@ }

*/
list() {
return _chunkEROSIHWEjs.__async.call(void 0, this, null, function* () {
return yield this.http.request({
method: "GET",
path: ["v2", "topics"]
});
async list() {
return await this.http.request({
method: "GET",
path: ["v2", "topics"]
});

@@ -292,8 +426,6 @@ }

*/
get(name) {
return _chunkEROSIHWEjs.__async.call(void 0, this, null, function* () {
return yield this.http.request({
method: "GET",
path: ["v2", "topics", name]
});
async get(name) {
return await this.http.request({
method: "GET",
path: ["v2", "topics", name]
});

@@ -304,9 +436,7 @@ }

*/
delete(name) {
return _chunkEROSIHWEjs.__async.call(void 0, this, null, function* () {
return yield this.http.request({
method: "DELETE",
path: ["v2", "topics", name],
parseResponseAsJson: false
});
async delete(name) {
return await this.http.request({
method: "DELETE",
path: ["v2", "topics", name],
parseResponseAsJson: false
});

@@ -317,3 +447,5 @@ }

// src/client/client.ts
var Client = class {
constructor(config) {

@@ -358,36 +490,19 @@ this.http = new HttpClient({

}
publish(req) {
return _chunkEROSIHWEjs.__async.call(void 0, this, null, function* () {
var _a, _b;
const headers = new Headers(req.headers);
headers.set("Upstash-Method", (_a = req.method) != null ? _a : "POST");
if (typeof req.delay !== "undefined") {
headers.set("Upstash-Delay", `${req.delay.toFixed()}s`);
}
if (typeof req.notBefore !== "undefined") {
headers.set("Upstash-Not-Before", req.notBefore.toFixed());
}
if (typeof req.deduplicationId !== "undefined") {
headers.set("Upstash-Deduplication-Id", req.deduplicationId);
}
if (typeof req.contentBasedDeduplication !== "undefined") {
headers.set("Upstash-Content-Based-Deduplication", "true");
}
if (typeof req.retries !== "undefined") {
headers.set("Upstash-Retries", req.retries.toFixed());
}
if (typeof req.callback !== "undefined") {
headers.set("Upstash-Callback", req.callback);
}
if (typeof req.failureCallback !== "undefined") {
headers.set("Upstash-Failure-Callback", req.failureCallback);
}
const res = yield this.http.request({
path: ["v2", "publish", (_b = req.url) != null ? _b : req.topic],
body: req.body,
headers,
method: "POST"
});
return res;
/**
* Access the queue API.
*
* Create, read, update or delete queues.
*/
queue(req) {
return new Queue(this.http, _optionalChain([req, 'optionalAccess', _8 => _8.queueName]));
}
async publish(req) {
const headers = processHeaders(req);
const res = await this.http.request({
path: ["v2", "publish", _nullishCoalesce(req.url, () => ( req.topic))],
body: req.body,
headers,
method: "POST"
});
return res;
}

@@ -398,14 +513,51 @@ /**

*/
publishJSON(req) {
return _chunkEROSIHWEjs.__async.call(void 0, this, null, function* () {
const headers = new Headers(req.headers);
headers.set("Content-Type", "application/json");
const res = yield this.publish(_chunkEROSIHWEjs.__spreadProps.call(void 0, _chunkEROSIHWEjs.__spreadValues.call(void 0, {}, req), {
headers,
body: JSON.stringify(req.body)
}));
return res;
async publishJSON(req) {
const headers = prefixHeaders(new (0, _undici.Headers)(req.headers));
headers.set("Content-Type", "application/json");
const res = await this.publish({
...req,
headers,
body: JSON.stringify(req.body)
});
return res;
}
/**
* Batch publish messages to QStash.
*/
async batch(req) {
const messages = [];
for (const message of req) {
const headers = processHeaders(message);
const headerEntries = Object.fromEntries(headers.entries());
messages.push({
destination: _nullishCoalesce(message.url, () => ( message.topic)),
headers: headerEntries,
body: message.body
});
}
const res = await this.http.request({
path: ["v2", "batch"],
body: JSON.stringify(messages),
headers: {
"Content-Type": "application/json"
},
method: "POST"
});
return res;
}
/**
* Batch publish messages to QStash, serializing each body to JSON.
*/
async batchJSON(req) {
for (const message of req) {
if ("body" in message) {
message.body = JSON.stringify(message.body);
}
message.headers = new (0, _undici.Headers)(message.headers);
message.headers.set("Content-Type", "application/json");
}
const res = await this.batch(req);
return res;
}
/**
* Retrieve your logs.

@@ -429,15 +581,21 @@ *

*/
events(req) {
return _chunkEROSIHWEjs.__async.call(void 0, this, null, function* () {
const query = {};
if ((req == null ? void 0 : req.cursor) && req.cursor > 0) {
query.cursor = req.cursor;
async events(req) {
const query = {};
if (_optionalChain([req, 'optionalAccess', _9 => _9.cursor]) && req.cursor > 0) {
query.cursor = req.cursor.toString();
}
for (const [key, value] of Object.entries(_nullishCoalesce(_optionalChain([req, 'optionalAccess', _10 => _10.filter]), () => ( {})))) {
if (typeof value === "number" && value < 0) {
continue;
}
const res = yield this.http.request({
path: ["v2", "events"],
method: "GET",
query
});
return res;
if (typeof value !== "undefined") {
query[key] = value.toString();
}
}
const res = await this.http.request({
path: ["v2", "events"],
method: "GET",
query
});
return res;
}

@@ -454,2 +612,2 @@ };

exports.Client = Client; exports.Messages = Messages; exports.QstashError = QstashError; exports.QstashRatelimitError = QstashRatelimitError; exports.Receiver = _chunkEROSIHWEjs.Receiver; exports.Schedules = Schedules; exports.SignatureError = _chunkEROSIHWEjs.SignatureError; exports.Topics = Topics;
exports.Client = Client; exports.Messages = Messages; exports.QstashError = QstashError; exports.QstashRatelimitError = QstashRatelimitError; exports.Receiver = _chunk77ATZ7AWjs.Receiver; exports.Schedules = Schedules; exports.SignatureError = _chunk77ATZ7AWjs.SignatureError; exports.Topics = Topics;

@@ -22,4 +22,5 @@ import { NextApiHandler } from 'next';

declare function verifySignatureEdge(handler: (req: NextRequest, nfe?: NextFetchEvent) => NextResponse | Promise<NextResponse>, config?: VerifySignatureConfig): (req: NextRequest, nfe: NextFetchEvent) => Promise<NextResponse<unknown>>;
declare function verifySignatureAppRouter(handler: (req: Request | NextRequest) => NextResponse | Promise<NextResponse>, config?: VerifySignatureConfig): (req: NextRequest | Request) => Promise<NextResponse<unknown>>;
type VerifySignatureAppRouterResponse = NextResponse | Promise<NextResponse>;
declare function verifySignatureAppRouter(handler: ((req: Request) => VerifySignatureAppRouterResponse) | ((req: NextRequest) => VerifySignatureAppRouterResponse), config?: VerifySignatureConfig): (req: NextRequest | Request) => Promise<NextResponse<unknown>>;
export { VerifySignatureConfig, verifySignature, verifySignatureAppRouter, verifySignatureEdge };
export { type VerifySignatureConfig, verifySignature, verifySignatureAppRouter, verifySignatureEdge };

@@ -1,12 +0,9 @@

"use strict";Object.defineProperty(exports, "__esModule", {value: true});
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
var _chunk77ATZ7AWjs = require('./chunk-77ATZ7AW.js');
var _chunkEROSIHWEjs = require('./chunk-EROSIHWE.js');
// src/nextjs.ts
var _server = require('next/server');
function verifySignature(handler, config) {
var _a, _b;
const currentSigningKey = (_a = config == null ? void 0 : config.currentSigningKey) != null ? _a : process.env.QSTASH_CURRENT_SIGNING_KEY;
const currentSigningKey = _nullishCoalesce(_optionalChain([config, 'optionalAccess', _ => _.currentSigningKey]), () => ( process.env.QSTASH_CURRENT_SIGNING_KEY));
if (!currentSigningKey) {

@@ -17,3 +14,3 @@ throw new Error(

}
const nextSigningKey = (_b = config == null ? void 0 : config.nextSigningKey) != null ? _b : process.env.QSTASH_NEXT_SIGNING_KEY;
const nextSigningKey = _nullishCoalesce(_optionalChain([config, 'optionalAccess', _2 => _2.nextSigningKey]), () => ( process.env.QSTASH_NEXT_SIGNING_KEY));
if (!nextSigningKey) {

@@ -24,7 +21,7 @@ throw new Error(

}
const receiver = new (0, _chunkEROSIHWEjs.Receiver)({
const receiver = new (0, _chunk77ATZ7AWjs.Receiver)({
currentSigningKey,
nextSigningKey
});
return (req, res) => _chunkEROSIHWEjs.__async.call(void 0, this, null, function* () {
return async (req, res) => {
const signature = req.headers["upstash-signature"];

@@ -41,22 +38,10 @@ if (!signature) {

const chunks = [];
try {
for (var iter = _chunkEROSIHWEjs.__forAwait.call(void 0, req), more, temp, error; more = !(temp = yield iter.next()).done; more = false) {
const chunk = temp.value;
chunks.push(typeof chunk === "string" ? Buffer.from(chunk) : chunk);
}
} catch (temp) {
error = [temp];
} finally {
try {
more && (temp = iter.return) && (yield temp.call(iter));
} finally {
if (error)
throw error[0];
}
for await (const chunk of req) {
chunks.push(typeof chunk === "string" ? Buffer.from(chunk) : chunk);
}
const body = Buffer.concat(chunks).toString("utf-8");
const isValid = yield receiver.verify({
const isValid = await receiver.verify({
signature,
body,
clockTolerance: config == null ? void 0 : config.clockTolerance
clockTolerance: _optionalChain([config, 'optionalAccess', _3 => _3.clockTolerance])
});

@@ -79,7 +64,6 @@ if (!isValid) {

return handler(req, res);
});
};
}
function verifySignatureEdge(handler, config) {
var _a, _b;
const currentSigningKey = (_a = config == null ? void 0 : config.currentSigningKey) != null ? _a : process.env.QSTASH_CURRENT_SIGNING_KEY;
const currentSigningKey = _nullishCoalesce(_optionalChain([config, 'optionalAccess', _4 => _4.currentSigningKey]), () => ( process.env.QSTASH_CURRENT_SIGNING_KEY));
if (!currentSigningKey) {

@@ -90,3 +74,3 @@ throw new Error(

}
const nextSigningKey = (_b = config == null ? void 0 : config.nextSigningKey) != null ? _b : process.env.QSTASH_NEXT_SIGNING_KEY;
const nextSigningKey = _nullishCoalesce(_optionalChain([config, 'optionalAccess', _5 => _5.nextSigningKey]), () => ( process.env.QSTASH_NEXT_SIGNING_KEY));
if (!nextSigningKey) {

@@ -97,7 +81,7 @@ throw new Error(

}
const receiver = new (0, _chunkEROSIHWEjs.Receiver)({
const receiver = new (0, _chunk77ATZ7AWjs.Receiver)({
currentSigningKey,
nextSigningKey
});
return (req, nfe) => _chunkEROSIHWEjs.__async.call(void 0, this, null, function* () {
return async (req, nfe) => {
const reqClone = req.clone();

@@ -113,7 +97,7 @@ const signature = req.headers.get("upstash-signature");

}
const body = yield req.text();
const isValid = yield receiver.verify({
const body = await req.text();
const isValid = await receiver.verify({
signature,
body,
clockTolerance: config == null ? void 0 : config.clockTolerance
clockTolerance: _optionalChain([config, 'optionalAccess', _6 => _6.clockTolerance])
});

@@ -124,7 +108,6 @@ if (!isValid) {

return handler(reqClone, nfe);
});
};
}
function verifySignatureAppRouter(handler, config) {
var _a, _b;
const currentSigningKey = (_a = config == null ? void 0 : config.currentSigningKey) != null ? _a : process.env.QSTASH_CURRENT_SIGNING_KEY;
const currentSigningKey = _nullishCoalesce(_optionalChain([config, 'optionalAccess', _7 => _7.currentSigningKey]), () => ( process.env.QSTASH_CURRENT_SIGNING_KEY));
if (!currentSigningKey) {

@@ -135,3 +118,3 @@ throw new Error(

}
const nextSigningKey = (_b = config == null ? void 0 : config.nextSigningKey) != null ? _b : process.env.QSTASH_NEXT_SIGNING_KEY;
const nextSigningKey = _nullishCoalesce(_optionalChain([config, 'optionalAccess', _8 => _8.nextSigningKey]), () => ( process.env.QSTASH_NEXT_SIGNING_KEY));
if (!nextSigningKey) {

@@ -142,7 +125,7 @@ throw new Error(

}
const receiver = new (0, _chunkEROSIHWEjs.Receiver)({
const receiver = new (0, _chunk77ATZ7AWjs.Receiver)({
currentSigningKey,
nextSigningKey
});
return (req) => _chunkEROSIHWEjs.__async.call(void 0, this, null, function* () {
return async (req) => {
const reqClone = req.clone();

@@ -158,7 +141,7 @@ const signature = req.headers.get("upstash-signature");

}
const body = yield req.text();
const isValid = yield receiver.verify({
const body = await req.text();
const isValid = await receiver.verify({
signature,
body,
clockTolerance: config == null ? void 0 : config.clockTolerance
clockTolerance: _optionalChain([config, 'optionalAccess', _9 => _9.clockTolerance])
});

@@ -169,3 +152,3 @@ if (!isValid) {

return handler(reqClone);
});
};
}

@@ -172,0 +155,0 @@

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

{ "name": "@upstash/qstash", "version": "v0.0.0-ci.8e51c7bcbaeb288246729b2deca55d9338f7b474-20231114113647", "description": "Official Typescript client for QStash", "repository": { "type": "git", "url": "git+https://github.com/upstash/sdk-qstash-ts.git" }, "module": "./dist/index.js", "main": "./dist/index.js", "types": "./dist/index.d.ts", "keywords": [ "qstash", "queue", "events", "serverless", "upstash" ], "author": "Andreas Thomas <dev@chronark.com>", "license": "MIT", "bugs": { "url": "https://github.com/upstash/sdk-qstash-ts/issues" }, "homepage": "https://github.com/upstash/sdk-qstash-ts#readme", "files": [ "dist" ], "scripts": { "build": "tsup", "fmt": "pnpm rome check . --apply-unsafe && pnpm rome format . --write" }, "devDependencies": { "@biomejs/biome": "^1.3.3", "@types/crypto-js": "^4.2.0", "@types/node": "^20.5.7", "next": "^14.0.2", "tsup": "^7.2.0", "typescript": "^5.2.2" }, "dependencies": { "crypto-js": "^4.2.0", "jose": "^4.14.4" }, "typesVersions": { "*": { ".": [ "./dist/index.d.ts" ], "nextjs": [ "./dist/nextjs.d.ts" ] } } }
{ "name": "@upstash/qstash", "version": "v0.0.0-ci.91df1d0db7459c9baa9dc99b2e0ac44907d6be4f-20240508125439", "description": "Official Typescript client for QStash", "repository": { "type": "git", "url": "git+https://github.com/upstash/sdk-qstash-ts.git" }, "module": "./dist/index.js", "main": "./dist/index.js", "types": "./dist/index.d.ts", "keywords": [ "qstash", "queue", "events", "serverless", "upstash" ], "author": "Andreas Thomas <dev@chronark.com>", "license": "MIT", "bugs": { "url": "https://github.com/upstash/sdk-qstash-ts/issues" }, "homepage": "https://github.com/upstash/sdk-qstash-ts#readme", "files": [ "dist" ], "scripts": { "build": "tsup", "fmt": "pnpm rome check . --apply-unsafe && pnpm rome format . --write" }, "exports": { ".": { "import": "./dist/index.mjs", "require": "./dist/index.js" }, "./nextjs": { "import": "./dist/index.mjs", "require": "./dist/index.js" } }, "devDependencies": { "@biomejs/biome": "^1.3.3", "@types/crypto-js": "^4.2.0", "@types/node": "^20.5.7", "next": "^14.0.2", "tsup": "^7.2.0", "typescript": "latest", "undici-types": "^6.16.0" }, "dependencies": { "crypto-js": ">=4.2.0", "jose": "^ 5.2.3", "undici": "^6.16.0" } }

@@ -96,9 +96,2 @@ # Upstash QStash SDK

body: "string";
/**
* Number of seconds to tolerate when checking `nbf` and `exp` claims, to deal with small clock differences among different servers
*
* @default 0
*/
clockTolerance?: number;
})

@@ -105,0 +98,0 @@ ```

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