mirror of https://github.com/keeweb/keeweb.git
creating browser socket in a group container on macOS
This commit is contained in:
parent
dc5ada1c04
commit
566e2fb35d
|
@ -47,7 +47,8 @@ module.exports = function (grunt) {
|
||||||
const webpackOptions = {
|
const webpackOptions = {
|
||||||
date,
|
date,
|
||||||
beta: !!grunt.option('beta'),
|
beta: !!grunt.option('beta'),
|
||||||
sha
|
sha,
|
||||||
|
appleTeamId: getCodeSignConfig()?.teamId
|
||||||
};
|
};
|
||||||
|
|
||||||
const windowsAppVersionString = {
|
const windowsAppVersionString = {
|
||||||
|
@ -755,7 +756,7 @@ module.exports = function (grunt) {
|
||||||
cmakeConfigure: ['-DCMAKE_OSX_ARCHITECTURES=x86_64']
|
cmakeConfigure: ['-DCMAKE_OSX_ARCHITECTURES=x86_64']
|
||||||
},
|
},
|
||||||
files: {
|
files: {
|
||||||
'tmp/desktop/KeeWeb-darwin-x64/KeeWeb.app/Contents/MacOS/keeweb-native-messaging-host':
|
'tmp/desktop/KeeWeb-darwin-x64/KeeWeb.app/Contents/MacOS/util/keeweb-native-messaging-host':
|
||||||
'extension/native-messaging-host'
|
'extension/native-messaging-host'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -765,7 +766,7 @@ module.exports = function (grunt) {
|
||||||
cmakeConfigure: ['-DCMAKE_OSX_ARCHITECTURES=arm64']
|
cmakeConfigure: ['-DCMAKE_OSX_ARCHITECTURES=arm64']
|
||||||
},
|
},
|
||||||
files: {
|
files: {
|
||||||
'tmp/desktop/KeeWeb-darwin-arm64/KeeWeb.app/Contents/MacOS/keeweb-native-messaging-host':
|
'tmp/desktop/KeeWeb-darwin-arm64/KeeWeb.app/Contents/MacOS/util/keeweb-native-messaging-host':
|
||||||
'extension/native-messaging-host'
|
'extension/native-messaging-host'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -55,9 +55,21 @@ const BrowserExtensionConnector = {
|
||||||
window.removeEventListener('message', this.browserWindowMessage);
|
window.removeEventListener('message', this.browserWindowMessage);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
isSocketNameTooLong(socketName) {
|
||||||
|
const maxLength = process.platform === 'win32' ? 256 : 104;
|
||||||
|
return socketName.length > maxLength;
|
||||||
|
},
|
||||||
|
|
||||||
startDesktopAppListener() {
|
startDesktopAppListener() {
|
||||||
Launcher.closeOldBrowserExtensionSocket(() => {
|
Launcher.prepareBrowserExtensionSocket(() => {
|
||||||
const sockName = Launcher.getBrowserExtensionSocketName();
|
const sockName = Launcher.getBrowserExtensionSocketName();
|
||||||
|
if (this.isSocketNameTooLong(sockName)) {
|
||||||
|
logger.error(
|
||||||
|
"Socket name is too big, browser connection won't be possible, probably OS username is very long.",
|
||||||
|
sockName
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
const { createServer } = Launcher.req('net');
|
const { createServer } = Launcher.req('net');
|
||||||
this.connectedSockets = [];
|
this.connectedSockets = [];
|
||||||
this.connectedSocketState = new WeakMap();
|
this.connectedSocketState = new WeakMap();
|
||||||
|
|
|
@ -290,16 +290,23 @@ const Launcher = {
|
||||||
return this.getMainWindow().isMaximized();
|
return this.getMainWindow().isMaximized();
|
||||||
},
|
},
|
||||||
getBrowserExtensionSocketName() {
|
getBrowserExtensionSocketName() {
|
||||||
const userInfo = this.req('os').userInfo();
|
const { username, uid } = this.req('os').userInfo();
|
||||||
if (process.platform === 'win32') {
|
if (process.platform === 'darwin') {
|
||||||
return `\\\\.\\pipe\\keeweb-browser-${userInfo.username}`;
|
const teamId = RuntimeInfo.appleTeamId;
|
||||||
|
return `/Users/${username}/Library/Group Containers/${teamId}.keeweb/browser.sock`;
|
||||||
|
} else if (process.platform === 'win32') {
|
||||||
|
return `\\\\.\\pipe\\keeweb-browser-${username}`;
|
||||||
} else {
|
} else {
|
||||||
const sockFileName = `keeweb-browser-${userInfo.uid}.sock`;
|
const sockFileName = `keeweb-browser-${uid}.sock`;
|
||||||
return this.joinPath(this.remoteApp().getPath('temp'), sockFileName);
|
return this.joinPath(this.remoteApp().getPath('temp'), sockFileName);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
closeOldBrowserExtensionSocket(done) {
|
prepareBrowserExtensionSocket(done) {
|
||||||
if (process.platform === 'win32') {
|
if (process.platform === 'darwin') {
|
||||||
|
const dir = this.req('path').dirname(this.getBrowserExtensionSocketName());
|
||||||
|
const fs = this.req('fs');
|
||||||
|
fs.mkdir(dir, () => done());
|
||||||
|
} else if (process.platform === 'win32') {
|
||||||
done();
|
done();
|
||||||
} else {
|
} else {
|
||||||
this.deleteFile(this.getBrowserExtensionSocketName(), done);
|
this.deleteFile(this.getBrowserExtensionSocketName(), done);
|
||||||
|
|
|
@ -3,7 +3,8 @@ const RuntimeInfo = {
|
||||||
beta: !!'@@BETA',
|
beta: !!'@@BETA',
|
||||||
buildDate: '@@DATE',
|
buildDate: '@@DATE',
|
||||||
commit: '@@COMMIT',
|
commit: '@@COMMIT',
|
||||||
devMode: '@@DEVMODE'
|
devMode: '@@DEVMODE',
|
||||||
|
appleTeamId: '@@APPLE_TEAM_ID'
|
||||||
};
|
};
|
||||||
|
|
||||||
export { RuntimeInfo };
|
export { RuntimeInfo };
|
||||||
|
|
|
@ -130,7 +130,8 @@ function config(options) {
|
||||||
search: /@@COMMIT/g,
|
search: /@@COMMIT/g,
|
||||||
replace: options.sha
|
replace: options.sha
|
||||||
},
|
},
|
||||||
{ search: /@@DEVMODE/g, replace: devMode ? '1' : '' }
|
{ search: /@@DEVMODE/g, replace: devMode ? '1' : '' },
|
||||||
|
{ search: /@@APPLE_TEAM_ID/g, replace: options.appleTeamId }
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -204,6 +204,9 @@ std::string keeweb_pipe_name() {
|
||||||
} else {
|
} else {
|
||||||
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32)
|
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32)
|
||||||
pipe_name = "\\\\.\\pipe\\keeweb-browser-" + std::string{user_info.username};
|
pipe_name = "\\\\.\\pipe\\keeweb-browser-" + std::string{user_info.username};
|
||||||
|
#elif __APPLE__
|
||||||
|
pipe_name = "/Users/" + std::string{user_info.username} +
|
||||||
|
"/Library/Group Containers/3LE7JZ657W.keeweb/browser.sock";
|
||||||
#else
|
#else
|
||||||
pipe_name = std::filesystem::temp_directory_path() /
|
pipe_name = std::filesystem::temp_directory_path() /
|
||||||
("keeweb-browser-" + std::to_string(user_info.uid) + ".sock");
|
("keeweb-browser-" + std::to_string(user_info.uid) + ".sock");
|
||||||
|
|
|
@ -11,7 +11,10 @@ describe('KeeWeb extension native module host', function () {
|
||||||
const userInfo = os.userInfo();
|
const userInfo = os.userInfo();
|
||||||
let sockPath;
|
let sockPath;
|
||||||
let hostPath;
|
let hostPath;
|
||||||
if (process.platform === 'win32') {
|
if (process.platform === 'darwin') {
|
||||||
|
sockPath = `/Users/${userInfo.username}/Library/Group Containers/3LE7JZ657W.keeweb/browser.sock`;
|
||||||
|
hostPath = 'build/keeweb-native-messaging-host';
|
||||||
|
} else if (process.platform === 'win32') {
|
||||||
sockPath = `\\\\.\\pipe\\keeweb-browser-${userInfo.username}`;
|
sockPath = `\\\\.\\pipe\\keeweb-browser-${userInfo.username}`;
|
||||||
hostPath = 'build\\Debug\\keeweb-native-messaging-host.exe';
|
hostPath = 'build\\Debug\\keeweb-native-messaging-host.exe';
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -12,6 +12,10 @@
|
||||||
<array>
|
<array>
|
||||||
<string>3LE7JZ657W.net.antelle.keeweb</string>
|
<string>3LE7JZ657W.net.antelle.keeweb</string>
|
||||||
</array>
|
</array>
|
||||||
|
<key>com.apple.security.application-groups</key>
|
||||||
|
<array>
|
||||||
|
<string>3LE7JZ657W.keeweb</string>
|
||||||
|
</array>
|
||||||
<key>com.apple.application-identifier</key>
|
<key>com.apple.application-identifier</key>
|
||||||
<string>3LE7JZ657W.net.antelle.keeweb</string>
|
<string>3LE7JZ657W.net.antelle.keeweb</string>
|
||||||
<key>com.apple.developer.team-identifier</key>
|
<key>com.apple.developer.team-identifier</key>
|
||||||
|
|
Loading…
Reference in New Issue