Skip to content

Commit 66f11a4

Browse files
Merge pull request #4 from Chinchill-AI/fix-lazy-crypto
fix: lazy import cryptography — broken install without extras
2 parents 5ba250f + 420e798 commit 66f11a4

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "chat-sdk"
3-
version = "0.0.1a1"
3+
version = "0.0.1a2"
44
description = "Multi-platform async chat SDK for Python — port of Vercel Chat"
55
readme = "README.md"
66
license = {text = "MIT"}

src/chat_sdk/adapters/slack/crypto.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
from dataclasses import dataclass
1111
from typing import Any
1212

13-
from cryptography.hazmat.primitives.ciphers.aead import AESGCM
14-
1513
ALGORITHM = "aes-256-gcm"
1614
IV_LENGTH = 12
1715
AUTH_TAG_LENGTH = 16
@@ -39,6 +37,8 @@ def encrypt_token(plaintext: str, key: bytes) -> EncryptedTokenData:
3937
"""
4038
import base64
4139

40+
from cryptography.hazmat.primitives.ciphers.aead import AESGCM
41+
4242
iv = os.urandom(IV_LENGTH)
4343
aesgcm = AESGCM(key)
4444
# AESGCM.encrypt returns ciphertext + tag concatenated
@@ -66,6 +66,8 @@ def decrypt_token(encrypted: EncryptedTokenData, key: bytes) -> str:
6666
"""
6767
import base64
6868

69+
from cryptography.hazmat.primitives.ciphers.aead import AESGCM
70+
6971
iv = base64.b64decode(encrypted.iv)
7072
ciphertext = base64.b64decode(encrypted.data)
7173
tag = base64.b64decode(encrypted.tag)

0 commit comments

Comments
 (0)