Migrate to eslint
This commit is contained in:
		
					parent
					
						
							
								0fe7e30398
							
						
					
				
			
			
				commit
				
					
						b4e9c278d3
					
				
			
		
					 27 changed files with 104 additions and 71 deletions
				
			
		| 
						 | 
					@ -31,10 +31,5 @@ webpack.config.ts
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Temporarily ignored during TSLint transition
 | 
					# Temporarily ignored during TSLint transition
 | 
				
			||||||
# JIRA: DESKTOP-304
 | 
					# JIRA: DESKTOP-304
 | 
				
			||||||
ts/shims/**
 | 
					 | 
				
			||||||
ts/sql/**
 | 
					ts/sql/**
 | 
				
			||||||
ts/storybook/**
 | 
					 | 
				
			||||||
ts/styleguide/**
 | 
					 | 
				
			||||||
ts/test/**
 | 
					 | 
				
			||||||
ts/textsecure/**
 | 
					ts/textsecure/**
 | 
				
			||||||
ts/updater/**
 | 
					 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -139,7 +139,7 @@ module.exports = {
 | 
				
			||||||
      rules,
 | 
					      rules,
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      files: ['**/*.stories.tsx', 'ts/build/**'],
 | 
					      files: ['**/*.stories.tsx', 'ts/build/**', 'ts/test/**'],
 | 
				
			||||||
      rules: {
 | 
					      rules: {
 | 
				
			||||||
        ...rules,
 | 
					        ...rules,
 | 
				
			||||||
        'import/no-extraneous-dependencies': 'off',
 | 
					        'import/no-extraneous-dependencies': 'off',
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -444,6 +444,32 @@ Signal Desktop makes use of the following open source projects.
 | 
				
			||||||
    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 | 
					    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 | 
				
			||||||
    THE SOFTWARE.
 | 
					    THE SOFTWARE.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## dashdash
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    # This is the MIT license
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    Copyright (c) 2013 Trent Mick. All rights reserved.
 | 
				
			||||||
 | 
					    Copyright (c) 2013 Joyent Inc. All rights reserved.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    Permission is hereby granted, free of charge, to any person obtaining a
 | 
				
			||||||
 | 
					    copy of this software and associated documentation files (the
 | 
				
			||||||
 | 
					    "Software"), to deal in the Software without restriction, including
 | 
				
			||||||
 | 
					    without limitation the rights to use, copy, modify, merge, publish,
 | 
				
			||||||
 | 
					    distribute, sublicense, and/or sell copies of the Software, and to
 | 
				
			||||||
 | 
					    permit persons to whom the Software is furnished to do so, subject to
 | 
				
			||||||
 | 
					    the following conditions:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    The above copyright notice and this permission notice shall be included
 | 
				
			||||||
 | 
					    in all copies or substantial portions of the Software.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 | 
				
			||||||
 | 
					    OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 | 
				
			||||||
 | 
					    MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 | 
				
			||||||
 | 
					    IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
 | 
				
			||||||
 | 
					    CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 | 
				
			||||||
 | 
					    TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 | 
				
			||||||
 | 
					    SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## draft-js
 | 
					## draft-js
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    BSD License
 | 
					    BSD License
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										1
									
								
								js/modules/string_to_array_buffer.d.ts
									
										
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								js/modules/string_to_array_buffer.d.ts
									
										
									
									
										vendored
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1 @@
 | 
				
			||||||
 | 
					export function stringToArrayBuffer(string: string): ArrayBuffer;
 | 
				
			||||||
| 
						 | 
					@ -76,6 +76,7 @@
 | 
				
			||||||
    "config": "1.28.1",
 | 
					    "config": "1.28.1",
 | 
				
			||||||
    "copy-text-to-clipboard": "2.1.0",
 | 
					    "copy-text-to-clipboard": "2.1.0",
 | 
				
			||||||
    "curve25519-n": "https://github.com/scottnonnenberg-signal/node-curve25519.git#3e94f60bc54b2426476520d8d1a0aa835c25f5cc",
 | 
					    "curve25519-n": "https://github.com/scottnonnenberg-signal/node-curve25519.git#3e94f60bc54b2426476520d8d1a0aa835c25f5cc",
 | 
				
			||||||
 | 
					    "dashdash": "1.14.1",
 | 
				
			||||||
    "draft-js": "0.10.5",
 | 
					    "draft-js": "0.10.5",
 | 
				
			||||||
    "emoji-datasource": "5.0.1",
 | 
					    "emoji-datasource": "5.0.1",
 | 
				
			||||||
    "emoji-datasource-apple": "5.0.1",
 | 
					    "emoji-datasource-apple": "5.0.1",
 | 
				
			||||||
| 
						 | 
					@ -163,6 +164,7 @@
 | 
				
			||||||
    "@types/chai": "4.1.2",
 | 
					    "@types/chai": "4.1.2",
 | 
				
			||||||
    "@types/classnames": "2.2.3",
 | 
					    "@types/classnames": "2.2.3",
 | 
				
			||||||
    "@types/config": "0.0.34",
 | 
					    "@types/config": "0.0.34",
 | 
				
			||||||
 | 
					    "@types/dashdash": "1.14.0",
 | 
				
			||||||
    "@types/draft-js": "0.10.32",
 | 
					    "@types/draft-js": "0.10.32",
 | 
				
			||||||
    "@types/filesize": "3.6.0",
 | 
					    "@types/filesize": "3.6.0",
 | 
				
			||||||
    "@types/fs-extra": "5.0.5",
 | 
					    "@types/fs-extra": "5.0.5",
 | 
				
			||||||
| 
						 | 
					@ -213,7 +215,6 @@
 | 
				
			||||||
    "core-js": "2.4.1",
 | 
					    "core-js": "2.4.1",
 | 
				
			||||||
    "cross-env": "5.2.0",
 | 
					    "cross-env": "5.2.0",
 | 
				
			||||||
    "css-loader": "3.2.0",
 | 
					    "css-loader": "3.2.0",
 | 
				
			||||||
    "dashdash": "1.14.1",
 | 
					 | 
				
			||||||
    "electron": "8.3.4",
 | 
					    "electron": "8.3.4",
 | 
				
			||||||
    "electron-builder": "22.3.6",
 | 
					    "electron-builder": "22.3.6",
 | 
				
			||||||
    "electron-mocha": "8.1.1",
 | 
					    "electron-mocha": "8.1.1",
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,18 +1,21 @@
 | 
				
			||||||
export function getSearchResultsProps(attributes: any) {
 | 
					// Matching Whisper.Message API
 | 
				
			||||||
  // @ts-ignore
 | 
					// eslint-disable-next-line max-len
 | 
				
			||||||
 | 
					// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
 | 
				
			||||||
 | 
					export function getSearchResultsProps(attributes: any): any {
 | 
				
			||||||
  const model = new window.Whisper.Message(attributes);
 | 
					  const model = new window.Whisper.Message(attributes);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  return model.getPropsForSearchResult();
 | 
					  return model.getPropsForSearchResult();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export function getBubbleProps(attributes: any) {
 | 
					// Matching Whisper.Message API
 | 
				
			||||||
  // @ts-ignore
 | 
					// eslint-disable-next-line max-len
 | 
				
			||||||
 | 
					// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
 | 
				
			||||||
 | 
					export function getBubbleProps(attributes: any): any {
 | 
				
			||||||
  const model = new window.Whisper.Message(attributes);
 | 
					  const model = new window.Whisper.Message(attributes);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  return model.getPropsForBubble();
 | 
					  return model.getPropsForBubble();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export function showSettings() {
 | 
					export function showSettings(): void {
 | 
				
			||||||
  // @ts-ignore
 | 
					 | 
				
			||||||
  window.showSettings();
 | 
					  window.showSettings();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,9 +1,9 @@
 | 
				
			||||||
import { ipcRenderer } from 'electron';
 | 
					import { ipcRenderer } from 'electron';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export function bounceAppIconStart(isCritical = false) {
 | 
					export function bounceAppIconStart(isCritical = false): void {
 | 
				
			||||||
  ipcRenderer.send('bounce-app-icon-start', isCritical);
 | 
					  ipcRenderer.send('bounce-app-icon-start', isCritical);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export function bounceAppIconStop() {
 | 
					export function bounceAppIconStop(): void {
 | 
				
			||||||
  ipcRenderer.send('bounce-app-icon-stop');
 | 
					  ipcRenderer.send('bounce-app-icon-stop');
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,3 +1,6 @@
 | 
				
			||||||
export function trigger(name: string, param1?: any, param2?: any) {
 | 
					// Matching Whisper.events.trigger API
 | 
				
			||||||
 | 
					// eslint-disable-next-line max-len
 | 
				
			||||||
 | 
					// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any
 | 
				
			||||||
 | 
					export function trigger(name: string, param1?: any, param2?: any): void {
 | 
				
			||||||
  window.Whisper.events.trigger(name, param1, param2);
 | 
					  window.Whisper.events.trigger(name, param1, param2);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,4 +1,4 @@
 | 
				
			||||||
export function getSocketStatus() {
 | 
					export function getSocketStatus(): number {
 | 
				
			||||||
  const { getSocketStatus: getMessageReceiverStatus } = window;
 | 
					  const { getSocketStatus: getMessageReceiverStatus } = window;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  return getMessageReceiverStatus();
 | 
					  return getMessageReceiverStatus();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,7 +1,10 @@
 | 
				
			||||||
export function put(key: string, value: any) {
 | 
					// Matching window.storage.put API
 | 
				
			||||||
 | 
					// eslint-disable-next-line max-len
 | 
				
			||||||
 | 
					// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
 | 
				
			||||||
 | 
					export function put(key: string, value: any): void {
 | 
				
			||||||
  window.storage.put(key, value);
 | 
					  window.storage.put(key, value);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export async function remove(key: string) {
 | 
					export async function remove(key: string): Promise<void> {
 | 
				
			||||||
  await window.storage.remove(key);
 | 
					  await window.storage.remove(key);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2,7 +2,7 @@ export function sendStickerPackSync(
 | 
				
			||||||
  packId: string,
 | 
					  packId: string,
 | 
				
			||||||
  packKey: string,
 | 
					  packKey: string,
 | 
				
			||||||
  installed: boolean
 | 
					  installed: boolean
 | 
				
			||||||
) {
 | 
					): void {
 | 
				
			||||||
  const { ConversationController, textsecure, log } = window;
 | 
					  const { ConversationController, textsecure, log } = window;
 | 
				
			||||||
  const ourNumber = textsecure.storage.user.getNumber();
 | 
					  const ourNumber = textsecure.storage.user.getNumber();
 | 
				
			||||||
  const { wrap, sendOptions } = ConversationController.prepareForSend(
 | 
					  const { wrap, sendOptions } = ConversationController.prepareForSend(
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,9 +1,9 @@
 | 
				
			||||||
import { ipcRenderer } from 'electron';
 | 
					import { ipcRenderer } from 'electron';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export function startUpdate() {
 | 
					export function startUpdate(): void {
 | 
				
			||||||
  ipcRenderer.send('start-update');
 | 
					  ipcRenderer.send('start-update');
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export function ackRender() {
 | 
					export function ackRender(): void {
 | 
				
			||||||
  ipcRenderer.send('show-update-dialog-ack');
 | 
					  ipcRenderer.send('show-update-dialog-ack');
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,3 +1,4 @@
 | 
				
			||||||
 | 
					/* eslint-disable @typescript-eslint/ban-ts-comment */
 | 
				
			||||||
