Skip to content

Commit 84b4445

Browse files
committed
Add EncObject
1 parent cd31c0e commit 84b4445

File tree

5 files changed

+23
-25
lines changed

5 files changed

+23
-25
lines changed

src/Api/Models/Request/CipherRequestModel.cs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public Cipher ToCipher(Cipher existingCipher)
8686
existingCipher.Data = JsonSerializer.Serialize(ToCipherSecureNoteData(), JsonHelpers.IgnoreWritingNull);
8787
break;
8888
default:
89-
existingCipher.Data = JsonSerializer.Serialize(ToCipherCustomData(), JsonHelpers.IgnoreWritingNull);
89+
//existingCipher.Data = JsonSerializer.Serialize(ToCipherCustomData(), JsonHelpers.IgnoreWritingNull);
9090
break;
9191
}
9292

@@ -231,17 +231,6 @@ private CipherSecureNoteData ToCipherSecureNoteData()
231231
Type = SecureNote.Type,
232232
};
233233
}
234-
235-
private CipherCustomData ToCipherCustomData()
236-
{
237-
return new CipherCustomData
238-
{
239-
Name = Name,
240-
Notes = Notes,
241-
Fields = Fields?.Select(f => f.ToCipherFieldData()),
242-
PasswordHistory = PasswordHistory?.Select(ph => ph.ToCipherPasswordHistoryData()),
243-
};
244-
}
245234
}
246235

247236
public class CipherWithIdRequestModel : CipherRequestModel

src/Api/Models/Response/CipherResponseModel.cs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,19 @@ public CipherMiniResponseModel(Cipher cipher, IGlobalSettings globalSettings, bo
5252
Identity = new CipherIdentityModel(identityData);
5353
break;
5454
default:
55-
var customData = JsonSerializer.Deserialize<CipherCustomData>(cipher.Data);
55+
var customData = JsonSerializer.Deserialize<EncObject>(cipher.Data);
5656
Data = customData;
57-
cipherData = customData;
57+
cipherData = null;
5858
break;
5959
}
6060

61-
Name = cipherData.Name;
62-
Notes = cipherData.Notes;
63-
Fields = cipherData.Fields?.Select(f => new CipherFieldModel(f));
64-
PasswordHistory = cipherData.PasswordHistory?.Select(ph => new CipherPasswordHistoryModel(ph));
61+
if (cipherData != null)
62+
{
63+
Name = cipherData.Name;
64+
Notes = cipherData.Notes;
65+
Fields = cipherData.Fields?.Select(f => new CipherFieldModel(f));
66+
PasswordHistory = cipherData.PasswordHistory?.Select(ph => new CipherPasswordHistoryModel(ph));
67+
}
6568
RevisionDate = cipher.RevisionDate;
6669
OrganizationId = cipher.OrganizationId?.ToString();
6770
Attachments = AttachmentResponseModel.FromCipher(cipher, globalSettings);

src/Core/Enums/CipherType.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ public enum CipherType : byte
77
Login = 1,
88
SecureNote = 2,
99
Card = 3,
10-
Identity = 4
10+
Identity = 4,
1111
}
1212
}

src/Core/Models/Data/Cipher/CipherCustomData.cs

Lines changed: 0 additions & 6 deletions
This file was deleted.

src/Core/Models/Data/EncObject.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using Bit.Core.Enums;
2+
3+
namespace Bit.Core.Models.Data
4+
{
5+
public class EncObject
6+
{
7+
public EncryptionType Type { get; set; }
8+
public string Data { get; set; }
9+
public string Iv { get; set; }
10+
public string Mac { get; set; }
11+
}
12+
}

0 commit comments

Comments
 (0)