@intuned/runtime-dev 1.3.18-interface.13 → 1.3.18-interface.16
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/dist/commands/api/run.d.ts +1 -3
- package/dist/commands/api/run.js +64 -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 +71 -1961
- package/dist/commands/auth-sessions/run-create.d.ts +1 -0
- package/dist/commands/auth-sessions/run-create.js +65 -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 +52 -172
- package/dist/commands/common/browserUtils.d.ts +14 -0
- package/dist/commands/common/browserUtils.js +57 -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 +227 -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 +15 -55
- package/dist/commands/common/utils/fileUtils.d.ts +6 -0
- package/dist/commands/common/utils/fileUtils.js +32 -0
- package/dist/commands/common/utils/interfaceClient.d.ts +31 -0
- package/dist/commands/common/utils/interfaceClient.js +98 -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 +30 -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 +139 -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 +35 -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 +194 -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 +35 -0
- package/dist/commands/intuned-cli/controller/deploy.d.ts +5 -0
- package/dist/commands/intuned-cli/controller/deploy.js +317 -0
- package/dist/commands/intuned-cli/controller/index.d.ts +1 -0
- package/dist/commands/intuned-cli/controller/index.js +45 -0
- package/dist/commands/intuned-cli/controller/provision.d.ts +21 -0
- package/dist/commands/intuned-cli/controller/provision.js +299 -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 +24 -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 +28 -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 +10 -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 +219 -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 +132 -0
- package/dist/common/jwtTokenManager.d.ts +4 -6
- package/dist/common/jwtTokenManager.js +40 -107
- package/dist/common/launchBrowser.d.ts +34 -0
- package/dist/common/launchBrowser.js +247 -0
- package/dist/common/playwrightContext.d.ts +29 -0
- package/dist/common/playwrightContext.js +148 -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 +70 -1765
- package/dist/common/settingsSchema.d.ts +6 -9
- package/dist/common/settingsSchema.js +18 -53
- 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 +8 -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/dist/vendor/runtime-interface.d.ts +1 -0
- package/dist/vendor/runtime-interface.js +474 -0
- package/package.json +18 -72
- 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/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
|
+
stealthMode?: {
|
|
160
|
+
enabled: boolean;
|
|
161
|
+
} | undefined;
|
|
162
|
+
workspaceId?: string | undefined;
|
|
163
|
+
projectName?: string | undefined;
|
|
164
|
+
metadata?: {
|
|
165
|
+
defaultJobInput?: Record<string, any> | undefined;
|
|
166
|
+
defaultRunPlaygroundInput?: Record<string, any> | undefined;
|
|
167
|
+
testAuthSessionInput?: Record<string, any> | undefined;
|
|
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
|
+
stealthMode?: {
|
|
199
|
+
enabled: boolean;
|
|
200
|
+
} | undefined;
|
|
201
|
+
workspaceId?: string | undefined;
|
|
202
|
+
projectName?: string | undefined;
|
|
203
|
+
metadata?: {
|
|
204
|
+
defaultJobInput?: Record<string, any> | undefined;
|
|
205
|
+
defaultRunPlaygroundInput?: Record<string, any> | undefined;
|
|
206
|
+
testAuthSessionInput?: Record<string, any> | undefined;
|
|
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,132 @@
|
|
|
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 _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
20
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
21
|
+
const playwright = undefined;
|
|
22
|
+
const intunedJsonSchema = exports.intunedJsonSchema = _zod.z.object({
|
|
23
|
+
projectName: _zod.z.string().optional(),
|
|
24
|
+
workspaceId: _zod.z.string().optional(),
|
|
25
|
+
metadata: _zod.z.object({
|
|
26
|
+
defaultJobInput: _zod.z.record(_zod.z.any()).optional().catch(undefined),
|
|
27
|
+
defaultRunPlaygroundInput: _zod.z.record(_zod.z.any()).optional().catch(undefined),
|
|
28
|
+
testAuthSessionInput: _zod.z.record(_zod.z.any()).optional().catch(undefined)
|
|
29
|
+
}).optional().catch(undefined),
|
|
30
|
+
stealthMode: _zod.z.object({
|
|
31
|
+
enabled: _zod.z.boolean()
|
|
32
|
+
}).optional().catch(undefined)
|
|
33
|
+
}).passthrough().and(_zod.z.union([_zod.z.object({
|
|
34
|
+
authSessions: _zod.z.object({
|
|
35
|
+
enabled: _zod.z.literal(false)
|
|
36
|
+
}),
|
|
37
|
+
apiAccess: _zod.z.object({
|
|
38
|
+
enabled: _zod.z.literal(false)
|
|
39
|
+
})
|
|
40
|
+
}), _zod.z.object({
|
|
41
|
+
authSessions: _zod.z.union([_zod.z.object({
|
|
42
|
+
enabled: _zod.z.literal(false)
|
|
43
|
+
}), _zod.z.object({
|
|
44
|
+
enabled: _zod.z.literal(true),
|
|
45
|
+
type: _zod.z.enum(["MANUAL", "API"]),
|
|
46
|
+
startUrl: _zod.z.string().optional(),
|
|
47
|
+
finishUrl: _zod.z.string().optional()
|
|
48
|
+
})]),
|
|
49
|
+
apiAccess: _zod.z.object({
|
|
50
|
+
enabled: _zod.z.literal(true)
|
|
51
|
+
})
|
|
52
|
+
})]));
|
|
53
|
+
const intunedSettingsFileNames = exports.intunedSettingsFileNames = ["Intuned.json", "Intuned.jsonc", "Intuned.yaml", "Intuned.yml", "Intuned.toml"];
|
|
54
|
+
async function loadIntunedJson() {
|
|
55
|
+
const settingsFileResult = await getIntunedSettingsFile();
|
|
56
|
+
if (!settingsFileResult.isOk()) {
|
|
57
|
+
return settingsFileResult;
|
|
58
|
+
}
|
|
59
|
+
const settingsFile = settingsFileResult.value;
|
|
60
|
+
const intunedJsonContent = await fs.readFile(settingsFile.path, "utf-8");
|
|
61
|
+
let intunedJson;
|
|
62
|
+
try {
|
|
63
|
+
intunedJson = settingsFile.parse(intunedJsonContent);
|
|
64
|
+
} catch (e) {
|
|
65
|
+
return (0, _neverthrow.err)(`Failed to parse ${settingsFile.name}: ${e.message}`);
|
|
66
|
+
}
|
|
67
|
+
const parseResult = intunedJsonSchema.safeParse(intunedJson);
|
|
68
|
+
if (!parseResult.success) {
|
|
69
|
+
return (0, _neverthrow.err)(`${settingsFile.name} is not valid:\n${(0, _formatZodError.formatZodError)(parseResult.error)}\nPlease fix the errors and try again.`);
|
|
70
|
+
}
|
|
71
|
+
return (0, _neverthrow.ok)(parseResult.data);
|
|
72
|
+
}
|
|
73
|
+
const intunedSettingsParsers = {
|
|
74
|
+
"Intuned.json": JSON.parse,
|
|
75
|
+
"Intuned.jsonc": JSONC.parse,
|
|
76
|
+
"Intuned.yaml": YAML.parse,
|
|
77
|
+
"Intuned.yml": YAML.parse,
|
|
78
|
+
"Intuned.toml": TOML.parse
|
|
79
|
+
};
|
|
80
|
+
async function getIntunedSettingsFile() {
|
|
81
|
+
for (const fileName of intunedSettingsFileNames) {
|
|
82
|
+
const filePath = _path.default.join(process.cwd(), fileName);
|
|
83
|
+
if (await fs.exists(filePath)) {
|
|
84
|
+
return (0, _neverthrow.ok)({
|
|
85
|
+
name: fileName,
|
|
86
|
+
path: filePath,
|
|
87
|
+
parse: intunedSettingsParsers[fileName]
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return (0, _neverthrow.err)("No Intuned settings file found.");
|
|
92
|
+
}
|
|
93
|
+
async function getIntunedSettingsFileName() {
|
|
94
|
+
const settingsFileResult = await getIntunedSettingsFile();
|
|
95
|
+
if (!settingsFileResult.isOk()) {
|
|
96
|
+
return settingsFileResult;
|
|
97
|
+
}
|
|
98
|
+
return (0, _neverthrow.ok)(settingsFileResult.value.name);
|
|
99
|
+
}
|
|
100
|
+
function loadIntunedJsonSync() {
|
|
101
|
+
const settingsFileResult = getIntunedSettingsFileSync();
|
|
102
|
+
if (!settingsFileResult.isOk()) {
|
|
103
|
+
return settingsFileResult;
|
|
104
|
+
}
|
|
105
|
+
const settingsFile = settingsFileResult.value;
|
|
106
|
+
const intunedJsonContent = fs.readFileSync(settingsFile.path, "utf-8");
|
|
107
|
+
let intunedJson;
|
|
108
|
+
try {
|
|
109
|
+
intunedJson = settingsFile.parse(intunedJsonContent);
|
|
110
|
+
} catch (e) {
|
|
111
|
+
return (0, _neverthrow.err)(`Failed to parse ${settingsFile.name}: ${e.message}`);
|
|
112
|
+
}
|
|
113
|
+
const parseResult = intunedJsonSchema.safeParse(intunedJson);
|
|
114
|
+
if (!parseResult.success) {
|
|
115
|
+
const formattedError = parseResult.error.errors.map(e => `- ${e.path.join(".")}: ${e.message}`).join("\n");
|
|
116
|
+
return (0, _neverthrow.err)(`${settingsFile.name} is not valid:\n${formattedError}\nPlease fix the errors and try again.`);
|
|
117
|
+
}
|
|
118
|
+
return (0, _neverthrow.ok)(parseResult.data);
|
|
119
|
+
}
|
|
120
|
+
function getIntunedSettingsFileSync() {
|
|
121
|
+
for (const fileName of intunedSettingsFileNames) {
|
|
122
|
+
const filePath = _path.default.join(process.cwd(), fileName);
|
|
123
|
+
if (fs.existsSync(filePath)) {
|
|
124
|
+
return (0, _neverthrow.ok)({
|
|
125
|
+
name: fileName,
|
|
126
|
+
path: filePath,
|
|
127
|
+
parse: intunedSettingsParsers[fileName]
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
return (0, _neverthrow.err)("No Intuned settings file found.");
|
|
132
|
+
}
|
|
@@ -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,24 @@
|
|
|
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
|
-
var
|
|
42
|
-
|
|
43
|
-
|
|
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 {
|
|
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 _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
13
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
|
+
class JwtTokenManager {
|
|
50
15
|
constructor(refreshTokenPath) {
|
|
51
16
|
this.refreshTokenPath = refreshTokenPath;
|
|
52
|
-
this._token =
|
|
17
|
+
this._token = undefined;
|
|
53
18
|
}
|
|
54
19
|
get token() {
|
|
55
20
|
return this._token;
|
|
56
21
|
}
|
|
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
22
|
set token(newToken) {
|
|
62
23
|
if (this._token != newToken) {
|
|
63
24
|
this._token = newToken;
|
|
@@ -70,14 +31,14 @@ var JwtTokenManager = class {
|
|
|
70
31
|
if (!payload || typeof payload == "string") return;
|
|
71
32
|
const expiry = payload.expiry;
|
|
72
33
|
if (!expiry || typeof expiry !== "number") return;
|
|
73
|
-
const timeWindow = 60 *
|
|
34
|
+
const timeWindow = 60 * 1000;
|
|
74
35
|
const timeToRefresh = expiry - Date.now() - timeWindow;
|
|
75
36
|
return Math.max(timeToRefresh, timeWindow);
|
|
76
37
|
}
|
|
77
38
|
async scheduleTokenRefresh() {
|
|
78
39
|
if (process.env.RUN_ENVIRONMENT?.toLowerCase() !== "authoring") return;
|
|
79
40
|
const timeToRefresh = this.timeToRefresh;
|
|
80
|
-
if (timeToRefresh ===
|
|
41
|
+
if (timeToRefresh === undefined) return;
|
|
81
42
|
if (this.tokenRefreshTimeout) clearTimeout(this.tokenRefreshTimeout);
|
|
82
43
|
this.tokenRefreshTimeout = setTimeout(async () => {
|
|
83
44
|
const result = await this.refreshToken();
|
|
@@ -90,91 +51,63 @@ var JwtTokenManager = class {
|
|
|
90
51
|
}
|
|
91
52
|
async refreshToken() {
|
|
92
53
|
if (process.env.RUN_ENVIRONMENT?.toLowerCase() !== "authoring") return;
|
|
93
|
-
const res = await this.fetchWithToken(
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
method: "GET"
|
|
97
|
-
}
|
|
98
|
-
);
|
|
54
|
+
const res = await this.fetchWithToken(`${this.backendFunctionsBaseUrl}/${this.refreshTokenPath}`, {
|
|
55
|
+
method: "GET"
|
|
56
|
+
});
|
|
99
57
|
if (res.status === 401) {
|
|
100
|
-
return (0,
|
|
58
|
+
return (0, _neverthrow.err)("Unauthorized");
|
|
101
59
|
}
|
|
102
|
-
const jsonResult = await
|
|
103
|
-
res.json(),
|
|
104
|
-
() => "not json"
|
|
105
|
-
);
|
|
60
|
+
const jsonResult = await _neverthrow.ResultAsync.fromPromise(res.json(), () => "not json");
|
|
106
61
|
if (jsonResult.isErr()) return;
|
|
107
62
|
const newToken = jsonResult.value.token;
|
|
108
63
|
if (newToken) this._token = newToken;
|
|
109
64
|
}
|
|
110
65
|
async fetchWithToken(...[input, init]) {
|
|
111
66
|
const headers = new Headers(init?.headers);
|
|
112
|
-
const apiKey = process.env[API_KEY_ENV_VAR_KEY];
|
|
67
|
+
const apiKey = process.env[_constants.API_KEY_ENV_VAR_KEY];
|
|
113
68
|
if (apiKey) {
|
|
114
|
-
headers.set(API_KEY_HEADER_NAME, apiKey);
|
|
69
|
+
headers.set(_constants.API_KEY_HEADER_NAME, apiKey);
|
|
115
70
|
}
|
|
116
|
-
const token = process.env[AUTH_TOKEN_ENV_VAR_KEY];
|
|
71
|
+
const token = process.env[_constants.AUTH_TOKEN_ENV_VAR_KEY];
|
|
117
72
|
if (token) {
|
|
118
73
|
headers.set("Authorization", `Bearer ${token}`);
|
|
119
74
|
}
|
|
120
|
-
if (this.token !==
|
|
75
|
+
if (this.token !== undefined) {
|
|
121
76
|
headers.set("Authorization", `Bearer ${this.token}`);
|
|
122
77
|
}
|
|
123
|
-
const result = await (0,
|
|
78
|
+
const result = await (0, _crossFetch.default)(input, {
|
|
124
79
|
...init,
|
|
125
80
|
headers
|
|
126
81
|
});
|
|
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
|
-
);
|
|
82
|
+
if (result.status === 401 && process.env[_constants.CLI_ENV_VAR_KEY] === "true") {
|
|
83
|
+
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
84
|
}
|
|
132
85
|
return result;
|
|
133
86
|
}
|
|
134
87
|
get backendFunctionsBaseUrl() {
|
|
135
88
|
try {
|
|
136
89
|
if (!process.env.FUNCTIONS_DOMAIN) {
|
|
137
|
-
throw new Error(
|
|
138
|
-
`Cannot call backend function - FUNCTIONS_DOMAIN not set`
|
|
139
|
-
);
|
|
90
|
+
throw new Error(`Cannot call backend function - FUNCTIONS_DOMAIN not set`);
|
|
140
91
|
}
|
|
141
92
|
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
|
-
);
|
|
93
|
+
if (!process.env[_constants.WORKSPACE_ID_ENV_VAR_KEY]) {
|
|
94
|
+
throw new Error(`Cannot call backend function - ${_constants.WORKSPACE_ID_ENV_VAR_KEY} not set`);
|
|
146
95
|
}
|
|
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
|
-
);
|
|
96
|
+
const workspaceId = process.env[_constants.WORKSPACE_ID_ENV_VAR_KEY];
|
|
97
|
+
if (!process.env[_constants.PROJECT_ID_ENV_VAR_KEY] && !process.env.INTUNED_INTEGRATION_ID) {
|
|
98
|
+
throw new Error(`Cannot call backend function - ${_constants.PROJECT_ID_ENV_VAR_KEY} or INTUNED_INTEGRATION_ID not set`);
|
|
152
99
|
}
|
|
153
|
-
const projectId = process.env.INTUNED_INTEGRATION_ID ?? process.env[PROJECT_ID_ENV_VAR_KEY];
|
|
100
|
+
const projectId = process.env.INTUNED_INTEGRATION_ID ?? process.env[_constants.PROJECT_ID_ENV_VAR_KEY];
|
|
154
101
|
return `${domain}/api/${workspaceId}/functions/${projectId}`;
|
|
155
102
|
} 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
|
-
);
|
|
103
|
+
if (process.env[_constants.CLI_ENV_VAR_KEY] === "true") {
|
|
104
|
+
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
105
|
}
|
|
163
106
|
}
|
|
164
107
|
}
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
`refreshBackendFunctionsToken`
|
|
168
|
-
);
|
|
108
|
+
}
|
|
109
|
+
const backendFunctionsTokenManager = exports.backendFunctionsTokenManager = new JwtTokenManager(`refreshBackendFunctionsToken`);
|
|
169
110
|
backendFunctionsTokenManager.token = process.env.INTUNED_AUTHORING_SESSION_BACKEND_FUNCTIONS_TOKEN;
|
|
170
111
|
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
|
-
});
|
|
112
|
+
return backendFunctionsTokenManager.fetchWithToken(`${backendFunctionsTokenManager.backendFunctionsBaseUrl}/${path}`, init);
|
|
113
|
+
}
|
|
@@ -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>;
|