Skip to main content

ton-devtools-auth-sdk

Server-side TON Connect 2.0 proof verification for ICP-compatible services.

Part of the ton-devtools monorepo.

PyPI Python License: MIT

What it does

Implements the server-side authentication pipeline:

  • §5.2 — TON proof message construction and ed25519 verification
  • §5.3 — On-chain public key resolution via Toncenter API v2 (or TRMS)
  • §5.6 — Single-use nonce management with TTL (replay attack prevention)
  • §10.2 — Timestamp skew enforcement (±300 s)

Installation

pip install ton-devtools-auth-sdk

Quick Start

from ton_devtools_auth import ICPAuthenticator

auth = ICPAuthenticator(
    rpc_base_url="https://toncenter.com/api/v2",
    rpc_api_key="YOUR_KEY",
    domain="id.yourapp.com",
)

# POST /auth/ton/connect
nonce = auth.issue_nonce()          # store and return to client

# POST /auth/ton/verify
result = await auth.verify(
    wallet_address=body.wallet_address,
    nonce=body.nonce,
    signature=body.signature,
    public_key=body.public_key,
    timestamp=body.timestamp,
    domain=body.domain,
)
# result.wallet_address, result.public_key, result.on_chain_verified

Nonce storage backends

from ton_devtools_auth.nonce import NonceManager, InMemoryNonceStore

# Testing / single-replica
auth = ICPAuthenticator(nonce_store=InMemoryNonceStore())

# Production: bring your own Redis client
class RedisNonceStore:
    def __init__(self, redis): self._r = redis
    def set(self, key, value, ttl): self._r.set(key, value, ex=ttl)
    def get(self, key): return self._r.get(key)
    def delete(self, key): return bool(self._r.delete(key))

auth = ICPAuthenticator(nonce_store=RedisNonceStore(redis_client))

Pointing at TRMS for testing

auth = ICPAuthenticator(
    rpc_base_url="http://localhost:8080",  # ton-devtools-rpc-mock
    domain="localhost",
)

License

MIT

Metadata

Release files for ton-devtools-auth-sdk 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ton-devtools-auth-sdk 0.1.0
File Size Uploaded
ton_devtools_auth_sdk-0.1.0.tar.gz 11.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ton-devtools-auth-sdk 0.1.0
File Interpreter ABI Platform
ton_devtools_auth_sdk-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 23.8 kB

Release files / ton_devtools_auth_sdk-0.1.0.tar.gz

Download URL ton_devtools_auth_sdk-0.1.0.tar.gz
Size 11.1 kB
Tags Source
SHA-256 checksum
How to use checksums
ea972915b619d257310a30dc377110526db020c26898370b01195a12bf956100
BLAKE2b-256 checksum
How to use checksums
c9b644e6a6f28f0c8e6d7344269d042d5799c3ed61a81966117916f0310385e4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.2

Release files / ton_devtools_auth_sdk-0.1.0-py3-none-any.whl

Download URL ton_devtools_auth_sdk-0.1.0-py3-none-any.whl
Size 12.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
78b8d00eb15a5ae655b5047c17b6b5da97549c1798537bd50ae0e7a256347f2f
BLAKE2b-256 checksum
How to use checksums
d7ffc6ce5b792adab17f74f0b60b7d56426d3194a24af2fec9d3eae057fea9a5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.2

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page