Skip to content

Commit df6c2a6

Browse files
committed
removed secretStuff directory, from now on sensitive info will be stored in .env file -- follow instructions in .env.example
1 parent cd0a43e commit df6c2a6

File tree

7 files changed

+62
-106
lines changed

7 files changed

+62
-106
lines changed

.env.example

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#DO NOT DELETE THIS FILE, and follow instructions:
2+
# Required for Slack Oauth features
3+
# Create a file named .env in this directory, and give it the following values
4+
# Any variable you create in .env, you must create an example for here in .env.example
5+
SLACK_CLIENT_SECRET = "ENTER_CLIENT_SECRET_HERE",
6+
SLACK_CLIENT_ID = "ENTER_CLIENT_ID_HERE"
7+
8+
# https://www.npmjs.com/package/dotenv
9+
# https://www.npmjs.com/package/quasar-dotenv
10+
# https://v1.quasar.dev/quasar-cli/handling-process-env
11+
# https://v1.quasar.dev/quasar-cli/quasar-conf-js#using-dotenv

package-lock.json

Lines changed: 32 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
"npm": "^6.14.14",
3939
"prismjs": "^1.24.1",
4040
"quasar": "^1.0.0",
41+
"quasar-dotenv": "^1.0.5",
4142
"vue-custom-context-menu": "^3.0.1",
4243
"vue-drag-resize": "^1.3.2",
4344
"vue-draggable-nested-tree": "^2.2.17",

quasar.conf.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// https://quasar.dev/quasar-cli/quasar-conf-js
33

