No flags found
Use flags to group coverage reports by test type, project and/or folders.
Then setup custom commit statuses and notifications for each flag.
e.g., #unittest #integration
#production #enterprise
#frontend #backend
a7d6e5e
... +5 ...
d8acd41
Use flags to group coverage reports by test type, project and/or folders.
Then setup custom commit statuses and notifications for each flag.
e.g., #unittest #integration
#production #enterprise
#frontend #backend
1 | + | from typing import Optional |
|
2 | + | import hashlib |
|
3 | + | ||
4 | + | from ..totp import TOTP |
|
5 | + | ||
6 | + | STEAM_CHARS = "23456789BCDFGHJKMNPQRTVWXY" # steam's custom alphabet |
|
7 | + | STEAM_DEFAULT_DIGITS = 5 # Steam TOTP code length |
|
8 | + | ||
9 | + | ||
10 | + | class Steam(TOTP): |
|
11 | + | """ |
|
12 | + | Steam's custom TOTP. Subclass of `pyotp.totp.TOTP`. |
|
13 | + | """ |
|
14 | + | ||
15 | + | def __init__(self, s: str, name: Optional[str] = None, |
|
16 | + | issuer: Optional[str] = None, interval: int = 30) -> None: |
|
17 | + | """ |
|
18 | + | :param s: secret in base32 format |
|
19 | + | :param interval: the time interval in seconds for OTP. This defaults to 30. |
|
20 | + | :param name: account name |
|
21 | + | :param issuer: issuer |
|
22 | + | """ |
|
23 | + | self.interval = interval |
|
24 | + | super().__init__(s=s, digits=10, digest=hashlib.sha1, name=name, issuer=issuer) |
|
25 | + | ||
26 | + | def generate_otp(self, input: int) -> str: |
|
27 | + | """ |
|
28 | + | :param input: the HMAC counter value to use as the OTP input. |
|
29 | + | Usually either the counter, or the computed integer based on the Unix timestamp |
|
30 | + | """ |
|
31 | + | str_code = super().generate_otp(input) |
|
32 | + | int_code = int(str_code) |
|
33 | + | ||
34 | + | steam_code = "" |
|
35 | + | total_chars = len(STEAM_CHARS) |
|
36 | + | ||
37 | + | for _ in range(STEAM_DEFAULT_DIGITS): |
|
38 | + | pos = int_code % total_chars |
|
39 | + | char = STEAM_CHARS[int(pos)] |
|
40 | + | steam_code += char |
|
41 | + | int_code //= total_chars |
|
42 | + | ||
43 | + | return steam_code |
1 | + | from .steam import Steam # noqa:F401 |
Learn more Showing 3 files with coverage changes found.
src/pyotp/compat.py
src/pyotp/contrib/__init__.py
src/pyotp/contrib/steam.py
Files | Coverage |
---|---|
src/pyotp | -0.87% 98.03% |
Project Totals (8 files) | 98.03% |
d8acd41
6568c1a
3089124
c1dc430
baf8b99
4a1fedc
a7d6e5e