mirror of
https://github.com/Luzifer/ots.git
synced 2025-09-26 11:01:05 -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
2 changed files with 11 additions and 5 deletions
|
@ -80,6 +80,7 @@
|
||||||
/* global maxSecretExpire */
|
/* global maxSecretExpire */
|
||||||
|
|
||||||
import appCrypto from '../crypto.js'
|
import appCrypto from '../crypto.js'
|
||||||
|
import OTSMeta from '../ots-meta'
|
||||||
|
|
||||||
const defaultExpiryChoices = [
|
const defaultExpiryChoices = [
|
||||||
90 * 86400, // 90 days
|
90 * 86400, // 90 days
|
||||||
|
@ -164,7 +165,12 @@ export default {
|
||||||
this.securePassword = [...window.crypto.getRandomValues(new Uint8Array(passwordLength))]
|
this.securePassword = [...window.crypto.getRandomValues(new Uint8Array(passwordLength))]
|
||||||
.map(n => passwordCharset[n % passwordCharset.length])
|
.map(n => passwordCharset[n % passwordCharset.length])
|
||||||
.join('')
|
.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 => {
|
.then(secret => {
|
||||||
let reqURL = 'api/create'
|
let reqURL = 'api/create'
|
||||||
if (this.selectedExpiry !== null) {
|
if (this.selectedExpiry !== null) {
|
||||||
|
|
|
@ -49,6 +49,7 @@
|
||||||
import appClipboardButton from './clipboard-button.vue'
|
import appClipboardButton from './clipboard-button.vue'
|
||||||
import appCrypto from '../crypto.js'
|
import appCrypto from '../crypto.js'
|
||||||
import appQrButton from './qr-button.vue'
|
import appQrButton from './qr-button.vue'
|
||||||
|
import OTSMeta from '../ots-meta'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: { appClipboardButton, appQrButton },
|
components: { appClipboardButton, appQrButton },
|
||||||
|
@ -89,11 +90,10 @@ export default {
|
||||||
|
|
||||||
appCrypto.dec(secret, this.securePassword)
|
appCrypto.dec(secret, this.securePassword)
|
||||||
.then(secret => {
|
.then(secret => {
|
||||||
this.secret = secret
|
const meta = new OTSMeta(secret)
|
||||||
})
|
this.secret = meta.secret
|
||||||
.catch(() => {
|
|
||||||
this.$emit('error', this.$t('alert-something-went-wrong'))
|
|
||||||
})
|
})
|
||||||
|
.catch(() => this.$emit('error', this.$t('alert-something-went-wrong')))
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue