Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
soundofspace committed Jan 9, 2025
1 parent fd35b91 commit e105ed6
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions agent/main/lib/Console.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// Currently this only used to support communication from chrome (injected scripts) to unblocked agent

import Log from '@ulixee/commons/lib/Logger';
import Resolvable from '@ulixee/commons/lib/Resolvable';
import TypedEventEmitter from '@ulixee/commons/lib/TypedEventEmitter';
import { Server } from 'net';
Expand All @@ -22,7 +20,10 @@ export class Console extends TypedEventEmitter<IConsoleEvents> {
private server: Server;
private intervals = new Set<NodeJS.Timeout>();

constructor(public devtoolsSession: DevtoolsSession, public secretKey?: string) {
constructor(
public devtoolsSession: DevtoolsSession,
public secretKey?: string,
) {
super();
}

Expand All @@ -42,7 +43,9 @@ export class Console extends TypedEventEmitter<IConsoleEvents> {
}

isConsoleRegisterUrl(url: string): boolean {
return url.includes(`/heroInternalUrl?secretKey=${this.secretKey}&action=registerConsoleClientId&clientId=`)
return url.includes(
`/heroInternalUrl?secretKey=${this.secretKey}&action=registerConsoleClientId&clientId=`,
);
}

registerFrameId(url: string, frameId: string): void {
Expand Down Expand Up @@ -112,7 +115,7 @@ function injectedScript(): void {
const clientId = Math.random();

// By using document.url.origin we avoid all content security problems
const url = `${new URL(document.URL).origin}/heroInternalUrl?secretKey=${this.secretKey}&action=registerConsoleClientId&clientId=${clientId}`
const url = `${new URL(document.URL).origin}/heroInternalUrl?secretKey=${this.secretKey}&action=registerConsoleClientId&clientId=${clientId}`;

// This will signal to network manager we are trying to make websocket connection
// This is needed later to map clientId to frameId
Expand Down

0 comments on commit e105ed6

Please sign in to comment.