From da27488d539a2a7db01c83a6b13403c823d3c211 Mon Sep 17 00:00:00 2001 From: Lightspark Eng Date: Tue, 30 May 2023 17:45:19 -0700 Subject: [PATCH] Project import generated by Copybara. GitOrigin-RevId: 5b87e4b4983b1cc6ecbfb60e6844f719692fd6ac --- CHANGELOG.md | 3 +++ README.md | 4 ++-- requester/requester.go | 10 +++++++--- version.go | 2 +- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e131860..da96e15 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +# v0.1.4 +Use CSPRNG to generate nonce. + # v0.1.3 Add two functions for test mode. - CreateTestModeInvoice for creating an test invoice. diff --git a/README.md b/README.md index 40d4bdd..11b5d0e 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ -# Lightspark Go SDK - v0.1.3 +# Lightspark Go SDK - v0.1.4 The Lightspark Go SDK provides a convenient way to interact with the Lightspark services from applications written in the Go. -***WARNING: This SDK is in version 0.1.3 (active development). It means that its APIs may not be fully stable. Please expect that changes to the APIs may happen until we move to v1.0.0.*** +***WARNING: This SDK is in version 0.1.4 (active development). It means that its APIs may not be fully stable. Please expect that changes to the APIs may happen until we move to v1.0.0.*** ## Documentation diff --git a/requester/requester.go b/requester/requester.go index fe10a48..856896e 100644 --- a/requester/requester.go +++ b/requester/requester.go @@ -3,10 +3,11 @@ package requester import ( "bytes" + "crypto/rand" "encoding/json" "errors" "io/ioutil" - "math/rand" + "math/big" "net/http" "regexp" "runtime" @@ -39,8 +40,11 @@ func (r *Requester) ExecuteGraphql(query string, variables map[string]interface{ var nonce uint32 if signingKey != nil { - rand.Seed(time.Now().UnixNano()) - nonce = rand.Uint32() + randomBigInt, err := rand.Int(rand.Reader, big.NewInt(0xFFFFFFFF)) + if err != nil { + return nil, err + } + nonce = uint32(randomBigInt.Uint64()) } var expiresAt string diff --git a/version.go b/version.go index 39bdaa8..a8cbde6 100644 --- a/version.go +++ b/version.go @@ -1,3 +1,3 @@ package lightspark -const VERSION = "0.1.3" +const VERSION = "0.1.4"