fix export
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
package entries
|
||||
|
||||
import "time"
|
||||
|
||||
const bitwardenLoginItemType = 1
|
||||
|
||||
// BitwardenExport represents Bitwarden's plaintext JSON vault export format.
|
||||
// BitwardenExport represents Bitwarden's portable plaintext JSON format.
|
||||
// MaxWarden does not have folders, so every item is exported at the vault root.
|
||||
// Server-owned metadata such as IDs and revision dates is deliberately omitted;
|
||||
// Bitwarden creates those values when importing into the destination vault.
|
||||
type BitwardenExport struct {
|
||||
Encrypted bool `json:"encrypted"`
|
||||
Folders []any `json:"folders"`
|
||||
@@ -13,20 +13,12 @@ type BitwardenExport struct {
|
||||
}
|
||||
|
||||
type BitwardenItem struct {
|
||||
PasswordHistory []any `json:"passwordHistory"`
|
||||
RevisionDate string `json:"revisionDate"`
|
||||
CreationDate string `json:"creationDate"`
|
||||
DeletedDate *string `json:"deletedDate"`
|
||||
ID string `json:"id"`
|
||||
OrganizationID *string `json:"organizationId"`
|
||||
FolderID *string `json:"folderId"`
|
||||
Type int `json:"type"`
|
||||
Reprompt int `json:"reprompt"`
|
||||
Name string `json:"name"`
|
||||
Notes string `json:"notes"`
|
||||
Favorite bool `json:"favorite"`
|
||||
Login BitwardenLogin `json:"login"`
|
||||
CollectionIDs []string `json:"collectionIds"`
|
||||
Type int `json:"type"`
|
||||
Reprompt int `json:"reprompt"`
|
||||
Name string `json:"name"`
|
||||
Notes string `json:"notes"`
|
||||
Favorite bool `json:"favorite"`
|
||||
Login BitwardenLogin `json:"login"`
|
||||
}
|
||||
|
||||
type BitwardenLogin struct {
|
||||
@@ -51,21 +43,16 @@ func NewBitwardenExport(secrets []Secret) BitwardenExport {
|
||||
}
|
||||
|
||||
items = append(items, BitwardenItem{
|
||||
PasswordHistory: nil,
|
||||
RevisionDate: bitwardenTime(secret.Modified),
|
||||
CreationDate: bitwardenTime(secret.Created),
|
||||
ID: secret.ID,
|
||||
Type: bitwardenLoginItemType,
|
||||
Reprompt: 0,
|
||||
Name: secret.Description,
|
||||
Notes: secret.Notes,
|
||||
Favorite: false,
|
||||
Type: bitwardenLoginItemType,
|
||||
Reprompt: 0,
|
||||
Name: secret.Description,
|
||||
Notes: secret.Notes,
|
||||
Favorite: false,
|
||||
Login: BitwardenLogin{
|
||||
URIs: uris,
|
||||
Username: secret.Username,
|
||||
Password: secret.Password,
|
||||
},
|
||||
CollectionIDs: nil,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -75,11 +62,3 @@ func NewBitwardenExport(secrets []Secret) BitwardenExport {
|
||||
Items: items,
|
||||
}
|
||||
}
|
||||
|
||||
func bitwardenTime(value time.Time) string {
|
||||
if value.IsZero() {
|
||||
return ""
|
||||
}
|
||||
|
||||
return value.UTC().Format(time.RFC3339Nano)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user