Utilize OTSMeta parser / serializer in de/encryption

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2023-10-01 13:54:29 +02:00
parent cf2cacbf23
commit 1fcd58e85c
No known key found for this signature in database
GPG Key ID: D91C3E91E4CAD6F5
2 changed files with 11 additions and 5 deletions

View File

@ -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) {

View File

@ -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(() => {