diff --git a/src/electron-main/constants.spec.ts b/src/electron-main/constants.spec.ts new file mode 100644 index 000000000..adb81a11c --- /dev/null +++ b/src/electron-main/constants.spec.ts @@ -0,0 +1,13 @@ +import {test} from "ava"; + +import {KEYTAR_MASTER_PASSWORD_ACCOUNT, KEYTAR_SERVICE_NAME} from "./constants"; + +// tslint:disable-next-line:no-var-requires +const {name: packageName} = require("../../package.json"); + +test(`"keytar" constants`, async (t) => { + t.truthy(KEYTAR_MASTER_PASSWORD_ACCOUNT); + t.truthy(KEYTAR_SERVICE_NAME); + t.truthy(packageName); + t.is(packageName, KEYTAR_SERVICE_NAME); +}); diff --git a/src/electron-main/constants.ts b/src/electron-main/constants.ts index 59f5e0484..9feeb6a57 100644 --- a/src/electron-main/constants.ts +++ b/src/electron-main/constants.ts @@ -1,7 +1,5 @@ import {Options as EncryptionAdapterOptions} from "fs-json-store-encryption-adapter"; -// tslint:disable-next-line:no-var-requires -const {name} = require("../../package.json"); const encryptionPreset: EncryptionAdapterOptions = { keyDerivation: {type: "sodium.crypto_pwhash", preset: "mode:interactive|algorithm:default"}, encryption: {type: "sodium.crypto_secretbox_easy", preset: "algorithm:default"}, @@ -22,5 +20,5 @@ export const INITIAL_STORES = Object.freeze({ settings: {accounts: []}, }); -export const KEYTAR_SERVICE_NAME = name; +export const KEYTAR_SERVICE_NAME = "protonmail-desktop-app"; export const KEYTAR_MASTER_PASSWORD_ACCOUNT = "master-password"; diff --git a/src/electron-main/ipc-main-api.ts b/src/electron-main/ipc-main-api.ts index 3861f9a3d..09cb7424e 100644 --- a/src/electron-main/ipc-main-api.ts +++ b/src/electron-main/ipc-main-api.ts @@ -100,8 +100,10 @@ export const initEndpoints = (ctx: Context): Endpoints => { aboutWindow({ icon_path: ctx.locations.icon, package_json_dir: "development" === (process.env.NODE_ENV as BuildEnvironment) ? process.cwd() : ctx.locations.app, - // TODO electron-builder strips "bugs" property out form the package.json preparing a build - bug_report_url: "https://github.com/vladimiry/protonmail-desktop-app/issues", + // TODO figure why ""about-window" doesn't automatically resolve properties like "bugs" or "description" from package.json + // properties are fulled in package.json, both original and modified by "electron-builder" + description: String(process.env.APP_ENV_PACKAGE_DESCRIPTION), + bug_report_url: String(process.env.APP_ENV_PACKAGE_BUGS_URL), }); return EMPTY; }, diff --git a/src/shared/api/main.ts b/src/shared/api/main.ts index cd58a2a7c..f752f29f8 100644 --- a/src/shared/api/main.ts +++ b/src/shared/api/main.ts @@ -41,5 +41,4 @@ export interface Endpoints { updateOverlayIcon: ApiMethod<{ count: number; dataURL?: string; }, never>; } -// TODO pick "channel" from "package.json => name" -export const IPC_MAIN_API = new IpcMainApiService({channel: "protonmail-desktop-app:ipcMain-api"}); +export const IPC_MAIN_API = new IpcMainApiService({channel: `${process.env.APP_ENV_PACKAGE_NAME}:ipcMain-api`}); diff --git a/src/shared/api/webview/index.ts b/src/shared/api/webview/index.ts index b5e60148f..0687464fb 100644 --- a/src/shared/api/webview/index.ts +++ b/src/shared/api/webview/index.ts @@ -11,5 +11,4 @@ export interface Endpoints { unlock: ApiMethod; } -// TODO pick "channel" from "package.json => name" -export const IPC_WEBVIEW_API = new WebViewApiService({channel: "protonmail-desktop-app:webview-api"}); +export const IPC_WEBVIEW_API = new WebViewApiService({channel: `${process.env.APP_ENV_PACKAGE_NAME}:webview-api`}); diff --git a/src/webpack/lib/index.ts b/src/webpack/lib/index.ts index ed33f71cb..2bd77afe7 100644 --- a/src/webpack/lib/index.ts +++ b/src/webpack/lib/index.ts @@ -22,7 +22,7 @@ const srcPath = (...value: string[]) => rootPath("./src", ...value); const outputPath = (...value: string[]) => rootPath(environmentSate.development ? "./app-dev" : "./app", ...value); // tslint:disable:no-var-requires -const {name: packageName} = require(rootPath("./package.json")); +const packageJson = require(rootPath("./package.json")); const buildConfig: BuildConfig = (config, options = {}) => { const {tsConfigFile} = {tsConfigFile: rootPath("./tsconfig.json"), ...options}; @@ -35,7 +35,9 @@ const buildConfig: BuildConfig = (config, options = {}) => { plugins: [ new webpack.DefinePlugin({ "process.env.NODE_ENV": JSON.stringify(environment), - "process.env.APP_ENV_PACKAGE_NAME": JSON.stringify(packageName), + "process.env.APP_ENV_PACKAGE_NAME": JSON.stringify(packageJson.name), + "process.env.APP_ENV_PACKAGE_DESCRIPTION": JSON.stringify(packageJson.description), + "process.env.APP_ENV_PACKAGE_BUGS_URL": JSON.stringify(packageJson.bugs.url), }), ], resolve: { diff --git a/yarn.lock b/yarn.lock index d51d38a60..7c1174113 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5273,12 +5273,6 @@ is-observable@^1.1.0: dependencies: symbol-observable "^1.1.0" -is-odd@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/is-odd/-/is-odd-2.0.0.tgz#7646624671fd7ea558ccd9a2795182f2958f1b24" - dependencies: - is-number "^4.0.0" - is-path-cwd@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/is-path-cwd/-/is-path-cwd-1.0.0.tgz#d225ec23132e89edd38fda767472e62e65f1106d" @@ -6609,15 +6603,14 @@ nan@^2.10.0, nan@^2.4.0, nan@^2.9.2: resolved "https://registry.yarnpkg.com/nan/-/nan-2.10.0.tgz#96d0cd610ebd58d4b4de9cc0c6828cda99c7548f" nanomatch@^1.2.9: - version "1.2.9" - resolved "https://registry.yarnpkg.com/nanomatch/-/nanomatch-1.2.9.tgz#879f7150cb2dab7a471259066c104eee6e0fa7c2" + version "1.2.13" + resolved "https://registry.yarnpkg.com/nanomatch/-/nanomatch-1.2.13.tgz#b87a8aa4fc0de8fe6be88895b38983ff265bd119" dependencies: arr-diff "^4.0.0" array-unique "^0.3.2" define-property "^2.0.2" extend-shallow "^3.0.2" fragment-cache "^0.2.1" - is-odd "^2.0.0" is-windows "^1.0.2" kind-of "^6.0.2" object.pick "^1.3.0"