@rayselfs/cf-rule-engine 1.5.0 → 1.6.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 (74) hide show
  1. package/README.md +2 -2
  2. package/dist/adapters/cf-function.d.cts +1 -1
  3. package/dist/adapters/cf-function.d.ts +1 -1
  4. package/dist/adapters/lambda-edge.d.cts +1 -1
  5. package/dist/adapters/lambda-edge.d.ts +1 -1
  6. package/dist/behaviors/construct-response.d.cts +3 -3
  7. package/dist/behaviors/construct-response.d.ts +3 -3
  8. package/dist/behaviors/copy-header.d.cts +3 -3
  9. package/dist/behaviors/copy-header.d.ts +3 -3
  10. package/dist/behaviors/directory-index.d.cts +3 -3
  11. package/dist/behaviors/directory-index.d.ts +3 -3
  12. package/dist/behaviors/image-optimize.cjs +2 -2
  13. package/dist/behaviors/image-optimize.d.cts +19 -7
  14. package/dist/behaviors/image-optimize.d.ts +19 -7
  15. package/dist/behaviors/image-optimize.js +1 -1
  16. package/dist/behaviors/index.cjs +2 -2
  17. package/dist/behaviors/index.d.cts +1 -1
  18. package/dist/behaviors/index.d.ts +1 -1
  19. package/dist/behaviors/index.js +1 -1
  20. package/dist/behaviors/redirect.d.cts +3 -3
  21. package/dist/behaviors/redirect.d.ts +3 -3
  22. package/dist/behaviors/remove-response-headers.d.cts +2 -2
  23. package/dist/behaviors/remove-response-headers.d.ts +2 -2
  24. package/dist/behaviors/rewrite-uri.d.cts +3 -3
  25. package/dist/behaviors/rewrite-uri.d.ts +3 -3
  26. package/dist/behaviors/set-cache-control.d.cts +4 -4
  27. package/dist/behaviors/set-cache-control.d.ts +4 -4
  28. package/dist/behaviors/set-cors-headers.d.cts +4 -4
  29. package/dist/behaviors/set-cors-headers.d.ts +4 -4
  30. package/dist/behaviors/set-csp.d.cts +2 -2
  31. package/dist/behaviors/set-csp.d.ts +2 -2
  32. package/dist/behaviors/set-request-header.d.cts +3 -3
  33. package/dist/behaviors/set-request-header.d.ts +3 -3
  34. package/dist/behaviors/set-response-header.d.cts +2 -2
  35. package/dist/behaviors/set-response-header.d.ts +2 -2
  36. package/dist/behaviors/set-security-headers.d.cts +2 -2
  37. package/dist/behaviors/set-security-headers.d.ts +2 -2
  38. package/dist/behaviors/strip-query-params.d.cts +2 -2
  39. package/dist/behaviors/strip-query-params.d.ts +2 -2
  40. package/dist/{cf-function-u0PvbW_s.d.ts → cf-function-C9eF2O9s.d.ts} +9 -9
  41. package/dist/{cf-function-D27hUVtN.d.cts → cf-function-DIQHy8L7.d.cts} +9 -9
  42. package/dist/{chunk-TQLJIT4H.cjs → chunk-KXC6ES3B.cjs} +6 -5
  43. package/dist/{chunk-5PT5X62W.js → chunk-LQRLWDQQ.js} +6 -5
  44. package/dist/criteria/country-is.d.cts +5 -5
  45. package/dist/criteria/country-is.d.ts +5 -5
  46. package/dist/criteria/file-extension.d.cts +3 -3
  47. package/dist/criteria/file-extension.d.ts +3 -3
  48. package/dist/criteria/header-contains.d.cts +4 -4
  49. package/dist/criteria/header-contains.d.ts +4 -4
  50. package/dist/criteria/header-equals.d.cts +4 -4
  51. package/dist/criteria/header-equals.d.ts +4 -4
  52. package/dist/criteria/hostname-is.d.cts +2 -2
  53. package/dist/criteria/hostname-is.d.ts +2 -2
  54. package/dist/criteria/index.cjs +3 -3
  55. package/dist/criteria/index.js +3 -3
  56. package/dist/criteria/ip-cidr.d.cts +4 -4
  57. package/dist/criteria/ip-cidr.d.ts +4 -4
  58. package/dist/criteria/method-is.d.cts +3 -3
  59. package/dist/criteria/method-is.d.ts +3 -3
  60. package/dist/criteria/user-agent-matches.d.cts +6 -6
  61. package/dist/criteria/user-agent-matches.d.ts +6 -6
  62. package/dist/helpers/index.d.cts +4 -4
  63. package/dist/helpers/index.d.ts +4 -4
  64. package/dist/helpers/preflight-request.d.cts +4 -4
  65. package/dist/helpers/preflight-request.d.ts +4 -4
  66. package/dist/helpers/send-country-code.d.cts +5 -5
  67. package/dist/helpers/send-country-code.d.ts +5 -5
  68. package/dist/helpers/staging-whitelist.d.cts +2 -2
  69. package/dist/helpers/staging-whitelist.d.ts +2 -2
  70. package/dist/index.d.cts +2 -2
  71. package/dist/index.d.ts +2 -2
  72. package/dist/{lambda-edge-DxTOa2cg.d.cts → lambda-edge-9xiONGmR.d.cts} +6 -6
  73. package/dist/{lambda-edge-D15Nf__n.d.ts → lambda-edge-BK3-bFx8.d.ts} +6 -6
  74. package/package.json +1 -1
