Whenever migrating to a different password manager an important thing is exporting all of the data. Unfortunately, most of the password managers export by default to csv or support importing from csv only. Exporting everything to a csv with 1password contains only the default fields (such as username, password, notes), but won't export all the custom fields (e.g. fields that it suggests to add for a passport, any imported SSH keys etc.). I created those functions in order to easily manage my items that have some additional information than what can be exported to a csv file.
In order to get the file, you need to export the 1password account to .1pux
file (1password unencrypted archive). Then change the file extension to .zip
- inside there is the export.data
file with a dump of the whole account.
import json
with open("export.data") as file:
data = json.load(file)
def get_all_vaults_for_the_first_account():
return [item for vault in data['accounts'][0]['vaults'] for item in vault['items']]
def has_custom_sections(item):
return len(item['details']['sections']) > 0
def create_dict(x):
data_dict = {}
elements = create_list(x)
for el in elements:
if el[0] in data_dict:
data_dict[el[0]].append(el[1])
else:
data_dict[el[0]] = el[1:]
return data_dict
def create_list(x):
return [[section['title'], field['title']] for section in x['details']['sections'] for field in section['fields']]
def create_names(x):
return [field['title'] for section in x['details']['sections'] for field in section['fields']]
[x['overview']['title'] for x in filter(has_custom_sections, get_all_vaults_for_the_first_account())]
Output e.g:
['Github'
'My Passport'
'Google'
...]
list(filter(has_custom_sections, get_all_vaults_for_the_first_account()))[0]
list(
map(lambda x: (x['overview']['title'], create_names(x)),
filter(has_custom_sections, get_all_vaults_for_the_first_account())))
Output e.g:
[('Github', ['private key', 'some field']),
('My Passport',
['number',
'full name',
'gender',
'nationality',
'issuing authority',
'date of birth',
'place of birth',
'issued on',
'expiry date'])
('Google', ['....'])
...]
list(
map(lambda x: (x['overview']['title'], create_dict(x)),
filter(has_custom_sections, get_all_vaults_for_the_first_account())))
Output e.g:
[('Github', {'': ['private key']}, {'other section': ['some field']}),
('My Passport',
{'details': ['number',
'full name',
'gender',
'nationality',
'issuing authority',
'date of birth',
'place of birth',
'issued on',
'expiry date']})
('Google', {'other fields': [.......]})
...]