jwt-toolkit 1.2.0__tar.gz → 1.2.1__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.
Files changed (95) hide show
  1. jwt_toolkit-1.2.1/.gitattributes +3 -0
  2. jwt_toolkit-1.2.1/.github/workflows/ci.yml +100 -0
  3. {jwt_toolkit-1.2.0 → jwt_toolkit-1.2.1}/.github/workflows/publish.yml +15 -9
  4. {jwt_toolkit-1.2.0 → jwt_toolkit-1.2.1}/.gitignore +3 -0
  5. {jwt_toolkit-1.2.0 → jwt_toolkit-1.2.1}/CONTRIBUTING.md +3 -2
  6. {jwt_toolkit-1.2.0 → jwt_toolkit-1.2.1}/Makefile +5 -2
  7. {jwt_toolkit-1.2.0 → jwt_toolkit-1.2.1}/PKG-INFO +6 -2
  8. {jwt_toolkit-1.2.0 → jwt_toolkit-1.2.1}/README.md +1 -1
  9. {jwt_toolkit-1.2.0 → jwt_toolkit-1.2.1}/jwt_toolkit/core/encoding.py +15 -5
  10. {jwt_toolkit-1.2.0 → jwt_toolkit-1.2.1}/pyproject.toml +6 -1
  11. {jwt_toolkit-1.2.0 → jwt_toolkit-1.2.1}/tests/test_cmd_crack.py +4 -1
  12. jwt_toolkit-1.2.1/tests/test_encoding.py +37 -0
  13. {jwt_toolkit-1.2.0 → jwt_toolkit-1.2.1}/uv.lock +160 -114
  14. jwt_toolkit-1.2.0/.github/workflows/ci.yml +0 -75
  15. jwt_toolkit-1.2.0/docs/plans/01-correctness-and-robustness.md +0 -260
  16. jwt_toolkit-1.2.0/docs/plans/02-verification-policies.md +0 -78
  17. jwt_toolkit-1.2.0/docs/plans/03-reports-and-automation.md +0 -89
  18. jwt_toolkit-1.2.0/docs/plans/04-jwks-and-discovery.md +0 -86
  19. jwt_toolkit-1.2.0/docs/plans/05-developer-workflows.md +0 -101
  20. jwt_toolkit-1.2.0/docs/plans/06-quality-and-releases.md +0 -113
  21. jwt_toolkit-1.2.0/docs/plans/07-delivery-and-handoff.md +0 -106
  22. jwt_toolkit-1.2.0/docs/plans/08-architecture-refactor.md +0 -118
  23. jwt_toolkit-1.2.0/docs/plans/README.md +0 -88
  24. {jwt_toolkit-1.2.0 → jwt_toolkit-1.2.1}/.editorconfig +0 -0
  25. {jwt_toolkit-1.2.0 → jwt_toolkit-1.2.1}/.github/ISSUE_TEMPLATE/bug_report.yml +0 -0
  26. {jwt_toolkit-1.2.0 → jwt_toolkit-1.2.1}/.github/ISSUE_TEMPLATE/config.yml +0 -0
  27. {jwt_toolkit-1.2.0 → jwt_toolkit-1.2.1}/.github/ISSUE_TEMPLATE/documentation.yml +0 -0
  28. {jwt_toolkit-1.2.0 → jwt_toolkit-1.2.1}/.github/ISSUE_TEMPLATE/feature_request.yml +0 -0
  29. {jwt_toolkit-1.2.0 → jwt_toolkit-1.2.1}/.github/PULL_REQUEST_TEMPLATE.md +0 -0
  30. {jwt_toolkit-1.2.0 → jwt_toolkit-1.2.1}/.github/dependabot.yml +0 -0
  31. {jwt_toolkit-1.2.0 → jwt_toolkit-1.2.1}/.pre-commit-config.yaml +0 -0
  32. {jwt_toolkit-1.2.0 → jwt_toolkit-1.2.1}/.python-version +0 -0
  33. {jwt_toolkit-1.2.0 → jwt_toolkit-1.2.1}/LICENSE +0 -0
  34. {jwt_toolkit-1.2.0 → jwt_toolkit-1.2.1}/SECURITY.md +0 -0
  35. {jwt_toolkit-1.2.0 → jwt_toolkit-1.2.1}/jwt_toolkit/__init__.py +0 -0
  36. {jwt_toolkit-1.2.0 → jwt_toolkit-1.2.1}/jwt_toolkit/cli/__init__.py +0 -0
  37. {jwt_toolkit-1.2.0 → jwt_toolkit-1.2.1}/jwt_toolkit/cli/algorithms.py +0 -0
  38. {jwt_toolkit-1.2.0 → jwt_toolkit-1.2.1}/jwt_toolkit/cli/banner.py +0 -0
  39. {jwt_toolkit-1.2.0 → jwt_toolkit-1.2.1}/jwt_toolkit/cli/console.py +0 -0
  40. {jwt_toolkit-1.2.0 → jwt_toolkit-1.2.1}/jwt_toolkit/cli/credentials.py +0 -0
  41. {jwt_toolkit-1.2.0 → jwt_toolkit-1.2.1}/jwt_toolkit/cli/decoding.py +0 -0
  42. {jwt_toolkit-1.2.0 → jwt_toolkit-1.2.1}/jwt_toolkit/cli/panels.py +0 -0
  43. {jwt_toolkit-1.2.0 → jwt_toolkit-1.2.1}/jwt_toolkit/cli/wordlists.py +0 -0
  44. {jwt_toolkit-1.2.0 → jwt_toolkit-1.2.1}/jwt_toolkit/commands/__init__.py +0 -0
  45. {jwt_toolkit-1.2.0 → jwt_toolkit-1.2.1}/jwt_toolkit/commands/audit.py +0 -0
  46. {jwt_toolkit-1.2.0 → jwt_toolkit-1.2.1}/jwt_toolkit/commands/crack.py +0 -0
  47. {jwt_toolkit-1.2.0 → jwt_toolkit-1.2.1}/jwt_toolkit/commands/decode.py +0 -0
  48. {jwt_toolkit-1.2.0 → jwt_toolkit-1.2.1}/jwt_toolkit/commands/diff.py +0 -0
  49. {jwt_toolkit-1.2.0 → jwt_toolkit-1.2.1}/jwt_toolkit/commands/download_wordlists.py +0 -0
  50. {jwt_toolkit-1.2.0 → jwt_toolkit-1.2.1}/jwt_toolkit/commands/forge.py +0 -0
  51. {jwt_toolkit-1.2.0 → jwt_toolkit-1.2.1}/jwt_toolkit/commands/generate_secret.py +0 -0
  52. {jwt_toolkit-1.2.0 → jwt_toolkit-1.2.1}/jwt_toolkit/commands/sign.py +0 -0
  53. {jwt_toolkit-1.2.0 → jwt_toolkit-1.2.1}/jwt_toolkit/commands/verify.py +0 -0
  54. {jwt_toolkit-1.2.0 → jwt_toolkit-1.2.1}/jwt_toolkit/core/__init__.py +0 -0
  55. {jwt_toolkit-1.2.0 → jwt_toolkit-1.2.1}/jwt_toolkit/core/auditor.py +0 -0
  56. {jwt_toolkit-1.2.0 → jwt_toolkit-1.2.1}/jwt_toolkit/core/claims.py +0 -0
  57. {jwt_toolkit-1.2.0 → jwt_toolkit-1.2.1}/jwt_toolkit/core/cracker.py +0 -0
  58. {jwt_toolkit-1.2.0 → jwt_toolkit-1.2.1}/jwt_toolkit/core/crypto.py +0 -0
  59. {jwt_toolkit-1.2.0 → jwt_toolkit-1.2.1}/jwt_toolkit/core/decoder.py +0 -0
  60. {jwt_toolkit-1.2.0 → jwt_toolkit-1.2.1}/jwt_toolkit/core/diff.py +0 -0
  61. {jwt_toolkit-1.2.0 → jwt_toolkit-1.2.1}/jwt_toolkit/core/errors.py +0 -0
  62. {jwt_toolkit-1.2.0 → jwt_toolkit-1.2.1}/jwt_toolkit/core/forge.py +0 -0
  63. {jwt_toolkit-1.2.0 → jwt_toolkit-1.2.1}/jwt_toolkit/core/jwks.py +0 -0
  64. {jwt_toolkit-1.2.0 → jwt_toolkit-1.2.1}/jwt_toolkit/core/lifetime.py +0 -0
  65. {jwt_toolkit-1.2.0 → jwt_toolkit-1.2.1}/jwt_toolkit/core/timestamps.py +0 -0
  66. {jwt_toolkit-1.2.0 → jwt_toolkit-1.2.1}/jwt_toolkit/core/wordlist.py +0 -0
  67. {jwt_toolkit-1.2.0 → jwt_toolkit-1.2.1}/jwt_toolkit/py.typed +0 -0
  68. {jwt_toolkit-1.2.0 → jwt_toolkit-1.2.1}/tests/__init__.py +0 -0
  69. {jwt_toolkit-1.2.0 → jwt_toolkit-1.2.1}/tests/conftest.py +0 -0
  70. {jwt_toolkit-1.2.0 → jwt_toolkit-1.2.1}/tests/helpers.py +0 -0
  71. {jwt_toolkit-1.2.0 → jwt_toolkit-1.2.1}/tests/test_auditor.py +0 -0
  72. {jwt_toolkit-1.2.0 → jwt_toolkit-1.2.1}/tests/test_claims.py +0 -0
  73. {jwt_toolkit-1.2.0 → jwt_toolkit-1.2.1}/tests/test_cmd_audit.py +0 -0
  74. {jwt_toolkit-1.2.0 → jwt_toolkit-1.2.1}/tests/test_cmd_decode.py +0 -0
  75. {jwt_toolkit-1.2.0 → jwt_toolkit-1.2.1}/tests/test_cmd_diff.py +0 -0
  76. {jwt_toolkit-1.2.0 → jwt_toolkit-1.2.1}/tests/test_cmd_download_wordlists.py +0 -0
  77. {jwt_toolkit-1.2.0 → jwt_toolkit-1.2.1}/tests/test_cmd_forge.py +0 -0
  78. {jwt_toolkit-1.2.0 → jwt_toolkit-1.2.1}/tests/test_cmd_generate_secret.py +0 -0
  79. {jwt_toolkit-1.2.0 → jwt_toolkit-1.2.1}/tests/test_cmd_global_flags.py +0 -0
  80. {jwt_toolkit-1.2.0 → jwt_toolkit-1.2.1}/tests/test_cmd_sign.py +0 -0
  81. {jwt_toolkit-1.2.0 → jwt_toolkit-1.2.1}/tests/test_cmd_verify.py +0 -0
  82. {jwt_toolkit-1.2.0 → jwt_toolkit-1.2.1}/tests/test_cracker.py +0 -0
  83. {jwt_toolkit-1.2.0 → jwt_toolkit-1.2.1}/tests/test_credentials.py +0 -0
  84. {jwt_toolkit-1.2.0 → jwt_toolkit-1.2.1}/tests/test_crypto.py +0 -0
  85. {jwt_toolkit-1.2.0 → jwt_toolkit-1.2.1}/tests/test_crypto_asymmetric.py +0 -0
  86. {jwt_toolkit-1.2.0 → jwt_toolkit-1.2.1}/tests/test_decoder.py +0 -0
  87. {jwt_toolkit-1.2.0 → jwt_toolkit-1.2.1}/tests/test_diff.py +0 -0
  88. {jwt_toolkit-1.2.0 → jwt_toolkit-1.2.1}/tests/test_forge.py +0 -0
  89. {jwt_toolkit-1.2.0 → jwt_toolkit-1.2.1}/tests/test_jwks.py +0 -0
  90. {jwt_toolkit-1.2.0 → jwt_toolkit-1.2.1}/tests/test_lifetime.py +0 -0
  91. {jwt_toolkit-1.2.0 → jwt_toolkit-1.2.1}/tests/test_markup_escaping.py +0 -0
  92. {jwt_toolkit-1.2.0 → jwt_toolkit-1.2.1}/tests/test_package.py +0 -0
  93. {jwt_toolkit-1.2.0 → jwt_toolkit-1.2.1}/tests/test_timestamps.py +0 -0
  94. {jwt_toolkit-1.2.0 → jwt_toolkit-1.2.1}/tests/test_wordlist.py +0 -0
  95. {jwt_toolkit-1.2.0 → jwt_toolkit-1.2.1}/wordlists/common-secrets.txt +0 -0
