@intuned/runtime-dev 1.3.12-ua.0 → 1.3.12-ua.1
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.
|
@@ -104,7 +104,7 @@ async function launchChromium(options) {
|
|
|
104
104
|
const ua = await tmpPage.evaluate(() => navigator.userAgent);
|
|
105
105
|
await tmpBrowser.close();
|
|
106
106
|
if (ua) {
|
|
107
|
-
userAgent = ua;
|
|
107
|
+
userAgent = ua.replace("HeadlessChrome", "Chrome");
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
110
|
const context = await playwright.chromium.launchPersistentContext(userDataDir, {
|
|
@@ -100,6 +100,7 @@ async function runApi({
|
|
|
100
100
|
apiParameters: params,
|
|
101
101
|
importFunction
|
|
102
102
|
};
|
|
103
|
+
const intunedContext = (0, _asyncLocalStorage.getExecutionContext)();
|
|
103
104
|
const runAutomationWithContext = async (context, page) => {
|
|
104
105
|
async function saveTraceIfNeeded({
|
|
105
106
|
errorMessage
|
|
@@ -148,7 +149,7 @@ async function runApi({
|
|
|
148
149
|
}
|
|
149
150
|
return (0, _neverthrow.ok)({
|
|
150
151
|
result: automationFunctionResult,
|
|
151
|
-
extendedPayloads:
|
|
152
|
+
extendedPayloads: intunedContext?.extendedPayloads,
|
|
152
153
|
session: retrieveSession ? await (0, _contextStorageStateHelpers.getStorageState)(context) : undefined
|
|
153
154
|
});
|
|
154
155
|
} catch (error) {
|
|
@@ -159,6 +160,9 @@ async function runApi({
|
|
|
159
160
|
});
|
|
160
161
|
}
|
|
161
162
|
};
|
|
163
|
+
if (intunedContext?.store) {
|
|
164
|
+
intunedContext.store = {};
|
|
165
|
+
}
|
|
162
166
|
if (runOptions.environment === "standalone") {
|
|
163
167
|
const downloadsPath = (0, _downloadDirectory.getDownloadDirectoryPath)();
|
|
164
168
|
try {
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.cache = void 0;
|
|
7
|
+
var _zod = require("zod");
|
|
8
|
+
var _jwtTokenManager = require("../common/jwtTokenManager");
|
|
9
|
+
const forbiddenCharacters = /[:#]/g;
|
|
10
|
+
const keySchema = _zod.z.string().min(1, "Key must be at least 1 character long").refine(key => (key.match(forbiddenCharacters)?.length ?? 0) === 0, 'Key cannot contain the following characters: ":" or "#"');
|
|
11
|
+
class Cache {
|
|
12
|
+
async get(key) {
|
|
13
|
+
const parsedKey = keySchema.parse(key);
|
|
14
|
+
const response = await (0, _jwtTokenManager.callBackendFunctionWithToken)(`cache/${parsedKey}`, {
|
|
15
|
+
method: "GET"
|
|
16
|
+
});
|
|
17
|
+
const json = await response.json();
|
|
18
|
+
if (!response.ok) {
|
|
19
|
+
throw new Error(json.message);
|
|
20
|
+
}
|
|
21
|
+
return json.value;
|
|
22
|
+
}
|
|
23
|
+
async set(key, value) {
|
|
24
|
+
const keyResult = keySchema.parse(key);
|
|
25
|
+
const response = await (0, _jwtTokenManager.callBackendFunctionWithToken)(`cache/${keyResult}`, {
|
|
26
|
+
method: "PUT",
|
|
27
|
+
body: JSON.stringify(value),
|
|
28
|
+
headers: {
|
|
29
|
+
"Content-Type": "application/json"
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
const json = await response.json();
|
|
33
|
+
if (!response.ok) {
|
|
34
|
+
throw new Error(json.message);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
const cache = exports.cache = new Cache();
|