From d402c7650c90e996b94d809f0863024ca434d366 Mon Sep 17 00:00:00 2001 From: wregulski Date: Fri, 7 Jul 2023 06:32:30 +0200 Subject: [PATCH] feat: adds string definitions - errors and authentication consts --- authentication.go | 26 ++++++++++++++++++++++++++ errors_def.go | 7 +++++++ 2 files changed, 33 insertions(+) create mode 100644 authentication.go create mode 100644 errors_def.go diff --git a/authentication.go b/authentication.go new file mode 100644 index 0000000..8ebdbbe --- /dev/null +++ b/authentication.go @@ -0,0 +1,26 @@ +package buxmodels + +import "time" + +const ( + // AuthHeader is the header to use for authentication (raw xPub) + AuthHeader = "bux-auth-xpub" + + // AuthAccessKey is the header to use for access key authentication (access public key) + AuthAccessKey = "bux-auth-key" + + // AuthSignature is the given signature (body + timestamp) + AuthSignature = "bux-auth-signature" + + // AuthHeaderHash hash of the body coming from the request + AuthHeaderHash = "bux-auth-hash" + + // AuthHeaderNonce random nonce for the request + AuthHeaderNonce = "bux-auth-nonce" + + // AuthHeaderTime the time of the request, only valid for 30 seconds + AuthHeaderTime = "bux-auth-time" + + // AuthSignatureTTL is the max TTL for a signature to be valid + AuthSignatureTTL = 20 * time.Second +) diff --git a/errors_def.go b/errors_def.go new file mode 100644 index 0000000..cbf9c87 --- /dev/null +++ b/errors_def.go @@ -0,0 +1,7 @@ +package buxmodels + +import "errors" + +var ErrDraftNotFound = errors.New("corresponding draft transaction not found") + +var ErrMissingXPriv = errors.New("missing xPriv key")