diff --git a/handle/yggdrasil/user.go b/handle/yggdrasil/user.go index 9da6039..d025f3c 100644 --- a/handle/yggdrasil/user.go +++ b/handle/yggdrasil/user.go @@ -177,3 +177,25 @@ func (y *Yggdrasil) BatchProfile() httprouter.Handle { w.Write(lo.Must1(json.Marshal(ul))) } } + +func (y *Yggdrasil) PlayerCertificates() httprouter.Handle { + return func(w http.ResponseWriter, r *http.Request, p httprouter.Params) { + ctx := r.Context() + token := y.getTokenbyAuthorization(ctx, w, r) + if token == "" { + return + } + c, err := y.yggdrasilService.PlayerCertificates(ctx, token) + if err != nil { + if errors.Is(err, sutils.ErrTokenInvalid) { + y.logger.DebugContext(ctx, err.Error()) + handleYgError(ctx, w, yggdrasil.Error{ErrorMessage: "Invalid token.", Error: "ForbiddenOperationException"}, 403) + return + } + y.logger.WarnContext(ctx, err.Error()) + handleYgError(ctx, w, yggdrasil.Error{ErrorMessage: err.Error()}, 500) + return + } + w.Write(lo.Must(json.Marshal(c))) + } +} diff --git a/server/route/route.go b/server/route/route.go index 1644b41..1e02075 100644 --- a/server/route/route.go +++ b/server/route/route.go @@ -37,6 +37,8 @@ func newYggdrasil(r *httprouter.Router, handelY yggdrasil.Yggdrasil) error { r.POST("/api/yggdrasil/sessionserver/session/minecraft/join", warpHJSON(handelY.SessionJoin())) r.GET("/api/yggdrasil/sessionserver/session/minecraft/hasJoined", warpHJSON(handelY.SessionJoin())) + r.POST("/api/yggdrasil/minecraftservices/player/certificates", warpHJSON(handelY.PlayerCertificates())) + r.GET("/api/yggdrasil", warpHJSON(handelY.YggdrasilRoot())) return nil }