@intuned/runtime-dev 1.3.14-ts-runtime-helpers → 1.3.15-hook.0

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 (32) hide show
  1. package/WebTemplate.zip +0 -0
  2. package/dist/commands/intuned-cli/commands/run_authsession.command.d.ts +6 -6
  3. package/dist/commands/intuned-cli/commands/types.d.ts +2 -2
  4. package/dist/commands/intuned-cli/controller/authSession.d.ts +6 -6
  5. package/dist/commands/intuned-cli/helpers/auth.d.ts +1 -1
  6. package/dist/commands/intuned-cli/helpers/intunedJson.d.ts +1 -1
  7. package/dist/common/constants.d.ts +0 -2
  8. package/dist/common/constants.js +2 -4
  9. package/dist/common/{extension/extensionsHelpers.d.ts → extensionsHelpers.d.ts} +1 -1
  10. package/dist/common/{extension/extensionsHelpers.js → extensionsHelpers.js} +6 -62
  11. package/dist/common/intunedJson.d.ts +6 -6
  12. package/dist/common/launchBrowser.js +1 -3
  13. package/dist/common/playwrightContext.js +1 -1
  14. package/dist/common/runApi/index.js +0 -6
  15. package/dist/common/runApi/types.d.ts +20 -20
  16. package/dist/common/settingsSchema.d.ts +1 -15
  17. package/dist/common/settingsSchema.js +0 -1
  18. package/dist/common/setupContextHook.d.ts +2 -2
  19. package/dist/index.d.ts +0 -1
  20. package/dist/index.js +1 -44
  21. package/dist/runtime/getAiGatewayConfig.d.ts +10 -0
  22. package/dist/runtime/getAiGatewayConfig.js +16 -0
  23. package/dist/runtime/index.d.ts +1 -1
  24. package/dist/runtime/index.js +7 -43
  25. package/package.json +1 -2
  26. package/dist/common/extension/intunedExtensionServer.d.ts +0 -25
  27. package/dist/common/extension/intunedExtensionServer.js +0 -164
  28. package/dist/common/extension/types.d.ts +0 -21
  29. package/dist/common/extension/types.js +0 -5
  30. package/dist/runtime/captcha.d.ts +0 -18
  31. package/dist/runtime/captcha.js +0 -190
  32. package/dist/runtime/captcha.test.js +0 -214
