@upstash/qstash 0.0.13 → 0.0.14
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.
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import * as dntShim from "../_dnt.shims.js";
|
|
2
|
-
// @ts-ignore Deno can't compile
|
|
3
|
-
import { buffer } from "micro";
|
|
4
2
|
import { Consumer } from "../pkg/consumer.js";
|
|
5
3
|
export function verifySignature(handler, config) {
|
|
6
4
|
const currentSigningKey = config?.currentSigningKey ??
|
|
@@ -28,8 +26,13 @@ export function verifySignature(handler, config) {
|
|
|
28
26
|
if (typeof signature !== "string") {
|
|
29
27
|
throw new Error("`Upstash-Signature` header is not a string");
|
|
30
28
|
}
|
|
31
|
-
const
|
|
32
|
-
|
|
29
|
+
const chunks = [];
|
|
30
|
+
for await (const chunk of req) {
|
|
31
|
+
chunks.push(typeof chunk === 'string' ? Buffer.from(chunk) : chunk);
|
|
32
|
+
}
|
|
33
|
+
const body = Buffer.concat(chunks).toString("utf-8");
|
|
34
|
+
// const body = (await buffer(req)).toString();
|
|
35
|
+
console.log(req.headers, body);
|
|
33
36
|
const url = config?.url ?? new URL(req.url, `https://${process.env.VERCEL_URL}`).href;
|
|
34
37
|
const isValid = await consumer.verify({ signature, body, url });
|
|
35
38
|
if (!isValid) {
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"main": "./script/entrypoints/nodejs.js",
|
|
4
4
|
"types": "./types/entrypoints/nodejs.d.ts",
|
|
5
5
|
"name": "@upstash/qstash",
|
|
6
|
-
"version": "v0.0.
|
|
6
|
+
"version": "v0.0.14",
|
|
7
7
|
"description": "Official Deno/Typescript client for qStash",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
@@ -22,8 +22,18 @@
|
|
|
22
22
|
"url": "https://github.com/upstash/sdk-qstash-ts/issues"
|
|
23
23
|
},
|
|
24
24
|
"homepage": "https://github.com/upstash/sdk-qstash-ts#readme",
|
|
25
|
-
"
|
|
26
|
-
"
|
|
25
|
+
"typesVersions": {
|
|
26
|
+
"*": {
|
|
27
|
+
"nodejs": [
|
|
28
|
+
"./types/entrypoints/nodejs.d.ts"
|
|
29
|
+
],
|
|
30
|
+
"cloudflare": [
|
|
31
|
+
"./types/entrypoints/cloudflare.d.ts"
|
|
32
|
+
],
|
|
33
|
+
"nextjs": [
|
|
34
|
+
"./types/entrypoints/nextjs.d.ts"
|
|
35
|
+
]
|
|
36
|
+
}
|
|
27
37
|
},
|
|
28
38
|
"exports": {
|
|
29
39
|
".": {
|
|
@@ -36,18 +46,18 @@
|
|
|
36
46
|
"require": "./script/entrypoints/nodejs.js",
|
|
37
47
|
"types": "./types/entrypoints/nodejs.d.ts"
|
|
38
48
|
},
|
|
39
|
-
"./nextjs": {
|
|
40
|
-
"import": "./esm/entrypoints/nextjs.js",
|
|
41
|
-
"require": "./script/entrypoints/nextjs.js",
|
|
42
|
-
"types": "./types/entrypoints/nextjs.d.ts"
|
|
43
|
-
},
|
|
44
49
|
"./cloudflare": {
|
|
45
50
|
"import": "./esm/entrypoints/cloudflare.js",
|
|
46
51
|
"require": "./script/entrypoints/cloudflare.js",
|
|
47
52
|
"types": "./types/entrypoints/cloudflare.d.ts"
|
|
53
|
+
},
|
|
54
|
+
"./nextjs": {
|
|
55
|
+
"import": "./esm/entrypoints/nextjs.js",
|
|
56
|
+
"require": "./script/entrypoints/nextjs.js",
|
|
57
|
+
"types": "./types/entrypoints/nextjs.d.ts"
|
|
48
58
|
}
|
|
49
59
|
},
|
|
50
60
|
"dependencies": {
|
|
51
|
-
"@deno/shim-crypto": "~0.3.
|
|
61
|
+
"@deno/shim-crypto": "~0.3.0"
|
|
52
62
|
}
|
|
53
63
|
}
|
|
@@ -25,8 +25,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.verifySignature = void 0;
|
|
27
27
|
const dntShim = __importStar(require("../_dnt.shims.js"));
|
|
28
|
-
// @ts-ignore Deno can't compile
|
|
29
|
-
const micro_1 = require("micro");
|
|
30
28
|
const consumer_js_1 = require("../pkg/consumer.js");
|
|
31
29
|
function verifySignature(handler, config) {
|
|
32
30
|
const currentSigningKey = config?.currentSigningKey ??
|
|
@@ -54,8 +52,13 @@ function verifySignature(handler, config) {
|
|
|
54
52
|
if (typeof signature !== "string") {
|
|
55
53
|
throw new Error("`Upstash-Signature` header is not a string");
|
|
56
54
|
}
|
|
57
|
-
const
|
|
58
|
-
|
|
55
|
+
const chunks = [];
|
|
56
|
+
for await (const chunk of req) {
|
|
57
|
+
chunks.push(typeof chunk === 'string' ? Buffer.from(chunk) : chunk);
|
|
58
|
+
}
|
|
59
|
+
const body = Buffer.concat(chunks).toString("utf-8");
|
|
60
|
+
// const body = (await buffer(req)).toString();
|
|
61
|
+
console.log(req.headers, body);
|
|
59
62
|
const url = config?.url ?? new URL(req.url, `https://${process.env.VERCEL_URL}`).href;
|
|
60
63
|
const isValid = await consumer.verify({ signature, body, url });
|
|
61
64
|
if (!isValid) {
|
|
@@ -23,7 +23,7 @@ declare const stdCrypto: {
|
|
|
23
23
|
encrypt: (algorithm: dntShim.AlgorithmIdentifier | dntShim.RsaOaepParams | dntShim.AesCtrParams | dntShim.AesCbcParams | dntShim.AesGcmParams, key: dntShim.CryptoKey, data: dntShim.BufferSource) => Promise<any>;
|
|
24
24
|
exportKey: {
|
|
25
25
|
(format: "jwk", key: dntShim.CryptoKey): Promise<dntShim.JsonWebKey>;
|
|
26
|
-
(format: "
|
|
26
|
+
(format: "raw" | "pkcs8" | "spki", key: dntShim.CryptoKey): Promise<ArrayBuffer>;
|
|
27
27
|
};
|
|
28
28
|
generateKey: {
|
|
29
29
|
(algorithm: dntShim.RsaHashedKeyGenParams | dntShim.EcKeyGenParams, extractable: boolean, keyUsages: readonly dntShim.KeyUsage[]): Promise<dntShim.CryptoKeyPair>;
|
|
@@ -32,7 +32,7 @@ declare const stdCrypto: {
|
|
|
32
32
|
};
|
|
33
33
|
importKey: {
|
|
34
34
|
(format: "jwk", keyData: dntShim.JsonWebKey, algorithm: dntShim.AlgorithmIdentifier | dntShim.HmacImportParams | dntShim.RsaHashedImportParams | dntShim.EcKeyImportParams | dntShim.AesKeyAlgorithm, extractable: boolean, keyUsages: readonly dntShim.KeyUsage[]): Promise<dntShim.CryptoKey>;
|
|
35
|
-
(format: "
|
|
35
|
+
(format: "raw" | "pkcs8" | "spki", keyData: dntShim.BufferSource, algorithm: dntShim.AlgorithmIdentifier | dntShim.HmacImportParams | dntShim.RsaHashedImportParams | dntShim.EcKeyImportParams | dntShim.AesKeyAlgorithm, extractable: boolean, keyUsages: dntShim.KeyUsage[]): Promise<dntShim.CryptoKey>;
|
|
36
36
|
};
|
|
37
37
|
sign: (algorithm: dntShim.AlgorithmIdentifier | dntShim.RsaPssParams | dntShim.EcdsaParams, key: dntShim.CryptoKey, data: dntShim.BufferSource) => Promise<ArrayBuffer>;
|
|
38
38
|
unwrapKey: (format: dntShim.KeyFormat, wrappedKey: dntShim.BufferSource, unwrappingKey: dntShim.CryptoKey, unwrapAlgorithm: dntShim.AlgorithmIdentifier | dntShim.RsaOaepParams | dntShim.AesCtrParams | dntShim.AesCbcParams | dntShim.AesGcmParams, unwrappedKeyAlgorithm: dntShim.AlgorithmIdentifier | dntShim.HmacImportParams | dntShim.RsaHashedImportParams | dntShim.EcKeyImportParams | dntShim.AesKeyAlgorithm, extractable: boolean, keyUsages: dntShim.KeyUsage[]) => Promise<dntShim.CryptoKey>;
|