@upstash/qstash 2.7.4 → 2.7.6-canary

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.
Files changed (60) hide show
  1. package/README.md +10 -3
  2. package/chunk-B3NB4QLV.mjs +2920 -0
  3. package/chunk-IJ3475FO.mjs +403 -0
  4. package/chunk-IJ5AEYLN.js +1 -0
  5. package/chunk-NMSGEGBP.js +403 -0
  6. package/chunk-S7JMIMW4.mjs +0 -0
  7. package/chunk-WQZ4U6LJ.js +2920 -0
  8. package/{dist/workflow/index.d.mts → client-aUVEwn93.d.mts} +867 -795
  9. package/{dist/nextjs/index.d.mts → client-aUVEwn93.d.ts} +869 -737
  10. package/cloudflare.d.mts +33 -0
  11. package/cloudflare.d.ts +33 -0
  12. package/cloudflare.js +37 -0
  13. package/cloudflare.mjs +37 -0
  14. package/h3.d.mts +17 -0
  15. package/h3.d.ts +17 -0
  16. package/h3.js +10 -0
  17. package/h3.mjs +10 -0
  18. package/hono.d.mts +25 -0
  19. package/hono.d.ts +25 -0
  20. package/hono.js +22 -0
  21. package/hono.mjs +22 -0
  22. package/index.d.mts +54 -0
  23. package/index.d.ts +54 -0
  24. package/index.js +41 -0
  25. package/index.mjs +41 -0
  26. package/nextjs.d.mts +38 -0
  27. package/nextjs.d.ts +38 -0
  28. package/nextjs.js +178 -0
  29. package/nextjs.mjs +178 -0
  30. package/nuxt.d.mts +12 -0
  31. package/nuxt.d.ts +12 -0
  32. package/nuxt.js +11 -0
  33. package/nuxt.mjs +11 -0
  34. package/package.json +1 -1
  35. package/solidjs.d.mts +22 -0
  36. package/solidjs.d.ts +22 -0
  37. package/solidjs.js +56 -0
  38. package/solidjs.mjs +56 -0
  39. package/svelte.d.mts +24 -0
  40. package/svelte.d.ts +24 -0
  41. package/svelte.js +53 -0
  42. package/svelte.mjs +53 -0
  43. package/workflow.d.mts +2 -0
  44. package/workflow.d.ts +2 -0
  45. package/workflow.js +18 -0
  46. package/workflow.mjs +18 -0
  47. package/dist/base/index.d.mts +0 -1279
  48. package/dist/base/index.mjs +0 -2
  49. package/dist/cloudflare/index.d.mts +0 -1648
  50. package/dist/cloudflare/index.mjs +0 -10
  51. package/dist/h3/index.d.mts +0 -1633
  52. package/dist/h3/index.mjs +0 -10
  53. package/dist/hono/index.d.mts +0 -1641
  54. package/dist/hono/index.mjs +0 -10
  55. package/dist/nextjs/index.mjs +0 -10
  56. package/dist/solidjs/index.d.mts +0 -1638
  57. package/dist/solidjs/index.mjs +0 -10
  58. package/dist/svelte/index.d.mts +0 -1640
  59. package/dist/svelte/index.mjs +0 -10
  60. package/dist/workflow/index.mjs +0 -10