@@ -15,13 +15,13 @@ import { Rule, ResponseBehaviorFn, ResponseRule } from './core/types.js';
15
15
  *
16
16
  * @example
17
17
  * ```ts
18
- * import { rule, not } from '@viverse/cf-engine'
19
- * import { ipCidr, pathPrefix } from '@viverse/cf-engine/criteria'
20
- * import { redirect, setRequestHeader } from '@viverse/cf-engine/behaviors'
21
- * import { defineViewerRequest } from '@viverse/cf-engine/adapters/cf-function'
18
+ * import { rule, not } from '@rayselfs/cf-rule-engine'
19
+ * import { ipCidr, pathPrefix } from '@rayselfs/cf-rule-engine/criteria'
20
+ * import { redirect, setRequestHeader } from '@rayselfs/cf-rule-engine/behaviors'
21
+ * import { defineViewerRequest } from '@rayselfs/cf-rule-engine/adapters/cf-function'
22
22
  *
23
23
  * export default defineViewerRequest([
24
- * rule(not(ipCidr(['10.0.0.0/8'])), redirect(302, 'https://www.viverse.com')),
24
+ * rule(not(ipCidr(['10.0.0.0/8'])), redirect(302, 'https://www.example.com')),
25
25
  * rule(pathPrefix(['/api/']), setRequestHeader('x-forwarded-host', 'api.internal')),
26
26
  * ])
27
27
  * ```
@@ -48,13 +48,13 @@ declare function defineViewerRequest(rules: Rule[]): (event: unknown) => unknown
48
48
  *
49
49
  * @example
50
50
  * ```ts
51
- * import { setSecurityHeaders, setCorsHeaders, setResponseHeader } from '@viverse/cf-engine/behaviors'
52
- * import { pathPrefix } from '@viverse/cf-engine/criteria'
53
- * import { defineViewerResponse } from '@viverse/cf-engine/adapters/cf-function'
51
+ * import { setSecurityHeaders, setCorsHeaders, setResponseHeader } from '@rayselfs/cf-rule-engine/behaviors'
52
+ * import { pathPrefix } from '@rayselfs/cf-rule-engine/criteria'
53
+ * import { defineViewerResponse } from '@rayselfs/cf-rule-engine/adapters/cf-function'
54
54
  *
55
55
  * export default defineViewerResponse([
56
56
  * setSecurityHeaders(),
57
- * setCorsHeaders({ allowedOrigins: ['https://www.viverse.com'] }),
57
+ * setCorsHeaders({ allowedOrigins: ['https://www.example.com'] }),
58
58
  * { criteria: pathPrefix(['/api/']), behavior: setResponseHeader('cache-control', 'no-store') },
59
59
  * ])
60
60
  * ```
@@ -15,13 +15,13 @@ import { Rule, ResponseBehaviorFn, ResponseRule } from './core/types.cjs';
15
15
  *
16
16
  * @example
17
17
  * ```ts
18
- * import { rule, not } from '@viverse/cf-engine'
19
- * import { ipCidr, pathPrefix } from '@viverse/cf-engine/criteria'
20
- * import { redirect, setRequestHeader } from '@viverse/cf-engine/behaviors'
21
- * import { defineViewerRequest } from '@viverse/cf-engine/adapters/cf-function'
18
+ * import { rule, not } from '@rayselfs/cf-rule-engine'
19
+ * import { ipCidr, pathPrefix } from '@rayselfs/cf-rule-engine/criteria'
20
+ * import { redirect, setRequestHeader } from '@rayselfs/cf-rule-engine/behaviors'
21
+ * import { defineViewerRequest } from '@rayselfs/cf-rule-engine/adapters/cf-function'
22
22
  *
23
23
  * export default defineViewerRequest([
24
- * rule(not(ipCidr(['10.0.0.0/8'])), redirect(302, 'https://www.viverse.com')),
24
+ * rule(not(ipCidr(['10.0.0.0/8'])), redirect(302, 'https://www.example.com')),
25
25
  * rule(pathPrefix(['/api/']), setRequestHeader('x-forwarded-host', 'api.internal')),
26
26
  * ])
27
27
  * ```
@@ -48,13 +48,13 @@ declare function defineViewerRequest(rules: Rule[]): (event: unknown) => unknown
48
48
  *
49
49
  * @example
