2019-07-17 14:58:39 +00:00
|
|
|
import click
|
2019-08-12 12:56:19 +00:00
|
|
|
import json
|
2019-07-17 14:58:39 +00:00
|
|
|
|
|
|
|
from dataclasses import dataclass
|
|
|
|
from pyotp import TOTP
|
|
|
|
|
|
|
|
|
|
|
|
@dataclass
|
|
|
|
class OTPCredentials:
|
|
|
|
name: str
|
|
|
|
realm: str
|
|
|
|
seed: str
|
|
|
|
|
|
|
|
def get_json(self):
|
|
|
|
r = {"name": self.name, "realm": self.realm, "token": TOTP(self.seed).now()}
|
|
|
|
return r
|
2019-08-12 12:56:19 +00:00
|
|
|
|
|
|
|
|
|
|
|
def load_dump_pretty(content):
|
|
|
|
parsed = json.loads(content)
|
|
|
|
return json.dumps(parsed, indent=4, sort_keys=True)
|