Clean & remove encryption part
This commit is contained in:
5
package-lock.json
generated
5
package-lock.json
generated
@@ -4408,11 +4408,6 @@
|
|||||||
"randomfill": "^1.0.3"
|
"randomfill": "^1.0.3"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"crypto-js": {
|
|
||||||
"version": "3.1.9-1",
|
|
||||||
"resolved": "https://registry.npmjs.org/crypto-js/-/crypto-js-3.1.9-1.tgz",
|
|
||||||
"integrity": "sha1-/aGedh/Ad+Af+/3G6f38WeiAbNg="
|
|
||||||
},
|
|
||||||
"css": {
|
"css": {
|
||||||
"version": "2.2.4",
|
"version": "2.2.4",
|
||||||
"resolved": "https://registry.npmjs.org/css/-/css-2.2.4.tgz",
|
"resolved": "https://registry.npmjs.org/css/-/css-2.2.4.tgz",
|
||||||
|
|||||||
@@ -19,7 +19,6 @@
|
|||||||
"bulma-checkradio": "^2.1.1",
|
"bulma-checkradio": "^2.1.1",
|
||||||
"bulma-pricingtable": "^0.2.0",
|
"bulma-pricingtable": "^0.2.0",
|
||||||
"bulma-switch": "^2.0.0",
|
"bulma-switch": "^2.0.0",
|
||||||
"crypto-js": "^3.1.9-1",
|
|
||||||
"font-color-contrast": "^1.0.3",
|
"font-color-contrast": "^1.0.3",
|
||||||
"lightness": "^1.0.0",
|
"lightness": "^1.0.0",
|
||||||
"lodash-es": "^4.17.15",
|
"lodash-es": "^4.17.15",
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
export default interface IEncryptable {
|
|
||||||
[key: string]: any
|
|
||||||
}
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
export default interface IEncrypted {
|
|
||||||
[key: string]: string
|
|
||||||
}
|
|
||||||
@@ -3,8 +3,6 @@ import IAccount from '@/models/IAccount'
|
|||||||
import ITransaction from '@/models/ITransaction'
|
import ITransaction from '@/models/ITransaction'
|
||||||
import transactionService from '@/services/TransactionService'
|
import transactionService from '@/services/TransactionService'
|
||||||
import { slug } from '@/utils'
|
import { slug } from '@/utils'
|
||||||
import IEncryptable from '@/models/IEncryptable'
|
|
||||||
import IEncrypted from '@/models/IEncrypted'
|
|
||||||
|
|
||||||
class AccountService {
|
class AccountService {
|
||||||
public async get(id: string): Promise<IAccount | null> {
|
public async get(id: string): Promise<IAccount | null> {
|
||||||
@@ -125,17 +123,6 @@ class AccountService {
|
|||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
private toEncrypt(account: IAccount): IEncryptable | IEncrypted {
|
|
||||||
if (!account) {
|
|
||||||
return {}
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
name: account.name,
|
|
||||||
slug: account.slug,
|
|
||||||
premium: account.premium
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default new AccountService()
|
export default new AccountService()
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import axios from 'axios'
|
|
||||||
import uuid from 'uuid/v4'
|
import uuid from 'uuid/v4'
|
||||||
import PouchDb from 'pouchdb-browser'
|
import PouchDb from 'pouchdb-browser'
|
||||||
import PouchDbAuthentication from 'pouchdb-authentication'
|
import PouchDbAuthentication from 'pouchdb-authentication'
|
||||||
@@ -7,11 +6,6 @@ import IUser from '@/models/IUser'
|
|||||||
import notif from '@/utils/notif'
|
import notif from '@/utils/notif'
|
||||||
import { debounce } from 'lodash-es'
|
import { debounce } from 'lodash-es'
|
||||||
import { confirmation, toHex } from '@/utils'
|
import { confirmation, toHex } from '@/utils'
|
||||||
import cryptoService from '@/services/CryptoService'
|
|
||||||
import IEncryptable from '@/models/IEncryptable'
|
|
||||||
import IEncrypted from '@/models/IEncrypted'
|
|
||||||
import IEncryptPassword from '@/models/IEncryptPassword'
|
|
||||||
import { SET_KEY_URL, GET_KEY_URL } from '@/utils/serverless-url'
|
|
||||||
import store from '@/store'
|
import store from '@/store'
|
||||||
|
|
||||||
PouchDb.plugin(PouchDbAuthentication)
|
PouchDb.plugin(PouchDbAuthentication)
|
||||||
|
|||||||
@@ -1,55 +0,0 @@
|
|||||||
import IEncryptable from '@/models/IEncryptable'
|
|
||||||
import IEncryptPassword from '@/models/IEncryptPassword'
|
|
||||||
import AES from 'crypto-js/aes'
|
|
||||||
import utf8 from 'crypto-js/enc-utf8'
|
|
||||||
|
|
||||||
const encrypting: boolean = false
|
|
||||||
|
|
||||||
class CryptoService {
|
|
||||||
public createPassword(): IEncryptPassword {
|
|
||||||
return {
|
|
||||||
password: this.guid()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public encrypt(toEncrypt: IEncryptable, password: string): IEncryptable {
|
|
||||||
if (!encrypting) {
|
|
||||||
return toEncrypt
|
|
||||||
}
|
|
||||||
const encrypted: IEncryptable = {}
|
|
||||||
for (const t in toEncrypt) {
|
|
||||||
if (t) {
|
|
||||||
encrypted[t] = AES.encrypt(
|
|
||||||
toEncrypt[t] && toEncrypt[t].toString(),
|
|
||||||
password
|
|
||||||
).toString()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return encrypted
|
|
||||||
}
|
|
||||||
|
|
||||||
public decrypt(encrypted: IEncryptable, password: string): IEncryptable {
|
|
||||||
if (!encrypting) {
|
|
||||||
return encrypted
|
|
||||||
}
|
|
||||||
const decrypted: IEncryptable = {}
|
|
||||||
for (const t in encrypted) {
|
|
||||||
if (t && encrypted[t]) {
|
|
||||||
const bytes = AES.decrypt(encrypted[t], password)
|
|
||||||
decrypted[t] = bytes.toString(utf8)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return decrypted
|
|
||||||
}
|
|
||||||
|
|
||||||
private guid(): string {
|
|
||||||
const s4 = () => {
|
|
||||||
return Math.floor((1 + Math.random()) * 0x10000)
|
|
||||||
.toString(16)
|
|
||||||
.substring(1)
|
|
||||||
}
|
|
||||||
return `${s4()}${s4()}-${s4()}-${s4()}-${s4()}`
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export default new CryptoService()
|
|
||||||
@@ -6,8 +6,6 @@ import TransactionType from '@/enums/TransactionType'
|
|||||||
import ISplit from '@/models/ISplit'
|
import ISplit from '@/models/ISplit'
|
||||||
import IUser from '@/models/IUser'
|
import IUser from '@/models/IUser'
|
||||||
import IAccount from '@/models/IAccount'
|
import IAccount from '@/models/IAccount'
|
||||||
import IEncryptable from '@/models/IEncryptable'
|
|
||||||
import IEncrypted from '@/models/IEncrypted'
|
|
||||||
|
|
||||||
class TransactionService {
|
class TransactionService {
|
||||||
public async getNew(
|
public async getNew(
|
||||||
@@ -142,19 +140,6 @@ class TransactionService {
|
|||||||
private round(n: number): number {
|
private round(n: number): number {
|
||||||
return Math.round(n * 100) / 100
|
return Math.round(n * 100) / 100
|
||||||
}
|
}
|
||||||
|
|
||||||
private toEncrypt(transaction: ITransaction): IEncryptable | IEncrypted {
|
|
||||||
if (!transaction) {
|
|
||||||
return {}
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
name: transaction.name,
|
|
||||||
date: transaction.date,
|
|
||||||
amount: transaction.amount,
|
|
||||||
payBy: transaction.payBy,
|
|
||||||
tag: transaction.tag
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default new TransactionService()
|
export default new TransactionService()
|
||||||
|
|||||||
Reference in New Issue
Block a user