@speedkit/cli 2.41.4 → 2.42.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.42.0](https://gitlab.orestes.info/baqend/speed-kit-cli/compare/v2.41.4...v2.42.0) (2024-07-17)
2
+
3
+
4
+ ### Features
5
+
6
+ * **onboarding:** authenticate virtual orestesApp against origin ([dc13ad5](https://gitlab.orestes.info/baqend/speed-kit-cli/commit/dc13ad50442157e5a34f60fa46d468eba34b8ba6))
7
+
1
8
  ## [2.41.4](https://gitlab.orestes.info/baqend/speed-kit-cli/compare/v2.41.3...v2.41.4) (2024-07-12)
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/2.41.4 linux-x64 node-v20.15.1
24
+ @speedkit/cli/2.42.0 linux-x64 node-v20.15.1
25
25
  $ sk --help [COMMAND]
26
26
  USAGE
27
27
  $ sk COMMAND
@@ -7,4 +7,5 @@ export declare class Crawler {
7
7
  fetchRemote(originUrl: string, variation: string): Promise<Response>;
8
8
  private setDefaultUserAgent;
9
9
  private prepareOriginRequest;
10
+ private prepareAuthRequest;
10
11
  }
@@ -22,7 +22,7 @@ class Crawler {
22
22
  const userAgent = this.setDefaultUserAgent(variation);
23
23
  const headers = { "User-Agent": userAgent };
24
24
  const requestInit = {
25
- ...this.prepareOriginRequest(variation, {
25
+ ...this.prepareOriginRequest(originUrl, variation, {
26
26
  headers,
27
27
  }),
28
28
  agent,
@@ -41,7 +41,7 @@ class Crawler {
41
41
  }
42
42
  return onboarding_model_1.USER_AGENT.DESKTOP;
43
43
  }
44
- prepareOriginRequest(variationParameter, init) {
44
+ prepareOriginRequest(originUrl, variationParameter, init) {
45
45
  if (!this.speedKitServerConfig || !variationParameter) {
46
46
  return init;
47
47
  }
@@ -52,7 +52,27 @@ class Crawler {
52
52
  return init;
53
53
  }
54
54
  }
55
+ const authentication = this.prepareAuthRequest(originUrl);
56
+ if (authentication) {
57
+ init.headers["Authorization"] = authentication;
58
+ }
55
59
  return init;
56
60
  }
61
+ prepareAuthRequest(originUrl) {
62
+ if (!this.speedKitServerConfig ||
63
+ this.speedKitServerConfig.speedKit?.authentications?.length < 1) {
64
+ return;
65
+ }
66
+ const origin = new URL(originUrl).origin;
67
+ for (const auth of this.speedKitServerConfig.speedKit.authentications) {
68
+ if (!auth.uri.includes(origin)) {
69
+ continue;
70
+ }
71
+ if (auth.type === "basic") {
72
+ return `Basic ${Buffer.from(`${auth.user}:${auth.password}`).toString("base64")}`;
73
+ }
74
+ }
75
+ return;
76
+ }
57
77
  }
58
78
  exports.Crawler = Crawler;
@@ -712,5 +712,5 @@
712
712
  ]
713
713
  }
714
714
  },
715
- "version": "2.41.4"
715
+ "version": "2.42.0"
716
716
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@speedkit/cli",
3
3
  "description": "Speed Kit CLI",
4
- "version": "2.41.4",
4
+ "version": "2.42.0",
5
5
  "author": {
6
6
  "name": "Baqend.com",
7
7
  "email": "info@baqend.com"