@speedkit/cli 3.9.0 → 3.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/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## [3.9.1](https://gitlab.orestes.info/baqend/speed-kit-cli/compare/v3.9.0...v3.9.1) (2025-10-15)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **onboarding:** encoding could not be detected cause of a whitespace ([680cc2d](https://gitlab.orestes.info/baqend/speed-kit-cli/commit/680cc2d27ecf9e09421a71bf135b9ac3968d658c))
7
+
1
8
  # [3.9.0](https://gitlab.orestes.info/baqend/speed-kit-cli/compare/v3.8.0...v3.9.0) (2025-10-14)
2
9
 
3
10
 
package/README.md CHANGED
@@ -21,7 +21,7 @@ $ npm install -g @speedkit/cli
21
21
  $ sk COMMAND
22
22
  running command...
23
23
  $ sk (--version)
24
- @speedkit/cli/3.9.0 linux-x64 node-v20.19.5
24
+ @speedkit/cli/3.9.1 linux-x64 node-v20.19.5
25
25
  $ sk --help [COMMAND]
26
26
  USAGE
27
27
  $ sk COMMAND
@@ -0,0 +1,5 @@
1
+ import ApplicationError from "../../error-handling/error/application-error";
2
+ export declare class UnsupportedEncodingError extends ApplicationError {
3
+ readonly code = "REQUEST_ENCODING_UNSUPPORTED";
4
+ readonly suggestions: string[];
5
+ }
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UnsupportedEncodingError = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const application_error_1 = tslib_1.__importDefault(require("../../error-handling/error/application-error"));
6
+ class UnsupportedEncodingError extends application_error_1.default {
7
+ code = "REQUEST_ENCODING_UNSUPPORTED";
8
+ suggestions = [
9
+ "Needs to be fixed by a developer.",
10
+ "Currently we use iconv to encode anything",
11
+ "If iconv can't handle it we need a special library",
12
+ ];
13
+ }
14
+ exports.UnsupportedEncodingError = UnsupportedEncodingError;
@@ -6,6 +6,7 @@ const onboarding_model_1 = require("../onboarding-model");
6
6
  const origin_response_1 = require("../browser/origin-response");
7
7
  const iconv_lite_1 = tslib_1.__importDefault(require("iconv-lite"));
8
8
  const encoding_japanese_1 = tslib_1.__importDefault(require("encoding-japanese"));
