@intuned/runtime-dev 1.3.18-interface.13 → 1.3.18-interface.15
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/.babelrc +27 -0
- package/.claude/settings.local.json +7 -0
- package/.eslintignore +10 -0
- package/.eslintrc.js +39 -0
- package/InterfaceTemplate/__utils.ts +3 -1
- package/WebTemplate.zip +0 -0
- package/package.json +19 -73
- package/template.tsconfig.json +11 -0
- package/tsconfig.eslint.json +5 -0
- package/tsconfig.json +25 -0
- package/tsup.config.ts +11 -0
- package/typedoc.json +49 -0
- package/dist/commands/api/run.d.ts +0 -8
- package/dist/commands/api/run.js +0 -2094
- package/dist/commands/auth-sessions/load.d.ts +0 -1
- package/dist/commands/auth-sessions/load.js +0 -1559
- package/dist/commands/auth-sessions/run-check.d.ts +0 -1
- package/dist/commands/auth-sessions/run-check.js +0 -1964
- package/dist/commands/auth-sessions/run-create.d.ts +0 -1
- package/dist/commands/auth-sessions/run-create.js +0 -1968
- package/dist/commands/browser/save-state.d.ts +0 -1
- package/dist/commands/browser/save-state.js +0 -108
- package/dist/commands/browser/start-browser.d.ts +0 -1
- package/dist/commands/browser/start-browser.js +0 -67
- package/dist/commands/build.d.ts +0 -2
- package/dist/commands/build.js +0 -203
- package/dist/commands/common/tsNodeImport.d.ts +0 -5
- package/dist/commands/common/tsNodeImport.js +0 -82
- package/dist/commands/get-headless-user-agent.d.ts +0 -2
- package/dist/commands/get-headless-user-agent.js +0 -354
- package/dist/commands/interface/run.d.ts +0 -3
- package/dist/commands/interface/run.js +0 -2084
- package/dist/commands/intuned-cli/main.d.ts +0 -2
- package/dist/commands/intuned-cli/main.js +0 -5403
- package/dist/commands/ts-check.d.ts +0 -1
- package/dist/commands/ts-check.js +0 -158
- package/dist/common/assets/browser_scripts.js +0 -2580
- package/dist/common/asyncLocalStorage/index.d.ts +0 -17
- package/dist/common/asyncLocalStorage/index.js +0 -41
- package/dist/common/binStartupScript.d.ts +0 -2
- package/dist/common/binStartupScript.js +0 -152
- package/dist/common/cleanEnvironmentVariables.d.ts +0 -3
- package/dist/common/cleanEnvironmentVariables.js +0 -38
- package/dist/common/constants.d.ts +0 -13
- package/dist/common/constants.js +0 -59
- package/dist/common/contextStorageStateHelpers.d.ts +0 -24
- package/dist/common/contextStorageStateHelpers.js +0 -108
- package/dist/common/jwtTokenManager.d.ts +0 -19
- package/dist/common/jwtTokenManager.js +0 -180
- package/dist/common/runApi/index.d.ts +0 -11
- package/dist/common/runApi/index.js +0 -1873
- package/dist/common/settingsSchema.d.ts +0 -540
- package/dist/common/settingsSchema.js +0 -92
- package/dist/common/telemetry.d.ts +0 -6
- package/dist/common/telemetry.js +0 -63
- package/dist/export.d-BAUMB-lG.d.ts +0 -140
- package/dist/index.d.ts +0 -6
- package/dist/index.js +0 -808
- package/dist/runtime/index.d.ts +0 -168
- package/dist/runtime/index.js +0 -801
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
2
|
-
import { R as RunInfo, P as Payload } from '../../export.d-BAUMB-lG.js';
|
|
3
|
-
|
|
4
|
-
declare const asyncLocalStorage: AsyncLocalStorage<InternalRunInfo>;
|
|
5
|
-
declare function runWithContext<R, TArgs extends any[]>(contextData: InternalRunInfo, callback: (...args: TArgs) => R, ...args: TArgs): R;
|
|
6
|
-
interface TimeoutInfo {
|
|
7
|
-
extendTimeoutCallback?: () => Promise<void>;
|
|
8
|
-
}
|
|
9
|
-
interface InternalRunInfo extends RunInfo {
|
|
10
|
-
extendedPayloads: Payload[];
|
|
11
|
-
timeoutInfo?: TimeoutInfo;
|
|
12
|
-
store?: Record<string, any>;
|
|
13
|
-
getAuthSessionParameters?: () => Promise<any>;
|
|
14
|
-
}
|
|
15
|
-
declare function getExecutionContext(): InternalRunInfo | undefined;
|
|
16
|
-
|
|
17
|
-
export { type InternalRunInfo, asyncLocalStorage, getExecutionContext, runWithContext };
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
|
|
19
|
-
// src/common/asyncLocalStorage/index.ts
|
|
20
|
-
var asyncLocalStorage_exports = {};
|
|
21
|
-
__export(asyncLocalStorage_exports, {
|
|
22
|
-
asyncLocalStorage: () => asyncLocalStorage,
|
|
23
|
-
getExecutionContext: () => getExecutionContext,
|
|
24
|
-
runWithContext: () => runWithContext
|
|
25
|
-
});
|
|
26
|
-
module.exports = __toCommonJS(asyncLocalStorage_exports);
|
|
27
|
-
var import_node_async_hooks = require("async_hooks");
|
|
28
|
-
var asyncLocalStorage = new import_node_async_hooks.AsyncLocalStorage();
|
|
29
|
-
function runWithContext(contextData, callback, ...args) {
|
|
30
|
-
return asyncLocalStorage.run(contextData, callback, ...args);
|
|
31
|
-
}
|
|
32
|
-
function getExecutionContext() {
|
|
33
|
-
const contextData = asyncLocalStorage.getStore();
|
|
34
|
-
return contextData;
|
|
35
|
-
}
|
|
36
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
37
|
-
0 && (module.exports = {
|
|
38
|
-
asyncLocalStorage,
|
|
39
|
-
getExecutionContext,
|
|
40
|
-
runWithContext
|
|
41
|
-
});
|
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __copyProps = (to, from, except, desc) => {
|
|
8
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
9
|
-
for (let key of __getOwnPropNames(from))
|
|
10
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
11
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
12
|
-
}
|
|
13
|
-
return to;
|
|
14
|
-
};
|
|
15
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
16
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
17
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
18
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
19
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
20
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
-
mod
|
|
22
|
-
));
|
|
23
|
-
|
|
24
|
-
// src/common/binStartupScript.ts
|
|
25
|
-
var import_dotenv = __toESM(require("dotenv"));
|
|
26
|
-
var path2 = __toESM(require("path"));
|
|
27
|
-
|
|
28
|
-
// src/common/intunedJson.ts
|
|
29
|
-
var import_path = __toESM(require("path"));
|
|
30
|
-
var fs = __toESM(require("fs-extra"));
|
|
31
|
-
var import_zod = require("zod");
|
|
32
|
-
var JSONC = __toESM(require("jsonc-parser"));
|
|
33
|
-
var YAML = __toESM(require("yaml"));
|
|
34
|
-
var TOML = __toESM(require("smol-toml"));
|
|
35
|
-
var import_neverthrow = require("neverthrow");
|
|
36
|
-
var intunedJsonSchema = import_zod.z.object({
|
|
37
|
-
projectName: import_zod.z.string().optional(),
|
|
38
|
-
workspaceId: import_zod.z.string().optional(),
|
|
39
|
-
metadata: import_zod.z.object({
|
|
40
|
-
defaultJobInput: import_zod.z.record(import_zod.z.any()).optional().catch(void 0),
|
|
41
|
-
defaultRunPlaygroundInput: import_zod.z.record(import_zod.z.any()).optional().catch(void 0),
|
|
42
|
-
testAuthSessionInput: import_zod.z.record(import_zod.z.any()).optional().catch(void 0)
|
|
43
|
-
}).optional().catch(void 0),
|
|
44
|
-
stealthMode: import_zod.z.object({
|
|
45
|
-
enabled: import_zod.z.boolean()
|
|
46
|
-
}).optional().catch(void 0)
|
|
47
|
-
}).passthrough().and(
|
|
48
|
-
import_zod.z.union([
|
|
49
|
-
import_zod.z.object({
|
|
50
|
-
authSessions: import_zod.z.object({ enabled: import_zod.z.literal(false) }),
|
|
51
|
-
apiAccess: import_zod.z.object({
|
|
52
|
-
enabled: import_zod.z.literal(false)
|
|
53
|
-
})
|
|
54
|
-
}),
|
|
55
|
-
import_zod.z.object({
|
|
56
|
-
authSessions: import_zod.z.union([
|
|
57
|
-
import_zod.z.object({ enabled: import_zod.z.literal(false) }),
|
|
58
|
-
import_zod.z.object({
|
|
59
|
-
enabled: import_zod.z.literal(true),
|
|
60
|
-
type: import_zod.z.enum(["MANUAL", "API"]),
|
|
61
|
-
startUrl: import_zod.z.string().optional(),
|
|
62
|
-
finishUrl: import_zod.z.string().optional()
|
|
63
|
-
})
|
|
64
|
-
]),
|
|
65
|
-
apiAccess: import_zod.z.object({
|
|
66
|
-
enabled: import_zod.z.literal(true)
|
|
67
|
-
})
|
|
68
|
-
})
|
|
69
|
-
])
|
|
70
|
-
);
|
|
71
|
-
var intunedSettingsFileNames = [
|
|
72
|
-
"Intuned.json",
|
|
73
|
-
"Intuned.jsonc",
|
|
74
|
-
"Intuned.yaml",
|
|
75
|
-
"Intuned.yml",
|
|
76
|
-
"Intuned.toml"
|
|
77
|
-
];
|
|
78
|
-
var intunedSettingsParsers = {
|
|
79
|
-
"Intuned.json": JSON.parse,
|
|
80
|
-
"Intuned.jsonc": JSONC.parse,
|
|
81
|
-
"Intuned.yaml": YAML.parse,
|
|
82
|
-
"Intuned.yml": YAML.parse,
|
|
83
|
-
"Intuned.toml": TOML.parse
|
|
84
|
-
};
|
|
85
|
-
function loadIntunedJsonSync() {
|
|
86
|
-
const settingsFileResult = getIntunedSettingsFileSync();
|
|
87
|
-
if (!settingsFileResult.isOk()) {
|
|
88
|
-
return settingsFileResult;
|
|
89
|
-
}
|
|
90
|
-
const settingsFile = settingsFileResult.value;
|
|
91
|
-
const intunedJsonContent = fs.readFileSync(settingsFile.path, "utf-8");
|
|
92
|
-
let intunedJson;
|
|
93
|
-
try {
|
|
94
|
-
intunedJson = settingsFile.parse(intunedJsonContent);
|
|
95
|
-
} catch (e) {
|
|
96
|
-
return (0, import_neverthrow.err)(`Failed to parse ${settingsFile.name}: ${e.message}`);
|
|
97
|
-
}
|
|
98
|
-
const parseResult = intunedJsonSchema.safeParse(intunedJson);
|
|
99
|
-
if (!parseResult.success) {
|
|
100
|
-
const formattedError = parseResult.error.errors.map((e) => `- ${e.path.join(".")}: ${e.message}`).join("\n");
|
|
101
|
-
return (0, import_neverthrow.err)(
|
|
102
|
-
`${settingsFile.name} is not valid:
|
|
103
|
-
${formattedError}
|
|
104
|
-
Please fix the errors and try again.`
|
|
105
|
-
);
|
|
106
|
-
}
|
|
107
|
-
return (0, import_neverthrow.ok)(parseResult.data);
|
|
108
|
-
}
|
|
109
|
-
function getIntunedSettingsFileSync() {
|
|
110
|
-
for (const fileName of intunedSettingsFileNames) {
|
|
111
|
-
const filePath = import_path.default.join(process.cwd(), fileName);
|
|
112
|
-
if (fs.existsSync(filePath)) {
|
|
113
|
-
return (0, import_neverthrow.ok)({
|
|
114
|
-
name: fileName,
|
|
115
|
-
path: filePath,
|
|
116
|
-
parse: intunedSettingsParsers[fileName]
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
return (0, import_neverthrow.err)("No Intuned settings file found.");
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
// src/common/binStartupScript.ts
|
|
124
|
-
import_dotenv.default.config({
|
|
125
|
-
path: `.env`
|
|
126
|
-
});
|
|
127
|
-
function isStealthModeEnabled() {
|
|
128
|
-
try {
|
|
129
|
-
const settingsResult = loadIntunedJsonSync();
|
|
130
|
-
if (settingsResult.isErr()) {
|
|
131
|
-
console.error(`Warning: Failed to load Intuned settings: ${settingsResult.error}
|
|
132
|
-
Stealth mode will not be enabled.`);
|
|
133
|
-
return false;
|
|
134
|
-
}
|
|
135
|
-
return settingsResult.value.stealthMode?.enabled === true;
|
|
136
|
-
} catch (error) {
|
|
137
|
-
console.error("Error reading Intuned.json:", error.message);
|
|
138
|
-
return false;
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
try {
|
|
142
|
-
if (isStealthModeEnabled()) {
|
|
143
|
-
const currentNodeModules = path2.resolve(process.cwd(), "node_modules");
|
|
144
|
-
process.env.NODE_PATH = process.env.NODE_PATH ? `${process.env.NODE_PATH}:${currentNodeModules}` : currentNodeModules;
|
|
145
|
-
require("module").Module._initPaths();
|
|
146
|
-
if (process.env.PLAYWRIGHT_PATCH_SCRIPT_PATH) {
|
|
147
|
-
require(process.env.PLAYWRIGHT_PATCH_SCRIPT_PATH);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
} catch (e) {
|
|
151
|
-
console.error("Failed to apply stealth mode");
|
|
152
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
|
|
19
|
-
// src/common/cleanEnvironmentVariables.ts
|
|
20
|
-
var cleanEnvironmentVariables_exports = {};
|
|
21
|
-
__export(cleanEnvironmentVariables_exports, {
|
|
22
|
-
cleanEnvironmentVariables: () => cleanEnvironmentVariables
|
|
23
|
-
});
|
|
24
|
-
module.exports = __toCommonJS(cleanEnvironmentVariables_exports);
|
|
25
|
-
function cleanEnvironmentVariables() {
|
|
26
|
-
Object.keys(process.env).filter((i) => {
|
|
27
|
-
if (i.toLocaleLowerCase().startsWith("npm")) {
|
|
28
|
-
return true;
|
|
29
|
-
}
|
|
30
|
-
if (i.toLocaleLowerCase().startsWith("fly") && i !== "FLY_ALLOC_ID") {
|
|
31
|
-
return true;
|
|
32
|
-
}
|
|
33
|
-
}).forEach((i) => delete process.env[i]);
|
|
34
|
-
}
|
|
35
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
36
|
-
0 && (module.exports = {
|
|
37
|
-
cleanEnvironmentVariables
|
|
38
|
-
});
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
declare const API_FOLDER_NAME = "api";
|
|
2
|
-
declare const AUTH_SESSIONS_FOLDER_NAME = "auth-sessions";
|
|
3
|
-
declare const AUTH_SESSIONS_INSTANCES_FOLDER_NAME = "auth-sessions-instances";
|
|
4
|
-
declare const WORKSPACE_ID_ENV_VAR_KEY = "INTUNED_WORKSPACE_ID";
|
|
5
|
-
declare const EXTENSION_PATH_ENV_VAR_KEY = "INTUNED_EXTENSION_PATH";
|
|
6
|
-
declare const PROJECT_ID_ENV_VAR_KEY = "INTUNED_PROJECT_ID";
|
|
7
|
-
declare const API_KEY_ENV_VAR_KEY = "INTUNED_API_KEY";
|
|
8
|
-
declare const AUTH_TOKEN_ENV_VAR_KEY = "INTUNED_AUTH_TOKEN";
|
|
9
|
-
declare const API_KEY_HEADER_NAME = "x-api-key";
|
|
10
|
-
declare const API_BASE_URL_ENV_VAR_KEY = "INTUNED_API_BASE_URL";
|
|
11
|
-
declare const CLI_ENV_VAR_KEY = "INTUNED_CLI";
|
|
12
|
-
|
|
13
|
-
export { API_BASE_URL_ENV_VAR_KEY, API_FOLDER_NAME, API_KEY_ENV_VAR_KEY, API_KEY_HEADER_NAME, AUTH_SESSIONS_FOLDER_NAME, AUTH_SESSIONS_INSTANCES_FOLDER_NAME, AUTH_TOKEN_ENV_VAR_KEY, CLI_ENV_VAR_KEY, EXTENSION_PATH_ENV_VAR_KEY, PROJECT_ID_ENV_VAR_KEY, WORKSPACE_ID_ENV_VAR_KEY };
|
package/dist/common/constants.js
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
|
|
19
|
-
// src/common/constants.ts
|
|
20
|
-
var constants_exports = {};
|
|
21
|
-
__export(constants_exports, {
|
|
22
|
-
API_BASE_URL_ENV_VAR_KEY: () => API_BASE_URL_ENV_VAR_KEY,
|
|
23
|
-
API_FOLDER_NAME: () => API_FOLDER_NAME,
|
|
24
|
-
API_KEY_ENV_VAR_KEY: () => API_KEY_ENV_VAR_KEY,
|
|
25
|
-
API_KEY_HEADER_NAME: () => API_KEY_HEADER_NAME,
|
|
26
|
-
AUTH_SESSIONS_FOLDER_NAME: () => AUTH_SESSIONS_FOLDER_NAME,
|
|
27
|
-
AUTH_SESSIONS_INSTANCES_FOLDER_NAME: () => AUTH_SESSIONS_INSTANCES_FOLDER_NAME,
|
|
28
|
-
AUTH_TOKEN_ENV_VAR_KEY: () => AUTH_TOKEN_ENV_VAR_KEY,
|
|
29
|
-
CLI_ENV_VAR_KEY: () => CLI_ENV_VAR_KEY,
|
|
30
|
-
EXTENSION_PATH_ENV_VAR_KEY: () => EXTENSION_PATH_ENV_VAR_KEY,
|
|
31
|
-
PROJECT_ID_ENV_VAR_KEY: () => PROJECT_ID_ENV_VAR_KEY,
|
|
32
|
-
WORKSPACE_ID_ENV_VAR_KEY: () => WORKSPACE_ID_ENV_VAR_KEY
|
|
33
|
-
});
|
|
34
|
-
module.exports = __toCommonJS(constants_exports);
|
|
35
|
-
var API_FOLDER_NAME = "api";
|
|
36
|
-
var AUTH_SESSIONS_FOLDER_NAME = "auth-sessions";
|
|
37
|
-
var AUTH_SESSIONS_INSTANCES_FOLDER_NAME = "auth-sessions-instances";
|
|
38
|
-
var WORKSPACE_ID_ENV_VAR_KEY = "INTUNED_WORKSPACE_ID";
|
|
39
|
-
var EXTENSION_PATH_ENV_VAR_KEY = "INTUNED_EXTENSION_PATH";
|
|
40
|
-
var PROJECT_ID_ENV_VAR_KEY = "INTUNED_PROJECT_ID";
|
|
41
|
-
var API_KEY_ENV_VAR_KEY = "INTUNED_API_KEY";
|
|
42
|
-
var AUTH_TOKEN_ENV_VAR_KEY = "INTUNED_AUTH_TOKEN";
|
|
43
|
-
var API_KEY_HEADER_NAME = "x-api-key";
|
|
44
|
-
var API_BASE_URL_ENV_VAR_KEY = "INTUNED_API_BASE_URL";
|
|
45
|
-
var CLI_ENV_VAR_KEY = "INTUNED_CLI";
|
|
46
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
47
|
-
0 && (module.exports = {
|
|
48
|
-
API_BASE_URL_ENV_VAR_KEY,
|
|
49
|
-
API_FOLDER_NAME,
|
|
50
|
-
API_KEY_ENV_VAR_KEY,
|
|
51
|
-
API_KEY_HEADER_NAME,
|
|
52
|
-
AUTH_SESSIONS_FOLDER_NAME,
|
|
53
|
-
AUTH_SESSIONS_INSTANCES_FOLDER_NAME,
|
|
54
|
-
AUTH_TOKEN_ENV_VAR_KEY,
|
|
55
|
-
CLI_ENV_VAR_KEY,
|
|
56
|
-
EXTENSION_PATH_ENV_VAR_KEY,
|
|
57
|
-
PROJECT_ID_ENV_VAR_KEY,
|
|
58
|
-
WORKSPACE_ID_ENV_VAR_KEY
|
|
59
|
-
});
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import * as playwright from 'playwright';
|
|
2
|
-
import { RunApiStorageState } from '@intuned/runtime-interface';
|
|
3
|
-
|
|
4
|
-
interface StorageEntry {
|
|
5
|
-
name: string;
|
|
6
|
-
value: string;
|
|
7
|
-
}
|
|
8
|
-
interface LocalStorageState {
|
|
9
|
-
origin: string;
|
|
10
|
-
localStorage: StorageEntry[];
|
|
11
|
-
}
|
|
12
|
-
interface SessionStorageState {
|
|
13
|
-
origin: string;
|
|
14
|
-
sessionStorage: StorageEntry[];
|
|
15
|
-
}
|
|
16
|
-
interface StorageState {
|
|
17
|
-
cookies?: playwright.Cookie[] | null;
|
|
18
|
-
origins?: LocalStorageState[] | null;
|
|
19
|
-
sessionStorage?: SessionStorageState[] | null;
|
|
20
|
-
}
|
|
21
|
-
declare function setStorageState(context: playwright.BrowserContext, state: RunApiStorageState): Promise<void>;
|
|
22
|
-
declare function getStorageState(context: playwright.BrowserContext): Promise<RunApiStorageState>;
|
|
23
|
-
|
|
24
|
-
export { type StorageState, getStorageState, setStorageState };
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
|
|
19
|
-
// src/common/contextStorageStateHelpers.ts
|
|
20
|
-
var contextStorageStateHelpers_exports = {};
|
|
21
|
-
__export(contextStorageStateHelpers_exports, {
|
|
22
|
-
getStorageState: () => getStorageState,
|
|
23
|
-
setStorageState: () => setStorageState
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(contextStorageStateHelpers_exports);
|
|
26
|
-
async function setStorageState(context, state) {
|
|
27
|
-
if ("cookies" in state && state.cookies) {
|
|
28
|
-
await context.addCookies(state.cookies);
|
|
29
|
-
}
|
|
30
|
-
const page = await context.newPage();
|
|
31
|
-
if ("origins" in state && state.origins) {
|
|
32
|
-
for (const originData of state.origins || []) {
|
|
33
|
-
const origin = originData.origin;
|
|
34
|
-
await page.route(
|
|
35
|
-
`${origin}/*`,
|
|
36
|
-
(route) => route.fulfill({
|
|
37
|
-
body: "<html><head><title>Set Storage</title></head><body><h1>Set Storage</h1></body></html>",
|
|
38
|
-
contentType: "text/html",
|
|
39
|
-
status: 200
|
|
40
|
-
})
|
|
41
|
-
);
|
|
42
|
-
try {
|
|
43
|
-
await page.goto(origin);
|
|
44
|
-
for (const item of originData.localStorage) {
|
|
45
|
-
await page.evaluate(
|
|
46
|
-
([key, value]) => {
|
|
47
|
-
window.localStorage.setItem(key, value);
|
|
48
|
-
},
|
|
49
|
-
[item.name, item.value]
|
|
50
|
-
);
|
|
51
|
-
}
|
|
52
|
-
} finally {
|
|
53
|
-
await page.unroute(`${origin}/*`);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
if ("sessionStorage" in state && state.sessionStorage) {
|
|
58
|
-
await context.addInitScript((storage) => {
|
|
59
|
-
for (const { origin, sessionStorage } of storage) {
|
|
60
|
-
if (window.location.origin === origin) {
|
|
61
|
-
for (const item of sessionStorage) {
|
|
62
|
-
const value = window.sessionStorage.getItem(item.name);
|
|
63
|
-
if (!value) {
|
|
64
|
-
window.sessionStorage.setItem(item.name, item.value);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}, state.sessionStorage);
|
|
70
|
-
}
|
|
71
|
-
await page.close();
|
|
72
|
-
}
|
|
73
|
-
async function getStorageState(context) {
|
|
74
|
-
const result = {
|
|
75
|
-
cookies: [],
|
|
76
|
-
origins: []
|
|
77
|
-
};
|
|
78
|
-
const storageState = await context.storageState();
|
|
79
|
-
result.cookies = storageState.cookies;
|
|
80
|
-
result.origins = storageState.origins;
|
|
81
|
-
const sessionDataList = [];
|
|
82
|
-
const pages = await context.pages();
|
|
83
|
-
for (const page of pages) {
|
|
84
|
-
if (page.isClosed()) continue;
|
|
85
|
-
try {
|
|
86
|
-
const sessionData = await page.evaluate(() => {
|
|
87
|
-
const items = { ...window.sessionStorage };
|
|
88
|
-
return {
|
|
89
|
-
origin: window.location.origin,
|
|
90
|
-
sessionStorage: Object.entries(items).map(([name, value]) => ({
|
|
91
|
-
name,
|
|
92
|
-
value
|
|
93
|
-
}))
|
|
94
|
-
};
|
|
95
|
-
});
|
|
96
|
-
sessionDataList.push(sessionData);
|
|
97
|
-
} catch (error) {
|
|
98
|
-
console.error("Error getting sessionStorage:", error);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
result["sessionStorage"] = sessionDataList;
|
|
102
|
-
return result;
|
|
103
|
-
}
|
|
104
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
105
|
-
0 && (module.exports = {
|
|
106
|
-
getStorageState,
|
|
107
|
-
setStorageState
|
|
108
|
-
});
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import fetch from 'cross-fetch';
|
|
2
|
-
|
|
3
|
-
declare class JwtTokenManager {
|
|
4
|
-
private _token;
|
|
5
|
-
private tokenRefreshTimeout;
|
|
6
|
-
private refreshTokenPath;
|
|
7
|
-
constructor(refreshTokenPath: string);
|
|
8
|
-
get token(): string | undefined;
|
|
9
|
-
set token(newToken: string | undefined);
|
|
10
|
-
private get timeToRefresh();
|
|
11
|
-
private scheduleTokenRefresh;
|
|
12
|
-
private refreshToken;
|
|
13
|
-
fetchWithToken(...[input, init]: Parameters<typeof fetch>): Promise<Response>;
|
|
14
|
-
get backendFunctionsBaseUrl(): string | undefined;
|
|
15
|
-
}
|
|
16
|
-
declare const backendFunctionsTokenManager: JwtTokenManager;
|
|
17
|
-
declare function callBackendFunctionWithToken(path: string, init?: Parameters<typeof fetch>[1]): Promise<Response>;
|
|
18
|
-
|
|
19
|
-
export { backendFunctionsTokenManager, callBackendFunctionWithToken };
|
|
@@ -1,180 +0,0 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
-
mod
|
|
26
|
-
));
|
|
27
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
-
|
|
29
|
-
// src/common/jwtTokenManager.ts
|
|
30
|
-
var jwtTokenManager_exports = {};
|
|
31
|
-
__export(jwtTokenManager_exports, {
|
|
32
|
-
backendFunctionsTokenManager: () => backendFunctionsTokenManager,
|
|
33
|
-
callBackendFunctionWithToken: () => callBackendFunctionWithToken
|
|
34
|
-
});
|
|
35
|
-
module.exports = __toCommonJS(jwtTokenManager_exports);
|
|
36
|
-
var import_cross_fetch = __toESM(require("cross-fetch"));
|
|
37
|
-
var jwt = __toESM(require("jsonwebtoken"));
|
|
38
|
-
var import_neverthrow = require("neverthrow");
|
|
39
|
-
|
|
40
|
-
// src/common/constants.ts
|
|
41
|
-
var WORKSPACE_ID_ENV_VAR_KEY = "INTUNED_WORKSPACE_ID";
|
|
42
|
-
var PROJECT_ID_ENV_VAR_KEY = "INTUNED_PROJECT_ID";
|
|
43
|
-
var API_KEY_ENV_VAR_KEY = "INTUNED_API_KEY";
|
|
44
|
-
var AUTH_TOKEN_ENV_VAR_KEY = "INTUNED_AUTH_TOKEN";
|
|
45
|
-
var API_KEY_HEADER_NAME = "x-api-key";
|
|
46
|
-
var CLI_ENV_VAR_KEY = "INTUNED_CLI";
|
|
47
|
-
|
|
48
|
-
// src/common/jwtTokenManager.ts
|
|
49
|
-
var JwtTokenManager = class {
|
|
50
|
-
constructor(refreshTokenPath) {
|
|
51
|
-
this.refreshTokenPath = refreshTokenPath;
|
|
52
|
-
this._token = void 0;
|
|
53
|
-
}
|
|
54
|
-
get token() {
|
|
55
|
-
return this._token;
|
|
56
|
-
}
|
|
57
|
-
// When the token is set, the schedule for renewal is issued automatically
|
|
58
|
-
// This is currently being set it two places:
|
|
59
|
-
// 1. Whenever the runner starts, initializes it from the environment variable (set whenever the api is run from the authoring IDE)
|
|
60
|
-
// 2. Whenever a published api is called to run (/api/run/*), it is set to the token received in the run request.
|
|
61
|
-
set token(newToken) {
|
|
62
|
-
if (this._token != newToken) {
|
|
63
|
-
this._token = newToken;
|
|
64
|
-
void this.scheduleTokenRefresh();
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
get timeToRefresh() {
|
|
68
|
-
if (!this._token) return;
|
|
69
|
-
const payload = jwt.decode(this._token);
|
|
70
|
-
if (!payload || typeof payload == "string") return;
|
|
71
|
-
const expiry = payload.expiry;
|
|
72
|
-
if (!expiry || typeof expiry !== "number") return;
|
|
73
|
-
const timeWindow = 60 * 1e3;
|
|
74
|
-
const timeToRefresh = expiry - Date.now() - timeWindow;
|
|
75
|
-
return Math.max(timeToRefresh, timeWindow);
|
|
76
|
-
}
|
|
77
|
-
async scheduleTokenRefresh() {
|
|
78
|
-
if (process.env.RUN_ENVIRONMENT?.toLowerCase() !== "authoring") return;
|
|
79
|
-
const timeToRefresh = this.timeToRefresh;
|
|
80
|
-
if (timeToRefresh === void 0) return;
|
|
81
|
-
if (this.tokenRefreshTimeout) clearTimeout(this.tokenRefreshTimeout);
|
|
82
|
-
this.tokenRefreshTimeout = setTimeout(async () => {
|
|
83
|
-
const result = await this.refreshToken();
|
|
84
|
-
if (result && result.isErr()) {
|
|
85
|
-
console.error(`[Internal Error] ${result.error}`);
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
await this.scheduleTokenRefresh();
|
|
89
|
-
}, timeToRefresh);
|
|
90
|
-
}
|
|
91
|
-
async refreshToken() {
|
|
92
|
-
if (process.env.RUN_ENVIRONMENT?.toLowerCase() !== "authoring") return;
|
|
93
|
-
const res = await this.fetchWithToken(
|
|
94
|
-
`${this.backendFunctionsBaseUrl}/${this.refreshTokenPath}`,
|
|
95
|
-
{
|
|
96
|
-
method: "GET"
|
|
97
|
-
}
|
|
98
|
-
);
|
|
99
|
-
if (res.status === 401) {
|
|
100
|
-
return (0, import_neverthrow.err)("Unauthorized");
|
|
101
|
-
}
|
|
102
|
-
const jsonResult = await import_neverthrow.ResultAsync.fromPromise(
|
|
103
|
-
res.json(),
|
|
104
|
-
() => "not json"
|
|
105
|
-
);
|
|
106
|
-
if (jsonResult.isErr()) return;
|
|
107
|
-
const newToken = jsonResult.value.token;
|
|
108
|
-
if (newToken) this._token = newToken;
|
|
109
|
-
}
|
|
110
|
-
async fetchWithToken(...[input, init]) {
|
|
111
|
-
const headers = new Headers(init?.headers);
|
|
112
|
-
const apiKey = process.env[API_KEY_ENV_VAR_KEY];
|
|
113
|
-
if (apiKey) {
|
|
114
|
-
headers.set(API_KEY_HEADER_NAME, apiKey);
|
|
115
|
-
}
|
|
116
|
-
const token = process.env[AUTH_TOKEN_ENV_VAR_KEY];
|
|
117
|
-
if (token) {
|
|
118
|
-
headers.set("Authorization", `Bearer ${token}`);
|
|
119
|
-
}
|
|
120
|
-
if (this.token !== void 0) {
|
|
121
|
-
headers.set("Authorization", `Bearer ${this.token}`);
|
|
122
|
-
}
|
|
123
|
-
const result = await (0, import_cross_fetch.default)(input, {
|
|
124
|
-
...init,
|
|
125
|
-
headers
|
|
126
|
-
});
|
|
127
|
-
if (result.status === 401 && process.env[CLI_ENV_VAR_KEY] === "true") {
|
|
128
|
-
console.warn(
|
|
129
|
-
"Unauthorized backend function call - make sure to provision your project to Intuned to set up the correct API credentials.\nRun 'intuned provision' or see https://docs.intunedhq.com/docs/05-references/cli#provision-project for more information."
|
|
130
|
-
);
|
|
131
|
-
}
|
|
132
|
-
return result;
|
|
133
|
-
}
|
|
134
|
-
get backendFunctionsBaseUrl() {
|
|
135
|
-
try {
|
|
136
|
-
if (!process.env.FUNCTIONS_DOMAIN) {
|
|
137
|
-
throw new Error(
|
|
138
|
-
`Cannot call backend function - FUNCTIONS_DOMAIN not set`
|
|
139
|
-
);
|
|
140
|
-
}
|
|
141
|
-
const domain = process.env.FUNCTIONS_DOMAIN;
|
|
142
|
-
if (!process.env[WORKSPACE_ID_ENV_VAR_KEY]) {
|
|
143
|
-
throw new Error(
|
|
144
|
-
`Cannot call backend function - ${WORKSPACE_ID_ENV_VAR_KEY} not set`
|
|
145
|
-
);
|
|
146
|
-
}
|
|
147
|
-
const workspaceId = process.env[WORKSPACE_ID_ENV_VAR_KEY];
|
|
148
|
-
if (!process.env[PROJECT_ID_ENV_VAR_KEY] && !process.env.INTUNED_INTEGRATION_ID) {
|
|
149
|
-
throw new Error(
|
|
150
|
-
`Cannot call backend function - ${PROJECT_ID_ENV_VAR_KEY} or INTUNED_INTEGRATION_ID not set`
|
|
151
|
-
);
|
|
152
|
-
}
|
|
153
|
-
const projectId = process.env.INTUNED_INTEGRATION_ID ?? process.env[PROJECT_ID_ENV_VAR_KEY];
|
|
154
|
-
return `${domain}/api/${workspaceId}/functions/${projectId}`;
|
|
155
|
-
} catch (e) {
|
|
156
|
-
if (process.env[CLI_ENV_VAR_KEY] === "true") {
|
|
157
|
-
throw new Error(
|
|
158
|
-
`API credentials not set - make sure to provision your project to Intuned to set up the correct API credentials.
|
|
159
|
-
Run 'intuned provision' or see https://docs.intunedhq.com/docs/05-references/cli#provision-project for more information.
|
|
160
|
-
Original error: ${e.message}`
|
|
161
|
-
);
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
};
|
|
166
|
-
var backendFunctionsTokenManager = new JwtTokenManager(
|
|
167
|
-
`refreshBackendFunctionsToken`
|
|
168
|
-
);
|
|
169
|
-
backendFunctionsTokenManager.token = process.env.INTUNED_AUTHORING_SESSION_BACKEND_FUNCTIONS_TOKEN;
|
|
170
|
-
function callBackendFunctionWithToken(path, init) {
|
|
171
|
-
return backendFunctionsTokenManager.fetchWithToken(
|
|
172
|
-
`${backendFunctionsTokenManager.backendFunctionsBaseUrl}/${path}`,
|
|
173
|
-
init
|
|
174
|
-
);
|
|
175
|
-
}
|
|
176
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
177
|
-
0 && (module.exports = {
|
|
178
|
-
backendFunctionsTokenManager,
|
|
179
|
-
callBackendFunctionWithToken
|
|
180
|
-
});
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Result } from 'neverthrow';
|
|
2
|
-
import { Page, BrowserContext } from 'playwright';
|
|
3
|
-
import { ExtendedRunApiParameters, RunApiResult, RunApiResultWithSessionOk, RunAutomationError } from '@intuned/runtime-interface';
|
|
4
|
-
|
|
5
|
-
declare function runApi<ResultType = any>(input: ExtendedRunApiParameters & {
|
|
6
|
-
retrieveSession: true;
|
|
7
|
-
}): Promise<RunApiResult<ResultType, RunApiResultWithSessionOk<ResultType>>>;
|
|
8
|
-
declare function runApi<ResultType = any>(input: ExtendedRunApiParameters): Promise<RunApiResult<ResultType>>;
|
|
9
|
-
declare function checkAuthSessionWithRetries(page: Page, context: BrowserContext, checkFn: (..._: any) => Promise<boolean>, retries?: number): Promise<Result<boolean, RunAutomationError>>;
|
|
10
|
-
|
|
11
|
-
export { checkAuthSessionWithRetries, runApi };
|