@nodeart/cloudflare-provisioning 1.0.14 → 1.0.15
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.
|
@@ -11,10 +11,10 @@ jobs:
|
|
|
11
11
|
build:
|
|
12
12
|
runs-on: ubuntu-latest
|
|
13
13
|
steps:
|
|
14
|
-
- uses: actions/checkout@
|
|
15
|
-
- uses: actions/setup-node@
|
|
14
|
+
- uses: actions/checkout@v4
|
|
15
|
+
- uses: actions/setup-node@v4
|
|
16
16
|
with:
|
|
17
|
-
node-version:
|
|
17
|
+
node-version: 24
|
|
18
18
|
- run: npm ci
|
|
19
19
|
- run: npm test
|
|
20
20
|
|
|
@@ -22,10 +22,10 @@ jobs:
|
|
|
22
22
|
needs: build
|
|
23
23
|
runs-on: ubuntu-latest
|
|
24
24
|
steps:
|
|
25
|
-
- uses: actions/checkout@
|
|
26
|
-
- uses: actions/setup-node@
|
|
25
|
+
- uses: actions/checkout@v4
|
|
26
|
+
- uses: actions/setup-node@v4
|
|
27
27
|
with:
|
|
28
|
-
node-version:
|
|
28
|
+
node-version: 24
|
|
29
29
|
registry-url: https://registry.npmjs.org/
|
|
30
30
|
- run: npm ci
|
|
31
31
|
- run: npm publish
|
|
@@ -10,9 +10,9 @@ jobs:
|
|
|
10
10
|
build:
|
|
11
11
|
runs-on: ubuntu-latest
|
|
12
12
|
steps:
|
|
13
|
-
- uses: actions/checkout@
|
|
14
|
-
- uses: actions/setup-node@
|
|
13
|
+
- uses: actions/checkout@v4
|
|
14
|
+
- uses: actions/setup-node@v4
|
|
15
15
|
with:
|
|
16
|
-
node-version:
|
|
16
|
+
node-version: 24
|
|
17
17
|
- run: npm ci
|
|
18
18
|
- run: npm test
|
package/cloudflare.js
CHANGED
|
@@ -460,27 +460,33 @@ class CloudFlare {
|
|
|
460
460
|
}
|
|
461
461
|
|
|
462
462
|
async rewriteRedirectRules (redirectRules) {
|
|
463
|
-
const { id: rulesetId
|
|
463
|
+
const { id: rulesetId } = await this.getRedirectRules()
|
|
464
464
|
|
|
465
465
|
if (!rulesetId) {
|
|
466
466
|
console.error(`Could not update redirect rules for domain ${this.domain}: custom firewall ruleset id is not found`)
|
|
467
467
|
throw new Error('Custom redirect ruleset id is not found')
|
|
468
468
|
}
|
|
469
469
|
|
|
470
|
-
|
|
471
|
-
const currentRedirectRule = currentRedirectRules?.find(
|
|
472
|
-
rule => rule.description === redirectRule.description
|
|
473
|
-
)
|
|
470
|
+
const url = CLOUDFLARE_API_URL + `zones/${this.zoneId}/rulesets/${rulesetId}`
|
|
474
471
|
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
472
|
+
const { statusCode, body } = await this.requestWithDelay(url, {
|
|
473
|
+
method: 'PUT',
|
|
474
|
+
headers: {
|
|
475
|
+
...this.authorizationHeaders,
|
|
476
|
+
'Content-Type': 'application/json'
|
|
477
|
+
},
|
|
478
|
+
body: JSON.stringify({ rules: redirectRules })
|
|
479
|
+
})
|
|
480
|
+
|
|
481
|
+
let response
|
|
482
|
+
try {
|
|
483
|
+
response = await body.json()
|
|
484
|
+
} catch (e) {
|
|
485
|
+
response = await body.text()
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
if (statusCode !== 200) {
|
|
489
|
+
throw new Error(`Could not update redirect rules: ${statusCode}, error: ${JSON.stringify(response)}`)
|
|
484
490
|
}
|
|
485
491
|
}
|
|
486
492
|
|
|
@@ -583,6 +589,9 @@ class CloudFlare {
|
|
|
583
589
|
const response = await body.json()
|
|
584
590
|
|
|
585
591
|
if (statusCode !== 200) {
|
|
592
|
+
if (response && response.errors && response.errors.find(e => e.code === 1015)) {
|
|
593
|
+
return response
|
|
594
|
+
}
|
|
586
595
|
throw new Error(`Could not set HTTP2: ${statusCode}, error: ${JSON.stringify(response)}`)
|
|
587
596
|
}
|
|
588
597
|
|