@speedkit/cli 2.15.0 → 2.16.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.
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
# [2.16.0](https://gitlab.orestes.info/baqend/speed-kit-cli/compare/v2.15.0...v2.16.0) (2024-04-02)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* **onboarding:** allow fetch from untrusted resources ([207d2db](https://gitlab.orestes.info/baqend/speed-kit-cli/commit/207d2db19d5723bf53831ba0411723d162c23c87))
|
|
7
|
+
|
|
1
8
|
# [2.15.0](https://gitlab.orestes.info/baqend/speed-kit-cli/compare/v2.14.3...v2.15.0) (2024-03-22)
|
|
2
9
|
|
|
3
10
|
|
package/README.md
CHANGED
|
@@ -17,6 +17,7 @@ export declare class SpeedKitAssetRequest implements FetchRequestPausedEventHand
|
|
|
17
17
|
get patterns(): Protocol.Fetch.RequestPattern[];
|
|
18
18
|
constructor(customerConfig: CustomerConfig, documentHandler: DocumentHandlerServer, cache: Cache, cli: CliService, speedKitServerConfig?: SpeedKitServerConfig);
|
|
19
19
|
handle(event: Protocol.Fetch.RequestPausedEvent): Promise<Partial<Protocol.Fetch.FulfillRequestRequest> | AbortResponse>;
|
|
20
|
+
private fetchAsset;
|
|
20
21
|
private getCachedResponse;
|
|
21
22
|
private buildCustomHeaders;
|
|
22
23
|
private createResponseFromLocalDocumentHandler;
|
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SpeedKitAssetRequest = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
4
5
|
const baqend_response_1 = require("../browser/baqend-response");
|
|
6
|
+
const https_1 = require("https");
|
|
7
|
+
const crypto_1 = tslib_1.__importDefault(require("crypto"));
|
|
8
|
+
const node_fetch_1 = tslib_1.__importDefault(require("node-fetch"));
|
|
9
|
+
const agent = new https_1.Agent({
|
|
10
|
+
rejectUnauthorized: false,
|
|
11
|
+
keepAlive: true,
|
|
12
|
+
secureOptions: crypto_1.default.constants.SSL_OP_LEGACY_SERVER_CONNECT,
|
|
13
|
+
});
|
|
5
14
|
/**
|
|
6
15
|
* Handles fetch requests for Speed Kit assets and returns customized responses.
|
|
7
16
|
*/
|
|
@@ -47,7 +56,7 @@ class SpeedKitAssetRequest {
|
|
|
47
56
|
if (cachedResponse instanceof baqend_response_1.BaqendResponse) {
|
|
48
57
|
return cachedResponse;
|
|
49
58
|
}
|
|
50
|
-
const response = await
|
|
59
|
+
const response = await this.fetchAsset(originUrl, variation, event);
|
|
51
60
|
const customHeaders = this.buildCustomHeaders(originUrl);
|
|
52
61
|
if (response.headers.get("Content-Type").includes("image") ||
|
|
53
62
|
response.headers.get("Content-Type").includes("font")) {
|
|
@@ -80,6 +89,14 @@ class SpeedKitAssetRequest {
|
|
|
80
89
|
return new baqend_response_1.BaqendResponse(message, null, customHeaders, 500);
|
|
81
90
|
}
|
|
82
91
|
}
|
|
92
|
+
fetchAsset(originUrl, variation, event) {
|
|
93
|
+
return (0, node_fetch_1.default)(originUrl, {
|
|
94
|
+
...this.prepareOriginRequest(variation, {
|
|
95
|
+
headers: event.request.headers,
|
|
96
|
+
}),
|
|
97
|
+
agent,
|
|
98
|
+
});
|
|
99
|
+
}
|
|
83
100
|
getCachedResponse(requestUrl) {
|
|
84
101
|
const response = this.cache.getEntry(requestUrl);
|
|
85
102
|
if (!(response instanceof baqend_response_1.BaqendResponse)) {
|
package/oclif.manifest.json
CHANGED