Metadata-Version: 2.4
Name: tier2
Version: 1.0.2
Summary: Literp Tier Two Credential Lib
Home-page: https://github.com/asinerum/tier2
Author: Asinerum Conlang Project
Author-email: asinerum.com@gmail.com
License: MIT
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: pyjwt>=2.10.1
Requires-Dist: pyotp>=2.9.0
Requires-Dist: pillow>=12.2.0
Requires-Dist: qrcode>=8.2
Requires-Dist: requests>=2.32.5
Dynamic: license-file

# LITERP TIER TWO CREDENTIAL LIBRARY

## Dependencies
- pyjwt
- requests

## Environment Variables
- TELEGRAM_BOT_TOKEN: Got from @BotFather.
- DISCORD_BOT_TOKEN: Got from Discord Developer Portal.
- WHATSAPP_API_TOKEN: Got from Meta Cloud API.
- WHATSAPP_PHONE_ID: Meta phone number ID for WhatsApp sender.
- JWT_SECRET: Any strong random string for signing JWT tokens.
- GOOGLE_AUTHENTICATOR_SETUP_KEY: Google authenticator secret key.

## Utility Functions

### create_random_id(user_name, id_length, id_timeout)
Generate a random digit-only ID of *id_length* characters, embed it with *user_name* in a JWT that expires after *id_timeout* seconds.  
- Parameters:  
  user_name: Unique identifier for the user (e.g. email, username).  
  id_length: Number of digits in the ID (default 6).  
  id_timeout: Token lifetime in seconds (default 60).  
- Returns: a plain digit ID.  

### verify_given_id(user_name, id_string)
Verify that *id_string* matches the active, non-expired token stored for *user_name*.  
- Parameters:  
  user_name: The user whose token to look up.  
  id_string: The digit ID to verify.  
- Returns: *True* when token found, not expired, and ID matches. *False* when token missing, expired, or ID mismatch.  

### verify_google_code(code)
Verify that *code* got from Google Authenticator App matches user's secret key.  
- Parameters:  
  code: A time-based code got from Google Authenticator App.  
- Returns: *True* on success. *False* on failure.  

### text_to_telegram(message, recipient)
Send *message* to a Telegram user or chat.  
- Parameters:  
  message: Text to send.  
  recipient: Telegram chat_id (numeric string), got by messaging @userinfobot on Telegram.  
- Returns: *True* on success. *False* on failure.  

### text_to_discord(message, recipient)
Send *message* to a Discord user via DM.  
- Parameters:  
  message: Text to send.  
  recipient: Discord user ID (numeric string), got from Discord Developer Mode.  
- Returns: *True* on success. *False* on failure.  

### text_to_whatsapp(message, recipient)
Send *message* to a WhatsApp number via Meta Cloud API. Deprecated.  
- Parameters:  
  message: Text to send.  
  recipient: Recipient's phone number in E164 format.  
- Returns: *True* on success. *False* on failure.  

### get_active_token(user_name)
Return the raw JWT for *user_name*, or None if not found.  

### invalidate_token(user_name)
Manually invalidate/delete the token for *user_name*.  

## Detailed Info

Detailed tips, tricks, and examples, can be found at project's repository
https://github.com/asinerum/tier2

(C) 2026 Asinerum Conlang Project
