mirror of
https://github.com/quexten/goldwarden.git
synced 2024-09-11 19:17:33 +03:00
This commit is contained in:
commit
d0b159f17c
8
.github/workflows/release.yml
vendored
8
.github/workflows/release.yml
vendored
@ -128,7 +128,7 @@ jobs:
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v4
|
||||
with:
|
||||
go-version: '1.20'
|
||||
go-version: ${{ env.GO_VERSION }}
|
||||
- name: Set up Homebrew
|
||||
id: set-up-homebrew
|
||||
uses: Homebrew/actions/setup-homebrew@master
|
||||
@ -149,7 +149,7 @@ jobs:
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v4
|
||||
with:
|
||||
go-version: '1.20'
|
||||
go-version: ${{ env.GO_VERSION }}
|
||||
- name: Set up Homebrew
|
||||
id: set-up-homebrew
|
||||
uses: Homebrew/actions/setup-homebrew@master
|
||||
@ -170,7 +170,7 @@ jobs:
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v4
|
||||
with:
|
||||
go-version: '1.20'
|
||||
go-version: ${{ env.GO_VERSION }}
|
||||
- uses: MinoruSekine/setup-scoop@v2
|
||||
- name: Fido2
|
||||
run: |
|
||||
@ -191,7 +191,7 @@ jobs:
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v4
|
||||
with:
|
||||
go-version: '1.20'
|
||||
go-version: ${{ env.GO_VERSION }}
|
||||
- name: Build
|
||||
run: set GOARCH=arm64 && go build -tags nofido2 -o "goldwarden_windows_aarch64.exe" -v .
|
||||
- uses: AButler/upload-release-assets@v2.0
|
||||
|
2
PKGBUILD
2
PKGBUILD
@ -1,5 +1,5 @@
|
||||
pkgname=goldwarden
|
||||
pkgver=0.2.14
|
||||
pkgver=0.2.15
|
||||
pkgrel=1
|
||||
pkgdesc='A feature-packed Bitwarden compatible desktop integration'
|
||||
arch=('x86_64' 'aarch64')
|
||||
|
@ -4,6 +4,8 @@ package autotype
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"github.com/godbus/dbus/v5"
|
||||
@ -16,6 +18,47 @@ const autoTypeDelay = 1 * time.Millisecond
|
||||
|
||||
var log = logging.GetLogger("Goldwarden", "Autotype")
|
||||
|
||||
// todo need to store this encrypted. will be done when migrating this file to python
|
||||
func persistToken(token string) error {
|
||||
tokenPath := ""
|
||||
userHome, err := os.UserHomeDir()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if _, err := os.Stat("/.flatpak-info"); err == nil {
|
||||
tokenPath = userHome + "/.var/app/com.quexten.Goldwarden/config/autotype_token.txt"
|
||||
} else {
|
||||
tokenPath = userHome + "/.config/goldwarden/autotype_token.txt"
|
||||
}
|
||||
|
||||
err = ioutil.WriteFile(tokenPath, []byte(token), 0644)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func readToken() (string, error) {
|
||||
tokenPath := ""
|
||||
userHome, err := os.UserHomeDir()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
if _, err := os.Stat("/.flatpak-info"); err == nil {
|
||||
tokenPath = userHome + "/.var/app/com.quexten.Goldwarden/config/autotype_token.txt"
|
||||
} else {
|
||||
tokenPath = userHome + "/.config/goldwarden/autotype_token.txt"
|
||||
}
|
||||
|
||||
token, err := ioutil.ReadFile(tokenPath)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return string(token), nil
|
||||
}
|
||||
|
||||
func TypeString(textToType string) {
|
||||
log.Info("Starting to Type String")
|
||||
bus, err := dbus.SessionBus()
|
||||
@ -49,9 +92,16 @@ func TypeString(textToType string) {
|
||||
result := message.Body[1].(map[string]dbus.Variant)
|
||||
resultSessionHandle := result["session_handle"]
|
||||
sessionHandle = dbus.ObjectPath(resultSessionHandle.String()[1 : len(resultSessionHandle.String())-1])
|
||||
res := obj.Call("org.freedesktop.portal.RemoteDesktop.SelectDevices", 0, sessionHandle, map[string]dbus.Variant{
|
||||
"types": dbus.MakeVariant(uint32(1)),
|
||||
})
|
||||
options := map[string]dbus.Variant{
|
||||
"types": dbus.MakeVariant(uint32(1)),
|
||||
"persist_mode": dbus.MakeVariant(uint32(2)),
|
||||
}
|
||||
if token, err := readToken(); err == nil {
|
||||
log.Info("Restoring token, no confirmation prompt")
|
||||
options["restore_token"] = dbus.MakeVariant(token)
|
||||
}
|
||||
|
||||
res := obj.Call("org.freedesktop.portal.RemoteDesktop.SelectDevices", 0, sessionHandle, options)
|
||||
if res.Err != nil {
|
||||
log.Error("Error selecting devices: %s", res.Err.Error())
|
||||
}
|
||||
@ -64,6 +114,19 @@ func TypeString(textToType string) {
|
||||
}
|
||||
state = 2
|
||||
case 2:
|
||||
// try to cast to interface array
|
||||
if len(message.Body) == 2 {
|
||||
if resMap, ok := message.Body[1].(map[string]dbus.Variant); ok {
|
||||
// check if restore token in response
|
||||
if restoreToken, ok := resMap["restore_token"]; ok {
|
||||
token := restoreToken.Value().(string)
|
||||
if err := persistToken(token); err != nil {
|
||||
log.Error("Error persisting token: %s", err.Error())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
log.Info("Performing Typing")
|
||||
time.Sleep(1000 * time.Millisecond)
|
||||
for _, char := range textToType {
|
||||
|
@ -126,21 +126,26 @@ func detectAndInstallBrowsers(startPath string) error {
|
||||
fmt.Printf("Found mozilla-like browser: %s\n", path)
|
||||
|
||||
fmt.Println("Removing old manifest and proxy script")
|
||||
err = os.Chown(path+"/com.8bit.bitwarden.json", 7, 7)
|
||||
if err != nil {
|
||||
return err
|
||||
if _, err := os.Stat(path + "/com.8bit.bitwarden.json"); err == nil {
|
||||
err = os.Chmod(path+"/com.8bit.bitwarden.json", 755)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = os.Remove(path + "/com.8bit.bitwarden.json")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
err = os.Remove(path + "/com.8bit.bitwarden.json")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = os.Chown(path+"/goldwarden-proxy.sh", 7, 7)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = os.Remove(path + "/goldwarden-proxy.sh")
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
if _, err := os.Stat(path + "/goldwarden-proxy.sh"); err == nil {
|
||||
err = os.Chmod(path+"/goldwarden-proxy.sh", 755)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = os.Remove(path + "/goldwarden-proxy.sh")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
fmt.Println("Writing new manifest")
|
||||
@ -159,21 +164,26 @@ func detectAndInstallBrowsers(startPath string) error {
|
||||
fmt.Printf("Found chrome-like browser: %s\n", path)
|
||||
|
||||
fmt.Println("Removing old manifest and proxy script")
|
||||
err = os.Chown(path+"/com.8bit.bitwarden.json", 7, 7)
|
||||
if err != nil {
|
||||
return err
|
||||
if _, err := os.Stat(path + "/com.8bit.bitwarden.json"); err == nil {
|
||||
err = os.Chmod(path+"/com.8bit.bitwarden.json", 755)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = os.Remove(path + "/com.8bit.bitwarden.json")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
err = os.Remove(path + "/com.8bit.bitwarden.json")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = os.Chown(path+"/goldwarden-proxy.sh", 7, 7)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = os.Remove(path + "/goldwarden-proxy.sh")
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
if _, err := os.Stat(path + "/goldwarden-proxy.sh"); err == nil {
|
||||
err = os.Chmod(path+"/goldwarden-proxy.sh", 755)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = os.Remove(path + "/goldwarden-proxy.sh")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
fmt.Println("Writing new manifest")
|
||||
|
@ -36,6 +36,7 @@
|
||||
<developer_name>Bernd Schoolmann</developer_name>
|
||||
<update_contact>mail@quexten.com</update_contact>
|
||||
<releases>
|
||||
<release version="0.2.15" date="2024-04-29"/>
|
||||
<release version="0.2.14" date="2024-04-28"/>
|
||||
<release version="0.2.13" date="2024-02-23"/>
|
||||
<release version="0.2.12" date="2024-02-17"/>
|
||||
|
@ -55,7 +55,7 @@ def request_autostart():
|
||||
|
||||
request_autostart()
|
||||
|
||||
thread = Timer(10, os._exit, [0])
|
||||
thread = Timer(10, sys.exit, [0])
|
||||
thread.start()
|
||||
|
||||
loop = GLib.MainLoop()
|
||||
|
Loading…
Reference in New Issue
Block a user