@rayselfs/cf-rule-engine 1.8.2 → 1.9.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/adapters/lambda-edge.cjs +2 -2
- package/dist/adapters/lambda-edge.js +1 -1
- package/dist/adapters/viewer-request-async.cjs +26 -0
- package/dist/adapters/viewer-request-async.d.cts +28 -0
- package/dist/adapters/viewer-request-async.d.ts +28 -0
- package/dist/adapters/viewer-request-async.js +26 -0
- package/dist/behaviors/construct-response.d.cts +2 -2
- package/dist/behaviors/construct-response.d.ts +2 -2
- package/dist/behaviors/image-optimize.d.cts +24 -13
- package/dist/behaviors/image-optimize.d.ts +24 -13
- package/dist/behaviors/index.cjs +12 -11
- package/dist/behaviors/index.d.cts +2 -2
- package/dist/behaviors/index.d.ts +2 -2
- package/dist/behaviors/index.js +11 -10
- package/dist/behaviors/kvs.cjs +24 -0
- package/dist/behaviors/kvs.d.cts +34 -0
- package/dist/behaviors/kvs.d.ts +34 -0
- package/dist/behaviors/kvs.js +24 -0
- package/dist/behaviors/redirect.d.cts +2 -2
- package/dist/behaviors/redirect.d.ts +2 -2
- package/dist/behaviors/rewrite-uri.cjs +2 -2
- package/dist/behaviors/rewrite-uri.js +1 -1
- package/dist/behaviors/set-cors-headers.cjs +3 -2
- package/dist/behaviors/set-cors-headers.d.cts +5 -22
- package/dist/behaviors/set-cors-headers.d.ts +5 -22
- package/dist/behaviors/set-cors-headers.js +2 -1
- package/dist/behaviors/set-csp.d.cts +2 -2
- package/dist/behaviors/set-csp.d.ts +2 -2
- package/dist/behaviors/set-security-headers.d.cts +2 -2
- package/dist/behaviors/set-security-headers.d.ts +2 -2
- package/dist/{chunk-ORW3KDO5.js → chunk-7EA7GFWX.js} +4 -7
- package/dist/{chunk-MRPTC74I.cjs → chunk-BSH5JZBL.cjs} +4 -2
- package/dist/{chunk-2DE6WPPL.js → chunk-EEZ7NUJG.js} +12 -1
- package/dist/{chunk-PBR6AREG.cjs → chunk-EMDI676G.cjs} +7 -10
- package/dist/{chunk-3BBLG4IX.cjs → chunk-G4JEAL6L.cjs} +11 -8
- package/dist/{chunk-CQA2DCVF.js → chunk-H3RK4USR.js} +4 -6
- package/dist/{chunk-RL7ZETZR.js → chunk-IHDSTTO2.js} +5 -5
- package/dist/{chunk-AEZDDJEW.cjs → chunk-IHVOAORH.cjs} +6 -8
- package/dist/{chunk-T5EXFHVA.cjs → chunk-ISXKMJCN.cjs} +5 -5
- package/dist/{chunk-MVGYPBYB.cjs → chunk-LVOM5GJ6.cjs} +2 -2
- package/dist/{chunk-D47P7HVZ.cjs → chunk-MK4QBCD5.cjs} +2 -2
- package/dist/chunk-NWRGD3AH.js +71 -0
- package/dist/{chunk-FTP7NLKX.js → chunk-QVY6REMD.js} +4 -2
- package/dist/{chunk-IBXAK2A4.cjs → chunk-ULICUDDH.cjs} +12 -1
- package/dist/{chunk-WEBU4R5C.js → chunk-ULR7EP5D.js} +11 -8
- package/dist/{chunk-S2AAATFN.js → chunk-VQGBRWJK.js} +1 -1
- package/dist/chunk-WZKRNMF2.cjs +71 -0
- package/dist/{chunk-LO2BO3RU.js → chunk-Y7TIDVVC.js} +1 -1
- package/dist/{chunk-KW5YBTSD.js → chunk-YHTUV2SA.js} +1 -1
- package/dist/{chunk-CF5PWWTF.cjs → chunk-ZEFLAOTL.cjs} +2 -2
- package/dist/core/types.d.cts +8 -8
- package/dist/core/types.d.ts +8 -8
- package/dist/criteria/file-extension.d.cts +3 -3
- package/dist/criteria/file-extension.d.ts +3 -3
- package/dist/criteria/index.cjs +8 -8
- package/dist/criteria/index.js +7 -7
- package/dist/criteria/ip-cidr.cjs +3 -3
- package/dist/criteria/ip-cidr.js +2 -2
- package/dist/criteria/kvs.cjs +14 -0
- package/dist/criteria/kvs.d.cts +34 -0
- package/dist/criteria/kvs.d.ts +34 -0
- package/dist/criteria/kvs.js +14 -0
- package/dist/criteria/path-matches.cjs +3 -3
- package/dist/criteria/path-matches.js +2 -2
- package/dist/criteria/user-agent-matches.cjs +3 -3
- package/dist/criteria/user-agent-matches.js +2 -2
- package/dist/helpers/index.cjs +10 -10
- package/dist/helpers/index.js +10 -10
- package/dist/helpers/preflight-request.cjs +4 -3
- package/dist/helpers/preflight-request.js +3 -2
- package/dist/helpers/whitelist.cjs +7 -7
- package/dist/helpers/whitelist.d.cts +2 -2
- package/dist/helpers/whitelist.d.ts +2 -2
- package/dist/helpers/whitelist.js +6 -6
- package/dist/index.cjs +2 -2
- package/dist/index.js +1 -1
- package/dist/shared/cidr.cjs +2 -2
- package/dist/shared/cidr.d.cts +2 -2
- package/dist/shared/cidr.d.ts +2 -2
- package/dist/shared/cidr.js +1 -1
- package/dist/shared/kvs.cjs +1 -0
- package/dist/shared/kvs.d.cts +10 -0
- package/dist/shared/kvs.d.ts +10 -0
- package/dist/shared/kvs.js +0 -0
- package/dist/shared/wildcard.cjs +4 -2
- package/dist/shared/wildcard.d.cts +10 -1
- package/dist/shared/wildcard.d.ts +10 -1
- package/dist/shared/wildcard.js +3 -1
- package/package.json +1 -1
- package/dist/chunk-LNQPYKGG.js +0 -20
- package/dist/chunk-YVUR35RN.cjs +0 -20
|
@@ -3,7 +3,7 @@ import { Rule } from '../core/types.js';
|
|
|
3
3
|
/**
|
|
4
4
|
* Configuration options for the IP/User-Agent access whitelist.
|
|
5
5
|
*/
|
|
6
|
-
|
|
6
|
+
type WhitelistOptions = {
|
|
7
7
|
/**
|
|
8
8
|
* CIDR ranges to allow (e.g. office IPs, VPN, stage VPCs).
|
|
9
9
|
* At least one of `cidrs` or `userAgents` must be non-empty, otherwise
|
|
@@ -32,7 +32,7 @@ interface WhitelistOptions {
|
|
|
32
32
|
* @example `['/api/health', '/public/*']`
|
|
33
33
|
*/
|
|
34
34
|
bypassPaths?: string[];
|
|
35
|
-
}
|
|
35
|
+
};
|
|
36
36
|
/**
|
|
37
37
|
* Creates a `Rule` that restricts access by IP CIDR range and/or User-Agent
|
|
38
38
|
* pattern. Any request that does not match an allowed CIDR or User-Agent
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
whitelist
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import "../chunk-
|
|
5
|
-
import "../chunk-
|
|
6
|
-
import "../chunk-
|
|
7
|
-
import "../chunk-
|
|
8
|
-
import "../chunk-
|
|
3
|
+
} from "../chunk-IHDSTTO2.js";
|
|
4
|
+
import "../chunk-Y7TIDVVC.js";
|
|
5
|
+
import "../chunk-VQGBRWJK.js";
|
|
6
|
+
import "../chunk-YHTUV2SA.js";
|
|
7
|
+
import "../chunk-NWRGD3AH.js";
|
|
8
|
+
import "../chunk-EEZ7NUJG.js";
|
|
9
9
|
import "../chunk-DSSFFJWL.js";
|
|
10
10
|
import "../chunk-Q4NP4C3B.js";
|
|
11
11
|
import "../chunk-MLKGABMK.js";
|
package/dist/index.cjs
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
var _chunk5ZIB3AJ7cjs = require('./chunk-5ZIB3AJ7.cjs');
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
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 =
|
|
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
package/dist/shared/cidr.cjs
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var _chunkWZKRNMF2cjs = require('../chunk-WZKRNMF2.cjs');
|
|
6
6
|
require('../chunk-75ZPJI57.cjs');
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
exports.inCidr =
|
|
11
|
+
exports.inCidr = _chunkWZKRNMF2cjs.inCidr; exports.ipToInt = _chunkWZKRNMF2cjs.ipToInt; exports.matchesAnyCidr = _chunkWZKRNMF2cjs.matchesAnyCidr;
|
package/dist/shared/cidr.d.cts
CHANGED
|
@@ -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
|
|
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 };
|
package/dist/shared/cidr.d.ts
CHANGED
|
@@ -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
|
|
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 };
|
package/dist/shared/cidr.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal interface for a CloudFront KeyValueStore handle.
|
|
3
|
+
* Compatible with the handle returned by `CloudFront.createKeyValueStore(event)`
|
|
4
|
+
* in the CF Function runtime.
|
|
5
|
+
*/
|
|
6
|
+
type KvsHandle = {
|
|
7
|
+
get(key: string): Promise<string | undefined>;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export type { KvsHandle };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal interface for a CloudFront KeyValueStore handle.
|
|
3
|
+
* Compatible with the handle returned by `CloudFront.createKeyValueStore(event)`
|
|
4
|
+
* in the CF Function runtime.
|
|
5
|
+
*/
|
|
6
|
+
type KvsHandle = {
|
|
7
|
+
get(key: string): Promise<string | undefined>;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export type { KvsHandle };
|
|
File without changes
|
package/dist/shared/wildcard.cjs
CHANGED
|
@@ -2,10 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
|
|
6
|
+
var _chunkULICUDDHcjs = require('../chunk-ULICUDDH.cjs');
|
|
6
7
|
require('../chunk-75ZPJI57.cjs');
|
|
7
8
|
|
|
8
9
|
|
|
9
10
|
|
|
10
11
|
|
|
11
|
-
|
|
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 };
|
package/dist/shared/wildcard.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
matchesAnyWildcard,
|
|
3
|
+
matchesOriginPattern,
|
|
3
4
|
matchesWildcard,
|
|
4
5
|
wildcardToRegex
|
|
5
|
-
} from "../chunk-
|
|
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
package/dist/chunk-LNQPYKGG.js
DELETED
|
@@ -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
|
-
};
|
package/dist/chunk-YVUR35RN.cjs
DELETED
|
@@ -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;
|