@intuned/runtime-dev 1.3.18-interface.13 → 1.3.18-interface.4
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 +21 -0
- package/.eslintignore +10 -0
- package/.eslintrc.js +39 -0
- package/.turbo/turbo-build.log +2 -0
- package/WebTemplate.zip +0 -0
- package/dist/commands/api/run.d.ts +1 -3
- package/dist/commands/api/run.js +65 -2039
- package/dist/commands/auth-sessions/load.d.ts +1 -0
- package/dist/commands/auth-sessions/load.js +28 -1552
- package/dist/commands/auth-sessions/run-check.d.ts +1 -0
- package/dist/commands/auth-sessions/run-check.js +72 -1961
- package/dist/commands/auth-sessions/run-create.d.ts +1 -0
- package/dist/commands/auth-sessions/run-create.js +66 -1955
- package/dist/commands/browser/save-state.d.ts +1 -0
- package/dist/commands/browser/save-state.js +11 -102
- package/dist/commands/browser/start-browser.d.ts +1 -0
- package/dist/commands/browser/start-browser.js +9 -62
- package/dist/commands/build.d.ts +1 -2
- package/dist/commands/build.js +53 -172
- package/dist/commands/common/browserUtils.d.ts +14 -0
- package/dist/commands/common/browserUtils.js +58 -0
- package/dist/commands/common/getFirstLineNumber.d.ts +9 -0
- package/dist/commands/common/getFirstLineNumber.js +101 -0
- package/dist/commands/common/getFirstLineNumber.test.js +228 -0
- package/dist/commands/common/projectExclusions.d.ts +2 -0
- package/dist/commands/common/projectExclusions.js +8 -0
- package/dist/commands/common/sendMessageToClient.d.ts +1 -0
- package/dist/commands/common/sendMessageToClient.js +10 -0
- package/dist/commands/common/tsNodeImport.d.ts +2 -5
- package/dist/commands/common/tsNodeImport.js +16 -55
- package/dist/commands/common/utils/fileUtils.d.ts +6 -0
- package/dist/commands/common/utils/fileUtils.js +33 -0
- package/dist/commands/common/utils/interfaceClient.d.ts +31 -0
- package/dist/commands/common/utils/interfaceClient.js +99 -0
- package/dist/commands/common/utils/settings.d.ts +2 -0
- package/dist/commands/common/utils/settings.js +31 -0
- package/dist/commands/common/utils/template.d.ts +2 -0
- package/dist/commands/common/utils/template.js +31 -0
- package/dist/commands/get-headless-user-agent.d.ts +1 -2
- package/dist/commands/get-headless-user-agent.js +12 -348
- package/dist/commands/interface/pingPong.d.ts +2 -0
- package/dist/commands/interface/pingPong.js +11 -0
- package/dist/commands/interface/run.d.ts +1 -3
- package/dist/commands/interface/run.js +140 -2034
- package/dist/commands/interface/runApi.d.ts +1 -0
- package/dist/commands/interface/runApi.js +102 -0
- package/dist/commands/intuned-cli/commands/attempt.command.d.ts +1 -0
- package/dist/commands/intuned-cli/commands/attempt.command.js +8 -0
- package/dist/commands/intuned-cli/commands/attempt_api.command.d.ts +1 -0
- package/dist/commands/intuned-cli/commands/attempt_api.command.js +30 -0
- package/dist/commands/intuned-cli/commands/attempt_authsession.command.d.ts +1 -0
- package/dist/commands/intuned-cli/commands/attempt_authsession.command.js +8 -0
- package/dist/commands/intuned-cli/commands/attempt_authsession_check.command.d.ts +1 -0
- package/dist/commands/intuned-cli/commands/attempt_authsession_check.command.js +19 -0
- package/dist/commands/intuned-cli/commands/attempt_authsession_create.command.d.ts +1 -0
- package/dist/commands/intuned-cli/commands/attempt_authsession_create.command.js +24 -0
- 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 +32 -0
- package/dist/commands/intuned-cli/commands/authsession_scaffold.command.d.ts +1 -0
- package/dist/commands/intuned-cli/commands/authsession_scaffold.command.js +16 -0
- package/dist/commands/intuned-cli/commands/build.command.d.ts +1 -0
- package/dist/commands/intuned-cli/commands/build.command.js +12 -0
- package/dist/commands/intuned-cli/commands/command.d.ts +2 -0
- package/dist/commands/intuned-cli/commands/command.js +9 -0
- package/dist/commands/intuned-cli/commands/deploy.command.d.ts +1 -0
- package/dist/commands/intuned-cli/commands/deploy.command.js +42 -0
- package/dist/commands/intuned-cli/commands/index.d.ts +18 -0
- package/dist/commands/intuned-cli/commands/index.js +203 -0
- package/dist/commands/intuned-cli/commands/provision.command.d.ts +13 -0
- package/dist/commands/intuned-cli/commands/provision.command.js +50 -0
- package/dist/commands/intuned-cli/commands/run.command.d.ts +1 -0
- package/dist/commands/intuned-cli/commands/run.command.js +8 -0
- package/dist/commands/intuned-cli/commands/run_api.command.d.ts +1 -0
- package/dist/commands/intuned-cli/commands/run_api.command.js +46 -0
- package/dist/commands/intuned-cli/commands/run_authsession.command.d.ts +34 -0
- package/dist/commands/intuned-cli/commands/run_authsession.command.js +17 -0
- package/dist/commands/intuned-cli/commands/run_authsession_create.command.d.ts +1 -0
- package/dist/commands/intuned-cli/commands/run_authsession_create.command.js +35 -0
- package/dist/commands/intuned-cli/commands/run_authsession_update.command.d.ts +1 -0
- package/dist/commands/intuned-cli/commands/run_authsession_update.command.js +35 -0
- package/dist/commands/intuned-cli/commands/run_authsession_validate.command.d.ts +1 -0
- package/dist/commands/intuned-cli/commands/run_authsession_validate.command.js +33 -0
- package/dist/commands/intuned-cli/commands/types.d.ts +39 -0
- package/dist/commands/intuned-cli/commands/types.js +33 -0
- package/dist/commands/intuned-cli/constants/index.d.ts +17 -0
- package/dist/commands/intuned-cli/constants/index.js +25 -0
- package/dist/commands/intuned-cli/controller/__test__/api.test.js +398 -0
- package/dist/commands/intuned-cli/controller/__test__/authSession.test.js +1060 -0
- package/dist/commands/intuned-cli/controller/api.d.ts +42 -0
- package/dist/commands/intuned-cli/controller/api.js +195 -0
- package/dist/commands/intuned-cli/controller/authSession.d.ts +209 -0
- package/dist/commands/intuned-cli/controller/authSession.js +425 -0
- package/dist/commands/intuned-cli/controller/build.d.ts +1 -0
- package/dist/commands/intuned-cli/controller/build.js +36 -0
- package/dist/commands/intuned-cli/controller/deploy.d.ts +5 -0
- package/dist/commands/intuned-cli/controller/deploy.js +318 -0
- package/dist/commands/intuned-cli/controller/index.d.ts +1 -0
- package/dist/commands/intuned-cli/controller/index.js +46 -0
- package/dist/commands/intuned-cli/controller/provision.d.ts +21 -0
- package/dist/commands/intuned-cli/controller/provision.js +300 -0
- package/dist/commands/intuned-cli/controller/scaffold.d.ts +1 -0
- package/dist/commands/intuned-cli/controller/scaffold.js +77 -0
- package/dist/commands/intuned-cli/helpers/__test__/browser.test.js +152 -0
- package/dist/commands/intuned-cli/helpers/__test__/tracing.test.js +41 -0
- package/dist/commands/intuned-cli/helpers/api.d.ts +3 -0
- package/dist/commands/intuned-cli/helpers/api.js +16 -0
- package/dist/commands/intuned-cli/helpers/auth.d.ts +46 -0
- package/dist/commands/intuned-cli/helpers/auth.js +147 -0
- package/dist/commands/intuned-cli/helpers/backend.d.ts +8 -0
- package/dist/commands/intuned-cli/helpers/backend.js +35 -0
- package/dist/commands/intuned-cli/helpers/browser.d.ts +14 -0
- package/dist/commands/intuned-cli/helpers/browser.js +93 -0
- package/dist/commands/intuned-cli/helpers/context.d.ts +3 -0
- package/dist/commands/intuned-cli/helpers/context.js +33 -0
- package/dist/commands/intuned-cli/helpers/errors.d.ts +16 -0
- package/dist/commands/intuned-cli/helpers/errors.js +44 -0
- package/dist/commands/intuned-cli/helpers/index.d.ts +12 -0
- package/dist/commands/intuned-cli/helpers/index.js +137 -0
- package/dist/commands/intuned-cli/helpers/intunedJson.d.ts +39 -0
- package/dist/commands/intuned-cli/helpers/intunedJson.js +20 -0
- package/dist/commands/intuned-cli/helpers/prompts.d.ts +3 -0
- package/dist/commands/intuned-cli/helpers/prompts.js +71 -0
- package/dist/commands/intuned-cli/helpers/proxy.d.ts +5 -0
- package/dist/commands/intuned-cli/helpers/proxy.js +23 -0
- package/dist/commands/intuned-cli/helpers/terminal.d.ts +5 -0
- package/dist/commands/intuned-cli/helpers/terminal.js +13 -0
- package/dist/commands/intuned-cli/helpers/timeout.d.ts +1 -0
- package/dist/commands/intuned-cli/helpers/timeout.js +23 -0
- 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.d.ts +2 -0
- package/dist/commands/intuned-cli/helpers/validation.js +14 -0
- package/dist/commands/intuned-cli/helpers/wrapper.d.ts +2 -0
- package/dist/commands/intuned-cli/helpers/wrapper.js +76 -0
- package/dist/commands/intuned-cli/index.d.ts +1 -0
- package/dist/commands/intuned-cli/index.js +16 -0
- package/dist/commands/intuned-cli/main.d.ts +1 -2
- package/dist/commands/intuned-cli/main.js +25 -5392
- package/dist/commands/intuned-cli/types.d.ts +70 -0
- package/dist/commands/intuned-cli/types.js +22 -0
- package/dist/commands/ts-check.d.ts +1 -0
- package/dist/commands/ts-check.js +29 -131
- package/dist/common/Logger/Logger/index.d.ts +12 -0
- package/dist/common/Logger/Logger/index.js +60 -0
- package/dist/common/Logger/Logger/types.d.ts +8 -0
- package/dist/common/Logger/Logger/types.js +5 -0
- package/dist/common/Logger/index.d.ts +12 -0
- package/dist/common/Logger/index.js +60 -0
- package/dist/common/Logger/types.d.ts +8 -0
- package/dist/common/Logger/types.js +5 -0
- package/dist/common/asyncLocalStorage/index.d.ts +8 -9
- package/dist/common/asyncLocalStorage/index.js +9 -33
- package/dist/common/backendFunctions/getAuthSessionParameters.d.ts +1 -0
- package/dist/common/backendFunctions/getAuthSessionParameters.js +38 -0
- package/dist/common/binStartupScript.d.ts +1 -2
- package/dist/common/binStartupScript.js +11 -126
- package/dist/common/browserTabs.d.ts +72 -0
- package/dist/common/browserTabs.js +74 -0
- package/dist/common/cleanEnvironmentVariables.d.ts +1 -3
- package/dist/common/cleanEnvironmentVariables.js +7 -29
- package/dist/common/constants.d.ts +11 -13
- package/dist/common/constants.js +15 -57
- package/dist/common/contextStorageStateHelpers.d.ts +6 -8
- package/dist/common/contextStorageStateHelpers.js +22 -46
- package/dist/common/extension/extensionsHelpers.d.ts +11 -0
- package/dist/common/extension/extensionsHelpers.js +147 -0
- package/dist/common/extension/intunedExtensionServer.d.ts +24 -0
- package/dist/common/extension/intunedExtensionServer.js +178 -0
- package/dist/common/extension/types.d.ts +212 -0
- package/dist/common/extension/types.js +51 -0
- package/dist/common/formatZodError.d.ts +2 -0
- package/dist/common/formatZodError.js +18 -0
- package/dist/common/intunedJson.d.ts +229 -0
- package/dist/common/intunedJson.js +133 -0
- package/dist/common/jwtTokenManager.d.ts +4 -6
- package/dist/common/jwtTokenManager.js +41 -107
- package/dist/common/launchBrowser.d.ts +34 -0
- package/dist/common/launchBrowser.js +248 -0
- package/dist/common/playwrightContext.d.ts +30 -0
- package/dist/common/playwrightContext.js +153 -0
- package/dist/common/runApi/importUsingImportFunction.d.ts +7 -0
- package/dist/common/runApi/importUsingImportFunction.js +46 -0
- package/dist/common/runApi/index.d.ts +6 -9
- package/dist/common/runApi/index.js +78 -1765
- package/dist/common/settingsSchema.d.ts +51 -58
- package/dist/common/settingsSchema.js +20 -54
- package/dist/common/setupContextHook.d.ts +16 -0
- package/dist/common/setupContextHook.js +22 -0
- package/dist/common/telemetry.d.ts +3 -6
- package/dist/common/telemetry.js +9 -40
- package/dist/index.d.ts +4 -6
- package/dist/index.js +92 -783
- package/dist/runtime/RunError.d.ts +5 -0
- package/dist/runtime/RunError.js +19 -0
- package/dist/runtime/attemptStore.d.ts +2 -0
- package/dist/runtime/attemptStore.js +23 -0
- package/dist/runtime/captcha.d.ts +15 -0
- package/dist/runtime/captcha.js +191 -0
- package/dist/runtime/captcha.test.js +821 -0
- package/dist/runtime/downloadDirectory.d.ts +1 -0
- package/dist/runtime/downloadDirectory.js +19 -0
- package/dist/runtime/enums.d.js +5 -0
- package/dist/runtime/enums.d.ts +11 -0
- package/dist/runtime/enums.js +18 -0
- package/dist/runtime/executionHelpers.test.js +52 -0
- package/dist/runtime/export.d.js +5 -0
- package/dist/runtime/export.d.ts +284 -0
- package/dist/runtime/extendPayload.d.ts +2 -0
- package/dist/runtime/extendPayload.js +21 -0
- package/dist/runtime/extendTimeout.d.ts +1 -0
- package/dist/runtime/extendTimeout.js +23 -0
- package/dist/runtime/getAiGatewayConfig.d.ts +10 -0
- package/dist/runtime/getAiGatewayConfig.js +16 -0
- package/dist/runtime/getAuthSessionParameters.d.ts +1 -0
- package/dist/runtime/getAuthSessionParameters.js +20 -0
- package/dist/runtime/index.d.ts +10 -168
- package/dist/runtime/index.js +88 -778
- package/dist/runtime/persistentStore.d.ts +2 -0
- package/dist/runtime/persistentStore.js +37 -0
- package/dist/runtime/persistentStore.test.js +101 -0
- package/dist/runtime/runInfo.d.ts +2 -0
- package/dist/runtime/runInfo.js +21 -0
- package/package.json +16 -77
- package/template.tsconfig.json +11 -0
- package/tsconfig.eslint.json +5 -0
- package/tsconfig.json +25 -0
- package/typedoc.json +49 -0
- package/dist/export.d-BAUMB-lG.d.ts +0 -140
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { type Err, type Ok } from "neverthrow";
|
|
3
|
+
export declare const intunedJsonSchema: z.ZodIntersection<z.ZodObject<{
|
|
4
|
+
projectName: z.ZodOptional<z.ZodString>;
|
|
5
|
+
workspaceId: z.ZodOptional<z.ZodString>;
|
|
6
|
+
metadata: z.ZodCatch<z.ZodOptional<z.ZodObject<{
|
|
7
|
+
defaultJobInput: z.ZodCatch<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>>;
|
|
8
|
+
defaultRunPlaygroundInput: z.ZodCatch<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>>;
|
|
9
|
+
testAuthSessionInput: z.ZodCatch<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>>;
|
|
10
|
+
}, "strip", z.ZodTypeAny, {
|
|
11
|
+
defaultJobInput?: Record<string, any> | undefined;
|
|
12
|
+
defaultRunPlaygroundInput?: Record<string, any> | undefined;
|
|
13
|
+
testAuthSessionInput?: Record<string, any> | undefined;
|
|
14
|
+
}, {
|
|
15
|
+
defaultJobInput?: unknown;
|
|
16
|
+
defaultRunPlaygroundInput?: unknown;
|
|
17
|
+
testAuthSessionInput?: unknown;
|
|
18
|
+
}>>>;
|
|
19
|
+
stealthMode: z.ZodCatch<z.ZodOptional<z.ZodObject<{
|
|
20
|
+
enabled: z.ZodBoolean;
|
|
21
|
+
}, "strip", z.ZodTypeAny, {
|
|
22
|
+
enabled: boolean;
|
|
23
|
+
}, {
|
|
24
|
+
enabled: boolean;
|
|
25
|
+
}>>>;
|
|
26
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
27
|
+
projectName: z.ZodOptional<z.ZodString>;
|
|
28
|
+
workspaceId: z.ZodOptional<z.ZodString>;
|
|
29
|
+
metadata: z.ZodCatch<z.ZodOptional<z.ZodObject<{
|
|
30
|
+
defaultJobInput: z.ZodCatch<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>>;
|
|
31
|
+
defaultRunPlaygroundInput: z.ZodCatch<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>>;
|
|
32
|
+
testAuthSessionInput: z.ZodCatch<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>>;
|
|
33
|
+
}, "strip", z.ZodTypeAny, {
|
|
34
|
+
defaultJobInput?: Record<string, any> | undefined;
|
|
35
|
+
defaultRunPlaygroundInput?: Record<string, any> | undefined;
|
|
36
|
+
testAuthSessionInput?: Record<string, any> | undefined;
|
|
37
|
+
}, {
|
|
38
|
+
defaultJobInput?: unknown;
|
|
39
|
+
defaultRunPlaygroundInput?: unknown;
|
|
40
|
+
testAuthSessionInput?: unknown;
|
|
41
|
+
}>>>;
|
|
42
|
+
stealthMode: z.ZodCatch<z.ZodOptional<z.ZodObject<{
|
|
43
|
+
enabled: z.ZodBoolean;
|
|
44
|
+
}, "strip", z.ZodTypeAny, {
|
|
45
|
+
enabled: boolean;
|
|
46
|
+
}, {
|
|
47
|
+
enabled: boolean;
|
|
48
|
+
}>>>;
|
|
49
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
50
|
+
projectName: z.ZodOptional<z.ZodString>;
|
|
51
|
+
workspaceId: z.ZodOptional<z.ZodString>;
|
|
52
|
+
metadata: z.ZodCatch<z.ZodOptional<z.ZodObject<{
|
|
53
|
+
defaultJobInput: z.ZodCatch<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>>;
|
|
54
|
+
defaultRunPlaygroundInput: z.ZodCatch<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>>;
|
|
55
|
+
testAuthSessionInput: z.ZodCatch<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>>;
|
|
56
|
+
}, "strip", z.ZodTypeAny, {
|
|
57
|
+
defaultJobInput?: Record<string, any> | undefined;
|
|
58
|
+
defaultRunPlaygroundInput?: Record<string, any> | undefined;
|
|
59
|
+
testAuthSessionInput?: Record<string, any> | undefined;
|
|
60
|
+
}, {
|
|
61
|
+
defaultJobInput?: unknown;
|
|
62
|
+
defaultRunPlaygroundInput?: unknown;
|
|
63
|
+
testAuthSessionInput?: unknown;
|
|
64
|
+
}>>>;
|
|
65
|
+
stealthMode: z.ZodCatch<z.ZodOptional<z.ZodObject<{
|
|
66
|
+
enabled: z.ZodBoolean;
|
|
67
|
+
}, "strip", z.ZodTypeAny, {
|
|
68
|
+
enabled: boolean;
|
|
69
|
+
}, {
|
|
70
|
+
enabled: boolean;
|
|
71
|
+
}>>>;
|
|
72
|
+
}, z.ZodTypeAny, "passthrough">>, z.ZodUnion<[z.ZodObject<{
|
|
73
|
+
authSessions: z.ZodObject<{
|
|
74
|
+
enabled: z.ZodLiteral<false>;
|
|
75
|
+
}, "strip", z.ZodTypeAny, {
|
|
76
|
+
enabled: false;
|
|
77
|
+
}, {
|
|
78
|
+
enabled: false;
|
|
79
|
+
}>;
|
|
80
|
+
apiAccess: z.ZodObject<{
|
|
81
|
+
enabled: z.ZodLiteral<false>;
|
|
82
|
+
}, "strip", z.ZodTypeAny, {
|
|
83
|
+
enabled: false;
|
|
84
|
+
}, {
|
|
85
|
+
enabled: false;
|
|
86
|
+
}>;
|
|
87
|
+
}, "strip", z.ZodTypeAny, {
|
|
88
|
+
authSessions: {
|
|
89
|
+
enabled: false;
|
|
90
|
+
};
|
|
91
|
+
apiAccess: {
|
|
92
|
+
enabled: false;
|
|
93
|
+
};
|
|
94
|
+
}, {
|
|
95
|
+
authSessions: {
|
|
96
|
+
enabled: false;
|
|
97
|
+
};
|
|
98
|
+
apiAccess: {
|
|
99
|
+
enabled: false;
|
|
100
|
+
};
|
|
101
|
+
}>, z.ZodObject<{
|
|
102
|
+
authSessions: z.ZodUnion<[z.ZodObject<{
|
|
103
|
+
enabled: z.ZodLiteral<false>;
|
|
104
|
+
}, "strip", z.ZodTypeAny, {
|
|
105
|
+
enabled: false;
|
|
106
|
+
}, {
|
|
107
|
+
enabled: false;
|
|
108
|
+
}>, z.ZodObject<{
|
|
109
|
+
enabled: z.ZodLiteral<true>;
|
|
110
|
+
type: z.ZodEnum<["MANUAL", "API"]>;
|
|
111
|
+
startUrl: z.ZodOptional<z.ZodString>;
|
|
112
|
+
finishUrl: z.ZodOptional<z.ZodString>;
|
|
113
|
+
}, "strip", z.ZodTypeAny, {
|
|
114
|
+
type: "API" | "MANUAL";
|
|
115
|
+
enabled: true;
|
|
116
|
+
startUrl?: string | undefined;
|
|
117
|
+
finishUrl?: string | undefined;
|
|
118
|
+
}, {
|
|
119
|
+
type: "API" | "MANUAL";
|
|
120
|
+
enabled: true;
|
|
121
|
+
startUrl?: string | undefined;
|
|
122
|
+
finishUrl?: string | undefined;
|
|
123
|
+
}>]>;
|
|
124
|
+
apiAccess: z.ZodObject<{
|
|
125
|
+
enabled: z.ZodLiteral<true>;
|
|
126
|
+
}, "strip", z.ZodTypeAny, {
|
|
127
|
+
enabled: true;
|
|
128
|
+
}, {
|
|
129
|
+
enabled: true;
|
|
130
|
+
}>;
|
|
131
|
+
}, "strip", z.ZodTypeAny, {
|
|
132
|
+
authSessions: {
|
|
133
|
+
enabled: false;
|
|
134
|
+
} | {
|
|
135
|
+
type: "API" | "MANUAL";
|
|
136
|
+
enabled: true;
|
|
137
|
+
startUrl?: string | undefined;
|
|
138
|
+
finishUrl?: string | undefined;
|
|
139
|
+
};
|
|
140
|
+
apiAccess: {
|
|
141
|
+
enabled: true;
|
|
142
|
+
};
|
|
143
|
+
}, {
|
|
144
|
+
authSessions: {
|
|
145
|
+
enabled: false;
|
|
146
|
+
} | {
|
|
147
|
+
type: "API" | "MANUAL";
|
|
148
|
+
enabled: true;
|
|
149
|
+
startUrl?: string | undefined;
|
|
150
|
+
finishUrl?: string | undefined;
|
|
151
|
+
};
|
|
152
|
+
apiAccess: {
|
|
153
|
+
enabled: true;
|
|
154
|
+
};
|
|
155
|
+
}>]>>;
|
|
156
|
+
export type IntunedJson = z.infer<typeof intunedJsonSchema>;
|
|
157
|
+
export declare const intunedSettingsFileNames: readonly ["Intuned.json", "Intuned.jsonc", "Intuned.yaml", "Intuned.yml", "Intuned.toml"];
|
|
158
|
+
export declare function loadIntunedJson(): Promise<Err<never, string> | Ok<{
|
|
159
|
+
projectName?: string | undefined;
|
|
160
|
+
workspaceId?: string | undefined;
|
|
161
|
+
metadata?: {
|
|
162
|
+
defaultJobInput?: Record<string, any> | undefined;
|
|
163
|
+
defaultRunPlaygroundInput?: Record<string, any> | undefined;
|
|
164
|
+
testAuthSessionInput?: Record<string, any> | undefined;
|
|
165
|
+
} | undefined;
|
|
166
|
+
stealthMode?: {
|
|
167
|
+
enabled: boolean;
|
|
168
|
+
} | undefined;
|
|
169
|
+
} & {
|
|
170
|
+
[k: string]: unknown;
|
|
171
|
+
} & ({
|
|
172
|
+
authSessions: {
|
|
173
|
+
enabled: false;
|
|
174
|
+
};
|
|
175
|
+
apiAccess: {
|
|
176
|
+
enabled: false;
|
|
177
|
+
};
|
|
178
|
+
} | {
|
|
179
|
+
authSessions: {
|
|
180
|
+
enabled: false;
|
|
181
|
+
} | {
|
|
182
|
+
type: "API" | "MANUAL";
|
|
183
|
+
enabled: true;
|
|
184
|
+
startUrl?: string | undefined;
|
|
185
|
+
finishUrl?: string | undefined;
|
|
186
|
+
};
|
|
187
|
+
apiAccess: {
|
|
188
|
+
enabled: true;
|
|
189
|
+
};
|
|
190
|
+
}), never>>;
|
|
191
|
+
export declare function getIntunedSettingsFile(): Promise<Ok<{
|
|
192
|
+
name: typeof intunedSettingsFileNames[number];
|
|
193
|
+
path: string;
|
|
194
|
+
parse: (content: string) => any;
|
|
195
|
+
}, never> | Err<never, string>>;
|
|
196
|
+
export declare function getIntunedSettingsFileName(): Promise<Err<never, string> | Ok<"Intuned.json" | "Intuned.jsonc" | "Intuned.yaml" | "Intuned.yml" | "Intuned.toml", never>>;
|
|
197
|
+
export declare function loadIntunedJsonSync(): Err<never, string> | Ok<{
|
|
198
|
+
projectName?: string | undefined;
|
|
199
|
+
workspaceId?: string | undefined;
|
|
200
|
+
metadata?: {
|
|
201
|
+
defaultJobInput?: Record<string, any> | undefined;
|
|
202
|
+
defaultRunPlaygroundInput?: Record<string, any> | undefined;
|
|
203
|
+
testAuthSessionInput?: Record<string, any> | undefined;
|
|
204
|
+
} | undefined;
|
|
205
|
+
stealthMode?: {
|
|
206
|
+
enabled: boolean;
|
|
207
|
+
} | undefined;
|
|
208
|
+
} & {
|
|
209
|
+
[k: string]: unknown;
|
|
210
|
+
} & ({
|
|
211
|
+
authSessions: {
|
|
212
|
+
enabled: false;
|
|
213
|
+
};
|
|
214
|
+
apiAccess: {
|
|
215
|
+
enabled: false;
|
|
216
|
+
};
|
|
217
|
+
} | {
|
|
218
|
+
authSessions: {
|
|
219
|
+
enabled: false;
|
|
220
|
+
} | {
|
|
221
|
+
type: "API" | "MANUAL";
|
|
222
|
+
enabled: true;
|
|
223
|
+
startUrl?: string | undefined;
|
|
224
|
+
finishUrl?: string | undefined;
|
|
225
|
+
};
|
|
226
|
+
apiAccess: {
|
|
227
|
+
enabled: true;
|
|
228
|
+
};
|
|
229
|
+
}), never>;
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getIntunedSettingsFile = getIntunedSettingsFile;
|
|
7
|
+
exports.getIntunedSettingsFileName = getIntunedSettingsFileName;
|
|
8
|
+
exports.intunedSettingsFileNames = exports.intunedJsonSchema = void 0;
|
|
9
|
+
exports.loadIntunedJson = loadIntunedJson;
|
|
10
|
+
exports.loadIntunedJsonSync = loadIntunedJsonSync;
|
|
11
|
+
var _path = _interopRequireDefault(require("path"));
|
|
12
|
+
var fs = _interopRequireWildcard(require("fs-extra"));
|
|
13
|
+
var _zod = require("zod");
|
|
14
|
+
var JSONC = _interopRequireWildcard(require("jsonc-parser"));
|
|
15
|
+
var YAML = _interopRequireWildcard(require("yaml"));
|
|
16
|
+
var TOML = _interopRequireWildcard(require("smol-toml"));
|
|
17
|
+
var _neverthrow = require("neverthrow");
|
|
18
|
+
var _formatZodError = require("./formatZodError");
|
|
19
|
+
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); }
|
|
20
|
+
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; }
|
|
21
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
22
|
+
const playwright = undefined;
|
|
23
|
+
const intunedJsonSchema = exports.intunedJsonSchema = _zod.z.object({
|
|
24
|
+
projectName: _zod.z.string().optional(),
|
|
25
|
+
workspaceId: _zod.z.string().optional(),
|
|
26
|
+
metadata: _zod.z.object({
|
|
27
|
+
defaultJobInput: _zod.z.record(_zod.z.any()).optional().catch(undefined),
|
|
28
|
+
defaultRunPlaygroundInput: _zod.z.record(_zod.z.any()).optional().catch(undefined),
|
|
29
|
+
testAuthSessionInput: _zod.z.record(_zod.z.any()).optional().catch(undefined)
|
|
30
|
+
}).optional().catch(undefined),
|
|
31
|
+
stealthMode: _zod.z.object({
|
|
32
|
+
enabled: _zod.z.boolean()
|
|
33
|
+
}).optional().catch(undefined)
|
|
34
|
+
}).passthrough().and(_zod.z.union([_zod.z.object({
|
|
35
|
+
authSessions: _zod.z.object({
|
|
36
|
+
enabled: _zod.z.literal(false)
|
|
37
|
+
}),
|
|
38
|
+
apiAccess: _zod.z.object({
|
|
39
|
+
enabled: _zod.z.literal(false)
|
|
40
|
+
})
|
|
41
|
+
}), _zod.z.object({
|
|
42
|
+
authSessions: _zod.z.union([_zod.z.object({
|
|
43
|
+
enabled: _zod.z.literal(false)
|
|
44
|
+
}), _zod.z.object({
|
|
45
|
+
enabled: _zod.z.literal(true),
|
|
46
|
+
type: _zod.z.enum(["MANUAL", "API"]),
|
|
47
|
+
startUrl: _zod.z.string().optional(),
|
|
48
|
+
finishUrl: _zod.z.string().optional()
|
|
49
|
+
})]),
|
|
50
|
+
apiAccess: _zod.z.object({
|
|
51
|
+
enabled: _zod.z.literal(true)
|
|
52
|
+
})
|
|
53
|
+
})]));
|
|
54
|
+
const intunedSettingsFileNames = exports.intunedSettingsFileNames = ["Intuned.json", "Intuned.jsonc", "Intuned.yaml", "Intuned.yml", "Intuned.toml"];
|
|
55
|
+
async function loadIntunedJson() {
|
|
56
|
+
const settingsFileResult = await getIntunedSettingsFile();
|
|
57
|
+
if (!settingsFileResult.isOk()) {
|
|
58
|
+
return settingsFileResult;
|
|
59
|
+
}
|
|
60
|
+
const settingsFile = settingsFileResult.value;
|
|
61
|
+
const intunedJsonContent = await fs.readFile(settingsFile.path, "utf-8");
|
|
62
|
+
let intunedJson;
|
|
63
|
+
try {
|
|
64
|
+
intunedJson = settingsFile.parse(intunedJsonContent);
|
|
65
|
+
} catch (e) {
|
|
66
|
+
return (0, _neverthrow.err)(`Failed to parse ${settingsFile.name}: ${e.message}`);
|
|
67
|
+
}
|
|
68
|
+
const parseResult = intunedJsonSchema.safeParse(intunedJson);
|
|
69
|
+
if (!parseResult.success) {
|
|
70
|
+
return (0, _neverthrow.err)(`${settingsFile.name} is not valid:\n${(0, _formatZodError.formatZodError)(parseResult.error)}\nPlease fix the errors and try again.`);
|
|
71
|
+
}
|
|
72
|
+
return (0, _neverthrow.ok)(parseResult.data);
|
|
73
|
+
}
|
|
74
|
+
const intunedSettingsParsers = {
|
|
75
|
+
"Intuned.json": JSON.parse,
|
|
76
|
+
"Intuned.jsonc": JSONC.parse,
|
|
77
|
+
"Intuned.yaml": YAML.parse,
|
|
78
|
+
"Intuned.yml": YAML.parse,
|
|
79
|
+
"Intuned.toml": TOML.parse
|
|
80
|
+
};
|
|
81
|
+
async function getIntunedSettingsFile() {
|
|
82
|
+
for (const fileName of intunedSettingsFileNames) {
|
|
83
|
+
const filePath = _path.default.join(process.cwd(), fileName);
|
|
84
|
+
if (await fs.exists(filePath)) {
|
|
85
|
+
return (0, _neverthrow.ok)({
|
|
86
|
+
name: fileName,
|
|
87
|
+
path: filePath,
|
|
88
|
+
parse: intunedSettingsParsers[fileName]
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return (0, _neverthrow.err)("No Intuned settings file found.");
|
|
93
|
+
}
|
|
94
|
+
async function getIntunedSettingsFileName() {
|
|
95
|
+
const settingsFileResult = await getIntunedSettingsFile();
|
|
96
|
+
if (!settingsFileResult.isOk()) {
|
|
97
|
+
return settingsFileResult;
|
|
98
|
+
}
|
|
99
|
+
return (0, _neverthrow.ok)(settingsFileResult.value.name);
|
|
100
|
+
}
|
|
101
|
+
function loadIntunedJsonSync() {
|
|
102
|
+
const settingsFileResult = getIntunedSettingsFileSync();
|
|
103
|
+
if (!settingsFileResult.isOk()) {
|
|
104
|
+
return settingsFileResult;
|
|
105
|
+
}
|
|
106
|
+
const settingsFile = settingsFileResult.value;
|
|
107
|
+
const intunedJsonContent = fs.readFileSync(settingsFile.path, "utf-8");
|
|
108
|
+
let intunedJson;
|
|
109
|
+
try {
|
|
110
|
+
intunedJson = settingsFile.parse(intunedJsonContent);
|
|
111
|
+
} catch (e) {
|
|
112
|
+
return (0, _neverthrow.err)(`Failed to parse ${settingsFile.name}: ${e.message}`);
|
|
113
|
+
}
|
|
114
|
+
const parseResult = intunedJsonSchema.safeParse(intunedJson);
|
|
115
|
+
if (!parseResult.success) {
|
|
116
|
+
const formattedError = parseResult.error.errors.map(e => `- ${e.path.join(".")}: ${e.message}`).join("\n");
|
|
117
|
+
return (0, _neverthrow.err)(`${settingsFile.name} is not valid:\n${formattedError}\nPlease fix the errors and try again.`);
|
|
118
|
+
}
|
|
119
|
+
return (0, _neverthrow.ok)(parseResult.data);
|
|
120
|
+
}
|
|
121
|
+
function getIntunedSettingsFileSync() {
|
|
122
|
+
for (const fileName of intunedSettingsFileNames) {
|
|
123
|
+
const filePath = _path.default.join(process.cwd(), fileName);
|
|
124
|
+
if (fs.existsSync(filePath)) {
|
|
125
|
+
return (0, _neverthrow.ok)({
|
|
126
|
+
name: fileName,
|
|
127
|
+
path: filePath,
|
|
128
|
+
parse: intunedSettingsParsers[fileName]
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return (0, _neverthrow.err)("No Intuned settings file found.");
|
|
133
|
+
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import fetch from
|
|
2
|
-
|
|
1
|
+
import fetch from "cross-fetch";
|
|
3
2
|
declare class JwtTokenManager {
|
|
4
3
|
private _token;
|
|
5
4
|
private tokenRefreshTimeout;
|
|
@@ -13,7 +12,6 @@ declare class JwtTokenManager {
|
|
|
13
12
|
fetchWithToken(...[input, init]: Parameters<typeof fetch>): Promise<Response>;
|
|
14
13
|
get backendFunctionsBaseUrl(): string | undefined;
|
|
15
14
|
}
|
|
16
|
-
declare const backendFunctionsTokenManager: JwtTokenManager;
|
|
17
|
-
declare function callBackendFunctionWithToken(path: string, init?: Parameters<typeof fetch>[1]): Promise<Response>;
|
|
18
|
-
|
|
19
|
-
export { backendFunctionsTokenManager, callBackendFunctionWithToken };
|
|
15
|
+
export declare const backendFunctionsTokenManager: JwtTokenManager;
|
|
16
|
+
export declare function callBackendFunctionWithToken(path: string, init?: Parameters<typeof fetch>[1]): Promise<Response>;
|
|
17
|
+
export {};
|
|
@@ -1,63 +1,25 @@
|
|
|
1
|
-
|
|
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);
|
|
1
|
+
"use strict";
|
|
28
2
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
__export(jwtTokenManager_exports, {
|
|
32
|
-
backendFunctionsTokenManager: () => backendFunctionsTokenManager,
|
|
33
|
-
callBackendFunctionWithToken: () => callBackendFunctionWithToken
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
34
5
|
});
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
var
|
|
38
|
-
var
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
var
|
|
43
|
-
|
|
44
|
-
|
|
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 {
|
|
6
|
+
exports.backendFunctionsTokenManager = void 0;
|
|
7
|
+
exports.callBackendFunctionWithToken = callBackendFunctionWithToken;
|
|
8
|
+
var _crossFetch = _interopRequireDefault(require("cross-fetch"));
|
|
9
|
+
var jwt = _interopRequireWildcard(require("jsonwebtoken"));
|
|
10
|
+
var _neverthrow = require("neverthrow");
|
|
11
|
+
var _constants = require("./constants");
|
|
12
|
+
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); }
|
|
13
|
+
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; }
|
|
14
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
15
|
+
class JwtTokenManager {
|
|
50
16
|
constructor(refreshTokenPath) {
|
|
51
17
|
this.refreshTokenPath = refreshTokenPath;
|
|
52
|
-
this._token =
|
|
18
|
+
this._token = undefined;
|
|
53
19
|
}
|
|
54
20
|
get token() {
|
|
55
21
|
return this._token;
|
|
56
22
|
}
|
|
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
23
|
set token(newToken) {
|
|
62
24
|
if (this._token != newToken) {
|
|
63
25
|
this._token = newToken;
|
|
@@ -70,14 +32,14 @@ var JwtTokenManager = class {
|
|
|
70
32
|
if (!payload || typeof payload == "string") return;
|
|
71
33
|
const expiry = payload.expiry;
|
|
72
34
|
if (!expiry || typeof expiry !== "number") return;
|
|
73
|
-
const timeWindow = 60 *
|
|
35
|
+
const timeWindow = 60 * 1000;
|
|
74
36
|
const timeToRefresh = expiry - Date.now() - timeWindow;
|
|
75
37
|
return Math.max(timeToRefresh, timeWindow);
|
|
76
38
|
}
|
|
77
39
|
async scheduleTokenRefresh() {
|
|
78
40
|
if (process.env.RUN_ENVIRONMENT?.toLowerCase() !== "authoring") return;
|
|
79
41
|
const timeToRefresh = this.timeToRefresh;
|
|
80
|
-
if (timeToRefresh ===
|
|
42
|
+
if (timeToRefresh === undefined) return;
|
|
81
43
|
if (this.tokenRefreshTimeout) clearTimeout(this.tokenRefreshTimeout);
|
|
82
44
|
this.tokenRefreshTimeout = setTimeout(async () => {
|
|
83
45
|
const result = await this.refreshToken();
|
|
@@ -90,91 +52,63 @@ var JwtTokenManager = class {
|
|
|
90
52
|
}
|
|
91
53
|
async refreshToken() {
|
|
92
54
|
if (process.env.RUN_ENVIRONMENT?.toLowerCase() !== "authoring") return;
|
|
93
|
-
const res = await this.fetchWithToken(
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
method: "GET"
|
|
97
|
-
}
|
|
98
|
-
);
|
|
55
|
+
const res = await this.fetchWithToken(`${this.backendFunctionsBaseUrl}/${this.refreshTokenPath}`, {
|
|
56
|
+
method: "GET"
|
|
57
|
+
});
|
|
99
58
|
if (res.status === 401) {
|
|
100
|
-
return (0,
|
|
59
|
+
return (0, _neverthrow.err)("Unauthorized");
|
|
101
60
|
}
|
|
102
|
-
const jsonResult = await
|
|
103
|
-
res.json(),
|
|
104
|
-
() => "not json"
|
|
105
|
-
);
|
|
61
|
+
const jsonResult = await _neverthrow.ResultAsync.fromPromise(res.json(), () => "not json");
|
|
106
62
|
if (jsonResult.isErr()) return;
|
|
107
63
|
const newToken = jsonResult.value.token;
|
|
108
64
|
if (newToken) this._token = newToken;
|
|
109
65
|
}
|
|
110
66
|
async fetchWithToken(...[input, init]) {
|
|
111
67
|
const headers = new Headers(init?.headers);
|
|
112
|
-
const apiKey = process.env[API_KEY_ENV_VAR_KEY];
|
|
68
|
+
const apiKey = process.env[_constants.API_KEY_ENV_VAR_KEY];
|
|
113
69
|
if (apiKey) {
|
|
114
|
-
headers.set(API_KEY_HEADER_NAME, apiKey);
|
|
70
|
+
headers.set(_constants.API_KEY_HEADER_NAME, apiKey);
|
|
115
71
|
}
|
|
116
|
-
const token = process.env[AUTH_TOKEN_ENV_VAR_KEY];
|
|
72
|
+
const token = process.env[_constants.AUTH_TOKEN_ENV_VAR_KEY];
|
|
117
73
|
if (token) {
|
|
118
74
|
headers.set("Authorization", `Bearer ${token}`);
|
|
119
75
|
}
|
|
120
|
-
if (this.token !==
|
|
76
|
+
if (this.token !== undefined) {
|
|
121
77
|
headers.set("Authorization", `Bearer ${this.token}`);
|
|
122
78
|
}
|
|
123
|
-
const result = await (0,
|
|
79
|
+
const result = await (0, _crossFetch.default)(input, {
|
|
124
80
|
...init,
|
|
125
81
|
headers
|
|
126
82
|
});
|
|
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
|
-
);
|
|
83
|
+
if (result.status === 401 && process.env[_constants.CLI_ENV_VAR_KEY] === "true") {
|
|
84
|
+
console.warn("Unauthorized backend function call - make sure to provision your project to Intuned to set up the correct API credentials.\n" + "Run 'intuned provision' or see https://docs.intunedhq.com/docs/05-references/cli#provision-project for more information.");
|
|
131
85
|
}
|
|
132
86
|
return result;
|
|
133
87
|
}
|
|
134
88
|
get backendFunctionsBaseUrl() {
|
|
135
89
|
try {
|
|
136
90
|
if (!process.env.FUNCTIONS_DOMAIN) {
|
|
137
|
-
throw new Error(
|
|
138
|
-
`Cannot call backend function - FUNCTIONS_DOMAIN not set`
|
|
139
|
-
);
|
|
91
|
+
throw new Error(`Cannot call backend function - FUNCTIONS_DOMAIN not set`);
|
|
140
92
|
}
|
|
141
93
|
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
|
-
);
|
|
94
|
+
if (!process.env[_constants.WORKSPACE_ID_ENV_VAR_KEY]) {
|
|
95
|
+
throw new Error(`Cannot call backend function - ${_constants.WORKSPACE_ID_ENV_VAR_KEY} not set`);
|
|
146
96
|
}
|
|
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
|
-
);
|
|
97
|
+
const workspaceId = process.env[_constants.WORKSPACE_ID_ENV_VAR_KEY];
|
|
98
|
+
if (!process.env[_constants.PROJECT_ID_ENV_VAR_KEY] && !process.env.INTUNED_INTEGRATION_ID) {
|
|
99
|
+
throw new Error(`Cannot call backend function - ${_constants.PROJECT_ID_ENV_VAR_KEY} or INTUNED_INTEGRATION_ID not set`);
|
|
152
100
|
}
|
|
153
|
-
const projectId = process.env.INTUNED_INTEGRATION_ID ?? process.env[PROJECT_ID_ENV_VAR_KEY];
|
|
101
|
+
const projectId = process.env.INTUNED_INTEGRATION_ID ?? process.env[_constants.PROJECT_ID_ENV_VAR_KEY];
|
|
154
102
|
return `${domain}/api/${workspaceId}/functions/${projectId}`;
|
|
155
103
|
} 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
|
-
);
|
|
104
|
+
if (process.env[_constants.CLI_ENV_VAR_KEY] === "true") {
|
|
105
|
+
throw new Error(`API credentials not set - make sure to provision your project to Intuned to set up the correct API credentials.\n` + `Run 'intuned provision' or see https://docs.intunedhq.com/docs/05-references/cli#provision-project for more information.\n` + `Original error: ${e.message}`);
|
|
162
106
|
}
|
|
163
107
|
}
|
|
164
108
|
}
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
`refreshBackendFunctionsToken`
|
|
168
|
-
);
|
|
109
|
+
}
|
|
110
|
+
const backendFunctionsTokenManager = exports.backendFunctionsTokenManager = new JwtTokenManager(`refreshBackendFunctionsToken`);
|
|
169
111
|
backendFunctionsTokenManager.token = process.env.INTUNED_AUTHORING_SESSION_BACKEND_FUNCTIONS_TOKEN;
|
|
170
112
|
function callBackendFunctionWithToken(path, init) {
|
|
171
|
-
return backendFunctionsTokenManager.fetchWithToken(
|
|
172
|
-
|
|
173
|
-
init
|
|
174
|
-
);
|
|
175
|
-
}
|
|
176
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
177
|
-
0 && (module.exports = {
|
|
178
|
-
backendFunctionsTokenManager,
|
|
179
|
-
callBackendFunctionWithToken
|
|
180
|
-
});
|
|
113
|
+
return backendFunctionsTokenManager.fetchWithToken(`${backendFunctionsTokenManager.backendFunctionsBaseUrl}/${path}`, init);
|
|
114
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import * as playwright from "playwright";
|
|
2
|
+
import { Result } from "neverthrow";
|
|
3
|
+
export interface Proxy {
|
|
4
|
+
server: string;
|
|
5
|
+
username: string;
|
|
6
|
+
password: string;
|
|
7
|
+
}
|
|
8
|
+
export type LaunchBrowserResult = {
|
|
9
|
+
page: playwright.Page;
|
|
10
|
+
context: playwright.BrowserContext;
|
|
11
|
+
};
|
|
12
|
+
export type LaunchChromiumStandaloneOptions = {
|
|
13
|
+
proxy?: Proxy;
|
|
14
|
+
headless: boolean;
|
|
15
|
+
downloadsPath?: string;
|
|
16
|
+
cdpPort?: number;
|
|
17
|
+
appModeInitialUrl?: string;
|
|
18
|
+
executablePath?: string;
|
|
19
|
+
};
|
|
20
|
+
export type LaunchChromiumCdpOptions = {
|
|
21
|
+
cdpAddress: string;
|
|
22
|
+
cdpTargetId?: string;
|
|
23
|
+
};
|
|
24
|
+
export declare function launchChromium(options: LaunchChromiumStandaloneOptions): Promise<LaunchBrowserResult>;
|
|
25
|
+
export declare function launchChromium(options: LaunchChromiumCdpOptions): Promise<LaunchBrowserResult>;
|
|
26
|
+
export declare function getBrowserExecutablePath(): Promise<string | undefined>;
|
|
27
|
+
export declare function launchBrowser(options: Omit<LaunchChromiumStandaloneOptions, "executablePath"> | LaunchChromiumCdpOptions): Promise<LaunchBrowserResult>;
|
|
28
|
+
export declare function getLocalCdpAddress(port: number): string;
|
|
29
|
+
export declare function getCdpWebSocketUrl(cdpAddress: string): Promise<Result<string, string>>;
|
|
30
|
+
export declare function getHeadlessUserAgent({ executablePath, args, ignoreDefaultArgs, }: {
|
|
31
|
+
executablePath?: string;
|
|
32
|
+
args?: string[];
|
|
33
|
+
ignoreDefaultArgs?: string[];
|
|
34
|
+
}): Promise<string | undefined>;
|