@rayselfs/cf-rule-engine 1.8.2 → 1.9.0

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 (73) hide show
  1. package/dist/adapters/lambda-edge.cjs +2 -2
  2. package/dist/adapters/lambda-edge.js +1 -1
  3. package/dist/adapters/viewer-request-async.cjs +26 -0
  4. package/dist/adapters/viewer-request-async.d.cts +5 -0
  5. package/dist/adapters/viewer-request-async.d.ts +5 -0
  6. package/dist/adapters/viewer-request-async.js +26 -0
  7. package/dist/behaviors/index.cjs +12 -11
  8. package/dist/behaviors/index.js +11 -10
  9. package/dist/behaviors/kvs.cjs +24 -0
  10. package/dist/behaviors/kvs.d.cts +6 -0
  11. package/dist/behaviors/kvs.d.ts +6 -0
  12. package/dist/behaviors/kvs.js +24 -0
  13. package/dist/behaviors/rewrite-uri.cjs +2 -2
  14. package/dist/behaviors/rewrite-uri.js +1 -1
  15. package/dist/behaviors/set-cors-headers.cjs +3 -2
  16. package/dist/behaviors/set-cors-headers.d.cts +0 -27
  17. package/dist/behaviors/set-cors-headers.d.ts +0 -27
  18. package/dist/behaviors/set-cors-headers.js +2 -1
  19. package/dist/{chunk-ORW3KDO5.js → chunk-7EA7GFWX.js} +4 -7
  20. package/dist/{chunk-MRPTC74I.cjs → chunk-BSH5JZBL.cjs} +4 -2
  21. package/dist/{chunk-2DE6WPPL.js → chunk-EEZ7NUJG.js} +12 -1
  22. package/dist/{chunk-PBR6AREG.cjs → chunk-EMDI676G.cjs} +7 -10
  23. package/dist/{chunk-3BBLG4IX.cjs → chunk-G4JEAL6L.cjs} +11 -8
  24. package/dist/{chunk-CQA2DCVF.js → chunk-H3RK4USR.js} +4 -6
  25. package/dist/{chunk-RL7ZETZR.js → chunk-IHDSTTO2.js} +5 -5
  26. package/dist/{chunk-AEZDDJEW.cjs → chunk-IHVOAORH.cjs} +6 -8
  27. package/dist/{chunk-T5EXFHVA.cjs → chunk-ISXKMJCN.cjs} +5 -5
  28. package/dist/{chunk-MVGYPBYB.cjs → chunk-LVOM5GJ6.cjs} +2 -2
  29. package/dist/{chunk-D47P7HVZ.cjs → chunk-MK4QBCD5.cjs} +2 -2
  30. package/dist/chunk-NWRGD3AH.js +71 -0
  31. package/dist/{chunk-FTP7NLKX.js → chunk-QVY6REMD.js} +4 -2
  32. package/dist/{chunk-IBXAK2A4.cjs → chunk-ULICUDDH.cjs} +12 -1
  33. package/dist/{chunk-WEBU4R5C.js → chunk-ULR7EP5D.js} +11 -8
  34. package/dist/{chunk-S2AAATFN.js → chunk-VQGBRWJK.js} +1 -1
  35. package/dist/chunk-WZKRNMF2.cjs +71 -0
  36. package/dist/{chunk-LO2BO3RU.js → chunk-Y7TIDVVC.js} +1 -1
  37. package/dist/{chunk-KW5YBTSD.js → chunk-YHTUV2SA.js} +1 -1
  38. package/dist/{chunk-CF5PWWTF.cjs → chunk-ZEFLAOTL.cjs} +2 -2
  39. package/dist/criteria/index.cjs +14 -14
  40. package/dist/criteria/index.js +19 -19
  41. package/dist/criteria/ip-cidr.cjs +3 -3
  42. package/dist/criteria/ip-cidr.js +2 -2
  43. package/dist/criteria/kvs.cjs +14 -0
  44. package/dist/criteria/kvs.d.cts +6 -0
  45. package/dist/criteria/kvs.d.ts +6 -0
  46. package/dist/criteria/kvs.js +14 -0
  47. package/dist/criteria/path-matches.cjs +3 -3
  48. package/dist/criteria/path-matches.js +2 -2
  49. package/dist/criteria/user-agent-matches.cjs +3 -3
  50. package/dist/criteria/user-agent-matches.js +2 -2
  51. package/dist/helpers/index.cjs +11 -11
  52. package/dist/helpers/index.js +11 -11
  53. package/dist/helpers/preflight-request.cjs +4 -3
  54. package/dist/helpers/preflight-request.js +3 -2
  55. package/dist/helpers/whitelist.cjs +7 -7
  56. package/dist/helpers/whitelist.js +6 -6
  57. package/dist/index.cjs +2 -2
  58. package/dist/index.js +1 -1
  59. package/dist/shared/cidr.cjs +2 -2
  60. package/dist/shared/cidr.d.cts +2 -2
  61. package/dist/shared/cidr.d.ts +2 -2
  62. package/dist/shared/cidr.js +1 -1
  63. package/dist/shared/kvs.cjs +1 -0
  64. package/dist/shared/kvs.d.cts +5 -0
  65. package/dist/shared/kvs.d.ts +5 -0
  66. package/dist/shared/kvs.js +0 -0
  67. package/dist/shared/wildcard.cjs +4 -2
  68. package/dist/shared/wildcard.d.cts +10 -1
  69. package/dist/shared/wildcard.d.ts +10 -1
  70. package/dist/shared/wildcard.js +3 -1
  71. package/package.json +1 -1
  72. package/dist/chunk-LNQPYKGG.js +0 -20
  73. package/dist/chunk-YVUR35RN.cjs +0 -20
