Fix Invisible Character in lobby.

This commit is contained in:
eccentric 2023-11-09 18:42:28 +00:00
parent f54644e3e9
commit 5237402c5e
6 changed files with 1391 additions and 1231 deletions

View File

@ -110,56 +110,56 @@ func PostOAuthTokenPassword(c *fiber.Ctx, body *OAuthTokenBody) error {
func GetOAuthVerify(c *fiber.Ctx) error {
auth := c.Get("Authorization")
if auth == "" {
return c.Status(fiber.StatusBadRequest).JSON(aid.ErrorBadRequest("Authorization Header is empty"))
return c.Status(fiber.StatusForbidden).JSON(aid.ErrorBadRequest("Authorization Header is empty"))
}
real := strings.ReplaceAll(auth, "bearer eg1~", "")
claims, err := aid.JWTVerify(real)
if err != nil {
return c.Status(fiber.StatusBadRequest).JSON(aid.ErrorBadRequest("Invalid Access Token"))
return c.Status(fiber.StatusForbidden).JSON(aid.ErrorBadRequest("Invalid Access Token"))
}
if claims["snow_id"] == nil {
return c.Status(fiber.StatusBadRequest).JSON(aid.ErrorBadRequest("Invalid Access Token"))
return c.Status(fiber.StatusForbidden).JSON(aid.ErrorBadRequest("Invalid Access Token"))
}
snowId, ok := claims["snow_id"].(string)
if !ok {
return c.Status(fiber.StatusBadRequest).JSON(aid.ErrorBadRequest("Invalid Access Token"))
return c.Status(fiber.StatusForbidden).JSON(aid.ErrorBadRequest("Invalid Access Token"))
}
person := p.Find(snowId)
if person == nil {
return c.Status(fiber.StatusBadRequest).JSON(aid.ErrorBadRequest("Invalid Access Token"))
return c.Status(fiber.StatusForbidden).JSON(aid.ErrorBadRequest("Invalid Access Token"))
}
return c.SendStatus(fiber.StatusNoContent)
return c.SendStatus(fiber.StatusOK)
}
func MiddlewareOAuthVerify(c *fiber.Ctx) error {
auth := c.Get("Authorization")
if auth == "" {
return c.Status(fiber.StatusBadRequest).JSON(aid.ErrorBadRequest("Authorization Header is empty"))
return c.Status(fiber.StatusForbidden).JSON(aid.ErrorBadRequest("Authorization Header is empty"))
}
real := strings.ReplaceAll(auth, "bearer eg1~", "")
claims, err := aid.JWTVerify(real)
if err != nil {
return c.Status(fiber.StatusBadRequest).JSON(aid.ErrorBadRequest("Invalid Access Token"))
return c.Status(fiber.StatusForbidden).JSON(aid.ErrorBadRequest("Invalid Access Token"))
}
if claims["snow_id"] == nil {
return c.Status(fiber.StatusBadRequest).JSON(aid.ErrorBadRequest("Invalid Access Token"))
return c.Status(fiber.StatusForbidden).JSON(aid.ErrorBadRequest("Invalid Access Token"))
}
snowId, ok := claims["snow_id"].(string)
if !ok {
return c.Status(fiber.StatusBadRequest).JSON(aid.ErrorBadRequest("Invalid Access Token"))
return c.Status(fiber.StatusForbidden).JSON(aid.ErrorBadRequest("Invalid Access Token"))
}
person := p.Find(snowId)
if person == nil {
return c.Status(fiber.StatusBadRequest).JSON(aid.ErrorBadRequest("Invalid Access Token"))
return c.Status(fiber.StatusForbidden).JSON(aid.ErrorBadRequest("Invalid Access Token"))
}
c.Locals("person", person)
@ -180,9 +180,33 @@ func GetPublicAccount(c *fiber.Ctx) error {
return c.Status(fiber.StatusOK).JSON(aid.JSON{
"id": person.ID,
"displayName": person.DisplayName,
"externalAuths": []aid.JSON{},
})
}
func GetPublicAccounts(c *fiber.Ctx) error {
response := []aid.JSON{}
accountIds := c.Request().URI().QueryArgs().PeekMulti("accountId")
for _, accountIdSlice := range accountIds {
person := p.Find(string(accountIdSlice))
if person == nil {
continue
}
response = append(response, aid.JSON{
"id": person.ID,
"displayName": person.DisplayName,
"externalAuths": []aid.JSON{},
})
}
aid.PrintJSON(accountIds)
aid.PrintJSON(response)
return c.Status(fiber.StatusOK).JSON(response)
}
func GetPublicAccountExternalAuths(c *fiber.Ctx) error {
person := p.Find(c.Params("accountId"))
if person == nil {
@ -190,4 +214,17 @@ func GetPublicAccountExternalAuths(c *fiber.Ctx) error {
}
return c.Status(fiber.StatusOK).JSON([]aid.JSON{})
}
func GetPublicAccountByDisplayName(c *fiber.Ctx) error {
person := p.FindByDisplay(c.Params("displayName"))
if person == nil {
return c.Status(fiber.StatusBadRequest).JSON(aid.ErrorBadRequest("No Account Found"))
}
return c.Status(fiber.StatusOK).JSON(aid.JSON{
"id": person.ID,
"displayName": person.DisplayName,
"externalAuths": []aid.JSON{},
})
}

File diff suppressed because it is too large Load Diff

13
main.go
View File

@ -64,14 +64,15 @@ func main() {
r.Get("/content/api/pages/fortnite-game", handlers.GetContentPages)
account := r.Group("/account/api")
account.Get("/public/account", handlers.GetPublicAccounts)
account.Get("/public/account/:accountId", handlers.GetPublicAccount)
account.Get("/public/account/:accountId/externalAuths", handlers.GetPublicAccountExternalAuths)
account.Get("/public/account/displayName/:displayName", handlers.GetPublicAccountByDisplayName)
account.Get("/oauth/verify", handlers.GetOAuthVerify)
account.Post("/oauth/token", handlers.PostOAuthToken)
account.Delete("/oauth/sessions/kill", handlers.DeleteOAuthSessions)
fortnite := r.Group("/fortnite/api")
fortnite.Use(handlers.MiddlewareOAuthVerify)
fortnite.Get("/receipts/v1/account/:accountId/receipts", handlers.GetFortniteReceipts)
fortnite.Get("/v2/versioncheck/*", handlers.GetFortniteVersion)
fortnite.Get("/calendar/v1/timeline", handlers.GetFortniteTimeline)
@ -88,12 +89,14 @@ func main() {
storage.Get("/system", handlers.GetCloudStorageFiles)
storage.Get("/system/config", handlers.GetCloudStorageConfig)
storage.Get("/system/:fileName", handlers.GetCloudStorageFile)
storage.Get("/user/:accountId", handlers.GetUserStorageFiles)
storage.Get("/user/:accountId/:fileName", handlers.GetUserStorageFile)
storage.Put("/user/:accountId/:fileName", handlers.PutUserStorageFile)
user := storage.Group("/user")
user.Use(handlers.MiddlewareOAuthVerify)
user.Get("/:accountId", handlers.GetUserStorageFiles)
user.Get("/:accountId/:fileName", handlers.GetUserStorageFile)
user.Put("/:accountId/:fileName", handlers.PutUserStorageFile)
game := fortnite.Group("/game/v2")
game.Use(handlers.MiddlewareOAuthVerify)
game.Get("/enabled_features", handlers.GetGameEnabledFeatures)
game.Post("/tryPlayOnPlatform/account/:accountId", handlers.PostGamePlatform)
game.Post("/grant_access/:accountId", handlers.PostGameAccess)

View File

@ -1 +0,0 @@
{}

View File

@ -6,12 +6,12 @@ import (
)
var (
//go:embed assets/*
//go:embed mem/*
Assets embed.FS
)
func Asset(file string) (*[]byte) {
data, err := Assets.ReadFile("assets/" + strings.ToLower(file))
data, err := Assets.ReadFile("mem/" + strings.ToLower(file))
if err != nil {
return nil
}

1210
storage/mem/keychain.json Normal file

File diff suppressed because it is too large Load Diff