From ade6269de9eccee0fc2c2b973f13c375573809d8 Mon Sep 17 00:00:00 2001 From: Max Leiter Date: Tue, 31 May 2022 14:42:00 -0700 Subject: [PATCH] Add more socketio types --- client/components/ChatUserList.vue | 2 +- client/components/MessageSearchForm.vue | 4 +- client/components/RoutedChat.vue | 4 +- client/components/Windows/NetworkEdit.vue | 9 ++- client/components/Windows/SearchResults.vue | 2 +- client/js/autocompletion.ts | 12 +-- client/js/helpers/contextMenu.ts | 4 +- client/js/socket-events/auth.ts | 16 ++-- client/js/socket-events/connection.ts | 2 +- client/js/socket-events/history_clear.ts | 14 ++-- client/js/socket-events/init.ts | 43 +++++------ client/js/socket-events/join.ts | 9 ++- client/js/socket-events/msg.ts | 34 ++++++--- client/js/socket-events/msg_preview.ts | 4 +- client/js/socket-events/msg_special.ts | 8 +- client/js/socket-events/mute_changed.ts | 11 +-- client/js/socket-events/names.ts | 6 +- client/js/socket-events/network.ts | 7 +- client/js/socket-events/part.ts | 4 +- client/js/socket-events/sync_sort.ts | 9 ++- client/js/store.ts | 2 +- client/js/upload.ts | 2 +- client/js/vue.ts | 2 +- src/plugins/clientCertificate.ts | 1 + src/plugins/inputs/msg.ts | 2 +- src/plugins/irc-events/connection.ts | 2 +- src/types/modules/irc-framework.d.ts | 4 +- src/types/socket-events.d.ts | 83 +++++++++++++++++++-- test/fixtures/.thelounge/sts-policies.json | 2 +- test/plugins/auth/ldap.ts | 2 +- 30 files changed, 204 insertions(+), 102 deletions(-) diff --git a/client/components/ChatUserList.vue b/client/components/ChatUserList.vue index e85b827d..18711058 100644 --- a/client/components/ChatUserList.vue +++ b/client/components/ChatUserList.vue @@ -28,7 +28,7 @@
@@ -27,7 +27,7 @@ export default defineComponent({ const store = useStore(); const activeChannel = computed(() => { - const chanId = parseInt(route.params.id as string, 10); + const chanId = parseInt(String(route.params.id), 10); const channel = store.getters.findChannel(chanId); return channel; }); diff --git a/client/components/Windows/NetworkEdit.vue b/client/components/Windows/NetworkEdit.vue index 5bc487f3..9c6d94b2 100644 --- a/client/components/Windows/NetworkEdit.vue +++ b/client/components/Windows/NetworkEdit.vue @@ -29,7 +29,7 @@ export default defineComponent({ const setNetworkData = () => { socket.emit("network:get", String(route.params.uuid)); - networkData.value = store.getters.findNetwork(route.params.uuid as string); + networkData.value = store.getters.findNetwork(String(route.params.uuid)); }; const handleSubmit = (data: {uuid: string; name: string}) => { @@ -38,9 +38,12 @@ export default defineComponent({ // TODO: move networks to vuex and update state when the network info comes in const network = store.getters.findNetwork(data.uuid); - network.name = network.channels[0].name = data.name; - switchToChannel(network.channels[0]); + if (network) { + network.name = network.channels[0].name = data.name; + + switchToChannel(network.channels[0]); + } }; watch( diff --git a/client/components/Windows/SearchResults.vue b/client/components/Windows/SearchResults.vue index 00e4a6d5..8f541a38 100644 --- a/client/components/Windows/SearchResults.vue +++ b/client/components/Windows/SearchResults.vue @@ -141,7 +141,7 @@ export default defineComponent({ }); const chan = computed(() => { - const chanId = parseInt(route.params.id as string, 10); + const chanId = parseInt(String(route.params.id), 10); return store.getters.findChannel(chanId); }); diff --git a/client/js/autocompletion.ts b/client/js/autocompletion.ts index 51b02e7a..bf184498 100644 --- a/client/js/autocompletion.ts +++ b/client/js/autocompletion.ts @@ -22,10 +22,10 @@ const emojiStrategy = { callback(fuzzyGrep(term, emojiSearchTerms)); }, template([string, original]: [string, string]) { - return `${emojiMap[original] as string} ${string}`; + return `${String(emojiMap[original])} ${string}`; }, replace([, original]) { - return "$1" + (emojiMap[original] as string); + return "$1" + String(emojiMap[original]); }, index: 2, }; @@ -195,7 +195,7 @@ function enableAutocomplete(input: HTMLTextAreaElement) { const position = input.selectionStart - lastMatch.length; const newMatch = replaceNick( // TODO: type this properly - currentMatches[tabCount % currentMatches.length] as string, + String(currentMatches[tabCount % currentMatches.length]), position ); const remainder = text.substring(input.selectionStart); @@ -317,13 +317,13 @@ function getCommands() { return cmds; } -function completeCommands(word) { +function completeCommands(word: string) { const commands = getCommands(); return fuzzyGrep(word, commands); } -function completeChans(word) { - const words = []; +function completeChans(word: string) { + const words: string[] = []; for (const channel of store.state.activeChannel.network.channels) { // Push all channels that start with the same CHANTYPE diff --git a/client/js/helpers/contextMenu.ts b/client/js/helpers/contextMenu.ts index fd696ea8..73db9692 100644 --- a/client/js/helpers/contextMenu.ts +++ b/client/js/helpers/contextMenu.ts @@ -200,7 +200,7 @@ export function generateChannelContextMenu( }); } - const humanFriendlyChanTypeMap = { + const humanFriendlyChanTypeMap: Record = { lobby: "network", channel: "channel", query: "conversation", @@ -210,7 +210,7 @@ export function generateChannelContextMenu( const mutableChanTypes = Object.keys(humanFriendlyChanTypeMap); if (mutableChanTypes.includes(channel.type)) { - const chanType = humanFriendlyChanTypeMap[channel.type] as string; + const chanType = humanFriendlyChanTypeMap[channel.type]; items.push({ label: channel.muted ? `Unmute ${chanType}` : `Mute ${chanType}`, diff --git a/client/js/socket-events/auth.ts b/client/js/socket-events/auth.ts index da37333a..6712500e 100644 --- a/client/js/socket-events/auth.ts +++ b/client/js/socket-events/auth.ts @@ -3,7 +3,7 @@ import storage from "../localStorage"; import {router, navigate} from "../router"; import {store} from "../store"; import location from "../location"; -let lastServerHash: string | null = null; +let lastServerHash: number | null = null; declare global { interface Window { @@ -16,17 +16,17 @@ socket.on("auth:success", function () { updateLoadingMessage(); }); -socket.on("auth:failed", function () { +socket.on("auth:failed", async function () { storage.remove("token"); if (store.state.appLoaded) { return reloadPage("Authentication failed, reloading…"); } - showSignIn(); + await showSignIn(); }); -socket.on("auth:start", function (serverHash) { +socket.on("auth:start", async function (serverHash) { // If we reconnected and serverHash differs, that means the server restarted // And we will reload the page to grab the latest version if (lastServerHash && serverHash !== lastServerHash) { @@ -74,18 +74,18 @@ socket.on("auth:start", function (serverHash) { hasConfig: store.state.serverConfiguration !== null, }); } else { - showSignIn(); + await showSignIn(); } }); -function showSignIn() { +async function showSignIn() { // TODO: this flashes grey background because it takes a little time for vue to mount signin if (window.g_TheLoungeRemoveLoading) { window.g_TheLoungeRemoveLoading(); } - if (router.currentRoute.name !== "SignIn") { - navigate("SignIn"); + if (router.currentRoute.value.name !== "SignIn") { + await navigate("SignIn"); } } diff --git a/client/js/socket-events/connection.ts b/client/js/socket-events/connection.ts index 89bcaf0e..446a9b79 100644 --- a/client/js/socket-events/connection.ts +++ b/client/js/socket-events/connection.ts @@ -26,7 +26,7 @@ socket.on("connect", function () { }); function handleDisconnect(data) { - const message = (data.message || data) as string; + const message = String(data.message || data); store.commit("isConnected", false); diff --git a/client/js/socket-events/history_clear.ts b/client/js/socket-events/history_clear.ts index dc19e0af..328bf124 100644 --- a/client/js/socket-events/history_clear.ts +++ b/client/js/socket-events/history_clear.ts @@ -2,11 +2,13 @@ import socket from "../socket"; import {store} from "../store"; socket.on("history:clear", function (data) { - const {channel} = store.getters.findChannel(data.target); + const netChan = store.getters.findChannel(data.target); - channel.messages = []; - channel.unread = 0; - channel.highlight = 0; - channel.firstUnread = 0; - channel.moreHistoryAvailable = false; + if (netChan?.channel) { + netChan.channel.messages = []; + netChan.channel.unread = 0; + netChan.channel.highlight = 0; + netChan.channel.firstUnread = 0; + netChan.channel.moreHistoryAvailable = false; + } }); diff --git a/client/js/socket-events/init.ts b/client/js/socket-events/init.ts index 2040ca1a..35e1e367 100644 --- a/client/js/socket-events/init.ts +++ b/client/js/socket-events/init.ts @@ -6,7 +6,7 @@ import {store} from "../store"; import parseIrcUri from "../helpers/parseIrcUri"; import {ClientNetwork, InitClientChan} from "../types"; -socket.on("init", function (data) { +socket.on("init", async function (data) { store.commit("networks", mergeNetworkData(data.networks)); store.commit("isConnected", true); store.commit("currentUserVisibleError", null); @@ -24,30 +24,27 @@ socket.on("init", function (data) { window.g_TheLoungeRemoveLoading(); } - void nextTick(() => { - // If we handled query parameters like irc:// links or just general - // connect parameters in public mode, then nothing to do here - if (!handleQueryParams()) { - // If we are on an unknown route or still on SignIn component - // then we can open last known channel on server, or Connect window if none - if ( - !router.currentRoute.value.name || - router.currentRoute.value.name === "SignIn" - ) { - const channel = store.getters.findChannel(data.active); + await nextTick(); - if (channel) { - switchToChannel(channel.channel); - } else if (store.state.networks.length > 0) { - // Server is telling us to open a channel that does not exist - // For example, it can be unset if you first open the page after server start - switchToChannel(store.state.networks[0].channels[0]); - } else { - navigate("Connect"); - } + // If we handled query parameters like irc:// links or just general + // connect parameters in public mode, then nothing to do here + if (!handleQueryParams()) { + // If we are on an unknown route or still on SignIn component + // then we can open last known channel on server, or Connect window if none + if (!router.currentRoute.value.name || router.currentRoute.value.name === "SignIn") { + const channel = store.getters.findChannel(data.active); + + if (channel) { + switchToChannel(channel.channel); + } else if (store.state.networks.length > 0) { + // Server is telling us to open a channel that does not exist + // For example, it can be unset if you first open the page after server start + switchToChannel(store.state.networks[0].channels[0]); + } else { + await navigate("Connect"); } } - }); + } } }); @@ -172,7 +169,7 @@ function handleQueryParams() { if (params.has("uri")) { // Set default connection settings from IRC protocol links const uri = params.get("uri"); - const queryParams = parseIrcUri(uri as string); + const queryParams = parseIrcUri(String(uri)); cleanParams(); router.push({name: "Connect", query: queryParams}).catch(() => { diff --git a/client/js/socket-events/join.ts b/client/js/socket-events/join.ts index f9141015..9f4539c0 100644 --- a/client/js/socket-events/join.ts +++ b/client/js/socket-events/join.ts @@ -18,5 +18,12 @@ socket.on("join", function (data) { return; } - switchToChannel(store.getters.findChannel(data.chan.id).channel); + const chan = store.getters.findChannel(data.chan.id); + + if (chan) { + switchToChannel(chan.channel); + } else { + // eslint-disable-next-line no-console + console.error("Could not find channel", data.chan.id); + } }); diff --git a/client/js/socket-events/msg.ts b/client/js/socket-events/msg.ts index 3ec7145b..fa17da1e 100644 --- a/client/js/socket-events/msg.ts +++ b/client/js/socket-events/msg.ts @@ -1,7 +1,9 @@ +/* eslint-disable @typescript-eslint/restrict-plus-operands */ import socket from "../socket"; import cleanIrcMessage from "../helpers/ircmessageparser/cleanIrcMessage"; import {store} from "../store"; import {switchToChannel} from "../router"; +import {ClientChan, ClientMention, ClientMessage, NetChan} from "../types"; let pop; @@ -10,6 +12,7 @@ try { pop.src = "audio/pop.wav"; } catch (e) { pop = { + // eslint-disable-next-line @typescript-eslint/no-empty-function play() {}, }; } @@ -92,7 +95,12 @@ socket.on("msg", function (data) { } }); -function notifyMessage(targetId, channel, activeChannel, msg) { +function notifyMessage( + targetId: number, + channel: ClientChan, + activeChannel: NetChan, + msg: ClientMessage +) { if (channel.muted) { return; } @@ -132,19 +140,23 @@ function notifyMessage(targetId, channel, activeChannel, msg) { body = cleanIrcMessage(msg.text); } - const timestamp = Date.parse(msg.time); + const timestamp = Date.parse(String(msg.time)); try { if (store.state.hasServiceWorker) { - navigator.serviceWorker.ready.then((registration) => { - registration.active.postMessage({ - type: "notification", - chanId: targetId, - timestamp: timestamp, - title: title, - body: body, + navigator.serviceWorker.ready + .then((registration) => { + registration.active?.postMessage({ + type: "notification", + chanId: targetId, + timestamp: timestamp, + title: title, + body: body, + }); + }) + .catch(() => { + // no-op }); - }); } else { const notify = new Notification(title, { tag: `chan-${targetId}`, @@ -160,7 +172,7 @@ function notifyMessage(targetId, channel, activeChannel, msg) { const channelTarget = store.getters.findChannel(targetId); if (channelTarget) { - switchToChannel(channelTarget); + switchToChannel(channelTarget.channel); } }); } diff --git a/client/js/socket-events/msg_preview.ts b/client/js/socket-events/msg_preview.ts index 2df4f1f4..96cb82e3 100644 --- a/client/js/socket-events/msg_preview.ts +++ b/client/js/socket-events/msg_preview.ts @@ -2,8 +2,8 @@ import socket from "../socket"; import {store} from "../store"; socket.on("msg:preview", function (data) { - const {channel} = store.getters.findChannel(data.chan); - const message = channel.messages.find((m) => m.id === data.id); + const netChan = store.getters.findChannel(data.chan); + const message = netChan?.channel.messages.find((m) => m.id === data.id); if (!message) { return; diff --git a/client/js/socket-events/msg_special.ts b/client/js/socket-events/msg_special.ts index 301f6440..34d05dbe 100644 --- a/client/js/socket-events/msg_special.ts +++ b/client/js/socket-events/msg_special.ts @@ -3,7 +3,9 @@ import {store} from "../store"; import {switchToChannel} from "../router"; socket.on("msg:special", function (data) { - const channel = store.getters.findChannel(data.chan); - channel.channel.data = data.data; - switchToChannel(channel.channel); + const netChan = store.getters.findChannel(data.chan); + // @ts-ignore + netChan.channel.data = data.data; + // @ts-ignore + switchToChannel(netChan.channel); }); diff --git a/client/js/socket-events/mute_changed.ts b/client/js/socket-events/mute_changed.ts index 6be52f37..bf754c34 100644 --- a/client/js/socket-events/mute_changed.ts +++ b/client/js/socket-events/mute_changed.ts @@ -3,15 +3,16 @@ import {store} from "../store"; socket.on("mute:changed", (response) => { const {target, status} = response; - const {channel, network} = store.getters.findChannel(target); - if (channel.type === "lobby") { - for (const chan of network.channels) { + const netChan = store.getters.findChannel(target); + + if (netChan?.channel.type === "lobby") { + for (const chan of netChan.network.channels) { if (chan.type !== "special") { chan.muted = status; } } - } else { - channel.muted = status; + } else if (netChan) { + netChan.channel.muted = status; } }); diff --git a/client/js/socket-events/names.ts b/client/js/socket-events/names.ts index d04a72af..b200385b 100644 --- a/client/js/socket-events/names.ts +++ b/client/js/socket-events/names.ts @@ -2,9 +2,9 @@ import socket from "../socket"; import {store} from "../store"; socket.on("names", function (data) { - const channel = store.getters.findChannel(data.id); + const netChan = store.getters.findChannel(data.id); - if (channel) { - channel.channel.users = data.users; + if (netChan) { + netChan.channel.users = data.users; } }); diff --git a/client/js/socket-events/network.ts b/client/js/socket-events/network.ts index 7ffd6de5..e5dae7b4 100644 --- a/client/js/socket-events/network.ts +++ b/client/js/socket-events/network.ts @@ -19,7 +19,7 @@ socket.on("network:options", function (data) { const network = store.getters.findNetwork(data.network); if (network) { - network.serverOptions = data.serverOptions; + network.serverOptions = data.serverOptions as typeof network.serverOptions; } }); @@ -63,5 +63,8 @@ socket.on("network:info", function (data) { socket.on("network:name", function (data) { const network = store.getters.findNetwork(data.uuid); - network.name = network.channels[0].name = data.name; + + if (network) { + network.name = network.channels[0].name = data.name; + } }); diff --git a/client/js/socket-events/part.ts b/client/js/socket-events/part.ts index 03b5b71c..548818c4 100644 --- a/client/js/socket-events/part.ts +++ b/client/js/socket-events/part.ts @@ -2,7 +2,7 @@ import socket from "../socket"; import {store} from "../store"; import {switchToChannel} from "../router"; -socket.on("part", function (data) { +socket.on("part", async function (data) { // When parting from the active channel/query, jump to the network's lobby if (store.state.activeChannel && store.state.activeChannel.channel.id === data.chan) { switchToChannel(store.state.activeChannel.network.channels[0]); @@ -19,5 +19,5 @@ socket.on("part", function (data) { 1 ); - store.dispatch("partChannel", channel); + await store.dispatch("partChannel", channel); }); diff --git a/client/js/socket-events/sync_sort.ts b/client/js/socket-events/sync_sort.ts index 09154c87..d39a5dba 100644 --- a/client/js/socket-events/sync_sort.ts +++ b/client/js/socket-events/sync_sort.ts @@ -6,7 +6,10 @@ socket.on("sync_sort", function (data) { switch (data.type) { case "networks": - store.commit("sortNetworks", (a, b) => order.indexOf(a.uuid) - order.indexOf(b.uuid)); + store.commit( + "sortNetworks", + (a, b) => (order as string[]).indexOf(a.uuid) - (order as string[]).indexOf(b.uuid) + ); break; @@ -17,7 +20,9 @@ socket.on("sync_sort", function (data) { return; } - network.channels.sort((a, b) => order.indexOf(a.id) - order.indexOf(b.id)); + network.channels.sort( + (a, b) => (order as number[]).indexOf(a.id) - (order as number[]).indexOf(b.id) + ); break; } diff --git a/client/js/store.ts b/client/js/store.ts index 0908a04a..9e53447b 100644 --- a/client/js/store.ts +++ b/client/js/store.ts @@ -131,7 +131,7 @@ type Getters = { network: ClientNetwork; channel: ClientChan; } | null; - findNetwork: (state: State) => (uuid: string) => any; + findNetwork: (state: State) => (uuid: string) => ClientNetwork | null; highlightCount(state: State): number; title(state: State, getters: Omit): string; initChannel: () => (channel: InitClientChan) => ClientChan; diff --git a/client/js/upload.ts b/client/js/upload.ts index d6b32900..9b53a73c 100644 --- a/client/js/upload.ts +++ b/client/js/upload.ts @@ -200,7 +200,7 @@ class Uploader { }, file.type); }; - img.src = fileReader.result as string; + img.src = String(fileReader.result); }; fileReader.readAsDataURL(file); diff --git a/client/js/vue.ts b/client/js/vue.ts index 507739c1..3ebd5d9c 100644 --- a/client/js/vue.ts +++ b/client/js/vue.ts @@ -76,7 +76,7 @@ VueApp.config.errorHandler = function (e) { if (e instanceof Error) { store.commit("currentUserVisibleError", `Vue error: ${e.message}`); } else { - store.commit("currentUserVisibleError", `Vue error: ${e as string}`); + store.commit("currentUserVisibleError", `Vue error: ${String(e)}`); } // eslint-disable-next-line no-console diff --git a/src/plugins/clientCertificate.ts b/src/plugins/clientCertificate.ts index d276fdc9..c52ff967 100644 --- a/src/plugins/clientCertificate.ts +++ b/src/plugins/clientCertificate.ts @@ -95,6 +95,7 @@ function generate() { // Set notAfter 100 years into the future just in case // the server actually validates this field cert.validity.notAfter = new Date(); + // eslint-disable-next-line @typescript-eslint/restrict-plus-operands cert.validity.notAfter.setFullYear(cert.validity.notBefore.getFullYear() + 100); const attrs = [ diff --git a/src/plugins/inputs/msg.ts b/src/plugins/inputs/msg.ts index ecbba9f5..3205d397 100644 --- a/src/plugins/inputs/msg.ts +++ b/src/plugins/inputs/msg.ts @@ -98,7 +98,7 @@ const input: PluginInputHandler = function (network, chan, cmd, args) { targetGroup = parsedTarget.target_group; } - const channel = network.getChannel(targetName); + const channel = network.getChannel(String(targetName)); if (typeof channel !== "undefined") { network.irc.emit("privmsg", { diff --git a/src/plugins/irc-events/connection.ts b/src/plugins/irc-events/connection.ts index 8deed087..dcb3be77 100644 --- a/src/plugins/irc-events/connection.ts +++ b/src/plugins/irc-events/connection.ts @@ -118,7 +118,7 @@ export default function (irc, network) { client, new Msg({ type: MessageType.ERROR, - text: `Connection closed unexpectedly: ${error}`, + text: `Connection closed unexpectedly: ${String(error)}`, }), true ); diff --git a/src/types/modules/irc-framework.d.ts b/src/types/modules/irc-framework.d.ts index dc3fd59c..3aca2482 100644 --- a/src/types/modules/irc-framework.d.ts +++ b/src/types/modules/irc-framework.d.ts @@ -143,7 +143,7 @@ declare module "irc-framework" { use(a: any): any; - connect(connect_options?: Object): void; + connect(connect_options?: Record): void; /** * Proxy the command handler events onto the client object, with some added sugar @@ -291,7 +291,7 @@ declare module "irc-framework" { reply(e: any): any; - tags: Object; + tags: Record; // any time?: any; diff --git a/src/types/socket-events.d.ts b/src/types/socket-events.d.ts index e9705b66..f98faf4b 100644 --- a/src/types/socket-events.d.ts +++ b/src/types/socket-events.d.ts @@ -1,8 +1,11 @@ -import {ClientMessage, ClientNetwork} from "../../client/js/types"; +import {ClientMessage, ClientNetwork, InitClientChan} from "../../client/js/types"; import {Mention} from "../client"; +import {ChanState} from "../models/chan"; import Msg from "../models/msg"; import Network from "../models/network"; +import User from "../models/user"; import {ChangelogData} from "../plugins/changelog"; +import {LinkPreview} from "../plugins/irc-events/link"; import {ClientConfiguration} from "../server"; type Session = { @@ -24,6 +27,8 @@ interface ServerToClientEvents { changelog: (data: ChangelogData) => void; "changelog:newversion": () => void; + "channel:state": (data: {chan: number; state: ChanState}) => void; + "change-password": ({success, error}: {success: boolean; error?: any}) => void; commands: (data: string[]) => void; @@ -40,6 +45,44 @@ interface ServerToClientEvents { "setting:new": ({name: string, value: any}) => void; "setting:all": (settings: {[key: string]: any}) => void; + "history:clear": ({target}: {target: number}) => void; + + "mute:changed": (response: {target: number; status: boolean}) => void; + + names: (data: {id: number; users: User[]}) => void; + + network: (data: {networks: ClientNetwork[]}) => void; + "network:options": (data: {network: string; serverOptions: {[key: string]: any}}) => void; + "network:status": (data: {network: string; connected: boolean; secure: boolean}) => void; + "network:info": (data: {uuid: string}) => void; + "network:name": (data: {uuid: string; name: string}) => void; + + nick: (data: {network: string; nick: string}) => void; + + open: (id: number) => void; + + part: (data: {chan: number}) => void; + + "sign-out": () => void; + + sync_sort: ( + data: + | { + type: "networks"; + order: string[]; + target: string; + } + | { + type: "channels"; + order: number[]; + target: string; + } + ) => void; + + topic: (data: {chan: number; topic: string}) => void; + + users: (data: {chan: number}) => void; + more: ({ chan, messages, @@ -50,7 +93,9 @@ interface ServerToClientEvents { totalMessages: number; }) => void; - "msg:preview": ({id, chan, preview}: {id: number; chan: number; preview: string}) => void; + "msg:preview": ({id, chan, preview}: {id: number; chan: number; preview: LinkPreview}) => void; + "msg:special": (data: {chan: number}) => void; + msg: (data: {msg: ClientMessage; chan: number; highlight?: number; unread?: number}) => void; init: ({ active, @@ -64,11 +109,35 @@ interface ServerToClientEvents { "search:results": (response: {results: ClientMessage[]}) => void; - quit: ({network}: {network: string}) => void; + quit: (args: {network: string}) => void; + + error: (error: any) => void; + connecting: () => void; + + join: (args: { + shouldOpen: boolean; + index: number; + network: string; + chan: InitClientChan; + }) => void; } interface ClientToServerEvents { - "auth:perform": ({user: string, password: string}) => void; + "auth:perform": + | (({user, password}: {user: string; password: string}) => void) + | (({ + user, + token, + lastMessage, + openChannel, + hasConfig, + }: { + user: string; + token: string; + lastMessage: number; + openChannel: number | null; + hasConfig: boolean; + }) => void); changelog: () => void; @@ -87,9 +156,7 @@ interface ClientToServerEvents { "upload:auth": () => void; "upload:ping": (token: string) => void; - "history:clear": ({target}: {target: number}) => void; - - "mute:change": ({target, setMutedTo}: {target: number; setMutedTo: boolean}) => void; + "mute:change": (response: {target: number; setMutedTo: boolean}) => void; "push:register": (subscriptionJson: PushSubscriptionJSON) => void; "push:unregister": () => void; @@ -133,6 +200,8 @@ interface ClientToServerEvents { "sign-out": (token?: string) => void; + "history:clear": ({target}: {target: number}) => void; + search: ({ networkUuid, channelName, diff --git a/test/fixtures/.thelounge/sts-policies.json b/test/fixtures/.thelounge/sts-policies.json index 033c1805..f91b6ce0 100644 --- a/test/fixtures/.thelounge/sts-policies.json +++ b/test/fixtures/.thelounge/sts-policies.json @@ -3,6 +3,6 @@ "host": "irc.example.com", "port": 7000, "duration": 3600, - "expires": 1654034491040 + "expires": 1654037133192 } ] diff --git a/test/plugins/auth/ldap.ts b/test/plugins/auth/ldap.ts index ff83657d..3a3a8384 100644 --- a/test/plugins/auth/ldap.ts +++ b/test/plugins/auth/ldap.ts @@ -18,7 +18,7 @@ const primaryKey = "uid"; const serverPort = 1389; function normalizeDN(dn: string) { - return ldap.parseDN(dn).toString() as string; + return String(ldap.parseDN(dn).toString()); } function startLdapServer(callback) {