Skip to content
This repository was archived by the owner on Sep 28, 2023. It is now read-only.

Commit e15a66e

Browse files
authored
Upgrades (#574)
* Added security fixes * More updates to apis * Added inoreader refresh token
1 parent 9f53116 commit e15a66e

22 files changed

+554
-283
lines changed

package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727
"axios": "^0.21.1",
2828
"bootstrap": "^4.0.0",
2929
"bootstrap-vue": "^2.16.0",
30-
"core-js": "^3.8.1",
30+
"btoa": "^1.2.1",
31+
"core-js": "^3.13.1",
3132
"cross-fetch": "^3.1.3-alpha.6",
3233
"crypto-js": "^4.0.0",
3334
"dayjs": "^1.8.31",
@@ -39,6 +40,7 @@
3940
"electron-util": "^0.16.0",
4041
"fast-xml-parser": "^3.18.0",
4142
"feather-icons": "^4.28.0",
43+
"form-data": "^4.0.0",
4244
"fuse.js": "^6.4.1",
4345
"global-agent": "^2.1.12",
4446
"i18next": "^20.1.0",
@@ -47,7 +49,7 @@
4749
"i18next-electron-language-detector": "^0.0.10",
4850
"i18next-fs-backend": "^1.0.8",
4951
"jquery": "^3.6.0",
50-
"js-yaml": "^4.0.0",
52+
"js-yaml": "^4.1.0",
5153
"lovefield": "^2.1.12",
5254
"md5": "^2.3.0",
5355
"node-schedule": "^2.0.0",
@@ -83,7 +85,7 @@
8385
"@vue/eslint-config-standard": "^6.0.0",
8486
"babel-eslint": "^10.1.0",
8587
"devtron": "^1.4.0",
86-
"electron": "12.0.0",
88+
"electron": "^12.0.9",
8789
"electron-builder-notarize": "^1.2.0",
8890
"electron-devtools-installer": "^3.1.0",
8991
"electron-icon-builder": "^2.0.1",
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"Connect Feedbin":"Connect Feedbin","Log into Feedbin":"Log into Feedbin","Connect Self-hosted (Google Reader API)":"Connect Self-hosted (Google Reader API)","Log into Self Hosted RSS Service":"Log into Self Hosted RSS Service","Enter username":"Enter username","Connect Fever":"Connect Fever","Log into Fever":"Log into Fever","No categories available":"No categories available","Feed in this categories would not be deleted":"Feed in this categories would not be deleted","Please select atleast one feed":"Please select atleast one feed","Title":"Title","Feed":"Feed","Articles":"Articles","Action":"Action","Unsubscribe":"Unsubscribe","Articles inside this feed would be deleted":"Articles inside this feed would be deleted","Category cannot be empty":{"":"Category cannot be empty."},"Category":"Category","Manage Categories":"Manage Categories","Manage Feeds":"Manage Feeds","Please subscribe to atleast one feed to add category":"Please subscribe to atleast one feed to add category","No feeds available":"No feeds available","Add new feed":"Add new feed","Disconnect Fever":"Disconnect Fever"}
1+
{"Connect Feedbin":"Connect Feedbin","Log into Feedbin":"Log into Feedbin","Connect Self-hosted (Google Reader API)":"Connect Self-hosted (Google Reader API)","Log into Self Hosted RSS Service":"Log into Self Hosted RSS Service","Enter username":"Enter username","Connect Fever":"Connect Fever","Log into Fever":"Log into Fever","No categories available":"No categories available","Feed in this categories would not be deleted":"Feed in this categories would not be deleted","Please select atleast one feed":"Please select atleast one feed","Title":"Title","Feed":"Feed","Articles":"Articles","Action":"Action","Unsubscribe":"Unsubscribe","Articles inside this feed would be deleted":"Articles inside this feed would be deleted","Category cannot be empty":{"":"Category cannot be empty."},"Category":"Category","Manage Categories":"Manage Categories","Manage Feeds":"Manage Feeds","Please subscribe to atleast one feed to add category":"Please subscribe to atleast one feed to add category","No feeds available":"No feeds available","Add new feed":"Add new feed","Disconnect Fever":"Disconnect Fever","Disconnect Self-hosted (Google Reader API)":"Disconnect Self-hosted (Google Reader API)","Copy link":"Copy link","Remove from favourite":"Remove from favourite","Edit Feedbin":"Edit Feedbin","Disconnect Feedbin":"Disconnect Feedbin","Disconnect pocket":"Disconnect pocket","Disconnect Instapaper":"Disconnect Instapaper"}

src/background.js

