ciphertoken 0.1.2__cp310-cp310-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,5 @@
1
+ from .secret import secret_key, secret_key_with_size, generate_hmac_secret, generate_hmac_secret_async,generate_rsa_keypair
2
+ from .utils import DEFAULT_SECRET_SIZE, EDDSA,ES256,ES384,HS256,HS384,HS512,MIN_SECRET_SIZE,PS256,PS384,PS512,RS256,RS384,RS512,TOKEN_ACCESS,TOKEN_REFRESH
3
+ from .time import seconds, minutes, hours, days, weeks,now
4
+
5
+ from .ciphertoken import CipherToken, is_jwt_format,validate_jwt_format
@@ -0,0 +1,12 @@
1
+ HS256: str
2
+ HS384: str
3
+ HS512: str
4
+ RS256: str
5
+ RS384: str
6
+ RS512: str
7
+ ES256: str
8
+ ES384: str
9
+ PS256: str
10
+ PS384: str
11
+ PS512: str
12
+ EDDSA: str
@@ -0,0 +1,26 @@
1
+ from typing import Optional, Dict, Any, Tuple, Awaitable
2
+
3
+ class CipherToken:
4
+ def __init__(self, secret: str, algorithm: str, access_ttl: int, refresh_ttl: int) -> None: ...
5
+
6
+ # Sync methods
7
+ def access(self, user_id: int, extra_payload: Optional[Dict[str, Any]] = None) -> str: ...
8
+ def refresh(self, user_id: int, extra_payload: Optional[Dict[str, Any]] = None) -> str: ...
9
+ def decode(self, token: str) -> Dict[str, Any]: ...
10
+ def verify(self, token: str) -> bool: ...
11
+ def rotation(self, refresh_token: str, extra_payload: Optional[Dict[str, Any]] = None) -> Tuple[str, str]: ...
12
+ def inspect(self, token: str) -> Dict[str, Any]: ...
13
+ def remaining_time(self, token: str) -> Optional[int]: ...
14
+ def algorithm_name(self) -> str: ...
15
+
16
+ # Async methods
17
+ async def access_async(self, user_id: int, extra_payload: Optional[Dict[str, Any]] = None) -> Awaitable[str]: ...
18
+ async def refresh_async(self, user_id: int, extra_payload: Optional[Dict[str, Any]] = None) -> Awaitable[str]: ...
19
+ async def decode_async(self, token: str) -> Awaitable[Dict[str, Any]]: ...
20
+ async def verify_async(self, token: str) -> Awaitable[bool]: ...
21
+ async def rotation_async(self, refresh_token: str, extra_payload: Optional[Dict[str, Any]] = None) -> Awaitable[Tuple[str, str]]: ...
22
+
23
+ # Utility functions
24
+ def is_jwt_format(token: str) -> bool: ...
25
+ def validate_jwt_format(token: str) -> bool: ...
26
+
ciphertoken/secret.pyi ADDED
@@ -0,0 +1,7 @@
1
+ from typing import Awaitable, Tuple, Optional
2
+
3
+ def secret_key() -> str: ...
4
+ def secret_key_with_size(size: int) -> str: ...
5
+ def generate_hmac_secret(size: int) -> str: ...
6
+ async def generate_hmac_secret_async(size: int) -> Awaitable[str]: ...
7
+ def generate_rsa_keypair(bits: Optional[int] = 2048) -> Tuple[str, str]:...
ciphertoken/time.pyi ADDED
@@ -0,0 +1,7 @@
1
+
2
+ def now() -> int: ...
3
+ def seconds(n: int) -> int: ...
4
+ def minutes(n: int) -> int: ...
5
+ def hours(n: int) -> int: ...
6
+ def days(n: int) -> int: ...
7
+ def weeks(n: int) -> int: ...
ciphertoken/utils.pyi ADDED
@@ -0,0 +1,7 @@
1
+
2
+
3
+ # Constants
4
+ DEFAULT_SECRET_SIZE: int
5
+ MIN_SECRET_SIZE: int
6
+ TOKEN_ACCESS: str
7
+ TOKEN_REFRESH: str
@@ -0,0 +1,170 @@
1
+ Metadata-Version: 2.4
2
+ Name: ciphertoken
3
+ Version: 0.1.2
4
+ Classifier: Programming Language :: Python :: 3
5
+ Classifier: Programming Language :: Python :: 3 :: Only
6
+ Classifier: Programming Language :: Rust
7
+ Classifier: Operating System :: OS Independent
8
+ Summary: High-performance token and crypto utilities written in Rust with PyO3
9
+ Author: Cipher-Unit
10
+ License: MIT
11
+ Requires-Python: >=3.8
12
+ Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
13
+
14
+ <img src="https://raw.githubusercontent.com/cipher-unit/CipherToken/refs/heads/main/logo.png" width=100>
15
+
16
+ # CipherToken
17
+
18
+ **CipherToken** is a modern, high-performance Python library for cryptography and JWT (JSON Web Token) management.
19
+ It is implemented in **Rust** using **PyO3**, providing both speed and security for generating, encoding, decoding, and verifying tokens.
20
+
21
+ The library is designed to be modular, organized into **submodules** for secret management, time utilities, algorithms, and token handling.
22
+ It supports both **synchronous** and **asynchronous** operations
23
+
24
+ ---
25
+
26
+ ## Library Overview
27
+
28
+ CipherToken is structured into the following main parts:
29
+
30
+ ### 1. `secret` Module
31
+ Handles key generation for symmetric (HMAC) and asymmetric (RSA) algorithms:
32
+
33
+ - `secret_key()` – Generate a random HMAC key (default 32 bytes)
34
+ - `secret_key_with_size(size: int)` – Generate HMAC key with a custom size
35
+ - `generate_hmac_secret(size: int)` – Generate an HMAC secret key
36
+ - `generate_hmac_secret_async(size: int)` – Async version of HMAC key generation
37
+ - `generate_rsa_keypair(bits: Optional[int] = 2048)` – Generate RSA private/public key pair
38
+
39
+ ---
40
+
41
+ ### 2. `time` Module
42
+ Provides utility functions for time conversion and timestamps:
43
+
44
+ - `now()` – Current UNIX timestamp
45
+ - `seconds(n: int)` – Convert n seconds to seconds
46
+ - `minutes(n: int)` – Convert n minutes to seconds
47
+ - `hours(n: int)` – Convert n hours to seconds
48
+ - `days(n: int)` – Convert n days to seconds
49
+ - `weeks(n: int)` – Convert n weeks to seconds
50
+
51
+ ---
52
+
53
+ ### 3. `utils` Module
54
+ Contains useful constants:
55
+
56
+ - `DEFAULT_SECRET_SIZE` – Default key size
57
+ - `MIN_SECRET_SIZE` – Minimum allowed key size
58
+ - `TOKEN_ACCESS` – Access token type
59
+ - `TOKEN_REFRESH` – Refresh token type
60
+
61
+ ---
62
+
63
+ ### 4. `algorithms` Module
64
+ Defines algorithm constants for token signing:
65
+
66
+ - HMAC: `HS256`, `HS384`, `HS512`
67
+ - RSA: `RS256`, `RS384`, `RS512`
68
+ - ECDSA: `ES256`, `ES384`
69
+ - RSA-PSS: `PS256`, `PS384`, `PS512`
70
+ - Edwards Curve: `EDDSA`
71
+
72
+ ---
73
+
74
+ ### 5. `CipherToken` Class
75
+ Main class for managing JWTs:
76
+
77
+ - **Constructor:**
78
+ ```python
79
+ from ciphertoken import CipherToken
80
+
81
+ CipherToken(secret: str, algorithm: str, access_ttl: int, refresh_ttl: int)
82
+ ```
83
+
84
+ ### Synchronous methods:
85
+ ```python
86
+ access(user_id: int, extra_payload: Optional[dict] = None) -> str
87
+ refresh(user_id: int, extra_payload: Optional[dict] = None) -> str
88
+ decode(token: str) -> dict
89
+ verify(token: str) -> bool
90
+ rotation(refresh_token: str, extra_payload: Optional[dict] = None) -> Tuple[str, str]
91
+ inspect(token: str) -> dict
92
+ remaining_time(token: str) -> Optional[int]
93
+ algorithm_name() -> str
94
+ ```
95
+
96
+ ### Asynchronous methods:
97
+ ```python
98
+ await access_async(user_id: int, extra_payload: Optional[dict] = None) -> str
99
+ await refresh_async(user_id: int, extra_payload: Optional[dict] = None) -> str
100
+ await decode_async(token: str) -> dict
101
+ await verify_async(token: str) -> bool
102
+ await rotation_async(refresh_token: str, extra_payload: Optional[dict] = None) -> Tuple[str, str]
103
+ ```
104
+
105
+ ### Helper Functions:
106
+
107
+ `is_jwt_format(token: str) – Check if a string is a valid JWT`
108
+
109
+ `validate_jwt_format(token: str) – Validate JWT structure`
110
+
111
+ ## Installation
112
+
113
+ CipherToken is available via PyPI. Install it with:
114
+
115
+ `pip install ciphertoken`
116
+
117
+ ---
118
+
119
+ ### Usage Example
120
+
121
+ ```python
122
+ from ciphertoken.secret import secret_key
123
+ from ciphertoken import CipherToken
124
+ from ciphertoken.time import minutes, days
125
+ from ciphertoken.utils import TOKEN_REFRESH
126
+ from ciphertoken.algorithms import HS256
127
+
128
+ # Generate a secret key
129
+ key = secret_key()
130
+
131
+ # Create a CipherToken instance
132
+ token = CipherToken(secret=key, algorithm=HS256, access_ttl=minutes(10), refresh_ttl=days(7))
133
+
134
+ # Generate access and refresh tokens
135
+ access_token = token.access(user_id=123)
136
+ refresh_token = token.refresh(user_id=123)
137
+
138
+ # Verify and decode tokens
139
+ payload = token.decode(access_token)
140
+ is_valid = token.verify(access_token)
141
+
142
+ # Async usage
143
+ import asyncio
144
+
145
+ async def generate_async_token():
146
+ access_token = await token.access_async(user_id=123)
147
+ payload = await token.decode_async(access_token)
148
+ return payload
149
+
150
+ asyncio.run(generate_async_token())
151
+
152
+ ```
153
+
154
+ ### Implementation Notes
155
+
156
+ - Built in Rust using PyO3 for maximum speed and memory safety
157
+
158
+ - Supports synchronous and asynchronous workflows
159
+
160
+ - Fully modular: secret, time, utils, algorithms, and CipherToken class
161
+
162
+ - Secure key handling with HMAC and RSA support
163
+
164
+ - Easily extendable for additional algorithms
165
+
166
+
167
+ ### Summary
168
+
169
+ CipherToken is a modern, Rust-backed Python library for authentication and JWT management.
170
+ It is ideal for web APIs, microservices, or any system that requires secure token generation, verification, and rotation.
@@ -0,0 +1,11 @@
1
+ ciphertoken/__init__.pyi,sha256=8VC9YMMj_UblS3kpvPnuBpuukGrtaAq90RdrDcMg9bU,414
2
+ ciphertoken/algorithms.pyi,sha256=i1izi1n0I11ObAXSmNNkblbZKuaTUob3EBoaSw0wS-g,144
3
+ ciphertoken/ciphertoken.cp310-win_amd64.pyd,sha256=7pbo4GjyX1LqlClmq5H2dRVAVDis1riJ-BzsU2OmZuw,2319360
4
+ ciphertoken/ciphertoken.pyi,sha256=cgAXn7FazrkXxlvUphLUwx3a93lZ0owvThfrgbPMwtg,1458
5
+ ciphertoken/secret.pyi,sha256=4ZeBaU7VR3pAKq076xrW5Tp1PUEApttARJ7ii1hdCnQ,324
6
+ ciphertoken/time.pyi,sha256=TwRIF6lr6c3D8Auq9RZXG4VZ_bAcuHBvLOhcaRG639A,181
7
+ ciphertoken/utils.pyi,sha256=UUjB6TKffjlaMg-V3b8rNtJRl_ASw4Qa3ATF65z1bzg,104
8
+ ciphertoken-0.1.2.dist-info/METADATA,sha256=sHuMlwCqpfW7Ci73Ye_Vhcr8tqj0_MHX34In3oNBJTU,5265
9
+ ciphertoken-0.1.2.dist-info/WHEEL,sha256=qztQ23OdXtRBO3SW-Pa5eKaAgySi2gewLIEhihDaoD4,97
10
+ ciphertoken-0.1.2.dist-info/sboms/ciphertoken.cyclonedx.json,sha256=Y0IlWHHuTy8VOdamEsbzwW1r6-z0q8Ig2XzjfuFN34c,142894
11
+ ciphertoken-0.1.2.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: maturin (1.13.1)
3
+ Root-Is-Purelib: false
4
+ Tag: cp310-cp310-win_amd64