@rayselfs/cf-rule-engine 1.8.0 → 1.8.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.
Files changed (34) hide show
  1. package/README.md +3 -1
  2. package/dist/adapters/cf-function.cjs +4 -4
  3. package/dist/adapters/cf-function.js +3 -3
  4. package/dist/adapters/viewer-request.cjs +3 -3
  5. package/dist/adapters/viewer-request.js +2 -2
  6. package/dist/behaviors/index.cjs +13 -13
  7. package/dist/behaviors/index.js +12 -12
  8. package/dist/behaviors/set-cors-headers.cjs +2 -2
  9. package/dist/behaviors/set-cors-headers.d.cts +15 -5
  10. package/dist/behaviors/set-cors-headers.d.ts +15 -5
  11. package/dist/behaviors/set-cors-headers.js +1 -1
  12. package/dist/{chunk-3VYYXEER.js → chunk-CLDF6FM5.js} +5 -5
  13. package/dist/{chunk-PR5UQJCC.js → chunk-MTZ35AIR.js} +1 -1
  14. package/dist/{chunk-SRA2DFKG.js → chunk-PI7RKMGS.js} +2 -2
  15. package/dist/{chunk-45SNLNLR.cjs → chunk-PW4FKMJ2.cjs} +7 -7
  16. package/dist/{chunk-5ZIB3AJ7.cjs → chunk-SYPOHDLN.cjs} +2 -2
  17. package/dist/{chunk-WAKA4OJD.cjs → chunk-XWJEVLMZ.cjs} +2 -2
  18. package/dist/criteria/index.cjs +12 -12
  19. package/dist/criteria/index.js +12 -12
  20. package/dist/helpers/index.cjs +9 -9
  21. package/dist/helpers/index.js +8 -8
  22. package/dist/helpers/preflight-request.cjs +3 -3
  23. package/dist/helpers/preflight-request.d.cts +2 -2
  24. package/dist/helpers/preflight-request.d.ts +2 -2
  25. package/dist/helpers/preflight-request.js +2 -2
  26. package/dist/helpers/whitelist.cjs +3 -3
  27. package/dist/helpers/whitelist.js +2 -2
  28. package/dist/index.cjs +7 -7
  29. package/dist/index.js +5 -5
  30. package/package.json +1 -1
  31. package/dist/{chunk-SGN2N3WI.cjs → chunk-FK3B4SP5.cjs} +2 -2
  32. package/dist/{chunk-BJZPAQHW.js → chunk-I2GJR6LY.js} +3 -3
  33. package/dist/{chunk-ER2YEZZO.js → chunk-RL7ZETZR.js} +3 -3
  34. package/dist/{chunk-MO7HW25R.cjs → chunk-T5EXFHVA.cjs} +3 -3