package/dist/index.cjs CHANGED
@@ -4,7 +4,7 @@
4
4
  var _chunk5ZIB3AJ7cjs = require('./chunk-5ZIB3AJ7.cjs');
5
5
 
6
6
 
7
- var _chunk3BBLG4IXcjs = require('./chunk-3BBLG4IX.cjs');
7
+ var _chunkG4JEAL6Lcjs = require('./chunk-G4JEAL6L.cjs');
8
8
  require('./chunk-SGN2N3WI.cjs');
9
9
 
10
10
 
@@ -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 = _chunk5ZIB3AJ7cjs.cf_function_exports; exports.chain = _chunkWKYMSRCDcjs.chain; exports.lambdaEdge = _chunkG4JEAL6Lcjs.lambda_edge_exports; exports.not = _chunkWKYMSRCDcjs.not; exports.rule = _chunkWKYMSRCDcjs.rule; exports.runRules = _chunkWKYMSRCDcjs.runRules;
package/dist/index.js CHANGED
@@ -4,7 +4,7 @@ import {
4
4
  } from "./chunk-PR5UQJCC.js";
5
5
  import {
6
6
  lambda_edge_exports
7
- } from "./chunk-WEBU4R5C.js";
7
+ } from "./chunk-ULR7EP5D.js";
8
8
  import "./chunk-BJZPAQHW.js";