9
+ const unsupported_encoding_error_1 = require("../error/unsupported-encoding-error");
9
10
  /**
10
11
  * Intercepts any request to the customersOrigin and equivalent requests to baqendAssetApi
11
12
  * @implements {FetchRequestPausedEventHandler}
@@ -119,9 +120,9 @@ class CustomerDomainDocumentResponse {
119
120
  const buffer = Buffer.from(body, "base64");
120
121
  const encodingFromBuffer = encoding_japanese_1.default.detect(buffer);
121
122
  const encodedBody = iconv_lite_1.default
122
- .decode(buffer, encodingFromHeader ?? encodingFromBuffer)
123
+ .decode(buffer, encodingFromHeader ?? "utf-8")
123
124
  .toString();
124
- const metaSelector = /<meta http-equiv="content-type" content="text\/html;charset=([^\s"(),./:;<=>?@[\]]*)">/is;
125
+ const metaSelector = onboarding_model_1.META_CONTENT_TYPE_REGEX;
125
126
  const encodingFromBodyMeta = metaSelector.test(encodedBody)
126
127
  ? metaSelector.exec(encodedBody)[1]
127
128
  : "";
@@ -130,8 +131,7 @@ class CustomerDomainDocumentResponse {
130
131
  encodingFromBuffer ||
131
132
  "utf-8";
132
133
  if (!iconv_lite_1.default.encodingExists(detectedEncoding)) {
133
- console.error(`Encoding not supported: "${detectedEncoding}" on url: ${event.request.url}`);
134
- return encodedBody;
134
+ throw new unsupported_encoding_error_1.UnsupportedEncodingError(`encoding is not supported by cli: "${detectedEncoding}"`);
135
135
  }
136
136
  event.responseHeaders.push({
137
137
  name: "x-sk-detected-encoding",
@@ -112,3 +112,4 @@ export declare const USER_AGENT: {
112
112
  TV: string;
113
113
  };
114
114
  export declare const SpeedKitInstallRegex: RegExp;
115
+ export declare const META_CONTENT_TYPE_REGEX: RegExp;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SpeedKitInstallRegex = exports.USER_AGENT = exports.OnboardingContext = exports.BrowserContext = exports.CDP_SESSION = exports.BROWSER_EVENTS = void 0;
3
+ exports.META_CONTENT_TYPE_REGEX = exports.SpeedKitInstallRegex = exports.USER_AGENT = exports.OnboardingContext = exports.BrowserContext = exports.CDP_SESSION = exports.BROWSER_EVENTS = void 0;
4
4
  const core_1 = require("@oclif/core");
5
5
  const cli_parameters_1 = require("../../models/cli-parameters");
6
6
  const browser_config_1 = require("./browser/config/browser-config");
@@ -156,3 +156,4 @@ exports.USER_AGENT = {
156
156
  TV: "Mozilla/5.0 (Linux; NetCast; U) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.79 Safari/537.36 SmartTV/10.0 Colt/2.0 (compatible; SpeedKit/1.0)",
157
157
  };
158
158
  exports.SpeedKitInstallRegex = /<script[^>]*src[^>]*app\.baqend\.com\/v1\/speedkit\/install.js[^>]*>(?:(?!<\/script>).)*<\/script>/s;
159
+ exports.META_CONTENT_TYPE_REGEX = /<meta[^"]*http-equiv="content-type"[^"]*content="text\/html;[^"]*charset=([^\s"(),./:;<=>?@[\]]*)"/is;
@@ -8,6 +8,7 @@ const onboarding_model_1 = require("../onboarding-model");
8
8
  const iconv_lite_1 = tslib_1.__importDefault(require("iconv-lite"));
9
9
  const encoding_japanese_1 = tslib_1.__importDefault(require("encoding-japanese"));
10
10
  const iconv_lite_2 = tslib_1.__importDefault(require("iconv-lite"));
11
+ const unsupported_encoding_error_1 = require("../error/unsupported-encoding-error");
11
12
  class VirtualOrestesApp {
12
13
  customerConfig;
13
14
  crawler;
@@ -95,9 +96,9 @@ class VirtualOrestesApp {
95
96
  : null;
96
97
  const encodingFromBuffer = encoding_japanese_1.default.detect(buffer);
97
98
  const encodedBody = iconv_lite_2.default
98
- .decode(buffer, encodingFromHeader ?? encodingFromBuffer)
99
+ .decode(buffer, encodingFromHeader ?? "utf-8")
99
100
  .toString();
100
- const metaSelector = /<meta http-equiv="content-type" content="text\/html;charset=([^\s"(),./:;<=>?@[\]]*)">/is;
101
+ const metaSelector = onboarding_model_1.META_CONTENT_TYPE_REGEX;
101
102
  const encodingFromBodyMeta = metaSelector.test(encodedBody)
102
103
  ? metaSelector.exec(encodedBody)[1]
103
104
  : "";
@@ -105,6 +106,9 @@ class VirtualOrestesApp {
105
106
  encodingFromBodyMeta ||
106
107
  encodingFromBuffer ||
107
108
  "utf-8";
109
+ if (!iconv_lite_2.default.encodingExists(detectedEncoding)) {
110
+ throw new unsupported_encoding_error_1.UnsupportedEncodingError(`encoding is not supported by cli: "${detectedEncoding}"`);
111
+ }
108
112
  return {
109
113
  responseContent: iconv_lite_1.default.decode(Buffer.from(buffer), detectedEncoding),
110
114
  responseEncoding: detectedEncoding,
@@ -732,5 +732,5 @@
732
732
  ]
733
733
  }
734
734
  },
735
- "version": "3.9.0"
735
+ "version": "3.9.1"
736
736
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@speedkit/cli",
3
3
  "description": "Speed Kit CLI",
4
- "version": "3.9.0",
4
+ "version": "3.9.1",
5
5
  "author": {
6
6
  "name": "Baqend.com",
7
7
  "email": "info@baqend.com"