1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-12-29 17:38:04 +01:00

Attempt to create NativeMessagingHosts directory if not already exist (#808)

This commit is contained in:
Oscar Hinton 2021-03-23 23:35:25 +01:00 committed by GitHub
parent 85f29e1222
commit 64da326be3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -93,12 +93,14 @@ export class NativeMessagingMain {
const nmhs = this.getDarwinNMHS(); const nmhs = this.getDarwinNMHS();
for (const [key, value] of Object.entries(nmhs)) { for (const [key, value] of Object.entries(nmhs)) {
if (existsSync(value)) { if (existsSync(value)) {
const p = path.join(value, 'com.8bit.bitwarden.json'); const p = path.join(value, 'NativeMessagingHosts', 'com.8bit.bitwarden.json');
let manifest: any = chromeJson;
if (key === 'Firefox') { if (key === 'Firefox') {
this.writeManifest(p, firefoxJson); manifest = firefoxJson;
} else {
this.writeManifest(p, chromeJson);
} }
this.writeManifest(p, manifest).catch(e => this.logService.error(`Error writing manifest for ${key}. ${e}`));
} else { } else {
this.logService.warning(`${key} not found skipping.`); this.logService.warning(`${key} not found skipping.`);
} }
@ -133,7 +135,7 @@ export class NativeMessagingMain {
case 'darwin': case 'darwin':
const nmhs = this.getDarwinNMHS(); const nmhs = this.getDarwinNMHS();
for (const [_, value] of Object.entries(nmhs)) { for (const [_, value] of Object.entries(nmhs)) {
const p = path.join(value, 'com.8bit.bitwarden.json'); const p = path.join(value, 'NativeMessagingHosts', 'com.8bit.bitwarden.json');
if (existsSync(p)) { if (existsSync(p)) {
fs.unlink(p); fs.unlink(p);
} }
@ -159,16 +161,16 @@ export class NativeMessagingMain {
private getDarwinNMHS() { private getDarwinNMHS() {
return { return {
'Firefox': `${this.homedir()}/Library/Application\ Support/Mozilla/NativeMessagingHosts/`, 'Firefox': `${this.homedir()}/Library/Application\ Support/Mozilla/`,
'Chrome': `${this.homedir()}/Library/Application\ Support/Google/Chrome/NativeMessagingHosts/`, 'Chrome': `${this.homedir()}/Library/Application\ Support/Google/Chrome/`,
'Chrome Beta': `${this.homedir()}/Library/Application\ Support/Google/Chrome\ Beta/NativeMessagingHosts/`, 'Chrome Beta': `${this.homedir()}/Library/Application\ Support/Google/Chrome\ Beta/`,
'Chrome Dev': `${this.homedir()}/Library/Application\ Support/Google/Chrome\ Dev/NativeMessagingHosts/`, 'Chrome Dev': `${this.homedir()}/Library/Application\ Support/Google/Chrome\ Dev/`,
'Chrome Canary': `${this.homedir()}/Library/Application\ Support/Google/Chrome\ Canary/NativeMessagingHosts/`, 'Chrome Canary': `${this.homedir()}/Library/Application\ Support/Google/Chrome\ Canary/`,
'Microsoft Edge': `${this.homedir()}/Library/Application\ Support/Microsoft\ Edge/NativeMessagingHosts/`, 'Microsoft Edge': `${this.homedir()}/Library/Application\ Support/Microsoft\ Edge/`,
'Microsoft Edge Beta': `${this.homedir()}/Library/Application\ Support/Microsoft\ Edge\ Beta/NativeMessagingHosts/`, 'Microsoft Edge Beta': `${this.homedir()}/Library/Application\ Support/Microsoft\ Edge\ Beta/`,
'Microsoft Edge Dev': `${this.homedir()}/Library/Application\ Support/Microsoft\ Edge\ Dev/NativeMessagingHosts/`, 'Microsoft Edge Dev': `${this.homedir()}/Library/Application\ Support/Microsoft\ Edge\ Dev/`,
'Microsoft Edge Canary': `${this.homedir()}/Library/Application\ Support/Microsoft\ Edge\ Canary/NativeMessagingHosts/`, 'Microsoft Edge Canary': `${this.homedir()}/Library/Application\ Support/Microsoft\ Edge\ Canary/`,
'Vivaldi': `${this.homedir()}/Library/Application\ Support/Vivaldi/NativeMessagingHosts/`, 'Vivaldi': `${this.homedir()}/Library/Application\ Support/Vivaldi/`,
}; };
} }