Compare commits
No commits in common. "main" and "v0.1.4" have entirely different histories.
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,5 +1,5 @@
|
||||
# claude
|
||||
.claude/
|
||||
CLAUDE.md
|
||||
|
||||
# python
|
||||
__pycache__/
|
||||
|
||||
10
README.md
10
README.md
@ -11,22 +11,22 @@ This reads codes from email; it does not generate them (that is `pyotp`'s job).
|
||||
`requirements.txt`:
|
||||
|
||||
```
|
||||
aiomail @ git+ssh://git@git.rethinkstudios.io/rethink-public/aiomail.git@v0.1.5
|
||||
aiomail @ git+ssh://git@git.rethinkstudios.io/rethink-public/aiomail.git@v0.1.4
|
||||
# OAuth token providers (Microsoft / Google) need the extra:
|
||||
aiomail[oauth] @ git+ssh://git@git.rethinkstudios.io/rethink-public/aiomail.git@v0.1.5
|
||||
aiomail[oauth] @ git+ssh://git@git.rethinkstudios.io/rethink-public/aiomail.git@v0.1.4
|
||||
```
|
||||
|
||||
Direct:
|
||||
|
||||
```bash
|
||||
pip install "aiomail @ git+ssh://git@git.rethinkstudios.io/rethink-public/aiomail.git@v0.1.5"
|
||||
pip install "aiomail[oauth] @ git+ssh://git@git.rethinkstudios.io/rethink-public/aiomail.git@v0.1.5"
|
||||
pip install "aiomail @ git+ssh://git@git.rethinkstudios.io/rethink-public/aiomail.git@v0.1.4"
|
||||
pip install "aiomail[oauth] @ git+ssh://git@git.rethinkstudios.io/rethink-public/aiomail.git@v0.1.4"
|
||||
```
|
||||
|
||||
Requires `aioimaplib` and `beautifulsoup4` (pulled transitively). The `oauth`
|
||||
extra adds `aiohttp` for the refresh-token providers.
|
||||
|
||||
Drop the `@v0.1.5` suffix from the line above to install the latest unpinned.
|
||||
Drop the `@v0.1.4` suffix from the line above to install the latest unpinned.
|
||||
|
||||
## Password auth
|
||||
|
||||
|
||||
@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
||||
|
||||
[project]
|
||||
name = "aiomail"
|
||||
version = "0.1.5"
|
||||
version = "0.1.4"
|
||||
description = "async IMAP one-time-code retrieval with password/OAuth2 auth and dynamic matching"
|
||||
requires-python = ">=3.10"
|
||||
dependencies = [
|
||||
|
||||
@ -29,4 +29,4 @@ __all__ = [
|
||||
"DEFAULT_FOLDERS",
|
||||
]
|
||||
|
||||
__version__ = "0.1.5"
|
||||
__version__ = "0.1.4"
|
||||
|
||||
@ -76,7 +76,7 @@ def _scan(text: str, patterns: list[Pattern], lengths: set[int]) -> Optional[str
|
||||
return m.group(1) if m.groups() else m.group(0)
|
||||
for token in re.split(r"\s+", text):
|
||||
digits = "".join(c for c in token if c.isdigit())
|
||||
if digits and len(digits) in lengths:
|
||||
if digits and len(digits) in lengths and digits.isdigit():
|
||||
return digits
|
||||
return None
|
||||
|
||||
@ -121,8 +121,6 @@ def as_predicate(spec: MatchSpec) -> Callable[[Optional[str]], bool]:
|
||||
if isinstance(spec, re.Pattern):
|
||||
return lambda value: bool(spec.search(value or ""))
|
||||
if callable(spec):
|
||||
# coalesce None like the string/regex branches so the documented Optional[str]
|
||||
# predicate contract holds even if a caller's callable assumes a real string
|
||||
return lambda value: bool(spec(value or ""))
|
||||
return spec
|
||||
needle = str(spec).lower()
|
||||
return lambda value: needle in (value or "").lower()
|
||||
|
||||
@ -76,17 +76,12 @@ class _RefreshTokenProvider:
|
||||
async with aiohttp.ClientSession(timeout=timeout) as session:
|
||||
async with session.post(endpoint, data=data) as resp:
|
||||
if resp.status == 200:
|
||||
# content_type=None: some token endpoints return a 200 with
|
||||
# text/plain or text/javascript; default json() would raise
|
||||
# ContentTypeError and discard a valid token body
|
||||
token = (await resp.json(content_type=None)).get("access_token")
|
||||
token = (await resp.json()).get("access_token")
|
||||
if token:
|
||||
self._failures = 0
|
||||
return token
|
||||
else:
|
||||
# log a truncated error body only — a token-endpoint
|
||||
# response can carry sensitive material; never dump it whole
|
||||
body = (await resp.text())[:200]
|
||||
body = await resp.text()
|
||||
log.warning("token endpoint %s -> %s: %s", endpoint, resp.status, body)
|
||||
except Exception as exc:
|
||||
log.warning("token request to %s failed: %s", endpoint, exc)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user