sealedwebtoken
The official Python SDK for Odysii Sealed Web Tokens (SWT).
Installation
# Sync client only (zero dependencies)
pip install sealedwebtoken
# With async support (installs aiohttp)
pip install sealedwebtoken[async]
Usage
Sync
import time
import swt
secret = "your-super-secret-key"
payload = {"user_id": 123, "role": "admin"}
# 1. Sign a token (expiresAt is required, max 31 days)
expires_at = int(time.time()) + 3600 # 1 hour from now
resp = swt.sign(payload, secret=secret, expires_at=expires_at)
print("Token:", resp.token)
print("Expires at:", resp.expires_at)
# 2. Verify a token
v = swt.verify(resp.token, secret=secret)
if v.valid:
print("Payload:", v.payload)
# 3. Revoke a token
swt.revoke(resp.token, secret=secret)
print("Token revoked")
Async
import asyncio, time
import swt
async def main():
client = swt.AsyncSWTClient()
expires_at = int(time.time()) + 3600
resp = await client.sign({"user_id": 42}, secret="mysecret123", expires_at=expires_at)
print("Token:", resp.token)
v = await client.verify(resp.token, secret="mysecret123")
if v.valid:
print("Payload:", v.payload)
await client.revoke(resp.token, secret="mysecret123")
print("Token revoked")
asyncio.run(main())
Using the class-based client
import swt
# Create a reusable client
client = swt.SWTClient()
resp = client.sign({"user_id": 1}, secret="mysecret123", expires_at=...)
API Reference
swt.sign(payload, *, secret, expires_at) → SignResponse
payload—dictto embed in the token (max 512 bytes serialised)secret— string, min 8 charactersexpires_at— Unix timestamp in seconds, required, max 31 days from now
swt.verify(token, *, secret) → VerifyResponse
token— the SWT token stringsecret— string, min 8 characters, required
swt.revoke(token, *, secret) → RevokeResponse
token— the SWT token string to revokesecret— the secret used when signing
Metadata
Release files for sealedwebtoken 1.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| sealedwebtoken-1.0.2.tar.gz | 6.2 kB | Without provenance | Details for sealedwebtoken-1.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sealedwebtoken-1.0.2-py3-none-any.whl | Python 3 | none | any | Details for sealedwebtoken-1.0.2-py3-none-any.whl |
Total release size: 10.6 kB
Release files / sealedwebtoken-1.0.2.tar.gz
| Download URL | sealedwebtoken-1.0.2.tar.gz |
|---|---|
| Size | 6.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
44be16b7dfcfbdea18d2446b5dbbc0edb9152c4776d3b10a24c0f880ba080284
|
|
BLAKE2b-256 checksum How to use checksums |
68fcbfa858f6b6426b2ceb07229c97ea9d7b05fc2156697f79e68a309b7d15c3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|
Release files / sealedwebtoken-1.0.2-py3-none-any.whl
| Download URL | sealedwebtoken-1.0.2-py3-none-any.whl |
|---|---|
| Size | 4.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bc53c804427144e7637c688c855f100ec63f88934bd93049f940e91afefdb31e
|
|
BLAKE2b-256 checksum How to use checksums |
c4d5373be0334e4d5800688e502cec77794bb4f01342b8dc9824cdab4c6a6d46
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|
Security for sealedwebtoken 1.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.