convert of login items keeps original env names in fields; env now also exposes the login triple so sourced consumers can map to legacy names. Ticket: https://projects.knownelement.com/issues/832
This commit is contained in:
@@ -251,6 +251,15 @@ func cmdEnv(name string) error {
|
||||
v := strings.ReplaceAll(f.Value, "'", "'\\''")
|
||||
fmt.Printf("export %s='%s'\n", f.Name, v)
|
||||
}
|
||||
if len(pc.URIs) > 0 {
|
||||
fmt.Printf("export URI='%s'\n", pc.URIs[0])
|
||||
}
|
||||
if pc.Login.Username != "" {
|
||||
fmt.Printf("export USERNAME='%s'\n", pc.Login.Username)
|
||||
}
|
||||
if pc.Login.Password != "" {
|
||||
fmt.Printf("export PASSWORD='%s'\n", pc.Login.Password)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -537,3 +546,5 @@ func cmdConvert(name string) error {
|
||||
fmt.Printf("converted: %s (user=%v pass=%v uris=%d fields=%d)\n", name, username != "", password != "", len(uris), len(rest))
|
||||
return nil
|
||||
}
|
||||
|
||||
func urisOf(pc *PlainCipher) []string { return pc.URIs }
|
||||
|
||||
+14
-1
@@ -90,7 +90,8 @@ type PlainCipher struct {
|
||||
Username string `json:"username"`
|
||||
Password string `json:"password"`
|
||||
} `json:"login"`
|
||||
FolderID string `json:"folderId"`
|
||||
FolderID string `json:"folderId"`
|
||||
URIs []string `json:"uris"`
|
||||
}
|
||||
|
||||
// DecryptCipher converts a raw sync cipher into PlainCipher.
|
||||
@@ -132,6 +133,18 @@ func DecryptCipher(userKey []byte, raw []byte) (*PlainCipher, error) {
|
||||
if cr.Login.Password != nil {
|
||||
pc.Login.Password, _ = decStr(userKey, ck, cr.Login.Password)
|
||||
}
|
||||
for _, u := range cr.Login.URIs {
|
||||
var um map[string]any
|
||||
um, _ = u.(map[string]any)
|
||||
if um != nil {
|
||||
if us, ok := um["uri"].(string); ok {
|
||||
v, err := decStr(userKey, ck, &us)
|
||||
if err == nil {
|
||||
pc.URIs = append(pc.URIs, v)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return pc, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user