@intuned/runtime-dev 1.3.18-interface.15 → 1.3.18-interface.18

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.
Files changed (225) hide show
  1. package/dist/commands/api/run.d.ts +6 -0
  2. package/dist/commands/api/run.js +119 -0
  3. package/dist/commands/auth-sessions/load.d.ts +2 -0
  4. package/dist/commands/auth-sessions/load.js +35 -0
  5. package/dist/commands/auth-sessions/run-check.d.ts +2 -0
  6. package/dist/commands/auth-sessions/run-check.js +74 -0
  7. package/dist/commands/auth-sessions/run-create.d.ts +2 -0
  8. package/dist/commands/auth-sessions/run-create.js +78 -0
  9. package/dist/commands/browser/save-state.d.ts +2 -0
  10. package/dist/commands/browser/save-state.js +17 -0
  11. package/dist/commands/browser/start-browser.d.ts +2 -0
  12. package/dist/commands/browser/start-browser.js +14 -0
  13. package/dist/commands/build.d.ts +1 -0
  14. package/dist/commands/build.js +83 -0
  15. package/dist/commands/common/browserUtils.d.ts +14 -0
  16. package/dist/commands/common/browserUtils.js +57 -0
  17. package/dist/commands/common/getFirstLineNumber.d.ts +9 -0
  18. package/dist/commands/common/getFirstLineNumber.js +101 -0
  19. package/dist/commands/common/getFirstLineNumber.test.js +227 -0
  20. package/dist/commands/common/projectExclusions.d.ts +2 -0
  21. package/dist/commands/common/projectExclusions.js +8 -0
  22. package/dist/commands/common/sendMessageToClient.d.ts +1 -0
  23. package/dist/commands/common/sendMessageToClient.js +10 -0
  24. package/dist/commands/common/tsNodeImport.d.ts +2 -0
  25. package/dist/commands/common/tsNodeImport.js +42 -0
  26. package/dist/commands/common/utils/fileUtils.d.ts +6 -0
  27. package/dist/commands/common/utils/fileUtils.js +32 -0
  28. package/dist/commands/common/utils/interfaceClient.d.ts +31 -0
  29. package/dist/commands/common/utils/interfaceClient.js +98 -0
  30. package/dist/commands/common/utils/settings.d.ts +2 -0
  31. package/dist/commands/common/utils/settings.js +31 -0
  32. package/dist/commands/common/utils/template.d.ts +2 -0
  33. package/dist/commands/common/utils/template.js +30 -0
  34. package/dist/commands/get-headless-user-agent.d.ts +1 -0
  35. package/dist/commands/get-headless-user-agent.js +18 -0
  36. package/dist/commands/interface/pingPong.d.ts +2 -0
  37. package/dist/commands/interface/pingPong.js +11 -0
  38. package/dist/commands/interface/run.d.ts +1 -0
  39. package/dist/commands/interface/run.js +189 -0
  40. package/dist/commands/interface/runApi.d.ts +1 -0
  41. package/dist/commands/interface/runApi.js +102 -0
  42. package/dist/commands/intuned-cli/commands/attempt.command.d.ts +1 -0
  43. package/dist/commands/intuned-cli/commands/attempt.command.js +8 -0
  44. package/dist/commands/intuned-cli/commands/attempt_api.command.d.ts +1 -0
  45. package/dist/commands/intuned-cli/commands/attempt_api.command.js +30 -0
  46. package/dist/commands/intuned-cli/commands/attempt_authsession.command.d.ts +1 -0
  47. package/dist/commands/intuned-cli/commands/attempt_authsession.command.js +8 -0
  48. package/dist/commands/intuned-cli/commands/attempt_authsession_check.command.d.ts +1 -0
  49. package/dist/commands/intuned-cli/commands/attempt_authsession_check.command.js +19 -0
  50. package/dist/commands/intuned-cli/commands/attempt_authsession_create.command.d.ts +1 -0
  51. package/dist/commands/intuned-cli/commands/attempt_authsession_create.command.js +24 -0
  52. package/dist/commands/intuned-cli/commands/authsession.command.d.ts +1 -0
  53. package/dist/commands/intuned-cli/commands/authsession.command.js +8 -0
  54. package/dist/commands/intuned-cli/commands/authsession_record.command.d.ts +1 -0
  55. package/dist/commands/intuned-cli/commands/authsession_record.command.js +32 -0
  56. package/dist/commands/intuned-cli/commands/authsession_scaffold.command.d.ts +1 -0
  57. package/dist/commands/intuned-cli/commands/authsession_scaffold.command.js +16 -0
  58. package/dist/commands/intuned-cli/commands/build.command.d.ts +1 -0
  59. package/dist/commands/intuned-cli/commands/build.command.js +12 -0
  60. package/dist/commands/intuned-cli/commands/command.d.ts +2 -0
  61. package/dist/commands/intuned-cli/commands/command.js +9 -0
  62. package/dist/commands/intuned-cli/commands/deploy.command.d.ts +1 -0
  63. package/dist/commands/intuned-cli/commands/deploy.command.js +42 -0
  64. package/dist/commands/intuned-cli/commands/index.d.ts +18 -0
  65. package/dist/commands/intuned-cli/commands/index.js +203 -0
  66. package/dist/commands/intuned-cli/commands/provision.command.d.ts +13 -0
  67. package/dist/commands/intuned-cli/commands/provision.command.js +50 -0
  68. package/dist/commands/intuned-cli/commands/run.command.d.ts +1 -0
  69. package/dist/commands/intuned-cli/commands/run.command.js +8 -0
  70. package/dist/commands/intuned-cli/commands/run_api.command.d.ts +1 -0
  71. package/dist/commands/intuned-cli/commands/run_api.command.js +46 -0
  72. package/dist/commands/intuned-cli/commands/run_authsession.command.d.ts +35 -0
  73. package/dist/commands/intuned-cli/commands/run_authsession.command.js +17 -0
  74. package/dist/commands/intuned-cli/commands/run_authsession_create.command.d.ts +1 -0
  75. package/dist/commands/intuned-cli/commands/run_authsession_create.command.js +35 -0
  76. package/dist/commands/intuned-cli/commands/run_authsession_update.command.d.ts +1 -0
  77. package/dist/commands/intuned-cli/commands/run_authsession_update.command.js +35 -0
  78. package/dist/commands/intuned-cli/commands/run_authsession_validate.command.d.ts +1 -0
  79. package/dist/commands/intuned-cli/commands/run_authsession_validate.command.js +33 -0
  80. package/dist/commands/intuned-cli/commands/types.d.ts +39 -0
  81. package/dist/commands/intuned-cli/commands/types.js +33 -0
  82. package/dist/commands/intuned-cli/constants/index.d.ts +17 -0
  83. package/dist/commands/intuned-cli/constants/index.js +25 -0
  84. package/dist/commands/intuned-cli/controller/__test__/api.test.js +399 -0
  85. package/dist/commands/intuned-cli/controller/__test__/authSession.test.js +1061 -0
  86. package/dist/commands/intuned-cli/controller/api.d.ts +42 -0
  87. package/dist/commands/intuned-cli/controller/api.js +194 -0
  88. package/dist/commands/intuned-cli/controller/authSession.d.ts +209 -0
  89. package/dist/commands/intuned-cli/controller/authSession.js +425 -0
  90. package/dist/commands/intuned-cli/controller/build.d.ts +1 -0
  91. package/dist/commands/intuned-cli/controller/build.js +35 -0
  92. package/dist/commands/intuned-cli/controller/deploy.d.ts +5 -0
  93. package/dist/commands/intuned-cli/controller/deploy.js +317 -0
  94. package/dist/commands/intuned-cli/controller/index.d.ts +1 -0
  95. package/dist/commands/intuned-cli/controller/index.js +45 -0
  96. package/dist/commands/intuned-cli/controller/provision.d.ts +21 -0
  97. package/dist/commands/intuned-cli/controller/provision.js +299 -0
  98. package/dist/commands/intuned-cli/controller/scaffold.d.ts +1 -0
  99. package/dist/commands/intuned-cli/controller/scaffold.js +77 -0
  100. package/dist/commands/intuned-cli/helpers/__test__/browser.test.js +152 -0
  101. package/dist/commands/intuned-cli/helpers/__test__/tracing.test.js +41 -0
  102. package/dist/commands/intuned-cli/helpers/api.d.ts +3 -0
  103. package/dist/commands/intuned-cli/helpers/api.js +16 -0
  104. package/dist/commands/intuned-cli/helpers/auth.d.ts +46 -0
  105. package/dist/commands/intuned-cli/helpers/auth.js +147 -0
  106. package/dist/commands/intuned-cli/helpers/backend.d.ts +8 -0
  107. package/dist/commands/intuned-cli/helpers/backend.js +35 -0
  108. package/dist/commands/intuned-cli/helpers/browser.d.ts +14 -0
  109. package/dist/commands/intuned-cli/helpers/browser.js +93 -0
  110. package/dist/commands/intuned-cli/helpers/context.d.ts +3 -0
  111. package/dist/commands/intuned-cli/helpers/context.js +33 -0
  112. package/dist/commands/intuned-cli/helpers/errors.d.ts +16 -0
  113. package/dist/commands/intuned-cli/helpers/errors.js +44 -0
  114. package/dist/commands/intuned-cli/helpers/index.d.ts +12 -0
  115. package/dist/commands/intuned-cli/helpers/index.js +137 -0
  116. package/dist/commands/intuned-cli/helpers/intunedJson.d.ts +39 -0
  117. package/dist/commands/intuned-cli/helpers/intunedJson.js +20 -0
  118. package/dist/commands/intuned-cli/helpers/prompts.d.ts +3 -0
  119. package/dist/commands/intuned-cli/helpers/prompts.js +71 -0
  120. package/dist/commands/intuned-cli/helpers/proxy.d.ts +5 -0
  121. package/dist/commands/intuned-cli/helpers/proxy.js +23 -0
  122. package/dist/commands/intuned-cli/helpers/terminal.d.ts +5 -0
  123. package/dist/commands/intuned-cli/helpers/terminal.js +13 -0
  124. package/dist/commands/intuned-cli/helpers/timeout.d.ts +1 -0
  125. package/dist/commands/intuned-cli/helpers/timeout.js +23 -0
  126. package/dist/commands/intuned-cli/helpers/traces.d.ts +2 -0
  127. package/dist/commands/intuned-cli/helpers/traces.js +32 -0
  128. package/dist/commands/intuned-cli/helpers/validation.d.ts +2 -0
  129. package/dist/commands/intuned-cli/helpers/validation.js +14 -0
  130. package/dist/commands/intuned-cli/helpers/wrapper.d.ts +2 -0
  131. package/dist/commands/intuned-cli/helpers/wrapper.js +76 -0
  132. package/dist/commands/intuned-cli/index.d.ts +1 -0
  133. package/dist/commands/intuned-cli/index.js +16 -0
  134. package/dist/commands/intuned-cli/main.d.ts +1 -0
  135. package/dist/commands/intuned-cli/main.js +35 -0
  136. package/dist/commands/intuned-cli/types.d.ts +70 -0
  137. package/dist/commands/intuned-cli/types.js +22 -0
  138. package/dist/commands/ts-check.d.ts +2 -0
  139. package/dist/commands/ts-check.js +55 -0
  140. package/dist/common/Logger/Logger/index.d.ts +12 -0
  141. package/dist/common/Logger/Logger/index.js +60 -0
  142. package/dist/common/Logger/Logger/types.d.ts +8 -0
  143. package/dist/common/Logger/Logger/types.js +5 -0
  144. package/dist/common/Logger/index.d.ts +12 -0
  145. package/dist/common/Logger/index.js +60 -0
  146. package/dist/common/Logger/types.d.ts +8 -0
  147. package/dist/common/Logger/types.js +5 -0
  148. package/dist/common/assets/browser_scripts.js +2580 -0
  149. package/dist/common/asyncLocalStorage/index.d.ts +16 -0
  150. package/dist/common/asyncLocalStorage/index.js +17 -0
  151. package/dist/common/backendFunctions/getAuthSessionParameters.d.ts +1 -0
  152. package/dist/common/backendFunctions/getAuthSessionParameters.js +38 -0
  153. package/dist/common/binStartupScript.d.ts +1 -0
  154. package/dist/common/binStartupScript.js +36 -0
  155. package/dist/common/browserTabs.d.ts +72 -0
  156. package/dist/common/browserTabs.js +74 -0
  157. package/dist/common/cleanEnvironmentVariables.d.ts +1 -0
  158. package/dist/common/cleanEnvironmentVariables.js +16 -0
  159. package/dist/common/constants.d.ts +11 -0
  160. package/dist/common/constants.js +17 -0
  161. package/dist/common/contextStorageStateHelpers.d.ts +22 -0
  162. package/dist/common/contextStorageStateHelpers.js +84 -0
  163. package/dist/common/extension/extensionsHelpers.d.ts +11 -0
  164. package/dist/common/extension/extensionsHelpers.js +147 -0
  165. package/dist/common/extension/intunedExtensionServer.d.ts +24 -0
  166. package/dist/common/extension/intunedExtensionServer.js +178 -0
  167. package/dist/common/extension/types.d.ts +219 -0
  168. package/dist/common/extension/types.js +51 -0
  169. package/dist/common/formatZodError.d.ts +2 -0
  170. package/dist/common/formatZodError.js +18 -0
  171. package/dist/common/intunedJson.d.ts +229 -0
  172. package/dist/common/intunedJson.js +132 -0
  173. package/dist/common/jwtTokenManager.d.ts +17 -0
  174. package/dist/common/jwtTokenManager.js +113 -0
  175. package/dist/common/launchBrowser.d.ts +34 -0
  176. package/dist/common/launchBrowser.js +247 -0
  177. package/dist/common/playwrightContext.d.ts +29 -0
  178. package/dist/common/playwrightContext.js +148 -0
  179. package/dist/common/runApi/importUsingImportFunction.d.ts +7 -0
  180. package/dist/common/runApi/importUsingImportFunction.js +46 -0
  181. package/dist/common/runApi/index.d.ts +8 -0
  182. package/dist/common/runApi/index.js +178 -0
  183. package/dist/common/settingsSchema.d.ts +537 -0
  184. package/dist/common/settingsSchema.js +57 -0
  185. package/dist/common/setupContextHook.d.ts +16 -0
  186. package/dist/common/setupContextHook.js +22 -0
  187. package/dist/common/telemetry.d.ts +3 -0
  188. package/dist/common/telemetry.js +31 -0
  189. package/dist/index.d.ts +4 -0
  190. package/dist/index.js +117 -0
  191. package/dist/runtime/RunError.d.ts +5 -0
  192. package/dist/runtime/RunError.js +19 -0
  193. package/dist/runtime/attemptStore.d.ts +2 -0
  194. package/dist/runtime/attemptStore.js +23 -0
  195. package/dist/runtime/captcha.d.ts +15 -0
  196. package/dist/runtime/captcha.js +191 -0
  197. package/dist/runtime/captcha.test.js +821 -0
  198. package/dist/runtime/downloadDirectory.d.ts +1 -0
  199. package/dist/runtime/downloadDirectory.js +19 -0
  200. package/dist/runtime/enums.d.js +5 -0
  201. package/dist/runtime/enums.d.ts +11 -0
  202. package/dist/runtime/enums.js +18 -0
  203. package/dist/runtime/executionHelpers.test.js +52 -0
  204. package/dist/runtime/export.d.js +5 -0
  205. package/dist/runtime/export.d.ts +284 -0
  206. package/dist/runtime/extendPayload.d.ts +2 -0
  207. package/dist/runtime/extendPayload.js +21 -0
  208. package/dist/runtime/extendTimeout.d.ts +1 -0
  209. package/dist/runtime/extendTimeout.js +23 -0
  210. package/dist/runtime/getAiGatewayConfig.d.ts +10 -0
  211. package/dist/runtime/getAiGatewayConfig.js +16 -0
  212. package/dist/runtime/getAuthSessionParameters.d.ts +1 -0
  213. package/dist/runtime/getAuthSessionParameters.js +20 -0
  214. package/dist/runtime/index.d.ts +10 -0
  215. package/dist/runtime/index.js +111 -0
  216. package/dist/runtime/persistentStore.d.ts +2 -0
  217. package/dist/runtime/persistentStore.js +37 -0
  218. package/dist/runtime/persistentStore.test.js +101 -0
  219. package/dist/runtime/runInfo.d.ts +2 -0
  220. package/dist/runtime/runInfo.js +21 -0
  221. package/dist/vendor/runtime-interface.d.ts +1 -0
  222. package/dist/vendor/runtime-interface.js +479 -0
  223. package/package.json +2 -2
  224. package/tsup.config.ts +1 -0
  225. package/WebTemplate.zip +0 -0
