4dda0536d6297075a8a50bcb8312f275bfafafa2b93395c75aec53fe5862a093.json raw

   1  {"ast":null,"code":"import _asyncToGenerator from \"/home/mleku/src/orly.dev/next/signer/node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js\";\nimport browser from 'webextension-polyfill';\nconst params = new URLSearchParams(location.search);\nconst id = params.get('id');\nconst host = params.get('host');\n// Elements\nconst passwordInput = document.getElementById('passwordInput');\nconst togglePasswordBtn = document.getElementById('togglePassword');\nconst unlockBtn = document.getElementById('unlockBtn');\nconst derivingOverlay = document.getElementById('derivingOverlay');\nconst errorAlert = document.getElementById('errorAlert');\nconst errorMessage = document.getElementById('errorMessage');\nconst hostInfo = document.getElementById('hostInfo');\nconst hostSpan = document.getElementById('hostSpan');\n// Show host info if available\nif (host && hostInfo && hostSpan) {\n  hostSpan.innerText = host;\n  hostInfo.classList.remove('hidden');\n}\n// Toggle password visibility\ntogglePasswordBtn?.addEventListener('click', () => {\n  if (passwordInput.type === 'password') {\n    passwordInput.type = 'text';\n    togglePasswordBtn.innerHTML = '<i class=\"bi bi-eye-slash\"></i>';\n  } else {\n    passwordInput.type = 'password';\n    togglePasswordBtn.innerHTML = '<i class=\"bi bi-eye\"></i>';\n  }\n});\n// Enable/disable unlock button based on password input\npasswordInput?.addEventListener('input', () => {\n  unlockBtn.disabled = !passwordInput.value;\n});\n// Handle enter key\npasswordInput?.addEventListener('keyup', e => {\n  if (e.key === 'Enter' && passwordInput.value) {\n    attemptUnlock();\n  }\n});\n// Handle unlock button click\nunlockBtn?.addEventListener('click', attemptUnlock);\nfunction attemptUnlock() {\n  return _attemptUnlock.apply(this, arguments);\n}\nfunction _attemptUnlock() {\n  _attemptUnlock = _asyncToGenerator(function* () {\n    if (!passwordInput?.value) return;\n    // Show deriving overlay\n    derivingOverlay?.classList.remove('hidden');\n    errorAlert?.classList.add('hidden');\n    const message = {\n      type: 'unlock-request',\n      id,\n      password: passwordInput.value\n    };\n    try {\n      const response = yield browser.runtime.sendMessage(message);\n      if (response.success) {\n        // Success - close the window\n        window.close();\n      } else {\n        // Failed - show error\n        derivingOverlay?.classList.add('hidden');\n        showError(response.error || 'Invalid password');\n      }\n    } catch (error) {\n      console.error('Failed to send unlock message:', error);\n      derivingOverlay?.classList.add('hidden');\n      showError('Failed to unlock vault');\n    }\n  });\n  return _attemptUnlock.apply(this, arguments);\n}\nfunction showError(message) {\n  if (errorAlert && errorMessage) {\n    errorMessage.innerText = message;\n    errorAlert.classList.remove('hidden');\n    setTimeout(() => {\n      errorAlert.classList.add('hidden');\n    }, 3000);\n  }\n}\n// Focus password input on load\ndocument.addEventListener('DOMContentLoaded', () => {\n  passwordInput?.focus();\n});","map":null,"metadata":{},"sourceType":"module","externalDependencies":[]}