Skip to content

Commit 9a67aa1

Browse files
Merge pull request #517 from supertokens/auto-transpiling
Auto transpiling to catchup to node sdk (as of 19.0 branch of node sdk)
2 parents 78e1072 + 04ffcf6 commit 9a67aa1

File tree

251 files changed

+21844
-3760
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

251 files changed

+21844
-3760
lines changed

.circleci/setupAndTestBackendSDKWithFreeCore.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ ST_CONNECTION_URI=http://localhost:8081
5656

5757
# start test-server
5858
pushd tests/test-server
59-
sh setup-for-test.sh
6059
SUPERTOKENS_ENV=testing API_PORT=$API_PORT ST_CONNECTION_URI=$ST_CONNECTION_URI python3 app.py &
6160
popd
6261

.cursorrules

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
You are an expert Python and Typescript developer. Your job is to convert node code (in typescript) into Python code. The python code then goes into this SDK. The python code style should keep in mind:
2+
- Avoid using TypeDict
3+
- Avoid using generic Dict as much as possible, except when defining the types for `user_context`.
4+
- If a function has multiple `status` strings as outputs, then define one unique class per unique `status` string. The class name should be such that it indicates the status it is associated with.
5+
- Variable and function names should be in snake_case. Class names in PascalCase.
6+
- Whenever importing `Literal`, import it from `typing_extensions`, and not `types`.
7+
- Do not use `|` for OR type, instead use `Union`
8+
- When defining API interface functions, make sure the output classes inherit from `APIResponse` class, and that they have a `to_json` function defined whose output matches the structure of the provided Typescript code output objects.
9+
10+
The semantic of the python code should be the same as what's of the provided Typescript code.

.pylintrc

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
[MASTER]
2-
32
# A comma-separated list of package or module names from where C extensions may
43
# be loaded. Extensions are loading into the active Python interpreter and may
54
# run arbitrary code.
@@ -20,11 +19,11 @@ fail-on=
2019
fail-under=10.0
2120

2221
# Files or directories to be skipped. They should be base names, not paths.
23-
ignore=CVS
22+
ignore=CVS,
2423

2524
# Add files or directories matching the regex patterns to the ignore-list. The
2625
# regex matches against paths and can be in Posix or Windows format.
27-
ignore-paths=
26+
ignore-paths=tests/test-server
2827

2928
# Files or directories matching the regex patterns are skipped. The regex
3029
# matches against base names, not paths.
@@ -116,7 +115,16 @@ disable=raw-checker-failed,
116115
global-statement,
117116
too-many-lines,
118117
duplicate-code,
119-
too-many-return-statements
118+
too-many-return-statements,
119+
logging-not-lazy,
120+
logging-fstring-interpolation,
121+
consider-using-f-string,
122+
consider-using-in,
123+
no-else-return,
124+
no-self-use,
125+
no-else-raise,
126+
too-many-nested-blocks,
127+
120128

121129
# Enable the message, report, category or checker with the given id(s). You can
122130
# either give multiple identifier separated by comma (,) or put this option

.vscode/launch.json

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"name": "Python: Flask, supertokens-website tests",
6+
"type": "python",
7+
"request": "launch",
8+
"program": "${workspaceFolder}/tests/frontendIntegration/flask-server/app.py",
9+
"args": [
10+
"--port",
11+
"8080"
12+
],
13+
"cwd": "${workspaceFolder}/tests/frontendIntegration/flask-server",
14+
"env": {
15+
"FLASK_DEBUG": "1"
16+
},
17+
"jinja": true
18+
},
19+
{
20+
"name": "Python: FastAPI, supertokens-website tests",
21+
"type": "python",
22+
"request": "launch",
23+
"program": "${workspaceFolder}/tests/frontendIntegration/fastapi-server/app.py",
24+
"args": [
25+
"--port",
26+
"8080"
27+
],
28+
"cwd": "${workspaceFolder}/tests/frontendIntegration/fastapi-server",
29+
"env": {
30+
"FLASK_DEBUG": "1"
31+
},
32+
"jinja": true
33+
},
34+
{
35+
"name": "Python: Flask, supertokens-auth-react tests",
36+
"type": "python",
37+
"request": "launch",
38+
"program": "${workspaceFolder}/tests/auth-react/flask-server/app.py",
39+
"args": [
40+
"--port",
41+
"8083"
42+
],
43+
"cwd": "${workspaceFolder}/tests/auth-react/flask-server",
44+
"env": {
45+
"FLASK_DEBUG": "1"
46+
},
47+
"jinja": true
48+
},
49+
{
50+
"name": "Python: FastAPI, supertokens-auth-react tests",
51+
"type": "python",
52+
"request": "launch",
53+
"program": "${workspaceFolder}/tests/auth-react/fastapi-server/app.py",
54+
"args": [
55+
"--port",
56+
"8083"
57+
],
58+
"cwd": "${workspaceFolder}/tests/auth-react/fastapi-server",
59+
"jinja": true
60+
},
61+
{
62+
"name": "Python: Django, supertokens-auth-react tests",
63+
"type": "python",
64+
"request": "launch",
65+
"program": "${workspaceFolder}/tests/auth-react/django3x/manage.py",
66+
"args": [
67+
"runserver",
68+
"0.0.0.0:8083"
69+
],
70+
"env": {
71+
"PYTHONPATH": "${workspaceFolder}"
72+
},
73+
"cwd": "${workspaceFolder}/tests/auth-react/django3x",
74+
"jinja": true
75+
},
76+
{
77+
"name": "Python: backend-sdk-testing repo",
78+
"type": "python",
79+
"request": "launch",
80+
"program": "${workspaceFolder}/tests/test-server/app.py",
81+
"cwd": "${workspaceFolder}/tests/test-server",
82+
"env": {
83+
"SUPERTOKENS_ENV": "testing",
84+
"API_PORT": "3030",
85+
"ST_CONNECTION_URI": "http://localhost:8081"
86+
},
87+
"console": "integratedTerminal"
88+
},
89+
]
90+
}

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,27 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88

