feat: add protected bookmark credentials and startup options
This commit is contained in:
1 parent
7108026544
commit
a1f5e43f5f
28 files changed
+1835
-102
No files matched your search
@@ -0,0 +1,296 @@
|
||||
'use strict';
|
||||
|
||||
const bookmarks = require('../renderer/shared/bookmarks.js');
|
||||
const { validateRequest } = require('./ipc-validate');
|
||||
const { ConnectionManager } = require('./connections');
|
||||
|
||||
/**
|
||||
* Bookmark passwords and bookmark connects, resolved only in main.
|
||||
*
|
||||
* Passwords are sealed with Electron's synchronous safeStorage (Windows DPAPI, macOS Keychain, Linux
|
||||
* libsecret/KWallet) and stored as opaque base64 in the bookmark (`server_password_encrypted`,
|
||||
* `channel_password_encrypted`). The sealed plaintext is an envelope binding the format version, the purpose
|
||||
* (server/channel) and the exact trimmed address, so ciphertext moved to another field or address never
|
||||
* decrypts into a connect. There is no plaintext fallback: Linux `basic_text` (a hardcoded key) and an
|
||||
* undetermined backend are refused, and nothing here ever enables safeStorage plain-text encryption.
|
||||
*
|
||||
* The renderer never receives plaintext except from an explicit `bookmarks:password-reveal`. Generic
|
||||
* `prefs:set` writes pass through `protectPrefsPatch`, which keeps the current ciphertext of an unchanged
|
||||
* bookmark whatever stale copy the renderer sends, drops it on an address change and accepts it on a new
|
||||
* bookmark only as an exact copy of a same-address bookmark (explicit duplication).
|
||||
*/
|
||||
|
||||
const ENVELOPE_VERSION = 1;
|
||||
const FIELDS = Object.freeze({ server: 'server_password_encrypted', channel: 'channel_password_encrypted' });
|
||||
const PASSWORD_MAX = 255;
|
||||
const CONTROL = /[\u0000-\u001f\u007f]/;
|
||||
// Backends whose key lives in the OS keyring; `basic_text` uses Chromium's hardcoded key and `unknown` means the
|
||||
// backend is not determined (for example before app ready).
|
||||
const LINUX_KEYRING_BACKENDS = new Set(['gnome_libsecret', 'kwallet', 'kwallet5', 'kwallet6']);
|
||||
// Chromium OSCrypt on Linux prefixes data sealed with its hardcoded fallback key `v10` (keyring key: `v11`).
|
||||
const LINUX_HARDCODED_KEY_PREFIX = 'v10';
|
||||
const MESSAGE_MAX = 200;
|
||||
|
||||
class BookmarkError extends Error {
|
||||
constructor(code, message) {
|
||||
super(message);
|
||||
this.code = code;
|
||||
}
|
||||
}
|
||||
|
||||
const fail = (code, message) => ({ ok: false, error: { code, message } });
|
||||
const isRecord = (value) => value !== null && typeof value === 'object' && !Array.isArray(value);
|
||||
const sameAddress = (a, b) => typeof a === 'string' && typeof b === 'string' && a.trim() === b.trim();
|
||||
const validAddress = (value) => typeof value === 'string' && value.length <= bookmarks.ADDRESS_MAX && value.trim().length > 0 && !CONTROL.test(value);
|
||||
// Same bound as the connect validator's server_password/channel_password (ipc-validate.js).
|
||||
const validPassword = (value) => typeof value === 'string' && value.length <= PASSWORD_MAX && !CONTROL.test(value);
|
||||
const validBookmarkId = (value) => typeof value === 'string' && bookmarks.ID.test(value);
|
||||
|
||||
/** Bounded, non-secret failure for any thrown error; unknown errors never echo their message. */
|
||||
function failure(error) {
|
||||
if (error instanceof BookmarkError) return fail(error.code, error.message);
|
||||
const message = typeof error?.message === 'string' ? error.message : '';
|
||||
// ipc-validate.js ValidationError and Prefs/bookmark validation name keys and rules, never values.
|
||||
if (error?.code === 'bad_request' || /^(prefs|bookmarks): /.test(message)) return fail('bad_request', message.slice(0, MESSAGE_MAX));
|
||||
// Node file errors (Prefs.set persisting) carry paths; report only that saving failed.
|
||||
if (typeof error?.code === 'string' && /^E[A-Z]+$/.test(error.code)) return fail('io', 'The bookmark could not be saved');
|
||||
return fail('internal', 'The bookmark request failed');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {object} o
|
||||
* @param {Electron.IpcMain} o.ipcMain
|
||||
* @param {(event) => boolean} o.trustedSender application top frame check
|
||||
* @param {{ get(): object, set(partial: object): object }} o.prefs the main Prefs instance
|
||||
* @param {Electron.SafeStorage} o.safeStorage
|
||||
* @param {NodeJS.Platform} o.platform
|
||||
* @param {(id: string) => ({ state: string, session: number, core: object | null } | null)} o.getConnection
|
||||
* @param {(id: string, cmd: string, args?: object) => Promise<object>} o.request core request on one connection
|
||||
* @param {boolean} o.testOffscreen hidden test runs never dispatch a bookmark connect
|
||||
* @returns {{ protectPrefsPatch(partial: unknown): unknown }}
|
||||
*/
|
||||
function registerBookmarkIpc({ ipcMain, trustedSender, prefs, safeStorage, platform, getConnection, request, testOffscreen }) {
|
||||
let startupIssued = false;
|
||||
/**
|
||||
* Whether OS-backed encryption can be used. `touch: false` (status display) avoids opening the macOS Keychain
|
||||
* or the Linux keyring, which can block on a user prompt; saving, revealing and connecting check for real.
|
||||
*/
|
||||
function storageStatus({ touch }) {
|
||||
// DPAPI never prompts; Keychain and keyring prompts would be visible in a hidden test run.
|
||||
if (testOffscreen && platform !== 'win32') return { available: false, reason: 'test_mode' };
|
||||
if (platform === 'linux') {
|
||||
let backend = 'unknown';
|
||||
try { backend = safeStorage.getSelectedStorageBackend(); } catch { /* treated as unknown */ }
|
||||
if (!LINUX_KEYRING_BACKENDS.has(backend)) return { available: false, reason: backend === 'basic_text' ? 'insecure_backend' : 'unknown_backend' };
|
||||
} else if (platform !== 'win32' && platform !== 'darwin') {
|
||||
return { available: false, reason: 'unsupported_platform' };
|
||||
}
|
||||
if (!touch && platform !== 'win32') return { available: true };
|
||||
let available = false;
|
||||
try { available = safeStorage.isEncryptionAvailable() === true; } catch { /* unavailable */ }
|
||||
return available ? { available: true } : { available: false, reason: 'unavailable' };
|
||||
}
|
||||
|
||||
function requireStorage() {
|
||||
const status = storageStatus({ touch: true });
|
||||
if (!status.available) throw new BookmarkError('storage_unavailable', `Secure password storage is unavailable (${status.reason})`);
|
||||
}
|
||||
|
||||
const hardcodedKey = (sealed) => platform === 'linux' && sealed.subarray(0, LINUX_HARDCODED_KEY_PREFIX.length).toString('latin1') === LINUX_HARDCODED_KEY_PREFIX;
|
||||
|
||||
function seal(kind, address, secret) {
|
||||
requireStorage();
|
||||
let sealed;
|
||||
try { sealed = safeStorage.encryptString(JSON.stringify({ v: ENVELOPE_VERSION, purpose: kind, address, secret })); } catch { sealed = null; }
|
||||
if (!Buffer.isBuffer(sealed) || sealed.length === 0 || hardcodedKey(sealed)) throw new BookmarkError('encryption_failed', 'The operating system could not encrypt the password');
|
||||
const text = sealed.toString('base64');
|
||||
if (!bookmarks.validSecret(text)) throw new BookmarkError('too_long', 'The encrypted password is too long to store');
|
||||
return text;
|
||||
}
|
||||
|
||||
/** Decrypts one stored field for `kind` at `address`; any doubt is an error, never an empty password. */
|
||||
function open(text, kind, address) {
|
||||
const unreadable = new BookmarkError('password_unreadable', `The saved ${kind} password cannot be decrypted; save it again`);
|
||||
if (!bookmarks.validSecret(text)) throw unreadable;
|
||||
const sealed = Buffer.from(text, 'base64');
|
||||
if (sealed.toString('base64') !== text || hardcodedKey(sealed)) throw unreadable;
|
||||
requireStorage();
|
||||
let envelope;
|
||||
try { envelope = JSON.parse(safeStorage.decryptString(sealed)); } catch { throw unreadable; }
|
||||
if (!isRecord(envelope) || Object.keys(envelope).length !== 4 || envelope.v !== ENVELOPE_VERSION || !validPassword(envelope.secret) || envelope.secret === '') throw unreadable;
|
||||
if (envelope.purpose !== kind || envelope.address !== address) {
|
||||
throw new BookmarkError('password_mismatch', `The saved ${kind} password does not belong to this bookmark address; save it again`);
|
||||
}
|
||||
return envelope.secret;
|
||||
}
|
||||
|
||||
const find = (id) => prefs.get().savedServers.find((server) => server.id === id) ?? null;
|
||||
|
||||
/** The bookmark `id`, still at `expectedAddress` (exact after trimming). */
|
||||
function target(id, expectedAddress) {
|
||||
const bookmark = find(id);
|
||||
if (!bookmark) throw new BookmarkError('not_found', 'The bookmark no longer exists');
|
||||
if (!sameAddress(bookmark.address, expectedAddress)) throw new BookmarkError('address_changed', 'The bookmark address changed; review it and try again');
|
||||
return bookmark;
|
||||
}
|
||||
|
||||
function passwordArgs(id, expectedAddress, kind) {
|
||||
if (!validBookmarkId(id)) throw new BookmarkError('bad_request', 'Invalid bookmark');
|
||||
if (!validAddress(expectedAddress)) throw new BookmarkError('bad_request', 'Invalid bookmark address');
|
||||
if (typeof kind !== 'string' || !Object.hasOwn(FIELDS, kind)) throw new BookmarkError('bad_request', 'Invalid password kind');
|
||||
}
|
||||
|
||||
/** Connect arguments for the stored bookmark, decrypted here and checked like a renderer connect. */
|
||||
function connectArgs(bookmark) {
|
||||
const address = bookmark.address.trim();
|
||||
const args = { address };
|
||||
if (bookmark.identity_id !== undefined) args.identity_id = bookmark.identity_id;
|
||||
if (bookmark.nickname !== undefined) args.nickname = bookmark.nickname;
|
||||
if (bookmark.channel !== undefined) args.channel = bookmark.channel;
|
||||
if (bookmark[FIELDS.server] !== undefined) args.server_password = open(bookmark[FIELDS.server], 'server', address);
|
||||
if (bookmark[FIELDS.channel] !== undefined) args.channel_password = open(bookmark[FIELDS.channel], 'channel', address);
|
||||
return validateRequest('connect', args);
|
||||
}
|
||||
|
||||
// Everything a connect is derived from; a difference after an await means the target changed.
|
||||
const connectSource = (bookmark) => JSON.stringify([bookmark.address, bookmark.identity_id, bookmark.nickname, bookmark.channel,
|
||||
bookmark.auto_connect, bookmark.auto_connect_muted, bookmark[FIELDS.server], bookmark[FIELDS.channel]]);
|
||||
|
||||
const handle = (channel, fn) => ipcMain.handle(channel, async (event, ...args) => {
|
||||
if (!trustedSender(event)) return fail('forbidden', 'forbidden');
|
||||
try { return await fn(event, ...args); } catch (error) { return failure(error); }
|
||||
});
|
||||
|
||||
handle('bookmarks:password-state', (_event, id) => {
|
||||
if (!validBookmarkId(id)) throw new BookmarkError('bad_request', 'Invalid bookmark');
|
||||
const bookmark = find(id);
|
||||
if (!bookmark) throw new BookmarkError('not_found', 'The bookmark no longer exists');
|
||||
const status = storageStatus({ touch: false });
|
||||
return {
|
||||
ok: true,
|
||||
available: status.available,
|
||||
serverPasswordSaved: bookmark[FIELDS.server] !== undefined,
|
||||
channelPasswordSaved: bookmark[FIELDS.channel] !== undefined,
|
||||
...(status.reason ? { reason: status.reason } : {}),
|
||||
};
|
||||
});
|
||||
|
||||
handle('bookmarks:password-set', (event, id, expectedAddress, kind, value) => {
|
||||
passwordArgs(id, expectedAddress, kind);
|
||||
if (!validPassword(value)) throw new BookmarkError('bad_request', `The ${kind} password must be at most ${PASSWORD_MAX} characters without control characters`);
|
||||
const field = FIELDS[kind];
|
||||
const original = target(id, expectedAddress);
|
||||
const address = original.address.trim();
|
||||
const previous = original[field];
|
||||
// Encryption may block on an OS prompt; the write below starts again from the current prefs.
|
||||
const sealed = value === '' ? null : seal(kind, address, value);
|
||||
if (!trustedSender(event)) throw new BookmarkError('forbidden', 'forbidden');
|
||||
const current = target(id, expectedAddress);
|
||||
if (current[field] !== previous) throw new BookmarkError('password_changed', 'The saved password changed; review it and try again');
|
||||
if (sealed === null && current[field] === undefined) return { ok: true, prefs: prefs.get() };
|
||||
const savedServers = prefs.get().savedServers.map((server) => {
|
||||
if (server.id !== id) return server;
|
||||
const next = { ...server };
|
||||
if (sealed === null) delete next[field];
|
||||
else next[field] = sealed;
|
||||
return next;
|
||||
});
|
||||
return { ok: true, prefs: prefs.set({ savedServers }) };
|
||||
});
|
||||
|
||||
handle('bookmarks:password-reveal', (event, id, expectedAddress, kind) => {
|
||||
passwordArgs(id, expectedAddress, kind);
|
||||
const bookmark = target(id, expectedAddress);
|
||||
const stored = bookmark[FIELDS[kind]];
|
||||
if (stored === undefined) throw new BookmarkError('not_saved', `No ${kind} password is saved for this bookmark`);
|
||||
const value = open(stored, kind, bookmark.address.trim());
|
||||
if (!trustedSender(event)) throw new BookmarkError('forbidden', 'forbidden');
|
||||
if (target(id, expectedAddress)[FIELDS[kind]] !== stored) throw new BookmarkError('password_changed', 'The saved password changed; try again');
|
||||
return { ok: true, value };
|
||||
});
|
||||
|
||||
handle('bookmarks:connect', async (event, connectionId, bookmarkId, startup = false) => {
|
||||
if (!ConnectionManager.validId(connectionId)) throw new BookmarkError('bad_request', 'Invalid server connection');
|
||||
if (!validBookmarkId(bookmarkId)) throw new BookmarkError('bad_request', 'Invalid bookmark');
|
||||
if (typeof startup !== 'boolean') throw new BookmarkError('bad_request', 'Invalid startup flag');
|
||||
const resolve = () => {
|
||||
const bookmark = find(bookmarkId);
|
||||
if (!bookmark) throw new BookmarkError('not_found', 'The bookmark no longer exists');
|
||||
if (startup && bookmark.auto_connect !== true) throw new BookmarkError('not_startup', 'The bookmark no longer connects at startup');
|
||||
return bookmark;
|
||||
};
|
||||
const bookmark = resolve();
|
||||
const source = connectSource(bookmark);
|
||||
const entry = getConnection(connectionId);
|
||||
if (!entry) throw new BookmarkError('connection_closed', 'The server connection is no longer available');
|
||||
if (!entry.core) throw new BookmarkError('core_unavailable', 'The core is not running');
|
||||
if (entry.state !== 'disconnected') throw new BookmarkError('already_connected', 'The server tab is already connected');
|
||||
const { session, core } = entry;
|
||||
const unchanged = () => getConnection(connectionId) === entry && entry.session === session && entry.core === core && entry.state === 'disconnected';
|
||||
// A keyring prompt may outlive the original window, bookmark or connection grant.
|
||||
const args = connectArgs(bookmark);
|
||||
if (!trustedSender(event)) throw new BookmarkError('forbidden', 'forbidden');
|
||||
if (!unchanged()) throw new BookmarkError('connection_changed', 'The server connection changed before connecting');
|
||||
if (connectSource(resolve()) !== source) throw new BookmarkError('bookmark_changed', 'The bookmark changed before connecting; try again');
|
||||
if (testOffscreen) throw new BookmarkError('test_safety', 'Real server connections are disabled in offscreen tests');
|
||||
// Official Connect(bookmark, autoconnect): connect_muted only on an automatic connect, and only the input
|
||||
// (initialClientSelfProperties.inputMuted). Unmuted bookmarks leave the current mute state alone.
|
||||
if (startup && bookmark.auto_connect_muted === true) {
|
||||
const muted = await request(connectionId, 'set_audio', { input_muted: true });
|
||||
if (!trustedSender(event)) throw new BookmarkError('forbidden', 'forbidden');
|
||||
if (muted?.ok !== true) return isRecord(muted?.error) ? muted : fail('mute_failed', 'The microphone could not be muted before connecting');
|
||||
if (!unchanged()) throw new BookmarkError('connection_changed', 'The server connection changed before connecting');
|
||||
if (connectSource(resolve()) !== source) throw new BookmarkError('bookmark_changed', 'The bookmark changed before connecting; try again');
|
||||
}
|
||||
return request(connectionId, 'connect', args);
|
||||
});
|
||||
|
||||
handle('bookmarks:startup', () => {
|
||||
if (testOffscreen || startupIssued) return { ok: true, bookmarks: [] };
|
||||
const list = bookmarks.allBookmarks(prefs.get())
|
||||
.filter((bookmark) => bookmark.auto_connect === true)
|
||||
.map((bookmark) => ({
|
||||
id: bookmark.id,
|
||||
address: bookmark.address,
|
||||
...(bookmark.identity_id !== undefined ? { identity_id: bookmark.identity_id } : {}),
|
||||
...(bookmark.nickname !== undefined ? { nickname: bookmark.nickname } : {}),
|
||||
...(bookmark.channel !== undefined ? { channel: bookmark.channel } : {}),
|
||||
}));
|
||||
startupIssued = true;
|
||||
return { ok: true, bookmarks: list };
|
||||
});
|
||||
|
||||
/**
|
||||
* Generic renderer prefs writes: call immediately before `prefs.set(partial)` with no await between, so both see
|
||||
* the same stored bookmarks. Returns the partial with protected fields taken from the store, or throws.
|
||||
*/
|
||||
function protectPrefsPatch(partial) {
|
||||
if (!isRecord(partial) || !Object.hasOwn(partial, 'savedServers') || !Array.isArray(partial.savedServers)) return partial;
|
||||
const current = prefs.get().savedServers;
|
||||
const byId = new Map(current.map((server) => [server.id, server]));
|
||||
const savedServers = partial.savedServers.map((incoming) => {
|
||||
if (!isRecord(incoming)) return incoming; // the prefs validator rejects it
|
||||
const next = { ...incoming };
|
||||
for (const field of bookmarks.SECRET_KEYS) delete next[field];
|
||||
const existing = typeof incoming.id === 'string' ? byId.get(incoming.id) : undefined;
|
||||
if (existing) {
|
||||
if (sameAddress(incoming.address, existing.address)) {
|
||||
for (const field of bookmarks.SECRET_KEYS) if (existing[field] !== undefined) next[field] = existing[field];
|
||||
}
|
||||
return next;
|
||||
}
|
||||
for (const field of bookmarks.SECRET_KEYS) {
|
||||
if (incoming[field] === undefined) continue;
|
||||
const copied = typeof incoming[field] === 'string' && current.some((server) => server[field] === incoming[field] && sameAddress(server.address, incoming.address));
|
||||
if (!copied) throw new Error(`prefs: ${field} can only be copied from a bookmark with the same address`);
|
||||
next[field] = incoming[field];
|
||||
}
|
||||
return next;
|
||||
});
|
||||
return { ...partial, savedServers };
|
||||
}
|
||||
|
||||
return { protectPrefsPatch };
|
||||
}
|
||||
|
||||
module.exports = { registerBookmarkIpc };
|
||||
@@ -173,6 +173,8 @@ const COMMANDS = {
|
||||
channel: optional(str(1, 512)),
|
||||
channel_password: optional(str(0, 255)),
|
||||
identity_id: optional((v, k) => { if (typeof v !== 'string' || !/^[A-Za-z0-9+/]{27}=$/.test(v)) throw new ValidationError(`${k}: invalid identity UID`); return v; }),
|
||||
// Per-connection override (bookmark nickname); same bound as rename, the core enforces 3-30 trimmed chars.
|
||||
nickname: optional(str(1, 64)),
|
||||
}),
|
||||
disconnect: shape({ message: optional(str(0, 80)) }),
|
||||
join_channel: shape({ channel_id: posInt, password: optional(str(0, 255)) }),
|
||||
|
||||
+5
-2
@@ -3,7 +3,7 @@
|
||||
const path = require('node:path');
|
||||
const fs = require('node:fs');
|
||||
const {
|
||||
app, BrowserWindow, ipcMain, protocol, session, nativeTheme, dialog, Menu, shell, clipboard, desktopCapturer, nativeImage, net,
|
||||
app, BrowserWindow, ipcMain, protocol, session, nativeTheme, dialog, Menu, shell, clipboard, desktopCapturer, nativeImage, net, safeStorage,
|
||||
} = require('electron');
|
||||
|
||||
// A disposable profile directory for tests/second instances. Set by whoever launches the app, never by the renderer.
|
||||
@@ -55,6 +55,7 @@ const { trustedHostsUpdateError } = require('./privacy-prefs');
|
||||
const { createInformationService, registerInformationIpc } = require('./information-panels');
|
||||
const { BadgeCatalog, registerBadgesIpc, officialBadgeCacheDirs } = require('./badges');
|
||||
const { registerServerIconsIpc } = require('./server-icons');
|
||||
const { registerBookmarkIpc } = require('./bookmark-secrets');
|
||||
|
||||
const APP_SCHEME = 'app';
|
||||
const APP_HOST = 'teamspeach';
|
||||
@@ -492,6 +493,8 @@ function registerIpc() {
|
||||
officialCacheDirs: testOffscreen ? [] : officialBadgeCacheDirs(),
|
||||
log: (level, message) => appendLog('main.log', `${level}: ${message}`) });
|
||||
registerBadgesIpc({ ipcMain, trustedSender, catalog: badgeCatalog });
|
||||
const bookmarkService = registerBookmarkIpc({ ipcMain, trustedSender, prefs, safeStorage, platform: process.platform,
|
||||
getConnection: (id) => connections.get(id), request: (id, cmd, args) => connections.request(id, cmd, args), testOffscreen });
|
||||
registerServerIconsIpc({ ipcMain, trustedSender, dialog, nativeImage, getWindow: () => mainWindow,
|
||||
request: (id, cmd, args) => ['file_upload', 'file_download'].includes(cmd) ? filesController.requestTransfer(id, cmd, args) : connections.request(id, cmd, args),
|
||||
validConnectionId: (id) => ConnectionManager.validId(id), getConnection: (id) => connections.get(id),
|
||||
@@ -593,7 +596,7 @@ function registerIpc() {
|
||||
const trustError = trustedHostsUpdateError(prefs.get(), partial, (host) => phishingList.has(host));
|
||||
if (trustError) return { ok: false, message: trustError };
|
||||
try {
|
||||
const next = prefs.set(partial);
|
||||
const next = prefs.set(bookmarkService.protectPrefsPatch(partial));
|
||||
if (partial && Object.prototype.hasOwnProperty.call(partial, 'theme')) nativeTheme.themeSource = next.theme;
|
||||
if (Object.hasOwn(partial, 'pttCode')) whisperIpc?.refreshBindings();
|
||||
return { ok: true, prefs: next };
|
||||
|
||||
+4
-19
@@ -47,8 +47,10 @@ const SCHEMA = {
|
||||
updateChannel: { default: 'preview', check: (v) => v === 'preview' || v === 'stable' },
|
||||
// Interface language: English for new profiles (owner's request); a stored valid choice is kept.
|
||||
language: { default: 'en', check: (v) => v === 'en' || v === 'ru' },
|
||||
// Quick-access servers may select a local identity UID and a containing folder; passwords are never stored.
|
||||
savedServers: { default: [], check: validServers },
|
||||
// Bookmarks: a local identity UID, containing folder and connect options (nickname, initial channel,
|
||||
// startup connect/mute). Passwords are only ever stored as OS-encrypted ciphertext written by
|
||||
// bookmark-secrets.js; the shape rules live in shared/bookmarks.js.
|
||||
savedServers: { default: [], check: bookmarks.validServers },
|
||||
// Local bookmark folders (official Bookmarks "New Folder") and the shared display order of folders and
|
||||
// bookmarks. Cross-field rules (references, cycles, depth, order permutation) live in shared/bookmarks.js.
|
||||
bookmarkFolders: { default: [], check: bookmarks.validFolders },
|
||||
@@ -82,23 +84,6 @@ const CONTROL = /[\u0000-\u001f\u007f]/;
|
||||
|
||||
const BOOKMARK_KEYS = ['savedServers', 'bookmarkFolders', 'bookmarkOrder'];
|
||||
|
||||
function validServers(list) {
|
||||
if (!Array.isArray(list) || list.length > bookmarks.MAX_BOOKMARKS) return false;
|
||||
const ids = new Set();
|
||||
for (const s of list) {
|
||||
if (!s || typeof s !== 'object' || Array.isArray(s)) return false;
|
||||
const keys = Object.keys(s);
|
||||
if (!keys.includes('id') || !keys.includes('name') || !keys.includes('address') || keys.some((key) => !['id', 'name', 'address', 'identity_id', 'folder'].includes(key))) return false;
|
||||
if (typeof s.id !== 'string' || !bookmarks.ID.test(s.id) || ids.has(s.id)) return false;
|
||||
if (typeof s.name !== 'string' || s.name.trim().length < 1 || s.name.length > 64 || CONTROL.test(s.name)) return false;
|
||||
if (typeof s.address !== 'string' || s.address.trim().length < 1 || s.address.length > 255 || CONTROL.test(s.address)) return false;
|
||||
if (s.identity_id !== undefined && (typeof s.identity_id !== 'string' || !/^[A-Za-z0-9+/]{27}=$/.test(s.identity_id))) return false;
|
||||
if (s.folder !== undefined && (typeof s.folder !== 'string' || !bookmarks.ID.test(s.folder))) return false;
|
||||
ids.add(s.id);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function validCollapsedChannels(list) {
|
||||
if (!Array.isArray(list) || list.length > 32) return false;
|
||||
const servers = new Set();
|
||||
|
||||
@@ -102,6 +102,11 @@ contextBridge.exposeInMainWorld('teamspeach', {
|
||||
onWindowState: (callback) => subscribe('window:state', callback),
|
||||
getPrefs: () => ipcRenderer.invoke('prefs:get'),
|
||||
setPrefs: (partial) => ipcRenderer.invoke('prefs:set', partial),
|
||||
getBookmarkPasswordState: (id) => ipcRenderer.invoke('bookmarks:password-state', id),
|
||||
setBookmarkPassword: (id, address, kind, value) => ipcRenderer.invoke('bookmarks:password-set', id, address, kind, value),
|
||||
revealBookmarkPassword: (id, address, kind) => ipcRenderer.invoke('bookmarks:password-reveal', id, address, kind),
|
||||
connectBookmark: (connectionId, id, startup = false) => ipcRenderer.invoke('bookmarks:connect', connectionId, id, startup),
|
||||
getStartupBookmarks: () => ipcRenderer.invoke('bookmarks:startup'),
|
||||
identityRequest: (action, args) => ipcRenderer.invoke('identity:request', action, args),
|
||||
exportIdentity: (uid) => ipcRenderer.invoke('identity:export', uid),
|
||||
onIdentityProgress: (callback) => subscribe('identity:progress', callback),
|
||||
|
||||
@@ -218,6 +218,7 @@
|
||||
<symbol id="i-waiting" viewBox="0 0 22 22" shape-rendering="geometricPrecision" class="tsv-icon-waiting" fill="none"><path d="M15.0764 18.0585C18.9747 15.8078 20.3104 10.823 18.0597 6.92461C15.809 3.02624 10.8241 1.69056 6.92578 3.94128" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" class="tsv-icon-base-stroke"/><path d="M15.0744 18.0587C11.1761 20.3094 6.19125 18.9737 3.94053 15.0753C1.68981 11.177 3.02548 6.19215 6.92385 3.94143" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" stroke-dasharray="3 3" class="tsv-icon-base-stroke"/><path d="M11 6.1095V10.9998L14.2602 12.63" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" class="tsv-icon-base-stroke"/></symbol>
|
||||
<symbol id="i-connection-whispers" class="tsv-icon-connection-whispers" viewBox="0 0 22 22" shape-rendering="geometricPrecision" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="2"> <rect id="i-connection-whispers--connection_whispers" x="-0" y="0" width="22" height="22" fill="none"/> <path d="M21,3C21,1.896 20.104,1 19,1L3,1C1.896,1 1,1.896 1,3L1,19C1,20.104 1.896,21 3,21L19,21C20.104,21 21,20.104 21,19L21,3Z" class="tsv-icon-base-contrast-fill"/> <g> <path d="M14.765,13.157L12.664,13.157C14.122,12.211 14.122,9.685 12.434,8.825L14.535,8.825C15.355,10.105 15.576,11.797 14.765,13.157Z" class="tsv-icon-tint-fill" fill-rule="nonzero"/> <path d="M17.007,15.938L14.494,15.938C14.809,15.747 15.108,15.521 15.383,15.258C17.886,12.871 17.408,8.106 14.478,6.062L17.065,6.062C18.491,7.716 19.28,9.924 18.937,12.163C18.716,13.609 18.009,14.901 17.007,15.938Z" class="tsv-icon-tint-fill" fill-rule="nonzero"/> </g> <g> <path d="M3.66,16.092C3.581,16.039 3.507,15.978 3.439,15.91C3.164,15.636 3.01,15.263 3.01,14.875L3.01,14.874C3.01,13.78 3.445,12.73 4.219,11.956C4.574,11.601 4.986,11.318 5.435,11.115C7.006,12.222 9.25,12.323 10.704,11.171C11.107,11.369 11.478,11.633 11.801,11.956C12.575,12.73 13.01,13.78 13.01,14.874C13.01,14.874 13.01,14.875 13.01,14.875C13.01,15.263 12.856,15.636 12.581,15.91C12.513,15.978 12.439,16.039 12.36,16.092C11.14,16.985 9.636,17.513 8.01,17.513C6.384,17.513 4.88,16.985 3.66,16.092Z" class="tsv-icon-subtitle-fill"/> <ellipse cx="8.01" cy="7.539" rx="3.394" ry="3.6" class="tsv-icon-subtitle-fill"/> </g></symbol>
|
||||
<symbol id="i-chat-contact" viewBox="0 0 23 23" shape-rendering="geometricPrecision" class="tsv-icon-chat-contact" fill="none"><path fill-rule="evenodd" clip-rule="evenodd" d="M20.6289 11.6531C20.6289 16.6236 16.5995 20.6531 11.6289 20.6531C6.65834 20.6531 2.62891 16.6236 2.62891 11.6531C2.62891 6.68251 6.65834 2.65308 11.6289 2.65308C16.5995 2.65308 20.6289 6.68251 20.6289 11.6531ZM7.16878 13.3811C7.75488 12.795 8.5498 12.4658 9.37866 12.4658H13.8792C14.708 12.4658 15.5029 12.795 16.089 13.3811C16.6751 13.9672 17.0044 14.7621 17.0044 15.591V16.7161C17.0044 17.1994 16.6126 17.5911 16.1294 17.5911C15.6461 17.5911 15.2544 17.1994 15.2544 16.7161V15.591C15.2544 15.2263 15.1095 14.8765 14.8516 14.6186C14.5937 14.3607 14.2439 14.2158 13.8792 14.2158H9.37866C9.01393 14.2158 8.66413 14.3607 8.40622 14.6186C8.14831 14.8765 8.00342 15.2263 8.00342 15.591V16.7161C8.00342 17.1994 7.61167 17.5911 7.12842 17.5911C6.64517 17.5911 6.25342 17.1994 6.25342 16.7161V15.591C6.25342 14.7621 6.58268 13.9672 7.16878 13.3811ZM10.2537 8.48752C10.2537 7.72799 10.8694 7.11227 11.6289 7.11227C12.3884 7.11227 13.0042 7.72799 13.0042 8.48752C13.0042 9.24704 12.3884 9.86276 11.6289 9.86276C10.8694 9.86276 10.2537 9.24704 10.2537 8.48752ZM11.6289 5.36227C9.90288 5.36227 8.50366 6.76149 8.50366 8.48752C8.50366 10.2135 9.90288 11.6128 11.6289 11.6128C13.3549 11.6128 14.7542 10.2135 14.7542 8.48752C14.7542 6.76149 13.3549 5.36227 11.6289 5.36227Z" class="tsv-icon-subtitle-fill"/></symbol>
|
||||
<symbol id="i-channel-select-default" class="tsv-icon-channel-select-default" viewBox="0 0 22 22" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="2"><rect id="i-channel-select-default--channel_select_default" x="-0" y="0" width="22" height="22" fill="none"/><g><path d="M11,3.941C13.922,3.941 16.294,6.313 16.294,9.235C16.294,12.157 13.904,14.872 11,18.059C8.142,14.84 5.706,12.157 5.706,9.235C5.706,6.313 8.078,3.941 11,3.941ZM11,6.294C12.623,6.294 13.941,7.612 13.941,9.235C13.941,10.859 12.623,12.177 11,12.177C9.377,12.177 8.059,10.859 8.059,9.235C8.059,7.612 9.377,6.294 11,6.294Z" class="tsv-icon-tint2-fill"/></g></symbol>
|
||||
<symbol id="i-whisper" viewBox="0 0 22 22" shape-rendering="geometricPrecision" class="tsv-icon-whisper" fill="none"><path d="M13.6445 17.75V16.25C13.6445 15.4544 13.3285 14.6913 12.7659 14.1287C12.2032 13.5661 11.4402 13.25 10.6445 13.25H4.64453C3.84888 13.25 3.08582 13.5661 2.52321 14.1287C1.9606 14.6913 1.64453 15.4544 1.64453 16.25V17.75" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" class="tsv-icon-base-stroke"/><path d="M7.64453 10.25C9.30139 10.25 10.6445 8.90685 10.6445 7.25C10.6445 5.59315 9.30139 4.25 7.64453 4.25C5.98768 4.25 4.64453 5.59315 4.64453 7.25C4.64453 8.90685 5.98768 10.25 7.64453 10.25Z" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" class="tsv-icon-base-stroke"/><path d="M18.0905 4.33325C19.542 5.7921 20.3574 7.77045 20.3574 9.83325C20.3574 11.8961 19.542 13.8744 18.0905 15.3333M15.3574 7.07936C16.0832 7.80878 16.4909 8.79796 16.4909 9.82936C16.4909 10.8608 16.0832 11.8499 15.3574 12.5794" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" class="tsv-icon-base-stroke"/></symbol>
|
||||
<!-- Default client avatar: official ts-icon-stack composition (main.js @3162500, @10693354): ClientDetailed portrait + ClientDetailedPlaceholder under the ClientDetailedMask alpha mask, centred as the masked tsv-avatar layer. Talking ring = i-client-detailed-talking overlay. -->
|
||||
<symbol id="i-avatar" viewBox="0 0 51 33"><use href="#i-client-detailed"/><mask id="i-avatar--mask" mask-type="alpha" maskUnits="userSpaceOnUse" x="0" y="0" width="51" height="33"><use href="#i-client-detailed-mask" x="9" width="33" height="33"/></mask><g mask="url(#i-avatar--mask)"><use href="#i-client-detailed-placeholder" x="9" width="33" height="33"/></g></symbol>
|
||||
@@ -610,7 +611,7 @@
|
||||
<label class="field"><span class="field-label" data-i18n="ui.identity">Identity</span><select id="server-add-identity"></select></label>
|
||||
<div class="form-actions"><button class="btn btn-primary btn-small" type="submit" data-i18n="ui.add">Add</button><span id="server-add-status" class="form-status" role="status"></span></div>
|
||||
</form>
|
||||
<p class="tsv-font-subtitle" data-i18n="ui.only.the.name.and.address.are.saved">Only the name and address are saved. Server passwords are not stored; you will be asked when connecting. The same identity is used for every server.</p>
|
||||
<p class="tsv-font-subtitle" data-i18n="bookmarks.settings.storage.info">Use the sidebar bookmark editor for nickname overrides, initial channels, startup options and encrypted passwords. Saving passwords requires secure OS storage.</p>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
@@ -733,7 +734,7 @@
|
||||
<h3 class="details-title" data-i18n="ui.receive.codecs.reported.by.the.engine">Receive codecs reported by the engine</h3>
|
||||
<ul id="codec-list" class="codec-list"></ul>
|
||||
<h3 class="details-title" data-i18n="ui.unavailable.settings">Unavailable settings</h3>
|
||||
<p class="tsv-font-subtitle" data-i18n="ui.unlike.teamspeak.6.there.is.no.cisco">Unlike TeamSpeak 6, there is no Cisco OpenH264 toggle or manual hardware backend selection (NVENC, AMF, QSV, etc.). TeamsPeach receives video through Chromium WebRTC, which has no decoder-selection API. Chromium decodes H.264 through FFmpeg; OpenH264 is only an encoder, and sending your own screen is not implemented in TeamsPeach.</p>
|
||||
<p class="tsv-font-subtitle" data-i18n="ui.unlike.teamspeak.6.there.is.no.cisco">TeamsPeach does not expose a Cisco OpenH264 toggle or individual hardware backend settings (NVENC, AMF, QSV, etc.). Chromium selects the WebRTC encoder and decoder within the enabled hardware policy.</p>
|
||||
</details>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
+33
-6
@@ -11,7 +11,7 @@ import {
|
||||
S, on, emit, newConnection, viewedConnection, connectionById, connectionList, inputConnection, isAlive,
|
||||
isConnected, ownClient, ownChannel, selectedChannel,
|
||||
} from './state.js';
|
||||
import { tp, callOn, profileCall, log } from './core.js';
|
||||
import { tp, callOn, profileCall, BridgeError, log } from './core.js';
|
||||
import { errorText, shortUid, stripBBCode } from './text.js';
|
||||
import { toast } from './toast.js';
|
||||
import { initTree, renderTree, updateTalking, joinChannel } from './tree.js';
|
||||
@@ -70,6 +70,7 @@ function renderHostBanner() {
|
||||
|
||||
const VIEWS = ['#boot', '#view-fatal', '#view-onboarding', '#view-app'];
|
||||
let appShown = false;
|
||||
let startupBookmarksRequested = false;
|
||||
let profileLoading = null;
|
||||
let lastAsyncError = { code: '', at: 0 };
|
||||
// Official defaultClientSelfProperties: "mute on all servers" also applies to connections opened later.
|
||||
@@ -199,7 +200,7 @@ function syncInput() {
|
||||
renderSessionHead();
|
||||
}
|
||||
|
||||
async function newConnectionTab() {
|
||||
async function newConnectionTab({ view = true } = {}) {
|
||||
const r = await tp.createConnection();
|
||||
if (!r?.ok) {
|
||||
toast(() => (r?.error?.code === 'too_many_connections' ? t('ui.connections.tooMany', { p0: 8 }) : errorText(r?.error)), 'error');
|
||||
@@ -207,7 +208,7 @@ async function newConnectionTab() {
|
||||
}
|
||||
// Main announced the connection (connections:changed) before answering.
|
||||
const conn = connectionById(r.connection.id);
|
||||
if (conn) setViewed(conn.id);
|
||||
if (conn && view) setViewed(conn.id);
|
||||
return conn;
|
||||
}
|
||||
|
||||
@@ -408,6 +409,7 @@ function showApp() {
|
||||
voice.startAudio();
|
||||
renderAll();
|
||||
if (S.view === 'main' && !isConnected()) $('#connect-address').focus();
|
||||
void connectStartupBookmarks();
|
||||
}
|
||||
|
||||
function renderAll() {
|
||||
@@ -582,12 +584,31 @@ function sameAddress(a, b) {
|
||||
return a.trim().toLowerCase() === b.trim().toLowerCase();
|
||||
}
|
||||
|
||||
/** Startup is opt-in per bookmark; starting one connection must not wait for another server's handshake. */
|
||||
async function connectStartupBookmarks() {
|
||||
if (startupBookmarksRequested) return;
|
||||
startupBookmarksRequested = true;
|
||||
try {
|
||||
const response = await tp.getStartupBookmarks();
|
||||
if (!response?.ok) throw new BridgeError(response?.error);
|
||||
const idle = connectionList().filter(conn => conn.conn.state === 'disconnected');
|
||||
for (const bookmark of response.bookmarks) {
|
||||
let conn = idle.shift();
|
||||
if (!isAlive(conn) || conn.conn.state !== 'disconnected') conn = null;
|
||||
conn ??= await newConnectionTab({ view: false });
|
||||
if (!conn) break; // newConnectionTab reports the connection limit or creation error.
|
||||
void connectTo(bookmark.address, { conn, identity_id: bookmark.identity_id || '', bookmark_id: bookmark.id, startup: true })
|
||||
.catch(error => toast(() => errorText(error), 'error'));
|
||||
}
|
||||
} catch (error) { toast(() => errorText(error), 'error'); }
|
||||
}
|
||||
|
||||
/**
|
||||
* Connects `conn` (default: a server tab chosen for `address`) to `address`. Opening a saved server never
|
||||
* disconnects another one: an existing connection to the same address is shown, an idle viewed tab is used,
|
||||
* otherwise a new server tab is opened (official: connections live side by side).
|
||||
*/
|
||||
async function connectTo(address, { password = '', identity_id = '', conn = null } = {}) {
|
||||
async function connectTo(address, { password = '', identity_id = '', bookmark_id = '', startup = false, conn = null } = {}) {
|
||||
const error = $('#connect-error');
|
||||
setText(error, () => '');
|
||||
if (!address) {
|
||||
@@ -615,6 +636,7 @@ async function connectTo(address, { password = '', identity_id = '', conn = null
|
||||
if (isAlive(conn) && conn.id === S.viewId) setText(error, () => coreStatusText(conn.core));
|
||||
return;
|
||||
}
|
||||
if (!isAlive(conn) || conn.conn.state !== 'disconnected') return;
|
||||
const args = { address };
|
||||
if (password) args.server_password = password;
|
||||
if (identity_id) args.identity_id = identity_id;
|
||||
@@ -628,7 +650,12 @@ async function connectTo(address, { password = '', identity_id = '', conn = null
|
||||
renderTree();
|
||||
}
|
||||
try {
|
||||
await callOn(conn.id, 'connect', args);
|
||||
if (bookmark_id) {
|
||||
const response = await tp.connectBookmark(conn.id, bookmark_id, startup);
|
||||
if (!response?.ok) throw new BridgeError(response?.error);
|
||||
} else {
|
||||
await callOn(conn.id, 'connect', args);
|
||||
}
|
||||
await savePrefs({ lastAddress: address });
|
||||
if (conn.id === S.viewId) $('#connect-password').value = '';
|
||||
} catch (err) {
|
||||
@@ -1057,7 +1084,7 @@ async function boot() {
|
||||
const conn = connectionList().find((entry) => `${connectionLabel(entry)} ${entry.conn.address}`.toLocaleLowerCase().includes(normalized));
|
||||
if (conn) { setViewed(conn.id); return; }
|
||||
const bookmark = S.prefs.savedServers.find((entry) => `${entry.name} ${entry.address}`.toLocaleLowerCase().includes(normalized));
|
||||
void connectTo(bookmark?.address || query, { identity_id: bookmark?.identity_id || '' });
|
||||
void connectTo(bookmark?.address || query, { identity_id: bookmark?.identity_id || '', bookmark_id: bookmark?.id || '' });
|
||||
});
|
||||
$('#btn-disconnect').addEventListener('click', () => disconnect());
|
||||
$('#server-bookmark').addEventListener('click', () => { if (isConnected()) void servers.saveCurrentServer(); });
|
||||
|
||||
+418
-32
@@ -1,11 +1,14 @@
|
||||
import { t, onLanguageChange } from './i18n.js';
|
||||
// Bookmarks (name, address, optional local identity and folder; never passwords): the official sidebar
|
||||
// ts-bookmark-list (folder navigation, inline New Folder / New Bookmark creators, rename, context menus,
|
||||
// drag and drop, edit sub-panel) plus the Settings → Servers manager. Persisted through main's validated
|
||||
// preferences; the hierarchy rules live in shared/bookmarks.js and are re-checked by main on every write.
|
||||
// Bookmarks: the official sidebar ts-bookmark-list (folder navigation, inline New Folder / New Bookmark
|
||||
// creators, rename, context menus, drag and drop) and its ts-edit-bookmark sub-panel (identity, nickname,
|
||||
// startup connect/mute, default channel, passwords), plus the Settings → Servers manager. Persisted through
|
||||
// main's validated preferences; the hierarchy and field rules live in shared/bookmarks.js and are re-checked
|
||||
// by main on every write. Passwords are encrypted and read only by main; the renderer sees saved flags and a
|
||||
// stored password only after an explicit Reveal. Every bookmark connection passes its bookmark_id so main
|
||||
// resolves the stored options and passwords.
|
||||
import '../shared/bookmarks.js';
|
||||
import { $, h, icon, setText } from './dom.js';
|
||||
import { S, connectionList, viewedConnection } from './state.js';
|
||||
import { $, h, icon, setIcon, setText } from './dom.js';
|
||||
import { S, connectionList, viewedConnection, isAlive } from './state.js';
|
||||
import { tp } from './core.js';
|
||||
import { toast } from './toast.js';
|
||||
import { menuPosition } from './menu-position.js';
|
||||
@@ -147,6 +150,8 @@ function changeError(error) {
|
||||
case 'folder-limit': return t('ui.bookmark.folder.limit', { count: B.MAX_FOLDERS });
|
||||
case 'depth': return t('ui.bookmark.folder.depth', { count: B.MAX_FOLDER_DEPTH });
|
||||
case 'cycle': return t('ui.bookmark.folder.cycle');
|
||||
case 'nickname-short': return t('client.action.rename.error.too_short');
|
||||
case 'nickname-long': return t('client.action.rename.error.too_long');
|
||||
default: return t('bookmarks.save.error', { error: error?.message ?? '' });
|
||||
}
|
||||
}
|
||||
@@ -280,7 +285,8 @@ function bookmarkRow(server) {
|
||||
'aria-label': `${server.name}, ${server.address}. ${label}`,
|
||||
title: current ? t('ui.you.are.connected.to.this.server') : t('ui.connect'),
|
||||
}, icon('bookmark'), itemText(server.name, server.address), h('span', { class: 'server-item-action', text: label }));
|
||||
btn.addEventListener('click', () => hooks.connectTo(server.address, { identity_id: server.identity_id || '' }));
|
||||
// Main resolves the bookmark's stored nickname, channel and passwords from its id.
|
||||
btn.addEventListener('click', () => hooks.connectTo(server.address, { identity_id: server.identity_id || '', bookmark_id: server.id }));
|
||||
return itemLi(server.id, 'bookmark', btn);
|
||||
}
|
||||
|
||||
@@ -707,7 +713,9 @@ async function keyboardMove(id, key) {
|
||||
if (!focusRow(focus)) focusRow(parent);
|
||||
}
|
||||
|
||||
// ---------- edit sub-panel (official ts-edit-bookmark, local fields) ----------
|
||||
// ---------- edit sub-panel (official ts-edit-bookmark) ----------
|
||||
|
||||
let editView = null; // { id, el, sync }
|
||||
|
||||
function openEdit(id) {
|
||||
renamingId = null;
|
||||
@@ -725,53 +733,332 @@ function closeEdit() {
|
||||
}
|
||||
|
||||
function renderEditPanel() {
|
||||
const existing = document.getElementById('bookmark-edit-panel');
|
||||
if (editPanelId === null) {
|
||||
existing?.remove();
|
||||
editView?.el.remove();
|
||||
editView = null;
|
||||
return;
|
||||
}
|
||||
if (existing?.dataset.id === editPanelId) return;
|
||||
existing?.remove();
|
||||
$('#servers-list').before(editPanel(findServer(editPanelId)));
|
||||
if (editView?.id !== editPanelId || !editView.el.isConnected) {
|
||||
editView?.el.remove();
|
||||
editView = editPanel(findServer(editPanelId));
|
||||
$('#servers-list').before(editView.el);
|
||||
}
|
||||
editView.sync();
|
||||
}
|
||||
|
||||
function bridgeError(result) {
|
||||
return result?.error?.message ?? result?.message ?? t('ui.error');
|
||||
}
|
||||
|
||||
/** Bridge call whose rejection becomes an ordinary failed result. */
|
||||
async function bridge(call) {
|
||||
try {
|
||||
return await call();
|
||||
} catch (error) {
|
||||
return { ok: false, message: error?.message };
|
||||
}
|
||||
}
|
||||
|
||||
/** Official ts-text-input caption row: `.ts-style-caption` label left, control right. */
|
||||
function captionRow(forId, key, control) {
|
||||
return h('div', { class: 'bookmark-edit-row' }, h('label', { for: forId, text: () => t(key) }), control);
|
||||
}
|
||||
|
||||
/** Official ts-toggle with its ts-card-subtitle description (the source appends a period). */
|
||||
function toggleRow(titleKey, descriptionKey, onChange) {
|
||||
const input = h('input', { type: 'checkbox', class: 'toggle', role: 'switch' });
|
||||
const title = h('span', { class: 'ts-toggle-label' });
|
||||
setText(title, () => t(titleKey));
|
||||
const description = h('p', { class: 'ts-card-subtitle' });
|
||||
setText(description, () => `${t(descriptionKey)}.`);
|
||||
input.addEventListener('change', () => onChange(input.checked));
|
||||
const row = h('div', { class: 'bookmark-edit-option' }, h('label', { class: 'ts-toggle-wrapper bookmark-edit-toggle' }, title, input), description);
|
||||
return { row, input };
|
||||
}
|
||||
|
||||
/**
|
||||
* Password field backed by main's OS-encrypted storage: the renderer never receives a stored password except
|
||||
* through an explicit Reveal click, and never writes one into preferences. Enter or leaving the field saves a
|
||||
* typed password; Clear removes the stored one (official ts-text-input reveal / clear actions).
|
||||
*/
|
||||
function secretField(id, kind, inputId, alive, onStored) {
|
||||
const placeholderKey = kind === 'server' ? 'server.password' : 'universal.channel_password';
|
||||
const input = h('input', { type: 'password', id: inputId, class: 'bookmark-secret-value', autocomplete: 'new-password', spellcheck: 'false', maxlength: '255' });
|
||||
const revealIcon = icon('hidden');
|
||||
const reveal = h('button', { type: 'button', class: 'bookmark-secret-action', 'aria-pressed': 'false', 'aria-controls': inputId }, revealIcon);
|
||||
const clear = h('button', { type: 'button', class: 'bookmark-secret-action', 'aria-controls': inputId }, icon('delete'));
|
||||
const note = h('p', { class: 'ts-card-subtitle bookmark-secret-note', role: 'status' });
|
||||
const box = h('div', { class: 'bookmark-secret' }, input, reveal, clear);
|
||||
let known = false;
|
||||
let available = false;
|
||||
let saved = false;
|
||||
let busy = false;
|
||||
let stored = null; // plaintext shown after an explicit Reveal, dropped as soon as it is hidden
|
||||
let shown = false;
|
||||
|
||||
const render = () => {
|
||||
input.disabled = busy || !available;
|
||||
input.type = shown ? 'text' : 'password';
|
||||
input.placeholder = saved ? t('bookmarks.edit.password.saved') : t(placeholderKey);
|
||||
input.setAttribute('aria-label', t(placeholderKey));
|
||||
reveal.disabled = busy || !available || (!saved && !input.value);
|
||||
reveal.setAttribute('aria-pressed', String(shown));
|
||||
for (const button of [reveal, clear]) {
|
||||
const key = button === reveal ? 'universal.input.password.reveal' : 'universal.input.clear';
|
||||
button.title = t(key);
|
||||
button.setAttribute('aria-label', t(key));
|
||||
}
|
||||
clear.disabled = busy || (!saved && !input.value);
|
||||
setIcon(revealIcon, shown ? 'visible' : 'hidden');
|
||||
setText(note, () => (known && !available ? t('bookmarks.edit.password.unavailable') : ''));
|
||||
note.hidden = !(known && !available);
|
||||
};
|
||||
const conceal = () => {
|
||||
if (stored !== null && input.value === stored) input.value = '';
|
||||
stored = null;
|
||||
shown = false;
|
||||
};
|
||||
const fail = (message) => {
|
||||
busy = false;
|
||||
render();
|
||||
toast(() => message, 'error');
|
||||
};
|
||||
/** Saves `value` (empty clears) for the bookmark's current stored address. */
|
||||
const store = async (value) => {
|
||||
const address = findServer(id)?.address;
|
||||
if (busy || (value !== '' && !available) || address === undefined) return;
|
||||
busy = true;
|
||||
render();
|
||||
const result = await bridge(() => tp.setBookmarkPassword(id, address, kind, value));
|
||||
if (!result?.ok) {
|
||||
if (alive()) fail(bridgeError(result));
|
||||
return;
|
||||
}
|
||||
busy = false;
|
||||
if (alive()) {
|
||||
input.value = '';
|
||||
stored = null;
|
||||
shown = false;
|
||||
}
|
||||
onStored(result.prefs);
|
||||
};
|
||||
const commit = () => {
|
||||
if (busy || !available) return;
|
||||
const value = input.value;
|
||||
// Unchanged revealed text is not re-encrypted; an emptied revealed field clears like the official save.
|
||||
if (stored !== null ? value === stored : value === '') return;
|
||||
void store(value);
|
||||
};
|
||||
input.addEventListener('input', render);
|
||||
input.addEventListener('keydown', (event) => {
|
||||
if (event.key === 'Enter') {
|
||||
event.preventDefault();
|
||||
commit();
|
||||
} else if (event.key === 'Escape' && (input.value || shown)) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
input.value = '';
|
||||
stored = null;
|
||||
shown = false;
|
||||
render();
|
||||
}
|
||||
});
|
||||
input.addEventListener('blur', commit);
|
||||
// Pointer use of the actions keeps the caret in the field, so a typed draft is not saved by the blur.
|
||||
for (const button of [reveal, clear]) button.addEventListener('pointerdown', (event) => event.preventDefault());
|
||||
reveal.addEventListener('click', async () => {
|
||||
if (busy) return;
|
||||
if (shown) {
|
||||
if (stored !== null) conceal();
|
||||
else shown = false;
|
||||
render();
|
||||
return;
|
||||
}
|
||||
if (input.value || !saved) {
|
||||
shown = Boolean(input.value);
|
||||
render();
|
||||
return;
|
||||
}
|
||||
const address = findServer(id)?.address;
|
||||
if (address === undefined) return;
|
||||
busy = true;
|
||||
render();
|
||||
const result = await bridge(() => tp.revealBookmarkPassword(id, address, kind));
|
||||
// A late answer for a closed panel or a changed target is discarded with its plaintext.
|
||||
if (!alive()) return;
|
||||
if (findServer(id)?.address !== address) {
|
||||
busy = false;
|
||||
render();
|
||||
return;
|
||||
}
|
||||
if (!result?.ok || typeof result.value !== 'string') {
|
||||
fail(bridgeError(result));
|
||||
return;
|
||||
}
|
||||
busy = false;
|
||||
stored = result.value;
|
||||
input.value = result.value;
|
||||
shown = true;
|
||||
render();
|
||||
});
|
||||
clear.addEventListener('click', () => {
|
||||
if (busy) return;
|
||||
if (saved) {
|
||||
void store('');
|
||||
return;
|
||||
}
|
||||
input.value = '';
|
||||
shown = false;
|
||||
render();
|
||||
input.focus();
|
||||
});
|
||||
render();
|
||||
return {
|
||||
box,
|
||||
note,
|
||||
clearStored: () => (saved ? store('') : undefined),
|
||||
setState(next) {
|
||||
known = true;
|
||||
available = next.available;
|
||||
saved = next.saved;
|
||||
if (!saved || !available) conceal();
|
||||
render();
|
||||
},
|
||||
render,
|
||||
};
|
||||
}
|
||||
|
||||
function editPanel(server) {
|
||||
const id = server.id;
|
||||
const alive = () => editView?.id === id && editView.el === panel && panel.isConnected;
|
||||
const patch = async (fields) => {
|
||||
await commit((state) => B.updateBookmark(state, id, fields));
|
||||
if (alive()) sync();
|
||||
};
|
||||
|
||||
const back = h('button', { class: 'server-item bookmark-folder-item', type: 'button' }, icon('navigation-back'), itemText(t('bookmarks.edit.title'), ''));
|
||||
back.querySelector('.server-item-name').dataset.i18n = 'bookmarks.edit.title';
|
||||
back.addEventListener('click', () => closeEdit());
|
||||
|
||||
// Card 1: name, address, server password.
|
||||
const name = h('input', { type: 'text', maxlength: String(B.NAME_MAX), value: server.name, placeholder: t('bookmarks.edit.name.placeholder'), title: t('bookmarks.edit.name.tooltip'), 'data-i18n-placeholder': 'bookmarks.edit.name.placeholder', 'data-i18n-title': 'bookmarks.edit.name.tooltip', 'aria-label': t('bookmarks.edit.name.placeholder'), 'data-i18n-aria-label': 'bookmarks.edit.name.placeholder', dataset: { field: 'name' } });
|
||||
const address = h('input', { type: 'text', maxlength: '255', value: server.address, spellcheck: 'false', id: 'bookmark-edit-address' });
|
||||
const identity = h('select', { 'data-bookmark-identity': '', id: 'bookmark-edit-identity' });
|
||||
identityOptions(identity, server.identity_id || '');
|
||||
const save = async () => {
|
||||
const address = h('input', { type: 'text', maxlength: String(B.ADDRESS_MAX), value: server.address, spellcheck: 'false', id: 'bookmark-edit-address' });
|
||||
const saveTarget = async () => {
|
||||
const current = findServer(id);
|
||||
if (!current) return;
|
||||
const fields = { name: name.value, address: address.value, identity_id: identity.value };
|
||||
if (fields.name.trim() === current.name && fields.address.trim() === current.address && fields.identity_id === (current.identity_id || '')) return;
|
||||
if (!fields.address.trim()) {
|
||||
if (name.value.trim() === current.name && address.value.trim() === current.address) return;
|
||||
if (!address.value.trim()) {
|
||||
toast(() => t('ui.name.and.address.cannot.be.empty'), 'error');
|
||||
address.value = current.address;
|
||||
return;
|
||||
}
|
||||
await commit((state) => B.updateBookmark(state, id, fields));
|
||||
const stored = findServer(id);
|
||||
if (stored && document.activeElement !== name) name.value = stored.name;
|
||||
// A changed address drops both stored passwords (they are bound to the exact address).
|
||||
await patch({ name: name.value, address: address.value });
|
||||
};
|
||||
for (const input of [name, address]) {
|
||||
input.addEventListener('keydown', (event) => {
|
||||
if (event.key === 'Enter') {
|
||||
event.preventDefault();
|
||||
void save();
|
||||
void saveTarget();
|
||||
}
|
||||
});
|
||||
input.addEventListener('blur', () => { void save(); });
|
||||
input.addEventListener('blur', () => { void saveTarget(); });
|
||||
}
|
||||
identity.addEventListener('change', () => { void save(); });
|
||||
const duplicate = h('button', { type: 'button', class: 'btn btn-ghost bookmark-edit-button' }, icon('item-copy'), h('span', { 'data-i18n': 'bookmarks.action.duplicate', text: t('bookmarks.action.duplicate') }));
|
||||
|
||||
let stateKey = null;
|
||||
let stateRevision = 0;
|
||||
const onStored = (prefs) => {
|
||||
if (prefs) S.prefs = prefs;
|
||||
stateKey = null; // re-read availability and saved flags from main
|
||||
renderServers();
|
||||
};
|
||||
const serverSecret = secretField(id, 'server', 'bookmark-edit-server-password', alive, onStored);
|
||||
const channelSecret = secretField(id, 'channel', 'bookmark-edit-channel-password', alive, onStored);
|
||||
const refreshSecrets = async () => {
|
||||
const revision = ++stateRevision;
|
||||
const result = await bridge(() => tp.getBookmarkPasswordState(id));
|
||||
if (!alive() || revision !== stateRevision) return;
|
||||
const ok = result?.ok === true;
|
||||
const available = ok && result.available === true;
|
||||
serverSecret.setState({ available, saved: ok && result.serverPasswordSaved === true });
|
||||
channelSecret.setState({ available, saved: ok && result.channelPasswordSaved === true });
|
||||
if (!ok) toast(() => bridgeError(result), 'error');
|
||||
};
|
||||
|
||||
// Card 2: identity and nickname override.
|
||||
const identity = h('select', { 'data-bookmark-identity': '', id: 'bookmark-edit-identity' });
|
||||
identityOptions(identity, server.identity_id || '');
|
||||
identity.addEventListener('change', () => { void patch({ identity_id: identity.value }); });
|
||||
const nickname = h('input', { type: 'text', id: 'bookmark-edit-nickname', class: 'bookmark-edit-nickname', maxlength: String(B.NICKNAME_MAX), spellcheck: 'false', placeholder: t('universal.nickname'), 'data-i18n-placeholder': 'universal.nickname' });
|
||||
const warningText = h('span');
|
||||
const warning = h('div', { class: 'bookmark-edit-warning', role: 'alert', hidden: true }, icon('exclamation-triangle'), warningText);
|
||||
const showWarning = (key) => {
|
||||
warning.hidden = key === null;
|
||||
setText(warningText, key === null ? '' : () => t(key));
|
||||
};
|
||||
// Official onEnterNicknameNormal: empty uses the identity's nickname; otherwise 3-30 characters.
|
||||
const saveNickname = () => {
|
||||
const current = findServer(id);
|
||||
if (!current) return;
|
||||
const value = nickname.value.trim();
|
||||
const length = [...value].length;
|
||||
if (value && length > B.NICKNAME_MAX) return showWarning('client.action.rename.error.too_long');
|
||||
if (value && length < B.NICKNAME_MIN) return showWarning('client.action.rename.error.too_short');
|
||||
showWarning(null);
|
||||
if (value !== (current.nickname ?? '')) void patch({ nickname: value });
|
||||
};
|
||||
nickname.addEventListener('keydown', (event) => {
|
||||
if (event.key === 'Enter') {
|
||||
event.preventDefault();
|
||||
saveNickname();
|
||||
}
|
||||
});
|
||||
nickname.addEventListener('blur', saveNickname);
|
||||
|
||||
// Card 3: startup connection (myTeamSpeak and contact sharing need an account and are omitted).
|
||||
const autoConnect = toggleRow('bookmarks.edit.connect_on_startup', 'bookmarks.edit.connect_on_startup.description', (checked) => { void patch({ auto_connect: checked }); });
|
||||
const connectMuted = toggleRow('bookmarks.edit.connect_muted', 'bookmarks.edit.connect_muted.description', (checked) => { void patch({ auto_connect_muted: checked }); });
|
||||
connectMuted.row.classList.add('ts-card-contents-margin-top');
|
||||
|
||||
// Card 4: default channel (typed path, current channel, or a channel dragged from this server's tree).
|
||||
const channel = h('input', { type: 'text', id: 'bookmark-edit-channel', class: 'bookmark-edit-channel', maxlength: String(B.CHANNEL_MAX), spellcheck: 'false', placeholder: t('channel.name'), 'data-i18n-placeholder': 'channel.name' });
|
||||
const saveChannel = () => {
|
||||
const current = findServer(id);
|
||||
if (!current) return;
|
||||
const value = channel.value.trim();
|
||||
if (value !== (current.channel ?? '')) void patch({ channel: value });
|
||||
};
|
||||
channel.addEventListener('keydown', (event) => {
|
||||
if (event.key === 'Enter') {
|
||||
event.preventDefault();
|
||||
saveChannel();
|
||||
}
|
||||
});
|
||||
channel.addEventListener('blur', saveChannel);
|
||||
const insertCurrent = h('button', { type: 'button', class: 'bookmark-secret-action bookmark-channel-current', 'data-i18n-title': 'bookmarks.edit.channel.current', 'data-i18n-aria-label': 'bookmarks.edit.channel.current', title: t('bookmarks.edit.channel.current'), 'aria-label': t('bookmarks.edit.channel.current') }, icon('channel-select-default'));
|
||||
insertCurrent.addEventListener('pointerdown', (event) => event.preventDefault());
|
||||
// Official insert_current_channel: the own channel's path; the stored channel password is reset.
|
||||
insertCurrent.addEventListener('click', async () => {
|
||||
const current = findServer(id);
|
||||
const conn = current && liveConnection(current);
|
||||
const path = conn && B.channelPath(conn.snap.channels, conn.snap.own_channel_id);
|
||||
if (!path) return;
|
||||
channel.value = path;
|
||||
if (path !== (current.channel ?? '')) await patch({ channel: path });
|
||||
if (alive() && findServer(id)?.channel === path) await channelSecret.clearStored();
|
||||
});
|
||||
const channelTarget = h('div', { class: 'bookmark-edit-row ts-option-default-channel' }, h('div', { class: 'bookmark-secret' }, channel, insertCurrent));
|
||||
wireChannelDrop(channelTarget, id, async (path) => {
|
||||
channel.value = path;
|
||||
const current = findServer(id);
|
||||
if (current && path !== (current.channel ?? '')) await patch({ channel: path });
|
||||
});
|
||||
const channelPasswordBlock = h('div', { class: 'bookmark-edit-option' }, captionRow('bookmark-edit-channel-password', 'universal.password', channelSecret.box), channelSecret.note);
|
||||
|
||||
const duplicate = h('button', { type: 'button', class: 'btn btn-ghost bookmark-edit-button' }, icon('item-copy'), h('span', { text: () => t('bookmarks.action.duplicate') }));
|
||||
duplicate.addEventListener('click', async (event) => {
|
||||
event.stopPropagation();
|
||||
// Official cloneBookmark: an identical copy, then the panel closes.
|
||||
// Official cloneBookmark: an identical copy (options and stored passwords included), then the panel closes.
|
||||
const copy = await duplicateItem(id, '');
|
||||
if (copy) {
|
||||
editPanelId = null;
|
||||
@@ -779,7 +1066,7 @@ function editPanel(server) {
|
||||
focusRow(copy);
|
||||
}
|
||||
});
|
||||
const remove = h('button', { type: 'button', class: 'btn btn-ghost bookmark-edit-button is-destructive' }, icon('item-close'), h('span', { 'data-i18n': 'universal.remove', text: t('universal.remove') }));
|
||||
const remove = h('button', { type: 'button', class: 'btn btn-ghost bookmark-edit-button is-destructive' }, icon('item-close'), h('span', { text: () => t('universal.remove') }));
|
||||
remove.addEventListener('click', (event) => {
|
||||
event.stopPropagation();
|
||||
const current = findServer(id);
|
||||
@@ -788,13 +1075,21 @@ function editPanel(server) {
|
||||
// The panel closes by itself once the bookmark is gone; a failed delete keeps it open.
|
||||
confirmPopup(id, { x: rect.left, y: rect.bottom }, t('bookmarks.warning.delete', { name: current.name }), () => deleteItem(id), remove);
|
||||
});
|
||||
|
||||
const channelCaption = h('label', { for: 'bookmark-edit-channel', class: 'bookmark-edit-caption', text: () => t('universal.default.channel') });
|
||||
const panel = h('div', { id: 'bookmark-edit-panel', class: 'bookmark-edit-panel', dataset: { id } },
|
||||
h('ul', { class: 'servers-list' }, h('li', { class: 'bookmark-back' }, back)),
|
||||
h('div', { class: 'bookmark-edit-card' },
|
||||
h('div', { class: 'bookmark-edit-row bookmark-edit-name' }, icon('server'), name),
|
||||
h('div', { class: 'bookmark-edit-row' }, h('label', { for: 'bookmark-edit-address', 'data-i18n': 'universal.address', text: t('universal.address') }), address)),
|
||||
captionRow('bookmark-edit-address', 'universal.address', address),
|
||||
captionRow('bookmark-edit-server-password', 'universal.password', serverSecret.box),
|
||||
serverSecret.note),
|
||||
h('div', { class: 'bookmark-edit-card' },
|
||||
h('div', { class: 'bookmark-edit-row' }, h('label', { for: 'bookmark-edit-identity', 'data-i18n': 'ui.identity', text: t('ui.identity') }), identity)),
|
||||
captionRow('bookmark-edit-identity', 'ui.identity', identity),
|
||||
captionRow('bookmark-edit-nickname', 'universal.nickname', nickname),
|
||||
warning),
|
||||
h('div', { class: 'bookmark-edit-card' }, autoConnect.row, connectMuted.row),
|
||||
h('div', { class: 'bookmark-edit-card' }, channelCaption, channelTarget, channelPasswordBlock),
|
||||
h('div', { class: 'bookmark-edit-row' }, duplicate),
|
||||
h('div', { class: 'bookmark-edit-row' }, remove));
|
||||
panel.addEventListener('keydown', (event) => {
|
||||
@@ -803,7 +1098,98 @@ function editPanel(server) {
|
||||
closeEdit();
|
||||
}
|
||||
});
|
||||
return panel;
|
||||
|
||||
/** Mirrors the stored bookmark into every control the user is not editing. */
|
||||
function sync() {
|
||||
const current = findServer(id);
|
||||
if (!current) return;
|
||||
const idle = (input) => document.activeElement !== input;
|
||||
if (idle(name)) name.value = current.name;
|
||||
if (idle(address)) address.value = current.address;
|
||||
if (idle(identity)) identityOptions(identity, current.identity_id || '');
|
||||
if (idle(nickname)) nickname.value = current.nickname ?? '';
|
||||
if (idle(channel)) channel.value = current.channel ?? '';
|
||||
autoConnect.input.checked = current.auto_connect === true;
|
||||
connectMuted.input.checked = current.auto_connect_muted === true;
|
||||
// Official: the muted option is offered only while Connect on Startup is on.
|
||||
connectMuted.row.hidden = current.auto_connect !== true;
|
||||
// Official: the channel password row appears once a default channel is set.
|
||||
const hasChannel = Boolean(current.channel);
|
||||
channelPasswordBlock.hidden = !hasChannel;
|
||||
const conn = liveConnection(current);
|
||||
insertCurrent.hidden = !conn || !B.channelPath(conn.snap.channels, conn.snap.own_channel_id);
|
||||
channelTarget.classList.toggle('ts-drag-target-area', hasServerAt(current));
|
||||
serverSecret.render();
|
||||
channelSecret.render();
|
||||
// Stored passwords are bound to the address; any change in target or ciphertext re-reads the state.
|
||||
const key = `${current.address}\n${Boolean(current.server_password_encrypted)}\n${Boolean(current.channel_password_encrypted)}`;
|
||||
if (key !== stateKey) {
|
||||
stateKey = key;
|
||||
void refreshSecrets();
|
||||
}
|
||||
}
|
||||
|
||||
return { id, el: panel, sync };
|
||||
}
|
||||
|
||||
/** Connected connection (with a snapshot) to this bookmark's server, like the official bookmark connection. */
|
||||
function liveConnection(server) {
|
||||
const conn = connectedTo(server);
|
||||
return conn?.conn.state === 'connected' && conn.snap ? conn : null;
|
||||
}
|
||||
|
||||
const CHANNEL_DRAG_TYPES = ['x-ts-channel-id', 'x-ts-connection-id', 'x-ts-session', 'x-ts-server-uid'];
|
||||
|
||||
/** Drag data is unreadable before the drop, so hovering only needs a connected server at this address. */
|
||||
function hasServerAt(server) {
|
||||
return connectionList().some((conn) => conn.conn.state === 'connected' && conn.snap && sameAddress(server.address, conn.conn.address || ''));
|
||||
}
|
||||
|
||||
/**
|
||||
* Official dragenter/dropDefaultChannel: a channel dragged from the tree of a server that matches this
|
||||
* bookmark becomes its default channel. The dragged data only names the channel; the connection must still be
|
||||
* the same session of the same virtual server at the bookmark's address, and the path is derived from that
|
||||
* connection's current snapshot. Anything stale or mismatched is ignored.
|
||||
*/
|
||||
function wireChannelDrop(target, bookmarkId, onChannel) {
|
||||
const isChannelDrag = (event) => CHANNEL_DRAG_TYPES.every((type) => event.dataTransfer.types.includes(type));
|
||||
const highlight = (on) => target.classList.toggle('ts-drag-target-area-active', on);
|
||||
const accepts = (event) => {
|
||||
const server = findServer(bookmarkId);
|
||||
return Boolean(server && hasServerAt(server) && isChannelDrag(event));
|
||||
};
|
||||
for (const type of ['dragenter', 'dragover']) {
|
||||
target.addEventListener(type, (event) => {
|
||||
if (!accepts(event)) return;
|
||||
event.preventDefault();
|
||||
event.dataTransfer.dropEffect = 'copy';
|
||||
highlight(true);
|
||||
});
|
||||
}
|
||||
target.addEventListener('dragleave', (event) => {
|
||||
if (!target.contains(event.relatedTarget)) highlight(false);
|
||||
});
|
||||
target.addEventListener('drop', (event) => {
|
||||
highlight(false);
|
||||
if (!isChannelDrag(event)) return;
|
||||
event.preventDefault();
|
||||
const data = Object.fromEntries(CHANNEL_DRAG_TYPES.map((type) => [type, event.dataTransfer.getData(type)]));
|
||||
const path = droppedChannelPath(findServer(bookmarkId), data);
|
||||
if (path) void onChannel(path);
|
||||
});
|
||||
}
|
||||
|
||||
function droppedChannelPath(server, data) {
|
||||
if (!server || !/^\d{1,16}$/.test(data['x-ts-channel-id']) || !/^\d{1,16}$/.test(data['x-ts-session'])) return null;
|
||||
const channelId = Number(data['x-ts-channel-id']);
|
||||
if (!Number.isSafeInteger(channelId) || channelId <= 0) return null;
|
||||
const conn = connectionList().find((entry) => String(entry.id) === data['x-ts-connection-id']);
|
||||
if (!conn || !isAlive(conn) || conn.conn.state !== 'connected' || !conn.snap) return null;
|
||||
if (String(conn.session) !== data['x-ts-session']) return null;
|
||||
const uid = conn.snap.server?.uid;
|
||||
if (typeof uid !== 'string' || !uid || uid !== data['x-ts-server-uid']) return null;
|
||||
if (!sameAddress(server.address, conn.conn.address || '')) return null;
|
||||
return B.channelPath(conn.snap.channels, channelId);
|
||||
}
|
||||
|
||||
// ---------- Settings → Servers manager ----------
|
||||
|
||||
+15
-1
@@ -126,7 +126,7 @@ function updateRow(el, item) {
|
||||
function createChannelRow() {
|
||||
const btn = h(
|
||||
'button',
|
||||
{ class: 'row-btn', type: 'button' },
|
||||
{ class: 'row-btn', type: 'button', draggable: true },
|
||||
icon('channel'),
|
||||
h('span', { class: 'row-label' }),
|
||||
h('span', { class: 'channel-preview', 'aria-hidden': 'true', hidden: true }),
|
||||
@@ -135,6 +135,20 @@ function createChannelRow() {
|
||||
);
|
||||
const collapse = h('button', { class: 'channel-collapse', type: 'button' }, icon('chevron-down'));
|
||||
const li = h('li', { class: 'tree-row channel-row' }, btn, collapse);
|
||||
btn.addEventListener('dragstart', (event) => {
|
||||
const conn = viewedConnection();
|
||||
const cid = Number(li.dataset.cid);
|
||||
const serverUid = conn?.snap?.server?.uid;
|
||||
if (!event.dataTransfer || !isConnected(conn) || !serverUid || !conn.snap.channels.some(channel => channel.id === cid)) {
|
||||
event.preventDefault();
|
||||
return;
|
||||
}
|
||||
event.dataTransfer.effectAllowed = 'copy';
|
||||
event.dataTransfer.setData('x-ts-channel-id', String(cid));
|
||||
event.dataTransfer.setData('x-ts-connection-id', conn.id);
|
||||
event.dataTransfer.setData('x-ts-server-uid', serverUid);
|
||||
event.dataTransfer.setData('x-ts-session', String(conn.session));
|
||||
});
|
||||
collapse.addEventListener('click', () => {
|
||||
if (!isConnected()) return;
|
||||
const cid = Number(li.dataset.cid);
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
// Local bookmark hierarchy shared by main (validation of persisted prefs) and the renderer (sidebar workflows).
|
||||
// State: { savedServers, bookmarkFolders, bookmarkOrder }.
|
||||
// - savedServers: bookmarks; optional `folder` names the containing folder (absent = root).
|
||||
// - savedServers: bookmarks; optional `folder` names the containing folder (absent = root). Optional
|
||||
// connect options (official ts-edit-bookmark): `identity_id`, `nickname` (override of the identity's
|
||||
// nickname), `channel` (initial channel path or "cid:<n>"), `auto_connect`, `auto_connect_muted` (startup
|
||||
// only, microphone only) and the main-owned OS-encrypted `server_password_encrypted` /
|
||||
// `channel_password_encrypted`. Absent keys keep the default behaviour; plaintext passwords never live here.
|
||||
// - bookmarkFolders: { id, name, parent? }; `name` may be empty (shown as the official "Unnamed Folder").
|
||||
// - bookmarkOrder: every bookmark and folder id exactly once. A container lists its items in this order, so
|
||||
// folders and bookmarks interleave like the official sort_order chain.
|
||||
@@ -12,8 +16,22 @@
|
||||
const MAX_FOLDERS = 50;
|
||||
const MAX_FOLDER_DEPTH = 8;
|
||||
const NAME_MAX = 64;
|
||||
const ADDRESS_MAX = 255;
|
||||
// Official client.action.rename bounds (too_short < 3, nicknameMaxLength 30); the core applies the same rule.
|
||||
const NICKNAME_MIN = 3;
|
||||
const NICKNAME_MAX = 30;
|
||||
// The connect bridge accepts channel paths of 1-512 characters.
|
||||
const CHANNEL_MAX = 512;
|
||||
// Opaque base64 ciphertext produced by main's OS-backed secret storage.
|
||||
const SECRET_MAX = 8192;
|
||||
const SECRET_KEYS = Object.freeze(['server_password_encrypted', 'channel_password_encrypted']);
|
||||
const BOOKMARK_KEYS = Object.freeze(['id', 'name', 'address', 'identity_id', 'folder', 'nickname', 'channel', 'auto_connect', 'auto_connect_muted', ...SECRET_KEYS]);
|
||||
const ID = /^[a-z0-9]{6,32}$/;
|
||||
const IDENTITY = /^[A-Za-z0-9+/]{27}=$/;
|
||||
const BASE64 = /^[A-Za-z0-9+/]+={0,2}$/;
|
||||
const CONTROL = /[\u0000-\u001f\u007f]/;
|
||||
// Rust char::is_control (the core's nickname check) also covers the C1 range.
|
||||
const NICK_CONTROL = /[\u0000-\u001f\u007f-\u009f]/;
|
||||
|
||||
function fail(code) {
|
||||
const error = new Error(`bookmarks: ${code}`);
|
||||
@@ -23,6 +41,47 @@
|
||||
|
||||
const isRecord = (value) => Boolean(value) && typeof value === 'object' && !Array.isArray(value);
|
||||
const validName = (name, allowEmpty) => typeof name === 'string' && name.length <= NAME_MAX && !CONTROL.test(name) && (allowEmpty || name.trim().length > 0);
|
||||
const validAddress = (address) => typeof address === 'string' && address.trim().length > 0 && address.length <= ADDRESS_MAX && !CONTROL.test(address);
|
||||
|
||||
/** Stored nickname override: already trimmed, 3-30 characters (code points), no control characters. */
|
||||
function validNickname(value) {
|
||||
if (typeof value !== 'string' || value !== value.trim() || NICK_CONTROL.test(value)) return false;
|
||||
const length = [...value].length;
|
||||
return length >= NICKNAME_MIN && length <= NICKNAME_MAX;
|
||||
}
|
||||
|
||||
/** Stored initial channel: trimmed, 1-512 characters, no control characters. */
|
||||
const validChannel = (value) => typeof value === 'string' && value.length > 0 && value.length <= CHANNEL_MAX && value === value.trim() && !CONTROL.test(value);
|
||||
|
||||
/** Opaque ciphertext: canonical base64, at most SECRET_MAX ASCII characters. */
|
||||
const validSecret = (value) => typeof value === 'string' && value.length >= 4 && value.length <= SECRET_MAX && value.length % 4 === 0 && BASE64.test(value);
|
||||
|
||||
/** One stored bookmark with only known keys of the right shape. */
|
||||
function validBookmark(entry) {
|
||||
if (!isRecord(entry)) return false;
|
||||
const keys = Object.keys(entry);
|
||||
if (!keys.includes('id') || !keys.includes('name') || !keys.includes('address') || keys.some((key) => !BOOKMARK_KEYS.includes(key))) return false;
|
||||
if (typeof entry.id !== 'string' || !ID.test(entry.id)) return false;
|
||||
if (!validName(entry.name, false) || !validAddress(entry.address)) return false;
|
||||
if (entry.identity_id !== undefined && (typeof entry.identity_id !== 'string' || !IDENTITY.test(entry.identity_id))) return false;
|
||||
if (entry.folder !== undefined && (typeof entry.folder !== 'string' || !ID.test(entry.folder))) return false;
|
||||
if (entry.nickname !== undefined && !validNickname(entry.nickname)) return false;
|
||||
if (entry.channel !== undefined && !validChannel(entry.channel)) return false;
|
||||
if (entry.auto_connect !== undefined && typeof entry.auto_connect !== 'boolean') return false;
|
||||
if (entry.auto_connect_muted !== undefined && typeof entry.auto_connect_muted !== 'boolean') return false;
|
||||
return SECRET_KEYS.every((key) => entry[key] === undefined || validSecret(entry[key]));
|
||||
}
|
||||
|
||||
/** Shape of the bookmark list alone (count, entries, unique ids); references are checked by `consistent`. */
|
||||
function validServers(list) {
|
||||
if (!Array.isArray(list) || list.length > MAX_BOOKMARKS) return false;
|
||||
const ids = new Set();
|
||||
for (const entry of list) {
|
||||
if (!validBookmark(entry) || ids.has(entry.id)) return false;
|
||||
ids.add(entry.id);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Shape of the folder list alone; references are checked by `consistent`. */
|
||||
function validFolders(list) {
|
||||
@@ -192,26 +251,87 @@
|
||||
return trimmed;
|
||||
}
|
||||
|
||||
function cleanAddress(address) {
|
||||
const trimmed = typeof address === 'string' ? address.trim() : '';
|
||||
if (!validAddress(trimmed)) throw fail('address');
|
||||
return trimmed;
|
||||
}
|
||||
|
||||
/** Stored key order (BOOKMARK_KEYS); absent and undefined values are omitted. */
|
||||
function bookmarkEntry(fields) {
|
||||
const entry = {};
|
||||
for (const key of BOOKMARK_KEYS) if (fields[key] !== undefined) entry[key] = fields[key];
|
||||
return entry;
|
||||
}
|
||||
|
||||
function addBookmark(state, bookmark, folderId = null) {
|
||||
if (state.savedServers.length >= MAX_BOOKMARKS) throw fail('bookmark-limit');
|
||||
requireFreshId(state, bookmark.id);
|
||||
requireFolder(state, folderId);
|
||||
const address = typeof bookmark.address === 'string' ? bookmark.address.trim() : '';
|
||||
if (!address || address.length > 255 || CONTROL.test(address)) throw fail('address');
|
||||
const address = cleanAddress(bookmark.address);
|
||||
const name = cleanName(bookmark.name ?? '') || address.slice(0, NAME_MAX);
|
||||
const entry = { id: bookmark.id, name, address, ...(bookmark.identity_id ? { identity_id: bookmark.identity_id } : {}), ...(folderId ? { folder: folderId } : {}) };
|
||||
const entry = bookmarkEntry({ id: bookmark.id, name, address, identity_id: bookmark.identity_id || undefined, folder: folderId || undefined });
|
||||
return { ...state, savedServers: [...state.savedServers, entry], bookmarkOrder: [...state.bookmarkOrder, entry.id] };
|
||||
}
|
||||
|
||||
/** Replaces name/address/identity; the bookmark keeps its id, folder and position. */
|
||||
function updateBookmark(state, id, { name, address, identity_id }) {
|
||||
/** Trimmed nickname override; '' clears it. Codes follow the official rename warnings. */
|
||||
function cleanNickname(value) {
|
||||
if (typeof value !== 'string') throw fail('nickname');
|
||||
const trimmed = value.trim();
|
||||
if (!trimmed) return undefined;
|
||||
const length = [...trimmed].length;
|
||||
if (length < NICKNAME_MIN) throw fail('nickname-short');
|
||||
if (length > NICKNAME_MAX) throw fail('nickname-long');
|
||||
if (!validNickname(trimmed)) throw fail('nickname');
|
||||
return trimmed;
|
||||
}
|
||||
|
||||
function cleanChannel(value) {
|
||||
if (typeof value !== 'string') throw fail('channel');
|
||||
const trimmed = value.trim();
|
||||
if (!trimmed) return undefined;
|
||||
if (!validChannel(trimmed)) throw fail('channel');
|
||||
return trimmed;
|
||||
}
|
||||
|
||||
function cleanFlag(value) {
|
||||
if (typeof value !== 'boolean') throw fail('flag');
|
||||
return value || undefined;
|
||||
}
|
||||
|
||||
const EDITABLE = {
|
||||
name: null, // resolved against the final address below
|
||||
address: cleanAddress,
|
||||
identity_id: (value) => {
|
||||
if (value === '' || value === undefined || value === null) return undefined;
|
||||
if (typeof value !== 'string' || !IDENTITY.test(value)) throw fail('identity');
|
||||
return value;
|
||||
},
|
||||
nickname: cleanNickname,
|
||||
channel: cleanChannel,
|
||||
auto_connect: cleanFlag,
|
||||
auto_connect_muted: cleanFlag,
|
||||
};
|
||||
|
||||
/**
|
||||
* Applies an editor patch (any of name, address, identity_id, nickname, channel, auto_connect,
|
||||
* auto_connect_muted); fields not in the patch stay as stored, '' / false clear an option. The bookmark keeps
|
||||
* its id, folder and position. Stored ciphertext is bound to the exact address, so a changed address drops
|
||||
* both encrypted passwords; they can never be set here.
|
||||
*/
|
||||
function updateBookmark(state, id, patch) {
|
||||
const current = state.savedServers.find((server) => server.id === id);
|
||||
if (!current) throw fail('missing');
|
||||
const cleanAddress = typeof address === 'string' ? address.trim() : '';
|
||||
if (!cleanAddress || cleanAddress.length > 255 || CONTROL.test(cleanAddress)) throw fail('address');
|
||||
const cleaned = cleanName(name ?? '') || cleanAddress.slice(0, NAME_MAX);
|
||||
const next = { id, name: cleaned, address: cleanAddress, ...(identity_id ? { identity_id } : {}), ...(current.folder ? { folder: current.folder } : {}) };
|
||||
return { ...state, savedServers: state.savedServers.map((server) => (server.id === id ? next : server)) };
|
||||
if (!isRecord(patch)) throw fail('field');
|
||||
const next = { ...current };
|
||||
for (const [key, value] of Object.entries(patch)) {
|
||||
if (!Object.hasOwn(EDITABLE, key)) throw fail('field');
|
||||
if (key !== 'name') next[key] = EDITABLE[key](value);
|
||||
}
|
||||
if (Object.hasOwn(patch, 'name')) next.name = cleanName(patch.name ?? '') || next.address.slice(0, NAME_MAX);
|
||||
if (next.address !== current.address) for (const key of SECRET_KEYS) delete next[key];
|
||||
const entry = bookmarkEntry(next);
|
||||
return { ...state, savedServers: state.savedServers.map((server) => (server.id === id ? entry : server)) };
|
||||
}
|
||||
|
||||
function createFolder(state, { id, name }, parentId = null) {
|
||||
@@ -315,10 +435,30 @@
|
||||
return contents(state, folderId).flatMap((entry) => (entry.kind === 'bookmark' ? [entry.item] : allBookmarks(state, entry.item.id)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Official insert_current_channel / dropDefaultChannel: the channel's name prefixed by its parents' names,
|
||||
* joined with "/" (root first). `channels` are snapshot entries { id, parent_id, name }; null when the
|
||||
* channel is unknown, a parent is missing or the path does not fit a stored channel.
|
||||
*/
|
||||
function channelPath(channels, channelId) {
|
||||
const byId = new Map(channels.map((channel) => [channel.id, channel]));
|
||||
const names = [];
|
||||
const seen = new Set();
|
||||
for (let current = byId.get(channelId); current; current = current.parent_id ? byId.get(current.parent_id) : null) {
|
||||
if (seen.has(current.id)) return null;
|
||||
seen.add(current.id);
|
||||
names.unshift(current.name);
|
||||
if (current.parent_id && !byId.has(current.parent_id)) return null;
|
||||
}
|
||||
if (!names.length) return null;
|
||||
const path = names.join('/');
|
||||
return validChannel(path) ? path : null;
|
||||
}
|
||||
|
||||
const api = Object.freeze({
|
||||
MAX_BOOKMARKS, MAX_FOLDERS, MAX_FOLDER_DEPTH, NAME_MAX, ID,
|
||||
validFolders, validOrder, consistent, normalize, completeOrder,
|
||||
contents, descendants, parentOf, nextSibling, allBookmarks,
|
||||
MAX_BOOKMARKS, MAX_FOLDERS, MAX_FOLDER_DEPTH, NAME_MAX, ADDRESS_MAX, NICKNAME_MIN, NICKNAME_MAX, CHANNEL_MAX, SECRET_MAX, SECRET_KEYS, ID,
|
||||
validServers, validBookmark, validNickname, validChannel, validSecret, validFolders, validOrder, consistent, normalize, completeOrder,
|
||||
contents, descendants, parentOf, nextSibling, allBookmarks, channelPath,
|
||||
addBookmark, updateBookmark, createFolder, rename, move, duplicate, remove,
|
||||
});
|
||||
if (typeof module === 'object' && module.exports) module.exports = api;
|
||||
|
||||
@@ -100,7 +100,7 @@
|
||||
"ui.name": "Name",
|
||||
"ui.address": "Address",
|
||||
"ui.add": "Add",
|
||||
"ui.only.the.name.and.address.are.saved": "Bookmarks save a name, address and optional local identity. Server passwords are never stored; you will be asked when connecting.",
|
||||
"bookmarks.settings.storage.info": "Use the sidebar bookmark editor for nickname overrides, initial channels, startup options and encrypted passwords. Saving passwords requires secure OS storage.",
|
||||
"ui.theme": "Theme",
|
||||
"ui.color.theme": "Color theme",
|
||||
"ui.system": "System",
|
||||
@@ -127,7 +127,7 @@
|
||||
"ui.current.reception": "Current reception",
|
||||
"ui.receive.codecs.reported.by.the.engine": "Receive codecs reported by the engine",
|
||||
"ui.unavailable.settings": "Unavailable settings",
|
||||
"ui.unlike.teamspeak.6.there.is.no.cisco": "Unlike TeamSpeak 6, there is no Cisco OpenH264 toggle or manual hardware backend selection (NVENC, AMF, QSV, etc.). TeamsPeach receives video through Chromium WebRTC, which has no decoder-selection API. Chromium decodes H.264 through FFmpeg; OpenH264 is only an encoder, and sending your own screen is not implemented in TeamsPeach.",
|
||||
"ui.unlike.teamspeak.6.there.is.no.cisco": "TeamsPeach does not expose a Cisco OpenH264 toggle or individual hardware backend settings (NVENC, AMF, QSV, etc.). Chromium selects the WebRTC encoder and decoder within the enabled hardware policy.",
|
||||
"ui.voice.transmission": "Voice transmission",
|
||||
"ui.transmission.mode": "Transmission mode",
|
||||
"ui.push.to.talk": "Push to talk",
|
||||
@@ -2158,6 +2158,23 @@
|
||||
"whisper.serverUid": "Target server UID",
|
||||
"whisper.groupId": "Target group ID",
|
||||
"settings.hotkey.title": "Key Bindings",
|
||||
"universal.input.password.reveal": "Reveal Password",
|
||||
"universal.input.clear": "Clear Input",
|
||||
"server.password": "Server Password",
|
||||
"universal.channel_password": "Channel Password",
|
||||
"universal.password": "Password",
|
||||
"universal.default.channel": "Default Channel",
|
||||
"channel.name": "Channel Name",
|
||||
"universal.nickname": "Nickname",
|
||||
"client.action.rename.error.too_short": "Nickname is too short",
|
||||
"client.action.rename.error.too_long": "Nickname is too long",
|
||||
"bookmarks.edit.connect_on_startup": "Connect on Startup",
|
||||
"bookmarks.edit.connect_on_startup.description": "Automatically connect to this server when TeamsPeach starts",
|
||||
"bookmarks.edit.connect_muted": "Connect on Startup Muted",
|
||||
"bookmarks.edit.connect_muted.description": "When auto-connecting, ensures the microphone is muted",
|
||||
"bookmarks.edit.password.saved": "Password saved",
|
||||
"bookmarks.edit.password.unavailable": "Secure password storage is not available on this system, so passwords cannot be saved",
|
||||
"bookmarks.edit.channel.current": "Use Current Channel",
|
||||
"server.icons.storage_unsupported": "This server stores icons in HTTP/S3 storage, which is not supported"
|
||||
});
|
||||
if (typeof module === 'object' && module.exports) module.exports = messages;
|
||||
|
||||
@@ -100,7 +100,7 @@
|
||||
"ui.name": "Название",
|
||||
"ui.address": "Адрес",
|
||||
"ui.add": "Добавить",
|
||||
"ui.only.the.name.and.address.are.saved": "Закладки сохраняют имя, адрес и выбранную локальную идентичность. Пароли серверов не сохраняются: при подключении появится запрос.",
|
||||
"bookmarks.settings.storage.info": "Ник, начальный канал, автоподключение и зашифрованные пароли настраиваются в редакторе закладки в боковой панели. Для сохранения паролей требуется защищённое хранилище ОС.",
|
||||
"ui.theme": "Тема",
|
||||
"ui.color.theme": "Тема оформления",
|
||||
"ui.system": "Как в системе",
|
||||
@@ -127,7 +127,7 @@
|
||||
"ui.current.reception": "Текущий приём",
|
||||
"ui.receive.codecs.reported.by.the.engine": "Кодеки приёма, объявленные движком",
|
||||
"ui.unavailable.settings": "Недоступные настройки",
|
||||
"ui.unlike.teamspeak.6.there.is.no.cisco": "Переключателя Cisco OpenH264 и ручного выбора аппаратных бэкендов (NVENC, AMF, QSV и др.), как в TeamSpeak 6, здесь нет: TeamsPeach принимает видео через WebRTC движка Chromium, у которого нет API выбора декодера. H.264 Chromium декодирует через FFmpeg — OpenH264 в нём служит только кодировщиком, а кодирование (отправка своего экрана) в TeamsPeach не реализовано.",
|
||||
"ui.unlike.teamspeak.6.there.is.no.cisco": "В TeamsPeach нет отдельного переключателя Cisco OpenH264 и настроек конкретных аппаратных бэкендов (NVENC, AMF, QSV и др.). Кодировщик и декодер WebRTC выбирает Chromium с учётом разрешённого аппаратного ускорения.",
|
||||
"ui.voice.transmission": "Передача голоса",
|
||||
"ui.transmission.mode": "Режим передачи",
|
||||
"ui.push.to.talk": "Нажми и говори",
|
||||
@@ -2160,6 +2160,23 @@
|
||||
"whisper.serverUid": "UID целевого сервера",
|
||||
"whisper.groupId": "ID целевой группы",
|
||||
"settings.hotkey.title": "Привязки клавиш",
|
||||
"universal.input.password.reveal": "Показать пароль",
|
||||
"universal.input.clear": "Очистить поле ввода",
|
||||
"server.password": "Пароль сервера",
|
||||
"universal.channel_password": "Пароль канала",
|
||||
"universal.password": "Пароль",
|
||||
"universal.default.channel": "Исходный канал",
|
||||
"channel.name": "Название канала",
|
||||
"universal.nickname": "Ник",
|
||||
"client.action.rename.error.too_short": "Никнейм слишком короткий",
|
||||
"client.action.rename.error.too_long": "Никнейм слишком длинный",
|
||||
"bookmarks.edit.connect_on_startup": "Подключаться при запуске",
|
||||
"bookmarks.edit.connect_on_startup.description": "Автоматически подключаться к серверу при запуске TeamsPeach",
|
||||
"bookmarks.edit.connect_muted": "Подключаться при запуске с отключенным микрофоном",
|
||||
"bookmarks.edit.connect_muted.description": "При автоматическом подключении микрофон будет отключен",
|
||||
"bookmarks.edit.password.saved": "Пароль сохранён",
|
||||
"bookmarks.edit.password.unavailable": "Защищённое хранилище паролей недоступно в этой системе, поэтому пароли нельзя сохранить",
|
||||
"bookmarks.edit.channel.current": "Использовать текущий канал",
|
||||
"server.icons.storage_unsupported": "Сервер хранит значки в HTTP/S3-хранилище, которое пока не поддерживается"
|
||||
});
|
||||
if (typeof module === 'object' && module.exports) module.exports = messages;
|
||||
|
||||
@@ -684,6 +684,32 @@ body.is-resizing[data-resize-axis="y"], body.is-resizing[data-resize-axis="y"] *
|
||||
.bookmark-edit-button.is-destructive { border-color: var(--tsv-error-color); color: var(--tsv-error-color); }
|
||||
.bookmark-edit-button.is-destructive:hover:not(:disabled) { border-color: var(--tsv-error-light-color); color: var(--tsv-error-light-color); }
|
||||
.bookmark-edit-button .icon { width: var(--tsv-icon-size); height: var(--tsv-icon-size); }
|
||||
/* options (ts-option-row caption min-width 65px; ts-toggle + ts-card-subtitle; .ts-card-contents-margin-top) */
|
||||
.bookmark-edit-row > label, .bookmark-edit-caption { min-width: 65px; }
|
||||
.bookmark-edit-caption { display: block; padding-top: var(--tsv-padding-v-small, 4px); color: var(--tsv-font-subtitle-color); }
|
||||
.bookmark-edit-nickname { text-align: right; }
|
||||
.bookmark-edit-option[hidden], .bookmark-edit-warning[hidden], .bookmark-secret-note[hidden], .bookmark-secret-action[hidden] { display: none; }
|
||||
.bookmark-edit-option.ts-card-contents-margin-top { margin-top: var(--tsv-padding-v); }
|
||||
.bookmark-edit-toggle { display: flex; align-items: center; justify-content: space-between; min-height: var(--tsv-bar-element-height); gap: var(--tsv-padding-h-small); cursor: pointer; user-select: none; }
|
||||
.bookmark-edit-toggle > .ts-toggle-label { flex: 1 1 auto; min-width: 0; color: var(--tsv-font-color); }
|
||||
.bookmark-edit-panel .ts-card-subtitle { margin: 0; color: var(--tsv-font-subtitle-color); font-size: var(--tsv-font-size-small); overflow-wrap: anywhere; }
|
||||
/* ts-text-input-box-warning: #db5959, 12px, exclamation icon 14px with 8px gap, 5px vertical margin */
|
||||
.bookmark-edit-warning { display: flex; align-items: center; gap: 8px; margin: 5px 0; color: #db5959; font-size: 12px; overflow-wrap: anywhere; }
|
||||
.bookmark-edit-warning > .icon { flex: none; width: 14px; height: 14px; }
|
||||
/* password / channel input with trailing actions (ts-text-input-box-reveal, -delete, -accept) */
|
||||
.bookmark-secret { position: relative; display: flex; flex: 1; align-items: center; min-width: 0; }
|
||||
.bookmark-secret > input { flex: 1; min-width: 0; padding-right: 55px; }
|
||||
.bookmark-secret > input.bookmark-edit-channel { padding-right: calc(var(--tsv-icon-size) + 10px); }
|
||||
.bookmark-secret-action { position: absolute; top: 0; bottom: 0; right: var(--tsv-padding-h-minimal); display: flex; align-items: center; justify-content: center; width: 24px; padding: 0; border: 0; background: transparent; color: var(--ts-menu-action-color, var(--tsv-font-subtitle-color)); cursor: pointer; }
|
||||
.bookmark-secret > .bookmark-secret-action:nth-of-type(1):not(.bookmark-channel-current) { right: calc(var(--tsv-padding-h-minimal) + 24px); }
|
||||
.bookmark-secret-action:hover:not(:disabled) { color: var(--tsv-tint); }
|
||||
.bookmark-secret-action[aria-pressed="true"] { color: var(--tsv-tint); }
|
||||
.bookmark-secret-action:disabled { opacity: .4; cursor: default; }
|
||||
.bookmark-secret-action:focus-visible { outline: 2px solid var(--tsv-tint); outline-offset: -2px; border-radius: var(--tsv-border-radius); }
|
||||
.bookmark-secret-action .icon { width: var(--tsv-icon-size); height: var(--tsv-icon-size); }
|
||||
/* default channel drop target (.ts-drag-target-area: dashed subtitle border, tint while a channel hovers) */
|
||||
.bookmark-edit-row.ts-drag-target-area { padding: 0 var(--tsv-padding-h-minimal); border: 2px dashed var(--tsv-font-subtitle-color); border-radius: var(--tsv-border-radius-large); }
|
||||
.bookmark-edit-row.ts-drag-target-area.ts-drag-target-area-active { border-color: var(--tsv-tint); }
|
||||
|
||||
/* footer self bar: 55px, 3px separator inset 20px (theme @11881–13578) */
|
||||
.self {
|
||||
|
||||
Reference in new issue
Block a user