Compare commits

...

6 Commits

Author SHA1 Message Date
yeongpin
5b64e54e90 Update CHANGELOG.md for version 1.9.02 with new features and fixes
- Added entry for bypassing Cursor JWT expiration issue.
- Fixed redirect issue in Cursor editor that caused automatic logout.
- Retained existing fixes for configuration file path, Windows user permissions, and other issues.
2025-04-12 17:31:14 +08:00
yeongpin
f667da64b3 Add token refresh functionality and improve token extraction
- Introduced a new `get_user_token.py` file to handle token refresh logic using the Chinese server API.
- Updated `config.py` to include new token settings for refresh server URL and enable refresh option.
- Refactored `oauth_auth.py` to utilize the new token extraction method, enhancing error handling and user feedback.
- Added localization strings for token refresh messages in both English and Chinese to improve user experience.
2025-04-12 17:28:11 +08:00
yeongpin
26a8e8da28 Update CHANGELOG.md for version 1.9.02 and enhance config handling
- Added entries for version 1.9.02 in CHANGELOG.md, detailing fixes for configuration file path, Windows user permissions, and other issues.
- Improved `config.py` to handle document path retrieval more robustly, including fallback to a temporary directory if the documents path is not found.
- Updated localization files to include new strings for configuration messages in both English and Chinese.
2025-04-12 17:00:18 +08:00
yeongpin
3862176867 Refactor README.md for improved readability
- Adjusted formatting of browser download instructions to enhance clarity and presentation.
- Separated links for better visual structure in both English and Chinese sections.
2025-04-12 14:37:32 +08:00
yeongpin
5adc598661 Update README.md and configuration files for enhanced browser support
- Revised browser download instructions in README.md to include multiple options: Google Chrome, Opera, Edge, Firefox, and Brave.
- Added new Windows path configurations for browser executables and drivers in the configuration section, improving support for various browsers and their respective drivers.
- Introduced new settings for OAuth configuration, including alert display options and timeout settings.
2025-04-12 14:36:37 +08:00
yeongpin
5e6651bb32 Update CHANGELOG.md for version 1.9.01
- Reorganized entries for clarity, ensuring the new features and fixes are listed under the correct version.
- Added details on enhanced browser support, including Opera, Brave, Edge, and Firefox, along with fixes for browser profile selection and other issues.
2025-04-12 14:35:10 +08:00
9 changed files with 234 additions and 38 deletions

4
.env
View File

@@ -1,2 +1,2 @@
version=1.9.01
VERSION=1.9.01
version=1.9.02
VERSION=1.9.02

View File

@@ -6,7 +6,7 @@ on:
version:
description: 'Version number (e.g. 1.0.9)'
required: true
default: '1.9.01'
default: '1.9.02'
permissions:
contents: write

View File

@@ -1,15 +1,20 @@
# Change Log
## v1.9.01
1. Add: More Browser Support | 添加更多瀏覽器支持
2. Support: Add Opera, Brave, Edge, Firefox | 添加支持 Opera, Brave, Edge, Firefox
3. Add config manual browser path | 添加配置手動選擇遊覽器路徑
4. Fix: Browser Profile Selection | 修復瀏覽器配置文件選擇
## v1.9.02
1. Add: Bypass Cursor JWT EXP Problem | 添加繞過 Cursor JWT EXP 問題
2. Fix: Cursor editor redirects to logout page and logout automatically | 修復 Cursor 編輯器重定向到登出頁面並自動登出
3. Fix: Config File Path | 修復配置文件路徑
4. Fix: window user permission | 修復 window 用戶權限
5. Fix: Some Issues | 修復一些問題
## v1.8.11
## v1.9.01
1. Add: Bypass Token Limit | 添加繞過 Token 限制
2. Fix: Some Issues | 修復一些問題
2. Add: More Browser Support | 添加更多瀏覽器支持
3. Support: Add Opera, Brave, Edge, Firefox | 添加支持 Opera, Brave, Edge, Firefox
4. Add config manual browser path | 添加配置手動選擇遊覽器路徑
5. Fix: Browser Profile Selection | 修復瀏覽器配置文件選擇
6. Fix: Some Issues | 修復一些問題
## v1.8.10
1. Add: Check User Authorized | 添加檢查用戶授權

