Skip to content

Commit fdddf4d

Browse files
committed
fix autocomplete
1 parent 5e7d228 commit fdddf4d

13 files changed

Lines changed: 281 additions & 10 deletions

‎.gitignore‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,5 @@ ciphertoken/*.abi3.so
1414
__pycache__/
1515
__pycache__/*
1616
.pytest_cache
17+
.ruff_cache
18+
.ruff_cache/

‎.pre-commit-config.yaml‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ repos:
33
rev: v0.13.0
44
hooks:
55
- id: ruff-check
6-
args: ['--ignore', 'F401']
6+
args: ['--ignore', 'F401', '--exclude', '.*\\.pyi']
77
- id: ruff-format
8+
exclude: '.*\\.pyi'
89

910
- repo: local
1011
hooks:

‎.vscode/settings.json‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"python.defaultInterpreterPath": "./.venv/bin/python",
3+
"python.analysis.autoCompleteExtraPaths": ["./ciphertoken"],
4+
"python.analysis.stubPath": "./typings",
5+
"python.languageServer": "Pylance"
6+
}

‎LICENSE‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2026 Cipher-Unit
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

‎ciphertoken.pyi‎

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
from typing import Any, Dict, Optional, Tuple
2+
3+
# Algorithm constants
4+
HS256: str
5+
HS384: str
6+
HS512: str
7+
RS256: str
8+
RS384: str
9+
RS512: str
10+
ES256: str
11+
ES384: str
12+
PS256: str
13+
PS384: str
14+
PS512: str
15+
EDDSA: str
16+
17+
# JWT module constants
18+
JWT_TOKEN_ACCESS: str
19+
JWT_TOKEN_REFRESH: str
20+
21+
# JWT functions
22+
def access(token_instance: Any, payload: Optional[Dict[str, Any]] = None) -> str: ...
23+
def refresh(token_instance: Any, payload: Optional[Dict[str, Any]] = None) -> str: ...
24+
def rotation(token_instance: Any, refresh_token: str, payload: Optional[Dict[str, Any]] = None) -> Tuple[str, str]: ...
25+
async def access_async(token_instance: Any, payload: Optional[Dict[str, Any]] = None) -> str: ...
26+
async def refresh_async(token_instance: Any, payload: Optional[Dict[str, Any]] = None) -> str: ...
27+
async def rotation_async(token_instance: Any, refresh_token: str, payload: Optional[Dict[str, Any]] = None) -> Tuple[str, str]: ...
28+
29+
# Secret functions
30+
def secret_key() -> str: ...
31+
def secret_key_with_size(size: int) -> str: ...
32+
def generate_hmac_secret(size: int) -> str: ...
33+
async def generate_hmac_secret_async(size: int) -> str: ...
34+
def generate_rsa_keypair(bits: Optional[int] = None) -> Tuple[str, str]: ...
35+
36+
# Time functions
37+
def now() -> int: ...
38+
def seconds(n: int) -> int: ...
39+
def minutes(n: int) -> int: ...
40+
def hours(n: int) -> int: ...
41+
def days(n: int) -> int: ...
42+
def weeks(n: int) -> int: ...
43+
44+
# Utils constants
45+
DEFAULT_SECRET_SIZE: int
46+
MIN_SECRET_SIZE: int
47+
TOKEN_ACCESS: str
48+
TOKEN_REFRESH: str
49+
50+
# JWT format functions
51+
def is_jwt_format(token: str) -> bool: ...
52+
def validate_jwt_format(token: str) -> bool: ...
53+
54+
# CipherToken class with full autocomplete support
55+
class CipherToken:
56+
def __init__(self, secret: str, algorithm: str, access_ttl: int, refresh_ttl: int) -> None: ...
57+
58+
# Token creation
59+
def create_token(self,ttl_time: int, token_type: str, payload: Optional[Dict[str, Any]] = None) -> str: ...
60+
def access(self,payload: Optional[Dict[str, Any]] = None) -> str: ...
61+
def refresh(self,payload: Optional[Dict[str, Any]] = None) -> str: ...
62+
63+
# Token inspection/decoding
64+
def decode(self,token: str) -> Dict[str, Any]: ...
65+
def verify(self,token: str) -> bool: ...
66+
def inspect(self,token: str) -> Dict[str, Any]: ...
67+
68+
# Token rotation
69+
def rotation(self,refresh_token: str, payload: Optional[Dict[str, Any]] = None) -> Tuple[str, str]: ...
70+
71+
# Utility methods
72+
def remaining_time(self,token: str) -> Optional[int]: ...
73+
def algorithm_name(self,) -> str: ...
74+
75+
# Properties
76+
@property
77+
def secret(self) -> str: ...
78+
@property
79+
def access_ttl(self) -> int: ...
80+
@property
81+
def refresh_ttl(self) -> int: ...
82+
83+
# Async methods
84+
async def access_async(self,payload: Optional[Dict[str, Any]] = None) -> str: ...
85+
async def refresh_async(self,payload: Optional[Dict[str, Any]] = None) -> str: ...
86+
async def decode_async(self,token: str) -> Dict[str, Any]: ...
87+
async def verify_async(self,token: str) -> bool: ...
88+
async def rotation_async(self,refresh_token: str, payload: Optional[Dict[str, Any]] = None) -> Tuple[str, str]: ...

‎ciphertoken/__init__.py‎

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@
1515
RS512,
1616
)
1717
from .ciphertoken import CipherToken, is_jwt_format, validate_jwt_format
18-
from .jwt import TOKEN_ACCESS as JWT_TOKEN_ACCESS, TOKEN_REFRESH as JWT_TOKEN_REFRESH
19-
from .jwt import access as jwt_access, refresh as jwt_refresh, rotation as jwt_rotation
18+
from .jwt import TOKEN_ACCESS, TOKEN_REFRESH
19+
from .jwt import access, refresh, rotation
2020
from .jwt import (
21-
access_async as jwt_access_async,
22-
refresh_async as jwt_refresh_async,
23-
rotation_async as jwt_rotation_async,
21+
access_async,
22+
refresh_async,
23+
rotation_async,
2424
)
2525
from .secret import (
2626
generate_hmac_secret,
@@ -30,7 +30,7 @@
3030
secret_key_with_size,
3131
)
3232
from .time import days, hours, minutes, now, seconds, weeks
33-
from .utils import DEFAULT_SECRET_SIZE, MIN_SECRET_SIZE, TOKEN_ACCESS, TOKEN_REFRESH
33+
from .utils import DEFAULT_SECRET_SIZE, MIN_SECRET_SIZE
3434

3535
__all__ = [
3636
"CipherToken",
@@ -69,6 +69,4 @@
6969
"weeks",
7070
"DEFAULT_SECRET_SIZE",
7171
"MIN_SECRET_SIZE",
72-
"TOKEN_ACCESS",
73-
"TOKEN_REFRESH",
7472
]

‎ciphertoken/__init__.pyi‎

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
from typing import Any, Dict, Optional, Tuple
2+
from typing_extensions import ParamSpec
3+
4+
P = ParamSpec("P")
5+
6+
# Algorithm constants
7+
HS256: str
8+
HS384: str
9+
HS512: str
10+
RS256: str
11+
RS384: str
12+
RS512: str
13+
ES256: str
14+
ES384: str
15+
PS256: str
16+
PS384: str
17+
PS512: str
18+
EDDSA: str
19+
20+
# JWT module constants (aliased)
21+
JWT_TOKEN_ACCESS: str
22+
JWT_TOKEN_REFRESH: str
23+
24+
# JWT functions (module-level wrappers)
25+
def jwt_access(token_instance: Any, payload: Optional[Dict[str, Any]] = None) -> str: ...
26+
def jwt_refresh(token_instance: Any, payload: Optional[Dict[str, Any]] = None) -> str: ...
27+
def jwt_rotation(token_instance: Any, refresh_token: str, payload: Optional[Dict[str, Any]] = None) -> Tuple[str, str]: ...
28+
async def jwt_access_async(token_instance: Any, payload: Optional[Dict[str, Any]] = None) -> str: ...
29+
async def jwt_refresh_async(token_instance: Any, payload: Optional[Dict[str, Any]] = None) -> str: ...
30+
async def jwt_rotation_async(token_instance: Any, refresh_token: str, payload: Optional[Dict[str, Any]] = None) -> Tuple[str, str]: ...
31+
32+
# Secret functions
33+
def secret_key() -> str: ...
34+
def secret_key_with_size(size: int) -> str: ...
35+
def generate_hmac_secret(size: int) -> str: ...
36+
async def generate_hmac_secret_async(size: int) -> str: ...
37+
def generate_rsa_keypair(bits: Optional[int] = None) -> Tuple[str, str]: ...
38+
39+
# Time functions
40+
def now() -> int: ...
41+
def seconds(n: int) -> int: ...
42+
def minutes(n: int) -> int: ...
43+
def hours(n: int) -> int: ...
44+
def days(n: int) -> int: ...
45+
def weeks(n: int) -> int: ...
46+
47+
# Utils constants
48+
DEFAULT_SECRET_SIZE: int
49+
MIN_SECRET_SIZE: int
50+
51+
# JWT format functions
52+
def is_jwt_format(token: str) -> bool: ...
53+
def validate_jwt_format(token: str) -> bool: ...
54+
55+
# CipherToken class
56+
class CipherToken:
57+
"""High-performance JWT token handler with support for multiple algorithms."""
58+
59+
secret: str
60+
access_ttl: int
61+
refresh_ttl: int
62+
63+
def __init__(self, secret: str, algorithm: str, access_ttl: int, refresh_ttl: int) -> None: ...
64+
65+
def create_token(self, ttl_time: int, token_type: str, payload: Optional[Dict[str, Any]] = None) -> str: ...
66+
def access(self, payload: Optional[Dict[str, Any]] = None) -> str: ...
67+
def refresh(self, payload: Optional[Dict[str, Any]] = None) -> str: ...
68+
def decode(self, token: str) -> Dict[str, Any]: ...
69+
def verify(self, token: str) -> bool: ...
70+
def inspect(self, token: str) -> Dict[str, Any]: ...
71+
def rotation(self, refresh_token: str, payload: Optional[Dict[str, Any]] = None) -> Tuple[str, str]: ...
72+
def remaining_time(self, token: str) -> Optional[int]: ...
73+
def algorithm_name(self) -> str: ...
74+
75+
async def access_async(self, payload: Optional[Dict[str, Any]] = None) -> str: ...
76+
async def refresh_async(self, payload: Optional[Dict[str, Any]] = None) -> str: ...
77+
async def decode_async(self, token: str) -> Dict[str, Any]: ...
78+
async def verify_async(self, token: str) -> bool: ...
79+
async def rotation_async(self, refresh_token: str, payload: Optional[Dict[str, Any]] = None) -> Tuple[str, str]: ...

‎ciphertoken/ciphertoken.abi3.so‎

3.92 MB
Binary file not shown.

‎ciphertoken/ciphertoken.pyi‎

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
from typing import Any, Dict, Optional, Tuple
2+
3+
# CipherToken class stub
4+
class CipherToken:
5+
def __init__(
6+
self,
7+
secret: str,
8+
algorithm: str,
9+
access_ttl: int,
10+
refresh_ttl: int,
11+
) -> None: ...
12+
13+
def create_token(
14+
self,
15+
ttl_time: int,
16+
token_type: str,
17+
payload: Optional[Dict[str, Any]] = None,
18+
) -> str: ...
19+
20+
def access(self, payload: Optional[Dict[str, Any]] = None) -> str: ...
21+
def refresh(self, payload: Optional[Dict[str, Any]] = None) -> str: ...
22+
def decode(self, token: str) -> Dict[str, Any]: ...
23+
def verify(self, token: str) -> bool: ...
24+
def inspect(self, token: str) -> Dict[str, Any]: ...
25+
def rotation(
26+
self, refresh_token: str, payload: Optional[Dict[str, Any]] = None
27+
) -> Tuple[str, str]: ...
28+
def remaining_time(self, token: str) -> Optional[int]: ...
29+
def algorithm_name(self) -> str: ...
30+
31+
@property
32+
def secret(self) -> str: ...
33+
@property
34+
def access_ttl(self) -> int: ...
35+
@property
36+
def refresh_ttl(self) -> int: ...
37+
38+
async def access_async(self, payload: Optional[Dict[str, Any]] = None) -> str: ...
39+
async def refresh_async(self, payload: Optional[Dict[str, Any]] = None) -> str: ...
40+
async def decode_async(self, token: str) -> Dict[str, Any]: ...
41+
async def verify_async(self, token: str) -> bool: ...
42+
async def rotation_async(
43+
self, refresh_token: str, payload: Optional[Dict[str, Any]] = None
44+
) -> Tuple[str, str]: ...
45+
46+
47+
def is_jwt_format(token: str) -> bool: ...
48+
def validate_jwt_format(token: str) -> bool: ...

‎ciphertoken/jwt.pyi‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from typing import Any, Dict, Optional
2+
3+
def access(token: Any, payload: Optional[Dict[str, Any]] = None) -> str: ...
4+
def refresh(token: Any, payload: Optional[Dict[str, Any]] = None) -> str: ...
5+
def rotation(token: Any, refresh_token: str, payload: Optional[Dict[str, Any]] = None) -> tuple[str, str]: ...
6+
async def access_async(token: Any, payload: Optional[Dict[str, Any]] = None) -> str: ...
7+
async def refresh_async(token: Any, payload: Optional[Dict[str, Any]] = None) -> str: ...
8+
async def rotation_async(token: Any, refresh_token: str, payload: Optional[Dict[str, Any]] = None) -> tuple[str, str]: ...
9+
10+
TOKEN_ACCESS: str
11+
TOKEN_REFRESH: str

0 commit comments

Comments
 (0)