@vercel/queue 0.2.0 → 0.2.1
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/dist/index.js +17 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +17 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -597,7 +597,13 @@ function parseBinaryHeaders(headers) {
|
|
|
597
597
|
`Missing required CloudEvent headers: ${missingFields.join(", ")}`
|
|
598
598
|
);
|
|
599
599
|
}
|
|
600
|
-
const
|
|
600
|
+
const rawRegion = getHeader(headers, "ce-vqsregion") ?? void 0;
|
|
601
|
+
if (rawRegion !== void 0 && !/^[a-z]{2,5}[0-9]{1,2}$/.test(rawRegion)) {
|
|
602
|
+
throw new Error(
|
|
603
|
+
`Invalid ce-vqsregion header: ${JSON.stringify(rawRegion)}. Region must match /^[a-z]{2,5}[0-9]{1,2}$/ (e.g. "iad1", "lhr1").`
|
|
604
|
+
);
|
|
605
|
+
}
|
|
606
|
+
const region = rawRegion;
|
|
601
607
|
const base = {
|
|
602
608
|
queueName,
|
|
603
609
|
consumerGroup,
|
|
@@ -1486,6 +1492,14 @@ function parseQueueHeaders(headers) {
|
|
|
1486
1492
|
receiptHandle
|
|
1487
1493
|
};
|
|
1488
1494
|
}
|
|
1495
|
+
var REGION_PATTERN = /^[a-z]{2,5}[0-9]{1,2}$/;
|
|
1496
|
+
function validateRegion(region) {
|
|
1497
|
+
if (!REGION_PATTERN.test(region)) {
|
|
1498
|
+
throw new Error(
|
|
1499
|
+
`Invalid region code: ${JSON.stringify(region)}. Region must match the pattern /^[a-z]{2,5}[0-9]{1,2}$/ (e.g. "iad1", "lhr1").`
|
|
1500
|
+
);
|
|
1501
|
+
}
|
|
1502
|
+
}
|
|
1489
1503
|
var DEFAULT_BASE_URL_RESOLVER = (region) => new URL(`https://${region}.vercel-queue.com`);
|
|
1490
1504
|
function resolveBaseUrl(region, resolver) {
|
|
1491
1505
|
return (resolver ?? DEFAULT_BASE_URL_RESOLVER)(region);
|
|
@@ -1503,6 +1517,7 @@ var ApiClient = class _ApiClient {
|
|
|
1503
1517
|
baseUrlResolver;
|
|
1504
1518
|
dispatcher;
|
|
1505
1519
|
constructor(options) {
|
|
1520
|
+
validateRegion(options.region);
|
|
1506
1521
|
this.region = options.region;
|
|
1507
1522
|
this.baseUrlResolver = options.resolveBaseUrl;
|
|
1508
1523
|
this.baseUrl = resolveBaseUrl(this.region, this.baseUrlResolver);
|
|
@@ -1617,7 +1632,7 @@ Cause: ${cause}`
|
|
|
1617
1632
|
}
|
|
1618
1633
|
console.debug("[VQS Debug] Request:", JSON.stringify(logData, null, 2));
|
|
1619
1634
|
}
|
|
1620
|
-
init.headers.set("User-Agent", `@vercel/queue/${"0.2.
|
|
1635
|
+
init.headers.set("User-Agent", `@vercel/queue/${"0.2.1"}`);
|
|
1621
1636
|
init.headers.set("Vqs-Client-Ts", (/* @__PURE__ */ new Date()).toISOString());
|
|
1622
1637
|
const fetchInit = this.dispatcher ? { ...init, dispatcher: this.dispatcher } : init;
|
|
1623
1638
|
const response = await fetch(url, fetchInit);
|