File size: 2,099 Bytes
e39e20a
 
89d69ea
 
 
a2fab76
e39e20a
 
a2fab76
e39e20a
 
 
d558d52
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
---
title: cursor-ai-proxy
emoji: 🔥
colorFrom: purple
colorTo: purple
sdk: docker
sdk_version: "3.0.0"
app_file: app.py
pinned: false
---

Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference

## Cursor AI Proxy with Checksum

This is a modified version of the Cursor AI proxy that includes a checksum mechanism for enhanced security.

**Features:**

*   Proxies requests from Cursor to OpenAI API.
*   Fetches the latest checksum from `https://cc.wisdgod.com/get-checksum` every 3 hours.
*   Verifies the checksum of incoming requests on the `/hf/v1/chat/completions` endpoint.

**How to Use:**

1. **Set the `CURSOR_CHECKSUM` Environment Variable:**
    *   In your Hugging Face Space's Settings, go to "Repository secrets" and add a new secret:
        *   **Name:** `CURSOR_CHECKSUM`
        *   **Value:** You can set an initial checksum value here, or leave it blank to initially rely on the value fetched from `https://cc.wisdgod.com/get-checksum`.
2. **Deploy to Hugging Face Spaces:**
    *   Commit and push the `hf.js` and `Dockerfile` to your Hugging Face Space's Git repository.
    *   Hugging Face will automatically build and deploy your application.

**Checksum Verification:**

*   The application fetches the latest checksum from `https://cc.wisdgod.com/get-checksum` on startup and every 3 hours.
*   Incoming requests to `/hf/v1/chat/completions` are checked against the current `checksumValue`.
*   If the checksum doesn't match, a `400 Invalid checksum` error is returned.

**Important Notes:**

*   The `verifyChecksum()` function in `hf.js` is a **placeholder**. You need to implement the actual checksum verification logic based on your security requirements and how Cursor sends data.
*   The current example uses a simple string comparison for demonstration purposes. You should use a robust cryptographic algorithm like HMAC for production environments.

**Disclaimer:**

This modified proxy is provided as-is. Use it at your own risk. Always thoroughly test your code and security measures before deploying to production.