fix export

This commit is contained in:
2026-09-03 11:26:47 -04:00
parent 7c04370e48
commit 7c886a7927
2 changed files with 22 additions and 49 deletions

View File

@@ -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)
}