Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
223 additions
and
136 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package commands | ||
|
||
import ( | ||
"fmt" | ||
"github.com/daveio/gotp/otputils" | ||
"github.com/daveio/gotp/storage" | ||
) | ||
|
||
func Generate(keychain storage.Keychain, site string, uid string) { | ||
secretKey, err := storage.GetSecret(keychain, site, uid) | ||
if err == nil { | ||
if uid == "__default" { | ||
fmt.Printf("%s : ", site) | ||
} else { | ||
fmt.Printf("%s @ %s : ", uid, site) | ||
} | ||
fmt.Printf("%s\n", otputils.GenerateOTP(secretKey)) | ||
} else { | ||
fmt.Printf("%s", err) | ||
} | ||
} | ||
|
||
func Store(keychain storage.Keychain, site string, key string, uid string) { | ||
storage.StoreSecret(keychain, site, key, uid) | ||
} | ||
|
||
func Delete(keychain storage.Keychain, site string, uid string) { | ||
_ = keychain | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package errors | ||
|
||
import "fmt" | ||
|
||
func (e *UidError) Error() string { | ||
return fmt.Sprintf("UID %s not found for site %s", e.Site, e.Uid) | ||
} | ||
|
||
func (e *SiteError) Error() string { | ||
return fmt.Sprintf("Site %s not found", e.Site) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package errors | ||
|
||
type SiteError struct { | ||
Site string | ||
} | ||
|
||
type UidError struct { | ||
Site string | ||
Uid string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.