package entries const bitwardenLoginItemType = 1 // 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"` Items []BitwardenItem `json:"items"` } type BitwardenItem struct { 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 { URIs []BitwardenURI `json:"uris"` Username string `json:"username"` Password string `json:"password"` TOTP *string `json:"totp"` } type BitwardenURI struct { Match *int `json:"match"` URI string `json:"uri"` } func NewBitwardenExport(secrets []Secret) BitwardenExport { items := make([]BitwardenItem, 0, len(secrets)) for _, secret := range secrets { uris := make([]BitwardenURI, 0, 1) if secret.URL != "" { uris = append(uris, BitwardenURI{URI: secret.URL}) } items = append(items, BitwardenItem{ Type: bitwardenLoginItemType, Reprompt: 0, Name: secret.Description, Notes: secret.Notes, Favorite: false, Login: BitwardenLogin{ URIs: uris, Username: secret.Username, Password: secret.Password, }, }) } return BitwardenExport{ Encrypted: false, Folders: make([]any, 0), Items: items, } }