@upstash/qstash 0.1.6 → 0.1.7

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 (42) hide show
  1. package/README.md +3 -3
  2. package/esm/deps/deno.land/{std@0.149.0 → std@0.152.0}/_wasm_crypto/lib/deno_std_wasm_crypto.generated.mjs +0 -0
  3. package/esm/deps/deno.land/{std@0.149.0 → std@0.152.0}/_wasm_crypto/mod.js +0 -0
  4. package/esm/deps/deno.land/{std@0.149.0 → std@0.152.0}/crypto/_fnv/fnv32.js +0 -0
  5. package/esm/deps/deno.land/{std@0.149.0 → std@0.152.0}/crypto/_fnv/fnv64.js +0 -0
  6. package/esm/deps/deno.land/{std@0.149.0 → std@0.152.0}/crypto/_fnv/index.js +0 -0
  7. package/esm/deps/deno.land/{std@0.149.0 → std@0.152.0}/crypto/_fnv/util.js +0 -0
  8. package/esm/deps/deno.land/{std@0.149.0 → std@0.152.0}/crypto/mod.js +17 -9
  9. package/esm/deps/deno.land/std@0.152.0/crypto/timing_safe_equal.js +24 -0
  10. package/esm/deps/deno.land/std@0.152.0/fmt/colors.js +442 -0
  11. package/esm/deps/deno.land/std@0.152.0/testing/_diff.js +304 -0
  12. package/esm/deps/deno.land/std@0.152.0/testing/_format.js +21 -0
  13. package/esm/deps/deno.land/std@0.152.0/testing/asserts.js +620 -0
  14. package/esm/pkg/client/client.js +1 -1
  15. package/package.json +1 -1
  16. package/script/deps/deno.land/{std@0.149.0 → std@0.152.0}/_wasm_crypto/lib/deno_std_wasm_crypto.generated.mjs +0 -0
  17. package/script/deps/deno.land/{std@0.149.0 → std@0.152.0}/_wasm_crypto/mod.js +0 -0
  18. package/script/deps/deno.land/{std@0.149.0 → std@0.152.0}/crypto/_fnv/fnv32.js +0 -0
  19. package/script/deps/deno.land/{std@0.149.0 → std@0.152.0}/crypto/_fnv/fnv64.js +0 -0
  20. package/script/deps/deno.land/{std@0.149.0 → std@0.152.0}/crypto/_fnv/index.js +0 -0
  21. package/script/deps/deno.land/{std@0.149.0 → std@0.152.0}/crypto/_fnv/util.js +0 -0
  22. package/script/deps/deno.land/{std@0.149.0 → std@0.152.0}/crypto/mod.js +18 -10
  23. package/script/deps/deno.land/std@0.152.0/crypto/timing_safe_equal.js +28 -0
  24. package/script/deps/deno.land/std@0.152.0/fmt/colors.js +516 -0
  25. package/script/deps/deno.land/std@0.152.0/testing/_diff.js +310 -0
  26. package/script/deps/deno.land/std@0.152.0/testing/_format.js +48 -0
  27. package/script/deps/deno.land/std@0.152.0/testing/asserts.js +645 -0
  28. package/script/pkg/client/client.js +1 -1
  29. package/types/deps/deno.land/{std@0.149.0 → std@0.152.0}/_wasm_crypto/lib/deno_std_wasm_crypto.generated.d.mts +0 -0
  30. package/types/deps/deno.land/{std@0.149.0 → std@0.152.0}/_wasm_crypto/mod.d.ts +0 -0
  31. package/types/deps/deno.land/{std@0.149.0 → std@0.152.0}/crypto/_fnv/fnv32.d.ts +0 -0
  32. package/types/deps/deno.land/{std@0.149.0 → std@0.152.0}/crypto/_fnv/fnv64.d.ts +0 -0
  33. package/types/deps/deno.land/{std@0.149.0 → std@0.152.0}/crypto/_fnv/index.d.ts +0 -0
  34. package/types/deps/deno.land/{std@0.149.0 → std@0.152.0}/crypto/_fnv/util.d.ts +0 -0
  35. package/types/deps/deno.land/std@0.152.0/crypto/mod.d.ts +51 -0
  36. package/types/deps/deno.land/std@0.152.0/crypto/timing_safe_equal.d.ts +3 -0
  37. package/types/deps/deno.land/std@0.152.0/fmt/colors.d.ts +270 -0
  38. package/types/deps/deno.land/std@0.152.0/testing/_diff.d.ts +26 -0
  39. package/types/deps/deno.land/std@0.152.0/testing/_format.d.ts +1 -0
  40. package/types/deps/deno.land/std@0.152.0/testing/asserts.d.ts +160 -0
  41. package/types/pkg/receiver.d.ts +1 -1
  42. package/types/deps/deno.land/std@0.149.0/crypto/mod.d.ts +0 -53
