@upstash/qstash 0.1.8 → 0.2.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.
Files changed (61) hide show
  1. package/README.md +7 -0
  2. package/esm/deps/deno.land/{std@0.161.0 → std@0.163.0}/crypto/_fnv/fnv32.js +0 -0
  3. package/esm/deps/deno.land/{std@0.161.0 → std@0.163.0}/crypto/_fnv/fnv64.js +0 -0
  4. package/esm/deps/deno.land/{std@0.161.0 → std@0.163.0}/crypto/_fnv/index.js +0 -0
  5. package/esm/deps/deno.land/{std@0.161.0 → std@0.163.0}/crypto/_fnv/util.js +0 -0
  6. package/esm/deps/deno.land/std@0.163.0/crypto/_wasm/lib/deno_std_wasm_crypto.generated.mjs +3299 -0
  7. package/esm/deps/deno.land/{std@0.161.0/crypto/_wasm_crypto → std@0.163.0/crypto/_wasm}/mod.js +1 -1
  8. package/esm/deps/deno.land/{std@0.161.0 → std@0.163.0}/crypto/keystack.js +0 -0
  9. package/esm/deps/deno.land/{std@0.161.0 → std@0.163.0}/crypto/mod.js +1 -1
  10. package/esm/deps/deno.land/{std@0.161.0 → std@0.163.0}/crypto/timing_safe_equal.js +0 -0
  11. package/esm/deps/deno.land/{std@0.161.0 → std@0.163.0}/crypto/util.js +0 -0
  12. package/esm/deps/deno.land/{std@0.161.0 → std@0.163.0}/encoding/base64.js +0 -0
  13. package/esm/deps/deno.land/{std@0.161.0 → std@0.163.0}/encoding/base64url.js +0 -0
  14. package/esm/deps/deno.land/{std@0.161.0 → std@0.163.0}/encoding/hex.js +0 -0
  15. package/esm/deps/deno.land/{std@0.161.0 → std@0.163.0}/fmt/colors.js +0 -0
  16. package/esm/deps/deno.land/{std@0.161.0 → std@0.163.0}/testing/_diff.js +0 -0
  17. package/esm/deps/deno.land/{std@0.161.0 → std@0.163.0}/testing/_format.js +0 -0
  18. package/esm/deps/deno.land/{std@0.161.0 → std@0.163.0}/testing/asserts.js +0 -0
  19. package/esm/entrypoints/nextjs.js +5 -1
  20. package/esm/pkg/receiver.js +3 -3
  21. package/package.json +1 -1
  22. package/script/deps/deno.land/{std@0.161.0 → std@0.163.0}/crypto/_fnv/fnv32.js +0 -0
  23. package/script/deps/deno.land/{std@0.161.0 → std@0.163.0}/crypto/_fnv/fnv64.js +0 -0
  24. package/script/deps/deno.land/{std@0.161.0 → std@0.163.0}/crypto/_fnv/index.js +0 -0
  25. package/script/deps/deno.land/{std@0.161.0 → std@0.163.0}/crypto/_fnv/util.js +0 -0
  26. package/script/deps/deno.land/std@0.163.0/crypto/_wasm/lib/deno_std_wasm_crypto.generated.mjs +3307 -0
  27. package/script/deps/deno.land/{std@0.161.0/crypto/_wasm_crypto → std@0.163.0/crypto/_wasm}/mod.js +1 -1
  28. package/script/deps/deno.land/{std@0.161.0 → std@0.163.0}/crypto/keystack.js +0 -0
  29. package/script/deps/deno.land/{std@0.161.0 → std@0.163.0}/crypto/mod.js +1 -1
  30. package/script/deps/deno.land/{std@0.161.0 → std@0.163.0}/crypto/timing_safe_equal.js +0 -0
  31. package/script/deps/deno.land/{std@0.161.0 → std@0.163.0}/crypto/util.js +0 -0
  32. package/script/deps/deno.land/{std@0.161.0 → std@0.163.0}/encoding/base64.js +0 -0
  33. package/script/deps/deno.land/{std@0.161.0 → std@0.163.0}/encoding/base64url.js +0 -0
  34. package/script/deps/deno.land/{std@0.161.0 → std@0.163.0}/encoding/hex.js +0 -0
  35. package/script/deps/deno.land/{std@0.161.0 → std@0.163.0}/fmt/colors.js +0 -0
  36. package/script/deps/deno.land/{std@0.161.0 → std@0.163.0}/testing/_diff.js +0 -0
  37. package/script/deps/deno.land/{std@0.161.0 → std@0.163.0}/testing/_format.js +0 -0
  38. package/script/deps/deno.land/{std@0.161.0 → std@0.163.0}/testing/asserts.js +0 -0
  39. package/script/entrypoints/nextjs.js +5 -1
  40. package/script/pkg/receiver.js +3 -3
  41. package/types/deps/deno.land/{std@0.161.0 → std@0.163.0}/crypto/_fnv/fnv32.d.ts +0 -0
  42. package/types/deps/deno.land/{std@0.161.0 → std@0.163.0}/crypto/_fnv/fnv64.d.ts +0 -0
  43. package/types/deps/deno.land/{std@0.161.0 → std@0.163.0}/crypto/_fnv/index.d.ts +0 -0
  44. package/types/deps/deno.land/{std@0.161.0 → std@0.163.0}/crypto/_fnv/util.d.ts +0 -0
  45. package/types/deps/deno.land/{std@0.161.0/crypto/_wasm_crypto → std@0.163.0/crypto/_wasm}/lib/deno_std_wasm_crypto.generated.d.mts +0 -0
  46. package/types/deps/deno.land/{std@0.161.0/crypto/_wasm_crypto → std@0.163.0/crypto/_wasm}/mod.d.ts +2 -2
  47. package/types/deps/deno.land/{std@0.161.0 → std@0.163.0}/crypto/keystack.d.ts +0 -0
  48. package/types/deps/deno.land/{std@0.161.0 → std@0.163.0}/crypto/mod.d.ts +1 -1
  49. package/types/deps/deno.land/{std@0.161.0 → std@0.163.0}/crypto/timing_safe_equal.d.ts +0 -0
  50. package/types/deps/deno.land/{std@0.161.0 → std@0.163.0}/crypto/util.d.ts +0 -0
  51. package/types/deps/deno.land/{std@0.161.0 → std@0.163.0}/encoding/base64.d.ts +0 -0
  52. package/types/deps/deno.land/{std@0.161.0 → std@0.163.0}/encoding/base64url.d.ts +0 -0
  53. package/types/deps/deno.land/{std@0.161.0 → std@0.163.0}/encoding/hex.d.ts +0 -0
  54. package/types/deps/deno.land/{std@0.161.0 → std@0.163.0}/fmt/colors.d.ts +0 -0
  55. package/types/deps/deno.land/{std@0.161.0 → std@0.163.0}/testing/_diff.d.ts +0 -0
  56. package/types/deps/deno.land/{std@0.161.0 → std@0.163.0}/testing/_format.d.ts +0 -0
  57. package/types/deps/deno.land/{std@0.161.0 → std@0.163.0}/testing/asserts.d.ts +0 -0
  58. package/types/entrypoints/nextjs.d.ts +6 -0
  59. package/types/pkg/receiver.d.ts +7 -1
  60. package/esm/deps/deno.land/std@0.161.0/crypto/_wasm_crypto/lib/deno_std_wasm_crypto.generated.mjs +0 -3253
  61. package/script/deps/deno.land/std@0.161.0/crypto/_wasm_crypto/lib/deno_std_wasm_crypto.generated.mjs +0 -3261
