@intuned/runtime-dev 1.1.3-bot-detection → 1.1.3-dev-00
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 +2 -2
- package/dist/commands/api/run.js +8 -2
- package/dist/commands/auth-sessions/run-check.js +18 -4
- package/dist/commands/auth-sessions/run-create.js +2 -1
- package/dist/commands/cli-auth-sessions/create.js +1 -1
- package/dist/commands/cli-auth-sessions/utils.d.ts +1 -1
- package/dist/commands/cli-auth-sessions/utils.js +2 -3
- package/dist/commands/common/browserUtils.d.ts +1 -1
- package/dist/commands/common/browserUtils.js +1 -1
- package/dist/commands/common/getFirstLineNumber.js +2 -4
- package/dist/commands/deploy/utils.js +1 -2
- package/dist/commands/interface/run.js +7 -6
- package/dist/commands/run-api-cli/utils.js +6 -6
- package/dist/common/assets/browser_scripts.js +2509 -2143
- package/dist/common/asyncLocalStorage/index.d.ts +1 -2
- package/dist/common/backendFunctions/getAuthSessionParameters.d.ts +1 -0
- package/dist/common/backendFunctions/getAuthSessionParameters.js +38 -0
- 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/getPlaywrightConstructs.d.ts +1 -1
- package/dist/common/getPlaywrightConstructs.js +4 -12
- package/dist/common/jwtTokenManager.js +3 -5
- package/dist/common/runApi/errors.d.ts +1 -1
- package/dist/common/runApi/errors.js +5 -6
- package/dist/common/runApi/index.d.ts +1 -1
- package/dist/common/runApi/index.js +8 -11
- package/dist/index.d.ts +1 -1
- package/dist/index.js +6 -0
- package/dist/runtime/executionHelpers.test.js +3 -4
- package/dist/runtime/export.d.ts +16 -0
- package/dist/runtime/extendPayload.js +1 -1
- package/dist/runtime/extendTimeout.js +0 -7
- package/dist/runtime/getAuthSessionParameters.d.ts +1 -0
- package/dist/runtime/getAuthSessionParameters.js +20 -0
- package/dist/runtime/index.d.ts +1 -0
- package/dist/runtime/index.js +7 -0
- package/package.json +2 -3
- package/template.tsconfig.json +4 -7
|
@@ -5,12 +5,11 @@ 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;
|
|
10
8
|
}
|
|
11
9
|
export interface InternalRunInfo extends RunInfo {
|
|
12
10
|
extendedPayloads: Payload[];
|
|
13
11
|
timeoutInfo?: TimeoutInfo;
|
|
12
|
+
getAuthSessionParameters?: () => Promise<any>;
|
|
14
13
|
}
|
|
15
14
|
export declare function getExecutionContext(): InternalRunInfo | undefined;
|
|
16
15
|
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getAuthSessionParameters(): Promise<any>;
|
|
@@ -0,0 +1,38 @@
|
|
|
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
|
+
}
|
|
@@ -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("playwright"));
|
|
11
11
|
var _fsExtra = _interopRequireWildcard(require("fs-extra"));
|
|
12
12
|
var fs = _fsExtra;
|
|
13
13
|
var _contextStorageStateHelpers = require("./contextStorageStateHelpers");
|
|
@@ -43,19 +43,12 @@ async function getProductionPlaywrightConstructs({
|
|
|
43
43
|
if (headless) {
|
|
44
44
|
extraArgs.push("--headless=new");
|
|
45
45
|
}
|
|
46
|
-
const executablePath = playwright.chromium.executablePath();
|
|
47
|
-
const chromium127Path = executablePath.replace("chromium-1117", "chromium-1124");
|
|
48
|
-
const isChrome127There = await (0, _fsExtra.exists)(chromium127Path);
|
|
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`;
|
|
50
46
|
const userDataDir = await createUserDirWithPreferences();
|
|
51
47
|
const context = await playwright.chromium.launchPersistentContext(userDataDir, {
|
|
52
48
|
headless,
|
|
53
|
-
|
|
49
|
+
viewport: null,
|
|
54
50
|
proxy,
|
|
55
|
-
|
|
56
|
-
args: extraArgs,
|
|
57
|
-
downloadsPath,
|
|
58
|
-
userAgent
|
|
51
|
+
downloadsPath
|
|
59
52
|
});
|
|
60
53
|
context.once("close", async () => {
|
|
61
54
|
try {
|
|
@@ -91,7 +84,6 @@ async function getProductionPlaywrightConstructs({
|
|
|
91
84
|
context
|
|
92
85
|
};
|
|
93
86
|
}
|
|
94
|
-
const getChromiumLaunchArgsToIgnore = () => ["--disable-field-trial-config", "--disable-background-networking", "--enable-features=NetworkService,NetworkServiceInProcess", "--disable-background-timer-throttling", "--disable-backgrounding-occluded-windows", "--disable-back-forward-cache", "--disable-breakpad", "--disable-client-side-phishing-detection", "--disable-component-extensions-with-background-pages", "--disable-component-update", "--no-default-browser-check", "--disable-default-apps", "--disable-dev-shm-usage", "--disable-extensions", "--disable-features=ImprovedCookieControls,LazyFrameLoading,GlobalMediaControls,DestroyProfileOnBrowserClose,MediaRouter,DialMediaRouteProvider,AcceptCHFrame,AutoExpandDetailsElement,CertificateTransparencyComponentUpdater,AvoidUnnecessaryBeforeUnloadCheckSync,Translate,TranslateUI", "--allow-pre-commit-input", "--disable-hang-monitor", "--disable-ipc-flooding-protection", "--disable-prompt-on-repost", "--disable-renderer-backgrounding", "--force-color-profile=srgb", "--metrics-recording-only", "--no-first-run", "--enable-automation", "--password-store=basic", "--use-mock-keychain", "--no-service-autorun", "--export-tagged-pdf", "--enable-use-zoom-for-dsf=false"];
|
|
95
87
|
async function getPlaywrightConstructsForMode(mode, cdpAddress, authSession) {
|
|
96
88
|
if (mode == "playwright-standalone") {
|
|
97
89
|
if (!cdpAddress) {
|
|
@@ -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("playwright
|
|
158
|
+
const playwright = await Promise.resolve().then(() => _interopRequireWildcard(require("playwright")));
|
|
167
159
|
let browser = null;
|
|
168
160
|
if (!cdpAddress) {
|
|
169
161
|
throw new Error("cdpAddress is required");
|
|
@@ -36,8 +36,7 @@ class JwtTokenManager {
|
|
|
36
36
|
return Math.max(timeToRefresh, timeWindow);
|
|
37
37
|
}
|
|
38
38
|
async scheduleTokenRefresh() {
|
|
39
|
-
|
|
40
|
-
if (((_process$env$RUN_ENVI = process.env.RUN_ENVIRONMENT) === null || _process$env$RUN_ENVI === void 0 ? void 0 : _process$env$RUN_ENVI.toLowerCase()) !== "authoring") return;
|
|
39
|
+
if (process.env.RUN_ENVIRONMENT?.toLowerCase() !== "authoring") return;
|
|
41
40
|
const timeToRefresh = this.timeToRefresh;
|
|
42
41
|
if (timeToRefresh === undefined) return;
|
|
43
42
|
if (this.tokenRefreshTimeout) clearTimeout(this.tokenRefreshTimeout);
|
|
@@ -51,8 +50,7 @@ class JwtTokenManager {
|
|
|
51
50
|
}, timeToRefresh);
|
|
52
51
|
}
|
|
53
52
|
async refreshToken() {
|
|
54
|
-
|
|
55
|
-
if (((_process$env$RUN_ENVI2 = process.env.RUN_ENVIRONMENT) === null || _process$env$RUN_ENVI2 === void 0 ? void 0 : _process$env$RUN_ENVI2.toLowerCase()) !== "authoring") return;
|
|
53
|
+
if (process.env.RUN_ENVIRONMENT?.toLowerCase() !== "authoring") return;
|
|
56
54
|
const res = await this.fetchWithToken(this.refreshTokenPath, {
|
|
57
55
|
method: "GET"
|
|
58
56
|
});
|
|
@@ -65,7 +63,7 @@ class JwtTokenManager {
|
|
|
65
63
|
if (newToken) this._token = newToken;
|
|
66
64
|
}
|
|
67
65
|
fetchWithToken(...[input, init]) {
|
|
68
|
-
const headers = new Headers(init
|
|
66
|
+
const headers = new Headers(init?.headers);
|
|
69
67
|
headers.set("Authorization", `Bearer ${this.token}`);
|
|
70
68
|
return (0, _crossFetch.default)(input, {
|
|
71
69
|
...init,
|
|
@@ -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 =
|
|
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("playwright-core"));
|
|
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";
|
|
@@ -22,11 +22,10 @@ const runAutomationErrorCodes = exports.runAutomationErrorCodes = [apiNotFoundEr
|
|
|
22
22
|
class RunAutomationError {
|
|
23
23
|
wrapped = false;
|
|
24
24
|
get json() {
|
|
25
|
-
var _this$cause;
|
|
26
25
|
return {
|
|
27
26
|
code: this.code,
|
|
28
27
|
details: this.details,
|
|
29
|
-
cause:
|
|
28
|
+
cause: this.cause?.json
|
|
30
29
|
};
|
|
31
30
|
}
|
|
32
31
|
}
|
|
@@ -136,10 +135,10 @@ class AutomationError extends RunAutomationError {
|
|
|
136
135
|
};
|
|
137
136
|
}
|
|
138
137
|
this.statusCode = 500;
|
|
139
|
-
this.message = `[${
|
|
138
|
+
this.message = `[${error?.name ?? error}] ${error?.message}`;
|
|
140
139
|
this.details = {
|
|
141
|
-
name: error
|
|
142
|
-
message: error
|
|
140
|
+
name: error?.name,
|
|
141
|
+
message: error?.message
|
|
143
142
|
};
|
|
144
143
|
}
|
|
145
144
|
}
|
|
@@ -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 "playwright";
|
|
4
4
|
import { ExtendedRunApiParameters, RunApiResult, RunApiResultWithSessionOk } from "./types";
|
|
5
5
|
export * from "./types";
|
|
6
6
|
export * from "./errors";
|
|
@@ -80,17 +80,15 @@ async function* runApiGenerator({
|
|
|
80
80
|
return;
|
|
81
81
|
}
|
|
82
82
|
try {
|
|
83
|
-
|
|
84
|
-
await ((_context = context) === null || _context === void 0 ? void 0 : _context.tracing.stop({
|
|
83
|
+
await context?.tracing.stop({
|
|
85
84
|
path: tracing.filePath
|
|
86
|
-
})
|
|
85
|
+
});
|
|
87
86
|
} catch (error) {
|
|
88
|
-
console.log(errorMessage, error
|
|
87
|
+
console.log(errorMessage, error?.message);
|
|
89
88
|
await (0, _fsExtra.remove)(tracing.filePath);
|
|
90
89
|
}
|
|
91
90
|
}
|
|
92
91
|
async function* runAutomation() {
|
|
93
|
-
var _getExecutionContext;
|
|
94
92
|
let page;
|
|
95
93
|
const validatedModuleResult = await importUsingImportFunction(automationFunction.name, importFunction);
|
|
96
94
|
if (validatedModuleResult.isErr()) {
|
|
@@ -98,7 +96,7 @@ async function* runApiGenerator({
|
|
|
98
96
|
}
|
|
99
97
|
const importedModule = validatedModuleResult.value;
|
|
100
98
|
let checkFn;
|
|
101
|
-
if (auth
|
|
99
|
+
if (auth?.runCheck) {
|
|
102
100
|
if (!auth.session) {
|
|
103
101
|
return (0, _neverthrow.err)(new _errors.AuthRequiredError());
|
|
104
102
|
}
|
|
@@ -130,7 +128,7 @@ async function* runApiGenerator({
|
|
|
130
128
|
headless,
|
|
131
129
|
proxy,
|
|
132
130
|
downloadsPath,
|
|
133
|
-
storageState: auth
|
|
131
|
+
storageState: auth?.session
|
|
134
132
|
}));
|
|
135
133
|
} else {
|
|
136
134
|
const {
|
|
@@ -140,7 +138,7 @@ async function* runApiGenerator({
|
|
|
140
138
|
({
|
|
141
139
|
page,
|
|
142
140
|
context
|
|
143
|
-
} = await (0, _getPlaywrightConstructs.getPlaywrightConstructsForMode)(mode, cdpAddress, auth
|
|
141
|
+
} = await (0, _getPlaywrightConstructs.getPlaywrightConstructsForMode)(mode, cdpAddress, auth?.session));
|
|
144
142
|
}
|
|
145
143
|
if (tracing.enabled) {
|
|
146
144
|
await context.tracing.start({
|
|
@@ -185,7 +183,7 @@ async function* runApiGenerator({
|
|
|
185
183
|
}
|
|
186
184
|
return (0, _neverthrow.ok)({
|
|
187
185
|
result,
|
|
188
|
-
extendedPayloads: (
|
|
186
|
+
extendedPayloads: (0, _asyncLocalStorage.getExecutionContext)()?.extendedPayloads,
|
|
189
187
|
session: retrieveSession ? await (0, _contextStorageStateHelpers.getStorageState)(context) : undefined
|
|
190
188
|
});
|
|
191
189
|
}
|
|
@@ -206,11 +204,10 @@ async function* runApiGenerator({
|
|
|
206
204
|
} catch (error) {
|
|
207
205
|
return (0, _neverthrow.err)(new _errors.AutomationError(error));
|
|
208
206
|
} finally {
|
|
209
|
-
var _context2;
|
|
210
207
|
await saveTraceIfNeeded({
|
|
211
208
|
errorMessage: "failed to save trace"
|
|
212
209
|
});
|
|
213
|
-
await
|
|
210
|
+
await context?.close();
|
|
214
211
|
if (downloadsPath !== undefined) {
|
|
215
212
|
await fs.remove(downloadsPath);
|
|
216
213
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { extendPayload, extendTimeout, runInfo, RunError, requestMultipleChoice, requestOTP, } from "./runtime";
|
|
1
|
+
export { extendPayload, extendTimeout, runInfo, RunError, requestMultipleChoice, requestOTP, getAuthSessionParameters, } 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,6 +21,12 @@ 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
|
+
});
|
|
24
30
|
Object.defineProperty(exports, "getDownloadDirectoryPath", {
|
|
25
31
|
enumerable: true,
|
|
26
32
|
get: function () {
|
|
@@ -24,13 +24,12 @@ var _enums = require("./enums");
|
|
|
24
24
|
runId: "test-run-id",
|
|
25
25
|
extendedPayloads: []
|
|
26
26
|
}, () => {
|
|
27
|
-
|
|
28
|
-
(0, _vitest.expect)((_getExecutionContext = (0, _asyncLocalStorage.getExecutionContext)()) === null || _getExecutionContext === void 0 ? void 0 : _getExecutionContext.extendedPayloads).toEqual([]);
|
|
27
|
+
(0, _vitest.expect)((0, _asyncLocalStorage.getExecutionContext)()?.extendedPayloads).toEqual([]);
|
|
29
28
|
(0, _.extendPayload)({
|
|
30
29
|
api: "test-api",
|
|
31
30
|
parameters: {}
|
|
32
31
|
});
|
|
33
|
-
(0, _vitest.expect)((
|
|
32
|
+
(0, _vitest.expect)((0, _asyncLocalStorage.getExecutionContext)()?.extendedPayloads).toEqual([{
|
|
34
33
|
api: "test-api",
|
|
35
34
|
parameters: {}
|
|
36
35
|
}]);
|
|
@@ -47,7 +46,7 @@ var _enums = require("./enums");
|
|
|
47
46
|
parameters: {}
|
|
48
47
|
});
|
|
49
48
|
const context = (0, _asyncLocalStorage.getExecutionContext)();
|
|
50
|
-
(0, _vitest.expect)(context
|
|
49
|
+
(0, _vitest.expect)(context?.extendedPayloads).toHaveLength(4);
|
|
51
50
|
});
|
|
52
51
|
});
|
|
53
52
|
});
|
package/dist/runtime/export.d.ts
CHANGED
|
@@ -99,6 +99,7 @@ export interface RunInfo {
|
|
|
99
99
|
jobRunId?: string;
|
|
100
100
|
queueId?: string;
|
|
101
101
|
proxy?: string;
|
|
102
|
+
authSessionId?: string;
|
|
102
103
|
}
|
|
103
104
|
|
|
104
105
|
/**
|
|
@@ -200,3 +201,18 @@ export declare function requestMultipleChoice(
|
|
|
200
201
|
* ```
|
|
201
202
|
*/
|
|
202
203
|
export declare function requestOTP(message: string): unknown;
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Retrieves the parameters for the authentication session currently being used.
|
|
207
|
+
*
|
|
208
|
+
* @returns {AuthSessionParameters} An object containing the parameters for the current authentication session.
|
|
209
|
+
*
|
|
210
|
+
* @example
|
|
211
|
+
* ```typescript getAuthSessionParameters
|
|
212
|
+
* import { getAuthSessionParameters } from "@intuned/sdk/runtime"
|
|
213
|
+
*
|
|
214
|
+
* const authSessionParams = getAuthSessionParameters();
|
|
215
|
+
* console.log(authSessionParams);
|
|
216
|
+
* ```
|
|
217
|
+
*/
|
|
218
|
+
export declare function getAuthSessionParameters(): Promise<any>;
|
|
@@ -16,6 +16,6 @@ function extendPayload(payload) {
|
|
|
16
16
|
context.extendedPayloads = [...items];
|
|
17
17
|
return;
|
|
18
18
|
}
|
|
19
|
-
context
|
|
19
|
+
context?.extendedPayloads.push(...items);
|
|
20
20
|
(0, _extendTimeout.extendTimeout)();
|
|
21
21
|
}
|
|
@@ -17,13 +17,6 @@ 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
|
-
}
|
|
27
20
|
if (timeoutInfo.extendTimeoutCallback !== undefined) {
|
|
28
21
|
void timeoutInfo.extendTimeoutCallback().catch(() => undefined);
|
|
29
22
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getAuthSessionParameters(): Promise<any>;
|
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
}
|
package/dist/runtime/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { extendPayload } from "./extendPayload";
|
|
2
2
|
export { extendTimeout } from "./extendTimeout";
|
|
3
|
+
export { getAuthSessionParameters } from "./getAuthSessionParameters";
|
|
3
4
|
export { runInfo } from "./runInfo";
|
|
4
5
|
export { RunError } from "./RunError";
|
|
5
6
|
export { requestMultipleChoice, requestOTP } from "./requestMoreInfo";
|
package/dist/runtime/index.js
CHANGED
|
@@ -21,6 +21,12 @@ 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
|
+
});
|
|
24
30
|
Object.defineProperty(exports, "getDownloadDirectoryPath", {
|
|
25
31
|
enumerable: true,
|
|
26
32
|
get: function () {
|
|
@@ -47,6 +53,7 @@ Object.defineProperty(exports, "runInfo", {
|
|
|
47
53
|
});
|
|
48
54
|
var _extendPayload = require("./extendPayload");
|
|
49
55
|
var _extendTimeout = require("./extendTimeout");
|
|
56
|
+
var _getAuthSessionParameters = require("./getAuthSessionParameters");
|
|
50
57
|
var _runInfo = require("./runInfo");
|
|
51
58
|
var _RunError = require("./RunError");
|
|
52
59
|
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-
|
|
3
|
+
"version": "1.1.3-dev-00",
|
|
4
4
|
"description": "Intuned runtime",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dist/index.js",
|
|
@@ -83,7 +83,6 @@
|
|
|
83
83
|
"minimatch": "10.0.1",
|
|
84
84
|
"nanoid": "3",
|
|
85
85
|
"neverthrow": "6.1.0",
|
|
86
|
-
"patchright": "1.48.2",
|
|
87
86
|
"playwright-extra": "4.3.6",
|
|
88
87
|
"prettier": "2.8.0",
|
|
89
88
|
"promptly": "3.2.0",
|
|
@@ -131,6 +130,6 @@
|
|
|
131
130
|
"vitest": "^1.1.3"
|
|
132
131
|
},
|
|
133
132
|
"peerDependencies": {
|
|
134
|
-
"
|
|
133
|
+
"playwright": "*"
|
|
135
134
|
}
|
|
136
135
|
}
|
package/template.tsconfig.json
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
|
-
"module": "ESNext",
|
|
4
3
|
"target": "ES2021",
|
|
5
|
-
"lib": [
|
|
6
|
-
"dom",
|
|
7
|
-
"es2021"
|
|
8
|
-
],
|
|
4
|
+
"lib": ["dom", "es2021"],
|
|
9
5
|
"resolveJsonModule": true,
|
|
10
6
|
"esModuleInterop": true,
|
|
11
|
-
"moduleResolution": "
|
|
7
|
+
"moduleResolution": "bundler",
|
|
8
|
+
"module": "esnext",
|
|
12
9
|
"skipLibCheck": true
|
|
13
10
|
}
|
|
14
|
-
}
|
|
11
|
+
}
|