// @ts-ignore
 | 
					// @ts-ignore
 | 
				
			||||||
import gif from '../../fixtures/giphy-GVNvOUpeYmI7e.gif';
 | 
					import gif from '../../fixtures/giphy-GVNvOUpeYmI7e.gif';
 | 
				
			||||||
// @ts-ignore
 | 
					// @ts-ignore
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -3,7 +3,6 @@ import { assert } from 'chai';
 | 
				
			||||||
import * as Attachment from '../../types/Attachment';
 | 
					import * as Attachment from '../../types/Attachment';
 | 
				
			||||||
import * as MIME from '../../types/MIME';
 | 
					import * as MIME from '../../types/MIME';
 | 
				
			||||||
import { SignalService } from '../../protobuf';
 | 
					import { SignalService } from '../../protobuf';
 | 
				
			||||||
// @ts-ignore
 | 
					 | 
				
			||||||
import { stringToArrayBuffer } from '../../../js/modules/string_to_array_buffer';
 | 
					import { stringToArrayBuffer } from '../../../js/modules/string_to_array_buffer';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
describe('Attachment', () => {
 | 
					describe('Attachment', () => {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2,7 +2,7 @@ import os from 'os';
 | 
				
			||||||
import Sinon from 'sinon';
 | 
					import Sinon from 'sinon';
 | 
				
			||||||
import { assert } from 'chai';
 | 
					import { assert } from 'chai';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import * as Settings from '../../../ts/types/Settings';
 | 
					import * as Settings from '../../types/Settings';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
describe('Settings', () => {
 | 
					describe('Settings', () => {
 | 
				
			||||||
  let sandbox: Sinon.SinonSandbox;
 | 
					  let sandbox: Sinon.SinonSandbox;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,10 +1,9 @@
 | 
				
			||||||
import { assert } from 'chai';
 | 
					import { assert } from 'chai';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import * as Message from '../../../../ts/types/message/initializeAttachmentMetadata';
 | 
					import * as Message from '../../../types/message/initializeAttachmentMetadata';
 | 
				
			||||||
import { IncomingMessage } from '../../../../ts/types/Message';
 | 
					import { IncomingMessage } from '../../../types/Message';
 | 
				
			||||||
import { SignalService } from '../../../../ts/protobuf';
 | 
					import { SignalService } from '../../../protobuf';
 | 
				
			||||||
import * as MIME from '../../../../ts/types/MIME';
 | 
					import * as MIME from '../../../types/MIME';
 | 
				
			||||||
// @ts-ignore
 | 
					 | 
				
			||||||
import { stringToArrayBuffer } from '../../../../js/modules/string_to_array_buffer';
 | 
					import { stringToArrayBuffer } from '../../../../js/modules/string_to_array_buffer';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
describe('Message', () => {
 | 
					describe('Message', () => {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,3 +1,4 @@
 | 
				
			||||||
 | 
					/* eslint-disable no-console */
 | 
				
			||||||
import {
 | 
					import {
 | 
				
			||||||
  createWriteStream,
 | 
					  createWriteStream,
 | 
				
			||||||
  statSync,
 | 
					  statSync,
 | 
				
			||||||
| 
						 | 
					@ -6,9 +7,7 @@ import {
 | 
				
			||||||
import { join, normalize } from 'path';
 | 
					import { join, normalize } from 'path';
 | 
				
			||||||
import { tmpdir } from 'os';
 | 
					import { tmpdir } from 'os';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// @ts-ignore
 | 
					import { createParser, ParserConfiguration } from 'dashdash';
 | 
				
			||||||
import { createParser } from 'dashdash';
 | 
					 | 
				
			||||||
// @ts-ignore
 | 
					 | 
				
			||||||
import ProxyAgent from 'proxy-agent';
 | 
					import ProxyAgent from 'proxy-agent';
 | 
				
			||||||
import { FAILSAFE_SCHEMA, safeLoad } from 'js-yaml';
 | 
					import { FAILSAFE_SCHEMA, safeLoad } from 'js-yaml';
 | 
				
			||||||
import { gt } from 'semver';
 | 
					import { gt } from 'semver';
 | 
				
			||||||
| 
						 | 
					@ -24,7 +23,6 @@ import { getTempPath } from '../../app/attachments';
 | 
				
			||||||
import { Dialogs } from '../types/Dialogs';
 | 
					import { Dialogs } from '../types/Dialogs';
 | 
				
			||||||
import { getUserAgent } from '../util/getUserAgent';
 | 
					import { getUserAgent } from '../util/getUserAgent';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// @ts-ignore
 | 
					 | 
				
			||||||
import * as packageJson from '../../package.json';
 | 
					import * as packageJson from '../../package.json';
 | 
				
			||||||
import { getSignatureFileName } from './signature';
 | 
					import { getSignatureFileName } from './signature';
 | 
				
			||||||
import { isPathInside } from '../util/isPathInside';
 | 
					import { isPathInside } from '../util/isPathInside';
 | 
				
			||||||
| 
						 | 
					@ -70,7 +68,7 @@ export async function checkForUpdates(
 | 
				
			||||||
  return null;
 | 
					  return null;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export function validatePath(basePath: string, targetPath: string) {
 | 
					export function validatePath(basePath: string, targetPath: string): void {
 | 
				
			||||||
  const normalized = normalize(targetPath);
 | 
					  const normalized = normalize(targetPath);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (!isPathInside(normalized, basePath)) {
 | 
					  if (!isPathInside(normalized, basePath)) {
 | 
				
			||||||
| 
						 | 
					@ -252,9 +250,9 @@ export function getUpdatesFileName(): string {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (platform === 'darwin') {
 | 
					  if (platform === 'darwin') {
 | 
				
			||||||
    return `${prefix}-mac.yml`;
 | 
					    return `${prefix}-mac.yml`;
 | 
				
			||||||
  } else {
 | 
					 | 
				
			||||||
    return `${prefix}.yml`;
 | 
					 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  return `${prefix}.yml`;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const hasBeta = /beta/i;
 | 
					const hasBeta = /beta/i;
 | 
				
			||||||
| 
						 | 
					@ -268,29 +266,27 @@ function isVersionNewer(newVersion: string): boolean {
 | 
				
			||||||
  return gt(newVersion, version);
 | 
					  return gt(newVersion, version);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export function getVersion(yaml: string): string | undefined {
 | 
					export function getVersion(yaml: string): string | null {
 | 
				
			||||||
  const info = parseYaml(yaml);
 | 
					  const info = parseYaml(yaml);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (info && info.version) {
 | 
					  return info && info.version;
 | 
				
			||||||
    return info.version;
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  return;
 | 
					const validFile = /^[A-Za-z0-9.-]+$/;
 | 
				
			||||||
}
 | 
					export function isUpdateFileNameValid(name: string): boolean {
 | 
				
			||||||
 | 
					 | 
				
			||||||
const validFile = /^[A-Za-z0-9\.\-]+$/;
 | 
					 | 
				
			||||||
export function isUpdateFileNameValid(name: string) {
 | 
					 | 
				
			||||||
  return validFile.test(name);
 | 
					  return validFile.test(name);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export function getUpdateFileName(yaml: string) {
 | 
					// Reliant on third party parser that returns any
 | 
				
			||||||
 | 
					// eslint-disable-next-line @typescript-eslint/no-explicit-any
 | 
				
			||||||
 | 
					export function getUpdateFileName(yaml: string): any {
 | 
				
			||||||
  const info = parseYaml(yaml);
 | 
					  const info = parseYaml(yaml);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (!info || !info.path) {
 | 
					  if (!info || !info.path) {
 | 
				
			||||||
    throw new Error('getUpdateFileName: No path present in YAML file');
 | 
					    throw new Error('getUpdateFileName: No path present in YAML file');
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const path = info.path;
 | 
					  const { path } = info;
 | 
				
			||||||
  if (!isUpdateFileNameValid(path)) {
 | 
					  if (!isUpdateFileNameValid(path)) {
 | 
				
			||||||
    throw new Error(
 | 
					    throw new Error(
 | 
				
			||||||
      `getUpdateFileName: Path '${path}' contains invalid characters`
 | 
					      `getUpdateFileName: Path '${path}' contains invalid characters`
 | 
				
			||||||
| 
						 | 
					@ -300,6 +296,8 @@ export function getUpdateFileName(yaml: string) {
 | 
				
			||||||
  return path;
 | 
					  return path;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Reliant on third party parser that returns any
 | 
				
			||||||
 | 
					// eslint-disable-next-line @typescript-eslint/no-explicit-any
 | 
				
			||||||
function parseYaml(yaml: string): any {
 | 
					function parseYaml(yaml: string): any {
 | 
				
			||||||
  return safeLoad(yaml, { schema: FAILSAFE_SCHEMA, json: true });
 | 
					  return safeLoad(yaml, { schema: FAILSAFE_SCHEMA, json: true });
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -336,7 +334,7 @@ function getBaseTempDir() {
 | 
				
			||||||
  return app ? getTempPath(app.getPath('userData')) : tmpdir();
 | 
					  return app ? getTempPath(app.getPath('userData')) : tmpdir();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export async function createTempDir() {
 | 
					export async function createTempDir(): Promise<string> {
 | 
				
			||||||
  const baseTempDir = getBaseTempDir();
 | 
					  const baseTempDir = getBaseTempDir();
 | 
				
			||||||
  const uniqueName = getGuid();
 | 
					  const uniqueName = getGuid();
 | 
				
			||||||
  const targetDir = join(baseTempDir, uniqueName);
 | 
					  const targetDir = join(baseTempDir, uniqueName);
 | 
				
			||||||
| 
						 | 
					@ -345,7 +343,7 @@ export async function createTempDir() {
 | 
				
			||||||
  return targetDir;
 | 
					  return targetDir;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export async function deleteTempDir(targetDir: string) {
 | 
					export async function deleteTempDir(targetDir: string): Promise<void> {
 | 
				
			||||||
  const pathInfo = statSync(targetDir);
 | 
					  const pathInfo = statSync(targetDir);
 | 
				
			||||||
  if (!pathInfo.isDirectory()) {
 | 
					  if (!pathInfo.isDirectory()) {
 | 
				
			||||||
    throw new Error(
 | 
					    throw new Error(
 | 
				
			||||||
| 
						 | 
					@ -363,22 +361,21 @@ export async function deleteTempDir(targetDir: string) {
 | 
				
			||||||
  await rimrafPromise(targetDir);
 | 
					  await rimrafPromise(targetDir);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export function getPrintableError(error: Error) {
 | 
					export function getPrintableError(error: Error): Error | string {
 | 
				
			||||||
  return error && error.stack ? error.stack : error;
 | 
					  return error && error.stack ? error.stack : error;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export function getCliOptions<T>(options: any): T {
 | 
					export function getCliOptions<T>(options: ParserConfiguration['options']): T {
 | 
				
			||||||
  const parser = createParser({ options });
 | 
					  const parser = createParser({ options });
 | 
				
			||||||
  const cliOptions = parser.parse(process.argv);
 | 
					  const cliOptions = parser.parse(process.argv);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (cliOptions.help) {
 | 
					  if (cliOptions.help) {
 | 
				
			||||||
    const help = parser.help().trimRight();
 | 
					    const help = parser.help().trimRight();
 | 
				
			||||||
    // tslint:disable-next-line:no-console
 | 
					 | 
				
			||||||
    console.log(help);
 | 
					    console.log(help);
 | 
				
			||||||
    process.exit(0);
 | 
					    process.exit(0);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  return cliOptions;
 | 
					  return (cliOptions as unknown) as T;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export function setUpdateListener(performUpdateCallback: () => void): void {
 | 
					export function setUpdateListener(performUpdateCallback: () => void): void {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -5,7 +5,7 @@ import {
 | 
				
			||||||
  verifySignature,
 | 
					  verifySignature,
 | 
				
			||||||
} from 'curve25519-n';
 | 
					} from 'curve25519-n';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export function keyPair() {
 | 
					export function keyPair(): Record<string, Buffer> {
 | 
				
			||||||
  const privateKey = randomBytes(32);
 | 
					  const privateKey = randomBytes(32);
 | 
				
			||||||
  const { pubKey, privKey } = generateKeyPair(privateKey);
 | 
					  const { pubKey, privKey } = generateKeyPair(privateKey);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,9 +1,8 @@
 | 
				
			||||||
 | 
					/* eslint-disable no-console */
 | 
				
			||||||
import { getCliOptions, getPrintableError } from './common';
 | 
					import { getCliOptions, getPrintableError } from './common';
 | 
				
			||||||
import { keyPair } from './curve';
 | 
					import { keyPair } from './curve';
 | 
				
			||||||
import { writeHexToPath } from './signature';
 | 
					import { writeHexToPath } from './signature';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* tslint:disable:no-console */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
const OPTIONS = [
 | 
					const OPTIONS = [
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    names: ['help', 'h'],
 | 
					    names: ['help', 'h'],
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,3 +1,4 @@
 | 
				
			||||||
 | 
					/* eslint-disable no-console */
 | 
				
			||||||
import { join, resolve } from 'path';
 | 
					import { join, resolve } from 'path';
 | 
				
			||||||
import { readdir as readdirCallback } from 'fs';
 | 
					import { readdir as readdirCallback } from 'fs';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -5,14 +6,10 @@ import pify from 'pify';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import { getCliOptions, getPrintableError } from './common';
 | 
					import { getCliOptions, getPrintableError } from './common';
 | 
				
			||||||
import { writeSignature } from './signature';
 | 
					import { writeSignature } from './signature';
 | 
				
			||||||
 | 
					 | 
				
			||||||
// @ts-ignore
 | 
					 | 
				
			||||||
import * as packageJson from '../../package.json';
 | 
					import * as packageJson from '../../package.json';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const readdir = pify(readdirCallback);
 | 
					const readdir = pify(readdirCallback);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* tslint:disable:no-console */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
const OPTIONS = [
 | 
					const OPTIONS = [
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    names: ['help', 'h'],
 | 
					    names: ['help', 'h'],
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -12,7 +12,7 @@ export async function start(
 | 
				
			||||||
  getMainWindow: () => BrowserWindow,
 | 
					  getMainWindow: () => BrowserWindow,
 | 
				
			||||||
  locale?: LocaleType,
 | 
					  locale?: LocaleType,
 | 
				
			||||||
  logger?: LoggerType
 | 
					  logger?: LoggerType
 | 
				
			||||||
) {
 | 
					): Promise<void> {
 | 
				
			||||||
  const { platform } = process;
 | 
					  const { platform } = process;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (initialized) {
 | 
					  if (initialized) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -33,7 +33,7 @@ export async function start(
 | 
				
			||||||
  getMainWindow: () => BrowserWindow,
 | 
					  getMainWindow: () => BrowserWindow,
 | 
				
			||||||
  locale: LocaleType,
 | 
					  locale: LocaleType,
 | 
				
			||||||
  logger: LoggerType
 | 
					  logger: LoggerType
 | 
				
			||||||
) {
 | 
					): Promise<void> {
 | 
				
			||||||
  logger.info('macos/start: starting checks...');
 | 
					  logger.info('macos/start: starting checks...');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  loggerForQuitHandler = logger;
 | 
					  loggerForQuitHandler = logger;
 | 
				
			||||||
| 
						 | 
					@ -214,8 +214,6 @@ async function handToAutoUpdate(
 | 
				
			||||||
        autoUpdater.checkForUpdates();
 | 
					        autoUpdater.checkForUpdates();
 | 
				
			||||||
      } catch (error) {
 | 
					      } catch (error) {
 | 
				
			||||||
        reject(error);
 | 
					        reject(error);
 | 
				
			||||||
 | 
					 | 
				
			||||||
        return;
 | 
					 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
| 
						 | 
					@ -296,7 +294,6 @@ function write404(
 | 
				
			||||||
function getServerUrl(server: Server) {
 | 
					function getServerUrl(server: Server) {
 | 
				
			||||||
  const address = server.address() as AddressInfo;
 | 
					  const address = server.address() as AddressInfo;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // tslint:disable-next-line:no-http-string
 | 
					 | 
				
			||||||
  return `http://127.0.0.1:${address.port}`;
 | 
					  return `http://127.0.0.1:${address.port}`;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
function generateFileUrl(): string {
 | 
					function generateFileUrl(): string {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -17,7 +17,7 @@ export async function generateSignature(
 | 
				
			||||||
  updatePackagePath: string,
 | 
					  updatePackagePath: string,
 | 
				
			||||||
  version: string,
 | 
					  version: string,
 | 
				
			||||||
  privateKeyPath: string
 | 
					  privateKeyPath: string
 | 
				
			||||||
) {
 | 
					): Promise<Buffer> {
 | 
				
			||||||
  const privateKey = await loadHexFromPath(privateKeyPath);
 | 
					  const privateKey = await loadHexFromPath(privateKeyPath);
 | 
				
			||||||
  const message = await generateMessage(updatePackagePath, version);
 | 
					  const message = await generateMessage(updatePackagePath, version);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -52,7 +52,7 @@ export async function writeSignature(
 | 
				
			||||||
  updatePackagePath: string,
 | 
					  updatePackagePath: string,
 | 
				
			||||||
  version: string,
 | 
					  version: string,
 | 
				
			||||||
  privateKeyPath: string
 | 
					  privateKeyPath: string
 | 
				
			||||||
) {
 | 
					): Promise<void> {
 | 
				
			||||||
  const signaturePath = getSignaturePath(updatePackagePath);
 | 
					  const signaturePath = getSignaturePath(updatePackagePath);
 | 
				
			||||||
  const signature = await generateSignature(
 | 
					  const signature = await generateSignature(
 | 
				
			||||||
    updatePackagePath,
 | 
					    updatePackagePath,
 | 
				
			||||||
| 
						 | 
					@ -79,7 +79,7 @@ export async function _getFileHash(updatePackagePath: string): Promise<Buffer> {
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export function getSignatureFileName(fileName: string) {
 | 
					export function getSignatureFileName(fileName: string): string {
 | 
				
			||||||
  return `${fileName}.sig`;
 | 
					  return `${fileName}.sig`;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -105,6 +105,9 @@ export async function loadHexFromPath(target: string): Promise<Buffer> {
 | 
				
			||||||
  return hexToBinary(hexString);
 | 
					  return hexToBinary(hexString);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export async function writeHexToPath(target: string, data: Buffer) {
 | 
					export async function writeHexToPath(
 | 
				
			||||||
 | 
					  target: string,
 | 
				
			||||||
 | 
					  data: Buffer
 | 
				
			||||||
 | 
					): Promise<void> {
 | 
				
			||||||
  await writeFile(target, binaryToHex(data));
 | 
					  await writeFile(target, binaryToHex(data));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -38,7 +38,7 @@ export async function start(
 | 
				
			||||||
  getMainWindow: () => BrowserWindow,
 | 
					  getMainWindow: () => BrowserWindow,
 | 
				
			||||||
  locale: LocaleType,
 | 
					  locale: LocaleType,
 | 
				
			||||||
  logger: LoggerType
 | 
					  logger: LoggerType
 | 
				
			||||||
) {
 | 
					): Promise<void> {
 | 
				
			||||||
  logger.info('windows/start: starting checks...');
 | 
					  logger.info('windows/start: starting checks...');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  loggerForQuitHandler = logger;
 | 
					  loggerForQuitHandler = logger;
 | 
				
			||||||
| 
						 | 
					@ -163,7 +163,7 @@ async function install(filePath: string, logger: LoggerType): Promise<void> {
 | 
				
			||||||
  const args = ['--updated'];
 | 
					  const args = ['--updated'];
 | 
				
			||||||
  const options = {
 | 
					  const options = {
 | 
				
			||||||
    detached: true,
 | 
					    detached: true,
 | 
				
			||||||
    stdio: 'ignore' as 'ignore', // TypeScript considers this a plain string without help
 | 
					    stdio: 'ignore' as const, // TypeScript considers this a plain string without help
 | 
				
			||||||
  };
 | 
					  };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  try {
 | 
					  try {
 | 
				
			||||||
| 
						 | 
					@ -209,7 +209,6 @@ async function spawn(
 | 
				
			||||||
    emitter.on('error', reject);
 | 
					    emitter.on('error', reject);
 | 
				
			||||||
    emitter.unref();
 | 
					    emitter.unref();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // tslint:disable-next-line no-string-based-set-timeout
 | 
					 | 
				
			||||||
    setTimeout(resolve, 200);
 | 
					    setTimeout(resolve, 200);
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										1
									
								
								ts/window.d.ts
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								ts/window.d.ts
									
										
									
									
										vendored
									
									
								
							| 
						 | 
					@ -72,6 +72,7 @@ declare global {
 | 
				
			||||||
    reduxActions: ReduxActions;
 | 
					    reduxActions: ReduxActions;
 | 
				
			||||||
    restart: () => void;
 | 
					    restart: () => void;
 | 
				
			||||||
    showWindow: () => void;
 | 
					    showWindow: () => void;
 | 
				
			||||||
 | 
					    showSettings: () => void;
 | 
				
			||||||
    setBadgeCount: (count: number) => void;
 | 
					    setBadgeCount: (count: number) => void;
 | 
				
			||||||
    storage: {
 | 
					    storage: {
 | 
				
			||||||
      put: (key: string, value: any) => void;
 | 
					      put: (key: string, value: any) => void;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -190,8 +190,12 @@
 | 
				
			||||||
      "ts/protobuf/**",
 | 
					      "ts/protobuf/**",
 | 
				
			||||||
      "ts/scripts/**",
 | 
					      "ts/scripts/**",
 | 
				
			||||||
      "ts/services/**",
 | 
					      "ts/services/**",
 | 
				
			||||||
 | 
					      "ts/shims/**",
 | 
				
			||||||
      "ts/state/**",
 | 
					      "ts/state/**",
 | 
				
			||||||
 | 
					      "ts/storybook/**",
 | 
				
			||||||
 | 
					      "ts/test/**",
 | 
				
			||||||
      "ts/types/**",
 | 
					      "ts/types/**",
 | 
				
			||||||
 | 
					      "ts/updater/**",
 | 
				
			||||||
      "ts/util/**"
 | 
					      "ts/util/**"
 | 
				
			||||||
    ]
 | 
					    ]
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2124,6 +2124,11 @@
 | 
				
			||||||
  dependencies:
 | 
					  dependencies:
 | 
				
			||||||
    "@types/node" "*"
 | 
					    "@types/node" "*"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					"@types/dashdash@1.14.0":
 | 
				
			||||||
 | 
					  version "1.14.0"
 | 
				
			||||||
 | 
					  resolved "https://registry.yarnpkg.com/@types/dashdash/-/dashdash-1.14.0.tgz#bfa457c2688497cf0e6695dbd522c67a9232833f"
 | 
				
			||||||
 | 
					  integrity sha512-dBnfu9H6TVawx85FGmVEs5lYFXNwUVxn3Nqu5FHhCAi4aPvZR35W4FEMK3ljlpM2vHPGgEnCZGARF59/QGTNJw==
 | 
				
			||||||
 | 
					
 | 
				
			||||||
"@types/debug@^4.1.4", "@types/debug@^4.1.5":
 | 
					"@types/debug@^4.1.4", "@types/debug@^4.1.5":
 | 
				
			||||||
  version "4.1.5"
 | 
					  version "4.1.5"
 | 
				
			||||||
  resolved "https://registry.yarnpkg.com/@types/debug/-/debug-4.1.5.tgz#b14efa8852b7768d898906613c23f688713e02cd"
 | 
					  resolved "https://registry.yarnpkg.com/@types/debug/-/debug-4.1.5.tgz#b14efa8852b7768d898906613c23f688713e02cd"
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue