@upstash/qstash 2.10.1 → 2.11.0
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/{chunk-Z37KJCW7.mjs → chunk-7DSF3QVE.mjs} +1 -1
- package/{chunk-PIBVA43B.mjs → chunk-JQP6NQUW.mjs} +1 -1
- package/{chunk-35B33QW3.mjs → chunk-LB3C5PJP.mjs} +486 -11
- package/{client-CsM1dTnz.d.ts → client-CUioGZfg.d.mts} +19 -0
- package/{client-CsM1dTnz.d.mts → client-CUioGZfg.d.ts} +19 -0
- package/cloudflare.d.mts +1 -1
- package/cloudflare.d.ts +1 -1
- package/cloudflare.js +484 -11
- package/cloudflare.mjs +1 -1
- package/h3.d.mts +1 -1
- package/h3.d.ts +1 -1
- package/h3.js +484 -11
- package/h3.mjs +3 -3
- package/hono.d.mts +1 -1
- package/hono.d.ts +1 -1
- package/hono.js +484 -11
- package/hono.mjs +1 -1
- package/index.d.mts +2 -2
- package/index.d.ts +2 -2
- package/index.js +484 -11
- package/index.mjs +2 -2
- package/nextjs.d.mts +33 -2
- package/nextjs.d.ts +33 -2
- package/nextjs.js +505 -17
- package/nextjs.mjs +24 -8
- package/nuxt.js +70 -3
- package/nuxt.mjs +3 -3
- package/package.json +1 -1
- package/solidjs.d.mts +1 -1
- package/solidjs.d.ts +1 -1
- package/solidjs.js +484 -11
- package/solidjs.mjs +2 -2
- package/svelte.d.mts +1 -1
- package/svelte.d.ts +1 -1
- package/svelte.js +484 -11
- package/svelte.mjs +2 -2
- package/workflow.d.mts +1 -1
- package/workflow.d.ts +1 -1
- package/workflow.js +484 -11
- package/workflow.mjs +1 -1
package/nextjs.mjs
CHANGED
|
@@ -1,21 +1,25 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Receiver,
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
ensureDevelopmentServer,
|
|
4
|
+
serve,
|
|
5
|
+
shouldUseDevelopmentMode
|
|
6
|
+
} from "./chunk-LB3C5PJP.mjs";
|
|
5
7
|
|
|
6
8
|
// platforms/nextjs.ts
|
|
7
9
|
var BAD_REQUEST = 400;
|
|
8
10
|
function verifySignature(handler, config) {
|
|
9
11
|
const currentSigningKey = config?.currentSigningKey ?? process.env.QSTASH_CURRENT_SIGNING_KEY;
|
|
10
12
|
const nextSigningKey = config?.nextSigningKey ?? process.env.QSTASH_NEXT_SIGNING_KEY;
|
|
11
|
-
|
|
13
|
+
const devMode = shouldUseDevelopmentMode(config?.devMode, process.env);
|
|
14
|
+
if (!devMode && !currentSigningKey && !nextSigningKey && !process.env.QSTASH_REGION) {
|
|
12
15
|
throw new Error(
|
|
13
16
|
"currentSigningKey and nextSigningKey are required, either in the config or as env variables (QSTASH_CURRENT_SIGNING_KEY and QSTASH_NEXT_SIGNING_KEY)"
|
|
14
17
|
);
|
|
15
18
|
}
|
|
16
19
|
const receiver = new Receiver({
|
|
17
20
|
currentSigningKey,
|
|
18
|
-
nextSigningKey
|
|
21
|
+
nextSigningKey,
|
|
22
|
+
devMode: config?.devMode
|
|
19
23
|
});
|
|
20
24
|
return async (request, response) => {
|
|
21
25
|
const signature = request.headers["upstash-signature"];
|
|
@@ -57,14 +61,16 @@ function verifySignature(handler, config) {
|
|
|
57
61
|
function verifySignatureEdge(handler, config) {
|
|
58
62
|
const currentSigningKey = config?.currentSigningKey ?? process.env.QSTASH_CURRENT_SIGNING_KEY;
|
|
59
63
|
const nextSigningKey = config?.nextSigningKey ?? process.env.QSTASH_NEXT_SIGNING_KEY;
|
|
60
|
-
|
|
64
|
+
const devMode = shouldUseDevelopmentMode(config?.devMode, process.env);
|
|
65
|
+
if (!devMode && !currentSigningKey && !nextSigningKey && !process.env.QSTASH_REGION) {
|
|
61
66
|
throw new Error(
|
|
62
67
|
"currentSigningKey and nextSigningKey are required, either in the config or as env variables (QSTASH_CURRENT_SIGNING_KEY and QSTASH_NEXT_SIGNING_KEY)"
|
|
63
68
|
);
|
|
64
69
|
}
|
|
65
70
|
const receiver = new Receiver({
|
|
66
71
|
currentSigningKey,
|
|
67
|
-
nextSigningKey
|
|
72
|
+
nextSigningKey,
|
|
73
|
+
devMode: config?.devMode
|
|
68
74
|
});
|
|
69
75
|
return async (request, nfe) => {
|
|
70
76
|
const requestClone = request.clone();
|
|
@@ -94,14 +100,16 @@ function verifySignatureEdge(handler, config) {
|
|
|
94
100
|
function verifySignatureAppRouter(handler, config) {
|
|
95
101
|
const currentSigningKey = config?.currentSigningKey ?? process.env.QSTASH_CURRENT_SIGNING_KEY;
|
|
96
102
|
const nextSigningKey = config?.nextSigningKey ?? process.env.QSTASH_NEXT_SIGNING_KEY;
|
|
97
|
-
|
|
103
|
+
const devMode = shouldUseDevelopmentMode(config?.devMode, process.env);
|
|
104
|
+
if (!devMode && !currentSigningKey && !nextSigningKey && !process.env.QSTASH_REGION) {
|
|
98
105
|
throw new Error(
|
|
99
106
|
"currentSigningKey and nextSigningKey are required, either in the config or as env variables (QSTASH_CURRENT_SIGNING_KEY and QSTASH_NEXT_SIGNING_KEY)"
|
|
100
107
|
);
|
|
101
108
|
}
|
|
102
109
|
const receiver = new Receiver({
|
|
103
110
|
currentSigningKey,
|
|
104
|
-
nextSigningKey
|
|
111
|
+
nextSigningKey,
|
|
112
|
+
devMode: config?.devMode
|
|
105
113
|
});
|
|
106
114
|
return async (request, params) => {
|
|
107
115
|
const requestClone = request.clone();
|
|
@@ -159,7 +167,15 @@ var servePagesRouter = (routeFunction, options) => {
|
|
|
159
167
|
res.status(response.status).json(await response.json());
|
|
160
168
|
};
|
|
161
169
|
};
|
|
170
|
+
async function registerQStashDev() {
|
|
171
|
+
if (process.env.NODE_ENV === "production")
|
|
172
|
+
return;
|
|
173
|
+
if (process.env.NEXT_PHASE === "phase-production-build")
|
|
174
|
+
return;
|
|
175
|
+
await ensureDevelopmentServer(void 0, true);
|
|
176
|
+
}
|
|
162
177
|
export {
|
|
178
|
+
registerQStashDev,
|
|
163
179
|
serve2 as serve,
|
|
164
180
|
servePagesRouter,
|
|
165
181
|
verifySignature,
|
package/nuxt.js
CHANGED
|
@@ -362,8 +362,13 @@ var jose = __toESM(require("jose"));
|
|
|
362
362
|
var import_crypto_js = __toESM(require("crypto-js"));
|
|
363
363
|
|
|
364
364
|
// src/client/utils.ts
|
|
365
|
+
function _processGlobal() {
|
|
366
|
+
const proc = globalThis["process"];
|
|
367
|
+
return proc;
|
|
368
|
+
}
|
|
365
369
|
function getSafeEnvironment() {
|
|
366
|
-
|
|
370
|
+
const proc = _processGlobal();
|
|
371
|
+
return proc?.env ?? {};
|
|
367
372
|
}
|
|
368
373
|
|
|
369
374
|
// src/client/multi-region/utils.ts
|
|
@@ -403,12 +408,71 @@ function normalizeRegionHeader(region) {
|
|
|
403
408
|
return void 0;
|
|
404
409
|
}
|
|
405
410
|
|
|
411
|
+
// src/dev-server/constants.ts
|
|
412
|
+
var DEFAULT_DEV_PORT = 8080;
|
|
413
|
+
var DEV_CREDENTIALS = {
|
|
414
|
+
token: "eyJVc2VySUQiOiJkZWZhdWx0VXNlciIsIlBhc3N3b3JkIjoiZGVmYXVsdFBhc3N3b3JkIn0=",
|
|
415
|
+
currentSigningKey: "sig_7kYjw48mhY7kAjqNGcy6cr29RJ6r",
|
|
416
|
+
nextSigningKey: "sig_5ZB6DVzB1wjE8S6rZ7eenA8Pdnhs"
|
|
417
|
+
};
|
|
418
|
+
var DEV_PREFIX = "\x1B[2m[QStash Dev]\x1B[0m";
|
|
419
|
+
|
|
420
|
+
// src/dev-server/index.ts
|
|
421
|
+
var _processGlobal2 = () => {
|
|
422
|
+
const proc = globalThis["process"];
|
|
423
|
+
return proc;
|
|
424
|
+
};
|
|
425
|
+
var shouldUseDevelopmentMode = (devMode, env) => {
|
|
426
|
+
if (devMode !== void 0)
|
|
427
|
+
return devMode;
|
|
428
|
+
const value = env?.QSTASH_DEV ?? getProcessEnvironment("QSTASH_DEV");
|
|
429
|
+
if (value === void 0 || value === "" || value === "false" || value === "0")
|
|
430
|
+
return false;
|
|
431
|
+
if (value === "true" || value === "1")
|
|
432
|
+
return true;
|
|
433
|
+
throw new Error(`[QStash Dev] Invalid value for QSTASH_DEV in environment: ${value}`);
|
|
434
|
+
};
|
|
435
|
+
var getDevelopmentCredentials = (env) => {
|
|
436
|
+
return {
|
|
437
|
+
...DEV_CREDENTIALS,
|
|
438
|
+
baseUrl: getDevUrl(env)
|
|
439
|
+
};
|
|
440
|
+
};
|
|
441
|
+
var getDevUrl = (env) => {
|
|
442
|
+
const portString = env?.QSTASH_DEV_PORT ?? getProcessEnvironment("QSTASH_DEV_PORT");
|
|
443
|
+
let port = DEFAULT_DEV_PORT;
|
|
444
|
+
if (portString) {
|
|
445
|
+
const parsed = Number.parseInt(portString, 10);
|
|
446
|
+
if (!Number.isNaN(parsed) && parsed > 0) {
|
|
447
|
+
port = parsed;
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
return `http://127.0.0.1:${port}`;
|
|
451
|
+
};
|
|
452
|
+
var getProcessEnvironment = (key) => {
|
|
453
|
+
const proc = _processGlobal2();
|
|
454
|
+
return proc?.env ? proc.env[key] : void 0;
|
|
455
|
+
};
|
|
456
|
+
|
|
406
457
|
// src/client/multi-region/incoming.ts
|
|
407
458
|
var getReceiverSigningKeys = ({
|
|
408
459
|
environment,
|
|
409
460
|
regionFromHeader,
|
|
410
|
-
config
|
|
461
|
+
config,
|
|
462
|
+
devMode
|
|
411
463
|
}) => {
|
|
464
|
+
if (shouldUseDevelopmentMode(devMode, environment)) {
|
|
465
|
+
if (config?.currentSigningKey || config?.nextSigningKey) {
|
|
466
|
+
console.warn(
|
|
467
|
+
`${DEV_PREFIX} Dev mode is active. Ignoring signing keys from config. Set devMode: false to use your own keys.`
|
|
468
|
+
);
|
|
469
|
+
}
|
|
470
|
+
const developmentCreds = getDevelopmentCredentials(environment);
|
|
471
|
+
return {
|
|
472
|
+
currentSigningKey: developmentCreds.currentSigningKey,
|
|
473
|
+
nextSigningKey: developmentCreds.nextSigningKey
|
|
474
|
+
};
|
|
475
|
+
}
|
|
412
476
|
if (config?.currentSigningKey && config.nextSigningKey) {
|
|
413
477
|
return {
|
|
414
478
|
currentSigningKey: config.currentSigningKey,
|
|
@@ -456,9 +520,11 @@ var SignatureError = class extends Error {
|
|
|
456
520
|
var Receiver = class {
|
|
457
521
|
currentSigningKey;
|
|
458
522
|
nextSigningKey;
|
|
523
|
+
devMode;
|
|
459
524
|
constructor(config) {
|
|
460
525
|
this.currentSigningKey = config?.currentSigningKey;
|
|
461
526
|
this.nextSigningKey = config?.nextSigningKey;
|
|
527
|
+
this.devMode = config?.devMode;
|
|
462
528
|
}
|
|
463
529
|
/**
|
|
464
530
|
* Verify the signature of a request.
|
|
@@ -477,7 +543,8 @@ var Receiver = class {
|
|
|
477
543
|
config: {
|
|
478
544
|
currentSigningKey: this.currentSigningKey,
|
|
479
545
|
nextSigningKey: this.nextSigningKey
|
|
480
|
-
}
|
|
546
|
+
},
|
|
547
|
+
devMode: this.devMode
|
|
481
548
|
});
|
|
482
549
|
if (!signingKeys) {
|
|
483
550
|
throw new Error(
|
package/nuxt.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
verifySignatureH3
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
5
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-JQP6NQUW.mjs";
|
|
4
|
+
import "./chunk-7DSF3QVE.mjs";
|
|
5
|
+
import "./chunk-LB3C5PJP.mjs";
|
|
6
6
|
|
|
7
7
|
// platforms/nuxt.ts
|
|
8
8
|
var verifySignatureNuxt = verifySignatureH3;
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"2.
|
|
1
|
+
{"version":"2.11.0","name":"@upstash/qstash","description":"Official Typescript client for QStash","author":"Andreas Thomas <dev@chronark.com>","license":"MIT","homepage":"https://github.com/upstash/qstash-js#readme","repository":{"type":"git","url":"git+https://github.com/upstash/qstash-js.git"},"bugs":{"url":"https://github.com/upstash/qstash-js/issues"},"main":"./index.js","module":"./index.mjs","types":"./index.d.ts","files":["./*"],"exports":{".":{"import":"./index.mjs","require":"./index.js"},"./dist/nextjs":{"import":"./nextjs.mjs","require":"./nextjs.js"},"./nextjs":{"import":"./nextjs.mjs","require":"./nextjs.js"},"./h3":{"import":"./h3.mjs","require":"./h3.js"},"./nuxt":{"import":"./nuxt.mjs","require":"./nuxt.js"},"./svelte":{"import":"./svelte.mjs","require":"./svelte.js"},"./solidjs":{"import":"./solidjs.mjs","require":"./solidjs.js"},"./workflow":{"import":"./workflow.mjs","require":"./workflow.js"},"./hono":{"import":"./hono.mjs","require":"./hono.js"},"./cloudflare":{"import":"./cloudflare.mjs","require":"./cloudflare.js"}},"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,platforms}/**/*.{js,ts,tsx}\" --quiet --fix","check-exports":"bun run build && cd dist && attw -P"},"devDependencies":{"@commitlint/cli":"^19.2.2","@commitlint/config-conventional":"^19.2.2","@eslint/eslintrc":"^3.1.0","@eslint/js":"^9.10.0","@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":"^8.4.0","@typescript-eslint/parser":"^8.4.0","bun-types":"^1.1.7","eslint":"^9.10.0","eslint-plugin-unicorn":"^51.0.1","h3":"^1.12.0","hono":"^4.5.8","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","neverthrow":"^7.0.1"}}
|
package/solidjs.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { APIHandler, APIEvent } from '@solidjs/start/server';
|
|
2
|
-
import { ae as RouteFunction, af as WorkflowServeOptions } from './client-
|
|
2
|
+
import { ae as RouteFunction, af as WorkflowServeOptions } from './client-CUioGZfg.mjs';
|
|
3
3
|
import 'neverthrow';
|
|
4
4
|
|
|
5
5
|
type VerifySignatureConfig = {
|
package/solidjs.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { APIHandler, APIEvent } from '@solidjs/start/server';
|
|
2
|
-
import { ae as RouteFunction, af as WorkflowServeOptions } from './client-
|
|
2
|
+
import { ae as RouteFunction, af as WorkflowServeOptions } from './client-CUioGZfg.js';
|
|
3
3
|
import 'neverthrow';
|
|
4
4
|
|
|
5
5
|
type VerifySignatureConfig = {
|