@speedkit/cli 4.45.1 → 4.45.2
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 +7 -0
- package/dist/services/onboarding/inject/deployed-installation.d.ts +5 -0
- package/dist/services/onboarding/inject/deployed-installation.js +9 -2
- package/dist/services/onboarding/spec/inject/deployed-installation.spec.js +8 -8
- package/oclif.manifest.json +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## [4.45.2](https://gitlab.orestes.info/baqend/speed-kit-cli/compare/v4.45.1...v4.45.2) (2026-10-16)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* inject mode requests the install resource as Chrome, without the d parameter ([800f3d6](https://gitlab.orestes.info/baqend/speed-kit-cli/commit/800f3d612b1de6c6185006d850ca82fd92bb6d57))
|
|
7
|
+
|
|
1
8
|
## [4.45.1](https://gitlab.orestes.info/baqend/speed-kit-cli/compare/v4.45.0...v4.45.1) (2026-10-16)
|
|
2
9
|
|
|
3
10
|
|
|
@@ -7,6 +7,11 @@ export interface DeployedInstallation {
|
|
|
7
7
|
}
|
|
8
8
|
/** Reads the service worker path and the scope out of the config in an install resource. */
|
|
9
9
|
export declare function parseInstallResource(installJs: string, origin: string): DeployedInstallation | undefined;
|
|
10
|
+
/**
|
|
11
|
+
* A desktop Chrome user agent. The server answers an unknown browser with a challenge script that
|
|
12
|
+
* names no service worker.
|
|
13
|
+
*/
|
|
14
|
+
export declare const INSTALL_RESOURCE_USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36";
|
|
10
15
|
/**
|
|
11
16
|
* Fetches the install resource as a page of `origin` does, and reads the installation from it.
|
|
12
17
|
*
|
|
@@ -8,15 +8,22 @@ export function parseInstallResource(installJs, origin) {
|
|
|
8
8
|
const scope = /\bscope:\s*"([^"]+)"/.exec(installJs)?.[1];
|
|
9
9
|
return { swPath: new URL(sw, origin).pathname, scope: scope ?? "/" };
|
|
10
10
|
}
|
|
11
|
+
/**
|
|
12
|
+
* A desktop Chrome user agent. The server answers an unknown browser with a challenge script that
|
|
13
|
+
* names no service worker.
|
|
14
|
+
*/
|
|
15
|
+
export const INSTALL_RESOURCE_USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36";
|
|
11
16
|
/**
|
|
12
17
|
* Fetches the install resource as a page of `origin` does, and reads the installation from it.
|
|
13
18
|
*
|
|
14
19
|
* @throws {InjectInstallationError} When the server answers with no install resource for the origin.
|
|
15
20
|
*/
|
|
16
21
|
export async function readDeployedInstallation(installPath, origin, fetchResource = fetch) {
|
|
17
|
-
const
|
|
22
|
+
const url = new URL(installPath, origin);
|
|
23
|
+
url.searchParams.delete("d");
|
|
24
|
+
const installUrl = url.href;
|
|
18
25
|
const response = await fetchResource(installUrl, {
|
|
19
|
-
headers: { origin },
|
|
26
|
+
headers: { origin, "user-agent": INSTALL_RESOURCE_USER_AGENT },
|
|
20
27
|
}).catch((error) => {
|
|
21
28
|
throw new InjectInstallationError(installUrl, String(error));
|
|
22
29
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { expect } from "chai";
|
|
2
2
|
import { describe, it } from "mocha";
|
|
3
3
|
import { InjectInstallationError } from "../../error/inject-installation-error.js";
|
|
4
|
-
import { parseInstallResource, readDeployedInstallation, } from "../../inject/deployed-installation.js";
|
|
4
|
+
import { INSTALL_RESOURCE_USER_AGENT, parseInstallResource, readDeployedInstallation, } from "../../inject/deployed-installation.js";
|
|
5
5
|
const ORIGIN = "https://www.example.com";
|
|
6
6
|
const INSTALL = "https://example.app.baqend.com/v1/speedkit/install.js";
|
|
7
7
|
function answer(status, body = "") {
|
|
@@ -19,22 +19,22 @@ describe("parseInstallResource", () => {
|
|
|
19
19
|
});
|
|
20
20
|
});
|
|
21
21
|
describe("readDeployedInstallation", () => {
|
|
22
|
-
it("fetches the install resource as a page of the origin", async () => {
|
|
22
|
+
it("fetches the install resource as Chrome on a page of the origin, without the d parameter", async () => {
|
|
23
23
|
const requests = [];
|
|
24
24
|
const fetchResource = (async (url, init) => {
|
|
25
|
-
requests.push({
|
|
26
|
-
url,
|
|
27
|
-
origin: init.headers.origin,
|
|
28
|
-
});
|
|
25
|
+
requests.push({ url, headers: init.headers });
|
|
29
26
|
return new Response(`{sw:"/wrapper-sw.js?r=abc"}`);
|
|
30
27
|
});
|
|
31
|
-
const installation = await readDeployedInstallation(`${INSTALL}?r=abc`, ORIGIN, fetchResource);
|
|
28
|
+
const installation = await readDeployedInstallation(`${INSTALL}?d=production&r=abc`, ORIGIN, fetchResource);
|
|
32
29
|
expect(installation).to.deep.equal({
|
|
33
30
|
swPath: "/wrapper-sw.js",
|
|
34
31
|
scope: "/",
|
|
35
32
|
});
|
|
36
33
|
expect(requests).to.deep.equal([
|
|
37
|
-
{
|
|
34
|
+
{
|
|
35
|
+
url: `${INSTALL}?r=abc`,
|
|
36
|
+
headers: { origin: ORIGIN, "user-agent": INSTALL_RESOURCE_USER_AGENT },
|
|
37
|
+
},
|
|
38
38
|
]);
|
|
39
39
|
});
|
|
40
40
|
it("fails when the origin has no live installation", async () => {
|
package/oclif.manifest.json
CHANGED