1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-29 06:33:40 +00:00

1password 1pif importer: create hidden fields (#32)

* allow base importer to receive custom field type

* 1password importer uses hidden field type

for custom fields marked as 'concealed'

* 1password 1pif importer specs

* remove 'focus' from specs

* change field type logic into simple one liner
This commit is contained in:
Robert Wachs
2019-03-23 17:27:50 +01:00
committed by Kyle Spearrin
parent 593870e936
commit f874ec253d
3 changed files with 100 additions and 3 deletions

View File

@@ -302,7 +302,7 @@ export abstract class BaseImporter {
}
}
protected processKvp(cipher: CipherView, key: string, value: string) {
protected processKvp(cipher: CipherView, key: string, value: string, type: FieldType = FieldType.Text) {
if (this.isNullOrWhitespace(value)) {
return;
}
@@ -319,7 +319,7 @@ export abstract class BaseImporter {
cipher.fields = [];
}
const field = new FieldView();
field.type = FieldType.Text;
field.type = type;
field.name = key;
field.value = value;
cipher.fields.push(field);

View File

@@ -8,6 +8,7 @@ import { CipherView } from '../models/view/cipherView';
import { SecureNoteView } from '../models/view/secureNoteView';
import { CipherType } from '../enums/cipherType';
import { FieldType } from '../enums/fieldType';
import { SecureNoteType } from '../enums/secureNoteType';
export class OnePassword1PifImporter extends BaseImporter implements Importer {
@@ -168,8 +169,9 @@ export class OnePassword1PifImporter extends BaseImporter implements Importer {
}
}
const fieldType = (field.k === 'concealed') ? FieldType.Hidden : FieldType.Text;
const fieldName = this.isNullOrWhitespace(field[nameKey]) ? 'no_name' : field[nameKey];
this.processKvp(cipher, fieldName, fieldValue);
this.processKvp(cipher, fieldName, fieldValue, fieldType);
});
}
}