Fixed helper functions
This commit is contained in:
parent
0d65ad45bb
commit
27909c4984
2
go.mod
2
go.mod
|
@ -3,7 +3,7 @@ module git.ailur.dev/ailur/fg-nucleus-library
|
||||||
go 1.23.3
|
go 1.23.3
|
||||||
|
|
||||||
require (
|
require (
|
||||||
git.ailur.dev/ailur/fg-library/v3 v3.5.0
|
git.ailur.dev/ailur/fg-library/v3 v3.6.2
|
||||||
github.com/google/uuid v1.6.0
|
github.com/google/uuid v1.6.0
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
2
go.sum
2
go.sum
|
@ -1,5 +1,7 @@
|
||||||
git.ailur.dev/ailur/fg-library/v3 v3.5.0 h1:BGDlS4nQ2PyZWNU4gH3eckVqhZUFIM/zKIj/HXx8RmA=
|
git.ailur.dev/ailur/fg-library/v3 v3.5.0 h1:BGDlS4nQ2PyZWNU4gH3eckVqhZUFIM/zKIj/HXx8RmA=
|
||||||
git.ailur.dev/ailur/fg-library/v3 v3.5.0/go.mod h1:ArNsafpqES2JuxQM5aM+bNe0FwHLIsL6pbjpiWvDwGs=
|
git.ailur.dev/ailur/fg-library/v3 v3.5.0/go.mod h1:ArNsafpqES2JuxQM5aM+bNe0FwHLIsL6pbjpiWvDwGs=
|
||||||
|
git.ailur.dev/ailur/fg-library/v3 v3.6.2 h1:PNJKxpvbel2iDeB9+/rpYRyMoim6JjRHOXPYFYky7Ng=
|
||||||
|
git.ailur.dev/ailur/fg-library/v3 v3.6.2/go.mod h1:ArNsafpqES2JuxQM5aM+bNe0FwHLIsL6pbjpiWvDwGs=
|
||||||
github.com/go-chi/chi/v5 v5.2.0 h1:Aj1EtB0qR2Rdo2dG4O94RIU35w2lvQSj6BRA4+qwFL0=
|
github.com/go-chi/chi/v5 v5.2.0 h1:Aj1EtB0qR2Rdo2dG4O94RIU35w2lvQSj6BRA4+qwFL0=
|
||||||
github.com/go-chi/chi/v5 v5.2.0/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8=
|
github.com/go-chi/chi/v5 v5.2.0/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8=
|
||||||
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||||
|
|
11
main.go
11
main.go
|
@ -2,6 +2,7 @@ package library
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/ed25519"
|
"crypto/ed25519"
|
||||||
|
"fmt"
|
||||||
library "git.ailur.dev/ailur/fg-library/v3"
|
library "git.ailur.dev/ailur/fg-library/v3"
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"time"
|
"time"
|
||||||
|
@ -36,7 +37,7 @@ var (
|
||||||
OAuthService = uuid.MustParse("00000000-0000-0000-0000-000000000004")
|
OAuthService = uuid.MustParse("00000000-0000-0000-0000-000000000004")
|
||||||
)
|
)
|
||||||
|
|
||||||
func OAuthSignup(oauth OAuthInformation, information library.ServiceInitializationInformation) (OAuthResponse, error) {
|
func OAuthSignup(oauth OAuthInformation, information *library.ServiceInitializationInformation) (OAuthResponse, error) {
|
||||||
message, err := information.SendAndAwaitISMessage(OAuthService, 1, oauth, time.Second*3)
|
message, err := information.SendAndAwaitISMessage(OAuthService, 1, oauth, time.Second*3)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return OAuthResponse{}, err
|
return OAuthResponse{}, err
|
||||||
|
@ -46,7 +47,7 @@ func OAuthSignup(oauth OAuthInformation, information library.ServiceInitializati
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetPublicKey(information library.ServiceInitializationInformation) (ed25519.PublicKey, error) {
|
func GetPublicKey(information *library.ServiceInitializationInformation) (ed25519.PublicKey, error) {
|
||||||
message, err := information.SendAndAwaitISMessage(OAuthService, 2, nil, time.Second*3)
|
message, err := information.SendAndAwaitISMessage(OAuthService, 2, nil, time.Second*3)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -55,7 +56,7 @@ func GetPublicKey(information library.ServiceInitializationInformation) (ed25519
|
||||||
return message.Message.(ed25519.PublicKey), nil
|
return message.Message.(ed25519.PublicKey), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetOAuthHostname(information library.ServiceInitializationInformation) (string, error) {
|
func GetOAuthHostname(information *library.ServiceInitializationInformation) (string, error) {
|
||||||
message, err := information.SendAndAwaitISMessage(OAuthService, 0, nil, time.Second*3)
|
message, err := information.SendAndAwaitISMessage(OAuthService, 0, nil, time.Second*3)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
|
@ -64,11 +65,13 @@ func GetOAuthHostname(information library.ServiceInitializationInformation) (str
|
||||||
return message.Message.(string), nil
|
return message.Message.(string), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func InitializeOAuth(oauth OAuthInformation, information library.ServiceInitializationInformation) (oauthResponse OAuthResponse, pk ed25519.PublicKey, hostname string, err error) {
|
func InitializeOAuth(oauth OAuthInformation, information *library.ServiceInitializationInformation) (oauthResponse OAuthResponse, pk ed25519.PublicKey, hostname string, err error) {
|
||||||
|
fmt.Println("Initializing OAuth")
|
||||||
pk, err = GetPublicKey(information)
|
pk, err = GetPublicKey(information)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
hostname, err = GetOAuthHostname(information)
|
hostname, err = GetOAuthHostname(information)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in New Issue