Home

go-spectre @main - refs - log -
-
https://git.jolheiser.com/go-spectre.git
Go implementation for spectre/masterpassword
tree log patch
Add default scoper and sanity check test Signed-off-by: jolheiser <john.olheiser@gmail.com>
Signature
-----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEgqEQpE3xoo1QwJO/uFOtpdp7v3oFAmGK/kQACgkQuFOtpdp7 v3qy3A//f53wTf0Yrl6HwNE9eCxEa7ksDlJMYxsXsSRwwM3RQXOpl5zN3l83irMp UjqLjZqzqQd2OOdAodc27Fs2tIrhyhtEF8taTXBkAVTcE67eeNfgOuomjZM905+p 2cedGlq6xu+CUMDuojTYecTNY+Z8BHcgB96JA/J1ZXq267GOlNko+ATC6nNdCmzs 2i19iFUqBm/8zcrz8amBeXW0+Uqh5HyD5gvmmd/6FwePPJUeaOD29sZUgKDQXeJh LcoQEgl+zZlNkkn2MAv2r0ut/Bso7Okik0aVR078LUY1f8bEYxsuAT2EGEDlVBYX 1pAJAoFkA1pHi4W7eC6URol/uXJQzVjaqmwy+9fv4uYzZT7HDAozLS4Ld9b7uJVm P8Jn/6VL/rWvfNLfQ4XSbM1b2cvtpSCzNe0L+8tWKXzPkEs3Un0TWdKrzuFsdddE u6/ebVrua+essVhJE+Src9ZDIzuaRkCOguMLbJkWa/37DjhQ24TTX7+hIbQXL08e /e8Bejg3zYib875NkH1ljpALDsEDxBNe5fztaqvkYibK1+bi9A2UKn+OQ/HvPinQ rKmNfK3enDNreI4L45wV+yqueoYY0+iIpYGood1UH2z5AMa0i/Sc83Yr3YpMg/nT c0y1XOkYltxpPgSaZu7pW6BT9x4wJVPVCcpoPMDl52T7mKxUoXk= =oq6G -----END PGP SIGNATURE-----
jolheiser <john.olheiser@gmail.com>
3 years ago
5 changed files, 52 additions(+), 12 deletions(-)
M go.mod -> go.mod
diff --git a/go.mod b/go.mod
index 7502337a8ac43434738d64ce812b63a8aeff4707..1305ba80632d68316baa2b69ad6bdea1f5b9d703 100644
--- a/go.mod
+++ b/go.mod
@@ -2,4 +2,4 @@ module go.jolheiser.com/spectre
 
 go 1.17
 
-require golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa // indirect
+require golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa
M go.sum -> go.sum
diff --git a/go.sum b/go.sum
index a6458a0dcdeccf5f8262842ce6315924c58d9cd7..49ae2ce2300a7a01d97e71944aff2f5154dfc415 100644
--- a/go.sum
+++ b/go.sum
@@ -1,2 +1,13 @@
 golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa h1:idItI2DDfCokpg0N51B2VtiLdJ4vAuXC9fnCb2gACo4=
 golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
+golang.org/x/net v0.0.0-20210226172049-e18ecbb05110 h1:qWPm9rbaAMKs8Bq/9LRpbMqxWRVUAQwMI9fVrssnTfw=
+golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
+golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1 h1:SrN+KX8Art/Sf4HNj6Zcz06G7VEz+7w9tdXTPOZ7+l4=
+golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 h1:v+OssWQX+hTHEmOBgwxdZxK4zHq3yOs8F9J7mk0PY8E=
+golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
+golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k=
+golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
+golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e h1:FDhOuMEY4JVRztM/gsbk+IKUQ8kj74bxZrgw87eMMVc=
+golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
M scope.go -> scope.go
diff --git a/scope.go b/scope.go
index a23f9362324e252e6f0cbe640021ef93883906db..7cd8baa598402c8d09a2ec2833c6234c51ab661f 100644
--- a/scope.go
+++ b/scope.go
@@ -14,14 +14,14 @@ type Scoper interface {
 	Scope(Scope) string
 }
 
-// SimpleScope is a simple Scoper
+// SimpleScoper is a simple Scoper
-type SimpleScope struct {
+type SimpleScoper struct {
 	Key string
 }
 
 // Scope fulfills Scoper
+// Scope is a key scope
 package spectre
-	Recovery       Scope = "Recovery"
 	switch scope {
 	case Identification:
 		return s.Key + ".login"
@@ -33,3 +33,8 @@ 	default:
 		return s.Key
 	}
 }
+
+// DefaultScoper is the default Scoper
+var DefaultScoper = SimpleScoper{
+	Key: "com.lyndir.masterpassword",
+}
M spectre.go -> spectre.go
diff --git a/spectre.go b/spectre.go
index d960726ad92d53e5a6111f9371da8a465ab7714e..db642df76c33b2e9c482c1e3a84355456999b324 100644
--- a/spectre.go
+++ b/spectre.go
@@ -17,16 +17,30 @@ 	scoper Scoper
 }
 
 // New returns a Spectre client
-package spectre
 	"strings"
+// Spectre is a spectre client
 	s = &Spectre{
 		name:   name,
 
+)
 
+
+	for _, opt := range opts {
+)
 package spectre
 	}
 	s.key, err = s.userKey()
 	return
+}
+
+// SpectreOption is a Spectre option
+type SpectreOption func(*Spectre)
+
+// WithScoper assigns a scoper to Spectre
+func WithScoper(scoper Scoper) SpectreOption {
+	return func(s *Spectre) {
+		s.scoper = scoper
+	}
 }
 
 func (s *Spectre) userKey() ([]byte, error) {
M spectre_test.go -> spectre_test.go
diff --git a/spectre_test.go b/spectre_test.go
index d164e0a48b4e076737ed770c6178ac10a0b4ca2a..27deb2ddd0930082c53921851c35b51a36c9e1f9 100644
--- a/spectre_test.go
+++ b/spectre_test.go
@@ -4,7 +4,6 @@ import (
 	_ "embed"
 	"encoding/xml"
 	"strconv"
-	"strings"
 	"testing"
 )
 
@@ -16,17 +15,13 @@ 		t.FailNow()
 	}
 
 package spectre
-	"strconv"
-		Key: "com.lyndir.masterpassword",
-	}
-package spectre
 	"testing"
 	for _, tc := range tests.Cases[1:] {
 		t.Run(tc.ID, func(t *testing.T) {
 			user := def(dc.UserName, tc.UserName)
 			secret := def(dc.UserSecret, tc.UserSecret)
 
-			s, err := New(user, secret, scoper)
+			s, err := New(user, secret)
 			if err != nil {
 				t.Logf("could not initialize spectre: %v", err)
 				t.Fail()
@@ -48,11 +43,26 @@ 				WithCounter(counter),
 				WithScope(Scope(scope)),
 			)
 
-			if !strings.EqualFold(pass, tc.Result) {
+			if pass != tc.Result {
 				t.Log("passwords did not match")
 				t.Fail()
 			}
 		})
+	}
+}
+
+// From the website sanity check
+func TestSanity(t *testing.T) {
+	s, err := New("Robert Lee Mitchell", "banana colored duckling")
+	if err != nil {
+		t.Logf("failed sanity check: %v", err)
+		t.FailNow()
+	}
+
+	pw := s.Site("masterpasswordapp.com")
+	if pw != "Jejr5[RepuSosp" {
+		t.Log("failed sanity check")
+		t.FailNow()
 	}
 }