Lines changed: 139 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,14 @@ import contextMenu from 'electron-context-menu'
2323
import { autoUpdater } from 'electron-updater'
2424
import fs from 'fs'
2525
import path from 'path'
26-
import { URL } from 'url'
26+
import { URL, URLSearchParams } from 'url'
2727
import dayjs from 'dayjs'
2828
import i18nextMainBackend from './i18nmain.config'
29+
import {
30+
parseArticle
31+
} from './main/article'
32+
const btoa = require('btoa')
33+
const FormData = require('form-data')
2934
const i18nextBackend = require('i18next-electron-fs-backend')
3035

3136
const isDevelopment = process.env.NODE_ENV !== 'production'
@@ -67,7 +72,6 @@ async function createWindow () {
6772
// Use pluginOptions.nodeIntegration, leave this alone
6873
// See nklayman.github.io/vue-cli-plugin-electron-builder/guide/security.html#node-integration for more info
6974
webviewTag: true,
70-
webSecurity: false,
7175
nodeIntegration: process.env.ELECTRON_NODE_INTEGRATION,
7276
preload: path.join(__dirname, 'preload.js'),
7377
disableBlinkFeatures: 'Auxclick'
@@ -496,6 +500,139 @@ ipcMain.handle('context-menu', (event, arg) => {
496500
}
497501
})
498502

503+
ipcMain.handle('parse-article', async (event, url) => {
504+
return await parseArticle(url)
505+
})
506+
507+
ipcMain.handle('instapaper-login', async (event, data) => {
508+
const result = await axios.post('https://www.instapaper.com/api/authenticate', {}, {
509+
auth: data
510+
})
511+
return result.data
512+
})
513+
514+
ipcMain.handle('instapaper-save', async (event, data) => {
515+
const result = await axios.post(`https://www.instapaper.com/api/add?url=${data.url}`, {}, {
516+
auth: {
517+
username: data.username,
518+
password: data.password
519+
}
520+
})
521+
return result.data
522+
})
523+
524+
ipcMain.handle('save-pocket', async (event, data) => {
525+
const result = await axios.post('https://getpocket.com/v3/add', {
526+
url: data.url,
527+
access_token: data.credential.access_token,
528+
consumer_key: data.credential.consumer_key
529+
})
530+
return result.data
531+
})
532+
533+
ipcMain.handle('fever-login', async (event, data) => {
534+
const formData = new FormData()
535+
formData.append('api_key', data.formData)
536+
const config = {
537+
url: `${data.endpoint}?api`,
538+
method: 'post',
539+
data: formData,
540+
headers: {
541+
...formData.getHeaders()
542+
}
543+
}
544+
const result = await axios(config)
545+
return result.data
546+
})
547+
548+
ipcMain.handle('fever-endpoint-execute', async (event, data) => {
549+
const formData = new FormData()
550+
formData.append('api_key', data.formData)
551+
const result = await axios.post(data.endpoint, formData, {
552+
headers: {
553+
...formData.getHeaders()
554+
}
555+
})
556+
return result.data
557+
})
558+
559+
ipcMain.handle('google-login', async (event, data) => {
560+
const params = new URLSearchParams(data.formData)
561+
const result = await axios.post(data.endpoint, params.toString())
562+
return result.data
563+
})
564+
565+
ipcMain.handle('inoreader-endpoint-fetch', async (event, data) => {
566+
const result = await axios.get(data.endpoint, {
567+
headers: {
568+
Authorization: `Bearer ${data.access_token}`
569+
}
570+
})
571+
return result.data
572+
})
573+
574+
ipcMain.handle('inoreader-endpoint-refresh', async (event, data) => {
575+
const result = axios.post(data.endpoint, data.formData)
576+
return result.data
577+
})
578+
579+
ipcMain.handle('inoreader-endpoint-execute', async (event, data) => {
580+
const result = await axios.post(data.endpoint, data.formData, {
581+
headers: {
582+
Authorization: `Bearer ${data.access_token}`
583+
}
584+
})
585+
return result.data
586+
})
587+
588+
ipcMain.handle('google-endpoint-fetch', async (event, data) => {
589+
const result = await axios.get(data.endpoint, {
590+
headers: {
591+
Authorization: `GoogleLogin auth=${data.formData.auth}`
592+
}
593+
})
594+
return result.data
595+
})
596+
597+
ipcMain.handle('google-endpoint-execute', async (event, data) => {
598+
const result = await axios.post(data.endpoint, data.formData.data, {
599+
headers: {
600+
Authorization: `GoogleLogin auth=${data.formData.auth}`
601+
}
602+
})
603+
return result.data
604+
})
605+
606+
ipcMain.handle('feedbin-login', async (event, data) => {
607+
const result = await axios.get(data.endpoint, {
608+
auth: {
609+
username: data.creds.email,
610+
password: data.creds.password
611+
}
612+
})
613+
return result.data
614+
})
615+
616+
ipcMain.handle('feedbin-endpoint-fetch', async (event, data) => {
617+
const result = await axios.get(data.endpoint, {
618+
auth: {
619+
username: data.creds.email,
620+
password: data.creds.password
621+
}
622+
})
623+
return result.data
624+
})
625+
626+
ipcMain.handle('feedbin-endpoint-execute', async (event, data) => {
627+
const result = await axios.post(data.endpoint, data.formData, {
628+
auth: {
629+
username: data.creds.email,
630+
password: data.creds.password
631+
}
632+
})
633+
return result.data
634+
})
635+
499636
powerMonitor.on('resume', () => {
500637
win.webContents.send('power-resume')
501638
})