50
50
  * ```ts
51
- * import { setSecurityHeaders, setCorsHeaders, setResponseHeader } from '@viverse/cf-engine/behaviors'
52
- * import { pathPrefix } from '@viverse/cf-engine/criteria'
53
- * import { defineViewerResponse } from '@viverse/cf-engine/adapters/cf-function'
51
+ * import { setSecurityHeaders, setCorsHeaders, setResponseHeader } from '@rayselfs/cf-rule-engine/behaviors'
52
+ * import { pathPrefix } from '@rayselfs/cf-rule-engine/criteria'
53
+ * import { defineViewerResponse } from '@rayselfs/cf-rule-engine/adapters/cf-function'
54
54
  *
55
55
  * export default defineViewerResponse([
56
56
  * setSecurityHeaders(),
57
- * setCorsHeaders({ allowedOrigins: ['https://www.viverse.com'] }),
57
+ * setCorsHeaders({ allowedOrigins: ['https://www.example.com'] }),
58
58
  * { criteria: pathPrefix(['/api/']), behavior: setResponseHeader('cache-control', 'no-store') },
59
59
  * ])
60
60
  * ```
@@ -77,12 +77,13 @@ function imageOptimize(options) {
77
77
  delete qs["imformat"];
78
78
  }
79
79
  var headers = Object.assign({}, request.headers);
