add blink to creator app

This commit is contained in:
kulikov0 committed 2026-10-25 12:13:04 +01:00
1 parent 38fff05bb3
commit e0e82f5212
25 files changed
+317 -111

No files matched your search

+14 -1
View File
@@ -175,6 +175,7 @@ export class BotManager {
else if (payload.cmd === BotCommand.WB) cmdPrefix = '/wb';
else if (payload.cmd === BotCommand.Dion) cmdPrefix = '/dion';
else if (payload.cmd === BotCommand.Bitrix) cmdPrefix = '/bitrix';
else if (payload.cmd === BotCommand.Blink) cmdPrefix = '/blink';
if (cmdPrefix && payload.mode) {
text = `${cmdPrefix} ${payload.mode}`;
}
@@ -198,7 +199,7 @@ export class BotManager {
if (wasAwaiting) {
await this.sendMessage(
peerId,
"Couldn't detect a VK / Telemost / WBStream / DION / Bitrix link in that message. Paste a join link or press Back.",
"Couldn't detect a VK / Telemost / WBStream / DION / Bitrix / Blink link in that message. Paste a join link or press Back.",
createWaitingKeyboard(),
);
return;
@@ -223,6 +224,9 @@ export class BotManager {
if (lower.includes('bitrix24') && lower.includes('/video/')) {
return { platform: Platform.Bitrix, target: trimmed };
}
if (lower.startsWith('blink://') || (lower.includes('blinkmap.com') && lower.includes('/join/'))) {
return { platform: Platform.Blink, target: trimmed };
}
if (lower.includes('vk.ru/call/join')) {
return { platform: Platform.VK, target: trimmed };
}
@@ -235,6 +239,7 @@ export class BotManager {
case Platform.WBStream: return TunnelMode.HeadlessWBStream;
case Platform.Dion: return TunnelMode.HeadlessDion;
case Platform.Bitrix: return TunnelMode.HeadlessBitrix;
case Platform.Blink: return TunnelMode.HeadlessBlink;
default: return TunnelMode.HeadlessVK;
}
}
@@ -245,6 +250,7 @@ export class BotManager {
case Platform.WBStream: return 'WB Stream';
case Platform.Dion: return 'DION';
case Platform.Bitrix: return 'Bitrix';
case Platform.Blink: return 'Blink';
default: return 'VK';
}
}
@@ -284,6 +290,7 @@ export class BotManager {
if (platform === Platform.WBStream) return TunnelMode.HeadlessWBStream;
if (platform === Platform.Dion) return TunnelMode.HeadlessDion;
if (platform === Platform.Bitrix) return TunnelMode.HeadlessBitrix;
if (platform === Platform.Blink) return TunnelMode.HeadlessBlink;
if (text.includes('headless')) {
return platform === Platform.VK ? TunnelMode.HeadlessVK : TunnelMode.HeadlessTelemost;
}
@@ -298,6 +305,7 @@ export class BotManager {
case TunnelMode.HeadlessWBStream:
case TunnelMode.HeadlessDion:
case TunnelMode.HeadlessBitrix:
case TunnelMode.HeadlessBlink:
return 'Headless';
case TunnelMode.PionVideo:
return 'Video';
@@ -332,6 +340,11 @@ export class BotManager {
console.log('[BOT] Creating Bitrix tab with mode:', mode);
this.onCreateTab({ mode, peerId, platform: Platform.Bitrix });
await this.sendMessage(peerId, `Creating Bitrix room (${this.tunnelModeLabel(mode)})`, createMainKeyboard());
} else if (text.startsWith('/blink')) {
const mode = this.parseTunnelMode(text, Platform.Blink);
console.log('[BOT] Creating Blink tab with mode:', mode);
this.onCreateTab({ mode, peerId, platform: Platform.Blink });
await this.sendMessage(peerId, `Creating Blink room (${this.tunnelModeLabel(mode)})`, createMainKeyboard());
} else if (text === '/list') {
await this.showList(peerId);
} else if (text.startsWith('/close ')) {
+1
View File
@@ -35,6 +35,7 @@ export function createMainKeyboard() {
],
[
{ action: { type: 'text', label: '🟧 Bitrix', payload: JSON.stringify({ cmd: BotCommand.Bitrix, mode: 'headless' }) } },
{ action: { type: 'text', label: '🟨 Blink', payload: JSON.stringify({ cmd: BotCommand.Blink, mode: 'headless' }) } },
],
[
{ action: { type: 'text', label: '🔗 Join by link', payload: JSON.stringify({ cmd: BotCommand.JoinPrompt }) } },
+2
View File
@@ -32,6 +32,7 @@ export const DION_AUTH_COOKIE = 'vc-refresh-token';
export const WBSTREAM_ACCESS_TOKEN_COOKIE = 'wb_access_token';
export const BITRIX_SESSION_COOKIE = 'BITRIX_SM_UIDH';
export const BITRIX_AUTH_NET_HOST = 'https://auth2.bitrix24.net';
export const BLINK_AUTH_COOKIE = 'blink_refresh_token';
export const SESSION_PARTITION = 'persist:creator';
export const WINDOW_WIDTH = 1200;
@@ -114,4 +115,5 @@ export enum HeadlessLogMarker {
TURN = 'TURN:',
PROTOCOL = 'protocol:',
TUNNEL_CONNECTED = 'TUNNEL CONNECTED',
LOGIN_LINK = 'STATUS:LOGIN_LINK:',
}
+12
View File
@@ -184,6 +184,12 @@ export class CookieStore {
console.log(`[COOKIES] cleared ${removed} bitrix cookies`);
return removed;
}
if (platform === Platform.Blink) {
const entries = await this.readBlinkCookies();
await fs.unlink(this.cookieFilePath(Platform.Blink)).catch(() => {});
console.log(`[COOKIES] cleared ${entries.length} blink cookies`);
return entries.length;
}
const config = PLATFORM_CONFIG[platform];
if (!config) return 0;
const removed = await this.removeCookiesForDomains(config.cookieDomains);
@@ -210,6 +216,10 @@ export class CookieStore {
return removed;
}
private async readBlinkCookies(): Promise<unknown[]> {
return fs.readFile(this.cookieFilePath(Platform.Blink), 'utf8').then(JSON.parse).catch(() => []);
}
async getDionCredentials(): Promise<DionCredentials> {
return new DionCookieFile(this.cookieFilePath(Platform.Dion)).readCredentials();
}
@@ -241,6 +251,8 @@ export class CookieStore {
});
const bitrixContent = await new BitrixCookieFile(this.cookieFilePath(Platform.Bitrix)).readRaw();
entries.push({ name: 'cookies-bitrix.json', data: Buffer.from(JSON.stringify(bitrixContent ?? {}, null, 2), 'utf8') });
const blinkContent = await this.readBlinkCookies();
entries.push({ name: 'cookies-blink.json', data: Buffer.from(JSON.stringify(blinkContent, null, 2), 'utf8') });
return buildStoredZip(entries);
}
+75 -1
View File
@@ -11,7 +11,7 @@ import {
HeadlessMode,
UpstreamProxy,
} from '../types';
import { IPC, BITRIX_LOGIN_URL } from '../constants';
import { IPC, BITRIX_LOGIN_URL, BLINK_AUTH_COOKIE } from '../constants';
import { BotManager } from '../bot/bot-manager';
import { DionCookieFile } from './dion-cookie-file';
import { BitrixCookieFile } from './bitrix-cookie-file';
@@ -48,6 +48,7 @@ async function cookieFileHasCookie(filePath: string, name: string | undefined):
export class HeadlessLauncher {
private relayPath: string;
private bitrixPath: string;
private blinkPath: string;
private binaryPaths = new Map<Platform, string>();
private upstreamProxy: UpstreamProxy = { socks: '', user: '', pass: '' };
private debugLogging = false;
@@ -66,6 +67,10 @@ export class HeadlessLauncher {
path.join('headless', 'bitrix', binaryName('headless-bitrix-creator')),
binaryName('headless-bitrix-creator'),
);
this.blinkPath = resolveResourcePath(
path.join('headless', 'blink', binaryName('headless-blink-creator')),
binaryName('headless-blink-creator'),
);
for (const [platform, config] of Object.entries(PLATFORM_CONFIG)) {
this.binaryPaths.set(
platform as Platform,
@@ -139,6 +144,10 @@ export class HeadlessLauncher {
await this.startBitrixHeadless(tabId, args);
return;
}
if (platform === Platform.Blink) {
await this.startBlinkHeadless(tabId, args);
return;
}
const tab = await this.host.getOrCreateTab(tabId);
tab.platform = platform;
const joinTarget = args.mode === HeadlessMode.Join ? (args.target || '').trim() : '';
@@ -301,6 +310,71 @@ export class HeadlessLauncher {
});
}
private async startBlinkHeadless(tabId: string, args: HeadlessStartArgs): Promise<void> {
const tab = await this.host.getOrCreateTab(tabId);
tab.platform = Platform.Blink;
tab.tunnelMode = TunnelMode.HeadlessBlink;
const joinTarget = args.mode === HeadlessMode.Join ? (args.target || '').trim() : '';
if (args.mode === HeadlessMode.Join && !joinTarget) {
this.sendLog(tabId, 'Join requested but no target link/room provided.');
return;
}
const cookiesPath = this.cookies.cookieFilePath(Platform.Blink);
if (!(await cookieFileHasCookie(cookiesPath, BLINK_AUTH_COOKIE))) {
if (tab.isBot) {
const reply = 'Please log into Blink in the creator app first, then try again.';
this.sendLog(tabId, reply);
if (this.host.botManager && tab.peerId != null) {
await this.host.botManager.sendMessage(tab.peerId, reply);
}
return;
}
this.sendLog(tabId, 'No Blink session found, opening login. Scan the QR with the Blink app or open the link on the phone.');
this.killRelay(tabId, tab);
const loginProc = spawn(this.blinkPath, ['--login', '--cookies', cookiesPath], {
stdio: ['ignore', 'pipe', 'pipe'],
});
tab.relay = loginProc;
this.attachProcessOutput(loginProc, tabId);
const code = await new Promise<number | null>((resolve) => loginProc.on('close', resolve));
if (tab.relay !== loginProc) return;
tab.relay = null;
const win = this.host.mainWindow;
if (win && !win.isDestroyed()) {
win.webContents.send(IPC.LOGIN_DONE, { tabId });
}
if (code !== 0) {
this.sendLog(tabId, 'Could not capture the Blink login, try again.');
return;
}
this.sendLog(tabId, 'Blink login captured.');
}
const spawnArgs = ['--resources', 'default', '--cookies', cookiesPath];
this.killRelay(tabId, tab);
if (joinTarget) {
spawnArgs.push('--room', joinTarget);
}
this.appendEgressArgs(spawnArgs);
if (this.debugLogging) spawnArgs.push('--debug');
const proc = spawn(this.blinkPath, spawnArgs, {
stdio: ['ignore', 'pipe', 'pipe'],
});
tab.relay = proc;
let authError: AuthErrorKind | null = null;
this.attachProcessOutput(proc, tabId, (msg) => {
const kind = parseAuthError(msg);
if (kind) authError = kind;
});
proc.on('close', async (code) => {
this.sendLog(tabId, `Headless exited with code ${code}`);
if (authError === 'expired') {
await this.cookies.clearPlatformCookies(Platform.Blink);
if (this.host.getTab(tabId) === tab) this.startBlinkHeadless(tabId, args);
}
});
}
private appendEgressArgs(args: string[]): void {
if (this.allowPrivateDst) args.push('--allow-private-dst');
if (this.allowLoopbackDst) args.push('--allow-loopback');
+2 -1
View File
@@ -190,7 +190,8 @@ export class TabManager {
mode === TunnelMode.HeadlessTelemost ||
mode === TunnelMode.HeadlessWBStream ||
mode === TunnelMode.HeadlessDion ||
mode === TunnelMode.HeadlessBitrix
mode === TunnelMode.HeadlessBitrix ||
mode === TunnelMode.HeadlessBlink
) return;
this.launcher.killRelay(tabId, tab);
setTimeout(() => this.launcher.startRelay(tabId, tab), RELAY_RESTART_DELAY_MS);
+21 -5
View File
@@ -58,6 +58,7 @@ export function renderContent(tm: RendererTabManager): void {
else if (activeTab.platform === Platform.WBStream) title = 'WBStream';
else if (activeTab.platform === Platform.Dion) title = 'DION';
else if (activeTab.platform === Platform.Bitrix) title = 'Bitrix';
else if (activeTab.platform === Platform.Blink) title = 'Blink';
document.getElementById('headlessTitle')!.textContent = title;
const startEl = document.getElementById('headlessStart')!;
const statusEl = document.getElementById('headlessStatus')!;
@@ -83,6 +84,9 @@ export function renderContent(tm: RendererTabManager): void {
} else if (activeTab.platform === Platform.Bitrix) {
targetLabel.textContent = 'Paste a portal /video/ link, or leave empty to create a new room.';
targetInput.placeholder = 'https://your-portal.bitrix24.ru/video/CODE';
} else if (activeTab.platform === Platform.Blink) {
targetLabel.textContent = 'Paste a chat id, blink:// link or group invite link.';
targetInput.placeholder = 'https://blinkmap.com/join/<key>';
} else if (activeTab.platform === Platform.Telemost) {
targetLabel.textContent = 'Paste a Telemost conference link.';
targetInput.placeholder = 'https://telemost.yandex.ru/j/...';
@@ -101,12 +105,20 @@ export function renderContent(tm: RendererTabManager): void {
const callInfoWB = document.getElementById('headlessCallInfoWB')!;
const callInfoDion = document.getElementById('headlessCallInfoDion')!;
const callInfoBitrix = document.getElementById('headlessCallInfoBitrix')!;
const callInfoBlink = document.getElementById('headlessCallInfoBlink')!;
const loginInfo = document.getElementById('headlessLoginInfo')!;
callInfoVK.style.display = 'none';
callInfoTM.style.display = 'none';
callInfoWB.style.display = 'none';
callInfoDion.style.display = 'none';
callInfoBitrix.style.display = 'none';
if (callInfo) {
callInfoBlink.style.display = 'none';
loginInfo.style.display = 'none';
if (activeTab.loginLink) {
loginInfo.style.display = 'block';
document.getElementById('headlessLoginLink')!.textContent = activeTab.loginLink;
renderHeadlessQr(activeTab.loginLink, `Scan with the ${title} app`);
} else if (callInfo) {
if (activeTab.platform === Platform.WBStream) {
callInfoWB.style.display = 'block';
document.getElementById('headlessWBJoinLink')!.textContent = callInfo.joinLink || '';
@@ -120,20 +132,23 @@ export function renderContent(tm: RendererTabManager): void {
} else if (activeTab.platform === Platform.Bitrix) {
callInfoBitrix.style.display = 'block';
document.getElementById('headlessBitrixJoinLink')!.textContent = callInfo.joinLink || '';
} else if (activeTab.platform === Platform.Blink) {
callInfoBlink.style.display = 'block';
document.getElementById('headlessBlinkJoinLink')!.textContent = callInfo.joinLink || '';
} else {
callInfoVK.style.display = 'block';
document.getElementById('headlessJoinLink')!.textContent = callInfo.joinLink || '';
document.getElementById('headlessTurn')!.textContent = callInfo.turn || '';
document.getElementById('headlessProtocol')!.textContent = callInfo.protocol || '';
}
renderJoinQr(callInfo.joinLink || '');
renderHeadlessQr(callInfo.joinLink || '', 'Scan in the Android app');
} else {
renderJoinQr('');
renderHeadlessQr('', '');
}
} else {
toolbar.style.display = 'flex';
headlessInfo.style.display = 'none';
renderJoinQr('');
renderHeadlessQr('', '');
const isVK = activeTab.platform === Platform.VK && activeTab.url.includes('vk.ru');
const modeSelect = document.getElementById('modeSelect') as HTMLSelectElement;
const tunnelLabel = document.getElementById('tunnelLabel') as HTMLElement;
@@ -310,7 +325,7 @@ export function exportCookiesZip(): void {
let renderedQrText = '';
function renderJoinQr(link: string): void {
function renderHeadlessQr(link: string, hint: string): void {
const wrap = document.getElementById('headlessQrWrap') as HTMLElement | null;
const image = document.getElementById('headlessQr') as HTMLImageElement | null;
if (!wrap || !image) return;
@@ -320,6 +335,7 @@ function renderJoinQr(link: string): void {
image.removeAttribute('src');
return;
}
document.getElementById('headlessQrHint')!.textContent = hint;
if (link === renderedQrText) {
wrap.style.display = 'block';
return;
+4
View File
@@ -67,6 +67,7 @@ function bindToolbarEvents(): void {
document.getElementById('btnHeadlessWB')!.addEventListener('click', () => tm.switchToHeadless(Platform.WBStream));
document.getElementById('btnHeadlessDion')!.addEventListener('click', () => tm.switchToHeadless(Platform.Dion));
document.getElementById('btnHeadlessBitrix')!.addEventListener('click', () => tm.switchToHeadless(Platform.Bitrix));
document.getElementById('btnHeadlessBlink')!.addEventListener('click', () => tm.switchToHeadless(Platform.Blink));
document.getElementById('modeSelect')!.addEventListener('change', (event) => {
tm.setTunnelMode((event.target as HTMLSelectElement).value);
});
@@ -318,6 +319,8 @@ function init(): void {
tm.switchToHeadless(Platform.Dion, data.joinTarget);
} else if (data.mode === TunnelMode.HeadlessBitrix) {
tm.switchToHeadless(Platform.Bitrix, data.joinTarget);
} else if (data.mode === TunnelMode.HeadlessBlink) {
tm.switchToHeadless(Platform.Blink, data.joinTarget);
} else {
const url = data.platform === Platform.Telemost ? TELEMOST_URL : VK_IM_URL;
loadURL(tm, url);
@@ -343,6 +346,7 @@ function init(): void {
const tab = tm.tabs[tabId];
if (!tab) return;
detachLoginWebview(tm, tabId);
tab.loginLink = undefined;
tab.headlessStatus = 'Starting...';
if (tabId === tm.activeTabId) renderContent(tm);
});
+1
View File
@@ -10,6 +10,7 @@ const PLATFORM_TITLES: Record<Platform, string> = {
[Platform.WBStream]: 'WBStream',
[Platform.Dion]: 'DION',
[Platform.Bitrix]: 'Bitrix',
[Platform.Blink]: 'Blink',
};
export class SavedCallsView {
+14 -1
View File
@@ -80,6 +80,10 @@ export class RendererTabManager {
tab.mode = TunnelMode.HeadlessBitrix;
if (!tab.isBot) tab.name = 'Bitrix';
break;
case Platform.Blink:
tab.mode = TunnelMode.HeadlessBlink;
if (!tab.isBot) tab.name = 'Blink';
break;
default:
tab.mode = TunnelMode.HeadlessVK;
if (!tab.isBot) tab.name = 'VK';
@@ -88,6 +92,7 @@ export class RendererTabManager {
tab.headlessStarted = false;
tab.platform = platform;
tab.callInfo = undefined;
tab.loginLink = undefined;
tab.headlessStatus = undefined;
tab.tunnelConnected = false;
tab.relayLogs = '';
@@ -109,6 +114,7 @@ export class RendererTabManager {
tab.headlessStarted = true;
tab.headlessStatus = 'Starting...';
tab.callInfo = undefined;
tab.loginLink = undefined;
window.bridge.startHeadless(this.activeTabId, tab.platform, args);
this.onRender();
}
@@ -120,12 +126,14 @@ export class RendererTabManager {
data.mode === TunnelMode.HeadlessTelemost ||
data.mode === TunnelMode.HeadlessWBStream ||
data.mode === TunnelMode.HeadlessDion ||
data.mode === TunnelMode.HeadlessBitrix;
data.mode === TunnelMode.HeadlessBitrix ||
data.mode === TunnelMode.HeadlessBlink;
let platformName = 'VK';
if (data.platform === Platform.Telemost) platformName = 'Telemost';
else if (data.platform === Platform.WBStream) platformName = 'WBStream';
else if (data.platform === Platform.Dion) platformName = 'DION';
else if (data.platform === Platform.Bitrix) platformName = 'Bitrix';
else if (data.platform === Platform.Blink) platformName = 'Blink';
const botName = isHeadless ? `Bot-${platformName}` : `Bot-${platformName} (legacy)`;
this.tabs[data.tabId] = {
wv: null,
@@ -225,6 +233,11 @@ export class RendererTabManager {
tab.callInfo.protocol = trimmed.split(HeadlessLogMarker.PROTOCOL)[1].trim();
changed = true;
}
if (trimmed.includes(HeadlessLogMarker.LOGIN_LINK)) {
tab.loginLink = trimmed.split(HeadlessLogMarker.LOGIN_LINK)[1].trim();
tab.headlessStatus = 'Waiting for login...';
changed = true;
}
if (trimmed.includes('[FATAL]')) {
const fatalMessage = trimmed.split('[FATAL]')[1]?.trim() || 'fatal error';
tab.headlessStatus = 'Disconnected: ' + fatalMessage;
+4
View File
@@ -8,6 +8,7 @@ export enum TunnelMode {
HeadlessWBStream = 'headless-wbstream',
HeadlessDion = 'headless-dion',
HeadlessBitrix = 'headless-bitrix',
HeadlessBlink = 'headless-blink',
}
export enum Platform {
@@ -16,6 +17,7 @@ export enum Platform {
WBStream = 'wbstream',
Dion = 'dion',
Bitrix = 'bitrix',
Blink = 'blink',
}
export enum RelayMode {
@@ -35,6 +37,7 @@ export enum BotCommand {
WB = 'wb',
Dion = 'dion',
Bitrix = 'bitrix',
Blink = 'blink',
JoinPrompt = 'join-prompt',
List = 'list',
Menu = 'menu',
@@ -158,6 +161,7 @@ export interface RendererTab {
callInfo?: CallInfo;
tunnelConnected?: boolean;
loginWebview?: Webview;
loginLink?: string;
joinedByLink?: boolean;
}