Skip to content

Commit

Permalink
Merge branch 'rc' into 'main'
Browse files Browse the repository at this point in the history
fix: collection decrypt error after accepting share + item not disappear from...

See merge request locker/web!72
  • Loading branch information
duchunter committed Oct 23, 2023
2 parents 0cd80d3 + 14cfa71 commit 4ad48a8
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/renderer/components/cipher/ListCipher.vue
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ export default {
collections.forEach(f => {
const ciphers =
this.ciphers &&
(this.ciphers.filter(c => c.collectionIds.includes(f.id)) || [])
(this.ciphers.filter(c => c.collectionIds?.includes(f.id)) || [])
f.ciphersCount = ciphers && ciphers.length
f.ciphers = ciphers
})
Expand Down
60 changes: 53 additions & 7 deletions src/renderer/components/setting/ExportItems.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<template>
<div class="setting-wrapper">
<!-- Header -->
<div class="setting-section">
<div
class="setting-section-header cursor-pointer"
Expand All @@ -12,6 +13,8 @@
<i v-else class="el-icon-arrow-down" />
</div>
</div>
<!-- Header -->

<div v-if="!collapsed" class="setting-section">
<div class="setting-description mb-2">
{{ $t('data.exportFile.export_items_desc') }}
Expand Down Expand Up @@ -55,7 +58,7 @@ export default {
data () {
return {
selectedType: 'csv',
exportFormats: ['csv', 'json'],
exportFormats: ['csv', 'json', 'encrypted_json'],
collapsed: true
}
},
Expand Down Expand Up @@ -163,15 +166,20 @@ export default {
}
},
// Not used
// But if used again, please handle organizationId, collectionIds and protected ciphers cases
// Encrypted export
async getEncryptedExport () {
let folders = []
let ciphers = []
folders = await this.$folderService.getAll()
ciphers = await this.$cipherService.getAll()
ciphers = ciphers.filter(c => c.deletedDate === null)
folders = [...(await this.$folderService.getAll())]
ciphers = [...(await this.$cipherService.getAll())]
// Don't export protected or deleted cipher
ciphers = ciphers.filter(
cipher => !this.isProtectedCipher(cipher) && cipher.deletedDate === null
)
// Create key validation
const encKeyValidation = await this.$cryptoService.encrypt(
Utils.newGuid()
)
Expand All @@ -182,6 +190,45 @@ export default {
items: []
}
// Encrypt shared cipher with personal key
const newCiphers = []
let promises = []
const _encryptCipherWithPersonalKey = async c => {
const decCipher = await this.$cipherService.getSingleDecrypted(c.id)
decCipher.folderId = c.collectionIds.length
? `collection_${c.collectionIds[0]}`
: c.folderId
decCipher.organizationId = null
decCipher.collectionIds = null
const cipher = await this.$cipherService.encrypt(decCipher)
newCiphers.push(cipher)
}
ciphers.forEach(c => {
if (!c.organizationId) {
newCiphers.push(c)
return
}
promises.push(_encryptCipherWithPersonalKey(c))
})
await Promise.all(promises)
ciphers = [...newCiphers]
// Convert collections to folders
promises = []
const collections = await this.$collectionService.getAllDecrypted()
collections.forEach(c => {
const f = new FolderView()
f.name = c.name
f.id = `collection_${c.id}`
promises.push(
this.$folderService.encrypt(f).then(encryptedFolder => {
folders.push(encryptedFolder)
})
)
})
await Promise.all(promises)
// Build export data
folders.forEach(f => {
if (f.id == null) {
return
Expand All @@ -190,7 +237,6 @@ export default {
folder.build(f)
jsonDoc.folders.push(folder)
})
ciphers.forEach(c => {
if (c.organizationId != null) {
return
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/components/setting/plans-billing/Invoices.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
</el-table-column>
<el-table-column label="">
<template slot-scope="scope">
{{ $t(`common.${scope.row.duration}`) }}
{{ $t(`common.${scope.row.duration.toLowerCase()}`) }}
</template>
</el-table-column>
<el-table-column prop="total_price" label="" align="right">
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/jslib
Submodule jslib updated from 5fc5fc to c0a087
2 changes: 2 additions & 0 deletions src/renderer/locales/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ module.exports = {
last_name_placeholder: 'Your last name',
learn_more: 'Learn more',
length: 'Length',
lifetime: 'Lifetime plan',
lock: 'Lock',
login: 'Log in',
logout: 'Log Out',
Expand Down Expand Up @@ -311,6 +312,7 @@ module.exports = {
4: 'Identity | Identities',
5: 'OTP | OTPs',
0: 'Item | Items',
null: 'Item | Items',
6: 'Crypto Account | Crypto Accounts',
7: 'Crypto Backup | Crypto Backups',
9: 'Driver License | Driver Licenses',
Expand Down
2 changes: 2 additions & 0 deletions src/renderer/locales/vi.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ module.exports = {
last_name_placeholder: 'Nguyen',
learn_more: 'Tìm hiểu thêm',
length: 'Độ dài',
lifetime: 'Gói trọn đời',
lock: 'Khóa',
login: 'Đăng nhập',
logout: 'Đăng xuất',
Expand Down Expand Up @@ -311,6 +312,7 @@ module.exports = {
4: 'Định danh | Định danh',
5: 'OTP | OTPs',
0: 'Mục | Mục',
null: 'Mục | Mục',
6: 'Tài khoản Crypto | Tài khoản Crypto',
7: 'Ví Crypto | Ví Crypto',
9: 'Giấy phép lái xe | Giấy phép lái xe',
Expand Down
3 changes: 2 additions & 1 deletion src/renderer/plugins/mixins/cipher/sharing.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ Vue.mixin({
!cipher.isDeleted &&
this.isOwner(organizations, cipher) &&
// Not in any shared folder
!cipher.collectionIds.length &&
!cipher.collectionIds?.length &&
!this.isProtectedCipher(cipher) &&
cipher.type !== CipherType.TOTP
)
Expand Down Expand Up @@ -319,6 +319,7 @@ Vue.mixin({
this.$t('data.notifications.leave_share_success'),
'success'
)
this.$store.commit('UPDATE_SYNCED_CIPHERS')
return true
} catch (error) {
this.notify(this.$t('errors.something_went_wrong'), 'warning')
Expand Down

0 comments on commit 4ad48a8

Please sign in to comment.