package/nextjs.js ADDED
@@ -0,0 +1,178 @@
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; }
2
+
3
+
4
+ var _chunkWQZ4U6LJjs = require('./chunk-WQZ4U6LJ.js');
5
+
6
+ // platforms/nextjs.ts
7
+ var _server = require('next/server');
8
+ var BAD_REQUEST = 400;
9
+ function verifySignature(handler, config) {
10
+ const currentSigningKey = _nullishCoalesce(_optionalChain([config, 'optionalAccess', _ => _.currentSigningKey]), () => ( process.env.QSTASH_CURRENT_SIGNING_KEY));
11
+ if (!currentSigningKey) {
12
+ throw new Error(
13
+ "currentSigningKey is required, either in the config or as env variable QSTASH_CURRENT_SIGNING_KEY"
14
+ );
15
+ }
16
+ const nextSigningKey = _nullishCoalesce(_optionalChain([config, 'optionalAccess', _2 => _2.nextSigningKey]), () => ( process.env.QSTASH_NEXT_SIGNING_KEY));
17
+ if (!nextSigningKey) {
18
+ throw new Error(
19
+ "nextSigningKey is required, either in the config or as env variable QSTASH_NEXT_SIGNING_KEY"
20
+ );
21
+ }
22
+ const receiver = new (0, _chunkWQZ4U6LJjs.Receiver)({
23
+ currentSigningKey,
24
+ nextSigningKey
25
+ });
26
+ return async (request, response) => {
27
+ const signature = request.headers["upstash-signature"];
28
+ if (!signature) {
29
+ response.status(BAD_REQUEST);
30
+ response.send("`Upstash-Signature` header is missing");
31
+ response.end();
32
+ return;
33
+ }
34
+ if (typeof signature !== "string") {
35
+ throw new TypeError("`Upstash-Signature` header is not a string");
36
+ }
37
+ const chunks = [];
38
+ for await (const chunk of request) {
39
+ chunks.push(typeof chunk === "string" ? Buffer.from(chunk) : chunk);
40
+ }
41
+ const body = Buffer.concat(chunks).toString("utf8");
42
+ const isValid = await receiver.verify({
43
+ signature,
44
+ body,
45
+ clockTolerance: _optionalChain([config, 'optionalAccess', _3 => _3.clockTolerance])
46
+ });
47
+ if (!isValid) {
48
+ response.status(BAD_REQUEST);
49
+ response.send("Invalid signature");
50
+ response.end();
51
+ return;
52
+ }
53
+ try {
54
+ request.body = request.headers["content-type"] === "application/json" ? JSON.parse(body) : body;
55
+ } catch (e) {
56
+ request.body = body;
57
+ }
58
+ return handler(request, response);
59
+ };
60
+ }
61
+ function verifySignatureEdge(handler, config) {
62
+ const currentSigningKey = _nullishCoalesce(_optionalChain([config, 'optionalAccess', _4 => _4.currentSigningKey]), () => ( process.env.QSTASH_CURRENT_SIGNING_KEY));
63
+ if (!currentSigningKey) {
64
+ throw new Error(
65
+ "currentSigningKey is required, either in the config or as env variable QSTASH_CURRENT_SIGNING_KEY"
66
+ );
67
+ }
68
+ const nextSigningKey = _nullishCoalesce(_optionalChain([config, 'optionalAccess', _5 => _5.nextSigningKey]), () => ( process.env.QSTASH_NEXT_SIGNING_KEY));
69
+ if (!nextSigningKey) {
70
+ throw new Error(
71
+ "nextSigningKey is required, either in the config or as env variable QSTASH_NEXT_SIGNING_KEY"
72
+ );
73
+ }
74
+ const receiver = new (0, _chunkWQZ4U6LJjs.Receiver)({
75
+ currentSigningKey,
76
+ nextSigningKey
77
+ });
78
+ return async (request, nfe) => {
79
+ const requestClone = request.clone();
80
+ const signature = request.headers.get("upstash-signature");
81
+ if (!signature) {
82
+ return new (0, _server.NextResponse)(new TextEncoder().encode("`Upstash-Signature` header is missing"), {
83
+ status: 403
84
+ });
85
+ }
86
+ if (typeof signature !== "string") {
87
+ throw new TypeError("`Upstash-Signature` header is not a string");
88
+ }
89
+ const body = await requestClone.text();
90
+ const isValid = await receiver.verify({
91
+ signature,
92
+ body,
93
+ clockTolerance: _optionalChain([config, 'optionalAccess', _6 => _6.clockTolerance])
94
+ });
95
+ if (!isValid) {
96
+ return new (0, _server.NextResponse)(new TextEncoder().encode("invalid signature"), { status: 403 });
97
+ }
98
+ return handler(request, nfe);
99
+ };
100
+ }
101
+ function verifySignatureAppRouter(handler, config) {
102
+ const currentSigningKey = _nullishCoalesce(_optionalChain([config, 'optionalAccess', _7 => _7.currentSigningKey]), () => ( process.env.QSTASH_CURRENT_SIGNING_KEY));
103
+ if (!currentSigningKey) {
104
+ throw new Error(
105
+ "currentSigningKey is required, either in the config or as env variable QSTASH_CURRENT_SIGNING_KEY"
106
+ );
107
+ }
108
+ const nextSigningKey = _nullishCoalesce(_optionalChain([config, 'optionalAccess', _8 => _8.nextSigningKey]), () => ( process.env.QSTASH_NEXT_SIGNING_KEY));
109
+ if (!nextSigningKey) {
110
+ throw new Error(
111
+ "nextSigningKey is required, either in the config or as env variable QSTASH_NEXT_SIGNING_KEY"
112
+ );
113
+ }
114
+ const receiver = new (0, _chunkWQZ4U6LJjs.Receiver)({
115
+ currentSigningKey,
116
+ nextSigningKey
117
+ });
118
+ return async (request, params) => {
119
+ const requestClone = request.clone();
120
+ const signature = request.headers.get("upstash-signature");
121
+ if (!signature) {
122
+ return new (0, _server.NextResponse)(new TextEncoder().encode("`Upstash-Signature` header is missing"), {
123
+ status: 403
124
+ });
125
+ }
126
+ if (typeof signature !== "string") {
127
+ throw new TypeError("`Upstash-Signature` header is not a string");
128
+ }
129
+ const body = await requestClone.text();
130
+ const isValid = await receiver.verify({
131
+ signature,
132
+ body,
133
+ clockTolerance: _optionalChain([config, 'optionalAccess', _9 => _9.clockTolerance])
134
+ });
135
+ if (!isValid) {
136
+ return new (0, _server.NextResponse)(new TextEncoder().encode("invalid signature"), { status: 403 });
137
+ }
138
+ return handler(request, params);
139
+ };
140
+ }
141
+ var serve2 = (routeFunction, options) => {
142
+ const handler = _chunkWQZ4U6LJjs.serve.call(void 0, routeFunction, {
143
+ onStepFinish: (workflowRunId) => new (0, _server.NextResponse)(JSON.stringify({ workflowRunId }), { status: 200 }),
144
+ ...options
145
+ });
146
+ return async (request) => {
147
+ return await handler(request);
148
+ };
149
+ };
150
+ var servePagesRouter = (routeFunction, options) => {
151
+ const handler = _chunkWQZ4U6LJjs.serve.call(void 0, routeFunction, options);
152
+ return async (req, res) => {
153
+ if (_optionalChain([req, 'access', _10 => _10.method, 'optionalAccess', _11 => _11.toUpperCase, 'call', _12 => _12()]) !== "POST") {
154
+ res.status(405).json("Only POST requests are allowed in worklfows");
155
+ return;
156
+ } else if (!req.url) {
157
+ res.status(400).json("url not found in the request");
158
+ return;
159
+ }
160
+ const protocol = req.headers["x-forwarded-proto"];
161
+ const baseUrl = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _13 => _13.baseUrl]), () => ( `${protocol}://${req.headers.host}`));
162
+ const request = new Request(_nullishCoalesce(_optionalChain([options, 'optionalAccess', _14 => _14.url]), () => ( `${baseUrl}${req.url}`)), {
163
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
164
+ body: _nullishCoalesce(JSON.stringify(req.body), () => ( "")),
165
+ headers: new Headers(req.headersDistinct),
166
+ method: "POST"
167
+ });
168
+ const response = await handler(request);
169
+ res.status(response.status).json(await response.json());
170
+ };
171
+ };
172
+
173
+
174
+
175
+
176
+
177
+
178
+ exports.serve = serve2; exports.servePagesRouter = servePagesRouter; exports.verifySignature = verifySignature; exports.verifySignatureAppRouter = verifySignatureAppRouter; exports.verifySignatureEdge = verifySignatureEdge;
package/nextjs.mjs ADDED
@@ -0,0 +1,178 @@
1
+ import {
2
+ Receiver,
3
+ serve
4
+ } from "./chunk-B3NB4QLV.mjs";
5
+
6
+ // platforms/nextjs.ts
7
+ import { NextResponse } from "next/server";
8
+ var BAD_REQUEST = 400;
9
+ function verifySignature(handler, config) {
10
+ const currentSigningKey = config?.currentSigningKey ?? process.env.QSTASH_CURRENT_SIGNING_KEY;
11
+ if (!currentSigningKey) {
12
+ throw new Error(
13
+ "currentSigningKey is required, either in the config or as env variable QSTASH_CURRENT_SIGNING_KEY"
14
+ );
15
+ }
16
+ const nextSigningKey = config?.nextSigningKey ?? process.env.QSTASH_NEXT_SIGNING_KEY;
17
+ if (!nextSigningKey) {
18
+ throw new Error(
19
+ "nextSigningKey is required, either in the config or as env variable QSTASH_NEXT_SIGNING_KEY"
20
+ );
21
+ }
22
+ const receiver = new Receiver({
23
+ currentSigningKey,
24
+ nextSigningKey
25
+ });
26
+ return async (request, response) => {
27
+ const signature = request.headers["upstash-signature"];
28
+ if (!signature) {
29
+ response.status(BAD_REQUEST);
30
+ response.send("`Upstash-Signature` header is missing");
31
+ response.end();
32
+ return;
33
+ }
34
+ if (typeof signature !== "string") {
35
+ throw new TypeError("`Upstash-Signature` header is not a string");
36
+ }
37
+ const chunks = [];
38
+ for await (const chunk of request) {
39
+ chunks.push(typeof chunk === "string" ? Buffer.from(chunk) : chunk);
40
+ }
41
+ const body = Buffer.concat(chunks).toString("utf8");
42
+ const isValid = await receiver.verify({
43
+ signature,
44
+ body,
45
+ clockTolerance: config?.clockTolerance
46
+ });
47
+ if (!isValid) {
48
+ response.status(BAD_REQUEST);
49
+ response.send("Invalid signature");
50
+ response.end();
51
+ return;
52
+ }
53
+ try {
54
+ request.body = request.headers["content-type"] === "application/json" ? JSON.parse(body) : body;
55
+ } catch {
56
+ request.body = body;
57
+ }
58
+ return handler(request, response);
59
+ };
60
+ }
61
+ function verifySignatureEdge(handler, config) {
62
+ const currentSigningKey = config?.currentSigningKey ?? process.env.QSTASH_CURRENT_SIGNING_KEY;
63
+ if (!currentSigningKey) {
64
+ throw new Error(
65
+ "currentSigningKey is required, either in the config or as env variable QSTASH_CURRENT_SIGNING_KEY"
66
+ );
67
+ }
68
+ const nextSigningKey = config?.nextSigningKey ?? process.env.QSTASH_NEXT_SIGNING_KEY;
69
+ if (!nextSigningKey) {
70
+ throw new Error(
71
+ "nextSigningKey is required, either in the config or as env variable QSTASH_NEXT_SIGNING_KEY"
72
+ );
73
+ }
74
+ const receiver = new Receiver({
75
+ currentSigningKey,
76
+ nextSigningKey
77
+ });
78
+ return async (request, nfe) => {
79
+ const requestClone = request.clone();
80
+ const signature = request.headers.get("upstash-signature");
81
+ if (!signature) {
82
+ return new NextResponse(new TextEncoder().encode("`Upstash-Signature` header is missing"), {
83
+ status: 403
84
+ });
85
+ }
86
+ if (typeof signature !== "string") {
87
+ throw new TypeError("`Upstash-Signature` header is not a string");
88
+ }
89
+ const body = await requestClone.text();
90
+ const isValid = await receiver.verify({
91
+ signature,
92
+ body,
93
+ clockTolerance: config?.clockTolerance
94
+ });
95
+ if (!isValid) {
96
+ return new NextResponse(new TextEncoder().encode("invalid signature"), { status: 403 });
97
+ }
98
+ return handler(request, nfe);
99
+ };
100
+ }
101
+ function verifySignatureAppRouter(handler, config) {
102
+ const currentSigningKey = config?.currentSigningKey ?? process.env.QSTASH_CURRENT_SIGNING_KEY;
103
+ if (!currentSigningKey) {
104
+ throw new Error(
105
+ "currentSigningKey is required, either in the config or as env variable QSTASH_CURRENT_SIGNING_KEY"
106
+ );
107
+ }
108
+ const nextSigningKey = config?.nextSigningKey ?? process.env.QSTASH_NEXT_SIGNING_KEY;
109
+ if (!nextSigningKey) {
110
+ throw new Error(
111
+ "nextSigningKey is required, either in the config or as env variable QSTASH_NEXT_SIGNING_KEY"
112
+ );
113
+ }
114
+ const receiver = new Receiver({
115
+ currentSigningKey,
116
+ nextSigningKey
117
+ });
118
+ return async (request, params) => {
119
+ const requestClone = request.clone();
120
+ const signature = request.headers.get("upstash-signature");
121
+ if (!signature) {
122
+ return new NextResponse(new TextEncoder().encode("`Upstash-Signature` header is missing"), {
123
+ status: 403
124
+ });
125
+ }
126
+ if (typeof signature !== "string") {
127
+ throw new TypeError("`Upstash-Signature` header is not a string");
128
+ }
129
+ const body = await requestClone.text();
130
+ const isValid = await receiver.verify({
131
+ signature,
132
+ body,
133
+ clockTolerance: config?.clockTolerance
134
+ });
135
+ if (!isValid) {
136
+ return new NextResponse(new TextEncoder().encode("invalid signature"), { status: 403 });
137
+ }
138
+ return handler(request, params);
139
+ };
140
+ }
141
+ var serve2 = (routeFunction, options) => {
142
+ const handler = serve(routeFunction, {
143
+ onStepFinish: (workflowRunId) => new NextResponse(JSON.stringify({ workflowRunId }), { status: 200 }),
144
+ ...options
145
+ });
146
+ return async (request) => {
147
+ return await handler(request);
148
+ };
149
+ };
150
+ var servePagesRouter = (routeFunction, options) => {
151
+ const handler = serve(routeFunction, options);
152
+ return async (req, res) => {
153
+ if (req.method?.toUpperCase() !== "POST") {
154
+ res.status(405).json("Only POST requests are allowed in worklfows");
155
+ return;
156
+ } else if (!req.url) {
157
+ res.status(400).json("url not found in the request");
158
+ return;
159
+ }
160
+ const protocol = req.headers["x-forwarded-proto"];
161
+ const baseUrl = options?.baseUrl ?? `${protocol}://${req.headers.host}`;
162
+ const request = new Request(options?.url ?? `${baseUrl}${req.url}`, {
163
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
164
+ body: JSON.stringify(req.body) ?? "",
165
+ headers: new Headers(req.headersDistinct),
166
+ method: "POST"
167
+ });
168
+ const response = await handler(request);
169
+ res.status(response.status).json(await response.json());
170
+ };
171
+ };
172
+ export {
173
+ serve2 as serve,
174
+ servePagesRouter,
175
+ verifySignature,
176
+ verifySignatureAppRouter,
177
+ verifySignatureEdge
178
+ };
package/nuxt.d.mts ADDED
@@ -0,0 +1,12 @@
1
+ import * as h3 from 'h3';
2
+
3
+ /**
4
+ * @deprecated Use import { verifySignatureH3 } from "@upstash/qstash/h3" instead
5
+ */
6
+ declare const verifySignatureNuxt: (handler: (event: h3.H3Event<h3.EventHandlerRequest>) => Promise<unknown>, config?: {
7
+ currentSigningKey?: string | undefined;
8
+ nextSigningKey?: string | undefined;
9
+ clockTolerance?: number | undefined;
10
+ } | undefined) => h3.EventHandler<h3.EventHandlerRequest, Promise<unknown>>;
11
+
12
+ export { verifySignatureNuxt };
package/nuxt.d.ts ADDED
@@ -0,0 +1,12 @@
1
+ import * as h3 from 'h3';
2
+
3
+ /**
4
+ * @deprecated Use import { verifySignatureH3 } from "@upstash/qstash/h3" instead
5
+ */
6
+ declare const verifySignatureNuxt: (handler: (event: h3.H3Event<h3.EventHandlerRequest>) => Promise<unknown>, config?: {
7
+ currentSigningKey?: string | undefined;
8
+ nextSigningKey?: string | undefined;
9
+ clockTolerance?: number | undefined;
10
+ } | undefined) => h3.EventHandler<h3.EventHandlerRequest, Promise<unknown>>;
11
+
12
+ export { verifySignatureNuxt };
package/nuxt.js ADDED
@@ -0,0 +1,11 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+ var _chunkNMSGEGBPjs = require('./chunk-NMSGEGBP.js');
4
+ require('./chunk-IJ5AEYLN.js');
5
+ require('./chunk-WQZ4U6LJ.js');
6
+
7
+ // platforms/nuxt.ts
8
+ var verifySignatureNuxt = _chunkNMSGEGBPjs.verifySignatureH3;
9
+
10
+
11
+ exports.verifySignatureNuxt = verifySignatureNuxt;
package/nuxt.mjs ADDED
@@ -0,0 +1,11 @@
1
+ import {
2
+ verifySignatureH3
3
+ } from "./chunk-IJ3475FO.mjs";
4
+ import "./chunk-S7JMIMW4.mjs";
5
+ import "./chunk-B3NB4QLV.mjs";
6
+
7
+ // platforms/nuxt.ts
8
+ var verifySignatureNuxt = verifySignatureH3;
9
+ export {
10
+ verifySignatureNuxt
11
+ };
package/package.json CHANGED
@@ -1 +1 @@
1
- { "version": "v2.7.4", "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" }, "files": [ "dist" ], "main": "./dist/base/index.mjs", "module": "./dist/base/index.mjs", "types": "./dist/base/index.d.mts", "exports": { ".": { "types": "./dist/base/index.d.mts", "import": "./dist/base/index.mjs", "require": "./dist/base/index.js" }, "./nextjs": { "import": "./dist/nextjs/index.mjs" }, "./dist/nextjs": { "import": "./dist/nextjs/index.mjs" }, "./h3": { "types": "./dist/h3/index.d.mts", "import": "./dist/h3/index.mjs" }, "./nuxt": { "types": "./dist/h3/index.d.mts", "import": "./dist/h3/index.mjs" }, "./svelte": { "types": "./dist/svelte/index.d.mts", "import": "./dist/svelte/index.mjs" }, "./solidjs": { "types": "./dist/solidjs/index.d.mts", "import": "./dist/solidjs/index.mjs" }, "./workflow": { "types": "./dist/workflow/index.d.mts", "import": "./dist/workflow/index.mjs" }, "./hono": { "types": "./dist/hono/index.d.mts", "import": "./dist/hono/index.mjs" }, "./cloudflare": { "types": "./dist/cloudflare/index.d.mts", "import": "./dist/cloudflare/index.mjs" } }, "keywords": [ "qstash", "queue", "events", "serverless", "upstash" ], "scripts": { "build": "tsup", "test": "bun test src", "fmt": "prettier --write .", "lint": "tsc && eslint \"src/**/*.{js,ts,tsx}\" --quiet --fix", "prepare": "husky" }, "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", "neverthrow": "^7.0.1", "next": "^14.0.2", "prettier": "^3.2.5", "tsup": "latest", "typescript": "^5.4.5", "undici-types": "^6.16.0", "@solidjs/start": "^1.0.6", "@sveltejs/kit": "^2.5.18", "hono": "^4.5.8", "h3": "^1.12.0", "vitest": "latest" }, "dependencies": { "crypto-js": ">=4.2.0", "jose": "^ 5.2.3" } }
1
+ {"version":"v2.7.6-canary","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"},"./h3":{"types":"./h3.d.ts","import":"./h3.mjs","require":"./h3.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"},"./workflow":{"types":"./workflow.d.ts","import":"./workflow.mjs","require":"./workflow.js"},"./hono":{"types":"./hono.d.ts","import":"./hono.mjs","require":"./hono.js"},"./cloudflare":{"types":"./cloudflare.d.ts","import":"./cloudflare.mjs","require":"./cloudflare.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 src","fmt":"prettier --write .","lint":"tsc && eslint \"src/**/*.{js,ts,tsx}\" --quiet --fix"},"devDependencies":{"@commitlint/cli":"^19.2.2","@commitlint/config-conventional":"^19.2.2","@solidjs/start":"^1.0.6","@sveltejs/kit":"^2.5.18","@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","h3":"^1.12.0","hono":"^4.5.8","husky":"^9.0.10","neverthrow":"^7.0.1","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"}}
package/solidjs.d.mts ADDED
@@ -0,0 +1,22 @@
1
+ import { APIHandler, APIEvent } from '@solidjs/start/server';
2
+ import { a2 as RouteFunction, a3 as WorkflowServeOptions } from './client-aUVEwn93.mjs';
3
+ import 'neverthrow';
4
+
5
+ type VerifySignatureConfig = {
6
+ currentSigningKey?: string;
7
+ nextSigningKey?: string;
8
+ clockTolerance?: number;
9
+ };
10
+ declare const verifySignatureSolidjs: (handler: APIHandler, config?: VerifySignatureConfig) => APIHandler;
11
+ /**
12
+ * Serve method to serve a QStash workflow in a Nextjs project
13
+ *
14
+ * See for options https://upstash.com/docs/qstash/workflows/basics/serve
15
+ *
16
+ * @param routeFunction workflow function
17
+ * @param options workflow options
18
+ * @returns
19
+ */
20
+ declare const serve: <TInitialPayload = unknown>(routeFunction: RouteFunction<TInitialPayload>, options?: Omit<WorkflowServeOptions<Response, TInitialPayload>, "onStepFinish">) => (event: APIEvent) => Promise<Response>;
21
+
22
+ export { serve, verifySignatureSolidjs };
package/solidjs.d.ts ADDED
@@ -0,0 +1,22 @@
1
+ import { APIHandler, APIEvent } from '@solidjs/start/server';
2
+ import { a2 as RouteFunction, a3 as WorkflowServeOptions } from './client-aUVEwn93.js';
3
+ import 'neverthrow';
4
+
5
+ type VerifySignatureConfig = {
6
+ currentSigningKey?: string;
7
+ nextSigningKey?: string;
8
+ clockTolerance?: number;
9
+ };
10
+ declare const verifySignatureSolidjs: (handler: APIHandler, config?: VerifySignatureConfig) => APIHandler;
11
+ /**
12
+ * Serve method to serve a QStash workflow in a Nextjs project
13
+ *
14
+ * See for options https://upstash.com/docs/qstash/workflows/basics/serve
15
+ *
16
+ * @param routeFunction workflow function
17
+ * @param options workflow options
18
+ * @returns
19
+ */
20
+ declare const serve: <TInitialPayload = unknown>(routeFunction: RouteFunction<TInitialPayload>, options?: Omit<WorkflowServeOptions<Response, TInitialPayload>, "onStepFinish">) => (event: APIEvent) => Promise<Response>;
21
+
22
+ export { serve, verifySignatureSolidjs };
package/solidjs.js ADDED
@@ -0,0 +1,56 @@
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-IJ5AEYLN.js');
2
+
3
+
4
+
5
+ var _chunkWQZ4U6LJjs = require('./chunk-WQZ4U6LJ.js');
6
+
7
+ // platforms/solidjs.ts
8
+ var verifySignatureSolidjs = (handler, config) => {
9
+ const currentSigningKey = _nullishCoalesce(_optionalChain([config, 'optionalAccess', _ => _.currentSigningKey]), () => ( process.env.QSTASH_CURRENT_SIGNING_KEY));
10
+ if (!currentSigningKey) {
11
+ throw new Error("currentSigningKey is required, either in the config or from the env");
12
+ }
13
+ const nextSigningKey = _nullishCoalesce(_optionalChain([config, 'optionalAccess', _2 => _2.nextSigningKey]), () => ( process.env.QSTASH_NEXT_SIGNING_KEY));
14
+ if (!nextSigningKey) {
15
+ throw new Error("nextSigningKey is required, either in the config or from the env");
16
+ }
17
+ const receiver = new (0, _chunkWQZ4U6LJjs.Receiver)({
18
+ currentSigningKey,
19
+ nextSigningKey
20
+ });
21
+ return async (event) => {
22
+ const signature = event.request.headers.get("upstash-signature");
23
+ if (!signature) {
24
+ return new Response("`Upstash-Signature` header is missing", { status: 403 });
25
+ }
26
+ if (typeof signature !== "string") {
27
+ throw new TypeError("`Upstash-Signature` header is not a string");
28
+ }
29
+ const cloneRequest = event.request.clone();
30
+ const body = await cloneRequest.text();
31
+ const isValid = await receiver.verify({
32
+ signature,
33
+ body,
34
+ clockTolerance: _optionalChain([config, 'optionalAccess', _3 => _3.clockTolerance])
35
+ });
36
+ if (!isValid) {
37
+ return new Response("invalid signature", { status: 403 });
38
+ }
39
+ return handler(event);
40
+ };
41
+ };
42
+ var serve2 = (routeFunction, options) => {
43
+ const handler = async (event) => {
44
+ const method = event.request.method;
45
+ if (method.toUpperCase() !== "POST") {
46
+ return new Response("Only POST requests are allowed in worklfows", { status: 405 });
47
+ }
48
+ const serveHandler = _chunkWQZ4U6LJjs.serve.call(void 0, routeFunction, options);
49
+ return await serveHandler(event.request);
50
+ };
51
+ return handler;
52
+ };
53
+
54
+
55
+
56
+ exports.serve = serve2; exports.verifySignatureSolidjs = verifySignatureSolidjs;
package/solidjs.mjs ADDED
@@ -0,0 +1,56 @@
1
+ import "./chunk-S7JMIMW4.mjs";
2
+ import {
3
+ Receiver,
4
+ serve
5
+ } from "./chunk-B3NB4QLV.mjs";
6
+
7
+ // platforms/solidjs.ts
8
+ var verifySignatureSolidjs = (handler, config) => {
9
+ const currentSigningKey = config?.currentSigningKey ?? process.env.QSTASH_CURRENT_SIGNING_KEY;
10
+ if (!currentSigningKey) {
11
+ throw new Error("currentSigningKey is required, either in the config or from the env");
12
+ }
13
+ const nextSigningKey = config?.nextSigningKey ?? process.env.QSTASH_NEXT_SIGNING_KEY;
14
+ if (!nextSigningKey) {
15
+ throw new Error("nextSigningKey is required, either in the config or from the env");
16
+ }
17
+ const receiver = new Receiver({
18
+ currentSigningKey,
19
+ nextSigningKey
20
+ });
21
+ return async (event) => {
22
+ const signature = event.request.headers.get("upstash-signature");
23
+ if (!signature) {
24
+ return new Response("`Upstash-Signature` header is missing", { status: 403 });
25
+ }
26
+ if (typeof signature !== "string") {
27
+ throw new TypeError("`Upstash-Signature` header is not a string");
28
+ }
29
+ const cloneRequest = event.request.clone();
30
+ const body = await cloneRequest.text();
31
+ const isValid = await receiver.verify({
32
+ signature,
33
+ body,
34
+ clockTolerance: config?.clockTolerance
35
+ });
36
+ if (!isValid) {
37
+ return new Response("invalid signature", { status: 403 });
38
+ }
39
+ return handler(event);
40
+ };
41
+ };
42
+ var serve2 = (routeFunction, options) => {
43
+ const handler = async (event) => {
44
+ const method = event.request.method;
45
+ if (method.toUpperCase() !== "POST") {
46
+ return new Response("Only POST requests are allowed in worklfows", { status: 405 });
47
+ }
48
+ const serveHandler = serve(routeFunction, options);
49
+ return await serveHandler(event.request);
50
+ };
51
+ return handler;
52
+ };
53
+ export {
54
+ serve2 as serve,
55
+ verifySignatureSolidjs
56
+ };
package/svelte.d.mts ADDED
@@ -0,0 +1,24 @@
1
+ import { RequestHandler } from '@sveltejs/kit';
2
+ import { a2 as RouteFunction, a3 as WorkflowServeOptions } from './client-aUVEwn93.mjs';
3
+ import 'neverthrow';
4
+
5
+ type VerifySignatureConfig = {
6
+ currentSigningKey: string;
7
+ nextSigningKey: string;
8
+ clockTolerance?: number;
9
+ };
10
+ 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>;
11
+ /**
12
+ * Serve method to serve a QStash workflow in a Nextjs project
13
+ *
14
+ * See for options https://upstash.com/docs/qstash/workflows/basics/serve
15
+ *
16
+ * @param routeFunction workflow function
17
+ * @param options workflow options
18
+ * @returns
19
+ */
20
+ declare const serve: <TInitialPayload = unknown>(routeFunction: RouteFunction<TInitialPayload>, options: Omit<WorkflowServeOptions<Response, TInitialPayload>, "onStepFinish"> & {
21
+ env: WorkflowServeOptions["env"];
22
+ }) => RequestHandler;
23
+
24
+ export { serve, verifySignatureSvelte };
package/svelte.d.ts ADDED
@@ -0,0 +1,24 @@
1
+ import { RequestHandler } from '@sveltejs/kit';
2
+ import { a2 as RouteFunction, a3 as WorkflowServeOptions } from './client-aUVEwn93.js';
3
+ import 'neverthrow';
4
+
5
+ type VerifySignatureConfig = {
6
+ currentSigningKey: string;
7
+ nextSigningKey: string;
8
+ clockTolerance?: number;
9
+ };
10
+ 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>;
11
+ /**
12
+ * Serve method to serve a QStash workflow in a Nextjs project
13
+ *
14
+ * See for options https://upstash.com/docs/qstash/workflows/basics/serve
15
+ *
16
+ * @param routeFunction workflow function
17
+ * @param options workflow options
18
+ * @returns
19
+ */
20
+ declare const serve: <TInitialPayload = unknown>(routeFunction: RouteFunction<TInitialPayload>, options: Omit<WorkflowServeOptions<Response, TInitialPayload>, "onStepFinish"> & {
21
+ env: WorkflowServeOptions["env"];
22
+ }) => RequestHandler;
23
+
24
+ export { serve, verifySignatureSvelte };