def generate_secure_token(self, data: dict, expiry: datetime) -> str:
        """Generate a secure token using JWT with HS256.

        The secret_key is used for symmetrical signing.
        """
        now = datetime.now(timezone.utc)
        to_encode = {
            **data,
            "exp": expiry.timestamp(),
            "iat": now.timestamp(),
            "nbf": now.timestamp(),
            "jti": base64.urlsafe_b64encode(nacl.utils.random(16)).decode(),
            "nonce": base64.urlsafe_b64encode(nacl.utils.random(16)).decode(),
        }

        return jwt.encode(to_encode, self.secret_key, algorithm="HS256")
Generate a secure token using JWT with HS256.

        The secret_key is used for symmetrical signing.
        
py/core/providers/crypto/nacl.py