44
module.exports = function (ctx) {
5-
console.log('webpack\'s context parameter: ', ctx)
5+
const env = require('quasar-dotenv').config()
66
return {
77
// app boot file (/src/boot)
88
// --> boot files are part of "main.js"
@@ -80,7 +80,7 @@ module.exports = function (ctx) {
8080
supportIE: false,
8181

8282
build: {
83-
scopeHoisting: true,
83+
// scopeHoisting: true,
8484
// vueRouterMode: 'history',
8585
// vueCompiler: true,
8686
// gzip: true,
@@ -96,7 +96,8 @@ module.exports = function (ctx) {
9696
// formatter: require('eslint').CLIEngine.getFormatter('stylish')
9797
// }
9898
// })
99-
}
99+
},
100+
env: env,
100101
},
101102

102103
devServer: {

secretStuff/secretStuff_instructions.txt

Lines changed: 0 additions & 10 deletions
This file was deleted.

src-electron/main-process/electron-main.js

Lines changed: 13 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,6 @@ import { Deeplink } from "electron-deeplink";
33
import isDev from "electron-is-dev";
44
import jwt_decode from 'jwt-decode';
55

6-
import slackApiStuff from "../../secretStuff/slackApiStuff";
7-
8-
const clientId = slackApiStuff.clientId;
9-
const clientSecret = slackApiStuff.clientSecret;
10-
import dotenv from "dotenv";
11-
dotenv.config();
12-
136
/**
147
* Set `__statics` path to static files in production;
158
* The reason we are setting it here is that the path needs to be evaluated at runtime
@@ -22,7 +15,9 @@ if (process.env.PROD) {
2215

2316
let mainWindow;
2417
let authCode;
18+
const protocol = isDev ? "overvuedev" : "overvue";
2519

20+
// Used to console log for main process in production mode
2621
function logEverywhere(toBeLogged) {
2722
if (isDev) {
2823
console.log(toBeLogged);
@@ -36,69 +31,24 @@ function logEverywhere(toBeLogged) {
3631
}
3732
}
3833

39-
const protocol = isDev ? "overvuedev" : "overvue";
4034
const deeplink = new Deeplink({
4135
app,
4236
mainWindow,
4337
protocol,
4438
isDev,
45-
debugLogging: true,
46-
electronPath: "../../node_modules/electron/dist/electron.exe"
39+
debugLogging: true
4740
});
48-
// ipcMain.handle('slackAuth', slackAuth)
49-
50-
// function customDeepLink() {
51-
// let deeplinkingUrl;
52-
53-
// if (isDev && process.platform === 'win32') {
54-
// // Set the path of electron.exe and your app.
55-
// // These two additional parameters are only available on windows.
56-
// // Setting this is required to get this working in dev mode.
57-
// app.setAsDefaultProtocolClient('overvuedev', process.execPath, [
58-
// resolve(process.argv[1])
59-
// ]);
60-
// } else {
61-
// app.setAsDefaultProtocolClient('overvue');
62-
// }
63-
64-
// app.on('open-url', function (event, url) {
65-
// event.preventDefault();
66-
// deeplinkingUrl = url;
67-
// });
68-
69-
// // Force single application instance
70-
// const gotTheLock = app.requestSingleInstanceLock();
71-
72-
// if (!gotTheLock) {
73-
// app.quit();
74-
// return;
75-
// } else {
76-
// app.on('second-instance', (e, argv) => {
77-
// if (process.platform !== 'darwin') {
78-
// // Find the arg that is our custom protocol url and store it
79-
// deeplinkingUrl = argv.find((arg) => arg.startsWith('overvuedev://test'));
80-
// }
81-
82-
// if (myWindow) {
83-
// if (myWindow.isMinimized()) myWindow.restore();
84-
// myWindow.focus();
85-
// }
86-
// })
87-
// }
88-
// }
8941

9042
function getSlackAuth() {
9143
logEverywhere("inside getSlackAuth");
92-
// let chunkedTogether = ''
9344

9445
const authData = {
95-
client_id: clientId,
96-
client_secret: clientSecret,
46+
client_id: process.env.SLACK_CLIENT_ID,
47+
client_secret: process.env.SLACK_CLIENT_SECRET,
9748
code: authCode,
9849
redirect_uri: isDev ? "overvuedev://test" : "overvue://slack"
9950
};
10051
logEverywhere(authData.code);
101-
// https://slack.com/api/openid.connect.token?client_id=2696943977700.2696948669268&client_secret=6a6206cc93da2e49243ee9683f958438&code=2696943977700.2713919388452.23b787dec24adec68eeca105f6b7d6e517425de1033a1b6bc5ba3e116b933619&redirect_uri=overvue://slack
10252
const url =
10353
"https://slack.com/api/openid.connect.token?" +
10454
"client_id=" +
@@ -121,31 +71,16 @@ function getSlackAuth() {
12171
});
12272

12373
request.on("response", response => {
124-
logEverywhere(`STATUS: ${response.statusCode}`)
125-
// logEverywhere(`HEADERS: ${JSON.stringify(response.headers)})`) //error
126-
// let body;
127-
logEverywhere("request.on response received");
128-
// logEverywhere('SEND #1')
129-
// mainWindow.webContents.send("tokenReceived", response);
130-
131-
// logEverywhere('STATUS: ', response.statusCode)
132-
// logEverywhere(`HEADERS: ${JSON.stringify(response.headers)}`)
74+
// logEverywhere("request.on response received");
13375
response.on("end", () => {
13476
logEverywhere("Response ended ");
13577
});
13678
response.on("data", data => {
137-
// logEverywhere(`response.on datas CHUNK: ${chunk}`)
138-
// logEverywhere("chunked");
139-
// logEverywhere(`data.id_token: ${data.id_token}`);
140-
// body = data;
14179
logEverywhere("res on data ");
14280
const decoded = JSON.parse(data.toString())
14381
decoded.id_token = jwt_decode(decoded.id_token)
144-
145-
// chunkedTogether += data
146-
14782
// logEverywhere(data + ')'); //error
148-
logEverywhere(`decoded: ${decoded}`)
83+
logEverywhere(`decoded in response.on data: ${decoded}`)
14984
logEverywhere('SEND #2')
15085
mainWindow.webContents.send("tokenReceived", decoded);
15186
});
@@ -154,19 +89,19 @@ function getSlackAuth() {
15489
}
15590

15691
function getSlackToken() {
92+
logEverywhere(`process.env.SLACK_CLIENT_ID in electron-main: ${process.env.SLACK_CLIENT_ID}`);
93+
logEverywhere(`process.env.SLACK_CLIENT_SECRET in electron-main: ${process.env.SLACK_CLIENT_SECRET}`);
15794
return deeplink.on("received", link => {
158-
logEverywhere(`auth worked here link: ${link}`);
95+
// logEverywhere(`auth worked here link: ${link}`);
15996
authCode = link.split("=")[1];
160-
// authCode = link.split("=")[1].split(".")[2];
16197
getSlackAuth();
16298
});
16399
}
164-
// overvue://lkjasdgjkasdg-235235235.235235235.235235235235235235235235
165100

166101
function createWindow() {
167102
/**
168-
* Initial window options
169-
*/
103+
* Initial window options
104+
*/
170105

171106
mainWindow = new BrowserWindow({
172107
width: 1000,
@@ -178,7 +113,7 @@ function createWindow() {
178113
}
179114
});
180115

181-
logEverywhere(`current protocol ${deeplink.getProtocol()}`);
116+
logEverywhere(`Current deeplink Protocol: ${deeplink.getProtocol()}`);
182117
mainWindow.loadURL(process.env.APP_URL);
183118

184119
mainWindow.on("closed", () => {
@@ -189,7 +124,6 @@ function createWindow() {
189124
app.on("ready", () => {
190125
createWindow();
191126
getSlackToken();
192-
logEverywhere(`process.env.CLIENT_ID: ${process.env.CLIENT_ID}`);
193127
});
194128

195129
app.on("window-all-closed", () => {
@@ -202,6 +136,5 @@ app.on("activate", () => {
202136
if (mainWindow === null) {
203137
createWindow();
204138
getSlackToken();
205-
logEverywhere(`process.env: ${process.env}`);
206139
}
207140
});

src/components/slack_login/SlackLoginWindow.vue

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,10 @@
3535
</div>
3636
</template>
3737

38-
39-
40-
4138
<script>
4239
// import { mapState, mapActions } from 'vuex'
4340
import localforage from 'localforage'
4441
import { shell, ipcRenderer } from 'electron'
45-
import slackApiStuff from '../../../secretStuff/slackApiStuff.js'
4642
4743
export default {
4844
name: 'SlackLoginWindow',
@@ -54,32 +50,24 @@ export default {
5450
},
5551
created () {
5652
ipcRenderer.on('tokenReceived', (event, data) => {
57-
// JSON.parse(data).then(output => {
58-
// console.log('PARSED DATA: ', output)
59-
// })
6053
console.log('data in SlackLoginWindow: ', data)
6154
})
6255
},
6356
methods: {
6457
slackOauth: function () {
6558
const slackBaseUrl = 'https://slack.com/openid/connect/authorize'
66-
// const slackBaseUrl = 'https://slack.com/oauth/v2/authorize'
6759
const responseType = 'code'
6860
const scope = 'openid profile'
69-
const clientId = slackApiStuff.clientId
61+
const clientId = process.env.SLACK_CLIENT_ID
7062
const redirectUri = process.env.DEV ? 'overvuedev://test' : 'overvue://slack'
71-
// const redirectUri = 'overvue://slack'
7263
7364
this.isAuthenticating = true;
7465
7566
console.log('clicked')
76-
// window.open(this.oauthURL, '_blank')
7767
shell.openExternal(
7868
`${slackBaseUrl}?response_type=${responseType}&scope=${scope}&client_id=${clientId}&redirect_uri=${redirectUri}`,
7969
{ activate: true }
8070
)
81-
// .then(data => console.log(data))
82-
// .then(data => )
8371
},
8472
closeLogin: function () {
8573
this.showLogin = false

0 commit comments

Comments
 (0)