Loading CHANGELOG.md +1 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ The format is based on [keep a changelog](http://keepachangelog.com) and this pr - Correct handling of `httpRequest` calls in the JavaScript runtime Nakama module. - Correct handling of `httpRequest` calls in the Lua runtime Nakama module. - Fix handling of users attempting to leave groups they're banned from. - Fix handling of optional parameters in JS runtime token generate function. ## [3.14.0] - 2022-10-14 ### Added Loading server/runtime_go_nakama.go +1 −1 Original line number Diff line number Diff line Loading @@ -395,10 +395,10 @@ func (n *RuntimeGoNakamaModule) AuthenticateSteam(ctx context.Context, token, us // @group authenticate // @summary Generate a Nakama session token from a user ID. // @param ctx(type=context.Context) The context object represents information about the server and requester. // @param userId(type=string) User ID to use to generate the token. // @param username(type=string, optional=true) The user's username. If left empty, one is generated. // @param expiresAt(type=int64, optional=true) UTC time in seconds when the token must expire. Defaults to server configured expiry time. // @param vars(type=map[string]string, optional=true) Extra information that will be bundled in the session token. // @return token(string) The Nakama session token. // @return validity(int64) The period for which the token remains valid. // @return create(bool) Value indicating if this account was just created or already existed. Loading server/runtime_javascript_nakama.go +10 −3 Original line number Diff line number Diff line Loading @@ -1668,6 +1668,7 @@ func (n *runtimeJavascriptNakamaModule) authenticateSteam(r *goja.Runtime) func( // @param userId(type=string) User ID to use to generate the token. // @param username(type=string, optional=true) The user's username. If left empty, one is generated. // @param expiresAt(type=number, optional=true) UTC time in seconds when the token must expire. Defaults to server configured expiry time. // @param vars(type={[key:string]:string}, optional=true) Extra information that will be bundled in the session token. // @return token(string) The Nakama session token. // @return validity(number) The period for which the token remains valid. // @return error(error) An optional error value if an error occurred. Loading @@ -1684,17 +1685,23 @@ func (n *runtimeJavascriptNakamaModule) authenticateTokenGenerate(r *goja.Runtim panic(r.NewTypeError("expects valid user id")) } username := getJsString(r, f.Argument(1)) var username string if f.Argument(1) != goja.Null() && f.Argument(1) != goja.Undefined() { username = getJsString(r, f.Argument(1)) } if username == "" { username = generateUsername() } exp := time.Now().UTC().Add(time.Duration(n.config.GetSession().TokenExpirySec) * time.Second).Unix() if f.Argument(2) != goja.Undefined() { if f.Argument(2) != goja.Null() && f.Argument(2) != goja.Undefined() { exp = getJsInt(r, f.Argument(2)) } vars := getJsStringMap(r, f.Argument(3)) var vars map[string]string if f.Argument(3) != goja.Null() && f.Argument(3) != goja.Undefined() { vars = getJsStringMap(r, f.Argument(3)) } token, exp := generateTokenWithExpiry(n.config.GetSession().EncryptionKey, userIDString, username, vars, exp) n.sessionCache.Add(uid, exp, token, 0, "") Loading server/runtime_lua_nakama.go +1 −0 Original line number Diff line number Diff line Loading @@ -2039,6 +2039,7 @@ func (n *RuntimeLuaNakamaModule) authenticateSteam(l *lua.LState) int { // @param userId(type=string) User ID to use to generate the token. // @param username(type=string, optional=true) The user's username. If left empty, one is generated. // @param expiresAt(type=number, optional=true) UTC time in seconds when the token must expire. Defaults to server configured expiry time. // @param vars(type=table, optional=true) Extra information that will be bundled in the session token. // @return token(string) The Nakama session token. // @return validity(number) The period for which the token remains valid. // @return error(error) An optional error value if an error occurred. Loading Loading
CHANGELOG.md +1 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ The format is based on [keep a changelog](http://keepachangelog.com) and this pr - Correct handling of `httpRequest` calls in the JavaScript runtime Nakama module. - Correct handling of `httpRequest` calls in the Lua runtime Nakama module. - Fix handling of users attempting to leave groups they're banned from. - Fix handling of optional parameters in JS runtime token generate function. ## [3.14.0] - 2022-10-14 ### Added Loading
server/runtime_go_nakama.go +1 −1 Original line number Diff line number Diff line Loading @@ -395,10 +395,10 @@ func (n *RuntimeGoNakamaModule) AuthenticateSteam(ctx context.Context, token, us // @group authenticate // @summary Generate a Nakama session token from a user ID. // @param ctx(type=context.Context) The context object represents information about the server and requester. // @param userId(type=string) User ID to use to generate the token. // @param username(type=string, optional=true) The user's username. If left empty, one is generated. // @param expiresAt(type=int64, optional=true) UTC time in seconds when the token must expire. Defaults to server configured expiry time. // @param vars(type=map[string]string, optional=true) Extra information that will be bundled in the session token. // @return token(string) The Nakama session token. // @return validity(int64) The period for which the token remains valid. // @return create(bool) Value indicating if this account was just created or already existed. Loading
server/runtime_javascript_nakama.go +10 −3 Original line number Diff line number Diff line Loading @@ -1668,6 +1668,7 @@ func (n *runtimeJavascriptNakamaModule) authenticateSteam(r *goja.Runtime) func( // @param userId(type=string) User ID to use to generate the token. // @param username(type=string, optional=true) The user's username. If left empty, one is generated. // @param expiresAt(type=number, optional=true) UTC time in seconds when the token must expire. Defaults to server configured expiry time. // @param vars(type={[key:string]:string}, optional=true) Extra information that will be bundled in the session token. // @return token(string) The Nakama session token. // @return validity(number) The period for which the token remains valid. // @return error(error) An optional error value if an error occurred. Loading @@ -1684,17 +1685,23 @@ func (n *runtimeJavascriptNakamaModule) authenticateTokenGenerate(r *goja.Runtim panic(r.NewTypeError("expects valid user id")) } username := getJsString(r, f.Argument(1)) var username string if f.Argument(1) != goja.Null() && f.Argument(1) != goja.Undefined() { username = getJsString(r, f.Argument(1)) } if username == "" { username = generateUsername() } exp := time.Now().UTC().Add(time.Duration(n.config.GetSession().TokenExpirySec) * time.Second).Unix() if f.Argument(2) != goja.Undefined() { if f.Argument(2) != goja.Null() && f.Argument(2) != goja.Undefined() { exp = getJsInt(r, f.Argument(2)) } vars := getJsStringMap(r, f.Argument(3)) var vars map[string]string if f.Argument(3) != goja.Null() && f.Argument(3) != goja.Undefined() { vars = getJsStringMap(r, f.Argument(3)) } token, exp := generateTokenWithExpiry(n.config.GetSession().EncryptionKey, userIDString, username, vars, exp) n.sessionCache.Add(uid, exp, token, 0, "") Loading
server/runtime_lua_nakama.go +1 −0 Original line number Diff line number Diff line Loading @@ -2039,6 +2039,7 @@ func (n *RuntimeLuaNakamaModule) authenticateSteam(l *lua.LState) int { // @param userId(type=string) User ID to use to generate the token. // @param username(type=string, optional=true) The user's username. If left empty, one is generated. // @param expiresAt(type=number, optional=true) UTC time in seconds when the token must expire. Defaults to server configured expiry time. // @param vars(type=table, optional=true) Extra information that will be bundled in the session token. // @return token(string) The Nakama session token. // @return validity(number) The period for which the token remains valid. // @return error(error) An optional error value if an error occurred. Loading