supabase_functions 0.10.0__tar.gz → 2.19.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,84 @@
1
+ Metadata-Version: 2.4
2
+ Name: supabase-functions
3
+ Version: 2.19.0
4
+ Summary: Library for Supabase Functions
5
+ Author: Joel Lee, Andrew Smith
6
+ Author-email: Joel Lee <joel@joellee.org>, Andrew Smith <a.smith@silentworks.co.uk>
7
+ License-Expression: MIT
8
+ Requires-Dist: httpx[http2]>=0.26,<0.29
9
+ Requires-Dist: strenum>=0.4.15
10
+ Maintainer: Leonardo Santiago
11
+ Maintainer-email: Leonardo Santiago <leonardo.santiago@supabase.io>
12
+ Requires-Python: >=3.9
13
+ Project-URL: homepage, https://github.com/supabase/supabase/tree/main/src/functions
14
+ Project-URL: repository, https://github.com/supabase/supabase-py
15
+ Description-Content-Type: text/markdown
16
+
17
+ # Functions-py
18
+
19
+ ## Installation
20
+ The package can be installed using pip, uv or poetry:
21
+ ### Pip
22
+ ```bash
23
+ pip install supabase_functions
24
+ ```
25
+ ### UV
26
+ ```bash
27
+ uv add supabase_functions
28
+ ```
29
+ ### Poetry
30
+ ```bash
31
+ poetry add supabase_functions
32
+ ```
33
+
34
+ ## Usage
35
+
36
+ Deploy your Edge Function following the [Supabase Functions documentation](https://supabase.com/docs/guides/functions).
37
+
38
+
39
+ ### Asynchronous Client
40
+
41
+ ```python
42
+ import asyncio
43
+ from supabase_functions import AsyncFunctionsClient
44
+
45
+ async def run_func():
46
+ # Initialize the client with your project URL and optional headers
47
+ headers = {
48
+ "Authorization": "Bearer your-anon-key",
49
+ # Add any other headers you might need
50
+ }
51
+
52
+ fc = AsyncFunctionsClient("https://<project_ref>.functions.supabase.co", headers)
53
+
54
+ try:
55
+ # Invoke your Edge Function
56
+ res = await fc.invoke("payment-sheet", {
57
+ "responseType": "json",
58
+ "body": {"amount": 1000, "currency": "usd"}
59
+ })
60
+ print("Response:", res)
61
+ except Exception as e:
62
+ print(f"Error: {e}")
63
+
64
+ if __name__ == "__main__":
65
+ asyncio.run(run_func())
66
+ ```
67
+ ### Synchronous Client
68
+ ```python
69
+ from supabase_functions import SyncFunctionsClient
70
+
71
+ # Initialize the client
72
+ headers = {"Authorization": "Bearer your-anon-key"}
73
+ fc = SyncFunctionsClient("https://<project_ref>.functions.supabase.co", headers)
74
+
75
+ # Invoke your Edge Function
76
+ try:
77
+ res = fc.invoke("payment-sheet", {
78
+ "responseType": "json",
79
+ "body": {"amount": 1000, "currency": "usd"}
80
+ })
81
+ print("Response:", res)
82
+ except Exception as e:
83
+ print(f"Error: {e}")
84
+ ```
@@ -0,0 +1,68 @@
1
+ # Functions-py
2
+
3
+ ## Installation
4
+ The package can be installed using pip, uv or poetry:
5
+ ### Pip
6
+ ```bash
7
+ pip install supabase_functions
8
+ ```
9
+ ### UV
10
+ ```bash
11
+ uv add supabase_functions
12
+ ```
13
+ ### Poetry
14
+ ```bash
15
+ poetry add supabase_functions
16
+ ```
17
+
18
+ ## Usage
19
+
20
+ Deploy your Edge Function following the [Supabase Functions documentation](https://supabase.com/docs/guides/functions).
21
+
22
+
23
+ ### Asynchronous Client
24
+
25
+ ```python
26
+ import asyncio
27
+ from supabase_functions import AsyncFunctionsClient
28
+
29
+ async def run_func():
30
+ # Initialize the client with your project URL and optional headers
31
+ headers = {
32
+ "Authorization": "Bearer your-anon-key",
33
+ # Add any other headers you might need
34
+ }
35
+
36
+ fc = AsyncFunctionsClient("https://<project_ref>.functions.supabase.co", headers)
37
+
38
+ try:
39
+ # Invoke your Edge Function
40
+ res = await fc.invoke("payment-sheet", {
41
+ "responseType": "json",
42
+ "body": {"amount": 1000, "currency": "usd"}
43
+ })
44
+ print("Response:", res)
45
+ except Exception as e:
46
+ print(f"Error: {e}")
47
+
48
+ if __name__ == "__main__":
49
+ asyncio.run(run_func())
50
+ ```
51
+ ### Synchronous Client
52
+ ```python
53
+ from supabase_functions import SyncFunctionsClient
54
+
55
+ # Initialize the client
56
+ headers = {"Authorization": "Bearer your-anon-key"}
57
+ fc = SyncFunctionsClient("https://<project_ref>.functions.supabase.co", headers)
58
+
59
+ # Invoke your Edge Function
60
+ try:
61
+ res = fc.invoke("payment-sheet", {
62
+ "responseType": "json",
63
+ "body": {"amount": 1000, "currency": "usd"}
64
+ })
65
+ print("Response:", res)
66
+ except Exception as e:
67
+ print(f"Error: {e}")
68
+ ```
@@ -0,0 +1,51 @@
1
+ [project]
2
+ name = "supabase_functions"
3
+ version = "2.19.0" # {x-release-please-version}
4
+ description = "Library for Supabase Functions"
5
+ authors = [
6
+ { name = "Joel Lee", email = "joel@joellee.org" },
7
+ { name = "Andrew Smith", email = "a.smith@silentworks.co.uk" },
8
+ ]
9
+ maintainers = [
10
+ { name = "Leonardo Santiago", email = "leonardo.santiago@supabase.io" }
11
+ ]
12
+ license = "MIT"
13
+ readme = "README.md"
14
+ requires-python = ">=3.9"
15
+ dependencies = [
16
+ "httpx[http2] >=0.26,<0.29",
17
+ "strenum >=0.4.15",
18
+ ]
19
+
20
+
21
+ [project.urls]
22
+ repository = "https://github.com/supabase/supabase-py"
23
+ homepage = "https://github.com/supabase/supabase/tree/main/src/functions"
24
+
25
+ [dependency-groups]
26
+ tests = [
27
+ "pyjwt >=2.8.0",
28
+ "pytest >=7.4.2,<9.0.0",
29
+ "pytest-cov >=4,<7",
30
+ "pytest-asyncio >=0.21.1,<1.2.0",
31
+ ]
32
+ lints = [
33
+ "unasync>=0.6.0",
34
+ "ruff >=0.12.1",
35
+ "pre-commit >=3.4,<5.0"
36
+ ]
37
+ dev = [{ include-group = "lints" }, {include-group = "tests" }]
38
+
39
+ [tool.uv]
40
+ default-groups = [ "dev" ]
41
+
42
+ [tool.pytest.ini_options]
43
+ asyncio_mode = "auto"
44
+ addopts = "tests"
45
+ filterwarnings = [
46
+ "ignore::DeprecationWarning", # ignore deprecation warnings globally
47
+ ]
48
+
49
+ [build-system]
50
+ requires = ["uv_build>=0.8.3,<0.9.0"]
51
+ build-backend = "uv_build"
@@ -7,7 +7,6 @@ from ..errors import FunctionsHttpError, FunctionsRelayError
7
7
  from ..utils import (
8
8
  FunctionRegion,
9
9
  is_http_url,
10
- is_valid_jwt,
11
10
  is_valid_str_arg,
12
11
  )
13
12
  from ..version import __version__
@@ -75,7 +74,6 @@ class AsyncFunctionsClient:
75
74
  headers: Optional[Dict[str, str]] = None,
76
75
  json: Optional[Dict[Any, Any]] = None,
77
76
  ) -> Response:
78
-
79
77
  user_data = {"data": json} if isinstance(json, str) else {"json": json}
80
78
  response = await self._client.request(method, url, **user_data, headers=headers)
81
79
 
@@ -103,9 +101,6 @@ class AsyncFunctionsClient:
103
101
  the new jwt token sent in the authorization header
104
102
  """
105
103
 
106
- if not is_valid_jwt(token):
107
- raise ValueError("token must be a valid JWT authorization token string.")
108
-
109
104
  self.headers["Authorization"] = f"Bearer {token}"
110
105
 
111
106
  async def invoke(
@@ -7,7 +7,6 @@ from ..errors import FunctionsHttpError, FunctionsRelayError
7
7
  from ..utils import (
8
8
  FunctionRegion,
9
9
  is_http_url,
10
- is_valid_jwt,
11
10
  is_valid_str_arg,
12
11
  )
13
12
  from ..version import __version__
@@ -75,7 +74,6 @@ class SyncFunctionsClient:
75
74
  headers: Optional[Dict[str, str]] = None,
76
75
  json: Optional[Dict[Any, Any]] = None,
77
76
  ) -> Response:
78
-
79
77
  user_data = {"data": json} if isinstance(json, str) else {"json": json}
80
78
  response = self._client.request(method, url, **user_data, headers=headers)
81
79
 
@@ -103,9 +101,6 @@ class SyncFunctionsClient:
103
101
  the new jwt token sent in the authorization header
104
102
  """
105
103
 
106
- if not is_valid_jwt(token):
107
- raise ValueError("token must be a valid JWT authorization token string.")
108
-
109
104
  self.headers["Authorization"] = f"Bearer {token}"
110
105
 
111
106
  def invoke(
@@ -1,4 +1,3 @@
1
- import re
2
1
  import sys
3
2
  from urllib.parse import urlparse
4
3
  from warnings import warn
@@ -59,26 +58,3 @@ def is_valid_str_arg(target: str) -> bool:
59
58
 
60
59
  def is_http_url(url: str) -> bool:
61
60
  return urlparse(url).scheme in {"https", "http"}
62
-
63
-
64
- def is_valid_jwt(value: str) -> bool:
65
- """Checks if value looks like a JWT, does not do any extra parsing."""
66
- if not isinstance(value, str):
67
- return False
68
-
69
- # Remove trailing whitespaces if any.
70
- value = value.strip()
71
-
72
- # Remove "Bearer " prefix if any.
73
- if value.startswith("Bearer "):
74
- value = value[7:]
75
-
76
- # Valid JWT must have 2 dots (Header.Paylod.Signature)
77
- if value.count(".") != 2:
78
- return False
79
-
80
- for part in value.split("."):
81
- if not re.search(BASE64URL_REGEX, part, re.IGNORECASE):
82
- return False
83
-
84
- return True
@@ -0,0 +1 @@
1
+ __version__ = "2.19.0" # {x-release-please-version}
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2020 Supabase
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
@@ -1,44 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: supabase_functions
3
- Version: 0.10.0
4
- Summary: Library for Supabase Functions
5
- Home-page: https://github.com/supabase/functions-py
6
- License: MIT
7
- Author: Joel Lee
8
- Author-email: joel@joellee.org
9
- Requires-Python: >=3.9,<4.0
10
- Classifier: License :: OSI Approved :: MIT License
11
- Classifier: Programming Language :: Python :: 3
12
- Classifier: Programming Language :: Python :: 3.9
13
- Classifier: Programming Language :: Python :: 3.10
14
- Classifier: Programming Language :: Python :: 3.11
15
- Classifier: Programming Language :: Python :: 3.12
16
- Classifier: Programming Language :: Python :: 3.13
17
- Requires-Dist: httpx[http2] (>=0.26,<0.29)
18
- Requires-Dist: strenum (>=0.4.15,<0.5.0)
19
- Project-URL: Repository, https://github.com/supabase/functions-py
20
- Description-Content-Type: text/markdown
21
-
22
- # Functions-py
23
-
24
-
25
- ## Installation
26
-
27
- `pip3 install supabase_functions`
28
-
29
- ## Usage
30
-
31
- Deploy your function as per documentation.
32
-
33
-
34
- ```python3
35
- import asyncio
36
- from supabase_functions import AsyncFunctionsClient
37
- async def run_func():
38
- fc = AsyncFunctionsClient("https://<project_ref>.functions.supabase.co", {})
39
- res = await fc.invoke("payment-sheet", {"responseType": "json"})
40
-
41
- if __name__ == "__main__":
42
- asyncio.run(run_func())
43
- ```
44
-
@@ -1,22 +0,0 @@
1
- # Functions-py
2
-
3
-
4
- ## Installation
5
-
6
- `pip3 install supabase_functions`
7
-
8
- ## Usage
9
-
10
- Deploy your function as per documentation.
11
-
12
-
13
- ```python3
14
- import asyncio
15
- from supabase_functions import AsyncFunctionsClient
16
- async def run_func():
17
- fc = AsyncFunctionsClient("https://<project_ref>.functions.supabase.co", {})
18
- res = await fc.invoke("payment-sheet", {"responseType": "json"})
19
-
20
- if __name__ == "__main__":
21
- asyncio.run(run_func())
22
- ```
@@ -1,38 +0,0 @@
1
- [tool.poetry]
2
- name = "supabase_functions"
3
- version = "0.10.0" # {x-release-please-version}
4
- description = "Library for Supabase Functions"
5
- authors = [
6
- "Joel Lee <joel@joellee.org>",
7
- "Andrew Smith <a.smith@silentworks.co.uk>"
8
- ]
9
- license = "MIT"
10
- readme = "README.md"
11
- repository = "https://github.com/supabase/functions-py"
12
-
13
- [tool.poetry.dependencies]
14
- python = "^3.9"
15
- httpx = {version = ">=0.26,<0.29", extras = ["http2"]}
16
- strenum = "^0.4.15"
17
-
18
- [tool.poetry.group.dev.dependencies]
19
- black = ">=23.9.1,<26.0.0"
20
- isort = ">=5.12,<7.0"
21
- pre-commit = ">=3.4,<5.0"
22
- pyjwt = "^2.8.0"
23
- pytest = ">=7.4.2,<9.0.0"
24
- pytest-cov = ">=4,<7"
25
- unasync-cli = "^0.0.9"
26
- pytest-asyncio = ">=0.21.1,<1.1.0"
27
- coveralls = "^3.3.0"
28
-
29
- [tool.pytest.ini_options]
30
- asyncio_mode = "auto"
31
- addopts = "tests"
32
- filterwarnings = [
33
- "ignore::DeprecationWarning", # ignore deprecation warnings globally
34
- ]
35
-
36
- [build-system]
37
- requires = ["poetry-core>=1.0.0"]
38
- build-backend = "poetry.core.masonry.api"
@@ -1 +0,0 @@
1
- __version__ = "0.10.0" # {x-release-please-version}