package/README.md CHANGED
@@ -136,7 +136,9 @@ setCorsHeaders({ allowedOrigins: ['https://*.viverse.com', 'https://sdk-api.vive
136
136
  setCorsHeaders({ allowedOrigins: ORIGIN_ECHO, allowCredentials: true })
137
137
  ```
138
138
 
139
- `allowedMethods` and `allowedHeaders` are optional omit to exclude those headers from the response.
139
+ `allowedMethods` accepts a `Methods[]` array (e.g. `['GET', 'POST', 'OPTIONS']`); items are joined with `, ` to form the header value.
140
+ `allowedHeaders` accepts a `string[]` array (e.g. `['Content-Type', 'Authorization']`); items are joined with `, `.
141
+ Both are optional — omit to exclude those headers from the response.
140
142
 
141
143
  ## Helpers (`@rayselfs/cf-rule-engine/helpers/index`)
142
144
 
@@ -1,14 +1,14 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});require('../chunk-5ZIB3AJ7.cjs');
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});require('../chunk-SYPOHDLN.cjs');
2
2
 
3
3
 
4
- var _chunkSGN2N3WIcjs = require('../chunk-SGN2N3WI.cjs');
5
- require('../chunk-WKYMSRCD.cjs');
4
+ var _chunkFK3B4SP5cjs = require('../chunk-FK3B4SP5.cjs');
6
5
 
7
6
 
8
7
  var _chunkN6QAQALUcjs = require('../chunk-N6QAQALU.cjs');
9
8
  require('../chunk-6NFAPLQ7.cjs');
9
+ require('../chunk-WKYMSRCD.cjs');
10
10
  require('../chunk-75ZPJI57.cjs');
11
11
 
12
12
 
13
13
 
14
- exports.defineViewerRequest = _chunkSGN2N3WIcjs.defineViewerRequest; exports.defineViewerResponse = _chunkN6QAQALUcjs.defineViewerResponse;
14
+ exports.defineViewerRequest = _chunkFK3B4SP5cjs.defineViewerRequest; exports.defineViewerResponse = _chunkN6QAQALUcjs.defineViewerResponse;
@@ -1,12 +1,12 @@
1
- import "../chunk-PR5UQJCC.js";
1
+ import "../chunk-MTZ35AIR.js";
2
2
  import {
3
3
  defineViewerRequest
4
- } from "../chunk-BJZPAQHW.js";
5
- import "../chunk-Q4NP4C3B.js";
4
+ } from "../chunk-I2GJR6LY.js";
6
5
  import {
7
6
  defineViewerResponse
8
7
  } from "../chunk-TURH5IFN.js";
9
8
  import "../chunk-CQ7YZ3AR.js";
9
+ import "../chunk-Q4NP4C3B.js";
10
10
  import "../chunk-MLKGABMK.js";
11
11
  export {
12
12
  defineViewerRequest,
@@ -1,9 +1,9 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkSGN2N3WIcjs = require('../chunk-SGN2N3WI.cjs');
4
- require('../chunk-WKYMSRCD.cjs');
3
+ var _chunkFK3B4SP5cjs = require('../chunk-FK3B4SP5.cjs');
5
4
  require('../chunk-6NFAPLQ7.cjs');
5
+ require('../chunk-WKYMSRCD.cjs');
6
6
  require('../chunk-75ZPJI57.cjs');
7
7
 
8
8
 
9
- exports.defineViewerRequest = _chunkSGN2N3WIcjs.defineViewerRequest;
9
+ exports.defineViewerRequest = _chunkFK3B4SP5cjs.defineViewerRequest;
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  defineViewerRequest
3
- } from "../chunk-BJZPAQHW.js";
4
- import "../chunk-Q4NP4C3B.js";
3
+ } from "../chunk-I2GJR6LY.js";
5
4
  import "../chunk-CQ7YZ3AR.js";
5
+ import "../chunk-Q4NP4C3B.js";
6
6
  import "../chunk-MLKGABMK.js";
7
7
  export {
8
8
  defineViewerRequest
@@ -1,5 +1,11 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
2
 
3
+ var _chunkXWJEVLMZcjs = require('../chunk-XWJEVLMZ.cjs');
4
+
5
+
6
+ var _chunkZXS23HXAcjs = require('../chunk-ZXS23HXA.cjs');
7
+
8
+
3
9
  var _chunkPPUHEL4Hcjs = require('../chunk-PPUHEL4H.cjs');
4
10
 
5
11
 
@@ -12,6 +18,12 @@ var _chunk3UXNXJ6Ncjs = require('../chunk-3UXNXJ6N.cjs');
12
18
  var _chunkMSES76XKcjs = require('../chunk-MSES76XK.cjs');
13
19
 
14
20
 
21
+ var _chunkJU5WX5RUcjs = require('../chunk-JU5WX5RU.cjs');
22
+
23
+
24
+ var _chunkLTLBEBKLcjs = require('../chunk-LTLBEBKL.cjs');
25
+
26
+
15
27
  var _chunkKXC6ES3Bcjs = require('../chunk-KXC6ES3B.cjs');
16
28
 
17
29
 
@@ -27,19 +39,7 @@ var _chunkMRPTC74Icjs = require('../chunk-MRPTC74I.cjs');
27
39
  var _chunkCV234DQTcjs = require('../chunk-CV234DQT.cjs');
28
40
 
29
41
 
30
- var _chunkWAKA4OJDcjs = require('../chunk-WAKA4OJD.cjs');
31
-
32
-
33
- var _chunkZXS23HXAcjs = require('../chunk-ZXS23HXA.cjs');
34
-
35
-
36
42
  var _chunkOSGZTNTScjs = require('../chunk-OSGZTNTS.cjs');
37
-
38
-
39
- var _chunkJU5WX5RUcjs = require('../chunk-JU5WX5RU.cjs');
40
-
41
-
42
- var _chunkLTLBEBKLcjs = require('../chunk-LTLBEBKL.cjs');
43
43
  require('../chunk-75ZPJI57.cjs');
44
44
 
45
45
  // src/behaviors/verify-token.ts
@@ -123,4 +123,4 @@ function verifyToken(options) {
123
123
 
124
124
 
125
125
 
126
- exports.constructResponse = _chunkOSGZTNTScjs.constructResponse; exports.copyHeader = _chunkJU5WX5RUcjs.copyHeader; exports.directoryIndex = _chunkLTLBEBKLcjs.directoryIndex; exports.imageOptimize = _chunkKXC6ES3Bcjs.imageOptimize; exports.redirect = _chunkWWSRNCUPcjs.redirect; exports.removeResponseHeaders = _chunkSGEBNQR2cjs.removeResponseHeaders; exports.rewriteUri = _chunkMRPTC74Icjs.rewriteUri; exports.setCacheControl = _chunkCV234DQTcjs.setCacheControl; exports.setCorsHeaders = _chunkWAKA4OJDcjs.setCorsHeaders; exports.setCsp = _chunkZXS23HXAcjs.setCsp; exports.setRequestHeader = _chunkPPUHEL4Hcjs.setRequestHeader; exports.setResponseHeader = _chunkB4WEJSEZcjs.setResponseHeader; exports.setSecurityHeaders = _chunk3UXNXJ6Ncjs.setSecurityHeaders; exports.stripQueryParams = _chunkMSES76XKcjs.stripQueryParams; exports.verifyToken = verifyToken;
126
+ exports.constructResponse = _chunkOSGZTNTScjs.constructResponse; exports.copyHeader = _chunkJU5WX5RUcjs.copyHeader; exports.directoryIndex = _chunkLTLBEBKLcjs.directoryIndex; exports.imageOptimize = _chunkKXC6ES3Bcjs.imageOptimize; exports.redirect = _chunkWWSRNCUPcjs.redirect; exports.removeResponseHeaders = _chunkSGEBNQR2cjs.removeResponseHeaders; exports.rewriteUri = _chunkMRPTC74Icjs.rewriteUri; exports.setCacheControl = _chunkCV234DQTcjs.setCacheControl; exports.setCorsHeaders = _chunkXWJEVLMZcjs.setCorsHeaders; exports.setCsp = _chunkZXS23HXAcjs.setCsp; exports.setRequestHeader = _chunkPPUHEL4Hcjs.setRequestHeader; exports.setResponseHeader = _chunkB4WEJSEZcjs.setResponseHeader; exports.setSecurityHeaders = _chunk3UXNXJ6Ncjs.setSecurityHeaders; exports.stripQueryParams = _chunkMSES76XKcjs.stripQueryParams; exports.verifyToken = verifyToken;
@@ -1,3 +1,9 @@
1
+ import {
2
+ setCorsHeaders
3
+ } from "../chunk-PI7RKMGS.js";
4
+ import {
5
+ setCsp
6
+ } from "../chunk-XUI4Y22M.js";
1
7
  import {
2
8
  setRequestHeader
3
9
  } from "../chunk-M5KUQBDW.js";
@@ -10,6 +16,12 @@ import {
10
16
  import {
11
17
  stripQueryParams
12
18
  } from "../chunk-XPQG5IML.js";
19
+ import {
20
+ copyHeader
21
+ } from "../chunk-BDNPQ7AU.js";
22
+ import {
23
+ directoryIndex
24
+ } from "../chunk-R7WXS7BI.js";
13
25
  import {
14
26
  imageOptimize
15
27
  } from "../chunk-LQRLWDQQ.js";
@@ -25,21 +37,9 @@ import {
25
37
  import {
26
38
  setCacheControl
27
39
  } from "../chunk-ZTMSH34E.js";
28
- import {
29
- setCorsHeaders
30
- } from "../chunk-SRA2DFKG.js";
31
- import {
32
- setCsp
33
- } from "../chunk-XUI4Y22M.js";
34
40
  import {
35
41
  constructResponse
36
42
  } from "../chunk-6DBZBV2M.js";
37
- import {
38
- copyHeader
39
- } from "../chunk-BDNPQ7AU.js";
40
- import {
41
- directoryIndex
42
- } from "../chunk-R7WXS7BI.js";
43
43
  import "../chunk-MLKGABMK.js";
44
44
 
45
45
  // src/behaviors/verify-token.ts
@@ -2,10 +2,10 @@
2
2
 
3
3
 
4
4
 
5
- var _chunkWAKA4OJDcjs = require('../chunk-WAKA4OJD.cjs');
5
+ var _chunkXWJEVLMZcjs = require('../chunk-XWJEVLMZ.cjs');
6
6
  require('../chunk-75ZPJI57.cjs');
7
7
 
8
8
 
9
9
 
10
10
 
11
- exports.ORIGIN_ECHO = _chunkWAKA4OJDcjs.ORIGIN_ECHO; exports.ORIGIN_WILDCARD = _chunkWAKA4OJDcjs.ORIGIN_WILDCARD; exports.setCorsHeaders = _chunkWAKA4OJDcjs.setCorsHeaders;
11
+ exports.ORIGIN_ECHO = _chunkXWJEVLMZcjs.ORIGIN_ECHO; exports.ORIGIN_WILDCARD = _chunkXWJEVLMZcjs.ORIGIN_WILDCARD; exports.setCorsHeaders = _chunkXWJEVLMZcjs.setCorsHeaders;
@@ -16,6 +16,10 @@ type Origin = `https://${string}` | `http://${string}`;
16
16
  * - `ORIGIN_ECHO` (`'echo'`) — echo any request `Origin` if present, skip if none
17
17
  */
18
18
  type OriginPolicy = OriginWildcard | Origin[] | OriginEcho;
19
+ /**
20
+ * Standard HTTP methods allowed in `Access-Control-Allow-Methods`.
21
+ */
22
+ type Methods = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS' | 'TRACE' | 'CONNECT';
19
23
  /**
20
24
  * CORS configuration options for `setCorsHeaders` and `preflightRequest`.
21
25
  */
@@ -25,15 +29,21 @@ interface CorsOptions {
25
29
  */
26
30
  allowedOrigins: OriginPolicy;
27
31
  /**
28
- * Value for the `Access-Control-Allow-Methods` header.
32
+ * HTTP methods to include in `Access-Control-Allow-Methods`.
33
+ * Array items are joined with `, ` before being written to the header.
29
34
  * Omit to exclude the header.
35
+ *
36
+ * @example `['GET', 'POST', 'OPTIONS']`
30
37
  */
31
- allowedMethods?: string;
38
+ allowedMethods?: Methods[];
32
39
  /**
33
- * Value for the `Access-Control-Allow-Headers` header.
40
+ * Header names to include in `Access-Control-Allow-Headers`.
41
+ * Array items are joined with `, ` before being written to the header.
34
42
  * Omit to exclude the header.
43
+ *
44
+ * @example `['Content-Type', 'Authorization']`
35
45
  */
36
- allowedHeaders?: string;
46
+ allowedHeaders?: string[];
37
47
  /**
38
48
  * When `true`, sets `Access-Control-Allow-Credentials: true`.
39
49
  * Use with `ORIGIN_ECHO` or `Origin[]` — browsers reject `*` with credentials.
@@ -74,4 +84,4 @@ interface CorsOptions {
74
84
  */
75
85
  declare function setCorsHeaders(options: CorsOptions): ResponseBehaviorFn;
76
86
 
77
- export { type CorsOptions, ORIGIN_ECHO, ORIGIN_WILDCARD, type Origin, type OriginEcho, type OriginPolicy, type OriginWildcard, setCorsHeaders };
87
+ export { type CorsOptions, type Methods, ORIGIN_ECHO, ORIGIN_WILDCARD, type Origin, type OriginEcho, type OriginPolicy, type OriginWildcard, setCorsHeaders };
@@ -16,6 +16,10 @@ type Origin = `https://${string}` | `http://${string}`;
16
16
  * - `ORIGIN_ECHO` (`'echo'`) — echo any request `Origin` if present, skip if none
17
17
  */
18
18
  type OriginPolicy = OriginWildcard | Origin[] | OriginEcho;
19
+ /**
20
+ * Standard HTTP methods allowed in `Access-Control-Allow-Methods`.
21
+ */
22
+ type Methods = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS' | 'TRACE' | 'CONNECT';
19
23
  /**
20
24
  * CORS configuration options for `setCorsHeaders` and `preflightRequest`.
21
25
  */
@@ -25,15 +29,21 @@ interface CorsOptions {
25
29
  */
26
30
  allowedOrigins: OriginPolicy;
27
31
  /**
28
- * Value for the `Access-Control-Allow-Methods` header.
32
+ * HTTP methods to include in `Access-Control-Allow-Methods`.
33
+ * Array items are joined with `, ` before being written to the header.
29
34
  * Omit to exclude the header.
35
+ *
36
+ * @example `['GET', 'POST', 'OPTIONS']`
30
37
  */
31
- allowedMethods?: string;
38
+ allowedMethods?: Methods[];
32
39
  /**
33
- * Value for the `Access-Control-Allow-Headers` header.
40
+ * Header names to include in `Access-Control-Allow-Headers`.
41
+ * Array items are joined with `, ` before being written to the header.
34
42
  * Omit to exclude the header.
43
+ *
44
+ * @example `['Content-Type', 'Authorization']`
35
45
  */
36
- allowedHeaders?: string;
46
+ allowedHeaders?: string[];
37
47
  /**
38
48
  * When `true`, sets `Access-Control-Allow-Credentials: true`.
39
49
  * Use with `ORIGIN_ECHO` or `Origin[]` — browsers reject `*` with credentials.
@@ -74,4 +84,4 @@ interface CorsOptions {
74
84
  */
75
85
  declare function setCorsHeaders(options: CorsOptions): ResponseBehaviorFn;
76
86
 
77
- export { type CorsOptions, ORIGIN_ECHO, ORIGIN_WILDCARD, type Origin, type OriginEcho, type OriginPolicy, type OriginWildcard, setCorsHeaders };
87
+ export { type CorsOptions, type Methods, ORIGIN_ECHO, ORIGIN_WILDCARD, type Origin, type OriginEcho, type OriginPolicy, type OriginWildcard, setCorsHeaders };
@@ -2,7 +2,7 @@ import {
2
2
  ORIGIN_ECHO,
3
3
  ORIGIN_WILDCARD,
4
4
  setCorsHeaders
5
- } from "../chunk-SRA2DFKG.js";
5
+ } from "../chunk-PI7RKMGS.js";
6
6
  import "../chunk-MLKGABMK.js";
7
7
  export {
8
8
  ORIGIN_ECHO,
@@ -4,7 +4,7 @@ import {
4
4
  import {
5
5
  ORIGIN_ECHO,
6
6
  ORIGIN_WILDCARD
7
- } from "./chunk-SRA2DFKG.js";
7
+ } from "./chunk-PI7RKMGS.js";
8
8
 
9
9
  // src/helpers/preflight-request.ts
10
10
  function matchesOriginPattern(origin, pattern) {
@@ -15,8 +15,8 @@ function matchesOriginPattern(origin, pattern) {
15
15
  }
16
16
  function preflightRequest(options) {
17
17
  const { allowedOrigins } = options;
18
- const allowedMethods = options.allowedMethods ?? "GET, POST, OPTIONS";
19
- const allowedHeaders = options.allowedHeaders ?? "Content-Type, Cache-Control, Pragma, Range";
18
+ const allowedMethods = options.allowedMethods ?? ["GET", "POST", "OPTIONS"];
19
+ const allowedHeaders = options.allowedHeaders ?? ["Content-Type", "Cache-Control", "Pragma", "Range"];
20
20
  const allowCredentials = options.allowCredentials ?? false;
21
21
  const maxAge = options.maxAge;
22
22
  return {
@@ -35,8 +35,8 @@ function preflightRequest(options) {
35
35
  }
36
36
  const headers = {
37
37
  "cache-control": { value: "no-store" },
38
- "access-control-allow-methods": { value: allowedMethods },
39
- "access-control-allow-headers": { value: allowedHeaders }
38
+ "access-control-allow-methods": { value: allowedMethods.join(", ") },
39
+ "access-control-allow-headers": { value: allowedHeaders.join(", ") }
40
40
  };
41
41
  if (allowOrigin !== void 0) {
42
42
  headers["access-control-allow-origin"] = { value: allowOrigin };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  defineViewerRequest
3
- } from "./chunk-BJZPAQHW.js";
3
+ } from "./chunk-I2GJR6LY.js";
4
4
  import {
5
5
  defineViewerResponse
6
6
  } from "./chunk-TURH5IFN.js";
@@ -26,10 +26,10 @@ function setCorsHeaders(options) {
26
26
  "access-control-allow-origin": { value: allowOrigin }
27
27
  };
28
28
  if (options.allowedMethods !== void 0) {
29
- corsHeaders["access-control-allow-methods"] = { value: options.allowedMethods };
29
+ corsHeaders["access-control-allow-methods"] = { value: options.allowedMethods.join(", ") };
30
30
  }
31
31
  if (options.allowedHeaders !== void 0) {
32
- corsHeaders["access-control-allow-headers"] = { value: options.allowedHeaders };
32
+ corsHeaders["access-control-allow-headers"] = { value: options.allowedHeaders.join(", ") };
33
33
  }
34
34
  if (options.allowCredentials) {
35
35
  corsHeaders["access-control-allow-credentials"] = { value: "true" };
@@ -4,7 +4,7 @@ var _chunkOTFDML3Kcjs = require('./chunk-OTFDML3K.cjs');
4
4
 
5
5
 
6
6
 
7
- var _chunkWAKA4OJDcjs = require('./chunk-WAKA4OJD.cjs');
7
+ var _chunkXWJEVLMZcjs = require('./chunk-XWJEVLMZ.cjs');
8
8
 
9
9
  // src/helpers/preflight-request.ts
10
10
  function matchesOriginPattern(origin, pattern) {
@@ -15,17 +15,17 @@ function matchesOriginPattern(origin, pattern) {
15
15
  }
16
16
  function preflightRequest(options) {
17
17
  const { allowedOrigins } = options;
18
- const allowedMethods = _nullishCoalesce(options.allowedMethods, () => ( "GET, POST, OPTIONS"));
19
- const allowedHeaders = _nullishCoalesce(options.allowedHeaders, () => ( "Content-Type, Cache-Control, Pragma, Range"));
18
+ const allowedMethods = _nullishCoalesce(options.allowedMethods, () => ( ["GET", "POST", "OPTIONS"]));
19
+ const allowedHeaders = _nullishCoalesce(options.allowedHeaders, () => ( ["Content-Type", "Cache-Control", "Pragma", "Range"]));
20
20
  const allowCredentials = _nullishCoalesce(options.allowCredentials, () => ( false));
21
21
  const maxAge = options.maxAge;
22
22
  return {
23
23
  criteria: _chunkOTFDML3Kcjs.methodIs.call(void 0, ["OPTIONS"]),
24
24
  behavior: (request) => {
25
25
  let allowOrigin;
26
- if (allowedOrigins === _chunkWAKA4OJDcjs.ORIGIN_WILDCARD) {
26
+ if (allowedOrigins === _chunkXWJEVLMZcjs.ORIGIN_WILDCARD) {
27
27
  allowOrigin = "*";
28
- } else if (allowedOrigins === _chunkWAKA4OJDcjs.ORIGIN_ECHO) {
28
+ } else if (allowedOrigins === _chunkXWJEVLMZcjs.ORIGIN_ECHO) {
29
29
  allowOrigin = _optionalChain([request, 'access', _ => _.headers, 'access', _2 => _2["origin"], 'optionalAccess', _3 => _3.value]);
30
30
  } else {
31
31
  const originHeader = _optionalChain([request, 'access', _4 => _4.headers, 'access', _5 => _5["origin"], 'optionalAccess', _6 => _6.value]);
@@ -35,8 +35,8 @@ function preflightRequest(options) {
35
35
  }
36
36
  const headers = {
37
37
  "cache-control": { value: "no-store" },
38
- "access-control-allow-methods": { value: allowedMethods },
39
- "access-control-allow-headers": { value: allowedHeaders }
38
+ "access-control-allow-methods": { value: allowedMethods.join(", ") },
39
+ "access-control-allow-headers": { value: allowedHeaders.join(", ") }
40
40
  };
41
41
  if (allowOrigin !== void 0) {
42
42
  headers["access-control-allow-origin"] = { value: allowOrigin };
@@ -1,6 +1,6 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkSGN2N3WIcjs = require('./chunk-SGN2N3WI.cjs');
3
+ var _chunkFK3B4SP5cjs = require('./chunk-FK3B4SP5.cjs');
4
4
 
5
5
 
6
6
  var _chunkN6QAQALUcjs = require('./chunk-N6QAQALU.cjs');
@@ -11,7 +11,7 @@ var _chunk75ZPJI57cjs = require('./chunk-75ZPJI57.cjs');
11
11
  // src/adapters/cf-function.ts
12
12
  var cf_function_exports = {};
13
13
  _chunk75ZPJI57cjs.__export.call(void 0, cf_function_exports, {
14
- defineViewerRequest: () => _chunkSGN2N3WIcjs.defineViewerRequest,
14
+ defineViewerRequest: () => _chunkFK3B4SP5cjs.defineViewerRequest,
15
15
  defineViewerResponse: () => _chunkN6QAQALUcjs.defineViewerResponse
16
16
  });
17
17
 
@@ -26,10 +26,10 @@ function setCorsHeaders(options) {
26
26
  "access-control-allow-origin": { value: allowOrigin }
27
27
  };
28
28
  if (options.allowedMethods !== void 0) {
29
- corsHeaders["access-control-allow-methods"] = { value: options.allowedMethods };
29
+ corsHeaders["access-control-allow-methods"] = { value: options.allowedMethods.join(", ") };
30
30
  }
31
31
  if (options.allowedHeaders !== void 0) {
32
- corsHeaders["access-control-allow-headers"] = { value: options.allowedHeaders };
32
+ corsHeaders["access-control-allow-headers"] = { value: options.allowedHeaders.join(", ") };
33
33
  }
34
34
  if (options.allowCredentials) {
35
35
  corsHeaders["access-control-allow-credentials"] = { value: "true" };
@@ -1,5 +1,17 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
+ var _chunkG7JGTBTTcjs = require('../chunk-G7JGTBTT.cjs');
4
+
5
+
6
+ var _chunkMVGYPBYBcjs = require('../chunk-MVGYPBYB.cjs');
7
+
8
+
9
+ var _chunk32SMWYAFcjs = require('../chunk-32SMWYAF.cjs');
10
+
11
+
12
+ var _chunkL7NBJ4JAcjs = require('../chunk-L7NBJ4JA.cjs');
13
+
14
+
3
15
  var _chunkJGJW7D2Ncjs = require('../chunk-JGJW7D2N.cjs');
4
16
 
5
17
 
@@ -14,12 +26,6 @@ var _chunkVEEOQ7TScjs = require('../chunk-VEEOQ7TS.cjs');
14
26
 
15
27
 
16
28
  var _chunkCF5PWWTFcjs = require('../chunk-CF5PWWTF.cjs');
17
-
18
-
19
- var _chunkG7JGTBTTcjs = require('../chunk-G7JGTBTT.cjs');
20
-
21
-
22
- var _chunkMVGYPBYBcjs = require('../chunk-MVGYPBYB.cjs');
23
29
  require('../chunk-IBXAK2A4.cjs');
24
30
 
25
31
 
@@ -27,12 +33,6 @@ var _chunkOSZWDCTScjs = require('../chunk-OSZWDCTS.cjs');
27
33
 
28
34
 
29
35
  var _chunkU54FZCOHcjs = require('../chunk-U54FZCOH.cjs');
30
-
31
-
32
- var _chunk32SMWYAFcjs = require('../chunk-32SMWYAF.cjs');
33
-
34
-
35
- var _chunkL7NBJ4JAcjs = require('../chunk-L7NBJ4JA.cjs');
36
36
  require('../chunk-75ZPJI57.cjs');
37
37
 
38
38
 
@@ -1,3 +1,15 @@
1
+ import {
2
+ pathPrefix
3
+ } from "../chunk-XLSZ5RB7.js";
4
+ import {
5
+ userAgentMatches
6
+ } from "../chunk-S2AAATFN.js";
7
+ import {
8
+ headerContains
9
+ } from "../chunk-SRQF5UEJ.js";
10
+ import {
11
+ headerEquals
12
+ } from "../chunk-BZQJYOU2.js";
1
13
  import {
2
14
  hostnameIs
3
15
  } from "../chunk-3PVDUC5M.js";
@@ -14,12 +26,6 @@ import {
14
26
  import {
15
27
  pathMatches
16
28
  } from "../chunk-LO2BO3RU.js";
17
- import {
18
- pathPrefix
19
- } from "../chunk-XLSZ5RB7.js";
20
- import {
21
- userAgentMatches
22
- } from "../chunk-S2AAATFN.js";
23
29
  import "../chunk-2DE6WPPL.js";
24
30
  import {
25
31
  countryIs
@@ -27,12 +33,6 @@ import {
27
33
  import {
28
34
  fileExtension
29
35
  } from "../chunk-LBJUCJF2.js";
30
- import {
31
- headerContains
32
- } from "../chunk-SRQF5UEJ.js";
33
- import {
34
- headerEquals
35
- } from "../chunk-BZQJYOU2.js";
36
36
  import "../chunk-MLKGABMK.js";
37
37
  export {
38
38
  countryIs,
@@ -1,28 +1,28 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunk45SNLNLRcjs = require('../chunk-45SNLNLR.cjs');
3
+ var _chunkPW4FKMJ2cjs = require('../chunk-PW4FKMJ2.cjs');
4
4
 
5
5
 
6
6
  var _chunkLSCC62CZcjs = require('../chunk-LSCC62CZ.cjs');
7
7
 
8
8
 
9
- var _chunkMO7HW25Rcjs = require('../chunk-MO7HW25R.cjs');
9
+ var _chunkT5EXFHVAcjs = require('../chunk-T5EXFHVA.cjs');
10
+ require('../chunk-MVGYPBYB.cjs');
11
+
12
+
13
+ var _chunkL7NBJ4JAcjs = require('../chunk-L7NBJ4JA.cjs');
10
14
  require('../chunk-D47P7HVZ.cjs');
11
15
  require('../chunk-YVUR35RN.cjs');
12
16
  require('../chunk-OTFDML3K.cjs');
13
17
  require('../chunk-CF5PWWTF.cjs');
14
- require('../chunk-MVGYPBYB.cjs');
15
18
  require('../chunk-IBXAK2A4.cjs');
16
-
17
-
18
- var _chunkL7NBJ4JAcjs = require('../chunk-L7NBJ4JA.cjs');
19
+ require('../chunk-XWJEVLMZ.cjs');
19
20
 
20
21
 
21
22
  var _chunkB4WEJSEZcjs = require('../chunk-B4WEJSEZ.cjs');
23
+ require('../chunk-JU5WX5RU.cjs');
22
24
  require('../chunk-WWSRNCUP.cjs');
23
- require('../chunk-WAKA4OJD.cjs');
24
25
  require('../chunk-WKYMSRCD.cjs');
25
- require('../chunk-JU5WX5RU.cjs');
26
26
  require('../chunk-75ZPJI57.cjs');
27
27
 
28
28
  // src/helpers/staging-indicator.ts
@@ -40,4 +40,4 @@ function stagingIndicator() {
40
40
 
41
41
 
42
42
 
43
- exports.preflightRequest = _chunk45SNLNLRcjs.preflightRequest; exports.sendCountryCode = _chunkLSCC62CZcjs.sendCountryCode; exports.stagingIndicator = stagingIndicator; exports.whitelist = _chunkMO7HW25Rcjs.whitelist;
43
+ exports.preflightRequest = _chunkPW4FKMJ2cjs.preflightRequest; exports.sendCountryCode = _chunkLSCC62CZcjs.sendCountryCode; exports.stagingIndicator = stagingIndicator; exports.whitelist = _chunkT5EXFHVAcjs.whitelist;
@@ -1,28 +1,28 @@
1
1
  import {
2
2
  preflightRequest
3
- } from "../chunk-3VYYXEER.js";
3
+ } from "../chunk-CLDF6FM5.js";
4
4
  import {
5
5
  sendCountryCode
6
6
  } from "../chunk-C32DL3EP.js";
7
7
  import {
8
8
  whitelist
9
- } from "../chunk-ER2YEZZO.js";
9
+ } from "../chunk-RL7ZETZR.js";
10
+ import "../chunk-S2AAATFN.js";
11
+ import {
12
+ headerEquals
13
+ } from "../chunk-BZQJYOU2.js";
10
14
  import "../chunk-KW5YBTSD.js";
11
15
  import "../chunk-LNQPYKGG.js";
12
16
  import "../chunk-PY3JMRDG.js";
13
17
  import "../chunk-LO2BO3RU.js";
14
- import "../chunk-S2AAATFN.js";
15
18
  import "../chunk-2DE6WPPL.js";
16
- import {
17
- headerEquals
18
- } from "../chunk-BZQJYOU2.js";
19
+ import "../chunk-PI7RKMGS.js";
19
20
  import {
20
21
  setResponseHeader
21
22
  } from "../chunk-RBBKFG5J.js";
23
+ import "../chunk-BDNPQ7AU.js";
22
24
  import "../chunk-DSSFFJWL.js";
23
- import "../chunk-SRA2DFKG.js";
24
25
  import "../chunk-Q4NP4C3B.js";
25
- import "../chunk-BDNPQ7AU.js";
26
26
  import "../chunk-MLKGABMK.js";
27
27
 
28
28
  // src/helpers/staging-indicator.ts
@@ -1,9 +1,9 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunk45SNLNLRcjs = require('../chunk-45SNLNLR.cjs');
3
+ var _chunkPW4FKMJ2cjs = require('../chunk-PW4FKMJ2.cjs');
4
4
  require('../chunk-OTFDML3K.cjs');
5
- require('../chunk-WAKA4OJD.cjs');
5
+ require('../chunk-XWJEVLMZ.cjs');
6
6
  require('../chunk-75ZPJI57.cjs');
7
7
 
8
8
 
9
- exports.preflightRequest = _chunk45SNLNLRcjs.preflightRequest;
9
+ exports.preflightRequest = _chunkPW4FKMJ2cjs.preflightRequest;
@@ -17,8 +17,8 @@ import { CorsOptions } from '../behaviors/set-cors-headers.cjs';
17
17
  *
18
18
  * const CORS: CorsOptions = {
19
19
  * allowedOrigins: ORIGIN_WILDCARD,
20
- * allowedMethods: 'GET, POST, OPTIONS',
21
- * allowedHeaders: 'Content-Type, Cache-Control, Pragma, Range',
20
+ * allowedMethods: ['GET', 'POST', 'OPTIONS'],
21
+ * allowedHeaders: ['Content-Type', 'Cache-Control', 'Pragma', 'Range'],
22
22
  * }
23
23
  *
24
24
  * // viewer-request.ts
@@ -17,8 +17,8 @@ import { CorsOptions } from '../behaviors/set-cors-headers.js';
17
17
  *
18
18
  * const CORS: CorsOptions = {
19
19
  * allowedOrigins: ORIGIN_WILDCARD,
20
- * allowedMethods: 'GET, POST, OPTIONS',
21
- * allowedHeaders: 'Content-Type, Cache-Control, Pragma, Range',
20
+ * allowedMethods: ['GET', 'POST', 'OPTIONS'],
21
+ * allowedHeaders: ['Content-Type', 'Cache-Control', 'Pragma', 'Range'],
22
22
  * }
23
23
  *
24
24
  * // viewer-request.ts
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  preflightRequest
3
- } from "../chunk-3VYYXEER.js";
3
+ } from "../chunk-CLDF6FM5.js";
4
4
  import "../chunk-PY3JMRDG.js";
5
- import "../chunk-SRA2DFKG.js";
5
+ import "../chunk-PI7RKMGS.js";
6
6
  import "../chunk-MLKGABMK.js";
7
7
  export {
8
8
  preflightRequest
@@ -1,14 +1,14 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkMO7HW25Rcjs = require('../chunk-MO7HW25R.cjs');
3
+ var _chunkT5EXFHVAcjs = require('../chunk-T5EXFHVA.cjs');
4
+ require('../chunk-MVGYPBYB.cjs');
4
5
  require('../chunk-D47P7HVZ.cjs');
5
6
  require('../chunk-YVUR35RN.cjs');
6
7
  require('../chunk-CF5PWWTF.cjs');
7
- require('../chunk-MVGYPBYB.cjs');
8
8
  require('../chunk-IBXAK2A4.cjs');
9
9
  require('../chunk-WWSRNCUP.cjs');
10
10
  require('../chunk-WKYMSRCD.cjs');
11
11
  require('../chunk-75ZPJI57.cjs');
12
12
 
13
13
 
14
- exports.whitelist = _chunkMO7HW25Rcjs.whitelist;
14
+ exports.whitelist = _chunkT5EXFHVAcjs.whitelist;
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  whitelist
3
- } from "../chunk-ER2YEZZO.js";
3
+ } from "../chunk-RL7ZETZR.js";
4
+ import "../chunk-S2AAATFN.js";
4
5
  import "../chunk-KW5YBTSD.js";
5
6
  import "../chunk-LNQPYKGG.js";
6
7
  import "../chunk-LO2BO3RU.js";
7
- import "../chunk-S2AAATFN.js";
8
8
  import "../chunk-2DE6WPPL.js";
9
9
  import "../chunk-DSSFFJWL.js";
10
10
  import "../chunk-Q4NP4C3B.js";
package/dist/index.cjs CHANGED
@@ -1,11 +1,12 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});require('./chunk-MEHWLQLR.cjs');
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
-
4
- var _chunk5ZIB3AJ7cjs = require('./chunk-5ZIB3AJ7.cjs');
3
+ var _chunkSYPOHDLNcjs = require('./chunk-SYPOHDLN.cjs');
5
4
 
6
5
 
7
6
  var _chunk3BBLG4IXcjs = require('./chunk-3BBLG4IX.cjs');
8
- require('./chunk-SGN2N3WI.cjs');
7
+ require('./chunk-FK3B4SP5.cjs');
8
+ require('./chunk-N6QAQALU.cjs');
9
+ require('./chunk-6NFAPLQ7.cjs');
9
10
 
10
11
 
11
12
 
@@ -14,8 +15,7 @@ require('./chunk-SGN2N3WI.cjs');
14
15
 
15
16
 
16
17
  var _chunkWKYMSRCDcjs = require('./chunk-WKYMSRCD.cjs');
17
- require('./chunk-N6QAQALU.cjs');
18
- require('./chunk-6NFAPLQ7.cjs');
18
+ require('./chunk-MEHWLQLR.cjs');
19
19
  require('./chunk-75ZPJI57.cjs');
20
20
 
21
21
 
@@ -26,4 +26,4 @@ require('./chunk-75ZPJI57.cjs');
26
26
 
27
27
 
28
28
 
29
- exports.all = _chunkWKYMSRCDcjs.all; exports.any = _chunkWKYMSRCDcjs.any; exports.cfFunction = _chunk5ZIB3AJ7cjs.cf_function_exports; exports.chain = _chunkWKYMSRCDcjs.chain; exports.lambdaEdge = _chunk3BBLG4IXcjs.lambda_edge_exports; exports.not = _chunkWKYMSRCDcjs.not; exports.rule = _chunkWKYMSRCDcjs.rule; exports.runRules = _chunkWKYMSRCDcjs.runRules;
29
+ exports.all = _chunkWKYMSRCDcjs.all; exports.any = _chunkWKYMSRCDcjs.any; exports.cfFunction = _chunkSYPOHDLNcjs.cf_function_exports; exports.chain = _chunkWKYMSRCDcjs.chain; exports.lambdaEdge = _chunk3BBLG4IXcjs.lambda_edge_exports; exports.not = _chunkWKYMSRCDcjs.not; exports.rule = _chunkWKYMSRCDcjs.rule; exports.runRules = _chunkWKYMSRCDcjs.runRules;
package/dist/index.js CHANGED
@@ -1,11 +1,12 @@
1
- import "./chunk-KZ72PI2A.js";
2
1
  import {
3
2
  cf_function_exports
4
- } from "./chunk-PR5UQJCC.js";
3
+ } from "./chunk-MTZ35AIR.js";
5
4
  import {
6
5
  lambda_edge_exports
7
6
  } from "./chunk-WEBU4R5C.js";
8
- import "./chunk-BJZPAQHW.js";
7
+ import "./chunk-I2GJR6LY.js";
8
+ import "./chunk-TURH5IFN.js";
9
+ import "./chunk-CQ7YZ3AR.js";
9
10
  import {
10
11
  all,
11
12
  any,
@@ -14,8 +15,7 @@ import {
14
15
  rule,
15
16
  runRules
16
17
  } from "./chunk-Q4NP4C3B.js";
17
- import "./chunk-TURH5IFN.js";
18
- import "./chunk-CQ7YZ3AR.js";
18
+ import "./chunk-KZ72PI2A.js";
19
19
  import "./chunk-MLKGABMK.js";
20
20
  export {
21
21
  all,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rayselfs/cf-rule-engine",
3
- "version": "1.8.0",
3
+ "version": "1.8.1",
4
4
  "description": "Composable, tree-shakeable CloudFront Function rules",
5
5
  "license": "MIT",
6
6
  "sideEffects": false,
@@ -1,11 +1,11 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
2
2
 
3
- var _chunkWKYMSRCDcjs = require('./chunk-WKYMSRCD.cjs');
4
3
 
5
4
 
5
+ var _chunk6NFAPLQ7cjs = require('./chunk-6NFAPLQ7.cjs');
6
6
 
7
7
 
8
- var _chunk6NFAPLQ7cjs = require('./chunk-6NFAPLQ7.cjs');
8
+ var _chunkWKYMSRCDcjs = require('./chunk-WKYMSRCD.cjs');
9
9
 
10
10
  // src/adapters/viewer-request.ts
11
11
  function defineViewerRequest(rules) {
@@ -1,11 +1,11 @@
1
- import {
2
- runRules
3
- } from "./chunk-Q4NP4C3B.js";
4
1
  import {
5
2
  denormalizeRequest,
6
3
  denormalizeResponse,
7
4
  normalizeRequest
8
5
  } from "./chunk-CQ7YZ3AR.js";
6
+ import {
7
+ runRules
8
+ } from "./chunk-Q4NP4C3B.js";
9
9
 
10
10
  // src/adapters/viewer-request.ts
11
11
  function defineViewerRequest(rules) {
@@ -1,12 +1,12 @@
1
+ import {
2
+ userAgentMatches
3
+ } from "./chunk-S2AAATFN.js";
1
4
  import {
2
5
  ipCidr
3
6
  } from "./chunk-KW5YBTSD.js";
4
7
  import {
5
8
  pathMatches
6
9
  } from "./chunk-LO2BO3RU.js";
7
- import {
8
- userAgentMatches
9
- } from "./chunk-S2AAATFN.js";
10
10
  import {
11
11
  redirect
12
12
  } from "./chunk-DSSFFJWL.js";
@@ -1,12 +1,12 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
2
2
 
3
- var _chunkD47P7HVZcjs = require('./chunk-D47P7HVZ.cjs');
3
+ var _chunkMVGYPBYBcjs = require('./chunk-MVGYPBYB.cjs');
4
4
 
5
5
 
6
- var _chunkCF5PWWTFcjs = require('./chunk-CF5PWWTF.cjs');
6
+ var _chunkD47P7HVZcjs = require('./chunk-D47P7HVZ.cjs');
7
7
 
8
8
 
9
- var _chunkMVGYPBYBcjs = require('./chunk-MVGYPBYB.cjs');
9
+ var _chunkCF5PWWTFcjs = require('./chunk-CF5PWWTF.cjs');
10
10
 
11
11
 
12
12
  var _chunkWWSRNCUPcjs = require('./chunk-WWSRNCUP.cjs');