提高对第三方启动器的兼容性
This commit is contained in:
parent
5c590ac78f
commit
7624268b93
@ -7,10 +7,6 @@ type Pass struct {
|
||||
}
|
||||
|
||||
type Authenticate struct {
|
||||
Agent struct {
|
||||
Name string `json:"name" validate:"required,eq=Minecraft"`
|
||||
Version int `json:"version" validate:"required,eq=1"`
|
||||
} `json:"agent"`
|
||||
ClientToken string `json:"clientToken"`
|
||||
RequestUser bool `json:"requestUser"`
|
||||
Pass
|
||||
@ -23,7 +19,8 @@ type Error struct {
|
||||
}
|
||||
|
||||
type TokenUserID struct {
|
||||
ID string `json:"id"`
|
||||
ID string `json:"id"`
|
||||
Properties []any `json:"properties,omitempty"`
|
||||
}
|
||||
|
||||
type Token struct {
|
||||
|
@ -11,7 +11,7 @@ type UserTextures struct {
|
||||
ProfileName string `json:"profileName"`
|
||||
Textures map[string]Textures `json:"textures"`
|
||||
// 时间戳 毫秒
|
||||
Timestamp string `json:"timestamp"`
|
||||
Timestamp int64 `json:"timestamp"`
|
||||
}
|
||||
|
||||
type Textures struct {
|
||||
|
@ -40,6 +40,7 @@ func newYggdrasil(r *httprouter.Router, handelY yggdrasil.Yggdrasil) error {
|
||||
r.POST("/api/yggdrasil/minecraftservices/player/certificates", warpHJSON(handelY.PlayerCertificates()))
|
||||
|
||||
r.GET("/api/yggdrasil", warpHJSON(handelY.YggdrasilRoot()))
|
||||
r.GET("/api/yggdrasil/", warpHJSON(handelY.YggdrasilRoot()))
|
||||
|
||||
r.GET("/texture/*filepath", handelY.TextureAssets())
|
||||
return nil
|
||||
|
@ -104,7 +104,8 @@ func (y *Yggdrasil) Authenticate(cxt context.Context, auth yggdrasil.Authenticat
|
||||
ClientToken: clientToken,
|
||||
SelectedProfile: p,
|
||||
User: yggdrasil.TokenUserID{
|
||||
ID: utils.UUIDGen(strconv.Itoa(u.ID)),
|
||||
ID: utils.UUIDGen(strconv.Itoa(u.ID)),
|
||||
Properties: []any{},
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
@ -171,16 +172,16 @@ func (y *Yggdrasil) Refresh(ctx context.Context, token yggdrasil.RefreshToken) (
|
||||
if err != nil {
|
||||
return yggdrasil.Token{}, fmt.Errorf("Authenticate: %w", err)
|
||||
}
|
||||
u := yggdrasil.UserInfo{ID: up.UUID, Name: up.Name}
|
||||
|
||||
return yggdrasil.Token{
|
||||
AccessToken: jwts,
|
||||
ClientToken: t.CID,
|
||||
SelectedProfile: yggdrasil.UserInfo{
|
||||
ID: up.UUID,
|
||||
Name: up.Name,
|
||||
},
|
||||
AccessToken: jwts,
|
||||
AvailableProfiles: []yggdrasil.UserInfo{u},
|
||||
ClientToken: t.CID,
|
||||
SelectedProfile: u,
|
||||
User: yggdrasil.TokenUserID{
|
||||
ID: utils.UUIDGen(strconv.Itoa(t.UID)),
|
||||
ID: utils.UUIDGen(strconv.Itoa(t.UID)),
|
||||
Properties: []any{},
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
@ -209,7 +210,7 @@ func (y *Yggdrasil) GetProfile(ctx context.Context, uuid string, unsigned bool,
|
||||
ProfileID: up.UUID,
|
||||
ProfileName: up.Name,
|
||||
Textures: map[string]yggdrasil.Textures{},
|
||||
Timestamp: strconv.FormatInt(time.Now().UnixMilli(), 10),
|
||||
Timestamp: time.Now().UnixMilli(),
|
||||
}
|
||||
|
||||
for _, v := range up.Edges.Usertexture {
|
||||
@ -230,25 +231,31 @@ func (y *Yggdrasil) GetProfile(ctx context.Context, uuid string, unsigned bool,
|
||||
|
||||
texturesBase64 := ut.Base64()
|
||||
|
||||
var signStr string
|
||||
pl := []yggdrasil.UserProperties{}
|
||||
pl = append(pl, yggdrasil.UserProperties{
|
||||
Name: "textures",
|
||||
Value: texturesBase64,
|
||||
})
|
||||
pl = append(pl, yggdrasil.UserProperties{
|
||||
Name: "uploadableTextures",
|
||||
Value: "skin,cape",
|
||||
})
|
||||
|
||||
if !unsigned {
|
||||
s := sign.NewAuthlibSignWithKey(y.prikey)
|
||||
signStr, err = s.Sign([]byte(texturesBase64))
|
||||
if err != nil {
|
||||
return yggdrasil.UserInfo{}, fmt.Errorf("GetProfile: %w", err)
|
||||
for i, v := range pl {
|
||||
sign, err := s.Sign([]byte(v.Signature))
|
||||
if err != nil {
|
||||
return yggdrasil.UserInfo{}, fmt.Errorf("GetProfile: %w", ErrNotUser)
|
||||
}
|
||||
pl[i].Signature = sign
|
||||
}
|
||||
}
|
||||
|
||||
uinfo := yggdrasil.UserInfo{
|
||||
ID: up.UUID,
|
||||
Name: up.Name,
|
||||
Properties: []yggdrasil.UserProperties{
|
||||
{
|
||||
Name: "textures",
|
||||
Value: texturesBase64,
|
||||
Signature: signStr,
|
||||
},
|
||||
},
|
||||
ID: up.UUID,
|
||||
Name: up.Name,
|
||||
Properties: pl,
|
||||
}
|
||||
|
||||
return uinfo, nil
|
||||
|
Loading…
x
Reference in New Issue
Block a user