Эх сурвалжийг харах

Rename checkpoint to challenge

Tulir Asokan 3 жил өмнө
parent
commit
c25ae16926

+ 2 - 2
mauigpapi/errors/__init__.py

@@ -3,8 +3,8 @@ from .mqtt import IGMQTTError, IrisSubscribeError, MQTTNotConnected, MQTTNotLogg
 from .response import (
     IGActionSpamError,
     IGBad2FACodeError,
+    IGChallengeError,
     IGChallengeWrongCodeError,
-    IGCheckpointError,
     IGConsentRequiredError,
     IGFBNoContactPointFoundError,
     IGInactiveUserError,
@@ -22,4 +22,4 @@ from .response import (
     IGUnknownError,
     IGUserHasLoggedOutError,
 )
-from .state import IGCookieNotFoundError, IGNoCheckpointError, IGUserIDNotFoundError
+from .state import IGCookieNotFoundError, IGNoChallengeError, IGUserIDNotFoundError

+ 3 - 3
mauigpapi/errors/response.py

@@ -20,7 +20,7 @@ from aiohttp import ClientResponse
 from mautrix.types import JSON, Serializable
 
 from ..types import (
-    CheckpointResponse,
+    ChallengeResponse,
     ConsentRequiredResponse,
     LoginErrorResponse,
     LoginRequiredResponse,
@@ -81,8 +81,8 @@ class IGRateLimitError(IGResponseError):
     pass
 
 
-class IGCheckpointError(IGResponseError):
-    body: CheckpointResponse
+class IGChallengeError(IGResponseError):
+    body: ChallengeResponse
 
     @property
     def url(self) -> str:

+ 2 - 2
mauigpapi/errors/state.py

@@ -26,6 +26,6 @@ class IGCookieNotFoundError(IGError):
         super().__init__(f"Cookie '{key}' not found")
 
 
-class IGNoCheckpointError(IGError):
-    def __init__(self, message: str = "No checkpoint data available"):
+class IGNoChallengeError(IGError):
+    def __init__(self, message: str = "No challenge data available"):
         super().__init__(message)

+ 2 - 2
mauigpapi/http/base.py

@@ -30,7 +30,7 @@ from mautrix.util.logging import TraceLogger
 from ..errors import (
     IGActionSpamError,
     IGBad2FACodeError,
-    IGCheckpointError,
+    IGChallengeError,
     IGConsentRequiredError,
     IGFBNoContactPointFoundError,
     IGInactiveUserError,
@@ -204,7 +204,7 @@ class BaseAndroidAPI:
         message = data.get("message")
         if isinstance(message, str):
             if message == "challenge_required":
-                err = IGCheckpointError(resp, data)
+                err = IGChallengeError(resp, data)
                 self.state.challenge_path = err.url
                 raise err
             elif message == "consent_required":

+ 2 - 2
mauigpapi/state/state.py

@@ -22,7 +22,7 @@ from attr import dataclass
 
 from mautrix.types import SerializableAttrs, field
 
-from ..errors import IGCookieNotFoundError, IGNoCheckpointError, IGUserIDNotFoundError
+from ..errors import IGCookieNotFoundError, IGNoChallengeError, IGUserIDNotFoundError
 from ..types import ChallengeStateResponse
 from .application import AndroidApplication
 from .cookies import Cookies
@@ -74,7 +74,7 @@ class AndroidState(SerializableAttrs):
     @property
     def challenge_path(self) -> str:
         if not self._challenge_path:
-            raise IGNoCheckpointError()
+            raise IGNoChallengeError()
         return self._challenge_path
 
     @challenge_path.setter

+ 2 - 2
mauigpapi/types/__init__.py

@@ -12,8 +12,8 @@ from .account import (
 from .challenge import ChallengeStateData, ChallengeStateResponse
 from .direct_inbox import DMInbox, DMInboxCursor, DMInboxResponse, DMThreadResponse
 from .error import (
-    CheckpointChallenge,
-    CheckpointResponse,
+    ChallengeData,
+    ChallengeResponse,
     ConsentRequiredResponse,
     LoginErrorResponse,
     LoginErrorResponseButton,

+ 3 - 3
mauigpapi/types/error.py

@@ -35,7 +35,7 @@ class SpamResponse(SerializableAttrs):
 
 
 @dataclass
-class CheckpointChallenge(SerializableAttrs):
+class ChallengeData(SerializableAttrs):
     url: str
     api_path: str
     hide_webview_header: bool
@@ -45,10 +45,10 @@ class CheckpointChallenge(SerializableAttrs):
 
 
 @dataclass
-class CheckpointResponse(SerializableAttrs):
+class ChallengeResponse(SerializableAttrs):
     message: str  # challenge_required
     status: str  # fail
-    challenge: CheckpointChallenge
+    challenge: ChallengeData
     error_type: Optional[str] = None
 
 

+ 3 - 3
mautrix_instagram/commands/auth.py

@@ -20,8 +20,8 @@ import hmac
 
 from mauigpapi.errors import (
     IGBad2FACodeError,
+    IGChallengeError,
     IGChallengeWrongCodeError,
-    IGCheckpointError,
     IGLoginBadPasswordError,
     IGLoginInvalidUserError,
     IGLoginTwoFactorRequiredError,
@@ -95,7 +95,7 @@ async def login(evt: CommandEvent) -> None:
             "2fa_identifier": tfa_info.two_factor_identifier,
         }
         await evt.reply(msg)
-    except IGCheckpointError:
+    except IGChallengeError:
         await api.challenge_auto(reset=True)
         evt.sender.command_status = {
             **evt.sender.command_status,
@@ -131,7 +131,7 @@ async def enter_login_2fa(evt: CommandEvent) -> None:
             "Invalid 2-factor authentication code. Please try again "
             "or use `$cmdprefix+sp cancel` to cancel."
         )
-    except IGCheckpointError:
+    except IGChallengeError:
         await api.challenge_auto(reset=True)
         evt.sender.command_status = {
             **evt.sender.command_status,

+ 4 - 4
mautrix_instagram/user.py

@@ -22,7 +22,7 @@ import time
 
 from mauigpapi import AndroidAPI, AndroidMQTT, AndroidState
 from mauigpapi.errors import (
-    IGCheckpointError,
+    IGChallengeError,
     IGConsentRequiredError,
     IGNotLoggedInError,
     IGRateLimitError,
@@ -186,7 +186,7 @@ class User(DBUser, BaseUser):
                 self.log.warning(f"Failed to connect to Instagram: {e}, logging out")
                 await self.logout(error=e)
                 return
-            except (IGCheckpointError, IGConsentRequiredError) as e:
+            except (IGChallengeError, IGConsentRequiredError) as e:
                 await self._handle_checkpoint(e, on="connect", client=client)
                 return
         self.client = client
@@ -365,7 +365,7 @@ class User(DBUser, BaseUser):
 
     async def _handle_checkpoint(
         self,
-        e: IGCheckpointError | IGConsentRequiredError,
+        e: IGChallengeError | IGConsentRequiredError,
         on: str,
         client: AndroidAPI | None = None,
     ) -> None:
@@ -434,7 +434,7 @@ class User(DBUser, BaseUser):
                 )
                 await asyncio.sleep(sleep_minutes * 60)
                 sleep_minutes += 2
-            except IGCheckpointError as e:
+            except IGChallengeError as e:
                 await self._handle_checkpoint(e, on="sync")
                 return
 

+ 5 - 5
mautrix_instagram/web/provisioning_api.py

@@ -29,8 +29,8 @@ from yarl import URL
 from mauigpapi import AndroidAPI, AndroidState
 from mauigpapi.errors import (
     IGBad2FACodeError,
+    IGChallengeError,
     IGChallengeWrongCodeError,
-    IGCheckpointError,
     IGFBNoContactPointFoundError,
     IGLoginBadPasswordError,
     IGLoginInvalidUserError,
@@ -156,7 +156,7 @@ class ProvisioningAPI:
                 status=202,
                 headers=self._acao_headers,
             )
-        except IGCheckpointError as e:
+        except IGChallengeError as e:
             self.log.debug("%s logged in as %s, but got a checkpoint", user.mxid, username)
             return await self.start_checkpoint(user, api, e)
         except IGLoginInvalidUserError:
@@ -220,13 +220,13 @@ class ProvisioningAPI:
                 status=403,
                 headers=self._acao_headers,
             )
-        except IGCheckpointError as e:
+        except IGChallengeError as e:
             self.log.debug("%s submitted a 2-factor auth code, but got a checkpoint", user.mxid)
             return await self.start_checkpoint(user, api, e)
         return await self._finish_login(user, state, api, login_resp=resp, after="2-factor auth")
 
     async def start_checkpoint(
-        self, user: u.User, api: AndroidAPI, err: IGCheckpointError
+        self, user: u.User, api: AndroidAPI, err: IGChallengeError
     ) -> web.Response:
         try:
             resp = await api.challenge_auto(reset=True)
@@ -311,7 +311,7 @@ class ProvisioningAPI:
         manufacturer, model = pl["manufacturer"], pl["model"]
         try:
             resp = await api.current_user()
-        except IGCheckpointError as e:
+        except IGChallengeError as e:
             if isinstance(login_resp, ChallengeStateResponse):
                 self.log.debug(
                     "%s got a checkpoint after a login that looked successful, "