@query-farm/vgi-rpc 0.6.2 → 0.6.4

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.
@@ -1 +1 @@
1
- {"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../src/http/handler.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAa/C,OAAO,EAAE,KAAK,kBAAkB,EAAuB,MAAM,YAAY,CAAC;AAI1E;;;;;;;;;;;GAWG;AACH,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,QAAQ,EAClB,OAAO,CAAC,EAAE,kBAAkB,GAC3B,CAAC,OAAO,EAAE,OAAO,KAAK,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,CAkSpD"}
1
+ {"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../src/http/handler.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAa/C,OAAO,EAAE,KAAK,kBAAkB,EAAuB,MAAM,YAAY,CAAC;AAI1E;;;;;;;;;;;GAWG;AACH,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,QAAQ,EAClB,OAAO,CAAC,EAAE,kBAAkB,GAC3B,CAAC,OAAO,EAAE,OAAO,KAAK,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,CAsSpD"}
@@ -11,6 +11,8 @@ export interface HttpHandlerOptions {
11
11
  tokenTtl?: number;
12
12
  /** CORS allowed origins. If set, CORS headers are added to all responses. */
13
13
  corsOrigins?: string;
14
+ /** Access-Control-Max-Age value in seconds for preflight OPTIONS responses. Default: 7200 (2 hours). null omits the header. */
15
+ corsMaxAge?: number | null;
14
16
  /** Maximum request body size in bytes. Advertised via VGI-Max-Request-Bytes header. */
15
17
  maxRequestBytes?: number;
16
18
  /** Maximum bytes before a producer stream emits a continuation token. */
@@ -1 +1 @@
1
- {"version":3,"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,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,uFAAuF;IACvF,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,oEAAoE;IACpE,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,0EAA0E;IAC1E,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,2EAA2E;IAC3E,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,wEAAwE;IACxE,gBAAgB,CAAC,EAAE,sBAAsB,CAAC;CAC3C;AAED,kEAAkE;AAClE,MAAM,WAAW,eAAe;IAC9B,SAAS,CAAC,KAAK,EAAE,GAAG,GAAG,UAAU,CAAC;IAClC,WAAW,CAAC,KAAK,EAAE,UAAU,GAAG,GAAG,CAAC;CACrC;AAED,iEAAiE;AACjE,eAAO,MAAM,mBAAmB,EAAE,eAWjC,CAAC"}
package/dist/index.js CHANGED
@@ -2732,6 +2732,7 @@ function createHttpHandler(protocol, options) {
2732
2732
  const signingKey = options?.signingKey ?? randomBytes(32);
2733
2733
  const tokenTtl = options?.tokenTtl ?? 3600;
2734
2734
  const corsOrigins = options?.corsOrigins;
2735
+ const corsMaxAge = options?.corsMaxAge === undefined ? 7200 : options.corsMaxAge;
2735
2736
  const maxRequestBytes = options?.maxRequestBytes;
2736
2737
  const maxStreamResponseBytes = options?.maxStreamResponseBytes;
2737
2738
  const serverId = options?.serverId ?? crypto.randomUUID().replace(/-/g, "").slice(0, 12);
@@ -2758,12 +2759,15 @@ function createHttpHandler(protocol, options) {
2758
2759
  stateSerializer,
2759
2760
  externalLocation
2760
2761
  };
2761
- function addCorsHeaders(headers) {
2762
+ function addCorsHeaders(headers, isOptions = false) {
2762
2763
  if (corsOrigins) {
2763
2764
  headers.set("Access-Control-Allow-Origin", corsOrigins);
2764
2765
  headers.set("Access-Control-Allow-Methods", "POST, OPTIONS");
2765
2766
  headers.set("Access-Control-Allow-Headers", "Content-Type, Authorization");
2766
- headers.set("Access-Control-Expose-Headers", "WWW-Authenticate, X-Request-ID");
2767
+ headers.set("Access-Control-Expose-Headers", "WWW-Authenticate, X-Request-ID, X-VGI-Content-Encoding");
2768
+ if (isOptions && corsMaxAge != null) {
2769
+ headers.set("Access-Control-Max-Age", String(corsMaxAge));
2770
+ }
2767
2771
  }
2768
2772
  }
2769
2773
  async function compressIfAccepted(response, clientAcceptsZstd) {
@@ -2803,7 +2807,7 @@ function createHttpHandler(protocol, options) {
2803
2807
  if (request.method === "OPTIONS") {
2804
2808
  if (path === `${prefix}/__capabilities__`) {
2805
2809
  const headers = new Headers;
2806
- addCorsHeaders(headers);
2810
+ addCorsHeaders(headers, true);
2807
2811
  if (maxRequestBytes != null) {
2808
2812
  headers.set("VGI-Max-Request-Bytes", String(maxRequestBytes));
2809
2813
  }
@@ -2811,7 +2815,7 @@ function createHttpHandler(protocol, options) {
2811
2815
  }
2812
2816
  if (corsOrigins) {
2813
2817
  const headers = new Headers;
2814
- addCorsHeaders(headers);
2818
+ addCorsHeaders(headers, true);
2815
2819
  return new Response(null, { status: 204, headers });
2816
2820
  }
2817
2821
  return new Response(null, { status: 405 });
@@ -4846,4 +4850,4 @@ export {
4846
4850
  ARROW_CONTENT_TYPE
4847
4851
  };
4848
4852
 
4849
- //# debugId=3A314BDDE11985E664756E2164756E21
4853
+ //# debugId=3B7AFF468BF99FC764756E2164756E21