@@ -1,7 +1,7 @@
1
1
  // Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
2
2
  export { DigestContext, instantiate as instantiateWasm, } from "./lib/deno_std_wasm_crypto.generated.js";
3
3
  /**
4
- * All cryptographic hash/digest algorithms supported by std/_wasm_crypto.
4
+ * All cryptographic hash/digest algorithms supported by std/crypto/_wasm.
5
5
  *
6
6
  * For algorithms that are supported by WebCrypto, the name here must match the
7
7
  * one used by WebCrypto. Otherwise we should prefer the formatting used in the
@@ -18,7 +18,7 @@
18
18
  * @module
19
19
  */
20
20
  import * as dntShim from "../../../../_dnt.shims.js";
21
- import { digestAlgorithms as wasmDigestAlgorithms, instantiateWasm, } from "./_wasm_crypto/mod.js";
21
+ import { digestAlgorithms as wasmDigestAlgorithms, instantiateWasm, } from "./_wasm/mod.js";
22
22
  import { timingSafeEqual } from "./timing_safe_equal.js";
23
23
  import { fnv } from "./_fnv/index.js";
24
24
  export { KeyStack } from "./keystack.js";
@@ -35,7 +35,11 @@ export function verifySignature(handler, config) {
35
35
  // req.url!,
36
36
  // `https://${process.env.VERCEL_URL}`,
37
37
  // ).href;
38
- const isValid = await receiver.verify({ signature, body });
38
+ const isValid = await receiver.verify({
39
+ signature,
40
+ body,
41
+ clockTolerance: config?.clockTolerance,
42
+ });
39
43
  if (!isValid) {
40
44
  res.status(400);
41
45
  res.send("Invalid signature");
@@ -70,18 +70,18 @@ export class Receiver {
70
70
  throw new SignatureError(`invalid subject: ${p.sub}, want: ${req.url}`);
71
71
  }
72
72
  const now = Math.floor(Date.now() / 1000);
73
- if (now > p.exp) {
73
+ if (now - (req.clockTolerance ?? 0) > p.exp) {
74
74
  console.log({ now, exp: p.exp });
75
75
  throw new SignatureError("token has expired");
76
76
  }
77
- if (now < p.nbf) {
77
+ if (now - (req.clockTolerance ?? 0) < p.nbf) {
78
78
  throw new SignatureError("token is not yet valid");
79
79
  }
80
80
  const bodyHash = await this.subtleCrypto.digest("SHA-256", typeof req.body === "string"
81
81
  ? new TextEncoder().encode(req.body)
82
82
  : req.body);
83
83
  const padding = new RegExp(/=+$/);
84
- if (p.body.replace(padding, "") !=
84
+ if (p.body.replace(padding, "") !==
85
85
  base64Url.encode(bodyHash).replace(padding, "")) {
86
86
  throw new SignatureError(`body hash does not match, want: ${p.body}, got: ${base64Url.encode(bodyHash)}`);
87
87
  }
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.1.8",
6
+ "version": "v0.2.0",
7
7
  "description": "Official Deno/Typescript client for QStash",
8
8
  "repository": {
9
9
  "type": "git",