@@ -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
+ }
@@ -0,0 +1,17 @@
1
+ import fetch from "cross-fetch";
2
+ declare class JwtTokenManager {
3
+ private _token;
4
+ private tokenRefreshTimeout;
5
+ private refreshTokenPath;
6
+ constructor(refreshTokenPath: string);
7
+ get token(): string | undefined;
8
+ set token(newToken: string | undefined);
9
+ private get timeToRefresh();
10
+ private scheduleTokenRefresh;
11
+ private refreshToken;
12
+ fetchWithToken(...[input, init]: Parameters<typeof fetch>): Promise<Response>;
13
+ get backendFunctionsBaseUrl(): string | undefined;
14
+ }
15
+ export declare const backendFunctionsTokenManager: JwtTokenManager;
16
+ export declare function callBackendFunctionWithToken(path: string, init?: Parameters<typeof fetch>[1]): Promise<Response>;
17
+ export {};
@@ -0,0 +1,113 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
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 {
15
+ constructor(refreshTokenPath) {
16
+ this.refreshTokenPath = refreshTokenPath;
17
+ this._token = undefined;
18
+ }
19
+ get token() {
20
+ return this._token;
21
+ }
22
+ set token(newToken) {
23
+ if (this._token != newToken) {
24
+ this._token = newToken;
25
+ void this.scheduleTokenRefresh();
26
+ }
27
+ }
28
+ get timeToRefresh() {
29
+ if (!this._token) return;
30
+ const payload = jwt.decode(this._token);
31
+ if (!payload || typeof payload == "string") return;
32
+ const expiry = payload.expiry;
33
+ if (!expiry || typeof expiry !== "number") return;
34
+ const timeWindow = 60 * 1000;
35
+ const timeToRefresh = expiry - Date.now() - timeWindow;
36
+ return Math.max(timeToRefresh, timeWindow);
37
+ }
38
+ async scheduleTokenRefresh() {
39
+ if (process.env.RUN_ENVIRONMENT?.toLowerCase() !== "authoring") return;
40
+ const timeToRefresh = this.timeToRefresh;
41
+ if (timeToRefresh === undefined) return;
42
+ if (this.tokenRefreshTimeout) clearTimeout(this.tokenRefreshTimeout);
43
+ this.tokenRefreshTimeout = setTimeout(async () => {
44
+ const result = await this.refreshToken();
45
+ if (result && result.isErr()) {
46
+ console.error(`[Internal Error] ${result.error}`);
47
+ return;
48
+ }
49
+ await this.scheduleTokenRefresh();
50
+ }, timeToRefresh);
51
+ }
52
+ async refreshToken() {
53
+ if (process.env.RUN_ENVIRONMENT?.toLowerCase() !== "authoring") return;
54
+ const res = await this.fetchWithToken(`${this.backendFunctionsBaseUrl}/${this.refreshTokenPath}`, {
55
+ method: "GET"
56
+ });
57
+ if (res.status === 401) {
58
+ return (0, _neverthrow.err)("Unauthorized");
59
+ }
60
+ const jsonResult = await _neverthrow.ResultAsync.fromPromise(res.json(), () => "not json");
61
+ if (jsonResult.isErr()) return;
62
+ const newToken = jsonResult.value.token;
63
+ if (newToken) this._token = newToken;
64
+ }
65
+ async fetchWithToken(...[input, init]) {
66
+ const headers = new Headers(init?.headers);
67
+ const apiKey = process.env[_constants.API_KEY_ENV_VAR_KEY];
68
+ if (apiKey) {
69
+ headers.set(_constants.API_KEY_HEADER_NAME, apiKey);
70
+ }
71
+ const token = process.env[_constants.AUTH_TOKEN_ENV_VAR_KEY];
72
+ if (token) {
73
+ headers.set("Authorization", `Bearer ${token}`);
74
+ }
75
+ if (this.token !== undefined) {
76
+ headers.set("Authorization", `Bearer ${this.token}`);
77
+ }
78
+ const result = await (0, _crossFetch.default)(input, {
79
+ ...init,
80
+ headers
81
+ });
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.");
84
+ }
85
+ return result;
86
+ }
87
+ get backendFunctionsBaseUrl() {
88
+ try {
89
+ if (!process.env.FUNCTIONS_DOMAIN) {
90
+ throw new Error(`Cannot call backend function - FUNCTIONS_DOMAIN not set`);
91
+ }
92
+ const domain = process.env.FUNCTIONS_DOMAIN;
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`);
95
+ }
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`);
99
+ }
100
+ const projectId = process.env.INTUNED_INTEGRATION_ID ?? process.env[_constants.PROJECT_ID_ENV_VAR_KEY];
101
+ return `${domain}/api/${workspaceId}/functions/${projectId}`;
102
+ } catch (e) {
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}`);
105
+ }
106
+ }
107
+ }
108
+ }
109
+ const backendFunctionsTokenManager = exports.backendFunctionsTokenManager = new JwtTokenManager(`refreshBackendFunctionsToken`);
110
+ backendFunctionsTokenManager.token = process.env.INTUNED_AUTHORING_SESSION_BACKEND_FUNCTIONS_TOKEN;
111
+ function callBackendFunctionWithToken(path, init) {
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>;