mirror of
https://github.com/Luzifer/cloudkeys-go.git
synced 2024-09-19 23:52:57 +00:00
Auto-fix linter errors
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
f1278a5cab
commit
e659999b3d
18
src/main.js
18
src/main.js
@ -8,13 +8,13 @@ import 'bootswatch/dist/flatly/bootstrap.css'
|
|||||||
import 'bootstrap-vue/dist/bootstrap-vue.css'
|
import 'bootstrap-vue/dist/bootstrap-vue.css'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
library
|
library,
|
||||||
} from '@fortawesome/fontawesome-svg-core'
|
} from '@fortawesome/fontawesome-svg-core'
|
||||||
import {
|
import {
|
||||||
fas
|
fas,
|
||||||
} from '@fortawesome/free-solid-svg-icons'
|
} from '@fortawesome/free-solid-svg-icons'
|
||||||
import {
|
import {
|
||||||
FontAwesomeIcon
|
FontAwesomeIcon,
|
||||||
} from '@fortawesome/vue-fontawesome'
|
} from '@fortawesome/vue-fontawesome'
|
||||||
|
|
||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
@ -26,17 +26,17 @@ import store from './store'
|
|||||||
Vue.config.productionTip = false
|
Vue.config.productionTip = false
|
||||||
Vue.use(BootstrapVue)
|
Vue.use(BootstrapVue)
|
||||||
Vue.use(VueShortkey, {
|
Vue.use(VueShortkey, {
|
||||||
prevent: ['input', 'textarea']
|
prevent: ['input', 'textarea'],
|
||||||
})
|
})
|
||||||
Vue.use(VueClipboard)
|
Vue.use(VueClipboard)
|
||||||
|
|
||||||
library.add(fas)
|
library.add(fas)
|
||||||
Vue.component('fa-icon', FontAwesomeIcon)
|
Vue.component('fa-icon', FontAwesomeIcon)
|
||||||
|
|
||||||
axios.defaults.baseURL = "v2"
|
axios.defaults.baseURL = 'v2'
|
||||||
|
|
||||||
const go = new Go()
|
const go = new Go()
|
||||||
WebAssembly.instantiateStreaming(fetch("cryptocore.wasm"), go.importObject)
|
WebAssembly.instantiateStreaming(fetch('cryptocore.wasm'), go.importObject)
|
||||||
.then(async obj => await go.run(obj.instance))
|
.then(async obj => await go.run(obj.instance))
|
||||||
|
|
||||||
const instance = new Vue({
|
const instance = new Vue({
|
||||||
@ -48,9 +48,11 @@ const instance = new Vue({
|
|||||||
// Wait for the cryptocore to be loaded (which makes encryption available)
|
// Wait for the cryptocore to be loaded (which makes encryption available)
|
||||||
new Promise(resolve => {
|
new Promise(resolve => {
|
||||||
(function waitForCryptocore() {
|
(function waitForCryptocore() {
|
||||||
if (window.opensslEncrypt) return resolve()
|
if (window.opensslEncrypt) {
|
||||||
|
return resolve()
|
||||||
|
}
|
||||||
setTimeout(waitForCryptocore, 100)
|
setTimeout(waitForCryptocore, 100)
|
||||||
})();
|
}())
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
store.commit('cryptocore_loaded')
|
store.commit('cryptocore_loaded')
|
||||||
})
|
})
|
||||||
|
@ -8,32 +8,34 @@ Vue.use(Vuex)
|
|||||||
|
|
||||||
export default new Vuex.Store({
|
export default new Vuex.Store({
|
||||||
state: {
|
state: {
|
||||||
//account_info: {
|
/*
|
||||||
// data: [{
|
*account_info: {
|
||||||
// "title": "Test entry",
|
* data: [{
|
||||||
// "username": "testuser",
|
* "title": "Test entry",
|
||||||
// "password": "quitesecretpass",
|
* "username": "testuser",
|
||||||
// "url": "https://example.com",
|
* "password": "quitesecretpass",
|
||||||
// "comment": "",
|
* "url": "https://example.com",
|
||||||
// "tags": "",
|
* "comment": "",
|
||||||
// "id": "f106cdd5-7b52-4c51-a386-6f2016ee70c8",
|
* "tags": "",
|
||||||
// },
|
* "id": "f106cdd5-7b52-4c51-a386-6f2016ee70c8",
|
||||||
// {
|
* },
|
||||||
// "title": "Test entry 2",
|
* {
|
||||||
// "username": "testuser",
|
* "title": "Test entry 2",
|
||||||
// "password": "quitesecretpass",
|
* "username": "testuser",
|
||||||
// "url": "https://example.com",
|
* "password": "quitesecretpass",
|
||||||
// "comment": "",
|
* "url": "https://example.com",
|
||||||
// "tags": "foobar",
|
* "comment": "",
|
||||||
// "id": "e956814f-c7dd-4730-b383-624f8bbc6923",
|
* "tags": "foobar",
|
||||||
// },
|
* "id": "e956814f-c7dd-4730-b383-624f8bbc6923",
|
||||||
// ],
|
* },
|
||||||
// data_raw: "",
|
* ],
|
||||||
// loaded: "Luzifer",
|
* data_raw: "",
|
||||||
// master_password: "foobar",
|
* loaded: "Luzifer",
|
||||||
// selected: null,
|
* master_password: "foobar",
|
||||||
//},
|
* selected: null,
|
||||||
//accounts: ["Luzifer"],
|
*},
|
||||||
|
*accounts: ["Luzifer"],
|
||||||
|
*/
|
||||||
account_info: {},
|
account_info: {},
|
||||||
accounts: [],
|
accounts: [],
|
||||||
cryptocore_available: false,
|
cryptocore_available: false,
|
||||||
@ -49,20 +51,25 @@ export default new Vuex.Store({
|
|||||||
|
|
||||||
decrypt_data(context) {
|
decrypt_data(context) {
|
||||||
// Do not try to decrypt empty data
|
// Do not try to decrypt empty data
|
||||||
if (context.state.account_info.data_raw == "") return
|
if (context.state.account_info.data_raw == '') {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
new Promise((resolve, reject) => {
|
new Promise((resolve, reject) => {
|
||||||
opensslDecrypt(
|
opensslDecrypt(
|
||||||
context.state.account_info.data_raw,
|
context.state.account_info.data_raw,
|
||||||
context.state.account_info.master_password,
|
context.state.account_info.master_password,
|
||||||
(data, error) => {
|
(data, error) => {
|
||||||
if (error) reject(error)
|
if (error) {
|
||||||
|
reject(error)
|
||||||
|
}
|
||||||
resolve(data)
|
resolve(data)
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}).then((plain_data) => {
|
}).then(plain_data => {
|
||||||
context.commit('decrypted_data', plain_data)
|
context.commit('decrypted_data', plain_data)
|
||||||
}).catch((error) => console.log(error))
|
})
|
||||||
|
.catch(error => console.log(error))
|
||||||
},
|
},
|
||||||
|
|
||||||
encrypt_data(context) {
|
encrypt_data(context) {
|
||||||
@ -71,14 +78,17 @@ export default new Vuex.Store({
|
|||||||
JSON.stringify(context.state.account_info.data),
|
JSON.stringify(context.state.account_info.data),
|
||||||
context.state.account_info.master_password,
|
context.state.account_info.master_password,
|
||||||
(data, error) => {
|
(data, error) => {
|
||||||
if (error) reject(error)
|
if (error) {
|
||||||
|
reject(error)
|
||||||
|
}
|
||||||
resolve(data)
|
resolve(data)
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}).then((enc_data) => {
|
}).then(enc_data => {
|
||||||
context.commit('encrypted_data', enc_data)
|
context.commit('encrypted_data', enc_data)
|
||||||
context.dispatch('save_user_data')
|
context.dispatch('save_user_data')
|
||||||
}).catch((error) => console.log(error))
|
})
|
||||||
|
.catch(error => console.log(error))
|
||||||
},
|
},
|
||||||
|
|
||||||
enter_master_password(context, password) {
|
enter_master_password(context, password) {
|
||||||
@ -88,7 +98,7 @@ export default new Vuex.Store({
|
|||||||
|
|
||||||
load_user_data(context, username) {
|
load_user_data(context, username) {
|
||||||
axios.get(`/user/${username}/data`)
|
axios.get(`/user/${username}/data`)
|
||||||
.then((response) => {
|
.then(response => {
|
||||||
context.commit('account_loaded', {
|
context.commit('account_loaded', {
|
||||||
checksum: response.data.checksum,
|
checksum: response.data.checksum,
|
||||||
data: [],
|
data: [],
|
||||||
@ -98,23 +108,23 @@ export default new Vuex.Store({
|
|||||||
selected: null,
|
selected: null,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.catch((error) => console.log(error))
|
.catch(error => console.log(error))
|
||||||
},
|
},
|
||||||
|
|
||||||
register(context, data) {
|
register(context, data) {
|
||||||
axios.post("/register", data)
|
axios.post('/register', data)
|
||||||
.then((response) => {
|
.then(response => {
|
||||||
context.dispatch('reload_users', data.username)
|
context.dispatch('reload_users', data.username)
|
||||||
})
|
})
|
||||||
.catch((error) => console.log(error))
|
.catch(error => console.log(error))
|
||||||
},
|
},
|
||||||
|
|
||||||
reload_users(context, autoload = null) {
|
reload_users(context, autoload = null) {
|
||||||
axios.get("/users")
|
axios.get('/users')
|
||||||
.then((response) => {
|
.then(response => {
|
||||||
let users = []
|
const users = []
|
||||||
for (let user in response.data) {
|
for (const user in response.data) {
|
||||||
let login_state = response.data[user]
|
const login_state = response.data[user]
|
||||||
if (login_state == 'logged-in') {
|
if (login_state == 'logged-in') {
|
||||||
users.push(user)
|
users.push(user)
|
||||||
}
|
}
|
||||||
@ -127,34 +137,37 @@ export default new Vuex.Store({
|
|||||||
context.commit('clear_active_user')
|
context.commit('clear_active_user')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch((error) => console.log(error))
|
.catch(error => console.log(error))
|
||||||
},
|
},
|
||||||
|
|
||||||
save_user_data(context) {
|
save_user_data(context) {
|
||||||
new Promise((resolve, reject) => {
|
new Promise((resolve, reject) => {
|
||||||
sha256sum(context.state.account_info.data_raw, (data, error) => {
|
sha256sum(context.state.account_info.data_raw, (data, error) => {
|
||||||
if (error) return reject(error)
|
if (error) {
|
||||||
|
return reject(error)
|
||||||
|
}
|
||||||
resolve(data)
|
resolve(data)
|
||||||
})
|
})
|
||||||
}).then((checksum) => {
|
}).then(checksum => {
|
||||||
axios.put(`/user/${context.state.account_info.loaded}/data`, {
|
axios.put(`/user/${context.state.account_info.loaded}/data`, {
|
||||||
'checksum': checksum,
|
checksum,
|
||||||
'old_checksum': context.state.account_info.checksum,
|
old_checksum: context.state.account_info.checksum,
|
||||||
'data': context.state.account_info.data_raw,
|
data: context.state.account_info.data_raw,
|
||||||
}).then((response) => {
|
}).then(response => {
|
||||||
context.commit('update_checksum', checksum)
|
context.commit('update_checksum', checksum)
|
||||||
}).catch((error) => console.log(error))
|
})
|
||||||
}).catch((error) => console.log(error))
|
.catch(error => console.log(error))
|
||||||
|
})
|
||||||
|
.catch(error => console.log(error))
|
||||||
},
|
},
|
||||||
|
|
||||||
sign_in(context, auth) {
|
sign_in(context, auth) {
|
||||||
console.log(auth)
|
console.log(auth)
|
||||||
axios.post("/login", auth)
|
axios.post('/login', auth)
|
||||||
.then((response) => {
|
.then(response => {
|
||||||
context.dispatch('reload_users', auth.username)
|
context.dispatch('reload_users', auth.username)
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch(error => {
|
||||||
if (error.response) {
|
if (error.response) {
|
||||||
console.log(error.response)
|
console.log(error.response)
|
||||||
} else {
|
} else {
|
||||||
@ -165,21 +178,21 @@ export default new Vuex.Store({
|
|||||||
|
|
||||||
sign_out(context) {
|
sign_out(context) {
|
||||||
axios.post(`/user/${context.state.account_info.loaded}/logout`)
|
axios.post(`/user/${context.state.account_info.loaded}/logout`)
|
||||||
.then((response) => {
|
.then(response => {
|
||||||
context.dispatch('reload_users')
|
context.dispatch('reload_users')
|
||||||
})
|
})
|
||||||
.catch((error) => console.log(error))
|
.catch(error => console.log(error))
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
getters: {
|
getters: {
|
||||||
filtered_entries: (state) => {
|
filtered_entries: state => {
|
||||||
if (state.filter === "" || state.filter === null) {
|
if (state.filter === '' || state.filter === null) {
|
||||||
return state.account_info.data
|
return state.account_info.data
|
||||||
}
|
}
|
||||||
|
|
||||||
let entries = []
|
const entries = []
|
||||||
|
|
||||||
for (let item of state.account_info.data) {
|
for (const item of state.account_info.data) {
|
||||||
if (item.title.indexOf(state.filter) > -1) {
|
if (item.title.indexOf(state.filter) > -1) {
|
||||||
entries.push(item)
|
entries.push(item)
|
||||||
continue
|
continue
|
||||||
@ -196,17 +209,17 @@ export default new Vuex.Store({
|
|||||||
|
|
||||||
return entries
|
return entries
|
||||||
},
|
},
|
||||||
selected_entry: (state) => {
|
selected_entry: state => {
|
||||||
if (!state.account_info.selected) {
|
if (!state.account_info.selected) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
for (let item of state.account_info.data) {
|
for (const item of state.account_info.data) {
|
||||||
if (item.id == state.account_info.selected) {
|
if (item.id == state.account_info.selected) {
|
||||||
return item
|
return item
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null
|
return null
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
mutations: {
|
mutations: {
|
||||||
account_loaded(state, account_info) {
|
account_loaded(state, account_info) {
|
||||||
@ -230,10 +243,12 @@ export default new Vuex.Store({
|
|||||||
},
|
},
|
||||||
|
|
||||||
decrypted_data(state, plain_data) {
|
decrypted_data(state, plain_data) {
|
||||||
let elms = JSON.parse(plain_data)
|
const elms = JSON.parse(plain_data)
|
||||||
for (let e of elms) {
|
for (const e of elms) {
|
||||||
// Migrate old entries without UUID
|
// Migrate old entries without UUID
|
||||||
if (!e.id) e.id = uuidv4()
|
if (!e.id) {
|
||||||
|
e.id = uuidv4()
|
||||||
|
}
|
||||||
state.account_info.data.push(e)
|
state.account_info.data.push(e)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -263,5 +278,5 @@ export default new Vuex.Store({
|
|||||||
update_filter(state, value) {
|
update_filter(state, value) {
|
||||||
state.filter = value
|
state.filter = value
|
||||||
},
|
},
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user