@upstash/qstash 2.6.2 → 2.6.4-workflow-alpha.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/dist/LICENSE +21 -0
- package/dist/README.md +160 -0
- package/{index.mjs → dist/chunk-AP5AZGAQ.mjs} +478 -426
- package/dist/chunk-EXC7PGHF.mjs +1540 -0
- package/dist/chunk-F6QRAN74.js +30 -0
- package/dist/chunk-OAS6SVLB.js +1540 -0
- package/dist/chunk-TAUBWUPA.mjs +30 -0
- package/{index.js → dist/chunk-Z3TALRVS.js} +505 -453
- package/dist/index.d.mts +47 -0
- package/dist/index.d.ts +47 -0
- package/dist/index.js +38 -0
- package/dist/index.mjs +38 -0
- package/{nextjs.d.mts → dist/nextjs.d.mts} +4 -1
- package/{nextjs.d.ts → dist/nextjs.d.ts} +4 -1
- package/{nextjs.js → dist/nextjs.js} +22 -6
- package/{nextjs.mjs → dist/nextjs.mjs} +18 -2
- package/dist/nuxt.d.mts +22 -0
- package/dist/nuxt.d.ts +22 -0
- package/dist/nuxt.js +103 -0
- package/dist/nuxt.mjs +103 -0
- package/dist/package.json +105 -0
- package/dist/solidjs.d.mts +13 -0
- package/dist/solidjs.d.ts +13 -0
- package/dist/solidjs.js +64 -0
- package/dist/solidjs.mjs +64 -0
- package/dist/svelte.d.mts +13 -0
- package/dist/svelte.d.ts +13 -0
- package/dist/svelte.js +67 -0
- package/dist/svelte.mjs +67 -0
- package/{index.d.mts → dist/types-BBuddmpw.d.mts} +450 -36
- package/{index.d.ts → dist/types-BBuddmpw.d.ts} +450 -36
- package/dist/workflow.d.mts +15 -0
- package/dist/workflow.d.ts +15 -0
- package/dist/workflow.js +15 -0
- package/dist/workflow.mjs +15 -0
- package/package.json +105 -1
- package/chunk-CP4IU45K.mjs +0 -59
- package/chunk-UUR7N6E6.js +0 -59
package/package.json
CHANGED
|
@@ -1 +1,105 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": "2.6.4-workflow-alpha.0",
|
|
3
|
+
"name": "@upstash/qstash",
|
|
4
|
+
"description": "Official Typescript client for QStash",
|
|
5
|
+
"author": "Andreas Thomas <dev@chronark.com>",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"homepage": "https://github.com/upstash/sdk-qstash-ts#readme",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/upstash/sdk-qstash-ts.git"
|
|
11
|
+
},
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/upstash/sdk-qstash-ts/issues"
|
|
14
|
+
},
|
|
15
|
+
"main": "./index.js",
|
|
16
|
+
"module": "./index.mjs",
|
|
17
|
+
"types": "./index.d.ts",
|
|
18
|
+
"files": [
|
|
19
|
+
"dist"
|
|
20
|
+
],
|
|
21
|
+
"exports": {
|
|
22
|
+
".": {
|
|
23
|
+
"import": "./index.mjs",
|
|
24
|
+
"require": "./index.js"
|
|
25
|
+
},
|
|
26
|
+
"./nextjs": {
|
|
27
|
+
"types": "./nextjs.d.ts",
|
|
28
|
+
"import": "./nextjs.mjs",
|
|
29
|
+
"require": "./nextjs.js"
|
|
30
|
+
},
|
|
31
|
+
"./dist/nextjs": {
|
|
32
|
+
"types": "./nextjs.d.ts",
|
|
33
|
+
"import": "./nextjs.mjs",
|
|
34
|
+
"require": "./nextjs.js"
|
|
35
|
+
},
|
|
36
|
+
"./nuxt": {
|
|
37
|
+
"types": "./nuxt.d.ts",
|
|
38
|
+
"import": "./nuxt.mjs",
|
|
39
|
+
"require": "./nuxt.js"
|
|
40
|
+
},
|
|
41
|
+
"./svelte": {
|
|
42
|
+
"types": "./svelte.d.ts",
|
|
43
|
+
"import": "./svelte.mjs",
|
|
44
|
+
"require": "./svelte.js"
|
|
45
|
+
},
|
|
46
|
+
"./solidjs": {
|
|
47
|
+
"types": "./solidjs.d.ts",
|
|
48
|
+
"import": "./solidjs.mjs",
|
|
49
|
+
"require": "./solidjs.js"
|
|
50
|
+
},
|
|
51
|
+
"./workflow": {
|
|
52
|
+
"types": "./workflow.d.ts",
|
|
53
|
+
"import": "./workflow.mjs",
|
|
54
|
+
"require": "./workflow.js"
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
"typesVersions": {
|
|
58
|
+
"*": {
|
|
59
|
+
"nextjs": [
|
|
60
|
+
"./nextjs.d.ts"
|
|
61
|
+
]
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
"keywords": [
|
|
65
|
+
"qstash",
|
|
66
|
+
"queue",
|
|
67
|
+
"events",
|
|
68
|
+
"serverless",
|
|
69
|
+
"upstash"
|
|
70
|
+
],
|
|
71
|
+
"scripts": {
|
|
72
|
+
"build": "tsup && cp README.md ./dist/ && cp package.json ./dist/ && cp LICENSE ./dist/",
|
|
73
|
+
"test": "bun test",
|
|
74
|
+
"fmt": "prettier --write .",
|
|
75
|
+
"lint": "tsc && eslint \"src/**/*.{js,ts,tsx}\" --quiet --fix",
|
|
76
|
+
"prepare": "husky install"
|
|
77
|
+
},
|
|
78
|
+
"devDependencies": {
|
|
79
|
+
"@commitlint/cli": "^19.2.2",
|
|
80
|
+
"@commitlint/config-conventional": "^19.2.2",
|
|
81
|
+
"@types/bun": "^1.1.1",
|
|
82
|
+
"@types/crypto-js": "^4.2.0",
|
|
83
|
+
"@typescript-eslint/eslint-plugin": "^7.0.1",
|
|
84
|
+
"@typescript-eslint/parser": "^7.0.1",
|
|
85
|
+
"ai": "^3.1.28",
|
|
86
|
+
"bun-types": "^1.1.7",
|
|
87
|
+
"eslint": "^8",
|
|
88
|
+
"eslint-plugin-unicorn": "^51.0.1",
|
|
89
|
+
"husky": "^9.0.10",
|
|
90
|
+
"neverthrow": "^7.0.0",
|
|
91
|
+
"next": "^14.0.2",
|
|
92
|
+
"prettier": "^3.2.5",
|
|
93
|
+
"tsup": "latest",
|
|
94
|
+
"typescript": "^5.4.5",
|
|
95
|
+
"undici-types": "^6.16.0",
|
|
96
|
+
"vitest": "latest"
|
|
97
|
+
},
|
|
98
|
+
"dependencies": {
|
|
99
|
+
"@solidjs/start": "^1.0.6",
|
|
100
|
+
"@sveltejs/kit": "^2.5.18",
|
|
101
|
+
"crypto-js": ">=4.2.0",
|
|
102
|
+
"h3": "^1.12.0",
|
|
103
|
+
"jose": "^ 5.2.3"
|
|
104
|
+
}
|
|
105
|
+
}
|
package/chunk-CP4IU45K.mjs
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
// src/receiver.ts
|
|
2
|
-
import * as jose from "jose";
|
|
3
|
-
import crypto from "crypto-js";
|
|
4
|
-
var SignatureError = class extends Error {
|
|
5
|
-
constructor(message) {
|
|
6
|
-
super(message);
|
|
7
|
-
this.name = "SignatureError";
|
|
8
|
-
}
|
|
9
|
-
};
|
|
10
|
-
var Receiver = class {
|
|
11
|
-
currentSigningKey;
|
|
12
|
-
nextSigningKey;
|
|
13
|
-
constructor(config) {
|
|
14
|
-
this.currentSigningKey = config.currentSigningKey;
|
|
15
|
-
this.nextSigningKey = config.nextSigningKey;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Verify the signature of a request.
|
|
19
|
-
*
|
|
20
|
-
* Tries to verify the signature with the current signing key.
|
|
21
|
-
* If that fails, maybe because you have rotated the keys recently, it will
|
|
22
|
-
* try to verify the signature with the next signing key.
|
|
23
|
-
*
|
|
24
|
-
* If that fails, the signature is invalid and a `SignatureError` is thrown.
|
|
25
|
-
*/
|
|
26
|
-
async verify(request) {
|
|
27
|
-
const isValid = await this.verifyWithKey(this.currentSigningKey, request);
|
|
28
|
-
if (isValid) {
|
|
29
|
-
return true;
|
|
30
|
-
}
|
|
31
|
-
return this.verifyWithKey(this.nextSigningKey, request);
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Verify signature with a specific signing key
|
|
35
|
-
*/
|
|
36
|
-
async verifyWithKey(key, request) {
|
|
37
|
-
const jwt = await jose.jwtVerify(request.signature, new TextEncoder().encode(key), {
|
|
38
|
-
issuer: "Upstash",
|
|
39
|
-
clockTolerance: request.clockTolerance
|
|
40
|
-
}).catch((error) => {
|
|
41
|
-
throw new SignatureError(error.message);
|
|
42
|
-
});
|
|
43
|
-
const p = jwt.payload;
|
|
44
|
-
if (request.url !== void 0 && p.sub !== request.url) {
|
|
45
|
-
throw new SignatureError(`invalid subject: ${p.sub}, want: ${request.url}`);
|
|
46
|
-
}
|
|
47
|
-
const bodyHash = crypto.SHA256(request.body).toString(crypto.enc.Base64url);
|
|
48
|
-
const padding = new RegExp(/=+$/);
|
|
49
|
-
if (p.body.replace(padding, "") !== bodyHash.replace(padding, "")) {
|
|
50
|
-
throw new SignatureError(`body hash does not match, want: ${p.body}, got: ${bodyHash}`);
|
|
51
|
-
}
|
|
52
|
-
return true;
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
export {
|
|
57
|
-
SignatureError,
|
|
58
|
-
Receiver
|
|
59
|
-
};
|
package/chunk-UUR7N6E6.js
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }// src/receiver.ts
|
|
2
|
-
var _jose = require('jose'); var jose = _interopRequireWildcard(_jose);
|
|
3
|
-
var _cryptojs = require('crypto-js'); var _cryptojs2 = _interopRequireDefault(_cryptojs);
|
|
4
|
-
var SignatureError = class extends Error {
|
|
5
|
-
constructor(message) {
|
|
6
|
-
super(message);
|
|
7
|
-
this.name = "SignatureError";
|
|
8
|
-
}
|
|
9
|
-
};
|
|
10
|
-
var Receiver = class {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
constructor(config) {
|
|
14
|
-
this.currentSigningKey = config.currentSigningKey;
|
|
15
|
-
this.nextSigningKey = config.nextSigningKey;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Verify the signature of a request.
|
|
19
|
-
*
|
|
20
|
-
* Tries to verify the signature with the current signing key.
|
|
21
|
-
* If that fails, maybe because you have rotated the keys recently, it will
|
|
22
|
-
* try to verify the signature with the next signing key.
|
|
23
|
-
*
|
|
24
|
-
* If that fails, the signature is invalid and a `SignatureError` is thrown.
|
|
25
|
-
*/
|
|
26
|
-
async verify(request) {
|
|
27
|
-
const isValid = await this.verifyWithKey(this.currentSigningKey, request);
|
|
28
|
-
if (isValid) {
|
|
29
|
-
return true;
|
|
30
|
-
}
|
|
31
|
-
return this.verifyWithKey(this.nextSigningKey, request);
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Verify signature with a specific signing key
|
|
35
|
-
*/
|
|
36
|
-
async verifyWithKey(key, request) {
|
|
37
|
-
const jwt = await jose.jwtVerify(request.signature, new TextEncoder().encode(key), {
|
|
38
|
-
issuer: "Upstash",
|
|
39
|
-
clockTolerance: request.clockTolerance
|
|
40
|
-
}).catch((error) => {
|
|
41
|
-
throw new SignatureError(error.message);
|
|
42
|
-
});
|
|
43
|
-
const p = jwt.payload;
|
|
44
|
-
if (request.url !== void 0 && p.sub !== request.url) {
|
|
45
|
-
throw new SignatureError(`invalid subject: ${p.sub}, want: ${request.url}`);
|
|
46
|
-
}
|
|
47
|
-
const bodyHash = _cryptojs2.default.SHA256(request.body).toString(_cryptojs2.default.enc.Base64url);
|
|
48
|
-
const padding = new RegExp(/=+$/);
|
|
49
|
-
if (p.body.replace(padding, "") !== bodyHash.replace(padding, "")) {
|
|
50
|
-
throw new SignatureError(`body hash does not match, want: ${p.body}, got: ${bodyHash}`);
|
|
51
|
-
}
|
|
52
|
-
return true;
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
exports.SignatureError = SignatureError; exports.Receiver = Receiver;
|