refactor: move clipboard to frontend, fix cipher type mapping, add context menu
This commit is contained in:
@@ -242,32 +242,27 @@ class Plugin:
|
||||
# ===== Credential Copy =====
|
||||
|
||||
async def copy_password(self, cipher_id: str) -> dict:
|
||||
"""Copy a password to clipboard with 60s auto-clear."""
|
||||
from clipboard import copy_to_clipboard
|
||||
"""Get password for clipboard copy."""
|
||||
password = self._get_cipher_field(cipher_id, "password")
|
||||
if password is None:
|
||||
return {"success": False, "error": "Password not found"}
|
||||
return await copy_to_clipboard(password, clear_after=60, label=f"password_{cipher_id}")
|
||||
return {"success": True, "value": password, "clear_after": 60}
|
||||
|
||||
async def copy_username(self, cipher_id: str) -> dict:
|
||||
"""Copy a username to clipboard with 60s auto-clear."""
|
||||
from clipboard import copy_to_clipboard
|
||||
"""Get username for clipboard copy."""
|
||||
username = self._get_cipher_field(cipher_id, "username")
|
||||
if username is None:
|
||||
return {"success": False, "error": "Username not found"}
|
||||
return await copy_to_clipboard(username, clear_after=60, label=f"username_{cipher_id}")
|
||||
return {"success": True, "value": username, "clear_after": 60}
|
||||
|
||||
async def copy_totp(self, cipher_id: str) -> dict:
|
||||
"""Copy TOTP code to clipboard with 60s auto-clear."""
|
||||
from clipboard import copy_to_clipboard
|
||||
"""Get TOTP code for clipboard copy."""
|
||||
from totp import generate_totp, get_totp_remaining_seconds
|
||||
totp_secret = self._get_cipher_field(cipher_id, "totp")
|
||||
if totp_secret:
|
||||
code = generate_totp(totp_secret)
|
||||
remaining = get_totp_remaining_seconds()
|
||||
result = await copy_to_clipboard(code, clear_after=min(remaining, 30), label=f"totp_{cipher_id}")
|
||||
result["remaining_seconds"] = remaining
|
||||
return result
|
||||
return {"success": True, "value": code, "clear_after": min(remaining, 30), "remaining_seconds": remaining}
|
||||
return {"success": False, "error": "TOTP not configured"}
|
||||
|
||||
async def get_totp_code(self, cipher_id: str) -> dict:
|
||||
|
||||
Reference in New Issue
Block a user