@upstash/qstash 2.6.1 → 2.6.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/nextjs.js CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  var _chunkUUR7N6E6js = require('./chunk-UUR7N6E6.js');
4
4
 
5
- // src/nextjs.ts
5
+ // platforms/nextjs.ts
6
6
  var _server = require('next/server');
7
7
  var BAD_REQUEST = 400;
8
8
  function verifySignature(handler, config) {
package/nextjs.mjs CHANGED
@@ -2,7 +2,7 @@ import {
2
2
  Receiver
3
3
  } from "./chunk-CP4IU45K.mjs";
4
4
 
5
- // src/nextjs.ts
5
+ // platforms/nextjs.ts
6
6
  import { NextResponse } from "next/server";
7
7
  var BAD_REQUEST = 400;
8
8
  function verifySignature(handler, config) {
package/nuxt.d.mts ADDED
@@ -0,0 +1,11 @@
1
+ import * as h3 from 'h3';
2
+ import { H3Event } from 'h3';
3
+
4
+ type VerifySignatureConfig = {
5
+ currentSigningKey?: string;
6
+ nextSigningKey?: string;
7
+ clockTolerance?: number;
8
+ };
9
+ declare const verifySignatureNuxt: (handler: (event: H3Event) => Promise<unknown>, config?: VerifySignatureConfig) => h3.EventHandler<h3.EventHandlerRequest, Promise<unknown>>;
10
+
11
+ export { verifySignatureNuxt };
package/nuxt.d.ts ADDED
@@ -0,0 +1,11 @@
1
+ import * as h3 from 'h3';
2
+ import { H3Event } from 'h3';
3
+
4
+ type VerifySignatureConfig = {
5
+ currentSigningKey?: string;
6
+ nextSigningKey?: string;
7
+ clockTolerance?: number;
8
+ };
9
+ declare const verifySignatureNuxt: (handler: (event: H3Event) => Promise<unknown>, config?: VerifySignatureConfig) => h3.EventHandler<h3.EventHandlerRequest, Promise<unknown>>;
10
+
11
+ export { verifySignatureNuxt };
package/nuxt.js ADDED
@@ -0,0 +1,48 @@
1
+ "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; }require('./chunk-DZD3BOMO.js');
2
+
3
+
4
+ var _chunkUUR7N6E6js = require('./chunk-UUR7N6E6.js');
5
+
6
+ // platforms/nuxt.ts
7
+ var _h3 = require('h3');
8
+ var verifySignatureNuxt = (handler, config) => {
9
+ const currentSigningKey = _nullishCoalesce(_optionalChain([config, 'optionalAccess', _ => _.currentSigningKey]), () => ( process.env.QSTASH_CURRENT_SIGNING_KEY));
10
+ if (!currentSigningKey) {
11
+ throw new Error(
12
+ "currentSigningKey is required, either in the config or as env variable QSTASH_CURRENT_SIGNING_KEY"
13
+ );
14
+ }
15
+ const nextSigningKey = _nullishCoalesce(_optionalChain([config, 'optionalAccess', _2 => _2.nextSigningKey]), () => ( process.env.QSTASH_NEXT_SIGNING_KEY));
16
+ if (!nextSigningKey) {
17
+ throw new Error(
18
+ "nextSigningKey is required, either in the config or as env variable QSTASH_NEXT_SIGNING_KEY"
19
+ );
20
+ }
21
+ const receiver = new (0, _chunkUUR7N6E6js.Receiver)({
22
+ currentSigningKey,
23
+ nextSigningKey
24
+ });
25
+ return _h3.defineEventHandler.call(void 0, async (event) => {
26
+ const signature = _h3.getHeader.call(void 0, event, "upstash-signature");
27
+ if (!signature) {
28
+ return { status: 403, body: "`Upstash-Signature` header is missing" };
29
+ }
30
+ if (typeof signature !== "string") {
31
+ throw new TypeError("`Upstash-Signature` header is not a string");
32
+ }
33
+ const body = await _h3.readRawBody.call(void 0, event);
34
+ const isValid = await receiver.verify({
35
+ signature,
36
+ body: JSON.stringify(body),
37
+ clockTolerance: _optionalChain([config, 'optionalAccess', _3 => _3.clockTolerance])
38
+ });
39
+ if (!isValid) {
40
+ return { status: 403, body: "invalid signature" };
41
+ }
42
+ event._requestBody = body;
43
+ return handler(event);
44
+ });
45
+ };
46
+
47
+
48
+ exports.verifySignatureNuxt = verifySignatureNuxt;
package/nuxt.mjs ADDED
@@ -0,0 +1,48 @@
1
+ import "./chunk-PTZPACVC.mjs";
2
+ import {
3
+ Receiver
4
+ } from "./chunk-CP4IU45K.mjs";
5
+
6
+ // platforms/nuxt.ts
7
+ import { defineEventHandler, getHeader, readRawBody } from "h3";
8
+ var verifySignatureNuxt = (handler, config) => {
9
+ const currentSigningKey = config?.currentSigningKey ?? process.env.QSTASH_CURRENT_SIGNING_KEY;
10
+ if (!currentSigningKey) {
11
+ throw new Error(
12
+ "currentSigningKey is required, either in the config or as env variable QSTASH_CURRENT_SIGNING_KEY"
13
+ );
14
+ }
15
+ const nextSigningKey = config?.nextSigningKey ?? process.env.QSTASH_NEXT_SIGNING_KEY;
16
+ if (!nextSigningKey) {
17
+ throw new Error(
18
+ "nextSigningKey is required, either in the config or as env variable QSTASH_NEXT_SIGNING_KEY"
19
+ );
20
+ }
21
+ const receiver = new Receiver({
22
+ currentSigningKey,
23
+ nextSigningKey
24
+ });
25
+ return defineEventHandler(async (event) => {
26
+ const signature = getHeader(event, "upstash-signature");
27
+ if (!signature) {
28
+ return { status: 403, body: "`Upstash-Signature` header is missing" };
29
+ }
30
+ if (typeof signature !== "string") {
31
+ throw new TypeError("`Upstash-Signature` header is not a string");
32
+ }
33
+ const body = await readRawBody(event);
34
+ const isValid = await receiver.verify({
35
+ signature,
36
+ body: JSON.stringify(body),
37
+ clockTolerance: config?.clockTolerance
38
+ });
39
+ if (!isValid) {
40
+ return { status: 403, body: "invalid signature" };
41
+ }
42
+ event._requestBody = body;
43
+ return handler(event);
44
+ });
45
+ };
46
+ export {
47
+ verifySignatureNuxt
48
+ };
package/package.json CHANGED
@@ -1 +1 @@
1
- {"version":"v2.6.1","name":"@upstash/qstash","description":"Official Typescript client for QStash","author":"Andreas Thomas <dev@chronark.com>","license":"MIT","homepage":"https://github.com/upstash/sdk-qstash-ts#readme","repository":{"type":"git","url":"git+https://github.com/upstash/sdk-qstash-ts.git"},"bugs":{"url":"https://github.com/upstash/sdk-qstash-ts/issues"},"main":"./index.js","module":"./index.mjs","types":"./index.d.ts","files":["./**"],"exports":{".":{"import":"./index.mjs","require":"./index.js"},"./nextjs":{"import":"./nextjs.js","require":"./nextjs.js"},"./dist/nextjs":{"import":"./nextjs.js","require":"./nextjs.js"}},"typesVersions":{"*":{"nextjs":["./nextjs.d.ts"]}},"keywords":["qstash","queue","events","serverless","upstash"],"scripts":{"build":"tsup && cp README.md ./dist/ && cp package.json ./dist/ && cp LICENSE ./dist/","test":"bun test","fmt":"prettier --write .","lint":"tsc && eslint \"src/**/*.{js,ts,tsx}\" --quiet --fix"},"devDependencies":{"@commitlint/cli":"^19.2.2","@commitlint/config-conventional":"^19.2.2","@types/bun":"^1.1.1","@types/crypto-js":"^4.2.0","@typescript-eslint/eslint-plugin":"^7.0.1","@typescript-eslint/parser":"^7.0.1","ai":"^3.1.28","bun-types":"^1.1.7","eslint":"^8","eslint-plugin-unicorn":"^51.0.1","husky":"^9.0.10","next":"^14.0.2","prettier":"^3.2.5","tsup":"latest","typescript":"^5.4.5","undici-types":"^6.16.0","vitest":"latest"},"dependencies":{"crypto-js":">=4.2.0","jose":"^ 5.2.3"}}
1
+ {"version":"v2.6.3","name":"@upstash/qstash","description":"Official Typescript client for QStash","author":"Andreas Thomas <dev@chronark.com>","license":"MIT","homepage":"https://github.com/upstash/sdk-qstash-ts#readme","repository":{"type":"git","url":"git+https://github.com/upstash/sdk-qstash-ts.git"},"bugs":{"url":"https://github.com/upstash/sdk-qstash-ts/issues"},"main":"./index.js","module":"./index.mjs","types":"./index.d.ts","files":["./**"],"exports":{".":{"import":"./index.mjs","require":"./index.js"},"./nextjs":{"types":"./nextjs.d.ts","import":"./nextjs.mjs","require":"./nextjs.js"},"./dist/nextjs":{"types":"./nextjs.d.ts","import":"./nextjs.mjs","require":"./nextjs.js"},"./nuxt":{"types":"./nuxt.d.ts","import":"./nuxt.mjs","require":"./nuxt.js"},"./svelte":{"types":"./svelte.d.ts","import":"./svelte.mjs","require":"./svelte.js"},"./solidjs":{"types":"./solidjs.d.ts","import":"./solidjs.mjs","require":"./solidjs.js"}},"typesVersions":{"*":{"nextjs":["./nextjs.d.ts"]}},"keywords":["qstash","queue","events","serverless","upstash"],"scripts":{"build":"tsup && cp README.md ./dist/ && cp package.json ./dist/ && cp LICENSE ./dist/","test":"bun test","fmt":"prettier --write .","lint":"tsc && eslint \"src/**/*.{js,ts,tsx}\" --quiet --fix"},"devDependencies":{"@commitlint/cli":"^19.2.2","@commitlint/config-conventional":"^19.2.2","@types/bun":"^1.1.1","@types/crypto-js":"^4.2.0","@typescript-eslint/eslint-plugin":"^7.0.1","@typescript-eslint/parser":"^7.0.1","ai":"^3.1.28","bun-types":"^1.1.7","eslint":"^8","eslint-plugin-unicorn":"^51.0.1","husky":"^9.0.10","next":"^14.0.2","prettier":"^3.2.5","tsup":"latest","typescript":"^5.4.5","undici-types":"^6.16.0","vitest":"latest"},"dependencies":{"@solidjs/start":"^1.0.6","@sveltejs/kit":"^2.5.18","crypto-js":">=4.2.0","h3":"^1.12.0","jose":"^ 5.2.3"}}
package/solidjs.d.mts ADDED
@@ -0,0 +1,10 @@
1
+ import { APIHandler } from '@solidjs/start/server';
2
+
3
+ type VerifySignatureConfig = {
4
+ currentSigningKey?: string;
5
+ nextSigningKey?: string;
6
+ clockTolerance?: number;
7
+ };
8
+ declare const verifySignatureSolidjs: (handler: APIHandler, config?: VerifySignatureConfig) => APIHandler;
9
+
10
+ export { verifySignatureSolidjs };
package/solidjs.d.ts ADDED
@@ -0,0 +1,10 @@
1
+ import { APIHandler } from '@solidjs/start/server';
2
+
3
+ type VerifySignatureConfig = {
4
+ currentSigningKey?: string;
5
+ nextSigningKey?: string;
6
+ clockTolerance?: number;
7
+ };
8
+ declare const verifySignatureSolidjs: (handler: APIHandler, config?: VerifySignatureConfig) => APIHandler;
9
+
10
+ export { verifySignatureSolidjs };
package/solidjs.js ADDED
@@ -0,0 +1,43 @@
1
+ "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; }require('./chunk-DZD3BOMO.js');
2
+
3
+
4
+ var _chunkUUR7N6E6js = require('./chunk-UUR7N6E6.js');
5
+
6
+ // platforms/solidjs.ts
7
+ var verifySignatureSolidjs = (handler, config) => {
8
+ const currentSigningKey = _nullishCoalesce(_optionalChain([config, 'optionalAccess', _ => _.currentSigningKey]), () => ( process.env.QSTASH_CURRENT_SIGNING_KEY));
9
+ if (!currentSigningKey) {
10
+ throw new Error("currentSigningKey is required, either in the config or from the env");
11
+ }
12
+ const nextSigningKey = _nullishCoalesce(_optionalChain([config, 'optionalAccess', _2 => _2.nextSigningKey]), () => ( process.env.QSTASH_NEXT_SIGNING_KEY));
13
+ if (!nextSigningKey) {
14
+ throw new Error("nextSigningKey is required, either in the config or from the env");
15
+ }
16
+ const receiver = new (0, _chunkUUR7N6E6js.Receiver)({
17
+ currentSigningKey,
18
+ nextSigningKey
19
+ });
20
+ return async (event) => {
21
+ const signature = event.request.headers.get("upstash-signature");
22
+ if (!signature) {
23
+ return new Response("`Upstash-Signature` header is missing", { status: 403 });
24
+ }
25
+ if (typeof signature !== "string") {
26
+ throw new TypeError("`Upstash-Signature` header is not a string");
27
+ }
28
+ const cloneRequest = event.request.clone();
29
+ const body = await cloneRequest.text();
30
+ const isValid = await receiver.verify({
31
+ signature,
32
+ body,
33
+ clockTolerance: _optionalChain([config, 'optionalAccess', _3 => _3.clockTolerance])
34
+ });
35
+ if (!isValid) {
36
+ return new Response("invalid signature", { status: 403 });
37
+ }
38
+ return handler(event);
39
+ };
40
+ };
41
+
42
+
43
+ exports.verifySignatureSolidjs = verifySignatureSolidjs;
package/solidjs.mjs ADDED
@@ -0,0 +1,43 @@
1
+ import "./chunk-PTZPACVC.mjs";
2
+ import {
3
+ Receiver
4
+ } from "./chunk-CP4IU45K.mjs";
5
+
6
+ // platforms/solidjs.ts
7
+ var verifySignatureSolidjs = (handler, config) => {
8
+ const currentSigningKey = config?.currentSigningKey ?? process.env.QSTASH_CURRENT_SIGNING_KEY;
9
+ if (!currentSigningKey) {
10
+ throw new Error("currentSigningKey is required, either in the config or from the env");
11
+ }
12
+ const nextSigningKey = config?.nextSigningKey ?? process.env.QSTASH_NEXT_SIGNING_KEY;
13
+ if (!nextSigningKey) {
14
+ throw new Error("nextSigningKey is required, either in the config or from the env");
15
+ }
16
+ const receiver = new Receiver({
17
+ currentSigningKey,
18
+ nextSigningKey
19
+ });
20
+ return async (event) => {
21
+ const signature = event.request.headers.get("upstash-signature");
22
+ if (!signature) {
23
+ return new Response("`Upstash-Signature` header is missing", { status: 403 });
24
+ }
25
+ if (typeof signature !== "string") {
26
+ throw new TypeError("`Upstash-Signature` header is not a string");
27
+ }
28
+ const cloneRequest = event.request.clone();
29
+ const body = await cloneRequest.text();
30
+ const isValid = await receiver.verify({
31
+ signature,
32
+ body,
33
+ clockTolerance: config?.clockTolerance
34
+ });
35
+ if (!isValid) {
36
+ return new Response("invalid signature", { status: 403 });
37
+ }
38
+ return handler(event);
39
+ };
40
+ };
41
+ export {
42
+ verifySignatureSolidjs
43
+ };
package/svelte.d.mts ADDED
@@ -0,0 +1,10 @@
1
+ import { RequestHandler } from '@sveltejs/kit';
2
+
3
+ type VerifySignatureConfig = {
4
+ currentSigningKey: string;
5
+ nextSigningKey: string;
6
+ clockTolerance?: number;
7
+ };
8
+ declare const verifySignatureSvelte: <Parameters extends Partial<Record<string, string>> = Partial<Record<string, string>>, RouteId extends string | null = string | null>(handler: RequestHandler<Parameters, RouteId>, config: VerifySignatureConfig) => RequestHandler<Parameters, RouteId>;
9
+
10
+ export { verifySignatureSvelte };
package/svelte.d.ts ADDED
@@ -0,0 +1,10 @@
1
+ import { RequestHandler } from '@sveltejs/kit';
2
+
3
+ type VerifySignatureConfig = {
4
+ currentSigningKey: string;
5
+ nextSigningKey: string;
6
+ clockTolerance?: number;
7
+ };
8
+ declare const verifySignatureSvelte: <Parameters extends Partial<Record<string, string>> = Partial<Record<string, string>>, RouteId extends string | null = string | null>(handler: RequestHandler<Parameters, RouteId>, config: VerifySignatureConfig) => RequestHandler<Parameters, RouteId>;
9
+
10
+ export { verifySignatureSvelte };
package/svelte.js ADDED
@@ -0,0 +1,44 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});require('./chunk-DZD3BOMO.js');
2
+
3
+
4
+ var _chunkUUR7N6E6js = require('./chunk-UUR7N6E6.js');
5
+
6
+ // platforms/svelte.ts
7
+ var verifySignatureSvelte = (handler, config) => {
8
+ const currentSigningKey = config.currentSigningKey;
9
+ if (!currentSigningKey) {
10
+ throw new Error("currentSigningKey is required, either in the config or from the env");
11
+ }
12
+ const nextSigningKey = config.nextSigningKey;
13
+ if (!nextSigningKey) {
14
+ throw new Error("nextSigningKey is required, either in the config or from the env");
15
+ }
16
+ const receiver = new (0, _chunkUUR7N6E6js.Receiver)({
17
+ currentSigningKey,
18
+ nextSigningKey
19
+ });
20
+ const wrappedHandler = async (event) => {
21
+ const signature = event.request.headers.get("upstash-signature");
22
+ if (!signature) {
23
+ return new Response("`Upstash-Signature` header is missing", { status: 403 });
24
+ }
25
+ if (typeof signature !== "string") {
26
+ throw new TypeError("`Upstash-Signature` header is not a string");
27
+ }
28
+ const cloneRequest = event.request.clone();
29
+ const body = await cloneRequest.text();
30
+ const isValid = await receiver.verify({
31
+ signature,
32
+ body,
33
+ clockTolerance: config.clockTolerance
34
+ });
35
+ if (!isValid) {
36
+ return new Response("invalid signature", { status: 403 });
37
+ }
38
+ return handler(event);
39
+ };
40
+ return wrappedHandler;
41
+ };
42
+
43
+
44
+ exports.verifySignatureSvelte = verifySignatureSvelte;
package/svelte.mjs ADDED
@@ -0,0 +1,44 @@
1
+ import "./chunk-PTZPACVC.mjs";
2
+ import {
3
+ Receiver
4
+ } from "./chunk-CP4IU45K.mjs";
5
+
6
+ // platforms/svelte.ts
7
+ var verifySignatureSvelte = (handler, config) => {
8
+ const currentSigningKey = config.currentSigningKey;
9
+ if (!currentSigningKey) {
10
+ throw new Error("currentSigningKey is required, either in the config or from the env");
11
+ }
12
+ const nextSigningKey = config.nextSigningKey;
13
+ if (!nextSigningKey) {
14
+ throw new Error("nextSigningKey is required, either in the config or from the env");
15
+ }
16
+ const receiver = new Receiver({
17
+ currentSigningKey,
18
+ nextSigningKey
19
+ });
20
+ const wrappedHandler = async (event) => {
21
+ const signature = event.request.headers.get("upstash-signature");
22
+ if (!signature) {
23
+ return new Response("`Upstash-Signature` header is missing", { status: 403 });
24
+ }
25
+ if (typeof signature !== "string") {
26
+ throw new TypeError("`Upstash-Signature` header is not a string");
27
+ }
28
+ const cloneRequest = event.request.clone();
29
+ const body = await cloneRequest.text();
30
+ const isValid = await receiver.verify({
31
+ signature,
32
+ body,
33
+ clockTolerance: config.clockTolerance
34
+ });
35
+ if (!isValid) {
36
+ return new Response("invalid signature", { status: 403 });
37
+ }
38
+ return handler(event);
39
+ };
40
+ return wrappedHandler;
41
+ };
42
+ export {
43
+ verifySignatureSvelte
44
+ };