diff -Nru python-itsdangerous-2.0.1/CHANGES.rst python-itsdangerous-2.1.0/CHANGES.rst --- python-itsdangerous-2.0.1/CHANGES.rst 2021-05-18 15:08:27.000000000 +0000 +++ python-itsdangerous-2.1.0/CHANGES.rst 2022-02-18 03:28:40.000000000 +0000 @@ -1,3 +1,17 @@ +Version 2.1.0 +------------- + +Released 2022-02-17 + +- Drop support for Python 3.6. :pr:`272` +- Remove previously deprecated code. :pr:`273` + + - JWS functionality: Use a dedicated library such as Authlib + instead. + - ``import itsdangerous.json``: Import ``json`` from the standard + library instead. + + Version 2.0.1 ------------- diff -Nru python-itsdangerous-2.0.1/CONTRIBUTING.rst python-itsdangerous-2.1.0/CONTRIBUTING.rst --- python-itsdangerous-2.0.1/CONTRIBUTING.rst 2021-05-18 15:08:27.000000000 +0000 +++ python-itsdangerous-2.1.0/CONTRIBUTING.rst 2022-02-18 03:28:40.000000000 +0000 @@ -93,7 +93,7 @@ .. code-block:: text - git remote add fork https://github.com/{username}/itsdangerous + $ git remote add fork https://github.com/{username}/itsdangerous - Create a virtualenv. @@ -108,6 +108,12 @@ > env\Scripts\activate +- Upgrade pip and setuptools. + + .. code-block:: text + + $ python -m pip install --upgrade pip setuptools + - Install the development dependencies, then install ItsDangerous in editable mode. @@ -125,7 +131,7 @@ .. _username: https://docs.github.com/en/github/using-git/setting-your-username-in-git .. _email: https://docs.github.com/en/github/setting-up-and-managing-your-github-user-account/setting-your-commit-email-address .. _GitHub account: https://github.com/join -.. _Fork: https://github.com/pallets/jinja/fork +.. _Fork: https://github.com/pallets/itsdangerous/fork .. _Clone: https://docs.github.com/en/github/getting-started-with-github/fork-a-repo#step-2-create-a-local-clone-of-your-fork @@ -139,7 +145,7 @@ .. code-block:: text $ git fetch origin - $ git checkout -b your-branch-name origin/1.0.x + $ git checkout -b your-branch-name origin/2.0.x If you're submitting a feature addition or change, branch off of the "main" branch. diff -Nru python-itsdangerous-2.0.1/debian/changelog python-itsdangerous-2.1.0/debian/changelog --- python-itsdangerous-2.0.1/debian/changelog 2021-08-22 05:48:20.000000000 +0000 +++ python-itsdangerous-2.1.0/debian/changelog 2022-02-20 18:38:23.000000000 +0000 @@ -1,3 +1,9 @@ +python-itsdangerous (2.1.0-1) unstable; urgency=medium + + * New upstream release. + + -- Julien Puydt Sun, 20 Feb 2022 19:38:23 +0100 + python-itsdangerous (2.0.1-1) unstable; urgency=medium * Rewrite d/watch to work again. diff -Nru python-itsdangerous-2.0.1/docs/conf.py python-itsdangerous-2.1.0/docs/conf.py --- python-itsdangerous-2.0.1/docs/conf.py 2021-05-18 15:08:27.000000000 +0000 +++ python-itsdangerous-2.1.0/docs/conf.py 2022-02-18 03:28:40.000000000 +0000 @@ -39,10 +39,10 @@ ] } html_sidebars = { - "index": ["project.html", "localtoc.html", "searchbox.html"], - "**": ["localtoc.html", "relations.html", "searchbox.html"], + "index": ["project.html", "localtoc.html", "searchbox.html", "ethicalads.html"], + "**": ["localtoc.html", "relations.html", "searchbox.html", "ethicalads.html"], } -singlehtml_sidebars = {"index": ["project.html", "localtoc.html"]} +singlehtml_sidebars = {"index": ["project.html", "localtoc.html", "ethicalads.html"]} html_static_path = ["_static"] html_favicon = "_static/itsdangerous-logo-sidebar.png" html_logo = "_static/itsdangerous-logo-sidebar.png" diff -Nru python-itsdangerous-2.0.1/docs/jws.rst python-itsdangerous-2.1.0/docs/jws.rst --- python-itsdangerous-2.0.1/docs/jws.rst 2021-05-18 15:08:27.000000000 +0000 +++ python-itsdangerous-2.1.0/docs/jws.rst 1970-01-01 00:00:00.000000000 +0000 @@ -1,51 +0,0 @@ -:orphan: - -.. module:: itsdangerous.jws - -JSON Web Signature (JWS) -======================== - -.. warning:: - .. deprecated:: 2.0 - ItsDangerous will no longer support JWS in version 2.1. Use a - dedicated JWS/JWT library such as `authlib`_. - -.. _authlib: https://authlib.org/ - -JSON Web Signatures (JWS) work similarly to the existing URL safe -serializer but will emit headers according to `draft-ietf-jose-json-web --signature `_. - -.. code-block:: python - - from itsdangerous import JSONWebSignatureSerializer - s = JSONWebSignatureSerializer("secret-key") - s.dumps({"x": 42}) - 'eyJhbGciOiJIUzI1NiJ9.eyJ4Ijo0Mn0.ZdTn1YyGz9Yx5B5wNpWRL221G1WpVE5fPCPKNuc6UAo' - -When loading the value back the header will not be returned by default -like with the other serializers. However it is possible to also ask for -the header by passing ``return_header=True``. Custom header fields can -be provided upon serialization: - -.. code-block:: python - - s.dumps(0, header_fields={"v": 1}) - 'eyJhbGciOiJIUzI1NiIsInYiOjF9.MA.wT-RZI9YU06R919VBdAfTLn82_iIQD70J_j-3F4z_aM' - s.loads( - "eyJhbGciOiJIUzI1NiIsInYiOjF9" - ".MA.wT-RZI9YU06R919VBdAfTLn82_iIQD70J_j-3F4z_aM" - ) - (0, {'alg': 'HS256', 'v': 1}) - -ItsDangerous only provides HMAC SHA derivatives and the none algorithm -at the moment and does not support the ECC based ones. The algorithm in -the header is checked against the one of the serializer and on a -mismatch a :exc:`~itsdangerous.exc.BadSignature` exception is raised. - -.. autoclass:: JSONWebSignatureSerializer - :members: - -.. autoclass:: TimedJSONWebSignatureSerializer - :members: diff -Nru python-itsdangerous-2.0.1/.github/dependabot.yml python-itsdangerous-2.1.0/.github/dependabot.yml --- python-itsdangerous-2.0.1/.github/dependabot.yml 2021-05-18 15:08:27.000000000 +0000 +++ python-itsdangerous-2.1.0/.github/dependabot.yml 2022-02-18 03:28:40.000000000 +0000 @@ -1,8 +1,9 @@ version: 2 updates: -- package-ecosystem: pip +- package-ecosystem: "github-actions" directory: "/" schedule: - interval: monthly - time: "08:00" - open-pull-requests-limit: 99 + interval: "monthly" + day: "monday" + time: "16:00" + timezone: "UTC" diff -Nru python-itsdangerous-2.0.1/.github/workflows/lock.yaml python-itsdangerous-2.1.0/.github/workflows/lock.yaml --- python-itsdangerous-2.0.1/.github/workflows/lock.yaml 2021-05-18 15:08:27.000000000 +0000 +++ python-itsdangerous-2.1.0/.github/workflows/lock.yaml 2022-02-18 03:28:40.000000000 +0000 @@ -8,8 +8,8 @@ lock: runs-on: ubuntu-latest steps: - - uses: dessant/lock-threads@v2 + - uses: dessant/lock-threads@v3 with: github-token: ${{ github.token }} - issue-lock-inactive-days: 14 - pr-lock-inactive-days: 14 + issue-inactive-days: 14 + pr-inactive-days: 14 diff -Nru python-itsdangerous-2.0.1/.github/workflows/tests.yaml python-itsdangerous-2.1.0/.github/workflows/tests.yaml --- python-itsdangerous-2.0.1/.github/workflows/tests.yaml 2021-05-18 15:08:27.000000000 +0000 +++ python-itsdangerous-2.1.0/.github/workflows/tests.yaml 2022-02-18 03:28:40.000000000 +0000 @@ -24,32 +24,27 @@ fail-fast: false matrix: include: - - {name: Linux, python: '3.9', os: ubuntu-latest, tox: py39} - - {name: Windows, python: '3.9', os: windows-latest, tox: py39} - - {name: Mac, python: '3.9', os: macos-latest, tox: py39} + - {name: Linux, python: '3.10', os: ubuntu-latest, tox: py310} + - {name: Windows, python: '3.10', os: windows-latest, tox: py310} + - {name: Mac, python: '3.10', os: macos-latest, tox: py310} + - {name: '3.11-dev', python: '3.11-dev', os: ubuntu-latest, tox: py311} + - {name: '3.9', python: '3.9', os: ubuntu-latest, tox: py39} - {name: '3.8', python: '3.8', os: ubuntu-latest, tox: py38} - {name: '3.7', python: '3.7', os: ubuntu-latest, tox: py37} - - {name: '3.6', python: '3.6', os: ubuntu-latest, tox: py36} - - {name: 'PyPy', python: pypy3, os: ubuntu-latest, tox: pypy3} - - {name: Typing, python: '3.9', os: ubuntu-latest, tox: typing} + - {name: 'PyPy', python: 'pypy-3.7', os: ubuntu-latest, tox: pypy37} + - {name: Typing, python: '3.10', os: ubuntu-latest, tox: typing} steps: - uses: actions/checkout@v2 - uses: actions/setup-python@v2 with: python-version: ${{ matrix.python }} + cache: 'pip' + cache-dependency-path: 'requirements/*.txt' - name: update pip run: | pip install -U wheel pip install -U setuptools python -m pip install -U pip - - name: get pip cache dir - id: pip-cache - run: echo "::set-output name=dir::$(pip cache dir)" - - name: cache pip - uses: actions/cache@v2 - with: - path: ${{ steps.pip-cache.outputs.dir }} - key: pip|${{ runner.os }}|${{ matrix.python }}|${{ hashFiles('setup.py') }}|${{ hashFiles('requirements/*.txt') }} - name: cache mypy uses: actions/cache@v2 with: diff -Nru python-itsdangerous-2.0.1/.pre-commit-config.yaml python-itsdangerous-2.1.0/.pre-commit-config.yaml --- python-itsdangerous-2.0.1/.pre-commit-config.yaml 2021-05-18 15:08:27.000000000 +0000 +++ python-itsdangerous-2.1.0/.pre-commit-config.yaml 2022-02-18 03:28:40.000000000 +0000 @@ -1,29 +1,33 @@ ci: + autoupdate_branch: "2.0.x" autoupdate_schedule: monthly repos: - repo: https://github.com/asottile/pyupgrade - rev: v2.15.0 + rev: v2.31.0 hooks: - id: pyupgrade - args: ["--py36-plus"] + args: ["--py37-plus"] - repo: https://github.com/asottile/reorder_python_imports - rev: v2.5.0 + rev: v2.7.1 hooks: - id: reorder-python-imports args: ["--application-directories", "src:tests"] + additional_dependencies: ["setuptools>60.9"] - repo: https://github.com/psf/black - rev: 21.5b1 + rev: 22.1.0 hooks: - id: black - repo: https://github.com/PyCQA/flake8 - rev: 3.9.2 + rev: 4.0.1 hooks: - id: flake8 - additional_dependencies: - - flake8-bugbear - - flake8-implicit-str-concat + additional_dependencies: [flake8-bugbear] + - repo: https://github.com/peterdemin/pip-compile-multi + rev: v2.4.3 + hooks: + - id: pip-compile-multi-verify - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v3.4.0 + rev: v4.1.0 hooks: - id: fix-byte-order-marker - id: trailing-whitespace diff -Nru python-itsdangerous-2.0.1/README.rst python-itsdangerous-2.1.0/README.rst --- python-itsdangerous-2.0.1/README.rst 2021-05-18 15:08:27.000000000 +0000 +++ python-itsdangerous-2.1.0/README.rst 2022-02-18 03:28:40.000000000 +0000 @@ -21,7 +21,7 @@ pip install -U itsdangerous -.. _pip: https://pip.pypa.io/en/stable/quickstart/ +.. _pip: https://pip.pypa.io/en/stable/getting-started/ A Simple Example @@ -62,7 +62,7 @@ - Changes: https://itsdangerous.palletsprojects.com/changes/ - PyPI Releases: https://pypi.org/project/ItsDangerous/ - Source Code: https://github.com/pallets/itsdangerous/ -- Issue Tracker: https://github.com/pallets/itsdnagerous/issues/ +- Issue Tracker: https://github.com/pallets/itsdangerous/issues/ - Website: https://palletsprojects.com/p/itsdangerous/ - Twitter: https://twitter.com/PalletsTeam - Chat: https://discord.gg/pallets diff -Nru python-itsdangerous-2.0.1/.readthedocs.yaml python-itsdangerous-2.1.0/.readthedocs.yaml --- python-itsdangerous-2.0.1/.readthedocs.yaml 2021-05-18 15:08:27.000000000 +0000 +++ python-itsdangerous-2.1.0/.readthedocs.yaml 2022-02-18 03:28:40.000000000 +0000 @@ -1,4 +1,8 @@ version: 2 +build: + os: ubuntu-20.04 + tools: + python: "3.10" python: install: - requirements: requirements/docs.txt diff -Nru python-itsdangerous-2.0.1/requirements/dev.in python-itsdangerous-2.1.0/requirements/dev.in --- python-itsdangerous-2.0.1/requirements/dev.in 2021-05-18 15:08:27.000000000 +0000 +++ python-itsdangerous-2.1.0/requirements/dev.in 2022-02-18 03:28:40.000000000 +0000 @@ -1,6 +1,6 @@ -r docs.in -r tests.in -r typing.in -pip-tools +pip-compile-multi pre-commit tox diff -Nru python-itsdangerous-2.0.1/requirements/dev.txt python-itsdangerous-2.1.0/requirements/dev.txt --- python-itsdangerous-2.0.1/requirements/dev.txt 2021-05-18 15:08:27.000000000 +0000 +++ python-itsdangerous-2.1.0/requirements/dev.txt 2022-02-18 03:28:40.000000000 +0000 @@ -1,138 +1,55 @@ +# SHA1:54b5b77ec8c7a0064ffa93b2fd16cb0130ba177c # -# This file is autogenerated by pip-compile +# This file is autogenerated by pip-compile-multi # To update, run: # -# pip-compile requirements/dev.in +# pip-compile-multi # -alabaster==0.7.12 - # via sphinx -appdirs==1.4.4 - # via virtualenv -attrs==21.2.0 - # via pytest -babel==2.9.1 - # via sphinx -certifi==2020.12.5 - # via requests -cfgv==3.2.0 +-r docs.txt +-r tests.txt +-r typing.txt +cfgv==3.3.1 # via pre-commit -chardet==4.0.0 - # via requests -click==7.1.2 - # via pip-tools -distlib==0.3.1 +click==8.0.3 + # via + # pip-compile-multi + # pip-tools +distlib==0.3.4 # via virtualenv -docutils==0.17.1 - # via sphinx -filelock==3.0.12 +filelock==3.5.1 # via # tox # virtualenv -freezegun==1.1.0 - # via -r requirements/tests.in -identify==2.2.4 +identify==2.4.10 # via pre-commit -idna==2.10 - # via requests -imagesize==1.2.0 - # via sphinx -iniconfig==1.1.1 - # via pytest -jinja2==2.11.3 - # via sphinx -markupsafe==1.1.1 - # via - # jinja2 - # sphinx -mypy-extensions==0.4.3 - # via mypy -mypy==0.812 - # via -r requirements/typing.in nodeenv==1.6.0 # via pre-commit -packaging==20.9 - # via - # pallets-sphinx-themes - # pytest - # sphinx - # tox -pallets-sphinx-themes==2.0.0 - # via -r requirements/docs.in -pep517==0.10.0 +pep517==0.12.0 # via pip-tools -pip-tools==6.1.0 +pip-compile-multi==2.4.3 # via -r requirements/dev.in -pluggy==0.13.1 - # via - # pytest - # tox -pre-commit==2.12.1 +pip-tools==6.5.1 + # via pip-compile-multi +platformdirs==2.5.0 + # via virtualenv +pre-commit==2.17.0 # via -r requirements/dev.in -py==1.10.0 - # via - # pytest - # tox -pygments==2.9.0 - # via sphinx -pyparsing==2.4.7 - # via packaging -pytest==6.2.4 - # via -r requirements/tests.in -python-dateutil==2.8.1 - # via freezegun -pytz==2021.1 - # via babel -pyyaml==5.4.1 +pyyaml==6.0 # via pre-commit -requests==2.25.1 - # via sphinx -six==1.16.0 - # via - # python-dateutil - # tox - # virtualenv -snowballstemmer==2.1.0 - # via sphinx -sphinx-issues==1.2.0 - # via -r requirements/docs.in -sphinx==4.0.1 - # via - # -r requirements/docs.in - # pallets-sphinx-themes - # sphinx-issues - # sphinxcontrib-log-cabinet -sphinxcontrib-applehelp==1.0.2 - # via sphinx -sphinxcontrib-devhelp==1.0.2 - # via sphinx -sphinxcontrib-htmlhelp==1.0.3 - # via sphinx -sphinxcontrib-jsmath==1.0.1 - # via sphinx -sphinxcontrib-log-cabinet==1.0.1 - # via -r requirements/docs.in -sphinxcontrib-qthelp==1.0.3 - # via sphinx -sphinxcontrib-serializinghtml==1.1.4 - # via sphinx toml==0.10.2 # via - # pep517 # pre-commit - # pytest # tox -tox==3.23.1 +toposort==1.7 + # via pip-compile-multi +tox==3.24.5 # via -r requirements/dev.in -typed-ast==1.4.3 - # via mypy -typing-extensions==3.10.0.0 - # via mypy -urllib3==1.26.4 - # via requests -virtualenv==20.4.6 +virtualenv==20.13.1 # via # pre-commit # tox +wheel==0.37.1 + # via pip-tools # The following packages are considered to be unsafe in a requirements file: # pip diff -Nru python-itsdangerous-2.0.1/requirements/docs.txt python-itsdangerous-2.1.0/requirements/docs.txt --- python-itsdangerous-2.0.1/requirements/docs.txt 2021-05-18 15:08:27.000000000 +0000 +++ python-itsdangerous-2.1.0/requirements/docs.txt 2022-02-18 03:28:40.000000000 +0000 @@ -1,58 +1,57 @@ +# SHA1:45c590f97fe95b8bdc755eef796e91adf5fbe4ea # -# This file is autogenerated by pip-compile +# This file is autogenerated by pip-compile-multi # To update, run: # -# pip-compile requirements/docs.in +# pip-compile-multi # alabaster==0.7.12 # via sphinx babel==2.9.1 # via sphinx -certifi==2020.12.5 +certifi==2021.10.8 # via requests -chardet==4.0.0 +charset-normalizer==2.0.12 # via requests docutils==0.17.1 # via sphinx -idna==2.10 +idna==3.3 # via requests -imagesize==1.2.0 +imagesize==1.3.0 # via sphinx -jinja2==2.11.3 +jinja2==3.0.3 # via sphinx -markupsafe==1.1.1 - # via - # jinja2 - # sphinx -packaging==20.9 +markupsafe==2.0.1 + # via jinja2 +packaging==21.3 # via # pallets-sphinx-themes # sphinx -pallets-sphinx-themes==2.0.0 +pallets-sphinx-themes==2.0.2 # via -r requirements/docs.in -pygments==2.9.0 +pygments==2.11.2 # via sphinx -pyparsing==2.4.7 +pyparsing==3.0.7 # via packaging -pytz==2021.1 +pytz==2021.3 # via babel -requests==2.25.1 +requests==2.27.1 # via sphinx -snowballstemmer==2.1.0 +snowballstemmer==2.2.0 # via sphinx -sphinx-issues==1.2.0 - # via -r requirements/docs.in -sphinx==4.0.1 +sphinx==4.4.0 # via # -r requirements/docs.in # pallets-sphinx-themes # sphinx-issues # sphinxcontrib-log-cabinet +sphinx-issues==3.0.1 + # via -r requirements/docs.in sphinxcontrib-applehelp==1.0.2 # via sphinx sphinxcontrib-devhelp==1.0.2 # via sphinx -sphinxcontrib-htmlhelp==1.0.3 +sphinxcontrib-htmlhelp==2.0.0 # via sphinx sphinxcontrib-jsmath==1.0.1 # via sphinx @@ -60,10 +59,7 @@ # via -r requirements/docs.in sphinxcontrib-qthelp==1.0.3 # via sphinx -sphinxcontrib-serializinghtml==1.1.4 +sphinxcontrib-serializinghtml==1.1.5 # via sphinx -urllib3==1.26.4 +urllib3==1.26.8 # via requests - -# The following packages are considered to be unsafe in a requirements file: -# setuptools diff -Nru python-itsdangerous-2.0.1/requirements/tests.txt python-itsdangerous-2.1.0/requirements/tests.txt --- python-itsdangerous-2.0.1/requirements/tests.txt 2021-05-18 15:08:27.000000000 +0000 +++ python-itsdangerous-2.1.0/requirements/tests.txt 2022-02-18 03:28:40.000000000 +0000 @@ -1,28 +1,29 @@ +# SHA1:817ecc8a9cb652b1473408ed241d76d464c7cfaa # -# This file is autogenerated by pip-compile +# This file is autogenerated by pip-compile-multi # To update, run: # -# pip-compile requirements/tests.in +# pip-compile-multi # -attrs==21.2.0 +attrs==21.4.0 # via pytest freezegun==1.1.0 # via -r requirements/tests.in iniconfig==1.1.1 # via pytest -packaging==20.9 +packaging==21.3 # via pytest -pluggy==0.13.1 +pluggy==1.0.0 # via pytest -py==1.10.0 +py==1.11.0 # via pytest -pyparsing==2.4.7 +pyparsing==3.0.7 # via packaging -pytest==6.2.4 +pytest==7.0.1 # via -r requirements/tests.in -python-dateutil==2.8.1 +python-dateutil==2.8.2 # via freezegun six==1.16.0 # via python-dateutil -toml==0.10.2 +tomli==2.0.1 # via pytest diff -Nru python-itsdangerous-2.0.1/requirements/typing.txt python-itsdangerous-2.1.0/requirements/typing.txt --- python-itsdangerous-2.0.1/requirements/typing.txt 2021-05-18 15:08:27.000000000 +0000 +++ python-itsdangerous-2.1.0/requirements/typing.txt 2022-02-18 03:28:40.000000000 +0000 @@ -1,14 +1,15 @@ +# SHA1:7983aaa01d64547827c20395d77e248c41b2572f # -# This file is autogenerated by pip-compile +# This file is autogenerated by pip-compile-multi # To update, run: # -# pip-compile requirements/typing.in +# pip-compile-multi # +mypy==0.931 + # via -r requirements/typing.in mypy-extensions==0.4.3 # via mypy -mypy==0.812 - # via -r requirements/typing.in -typed-ast==1.4.3 +tomli==2.0.1 # via mypy -typing-extensions==3.10.0.0 +typing-extensions==4.1.1 # via mypy diff -Nru python-itsdangerous-2.0.1/setup.cfg python-itsdangerous-2.1.0/setup.cfg --- python-itsdangerous-2.0.1/setup.cfg 2021-05-18 15:08:27.000000000 +0000 +++ python-itsdangerous-2.1.0/setup.cfg 2022-02-18 03:28:40.000000000 +0000 @@ -29,8 +29,8 @@ [options] packages = find: package_dir = = src -include_package_data = true -python_requires = >= 3.6 +include_package_data = True +python_requires = >= 3.7 [options.packages.find] where = src @@ -41,7 +41,7 @@ error [coverage:run] -branch = true +branch = True source = itsdangerous tests @@ -57,7 +57,7 @@ # F = flake8 pyflakes # W = pycodestyle warnings # B9 = bugbear opinions -# ISC = implicit-str-concat +# ISC = implicit str concat select = B, E, F, W, B9, ISC ignore = # slice notation whitespace, invalid @@ -71,12 +71,13 @@ # up to 88 allowed by bugbear B950 max-line-length = 80 per-file-ignores = - # __init__ export names + # __init__ exports names src/itsdangerous/__init__.py: F401 [mypy] files = src/itsdangerous -python_version = 3.6 +python_version = 3.7 +show_error_codes = True disallow_subclassing_any = True disallow_untyped_calls = True disallow_untyped_defs = True diff -Nru python-itsdangerous-2.0.1/src/itsdangerous/encoding.py python-itsdangerous-2.1.0/src/itsdangerous/encoding.py --- python-itsdangerous-2.0.1/src/itsdangerous/encoding.py 2021-05-18 15:08:27.000000000 +0000 +++ python-itsdangerous-2.1.0/src/itsdangerous/encoding.py 2022-02-18 03:28:40.000000000 +0000 @@ -34,8 +34,8 @@ try: return base64.urlsafe_b64decode(string) - except (TypeError, ValueError): - raise BadData("Invalid base64-encoded data") + except (TypeError, ValueError) as e: + raise BadData("Invalid base64-encoded data") from e # The alphabet used by base64.urlsafe_* diff -Nru python-itsdangerous-2.0.1/src/itsdangerous/__init__.py python-itsdangerous-2.1.0/src/itsdangerous/__init__.py --- python-itsdangerous-2.0.1/src/itsdangerous/__init__.py 2021-05-18 15:08:27.000000000 +0000 +++ python-itsdangerous-2.1.0/src/itsdangerous/__init__.py 2022-02-18 03:28:40.000000000 +0000 @@ -1,4 +1,3 @@ -from ._json import json from .encoding import base64_decode as base64_decode from .encoding import base64_encode as base64_encode from .encoding import want_bytes as want_bytes @@ -8,8 +7,6 @@ from .exc import BadSignature as BadSignature from .exc import BadTimeSignature as BadTimeSignature from .exc import SignatureExpired as SignatureExpired -from .jws import JSONWebSignatureSerializer -from .jws import TimedJSONWebSignatureSerializer from .serializer import Serializer as Serializer from .signer import HMACAlgorithm as HMACAlgorithm from .signer import NoneAlgorithm as NoneAlgorithm @@ -19,4 +16,4 @@ from .url_safe import URLSafeSerializer as URLSafeSerializer from .url_safe import URLSafeTimedSerializer as URLSafeTimedSerializer -__version__ = "2.0.1" +__version__ = "2.1.0" diff -Nru python-itsdangerous-2.0.1/src/itsdangerous/_json.py python-itsdangerous-2.1.0/src/itsdangerous/_json.py --- python-itsdangerous-2.0.1/src/itsdangerous/_json.py 2021-05-18 15:08:27.000000000 +0000 +++ python-itsdangerous-2.1.0/src/itsdangerous/_json.py 2022-02-18 03:28:40.000000000 +0000 @@ -1,6 +1,5 @@ import json as _json import typing as _t -from types import ModuleType class _CompactJSON: @@ -15,20 +14,3 @@ kwargs.setdefault("ensure_ascii", False) kwargs.setdefault("separators", (",", ":")) return _json.dumps(obj, **kwargs) - - -class DeprecatedJSON(ModuleType): - def __getattribute__(self, item: str) -> _t.Any: - import warnings - - warnings.warn( - "Importing 'itsdangerous.json' is deprecated and will be" - " removed in ItsDangerous 2.1. Use Python's 'json' module" - " instead.", - DeprecationWarning, - stacklevel=2, - ) - return getattr(_json, item) - - -json = DeprecatedJSON("json") diff -Nru python-itsdangerous-2.0.1/src/itsdangerous/jws.py python-itsdangerous-2.1.0/src/itsdangerous/jws.py --- python-itsdangerous-2.0.1/src/itsdangerous/jws.py 2021-05-18 15:08:27.000000000 +0000 +++ python-itsdangerous-2.1.0/src/itsdangerous/jws.py 1970-01-01 00:00:00.000000000 +0000 @@ -1,259 +0,0 @@ -import hashlib -import time -import warnings -from datetime import datetime -from datetime import timezone -from decimal import Decimal -from numbers import Real - -from ._json import _CompactJSON -from .encoding import base64_decode -from .encoding import base64_encode -from .encoding import want_bytes -from .exc import BadData -from .exc import BadHeader -from .exc import BadPayload -from .exc import BadSignature -from .exc import SignatureExpired -from .serializer import Serializer -from .signer import HMACAlgorithm -from .signer import NoneAlgorithm - - -class JSONWebSignatureSerializer(Serializer): - """This serializer implements JSON Web Signature (JWS) support. Only - supports the JWS Compact Serialization. - - .. deprecated:: 2.0 - Will be removed in ItsDangerous 2.1. Use a dedicated library - such as authlib. - """ - - jws_algorithms = { - "HS256": HMACAlgorithm(hashlib.sha256), - "HS384": HMACAlgorithm(hashlib.sha384), - "HS512": HMACAlgorithm(hashlib.sha512), - "none": NoneAlgorithm(), - } - - #: The default algorithm to use for signature generation - default_algorithm = "HS512" - - default_serializer = _CompactJSON - - def __init__( - self, - secret_key, - salt=None, - serializer=None, - serializer_kwargs=None, - signer=None, - signer_kwargs=None, - algorithm_name=None, - ): - warnings.warn( - "JWS support is deprecated and will be removed in" - " ItsDangerous 2.1. Use a dedicated JWS/JWT library such as" - " authlib.", - DeprecationWarning, - stacklevel=2, - ) - super().__init__( - secret_key, - salt=salt, - serializer=serializer, - serializer_kwargs=serializer_kwargs, - signer=signer, - signer_kwargs=signer_kwargs, - ) - - if algorithm_name is None: - algorithm_name = self.default_algorithm - - self.algorithm_name = algorithm_name - self.algorithm = self.make_algorithm(algorithm_name) - - def load_payload(self, payload, serializer=None, return_header=False): - payload = want_bytes(payload) - - if b"." not in payload: - raise BadPayload('No "." found in value') - - base64d_header, base64d_payload = payload.split(b".", 1) - - try: - json_header = base64_decode(base64d_header) - except Exception as e: - raise BadHeader( - "Could not base64 decode the header because of an exception", - original_error=e, - ) - - try: - json_payload = base64_decode(base64d_payload) - except Exception as e: - raise BadPayload( - "Could not base64 decode the payload because of an exception", - original_error=e, - ) - - try: - header = super().load_payload(json_header, serializer=_CompactJSON) - except BadData as e: - raise BadHeader( - "Could not unserialize header because it was malformed", - original_error=e, - ) - - if not isinstance(header, dict): - raise BadHeader("Header payload is not a JSON object", header=header) - - payload = super().load_payload(json_payload, serializer=serializer) - - if return_header: - return payload, header - - return payload - - def dump_payload(self, header, obj): - base64d_header = base64_encode( - self.serializer.dumps(header, **self.serializer_kwargs) - ) - base64d_payload = base64_encode( - self.serializer.dumps(obj, **self.serializer_kwargs) - ) - return base64d_header + b"." + base64d_payload - - def make_algorithm(self, algorithm_name): - try: - return self.jws_algorithms[algorithm_name] - except KeyError: - raise NotImplementedError("Algorithm not supported") - - def make_signer(self, salt=None, algorithm=None): - if salt is None: - salt = self.salt - - key_derivation = "none" if salt is None else None - - if algorithm is None: - algorithm = self.algorithm - - return self.signer( - self.secret_keys, - salt=salt, - sep=".", - key_derivation=key_derivation, - algorithm=algorithm, - ) - - def make_header(self, header_fields): - header = header_fields.copy() if header_fields else {} - header["alg"] = self.algorithm_name - return header - - def dumps(self, obj, salt=None, header_fields=None): - """Like :meth:`.Serializer.dumps` but creates a JSON Web - Signature. It also allows for specifying additional fields to be - included in the JWS header. - """ - header = self.make_header(header_fields) - signer = self.make_signer(salt, self.algorithm) - return signer.sign(self.dump_payload(header, obj)) - - def loads(self, s, salt=None, return_header=False): - """Reverse of :meth:`dumps`. If requested via ``return_header`` - it will return a tuple of payload and header. - """ - payload, header = self.load_payload( - self.make_signer(salt, self.algorithm).unsign(want_bytes(s)), - return_header=True, - ) - - if header.get("alg") != self.algorithm_name: - raise BadHeader("Algorithm mismatch", header=header, payload=payload) - - if return_header: - return payload, header - - return payload - - def loads_unsafe(self, s, salt=None, return_header=False): - kwargs = {"return_header": return_header} - return self._loads_unsafe_impl(s, salt, kwargs, kwargs) - - -class TimedJSONWebSignatureSerializer(JSONWebSignatureSerializer): - """Works like the regular :class:`JSONWebSignatureSerializer` but - also records the time of the signing and can be used to expire - signatures. - - JWS currently does not specify this behavior but it mentions a - possible extension like this in the spec. Expiry date is encoded - into the header similar to what's specified in `draft-ietf-oauth - -json-web-token `_. - """ - - DEFAULT_EXPIRES_IN = 3600 - - def __init__(self, secret_key, expires_in=None, **kwargs): - super().__init__(secret_key, **kwargs) - - if expires_in is None: - expires_in = self.DEFAULT_EXPIRES_IN - - self.expires_in = expires_in - - def make_header(self, header_fields): - header = super().make_header(header_fields) - iat = self.now() - exp = iat + self.expires_in - header["iat"] = iat - header["exp"] = exp - return header - - def loads(self, s, salt=None, return_header=False): - payload, header = super().loads(s, salt, return_header=True) - - if "exp" not in header: - raise BadSignature("Missing expiry date", payload=payload) - - int_date_error = BadHeader("Expiry date is not an IntDate", payload=payload) - - try: - header["exp"] = int(header["exp"]) - except ValueError: - raise int_date_error - - if header["exp"] < 0: - raise int_date_error - - if header["exp"] < self.now(): - raise SignatureExpired( - "Signature expired", - payload=payload, - date_signed=self.get_issue_date(header), - ) - - if return_header: - return payload, header - - return payload - - def get_issue_date(self, header): - """If the header contains the ``iat`` field, return the date the - signature was issued, as a timezone-aware - :class:`datetime.datetime` in UTC. - - .. versionchanged:: 2.0 - The timestamp is returned as a timezone-aware ``datetime`` - in UTC rather than a naive ``datetime`` assumed to be UTC. - """ - rv = header.get("iat") - - if isinstance(rv, (Real, Decimal)): - return datetime.fromtimestamp(int(rv), tz=timezone.utc) - - def now(self): - return int(time.time()) diff -Nru python-itsdangerous-2.0.1/src/itsdangerous/serializer.py python-itsdangerous-2.1.0/src/itsdangerous/serializer.py --- python-itsdangerous-2.0.1/src/itsdangerous/serializer.py 2021-05-18 15:08:27.000000000 +0000 +++ python-itsdangerous-2.1.0/src/itsdangerous/serializer.py 2022-02-18 03:28:40.000000000 +0000 @@ -159,7 +159,7 @@ "Could not load the payload because an exception" " occurred on unserializing the data.", original_error=e, - ) + ) from e def dump_payload(self, obj: _t.Any) -> bytes: """Dumps the encoded object. The return value is always bytes. diff -Nru python-itsdangerous-2.0.1/src/itsdangerous/url_safe.py python-itsdangerous-2.1.0/src/itsdangerous/url_safe.py --- python-itsdangerous-2.0.1/src/itsdangerous/url_safe.py 2021-05-18 15:08:27.000000000 +0000 +++ python-itsdangerous-2.1.0/src/itsdangerous/url_safe.py 2022-02-18 03:28:40.000000000 +0000 @@ -36,7 +36,7 @@ raise BadPayload( "Could not base64 decode the payload because of an exception", original_error=e, - ) + ) from e if decompress: try: @@ -45,7 +45,7 @@ raise BadPayload( "Could not zlib decompress the payload before decoding the payload", original_error=e, - ) + ) from e return super().load_payload(json, *args, **kwargs) diff -Nru python-itsdangerous-2.0.1/tests/test_itsdangerous/test_jws.py python-itsdangerous-2.1.0/tests/test_itsdangerous/test_jws.py --- python-itsdangerous-2.0.1/tests/test_itsdangerous/test_jws.py 2021-05-18 15:08:27.000000000 +0000 +++ python-itsdangerous-2.1.0/tests/test_itsdangerous/test_jws.py 1970-01-01 00:00:00.000000000 +0000 @@ -1,143 +0,0 @@ -from datetime import timedelta - -import pytest - -from itsdangerous.exc import BadData -from itsdangerous.exc import BadHeader -from itsdangerous.exc import BadPayload -from itsdangerous.exc import BadSignature -from itsdangerous.exc import SignatureExpired -from itsdangerous.jws import JSONWebSignatureSerializer -from itsdangerous.jws import TimedJSONWebSignatureSerializer -from test_itsdangerous.test_serializer import TestSerializer -from test_itsdangerous.test_timed import TestTimedSerializer - - -class TestJWSSerializer(TestSerializer): - @pytest.fixture() - def serializer_factory(self): - def factory(secret_key="secret-key", **kwargs): - with pytest.deprecated_call(): - return JSONWebSignatureSerializer(secret_key=secret_key, **kwargs) - - return factory - - test_signer_cls = None # type: ignore - test_signer_kwargs = None # type: ignore - test_fallback_signers = None # type: ignore - test_iter_unsigners = None # type: ignore - - @pytest.mark.parametrize("algorithm_name", ("HS256", "HS384", "HS512", "none")) - def test_algorithm(self, serializer_factory, algorithm_name): - serializer = serializer_factory(algorithm_name=algorithm_name) - assert serializer.loads(serializer.dumps("value")) == "value" - - def test_invalid_algorithm(self, serializer_factory): - with pytest.raises(NotImplementedError) as exc_info: - serializer_factory(algorithm_name="invalid") - - assert "not supported" in str(exc_info.value) - - def test_algorithm_mismatch(self, serializer_factory, serializer): - other = serializer_factory(algorithm_name="HS256") - other.algorithm = serializer.algorithm - signed = other.dumps("value") - - with pytest.raises(BadHeader) as exc_info: - serializer.loads(signed) - - assert "mismatch" in str(exc_info.value) - - @pytest.mark.parametrize( - ("value", "exc_cls", "match"), - ( - ("ab", BadPayload, '"."'), - ("a.b", BadHeader, "base64 decode"), - ("ew.b", BadPayload, "base64 decode"), - ("ew.ab", BadData, "malformed"), - ("W10.ab", BadHeader, "JSON object"), - ), - ) - def test_load_payload_exceptions(self, serializer, value, exc_cls, match): - signer = serializer.make_signer() - signed = signer.sign(value) - - with pytest.raises(exc_cls) as exc_info: - serializer.loads(signed) - - assert match in str(exc_info.value) - - def test_secret_keys(self): - with pytest.deprecated_call(): - serializer = JSONWebSignatureSerializer("a") - - dumped = serializer.dumps("value") - - with pytest.deprecated_call(): - serializer = JSONWebSignatureSerializer(["a", "b"]) - - assert serializer.loads(dumped) == "value" - - -class TestTimedJWSSerializer(TestJWSSerializer, TestTimedSerializer): - @pytest.fixture() - def serializer_factory(self): - def factory(secret_key="secret-key", expires_in=10, **kwargs): - with pytest.deprecated_call(): - return TimedJSONWebSignatureSerializer( - secret_key=secret_key, expires_in=expires_in, **kwargs - ) - - return factory - - def test_default_expires_in(self, serializer_factory): - serializer = serializer_factory(expires_in=None) - assert serializer.expires_in == serializer.DEFAULT_EXPIRES_IN - - test_max_age = None - - def test_exp(self, serializer, value, ts, freeze): - signed = serializer.dumps(value) - freeze.tick() - assert serializer.loads(signed) == value - freeze.tick(timedelta(seconds=10)) - - with pytest.raises(SignatureExpired) as exc_info: - serializer.loads(signed) - - assert exc_info.value.date_signed == ts - assert exc_info.value.payload == value - - test_return_payload = None - - def test_return_header(self, serializer, value, ts): - signed = serializer.dumps(value) - payload, header = serializer.loads(signed, return_header=True) - date_signed = serializer.get_issue_date(header) - assert (payload, date_signed) == (value, ts) - - def test_missing_exp(self, serializer): - header = serializer.make_header(None) - del header["exp"] - signer = serializer.make_signer() - signed = signer.sign(serializer.dump_payload(header, "value")) - - with pytest.raises(BadSignature): - serializer.loads(signed) - - @pytest.mark.parametrize("exp", ("invalid", -1)) - def test_invalid_exp(self, serializer, exp): - header = serializer.make_header(None) - header["exp"] = exp - signer = serializer.make_signer() - signed = signer.sign(serializer.dump_payload(header, "value")) - - with pytest.raises(BadHeader) as exc_info: - serializer.loads(signed) - - assert "IntDate" in str(exc_info.value) - - def test_invalid_iat(self, serializer): - header = serializer.make_header(None) - header["iat"] = "invalid" - assert serializer.get_issue_date(header) is None diff -Nru python-itsdangerous-2.0.1/tox.ini python-itsdangerous-2.1.0/tox.ini --- python-itsdangerous-2.0.1/tox.ini 2021-05-18 15:08:27.000000000 +0000 +++ python-itsdangerous-2.1.0/tox.ini 2022-02-18 03:28:40.000000000 +0000 @@ -1,6 +1,6 @@ [tox] envlist = - py{39,38,37,36,py3} + py3{11,10,9,8,7},pypy3{8,7} style typing docs