@upstash/qstash 0.0.7 → 0.0.10
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/esm/consumer.js +2 -3
- package/package.json +1 -1
- package/script/consumer.js +2 -3
package/esm/consumer.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import * as dntShim from "./_dnt.shims.js";
|
|
2
2
|
import * as base64url from "./deps/deno.land/std@0.144.0/encoding/base64url.js";
|
|
3
|
-
import * as base64 from "./deps/deno.land/std@0.144.0/encoding/base64.js";
|
|
4
3
|
export class SignatureError extends Error {
|
|
5
4
|
constructor(message) {
|
|
6
5
|
super(message);
|
|
@@ -74,8 +73,8 @@ export class Consumer {
|
|
|
74
73
|
throw new SignatureError("token is not yet valid");
|
|
75
74
|
}
|
|
76
75
|
const bodyHash = await dntShim.crypto.subtle.digest("SHA-256", new TextEncoder().encode(req.body));
|
|
77
|
-
if (p.body !=
|
|
78
|
-
throw new SignatureError(
|
|
76
|
+
if (p.body.replaceAll("=", "") != base64url.encode(bodyHash).replace("=", "")) {
|
|
77
|
+
throw new SignatureError(`body hash does not match, want: ${p.body}, got: ${base64url.encode(bodyHash)}`);
|
|
79
78
|
}
|
|
80
79
|
return true;
|
|
81
80
|
}
|
package/package.json
CHANGED
package/script/consumer.js
CHANGED
|
@@ -26,7 +26,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
26
26
|
exports.Consumer = exports.SignatureError = void 0;
|
|
27
27
|
const dntShim = __importStar(require("./_dnt.shims.js"));
|
|
28
28
|
const base64url = __importStar(require("./deps/deno.land/std@0.144.0/encoding/base64url.js"));
|
|
29
|
-
const base64 = __importStar(require("./deps/deno.land/std@0.144.0/encoding/base64.js"));
|
|
30
29
|
class SignatureError extends Error {
|
|
31
30
|
constructor(message) {
|
|
32
31
|
super(message);
|
|
@@ -101,8 +100,8 @@ class Consumer {
|
|
|
101
100
|
throw new SignatureError("token is not yet valid");
|
|
102
101
|
}
|
|
103
102
|
const bodyHash = await dntShim.crypto.subtle.digest("SHA-256", new TextEncoder().encode(req.body));
|
|
104
|
-
if (p.body !=
|
|
105
|
-
throw new SignatureError(
|
|
103
|
+
if (p.body.replaceAll("=", "") != base64url.encode(bodyHash).replace("=", "")) {
|
|
104
|
+
throw new SignatureError(`body hash does not match, want: ${p.body}, got: ${base64url.encode(bodyHash)}`);
|
|
106
105
|
}
|
|
107
106
|
return true;
|
|
108
107
|
}
|