mirror of
https://github.com/zulip/zulip-desktop.git
synced 2025-11-15 19:31:39 +00:00
js: Explode more singleton classes to modules.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
This commit is contained in:
@@ -5,32 +5,28 @@ import ConfigUtil = require('./config-util');
|
||||
|
||||
const { shell } = remote;
|
||||
|
||||
class AuthUtil {
|
||||
openInBrowser = (link: string): void => {
|
||||
const otp = cryptoRandomString({length: 64});
|
||||
ConfigUtil.setConfigItem('desktopOtp', otp);
|
||||
shell.openExternal(`${link}?desktop_flow_otp=${otp}`);
|
||||
};
|
||||
export const openInBrowser = (link: string): void => {
|
||||
const otp = cryptoRandomString({length: 64});
|
||||
ConfigUtil.setConfigItem('desktopOtp', otp);
|
||||
shell.openExternal(`${link}?desktop_flow_otp=${otp}`);
|
||||
};
|
||||
|
||||
xorStrings = (a: string, b: string): string => {
|
||||
if (a.length === b.length) {
|
||||
return a
|
||||
.split('')
|
||||
.map((char, i) => (parseInt(a[i], 16) ^ parseInt(b[i], 16)).toString(16))
|
||||
.join('')
|
||||
.toUpperCase();
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
};
|
||||
export const xorStrings = (a: string, b: string): string => {
|
||||
if (a.length === b.length) {
|
||||
return a
|
||||
.split('')
|
||||
.map((char, i) => (parseInt(a[i], 16) ^ parseInt(b[i], 16)).toString(16))
|
||||
.join('')
|
||||
.toUpperCase();
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
};
|
||||
|
||||
hexToAscii = (hex: string): string => {
|
||||
let ascii = '';
|
||||
for (let i = 0; i < hex.length; i += 2) {
|
||||
ascii += String.fromCharCode(parseInt(hex.slice(i, i + 2), 16));
|
||||
}
|
||||
return ascii;
|
||||
};
|
||||
}
|
||||
|
||||
export = new AuthUtil();
|
||||
export const hexToAscii = (hex: string): string => {
|
||||
let ascii = '';
|
||||
for (let i = 0; i < hex.length; i += 2) {
|
||||
ascii += String.fromCharCode(parseInt(hex.slice(i, i + 2), 16));
|
||||
}
|
||||
return ascii;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user