@rayselfs/cf-rule-engine 1.6.0 → 1.6.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/README.md +5 -5
- package/dist/adapters/cf-function.d.cts +1 -1
- package/dist/adapters/cf-function.d.ts +1 -1
- package/dist/adapters/viewer-request.cjs +8 -0
- package/dist/adapters/viewer-request.d.cts +2 -0
- package/dist/adapters/viewer-request.d.ts +2 -0
- package/dist/adapters/viewer-request.js +8 -0
- package/dist/adapters/viewer-response.cjs +8 -0
- package/dist/adapters/viewer-response.d.cts +2 -0
- package/dist/adapters/viewer-response.d.ts +2 -0
- package/dist/adapters/viewer-response.js +8 -0
- package/dist/behaviors/index.cjs +9 -9
- package/dist/behaviors/index.js +9 -9
- package/dist/{chunk-UKB5JAX4.js → chunk-RL7ZETZR.js} +8 -8
- package/dist/{chunk-WW7YVRAI.cjs → chunk-T5EXFHVA.cjs} +7 -7
- package/dist/criteria/index.cjs +13 -13
- package/dist/criteria/index.js +15 -15
- package/dist/helpers/index.cjs +8 -8
- package/dist/helpers/index.d.cts +1 -1
- package/dist/helpers/index.d.ts +1 -1
- package/dist/helpers/index.js +9 -9
- package/dist/helpers/{staging-whitelist.cjs → whitelist.cjs} +4 -4
- package/dist/helpers/{staging-whitelist.d.cts → whitelist.d.cts} +11 -11
- package/dist/helpers/{staging-whitelist.d.ts → whitelist.d.ts} +11 -11
- package/dist/helpers/{staging-whitelist.js → whitelist.js} +5 -5
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3 -3
- package/package.json +1 -1
- /package/dist/{cf-function-C9eF2O9s.d.ts → viewer-response-C9eF2O9s.d.ts} +0 -0
- /package/dist/{cf-function-DIQHy8L7.d.cts → viewer-response-DIQHy8L7.d.cts} +0 -0
package/README.md
CHANGED
|
@@ -141,23 +141,23 @@ defineViewerResponse([
|
|
|
141
141
|
|
|
142
142
|
Primary distribution requests do not carry `aws-cf-cd-staging`, so the rule is a no-op there.
|
|
143
143
|
|
|
144
|
-
###
|
|
144
|
+
### whitelist
|
|
145
145
|
|
|
146
|
-
Restricts access
|
|
146
|
+
Restricts access by IP CIDR range and/or User-Agent pattern. Requests that don't match any allowed CIDR or User-Agent (and aren't on a bypassed path) are redirected with HTTP 302.
|
|
147
147
|
|
|
148
148
|
No default allowlists are included — callers must supply all CIDRs and User-Agent patterns explicitly.
|
|
149
149
|
|
|
150
150
|
```typescript
|
|
151
|
-
import {
|
|
151
|
+
import { whitelist } from '@rayselfs/cf-rule-engine/helpers/index'
|
|
152
152
|
|
|
153
|
-
|
|
153
|
+
whitelist({
|
|
154
154
|
cidrs: ['203.0.113.0/24', '10.0.0.0/8'],
|
|
155
155
|
userAgents: ['*InternalBot*', '*Prerender*'],
|
|
156
156
|
redirectUrl: 'https://www.example.com',
|
|
157
157
|
})
|
|
158
158
|
|
|
159
159
|
// With bypass paths:
|
|
160
|
-
|
|
160
|
+
whitelist({
|
|
161
161
|
cidrs: ['203.0.113.0/24'],
|
|
162
162
|
redirectUrl: 'https://www.example.com',
|
|
163
163
|
bypassPaths: ['/api/health', '/robots.txt'],
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import '../core/types.cjs';
|
|
2
|
-
export { d as defineViewerRequest, a as defineViewerResponse } from '../
|
|
2
|
+
export { d as defineViewerRequest, a as defineViewerResponse } from '../viewer-response-DIQHy8L7.cjs';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import '../core/types.js';
|
|
2
|
-
export { d as defineViewerRequest, a as defineViewerResponse } from '../
|
|
2
|
+
export { d as defineViewerRequest, a as defineViewerResponse } from '../viewer-response-C9eF2O9s.js';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
var _chunkSAXDN5NScjs = require('../chunk-SAXDN5NS.cjs');
|
|
4
|
+
require('../chunk-WKYMSRCD.cjs');
|
|
5
|
+
require('../chunk-75ZPJI57.cjs');
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
exports.defineViewerRequest = _chunkSAXDN5NScjs.defineViewerRequest;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
var _chunkSAXDN5NScjs = require('../chunk-SAXDN5NS.cjs');
|
|
4
|
+
require('../chunk-WKYMSRCD.cjs');
|
|
5
|
+
require('../chunk-75ZPJI57.cjs');
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
exports.defineViewerResponse = _chunkSAXDN5NScjs.defineViewerResponse;
|
package/dist/behaviors/index.cjs
CHANGED
|
@@ -1,11 +1,20 @@
|
|
|
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 _chunkPPUHEL4Hcjs = require('../chunk-PPUHEL4H.cjs');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
var _chunkB4WEJSEZcjs = require('../chunk-B4WEJSEZ.cjs');
|
|
7
|
+
|
|
8
|
+
|
|
3
9
|
var _chunkUI6LKDJIcjs = require('../chunk-UI6LKDJI.cjs');
|
|
4
10
|
|
|
5
11
|
|
|
6
12
|
var _chunkMSES76XKcjs = require('../chunk-MSES76XK.cjs');
|
|
7
13
|
|
|
8
14
|
|
|
15
|
+
var _chunkKXC6ES3Bcjs = require('../chunk-KXC6ES3B.cjs');
|
|
16
|
+
|
|
17
|
+
|
|
9
18
|
var _chunkWWSRNCUPcjs = require('../chunk-WWSRNCUP.cjs');
|
|
10
19
|
|
|
11
20
|
|
|
@@ -24,12 +33,6 @@ var _chunkGK5JX7OMcjs = require('../chunk-GK5JX7OM.cjs');
|
|
|
24
33
|
var _chunkZXS23HXAcjs = require('../chunk-ZXS23HXA.cjs');
|
|
25
34
|
|
|
26
35
|
|
|
27
|
-
var _chunkPPUHEL4Hcjs = require('../chunk-PPUHEL4H.cjs');
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
var _chunkB4WEJSEZcjs = require('../chunk-B4WEJSEZ.cjs');
|
|
31
|
-
|
|
32
|
-
|
|
33
36
|
var _chunkOSGZTNTScjs = require('../chunk-OSGZTNTS.cjs');
|
|
34
37
|
|
|
35
38
|
|
|
@@ -37,9 +40,6 @@ var _chunkJU5WX5RUcjs = require('../chunk-JU5WX5RU.cjs');
|
|
|
37
40
|
|
|
38
41
|
|
|
39
42
|
var _chunkLTLBEBKLcjs = require('../chunk-LTLBEBKL.cjs');
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
var _chunkKXC6ES3Bcjs = require('../chunk-KXC6ES3B.cjs');
|
|
43
43
|
require('../chunk-75ZPJI57.cjs');
|
|
44
44
|
|
|
45
45
|
// src/behaviors/verify-token.ts
|
package/dist/behaviors/index.js
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
1
|
+
import {
|
|
2
|
+
setRequestHeader
|
|
3
|
+
} from "../chunk-M5KUQBDW.js";
|
|
4
|
+
import {
|
|
5
|
+
setResponseHeader
|
|
6
|
+
} from "../chunk-RBBKFG5J.js";
|
|
1
7
|
import {
|
|
2
8
|
setSecurityHeaders
|
|
3
9
|
} from "../chunk-VQCRSBWL.js";
|
|
4
10
|
import {
|
|
5
11
|
stripQueryParams
|
|
6
12
|
} from "../chunk-XPQG5IML.js";
|
|
13
|
+
import {
|
|
14
|
+
imageOptimize
|
|
15
|
+
} from "../chunk-LQRLWDQQ.js";
|
|
7
16
|
import {
|
|
8
17
|
redirect
|
|
9
18
|
} from "../chunk-DSSFFJWL.js";
|
|
@@ -22,12 +31,6 @@ import {
|
|
|
22
31
|
import {
|
|
23
32
|
setCsp
|
|
24
33
|
} from "../chunk-XUI4Y22M.js";
|
|
25
|
-
import {
|
|
26
|
-
setRequestHeader
|
|
27
|
-
} from "../chunk-M5KUQBDW.js";
|
|
28
|
-
import {
|
|
29
|
-
setResponseHeader
|
|
30
|
-
} from "../chunk-RBBKFG5J.js";
|
|
31
34
|
import {
|
|
32
35
|
constructResponse
|
|
33
36
|
} from "../chunk-6DBZBV2M.js";
|
|
@@ -37,9 +40,6 @@ import {
|
|
|
37
40
|
import {
|
|
38
41
|
directoryIndex
|
|
39
42
|
} from "../chunk-R7WXS7BI.js";
|
|
40
|
-
import {
|
|
41
|
-
imageOptimize
|
|
42
|
-
} from "../chunk-LQRLWDQQ.js";
|
|
43
43
|
import "../chunk-MLKGABMK.js";
|
|
44
44
|
|
|
45
45
|
// src/behaviors/verify-token.ts
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import {
|
|
2
|
+
userAgentMatches
|
|
3
|
+
} from "./chunk-S2AAATFN.js";
|
|
1
4
|
import {
|
|
2
5
|
ipCidr
|
|
3
6
|
} from "./chunk-KW5YBTSD.js";
|
|
@@ -5,19 +8,16 @@ import {
|
|
|
5
8
|
pathMatches
|
|
6
9
|
} from "./chunk-LO2BO3RU.js";
|
|
7
10
|
import {
|
|
8
|
-
|
|
9
|
-
} from "./chunk-
|
|
11
|
+
redirect
|
|
12
|
+
} from "./chunk-DSSFFJWL.js";
|
|
10
13
|
import {
|
|
11
14
|
all,
|
|
12
15
|
not,
|
|
13
16
|
rule
|
|
14
17
|
} from "./chunk-Q4NP4C3B.js";
|
|
15
|
-
import {
|
|
16
|
-
redirect
|
|
17
|
-
} from "./chunk-DSSFFJWL.js";
|
|
18
18
|
|
|
19
|
-
// src/helpers/
|
|
20
|
-
function
|
|
19
|
+
// src/helpers/whitelist.ts
|
|
20
|
+
function whitelist(options) {
|
|
21
21
|
const userAgents = options.userAgents ?? [];
|
|
22
22
|
const bypassPaths = options.bypassPaths ?? [];
|
|
23
23
|
const criteria = [not(ipCidr(options.cidrs)), not(userAgentMatches(userAgents))];
|
|
@@ -28,5 +28,5 @@ function stagingWhitelist(options) {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
export {
|
|
31
|
-
|
|
31
|
+
whitelist
|
|
32
32
|
};
|
|
@@ -1,23 +1,23 @@
|
|
|
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 _chunkMVGYPBYBcjs = require('./chunk-MVGYPBYB.cjs');
|
|
4
|
+
|
|
5
|
+
|
|
3
6
|
var _chunkD47P7HVZcjs = require('./chunk-D47P7HVZ.cjs');
|
|
4
7
|
|
|
5
8
|
|
|
6
9
|
var _chunkCF5PWWTFcjs = require('./chunk-CF5PWWTF.cjs');
|
|
7
10
|
|
|
8
11
|
|
|
9
|
-
var
|
|
12
|
+
var _chunkWWSRNCUPcjs = require('./chunk-WWSRNCUP.cjs');
|
|
10
13
|
|
|
11
14
|
|
|
12
15
|
|
|
13
16
|
|
|
14
17
|
var _chunkWKYMSRCDcjs = require('./chunk-WKYMSRCD.cjs');
|
|
15
18
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
// src/helpers/staging-whitelist.ts
|
|
20
|
-
function stagingWhitelist(options) {
|
|
19
|
+
// src/helpers/whitelist.ts
|
|
20
|
+
function whitelist(options) {
|
|
21
21
|
const userAgents = _nullishCoalesce(options.userAgents, () => ( []));
|
|
22
22
|
const bypassPaths = _nullishCoalesce(options.bypassPaths, () => ( []));
|
|
23
23
|
const criteria = [_chunkWKYMSRCDcjs.not.call(void 0, _chunkD47P7HVZcjs.ipCidr.call(void 0, options.cidrs)), _chunkWKYMSRCDcjs.not.call(void 0, _chunkMVGYPBYBcjs.userAgentMatches.call(void 0, userAgents))];
|
|
@@ -29,4 +29,4 @@ function stagingWhitelist(options) {
|
|
|
29
29
|
|
|
30
30
|
|
|
31
31
|
|
|
32
|
-
exports.
|
|
32
|
+
exports.whitelist = whitelist;
|
package/dist/criteria/index.cjs
CHANGED
|
@@ -1,38 +1,38 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('../chunk-YVUR35RN.cjs');
|
|
3
|
+
var _chunkG7JGTBTTcjs = require('../chunk-G7JGTBTT.cjs');
|
|
5
4
|
|
|
6
5
|
|
|
7
|
-
var
|
|
6
|
+
var _chunkMVGYPBYBcjs = require('../chunk-MVGYPBYB.cjs');
|
|
8
7
|
|
|
9
8
|
|
|
10
|
-
var
|
|
9
|
+
var _chunk32SMWYAFcjs = require('../chunk-32SMWYAF.cjs');
|
|
11
10
|
|
|
12
11
|
|
|
13
|
-
var
|
|
12
|
+
var _chunkL7NBJ4JAcjs = require('../chunk-L7NBJ4JA.cjs');
|
|
14
13
|
|
|
15
14
|
|
|
16
|
-
var
|
|
15
|
+
var _chunkJGJW7D2Ncjs = require('../chunk-JGJW7D2N.cjs');
|
|
17
16
|
|
|
18
17
|
|
|
19
|
-
var
|
|
20
|
-
require('../chunk-
|
|
18
|
+
var _chunkD47P7HVZcjs = require('../chunk-D47P7HVZ.cjs');
|
|
19
|
+
require('../chunk-YVUR35RN.cjs');
|
|
21
20
|
|
|
22
21
|
|
|
23
|
-
var
|
|
22
|
+
var _chunkOTFDML3Kcjs = require('../chunk-OTFDML3K.cjs');
|
|
24
23
|
|
|
25
24
|
|
|
26
|
-
var
|
|
25
|
+
var _chunkVEEOQ7TScjs = require('../chunk-VEEOQ7TS.cjs');
|
|
27
26
|
|
|
28
27
|
|
|
29
|
-
var
|
|
28
|
+
var _chunkCF5PWWTFcjs = require('../chunk-CF5PWWTF.cjs');
|
|
29
|
+
require('../chunk-IBXAK2A4.cjs');
|
|
30
30
|
|
|
31
31
|
|
|
32
|
-
var
|
|
32
|
+
var _chunkOSZWDCTScjs = require('../chunk-OSZWDCTS.cjs');
|
|
33
33
|
|
|
34
34
|
|
|
35
|
-
var
|
|
35
|
+
var _chunkU54FZCOHcjs = require('../chunk-U54FZCOH.cjs');
|
|
36
36
|
require('../chunk-75ZPJI57.cjs');
|
|
37
37
|
|
|
38
38
|
|
package/dist/criteria/index.js
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
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";
|
|
13
|
+
import {
|
|
14
|
+
hostnameIs
|
|
15
|
+
} from "../chunk-3PVDUC5M.js";
|
|
1
16
|
import {
|
|
2
17
|
ipCidr
|
|
3
18
|
} from "../chunk-KW5YBTSD.js";
|
|
@@ -11,12 +26,6 @@ import {
|
|
|
11
26
|
import {
|
|
12
27
|
pathMatches
|
|
13
28
|
} from "../chunk-LO2BO3RU.js";
|
|
14
|
-
import {
|
|
15
|
-
pathPrefix
|
|
16
|
-
} from "../chunk-XLSZ5RB7.js";
|
|
17
|
-
import {
|
|
18
|
-
userAgentMatches
|
|
19
|
-
} from "../chunk-S2AAATFN.js";
|
|
20
29
|
import "../chunk-2DE6WPPL.js";
|
|
21
30
|
import {
|
|
22
31
|
countryIs
|
|
@@ -24,15 +33,6 @@ import {
|
|
|
24
33
|
import {
|
|
25
34
|
fileExtension
|
|
26
35
|
} from "../chunk-LBJUCJF2.js";
|
|
27
|
-
import {
|
|
28
|
-
headerContains
|
|
29
|
-
} from "../chunk-SRQF5UEJ.js";
|
|
30
|
-
import {
|
|
31
|
-
headerEquals
|
|
32
|
-
} from "../chunk-BZQJYOU2.js";
|
|
33
|
-
import {
|
|
34
|
-
hostnameIs
|
|
35
|
-
} from "../chunk-3PVDUC5M.js";
|
|
36
36
|
import "../chunk-MLKGABMK.js";
|
|
37
37
|
export {
|
|
38
38
|
countryIs,
|
package/dist/helpers/index.cjs
CHANGED
|
@@ -6,21 +6,21 @@ var _chunk63WIEBQBcjs = require('../chunk-63WIEBQB.cjs');
|
|
|
6
6
|
var _chunkLSCC62CZcjs = require('../chunk-LSCC62CZ.cjs');
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
var
|
|
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
19
|
|
|
17
20
|
|
|
18
|
-
var _chunkL7NBJ4JAcjs = require('../chunk-L7NBJ4JA.cjs');
|
|
19
|
-
require('../chunk-WKYMSRCD.cjs');
|
|
20
|
-
require('../chunk-WWSRNCUP.cjs');
|
|
21
|
-
|
|
22
|
-
|
|
23
21
|
var _chunkB4WEJSEZcjs = require('../chunk-B4WEJSEZ.cjs');
|
|
22
|
+
require('../chunk-WWSRNCUP.cjs');
|
|
23
|
+
require('../chunk-WKYMSRCD.cjs');
|
|
24
24
|
require('../chunk-JU5WX5RU.cjs');
|
|
25
25
|
require('../chunk-75ZPJI57.cjs');
|
|
26
26
|
|
|
@@ -39,4 +39,4 @@ function stagingIndicator() {
|
|
|
39
39
|
|
|
40
40
|
|
|
41
41
|
|
|
42
|
-
exports.preflightRequest = _chunk63WIEBQBcjs.preflightRequest; exports.sendCountryCode = _chunkLSCC62CZcjs.sendCountryCode; exports.stagingIndicator = stagingIndicator; exports.
|
|
42
|
+
exports.preflightRequest = _chunk63WIEBQBcjs.preflightRequest; exports.sendCountryCode = _chunkLSCC62CZcjs.sendCountryCode; exports.stagingIndicator = stagingIndicator; exports.whitelist = _chunkT5EXFHVAcjs.whitelist;
|
package/dist/helpers/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { sendCountryCode } from './send-country-code.cjs';
|
|
2
|
-
export {
|
|
2
|
+
export { WhitelistOptions, whitelist } from './whitelist.cjs';
|
|
3
3
|
import { ResponseRule } from '../core/types.cjs';
|
|
4
4
|
export { preflightRequest } from './preflight-request.cjs';
|
|
5
5
|
import '../behaviors/set-cors-headers.cjs';
|
package/dist/helpers/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { sendCountryCode } from './send-country-code.js';
|
|
2
|
-
export {
|
|
2
|
+
export { WhitelistOptions, whitelist } from './whitelist.js';
|
|
3
3
|
import { ResponseRule } from '../core/types.js';
|
|
4
4
|
export { preflightRequest } from './preflight-request.js';
|
|
5
5
|
import '../behaviors/set-cors-headers.js';
|
package/dist/helpers/index.js
CHANGED
|
@@ -5,22 +5,22 @@ import {
|
|
|
5
5
|
sendCountryCode
|
|
6
6
|
} from "../chunk-C32DL3EP.js";
|
|
7
7
|
import {
|
|
8
|
-
|
|
9
|
-
} from "../chunk-
|
|
8
|
+
whitelist
|
|
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-Q4NP4C3B.js";
|
|
20
|
-
import "../chunk-DSSFFJWL.js";
|
|
21
19
|
import {
|
|
22
20
|
setResponseHeader
|
|
23
21
|
} from "../chunk-RBBKFG5J.js";
|
|
22
|
+
import "../chunk-DSSFFJWL.js";
|
|
23
|
+
import "../chunk-Q4NP4C3B.js";
|
|
24
24
|
import "../chunk-BDNPQ7AU.js";
|
|
25
25
|
import "../chunk-MLKGABMK.js";
|
|
26
26
|
|
|
@@ -38,5 +38,5 @@ export {
|
|
|
38
38
|
preflightRequest,
|
|
39
39
|
sendCountryCode,
|
|
40
40
|
stagingIndicator,
|
|
41
|
-
|
|
41
|
+
whitelist
|
|
42
42
|
};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
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
|
-
require('../chunk-WKYMSRCD.cjs');
|
|
10
9
|
require('../chunk-WWSRNCUP.cjs');
|
|
10
|
+
require('../chunk-WKYMSRCD.cjs');
|
|
11
11
|
require('../chunk-75ZPJI57.cjs');
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
exports.
|
|
14
|
+
exports.whitelist = _chunkT5EXFHVAcjs.whitelist;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Rule } from '../core/types.cjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* Configuration options for the
|
|
4
|
+
* Configuration options for the IP/User-Agent access whitelist.
|
|
5
5
|
*/
|
|
6
|
-
interface
|
|
6
|
+
interface 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
|
|
@@ -34,10 +34,10 @@ interface StagingWhitelistOptions {
|
|
|
34
34
|
bypassPaths?: string[];
|
|
35
35
|
}
|
|
36
36
|
/**
|
|
37
|
-
* Creates a `Rule` that restricts access
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
37
|
+
* Creates a `Rule` that restricts access by IP CIDR range and/or User-Agent
|
|
38
|
+
* pattern. Any request that does not match an allowed CIDR or User-Agent
|
|
39
|
+
* (and is not on a bypassed path) is redirected with HTTP 302 to
|
|
40
|
+
* `options.redirectUrl`.
|
|
41
41
|
*
|
|
42
42
|
* No default allowlists are included — callers must supply all allowed
|
|
43
43
|
* CIDRs and User-Agent patterns explicitly.
|
|
@@ -47,11 +47,11 @@ interface StagingWhitelistOptions {
|
|
|
47
47
|
*
|
|
48
48
|
* @example
|
|
49
49
|
* ```ts
|
|
50
|
-
* import {
|
|
50
|
+
* import { whitelist } from '@rayselfs/cf-rule-engine/helpers'
|
|
51
51
|
* import { defineViewerRequest } from '@rayselfs/cf-rule-engine/adapters/cf-function'
|
|
52
52
|
*
|
|
53
53
|
* export default defineViewerRequest([
|
|
54
|
-
*
|
|
54
|
+
* whitelist({
|
|
55
55
|
* cidrs: ['203.0.113.0/24', '10.0.0.0/8'],
|
|
56
56
|
* userAgents: ['*InternalBot*'],
|
|
57
57
|
* redirectUrl: 'https://www.example.com',
|
|
@@ -60,7 +60,7 @@ interface StagingWhitelistOptions {
|
|
|
60
60
|
*
|
|
61
61
|
* // With bypass paths:
|
|
62
62
|
* export default defineViewerRequest([
|
|
63
|
-
*
|
|
63
|
+
* whitelist({
|
|
64
64
|
* cidrs: ['203.0.113.0/24'],
|
|
65
65
|
* redirectUrl: 'https://www.example.com',
|
|
66
66
|
* bypassPaths: ['/api/health', '/robots.txt'],
|
|
@@ -68,6 +68,6 @@ interface StagingWhitelistOptions {
|
|
|
68
68
|
* ])
|
|
69
69
|
* ```
|
|
70
70
|
*/
|
|
71
|
-
declare function
|
|
71
|
+
declare function whitelist(options: WhitelistOptions): Rule;
|
|
72
72
|
|
|
73
|
-
export { type
|
|
73
|
+
export { type WhitelistOptions, whitelist };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Rule } from '../core/types.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* Configuration options for the
|
|
4
|
+
* Configuration options for the IP/User-Agent access whitelist.
|
|
5
5
|
*/
|
|
6
|
-
interface
|
|
6
|
+
interface 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
|
|
@@ -34,10 +34,10 @@ interface StagingWhitelistOptions {
|
|
|
34
34
|
bypassPaths?: string[];
|
|
35
35
|
}
|
|
36
36
|
/**
|
|
37
|
-
* Creates a `Rule` that restricts access
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
37
|
+
* Creates a `Rule` that restricts access by IP CIDR range and/or User-Agent
|
|
38
|
+
* pattern. Any request that does not match an allowed CIDR or User-Agent
|
|
39
|
+
* (and is not on a bypassed path) is redirected with HTTP 302 to
|
|
40
|
+
* `options.redirectUrl`.
|
|
41
41
|
*
|
|
42
42
|
* No default allowlists are included — callers must supply all allowed
|
|
43
43
|
* CIDRs and User-Agent patterns explicitly.
|
|
@@ -47,11 +47,11 @@ interface StagingWhitelistOptions {
|
|
|
47
47
|
*
|
|
48
48
|
* @example
|
|
49
49
|
* ```ts
|
|
50
|
-
* import {
|
|
50
|
+
* import { whitelist } from '@rayselfs/cf-rule-engine/helpers'
|
|
51
51
|
* import { defineViewerRequest } from '@rayselfs/cf-rule-engine/adapters/cf-function'
|
|
52
52
|
*
|
|
53
53
|
* export default defineViewerRequest([
|
|
54
|
-
*
|
|
54
|
+
* whitelist({
|
|
55
55
|
* cidrs: ['203.0.113.0/24', '10.0.0.0/8'],
|
|
56
56
|
* userAgents: ['*InternalBot*'],
|
|
57
57
|
* redirectUrl: 'https://www.example.com',
|
|
@@ -60,7 +60,7 @@ interface StagingWhitelistOptions {
|
|
|
60
60
|
*
|
|
61
61
|
* // With bypass paths:
|
|
62
62
|
* export default defineViewerRequest([
|
|
63
|
-
*
|
|
63
|
+
* whitelist({
|
|
64
64
|
* cidrs: ['203.0.113.0/24'],
|
|
65
65
|
* redirectUrl: 'https://www.example.com',
|
|
66
66
|
* bypassPaths: ['/api/health', '/robots.txt'],
|
|
@@ -68,6 +68,6 @@ interface StagingWhitelistOptions {
|
|
|
68
68
|
* ])
|
|
69
69
|
* ```
|
|
70
70
|
*/
|
|
71
|
-
declare function
|
|
71
|
+
declare function whitelist(options: WhitelistOptions): Rule;
|
|
72
72
|
|
|
73
|
-
export { type
|
|
73
|
+
export { type WhitelistOptions, whitelist };
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
} from "../chunk-
|
|
2
|
+
whitelist
|
|
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
|
-
import "../chunk-Q4NP4C3B.js";
|
|
10
9
|
import "../chunk-DSSFFJWL.js";
|
|
10
|
+
import "../chunk-Q4NP4C3B.js";
|
|
11
11
|
import "../chunk-MLKGABMK.js";
|
|
12
12
|
export {
|
|
13
|
-
|
|
13
|
+
whitelist
|
|
14
14
|
};
|
package/dist/index.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});require('./chunk-MEHWLQLR.cjs');
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var _chunk3BBLG4IXcjs = require('./chunk-3BBLG4IX.cjs');
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunkSAXDN5NScjs = require('./chunk-SAXDN5NS.cjs');
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { BehaviorFn, BehaviorResult, CriteriaFn, HttpRequest, HttpResponse, ResponseBehaviorFn, ResponseRule, Rule, ViewerRequestHandler, ViewerResponseHandler } from './core/types.cjs';
|
|
2
2
|
export { all, any, chain, not, rule, runRules } from './core/rule.cjs';
|
|
3
|
-
export { c as cfFunction } from './
|
|
3
|
+
export { c as cfFunction } from './viewer-response-DIQHy8L7.cjs';
|
|
4
4
|
export { l as lambdaEdge } from './lambda-edge-9xiONGmR.cjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { BehaviorFn, BehaviorResult, CriteriaFn, HttpRequest, HttpResponse, ResponseBehaviorFn, ResponseRule, Rule, ViewerRequestHandler, ViewerResponseHandler } from './core/types.js';
|
|
2
2
|
export { all, any, chain, not, rule, runRules } from './core/rule.js';
|
|
3
|
-
export { c as cfFunction } from './
|
|
3
|
+
export { c as cfFunction } from './viewer-response-C9eF2O9s.js';
|
|
4
4
|
export { l as lambdaEdge } from './lambda-edge-BK3-bFx8.js';
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
File without changes
|
|
File without changes
|