Skip to content

Commit

Permalink
feat: use papaparse to export credentials
Browse files Browse the repository at this point in the history
  • Loading branch information
RubenSmn committed Jan 23, 2025
1 parent 7d1797c commit 5008cc2
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions js/passwordManager/passwordViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const settings = require('util/settings/settings.js')
const PasswordManagers = require('passwordManager/passwordManager.js')
const modalMode = require('modalMode.js')
const { ipcRenderer } = require('electron')
const papaparse = require('papaparse')

const passwordViewer = {
container: document.getElementById('password-viewer'),
Expand Down Expand Up @@ -178,8 +179,14 @@ const passwordViewer = {
manager.getAllCredentials().then(function (credentials) {
if (credentials.length === 0) return

const header = 'url,username,password\n'
const csvData = header + credentials.map(credential => `https://${credential.domain},${credential.username},${credential.password}`).join('\n')
const csvData = papaparse.unparse({
fields: ['url', 'username', 'password'],
data: credentials.map(credential => [
`https://${credential.domain}`,
credential.username,
credential.password
])
})
const blob = new Blob([csvData], { type: 'text/csv' })
const url = URL.createObjectURL(blob)
const anchor = document.createElement('a')
Expand Down

0 comments on commit 5008cc2

Please sign in to comment.