99
## [unreleased]
1010

11+
12+
## [0.25.0] - 2024-09-18
13+
14+
### Breaking changes
15+
- `supertokens_python.recipe.emailverification.types.User` has been renamed to `supertokens_python.recipe.emailverification.types.EmailVerificationUser`
16+
- The user object has been changed to be a global one, containing information about all emails, phone numbers, third party info and login methods associated with that user.
17+
- Type of `get_email_for_user_id` in `emailverification.init` has changed
18+
- Session recipe's error handlers take an extra param of recipe_user_id as well
19+
- Session recipe, removes `validate_claims_in_jwt_payload` that is exposed to the user.
20+
- TODO..
21+
1122
## [0.24.4] - 2024-10-16
1223

1324
- Updates `phonenumbers` and `twilio` to latest versions
1425

26+
>>>>>>> 0.24
1527
## [0.24.3] - 2024-09-24
1628

1729
- Adds support for form field related improvements by making fields accept any type of values
1830
- Adds support for optional fields to properly optional
31+
>>>>>>> 0.24
1932
2033
### Migration
2134

coreDriverInterfaceSupported.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"_comment": "contains a list of core-driver interfaces branch names that this core supports",
33
"versions": [
4-
"3.1"
4+
"5.1"
55
]
6-
}
6+
}

dev-requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,5 @@ uvicorn==0.18.2
8585
Werkzeug==2.0.3
8686
wrapt==1.13.3
8787
zipp==3.7.0
88+
pyotp==2.9.0
89+
aiofiles==23.2.1

frontendDriverInterfaceSupported.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
"_comment": "contains a list of frontend-driver interfaces branch names that this core supports",
33
"versions": [
44
"1.17",
5-
"2.0"
5+
"1.18",
6+
"1.19",
7+
"2.0",
8+
"3.0",
9+
"3.1"
610
]
711
}

setup.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,16 @@
1919
"Fastapi",
2020
"uvicorn==0.18.2",
2121
"python-dotenv==0.19.2",
22+
"pyotp<3",
23+
"aiofiles==23.2.1",
2224
]
2325
),
2426
"flask": (
2527
[
2628
"flask_cors",
2729
"Flask",
2830
"python-dotenv==0.19.2",
31+
"pyotp<3",
2932
]
3033
),
3134
"django": (
@@ -35,6 +38,7 @@
3538
"django-stubs==1.9.0",
3639
"uvicorn==0.18.2",
3740
"python-dotenv==0.19.2",
41+
"pyotp<3",
3842
]
3943
),
4044
"django2x": (
@@ -44,6 +48,7 @@
4448
"django-stubs==1.9.0",
4549
"gunicorn==20.1.0",
4650
"python-dotenv==0.19.2",
51+
"pyotp<3",
4752
]
4853
),
4954
"drf": (
@@ -57,6 +62,7 @@
5762
"uvicorn==0.18.2",
5863
"python-dotenv==0.19.2",
5964
"tzdata==2021.5",
65+
"pyotp<3",
6066
]
6167
),
6268
}
@@ -83,7 +89,7 @@
8389

8490
setup(
8591
name="supertokens_python",
86-
version="0.24.4",
92+
version="0.25.0",
8793
author="SuperTokens",
8894
license="Apache 2.0",
8995
author_email="[email protected]",
@@ -121,10 +127,11 @@
121127
"asgiref>=3.4.1,<4",
122128
"typing_extensions>=4.1.1,<5.0.0",
123129
"Deprecated==1.2.13",
124-
"phonenumbers==8.13.47",
125-
"twilio==9.3.3",
130+
"phonenumbers<9",
131+
"twilio<10",
126132
"aiosmtplib>=1.1.6,<4.0.0",
127133
"pkce==1.0.3",
134+
"pyotp<3",
128135
],
129136
python_requires=">=3.7",
130137
include_package_data=True,

supertokens_python/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
from typing_extensions import Literal
1818

1919
from supertokens_python.framework.request import BaseRequest
20+
from supertokens_python.types import RecipeUserId
2021

2122
from . import supertokens
2223
from .recipe_module import RecipeModule
@@ -49,3 +50,7 @@ def get_request_from_user_context(
4950
user_context: Optional[Dict[str, Any]],
5051
) -> Optional[BaseRequest]:
5152
return Supertokens.get_instance().get_request_from_user_context(user_context)
53+
54+
55+
def convert_to_recipe_user_id(user_id: str) -> RecipeUserId:
56+
return RecipeUserId(user_id)

0 commit comments

Comments
 (0)