@upstash/qstash 2.7.13 → 2.7.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.
package/hono.js CHANGED
@@ -60,11 +60,14 @@ var Receiver = class {
60
60
  * If that fails, the signature is invalid and a `SignatureError` is thrown.
61
61
  */
62
62
  async verify(request) {
63
- const isValid = await this.verifyWithKey(this.currentSigningKey, request);
64
- if (isValid) {
65
- return true;
63
+ let payload;
64
+ try {
65
+ payload = await this.verifyWithKey(this.currentSigningKey, request);
66
+ } catch {
67
+ payload = await this.verifyWithKey(this.nextSigningKey, request);
66
68
  }
67
- return this.verifyWithKey(this.nextSigningKey, request);
69
+ this.verifyBodyAndUrl(payload, request);
70
+ return true;
68
71
  }
69
72
  /**
70
73
  * Verify signature with a specific signing key
@@ -76,7 +79,10 @@ var Receiver = class {
76
79
  }).catch((error) => {
77
80
  throw new SignatureError(error.message);
78
81
  });
79
- const p = jwt.payload;
82
+ return jwt.payload;
83
+ }
84
+ verifyBodyAndUrl(payload, request) {
85
+ const p = payload;
80
86
  if (request.url !== void 0 && p.sub !== request.url) {
81
87
  throw new SignatureError(`invalid subject: ${p.sub}, want: ${request.url}`);
82
88
  }
@@ -85,7 +91,14 @@ var Receiver = class {
85
91
  if (p.body.replace(padding, "") !== bodyHash.replace(padding, "")) {
86
92
  throw new SignatureError(`body hash does not match, want: ${p.body}, got: ${bodyHash}`);
87
93
  }
88
- return true;
94
+ }
95
+ };
96
+
97
+ // src/client/api/utils.ts
98
+ var appendAPIOptions = (request, headers) => {
99
+ if (request.api?.name === "email") {
100
+ headers.set("Authorization", request.api.provider.token);
101
+ request.method = request.method ?? "POST";
89
102
  }
90
103
  };
91
104
 
@@ -522,7 +535,7 @@ var Chat = class _Chat {
522
535
 
523
536
  // src/client/llm/utils.ts
524
537
  function appendLLMOptionsIfNeeded(request, headers, http) {
525
- if (!request.api)
538
+ if (request.api?.name === "email" || !request.api)
526
539
  return;
527
540
  const provider = request.api.provider;
528
541
  const analytics = request.api.analytics;
@@ -679,7 +692,15 @@ function processHeaders(request) {
679
692
  return headers;
680
693
  }
681
694
  function getRequestPath(request) {
682
- return request.url ?? request.urlGroup ?? request.topic ?? `api/${request.api?.name}`;
695
+ const nonApiPath = request.url ?? request.urlGroup ?? request.topic;
696
+ if (nonApiPath)
697
+ return nonApiPath;
698
+ if (request.api?.name === "llm")
699
+ return `api/${request.api.name}`;
700
+ if (request.api?.name === "email") {
701
+ return request.api.provider.baseUrl;
702
+ }
703
+ throw new QstashError(`Failed to infer request path for ${JSON.stringify(request)}`);
683
704
  }
684
705
  var NANOID_CHARS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_";
685
706
  var NANOID_LENGTH = 21;
@@ -692,10 +713,18 @@ function decodeBase64(base64) {
692
713
  const intArray = Uint8Array.from(binString, (m) => m.codePointAt(0));
693
714
  return new TextDecoder().decode(intArray);
694
715
  } catch (error) {
695
- console.warn(
696
- `Upstash Qstash: Failed while decoding base64 "${base64}". Decoding with atob and returning it instead. ${error}`
697
- );
698
- return atob(base64);
716
+ try {
717
+ const result = atob(base64);
718
+ console.warn(
719
+ `Upstash QStash: Failed while decoding base64 "${base64}". Decoding with atob and returning it instead. ${error}`
720
+ );
721
+ return result;
722
+ } catch (error2) {
723
+ console.warn(
724
+ `Upstash QStash: Failed to decode base64 "${base64}" with atob. Returning it as it is. ${error2}`
725
+ );
726
+ return base64;
727
+ }
699
728
  }
700
729
  }
701
730
 
@@ -788,6 +817,7 @@ var Queue = class {
788
817
  headers.set("Content-Type", "application/json");
789
818
  ensureCallbackPresent(request);
790
819
  appendLLMOptionsIfNeeded(request, headers, this.http);
820
+ appendAPIOptions(request, headers);
791
821
  const response = await this.enqueue({
792
822
  ...request,
793
823
  body: JSON.stringify(request.body),
@@ -870,6 +900,9 @@ var Schedules = class {
870
900
  if (request.scheduleId !== void 0) {
871
901
  headers.set("Upstash-Schedule-Id", request.scheduleId);
872
902
  }
903
+ if (request.queueName !== void 0) {
904
+ headers.set("Upstash-Queue-Name", request.queueName);
905
+ }
873
906
  return await this.http.request({
874
907
  method: "POST",
875
908
  headers,
@@ -1087,6 +1120,7 @@ var Client = class {
1087
1120
  headers.set("Content-Type", "application/json");
1088
1121
  ensureCallbackPresent(request);
1089
1122
  appendLLMOptionsIfNeeded(request, headers, this.http);
1123
+ appendAPIOptions(request, headers);
1090
1124
  const response = await this.publish({
1091
1125
  ...request,
1092
1126
  headers,
@@ -1131,6 +1165,7 @@ var Client = class {
1131
1165
  message.headers = new Headers(message.headers);
1132
1166
  ensureCallbackPresent(message);
1133
1167
  appendLLMOptionsIfNeeded(message, message.headers, this.http);
1168
+ appendAPIOptions(message, message.headers);
1134
1169
  message.headers.set("Content-Type", "application/json");
1135
1170
  }
1136
1171
  const response = await this.batch(request);
package/hono.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  serve
3
- } from "./chunk-Q6E5NF42.mjs";
3
+ } from "./chunk-Q2AGFQYM.mjs";
4
4
 
5
5
  // platforms/hono.ts
6
6
  var serve2 = (routeFunction, options) => {
package/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { R as RateLimit, C as ChatRateLimit, S as Step, F as FailureFunctionPayload } from './client-DEZq0-qk.mjs';
2
- export { A as AddEndpointsRequest, $ as AnalyticsConfig, a0 as AnalyticsSetup, B as BodyInit, y as Chat, D as ChatCompletion, I as ChatCompletionChunk, z as ChatCompletionMessage, T as ChatRequest, f as Client, n as CreateScheduleRequest, p as Endpoint, t as Event, u as EventPayload, E as EventsRequest, v as GetEventsPayload, G as GetEventsResponse, H as HTTPMethods, w as HeadersInit, M as Message, k as MessagePayload, l as Messages, O as OpenAIChatModel, N as PromptChatRequest, _ as ProviderReturnType, P as PublishBatchRequest, e as PublishJsonRequest, d as PublishRequest, j as PublishResponse, g as PublishToApiResponse, i as PublishToUrlGroupsResponse, h as PublishToUrlResponse, Q as QueueRequest, c as Receiver, a as ReceiverConfig, q as RemoveEndpointsRequest, x as RequestOptions, m as Schedule, o as Schedules, b as SignatureError, s as State, K as StreamDisabled, J as StreamEnabled, L as StreamParameter, U as UrlGroup, r as UrlGroups, V as VerifyRequest, W as WithCursor, X as custom, Y as openai, a1 as setupAnalytics, Z as upstash } from './client-DEZq0-qk.mjs';
1
+ import { R as RateLimit, C as ChatRateLimit, S as Step, F as FailureFunctionPayload } from './client-kxUsvnWj.mjs';
2
+ export { A as AddEndpointsRequest, $ as AnalyticsConfig, a0 as AnalyticsSetup, B as BodyInit, y as Chat, D as ChatCompletion, I as ChatCompletionChunk, z as ChatCompletionMessage, T as ChatRequest, f as Client, n as CreateScheduleRequest, p as Endpoint, t as Event, u as EventPayload, E as EventsRequest, v as GetEventsPayload, G as GetEventsResponse, H as HTTPMethods, w as HeadersInit, M as Message, k as MessagePayload, l as Messages, O as OpenAIChatModel, N as PromptChatRequest, _ as ProviderReturnType, P as PublishBatchRequest, e as PublishJsonRequest, d as PublishRequest, j as PublishResponse, g as PublishToApiResponse, i as PublishToUrlGroupsResponse, h as PublishToUrlResponse, Q as QueueRequest, c as Receiver, a as ReceiverConfig, q as RemoveEndpointsRequest, x as RequestOptions, m as Schedule, o as Schedules, b as SignatureError, s as State, K as StreamDisabled, J as StreamEnabled, L as StreamParameter, U as UrlGroup, r as UrlGroups, V as VerifyRequest, W as WithCursor, X as custom, Y as openai, a2 as resend, a1 as setupAnalytics, Z as upstash } from './client-kxUsvnWj.mjs';
3
3
  import 'neverthrow';
4
4
 
5
5
  /**
package/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { R as RateLimit, C as ChatRateLimit, S as Step, F as FailureFunctionPayload } from './client-DEZq0-qk.js';
2
- export { A as AddEndpointsRequest, $ as AnalyticsConfig, a0 as AnalyticsSetup, B as BodyInit, y as Chat, D as ChatCompletion, I as ChatCompletionChunk, z as ChatCompletionMessage, T as ChatRequest, f as Client, n as CreateScheduleRequest, p as Endpoint, t as Event, u as EventPayload, E as EventsRequest, v as GetEventsPayload, G as GetEventsResponse, H as HTTPMethods, w as HeadersInit, M as Message, k as MessagePayload, l as Messages, O as OpenAIChatModel, N as PromptChatRequest, _ as ProviderReturnType, P as PublishBatchRequest, e as PublishJsonRequest, d as PublishRequest, j as PublishResponse, g as PublishToApiResponse, i as PublishToUrlGroupsResponse, h as PublishToUrlResponse, Q as QueueRequest, c as Receiver, a as ReceiverConfig, q as RemoveEndpointsRequest, x as RequestOptions, m as Schedule, o as Schedules, b as SignatureError, s as State, K as StreamDisabled, J as StreamEnabled, L as StreamParameter, U as UrlGroup, r as UrlGroups, V as VerifyRequest, W as WithCursor, X as custom, Y as openai, a1 as setupAnalytics, Z as upstash } from './client-DEZq0-qk.js';
1
+ import { R as RateLimit, C as ChatRateLimit, S as Step, F as FailureFunctionPayload } from './client-kxUsvnWj.js';
2
+ export { A as AddEndpointsRequest, $ as AnalyticsConfig, a0 as AnalyticsSetup, B as BodyInit, y as Chat, D as ChatCompletion, I as ChatCompletionChunk, z as ChatCompletionMessage, T as ChatRequest, f as Client, n as CreateScheduleRequest, p as Endpoint, t as Event, u as EventPayload, E as EventsRequest, v as GetEventsPayload, G as GetEventsResponse, H as HTTPMethods, w as HeadersInit, M as Message, k as MessagePayload, l as Messages, O as OpenAIChatModel, N as PromptChatRequest, _ as ProviderReturnType, P as PublishBatchRequest, e as PublishJsonRequest, d as PublishRequest, j as PublishResponse, g as PublishToApiResponse, i as PublishToUrlGroupsResponse, h as PublishToUrlResponse, Q as QueueRequest, c as Receiver, a as ReceiverConfig, q as RemoveEndpointsRequest, x as RequestOptions, m as Schedule, o as Schedules, b as SignatureError, s as State, K as StreamDisabled, J as StreamEnabled, L as StreamParameter, U as UrlGroup, r as UrlGroups, V as VerifyRequest, W as WithCursor, X as custom, Y as openai, a2 as resend, a1 as setupAnalytics, Z as upstash } from './client-kxUsvnWj.js';
3
3
  import 'neverthrow';
4
4
 
5
5
  /**
package/index.js CHANGED
@@ -47,6 +47,7 @@ __export(src_exports, {
47
47
  decodeBase64: () => decodeBase64,
48
48
  formatWorkflowError: () => formatWorkflowError,
49
49
  openai: () => openai,
50
+ resend: () => resend,
50
51
  setupAnalytics: () => setupAnalytics,
51
52
  upstash: () => upstash
52
53
  });
@@ -78,11 +79,14 @@ var Receiver = class {
78
79
  * If that fails, the signature is invalid and a `SignatureError` is thrown.
79
80
  */
80
81
  async verify(request) {
81
- const isValid = await this.verifyWithKey(this.currentSigningKey, request);
82
- if (isValid) {
83
- return true;
82
+ let payload;
83
+ try {
84
+ payload = await this.verifyWithKey(this.currentSigningKey, request);
85
+ } catch {
86
+ payload = await this.verifyWithKey(this.nextSigningKey, request);
84
87
  }
85
- return this.verifyWithKey(this.nextSigningKey, request);
88
+ this.verifyBodyAndUrl(payload, request);
89
+ return true;
86
90
  }
87
91
  /**
88
92
  * Verify signature with a specific signing key
@@ -94,7 +98,10 @@ var Receiver = class {
94
98
  }).catch((error) => {
95
99
  throw new SignatureError(error.message);
96
100
  });
97
- const p = jwt.payload;
101
+ return jwt.payload;
102
+ }
103
+ verifyBodyAndUrl(payload, request) {
104
+ const p = payload;
98
105
  if (request.url !== void 0 && p.sub !== request.url) {
99
106
  throw new SignatureError(`invalid subject: ${p.sub}, want: ${request.url}`);
100
107
  }
@@ -103,7 +110,14 @@ var Receiver = class {
103
110
  if (p.body.replace(padding, "") !== bodyHash.replace(padding, "")) {
104
111
  throw new SignatureError(`body hash does not match, want: ${p.body}, got: ${bodyHash}`);
105
112
  }
106
- return true;
113
+ }
114
+ };
115
+
116
+ // src/client/api/utils.ts
117
+ var appendAPIOptions = (request, headers) => {
118
+ if (request.api?.name === "email") {
119
+ headers.set("Authorization", request.api.provider.token);
120
+ request.method = request.method ?? "POST";
107
121
  }
108
122
  };
109
123
 
@@ -571,7 +585,7 @@ var Chat = class _Chat {
571
585
 
572
586
  // src/client/llm/utils.ts
573
587
  function appendLLMOptionsIfNeeded(request, headers, http) {
574
- if (!request.api)
588
+ if (request.api?.name === "email" || !request.api)
575
589
  return;
576
590
  const provider = request.api.provider;
577
591
  const analytics = request.api.analytics;
@@ -728,7 +742,15 @@ function processHeaders(request) {
728
742
  return headers;
729
743
  }
730
744
  function getRequestPath(request) {
731
- return request.url ?? request.urlGroup ?? request.topic ?? `api/${request.api?.name}`;
745
+ const nonApiPath = request.url ?? request.urlGroup ?? request.topic;
746
+ if (nonApiPath)
747
+ return nonApiPath;
748
+ if (request.api?.name === "llm")
749
+ return `api/${request.api.name}`;
750
+ if (request.api?.name === "email") {
751
+ return request.api.provider.baseUrl;
752
+ }
753
+ throw new QstashError(`Failed to infer request path for ${JSON.stringify(request)}`);
732
754
  }
733
755
  function decodeBase64(base64) {
734
756
  try {
@@ -736,10 +758,18 @@ function decodeBase64(base64) {
736
758
  const intArray = Uint8Array.from(binString, (m) => m.codePointAt(0));
737
759
  return new TextDecoder().decode(intArray);
738
760
  } catch (error) {
739
- console.warn(
740
- `Upstash Qstash: Failed while decoding base64 "${base64}". Decoding with atob and returning it instead. ${error}`
741
- );
742
- return atob(base64);
761
+ try {
762
+ const result = atob(base64);
763
+ console.warn(
764
+ `Upstash QStash: Failed while decoding base64 "${base64}". Decoding with atob and returning it instead. ${error}`
765
+ );
766
+ return result;
767
+ } catch (error2) {
768
+ console.warn(
769
+ `Upstash QStash: Failed to decode base64 "${base64}" with atob. Returning it as it is. ${error2}`
770
+ );
771
+ return base64;
772
+ }
743
773
  }
744
774
  }
745
775
 
@@ -832,6 +862,7 @@ var Queue = class {
832
862
  headers.set("Content-Type", "application/json");
833
863
  ensureCallbackPresent(request);
834
864
  appendLLMOptionsIfNeeded(request, headers, this.http);
865
+ appendAPIOptions(request, headers);
835
866
  const response = await this.enqueue({
836
867
  ...request,
837
868
  body: JSON.stringify(request.body),
@@ -914,6 +945,9 @@ var Schedules = class {
914
945
  if (request.scheduleId !== void 0) {
915
946
  headers.set("Upstash-Schedule-Id", request.scheduleId);
916
947
  }
948
+ if (request.queueName !== void 0) {
949
+ headers.set("Upstash-Queue-Name", request.queueName);
950
+ }
917
951
  return await this.http.request({
918
952
  method: "POST",
919
953
  headers,
@@ -1162,6 +1196,7 @@ var Client = class {
1162
1196
  headers.set("Content-Type", "application/json");
1163
1197
  ensureCallbackPresent(request);
1164
1198
  appendLLMOptionsIfNeeded(request, headers, this.http);
1199
+ appendAPIOptions(request, headers);
1165
1200
  const response = await this.publish({
1166
1201
  ...request,
1167
1202
  headers,
@@ -1206,6 +1241,7 @@ var Client = class {
1206
1241
  message.headers = new Headers(message.headers);
1207
1242
  ensureCallbackPresent(message);
1208
1243
  appendLLMOptionsIfNeeded(message, message.headers, this.http);
1244
+ appendAPIOptions(message, message.headers);
1209
1245
  message.headers.set("Content-Type", "application/json");
1210
1246
  }
1211
1247
  const response = await this.batch(request);
@@ -1263,6 +1299,18 @@ var Client = class {
1263
1299
  };
1264
1300
  }
1265
1301
  };
1302
+
1303
+ // src/client/api/email.ts
1304
+ var resend = ({
1305
+ token,
1306
+ batch = false
1307
+ }) => {
1308
+ return {
1309
+ owner: "resend",
1310
+ baseUrl: `https://api.resend.com/emails${batch ? "/batch" : ""}`,
1311
+ token
1312
+ };
1313
+ };
1266
1314
  // Annotate the CommonJS export names for ESM import in node:
1267
1315
  0 && (module.exports = {
1268
1316
  Chat,
@@ -1282,6 +1330,7 @@ var Client = class {
1282
1330
  decodeBase64,
1283
1331
  formatWorkflowError,
1284
1332
  openai,
1333
+ resend,
1285
1334
  setupAnalytics,
1286
1335
  upstash
1287
1336
  });
package/index.mjs CHANGED
@@ -1,4 +1,6 @@
1
- import "./chunk-CIVGPRQN.mjs";
1
+ import {
2
+ resend
3
+ } from "./chunk-AROUU44N.mjs";
2
4
  import {
3
5
  Chat,
4
6
  Client,
@@ -19,7 +21,7 @@ import {
19
21
  openai,
20
22
  setupAnalytics,
21
23
  upstash
22
- } from "./chunk-Q6E5NF42.mjs";
24
+ } from "./chunk-Q2AGFQYM.mjs";
23
25
  export {
24
26
  Chat,
25
27
  Client,
@@ -38,6 +40,7 @@ export {
38
40
  decodeBase64,
39
41
  formatWorkflowError,
40
42
  openai,
43
+ resend,
41
44
  setupAnalytics,
42
45
  upstash
43
46
  };
package/nextjs.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { NextApiHandler } from 'next';
2
2
  import { NextRequest, NextFetchEvent } from 'next/server';
3
- import { a2 as RouteFunction, a3 as WorkflowServeOptions } from './client-DEZq0-qk.mjs';
3
+ import { a3 as RouteFunction, a4 as WorkflowServeOptions } from './client-kxUsvnWj.mjs';
4
4
  import 'neverthrow';
5
5
 
6
6
  type VerifySignatureConfig = {
package/nextjs.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { NextApiHandler } from 'next';
2
2
  import { NextRequest, NextFetchEvent } from 'next/server';
3
- import { a2 as RouteFunction, a3 as WorkflowServeOptions } from './client-DEZq0-qk.js';
3
+ import { a3 as RouteFunction, a4 as WorkflowServeOptions } from './client-kxUsvnWj.js';
4
4
  import 'neverthrow';
5
5
 
6
6
  type VerifySignatureConfig = {
package/nextjs.js CHANGED
@@ -64,11 +64,14 @@ var Receiver = class {
64
64
  * If that fails, the signature is invalid and a `SignatureError` is thrown.
65
65
  */
66
66
  async verify(request) {
67
- const isValid = await this.verifyWithKey(this.currentSigningKey, request);
68
- if (isValid) {
69
- return true;
67
+ let payload;
68
+ try {
69
+ payload = await this.verifyWithKey(this.currentSigningKey, request);
70
+ } catch {
71
+ payload = await this.verifyWithKey(this.nextSigningKey, request);
70
72
  }
71
- return this.verifyWithKey(this.nextSigningKey, request);
73
+ this.verifyBodyAndUrl(payload, request);
74
+ return true;
72
75
  }
73
76
  /**
74
77
  * Verify signature with a specific signing key
@@ -80,7 +83,10 @@ var Receiver = class {
80
83
  }).catch((error) => {
81
84
  throw new SignatureError(error.message);
82
85
  });
83
- const p = jwt.payload;
86
+ return jwt.payload;
87
+ }
88
+ verifyBodyAndUrl(payload, request) {
89
+ const p = payload;
84
90
  if (request.url !== void 0 && p.sub !== request.url) {
85
91
  throw new SignatureError(`invalid subject: ${p.sub}, want: ${request.url}`);
86
92
  }
@@ -89,7 +95,14 @@ var Receiver = class {
89
95
  if (p.body.replace(padding, "") !== bodyHash.replace(padding, "")) {
90
96
  throw new SignatureError(`body hash does not match, want: ${p.body}, got: ${bodyHash}`);
91
97
  }
92
- return true;
98
+ }
99
+ };
100
+
101
+ // src/client/api/utils.ts
102
+ var appendAPIOptions = (request, headers) => {
103
+ if (request.api?.name === "email") {
104
+ headers.set("Authorization", request.api.provider.token);
105
+ request.method = request.method ?? "POST";
93
106
  }
94
107
  };
95
108
 
@@ -526,7 +539,7 @@ var Chat = class _Chat {
526
539
 
527
540
  // src/client/llm/utils.ts
528
541
  function appendLLMOptionsIfNeeded(request, headers, http) {
529
- if (!request.api)
542
+ if (request.api?.name === "email" || !request.api)
530
543
  return;
531
544
  const provider = request.api.provider;
532
545
  const analytics = request.api.analytics;
@@ -683,7 +696,15 @@ function processHeaders(request) {
683
696
  return headers;
684
697
  }
685
698
  function getRequestPath(request) {
686
- return request.url ?? request.urlGroup ?? request.topic ?? `api/${request.api?.name}`;
699
+ const nonApiPath = request.url ?? request.urlGroup ?? request.topic;
700
+ if (nonApiPath)
701
+ return nonApiPath;
702
+ if (request.api?.name === "llm")
703
+ return `api/${request.api.name}`;
704
+ if (request.api?.name === "email") {
705
+ return request.api.provider.baseUrl;
706
+ }
707
+ throw new QstashError(`Failed to infer request path for ${JSON.stringify(request)}`);
687
708
  }
688
709
  var NANOID_CHARS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_";
689
710
  var NANOID_LENGTH = 21;
@@ -696,10 +717,18 @@ function decodeBase64(base64) {
696
717
  const intArray = Uint8Array.from(binString, (m) => m.codePointAt(0));
697
718
  return new TextDecoder().decode(intArray);
698
719
  } catch (error) {
699
- console.warn(
700
- `Upstash Qstash: Failed while decoding base64 "${base64}". Decoding with atob and returning it instead. ${error}`
701
- );
702
- return atob(base64);
720
+ try {
721
+ const result = atob(base64);
722
+ console.warn(
723
+ `Upstash QStash: Failed while decoding base64 "${base64}". Decoding with atob and returning it instead. ${error}`
724
+ );
725
+ return result;
726
+ } catch (error2) {
727
+ console.warn(
728
+ `Upstash QStash: Failed to decode base64 "${base64}" with atob. Returning it as it is. ${error2}`
729
+ );
730
+ return base64;
731
+ }
703
732
  }
704
733
  }
705
734
 
@@ -792,6 +821,7 @@ var Queue = class {
792
821
  headers.set("Content-Type", "application/json");
793
822
  ensureCallbackPresent(request);
794
823
  appendLLMOptionsIfNeeded(request, headers, this.http);
824
+ appendAPIOptions(request, headers);
795
825
  const response = await this.enqueue({
796
826
  ...request,
797
827
  body: JSON.stringify(request.body),
@@ -874,6 +904,9 @@ var Schedules = class {
874
904
  if (request.scheduleId !== void 0) {
875
905
  headers.set("Upstash-Schedule-Id", request.scheduleId);
876
906
  }
907
+ if (request.queueName !== void 0) {
908
+ headers.set("Upstash-Queue-Name", request.queueName);
909
+ }
877
910
  return await this.http.request({
878
911
  method: "POST",
879
912
  headers,
@@ -1091,6 +1124,7 @@ var Client = class {
1091
1124
  headers.set("Content-Type", "application/json");
1092
1125
  ensureCallbackPresent(request);
1093
1126
  appendLLMOptionsIfNeeded(request, headers, this.http);
1127
+ appendAPIOptions(request, headers);
1094
1128
  const response = await this.publish({
1095
1129
  ...request,
1096
1130
  headers,
@@ -1135,6 +1169,7 @@ var Client = class {
1135
1169
  message.headers = new Headers(message.headers);
1136
1170
  ensureCallbackPresent(message);
1137
1171
  appendLLMOptionsIfNeeded(message, message.headers, this.http);
1172
+ appendAPIOptions(message, message.headers);
1138
1173
  message.headers.set("Content-Type", "application/json");
1139
1174
  }
1140
1175
  const response = await this.batch(request);
package/nextjs.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  Receiver,
3
3
  serve
4
- } from "./chunk-Q6E5NF42.mjs";
4
+ } from "./chunk-Q2AGFQYM.mjs";
5
5
 
6
6
  // platforms/nextjs.ts
7
7
  var BAD_REQUEST = 400;
package/nuxt.js CHANGED
@@ -383,11 +383,14 @@ var Receiver = class {
383
383
  * If that fails, the signature is invalid and a `SignatureError` is thrown.
384
384
  */
385
385
  async verify(request) {
386
- const isValid = await this.verifyWithKey(this.currentSigningKey, request);
387
- if (isValid) {
388
- return true;
386
+ let payload;
387
+ try {
388
+ payload = await this.verifyWithKey(this.currentSigningKey, request);
389
+ } catch {
390
+ payload = await this.verifyWithKey(this.nextSigningKey, request);
389
391
  }
390
- return this.verifyWithKey(this.nextSigningKey, request);
392
+ this.verifyBodyAndUrl(payload, request);
393
+ return true;
391
394
  }
392
395
  /**
393
396
  * Verify signature with a specific signing key
@@ -399,7 +402,10 @@ var Receiver = class {
399
402
  }).catch((error) => {
400
403
  throw new SignatureError(error.message);
401
404
  });
402
- const p = jwt.payload;
405
+ return jwt.payload;
406
+ }
407
+ verifyBodyAndUrl(payload, request) {
408
+ const p = payload;
403
409
  if (request.url !== void 0 && p.sub !== request.url) {
404
410
  throw new SignatureError(`invalid subject: ${p.sub}, want: ${request.url}`);
405
411
  }
@@ -408,7 +414,6 @@ var Receiver = class {
408
414
  if (p.body.replace(padding, "") !== bodyHash.replace(padding, "")) {
409
415
  throw new SignatureError(`body hash does not match, want: ${p.body}, got: ${bodyHash}`);
410
416
  }
411
- return true;
412
417
  }
413
418
  };
414
419
 
package/nuxt.mjs CHANGED
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  verifySignatureH3
3
- } from "./chunk-IYU467WN.mjs";
4
- import "./chunk-CIVGPRQN.mjs";
5
- import "./chunk-Q6E5NF42.mjs";
3
+ } from "./chunk-2OTIVTGG.mjs";
4
+ import "./chunk-AROUU44N.mjs";
5
+ import "./chunk-Q2AGFQYM.mjs";
6
6
 
7
7
  // platforms/nuxt.ts
8
8
  var verifySignatureNuxt = verifySignatureH3;
package/package.json CHANGED
@@ -1 +1 @@
1
- {"version":"v2.7.13","name":"@upstash/qstash","description":"Official Typescript client for QStash","author":"Andreas Thomas <dev@chronark.com>","license":"MIT","homepage":"https://github.com/upstash/sdk-qstash-ts#readme","repository":{"type":"git","url":"git+https://github.com/upstash/sdk-qstash-ts.git"},"bugs":{"url":"https://github.com/upstash/sdk-qstash-ts/issues"},"main":"./index.js","module":"./index.mjs","types":"./index.d.ts","files":["./*"],"exports":{".":{"import":"./index.mjs","require":"./index.js"},"./dist/nextjs":{"import":"./nextjs.mjs","require":"./nextjs.js"},"./nextjs":{"import":"./nextjs.mjs","require":"./nextjs.js"},"./h3":{"import":"./h3.mjs","require":"./h3.js"},"./nuxt":{"import":"./nuxt.mjs","require":"./nuxt.js"},"./svelte":{"import":"./svelte.mjs","require":"./svelte.js"},"./solidjs":{"import":"./solidjs.mjs","require":"./solidjs.js"},"./workflow":{"import":"./workflow.mjs","require":"./workflow.js"},"./hono":{"import":"./hono.mjs","require":"./hono.js"},"./cloudflare":{"import":"./cloudflare.mjs","require":"./cloudflare.js"}},"keywords":["qstash","queue","events","serverless","upstash"],"scripts":{"build":"tsup && cp README.md ./dist/ && cp package.json ./dist/ && cp LICENSE ./dist/","test":"bun test src","fmt":"prettier --write .","lint":"tsc && eslint \"{src,platforms}/**/*.{js,ts,tsx}\" --quiet --fix","check-exports":"bun run build && cd dist && attw -P"},"devDependencies":{"@commitlint/cli":"^19.2.2","@commitlint/config-conventional":"^19.2.2","@eslint/eslintrc":"^3.1.0","@eslint/js":"^9.10.0","@solidjs/start":"^1.0.6","@sveltejs/kit":"^2.5.18","@types/bun":"^1.1.1","@types/crypto-js":"^4.2.0","@typescript-eslint/eslint-plugin":"^8.4.0","@typescript-eslint/parser":"^8.4.0","ai":"^3.1.28","bun-types":"^1.1.7","eslint":"^9.10.0","eslint-plugin-unicorn":"^51.0.1","h3":"^1.12.0","hono":"^4.5.8","husky":"^9.0.10","next":"^14.0.2","prettier":"^3.2.5","tsup":"latest","typescript":"^5.4.5","undici-types":"^6.16.0","vitest":"latest"},"dependencies":{"crypto-js":">=4.2.0","jose":"^5.2.3","neverthrow":"^7.0.1"}}
1
+ {"version":"v2.7.14","name":"@upstash/qstash","description":"Official Typescript client for QStash","author":"Andreas Thomas <dev@chronark.com>","license":"MIT","homepage":"https://github.com/upstash/sdk-qstash-ts#readme","repository":{"type":"git","url":"git+https://github.com/upstash/sdk-qstash-ts.git"},"bugs":{"url":"https://github.com/upstash/sdk-qstash-ts/issues"},"main":"./index.js","module":"./index.mjs","types":"./index.d.ts","files":["./*"],"exports":{".":{"import":"./index.mjs","require":"./index.js"},"./dist/nextjs":{"import":"./nextjs.mjs","require":"./nextjs.js"},"./nextjs":{"import":"./nextjs.mjs","require":"./nextjs.js"},"./h3":{"import":"./h3.mjs","require":"./h3.js"},"./nuxt":{"import":"./nuxt.mjs","require":"./nuxt.js"},"./svelte":{"import":"./svelte.mjs","require":"./svelte.js"},"./solidjs":{"import":"./solidjs.mjs","require":"./solidjs.js"},"./workflow":{"import":"./workflow.mjs","require":"./workflow.js"},"./hono":{"import":"./hono.mjs","require":"./hono.js"},"./cloudflare":{"import":"./cloudflare.mjs","require":"./cloudflare.js"}},"keywords":["qstash","queue","events","serverless","upstash"],"scripts":{"build":"tsup && cp README.md ./dist/ && cp package.json ./dist/ && cp LICENSE ./dist/","test":"bun test src","fmt":"prettier --write .","lint":"tsc && eslint \"{src,platforms}/**/*.{js,ts,tsx}\" --quiet --fix","check-exports":"bun run build && cd dist && attw -P"},"devDependencies":{"@commitlint/cli":"^19.2.2","@commitlint/config-conventional":"^19.2.2","@eslint/eslintrc":"^3.1.0","@eslint/js":"^9.10.0","@solidjs/start":"^1.0.6","@sveltejs/kit":"^2.5.18","@types/bun":"^1.1.1","@types/crypto-js":"^4.2.0","@typescript-eslint/eslint-plugin":"^8.4.0","@typescript-eslint/parser":"^8.4.0","ai":"^3.1.28","bun-types":"^1.1.7","eslint":"^9.10.0","eslint-plugin-unicorn":"^51.0.1","h3":"^1.12.0","hono":"^4.5.8","husky":"^9.0.10","next":"^14.0.2","prettier":"^3.2.5","tsup":"latest","typescript":"^5.4.5","undici-types":"^6.16.0","vitest":"latest"},"dependencies":{"crypto-js":">=4.2.0","jose":"^5.2.3","neverthrow":"^7.0.1"}}
package/solidjs.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { APIHandler, APIEvent } from '@solidjs/start/server';
2
- import { a2 as RouteFunction, a3 as WorkflowServeOptions } from './client-DEZq0-qk.mjs';
2
+ import { a3 as RouteFunction, a4 as WorkflowServeOptions } from './client-kxUsvnWj.mjs';
3
3
  import 'neverthrow';
4
4
 
5
5
  type VerifySignatureConfig = {
package/solidjs.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { APIHandler, APIEvent } from '@solidjs/start/server';
2
- import { a2 as RouteFunction, a3 as WorkflowServeOptions } from './client-DEZq0-qk.js';
2
+ import { a3 as RouteFunction, a4 as WorkflowServeOptions } from './client-kxUsvnWj.js';
3
3
  import 'neverthrow';
4
4
 
5
5
  type VerifySignatureConfig = {