9
9
  import {
10
10
  all,
@@ -2,10 +2,10 @@
2
2
 
3
3
 
4
4
 
5
- var _chunkYVUR35RNcjs = require('../chunk-YVUR35RN.cjs');
5
+ var _chunkWZKRNMF2cjs = require('../chunk-WZKRNMF2.cjs');
6
6
  require('../chunk-75ZPJI57.cjs');
7
7
 
8
8
 
9
9
 
10
10
 
11
- exports.inCidr = _chunkYVUR35RNcjs.inCidr; exports.ipToInt = _chunkYVUR35RNcjs.ipToInt; exports.matchesAnyCidr = _chunkYVUR35RNcjs.matchesAnyCidr;
11
+ exports.inCidr = _chunkWZKRNMF2cjs.inCidr; exports.ipToInt = _chunkWZKRNMF2cjs.ipToInt; exports.matchesAnyCidr = _chunkWZKRNMF2cjs.matchesAnyCidr;
@@ -1,8 +1,8 @@
1
1
  /** Convert IPv4 string to unsigned 32-bit integer */
2
2
  declare function ipToInt(ip: string): number;
3
- /** Returns true if `ip` falls within the `cidr` range (e.g. "10.0.0.0/8") */
3
+ /** Returns true if `ip` falls within the `cidr` range. Supports IPv4 and IPv6. */
4
4
  declare function inCidr(ip: string, cidr: string): boolean;
5
- /** Returns true if `ip` matches ANY of the given CIDR ranges */
5
+ /** Returns true if `ip` matches ANY of the given CIDR ranges. Supports IPv4 and IPv6. */
6
6
  declare function matchesAnyCidr(ip: string, cidrs: string[]): boolean;
7
7
 
8
8
  export { inCidr, ipToInt, matchesAnyCidr };
@@ -1,8 +1,8 @@
1
1
  /** Convert IPv4 string to unsigned 32-bit integer */
2
2
  declare function ipToInt(ip: string): number;
3
- /** Returns true if `ip` falls within the `cidr` range (e.g. "10.0.0.0/8") */
3
+ /** Returns true if `ip` falls within the `cidr` range. Supports IPv4 and IPv6. */
4
4
  declare function inCidr(ip: string, cidr: string): boolean;
5
- /** Returns true if `ip` matches ANY of the given CIDR ranges */
5
+ /** Returns true if `ip` matches ANY of the given CIDR ranges. Supports IPv4 and IPv6. */
6
6
  declare function matchesAnyCidr(ip: string, cidrs: string[]): boolean;
7
7
 
8
8
  export { inCidr, ipToInt, matchesAnyCidr };
@@ -2,7 +2,7 @@ import {
2
2
  inCidr,
3
3
  ipToInt,
4
4
  matchesAnyCidr
5
- } from "../chunk-LNQPYKGG.js";
5
+ } from "../chunk-NWRGD3AH.js";
6
6
  import "../chunk-MLKGABMK.js";
7
7
  export {
8
8
  inCidr,
@@ -0,0 +1 @@
1
+ "use strict";
@@ -0,0 +1,5 @@
1
+ interface KvsHandle {
2
+ get(key: string): Promise<string | undefined>;
3
+ }
4
+
5
+ export type { KvsHandle };
@@ -0,0 +1,5 @@
1
+ interface KvsHandle {
2
+ get(key: string): Promise<string | undefined>;
3
+ }
4
+
5
+ export type { KvsHandle };
File without changes
@@ -2,10 +2,12 @@
2
2
 
3
3
 
4
4
 
5
- var _chunkIBXAK2A4cjs = require('../chunk-IBXAK2A4.cjs');
5
+
6
+ var _chunkULICUDDHcjs = require('../chunk-ULICUDDH.cjs');
6
7
  require('../chunk-75ZPJI57.cjs');
7
8
 
8
9
 
9
10
 
10
11
 
11
- exports.matchesAnyWildcard = _chunkIBXAK2A4cjs.matchesAnyWildcard; exports.matchesWildcard = _chunkIBXAK2A4cjs.matchesWildcard; exports.wildcardToRegex = _chunkIBXAK2A4cjs.wildcardToRegex;
12
+
13
+ exports.matchesAnyWildcard = _chunkULICUDDHcjs.matchesAnyWildcard; exports.matchesOriginPattern = _chunkULICUDDHcjs.matchesOriginPattern; exports.matchesWildcard = _chunkULICUDDHcjs.matchesWildcard; exports.wildcardToRegex = _chunkULICUDDHcjs.wildcardToRegex;
@@ -4,5 +4,14 @@ declare function wildcardToRegex(pattern: string): RegExp;
4
4
  declare function matchesWildcard(str: string, pattern: string): boolean;
5
5
  /** Returns true if `str` matches ANY of the given wildcard patterns */
6
6
  declare function matchesAnyWildcard(str: string, patterns: string[]): boolean;
7
+ /**
8
+ * Returns true if `origin` matches the given origin pattern.
9
+ * - `'*'` matches any origin.
10
+ * - Patterns without `*` are exact-matched (case-sensitive).
11
+ * - Patterns with `*` are converted to a cached RegExp (case-sensitive, `*` maps to `.*`).
12
+ *
13
+ * Unlike `matchesWildcard`, this function is case-sensitive and does not support `?`.
14
+ */
15
+ declare function matchesOriginPattern(origin: string, pattern: string): boolean;
7
16
 
8
- export { matchesAnyWildcard, matchesWildcard, wildcardToRegex };
17
+ export { matchesAnyWildcard, matchesOriginPattern, matchesWildcard, wildcardToRegex };
@@ -4,5 +4,14 @@ declare function wildcardToRegex(pattern: string): RegExp;
4
4
  declare function matchesWildcard(str: string, pattern: string): boolean;
5
5
  /** Returns true if `str` matches ANY of the given wildcard patterns */
6
6
  declare function matchesAnyWildcard(str: string, patterns: string[]): boolean;
7
+ /**
8
+ * Returns true if `origin` matches the given origin pattern.
9
+ * - `'*'` matches any origin.
10
+ * - Patterns without `*` are exact-matched (case-sensitive).
11
+ * - Patterns with `*` are converted to a cached RegExp (case-sensitive, `*` maps to `.*`).
12
+ *
13
+ * Unlike `matchesWildcard`, this function is case-sensitive and does not support `?`.
14
+ */
15
+ declare function matchesOriginPattern(origin: string, pattern: string): boolean;
7
16
 
8
- export { matchesAnyWildcard, matchesWildcard, wildcardToRegex };
17
+ export { matchesAnyWildcard, matchesOriginPattern, matchesWildcard, wildcardToRegex };
@@ -1,11 +1,13 @@
1
1
  import {
2
2
  matchesAnyWildcard,
3
+ matchesOriginPattern,
3
4
  matchesWildcard,
4
5
  wildcardToRegex
5
- } from "../chunk-2DE6WPPL.js";
6
+ } from "../chunk-EEZ7NUJG.js";
6
7
  import "../chunk-MLKGABMK.js";