@@ -0,0 +1,3 @@
1
+ # The bundled wordlist ships with a pinned SHA-256, so its bytes must not change
2
+ # with the checkout platform (Windows would otherwise convert it to CRLF).
3
+ wordlists/** -text
@@ -0,0 +1,100 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ # Lets the release workflow run this same gate on the commit it publishes.
8
+ workflow_call:
9
+
10
+ permissions:
11
+ contents: read
12
+
13
+ concurrency:
14
+ group: ci-${{ github.workflow }}-${{ github.ref }}
15
+ # Superseded PR pushes are cancelled; main and release runs always finish.
16
+ cancel-in-progress: ${{ github.event_name == 'pull_request' }}
17
+
18
+ jobs:
19
+ lint:
20
+ name: Lint & format
21
+ runs-on: ubuntu-latest
22
+ steps:
23
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
24
+ with:
25
+ persist-credentials: false
26
+ - uses: astral-sh/setup-uv@37802adc94f370d6bfd71619e3f0bf239e1f3b78 # v7.6.0
27
+ with:
28
+ enable-cache: true
29
+ - name: Install dev dependencies
30
+ run: uv sync --locked --group dev
31
+ - name: Ruff format (check only)
32
+ run: uv run ruff format --check .
33
+ - name: Ruff lint
34
+ run: uv run ruff check .
35
+ - name: Workflow security lint (zizmor)
36
+ run: uv run zizmor --offline --persona=regular .github/workflows
37
+
38
+ typecheck:
39
+ name: Type check
40
+ runs-on: ubuntu-latest
41
+ steps:
42
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
43
+ with:
44
+ persist-credentials: false
45
+ - uses: astral-sh/setup-uv@37802adc94f370d6bfd71619e3f0bf239e1f3b78 # v7.6.0
46
+ with:
47
+ enable-cache: true
48
+ - run: uv sync --locked --group dev
49
+ - run: uv run mypy
50
+
51
+ security:
52
+ name: Security scan
53
+ runs-on: ubuntu-latest
54
+ steps:
55
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
56
+ with:
57
+ persist-credentials: false
58
+ - uses: astral-sh/setup-uv@37802adc94f370d6bfd71619e3f0bf239e1f3b78 # v7.6.0
59
+ with:
60
+ enable-cache: true
61
+ - run: uv sync --locked --group dev
62
+ - name: Bandit static analysis
63
+ run: uv run bandit -c pyproject.toml -r jwt_toolkit --severity-level medium
64
+ - name: pip-audit dependency CVEs
65
+ run: uv run pip-audit
66
+
67
+ test:
68
+ name: Tests (${{ matrix.os }}, Python ${{ matrix.python-version }})
69
+ runs-on: ${{ matrix.os }}
70
+ strategy:
71
+ fail-fast: false
72
+ matrix:
73
+ # Every supported CPython on Linux and Windows (crack's worker processes
74
+ # use spawn there), plus the minimum on macOS. Keep in sync with the
75
+ # pyproject classifiers and the README "Installation" section.
76
+ os: [ubuntu-latest, windows-latest]
77
+ python-version: ["3.13", "3.14", "3.15"]
78
+ include:
79
+ - os: macos-latest
80
+ python-version: "3.13"
81
+ env:
82
+ COVERAGE_CELL: ${{ matrix.os == 'ubuntu-latest' && matrix.python-version == '3.15' }}
83
+ steps:
84
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
85
+ with:
86
+ persist-credentials: false
87
+ - uses: astral-sh/setup-uv@37802adc94f370d6bfd71619e3f0bf239e1f3b78 # v7.6.0
88
+ with:
89
+ enable-cache: true
90
+ python-version: ${{ matrix.python-version }}
91
+ - run: uv sync --locked --group dev
92
+ - name: Run tests with coverage
93
+ run: uv run pytest --cov --cov-report=term-missing --cov-report=xml -n auto
94
+ - name: Upload coverage artifact
95
+ if: always() && env.COVERAGE_CELL == 'true'
96
+ uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
97
+ with:
98
+ name: coverage
99
+ path: coverage.xml
100
+ if-no-files-found: ignore
@@ -17,10 +17,13 @@ jobs:
17
17
  name: Validate release commit
18
18
  runs-on: ubuntu-latest
19
19
  steps:
20
- - uses: actions/checkout@v7
21
- - uses: astral-sh/setup-uv@v7
20
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
22
21
  with:
23
- enable-cache: true
22
+ persist-credentials: false
23
+ - uses: astral-sh/setup-uv@37802adc94f370d6bfd71619e3f0bf239e1f3b78 # v7.6.0
24
+ with:
25
+ # A release build never restores a cache another run could have written.
26
+ enable-cache: false
24
27
  - name: Require a tag matching the package version
25
28
  env:
26
29
  REF_TYPE: ${{ github.ref_type }}
@@ -50,16 +53,19 @@ jobs:
50
53
  name: Build distribution
51
54
  runs-on: ubuntu-latest
52
55
  steps:
53
- - uses: actions/checkout@v7
54
- - uses: astral-sh/setup-uv@v7
56
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
57
+ with:
58
+ persist-credentials: false
59
+ - uses: astral-sh/setup-uv@37802adc94f370d6bfd71619e3f0bf239e1f3b78 # v7.6.0
55
60
  with:
56
- enable-cache: true
61
+ # A release build never restores a cache another run could have written.
62
+ enable-cache: false
57
63
  - name: Build sdist + wheel
58
64
  run: uv build
59
65
  - name: Check package metadata
60
66
  run: uvx twine check --strict dist/*
61
67
  - name: Upload build artifacts
62
- uses: actions/upload-artifact@v7
68
+ uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
63
69
  with:
64
70
  name: dist
65
71
  path: dist/
@@ -77,11 +83,11 @@ jobs:
77
83
  contents: read
78
84
  steps:
79
85
  - name: Download build artifacts
80
- uses: actions/download-artifact@v8
86
+ uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
81
87
  with:
82
88
  name: dist
83
89
  path: dist/
84
90
  - name: Publish to PyPI (Trusted Publishing + PEP 740 attestations)
85
- uses: pypa/gh-action-pypi-publish@release/v1
91
+ uses: pypa/gh-action-pypi-publish@7245906fb61fa33a13554f9d5fb856fe61758086 # v1.14.3
86
92
  with:
87
93
  attestations: true
@@ -222,3 +222,6 @@ __marimo__/
222
222
 
223
223
  # Code editor
224
224
  .vscode/
225
+
226
+ # Private planning notes
227
+ /.project-planning/
@@ -131,7 +131,7 @@ uv run jwt-toolkit --version
131
131
  make check
132
132
  ```
133
133
 
134
- `make check` runs the full local CI gate: lint, type checking, tests, security scan, and dependency audit. Run this before opening a pull request.
134
+ `make check` runs the full local CI gate: lint, type checking, tests, security scan, dependency audit, and the GitHub Actions security lint. Run this before opening a pull request.
135
135
 
136
136
  ## Common tasks
137
137
 
@@ -147,6 +147,7 @@ make check
147
147
  | Coverage report on stdout | `make cov` |
148
148
  | Static security scan (bandit) | `make security` |
149
149
  | Check deps for known CVEs (pip-audit)| `make audit` |
150
+ | Security-lint workflows (zizmor) | `make actions` |
150
151
  | Full local CI gate | `make check` |
151
152
  | Run all pre-commit hooks | `make pre-commit` |
152
153
  | Clean caches and build artifacts | `make clean` |
@@ -229,7 +230,7 @@ chore(deps): bump cryptography to 48.0.0
229
230
  3. Make focused commits that follow the conventions above.
230
231
  4. Run `make check` and make sure everything passes locally.
231
232
  5. Push your branch and open a pull request against `main`. Fill in every section of the PR template.
232
- 6. The CI workflow runs lint, type check, tests, and security checks. All checks must pass.
233
+ 6. The CI workflow runs lint, type check, security checks, and the tests on Linux and Windows with every supported Python, plus macOS. All checks must pass. Actions are pinned to full commit SHAs; keep the version comment when you change one.
233
234
  7. A maintainer will review. Address review feedback by pushing additional commits to the same branch. Avoid force-pushing during review so reviewers can see incremental changes. Squash-merging is performed by the maintainer at merge time.
234
235
  8. Once approved and green, a maintainer merges with a squash commit whose message follows the conventional-commits format.
235
236
 
@@ -1,7 +1,7 @@
1
1
  # jwt-toolkit dev commands. Run `make` or `make help` for the list.
2
2
 
3
3
  .DEFAULT_GOAL := help
4
- .PHONY: help install fmt lint typecheck test test-fast cov security audit check pre-commit clean
4
+ .PHONY: help install fmt lint typecheck test test-fast cov security audit actions check pre-commit clean
5
5
 
6
6
  UV ?= uv
7
7
 
@@ -38,7 +38,10 @@ security: ## Static security scan of the source.
38
38
  audit: ## Check dependencies for known CVEs.
39
39
  $(UV) run pip-audit
40
40
 
41
- check: lint typecheck test security audit ## Full local CI gate.
41
+ actions: ## Security-lint the GitHub Actions workflows (zizmor).
42
+ $(UV) run zizmor --offline --persona=regular .github/workflows
43
+
44
+ check: lint typecheck test security audit actions ## Full local CI gate.
42
45
 
43
46
  pre-commit: ## Run all pre-commit hooks on every file.
44
47
  $(UV) run pre-commit run --all-files
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: jwt-toolkit
3
- Version: 1.2.0
3
+ Version: 1.2.1
4
4
  Summary: A command-line toolkit for inspecting, verifying, cracking, and securing JSON Web Tokens. Built to expose how JWT signing works and where it breaks.
5
5
  Project-URL: Homepage, https://github.com/KhaledSaeed18/jwt-toolkit
6
6
  Project-URL: Repository, https://github.com/KhaledSaeed18/jwt-toolkit
@@ -17,7 +17,11 @@ Classifier: Intended Audience :: Information Technology
17
17
  Classifier: Intended Audience :: System Administrators
18
18
  Classifier: Operating System :: OS Independent
19
19
  Classifier: Programming Language :: Python :: 3
20
+ Classifier: Programming Language :: Python :: 3 :: Only
20
21
  Classifier: Programming Language :: Python :: 3.13
22
+ Classifier: Programming Language :: Python :: 3.14
23
+ Classifier: Programming Language :: Python :: 3.15
24
+ Classifier: Programming Language :: Python :: Implementation :: CPython
21
25
  Classifier: Topic :: Security
22
26
  Classifier: Topic :: Security :: Cryptography
23
27
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
@@ -92,7 +96,7 @@ To try it without installing:
92
96
  uvx jwt-toolkit --help
93
97
  ```
94
98
 
95
- `pip install jwt-toolkit` also works inside a virtual environment. Requires Python 3.13 or newer.
99
+ `pip install jwt-toolkit` also works inside a virtual environment. Requires Python 3.13 or newer. CI tests CPython 3.13, 3.14 and 3.15 on Linux and Windows, and 3.13 on macOS.
96
100
 
97
101
  ## A two-minute tour
98
102
 
@@ -61,7 +61,7 @@ To try it without installing:
61
61
  uvx jwt-toolkit --help
62
62
  ```
63
63
 
64
- `pip install jwt-toolkit` also works inside a virtual environment. Requires Python 3.13 or newer.
64
+ `pip install jwt-toolkit` also works inside a virtual environment. Requires Python 3.13 or newer. CI tests CPython 3.13, 3.14 and 3.15 on Linux and Windows, and 3.13 on macOS.
65
65
 
66
66
  ## A two-minute tour
67
67
 
@@ -2,6 +2,7 @@ import base64
2
2
  import binascii
3
3
  import json
4
4
  import math
5
+ import re
5
6
  from typing import Any
6
7
 
7
8
  # JWT strips '=' padding by spec, so every encode trims it and every decode restores it.
@@ -18,17 +19,26 @@ def base64url_encode(value: bytes) -> str:
18
19
  return base64.urlsafe_b64encode(value).rstrip(b"=").decode()
19
20
 
20
21
 
22
+ _BASE64URL = re.compile(r"[A-Za-z0-9_-]*=*")
23
+ _BASE64 = re.compile(r"[A-Za-z0-9+/]*=*")
24
+
25
+
26
+ def _strict_decode(value: str, alphabet: re.Pattern[str], altchars: bytes | None) -> bytes:
27
+ # Python 3.15 stopped rejecting characters outside the alphabet in non-validating
28
+ # mode, so the alphabet is checked here and the stdlib decode always validates.
29
+ if not alphabet.fullmatch(value):
30
+ raise binascii.Error("input contains characters outside the base64 alphabet")
31
+ return base64.b64decode(_pad(value.rstrip("=")), altchars=altchars, validate=True)
32
+
33
+
21
34
  def base64url_decode(value: str) -> bytes:
22
- # The stdlib raises a bare ValueError for non-ASCII input; callers expect binascii.Error.
23
- if not value.isascii():
24
- raise binascii.Error("base64url input must be ASCII")
25
- return base64.urlsafe_b64decode(_pad(value))
35
+ return _strict_decode(value, _BASE64URL, b"-_")
26
36
 
27
37
 
28
38
  def base64_decode_padded(value: str) -> bytes:
29
39
  # Standard base64 (not url-safe) with the same padding restoration —
30
40
  # used by `crack` when interpreting a wordlist entry as a base64 secret.
31
- return base64.b64decode(_pad(value))
41
+ return _strict_decode(value, _BASE64, None)
32
42
 
33
43
 
34
44
  class NonFiniteNumberError(ValueError):
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "jwt-toolkit"
3
- version = "1.2.0"
3
+ version = "1.2.1"
4
4
  description = "A command-line toolkit for inspecting, verifying, cracking, and securing JSON Web Tokens. Built to expose how JWT signing works and where it breaks."
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.13"
@@ -26,6 +26,10 @@ classifiers = [
26
26
  "Operating System :: OS Independent",
27
27
  "Programming Language :: Python :: 3",
28
28
  "Programming Language :: Python :: 3.13",
29
+ "Programming Language :: Python :: 3.14",
30
+ "Programming Language :: Python :: 3.15",
31
+ "Programming Language :: Python :: 3 :: Only",
32
+ "Programming Language :: Python :: Implementation :: CPython",
29
33
  "Topic :: Security",
30
34
  "Topic :: Security :: Cryptography",
31
35
  "Topic :: Software Development :: Libraries :: Python Modules",
@@ -85,6 +89,7 @@ dev = [
85
89
  "pre-commit>=4.0",
86
90
  "bandit>=1.8",
87
91
  "pip-audit>=2.7",
92
+ "zizmor>=1.33.1",
88
93
  ]
89
94
 
90
95
  [tool.pytest.ini_options]
@@ -1,6 +1,7 @@
1
1
  import hashlib
2
2
  import hmac
3
3
  import json
4
+ import os
4
5
 
5
6
  import pytest
6
7
 
@@ -289,7 +290,9 @@ def test_crack_output_file_is_owner_only(runner, tmp_path):
289
290
  out.write_text("old")
290
291
  out.chmod(0o644)
291
292
  invoke(runner, wl, make_token({"sub": "1"}), "--output", str(out))
292
- assert out.stat().st_mode & 0o777 == 0o600
293
+ # Windows has no POSIX owner/group/other bits; there only the content is checked.
294
+ if os.name == "posix":
295
+ assert out.stat().st_mode & 0o777 == 0o600
293
296
  assert out.read_text() == "testsecret\n"
294
297
 
295
298
 
@@ -0,0 +1,37 @@
1
+ import binascii
2
+
3
+ import pytest
4
+
5
+ from jwt_toolkit.core.encoding import base64_decode_padded, base64url_decode, base64url_encode
6
+
7
+
8
+ @pytest.mark.parametrize("raw", [b"", b"i", b"i\xb7", b"i\xb7\x1d", b"\xfb\xff\xbf"])
9
+ def test_base64url_round_trip(raw):
10
+ assert base64url_decode(base64url_encode(raw)) == raw
11
+
12
+
13
+ def test_base64url_accepts_trailing_padding():
14
+ assert base64url_decode("abcd===") == b"i\xb7\x1d"
15
+ assert base64url_decode("abc=") == b"i\xb7"
16
+
17
+
18
+ # Python 3.15 decodes these leniently by dropping the stray characters; a JWT
19
+ # segment carrying them must be rejected on every supported version.
20
+ @pytest.mark.parametrize(
21
+ "value",
22
+ ["ab!c", "@@@not-base64@@@", "ab c", "ab\nc", "abc\n", "ab+c", "ab/c", "a=bc", "abcé", "abcde"],
23
+ )
24
+ def test_base64url_rejects_input_outside_the_alphabet(value):
25
+ with pytest.raises(binascii.Error):
26
+ base64url_decode(value)
27
+
28
+
29
+ def test_base64_padded_decodes_standard_alphabet():
30
+ assert base64_decode_padded("+/8") == b"\xfb\xff"
31
+ assert base64_decode_padded("+/8=") == b"\xfb\xff"
32
+
33
+
34
+ @pytest.mark.parametrize("value", ["-_8", "ab!c", "ab c", "abcde"])
35
+ def test_base64_padded_rejects_input_outside_the_alphabet(value):
36
+ with pytest.raises(binascii.Error):
37
+ base64_decode_padded(value)