80
- if (options.origin !== void 0) {
81
- headers["x-img-source-type"] = { value: options.origin.type };
82
- if (options.origin.type === "gateway") {
83
- headers["x-img-upstream-gateway"] = { value: options.origin.upstreamGateway };
80
+ var resolvedOrigin = typeof options.origin === "function" ? options.origin(request) : options.origin;
81
+ if (resolvedOrigin !== void 0) {
82
+ headers["x-img-source-type"] = { value: resolvedOrigin.type };
83
+ if (resolvedOrigin.type === "gateway") {
84
+ headers["x-img-upstream-gateway"] = { value: resolvedOrigin.upstreamGateway };
84
85
  } else {
85
- headers["x-img-source-bucket"] = { value: options.origin.sourceBucket };
86
+ headers["x-img-source-bucket"] = { value: resolvedOrigin.sourceBucket };
86
87
  }
87
88
  }
88
89
  if (options.originSecret !== void 0) {
@@ -77,12 +77,13 @@ function imageOptimize(options) {
77
77
  delete qs["imformat"];
78
78
  }
79
79
  var headers = Object.assign({}, request.headers);
80
- if (options.origin !== void 0) {
81
- headers["x-img-source-type"] = { value: options.origin.type };
82
- if (options.origin.type === "gateway") {
83
- headers["x-img-upstream-gateway"] = { value: options.origin.upstreamGateway };
80
+ var resolvedOrigin = typeof options.origin === "function" ? options.origin(request) : options.origin;
81
+ if (resolvedOrigin !== void 0) {
82
+ headers["x-img-source-type"] = { value: resolvedOrigin.type };
83
+ if (resolvedOrigin.type === "gateway") {
84
+ headers["x-img-upstream-gateway"] = { value: resolvedOrigin.upstreamGateway };
84
85
  } else {
85
- headers["x-img-source-bucket"] = { value: options.origin.sourceBucket };
86
+ headers["x-img-source-bucket"] = { value: resolvedOrigin.sourceBucket };
86
87
  }
87
88
  }
88
89
  if (options.originSecret !== void 0) {
@@ -18,16 +18,16 @@ import { CriteriaFn } from '../core/types.cjs';
18
18
  *
19
19
  * @example
20
20
  * ```typescript
21
- * import { rule } from '@viverse/cf-engine'
22
- * import { countryIs } from '@viverse/cf-engine/criteria'
23
- * import { redirect } from '@viverse/cf-engine/behaviors'
21
+ * import { rule } from '@rayselfs/cf-rule-engine'
22
+ * import { countryIs } from '@rayselfs/cf-rule-engine/criteria'
23
+ * import { redirect } from '@rayselfs/cf-rule-engine/behaviors'
24
24
  *
25
25
  * // Redirect mainland China traffic to the CN domain
26
- * rule(countryIs(['CN']), redirect(302, 'https://www.viverse.cn'))
26
+ * rule(countryIs(['CN']), redirect(302, 'https://www.example.cn'))
27
27
  *
28
28
  * // Serve region-specific content for APAC countries
29
29
  * rule(countryIs(['TW', 'JP', 'KR', 'SG', 'HK']),
30
- * redirect(302, 'https://www.viverse.com/apac'))
30
+ * redirect(302, 'https://www.example.com/apac'))
31
31
  * ```
32
32
  */
33
33
  declare function countryIs(codes: string[]): CriteriaFn;
@@ -18,16 +18,16 @@ import { CriteriaFn } from '../core/types.js';
18
18
  *
19
19
  * @example
20
20
  * ```typescript
21
- * import { rule } from '@viverse/cf-engine'
22
- * import { countryIs } from '@viverse/cf-engine/criteria'
23
- * import { redirect } from '@viverse/cf-engine/behaviors'
21
+ * import { rule } from '@rayselfs/cf-rule-engine'
22
+ * import { countryIs } from '@rayselfs/cf-rule-engine/criteria'
23
+ * import { redirect } from '@rayselfs/cf-rule-engine/behaviors'
24
24
  *
25
25
  * // Redirect mainland China traffic to the CN domain
26
- * rule(countryIs(['CN']), redirect(302, 'https://www.viverse.cn'))
26
+ * rule(countryIs(['CN']), redirect(302, 'https://www.example.cn'))
27
27
  *
28
28
  * // Serve region-specific content for APAC countries
29
29
  * rule(countryIs(['TW', 'JP', 'KR', 'SG', 'HK']),
30
- * redirect(302, 'https://www.viverse.com/apac'))
30
+ * redirect(302, 'https://www.example.com/apac'))
31
31
  * ```
32
32
  */
33
33
  declare function countryIs(codes: string[]): CriteriaFn;
@@ -14,9 +14,9 @@ import { CriteriaFn } from '../core/types.cjs';
14
14
  *
15
15
  * @example
16
16
  * ```typescript
17
- * import { rule } from '@viverse/cf-engine'
18
- * import { fileExtension } from '@viverse/cf-engine/criteria'
19
- * import { setCacheControl, imageOptimize } from '@viverse/cf-engine/behaviors'
17
+ * import { rule } from '@rayselfs/cf-rule-engine'
18
+ * import { fileExtension } from '@rayselfs/cf-rule-engine/criteria'
19
+ * import { setCacheControl, imageOptimize } from '@rayselfs/cf-rule-engine/behaviors'
20
20
  *
21
21
  * // Apply long-lived cache to static assets
22
22
  * rule(fileExtension(['js', 'css', 'woff2', 'woff']),
@@ -14,9 +14,9 @@ import { CriteriaFn } from '../core/types.js';
14
14
  *
15
15
  * @example
16
16
  * ```typescript
17
- * import { rule } from '@viverse/cf-engine'
18
- * import { fileExtension } from '@viverse/cf-engine/criteria'
19
- * import { setCacheControl, imageOptimize } from '@viverse/cf-engine/behaviors'
17
+ * import { rule } from '@rayselfs/cf-rule-engine'
18
+ * import { fileExtension } from '@rayselfs/cf-rule-engine/criteria'
19
+ * import { setCacheControl, imageOptimize } from '@rayselfs/cf-rule-engine/behaviors'
20
20
  *
21
21
  * // Apply long-lived cache to static assets
22
22
  * rule(fileExtension(['js', 'css', 'woff2', 'woff']),
@@ -15,9 +15,9 @@ import { CriteriaFn } from '../core/types.cjs';
15
15
  *
16
16
  * @example
17
17
  * ```typescript
18
- * import { rule } from '@viverse/cf-engine'
19
- * import { headerContains } from '@viverse/cf-engine/criteria'
20
- * import { redirect } from '@viverse/cf-engine/behaviors'
18
+ * import { rule } from '@rayselfs/cf-rule-engine'
19
+ * import { headerContains } from '@rayselfs/cf-rule-engine/criteria'
20
+ * import { redirect } from '@rayselfs/cf-rule-engine/behaviors'
21
21
  *
22
22
  * // Redirect requests that accept WebP to an optimized image path
23
23
  * rule(headerContains('accept', ['image/webp']),
@@ -25,7 +25,7 @@ import { CriteriaFn } from '../core/types.cjs';
25
25
  *
26
26
  * // Match requests from mobile browsers
27
27
  * rule(headerContains('user-agent', ['Mobile', 'Android', 'iPhone']),
28
- * redirect(302, 'https://m.viverse.com'))
28
+ * redirect(302, 'https://m.example.com'))
29
29
  * ```
30
30
  */
31
31
  declare function headerContains(headerName: string, substrings: string[]): CriteriaFn;
@@ -15,9 +15,9 @@ import { CriteriaFn } from '../core/types.js';
15
15
  *
16
16
  * @example
17
17
  * ```typescript
18
- * import { rule } from '@viverse/cf-engine'
19
- * import { headerContains } from '@viverse/cf-engine/criteria'
20
- * import { redirect } from '@viverse/cf-engine/behaviors'
18
+ * import { rule } from '@rayselfs/cf-rule-engine'
19
+ * import { headerContains } from '@rayselfs/cf-rule-engine/criteria'
20
+ * import { redirect } from '@rayselfs/cf-rule-engine/behaviors'
21
21
  *
22
22
  * // Redirect requests that accept WebP to an optimized image path
23
23
  * rule(headerContains('accept', ['image/webp']),
@@ -25,7 +25,7 @@ import { CriteriaFn } from '../core/types.js';
25
25
  *
26
26
  * // Match requests from mobile browsers
27
27
  * rule(headerContains('user-agent', ['Mobile', 'Android', 'iPhone']),
28
- * redirect(302, 'https://m.viverse.com'))
28
+ * redirect(302, 'https://m.example.com'))
29
29
  * ```
30
30
  */
31
31
  declare function headerContains(headerName: string, substrings: string[]): CriteriaFn;
@@ -15,13 +15,13 @@ import { CriteriaFn } from '../core/types.cjs';
15
15
  *
16
16
  * @example
17
17
  * ```typescript
18
- * import { rule } from '@viverse/cf-engine'
19
- * import { headerEquals } from '@viverse/cf-engine/criteria'
20
- * import { setCorsHeaders } from '@viverse/cf-engine/behaviors'
18
+ * import { rule } from '@rayselfs/cf-rule-engine'
19
+ * import { headerEquals } from '@rayselfs/cf-rule-engine/criteria'
20
+ * import { setCorsHeaders } from '@rayselfs/cf-rule-engine/behaviors'
21
21
  *
22
22
  * // Apply CORS headers only for requests from known origins
23
23
  * rule(
24
- * headerEquals('origin', ['https://www.viverse.com', 'https://store.viverse.com']),
24
+ * headerEquals('origin', ['https://www.example.com', 'https://store.example.com']),
25
25
  * setCorsHeaders({ allowOriginEcho: true, allowCredentials: true }),
26
26
  * )
27
27
  * ```
@@ -15,13 +15,13 @@ import { CriteriaFn } from '../core/types.js';
15
15
  *
16
16
  * @example
17
17
  * ```typescript
18
- * import { rule } from '@viverse/cf-engine'
19
- * import { headerEquals } from '@viverse/cf-engine/criteria'
20
- * import { setCorsHeaders } from '@viverse/cf-engine/behaviors'
18
+ * import { rule } from '@rayselfs/cf-rule-engine'
19
+ * import { headerEquals } from '@rayselfs/cf-rule-engine/criteria'
20
+ * import { setCorsHeaders } from '@rayselfs/cf-rule-engine/behaviors'
21
21
  *
22
22
  * // Apply CORS headers only for requests from known origins
23
23
  * rule(
24
- * headerEquals('origin', ['https://www.viverse.com', 'https://store.viverse.com']),
24
+ * headerEquals('origin', ['https://www.example.com', 'https://store.example.com']),
25
25
  * setCorsHeaders({ allowOriginEcho: true, allowCredentials: true }),
26
26
  * )
27
27
  * ```
@@ -9,12 +9,12 @@ import { CriteriaFn } from '../core/types.cjs';
9
9
  *
10
10
  * Akamai equivalent: `hostname` criterion.
11
11
  *
12
- * @param hostnames - Array of exact hostnames to match (e.g. `['www.viverse.com', 'viverse.com']`).
12
+ * @param hostnames - Array of exact hostnames to match (e.g. `['www.example.com', 'example.com']`).
13
13
  * @returns A `CriteriaFn` to use as the first argument to `rule()`.
14
14
  *
15
15
  * @example
16
16
  * ```ts
17
- * rule(hostnameIs(['legacy.viverse.com']), redirect(301, 'https://www.viverse.com'))
17
+ * rule(hostnameIs(['legacy.example.com']), redirect(301, 'https://www.example.com'))
18
18
  * ```
19
19
  */
20
20
  declare function hostnameIs(hostnames: string[]): CriteriaFn;
@@ -9,12 +9,12 @@ import { CriteriaFn } from '../core/types.js';
9
9
  *
10
10
  * Akamai equivalent: `hostname` criterion.
11
11
  *
12
- * @param hostnames - Array of exact hostnames to match (e.g. `['www.viverse.com', 'viverse.com']`).
12
+ * @param hostnames - Array of exact hostnames to match (e.g. `['www.example.com', 'example.com']`).
13
13
  * @returns A `CriteriaFn` to use as the first argument to `rule()`.
14
14
  *
15
15
  * @example
16
16
  * ```ts
17
- * rule(hostnameIs(['legacy.viverse.com']), redirect(301, 'https://www.viverse.com'))
17
+ * rule(hostnameIs(['legacy.example.com']), redirect(301, 'https://www.example.com'))
18
18
  * ```
19
19
  */
20
20
  declare function hostnameIs(hostnames: string[]): CriteriaFn;
@@ -1,8 +1,5 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkJGJW7D2Ncjs = require('../chunk-JGJW7D2N.cjs');
4
-
5
-
6
3
  var _chunkD47P7HVZcjs = require('../chunk-D47P7HVZ.cjs');
7
4
  require('../chunk-YVUR35RN.cjs');
8
5
 
@@ -33,6 +30,9 @@ var _chunk32SMWYAFcjs = require('../chunk-32SMWYAF.cjs');
33
30
 
34
31
 
35
32
  var _chunkL7NBJ4JAcjs = require('../chunk-L7NBJ4JA.cjs');
33
+
34
+
35
+ var _chunkJGJW7D2Ncjs = require('../chunk-JGJW7D2N.cjs');
36
36
  require('../chunk-75ZPJI57.cjs');
37
37
 
38
38
 
@@ -1,6 +1,3 @@
1
- import {
2
- hostnameIs
3
- } from "../chunk-3PVDUC5M.js";
4
1
  import {
5
2
  ipCidr
6
3
  } from "../chunk-KW5YBTSD.js";
@@ -33,6 +30,9 @@ import {
33
30
  import {
34
31
  headerEquals
35
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,
@@ -13,13 +13,13 @@ import { CriteriaFn } from '../core/types.cjs';
13
13
  *
14
14
  * @example
15
15
  * ```typescript
16
- * import { rule, not } from '@viverse/cf-engine'
17
- * import { ipCidr } from '@viverse/cf-engine/criteria'
18
- * import { redirect, constructResponse } from '@viverse/cf-engine/behaviors'
16
+ * import { rule, not } from '@rayselfs/cf-rule-engine'
17
+ * import { ipCidr } from '@rayselfs/cf-rule-engine/criteria'
18
+ * import { redirect, constructResponse } from '@rayselfs/cf-rule-engine/behaviors'
19
19
  *
20
20
  * // Block traffic not originating from internal networks
21
21
  * rule(not(ipCidr(['10.0.0.0/8', '172.16.0.0/12', '192.168.0.0/16'])),
22
- * redirect(302, 'https://www.viverse.com'))
22
+ * redirect(302, 'https://www.example.com'))
23
23
  *
24
24
  * // Allow only specific office IPs
25
25
  * rule(not(ipCidr(['61.218.44.76/32', '122.147.213.24/32'])),
@@ -13,13 +13,13 @@ import { CriteriaFn } from '../core/types.js';
13
13
  *
14
14
  * @example
15
15
  * ```typescript
16
- * import { rule, not } from '@viverse/cf-engine'
17
- * import { ipCidr } from '@viverse/cf-engine/criteria'
18
- * import { redirect, constructResponse } from '@viverse/cf-engine/behaviors'
16
+ * import { rule, not } from '@rayselfs/cf-rule-engine'
17
+ * import { ipCidr } from '@rayselfs/cf-rule-engine/criteria'
18
+ * import { redirect, constructResponse } from '@rayselfs/cf-rule-engine/behaviors'
19
19
  *
20
20
  * // Block traffic not originating from internal networks
21
21
  * rule(not(ipCidr(['10.0.0.0/8', '172.16.0.0/12', '192.168.0.0/16'])),
22
- * redirect(302, 'https://www.viverse.com'))
22
+ * redirect(302, 'https://www.example.com'))
23
23
  *
24
24
  * // Allow only specific office IPs
25
25
  * rule(not(ipCidr(['61.218.44.76/32', '122.147.213.24/32'])),
@@ -12,9 +12,9 @@ import { CriteriaFn } from '../core/types.cjs';
12
12
  *
13
13
  * @example
14
14
  * ```typescript
15
- * import { rule } from '@viverse/cf-engine'
16
- * import { methodIs } from '@viverse/cf-engine/criteria'
17
- * import { constructResponse } from '@viverse/cf-engine/behaviors'
15
+ * import { rule } from '@rayselfs/cf-rule-engine'
16
+ * import { methodIs } from '@rayselfs/cf-rule-engine/criteria'
17
+ * import { constructResponse } from '@rayselfs/cf-rule-engine/behaviors'
18
18
  *
19
19
  * // Respond immediately to OPTIONS preflight requests
20
20
  * rule(methodIs(['OPTIONS']), constructResponse({ statusCode: 200, body: '' }))
@@ -12,9 +12,9 @@ import { CriteriaFn } from '../core/types.js';
12
12
  *
13
13
  * @example
14
14
  * ```typescript
15
- * import { rule } from '@viverse/cf-engine'
16
- * import { methodIs } from '@viverse/cf-engine/criteria'
17
- * import { constructResponse } from '@viverse/cf-engine/behaviors'
15
+ * import { rule } from '@rayselfs/cf-rule-engine'
16
+ * import { methodIs } from '@rayselfs/cf-rule-engine/criteria'
17
+ * import { constructResponse } from '@rayselfs/cf-rule-engine/behaviors'
18
18
  *
19
19
  * // Respond immediately to OPTIONS preflight requests
20
20
  * rule(methodIs(['OPTIONS']), constructResponse({ statusCode: 200, body: '' }))
@@ -14,17 +14,17 @@ import { CriteriaFn } from '../core/types.cjs';
14
14
  *
15
15
  * @example
16
16
  * ```typescript
17
- * import { rule, not } from '@viverse/cf-engine'
18
- * import { userAgentMatches } from '@viverse/cf-engine/criteria'
19
- * import { redirect, constructResponse } from '@viverse/cf-engine/behaviors'
17
+ * import { rule, not } from '@rayselfs/cf-rule-engine'
18
+ * import { userAgentMatches } from '@rayselfs/cf-rule-engine/criteria'
19
+ * import { redirect, constructResponse } from '@rayselfs/cf-rule-engine/behaviors'
20
20
  *
21
21
  * // Block known scraper bots
22
22
  * rule(userAgentMatches(['*SemrushBot*', '*AhrefsBot*', '*MJ12bot*']),
23
23
  * constructResponse({ statusCode: 403, body: 'Forbidden' }))
24
24
  *
25
- * // Allow only HTC internal automation tools (stage environment)
26
- * rule(not(userAgentMatches(['*HTCVRSDET*', '*Prerender*', '*HTC3PARTY*'])),
27
- * redirect(302, 'https://www.viverse.com'))
25
+ * // Allow only internal automation tools (stage environment)
26
+ * rule(not(userAgentMatches(['*MYBOT*', '*Prerender*', '*PARTNER*'])),
27
+ * redirect(302, 'https://www.example.com'))
28
28
  * ```
29
29
  */
30
30
  declare function userAgentMatches(patterns: string[]): CriteriaFn;
@@ -14,17 +14,17 @@ import { CriteriaFn } from '../core/types.js';
14
14
  *
15
15
  * @example
16
16
  * ```typescript
17
- * import { rule, not } from '@viverse/cf-engine'
18
- * import { userAgentMatches } from '@viverse/cf-engine/criteria'
19
- * import { redirect, constructResponse } from '@viverse/cf-engine/behaviors'
17
+ * import { rule, not } from '@rayselfs/cf-rule-engine'
18
+ * import { userAgentMatches } from '@rayselfs/cf-rule-engine/criteria'
19
+ * import { redirect, constructResponse } from '@rayselfs/cf-rule-engine/behaviors'
20
20
  *
21
21
  * // Block known scraper bots
22
22
  * rule(userAgentMatches(['*SemrushBot*', '*AhrefsBot*', '*MJ12bot*']),
23
23
  * constructResponse({ statusCode: 403, body: 'Forbidden' }))
24
24
  *
25
- * // Allow only HTC internal automation tools (stage environment)
26
- * rule(not(userAgentMatches(['*HTCVRSDET*', '*Prerender*', '*HTC3PARTY*'])),
27
- * redirect(302, 'https://www.viverse.com'))
25
+ * // Allow only internal automation tools (stage environment)
26
+ * rule(not(userAgentMatches(['*MYBOT*', '*Prerender*', '*PARTNER*'])),
27
+ * redirect(302, 'https://www.example.com'))
28
28
  * ```
29
29
  */
30
30
  declare function userAgentMatches(patterns: string[]): CriteriaFn;
@@ -19,12 +19,12 @@ import '../behaviors/set-cors-headers.cjs';
19
19
  *
20
20
  * @example
21
21
  * ```ts
22
- * import { setCorsHeaders } from '@viverse/cf-engine/behaviors'
23
- * import { stagingIndicator } from '@viverse/cf-engine/helpers'
24
- * import { defineViewerResponse } from '@viverse/cf-engine/adapters/cf-function'
22
+ * import { setCorsHeaders } from '@rayselfs/cf-rule-engine/behaviors'
23
+ * import { stagingIndicator } from '@rayselfs/cf-rule-engine/helpers'
24
+ * import { defineViewerResponse } from '@rayselfs/cf-rule-engine/adapters/cf-function'
25
25
  *
26
26
  * export default defineViewerResponse([
27
- * setCorsHeaders({ allowedOrigins: ['https://www.viverse.com'] }),
27
+ * setCorsHeaders({ allowedOrigins: ['https://www.example.com'] }),
28
28
  * stagingIndicator(),
29
29
  * ])
30
30
  * ```
@@ -19,12 +19,12 @@ import '../behaviors/set-cors-headers.js';
19
19
  *
20
20
  * @example
21
21
  * ```ts
22
- * import { setCorsHeaders } from '@viverse/cf-engine/behaviors'
23
- * import { stagingIndicator } from '@viverse/cf-engine/helpers'
24
- * import { defineViewerResponse } from '@viverse/cf-engine/adapters/cf-function'
22
+ * import { setCorsHeaders } from '@rayselfs/cf-rule-engine/behaviors'
23
+ * import { stagingIndicator } from '@rayselfs/cf-rule-engine/helpers'
24
+ * import { defineViewerResponse } from '@rayselfs/cf-rule-engine/adapters/cf-function'
25
25
  *
26
26
  * export default defineViewerResponse([
27
- * setCorsHeaders({ allowedOrigins: ['https://www.viverse.com'] }),
27
+ * setCorsHeaders({ allowedOrigins: ['https://www.example.com'] }),
28
28
  * stagingIndicator(),
29
29
  * ])
30
30
  * ```
@@ -9,10 +9,10 @@ import { CorsOptions } from '../behaviors/set-cors-headers.cjs';
9
9
  *
10
10
  * @example
11
11
  * ```ts
12
- * import { preflightRequest } from '@viverse/cf-engine/helpers'
13
- * import { setCorsHeaders } from '@viverse/cf-engine/behaviors'
14
- * import { defineViewerRequest, defineViewerResponse } from '@viverse/cf-engine/adapters/cf-function'
15
- * import type { CorsOptions } from '@viverse/cf-engine/behaviors'
12
+ * import { preflightRequest } from '@rayselfs/cf-rule-engine/helpers'
13
+ * import { setCorsHeaders } from '@rayselfs/cf-rule-engine/behaviors'
14
+ * import { defineViewerRequest, defineViewerResponse } from '@rayselfs/cf-rule-engine/adapters/cf-function'
15
+ * import type { CorsOptions } from '@rayselfs/cf-rule-engine/behaviors'
16
16
  *
17
17
  * const CORS: CorsOptions = {
18
18
  * allowedOrigins: ['*'],
@@ -9,10 +9,10 @@ import { CorsOptions } from '../behaviors/set-cors-headers.js';
9
9
  *
10
10
  * @example
11
11
  * ```ts
12
- * import { preflightRequest } from '@viverse/cf-engine/helpers'
13
- * import { setCorsHeaders } from '@viverse/cf-engine/behaviors'
14
- * import { defineViewerRequest, defineViewerResponse } from '@viverse/cf-engine/adapters/cf-function'
15
- * import type { CorsOptions } from '@viverse/cf-engine/behaviors'
12
+ * import { preflightRequest } from '@rayselfs/cf-rule-engine/helpers'
13
+ * import { setCorsHeaders } from '@rayselfs/cf-rule-engine/behaviors'
14
+ * import { defineViewerRequest, defineViewerResponse } from '@rayselfs/cf-rule-engine/adapters/cf-function'
15
+ * import type { CorsOptions } from '@rayselfs/cf-rule-engine/behaviors'
16
16
  *
17
17
  * const CORS: CorsOptions = {
18
18
  * allowedOrigins: ['*'],
@@ -6,20 +6,20 @@ import { BehaviorFn } from '../core/types.cjs';
6
6
  *
7
7
  * CloudFront sets `CloudFront-Viewer-Country` to the ISO 3166-1 alpha-2 country code
8
8
  * of the viewer (e.g. `'US'`, `'TW'`, `'JP'`). This helper copies it to the header name
9
- * your origin expects, defaulting to `'x-htc-request-country-code'`.
9
+ * your origin expects, defaulting to `'x-viewer-country'`.
10
10
  *
11
11
  * Note: The `CloudFront-Viewer-Country` header must be enabled in the CloudFront
12
12
  * cache policy (under "Headers") for the origin behavior.
13
13
  *
14
14
  * @param targetHeader - The request header to copy the country code into.
15
- * Default: `'x-htc-request-country-code'`.
15
+ * Default: `'x-viewer-country'`.
16
16
  * @returns A `BehaviorFn` to use as the second argument to `rule()`.
17
17
  *
18
18
  * @example
19
19
  * ```ts
20
- * import { sendCountryCode } from '@viverse/cf-engine/helpers'
21
- * import { rule } from '@viverse/cf-engine'
22
- * import { defineViewerRequest } from '@viverse/cf-engine/adapters/cf-function'
20
+ * import { sendCountryCode } from '@rayselfs/cf-rule-engine/helpers'
21
+ * import { rule } from '@rayselfs/cf-rule-engine'
22
+ * import { defineViewerRequest } from '@rayselfs/cf-rule-engine/adapters/cf-function'
23
23
  *
24
24
  * export default defineViewerRequest([
25
25
  * // Forward country code using the default header name
@@ -6,20 +6,20 @@ import { BehaviorFn } from '../core/types.js';
6
6
  *
7
7
  * CloudFront sets `CloudFront-Viewer-Country` to the ISO 3166-1 alpha-2 country code
8
8
  * of the viewer (e.g. `'US'`, `'TW'`, `'JP'`). This helper copies it to the header name
9
- * your origin expects, defaulting to `'x-htc-request-country-code'`.
9
+ * your origin expects, defaulting to `'x-viewer-country'`.
10
10
  *
11
11
  * Note: The `CloudFront-Viewer-Country` header must be enabled in the CloudFront
12
12
  * cache policy (under "Headers") for the origin behavior.
13
13
  *
14
14
  * @param targetHeader - The request header to copy the country code into.
15
- * Default: `'x-htc-request-country-code'`.
15
+ * Default: `'x-viewer-country'`.
16
16
  * @returns A `BehaviorFn` to use as the second argument to `rule()`.
17
17
  *
18
18
  * @example
19
19
  * ```ts
20
- * import { sendCountryCode } from '@viverse/cf-engine/helpers'
21
- * import { rule } from '@viverse/cf-engine'
22
- * import { defineViewerRequest } from '@viverse/cf-engine/adapters/cf-function'
20
+ * import { sendCountryCode } from '@rayselfs/cf-rule-engine/helpers'
21
+ * import { rule } from '@rayselfs/cf-rule-engine'
22
+ * import { defineViewerRequest } from '@rayselfs/cf-rule-engine/adapters/cf-function'
23
23
  *
24
24
  * export default defineViewerRequest([
25
25
  * // Forward country code using the default header name
@@ -47,8 +47,8 @@ interface StagingWhitelistOptions {
47
47
  *
48
48
  * @example
49
49
  * ```ts
50
- * import { stagingWhitelist } from '@viverse/cf-engine/helpers'
51
- * import { defineViewerRequest } from '@viverse/cf-engine/adapters/cf-function'
50
+ * import { stagingWhitelist } from '@rayselfs/cf-rule-engine/helpers'
51
+ * import { defineViewerRequest } from '@rayselfs/cf-rule-engine/adapters/cf-function'
52
52
  *
53
53
  * export default defineViewerRequest([
54
54
  * stagingWhitelist({
@@ -47,8 +47,8 @@ interface StagingWhitelistOptions {
47
47
  *
48
48
  * @example
49
49
  * ```ts
50
- * import { stagingWhitelist } from '@viverse/cf-engine/helpers'
51
- * import { defineViewerRequest } from '@viverse/cf-engine/adapters/cf-function'
50
+ * import { stagingWhitelist } from '@rayselfs/cf-rule-engine/helpers'
51
+ * import { defineViewerRequest } from '@rayselfs/cf-rule-engine/adapters/cf-function'
52
52
  *
53
53
  * export default defineViewerRequest([
54
54
  * stagingWhitelist({
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 './cf-function-D27hUVtN.cjs';
4
- export { l as lambdaEdge } from './lambda-edge-DxTOa2cg.cjs';
3
+ export { c as cfFunction } from './cf-function-DIQHy8L7.cjs';
4
+ export { l as lambdaEdge } from './lambda-edge-9xiONGmR.cjs';