@@ -1,214 +0,0 @@
1
- "use strict";
2
-
3
- var _vitest = require("vitest");
4
- var _captcha = require("./captcha");
5
- _vitest.vi.mock("fastify", () => {
6
- const fastify = () => ({
7
- post: _vitest.vi.fn(),
8
- setNotFoundHandler: _vitest.vi.fn(),
9
- listen: _vitest.vi.fn(async () => undefined),
10
- close: _vitest.vi.fn(async () => undefined)
11
- });
12
- return {
13
- default: fastify
14
- };
15
- });
16
- class FakeExtensionServer {
17
- captchas = new Map();
18
- subscribers = new Set();
19
- subscribeCalls = 0;
20
- unsubscribeCalls = 0;
21
- seed(captchas) {
22
- this.captchas.clear();
23
- for (const c of captchas) this.captchas.set(c.id, c);
24
- }
25
- async upsertCaptcha(captcha) {
26
- this.captchas.set(captcha.id, captcha);
27
- for (const h of this.subscribers) {
28
- await h(captcha);
29
- }
30
- }
31
- async getCaptchas(_page, status) {
32
- const list = [...this.captchas.values()];
33
- return status ? list.filter(c => c.status === status) : list;
34
- }
35
- async subscribe(_page, handler) {
36
- this.subscribeCalls += 1;
37
- this.subscribers.add(handler);
38
- }
39
- async unsubscribe(_page, handler) {
40
- this.unsubscribeCalls += 1;
41
- this.subscribers.delete(handler);
42
- }
43
- }
44
- let server;
45
- _vitest.vi.mock("../common/extension/intunedExtensionServer", () => {
46
- return {
47
- getIntunedExtensionServer: () => server
48
- };
49
- });
50
- function makeMockPage() {
51
- return {
52
- waitForLoadState: _vitest.vi.fn().mockResolvedValue(undefined)
53
- };
54
- }
55
- (0, _vitest.beforeEach)(() => {
56
- _vitest.vi.useFakeTimers();
57
- server = new FakeExtensionServer();
58
- });
59
- (0, _vitest.afterEach)(() => {
60
- _vitest.vi.useRealTimers();
61
- _vitest.vi.restoreAllMocks();
62
- });
63
- (0, _vitest.describe)("runtime/captcha", () => {
64
- (0, _vitest.it)("waitForCaptchaSolve: resolves after settle period when no captchas are present", async () => {
65
- const page = makeMockPage();
66
- const p = (0, _captcha.waitForCaptchaSolve)(page, {
67
- timeoutInMs: 1000,
68
- settlePeriodInMs: 10
69
- });
70
- await _vitest.vi.advanceTimersByTimeAsync(10);
71
- await p;
72
- (0, _vitest.expect)(page.waitForLoadState).not.toHaveBeenCalled();
73
- (0, _vitest.expect)(server.subscribeCalls).toBe(1);
74
- (0, _vitest.expect)(server.unsubscribeCalls).toBe(1);
75
- });
76
- (0, _vitest.it)("withWaitForCaptchaSolve: preserves return value and waits for networkidle by default", async () => {
77
- const page = makeMockPage();
78
- const p = (0, _captcha.withWaitForCaptchaSolve)(async () => "ok", {
79
- page,
80
- timeoutInMs: 1000,
81
- settleDurationMs: 10
82
- });
83
- await _vitest.vi.advanceTimersByTimeAsync(10);
84
- await (0, _vitest.expect)(p).resolves.toBe("ok");
85
- (0, _vitest.expect)(page.waitForLoadState).toHaveBeenCalledWith("networkidle");
86
- });
87
- (0, _vitest.it)("withWaitForCaptchaSolve: skips networkidle when disabled", async () => {
88
- const page = makeMockPage();
89
- const p = (0, _captcha.withWaitForCaptchaSolve)(async () => "ok", {
90
- page,
91
- timeoutInMs: 1000,
92
- settleDurationMs: 10,
93
- waitForNetworkSettled: false
94
- });
95
- await _vitest.vi.advanceTimersByTimeAsync(10);
96
- await (0, _vitest.expect)(p).resolves.toBe("ok");
97
- (0, _vitest.expect)(page.waitForLoadState).not.toHaveBeenCalled();
98
- });
99
- (0, _vitest.it)("waitForCaptchaSolve: completes when a solving captcha becomes solved", async () => {
100
- const page = makeMockPage();
101
- server.seed([{
102
- id: "c1",
103
- tabId: 0,
104
- type: "recaptcha",
105
- status: "solving",
106
- retryCount: 0
107
- }]);
108
- const p = (0, _captcha.waitForCaptchaSolve)(page, {
109
- timeoutInMs: 1000,
110
- settlePeriodInMs: 10
111
- });
112
- await Promise.resolve();
113
- await server.upsertCaptcha({
114
- id: "c1",
115
- tabId: 0,
116
- type: "recaptcha",
117
- status: "solved",
118
- retryCount: 0
119
- });
120
- await _vitest.vi.advanceTimersByTimeAsync(10);
121
- await (0, _vitest.expect)(p).resolves.toBeUndefined();
122
- });
123
- (0, _vitest.it)("waitForCaptchaSolve: throws on captcha error", async () => {
124
- const page = makeMockPage();
125
- server.seed([{
126
- id: "c1",
127
- tabId: 0,
128
- type: "recaptcha",
129
- status: "solving",
130
- retryCount: 0
131
- }]);
132
- const p = (0, _captcha.waitForCaptchaSolve)(page, {
133
- timeoutInMs: 1000,
134
- settlePeriodInMs: 10
135
- });
136
- const assertion = (0, _vitest.expect)(p).rejects.toThrow("CAPTCHA Solve Error: UNEXPECTED_ERROR");
137
- await Promise.resolve();
138
- await server.upsertCaptcha({
139
- id: "c1",
140
- tabId: 0,
141
- type: "recaptcha",
142
- status: "error",
143
- retryCount: 0,
144
- error: {
145
- code: "UNEXPECTED_ERROR"
146
- }
147
- });
148
- await _vitest.vi.advanceTimersByTimeAsync(10);
149
- await assertion;
150
- (0, _vitest.expect)(server.unsubscribeCalls).toBe(1);
151
- });
152
- (0, _vitest.it)("waitForCaptchaSolve: times out if captchas are still pending", async () => {
153
- const page = makeMockPage();
154
- server.seed([{
155
- id: "c1",
156
- tabId: 0,
157
- type: "recaptcha",
158
- status: "solving",
159
- retryCount: 0
160
- }]);
161
- const p = (0, _captcha.waitForCaptchaSolve)(page, {
162
- timeoutInMs: 5,
163
- settlePeriodInMs: 1
164
- });
165
- const assertion = (0, _vitest.expect)(p).rejects.toThrow("CAPTCHA Solve timed out with pending captchas.");
166
- await Promise.resolve();
167
- await _vitest.vi.advanceTimersByTimeAsync(6);
168
- await _vitest.vi.advanceTimersByTimeAsync(1);
169
- await assertion;
170
- (0, _vitest.expect)(server.unsubscribeCalls).toBe(1);
171
- });
172
- (0, _vitest.it)("waitForCaptchaSolve: waits for all captchas to resolve", async () => {
173
- const page = makeMockPage();
174
- server.seed([{
175
- id: "c1",
176
- tabId: 0,
177
- type: "recaptcha",
178
- status: "solving",
179
- retryCount: 0
180
- }, {
181
- id: "c2",
182
- tabId: 0,
183
- type: "hcaptcha",
184
- status: "solving",
185
- retryCount: 0
186
- }]);
187
- const p = (0, _captcha.waitForCaptchaSolve)(page, {
188
- timeoutInMs: 1000,
189
- settlePeriodInMs: 10
190
- });
191
- await Promise.resolve();
192
- await server.upsertCaptcha({
193
- id: "c1",
194
- tabId: 0,
195
- type: "recaptcha",
196
- status: "solved",
197
- retryCount: 0
198
- });
199
- await _vitest.vi.advanceTimersByTimeAsync(10);
200
- let settled = false;
201
- p.then(() => settled = true).catch(() => settled = true);
202
- await Promise.resolve();
203
- (0, _vitest.expect)(settled).toBe(false);
204
- await server.upsertCaptcha({
205
- id: "c2",
206
- tabId: 0,
207
- type: "hcaptcha",
208
- status: "detached",
209
- retryCount: 0
210
- });
211
- await _vitest.vi.advanceTimersByTimeAsync(10);
212
- await (0, _vitest.expect)(p).resolves.toBeUndefined();
213
- });
214
- });