semvec/pypi-packages huggingface dataset:
beepberry-lib 0.0.2
PythonLib for BEEPBERRY
License: MIT
Requires Python: >=3.6.0


# BEEPBERRY    PYTHON-LIB

This is a Python library for BeepBerry. Currently, it includes functionalities for key, RGB light, and screen, encompassing three types of hardware. It can be easily installed via pip and simplifies the process of driving these hardware components.

![](beepberry.jpg)


## Install instructions 

From pip:

```
pip install --upgrade beepberry-lib
```

## Examples

```python
import beepberry

#rgb
import time
bb=beepberry.BEEPBERRY()
bb.rgb(0,0,100)   #r,g,b   form 0 to 255 
time.sleep(1)
bb.rgb_off()

#button  See: https://gpiozero.readthedocs.io/en/stable/recipes.html#button 
#button.is_pressed  button.wait_for_press() button.when_presse  button.when_released
from gpiozero import Button
from signal import pause

def say_hello():
    print("Hello!")

def say_goodbye():
    print("Goodbye!")

button = bb.button

button.when_pressed = say_hello
button.when_released = say_goodbye

pause()

#scr
from PIL import Image, ImageDraw, ImageFont
bb=beepberry.BEEPBERRY()
scr=bb.lcd

font = ImageFont.truetype("yahei.ttf", 24)  # load font

scr.text(xy=(10,10),text='beepberry',fill='red',font=font)
bb.show() 

bb.show_pic('test.jpg')   #show pics directly

#battery
vbat=bb.battery()
```
## KEYMAP


```
 *                  BBQ20KBD PMOD KEYBOARD LAYOUT
 *
 *  +------+-----+----+----+----+----+----+-----+-----+-------+
 *  |      |          |BR     ↑TPY-       |           |       |
 *  | Ctrl |   PgDn   |←TPX- BL(HOME)TPX+→|   PgUp    | MENU  |
 *  |      |          |       ↓TPY+       |           |       |
 *  +------+-----+----+----+----+----+----+-----+-----+-------+
 *  |                                                         |
 *  +------+-----+----+----+----+----+----+-----+-----+-------+
 *  |#     |1    |2   |3   |(   |   )|_   |    -|    +|      @|
 *  |  Q   |  W  | E  | R  | T  |  Y |  U |  I  |  O  |   P   |
 *  |      |     |PgDn|PgUp|   \|UP  |^   |=    |{    |}      |
 *  +------+-----+----+----+----+----+----+-----+-----+-------+
 *  |*     |4    |5   |6   |/   |   :|;   |    '|    "|    ESC|
 *  |  A   |  S  | D  | F  | G  |  H |  J |  K  |  L  |  BKSP |
 *  |     ?|     |   [|   ]|LEFT|HOME|RGHT|V+   |V-   |DLT    |
 *  +------+-----+----+----+----+----+----+-----+-----+-------+
 *  |      |7    |8   |9   |?   |   !|,   |    .|    `|       |
 *  |LFTALT|  Z  | X  | C  | V  |  B |  N |  M  |  $  | ENTER |
 *  |      |   K+|  K-|   °|   
   |MENU |Vx   |       |
 *  +------+-----+----+----+----+----+----+-----+-----+-------+
 *  |            |0   |TAB                |     |             |
 *  | LEFT_SHIFT | ~  |       SPACE       |RTALT| RIGHT_SHIFT |
 *  |            |  Kx|                  &|     |             |
 *  +------------+----+-------------------+-----+-------------+
```

## Change Log

### [0.0.2] - 2023-08-13

- Add battery.

### [0.0.1] - 2023-08-09

- First commit.
django-channels-secure-jwt 1.0.0
Secure JWT Auth Middleware for Django Channels
License: MIT
Requires Python: >=3.8
Keywords: django,channels,jwt,auth,middleware,python,authentication

# Django Channels JWT 

Django Channels JWT Middleware is a secure way to handle authentication for Django Channels WebSocket connections without directly exposing JWT tokens. Instead of sending the token itself in the query parameter, this middleware uses UUID-based authentication and cache-based user retrieval for enhanced security.

## Security Benefits

- **Enhanced Security**: JWT tokens can potentially be intercepted if sent as query parameters. This middleware avoids sending tokens directly, minimizing the risk of token leakage.

- **UUID-based Authentication**: This middleware generates UUIDs as tokens for WebSocket connections. These UUIDs are short-lived and act as temporary access keys. When a user connects, they provide the UUID, which is used to retrieve the authenticated user.

- **Cache-based User Retrieval**: Upon connection, the middleware validates the UUID, retrieves the corresponding user ID from the cache, and fetches the user asynchronously. This ensures that the WebSocket connection is only established for authenticated users.

## Risks of Sending Tokens as Query Parameters

Sending tokens as query parameters can expose security vulnerabilities:
- **Token Exposure**: Tokens in query parameters can be captured in logs, browser history, or server logs, increasing the risk of unauthorized access.
- **Caching**: Some proxies or servers may cache URLs, which could lead to tokens being stored in shared caches.

## Installation

Install the package using pip:

```bash
pip install django-channels-jwt
```

## Configuration

1. Wrap your URLRouter
   ```python
   from django_channels_jwt.middlware import JwtAuthMiddlewareStack

   application = ProtocolTypeRouter({
       "http": get_asgi_application(),
       "websocket": JwtAuthMiddlewareStack(
           URLRouter(
               websocket_urlpatterns,
           )
       ),
   })
   ```

2. Include the provided URL for ticket generation in your project's `urls.py`:

  ```python
   from django.urls import path, include

   url_patterns = [
       # ... your other URL patterns
       path("api/auth/", include('django_channels_jwt.urls')
   ]
   ```
or if you want to set customized route

   ```python
   from django.urls import path, include
   from django_channels_jwt.views import AsgiValidateTokenView

   url_patterns = [
       # ... your other URL patterns
       path("auth_for_ws_connection/", AsgiValidateTokenView.as_view())
   ]
   ```

## Usage

1. Ensure your Django app's models are configured correctly.
2. Use the included `AsgiValidateTokenView` to generate a ticket (UUID) for WebSocket connections.
3. Connect to your WebSocket with the generated UUID to authenticate the connection without exposing the token.
 ```
 ws://localhost:8001/ws/chat/?uuid=
 ```


1.0.0 (2023-08-11)
------------------

* First release on PyPI.