@intuned/runtime-dev 1.0.0-udas.6 → 1.0.2-abort.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/dist/commands/common/utils/unixSocket.js +0 -1
- package/dist/commands/interface/run.js +1 -5
- package/dist/common/contextStorageStateHelpers.js +2 -6
- package/dist/common/getPlaywrightConstructs.js +0 -17
- package/package.json +1 -1
- package/Intuned.json +0 -5
- package/api/authed.ts +0 -12
- package/api/test.ts +0 -3
- package/api/test2.ts +0 -27
- package/auth-sessions/check.ts +0 -11
- package/auth-sessions/create.ts +0 -32
- package/authSessions +0 -1
- package/output.txt +0 -39
|
@@ -119,11 +119,6 @@ function runAutomationCLI(importFunction) {
|
|
|
119
119
|
const input = inputParseResult.data;
|
|
120
120
|
if (input.type === "abort") {
|
|
121
121
|
abortController.abort();
|
|
122
|
-
await (0, _promises.setTimeout)(10);
|
|
123
|
-
jsonUnixSocket.sendJSON({
|
|
124
|
-
type: "done",
|
|
125
|
-
result: null
|
|
126
|
-
});
|
|
127
122
|
break;
|
|
128
123
|
}
|
|
129
124
|
if (input.type === "tokenUpdate") {
|
|
@@ -179,6 +174,7 @@ function runAutomationCLI(importFunction) {
|
|
|
179
174
|
}
|
|
180
175
|
if (!client.closed) {
|
|
181
176
|
client.end();
|
|
177
|
+
await Promise.race([new Promise(resolve => client.once("close", resolve)), new Promise(resolve => client.once("error", resolve)), (0, _promises.setTimeout)(3000)]);
|
|
182
178
|
}
|
|
183
179
|
process.exit(0);
|
|
184
180
|
});
|
|
@@ -35,11 +35,8 @@ async function getContextStorageState(context) {
|
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
37
|
async function setContextStorageState(context, storage) {
|
|
38
|
-
console.log("Setting storage state");
|
|
39
38
|
await context.intunedSetStorageState(storage);
|
|
40
|
-
console.log("Storage state set");
|
|
41
39
|
const sessionStorage = storage.sessionStorage;
|
|
42
|
-
console.log("Adding init script session");
|
|
43
40
|
await context.addInitScript(storage => {
|
|
44
41
|
for (const {
|
|
45
42
|
origin,
|
|
@@ -47,12 +44,11 @@ async function setContextStorageState(context, storage) {
|
|
|
47
44
|
} of storage) {
|
|
48
45
|
if (window.location.origin === origin) {
|
|
49
46
|
for (const item of sessionStorage) {
|
|
50
|
-
const
|
|
51
|
-
if (
|
|
47
|
+
const existingValue = window.sessionStorage.getItem(item.name);
|
|
48
|
+
if (existingValue !== null) continue;
|
|
52
49
|
window.sessionStorage.setItem(item.name, item.value);
|
|
53
50
|
}
|
|
54
51
|
}
|
|
55
52
|
}
|
|
56
53
|
}, sessionStorage);
|
|
57
|
-
console.log("Added init script session");
|
|
58
54
|
}
|
|
@@ -45,16 +45,9 @@ async function getProductionPlaywrightConstructs({
|
|
|
45
45
|
}
|
|
46
46
|
const executablePath = playwright.chromium.executablePath();
|
|
47
47
|
const chromium127Path = executablePath.replace("chromium-1117", "chromium-1124");
|
|
48
|
-
console.log("Checking if chrome exists at", chromium127Path);
|
|
49
48
|
const isChrome127There = await (0, _fsExtra.exists)(chromium127Path);
|
|
50
|
-
console.log({
|
|
51
|
-
isChrome127There
|
|
52
|
-
});
|
|
53
49
|
const userAgent = `Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/${isChrome127There ? 127 : 125}.0.0.0 Safari/537.36`;
|
|
54
|
-
console.log("Creating user dir with preferences");
|
|
55
50
|
const userDataDir = await createUserDirWithPreferences();
|
|
56
|
-
console.log("User data dir created", userDataDir);
|
|
57
|
-
console.log("Launching playwright context");
|
|
58
51
|
const context = await playwright.chromium.launchPersistentContext(userDataDir, {
|
|
59
52
|
headless,
|
|
60
53
|
ignoreDefaultArgs: [...getChromiumLaunchArgsToIgnore(), "--headless"],
|
|
@@ -64,7 +57,6 @@ async function getProductionPlaywrightConstructs({
|
|
|
64
57
|
downloadsPath,
|
|
65
58
|
userAgent
|
|
66
59
|
});
|
|
67
|
-
console.log("Playwright context launched");
|
|
68
60
|
context.once("close", async () => {
|
|
69
61
|
try {
|
|
70
62
|
await (0, _fsExtra.rm)(userDataDir, {
|
|
@@ -78,29 +70,20 @@ async function getProductionPlaywrightConstructs({
|
|
|
78
70
|
}
|
|
79
71
|
});
|
|
80
72
|
if (storageState) {
|
|
81
|
-
console.log("Loading session to context");
|
|
82
73
|
await loadSessionToContext({
|
|
83
74
|
context,
|
|
84
75
|
session: storageState
|
|
85
76
|
});
|
|
86
|
-
console.log("Session loaded to context");
|
|
87
|
-
} else {
|
|
88
|
-
console.log("No session to load");
|
|
89
77
|
}
|
|
90
|
-
console.log("Adding init script");
|
|
91
78
|
const assetsFile = _path.default.join(__dirname, "./assets/browser_scripts.js");
|
|
92
79
|
await context.addInitScript({
|
|
93
80
|
path: assetsFile
|
|
94
81
|
});
|
|
95
|
-
console.log("Init script added");
|
|
96
82
|
let page = context.pages().at(0);
|
|
97
83
|
if (page) {
|
|
98
|
-
console.log("Adding script to page");
|
|
99
84
|
const scriptString = await (0, _fsExtra.readFile)(assetsFile, "utf8");
|
|
100
85
|
await page.evaluate(scriptString);
|
|
101
|
-
console.log("Script added to page");
|
|
102
86
|
} else {
|
|
103
|
-
console.log("Creating new page");
|
|
104
87
|
page = await context.newPage();
|
|
105
88
|
}
|
|
106
89
|
return {
|
package/package.json
CHANGED
package/Intuned.json
DELETED
package/api/authed.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Page, BrowserContext } from "@intuned/playwright-core";
|
|
2
|
-
|
|
3
|
-
export default async function authed(
|
|
4
|
-
params: any,
|
|
5
|
-
page: Page,
|
|
6
|
-
context: BrowserContext
|
|
7
|
-
) {
|
|
8
|
-
await page.goto("https://setcookie.net");
|
|
9
|
-
return {
|
|
10
|
-
cookies: await page.locator("ul li code").allInnerTexts(),
|
|
11
|
-
};
|
|
12
|
-
}
|
package/api/test.ts
DELETED
package/api/test2.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { Page, BrowserContext } from "@intuned/playwright-core";
|
|
2
|
-
import { extendTimeout, extendPayload } from "../src/runtime";
|
|
3
|
-
|
|
4
|
-
export default async function test2(
|
|
5
|
-
{ n }: { n?: number },
|
|
6
|
-
page: Page,
|
|
7
|
-
context: BrowserContext
|
|
8
|
-
) {
|
|
9
|
-
await page.goto("https://wikipedia.org/");
|
|
10
|
-
await page.waitForTimeout(1000);
|
|
11
|
-
|
|
12
|
-
const titles: string[] = [];
|
|
13
|
-
|
|
14
|
-
for (let i = 0; i < (n ?? 2); i++) {
|
|
15
|
-
await page.goto(`https://wikipedia.org/wiki/Special:Random`);
|
|
16
|
-
await page.waitForTimeout(1000);
|
|
17
|
-
titles.push(await page.locator("h1").innerText());
|
|
18
|
-
extendTimeout();
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
extendPayload({
|
|
22
|
-
api: "test",
|
|
23
|
-
parameters: {},
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
return { titles };
|
|
27
|
-
}
|
package/auth-sessions/check.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Page, BrowserContext } from "@intuned/playwright-core";
|
|
2
|
-
|
|
3
|
-
export default async function check(
|
|
4
|
-
page: Page,
|
|
5
|
-
_context: BrowserContext
|
|
6
|
-
): Promise<boolean> {
|
|
7
|
-
await page.goto("https://setcookie.net");
|
|
8
|
-
const result = (await page.locator("ul li code").all()).length > 0;
|
|
9
|
-
console.log("Check result", result);
|
|
10
|
-
return result;
|
|
11
|
-
}
|
package/auth-sessions/create.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { Page, BrowserContext } from "@intuned/playwright-core";
|
|
2
|
-
import {
|
|
3
|
-
requestOTP,
|
|
4
|
-
requestMultipleChoice,
|
|
5
|
-
} from "../src/runtime/requestMoreInfo";
|
|
6
|
-
|
|
7
|
-
// eslint-disable-next-line require-yield
|
|
8
|
-
export default async function* create(
|
|
9
|
-
params: any,
|
|
10
|
-
page: Page,
|
|
11
|
-
context: BrowserContext
|
|
12
|
-
) {
|
|
13
|
-
await page.goto("https://setcookie.net/");
|
|
14
|
-
await page.locator("#name").fill("intuned");
|
|
15
|
-
await page.locator("#value").fill("password");
|
|
16
|
-
await page.locator("input[type=submit]").click();
|
|
17
|
-
|
|
18
|
-
// console.log("Received", yield requestOTP("Enter useless otp"));
|
|
19
|
-
// console.log(
|
|
20
|
-
// "Received",
|
|
21
|
-
// yield requestMultipleChoice("Choose the correct answer", [
|
|
22
|
-
// "A",
|
|
23
|
-
// "B",
|
|
24
|
-
// "C",
|
|
25
|
-
// "D",
|
|
26
|
-
// ])
|
|
27
|
-
// );
|
|
28
|
-
|
|
29
|
-
await page.goto("http://www.sharonminsuk.com/code/storage-test.html");
|
|
30
|
-
await page.locator("#local").fill("intuned");
|
|
31
|
-
await page.locator("#local + input[type=button]").click();
|
|
32
|
-
}
|
package/authSessions
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"cookies":[{"name":"intuned","value":"password","domain":"setcookie.net","path":"/","expires":-1,"httpOnly":true,"secure":false,"sameSite":"Lax"}],"origins":[{"origin":"http://www.sharonminsuk.com","localStorage":[{"name":"theirValue","value":"intuned"}]}],"sessionStorage":[{"origin":"http://www.sharonminsuk.com","sessionStorage":[]}]}
|