mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-21 11:35:34 +01:00
added fromNullable to reduces repetitive logic
This commit is contained in:
parent
186eb392fc
commit
ce5fc9c278
@ -37,18 +37,17 @@ export class Fido2CredentialExport {
|
||||
}
|
||||
|
||||
static toDomain(req: Fido2CredentialExport, domain = new Fido2Credential()) {
|
||||
domain.credentialId = req.credentialId != null ? new EncString(req.credentialId) : null;
|
||||
domain.keyType = req.keyType != null ? new EncString(req.keyType) : null;
|
||||
domain.keyAlgorithm = req.keyAlgorithm != null ? new EncString(req.keyAlgorithm) : null;
|
||||
domain.keyCurve = req.keyCurve != null ? new EncString(req.keyCurve) : null;
|
||||
domain.keyValue = req.keyValue != null ? new EncString(req.keyValue) : null;
|
||||
domain.rpId = req.rpId != null ? new EncString(req.rpId) : null;
|
||||
domain.userHandle = req.userHandle != null ? new EncString(req.userHandle) : null;
|
||||
domain.counter = req.counter != null ? new EncString(req.counter) : null;
|
||||
domain.rpName = req.rpName != null ? new EncString(req.rpName) : null;
|
||||
domain.userDisplayName =
|
||||
req.userDisplayName != null ? new EncString(req.userDisplayName) : null;
|
||||
domain.discoverable = req.discoverable != null ? new EncString(req.discoverable) : null;
|
||||
domain.credentialId = EncString.fromNullable(req.credentialId);
|
||||
domain.keyType = EncString.fromNullable(req.keyType);
|
||||
domain.keyAlgorithm = EncString.fromNullable(req.keyAlgorithm);
|
||||
domain.keyCurve = EncString.fromNullable(req.keyCurve);
|
||||
domain.keyValue = EncString.fromNullable(req.keyValue);
|
||||
domain.rpId = EncString.fromNullable(req.rpId);
|
||||
domain.userHandle = EncString.fromNullable(req.userHandle);
|
||||
domain.counter = EncString.fromNullable(req.counter);
|
||||
domain.rpName = EncString.fromNullable(req.rpName);
|
||||
domain.userDisplayName = EncString.fromNullable(req.userDisplayName);
|
||||
domain.discoverable = EncString.fromNullable(req.discoverable);
|
||||
domain.creationDate = req.creationDate;
|
||||
return domain;
|
||||
}
|
||||
|
@ -43,6 +43,10 @@ export class EncString implements Encrypted {
|
||||
return this.encryptedString;
|
||||
}
|
||||
|
||||
static fromNullable(val: string | null) {
|
||||
return val ? new EncString(val) : null;
|
||||
}
|
||||
|
||||
static fromJSON(obj: Jsonify<EncString>): EncString {
|
||||
if (obj == null) {
|
||||
return null;
|
||||
|
Loading…
Reference in New Issue
Block a user