Skip to content

Commit

Permalink
Fixes to Go backend (RELEASEPATCH)
Browse files Browse the repository at this point in the history
  • Loading branch information
bravecorvus committed Nov 5, 2021
1 parent dc3cea1 commit d05ad74
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 19 deletions.
2 changes: 1 addition & 1 deletion frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "voiceit2-web-sdk",
"version": "1.5.10",
"version": "1.5.11",
"scripts": {
"start": "node src/index.js",
"build": "./node_modules/webpack/bin/webpack.js"
Expand Down
2 changes: 1 addition & 1 deletion node-server-example/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion node-server-example/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "node-server-example",
"version": "1.5.10",
"version": "1.5.11",
"description": "Node Web SDK Example",
"main": "server.js",
"scripts": {
Expand Down
3 changes: 3 additions & 0 deletions voiceit-go-websdk/liveness_server_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ type GenerateLCORequestReturn struct {
func (livenessServerClient LivenessServerClient) GenerateLCORequest(userId, contentLanguage string) ([]byte, error) {

req, err := http.NewRequest("GET", livenessServerClient.BaseUrl+"/v1/verification/"+userId+"/"+contentLanguage, nil)
if err != nil {
return []byte{}, errors.New(`http.NewRequest("GET", "` + livenessServerClient.BaseUrl + "/v1/verification/" + userId + "/" + contentLanguage + `", nil) Exception: ` + err.Error())
}

req.SetBasicAuth(livenessServerClient.APIKey, livenessServerClient.APIToken)

Expand Down
17 changes: 6 additions & 11 deletions voiceit-go-websdk/websdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
)

const (
platformVersion = "1.5.10"
platformVersion = "1.5.11"
platformId = "53"
)

Expand Down Expand Up @@ -133,13 +133,13 @@ func (websdk WebSDK) validateToken(tokenString string) (valid bool, userId strin

}

func (websdk WebSDK) MakeCall(w http.ResponseWriter, r *http.Request) (map[string]interface{}, error) {
func (websdk WebSDK) MakeCall(r *http.Request) (map[string]interface{}, error) {

res := make(map[string]interface{})

if err := r.ParseMultipartForm(32 << 20); err != nil {
log.Println("r.ParseMultipartForm(32 << 20) Exception: " + err.Error())
w.WriteHeader(http.StatusBadRequest)
// w.WriteHeader(http.StatusBadRequest)
// w.Write([]byte("r.ParseMultipartForm(32 << 20) Exception: " + err.Error()))
return res, errors.New("r.ParseMultipartForm(32 << 20) Exception: " + err.Error())
}
Expand All @@ -148,7 +148,7 @@ func (websdk WebSDK) MakeCall(w http.ResponseWriter, r *http.Request) (map[strin

if viRequestType == "" {
log.Println(`viRequestType == ""`)
w.WriteHeader(http.StatusBadRequest)
// w.WriteHeader(http.StatusBadRequest)
// w.Write([]byte("viRequestType not passed"))
return res, errors.New("viRequestType not passed")
}
Expand Down Expand Up @@ -193,11 +193,9 @@ func (websdk WebSDK) MakeCall(w http.ResponseWriter, r *http.Request) (map[strin
case "createVoiceEnrollment", "voiceVerification":
key = "viVoiceData"
extension = ".wav"
break
case "createFaceEnrollment", "createVideoEnrollment", "faceVerification", "faceVerificationWithLiveness", "videoVerificationWithLiveness", "videoVerification":
key = "viVideoData"
extension = ".mp4"
break
}

file, header, err := r.FormFile(key)
Expand Down Expand Up @@ -228,7 +226,7 @@ func (websdk WebSDK) MakeCall(w http.ResponseWriter, r *http.Request) (map[strin

// Make client request to API 2/Liveness Server
} else if viRequestType == "enoughVoiceEnrollments" || viRequestType == "enoughFaceEnrollments" || viRequestType == "enoughVideoEnrollments" {
return websdk.enoughEnrollments(w, viRequestType, userId)
return websdk.enoughEnrollments(res, viRequestType, userId)
// return
}

Expand Down Expand Up @@ -280,8 +278,7 @@ func (websdk WebSDK) MakeCall(w http.ResponseWriter, r *http.Request) (map[strin

}

func (websdk WebSDK) enoughEnrollments(w http.ResponseWriter, viRequestType, userId string) (map[string]interface{}, error) {
res := make(map[string]interface{})
func (websdk WebSDK) enoughEnrollments(res map[string]interface{}, viRequestType, userId string) (map[string]interface{}, error) {
switch viRequestType {
case "enoughVoiceEnrollments":
var voiceEnrollmentsResponse structs.GetAllVoiceEnrollmentsReturn
Expand All @@ -299,8 +296,6 @@ func (websdk WebSDK) enoughEnrollments(w http.ResponseWriter, viRequestType, use
log.Println(`json.Unmarshal([]byte("` + string(ret) + `"), &voiceEnrollmentsResponse) Exception: ` + err.Error())
res["responseCode"] = "BERR"
res["message"] = err.Error()
marshaled, _ := json.Marshal(res)
w.Write(marshaled)
return res, nil
}
ret, err = websdk.vi.GetAllVideoEnrollments(userId)
Expand Down
4 changes: 2 additions & 2 deletions voiceit-node-websdk/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion voiceit-node-websdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "voiceit-node-websdk",
"version": "1.5.10",
"version": "1.5.11",
"description": "NodeJS Backend for VoiceIt Web SDK",
"main": "index.js",
"author": "VoiceIt Technologies, LLC (C) 2020",
Expand Down
2 changes: 1 addition & 1 deletion voiceit-php-websdk/VoiceIt2WebBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function returnJson($jsonResponse){
class VoiceIt2WebBackend {
public $BASE_URL = 'https://api.voiceit.io';
public $LIVENESS_URL = 'https://liveness.voiceit.io/v1';
const VERSION = '1.5.10';
const VERSION = '1.5.11';
public $api_key;
public $platformId = '48';
public $notification_url = '';
Expand Down

0 comments on commit d05ad74

Please sign in to comment.