diff --git a/auth_types.go b/auth_types.go index 397a3a2..eebfc83 100644 --- a/auth_types.go +++ b/auth_types.go @@ -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 diff --git a/example_test.go b/example_test.go index e74adf2..a65425b 100644 --- a/example_test.go +++ b/example_test.go @@ -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) } diff --git a/server/backend/api_auth.go b/server/backend/api_auth.go index 6c01c58..a8f11d7 100644 --- a/server/backend/api_auth.go +++ b/server/backend/api_auth.go @@ -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 }) } diff --git a/server/backend/types.go b/server/backend/types.go index 8b91c40..fba1d0e 100644 --- a/server/backend/types.go +++ b/server/backend/types.go @@ -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, } }