// Package tdesktop contains Telegram Desktop session decoder.
package tdesktop import ( ) // Account is a Telegram user account representation in Telegram Desktop storage. type Account struct { // IDx is an internal Telegram Desktop account ID. IDx uint32 // Authorization contains Telegram user and MTProto sessions. Authorization MTPAuthorization // Config contains Telegram config. Config MTPConfig } // Read reads accounts info from given Telegram Desktop tdata root. // Shorthand for: // // ReadFS(os.DirFS(root), passcode) func ( string, []byte) ([]Account, error) { return ReadFS(os.DirFS(), ) } // ReadFS reads Telegram Desktop accounts info from given FS root. func ( fs.FS, []byte) ([]Account, error) { , := open(, "key_data") if != nil { return nil, errors.Wrap(, "open key_data") } , := readKeyData(, ) if != nil { return nil, } if len(.accountsIDx) < 1 { return nil, ErrNoAccounts } := make([]Account, 0, len(.accountsIDx)) for , := range .accountsIDx { var = fileKey("data") if > 0 { = fileKey(fmt.Sprintf("data#%d", +1)) } , := open(, ) if != nil { return nil, errors.Wrap(, "open key_data") } , := readMTPData(, .localKey) if != nil { return nil, errors.Wrap(, "read mtp") } := Account{ IDx: , Authorization: , } , := open(, path.Join(, "config")) if == nil { , := readMTPConfig(, .localKey) // HACK: ignoring error, because config is optional. if == nil { .Config = } } = append(, ) } return , nil }