package/README.md CHANGED
@@ -1,8 +1,7 @@
1
1
  # Upstash qStash SDK
2
2
 
3
3
  [![Tests](https://github.com/upstash/sdk-qstash-ts/actions/workflows/tests.yaml/badge.svg)](https://github.com/upstash/sdk-qstash-ts/actions/workflows/tests.yaml)
4
- ![npm (scoped)](https://img.shields.io/npm/v/@upstash/redis)
5
- ![npm bundle size](https://img.shields.io/bundlephobia/minzip/@upstash/redis)
4
+ ![npm (scoped)](https://img.shields.io/npm/v/@upstash/qstash)
6
5
 
7
6
  **qStash** is an HTTP based messaging and scheduling solution for serverless and
8
7
  edge runtimes.
@@ -75,7 +74,8 @@ const c = new Client({
75
74
  });
76
75
 
77
76
  const res = await c.publishJSON({
78
- destination: "https://my-api...",
77
+ url: "https://my-api...",
78
+ // or topic: "the name or id of a topic"
79
79
  body: {
80
80
  hello: "world",
81
81
  },
@@ -1,11 +1,25 @@
1
1
  // Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
2
+ /**
3
+ * Extensions to the
4
+ * [Web Crypto](https://developer.mozilla.org/en-US/docs/Web/API/Web_Crypto_API)
5
+ * supporting additional encryption APIs.
6
+ *
7
+ * Provides additional digest algorithms that are not part of the WebCrypto
8
+ * standard as well as a `subtle.digest` and `subtle.digestSync` methods. It
9
+ * also provide a `subtle.timingSafeEqual()` method to compare array buffers
10
+ * or data views in a way that isn't prone to timing based attacks.
11
+ *
12
+ * The "polyfill" delegates to `WebCrypto` where possible.
13
+ *
14
+ * @module
15
+ */
2
16
  import * as dntShim from "../../../../_dnt.shims.js";
3
17
  import { digestAlgorithms as wasmDigestAlgorithms, instantiateWasm, } from "../_wasm_crypto/mod.js";
18
+ import { timingSafeEqual } from "./timing_safe_equal.js";
4
19
  import { fnv } from "./_fnv/index.js";
5
20
  /**
6
21
  * A copy of the global WebCrypto interface, with methods bound so they're
7
22
  * safe to re-export.
8
- * @module
9
23
  */
10
24
  const webCrypto = ((crypto) => ({
11
25
  getRandomValues: crypto.getRandomValues?.bind(crypto),
@@ -47,10 +61,6 @@ const stdCrypto = ((x) => x)({
47
61
  ...webCrypto,
48
62
  subtle: {
49
63
  ...webCrypto.subtle,
50
- /**
51
- * Returns a new `Promise` object that will digest `data` using the specified
52
- * `AlgorithmIdentifier`.
53
- */
54
64
  async digest(algorithm, data) {
55
65
  const { name, length } = normalizeAlgorithm(algorithm);
56
66
  const bytes = bufferSourceBytes(data);
@@ -101,10 +111,6 @@ const stdCrypto = ((x) => x)({
101
111
  throw new TypeError(`unsupported digest algorithm: ${algorithm}`);
102
112
  }
103
113
  },
104
- /**
105
- * Returns a ArrayBuffer with the result of digesting `data` using the
106
- * specified `AlgorithmIdentifier`.
107
- */
108
114
  digestSync(algorithm, data) {
109
115
  algorithm = normalizeAlgorithm(algorithm);
110
116
  const bytes = bufferSourceBytes(data);
@@ -131,6 +137,8 @@ const stdCrypto = ((x) => x)({
131
137
  throw new TypeError("data must be a BufferSource or Iterable<BufferSource>");
132
138
  }
133
139
  },
140
+ // TODO(@kitsonk): rework when https://github.com/w3c/webcrypto/issues/270 resolved
141
+ timingSafeEqual,
134
142
  },
135
143
  });
136
144
  const FNVAlgorithms = ["FNV32", "FNV32A", "FNV64", "FNV64A"];
@@ -0,0 +1,24 @@
1
+ // Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
2
+ import { assert } from "../testing/asserts.js";
3
+ /** Compare to array buffers or data views in a way that timing based attacks
4
+ * cannot gain information about the platform. */
5
+ export function timingSafeEqual(a, b) {
6
+ if (a.byteLength !== b.byteLength) {
7
+ return false;
8
+ }
9
+ if (!(a instanceof DataView)) {
10
+ a = new DataView(ArrayBuffer.isView(a) ? a.buffer : a);
11
+ }
12
+ if (!(b instanceof DataView)) {
13
+ b = new DataView(ArrayBuffer.isView(b) ? b.buffer : b);
14
+ }
15
+ assert(a instanceof DataView);
16
+ assert(b instanceof DataView);
17
+ const length = a.byteLength;
18
+ let out = 0;
19
+ let i = -1;
20
+ while (++i < length) {
21
+ out |= a.getUint8(i) ^ b.getUint8(i);
22
+ }
23
+ return out === 0;
24
+ }
@@ -0,0 +1,442 @@
1
+ // Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
2
+ // A module to print ANSI terminal colors. Inspired by chalk, kleur, and colors
3
+ // on npm.
4
+ /**
5
+ * String formatters and utilities for dealing with ANSI color codes.
6
+ *
7
+ * This module is browser compatible.
8
+ *
9
+ * ```ts
10
+ * import { bgBlue, red, bold } from "https://deno.land/std@$STD_VERSION/fmt/colors.ts";
11
+ * console.log(bgBlue(red(bold("Hello world!"))));
12
+ * ```
13
+ *
14
+ * This module supports `NO_COLOR` environmental variable disabling any coloring
15
+ * if `NO_COLOR` is set.
16
+ *
17
+ * @module
18
+ */
19
+ // deno-lint-ignore no-explicit-any
20
+ import * as dntShim from "../../../../_dnt.shims.js";
21
+ const { Deno } = dntShim.dntGlobalThis;
22
+ const noColor = typeof Deno?.noColor === "boolean"
23
+ ? Deno.noColor
24
+ : true;
25
+ let enabled = !noColor;
26
+ /**
27
+ * Set changing text color to enabled or disabled
28
+ * @param value
29
+ */
30
+ export function setColorEnabled(value) {
31
+ if (noColor) {
32
+ return;
33
+ }
34
+ enabled = value;
35
+ }
36
+ /** Get whether text color change is enabled or disabled. */
37
+ export function getColorEnabled() {
38
+ return enabled;
39
+ }
40
+ /**
41
+ * Builds color code
42
+ * @param open
43
+ * @param close
44
+ */
45
+ function code(open, close) {
46
+ return {
47
+ open: `\x1b[${open.join(";")}m`,
48
+ close: `\x1b[${close}m`,
49
+ regexp: new RegExp(`\\x1b\\[${close}m`, "g"),
50
+ };
51
+ }
52
+ /**
53
+ * Applies color and background based on color code and its associated text
54
+ * @param str text to apply color settings to
55
+ * @param code color code to apply
56
+ */
57
+ function run(str, code) {
58
+ return enabled
59
+ ? `${code.open}${str.replace(code.regexp, code.open)}${code.close}`
60
+ : str;
61
+ }
62
+ /**
63
+ * Reset the text modified
64
+ * @param str text to reset
65
+ */
66
+ export function reset(str) {
67
+ return run(str, code([0], 0));
68
+ }
69
+ /**
70
+ * Make the text bold.
71
+ * @param str text to make bold
72
+ */
73
+ export function bold(str) {
74
+ return run(str, code([1], 22));
75
+ }
76
+ /**
77
+ * The text emits only a small amount of light.
78
+ * @param str text to dim
79
+ */
80
+ export function dim(str) {
81
+ return run(str, code([2], 22));
82
+ }
83
+ /**
84
+ * Make the text italic.
85
+ * @param str text to make italic
86
+ */
87
+ export function italic(str) {
88
+ return run(str, code([3], 23));
89
+ }
90
+ /**
91
+ * Make the text underline.
92
+ * @param str text to underline
93
+ */
94
+ export function underline(str) {
95
+ return run(str, code([4], 24));
96
+ }
97
+ /**
98
+ * Invert background color and text color.
99
+ * @param str text to invert its color
100
+ */
101
+ export function inverse(str) {
102
+ return run(str, code([7], 27));
103
+ }
104
+ /**
105
+ * Make the text hidden.
106
+ * @param str text to hide
107
+ */
108
+ export function hidden(str) {
109
+ return run(str, code([8], 28));
110
+ }
111
+ /**
112
+ * Put horizontal line through the center of the text.
113
+ * @param str text to strike through
114
+ */
115
+ export function strikethrough(str) {
116
+ return run(str, code([9], 29));
117
+ }
118
+ /**
119
+ * Set text color to black.
120
+ * @param str text to make black
121
+ */
122
+ export function black(str) {
123
+ return run(str, code([30], 39));
124
+ }
125
+ /**
126
+ * Set text color to red.
127
+ * @param str text to make red
128
+ */
129
+ export function red(str) {
130
+ return run(str, code([31], 39));
131
+ }
132
+ /**
133
+ * Set text color to green.
134
+ * @param str text to make green
135
+ */
136
+ export function green(str) {
137
+ return run(str, code([32], 39));
138
+ }
139
+ /**
140
+ * Set text color to yellow.
141
+ * @param str text to make yellow
142
+ */
143
+ export function yellow(str) {
144
+ return run(str, code([33], 39));
145
+ }
146
+ /**
147
+ * Set text color to blue.
148
+ * @param str text to make blue
149
+ */
150
+ export function blue(str) {
151
+ return run(str, code([34], 39));
152
+ }
153
+ /**
154
+ * Set text color to magenta.
155
+ * @param str text to make magenta
156
+ */
157
+ export function magenta(str) {
158
+ return run(str, code([35], 39));
159
+ }
160
+ /**
161
+ * Set text color to cyan.
162
+ * @param str text to make cyan
163
+ */
164
+ export function cyan(str) {
165
+ return run(str, code([36], 39));
166
+ }
167
+ /**
168
+ * Set text color to white.
169
+ * @param str text to make white
170
+ */
171
+ export function white(str) {
172
+ return run(str, code([37], 39));
173
+ }
174
+ /**
175
+ * Set text color to gray.
176
+ * @param str text to make gray
177
+ */
178
+ export function gray(str) {
179
+ return brightBlack(str);
180
+ }
181
+ /**
182
+ * Set text color to bright black.
183
+ * @param str text to make bright-black
184
+ */
185
+ export function brightBlack(str) {
186
+ return run(str, code([90], 39));
187
+ }
188
+ /**
189
+ * Set text color to bright red.
190
+ * @param str text to make bright-red
191
+ */
192
+ export function brightRed(str) {
193
+ return run(str, code([91], 39));
194
+ }
195
+ /**
196
+ * Set text color to bright green.
197
+ * @param str text to make bright-green
198
+ */
199
+ export function brightGreen(str) {
200
+ return run(str, code([92], 39));
201
+ }
202
+ /**
203
+ * Set text color to bright yellow.
204
+ * @param str text to make bright-yellow
205
+ */
206
+ export function brightYellow(str) {
207
+ return run(str, code([93], 39));
208
+ }
209
+ /**
210
+ * Set text color to bright blue.
211
+ * @param str text to make bright-blue
212
+ */
213
+ export function brightBlue(str) {
214
+ return run(str, code([94], 39));
215
+ }
216
+ /**
217
+ * Set text color to bright magenta.
218
+ * @param str text to make bright-magenta
219
+ */
220
+ export function brightMagenta(str) {
221
+ return run(str, code([95], 39));
222
+ }
223
+ /**
224
+ * Set text color to bright cyan.
225
+ * @param str text to make bright-cyan
226
+ */
227
+ export function brightCyan(str) {
228
+ return run(str, code([96], 39));
229
+ }
230
+ /**
231
+ * Set text color to bright white.
232
+ * @param str text to make bright-white
233
+ */
234
+ export function brightWhite(str) {
235
+ return run(str, code([97], 39));
236
+ }
237
+ /**
238
+ * Set background color to black.
239
+ * @param str text to make its background black
240
+ */
241
+ export function bgBlack(str) {
242
+ return run(str, code([40], 49));
243
+ }
244
+ /**
245
+ * Set background color to red.
246
+ * @param str text to make its background red
247
+ */
248
+ export function bgRed(str) {
249
+ return run(str, code([41], 49));
250
+ }
251
+ /**
252
+ * Set background color to green.
253
+ * @param str text to make its background green
254
+ */
255
+ export function bgGreen(str) {
256
+ return run(str, code([42], 49));
257
+ }
258
+ /**
259
+ * Set background color to yellow.
260
+ * @param str text to make its background yellow
261
+ */
262
+ export function bgYellow(str) {
263
+ return run(str, code([43], 49));
264
+ }
265
+ /**
266
+ * Set background color to blue.
267
+ * @param str text to make its background blue
268
+ */
269
+ export function bgBlue(str) {
270
+ return run(str, code([44], 49));
271
+ }
272
+ /**
273
+ * Set background color to magenta.
274
+ * @param str text to make its background magenta
275
+ */
276
+ export function bgMagenta(str) {
277
+ return run(str, code([45], 49));
278
+ }
279
+ /**
280
+ * Set background color to cyan.
281
+ * @param str text to make its background cyan
282
+ */
283
+ export function bgCyan(str) {
284
+ return run(str, code([46], 49));
285
+ }
286
+ /**
287
+ * Set background color to white.
288
+ * @param str text to make its background white
289
+ */
290
+ export function bgWhite(str) {
291
+ return run(str, code([47], 49));
292
+ }
293
+ /**
294
+ * Set background color to bright black.
295
+ * @param str text to make its background bright-black
296
+ */
297
+ export function bgBrightBlack(str) {
298
+ return run(str, code([100], 49));
299
+ }
300
+ /**
301
+ * Set background color to bright red.
302
+ * @param str text to make its background bright-red
303
+ */
304
+ export function bgBrightRed(str) {
305
+ return run(str, code([101], 49));
306
+ }
307
+ /**
308
+ * Set background color to bright green.
309
+ * @param str text to make its background bright-green
310
+ */
311
+ export function bgBrightGreen(str) {
312
+ return run(str, code([102], 49));
313
+ }
314
+ /**
315
+ * Set background color to bright yellow.
316
+ * @param str text to make its background bright-yellow
317
+ */
318
+ export function bgBrightYellow(str) {
319
+ return run(str, code([103], 49));
320
+ }
321
+ /**
322
+ * Set background color to bright blue.
323
+ * @param str text to make its background bright-blue
324
+ */
325
+ export function bgBrightBlue(str) {
326
+ return run(str, code([104], 49));
327
+ }
328
+ /**
329
+ * Set background color to bright magenta.
330
+ * @param str text to make its background bright-magenta
331
+ */
332
+ export function bgBrightMagenta(str) {
333
+ return run(str, code([105], 49));
334
+ }
335
+ /**
336
+ * Set background color to bright cyan.
337
+ * @param str text to make its background bright-cyan
338
+ */
339
+ export function bgBrightCyan(str) {
340
+ return run(str, code([106], 49));
341
+ }
342
+ /**
343
+ * Set background color to bright white.
344
+ * @param str text to make its background bright-white
345
+ */
346
+ export function bgBrightWhite(str) {
347
+ return run(str, code([107], 49));
348
+ }
349
+ /* Special Color Sequences */
350
+ /**
351
+ * Clam and truncate color codes
352
+ * @param n
353
+ * @param max number to truncate to
354
+ * @param min number to truncate from
355
+ */
356
+ function clampAndTruncate(n, max = 255, min = 0) {
357
+ return Math.trunc(Math.max(Math.min(n, max), min));
358
+ }
359
+ /**
360
+ * Set text color using paletted 8bit colors.
361
+ * https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit
362
+ * @param str text color to apply paletted 8bit colors to
363
+ * @param color code
364
+ */
365
+ export function rgb8(str, color) {
366
+ return run(str, code([38, 5, clampAndTruncate(color)], 39));
367
+ }
368
+ /**
369
+ * Set background color using paletted 8bit colors.
370
+ * https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit
371
+ * @param str text color to apply paletted 8bit background colors to
372
+ * @param color code
373
+ */
374
+ export function bgRgb8(str, color) {
375
+ return run(str, code([48, 5, clampAndTruncate(color)], 49));
376
+ }
377
+ /**
378
+ * Set text color using 24bit rgb.
379
+ * `color` can be a number in range `0x000000` to `0xffffff` or
380
+ * an `Rgb`.
381
+ *
382
+ * To produce the color magenta:
383
+ *
384
+ * ```ts
385
+ * import { rgb24 } from "./colors.ts";
386
+ * rgb24("foo", 0xff00ff);
387
+ * rgb24("foo", {r: 255, g: 0, b: 255});
388
+ * ```
389
+ * @param str text color to apply 24bit rgb to
390
+ * @param color code
391
+ */
392
+ export function rgb24(str, color) {
393
+ if (typeof color === "number") {
394
+ return run(str, code([38, 2, (color >> 16) & 0xff, (color >> 8) & 0xff, color & 0xff], 39));
395
+ }
396
+ return run(str, code([
397
+ 38,
398
+ 2,
399
+ clampAndTruncate(color.r),
400
+ clampAndTruncate(color.g),
401
+ clampAndTruncate(color.b),
402
+ ], 39));
403
+ }
404
+ /**
405
+ * Set background color using 24bit rgb.
406
+ * `color` can be a number in range `0x000000` to `0xffffff` or
407
+ * an `Rgb`.
408
+ *
409
+ * To produce the color magenta:
410
+ *
411
+ * ```ts
412
+ * import { bgRgb24 } from "./colors.ts";
413
+ * bgRgb24("foo", 0xff00ff);
414
+ * bgRgb24("foo", {r: 255, g: 0, b: 255});
415
+ * ```
416
+ * @param str text color to apply 24bit rgb to
417
+ * @param color code
418
+ */
419
+ export function bgRgb24(str, color) {
420
+ if (typeof color === "number") {
421
+ return run(str, code([48, 2, (color >> 16) & 0xff, (color >> 8) & 0xff, color & 0xff], 49));
422
+ }
423
+ return run(str, code([
424
+ 48,
425
+ 2,
426
+ clampAndTruncate(color.r),
427
+ clampAndTruncate(color.g),
428
+ clampAndTruncate(color.b),
429
+ ], 49));
430
+ }
431
+ // https://github.com/chalk/ansi-regex/blob/02fa893d619d3da85411acc8fd4e2eea0e95a9d9/index.js
432
+ const ANSI_PATTERN = new RegExp([
433
+ "[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)",
434
+ "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))",
435
+ ].join("|"), "g");
436
+ /**
437
+ * Remove ANSI escape codes from the string.
438
+ * @param string to remove ANSI escape codes from
439
+ */
440
+ export function stripColor(string) {
441
+ return string.replace(ANSI_PATTERN, "");
442
+ }