Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pkg/connector/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ var (
ErrLoginConsent = bridgev2.RespError{ErrCode: "FI.MAU.META_CONSENT_ERROR", Err: "Consent required, please check the official website or app and then try again", StatusCode: http.StatusBadRequest}
ErrLoginCheckpoint = bridgev2.RespError{ErrCode: "FI.MAU.META_CHECKPOINT_ERROR", Err: "Checkpoint required, please check the official website or app and then try again", StatusCode: http.StatusBadRequest}
ErrLoginTokenInvalidated = bridgev2.RespError{ErrCode: "FI.MAU.META_TOKEN_ERROR", Err: "Got logged out immediately", StatusCode: http.StatusBadRequest}
ErrLoginTransientToken = bridgev2.RespError{ErrCode: "FI.MAU.META_TRANSIENT_TOKEN_ERROR", Err: "Login approved but could not be completed automatically, please try again", StatusCode: http.StatusBadRequest}
ErrLoginUnknown = bridgev2.RespError{ErrCode: "M_UNKNOWN", Err: "Internal error logging in", StatusCode: http.StatusInternalServerError}
)

Expand Down Expand Up @@ -377,6 +378,8 @@ func (m *MetaNativeLogin) proceed(ctx context.Context, userInput map[string]stri
log.Error().Err(err).Msg("Login steps returned error")
if errors.As(err, &bloks.CheckpointError{}) {
err = ErrLoginCheckpoint
} else if errors.Is(err, messagix.ErrTransientTokenLogin) {
err = ErrLoginTransientToken
}
return nil, err
}
Expand Down
15 changes: 9 additions & 6 deletions pkg/messagix/bloks/selenium.go
Original file line number Diff line number Diff line change
Expand Up @@ -1074,13 +1074,16 @@ func (b *Browser) DoLoginStep(ctx context.Context, userInput map[string]string)
methodNames := []string{}

knownMethods := map[string]bool{
"Authentication app": true,
"Email": true,
"Text message": true,
"Backup code": true,
"WhatsApp": true,
// Disabled because there's no reasonable way to support this outside of a webview
"Verify with Google": false,
// Intentionally last because this tends to give transient_token results rather than
// cookies directly, which requires a currently unknown extra step.
"Notification on another device": true,
"Authentication app": true,
"Email": true,
"Text message": true,
"Backup code": true,
"WhatsApp": true,
"Verify with Google": false,
}

listItems := b.CurrentPage.FindDescendant(FilterByAttribute(
Expand Down
4 changes: 4 additions & 0 deletions pkg/messagix/messengerlite.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package messagix
import (
"context"
"encoding/json"
"errors"
"fmt"
"net/http"
"net/url"
Expand All @@ -19,6 +20,8 @@ import (
"go.mau.fi/mautrix-meta/pkg/messagix/useragent"
)

var ErrTransientTokenLogin = errors.New("login approved but could not be completed automatically, please try logging in again")

type MessengerLiteMethods struct {
client *Client

Expand Down Expand Up @@ -200,6 +203,7 @@ func (m *MessengerLiteMethods) DoLoginSteps(ctx context.Context, userInput map[s
// is two_factor. It depends on the account, not on the MFA method
// selected.
m.client.Logger.Warn().Msg("Got credential_type transient_token, login will fail")
return nil, nil, ErrTransientTokenLogin
}

if len(loginRespPayload.SessionCookies) == 0 {
Expand Down
Loading