@revoengine/cli 1.0.39 → 2.0.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.
- package/CHANGELOG.md +14 -0
- package/README.md +7 -3
- package/dist/src/argument-contract.js +1 -1
- package/dist/src/automation-contract.generated.d.ts +6 -30
- package/dist/src/automation-contract.generated.js +6 -30
- package/dist/src/commands/component.js +16 -0
- package/dist/src/commands/terminal-browser-human-input.d.ts +28 -0
- package/dist/src/commands/terminal-browser-human-input.js +56 -7
- package/dist/src/commands/terminal-browser-live-protocol.d.ts +9 -1
- package/dist/src/commands/terminal-browser-live-protocol.js +16 -3
- package/dist/src/commands/terminal-browser-live-transport.d.ts +2 -0
- package/dist/src/commands/terminal-browser-live-transport.js +21 -5
- package/dist/src/commands/terminal-browser-live.d.ts +18 -1
- package/dist/src/commands/terminal-browser-live.js +190 -14
- package/dist/src/commands/terminal-browser-observation.d.ts +1 -1
- package/dist/src/commands/terminal-browser-observation.js +10 -1
- package/dist/src/commands/terminal-browser-page-input.d.ts +1 -0
- package/dist/src/commands/terminal-browser-page-input.js +20 -0
- package/dist/src/commands/terminal-browser-profile-sync.d.ts +5 -1
- package/dist/src/commands/terminal-browser-profile-sync.js +13 -2
- package/dist/src/commands/terminal-browser-profile-sync.protocol.d.ts +2 -0
- package/dist/src/commands/terminal-browser.d.ts +17 -0
- package/dist/src/commands/terminal-browser.js +310 -104
- package/dist/src/commands/terminal.js +104 -24
- package/dist/src/endpoint-emulator.js +9 -10
- package/dist/src/project.js +1 -0
- package/dist/src/request-contract.d.ts +2 -0
- package/dist/src/request-contract.js +11 -1
- package/dist/src/types.d.ts +0 -3
- package/dist/src/ui.js +1 -1
- package/package.json +1 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { randomUUID } from 'node:crypto';
|
|
4
|
-
import { applyPageInteraction, pageHasSecretFocus, releasePageInput } from "./terminal-browser-page-input.js";
|
|
5
|
-
import { decryptBrowserHumanInput } from "./terminal-browser-human-input.js";
|
|
4
|
+
import { applyPageInteraction, pageHasSecretFocus, readPageSelection, releasePageInput } from "./terminal-browser-page-input.js";
|
|
5
|
+
import { decryptBrowserHumanInput, decryptBrowserPointer, decryptClipboardRequest, encryptBrowserSelection } from "./terminal-browser-human-input.js";
|
|
6
6
|
import { BROWSER_LIVE_MAX_FRAME_BYTES, validBrowserLiveControl, safeBrowserLiveState } from "./terminal-browser-live-protocol.js";
|
|
7
7
|
/** Reads SOF JPEG dimensions without decoding or allocating an image. */
|
|
8
8
|
export function jpegDimensions(jpeg) {
|
|
@@ -33,6 +33,9 @@ export function browserAuthPage(value) {
|
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
export class BrowserLiveHandle {
|
|
36
|
+
pointer;
|
|
37
|
+
pointerExpiry;
|
|
38
|
+
pointerStarts = new Map();
|
|
36
39
|
baseOptions;
|
|
37
40
|
viewerOptions;
|
|
38
41
|
get options() { return this.viewerOptions ?? this.baseOptions; }
|
|
@@ -494,6 +497,137 @@ export class BrowserLiveHandle {
|
|
|
494
497
|
}
|
|
495
498
|
throw new Error('browser_observation_stale');
|
|
496
499
|
}
|
|
500
|
+
async stopPointer(commit = false) {
|
|
501
|
+
if (this.pointerExpiry)
|
|
502
|
+
clearTimeout(this.pointerExpiry);
|
|
503
|
+
this.pointerExpiry = undefined;
|
|
504
|
+
const pointer = this.pointer;
|
|
505
|
+
this.pointer = undefined;
|
|
506
|
+
if (pointer) {
|
|
507
|
+
pointer.page.off('framenavigated', pointer.navigation);
|
|
508
|
+
if (!commit)
|
|
509
|
+
await pointer.page.mouse.move(-1, -1).catch(() => undefined);
|
|
510
|
+
await pointer.page.mouse.up({ button: pointer.button }).catch(() => undefined);
|
|
511
|
+
for (const key of pointer.modifiers)
|
|
512
|
+
await pointer.page.keyboard.up(key).catch(() => undefined);
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
async pointerInput(frame) {
|
|
516
|
+
const options = this.options;
|
|
517
|
+
this.assertAuthorized(options);
|
|
518
|
+
if (frame.action === 'pointer' && frame.liveSessionId === options.liveSessionId && frame.controlEpoch === this.controlEpoch
|
|
519
|
+
&& Number.isSafeInteger(frame.privateInput?.expiresAt) && frame.privateInput.expiresAt <= Date.now()) {
|
|
520
|
+
await this.stopPointer();
|
|
521
|
+
return;
|
|
522
|
+
}
|
|
523
|
+
if (!validBrowserLiveControl(frame) || frame.action !== 'pointer' || frame.liveSessionId !== options.liveSessionId
|
|
524
|
+
|| this.sessionOwned && (!this.viewerOptions || !this.viewerOptions.isAuthorized()))
|
|
525
|
+
throw new Error('browser_live_scope_invalid');
|
|
526
|
+
if (frame.controlEpoch !== this.controlEpoch || this.mode !== 'human' || !this.private)
|
|
527
|
+
return;
|
|
528
|
+
const input = decryptBrowserPointer(frame, options, options.identity);
|
|
529
|
+
await this.port.queue(async () => {
|
|
530
|
+
this.assertAuthorized(options);
|
|
531
|
+
if (frame.controlEpoch !== this.controlEpoch || this.mode !== 'human' || !this.private)
|
|
532
|
+
return;
|
|
533
|
+
const { page, tabId } = this.port.active();
|
|
534
|
+
const viewport = page.viewportSize();
|
|
535
|
+
try {
|
|
536
|
+
if (input.phase === 'down') {
|
|
537
|
+
for (const [id, expiresAt] of this.pointerStarts)
|
|
538
|
+
if (expiresAt <= Date.now())
|
|
539
|
+
this.pointerStarts.delete(id);
|
|
540
|
+
if (this.pointerStarts.has(input.gestureId) || this.pointerStarts.size >= 64)
|
|
541
|
+
return;
|
|
542
|
+
this.pointerStarts.set(input.gestureId, frame.privateInput.expiresAt);
|
|
543
|
+
await this.stopPointer();
|
|
544
|
+
this.port.observations.require(input.observationId, page, tabId, true);
|
|
545
|
+
if (!viewport || input.x >= viewport.width || input.y >= viewport.height)
|
|
546
|
+
return;
|
|
547
|
+
const pointer = { id: input.gestureId, page, tabId, url: page.url(), width: viewport.width, height: viewport.height,
|
|
548
|
+
navigation: () => { void this.stopPointer(); },
|
|
549
|
+
epoch: frame.controlEpoch, sequence: 0, button: input.button, modifiers: input.modifiers ?? [] };
|
|
550
|
+
this.pointer = pointer;
|
|
551
|
+
page.on('framenavigated', pointer.navigation);
|
|
552
|
+
for (const key of pointer.modifiers)
|
|
553
|
+
await page.keyboard.down(key);
|
|
554
|
+
await page.mouse.move(input.x, input.y);
|
|
555
|
+
this.assertAuthorized(options);
|
|
556
|
+
if (this.pointer !== pointer || this.controlEpoch !== pointer.epoch || this.mode !== 'human') {
|
|
557
|
+
await releasePageInput(page);
|
|
558
|
+
return;
|
|
559
|
+
}
|
|
560
|
+
await page.mouse.down({ button: pointer.button });
|
|
561
|
+
if (this.pointer !== pointer || this.controlEpoch !== pointer.epoch || this.mode !== 'human') {
|
|
562
|
+
await releasePageInput(page);
|
|
563
|
+
return;
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
else {
|
|
567
|
+
const pointer = this.pointer;
|
|
568
|
+
if (!pointer || pointer.id !== input.gestureId || input.sequence <= pointer.sequence)
|
|
569
|
+
return;
|
|
570
|
+
if (input.phase === 'cancel' || pointer.page !== page || pointer.tabId !== tabId || pointer.url !== page.url()
|
|
571
|
+
|| viewport?.width !== pointer.width || viewport?.height !== pointer.height
|
|
572
|
+
|| input.x >= viewport.width || input.y >= viewport.height) {
|
|
573
|
+
await this.stopPointer();
|
|
574
|
+
return;
|
|
575
|
+
}
|
|
576
|
+
pointer.sequence = input.sequence;
|
|
577
|
+
await page.mouse.move(input.x, input.y);
|
|
578
|
+
if (input.phase === 'up') {
|
|
579
|
+
await this.stopPointer(true);
|
|
580
|
+
return;
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
if (this.pointer) {
|
|
584
|
+
if (this.pointerExpiry)
|
|
585
|
+
clearTimeout(this.pointerExpiry);
|
|
586
|
+
this.pointerExpiry = setTimeout(() => { void this.stopPointer(); }, 10_000);
|
|
587
|
+
this.pointerExpiry.unref();
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
catch (error) {
|
|
591
|
+
await this.stopPointer();
|
|
592
|
+
if (!(error instanceof Error && error.message === 'browser_observation_stale'))
|
|
593
|
+
throw error;
|
|
594
|
+
}
|
|
595
|
+
}, true);
|
|
596
|
+
}
|
|
597
|
+
async copySelection(frame) {
|
|
598
|
+
const options = this.options;
|
|
599
|
+
this.assertAuthorized(options);
|
|
600
|
+
if (!validBrowserLiveControl(frame) || frame.action !== 'copy_selection' || frame.liveSessionId !== options.liveSessionId
|
|
601
|
+
|| this.sessionOwned && (!this.viewerOptions || !this.viewerOptions.isAuthorized()))
|
|
602
|
+
throw new Error('browser_live_scope_invalid');
|
|
603
|
+
if (frame.controlEpoch !== this.controlEpoch || this.mode !== 'human' || !this.private)
|
|
604
|
+
return undefined;
|
|
605
|
+
const request = decryptClipboardRequest(frame, options, options.identity);
|
|
606
|
+
try {
|
|
607
|
+
return await this.port.queue(async () => {
|
|
608
|
+
this.assertAuthorized(options);
|
|
609
|
+
if (this.mode !== 'human' || this.controlEpoch !== frame.controlEpoch || !this.private)
|
|
610
|
+
return undefined;
|
|
611
|
+
const { page, tabId } = this.port.active();
|
|
612
|
+
try {
|
|
613
|
+
this.port.observations.require(request.observationId, page, tabId, true);
|
|
614
|
+
}
|
|
615
|
+
catch {
|
|
616
|
+
return undefined;
|
|
617
|
+
}
|
|
618
|
+
const url = page.url();
|
|
619
|
+
const selected = await readPageSelection(page);
|
|
620
|
+
this.assertAuthorized(options);
|
|
621
|
+
if (!selected || this.mode !== 'human' || this.controlEpoch !== frame.controlEpoch
|
|
622
|
+
|| this.port.active().page !== page || page.url() !== url)
|
|
623
|
+
return undefined;
|
|
624
|
+
return encryptBrowserSelection(frame, request.key, selected);
|
|
625
|
+
}, true);
|
|
626
|
+
}
|
|
627
|
+
finally {
|
|
628
|
+
request.key.fill(0);
|
|
629
|
+
}
|
|
630
|
+
}
|
|
497
631
|
async control(frame) {
|
|
498
632
|
const options = this.options;
|
|
499
633
|
let humanProfileTransition = false;
|
|
@@ -513,14 +647,16 @@ export class BrowserLiveHandle {
|
|
|
513
647
|
if (this.requests.size >= 4096)
|
|
514
648
|
throw new Error('browser_live_reconnect_required');
|
|
515
649
|
this.requests.set(frame.requestId, Date.now());
|
|
516
|
-
const transition = ['takeover', 'release', 'profile', 'select_tab'].includes(frame.action)
|
|
650
|
+
const transition = ['takeover', 'release', 'profile', 'select_tab', 'new_tab', 'close_tab', 'close_session'].includes(frame.action)
|
|
517
651
|
|| frame.action === 'stop' && this.mode !== 'observe';
|
|
518
652
|
if (transition ? frame.controlEpoch !== this.controlEpoch + 1
|
|
519
653
|
: frame.action === 'start' ? frame.controlEpoch > this.controlEpoch : frame.controlEpoch !== this.controlEpoch)
|
|
520
654
|
throw new Error('browser_live_epoch_stale');
|
|
521
655
|
const priorMode = this.mode;
|
|
656
|
+
if (this.port.control.tabId && ['profile', 'select_tab', 'new_tab', 'close_tab', 'close_session'].includes(frame.action))
|
|
657
|
+
throw new Error('browser_live_tab_scope_required');
|
|
522
658
|
humanProfileTransition = frame.action === 'profile' && priorMode === 'human';
|
|
523
|
-
if (['input', 'profile', 'select_tab', 'settings', 'navigate'].includes(frame.action) && priorMode !== 'human'
|
|
659
|
+
if (['input', 'profile', 'select_tab', 'new_tab', 'close_tab', 'settings', 'navigate'].includes(frame.action) && priorMode !== 'human'
|
|
524
660
|
|| frame.action === 'recording' && priorMode === 'blocked' && frame.recording?.mode !== 'off')
|
|
525
661
|
throw new Error('browser_live_human_owner_required');
|
|
526
662
|
if (frame.action === 'recording_save') {
|
|
@@ -531,27 +667,35 @@ export class BrowserLiveHandle {
|
|
|
531
667
|
if (transition) {
|
|
532
668
|
this.port.control.epoch = frame.controlEpoch;
|
|
533
669
|
this.port.control.mode = 'blocked';
|
|
670
|
+
if (frame.action === 'takeover')
|
|
671
|
+
this.port.control.tabId = frame.tabId;
|
|
534
672
|
this.port.observations.invalidate();
|
|
535
673
|
}
|
|
536
674
|
return await this.port.queue(async () => {
|
|
537
675
|
this.assertAuthorized(options);
|
|
538
676
|
if (frame.action !== 'start' && frame.controlEpoch !== this.controlEpoch)
|
|
539
677
|
throw new Error('browser_live_epoch_stale');
|
|
678
|
+
if (this.pointer)
|
|
679
|
+
await this.stopPointer();
|
|
540
680
|
if (frame.action === 'takeover') {
|
|
681
|
+
if (frame.tabId && this.port.active().tabId !== frame.tabId)
|
|
682
|
+
throw new Error('browser_tab_missing');
|
|
541
683
|
this.port.control.private = frame.private !== false;
|
|
542
684
|
if (this.private)
|
|
543
685
|
await this.stopCapture();
|
|
544
|
-
for (const page of this.
|
|
686
|
+
for (const page of this.controlledPages())
|
|
545
687
|
await releasePageInput(page);
|
|
546
688
|
this.assertAuthorized(options);
|
|
547
689
|
this.port.control.mode = 'human';
|
|
548
690
|
}
|
|
549
691
|
else if (frame.action === 'release') {
|
|
550
|
-
|
|
692
|
+
if (this.private)
|
|
693
|
+
await this.stopCapture();
|
|
551
694
|
this.assertAuthorized(options);
|
|
552
695
|
await this.port.release();
|
|
553
696
|
this.assertAuthorized(options);
|
|
554
697
|
this.port.control.private = false;
|
|
698
|
+
this.port.control.mode = 'observe';
|
|
555
699
|
}
|
|
556
700
|
else if (frame.action === 'input') {
|
|
557
701
|
const interaction = decryptBrowserHumanInput(frame, options, options.identity);
|
|
@@ -580,6 +724,20 @@ export class BrowserLiveHandle {
|
|
|
580
724
|
this.assertAuthorized(options);
|
|
581
725
|
this.port.control.mode = 'human';
|
|
582
726
|
}
|
|
727
|
+
else if (frame.action === 'new_tab' || frame.action === 'close_tab' || frame.action === 'close_session') {
|
|
728
|
+
await this.stopCapture();
|
|
729
|
+
this.assertAuthorized(options);
|
|
730
|
+
if (frame.action === 'close_session') {
|
|
731
|
+
await this.port.closeSession();
|
|
732
|
+
return { ...ack(true), closed: true };
|
|
733
|
+
}
|
|
734
|
+
if (frame.action === 'close_tab' && await this.port.closeTab(frame.tabId))
|
|
735
|
+
return { ...ack(true), closed: true };
|
|
736
|
+
if (frame.action === 'new_tab')
|
|
737
|
+
await this.port.newTab();
|
|
738
|
+
this.assertAuthorized(options);
|
|
739
|
+
this.port.control.mode = 'human';
|
|
740
|
+
}
|
|
583
741
|
else if (frame.action === 'settings') {
|
|
584
742
|
await this.stopCapture();
|
|
585
743
|
this.assertAuthorized(options);
|
|
@@ -656,18 +814,25 @@ export class BrowserLiveHandle {
|
|
|
656
814
|
await this.refreshFrame();
|
|
657
815
|
const state = await this.state();
|
|
658
816
|
this.assertAuthorized(options);
|
|
659
|
-
if (frame.action === 'release')
|
|
660
|
-
this.port.control.
|
|
661
|
-
|
|
662
|
-
await this.sync();
|
|
663
|
-
}
|
|
664
|
-
return ack(true, undefined, frame.action === 'release' ? await this.state() : state);
|
|
817
|
+
if (frame.action === 'release')
|
|
818
|
+
this.port.control.tabId = undefined;
|
|
819
|
+
return ack(true, undefined, state);
|
|
665
820
|
});
|
|
666
821
|
}
|
|
667
822
|
catch (error) {
|
|
668
823
|
const message = error instanceof Error && /^browser_[a-z_]+$/u.test(error.message) ? error.message : 'browser_live_control_failed';
|
|
669
824
|
// Geometry may change during native smooth scrolling. This rejected action had no
|
|
670
825
|
// side effects: refresh its observation without ending the user's control or replaying it.
|
|
826
|
+
if ((frame.action === 'new_tab' || frame.action === 'close_tab') && ['browser_tab_limit', 'browser_tab_missing'].includes(message)) {
|
|
827
|
+
try {
|
|
828
|
+
this.assertAuthorized(options);
|
|
829
|
+
this.port.control.mode = 'human';
|
|
830
|
+
await this.sync();
|
|
831
|
+
await this.refreshFrame(this.controlEpoch);
|
|
832
|
+
return ack(false, message, await this.state());
|
|
833
|
+
}
|
|
834
|
+
catch { /* Keep ordinary authorization failures fenced. */ }
|
|
835
|
+
}
|
|
671
836
|
if (frame.action === 'recording' && ['browser_recording_private', 'browser_recording_network_required'].includes(message)) {
|
|
672
837
|
try {
|
|
673
838
|
this.assertAuthorized(options);
|
|
@@ -733,10 +898,21 @@ export class BrowserLiveHandle {
|
|
|
733
898
|
this.port.control.mode = 'blocked';
|
|
734
899
|
this.port.control.private = true;
|
|
735
900
|
this.port.observations.invalidate();
|
|
901
|
+
void this.stopPointer();
|
|
736
902
|
void this.stopCapture().catch(() => undefined);
|
|
737
|
-
for (const page of this.
|
|
903
|
+
for (const page of this.controlledPages())
|
|
738
904
|
void releasePageInput(page);
|
|
739
905
|
}
|
|
906
|
+
controlledPages() {
|
|
907
|
+
if (!this.port.control.tabId)
|
|
908
|
+
return this.port.pages();
|
|
909
|
+
try {
|
|
910
|
+
return [this.port.active().page];
|
|
911
|
+
}
|
|
912
|
+
catch {
|
|
913
|
+
return [];
|
|
914
|
+
}
|
|
915
|
+
}
|
|
740
916
|
async settled() { await this.captureQueue.catch(() => undefined); }
|
|
741
917
|
disconnect() {
|
|
742
918
|
if (this.closed)
|
|
@@ -771,7 +947,7 @@ export class BrowserLiveHandle {
|
|
|
771
947
|
if (this.poll)
|
|
772
948
|
clearInterval(this.poll);
|
|
773
949
|
void this.stopCapture().catch(() => undefined);
|
|
774
|
-
for (const page of this.
|
|
950
|
+
for (const page of this.controlledPages())
|
|
775
951
|
void releasePageInput(page);
|
|
776
952
|
}
|
|
777
953
|
}
|
|
@@ -4,7 +4,7 @@ import type { BrowserObservation } from './terminal-browser-interaction.ts';
|
|
|
4
4
|
export declare class BrowserObservations {
|
|
5
5
|
private generation;
|
|
6
6
|
private readonly entries;
|
|
7
|
-
invalidate(): void;
|
|
7
|
+
invalidate(page?: Page): void;
|
|
8
8
|
fresh(page: Page, tabId: string): BrowserObservation;
|
|
9
9
|
require(id: string, page: Page, tabId: string, human?: boolean): BrowserObservation;
|
|
10
10
|
}
|
|
@@ -3,7 +3,16 @@ import { randomUUID } from 'node:crypto';
|
|
|
3
3
|
export class BrowserObservations {
|
|
4
4
|
generation = 0;
|
|
5
5
|
entries = new Map();
|
|
6
|
-
invalidate() {
|
|
6
|
+
invalidate(page) {
|
|
7
|
+
if (page) {
|
|
8
|
+
for (const [id, observed] of this.entries)
|
|
9
|
+
if (observed.page === page)
|
|
10
|
+
this.entries.delete(id);
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
this.generation++;
|
|
14
|
+
this.entries.clear();
|
|
15
|
+
}
|
|
7
16
|
fresh(page, tabId) {
|
|
8
17
|
const viewport = page.viewportSize();
|
|
9
18
|
if (!viewport || page.isClosed())
|
|
@@ -4,6 +4,7 @@ export declare function describeFocusedField(page: Page): Promise<string | undef
|
|
|
4
4
|
/** CAPTCHA answers are model-solvable; explicit password/MFA controls remain private. */
|
|
5
5
|
export declare function secretControlAttributes(attributes: Array<string | null>): boolean;
|
|
6
6
|
export declare function pageHasSecretFocus(page: Page): Promise<boolean>;
|
|
7
|
+
export declare function readPageSelection(page: Page): Promise<string | undefined>;
|
|
7
8
|
export declare function clearSecretInputs(page: Page): Promise<void>;
|
|
8
9
|
export declare function releasePageInput(page: Page): Promise<void>;
|
|
9
10
|
export declare function applyPageInteraction(page: Page, interaction: BrowserInteraction & {
|
|
@@ -64,6 +64,26 @@ export async function pageHasSecretFocus(page) {
|
|
|
64
64
|
}
|
|
65
65
|
return false;
|
|
66
66
|
}
|
|
67
|
+
export async function readPageSelection(page) {
|
|
68
|
+
if (await pageHasSecretFocus(page))
|
|
69
|
+
return undefined;
|
|
70
|
+
for (const frame of page.frames()) {
|
|
71
|
+
const selection = await frame.evaluate(() => {
|
|
72
|
+
let active = document.activeElement;
|
|
73
|
+
while (active?.shadowRoot?.activeElement)
|
|
74
|
+
active = active.shadowRoot.activeElement;
|
|
75
|
+
if (active instanceof HTMLInputElement || active instanceof HTMLTextAreaElement) {
|
|
76
|
+
if (active instanceof HTMLInputElement && active.type === 'password')
|
|
77
|
+
return null;
|
|
78
|
+
const attrs = ['type', 'id', 'name', 'autocomplete', 'aria-label', 'placeholder'].map(name => active.getAttribute(name));
|
|
79
|
+
return { attrs, text: active.value.slice(active.selectionStart ?? 0, Math.min(active.selectionEnd ?? 0, (active.selectionStart ?? 0) + 4097)) };
|
|
80
|
+
}
|
|
81
|
+
return { attrs: [], text: document.getSelection()?.toString().slice(0, 4097) ?? '' };
|
|
82
|
+
}).catch(() => null);
|
|
83
|
+
if (selection?.text && !secretControlAttributes(selection.attrs))
|
|
84
|
+
return selection.text;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
67
87
|
export async function clearSecretInputs(page) {
|
|
68
88
|
for (const frame of page.frames())
|
|
69
89
|
await frame.evaluate(() => {
|
|
@@ -9,6 +9,10 @@ export declare class BrowserProfileRunnerRpc {
|
|
|
9
9
|
constructor(connectionId: string, send: (request: BrowserProfileSyncRequest) => void);
|
|
10
10
|
accept(value: unknown): void;
|
|
11
11
|
private request;
|
|
12
|
-
|
|
12
|
+
releaseMember(browserSessionId: string): Promise<void>;
|
|
13
|
+
transport(grant: BrowserProfileRunnerGrant, membership?: {
|
|
14
|
+
current(): string[];
|
|
15
|
+
revoke(ids: string[]): void;
|
|
16
|
+
}): CentralBrowserProfileTransport;
|
|
13
17
|
dispose(): void;
|
|
14
18
|
}
|
|
@@ -54,10 +54,13 @@ export class BrowserProfileRunnerRpc {
|
|
|
54
54
|
}
|
|
55
55
|
});
|
|
56
56
|
}
|
|
57
|
-
|
|
57
|
+
async releaseMember(browserSessionId) {
|
|
58
|
+
await this.request(browserSessionId, 'release');
|
|
59
|
+
}
|
|
60
|
+
transport(grant, membership) {
|
|
58
61
|
if (grant.scope.connectionId !== this.connectionId)
|
|
59
62
|
throw new Error('browser_profile_lease_expired');
|
|
60
|
-
const browserSessionId = grant.scope.browserSessionId;
|
|
63
|
+
const browserSessionId = grant.sharedContextId ?? grant.scope.browserSessionId;
|
|
61
64
|
return {
|
|
62
65
|
read: async () => grant.download ? downloadProfile(grant.download) : null,
|
|
63
66
|
readback: async (expectedRevision) => {
|
|
@@ -80,7 +83,15 @@ export class BrowserProfileRunnerRpc {
|
|
|
80
83
|
return { revision: result.revision };
|
|
81
84
|
},
|
|
82
85
|
renew: async () => {
|
|
86
|
+
const known = membership?.current() || [];
|
|
83
87
|
const result = await this.request(browserSessionId, 'renew');
|
|
88
|
+
if (membership) {
|
|
89
|
+
const active = result.activeMemberIds;
|
|
90
|
+
if (!Array.isArray(active) || !active.length || active.length > 16
|
|
91
|
+
|| active.some(id => typeof id !== 'string' || !/^[a-f0-9]{64}$/u.test(id)))
|
|
92
|
+
throw new Error('browser_profile_sync_invalid');
|
|
93
|
+
membership.revoke(known.filter(id => !active.includes(id)));
|
|
94
|
+
}
|
|
84
95
|
if (!Number.isSafeInteger(result.leaseRemainingMs) || result.leaseRemainingMs < 1 || result.leaseRemainingMs > 45_000)
|
|
85
96
|
throw new Error('browser_profile_sync_invalid');
|
|
86
97
|
return { leaseRemainingMs: result.leaseRemainingMs };
|
|
@@ -9,6 +9,7 @@ export type BrowserProfileRunnerGrant = {
|
|
|
9
9
|
sealedKey: BrowserProfileSealedKey;
|
|
10
10
|
revision: number;
|
|
11
11
|
leaseRemainingMs: number;
|
|
12
|
+
sharedContextId?: string;
|
|
12
13
|
download: {
|
|
13
14
|
url: string;
|
|
14
15
|
size: number;
|
|
@@ -35,6 +36,7 @@ export type BrowserProfileSyncResult = {
|
|
|
35
36
|
leaseRemainingMs?: number;
|
|
36
37
|
revision?: number;
|
|
37
38
|
keyVersion?: string;
|
|
39
|
+
activeMemberIds?: string[];
|
|
38
40
|
download?: {
|
|
39
41
|
url: string;
|
|
40
42
|
size: number;
|
|
@@ -46,6 +46,11 @@ export type BrowserActionInput = {
|
|
|
46
46
|
id: string;
|
|
47
47
|
name: string;
|
|
48
48
|
lease: BrowserProfilePersistenceLease;
|
|
49
|
+
shared?: {
|
|
50
|
+
contextId: string;
|
|
51
|
+
authorized: () => boolean;
|
|
52
|
+
releaseMember: () => Promise<void>;
|
|
53
|
+
};
|
|
49
54
|
};
|
|
50
55
|
recording?: {
|
|
51
56
|
options: BrowserLiveOptions;
|
|
@@ -100,6 +105,18 @@ export declare function threadBrowserScopes(): Array<{
|
|
|
100
105
|
}>;
|
|
101
106
|
export declare function closeThreadBrowserSession(browserSessionId: string): Promise<void>;
|
|
102
107
|
export declare function browserSessionIds(): string[];
|
|
108
|
+
/** Local runner display. Authentication itself is known only to the website. */
|
|
109
|
+
export declare function browserRuntimeInventory(): {
|
|
110
|
+
browsers: number;
|
|
111
|
+
tabs: number;
|
|
112
|
+
sessions: {
|
|
113
|
+
id: string;
|
|
114
|
+
tabs: number;
|
|
115
|
+
mode: "blocked" | "observe" | "human";
|
|
116
|
+
profile: string | null;
|
|
117
|
+
restored: boolean;
|
|
118
|
+
}[];
|
|
119
|
+
};
|
|
103
120
|
export declare function hasBrowserSessions(): boolean;
|
|
104
121
|
/** Revocation closes only this central context and never checkpoints its authentication. */
|
|
105
122
|
export declare function revokeBrowserProfileSession(browserSessionId: string, profileId: string): Promise<void>;
|