View File

@@ -30,9 +30,11 @@ Always clean your browser's cache and cookies. If possible, use a VPN to create
<img src="./images/pro_2025-04-05_18-47-56.png" alt="new" width="800" style="border-radius: 6px;"/><br>
</p>
##### If you don't have Google Chrome, you can download it from [here](https://www.google.com/intl/en_pk/chrome/)
##### If you don't have browser, you can download it from
[Google Chrome](https://www.google.com/intl/en_pk/chrome/) or [Opera](https://www.opera.com/download) or [Edge](https://www.microsoft.com/en-us/edge) or [Firefox](https://www.mozilla.org/en-US/firefox/new/) or [Brave](https://www.brave.com/download/)
##### 如果沒有 Google Chrome可以從[這裡](https://www.google.com/intl/en_pk/chrome/)下載
##### 如果沒有瀏覽器,可以從
[Google Chrome](https://www.google.com/intl/en_pk/chrome/) 或 [Opera](https://www.opera.com/download) 或 [Edge](https://www.microsoft.com/en-us/edge) 或 [Firefox](https://www.mozilla.org/en-US/firefox/new/) 或 [Brave](https://www.brave.com/download/) 下載
</div>
@@ -166,6 +168,33 @@ max_timeout = 160
check_update = True
# Show Account Info | 顯示賬號信息
show_account_info = True
[WindowsPaths]
storage_path = C:\Users\yeongpin\AppData\Roaming\Cursor\User\globalStorage\storage.json
sqlite_path = C:\Users\yeongpin\AppData\Roaming\Cursor\User\globalStorage\state.vscdb
machine_id_path = C:\Users\yeongpin\AppData\Roaming\Cursor\machineId
cursor_path = C:\Users\yeongpin\AppData\Local\Programs\Cursor\resources\app
updater_path = C:\Users\yeongpin\AppData\Local\cursor-updater
update_yml_path = C:\Users\yeongpin\AppData\Local\Programs\Cursor\resources\app-update.yml
product_json_path = C:\Users\yeongpin\AppData\Local\Programs\Cursor\resources\app\product.json
[Browser]
default_browser = opera
chrome_path = C:\Program Files\Google\Chrome\Application\chrome.exe
edge_path = C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe
firefox_path = C:\Program Files\Mozilla Firefox\firefox.exe
brave_path = C:\Program Files\BraveSoftware/Brave-Browser/Application/brave.exe
chrome_driver_path = D:\VisualCode\cursor-free-vip-new\drivers\chromedriver.exe
edge_driver_path = D:\VisualCode\cursor-free-vip-new\drivers\msedgedriver.exe
firefox_driver_path = D:\VisualCode\cursor-free-vip-new\drivers\geckodriver.exe
brave_driver_path = D:\VisualCode\cursor-free-vip-new\drivers\chromedriver.exe
opera_path = C:\Users\yeongpin\AppData\Local\Programs\Opera\opera.exe
opera_driver_path = D:\VisualCode\cursor-free-vip-new\drivers\chromedriver.exe
[OAuth]
show_selection_alert = False
timeout = 120
max_attempts = 3
```
</details>

View File

@@ -18,13 +18,41 @@ EMOJI = {
"SETTINGS": "⚙️"
}
# global config cache
_config_cache = None
def setup_config(translator=None):
"""Setup configuration file and return config object"""
try:
config_dir = os.path.join(get_user_documents_path(), ".cursor-free-vip")
config_file = os.path.join(config_dir, "config.ini")
os.makedirs(config_dir, exist_ok=True)
# get documents path
docs_path = get_user_documents_path()
if not docs_path or not os.path.exists(docs_path):
# if documents path not found, use current directory
print(f"{Fore.YELLOW}{EMOJI['WARNING']} {translator.get('config.documents_path_not_found', fallback='Documents path not found, using current directory') if translator else 'Documents path not found, using current directory'}{Style.RESET_ALL}")
docs_path = os.path.abspath('.')
# normalize path
config_dir = os.path.normpath(os.path.join(docs_path, ".cursor-free-vip"))
config_file = os.path.normpath(os.path.join(config_dir, "config.ini"))
# create config directory, only print message when directory not exists
dir_exists = os.path.exists(config_dir)
try:
os.makedirs(config_dir, exist_ok=True)
if not dir_exists: # only print message when directory not exists
print(f"{Fore.CYAN}{EMOJI['INFO']} {translator.get('config.config_dir_created', path=config_dir) if translator else f'Config directory created: {config_dir}'}{Style.RESET_ALL}")
except Exception as e:
# if cannot create directory, use temporary directory
import tempfile
temp_dir = os.path.normpath(os.path.join(tempfile.gettempdir(), ".cursor-free-vip"))
temp_exists = os.path.exists(temp_dir)
config_dir = temp_dir
config_file = os.path.normpath(os.path.join(config_dir, "config.ini"))
os.makedirs(config_dir, exist_ok=True)
if not temp_exists: # only print message when temporary directory not exists
print(f"{Fore.YELLOW}{EMOJI['WARNING']} {translator.get('config.using_temp_dir', path=config_dir, error=str(e)) if translator else f'Using temporary directory due to error: {config_dir} (Error: {str(e)})'}{Style.RESET_ALL}")
# create config object
config = configparser.ConfigParser()
# Default configuration
@@ -74,6 +102,10 @@ def setup_config(translator=None):
'show_selection_alert': False, # 默认不显示选择提示弹窗
'timeout': 120,
'max_attempts': 3
},
'Token': {
'refresh_server': 'https://token.cursorpro.com.cn',
'enable_refresh': True
}
}
@@ -330,4 +362,7 @@ def force_update_config(translator=None):
def get_config(translator=None):
"""Get existing config or create new one"""
return setup_config(translator)
global _config_cache
if _config_cache is None:
_config_cache = setup_config(translator)
return _config_cache

112
get_user_token.py Normal file
View File

@@ -0,0 +1,112 @@
import requests
import json
import time
from colorama import Fore, Style
import os
from config import get_config
# Define emoji constants
EMOJI = {
'START': '🚀',
'OAUTH': '🔑',
'SUCCESS': '',
'ERROR': '',
'WAIT': '',
'INFO': '',
'WARNING': '⚠️'
}
def refresh_token(token, translator=None):
"""Refresh the token using the Chinese server API
Args:
token (str): The full WorkosCursorSessionToken cookie value
translator: Optional translator object
Returns:
str: The refreshed access token or original token if refresh fails
"""
try:
config = get_config(translator)
# Get refresh_server URL from config or use default
refresh_server = config.get('Token', 'refresh_server', fallback='https://token.cursorpro.com.cn')
# Ensure the token is URL encoded properly
if '%3A%3A' not in token and '::' in token:
# Replace :: with URL encoded version if needed
token = token.replace('::', '%3A%3A')
# Make the request to the refresh server
url = f"{refresh_server}/reftoken?token={token}"
print(f"{Fore.CYAN}{EMOJI['INFO']} {translator.get('token.refreshing') if translator else 'Refreshing token...'}{Style.RESET_ALL}")
response = requests.get(url, timeout=30)
if response.status_code == 200:
try:
data = response.json()
if data.get('code') == 0 and data.get('msg') == "获取成功":
access_token = data.get('data', {}).get('accessToken')
days_left = data.get('data', {}).get('days_left', 0)
expire_time = data.get('data', {}).get('expire_time', 'Unknown')
if access_token:
print(f"{Fore.GREEN}{EMOJI['SUCCESS']} {translator.get('token.refresh_success', days=days_left, expire=expire_time) if translator else f'Token refreshed successfully! Valid for {days_left} days (expires: {expire_time})'}{Style.RESET_ALL}")
return access_token
else:
print(f"{Fore.YELLOW}{EMOJI['WARNING']} {translator.get('token.no_access_token') if translator else 'No access token in response'}{Style.RESET_ALL}")
else:
error_msg = data.get('msg', 'Unknown error')
print(f"{Fore.RED}{EMOJI['ERROR']} {translator.get('token.refresh_failed', error=error_msg) if translator else f'Token refresh failed: {error_msg}'}{Style.RESET_ALL}")
except json.JSONDecodeError:
print(f"{Fore.RED}{EMOJI['ERROR']} {translator.get('token.invalid_response') if translator else 'Invalid JSON response from refresh server'}{Style.RESET_ALL}")
else:
print(f"{Fore.RED}{EMOJI['ERROR']} {translator.get('token.server_error', status=response.status_code) if translator else f'Refresh server error: HTTP {response.status_code}'}{Style.RESET_ALL}")
except requests.exceptions.Timeout:
print(f"{Fore.RED}{EMOJI['ERROR']} {translator.get('token.request_timeout') if translator else 'Request to refresh server timed out'}{Style.RESET_ALL}")
except requests.exceptions.ConnectionError:
print(f"{Fore.RED}{EMOJI['ERROR']} {translator.get('token.connection_error') if translator else 'Connection error to refresh server'}{Style.RESET_ALL}")
except Exception as e:
print(f"{Fore.RED}{EMOJI['ERROR']} {translator.get('token.unexpected_error', error=str(e)) if translator else f'Unexpected error during token refresh: {str(e)}'}{Style.RESET_ALL}")
# Return original token if refresh fails
return token.split('%3A%3A')[-1] if '%3A%3A' in token else token.split('::')[-1] if '::' in token else token
def get_token_from_cookie(cookie_value, translator=None):
"""Extract and process token from cookie value
Args:
cookie_value (str): The WorkosCursorSessionToken cookie value
translator: Optional translator object
Returns:
str: The processed token
"""
try:
# Try to refresh the token with the API first
refreshed_token = refresh_token(cookie_value, translator)
# If refresh succeeded and returned a different token, use it
if refreshed_token and refreshed_token != cookie_value:
return refreshed_token
# If refresh failed or returned same token, use traditional extraction method
if '%3A%3A' in cookie_value:
return cookie_value.split('%3A%3A')[-1]
elif '::' in cookie_value:
return cookie_value.split('::')[-1]
else:
return cookie_value
except Exception as e:
print(f"{Fore.RED}{EMOJI['ERROR']} {translator.get('token.extraction_error', error=str(e)) if translator else f'Error extracting token: {str(e)}'}{Style.RESET_ALL}")
# Fall back to original behavior
if '%3A%3A' in cookie_value:
return cookie_value.split('%3A%3A')[-1]
elif '::' in cookie_value:
return cookie_value.split('::')[-1]
else:
return cookie_value

View File

@@ -572,7 +572,10 @@
"backup_failed": "Failed to backup config: {error}",
"force_update_failed": "Force update config failed: {error}",
"config_force_update_disabled": "Config file force update disabled , skipping forced update",
"config_force_update_enabled": "Config file force update enabled , performing forced update"
"config_force_update_enabled": "Config file force update enabled , performing forced update",
"documents_path_not_found": "Documents path not found, using current directory",
"config_dir_created": "Config directory created: {path}",
"using_temp_dir": "Using temporary directory due to error: {path} (Error: {error})"
},
"oauth": {
"authentication_button_not_found": "Authentication button not found",
@@ -749,5 +752,17 @@
"title": "Bypass Token Limit Tool",
"description": "This tool modifies the workbench.desktop.main.js file to bypass the token limit",
"press_enter": "Press Enter to continue..."
},
"token": {
"refreshing": "Refreshing token...",
"refresh_success": "Token refreshed successfully! Valid for {days} days (expires: {expire})",
"no_access_token": "No access token in response",
"refresh_failed": "Token refresh failed: {error}",
"invalid_response": "Invalid JSON response from refresh server",
"server_error": "Refresh server error: HTTP {status}",
"request_timeout": "Request to refresh server timed out",
"connection_error": "Connection error to refresh server",
"unexpected_error": "Unexpected error during token refresh: {error}",
"extraction_error": "Error extracting token: {error}"
}
}

View File

@@ -550,7 +550,10 @@
"backup_failed": "备份失败: {error}",
"force_update_failed": "强制更新配置失败: {error}",
"config_force_update_disabled": "配置文件强制更新已禁用,跳过强制更新",
"config_force_update_enabled": "配置文件强制更新已启用,正在执行强制更新"
"config_force_update_enabled": "配置文件强制更新已启用,正在执行强制更新",
"documents_path_not_found": "找不到文档路径,使用当前目录",
"config_dir_created": "已创建配置目录: {path}",
"using_temp_dir": "由于错误使用临时目录: {path} (错误: {error})"
},
"oauth": {
"authentication_button_not_found": "未找到认证按钮",
@@ -727,5 +730,17 @@
"title": "绕过 Token 限制工具",
"description": "此工具修改 workbench.desktop.main.js 文件以绕过 token 限制",
"press_enter": "按回车键继续..."
},
"token": {
"refreshing": "正在刷新令牌...",
"refresh_success": "令牌刷新成功!有效期 {days} 天(到期时间: {expire}",
"no_access_token": "响应中没有访问令牌",
"refresh_failed": "令牌刷新失败: {error}",
"invalid_response": "刷新服务器返回无效的 JSON 响应",
"server_error": "刷新服务器错误: HTTP {status}",
"request_timeout": "刷新服务器请求超时",
"connection_error": "连接刷新服务器错误",
"unexpected_error": "令牌刷新过程中出现意外错误: {error}",
"extraction_error": "提取令牌时出错: {error}"
}
}

View File

@@ -10,6 +10,7 @@ from cursor_auth import CursorAuth
from utils import get_random_wait_time, get_default_browser_path
from config import get_config
import platform
from get_user_token import get_token_from_cookie
# Initialize colorama
init()
@@ -587,13 +588,7 @@ class OAuthHandler:
for cookie in cookies:
if cookie.get("name") == "WorkosCursorSessionToken":
value = cookie.get("value", "")
token = None
if "::" in value:
token = value.split("::")[-1]
elif "%3A%3A" in value:
token = value.split("%3A%3A")[-1]
token = get_token_from_cookie(value, self.translator)
if token:
# Get email from settings page
print(f"{Fore.CYAN}{EMOJI['INFO']} {self.translator.get('oauth.authentication_successful_getting_account_info') if self.translator else 'Authentication successful, getting account info...'}{Style.RESET_ALL}")
@@ -798,11 +793,7 @@ class OAuthHandler:
for cookie in cookies:
if cookie.get("name") == "WorkosCursorSessionToken":
value = cookie.get("value", "")
if "::" in value:
token = value.split("::")[-1]
elif "%3A%3A" in value:
token = value.split("%3A%3A")[-1]
token = get_token_from_cookie(value, self.translator)
if token:
print(f"{Fore.GREEN}{EMOJI['SUCCESS']} {self.translator.get('oauth.authentication_successful') if self.translator else 'Authentication successful!'}{Style.RESET_ALL}")
# Navigate to settings page
@@ -865,10 +856,7 @@ class OAuthHandler:
for cookie in cookies:
if cookie.get("name") == "WorkosCursorSessionToken":
value = cookie.get("value", "")
if "::" in value:
token = value.split("::")[-1]
elif "%3A%3A" in value:
token = value.split("%3A%3A")[-1]
token = get_token_from_cookie(value, self.translator)
if token:
# Get email and check usage here too
try:
@@ -965,10 +953,7 @@ class OAuthHandler:
if name == "WorkosCursorSessionToken":
try:
value = cookie.get("value", "")
if "::" in value:
token = value.split("::")[-1]
elif "%3A%3A" in value:
token = value.split("%3A%3A")[-1]
token = get_token_from_cookie(value, self.translator)
except Exception as e:
print(f"{Fore.YELLOW}{EMOJI['INFO']} {self.translator.get('oauth.token_extraction_error', error=str(e)) if self.translator else f'Token extraction error: {str(e)}'}{Style.RESET_ALL}")
elif name == "cursor_email":