Skip to content

Commit

Permalink
Local updates for credential changes and GH issues
Browse files Browse the repository at this point in the history
  • Loading branch information
dacoaster committed Apr 25, 2023
1 parent cfba0ff commit 2c03bd8
Show file tree
Hide file tree
Showing 87 changed files with 4,537 additions and 1,611 deletions.
6 changes: 0 additions & 6 deletions .env

This file was deleted.

6 changes: 6 additions & 0 deletions .env.production
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
VUE_APP_I18N_LOCALE=en
VUE_APP_I18N_FALLBACK_LOCALE=en

VUE_APP_SERVER_PORT=64064

VUE_APP_YATT_API_URL="https://api.yatt.ai"
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "yattie",
"version": "0.5.5",
"version": "0.6.0",
"engines": {
"npm": ">=8.0.0 <9.0.0",
"node": ">=16.0.0 <17.0.0"
Expand All @@ -25,6 +25,10 @@
"main": "background.js",
"dependencies": {
"@fortawesome/fontawesome-free": "^6.2.1",
"@fortawesome/fontawesome-svg-core": "^6.4.0",
"@fortawesome/free-regular-svg-icons": "^6.4.0",
"@fortawesome/free-solid-svg-icons": "^6.4.0",
"@fortawesome/vue-fontawesome": "^2.0.10",
"@johmun/vue-tags-input": "^2.1.0",
"@peepi/vuetify-tiptap": "^1.2.3",
"adm-zip": "^0.5.9",
Expand All @@ -41,6 +45,7 @@
"fluent-ffmpeg": "^2.1.2",
"form-data": "^4.0.0",
"lodash": "^4.17.21",
"node-polyfill-webpack-plugin": "^2.0.1",
"simple-json-db": "^2.0.0",
"sinon": "^15.0.0",
"tui-image-editor": "^3.15.3",
Expand Down
81 changes: 81 additions & 0 deletions server/jira_error.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title>YATTIE</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@mdi/font@latest/css/materialdesignicons.min.css">
<link rel="icon" href="/favicon.ico">
<style>
body {
margin: 0;
background-color: #fafafa;
border-color: #fafafa;
}

.wrapper {
width: 100%;
min-height: 100vh;
}

.container {
padding: 12px;
padding-top: 80px;
margin-left: auto;
margin-right: auto;
}

.container .logo {
display: flex;
justify-content: center;
align-items: center;
margin-bottom: 1rem;
}

.container .notification {
display: flex;
justify-content: center;
align-items: center;
}

.container .notification span {
background-color: #fff;
border-color: #fff;
border-radius: 4px;
color: rgba(0, 0, 0, .87);
box-shadow: 0 3px 1px -2px rgba(0, 0, 0, .2), 0 2px 2px 0 rgba(0, 0, 0, .14), 0 1px 5px 0 rgba(0, 0, 0, .12) !important;
display: block;
font-size: 20px;
margin-bottom: 16px;
padding: 25px;
position: relative;
transition: .3s cubic-bezier(.25, .8, .5, 1);
border-left: 4px solid #6200ea;
}
</style>
</head>

<body>
<div class="wrapper">
<div class="container">
<div class="logo">
<img src="/logo.png" alt="logo" width="80">
</div>
<div class="notification">
<span>There was an issue while trying to authenticate via JIRA. The JIRA API returned a <span id="responseCode"></span> response code with the message: <span id="responseMessage"></span> Please try again!</span>
</div>
</div>
</div>
<script>
const url = new URL(window.location.href);
const codeSpan = document.getElementById("responseCode");
const messageSpan = document.getElementById("responseMessage");
codeSpan.innerText = url.searchParams.get("code");
codeMessage.innerText = url.searchParams.get("message");
</script>
</body>

</html>
File renamed without changes.
80 changes: 57 additions & 23 deletions server/modules/JiraUtility.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
const axios = require("axios");
const open = require("open");
const https = require("https");
const path = require("path");
const ClientOAuth2 = require("client-oauth2");
const port = process.env.VUE_APP_SERVER_PORT || 64064;

const auth = new ClientOAuth2({
clientId: "3tPI6y3UgOxjUUVd2ELL3mhZr6cGAatt",
clientSecret:
"ATOAHCxhe5I4NKjvZo_hnzLSS6N038CmfyUsdnoXHCI0e8el_dY_xrFmMFJVHMAfa14d8502F3BF",
accessTokenUri: "https://auth.atlassian.com/oauth/token",
authorizationUri:
"https://auth.atlassian.com/authorize?audience=api.atlassian.com&prompt=consent",
redirectUri: `http://localhost:${port}/oauth2/atlassian/callback`,
scopes: ["read:jira-work", "write:jira-work", "read:me", "offline_access"],
});

const clientId = process.env.clientId;
const clientSecret = process.env.clientSecret;
const serverURL = process.env.url;
const codeVerifier = process.env.codeVerifier;
const codeChallenge = process.env.codeChallenge;
const scopes = "WRITE";
const redirectURL = `http://localhost:${port}/oauth2/atlassian/callback`;

module.exports = (app) => {
app.use((req, res, next) => {
res.header(
Expand All @@ -23,21 +23,55 @@ module.exports = (app) => {
});

app.get("/oauth2/atlassian", (req, res) => {
var uri = auth.code.getUri();
open(uri, (err) => {
console.log(err);
});
var uri = encodeURI(
`https://${serverURL}/rest/oauth2/latest/authorize?client_id=${clientId}&redirect_uri=${redirectURL}&response_type=code&scope=${scopes}&code_challenge=${codeChallenge}&code_challenge_method=S256`
);
return res.send(uri);
});


app.get("/oauth2/atlassian/callback", (req, res) => {
auth.code.getToken(req.originalUrl).then((user) => {
const data = {
type: "jira",
accessToken: user.data,
};
process.send(data);

return res.sendFile(path.join(__dirname, "../jira.html"));
var uri = encodeURI(
`https://${serverURL}/rest/oauth2/latest/token?client_id=${clientId}&client_secret=${clientSecret}&code=${req.query.code}&grant_type=authorization_code&redirect_uri=${redirectURL}&code_verifier=${codeVerifier}`
);

const instance = axios.create({
httpsAgent: new https.Agent({
rejectUnauthorized: false,
}),
});

instance
.post(uri)
.then((data) => {
const responseData = {};
for(const [key, value] of Object.entries(data.data)) {
// Convert keys to camel case.
const newKey = key.toLowerCase().replace(/([-_][a-z0-9])/g, group =>
group
.toUpperCase()
.replace('-', '')
.replace('_', '')
);
responseData[newKey] = value;
}
responseData.type = "oauth";
responseData.url = serverURL;
responseData.clientId = clientId;
responseData.clientSecret = clientSecret;

process.send({
type: "jira",
data: {
jira: responseData,
},
});
return res.sendFile(path.join(__dirname, "../jira_success.html"));
})
.catch((error) => {
console.log(`Connection error: ${JSON.stringify(error)}`);
return res.sendFile(path.join(__dirname, `../jira_error.html?code=${error.response.status}&message=${encodeURI(error.message)}`));
});
});

};
3 changes: 1 addition & 2 deletions server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"name": "yattie-oauth-backend",
"version": "0.1.0",
"description": "Express backend for YATTIE OAuth",
"private": true,
"main": "server.js",
"scripts": {
"server": "node server.js",
Expand All @@ -16,8 +15,8 @@
"author": "",
"license": "ISC",
"dependencies": {
"axios": "^1.3.4",
"body-parser": "^1.20.1",
"client-oauth2": "^4.3.3",
"cors": "^2.8.5",
"express": "^4.18.2",
"open": "^8.4.0",
Expand Down
1 change: 1 addition & 0 deletions server/server.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const fs = require("fs");
const express = require("express");
const bodyParser = require("body-parser");
const cors = require("cors");
Expand Down
47 changes: 46 additions & 1 deletion server/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,20 @@ array-flatten@1.1.1:
resolved "https://registry.yarnpkg.com/array-flatten/-/array-flatten-1.1.1.tgz#9a5f699051b1e7073328f2a008968b64ea2955d2"
integrity sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg==

asynckit@^0.4.0:
version "0.4.0"
resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79"
integrity sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==

axios@^1.3.4:
version "1.3.4"
resolved "https://registry.yarnpkg.com/axios/-/axios-1.3.4.tgz#f5760cefd9cfb51fd2481acf88c05f67c4523024"
integrity sha512-toYm+Bsyl6VC5wSkfkbbNB6ROv7KY93PEBBL6xyDczaIHasAiv4wPqQ/c4RjoQzipxRD2W5g21cOqQulZ7rHwQ==
dependencies:
follow-redirects "^1.15.0"
form-data "^4.0.0"
proxy-from-env "^1.1.0"

body-parser@1.20.1, body-parser@^1.20.1:
version "1.20.1"
resolved "https://registry.yarnpkg.com/body-parser/-/body-parser-1.20.1.tgz#b1812a8912c195cd371a3ee5e66faa2338a5c668"
Expand Down Expand Up @@ -69,6 +83,13 @@ client-oauth2@^4.3.3:
popsicle "^12.0.5"
safe-buffer "^5.2.0"

combined-stream@^1.0.8:
version "1.0.8"
resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.8.tgz#c3d45a8b34fd730631a110a8a2520682b31d5a7f"
integrity sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==
dependencies:
delayed-stream "~1.0.0"

content-disposition@0.5.4:
version "0.5.4"
resolved "https://registry.yarnpkg.com/content-disposition/-/content-disposition-0.5.4.tgz#8b82b4efac82512a02bb0b1dcec9d2c5e8eb5bfe"
Expand Down Expand Up @@ -111,6 +132,11 @@ define-lazy-prop@^2.0.0:
resolved "https://registry.yarnpkg.com/define-lazy-prop/-/define-lazy-prop-2.0.0.tgz#3f7ae421129bcaaac9bc74905c98a0009ec9ee7f"
integrity sha512-Ds09qNh8yw3khSjiJjiUInaGX9xlqZDY7JVryGxdxV7NPeuqQfplOpQ66yJFZut3jLa5zOwkXw1g9EI2uKh4Og==

delayed-stream@~1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619"
integrity sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==

depd@2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/depd/-/depd-2.0.0.tgz#b696163cc757560d09cf22cc8fad1571b79e76df"
Expand Down Expand Up @@ -191,6 +217,20 @@ finalhandler@1.2.0:
statuses "2.0.1"
unpipe "~1.0.0"

follow-redirects@^1.15.0:
version "1.15.2"
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.2.tgz#b460864144ba63f2681096f274c4e57026da2c13"
integrity sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==

form-data@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/form-data/-/form-data-4.0.0.tgz#93919daeaf361ee529584b9b31664dc12c9fa452"
integrity sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==
dependencies:
asynckit "^0.4.0"
combined-stream "^1.0.8"
mime-types "^2.1.12"

forwarded@0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/forwarded/-/forwarded-0.2.0.tgz#2269936428aad4c15c7ebe9779a84bf0b2a81811"
Expand Down Expand Up @@ -309,7 +349,7 @@ mime-db@1.52.0:
resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.52.0.tgz#bbabcdc02859f4987301c856e3387ce5ec43bf70"
integrity sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==

mime-types@~2.1.24, mime-types@~2.1.34:
mime-types@^2.1.12, mime-types@~2.1.24, mime-types@~2.1.34:
version "2.1.35"
resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.35.tgz#381a871b62a734450660ae3deee44813f70d959a"
integrity sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==
Expand Down Expand Up @@ -442,6 +482,11 @@ proxy-addr@~2.0.7:
forwarded "0.2.0"
ipaddr.js "1.9.1"

proxy-from-env@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/proxy-from-env/-/proxy-from-env-1.1.0.tgz#e102f16ca355424865755d2c9e8ea4f24d58c3e2"
integrity sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==

psl@^1.1.28:
version "1.9.0"
resolved "https://registry.yarnpkg.com/psl/-/psl-1.9.0.tgz#d0df2a137f00794565fcaf3b2c00cd09f8d5a5a7"
Expand Down
Binary file added src/assets/icon/yatt.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions src/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ const databaseUtility = require("./modules/DatabaseUtility");
const windowUtility = require("./modules/WindowUtility");
const serverUtility = require("./modules/ServerUtility");

import { session } from "electron";

require("./modules/IpcHandlers");

// initialize session
Expand Down Expand Up @@ -66,6 +68,11 @@ app.on("activate", () => {
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
app.on("ready", async () => {
// Changing the User-Agent is required for JIRA token integration to work.
session.defaultSession.webRequest.onBeforeSendHeaders((details, callback) => {
details.requestHeaders["User-Agent"] = "YATTIE";
callback({ cancel: false, requestHeaders: details.requestHeaders });
});
if (isDevelopment && !process.env.IS_TEST) {
// Install Vue Devtools
try {
Expand Down
16 changes: 9 additions & 7 deletions src/components/CheckTaskWrapper.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,15 @@ export default {
this.handleValidate();
});
},
computed: {
currentTheme() {
if (this.$vuetify.theme.dark) {
return this.$vuetify.theme.themes.dark;
} else {
return this.$vuetify.theme.themes.light;
}
},
},
methods: {
rules(required) {
if (required) {
Expand All @@ -67,13 +76,6 @@ export default {
el.scrollIntoView();
}
},
currentTheme() {
if (this.$vuetify.theme.dark) {
return this.$vuetify.theme.themes.dark;
} else {
return this.$vuetify.theme.themes.light;
}
},
},
};
</script>
Expand Down
Loading

0 comments on commit 2c03bd8

Please sign in to comment.