mirror of
https://github.com/ProtonMail/go-proton-api.git
synced 2025-12-23 15:47:52 -05:00
feat: Add TOTP-enabled flag
This commit is contained in:
@@ -41,25 +41,26 @@ type Auth struct {
|
||||
}
|
||||
|
||||
type RegisteredKey struct {
|
||||
Version string
|
||||
KeyHandle string
|
||||
AttestationFormat string
|
||||
CredentialID []int
|
||||
Name string
|
||||
}
|
||||
|
||||
type U2FInfo struct {
|
||||
Challenge string
|
||||
RegisteredKeys []RegisteredKey
|
||||
type FIDO2Info struct {
|
||||
AuthenticationOptions any
|
||||
RegisteredKeys []RegisteredKey
|
||||
}
|
||||
|
||||
type TwoFAInfo struct {
|
||||
Enabled TwoFAStatus
|
||||
U2F U2FInfo
|
||||
FIDO2 FIDO2Info
|
||||
}
|
||||
|
||||
type TwoFAStatus int
|
||||
|
||||
const (
|
||||
TwoFADisabled TwoFAStatus = iota
|
||||
TOTPEnabled
|
||||
HasTOTP TwoFAStatus = 1 << iota
|
||||
HasFIDO2
|
||||
)
|
||||
|
||||
type PasswordMode int
|
||||
|
||||
@@ -63,7 +63,7 @@ func ExampleManager_NewClientWithLogin() {
|
||||
defer c.Close()
|
||||
|
||||
// If 2FA is necessary, an additional request is required.
|
||||
if auth.TwoFA.Enabled == proton.TOTPEnabled {
|
||||
if auth.TwoFA.Enabled&proton.HasTOTP != 0 {
|
||||
if err := c.Auth2FA(ctx, proton.Auth2FAReq{TwoFactorCode: "...TOTP..."}); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
@@ -34,7 +34,6 @@ func (b *Backend) NewAuthInfo(username string) (proton.AuthInfo, error) {
|
||||
ServerEphemeral: base64.StdEncoding.EncodeToString(challenge),
|
||||
Salt: base64.StdEncoding.EncodeToString(acc.salt),
|
||||
SRPSession: session,
|
||||
TwoFA: proton.TwoFAInfo{Enabled: proton.TwoFADisabled},
|
||||
}, nil
|
||||
})
|
||||
}
|
||||
|
||||
@@ -60,7 +60,6 @@ func (auth *auth) toAuth(userID, authUID string, proof []byte) proton.Auth {
|
||||
RefreshToken: auth.ref,
|
||||
ServerProof: base64.StdEncoding.EncodeToString(proof),
|
||||
|
||||
TwoFA: proton.TwoFAInfo{Enabled: proton.TwoFADisabled},
|
||||
PasswordMode: proton.OnePasswordMode,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user