@intuned/runtime 1.3.3 → 1.3.5
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 +1 -2
- package/dist/commands/auth-sessions/run-check.js +0 -1
- package/dist/commands/auth-sessions/run-create.js +0 -1
- package/dist/commands/common/projectExclusions.js +1 -1
- package/dist/commands/common/tsNodeImport.js +1 -1
- package/dist/commands/common/utils/settings.js +6 -6
- package/dist/commands/intuned-cli/commands/attempt_api.command.js +10 -20
- package/dist/commands/intuned-cli/commands/attempt_authsession_check.command.js +2 -7
- package/dist/commands/intuned-cli/commands/attempt_authsession_create.command.js +5 -17
- package/dist/commands/intuned-cli/commands/authsession.command.d.ts +1 -0
- package/dist/commands/intuned-cli/commands/authsession.command.js +8 -0
- package/dist/commands/intuned-cli/commands/authsession_record.command.d.ts +1 -0
- package/dist/commands/intuned-cli/commands/authsession_record.command.js +31 -0
- package/dist/commands/intuned-cli/commands/build.command.js +1 -1
- package/dist/commands/intuned-cli/commands/deploy.command.js +2 -7
- package/dist/commands/intuned-cli/commands/index.d.ts +2 -0
- package/dist/commands/intuned-cli/commands/index.js +22 -0
- package/dist/commands/intuned-cli/commands/init.command.js +1 -1
- package/dist/commands/intuned-cli/commands/run_api.command.js +13 -21
- package/dist/commands/intuned-cli/commands/run_authsession.command.d.ts +10 -3
- package/dist/commands/intuned-cli/commands/run_authsession.command.js +5 -1
- package/dist/commands/intuned-cli/commands/run_authsession_create.command.d.ts +1 -1
- package/dist/commands/intuned-cli/commands/run_authsession_create.command.js +16 -20
- package/dist/commands/intuned-cli/commands/run_authsession_update.command.d.ts +1 -1
- package/dist/commands/intuned-cli/commands/run_authsession_update.command.js +16 -20
- package/dist/commands/intuned-cli/commands/run_authsession_validate.command.d.ts +1 -1
- package/dist/commands/intuned-cli/commands/run_authsession_validate.command.js +16 -20
- package/dist/commands/intuned-cli/commands/save.command.d.ts +3 -2
- package/dist/commands/intuned-cli/commands/save.command.js +6 -10
- package/dist/commands/intuned-cli/commands/types.d.ts +11 -1
- package/dist/commands/intuned-cli/commands/types.js +11 -3
- package/dist/commands/intuned-cli/controller/__test__/api.test.js +128 -10
- package/dist/commands/intuned-cli/controller/__test__/authSession.test.js +428 -45
- package/dist/commands/intuned-cli/controller/api.d.ts +5 -7
- package/dist/commands/intuned-cli/controller/api.js +16 -7
- package/dist/commands/intuned-cli/controller/authSession.d.ts +18 -7
- package/dist/commands/intuned-cli/controller/authSession.js +153 -24
- package/dist/commands/intuned-cli/controller/save.js +10 -3
- package/dist/commands/intuned-cli/helpers/__test__/browser.test.js +103 -0
- package/dist/commands/intuned-cli/helpers/__test__/tracing.test.js +40 -0
- package/dist/commands/intuned-cli/helpers/auth.d.ts +7 -2
- package/dist/commands/intuned-cli/helpers/auth.js +38 -23
- package/dist/commands/intuned-cli/helpers/backend.d.ts +1 -1
- package/dist/commands/intuned-cli/helpers/backend.js +2 -2
- package/dist/commands/intuned-cli/helpers/browser.d.ts +14 -0
- package/dist/commands/intuned-cli/helpers/browser.js +57 -0
- package/dist/commands/intuned-cli/helpers/errors.d.ts +0 -1
- package/dist/commands/intuned-cli/helpers/errors.js +0 -22
- package/dist/commands/intuned-cli/helpers/index.d.ts +2 -0
- package/dist/commands/intuned-cli/helpers/index.js +22 -0
- package/dist/commands/intuned-cli/helpers/intunedJson.d.ts +69 -1
- package/dist/commands/intuned-cli/helpers/intunedJson.js +59 -7
- package/dist/commands/intuned-cli/helpers/traces.d.ts +2 -0
- package/dist/commands/intuned-cli/helpers/traces.js +32 -0
- package/dist/commands/intuned-cli/helpers/validation.js +5 -3
- package/dist/commands/intuned-cli/helpers/wrapper.d.ts +2 -0
- package/dist/commands/intuned-cli/helpers/wrapper.js +60 -0
- package/dist/common/constants.d.ts +1 -0
- package/dist/common/constants.js +2 -1
- package/dist/common/extensionsHelpers.d.ts +15 -0
- package/dist/common/extensionsHelpers.js +81 -0
- package/dist/common/playwrightContext.d.ts +1 -0
- package/dist/common/playwrightContext.js +23 -2
- package/dist/common/runApi/types.d.ts +2 -7
- package/dist/common/runApi/types.js +1 -2
- package/dist/common/settingsSchema.d.ts +513 -0
- package/dist/common/settingsSchema.js +40 -2
- package/package.json +4 -1
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.buildExtensionsList = buildExtensionsList;
|
|
7
|
+
exports.getIntunedExtensionPath = getIntunedExtensionPath;
|
|
8
|
+
exports.getIntunedExtensionSettings = getIntunedExtensionSettings;
|
|
9
|
+
exports.getIntunedExtensionWorker = getIntunedExtensionWorker;
|
|
10
|
+
exports.isIntunedExtensionEnabled = isIntunedExtensionEnabled;
|
|
11
|
+
exports.setupIntunedExtension = setupIntunedExtension;
|
|
12
|
+
var _settings = require("../commands/common/utils/settings");
|
|
13
|
+
var _settingsSchema = require("./settingsSchema");
|
|
14
|
+
var _constants = require("./constants");
|
|
15
|
+
var _jwtTokenManager = require("./jwtTokenManager");
|
|
16
|
+
var _path = _interopRequireDefault(require("path"));
|
|
17
|
+
var _promises = require("fs/promises");
|
|
18
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
19
|
+
const INTUNED_WORKER = "intunedWorker.js";
|
|
20
|
+
const INTUNED_EXTENSION_SETTINGS_FILE_NAME = "intunedSettings.json";
|
|
21
|
+
function buildExtensionsList() {
|
|
22
|
+
const extensionsList = [];
|
|
23
|
+
if (isIntunedExtensionEnabled()) {
|
|
24
|
+
const intunedExtensionPath = getIntunedExtensionPath();
|
|
25
|
+
extensionsList.push(intunedExtensionPath);
|
|
26
|
+
}
|
|
27
|
+
return extensionsList;
|
|
28
|
+
}
|
|
29
|
+
function getIntunedExtensionPath() {
|
|
30
|
+
return process.env.INTUNED_EXTENSION_PATH;
|
|
31
|
+
}
|
|
32
|
+
function isIntunedExtensionEnabled() {
|
|
33
|
+
return !!getIntunedExtensionPath();
|
|
34
|
+
}
|
|
35
|
+
async function getIntunedExtensionWorker(context) {
|
|
36
|
+
if (!isIntunedExtensionEnabled()) {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
let attemptCount = 0;
|
|
40
|
+
while (attemptCount < 4) {
|
|
41
|
+
const intunedServiceWorker = context.serviceWorkers().find(serviceWorker => serviceWorker.url().includes(INTUNED_WORKER));
|
|
42
|
+
if (intunedServiceWorker) {
|
|
43
|
+
return intunedServiceWorker;
|
|
44
|
+
}
|
|
45
|
+
try {
|
|
46
|
+
await context.waitForEvent("serviceworker", {
|
|
47
|
+
timeout: 3000
|
|
48
|
+
});
|
|
49
|
+
} catch (err) {
|
|
50
|
+
console.log(`Error accessing service workers (attempt ${attemptCount})`);
|
|
51
|
+
}
|
|
52
|
+
attemptCount++;
|
|
53
|
+
}
|
|
54
|
+
console.error("Failed to get intuned worker after 5 attmepts");
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
async function getIntunedExtensionSettings() {
|
|
58
|
+
const settings = await (0, _settings.getSettings)();
|
|
59
|
+
const captchaSolverSettings = settings.captchaSolver ?? _settingsSchema.captchaSolverSettingsSchema.parse({});
|
|
60
|
+
const [domain, workspaceId, projectId] = [process.env.FUNCTIONS_DOMAIN, process.env[_constants.WORKSPACE_ID_ENV_VAR_KEY], process.env.INTUNED_INTEGRATION_ID ?? process.env[_constants.PROJECT_ID_ENV_VAR_KEY]];
|
|
61
|
+
if (!domain || !workspaceId || !projectId) {
|
|
62
|
+
const missingEnvVars = [domain && "FUNCTIONS_DOMAIN", workspaceId && _constants.WORKSPACE_ID_ENV_VAR_KEY, projectId && `INTUNED_INTEGRATION_ID OR ${_constants.PROJECT_ID_ENV_VAR_KEY}`];
|
|
63
|
+
throw new Error(`Missing required environment variables: ${missingEnvVars}`);
|
|
64
|
+
}
|
|
65
|
+
return {
|
|
66
|
+
...captchaSolverSettings,
|
|
67
|
+
baseUrl: domain,
|
|
68
|
+
token: _jwtTokenManager.backendFunctionsTokenManager.token,
|
|
69
|
+
workspaceId,
|
|
70
|
+
projectId
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
async function setupIntunedExtension() {
|
|
74
|
+
if (!isIntunedExtensionEnabled()) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
const intunedExtensionPath = getIntunedExtensionPath();
|
|
78
|
+
const intunedExtensionSettingsPath = _path.default.join(intunedExtensionPath, INTUNED_EXTENSION_SETTINGS_FILE_NAME);
|
|
79
|
+
const settings = await getIntunedExtensionSettings();
|
|
80
|
+
await (0, _promises.writeFile)(intunedExtensionSettingsPath, JSON.stringify(settings));
|
|
81
|
+
}
|
|
@@ -19,6 +19,7 @@ var _errors = require("./runApi/errors");
|
|
|
19
19
|
var _neverthrow = require("neverthrow");
|
|
20
20
|
var _setupContextHook = require("./setupContextHook");
|
|
21
21
|
var _portfinder = require("portfinder");
|
|
22
|
+
var _extensionsHelpers = require("./extensionsHelpers");
|
|
22
23
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
23
24
|
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); }
|
|
24
25
|
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; }
|
|
@@ -42,7 +43,8 @@ async function launchChromium({
|
|
|
42
43
|
headless = true,
|
|
43
44
|
downloadsPath,
|
|
44
45
|
cdpAddress,
|
|
45
|
-
cdpPort
|
|
46
|
+
cdpPort,
|
|
47
|
+
appModeInitialUrl
|
|
46
48
|
}) {
|
|
47
49
|
if (cdpAddress) {
|
|
48
50
|
const browser = await playwright.chromium.connectOverCDP(cdpAddress);
|
|
@@ -59,17 +61,33 @@ async function launchChromium({
|
|
|
59
61
|
context
|
|
60
62
|
};
|
|
61
63
|
}
|
|
64
|
+
const defaultArgsToIgnore = ["--disable-extensions", "--disable-component-extensions-with-background-pages", "--disable-background-networking", "--disable-backgrounding-occluded-windows", "--disable-background-timer-throttling"];
|
|
62
65
|
const extraArgs = [];
|
|
63
66
|
const userDataDir = await createUserDirWithPreferences();
|
|
67
|
+
if ((0, _extensionsHelpers.isIntunedExtensionEnabled)()) {
|
|
68
|
+
const extensionsList = (0, _extensionsHelpers.buildExtensionsList)();
|
|
69
|
+
const extensions = extensionsList.join(",");
|
|
70
|
+
extraArgs.push(`--disable-extensions-except=${extensions}`);
|
|
71
|
+
extraArgs.push(`--load-extension=${extensions}`);
|
|
72
|
+
await (0, _extensionsHelpers.setupIntunedExtension)();
|
|
73
|
+
}
|
|
64
74
|
if (cdpPort) {
|
|
65
75
|
extraArgs.push(`--remote-debugging-port=${cdpPort}`);
|
|
66
76
|
}
|
|
77
|
+
if (headless) {
|
|
78
|
+
defaultArgsToIgnore.push("--headless=old");
|
|
79
|
+
extraArgs.push("--headless=new");
|
|
80
|
+
}
|
|
81
|
+
if (appModeInitialUrl) {
|
|
82
|
+
extraArgs.push(`--app=${appModeInitialUrl}`);
|
|
83
|
+
}
|
|
67
84
|
const context = await playwright.chromium.launchPersistentContext(userDataDir, {
|
|
68
85
|
headless,
|
|
69
86
|
viewport: null,
|
|
70
87
|
proxy,
|
|
71
88
|
downloadsPath,
|
|
72
|
-
args: extraArgs
|
|
89
|
+
args: extraArgs,
|
|
90
|
+
ignoreDefaultArgs: defaultArgsToIgnore
|
|
73
91
|
});
|
|
74
92
|
context.once("close", async () => {
|
|
75
93
|
try {
|
|
@@ -88,6 +106,9 @@ async function launchChromium({
|
|
|
88
106
|
await waitOnCdpAddress(createdCdpAddress);
|
|
89
107
|
}
|
|
90
108
|
const page = context.pages().at(0) ?? (await context.newPage());
|
|
109
|
+
if ((0, _extensionsHelpers.isIntunedExtensionEnabled)()) {
|
|
110
|
+
await (0, _extensionsHelpers.getIntunedExtensionWorker)(context);
|
|
111
|
+
}
|
|
91
112
|
return {
|
|
92
113
|
page,
|
|
93
114
|
context
|
|
@@ -673,22 +673,19 @@ export declare const runApiParametersSchema: z.ZodObject<{
|
|
|
673
673
|
} | undefined;
|
|
674
674
|
}, {
|
|
675
675
|
environment: "standalone";
|
|
676
|
+
headless?: boolean | undefined;
|
|
676
677
|
proxy?: {
|
|
677
678
|
server: string;
|
|
678
679
|
username: string;
|
|
679
680
|
password: string;
|
|
680
681
|
} | undefined;
|
|
681
|
-
headless?: boolean | undefined;
|
|
682
682
|
}>, z.ZodObject<{
|
|
683
683
|
environment: z.ZodLiteral<"cdp">;
|
|
684
684
|
cdpAddress: z.ZodString;
|
|
685
|
-
mode: z.ZodUnion<[z.ZodLiteral<"vanilla">, z.ZodLiteral<"playwright">, z.ZodLiteral<"playwright-standalone">, z.ZodLiteral<"playwright-headless">]>;
|
|
686
685
|
}, "strip", z.ZodTypeAny, {
|
|
687
|
-
mode: "vanilla" | "playwright" | "playwright-standalone" | "playwright-headless";
|
|
688
686
|
environment: "cdp";
|
|
689
687
|
cdpAddress: string;
|
|
690
688
|
}, {
|
|
691
|
-
mode: "vanilla" | "playwright" | "playwright-standalone" | "playwright-headless";
|
|
692
689
|
environment: "cdp";
|
|
693
690
|
cdpAddress: string;
|
|
694
691
|
}>]>>;
|
|
@@ -713,7 +710,6 @@ export declare const runApiParametersSchema: z.ZodObject<{
|
|
|
713
710
|
password: string;
|
|
714
711
|
} | undefined;
|
|
715
712
|
} | {
|
|
716
|
-
mode: "vanilla" | "playwright" | "playwright-standalone" | "playwright-headless";
|
|
717
713
|
environment: "cdp";
|
|
718
714
|
cdpAddress: string;
|
|
719
715
|
};
|
|
@@ -799,14 +795,13 @@ export declare const runApiParametersSchema: z.ZodObject<{
|
|
|
799
795
|
} | undefined;
|
|
800
796
|
runOptions?: {
|
|
801
797
|
environment: "standalone";
|
|
798
|
+
headless?: boolean | undefined;
|
|
802
799
|
proxy?: {
|
|
803
800
|
server: string;
|
|
804
801
|
username: string;
|
|
805
802
|
password: string;
|
|
806
803
|
} | undefined;
|
|
807
|
-
headless?: boolean | undefined;
|
|
808
804
|
} | {
|
|
809
|
-
mode: "vanilla" | "playwright" | "playwright-standalone" | "playwright-headless";
|
|
810
805
|
environment: "cdp";
|
|
811
806
|
cdpAddress: string;
|
|
812
807
|
} | undefined;
|
|
@@ -65,8 +65,7 @@ const runApiParametersSchema = exports.runApiParametersSchema = _zod.default.obj
|
|
|
65
65
|
}).optional()
|
|
66
66
|
}), _zod.default.object({
|
|
67
67
|
environment: _zod.default.literal("cdp"),
|
|
68
|
-
cdpAddress: _zod.default.string()
|
|
69
|
-
mode: _zod.default.union([_zod.default.literal("vanilla"), _zod.default.literal("playwright"), _zod.default.literal("playwright-standalone"), _zod.default.literal("playwright-headless")])
|
|
68
|
+
cdpAddress: _zod.default.string()
|
|
70
69
|
})]).default({
|
|
71
70
|
environment: "standalone"
|
|
72
71
|
}),
|