aboutsummaryrefslogtreecommitdiff
path: root/client.go
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2015-11-27 14:42:12 +0100
committerDimitri Sokolyuk <demon@dim13.org>2015-11-27 14:42:12 +0100
commit0456617941c2508cf128a04ebfb58c8d2169586f (patch)
treef1cb94f64af003e05ddf4972f93f23ed7ccc35e8 /client.go
parent6c0b2240d3d53621e0b145b1bd1b79a3826e3485 (diff)
WIP
Diffstat (limited to 'client.go')
-rw-r--r--client.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/client.go b/client.go
index 8759ad1..8f7138a 100644
--- a/client.go
+++ b/client.go
@@ -6,6 +6,8 @@ import (
"io/ioutil"
"log"
"net/http"
+
+ jose "github.com/square/go-jose"
)
func Get(uri string, v interface{}) error {
@@ -36,3 +38,29 @@ func Post(uri string, v interface{}) error {
}
return nil
}
+
+type Z struct{}
+
+func (Z) Nonce() (string, error) { return "test", nil }
+
+func Sign(acc Account, body []byte) (string, error) {
+ signer, err := jose.NewSigner(jose.RS256, acc.PrivKey)
+ signer.SetNonceSource(Z{})
+ if err != nil {
+ return "", err
+ }
+ obj, err := signer.Sign(body)
+ if err != nil {
+ return "", err
+ }
+ return obj.FullSerialize(), nil
+}
+
+func ParseSigned(body string) error {
+ obj, err := jose.ParseSigned(body)
+ if err != nil {
+ return err
+ }
+ log.Printf("%+v\n", obj)
+ return nil
+}