feat: app image + cookie

fix: password stuff
This commit is contained in:
Thomas Zarebczan 2020-01-14 23:34:28 -05:00 committed by Sean Yesmunt
parent d256d9eac1
commit 939a7d7689
9 changed files with 39 additions and 68 deletions

View file

@ -50,7 +50,7 @@ addons:
artifacts:
working_dir: dist
paths:
- $(git ls-files -o dist/{*.dmg,*.exe,*.deb} | tr "\n" ":")
- $(git ls-files -o dist/{*.dmg,*.exe,*.deb,*.AppImage} | tr "\n" ":")
target_paths:
- '/app/build-${TRAVIS_BUILD_NUMBER}_commit-${TRAVIS_COMMIT:0:7}$([ ! -z ${TRAVIS_TAG}
] && echo _tag-${TRAVIS_TAG})'

View file

@ -73,7 +73,7 @@
}
],
"linux": {
"target": "deb",
"target": ["AppImage", "deb"],
"executableName": "lbry",
"category": "AudioVideo;Video",
"desktop": {

View file

@ -318,17 +318,14 @@ ipcMain.on('version-info-requested', () => {
requestLatestRelease();
});
// In a few months, we can remove the keytar dependency and below calls once
// enough users have moved over to cookies
ipcMain.on('get-auth-token', event => {
keytar.getPassword('LBRY', 'auth_token').then(token => {
event.sender.send('auth-token-response', token ? token.toString().trim() : null);
});
});
ipcMain.on('set-auth-token', (event, token) => {
keytar.setPassword('LBRY', 'auth_token', token ? token.toString().trim() : null);
});
ipcMain.on('delete-auth-token', (event, password) => {
keytar.deletePassword('LBRY', 'auth_token', password).then(res => {
event.sender.send('delete-auth-token-response', res);

View file

@ -109,10 +109,6 @@ Lbryio.setOverride(
authToken = response.auth_token;
setAuthToken(authToken);
// @if TARGET='app'
ipcRenderer.send('set-auth-token', authToken);
// @endif
resolve(authToken);
});
})
@ -123,6 +119,10 @@ Lbryio.setOverride(
() =>
new Promise(resolve => {
// @if TARGET='app'
// NEED TO DO SOMETHING HERE TO CHECK FOR A COOKIE AUTH TOKEN.
// IF IT EXISTS, SKIP AND CONTINUE BELOW THE @ENDIF
// IF NOT, COPY THE KEYTAR AUTH TOKEN AND PASSWORD TO THE COOKIE (SetAuthToken/SetPassword?)
// AND THEN DELETE KEYTAR ONE (Or leave for now?)
if (authToken) {
resolve(authToken);
}
@ -135,7 +135,6 @@ Lbryio.setOverride(
ipcRenderer.send('get-auth-token');
// @endif
// @if TARGET='web'
const authTokenToReturn = authToken || getAuthToken();
if (authTokenToReturn !== null) {
@ -143,7 +142,6 @@ Lbryio.setOverride(
}
resolve(authTokenToReturn);
// @endif
})
);
@ -245,7 +243,7 @@ function AppWrapper() {
console.error(error.message); // eslint-disable-line no-console
});
if (['win32', 'darwin'].includes(process.platform)) {
if (['win32', 'darwin'].includes(process.platform) || !!process.env.APPIMAGE) {
autoUpdater.on('update-available', () => {
console.log('Update available'); // eslint-disable-line no-console
});

View file

@ -33,6 +33,12 @@ class ModalDownloading extends React.PureComponent<Props> {
</p>
<blockquote>sudo dpkg -i {downloadItem}</blockquote>
<p>{__('After the install is complete, please reopen the app.')}</p>
<p>
{__('Note: You can also install the AppImage version for streamlined updates.')}{' '}
<span style={{ whiteSpace: 'nowrap' }}>
<Button button="link" label={__('Download here.')} href="https://lbry.com/get/lbry.AppImage" />
</span>
</p>
</React.Fragment>
) : null}

View file

@ -111,6 +111,9 @@ class HelpPage extends React.PureComponent<Props, State> {
platform = `${osName} ${ver.os_release}`;
newVerLink = 'https://lbry.com/get/lbry.dmg';
} else if (process.env.APPIMAGE !== undefined) {
platform = `Linux (AppImage)`;
newVerLink = 'https://lbry.com/get/lbry.AppImage';
} else if (ver.os_system === 'Linux') {
platform = `Linux (${ver.platform})`;
newVerLink = 'https://lbry.com/get/lbry.deb';

View file

@ -103,7 +103,7 @@ class SettingsPage extends React.PureComponent<Props, State> {
componentDidMount() {
const { isAuthenticated } = this.props;
if (isAuthenticated) {
if (isAuthenticated || !IS_WEB) {
this.props.updateWalletStatus();
getKeychainPassword().then(p => {
if (typeof p === 'string') {
@ -416,7 +416,7 @@ class SettingsPage extends React.PureComponent<Props, State> {
}
/>
{isAuthenticated && (
{(isAuthenticated || !IS_WEB) && (
<Card
title={__('Blocked Channels')}
actions={

View file

@ -130,7 +130,7 @@ export function doDownloadUpgradeRequested() {
// the old logic.
return dispatch => {
if (['win32', 'darwin'].includes(process.platform)) {
if (['win32', 'darwin'].includes(process.platform) || !!process.env.APPIMAGE) {
// electron-updater behavior
dispatch(doOpenModal(MODALS.AUTO_UPDATE_DOWNLOADED));
} else {
@ -204,8 +204,8 @@ export function doCheckUpgradeAvailable() {
type: ACTIONS.CHECK_UPGRADE_START,
});
if (['win32', 'darwin'].includes(process.platform)) {
// On Windows and Mac, updates happen silently through
if (['win32', 'darwin'].includes(process.platform) || !!process.env.APPIMAGE) {
// On Windows, Mac, and AppImage, updates happen silently through
// electron-updater.
const autoUpdateDeclined = selectAutoUpdateDeclined(state);

View file

@ -3,6 +3,7 @@ import { ipcRenderer } from 'electron';
import { DOMAIN } from 'config';
const isProduction = process.env.NODE_ENV === 'production';
const maxExpiration = 2147483647;
let sessionPassword;
function setCookie(name: string, value: string, days: number) {
@ -10,7 +11,8 @@ function setCookie(name: string, value: string, days: number) {
if (days) {
let date = new Date();
date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);
expires = `expires=${date.toUTCString()};`;
// If on PC, set to not expire (max)
expires = `expires=${IS_WEB ? date.toUTCString() : maxExpiration};`;
}
let cookie = `${name}=${value || ''}; ${expires} path=/; SameSite=Lax;`;
@ -49,23 +51,12 @@ function deleteCookie(name: string) {
export const setSavedPassword = (value?: string, saveToDisk: boolean) => {
return new Promise<*>(resolve => {
// @if TARGET='app'
ipcRenderer.once('set-password-response', (event, success) => {
resolve(success);
});
// @endif
const password = value === undefined || value === null ? '' : value;
sessionPassword = password;
if (saveToDisk) {
if (password) {
// @if TARGET='app'
ipcRenderer.send('set-password', password);
// @endif
// @if TARGET='web'
setCookie('saved-password', password, 14);
// @endif
} else {
deleteSavedPassword();
}
@ -85,32 +76,28 @@ export const getSavedPassword = () => {
export const getKeychainPassword = () => {
return new Promise<*>(resolve => {
// @if TARGET='app'
ipcRenderer.once('get-password-response', (event, password) => {
resolve(password);
});
ipcRenderer.send('get-password');
// @endif
// @if TARGET='web'
const password = getCookie('saved-password');
resolve(password);
if (password) {
resolve(password);
}
// We can remove this when we remove keytar
else {
ipcRenderer.once('get-password-response', (event, password) => {
resolve(password);
});
ipcRenderer.send('get-password');
}
// @if TARGET='app'
// @endif
});
};
export const deleteSavedPassword = () => {
return new Promise<*>(resolve => {
// @if TARGET='app'
ipcRenderer.once('delete-password-response', (event, success) => {
resolve();
});
ipcRenderer.send('delete-password');
// @endif;
// @if TARGET='web'
deleteCookie('saved-password');
resolve();
// @endif
});
};
@ -125,17 +112,7 @@ export const setAuthToken = (value: string) => {
export const deleteAuthToken = () => {
return new Promise<*>(resolve => {
deleteCookie('auth_token');
// @if TARGET='app'
ipcRenderer.once('delete-auth-token-response', (event, success) => {
resolve();
});
ipcRenderer.send('delete-auth-token');
// @endif;
// @if TARGET='web'
resolve();
// @endif
});
};
@ -143,17 +120,7 @@ export const doSignOutCleanup = () => {
return new Promise<*>(resolve => {
deleteCookie('auth_token');
deleteCookie('saved-password');
// @if TARGET='app'
ipcRenderer.once('delete-auth-token-response', (event, success) => {
resolve();
});
ipcRenderer.send('delete-auth-token');
// @endif;
// @if TARGET='web'
resolve();
// @endif
});
};