diff --git a/supabase_auth/_async/gotrue_admin_api.py b/supabase_auth/_async/gotrue_admin_api.py index 24f64bd0..b9dd871f 100644 --- a/supabase_auth/_async/gotrue_admin_api.py +++ b/supabase_auth/_async/gotrue_admin_api.py @@ -1,7 +1,7 @@ from __future__ import annotations from functools import partial -from typing import Dict, List, Union +from typing import Dict, List, Optional, Union from ..helpers import model_validate, parse_link_response, parse_user_response from ..http_clients import AsyncClient @@ -30,6 +30,7 @@ def __init__( headers: Dict[str, str] = {}, http_client: Union[AsyncClient, None] = None, verify: bool = True, + proxy: Optional[str] = None, ) -> None: AsyncGoTrueBaseAPI.__init__( self, @@ -37,6 +38,7 @@ def __init__( headers=headers, http_client=http_client, verify=verify, + proxy=proxy, ) self.mfa = AsyncGoTrueAdminMFAAPI() self.mfa.list_factors = self._list_factors diff --git a/supabase_auth/_async/gotrue_base_api.py b/supabase_auth/_async/gotrue_base_api.py index 9bab1581..7dfb22fb 100644 --- a/supabase_auth/_async/gotrue_base_api.py +++ b/supabase_auth/_async/gotrue_base_api.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import Any, Callable, Dict, TypeVar, Union, overload +from typing import Any, Callable, Dict, Optional, TypeVar, Union, overload from httpx import Response from pydantic import BaseModel @@ -21,11 +21,13 @@ def __init__( headers: Dict[str, str], http_client: Union[AsyncClient, None], verify: bool = True, + proxy: Optional[str] = None, ): self._url = url self._headers = headers self._http_client = http_client or AsyncClient( verify=bool(verify), + proxy=proxy, follow_redirects=True, http2=True, ) diff --git a/supabase_auth/_async/gotrue_client.py b/supabase_auth/_async/gotrue_client.py index 90013a9e..f4c7ba09 100644 --- a/supabase_auth/_async/gotrue_client.py +++ b/supabase_auth/_async/gotrue_client.py @@ -4,7 +4,7 @@ from functools import partial from json import loads from time import time -from typing import Callable, Dict, List, Tuple, Union +from typing import Callable, Dict, List, Optional, Tuple, Union from urllib.parse import parse_qs, urlencode, urlparse from uuid import uuid4 @@ -96,6 +96,7 @@ def __init__( http_client: Union[AsyncClient, None] = None, flow_type: AuthFlowType = "implicit", verify: bool = True, + proxy: Optional[str] = None, ) -> None: AsyncGoTrueBaseAPI.__init__( self, @@ -103,6 +104,7 @@ def __init__( headers=headers or DEFAULT_HEADERS, http_client=http_client, verify=verify, + proxy=proxy, ) self._storage_key = storage_key or STORAGE_KEY self._auto_refresh_token = auto_refresh_token diff --git a/supabase_auth/_sync/api.py b/supabase_auth/_sync/api.py index 11e1b8aa..012f2473 100644 --- a/supabase_auth/_sync/api.py +++ b/supabase_auth/_sync/api.py @@ -27,6 +27,7 @@ def __init__( cookie_options: CookieOptions, http_client: Optional[SyncClient] = None, verify: bool = True, + proxy: Optional[str] = None, ) -> None: """Initialise API class.""" self.url = url @@ -34,6 +35,7 @@ def __init__( self.cookie_options = cookie_options self.http_client = http_client or SyncClient( verify=bool(verify), + proxy=proxy, follow_redirects=True, http2=True, ) diff --git a/supabase_auth/_sync/client.py b/supabase_auth/_sync/client.py index d55e6999..46577133 100644 --- a/supabase_auth/_sync/client.py +++ b/supabase_auth/_sync/client.py @@ -38,6 +38,7 @@ def __init__( api: Optional[SyncGoTrueAPI] = None, replace_default_headers: bool = False, verify: bool = True, + proxy: Optional[str] = None, ) -> None: """Create a new client @@ -57,6 +58,8 @@ def __init__( The options for the cookie. verify: bool Verify SSL, True by default, False disables verification. + proxy: str + HTTP Proxy string or None, None by default, None disables proxy. """ if url.startswith("http://"): print( @@ -76,6 +79,7 @@ def __init__( "headers": {**empty_or_default_headers, **headers}, "cookie_options": cookie_options, "verify": verify, + "proxy": proxy, } self.api = api or SyncGoTrueAPI(**args) diff --git a/supabase_auth/_sync/gotrue_admin_api.py b/supabase_auth/_sync/gotrue_admin_api.py index c4ae6b99..cedd4bb7 100644 --- a/supabase_auth/_sync/gotrue_admin_api.py +++ b/supabase_auth/_sync/gotrue_admin_api.py @@ -1,7 +1,7 @@ from __future__ import annotations from functools import partial -from typing import Dict, List, Union +from typing import Dict, List, Optional, Union from ..helpers import model_validate, parse_link_response, parse_user_response from ..http_clients import SyncClient @@ -30,6 +30,7 @@ def __init__( headers: Dict[str, str] = {}, http_client: Union[SyncClient, None] = None, verify: bool = True, + proxy: Optional[str] = None, ) -> None: SyncGoTrueBaseAPI.__init__( self, @@ -37,6 +38,7 @@ def __init__( headers=headers, http_client=http_client, verify=verify, + proxy=proxy, ) self.mfa = SyncGoTrueAdminMFAAPI() self.mfa.list_factors = self._list_factors diff --git a/supabase_auth/_sync/gotrue_base_api.py b/supabase_auth/_sync/gotrue_base_api.py index dd2cf257..19448760 100644 --- a/supabase_auth/_sync/gotrue_base_api.py +++ b/supabase_auth/_sync/gotrue_base_api.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import Any, Callable, Dict, TypeVar, Union, overload +from typing import Any, Callable, Dict, Optional, TypeVar, Union, overload from httpx import Response from pydantic import BaseModel @@ -21,11 +21,13 @@ def __init__( headers: Dict[str, str], http_client: Union[SyncClient, None], verify: bool = True, + proxy: Optional[str] = None, ): self._url = url self._headers = headers self._http_client = http_client or SyncClient( verify=bool(verify), + proxy=proxy, follow_redirects=True, http2=True, ) diff --git a/supabase_auth/_sync/gotrue_client.py b/supabase_auth/_sync/gotrue_client.py index 16ee3e65..684d0365 100644 --- a/supabase_auth/_sync/gotrue_client.py +++ b/supabase_auth/_sync/gotrue_client.py @@ -4,7 +4,7 @@ from functools import partial from json import loads from time import time -from typing import Callable, Dict, List, Tuple, Union +from typing import Callable, Dict, List, Optional, Tuple, Union from urllib.parse import parse_qs, urlencode, urlparse from uuid import uuid4 @@ -96,6 +96,7 @@ def __init__( http_client: Union[SyncClient, None] = None, flow_type: AuthFlowType = "implicit", verify: bool = True, + proxy: Optional[str] = None, ) -> None: SyncGoTrueBaseAPI.__init__( self, @@ -103,6 +104,7 @@ def __init__( headers=headers or DEFAULT_HEADERS, http_client=http_client, verify=verify, + proxy=proxy, ) self._storage_key = storage_key or STORAGE_KEY self._auto_refresh_token = auto_refresh_token