src/bridge/feedbin.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import {
2+
ipcRenderer
3+
} from 'electron'
4+
5+
export default {
6+
login: async (endpoint, creds) => {
7+
return await ipcRenderer.invoke('feedbin-login', {
8+
endpoint: endpoint,
9+
creds: {
10+
email: creds.email,
11+
password: creds.password
12+
}
13+
})
14+
},
15+
fetch: async (endpoint, creds) => {
16+
return await ipcRenderer.invoke('feedbin-endpoint-fetch', {
17+
endpoint: endpoint,
18+
creds: {
19+
email: creds.email,
20+
password: creds.password
21+
}
22+
})
23+
},
24+
post: async (endpoint, formData, creds) => {
25+
return await ipcRenderer.invoke('feedbin-endpoint-execute', {
26+
endpoint: endpoint,
27+
formData: formData,
28+
creds: {
29+
email: creds.email,
30+
password: creds.password
31+
}
32+
})
33+
}
34+
}

src/bridge/fever.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import {
2+
ipcRenderer
3+
} from 'electron'
4+
5+
export default {
6+
login: async (endpoint, formData) => {
7+
return await ipcRenderer.invoke('fever-login', {
8+
endpoint: endpoint,
9+
formData: formData
10+
})
11+
},
12+
post: async (endpoint, formData) => {
13+
return await ipcRenderer.invoke('fever-endpoint-execute', {
14+
endpoint: endpoint,
15+
formData: formData
16+
})
17+
}
18+
}

src/bridge/greader.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import {
2+
ipcRenderer
3+
} from 'electron'
4+
5+
export default {
6+
login: async (endpoint, formData) => {
7+
return await ipcRenderer.invoke('google-login', {
8+
endpoint: endpoint,
9+
formData: formData
10+
})
11+
},
12+
fetch: async (endpoint, formData) => {
13+
return await ipcRenderer.invoke('google-endpoint-fetch', {
14+
endpoint: endpoint,
15+
formData: formData
16+
})
17+
},
18+
post: async (endpoint, formData) => {
19+
return await ipcRenderer.invoke('google-endpoint-execute', {
20+
endpoint: endpoint,
21+
formData: formData
22+
})
23+
}
24+
}

src/bridge/inoreader.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import {
2+
ipcRenderer
3+
} from 'electron'
4+
5+
export default {
6+
fetch: async (endpoint, accessToken) => {
7+
return await ipcRenderer.invoke('inoreader-endpoint-fetch', {
8+
endpoint: endpoint,
9+
access_token: accessToken.access_token
10+
})
11+
},
12+
refresh: async (endpoint, formData) => {
13+
return await ipcRenderer.invoke('inoreader-endpoint-refresh', {
14+
endpoint: endpoint,
15+
formData: formData
16+
})
17+
},
18+
post: async (endpoint, formData, accessToken) => {
19+
return await ipcRenderer.invoke('inoreader-endpoint-execute', {
20+
endpoint: endpoint,
21+
formData: formData,
22+
access_token: accessToken.access_token
23+
})
24+
}
25+
}

src/bridge/instapaper.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import {
2+
ipcRenderer
3+
} from 'electron'
4+
5+
export default {
6+
login: async (username, password) => {
7+
return await ipcRenderer.invoke('instapaper-login', {
8+
username: username,
9+
password: password
10+
})
11+
},
12+
save: async (url, username, password) => {
13+
return await ipcRenderer.invoke('instapaper-save', {
14+
url: url,
15+
username: username,
16+
password: password
17+
})
18+
}
19+
}

src/bridge/mercury.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import {
2+
ipcRenderer
3+
} from 'electron'
4+
5+
export default {
6+
parseArticle: async (url) => {
7+
return await ipcRenderer.invoke('parse-article', url)
8+
}
9+
}

src/bridge/pocket.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import {
2+
ipcRenderer
3+
} from 'electron'
4+
5+
export default {
6+
save: async (url, credential) => {
7+
return await ipcRenderer.invoke('save-pocket', {
8+
url: url,
9+
credential: credential
10+
})
11+
}
12+
}

0 commit comments

Comments
 (0)