7
8
  export {
8
9
  matchesAnyWildcard,
10
+ matchesOriginPattern,
9
11
  matchesWildcard,
10
12
  wildcardToRegex
11
13
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rayselfs/cf-rule-engine",
3
- "version": "1.8.2",
3
+ "version": "1.9.0",
4
4
  "description": "Composable, tree-shakeable CloudFront Function rules",
5
5
  "license": "MIT",
6
6
  "sideEffects": false,
@@ -1,20 +0,0 @@
1
- // src/shared/cidr.ts
2
- function ipToInt(ip) {
3
- return ip.split(".").reduce((acc, octet) => (acc << 8) + parseInt(octet, 10) >>> 0, 0);
4
- }
5
- function inCidr(ip, cidr) {
6
- const parts = cidr.split("/");
7
- const range = parts[0];
8
- const bits = parts[1] || "32";
9
- const mask = bits === "0" ? 0 : ~0 << 32 - parseInt(bits, 10) >>> 0;
10
- return (ipToInt(ip) & mask) === (ipToInt(range) & mask);
11
- }
12
- function matchesAnyCidr(ip, cidrs) {
13
- return cidrs.some((cidr) => inCidr(ip, cidr));
14
- }
15
-
16
- export {
17
- ipToInt,
18
- inCidr,
19
- matchesAnyCidr
20
- };
@@ -1,20 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/shared/cidr.ts
2
- function ipToInt(ip) {
3
- return ip.split(".").reduce((acc, octet) => (acc << 8) + parseInt(octet, 10) >>> 0, 0);
4
- }
5
- function inCidr(ip, cidr) {
6
- const parts = cidr.split("/");
7
- const range = parts[0];
8
- const bits = parts[1] || "32";
9
- const mask = bits === "0" ? 0 : ~0 << 32 - parseInt(bits, 10) >>> 0;
10
- return (ipToInt(ip) & mask) === (ipToInt(range) & mask);
11
- }
12
- function matchesAnyCidr(ip, cidrs) {
13
- return cidrs.some((cidr) => inCidr(ip, cidr));
14
- }
15
-
16
-
17
-
18
-
19
-
20
- exports.ipToInt = ipToInt; exports.inCidr = inCidr; exports.matchesAnyCidr = matchesAnyCidr;