Skip to main content

Literp Tier Two Credential Lib

Project description

LITERP TIER TWO CREDENTIAL LIBRARY

Dependencies

  • pyjwt
  • requests
  • python-jose
  • python-dotenv

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.
  • SETUPKEY_ENCRYPT_SECRET: any strong random string for encrypting setup-key.
  • TOKEN_EXPIRE_MINUTES: JWT token expiration time in minutes.
  • 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.

generate_access_token(user_name)

Generate JWT access token for user_name.

verify_access_token(access_token, user_name)

Validate the access_token (generated by generate_access_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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tier2-1.0.9.tar.gz (9.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tier2-1.0.9-py3-none-any.whl (9.0 kB view details)

Uploaded Python 3

File details

Details for the file tier2-1.0.9.tar.gz.

File metadata

  • Download URL: tier2-1.0.9.tar.gz
  • Upload date:
  • Size: 9.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for tier2-1.0.9.tar.gz
Algorithm Hash digest
SHA256 9a0112b3cc9b0ca3af519f20019cfa91d0e3fe55ea341bc24ebcefa287be047f
MD5 e80c3d7db2788bebf2ae55fdcb6933c9
BLAKE2b-256 a0a62d5fb8c60bec229f761bbadb476b4ab85646e854ff525f12b69966f100d1

See more details on using hashes here.

File details

Details for the file tier2-1.0.9-py3-none-any.whl.

File metadata

  • Download URL: tier2-1.0.9-py3-none-any.whl
  • Upload date:
  • Size: 9.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for tier2-1.0.9-py3-none-any.whl
Algorithm Hash digest
SHA256 edf88fec41c8abe74b1e30a87b591340a330743cce0fd90eab1398c02a8e6f4c
MD5 5bf641148c6377bf8559fa251c9cc034
BLAKE2b-256 d4aecfe2aa211d1078e9f95520e60586e5620aa696bb4cac145d46aff791c647

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page