@intuned/runtime-dev 1.1.5-dev-52 → 1.1.6-bot-detection
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/api/run.js +2 -8
- package/dist/commands/auth-sessions/run-check.js +4 -18
- package/dist/commands/auth-sessions/run-create.js +1 -2
- package/dist/commands/cli-auth-sessions/utils.d.ts +1 -1
- package/dist/commands/cli-auth-sessions/utils.js +1 -1
- package/dist/commands/common/browserUtils.d.ts +1 -1
- package/dist/commands/common/browserUtils.js +1 -1
- package/dist/commands/interface/run.js +0 -2
- package/dist/common/asyncLocalStorage/index.d.ts +2 -1
- package/dist/common/cli/constants.js +1 -1
- package/dist/common/cli/types.d.ts +1 -1
- package/dist/common/contextStorageStateHelpers.d.ts +1 -1
- package/dist/common/contextStorageStateHelpers.js +0 -56
- package/dist/common/getPlaywrightConstructs.d.ts +1 -1
- package/dist/common/getPlaywrightConstructs.js +2 -10
- package/dist/common/runApi/errors.d.ts +1 -1
- package/dist/common/runApi/errors.js +1 -1
- package/dist/common/runApi/index.d.ts +1 -1
- package/dist/common/runApi/types.d.ts +16 -16
- package/dist/index.d.ts +1 -1
- package/dist/index.js +0 -6
- package/dist/runtime/export.d.ts +0 -1
- package/dist/runtime/extendTimeout.js +7 -0
- package/dist/runtime/index.d.ts +0 -1
- package/dist/runtime/index.js +0 -7
- package/package.json +3 -2
- package/template.tsconfig.json +7 -4
- package/dist/common/backendFunctions/getAuthSessionParameters.d.ts +0 -1
- package/dist/common/backendFunctions/getAuthSessionParameters.js +0 -38
- package/dist/runtime/getAuthSessionParameters.d.ts +0 -1
- package/dist/runtime/getAuthSessionParameters.js +0 -20
package/dist/commands/api/run.js
CHANGED
|
@@ -17,7 +17,6 @@ var _nanoid = require("nanoid");
|
|
|
17
17
|
var _chalk = _interopRequireDefault(require("chalk"));
|
|
18
18
|
var _runApi = require("../../common/runApi");
|
|
19
19
|
var _tsNodeImport = require("../common/tsNodeImport");
|
|
20
|
-
var _isNil = _interopRequireDefault(require("lodash/isNil"));
|
|
21
20
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
22
21
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
23
22
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
@@ -96,7 +95,7 @@ async function executeCLI(apiName, mode, inputData, options) {
|
|
|
96
95
|
_Logger.logger.info("This will only take an effect if this API run was part of a job.");
|
|
97
96
|
}
|
|
98
97
|
}
|
|
99
|
-
_commander.program.description("run the user function in the cli for testing purposes").option("-i, --input [file]", "input json file").option("-j, --json [json]", "input json string").option("--cdpAddress <cdpAddress>", "CDP address", "http://localhost:9222").option("--authSessionPath <authSession>", "auth session to use when executing the api").option("--outputFileId <outputFileId>", "the output file id to save the result in").option("--proxy <proxy>", "proxy to use").
|
|
98
|
+
_commander.program.description("run the user function in the cli for testing purposes").option("-i, --input [file]", "input json file").option("-j, --json [json]", "input json string").option("--cdpAddress <cdpAddress>", "CDP address", "http://localhost:9222").option("--authSessionPath <authSession>", "auth session to use when executing the api").option("--outputFileId <outputFileId>", "the output file id to save the result in").option("--proxy <proxy>", "proxy to use").argument("[apiName]", "name of the api", "default").allowUnknownOption().addArgument(new _commander.Argument("<mode>", "mode of execution").choices(["vanilla", "playwright", "playwright-standalone", "playwright-headless"]).default("playwright-standalone").argOptional()).action(async (apiName, mode, options) => {
|
|
100
99
|
let inputData = null;
|
|
101
100
|
if (options.input) {
|
|
102
101
|
inputData = await fs.readJSON(options.input);
|
|
@@ -105,16 +104,11 @@ _commander.program.description("run the user function in the cli for testing pur
|
|
|
105
104
|
} else {
|
|
106
105
|
inputData = {};
|
|
107
106
|
}
|
|
108
|
-
let authSessionParametersJson = undefined;
|
|
109
|
-
if (!(0, _isNil.default)(options === null || options === void 0 ? void 0 : options.authSessionParameters)) {
|
|
110
|
-
authSessionParametersJson = JSON.parse(options.authSessionParameters);
|
|
111
|
-
}
|
|
112
107
|
await (0, _asyncLocalStorage.runWithContext)({
|
|
113
108
|
runEnvironment: _enums.RunEnvironment.IDE,
|
|
114
109
|
extendedPayloads: [],
|
|
115
110
|
runId: (0, _nanoid.nanoid)(),
|
|
116
|
-
proxy: options.proxy
|
|
117
|
-
getAuthSessionParameters: authSessionParametersJson !== undefined ? async () => authSessionParametersJson : undefined
|
|
111
|
+
proxy: options.proxy
|
|
118
112
|
}, () => executeCLI(apiName, mode, inputData, options));
|
|
119
113
|
process.exit(0);
|
|
120
114
|
});
|
|
@@ -9,20 +9,15 @@ var _dotenv = _interopRequireDefault(require("dotenv"));
|
|
|
9
9
|
var _constants = require("../../common/constants");
|
|
10
10
|
var _runApi = require("../../common/runApi");
|
|
11
11
|
var _tsNodeImport = require("../common/tsNodeImport");
|
|
12
|
-
var _enums = require("../../runtime/enums");
|
|
13
|
-
var _nanoid = require("nanoid");
|
|
14
|
-
var _asyncLocalStorage = require("../../common/asyncLocalStorage");
|
|
15
|
-
var _isNil = _interopRequireDefault(require("lodash/isNil"));
|
|
16
12
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
17
13
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
18
14
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
19
15
|
_dotenv.default.config({
|
|
20
16
|
path: `.env`
|
|
21
17
|
});
|
|
22
|
-
_commander.program.description("run auth session check").option("--cdpAddress <cdpAddress>", "CDP address", "http://localhost:9222").option("--authSessionPath <authSession>", "auth session to use when executing the check").
|
|
18
|
+
_commander.program.description("run auth session check").option("--cdpAddress <cdpAddress>", "CDP address", "http://localhost:9222").option("--authSessionPath <authSession>", "auth session to use when executing the check").allowUnknownOption().addArgument(new _commander.Argument("<mode>", "mode of execution").choices(["vanilla", "playwright", "playwright-standalone"]).default("playwright-standalone").argOptional()).action(async (mode, {
|
|
23
19
|
cdpAddress,
|
|
24
|
-
authSessionPath
|
|
25
|
-
authSessionParameters
|
|
20
|
+
authSessionPath
|
|
26
21
|
}) => {
|
|
27
22
|
const setting = await (0, _settings.getSettings)();
|
|
28
23
|
if (!setting.authSessions.enabled) {
|
|
@@ -32,16 +27,7 @@ _commander.program.description("run auth session check").option("--cdpAddress <c
|
|
|
32
27
|
if (!fs.exists(checkFilePath)) {
|
|
33
28
|
throw new Error("auth session check file not found");
|
|
34
29
|
}
|
|
35
|
-
|
|
36
|
-
if (!(0, _isNil.default)(authSessionParameters)) {
|
|
37
|
-
authSessionParametersJson = JSON.parse(authSessionParameters);
|
|
38
|
-
}
|
|
39
|
-
const runApiResult = await (0, _asyncLocalStorage.runWithContext)({
|
|
40
|
-
runEnvironment: _enums.RunEnvironment.IDE,
|
|
41
|
-
extendedPayloads: [],
|
|
42
|
-
runId: (0, _nanoid.nanoid)(),
|
|
43
|
-
getAuthSessionParameters: authSessionParametersJson !== undefined ? async () => authSessionParametersJson : undefined
|
|
44
|
-
}, async () => await (0, _runApi.runApi)({
|
|
30
|
+
const runApiResult = await (0, _runApi.runApi)({
|
|
45
31
|
automationFunction: {
|
|
46
32
|
name: `${_constants.AUTH_SESSIONS_FOLDER_NAME}/check`
|
|
47
33
|
},
|
|
@@ -58,7 +44,7 @@ _commander.program.description("run auth session check").option("--cdpAddress <c
|
|
|
58
44
|
runCheck: false
|
|
59
45
|
},
|
|
60
46
|
importFunction: _tsNodeImport.tsNodeImport
|
|
61
|
-
})
|
|
47
|
+
});
|
|
62
48
|
if (runApiResult.isErr()) {
|
|
63
49
|
if (runApiResult.error instanceof _runApi.AutomationError) {
|
|
64
50
|
throw runApiResult.error.error;
|
|
@@ -94,8 +94,7 @@ _commander.program.description("run auth session create").option("--cdpAddress <
|
|
|
94
94
|
await (0, _asyncLocalStorage.runWithContext)({
|
|
95
95
|
runEnvironment: _enums.RunEnvironment.IDE,
|
|
96
96
|
extendedPayloads: [],
|
|
97
|
-
runId: (0, _nanoid.nanoid)()
|
|
98
|
-
getAuthSessionParameters: async () => inputData
|
|
97
|
+
runId: (0, _nanoid.nanoid)()
|
|
99
98
|
}, runCreate);
|
|
100
99
|
process.exit(0);
|
|
101
100
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { StorageState } from "../../common/contextStorageStateHelpers";
|
|
2
2
|
import { AuthSessionMetadata, AuthSessionType } from "../../common/cli/types";
|
|
3
|
-
import * as playwright from "
|
|
3
|
+
import * as playwright from "patchright";
|
|
4
4
|
export declare function isAuthEnabled(): Promise<boolean>;
|
|
5
5
|
export declare function getAuthType(): Promise<AuthSessionType>;
|
|
6
6
|
export declare function ensureRecorderURLs(): Promise<{
|
|
@@ -26,7 +26,7 @@ var _tsNodeImport = require("../common/tsNodeImport");
|
|
|
26
26
|
var _promptly = require("promptly");
|
|
27
27
|
var _utils = require("../../common/cli/utils");
|
|
28
28
|
var _types = require("../../common/cli/types");
|
|
29
|
-
var playwright = _interopRequireWildcard(require("
|
|
29
|
+
var playwright = _interopRequireWildcard(require("patchright"));
|
|
30
30
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
31
31
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
32
32
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BrowserContext } from "
|
|
1
|
+
import { BrowserContext } from "patchright";
|
|
2
2
|
export declare const REMOTE_DEBUGGING_PORT = 9222;
|
|
3
3
|
export declare const getChromiumLaunchArgs: () => string[];
|
|
4
4
|
export declare function startOrRestartBrowser(): Promise<void>;
|
|
@@ -9,7 +9,7 @@ exports.saveSession = saveSession;
|
|
|
9
9
|
exports.saveSessionFromOpenedBrowser = saveSessionFromOpenedBrowser;
|
|
10
10
|
exports.startOrRestartBrowser = startOrRestartBrowser;
|
|
11
11
|
var _child_process = require("child_process");
|
|
12
|
-
var playwright = _interopRequireWildcard(require("
|
|
12
|
+
var playwright = _interopRequireWildcard(require("patchright"));
|
|
13
13
|
var fs = _interopRequireWildcard(require("fs-extra"));
|
|
14
14
|
var _fileUtils = require("./utils/fileUtils");
|
|
15
15
|
var _contextStorageStateHelpers = require("../../common/contextStorageStateHelpers");
|
|
@@ -16,7 +16,6 @@ var _promises = require("timers/promises");
|
|
|
16
16
|
var _jwtTokenManager = require("../../common/jwtTokenManager");
|
|
17
17
|
var _formatZodError = require("../../common/formatZodError");
|
|
18
18
|
var _neverthrow = require("neverthrow");
|
|
19
|
-
var _getAuthSessionParameters = require("../../common/backendFunctions/getAuthSessionParameters");
|
|
20
19
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
21
20
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
22
21
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
@@ -125,7 +124,6 @@ function runAutomationCLI(importFunction) {
|
|
|
125
124
|
});
|
|
126
125
|
}
|
|
127
126
|
},
|
|
128
|
-
getAuthSessionParameters: _getAuthSessionParameters.getAuthSessionParameters,
|
|
129
127
|
...(message.parameters.context ?? {}),
|
|
130
128
|
proxy: getProxyUrlFromRunOptions(message.parameters.runOptions)
|
|
131
129
|
};
|
|
@@ -5,11 +5,12 @@ export declare const asyncLocalStorage: AsyncLocalStorage<InternalRunInfo>;
|
|
|
5
5
|
export declare function runWithContext<R, TArgs extends any[]>(contextData: InternalRunInfo, callback: (...args: TArgs) => R, ...args: TArgs): R;
|
|
6
6
|
interface TimeoutInfo {
|
|
7
7
|
extendTimeoutCallback?: () => Promise<void>;
|
|
8
|
+
timeoutDuration?: number;
|
|
9
|
+
timeoutTimestamp?: number;
|
|
8
10
|
}
|
|
9
11
|
export interface InternalRunInfo extends RunInfo {
|
|
10
12
|
extendedPayloads: Payload[];
|
|
11
13
|
timeoutInfo?: TimeoutInfo;
|
|
12
|
-
getAuthSessionParameters?: () => Promise<any>;
|
|
13
14
|
}
|
|
14
15
|
export declare function getExecutionContext(): InternalRunInfo | undefined;
|
|
15
16
|
export {};
|
|
@@ -9,45 +9,6 @@ async function setStorageState(context, state) {
|
|
|
9
9
|
if ("cookies" in state && state.cookies) {
|
|
10
10
|
await context.addCookies(state.cookies);
|
|
11
11
|
}
|
|
12
|
-
const page = await context.newPage();
|
|
13
|
-
if ("origins" in state && state.origins) {
|
|
14
|
-
for (const originData of state.origins || []) {
|
|
15
|
-
const origin = originData.origin;
|
|
16
|
-
await page.route(`${origin}/*`, route => route.fulfill({
|
|
17
|
-
body: "<html><head><title>Set Storage</title></head><body><h1>Set Storage</h1></body></html>",
|
|
18
|
-
contentType: "text/html",
|
|
19
|
-
status: 200
|
|
20
|
-
}));
|
|
21
|
-
try {
|
|
22
|
-
await page.goto(origin);
|
|
23
|
-
for (const item of originData.localStorage) {
|
|
24
|
-
await page.evaluate(([key, value]) => {
|
|
25
|
-
window.localStorage.setItem(key, value);
|
|
26
|
-
}, [item.name, item.value]);
|
|
27
|
-
}
|
|
28
|
-
} finally {
|
|
29
|
-
await page.unroute(`${origin}/*`);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
if ("sessionStorage" in state && state.sessionStorage) {
|
|
34
|
-
await context.addInitScript(storage => {
|
|
35
|
-
for (const {
|
|
36
|
-
origin,
|
|
37
|
-
sessionStorage
|
|
38
|
-
} of storage) {
|
|
39
|
-
if (window.location.origin === origin) {
|
|
40
|
-
for (const item of sessionStorage) {
|
|
41
|
-
const value = window.sessionStorage.getItem(item.name);
|
|
42
|
-
if (!value) {
|
|
43
|
-
window.sessionStorage.setItem(item.name, item.value);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}, state.sessionStorage);
|
|
49
|
-
}
|
|
50
|
-
await page.close();
|
|
51
12
|
}
|
|
52
13
|
async function getStorageState(context) {
|
|
53
14
|
const result = {};
|
|
@@ -58,23 +19,6 @@ async function getStorageState(context) {
|
|
|
58
19
|
const pages = await context.pages();
|
|
59
20
|
for (const page of pages) {
|
|
60
21
|
if (page.isClosed()) continue;
|
|
61
|
-
try {
|
|
62
|
-
const sessionData = await page.evaluate(() => {
|
|
63
|
-
const items = {
|
|
64
|
-
...window.sessionStorage
|
|
65
|
-
};
|
|
66
|
-
return {
|
|
67
|
-
origin: window.location.origin,
|
|
68
|
-
sessionStorage: Object.entries(items).map(([name, value]) => ({
|
|
69
|
-
name,
|
|
70
|
-
value
|
|
71
|
-
}))
|
|
72
|
-
};
|
|
73
|
-
});
|
|
74
|
-
sessionDataList.push(sessionData);
|
|
75
|
-
} catch (error) {
|
|
76
|
-
console.error("Error getting sessionStorage:", error);
|
|
77
|
-
}
|
|
78
22
|
}
|
|
79
23
|
result["sessionStorage"] = sessionDataList;
|
|
80
24
|
return result;
|
|
@@ -7,7 +7,7 @@ exports.getPlaywrightConstructsForMode = getPlaywrightConstructsForMode;
|
|
|
7
7
|
exports.getProductionPlaywrightConstructs = getProductionPlaywrightConstructs;
|
|
8
8
|
exports.getRemotePlaywrightContext = getRemotePlaywrightContext;
|
|
9
9
|
exports.loadSessionToContext = loadSessionToContext;
|
|
10
|
-
var playwright = _interopRequireWildcard(require("
|
|
10
|
+
var playwright = _interopRequireWildcard(require("patchright"));
|
|
11
11
|
var _fsExtra = _interopRequireWildcard(require("fs-extra"));
|
|
12
12
|
var fs = _fsExtra;
|
|
13
13
|
var _contextStorageStateHelpers = require("./contextStorageStateHelpers");
|
|
@@ -76,9 +76,6 @@ async function getProductionPlaywrightConstructs({
|
|
|
76
76
|
});
|
|
77
77
|
}
|
|
78
78
|
const assetsFile = _path.default.join(__dirname, "./assets/browser_scripts.js");
|
|
79
|
-
await context.addInitScript({
|
|
80
|
-
path: assetsFile
|
|
81
|
-
});
|
|
82
79
|
let page = context.pages().at(0);
|
|
83
80
|
if (page) {
|
|
84
81
|
const scriptString = await (0, _fsExtra.readFile)(assetsFile, "utf8");
|
|
@@ -104,15 +101,10 @@ async function getPlaywrightConstructsForMode(mode, cdpAddress, authSession) {
|
|
|
104
101
|
throw new Error("no context found");
|
|
105
102
|
}
|
|
106
103
|
const assetsFile = _path.default.join(__dirname, "./assets/browser_scripts.js");
|
|
107
|
-
await context.addInitScript({
|
|
108
|
-
path: assetsFile
|
|
109
|
-
});
|
|
110
104
|
const pages = await context.pages();
|
|
111
105
|
let page = null;
|
|
112
106
|
if (pages.length > 0) {
|
|
113
107
|
page = pages[0];
|
|
114
|
-
const scriptString = await fs.readFile(assetsFile, "utf8");
|
|
115
|
-
await page.evaluate(scriptString);
|
|
116
108
|
} else {
|
|
117
109
|
page = await context.newPage();
|
|
118
110
|
}
|
|
@@ -163,7 +155,7 @@ async function loadSessionToContext({
|
|
|
163
155
|
await (0, _contextStorageStateHelpers.setStorageState)(context, sessionToLoad);
|
|
164
156
|
}
|
|
165
157
|
async function getRemotePlaywrightContext(cdpAddress) {
|
|
166
|
-
const playwright = await Promise.resolve().then(() => _interopRequireWildcard(require("
|
|
158
|
+
const playwright = await Promise.resolve().then(() => _interopRequireWildcard(require("patchright")));
|
|
167
159
|
let browser = null;
|
|
168
160
|
if (!cdpAddress) {
|
|
169
161
|
throw new Error("cdpAddress is required");
|
|
@@ -10,7 +10,7 @@ export declare const maxLevelsExceededErrorCode = "MaxLevelsExceededError";
|
|
|
10
10
|
export declare const automationError = "AutomationError";
|
|
11
11
|
export declare const internalInvalidInputErrorCode = "InternalInvalidInputError";
|
|
12
12
|
export declare const runAutomationErrorCodes: readonly ["APINotFoundError", "InvalidAPIError", "InvalidCheckError", "AbortedError", "AuthRequiredError", "AuthCheckNotFoundError", "AuthCheckFailedError", "MaxLevelsExceededError", "AutomationError", "InternalInvalidInputError"];
|
|
13
|
-
export type RunAutomationErrorCode = typeof runAutomationErrorCodes[number];
|
|
13
|
+
export type RunAutomationErrorCode = (typeof runAutomationErrorCodes)[number];
|
|
14
14
|
export declare abstract class RunAutomationError<T = any> {
|
|
15
15
|
code: RunAutomationErrorCode;
|
|
16
16
|
statusCode: number;
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.runAutomationErrorCodes = exports.maxLevelsExceededErrorCode = exports.invalidCheckErrorCode = exports.invalidApiErrorCode = exports.internalInvalidInputErrorCode = exports.automationError = exports.authRequiredErrorCode = exports.authCheckNotFoundErrorCode = exports.authCheckFailedErrorCode = exports.apiNotFoundErrorCode = exports.abortedErrorCode = exports.RunAutomationError = exports.MaxLevelsExceededError = exports.InvalidCheckError = exports.InvalidApiError = exports.InternalInvalidInputError = exports.AutomationError = exports.AuthRequiredError = exports.AuthCheckNotFoundError = exports.AuthCheckFailedError = exports.ApiNotFoundError = exports.AbortedError = void 0;
|
|
7
7
|
var _runtime = require("../../runtime");
|
|
8
|
-
var playwright = _interopRequireWildcard(require("
|
|
8
|
+
var playwright = _interopRequireWildcard(require("patchright"));
|
|
9
9
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
10
10
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
11
11
|
const apiNotFoundErrorCode = exports.apiNotFoundErrorCode = "APINotFoundError";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Result } from "neverthrow";
|
|
2
2
|
import { RunAutomationError } from "./errors";
|
|
3
|
-
import { Page, BrowserContext } from "
|
|
3
|
+
import { Page, BrowserContext } from "patchright";
|
|
4
4
|
import { ExtendedRunApiParameters, RunApiResult, RunApiResultWithSessionOk } from "./types";
|
|
5
5
|
export * from "./types";
|
|
6
6
|
export * from "./errors";
|
|
@@ -47,18 +47,18 @@ export declare const runApiSessionSchema: z.ZodDiscriminatedUnion<"type", [z.Zod
|
|
|
47
47
|
secure: z.ZodBoolean;
|
|
48
48
|
sameSite: z.ZodEnum<["Strict", "Lax", "None"]>;
|
|
49
49
|
}, "strip", z.ZodTypeAny, {
|
|
50
|
+
path: string;
|
|
50
51
|
value: string;
|
|
51
52
|
name: string;
|
|
52
|
-
path: string;
|
|
53
53
|
domain: string;
|
|
54
54
|
expires: number;
|
|
55
55
|
httpOnly: boolean;
|
|
56
56
|
secure: boolean;
|
|
57
57
|
sameSite: "Strict" | "Lax" | "None";
|
|
58
58
|
}, {
|
|
59
|
+
path: string;
|
|
59
60
|
value: string;
|
|
60
61
|
name: string;
|
|
61
|
-
path: string;
|
|
62
62
|
domain: string;
|
|
63
63
|
expires: number;
|
|
64
64
|
httpOnly: boolean;
|
|
@@ -117,9 +117,9 @@ export declare const runApiSessionSchema: z.ZodDiscriminatedUnion<"type", [z.Zod
|
|
|
117
117
|
}>, "many">>;
|
|
118
118
|
}, "strip", z.ZodTypeAny, {
|
|
119
119
|
cookies: {
|
|
120
|
+
path: string;
|
|
120
121
|
value: string;
|
|
121
122
|
name: string;
|
|
122
|
-
path: string;
|
|
123
123
|
domain: string;
|
|
124
124
|
expires: number;
|
|
125
125
|
httpOnly: boolean;
|
|
@@ -142,9 +142,9 @@ export declare const runApiSessionSchema: z.ZodDiscriminatedUnion<"type", [z.Zod
|
|
|
142
142
|
}[] | undefined;
|
|
143
143
|
}, {
|
|
144
144
|
cookies: {
|
|
145
|
+
path: string;
|
|
145
146
|
value: string;
|
|
146
147
|
name: string;
|
|
147
|
-
path: string;
|
|
148
148
|
domain: string;
|
|
149
149
|
expires: number;
|
|
150
150
|
httpOnly: boolean;
|
|
@@ -170,9 +170,9 @@ export declare const runApiSessionSchema: z.ZodDiscriminatedUnion<"type", [z.Zod
|
|
|
170
170
|
type: "state";
|
|
171
171
|
state?: {
|
|
172
172
|
cookies: {
|
|
173
|
+
path: string;
|
|
173
174
|
value: string;
|
|
174
175
|
name: string;
|
|
175
|
-
path: string;
|
|
176
176
|
domain: string;
|
|
177
177
|
expires: number;
|
|
178
178
|
httpOnly: boolean;
|
|
@@ -198,9 +198,9 @@ export declare const runApiSessionSchema: z.ZodDiscriminatedUnion<"type", [z.Zod
|
|
|
198
198
|
type: "state";
|
|
199
199
|
state?: {
|
|
200
200
|
cookies: {
|
|
201
|
+
path: string;
|
|
201
202
|
value: string;
|
|
202
203
|
name: string;
|
|
203
|
-
path: string;
|
|
204
204
|
domain: string;
|
|
205
205
|
expires: number;
|
|
206
206
|
httpOnly: boolean;
|
|
@@ -273,18 +273,18 @@ export declare const runApiParametersSchema: z.ZodObject<{
|
|
|
273
273
|
secure: z.ZodBoolean;
|
|
274
274
|
sameSite: z.ZodEnum<["Strict", "Lax", "None"]>;
|
|
275
275
|
}, "strip", z.ZodTypeAny, {
|
|
276
|
+
path: string;
|
|
276
277
|
value: string;
|
|
277
278
|
name: string;
|
|
278
|
-
path: string;
|
|
279
279
|
domain: string;
|
|
280
280
|
expires: number;
|
|
281
281
|
httpOnly: boolean;
|
|
282
282
|
secure: boolean;
|
|
283
283
|
sameSite: "Strict" | "Lax" | "None";
|
|
284
284
|
}, {
|
|
285
|
+
path: string;
|
|
285
286
|
value: string;
|
|
286
287
|
name: string;
|
|
287
|
-
path: string;
|
|
288
288
|
domain: string;
|
|
289
289
|
expires: number;
|
|
290
290
|
httpOnly: boolean;
|
|
@@ -343,9 +343,9 @@ export declare const runApiParametersSchema: z.ZodObject<{
|
|
|
343
343
|
}>, "many">>;
|
|
344
344
|
}, "strip", z.ZodTypeAny, {
|
|
345
345
|
cookies: {
|
|
346
|
+
path: string;
|
|
346
347
|
value: string;
|
|
347
348
|
name: string;
|
|
348
|
-
path: string;
|
|
349
349
|
domain: string;
|
|
350
350
|
expires: number;
|
|
351
351
|
httpOnly: boolean;
|
|
@@ -368,9 +368,9 @@ export declare const runApiParametersSchema: z.ZodObject<{
|
|
|
368
368
|
}[] | undefined;
|
|
369
369
|
}, {
|
|
370
370
|
cookies: {
|
|
371
|
+
path: string;
|
|
371
372
|
value: string;
|
|
372
373
|
name: string;
|
|
373
|
-
path: string;
|
|
374
374
|
domain: string;
|
|
375
375
|
expires: number;
|
|
376
376
|
httpOnly: boolean;
|
|
@@ -396,9 +396,9 @@ export declare const runApiParametersSchema: z.ZodObject<{
|
|
|
396
396
|
type: "state";
|
|
397
397
|
state?: {
|
|
398
398
|
cookies: {
|
|
399
|
+
path: string;
|
|
399
400
|
value: string;
|
|
400
401
|
name: string;
|
|
401
|
-
path: string;
|
|
402
402
|
domain: string;
|
|
403
403
|
expires: number;
|
|
404
404
|
httpOnly: boolean;
|
|
@@ -424,9 +424,9 @@ export declare const runApiParametersSchema: z.ZodObject<{
|
|
|
424
424
|
type: "state";
|
|
425
425
|
state?: {
|
|
426
426
|
cookies: {
|
|
427
|
+
path: string;
|
|
427
428
|
value: string;
|
|
428
429
|
name: string;
|
|
429
|
-
path: string;
|
|
430
430
|
domain: string;
|
|
431
431
|
expires: number;
|
|
432
432
|
httpOnly: boolean;
|
|
@@ -458,9 +458,9 @@ export declare const runApiParametersSchema: z.ZodObject<{
|
|
|
458
458
|
type: "state";
|
|
459
459
|
state?: {
|
|
460
460
|
cookies: {
|
|
461
|
+
path: string;
|
|
461
462
|
value: string;
|
|
462
463
|
name: string;
|
|
463
|
-
path: string;
|
|
464
464
|
domain: string;
|
|
465
465
|
expires: number;
|
|
466
466
|
httpOnly: boolean;
|
|
@@ -492,9 +492,9 @@ export declare const runApiParametersSchema: z.ZodObject<{
|
|
|
492
492
|
type: "state";
|
|
493
493
|
state?: {
|
|
494
494
|
cookies: {
|
|
495
|
+
path: string;
|
|
495
496
|
value: string;
|
|
496
497
|
name: string;
|
|
497
|
-
path: string;
|
|
498
498
|
domain: string;
|
|
499
499
|
expires: number;
|
|
500
500
|
httpOnly: boolean;
|
|
@@ -598,9 +598,9 @@ export declare const runApiParametersSchema: z.ZodObject<{
|
|
|
598
598
|
type: "state";
|
|
599
599
|
state?: {
|
|
600
600
|
cookies: {
|
|
601
|
+
path: string;
|
|
601
602
|
value: string;
|
|
602
603
|
name: string;
|
|
603
|
-
path: string;
|
|
604
604
|
domain: string;
|
|
605
605
|
expires: number;
|
|
606
606
|
httpOnly: boolean;
|
|
@@ -644,9 +644,9 @@ export declare const runApiParametersSchema: z.ZodObject<{
|
|
|
644
644
|
type: "state";
|
|
645
645
|
state?: {
|
|
646
646
|
cookies: {
|
|
647
|
+
path: string;
|
|
647
648
|
value: string;
|
|
648
649
|
name: string;
|
|
649
|
-
path: string;
|
|
650
650
|
domain: string;
|
|
651
651
|
expires: number;
|
|
652
652
|
httpOnly: boolean;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { extendPayload, extendTimeout, runInfo, RunError, requestMultipleChoice, requestOTP,
|
|
1
|
+
export { extendPayload, extendTimeout, runInfo, RunError, requestMultipleChoice, requestOTP, } from "./runtime";
|
|
2
2
|
export { runWithContext, getExecutionContext, } from "./common/asyncLocalStorage";
|
|
3
3
|
export { getDownloadDirectoryPath } from "./runtime/downloadDirectory";
|
|
4
4
|
export { getProductionPlaywrightConstructs } from "./common/getPlaywrightConstructs";
|
package/dist/index.js
CHANGED
|
@@ -21,12 +21,6 @@ Object.defineProperty(exports, "extendTimeout", {
|
|
|
21
21
|
return _runtime.extendTimeout;
|
|
22
22
|
}
|
|
23
23
|
});
|
|
24
|
-
Object.defineProperty(exports, "getAuthSessionParameters", {
|
|
25
|
-
enumerable: true,
|
|
26
|
-
get: function () {
|
|
27
|
-
return _runtime.getAuthSessionParameters;
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
24
|
Object.defineProperty(exports, "getDownloadDirectoryPath", {
|
|
31
25
|
enumerable: true,
|
|
32
26
|
get: function () {
|
package/dist/runtime/export.d.ts
CHANGED
|
@@ -17,6 +17,13 @@ function extendTimeout() {
|
|
|
17
17
|
if (!timeoutInfo) {
|
|
18
18
|
return;
|
|
19
19
|
}
|
|
20
|
+
if (timeoutInfo.timeoutTimestamp !== undefined && timeoutInfo.timeoutDuration !== undefined) {
|
|
21
|
+
const newTimeoutStamp = Date.now() + timeoutInfo.timeoutDuration;
|
|
22
|
+
if (newTimeoutStamp - timeoutInfo.timeoutTimestamp < _DEBOUNCE_TIME) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
timeoutInfo.timeoutTimestamp = newTimeoutStamp;
|
|
26
|
+
}
|
|
20
27
|
if (timeoutInfo.extendTimeoutCallback !== undefined) {
|
|
21
28
|
void timeoutInfo.extendTimeoutCallback().catch(() => undefined);
|
|
22
29
|
}
|
package/dist/runtime/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export { extendPayload } from "./extendPayload";
|
|
2
2
|
export { extendTimeout } from "./extendTimeout";
|
|
3
|
-
export { getAuthSessionParameters } from "./getAuthSessionParameters";
|
|
4
3
|
export { runInfo } from "./runInfo";
|
|
5
4
|
export { RunError } from "./RunError";
|
|
6
5
|
export { requestMultipleChoice, requestOTP } from "./requestMoreInfo";
|
package/dist/runtime/index.js
CHANGED
|
@@ -21,12 +21,6 @@ Object.defineProperty(exports, "extendTimeout", {
|
|
|
21
21
|
return _extendTimeout.extendTimeout;
|
|
22
22
|
}
|
|
23
23
|
});
|
|
24
|
-
Object.defineProperty(exports, "getAuthSessionParameters", {
|
|
25
|
-
enumerable: true,
|
|
26
|
-
get: function () {
|
|
27
|
-
return _getAuthSessionParameters.getAuthSessionParameters;
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
24
|
Object.defineProperty(exports, "getDownloadDirectoryPath", {
|
|
31
25
|
enumerable: true,
|
|
32
26
|
get: function () {
|
|
@@ -53,7 +47,6 @@ Object.defineProperty(exports, "runInfo", {
|
|
|
53
47
|
});
|
|
54
48
|
var _extendPayload = require("./extendPayload");
|
|
55
49
|
var _extendTimeout = require("./extendTimeout");
|
|
56
|
-
var _getAuthSessionParameters = require("./getAuthSessionParameters");
|
|
57
50
|
var _runInfo = require("./runInfo");
|
|
58
51
|
var _RunError = require("./RunError");
|
|
59
52
|
var _requestMoreInfo = require("./requestMoreInfo");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intuned/runtime-dev",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.6-bot-detection",
|
|
4
4
|
"description": "Intuned runtime",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dist/index.js",
|
|
@@ -83,6 +83,7 @@
|
|
|
83
83
|
"minimatch": "10.0.1",
|
|
84
84
|
"nanoid": "3",
|
|
85
85
|
"neverthrow": "6.1.0",
|
|
86
|
+
"patchright": "1.48.2",
|
|
86
87
|
"playwright-extra": "4.3.6",
|
|
87
88
|
"prettier": "2.8.0",
|
|
88
89
|
"promptly": "3.2.0",
|
|
@@ -130,6 +131,6 @@
|
|
|
130
131
|
"vitest": "^1.1.3"
|
|
131
132
|
},
|
|
132
133
|
"peerDependencies": {
|
|
133
|
-
"
|
|
134
|
+
"@intuned/runtime": "*"
|
|
134
135
|
}
|
|
135
136
|
}
|
package/template.tsconfig.json
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
|
+
"module": "ESNext",
|
|
3
4
|
"target": "ES2021",
|
|
4
|
-
"lib": [
|
|
5
|
+
"lib": [
|
|
6
|
+
"dom",
|
|
7
|
+
"es2021"
|
|
8
|
+
],
|
|
5
9
|
"resolveJsonModule": true,
|
|
6
10
|
"esModuleInterop": true,
|
|
7
|
-
"moduleResolution": "
|
|
8
|
-
"module": "esnext",
|
|
11
|
+
"moduleResolution": "node",
|
|
9
12
|
"skipLibCheck": true
|
|
10
13
|
}
|
|
11
|
-
}
|
|
14
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function getAuthSessionParameters(): Promise<any>;
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getAuthSessionParameters = getAuthSessionParameters;
|
|
7
|
-
var _isNil = _interopRequireDefault(require("lodash/isNil"));
|
|
8
|
-
var _asyncLocalStorage = require("../asyncLocalStorage");
|
|
9
|
-
var _zod = require("zod");
|
|
10
|
-
var _jwtTokenManager = require("../jwtTokenManager");
|
|
11
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
-
const authSessionParametersResponseSchema = _zod.z.object({
|
|
13
|
-
parameters: _zod.z.any().refine(v => v !== undefined)
|
|
14
|
-
});
|
|
15
|
-
async function getAuthSessionParameters() {
|
|
16
|
-
const context = (0, _asyncLocalStorage.getExecutionContext)();
|
|
17
|
-
if (!context) {
|
|
18
|
-
throw new Error("getAuthSessionParameters failed due to an internal error (context was not found).");
|
|
19
|
-
}
|
|
20
|
-
const authSessionId = context.authSessionId;
|
|
21
|
-
if ((0, _isNil.default)(authSessionId)) {
|
|
22
|
-
throw new Error("Auth sessions are not enabled");
|
|
23
|
-
}
|
|
24
|
-
const response = await (0, _jwtTokenManager.callBackendFunctionWithToken)(`auth-session/${authSessionId}/parameters`, {
|
|
25
|
-
method: "GET"
|
|
26
|
-
});
|
|
27
|
-
const body = await response.text();
|
|
28
|
-
if (!response.ok) {
|
|
29
|
-
throw new Error(`getAuthSessionParameters failed with status ${response.status}: ${body}`);
|
|
30
|
-
}
|
|
31
|
-
let json;
|
|
32
|
-
try {
|
|
33
|
-
json = JSON.parse(body);
|
|
34
|
-
} catch (e) {
|
|
35
|
-
throw new Error(`Expected JSON response, but got ${body}`);
|
|
36
|
-
}
|
|
37
|
-
return authSessionParametersResponseSchema.parse(json).parameters;
|
|
38
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function getAuthSessionParameters(): Promise<any>;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getAuthSessionParameters = getAuthSessionParameters;
|
|
7
|
-
var _asyncLocalStorage = require("../common/asyncLocalStorage");
|
|
8
|
-
async function getAuthSessionParameters() {
|
|
9
|
-
const context = (0, _asyncLocalStorage.getExecutionContext)();
|
|
10
|
-
if (!context) {
|
|
11
|
-
throw new Error("getAuthSessionParameters failed due to an internal error (context was not found).");
|
|
12
|
-
}
|
|
13
|
-
const {
|
|
14
|
-
getAuthSessionParameters
|
|
15
|
-
} = context;
|
|
16
|
-
if (!getAuthSessionParameters) {
|
|
17
|
-
throw new Error("getAuthSessionParameters failed due to an internal error (helper was not found on context).");
|
|
18
|
-
}
|
|
19
|
-
return await getAuthSessionParameters();
|
|
20
|
-
}
|