mirror of
https://github.com/Luzifer/ots.git
synced 2025-04-19 06:55:51 -04:00
Utilize OTSMeta parser / serializer in de/encryption
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
cf2cacbf23
commit
1fcd58e85c
@ -80,6 +80,7 @@
|
||||
/* global maxSecretExpire */
|
||||
|
||||
import appCrypto from '../crypto.js'
|
||||
import OTSMeta from '../ots-meta'
|
||||
|
||||
const defaultExpiryChoices = [
|
||||
90 * 86400, // 90 days
|
||||
@ -164,7 +165,12 @@ export default {
|
||||
this.securePassword = [...window.crypto.getRandomValues(new Uint8Array(passwordLength))]
|
||||
.map(n => passwordCharset[n % passwordCharset.length])
|
||||
.join('')
|
||||
appCrypto.enc(this.secret, this.securePassword)
|
||||
|
||||
const meta = new OTSMeta()
|
||||
meta.secret = this.secret
|
||||
|
||||
meta.serialize()
|
||||
.then(secret => appCrypto.enc(secret, this.securePassword))
|
||||
.then(secret => {
|
||||
let reqURL = 'api/create'
|
||||
if (this.selectedExpiry !== null) {
|
||||
|
@ -49,6 +49,7 @@
|
||||
import appClipboardButton from './clipboard-button.vue'
|
||||
import appCrypto from '../crypto.js'
|
||||
import appQrButton from './qr-button.vue'
|
||||
import OTSMeta from '../ots-meta'
|
||||
|
||||
export default {
|
||||
components: { appClipboardButton, appQrButton },
|
||||
@ -89,11 +90,10 @@ export default {
|
||||
|
||||
appCrypto.dec(secret, this.securePassword)
|
||||
.then(secret => {
|
||||
this.secret = secret
|
||||
})
|
||||
.catch(() => {
|
||||
this.$emit('error', this.$t('alert-something-went-wrong'))
|
||||
const meta = new OTSMeta(secret)
|
||||
this.secret = meta.secret
|
||||
})
|
||||
.catch(() => this.$emit('error', this.$t('alert-something-went-wrong')))
|
||||
})
|
||||
})
|
||||
.catch(() => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user