diff --git a/CHANGELOG.md b/CHANGELOG.md index 4b60915591..c82bd0eb09 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ The format is based on [keep a changelog](http://keepachangelog.com) and this pr - Add new runtime function to get a list of user's friend status. - Add new Follow/Unfollow runtime APIs. - Add new NotificationsUpdate runtime API. +- Add new initializers function to get config values. ### Changed - Increase limit of runtime friend listing operations to 1,000. diff --git a/go.mod b/go.mod index d42e8df876..bd6d0ffe77 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,7 @@ require ( github.com/gorilla/mux v1.8.1 github.com/gorilla/websocket v1.5.1 github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 - github.com/heroiclabs/nakama-common v1.34.1-0.20241121105602-e24311ad3419 + github.com/heroiclabs/nakama-common v1.34.1-0.20241123094823-fd6420e8b69d github.com/heroiclabs/sql-migrate v0.0.0-20240528102547-233afc8cf05a github.com/jackc/pgerrcode v0.0.0-20240316143900-6e2875d9b438 github.com/jackc/pgx/v5 v5.6.0 diff --git a/go.sum b/go.sum index 029c6cb769..0ea9eb5539 100644 --- a/go.sum +++ b/go.sum @@ -130,8 +130,8 @@ github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZH github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 h1:bkypFPDjIYGfCYD5mRBvpqxfYX1YCS1PXdKYWi8FsN0= github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0/go.mod h1:P+Lt/0by1T8bfcF3z737NnSbmxQAppXMRziHUxPOC8k= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= -github.com/heroiclabs/nakama-common v1.34.1-0.20241121105602-e24311ad3419 h1:sC+dslMcIE3E8lc1fXOIvYb7cPjtZUVvHiegHdLah4k= -github.com/heroiclabs/nakama-common v1.34.1-0.20241121105602-e24311ad3419/go.mod h1:lPG64MVCs0/tEkh311Cd6oHX9NLx2vAPx7WW7QCJHQ0= +github.com/heroiclabs/nakama-common v1.34.1-0.20241123094823-fd6420e8b69d h1:Ovj8fbsxDXldEDXwwlYtCtWgSSEZtgy/S4ou2Mprdfk= +github.com/heroiclabs/nakama-common v1.34.1-0.20241123094823-fd6420e8b69d/go.mod h1:lPG64MVCs0/tEkh311Cd6oHX9NLx2vAPx7WW7QCJHQ0= github.com/heroiclabs/sql-migrate v0.0.0-20240528102547-233afc8cf05a h1:tuL2ZPaeCbNw8rXmV9ywd00nXRv95V4/FmbIGKLQJAE= github.com/heroiclabs/sql-migrate v0.0.0-20240528102547-233afc8cf05a/go.mod h1:hzCTPoEi/oml2BllVydJcNP63S7b56e5DzeQeLGvw1U= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= diff --git a/server/config.go b/server/config.go index dfc8091916..1c3608081d 100644 --- a/server/config.go +++ b/server/config.go @@ -18,17 +18,17 @@ import ( "crypto/tls" "flag" "fmt" - "net/url" - "os" - "path/filepath" - "sort" - "strings" - + "github.com/heroiclabs/nakama-common/runtime" "github.com/heroiclabs/nakama/v3/flags" "go.uber.org/zap" "golang.org/x/oauth2" "golang.org/x/oauth2/google" "gopkg.in/yaml.v3" + "net/url" + "os" + "path/filepath" + "sort" + "strings" ) // Config interface is the Nakama core configuration. @@ -56,6 +56,7 @@ type Config interface { GetLimit() int Clone() (Config, error) + GetRuntimeConfig() (runtime.Config, error) } func ParseArgs(logger *zap.Logger, args []string) Config { @@ -625,10 +626,43 @@ func (c *config) GetMFA() *MFAConfig { return c.MFA } +func (c *config) GetRuntimeConfig() (runtime.Config, error) { + clone, err := c.Clone() + if err != nil { + return nil, err + } + + var lc runtime.LoggerConfig = clone.GetLogger() + var sc runtime.SessionConfig = clone.GetSession() + var soc runtime.SocketConfig = clone.GetSocket() + var socialConf runtime.SocialConfig = clone.GetSocial() + var rc runtime.RuntimeConfig = clone.GetRuntime() + var iap runtime.IAPConfig = clone.GetIAP() + var gauth runtime.GoogleAuthConfig = clone.GetGoogleAuth() + var satori runtime.SatoriConfig = clone.GetSatori() + + cn := &RuntimeConfigClone{ + Name: clone.GetName(), + ShutdownGrace: clone.GetShutdownGraceSec(), + Logger: lc, + Session: sc, + Socket: soc, + Social: socialConf, + Runtime: rc, + Iap: iap, + GoogleAuth: gauth, + Satori: satori, + } + + return cn, nil +} + func (c *config) GetLimit() int { return c.Limit } +var _ runtime.LoggerConfig = &LoggerConfig{} + // LoggerConfig is configuration relevant to logging levels and output. type LoggerConfig struct { Level string `yaml:"level" json:"level" usage:"Log level to set. Valid values are 'debug', 'info', 'warn', 'error'. Default 'info'."` @@ -644,6 +678,10 @@ type LoggerConfig struct { Format string `yaml:"format" json:"format" usage:"Set logging output format. Can either be 'JSON' or 'Stackdriver'. Default is 'JSON'."` } +func (cfg *LoggerConfig) GetLevel() string { + return cfg.Level +} + func (cfg *LoggerConfig) Clone() *LoggerConfig { if cfg == nil { return nil @@ -696,6 +734,8 @@ func NewMetricsConfig() *MetricsConfig { } } +var _ runtime.SessionConfig = &SessionConfig{} + // SessionConfig is configuration relevant to the session. type SessionConfig struct { EncryptionKey string `yaml:"encryption_key" json:"encryption_key" usage:"The encryption key used to produce the client token."` @@ -708,6 +748,38 @@ type SessionConfig struct { SingleSession bool `yaml:"single_session" json:"single_session" usage:"Only allow one session token per user. Older session tokens are invalidated in the session cache. Default false."` } +func (cfg *SessionConfig) GetEncryptionKey() string { + return cfg.EncryptionKey +} + +func (cfg *SessionConfig) GetTokenExpirySec() int64 { + return cfg.TokenExpirySec +} + +func (cfg *SessionConfig) GetRefreshEncryptionKey() string { + return cfg.RefreshEncryptionKey +} + +func (cfg *SessionConfig) GetRefreshTokenExpirySec() int64 { + return cfg.RefreshTokenExpirySec +} + +func (cfg *SessionConfig) GetSingleSocket() bool { + return cfg.SingleSocket +} + +func (cfg *SessionConfig) GetSingleMatch() bool { + return cfg.SingleMatch +} + +func (cfg *SessionConfig) GetSingleParty() bool { + return cfg.SingleParty +} + +func (cfg *SessionConfig) GetSingleSession() bool { + return cfg.SingleSession +} + func (cfg *SessionConfig) Clone() *SessionConfig { if cfg == nil { return nil @@ -726,6 +798,8 @@ func NewSessionConfig() *SessionConfig { } } +var _ runtime.SocketConfig = &SocketConfig{} + // SocketConfig is configuration relevant to the transport socket and protocol. type SocketConfig struct { ServerKey string `yaml:"server_key" json:"server_key" usage:"Server key to use to establish a connection to the server."` @@ -753,6 +827,22 @@ type SocketConfig struct { TLSCert []tls.Certificate `yaml:"-" json:"-"` // Created by processing CertPEMBlock and KeyPEMBlock, not set from input args directly. } +func (cfg *SocketConfig) GetServerKey() string { + return cfg.ServerKey +} + +func (cfg *SocketConfig) GetPort() int { + return cfg.Port +} + +func (cfg *SocketConfig) GetAddress() string { + return cfg.Address +} + +func (cfg *SocketConfig) GetProtocol() string { + return cfg.Protocol +} + func (cfg *SocketConfig) Clone() (*SocketConfig, error) { if cfg == nil { return nil, nil @@ -846,6 +936,8 @@ func NewDatabaseConfig() *DatabaseConfig { } } +var _ runtime.SocialConfig = &SocialConfig{} + // SocialConfig is configuration relevant to the social authentication providers. type SocialConfig struct { Steam *SocialConfigSteam `yaml:"steam" json:"steam" usage:"Steam configuration."` @@ -854,6 +946,22 @@ type SocialConfig struct { Apple *SocialConfigApple `yaml:"apple" json:"apple" usage:"Apple Sign In configuration."` } +func (cfg *SocialConfig) GetSteam() runtime.SocialConfigSteam { + return cfg.Steam +} + +func (cfg *SocialConfig) GetFacebookInstantGame() runtime.SocialConfigFacebookInstantGame { + return cfg.FacebookInstantGame +} + +func (cfg *SocialConfig) GetFacebookLimitedLogin() runtime.SocialConfigFacebookLimitedLogin { + return cfg.FacebookLimitedLogin +} + +func (cfg *SocialConfig) GetApple() runtime.SocialConfigApple { + return cfg.Apple +} + func (cfg *SocialConfig) Clone() *SocialConfig { if cfg == nil { return nil @@ -881,27 +989,55 @@ func (cfg *SocialConfig) Clone() *SocialConfig { return &cfgCopy } +var _ runtime.SocialConfigSteam = &SocialConfigSteam{} + // SocialConfigSteam is configuration relevant to Steam. type SocialConfigSteam struct { PublisherKey string `yaml:"publisher_key" json:"publisher_key" usage:"Steam Publisher Key value."` AppID int `yaml:"app_id" json:"app_id" usage:"Steam App ID."` } +func (s SocialConfigSteam) GetPublisherKey() string { + return s.PublisherKey +} + +func (s SocialConfigSteam) GetAppID() int { + return s.AppID +} + +var _ runtime.SocialConfigFacebookInstantGame = &SocialConfigFacebookInstantGame{} + // SocialConfigFacebookInstantGame is configuration relevant to Facebook Instant Games. type SocialConfigFacebookInstantGame struct { AppSecret string `yaml:"app_secret" json:"app_secret" usage:"Facebook Instant App secret."` } +func (s SocialConfigFacebookInstantGame) GetAppSecret() string { + return s.AppSecret +} + +var _ runtime.SocialConfigFacebookLimitedLogin = &SocialConfigFacebookLimitedLogin{} + // SocialConfigFacebookLimitedLogin is configuration relevant to Facebook Limited Login. type SocialConfigFacebookLimitedLogin struct { AppId string `yaml:"app_id" json:"app_id" usage:"Facebook Limited Login App ID."` } +func (s SocialConfigFacebookLimitedLogin) GetAppId() string { + return s.AppId +} + +var _ runtime.SocialConfigApple = &SocialConfigApple{} + // SocialConfigApple is configuration relevant to Apple Sign In. type SocialConfigApple struct { BundleId string `yaml:"bundle_id" json:"bundle_id" usage:"Apple Sign In bundle ID."` } +func (s SocialConfigApple) GetBundleId() string { + return s.BundleId +} + func NewSocialConfig() *SocialConfig { return &SocialConfig{ Steam: &SocialConfigSteam{ @@ -920,6 +1056,8 @@ func NewSocialConfig() *SocialConfig { } } +var _ runtime.RuntimeConfig = &RuntimeConfig{} + // RuntimeConfig is configuration relevant to the Runtimes. type RuntimeConfig struct { Environment map[string]string `yaml:"-" json:"-"` @@ -945,6 +1083,14 @@ type RuntimeConfig struct { JsEntrypoint string `yaml:"js_entrypoint" json:"js_entrypoint" usage:"Specifies the location of the bundled JavaScript runtime source code."` } +func (r *RuntimeConfig) GetEnv() []string { + return r.Env +} + +func (r *RuntimeConfig) GetHTTPKey() string { + return r.HTTPKey +} + func (r *RuntimeConfig) Clone() *RuntimeConfig { if r == nil { return nil @@ -1185,6 +1331,8 @@ func NewMatchmakerConfig() *MatchmakerConfig { } } +var _ runtime.IAPConfig = &IAPConfig{} + type IAPConfig struct { Apple *IAPAppleConfig `yaml:"apple" json:"apple" usage:"Apple App Store purchase validation configuration."` Google *IAPGoogleConfig `yaml:"google" json:"google" usage:"Google Play Store purchase validation configuration."` @@ -1192,6 +1340,22 @@ type IAPConfig struct { FacebookInstant *IAPFacebookInstantConfig `yaml:"facebook_instant" json:"facebook_instant" usage:"Facebook Instant purchase validation configuration."` } +func (cfg *IAPConfig) GetApple() runtime.IAPAppleConfig { + return cfg.Apple +} + +func (cfg *IAPConfig) GetGoogle() runtime.IAPGoogleConfig { + return cfg.Google +} + +func (cfg *IAPConfig) GetHuawei() runtime.IAPHuaweiConfig { + return cfg.Huawei +} + +func (cfg *IAPConfig) GetFacebookInstant() runtime.IAPFacebookInstantConfig { + return cfg.FacebookInstant +} + func (cfg *IAPConfig) Clone() *IAPConfig { if cfg == nil { return nil @@ -1228,11 +1392,23 @@ func NewIAPConfig() *IAPConfig { } } +var _ runtime.IAPAppleConfig = &IAPAppleConfig{} + type IAPAppleConfig struct { SharedPassword string `yaml:"shared_password" json:"shared_password" usage:"Your Apple Store App IAP shared password. Only necessary for validation of auto-renewable subscriptions."` NotificationsEndpointId string `yaml:"notifications_endpoint_id" json:"notifications_endpoint_id" usage:"The callback endpoint identifier for Apple Store subscription notifications."` } +func (iap IAPAppleConfig) GetSharedPassword() string { + return iap.SharedPassword +} + +func (iap IAPAppleConfig) GetNotificationsEndpointId() string { + return iap.NotificationsEndpointId +} + +var _ runtime.IAPGoogleConfig = &IAPGoogleConfig{} + type IAPGoogleConfig struct { ClientEmail string `yaml:"client_email" json:"client_email" usage:"Google Service Account client email."` PrivateKey string `yaml:"private_key" json:"private_key" usage:"Google Service Account private key."` @@ -1241,6 +1417,26 @@ type IAPGoogleConfig struct { PackageName string `yaml:"package_name" json:"package_name" usage:"Google Play Store App Package Name."` } +func (iapg *IAPGoogleConfig) GetClientEmail() string { + return iapg.ClientEmail +} + +func (iapg *IAPGoogleConfig) GetPrivateKey() string { + return iapg.PrivateKey +} + +func (iapg *IAPGoogleConfig) GetNotificationsEndpointId() string { + return iapg.NotificationsEndpointId +} + +func (iapg *IAPGoogleConfig) GetRefundCheckPeriodMin() int { + return iapg.RefundCheckPeriodMin +} + +func (iapg *IAPGoogleConfig) GetPackageName() string { + return iapg.PackageName +} + func (iapg *IAPGoogleConfig) Enabled() bool { if iapg.PrivateKey != "" && iapg.PackageName != "" { return true @@ -1248,6 +1444,8 @@ func (iapg *IAPGoogleConfig) Enabled() bool { return false } +var _ runtime.SatoriConfig = &SatoriConfig{} + type SatoriConfig struct { Url string `yaml:"url" json:"url" usage:"Satori URL."` ApiKeyName string `yaml:"api_key_name" json:"api_key_name" usage:"Satori Api key name."` @@ -1255,6 +1453,22 @@ type SatoriConfig struct { SigningKey string `yaml:"signing_key" json:"signing_key" usage:"Key used to sign Satori session tokens."` } +func (sc *SatoriConfig) GetUrl() string { + return sc.Url +} + +func (sc *SatoriConfig) GetApiKeyName() string { + return sc.ApiKeyName +} + +func (sc *SatoriConfig) GetApiKey() string { + return sc.ApiKey +} + +func (sc *SatoriConfig) GetSigningKey() string { + return sc.SigningKey +} + func (sc *SatoriConfig) Clone() *SatoriConfig { if sc == nil { return nil @@ -1289,21 +1503,47 @@ func (sc *SatoriConfig) Validate(logger *zap.Logger) { } } +var _ runtime.IAPHuaweiConfig = &IAPHuaweiConfig{} + type IAPHuaweiConfig struct { PublicKey string `yaml:"public_key" json:"public_key" usage:"Huawei IAP store Base64 encoded Public Key."` ClientID string `yaml:"client_id" json:"client_id" usage:"Huawei OAuth client secret."` ClientSecret string `yaml:"client_secret" json:"client_secret" usage:"Huawei OAuth app client secret."` } +func (i IAPHuaweiConfig) GetPublicKey() string { + return i.PublicKey +} + +func (i IAPHuaweiConfig) GetClientID() string { + return i.ClientID +} + +func (i IAPHuaweiConfig) GetClientSecret() string { + return i.ClientSecret +} + +var _ runtime.IAPFacebookInstantConfig = &IAPFacebookInstantConfig{} + type IAPFacebookInstantConfig struct { AppSecret string `yaml:"app_secret" json:"app_secret" usage:"Facebook Instant OAuth app client secret."` } +func (i IAPFacebookInstantConfig) GetAppSecret() string { + return i.AppSecret +} + +var _ runtime.GoogleAuthConfig = &GoogleAuthConfig{} + type GoogleAuthConfig struct { CredentialsJSON string `yaml:"credentials_json" json:"credentials_json" usage:"Google's Access Credentials."` OAuthConfig *oauth2.Config `yaml:"-" json:"-"` } +func (cfg *GoogleAuthConfig) GetCredentialsJSON() string { + return cfg.CredentialsJSON +} + func (cfg *GoogleAuthConfig) Clone() *GoogleAuthConfig { if cfg == nil { return nil diff --git a/server/config_test.go b/server/config_test.go new file mode 100644 index 0000000000..abb4e431ab --- /dev/null +++ b/server/config_test.go @@ -0,0 +1 @@ +package server diff --git a/server/console_match.go b/server/console_match.go index 0c1aeca0b5..2e676800f4 100644 --- a/server/console_match.go +++ b/server/console_match.go @@ -16,6 +16,7 @@ package server import ( "context" + "errors" "strings" "github.com/gofrs/uuid/v5" @@ -28,7 +29,7 @@ import ( func (s *ConsoleServer) ListMatches(ctx context.Context, in *console.ListMatchesRequest) (*console.MatchList, error) { matchID := in.MatchId - // Try get match ID for authoritative query + // Try to get match ID for authoritative query. if in.Authoritative != nil && in.Authoritative.Value && in.Query != nil { matchID = in.Query.Value } @@ -40,7 +41,7 @@ func (s *ConsoleServer) ListMatches(ctx context.Context, in *console.ListMatches } return &console.MatchList{Matches: []*console.MatchList_Match{{ApiMatch: match, Node: node}}}, nil } else { - if err == runtime.ErrMatchIdInvalid { + if errors.Is(err, runtime.ErrMatchIdInvalid) { if (in.Authoritative != nil && !in.Authoritative.Value) || in.Authoritative == nil { return nil, status.Error(codes.InvalidArgument, "Match ID is not valid.") } @@ -111,10 +112,10 @@ func (s *ConsoleServer) GetMatchState(ctx context.Context, in *console.MatchStat presences, tick, state, err := s.matchRegistry.GetState(ctx, matchID, node) if err != nil { - if err != context.Canceled && err != runtime.ErrMatchNotFound { + if !errors.Is(err, context.Canceled) && !errors.Is(err, runtime.ErrMatchNotFound) { s.logger.Error("Error getting match state.", zap.Any("in", in), zap.Error(err)) } - if err == runtime.ErrMatchNotFound { + if errors.Is(err, runtime.ErrMatchNotFound) { return nil, status.Error(codes.InvalidArgument, "Match not found, or match handler already stopped.") } return nil, status.Error(codes.Internal, "Error listing matches.") diff --git a/server/runtime_config.go b/server/runtime_config.go new file mode 100644 index 0000000000..f837a5c2b8 --- /dev/null +++ b/server/runtime_config.go @@ -0,0 +1,70 @@ +// Copyright 2024 The Nakama Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package server + +import "github.com/heroiclabs/nakama-common/runtime" + +type RuntimeConfigClone struct { + Name string + ShutdownGrace int + Logger runtime.LoggerConfig + Session runtime.SessionConfig + Socket runtime.SocketConfig + Social runtime.SocialConfig + Runtime runtime.RuntimeConfig + Iap runtime.IAPConfig + GoogleAuth runtime.GoogleAuthConfig + Satori runtime.SatoriConfig +} + +func (c *RuntimeConfigClone) GetName() string { + return c.Name +} + +func (c *RuntimeConfigClone) GetShutdownGraceSec() int { + return c.ShutdownGrace +} + +func (c *RuntimeConfigClone) GetLogger() runtime.LoggerConfig { + return c.Logger +} + +func (c *RuntimeConfigClone) GetSession() runtime.SessionConfig { + return c.Session +} + +func (c *RuntimeConfigClone) GetSocket() runtime.SocketConfig { + return c.Socket +} + +func (c *RuntimeConfigClone) GetSocial() runtime.SocialConfig { + return c.Social +} + +func (c *RuntimeConfigClone) GetRuntime() runtime.RuntimeConfig { + return c.Runtime +} + +func (c *RuntimeConfigClone) GetIAP() runtime.IAPConfig { + return c.Iap +} + +func (c *RuntimeConfigClone) GetGoogleAuth() runtime.GoogleAuthConfig { + return c.GoogleAuth +} + +func (c *RuntimeConfigClone) GetSatori() runtime.SatoriConfig { + return c.Satori +} diff --git a/server/runtime_go.go b/server/runtime_go.go index fe0eefbf8f..abd6374258 100644 --- a/server/runtime_go.go +++ b/server/runtime_go.go @@ -46,6 +46,7 @@ type RuntimeGoInitializer struct { version string env map[string]string nk runtime.NakamaModule + config Config rpc map[string]RuntimeRpcFunction beforeRt map[string]RuntimeBeforeRtFunction @@ -79,6 +80,14 @@ type RuntimeGoInitializer struct { fmCallbackHandler runtime.FmCallbackHandler } +func (ri *RuntimeGoInitializer) GetConfig() (runtime.Config, error) { + cfg, err := ri.config.GetRuntimeConfig() + if err != nil { + return nil, err + } + return cfg, nil +} + func (ri *RuntimeGoInitializer) RegisterEvent(fn func(ctx context.Context, logger runtime.Logger, evt *api.Event)) error { ri.eventFunctions = append(ri.eventFunctions, fn) return nil @@ -2860,6 +2869,7 @@ func NewRuntimeProviderGo(ctx context.Context, logger, startupLogger *zap.Logger version: version, env: env, nk: nk, + config: config, rpc: make(map[string]RuntimeRpcFunction), diff --git a/server/runtime_javascript.go b/server/runtime_javascript.go index 1826a7b21e..62a93d8d2c 100644 --- a/server/runtime_javascript.go +++ b/server/runtime_javascript.go @@ -52,7 +52,7 @@ type RuntimeJS struct { env goja.Value envMap map[string]string vm *goja.Runtime - nakamaModule *runtimeJavascriptNakamaModule + nakamaModule *RuntimeJavascriptNakamaModule callbacks *RuntimeJavascriptCallbacks } @@ -2425,7 +2425,7 @@ func evalRuntimeModules(rp *RuntimeProviderJS, modCache *RuntimeJSModuleCache, m } modName := modCache.Names[0] - initializer := NewRuntimeJavascriptInitModule(logger, modCache.Modules[modName].Ast, storageIndex, callbacks, matchHandlers, announceCallbackFn) + initializer := NewRuntimeJavascriptInitModule(logger, rp.config, modCache.Modules[modName].Ast, storageIndex, callbacks, matchHandlers, announceCallbackFn) init, err := initializer.Constructor(r) if err != nil { return nil, err diff --git a/server/runtime_javascript_init.go b/server/runtime_javascript_init.go index 924f64f3aa..70164c6f27 100644 --- a/server/runtime_javascript_init.go +++ b/server/runtime_javascript_init.go @@ -83,9 +83,10 @@ type RuntimeJavascriptInitModule struct { announceCallbackFn func(RuntimeExecutionMode, string) storageIndex StorageIndex ast *ast.Program + config Config } -func NewRuntimeJavascriptInitModule(logger *zap.Logger, ast *ast.Program, storageIndex StorageIndex, callbacks *RuntimeJavascriptCallbacks, matchCallbacks *RuntimeJavascriptMatchHandlers, announceCallbackFn func(RuntimeExecutionMode, string)) *RuntimeJavascriptInitModule { +func NewRuntimeJavascriptInitModule(logger *zap.Logger, config Config, ast *ast.Program, storageIndex StorageIndex, callbacks *RuntimeJavascriptCallbacks, matchCallbacks *RuntimeJavascriptMatchHandlers, announceCallbackFn func(RuntimeExecutionMode, string)) *RuntimeJavascriptInitModule { return &RuntimeJavascriptInitModule{ Logger: logger, storageIndex: storageIndex, @@ -93,11 +94,13 @@ func NewRuntimeJavascriptInitModule(logger *zap.Logger, ast *ast.Program, storag Callbacks: callbacks, MatchCallbacks: matchCallbacks, ast: ast, + config: config, } } func (im *RuntimeJavascriptInitModule) mappings(r *goja.Runtime) map[string]func(goja.FunctionCall) goja.Value { return map[string]func(goja.FunctionCall) goja.Value{ + "getConfig": im.getConfig(r), "registerRpc": im.registerRpc(r), "registerRtBefore": im.registerRtBefore(r), "registerRtAfter": im.registerRtAfter(r), @@ -288,6 +291,106 @@ func (im *RuntimeJavascriptInitModule) Constructor(r *goja.Runtime) (*goja.Objec return r.New(r.ToValue(constructor)) } +func (im *RuntimeJavascriptInitModule) getConfig(r *goja.Runtime) func(goja.FunctionCall) goja.Value { + return func(f goja.FunctionCall) goja.Value { + rnc, err := im.config.GetRuntimeConfig() + if err != nil { + panic(r.NewGoError(err)) + } + + cfgObj := r.NewObject() + _ = cfgObj.Set("name", rnc.GetName()) + _ = cfgObj.Set("shutdown_grace_sec", rnc.GetShutdownGraceSec()) + + lgCfg := r.NewObject() + _ = lgCfg.Set("level", rnc.GetLogger().GetLevel()) + _ = cfgObj.Set("logger", lgCfg) + + sessCfg := r.NewObject() + _ = sessCfg.Set("encryption_key", rnc.GetSession().GetEncryptionKey()) + _ = sessCfg.Set("token_expiry_sec", rnc.GetSession().GetTokenExpirySec()) + _ = sessCfg.Set("refresh_encryption_key", rnc.GetSession().GetRefreshEncryptionKey()) + _ = sessCfg.Set("refresh_token_expiry_sec", rnc.GetSession().GetRefreshTokenExpirySec()) + _ = sessCfg.Set("single_socket", rnc.GetSession().GetSingleSocket()) + _ = sessCfg.Set("single_match", rnc.GetSession().GetSingleMatch()) + _ = sessCfg.Set("single_party", rnc.GetSession().GetSingleParty()) + _ = sessCfg.Set("single_session", rnc.GetSession().GetSingleSession()) + _ = cfgObj.Set("session", sessCfg) + + socketCfg := r.NewObject() + _ = socketCfg.Set("server_key", rnc.GetSocket().GetServerKey()) + _ = socketCfg.Set("port", rnc.GetSocket().GetPort()) + _ = socketCfg.Set("address", rnc.GetSocket().GetAddress()) + _ = socketCfg.Set("protocol", rnc.GetSocket().GetProtocol()) + _ = cfgObj.Set("socket", socketCfg) + + // Social + steamCfg := r.NewObject() + _ = steamCfg.Set("publisher_key", rnc.GetSocial().GetSteam().GetPublisherKey()) + _ = steamCfg.Set("app_id", rnc.GetSocial().GetSteam().GetAppID()) + + fbInstantCfg := r.NewObject() + _ = fbInstantCfg.Set("app_secret", rnc.GetSocial().GetFacebookInstantGame().GetAppSecret()) + + fbLimitedCfg := r.NewObject() + _ = fbLimitedCfg.Set("app_id", rnc.GetSocial().GetFacebookLimitedLogin().GetAppId()) + + appleCfg := r.NewObject() + _ = appleCfg.Set("bundle_id", rnc.GetSocial().GetApple().GetBundleId()) + + socialCfg := r.NewObject() + _ = socialCfg.Set("steam", steamCfg) + _ = socialCfg.Set("facebook_instant_game", fbInstantCfg) + _ = socialCfg.Set("facebook_limited_login", fbLimitedCfg) + _ = socialCfg.Set("apple", appleCfg) + _ = cfgObj.Set("social", socialCfg) + + runtimeCfg := r.NewObject() + _ = runtimeCfg.Set("env", rnc.GetRuntime().GetEnv()) + _ = runtimeCfg.Set("http_key", rnc.GetRuntime().GetHTTPKey()) + _ = cfgObj.Set("runtime", runtimeCfg) + + // IAP + iapAppleCfg := r.NewObject() + _ = iapAppleCfg.Set("shared_password", rnc.GetIAP().GetApple().GetSharedPassword()) + _ = iapAppleCfg.Set("notifications_endpoint_id", rnc.GetIAP().GetApple().GetNotificationsEndpointId()) + + iapGoogleCfg := r.NewObject() + _ = iapGoogleCfg.Set("client_email", rnc.GetIAP().GetGoogle().GetClientEmail()) + _ = iapGoogleCfg.Set("private_key", rnc.GetIAP().GetGoogle().GetPrivateKey()) + _ = iapGoogleCfg.Set("notifications_endpoint_id", rnc.GetIAP().GetGoogle().GetNotificationsEndpointId()) + _ = iapGoogleCfg.Set("refund_check_period_min", rnc.GetIAP().GetGoogle().GetRefundCheckPeriodMin()) + _ = iapGoogleCfg.Set("package_name", rnc.GetIAP().GetGoogle().GetPackageName()) + + iapHuaweiCfg := r.NewObject() + _ = iapHuaweiCfg.Set("public_key", rnc.GetIAP().GetHuawei().GetPublicKey()) + _ = iapHuaweiCfg.Set("client_id", rnc.GetIAP().GetHuawei().GetClientID()) + _ = iapHuaweiCfg.Set("client_secret", rnc.GetIAP().GetHuawei().GetClientSecret()) + + iapFacebookInstantCfg := r.NewObject() + _ = iapFacebookInstantCfg.Set("app_secret", rnc.GetIAP().GetFacebookInstant().GetAppSecret()) + iapCfg := r.NewObject() + _ = iapCfg.Set("apple", iapAppleCfg) + _ = iapCfg.Set("google", iapGoogleCfg) + _ = iapCfg.Set("huawei", iapHuaweiCfg) + _ = iapCfg.Set("facebook_instant", iapFacebookInstantCfg) + _ = cfgObj.Set("iap", iapCfg) + + googleAuthCfg := r.NewObject() + _ = googleAuthCfg.Set("credentials_json", rnc.GetGoogleAuth().GetCredentialsJSON()) + _ = cfgObj.Set("google_auth", googleAuthCfg) + + satoriCfg := r.NewObject() + _ = satoriCfg.Set("url", rnc.GetSatori().GetUrl()) + _ = satoriCfg.Set("api_key_name", rnc.GetSatori().GetApiKeyName()) + _ = satoriCfg.Set("api_key", rnc.GetSatori().GetApiKey()) + _ = satoriCfg.Set("signing_key", rnc.GetSatori().GetSigningKey()) + _ = cfgObj.Set("satori", satoriCfg) + + return cfgObj + } +} + func (im *RuntimeJavascriptInitModule) registerRpc(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { fName := f.Argument(0) diff --git a/server/runtime_javascript_nakama.go b/server/runtime_javascript_nakama.go index 55637ae0b8..8771eaac24 100644 --- a/server/runtime_javascript_nakama.go +++ b/server/runtime_javascript_nakama.go @@ -57,7 +57,7 @@ import ( "google.golang.org/protobuf/types/known/wrapperspb" ) -type runtimeJavascriptNakamaModule struct { +type RuntimeJavascriptNakamaModule struct { ctx context.Context logger *zap.Logger config Config @@ -88,8 +88,8 @@ type runtimeJavascriptNakamaModule struct { satori runtime.Satori } -func NewRuntimeJavascriptNakamaModule(logger *zap.Logger, db *sql.DB, protojsonMarshaler *protojson.MarshalOptions, protojsonUnmarshaler *protojson.UnmarshalOptions, config Config, socialClient *social.Client, leaderboardCache LeaderboardCache, rankCache LeaderboardRankCache, storageIndex StorageIndex, localCache *RuntimeJavascriptLocalCache, leaderboardScheduler LeaderboardScheduler, sessionRegistry SessionRegistry, sessionCache SessionCache, statusRegistry StatusRegistry, matchRegistry MatchRegistry, tracker Tracker, metrics Metrics, streamManager StreamManager, router MessageRouter, eventFn RuntimeEventCustomFunction, matchCreateFn RuntimeMatchCreateFunction) *runtimeJavascriptNakamaModule { - return &runtimeJavascriptNakamaModule{ +func NewRuntimeJavascriptNakamaModule(logger *zap.Logger, db *sql.DB, protojsonMarshaler *protojson.MarshalOptions, protojsonUnmarshaler *protojson.UnmarshalOptions, config Config, socialClient *social.Client, leaderboardCache LeaderboardCache, rankCache LeaderboardRankCache, storageIndex StorageIndex, localCache *RuntimeJavascriptLocalCache, leaderboardScheduler LeaderboardScheduler, sessionRegistry SessionRegistry, sessionCache SessionCache, statusRegistry StatusRegistry, matchRegistry MatchRegistry, tracker Tracker, metrics Metrics, streamManager StreamManager, router MessageRouter, eventFn RuntimeEventCustomFunction, matchCreateFn RuntimeMatchCreateFunction) *RuntimeJavascriptNakamaModule { + return &RuntimeJavascriptNakamaModule{ ctx: context.Background(), logger: logger, config: config, @@ -128,7 +128,7 @@ func NewRuntimeJavascriptNakamaModule(logger *zap.Logger, db *sql.DB, protojsonM } } -func (n *runtimeJavascriptNakamaModule) Constructor(r *goja.Runtime) (*goja.Object, +func (n *RuntimeJavascriptNakamaModule) Constructor(r *goja.Runtime) (*goja.Object, error) { satoriJsObj, err := n.satoriConstructor(r) if err != nil { @@ -148,7 +148,7 @@ func (n *runtimeJavascriptNakamaModule) Constructor(r *goja.Runtime) (*goja.Obje return r.New(r.ToValue(constructor)) } -func (n *runtimeJavascriptNakamaModule) mappings(r *goja.Runtime) map[string]func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) mappings(r *goja.Runtime) map[string]func(goja.FunctionCall) goja.Value { return map[string]func(goja.FunctionCall) goja.Value{ "event": n.event(r), "metricsCounterAdd": n.metricsCounterAdd(r), @@ -323,7 +323,7 @@ func (n *runtimeJavascriptNakamaModule) mappings(r *goja.Runtime) map[string]fun // @param data(type=ArrayBuffer) The binary data to be converted. // @return result(string) The resulting string. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) binaryToString(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) binaryToString(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { if goja.IsUndefined(f.Argument(0)) || goja.IsNull(f.Argument(0)) { panic(r.NewTypeError("expects a ArrayBuffer object")) @@ -347,7 +347,7 @@ func (n *runtimeJavascriptNakamaModule) binaryToString(r *goja.Runtime) func(goj // @param str(type=string) The string to be converted. // @return result(ArrayBuffer) The resulting binary data. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) stringToBinary(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) stringToBinary(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { if goja.IsUndefined(f.Argument(0)) || goja.IsNull(f.Argument(0)) { panic(r.NewTypeError("expects a string")) @@ -371,7 +371,7 @@ func (n *runtimeJavascriptNakamaModule) stringToBinary(r *goja.Runtime) func(goj // @param callerId(type=string, optional=true) User ID of the caller, will apply permissions checks of the user. If empty defaults to system user and permission checks are bypassed. // @return objects(nkruntime.StorageIndexResult) A list of storage objects. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) storageIndexList(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) storageIndexList(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { idxName := getJsString(r, f.Argument(0)) queryString := getJsString(r, f.Argument(1)) @@ -459,7 +459,7 @@ func (n *runtimeJavascriptNakamaModule) storageIndexList(r *goja.Runtime) func(g // @param ts(type=int, optional=true) Timestamp for when event is created. // @param external(type=bool, optional=true, default=false) Whether the event is external. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) event(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) event(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { eventName := getJsString(r, f.Argument(0)) properties := getJsStringMap(r, f.Argument(1)) @@ -492,7 +492,7 @@ func (n *runtimeJavascriptNakamaModule) event(r *goja.Runtime) func(goja.Functio // @param name(type=string) The name of the custom metrics counter. // @param tags(type=map[string]string) The metrics tags associated with this counter. // @param delta(type=number) An integer value to update this metric with. -func (n *runtimeJavascriptNakamaModule) metricsCounterAdd(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) metricsCounterAdd(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { name := getJsString(r, f.Argument(0)) tags := getJsStringMap(r, f.Argument(1)) @@ -508,7 +508,7 @@ func (n *runtimeJavascriptNakamaModule) metricsCounterAdd(r *goja.Runtime) func( // @param name(type=string) The name of the custom metrics gauge. // @param tags(type=map[string]string) The metrics tags associated with this gauge. // @param value(type=number) A value to update this metric with. -func (n *runtimeJavascriptNakamaModule) metricsGaugeSet(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) metricsGaugeSet(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { name := getJsString(r, f.Argument(0)) tags := getJsStringMap(r, f.Argument(1)) @@ -524,7 +524,7 @@ func (n *runtimeJavascriptNakamaModule) metricsGaugeSet(r *goja.Runtime) func(go // @param name(type=string) The name of the custom metrics timer. // @param tags(type=map[string]string) The metrics tags associated with this timer. // @param value(type=number) An integer value to update this metric with (in nanoseconds). -func (n *runtimeJavascriptNakamaModule) metricsTimerRecord(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) metricsTimerRecord(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { name := getJsString(r, f.Argument(0)) tags := getJsStringMap(r, f.Argument(1)) @@ -539,7 +539,7 @@ func (n *runtimeJavascriptNakamaModule) metricsTimerRecord(r *goja.Runtime) func // @summary Generate a version 4 UUID in the standard 36-character string representation. // @return uuid(string) The newly generated version 4 UUID identifier string. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) uuidV4(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) uuidV4(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { return r.ToValue(uuid.Must(uuid.NewV4()).String()) } @@ -551,7 +551,7 @@ func (n *runtimeJavascriptNakamaModule) uuidV4(r *goja.Runtime) func(goja.Functi // @param timestamp(type=number) A time value expressed as UTC seconds. // @return next_ts(number) The next UTC seconds timestamp (number) that matches the given CRON expression, and is immediately after the given timestamp. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) cronNext(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) cronNext(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { cron := getJsString(r, f.Argument(0)) ts := getJsInt(r, f.Argument(1)) @@ -575,7 +575,7 @@ func (n *runtimeJavascriptNakamaModule) cronNext(r *goja.Runtime) func(goja.Func // @param timestamp(type=number) A time value expressed as UTC seconds. // @return prev_ts(number) The previous UTC seconds timestamp (number) that matches the given CRON expression, and is immediately before the given timestamp. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) cronPrev(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) cronPrev(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { cron := getJsString(r, f.Argument(0)) ts := getJsInt(r, f.Argument(1)) @@ -599,7 +599,7 @@ func (n *runtimeJavascriptNakamaModule) cronPrev(r *goja.Runtime) func(goja.Func // @param parameters(type=any[]) Arbitrary parameters to pass to placeholders in the query. // @return rowsAffected(number) A list of matches matching the parameters criteria. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) sqlExec(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) sqlExec(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { query := getJsString(r, f.Argument(0)) var args []interface{} @@ -640,7 +640,7 @@ func (n *runtimeJavascriptNakamaModule) sqlExec(r *goja.Runtime) func(goja.Funct // @param parameters(type=any[]) Arbitrary parameters to pass to placeholders in the query. // @return result(nkruntime.SqlQueryResult) An array of rows and the respective columns and values. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) sqlQuery(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) sqlQuery(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { query := getJsString(r, f.Argument(0)) var args []interface{} @@ -713,7 +713,7 @@ func (n *runtimeJavascriptNakamaModule) sqlQuery(r *goja.Runtime) func(goja.Func // @param insecure(type=bool, optional=true, default=false) Set to true to skip request TLS validations. // @return returnVal(nkruntime.httpResponse) Code, Headers, and Body response values for the HTTP response. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) httpRequest(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) httpRequest(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { url := getJsString(r, f.Argument(0)) method := strings.ToUpper(getJsString(r, f.Argument(1))) @@ -811,7 +811,7 @@ func (n *runtimeJavascriptNakamaModule) httpRequest(r *goja.Runtime) func(goja.F // @param input(type=string) The string which will be base64 encoded. // @return out(string) Encoded string. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) base64Encode(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) base64Encode(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { if goja.IsUndefined(f.Argument(0)) || goja.IsNull(f.Argument(0)) { panic(r.NewTypeError("expects a string or ArrayBuffer object")) @@ -848,7 +848,7 @@ func (n *runtimeJavascriptNakamaModule) base64Encode(r *goja.Runtime) func(goja. // @param padding(type=bool, optional=true, default=true) Pad the string if padding is missing. // @return out(ArrayBuffer) Decoded data. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) base64Decode(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) base64Decode(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { in := getJsString(r, f.Argument(0)) padding := true @@ -876,7 +876,7 @@ func (n *runtimeJavascriptNakamaModule) base64Decode(r *goja.Runtime) func(goja. // @param input(type=string) The string which will be base64 URL encoded. // @return out(string) Encoded string. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) base64UrlEncode(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) base64UrlEncode(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { if goja.IsUndefined(f.Argument(0)) || goja.IsNull(f.Argument(0)) { panic(r.NewTypeError("expects a string or ArrayBuffer object")) @@ -912,7 +912,7 @@ func (n *runtimeJavascriptNakamaModule) base64UrlEncode(r *goja.Runtime) func(go // @param input(type=string) The string to be decoded. // @return out(ArrayBuffer) Decoded data. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) base64UrlDecode(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) base64UrlDecode(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { in := getJsString(r, f.Argument(0)) padding := true @@ -940,7 +940,7 @@ func (n *runtimeJavascriptNakamaModule) base64UrlDecode(r *goja.Runtime) func(go // @param input(type=string) The string to be encoded. // @return out(string) Encoded string. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) base16Encode(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) base16Encode(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { if goja.IsUndefined(f.Argument(0)) || goja.IsNull(f.Argument(0)) { panic(r.NewTypeError("expects a string or ArrayBuffer object")) @@ -966,7 +966,7 @@ func (n *runtimeJavascriptNakamaModule) base16Encode(r *goja.Runtime) func(goja. // @param input(type=string) The string to be decoded. // @return out(ArrayBuffer) Decoded data. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) base16Decode(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) base16Decode(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { in := getJsString(r, f.Argument(0)) @@ -984,7 +984,7 @@ func (n *runtimeJavascriptNakamaModule) base16Decode(r *goja.Runtime) func(goja. // @param claims(type=[]string) The JWT payload. // @return signedToken(string) The newly generated JWT. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) jwtGenerate(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) jwtGenerate(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { algoType := getJsString(r, f.Argument(0)) @@ -1049,7 +1049,7 @@ func (n *runtimeJavascriptNakamaModule) jwtGenerate(r *goja.Runtime) func(goja.F // @param key(type=string) The 16 Byte encryption key. // @return cipherText(string) The ciphered input. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) aes128Encrypt(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) aes128Encrypt(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { input := getJsString(r, f.Argument(0)) key := getJsString(r, f.Argument(1)) @@ -1069,7 +1069,7 @@ func (n *runtimeJavascriptNakamaModule) aes128Encrypt(r *goja.Runtime) func(goja // @param key(type=string) The 16 Byte decryption key. // @return clearText(string) The deciphered input. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) aes128Decrypt(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) aes128Decrypt(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { input := getJsString(r, f.Argument(0)) key := getJsString(r, f.Argument(1)) @@ -1089,7 +1089,7 @@ func (n *runtimeJavascriptNakamaModule) aes128Decrypt(r *goja.Runtime) func(goja // @param key(type=string) The 32 Byte encryption key. // @return cipherText(string) The ciphered input. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) aes256Encrypt(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) aes256Encrypt(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { input := getJsString(r, f.Argument(0)) key := getJsString(r, f.Argument(1)) @@ -1109,7 +1109,7 @@ func (n *runtimeJavascriptNakamaModule) aes256Encrypt(r *goja.Runtime) func(goja // @param key(type=string) The 32 Byte decryption key. // @return clearText(string) The deciphered input. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) aes256Decrypt(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) aes256Decrypt(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { input := getJsString(r, f.Argument(0)) key := getJsString(r, f.Argument(1)) @@ -1130,7 +1130,7 @@ func (n *runtimeJavascriptNakamaModule) aes256Decrypt(r *goja.Runtime) func(goja // @param key(type=string) The encryption key. // @return cipherText(string) The ciphered and base64 encoded input. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) aesEncrypt(keySize int, input, key string) (string, error) { +func (n *RuntimeJavascriptNakamaModule) aesEncrypt(keySize int, input, key string) (string, error) { if len(key) != keySize { return "", fmt.Errorf("expects key %v bytes long", keySize) } @@ -1164,7 +1164,7 @@ func (n *runtimeJavascriptNakamaModule) aesEncrypt(keySize int, input, key strin // @param key(type=string) The encryption key. // @return clearText(string) The deciphered and decoded input. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) aesDecrypt(keySize int, input, key string) (string, error) { +func (n *RuntimeJavascriptNakamaModule) aesDecrypt(keySize int, input, key string) (string, error) { if len(key) != keySize { return "", fmt.Errorf("expects key %v bytes long", keySize) } @@ -1193,7 +1193,7 @@ func (n *runtimeJavascriptNakamaModule) aesDecrypt(keySize int, input, key strin // @param input(type=string) The input string to hash. // @return hash(string) A string with the md5 hash of the input. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) md5Hash(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) md5Hash(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { input := getJsString(r, f.Argument(0)) @@ -1208,7 +1208,7 @@ func (n *runtimeJavascriptNakamaModule) md5Hash(r *goja.Runtime) func(goja.Funct // @param input(type=string) The input string to hash. // @return hash(string) A string with the SHA256 hash of the input. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) sha256Hash(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) sha256Hash(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { input := getJsString(r, f.Argument(0)) @@ -1224,7 +1224,7 @@ func (n *runtimeJavascriptNakamaModule) sha256Hash(r *goja.Runtime) func(goja.Fu // @param key(type=string) The RSA private key. // @return signature(string) A string with the RSA encrypted SHA256 hash of the input. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) rsaSHA256Hash(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) rsaSHA256Hash(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { input := getJsString(r, f.Argument(0)) key := getJsString(r, f.Argument(1)) @@ -1257,7 +1257,7 @@ func (n *runtimeJavascriptNakamaModule) rsaSHA256Hash(r *goja.Runtime) func(goja // @param key(type=string) The hashing key. // @return mac(string) Hashed input as a string using the key. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) hmacSHA256Hash(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) hmacSHA256Hash(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { input := getJsString(r, f.Argument(0)) key := getJsString(r, f.Argument(1)) @@ -1280,7 +1280,7 @@ func (n *runtimeJavascriptNakamaModule) hmacSHA256Hash(r *goja.Runtime) func(goj // @param input(type=string) The input string to bcrypt. // @return hash(string) Hashed string. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) bcryptHash(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) bcryptHash(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { input := getJsString(r, f.Argument(0)) hash, err := bcrypt.GenerateFromPassword([]byte(input), bcrypt.DefaultCost) @@ -1298,7 +1298,7 @@ func (n *runtimeJavascriptNakamaModule) bcryptHash(r *goja.Runtime) func(goja.Fu // @param plaintext(type=string) Plaintext input to compare against. // @return result(bool) True if they are the same, false otherwise. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) bcryptCompare(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) bcryptCompare(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { hash := getJsString(r, f.Argument(0)) if hash == "" { @@ -1330,7 +1330,7 @@ func (n *runtimeJavascriptNakamaModule) bcryptCompare(r *goja.Runtime) func(goja // @return username(string) The username of the authenticated user. // @return create(bool) Value indicating if this account was just created or already existed. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) authenticateApple(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) authenticateApple(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { if n.config.GetSocial().Apple.BundleId == "" { panic(r.NewGoError(errors.New("Apple authentication is not configured"))) @@ -1381,7 +1381,7 @@ func (n *runtimeJavascriptNakamaModule) authenticateApple(r *goja.Runtime) func( // @return username(string) The username of the authenticated user. // @return create(bool) Value indicating if this account was just created or already existed. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) authenticateCustom(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) authenticateCustom(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { id := getJsString(r, f.Argument(0)) if id == "" { @@ -1432,7 +1432,7 @@ func (n *runtimeJavascriptNakamaModule) authenticateCustom(r *goja.Runtime) func // @return username(string) The username of the authenticated user. // @return create(bool) Value indicating if this account was just created or already existed. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) authenticateDevice(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) authenticateDevice(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { id := getJsString(r, f.Argument(0)) if id == "" { @@ -1484,7 +1484,7 @@ func (n *runtimeJavascriptNakamaModule) authenticateDevice(r *goja.Runtime) func // @return username(string) The username of the authenticated user. // @return create(bool) Value indicating if this account was just created or already existed. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) authenticateEmail(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) authenticateEmail(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { var attemptUsernameLogin bool // Parse email. @@ -1562,7 +1562,7 @@ func (n *runtimeJavascriptNakamaModule) authenticateEmail(r *goja.Runtime) func( // @return username(string) The username of the authenticated user. // @return create(bool) Value indicating if this account was just created or already existed. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) authenticateFacebook(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) authenticateFacebook(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { token := getJsString(r, f.Argument(0)) if token == "" { @@ -1619,7 +1619,7 @@ func (n *runtimeJavascriptNakamaModule) authenticateFacebook(r *goja.Runtime) fu // @return username(string) The username of the authenticated user. // @return create(bool) Value indicating if this account was just created or already existed. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) authenticateFacebookInstantGame(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) authenticateFacebookInstantGame(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { signedPlayerInfo := getJsString(r, f.Argument(0)) if signedPlayerInfo == "" { @@ -1671,7 +1671,7 @@ func (n *runtimeJavascriptNakamaModule) authenticateFacebookInstantGame(r *goja. // @return username(string) The username of the authenticated user. // @return create(bool) Value indicating if this account was just created or already existed. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) authenticateGameCenter(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) authenticateGameCenter(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { playerID := getJsString(r, f.Argument(0)) if playerID == "" { @@ -1738,7 +1738,7 @@ func (n *runtimeJavascriptNakamaModule) authenticateGameCenter(r *goja.Runtime) // @return username(string) The username of the authenticated user. // @return create(bool) Value indicating if this account was just created or already existed. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) authenticateGoogle(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) authenticateGoogle(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { token := getJsString(r, f.Argument(0)) if token == "" { @@ -1786,7 +1786,7 @@ func (n *runtimeJavascriptNakamaModule) authenticateGoogle(r *goja.Runtime) func // @return username(string) The username of the authenticated user. // @return create(bool) Value indicating if this account was just created or already existed. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) authenticateSteam(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) authenticateSteam(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { if n.config.GetSocial().Steam.PublisherKey == "" || n.config.GetSocial().Steam.AppID == 0 { panic(r.NewGoError(errors.New("Steam authentication is not configured"))) @@ -1848,7 +1848,7 @@ func (n *runtimeJavascriptNakamaModule) authenticateSteam(r *goja.Runtime) func( // @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. -func (n *runtimeJavascriptNakamaModule) authenticateTokenGenerate(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) authenticateTokenGenerate(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { // Parse input User ID. userIDString := getJsString(r, f.Argument(0)) @@ -1896,7 +1896,7 @@ func (n *runtimeJavascriptNakamaModule) authenticateTokenGenerate(r *goja.Runtim // @param userId(type=string) User ID to fetch information for. Must be valid UUID. // @return account(nkruntime.Account) All account information including wallet, device IDs and more. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) accountGetId(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) accountGetId(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { input := getJsString(r, f.Argument(0)) if input == "" { @@ -1926,7 +1926,7 @@ func (n *runtimeJavascriptNakamaModule) accountGetId(r *goja.Runtime) func(goja. // @param userIds(type=[]string) Array of user IDs to fetch information for. Must be valid UUID. // @return account(nkruntime.Account[]) Array of accounts. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) accountsGetId(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) accountsGetId(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { input := f.Argument(0) if input == goja.Undefined() || input == goja.Null() { @@ -1972,7 +1972,7 @@ func (n *runtimeJavascriptNakamaModule) accountsGetId(r *goja.Runtime) func(goja // @param language(type=string, optional=true) Lang tag to be updated. Use null if it is not being updated. // @param avatarUrl(type=string, optional=true) User's avatar URL. Use null if it is not being updated. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) accountUpdateId(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) accountUpdateId(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { userID, err := uuid.FromString(getJsString(r, f.Argument(0))) if err != nil { @@ -2044,7 +2044,7 @@ func (n *runtimeJavascriptNakamaModule) accountUpdateId(r *goja.Runtime) func(go // @param userId(type=string) User ID for the account to be deleted. Must be valid UUID. // @param recorded(type=bool, optional=true, default=false) Whether to record this deletion in the database. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) accountDeleteId(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) accountDeleteId(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { userID, err := uuid.FromString(getJsString(r, f.Argument(0))) if err != nil { @@ -2069,7 +2069,7 @@ func (n *runtimeJavascriptNakamaModule) accountDeleteId(r *goja.Runtime) func(go // @param userId(type=string) User ID for the account to be exported. Must be valid UUID. // @return export(string) Account information for the provided user ID, in JSON format. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) accountExportId(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) accountExportId(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { userID, err := uuid.FromString(getJsString(r, f.Argument(0))) if err != nil { @@ -2095,7 +2095,7 @@ func (n *runtimeJavascriptNakamaModule) accountExportId(r *goja.Runtime) func(go // @param userIds(type=[]string) An array of user IDs to fetch. // @return users(nkruntime.User[]) A list of user record objects. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) usersGetId(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) usersGetId(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { var userIds []string userIdsIn := f.Argument(0) @@ -2149,7 +2149,7 @@ func (n *runtimeJavascriptNakamaModule) usersGetId(r *goja.Runtime) func(goja.Fu // @param usernames(type=[]string) An array of usernames to fetch. // @return users(nkruntime.User[]) A list of user record objects. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) usersGetUsername(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) usersGetUsername(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { usernamesIn := f.Argument(0) if usernamesIn == goja.Undefined() || usernamesIn == goja.Null() { @@ -2185,7 +2185,7 @@ func (n *runtimeJavascriptNakamaModule) usersGetUsername(r *goja.Runtime) func(g // @param userIDs(type=string[]) An array of target user IDs. // @return friends(nkruntime.Friend[]) A list of user friends objects. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) usersGetFriendStatus(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) usersGetFriendStatus(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { id := getJsString(r, f.Argument(0)) @@ -2239,7 +2239,7 @@ func (n *runtimeJavascriptNakamaModule) usersGetFriendStatus(r *goja.Runtime) fu // @param count(type=number) The number of users to fetch. // @return users(nkruntime.User[]) A list of user record objects. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) usersGetRandom(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) usersGetRandom(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { count := getJsInt(r, f.Argument(0)) @@ -2269,7 +2269,7 @@ func (n *runtimeJavascriptNakamaModule) usersGetRandom(r *goja.Runtime) func(goj // @summary Ban one or more users by ID. // @param userIds(type=string[]) An array of user IDs to ban. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) usersBanId(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) usersBanId(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { userIdsIn := f.Argument(0) if userIdsIn == goja.Undefined() || userIdsIn == goja.Null() { @@ -2302,7 +2302,7 @@ func (n *runtimeJavascriptNakamaModule) usersBanId(r *goja.Runtime) func(goja.Fu // @summary Unban one or more users by ID. // @param userIds(type=string[]) An array of user IDs to unban. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) usersUnbanId(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) usersUnbanId(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { userIdsIn := f.Argument(0) if userIdsIn == goja.Undefined() || userIdsIn == goja.Null() { @@ -2336,7 +2336,7 @@ func (n *runtimeJavascriptNakamaModule) usersUnbanId(r *goja.Runtime) func(goja. // @param userId(type=string) The user ID to be linked. // @param token(type=string) Apple sign in token. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) linkApple(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) linkApple(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { userID := getJsString(r, f.Argument(0)) id, err := uuid.FromString(userID) @@ -2362,7 +2362,7 @@ func (n *runtimeJavascriptNakamaModule) linkApple(r *goja.Runtime) func(goja.Fun // @param userId(type=string) The user ID to be linked. // @param customId(type=string) Custom ID to be linked to the user. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) linkCustom(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) linkCustom(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { userID := getJsString(r, f.Argument(0)) id, err := uuid.FromString(userID) @@ -2388,7 +2388,7 @@ func (n *runtimeJavascriptNakamaModule) linkCustom(r *goja.Runtime) func(goja.Fu // @param userId(type=string) The user ID to be linked. // @param deviceId(type=string) Device ID to be linked to the user. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) linkDevice(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) linkDevice(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { userID := getJsString(r, f.Argument(0)) id, err := uuid.FromString(userID) @@ -2415,7 +2415,7 @@ func (n *runtimeJavascriptNakamaModule) linkDevice(r *goja.Runtime) func(goja.Fu // @param email(type=string) Authentication email to be linked to the user. // @param password(type=string) Password to set. Must be longer than 8 characters. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) linkEmail(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) linkEmail(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { userID := getJsString(r, f.Argument(0)) id, err := uuid.FromString(userID) @@ -2447,7 +2447,7 @@ func (n *runtimeJavascriptNakamaModule) linkEmail(r *goja.Runtime) func(goja.Fun // @param token(type=string) Facebook OAuth or Limited Login (JWT) access token. // @param importFriends(type=bool, optional=true, default=true) Whether to automatically import Facebook friends after authentication. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) linkFacebook(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) linkFacebook(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { userID := getJsString(r, f.Argument(0)) id, err := uuid.FromString(userID) @@ -2481,7 +2481,7 @@ func (n *runtimeJavascriptNakamaModule) linkFacebook(r *goja.Runtime) func(goja. // @param userId(type=string) The user ID to be linked. // @param playerInfo(type=string) Facebook player info. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) linkFacebookInstantGame(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) linkFacebookInstantGame(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { userID := getJsString(r, f.Argument(0)) id, err := uuid.FromString(userID) @@ -2512,7 +2512,7 @@ func (n *runtimeJavascriptNakamaModule) linkFacebookInstantGame(r *goja.Runtime) // @param signature(type=string) A signature returned by Game Center authentication on client. // @param publicKeyUrl(type=string) A URL to the public key returned by Game Center authentication on client. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) linkGameCenter(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) linkGameCenter(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { userID := getJsString(r, f.Argument(0)) id, err := uuid.FromString(userID) @@ -2558,7 +2558,7 @@ func (n *runtimeJavascriptNakamaModule) linkGameCenter(r *goja.Runtime) func(goj // @param userId(type=string) The user ID to be linked. // @param token(type=string) Google OAuth access token. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) linkGoogle(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) linkGoogle(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { userID := getJsString(r, f.Argument(0)) id, err := uuid.FromString(userID) @@ -2586,7 +2586,7 @@ func (n *runtimeJavascriptNakamaModule) linkGoogle(r *goja.Runtime) func(goja.Fu // @param token(type=string) Steam access token. // @param importFriends(type=bool, optional=true, default=true) Whether to automatically import Steam friends after authentication. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) linkSteam(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) linkSteam(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { userID := getJsString(r, f.Argument(0)) id, err := uuid.FromString(userID) @@ -2620,7 +2620,7 @@ func (n *runtimeJavascriptNakamaModule) linkSteam(r *goja.Runtime) func(goja.Fun // @param userId(type=string) The user ID to be unlinked. // @param token(type=string) Apple sign in token. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) unlinkApple(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) unlinkApple(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { userID := getJsString(r, f.Argument(0)) id, err := uuid.FromString(userID) @@ -2646,7 +2646,7 @@ func (n *runtimeJavascriptNakamaModule) unlinkApple(r *goja.Runtime) func(goja.F // @param userId(type=string) The user ID to be unlinked. // @param customId(type=string, optional=true) Custom ID to be unlinked from the user. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) unlinkCustom(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) unlinkCustom(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { userID := getJsString(r, f.Argument(0)) id, err := uuid.FromString(userID) @@ -2672,7 +2672,7 @@ func (n *runtimeJavascriptNakamaModule) unlinkCustom(r *goja.Runtime) func(goja. // @param userId(type=string) The user ID to be unlinked. // @param deviceId(type=string) Device ID to be unlinked to the user. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) unlinkDevice(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) unlinkDevice(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { userID := getJsString(r, f.Argument(0)) id, err := uuid.FromString(userID) @@ -2698,7 +2698,7 @@ func (n *runtimeJavascriptNakamaModule) unlinkDevice(r *goja.Runtime) func(goja. // @param userId(type=string) The user ID to be unlinked. // @param email(type=string, optional=true) Email to be unlinked from the user. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) unlinkEmail(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) unlinkEmail(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { userID := getJsString(r, f.Argument(0)) id, err := uuid.FromString(userID) @@ -2724,7 +2724,7 @@ func (n *runtimeJavascriptNakamaModule) unlinkEmail(r *goja.Runtime) func(goja.F // @param userId(type=string) The user ID to be unlinked. // @param token(type=string, optional=true) Facebook OAuth or Limited Login (JWT) access token. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) unlinkFacebook(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) unlinkFacebook(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { userID := getJsString(r, f.Argument(0)) id, err := uuid.FromString(userID) @@ -2750,7 +2750,7 @@ func (n *runtimeJavascriptNakamaModule) unlinkFacebook(r *goja.Runtime) func(goj // @param userId(type=string) The user ID to be unlinked. // @param playerInfo(type=string, optional=true) Facebook player info. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) unlinkFacebookInstantGame(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) unlinkFacebookInstantGame(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { userID := getJsString(r, f.Argument(0)) id, err := uuid.FromString(userID) @@ -2781,7 +2781,7 @@ func (n *runtimeJavascriptNakamaModule) unlinkFacebookInstantGame(r *goja.Runtim // @param signature(type=string) A signature returned by Game Center authentication on client. // @param publicKeyUrl(type=string) A URL to the public key returned by Game Center authentication on client. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) unlinkGameCenter(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) unlinkGameCenter(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { userID := getJsString(r, f.Argument(0)) id, err := uuid.FromString(userID) @@ -2827,7 +2827,7 @@ func (n *runtimeJavascriptNakamaModule) unlinkGameCenter(r *goja.Runtime) func(g // @param userId(type=string) The user ID to be unlinked. // @param token(type=string, optional=true) Google OAuth access token. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) unlinkGoogle(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) unlinkGoogle(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { userID := getJsString(r, f.Argument(0)) id, err := uuid.FromString(userID) @@ -2853,7 +2853,7 @@ func (n *runtimeJavascriptNakamaModule) unlinkGoogle(r *goja.Runtime) func(goja. // @param userId(type=string) The user ID to be unlinked. // @param token(type=string, optional=true) Steam access token. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) unlinkSteam(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) unlinkSteam(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { userID := getJsString(r, f.Argument(0)) id, err := uuid.FromString(userID) @@ -2881,7 +2881,7 @@ func (n *runtimeJavascriptNakamaModule) unlinkSteam(r *goja.Runtime) func(goja.F // @param includeNotHidden(type=bool, optional=true) Include stream presences not marked as hidden in the results. // @return presences(nkruntime.Presences[]) Array of stream presences and their information. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) streamUserList(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) streamUserList(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { streamIn := f.Argument(0) if streamIn == goja.Undefined() { @@ -2928,7 +2928,7 @@ func (n *runtimeJavascriptNakamaModule) streamUserList(r *goja.Runtime) func(goj // @param stream(type=nkruntime.Stream) A stream object. // @return meta(nkruntime.Presence) Presence for the user. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) streamUserGet(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) streamUserGet(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { userIDString := getJsString(r, f.Argument(0)) if userIDString == "" { @@ -2983,7 +2983,7 @@ func (n *runtimeJavascriptNakamaModule) streamUserGet(r *goja.Runtime) func(goja // @param status(type=string) User status message. // @return success(bool) Whether the user was successfully added. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) streamUserJoin(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) streamUserJoin(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { userIDString := getJsString(r, f.Argument(0)) if userIDString == "" { @@ -3054,7 +3054,7 @@ func (n *runtimeJavascriptNakamaModule) streamUserJoin(r *goja.Runtime) func(goj // @param persistence(type=bool) Whether message data should be stored in the database. // @param status(type=string) User status message. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) streamUserUpdate(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) streamUserUpdate(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { userIDString := getJsString(r, f.Argument(0)) if userIDString == "" { @@ -3122,7 +3122,7 @@ func (n *runtimeJavascriptNakamaModule) streamUserUpdate(r *goja.Runtime) func(g // @param sessionId(type=string) The current session ID for the user. // @param stream(type=nkruntime.Stream) A stream object. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) streamUserLeave(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) streamUserLeave(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { userIDString := getJsString(r, f.Argument(0)) if userIDString == "" { @@ -3166,7 +3166,7 @@ func (n *runtimeJavascriptNakamaModule) streamUserLeave(r *goja.Runtime) func(go // @param presence(type=nkruntime.Presence) The presence to be kicked. // @param stream(type=nkruntime.Stream) A stream object. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) streamUserKick(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) streamUserKick(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { presenceIn := f.Argument(0) if presenceIn == goja.Undefined() { @@ -3244,7 +3244,7 @@ func (n *runtimeJavascriptNakamaModule) streamUserKick(r *goja.Runtime) func(goj // @param stream(type=nkruntime.Stream) A stream object. // @return countByStream(number) Number of current stream presences. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) streamCount(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) streamCount(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { streamIn := f.Argument(0) if streamIn == goja.Undefined() { @@ -3267,7 +3267,7 @@ func (n *runtimeJavascriptNakamaModule) streamCount(r *goja.Runtime) func(goja.F // @summary Close a stream and remove all presences on it. // @param stream(type=nkruntime.Stream) A stream object. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) streamClose(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) streamClose(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { streamIn := f.Argument(0) if streamIn == goja.Undefined() { @@ -3293,7 +3293,7 @@ func (n *runtimeJavascriptNakamaModule) streamClose(r *goja.Runtime) func(goja.F // @param presences(type=nkruntime.Presence[], optional=true, default=all) Array of presences to receive the sent data. // @param reliable(type=bool, optional=true, default=true) Whether the sender has been validated prior. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) streamSend(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) streamSend(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { streamIn := f.Argument(0) if streamIn == goja.Undefined() { @@ -3389,7 +3389,7 @@ func (n *runtimeJavascriptNakamaModule) streamSend(r *goja.Runtime) func(goja.Fu // @param presences(type=nkruntime.Presence[], optional=true, default=all) Array of presences to receive the sent data. // @param reliable(type=bool, optional=true, default=true) Whether the sender has been validated prior. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) streamSendRaw(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) streamSendRaw(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { streamIn := f.Argument(0) if streamIn == goja.Undefined() { @@ -3477,7 +3477,7 @@ func (n *runtimeJavascriptNakamaModule) streamSendRaw(r *goja.Runtime) func(goja // @param sessionId(type=string) The ID of the session to be disconnected. // @param reason(type=nkruntime.PresenceReason) The reason for the session disconnect. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) sessionDisconnect(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) sessionDisconnect(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { sessionIDString := getJsString(r, f.Argument(0)) if sessionIDString == "" { @@ -3511,7 +3511,7 @@ func (n *runtimeJavascriptNakamaModule) sessionDisconnect(r *goja.Runtime) func( // @param token(type=string, optional=true) The current session authentication token. If the current auth and refresh tokens are not provided, all user sessions will be logged out. // @param refreshToken(type=string, optional=true) The current session refresh token. If the current auth and refresh tokens are not provided, all user sessions will be logged out. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) sessionLogout(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) sessionLogout(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { userIDString := getJsString(r, f.Argument(0)) if userIDString == "" { @@ -3556,7 +3556,7 @@ func (n *runtimeJavascriptNakamaModule) sessionLogout(r *goja.Runtime) func(goja // @param params(type={[key:string]:any}, optional=true) Any value to pass to the match init hook. // @return matchId(string) The match ID of the newly created match. Clients can immediately use this ID to join the match. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) matchCreate(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) matchCreate(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { module := getJsString(r, f.Argument(0)) if module == "" { @@ -3589,7 +3589,7 @@ func (n *runtimeJavascriptNakamaModule) matchCreate(r *goja.Runtime) func(goja.F // @param id(type=string) The ID of the match to fetch. // @return match(nkruntime.Match) Information for the running match. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) matchGet(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) matchGet(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { id := getJsString(r, f.Argument(0)) @@ -3627,7 +3627,7 @@ func (n *runtimeJavascriptNakamaModule) matchGet(r *goja.Runtime) func(goja.Func // @param query(type=string, optional=true) Additional query parameters to shortlist matches. // @return match(nkruntime.Match[]) A list of matches matching the parameters criteria. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) matchList(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) matchList(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { limit := 1 if f.Argument(0) != goja.Undefined() { @@ -3691,7 +3691,7 @@ func (n *runtimeJavascriptNakamaModule) matchList(r *goja.Runtime) func(goja.Fun // @return state(interface{}) An (optionally) updated state. May be any non-nil value, or nil to end the match. // @return data(string) Arbitrary data to return to the runtime caller of the signal. May be a string or nil. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) matchSignal(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) matchSignal(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { id := getJsString(r, f.Argument(0)) var data string @@ -3717,7 +3717,7 @@ func (n *runtimeJavascriptNakamaModule) matchSignal(r *goja.Runtime) func(goja.F // @param sender(type=string, optional=true) The sender of this notification. If left empty, it will be assumed that it is a system notification. // @param persistent(type=bool, optional=true, default=false) Whether to record this in the database for later listing. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) notificationSend(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) notificationSend(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { userIDString := getJsString(r, f.Argument(0)) userID, err := uuid.FromString(userIDString) @@ -3792,7 +3792,7 @@ func (n *runtimeJavascriptNakamaModule) notificationSend(r *goja.Runtime) func(g // @param cursor(type=string, optional=true, default="") Pagination cursor from previous result. Don't set to start fetching from the beginning. // @return notifications(nkruntime.NotificationList) A list of notifications. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) notificationsList(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) notificationsList(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { userIDString := getJsString(r, f.Argument(0)) if userIDString == "" { @@ -3855,7 +3855,7 @@ func (n *runtimeJavascriptNakamaModule) notificationsList(r *goja.Runtime) func( // @summary Send one or more in-app notifications to a user. // @param notifications(type=any[]) A list of notifications to be sent together. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) notificationsSend(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) notificationsSend(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { notificationsIn := f.Argument(0) if notificationsIn == goja.Undefined() || notificationsIn == goja.Null() { @@ -3971,7 +3971,7 @@ func (n *runtimeJavascriptNakamaModule) notificationsSend(r *goja.Runtime) func( // @param code(type=number) Notification code to use. Must be greater than or equal to 0. // @param persistent(type=bool, optional=true, default=false) Whether to record this in the database for later listing. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) notificationSendAll(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) notificationSendAll(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { subject := getJsString(r, f.Argument(0)) if subject == "" { @@ -4027,7 +4027,7 @@ func (n *runtimeJavascriptNakamaModule) notificationSendAll(r *goja.Runtime) fun // @summary Delete one or more in-app notifications. // @param notifications(type=any[]) A list of notifications to be deleted. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) notificationsDelete(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) notificationsDelete(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { notificationsIn := f.Argument(0) if notificationsIn == goja.Undefined() || notificationsIn == goja.Null() { @@ -4089,7 +4089,7 @@ func (n *runtimeJavascriptNakamaModule) notificationsDelete(r *goja.Runtime) fun // @summary Update notifications by their id. // @param updates(type=nkruntime.NotificationUpdate[]) // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) notificationsUpdate(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) notificationsUpdate(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { updatesIn := f.Argument(0) @@ -4159,7 +4159,7 @@ func (n *runtimeJavascriptNakamaModule) notificationsUpdate(r *goja.Runtime) fun // @param userID(type=string) Optional userID to scope results to that user only. // @return notifications(type=runtime.Notification[]) A list of notifications. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) notificationsGetId(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) notificationsGetId(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { notifIdsIn := f.Argument(0) @@ -4218,7 +4218,7 @@ func (n *runtimeJavascriptNakamaModule) notificationsGetId(r *goja.Runtime) func // @param ids(type=string[]) A list of notification ids. // @param userID(type=string) Optional userID to scope deletions to that user only. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) notificationsDeleteId(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) notificationsDeleteId(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { notifIdsIn := f.Argument(0) @@ -4262,7 +4262,7 @@ func (n *runtimeJavascriptNakamaModule) notificationsDeleteId(r *goja.Runtime) f // @param updateLedger(type=bool, optional=true, default=false) Whether to record this update in the ledger. // @return result(nkruntime.WalletUpdateResult) The changeset after the update and before to the update, respectively. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) walletUpdate(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) walletUpdate(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { uid := getJsString(r, f.Argument(0)) if uid == "" { @@ -4331,7 +4331,7 @@ func (n *runtimeJavascriptNakamaModule) walletUpdate(r *goja.Runtime) func(goja. // @param updateLedger(type=bool, optional=true, default=false) Whether to record this update in the ledger. // @return updateWallets(nkruntime.WalletUpdateResult[]) A list of wallet update results. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) walletsUpdate(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) walletsUpdate(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { updatesIn, err := exportToSlice[[]map[string]any](f.Argument(0)) if err != nil { @@ -4422,7 +4422,7 @@ func (n *runtimeJavascriptNakamaModule) walletsUpdate(r *goja.Runtime) func(goja // @param metadata(type=object) The new metadata to set on the wallet ledger item. // @return updateWalletLedger(nkruntime.WalletLedgerItem) The updated wallet ledger item. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) walletLedgerUpdate(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) walletLedgerUpdate(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { // Parse ledger ID. id := getJsString(r, f.Argument(0)) @@ -4463,7 +4463,7 @@ func (n *runtimeJavascriptNakamaModule) walletLedgerUpdate(r *goja.Runtime) func // @param sessionID(type=string) A valid session identifier. // @param userIDs(type=string[]) A list of userIDs to follow. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) statusFollow(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) statusFollow(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { sid := getJsString(r, f.Argument(0)) @@ -4503,7 +4503,7 @@ func (n *runtimeJavascriptNakamaModule) statusFollow(r *goja.Runtime) func(goja. // @param sessionID(type=string) A valid session identifier. // @param userIDs(type=string[]) A list of userIDs to unfollow. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) statusUnfollow(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) statusUnfollow(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { sid := getJsString(r, f.Argument(0)) @@ -4545,7 +4545,7 @@ func (n *runtimeJavascriptNakamaModule) statusUnfollow(r *goja.Runtime) func(goj // @param cursor(type=string, optional=true, default="") Pagination cursor from previous result. Don't set to start fetching from the beginning. // @return runtimeItems(nkruntime.WalletLedgerItem[]) A JavaScript Object containing wallet entries with Id, UserId, CreateTime, UpdateTime, Changeset, Metadata parameters, and possibly a cursor. If cursor is empty/null there are no further results. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) walletLedgerList(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) walletLedgerList(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { id := getJsString(r, f.Argument(0)) if id == "" { @@ -4605,7 +4605,7 @@ func (n *runtimeJavascriptNakamaModule) walletLedgerList(r *goja.Runtime) func(g // @return objects(nkruntime.StorageObjectList) A list of storage objects. // @return cursor(string) Pagination cursor. Will be set to "" or null when fetching last available page. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) storageList(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) storageList(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { var uid *uuid.UUID if f.Argument(0) != goja.Undefined() && f.Argument(0) != goja.Null() { @@ -4695,7 +4695,7 @@ func (n *runtimeJavascriptNakamaModule) storageList(r *goja.Runtime) func(goja.F // @param objectIds(type=nkruntime.StorageReadRequest[]) An array of object identifiers to be fetched. // @return objects(nkruntime.StorageObject[]) A list of storage records matching the parameters criteria. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) storageRead(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) storageRead(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { keysIn := f.Argument(0) if keysIn == goja.Undefined() || keysIn == goja.Null() { @@ -4796,7 +4796,7 @@ func (n *runtimeJavascriptNakamaModule) storageRead(r *goja.Runtime) func(goja.F // @param objectIds(type=nkruntime.StorageWriteRequest[]) An array of object identifiers to be written. // @return acks(nkruntime.StorageWriteAck[]) A list of acks with the version of the written objects. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) storageWrite(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) storageWrite(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { data := f.Argument(0) if data == goja.Undefined() || data == goja.Null() { @@ -4938,7 +4938,7 @@ func jsArrayToStorageOpWrites(dataSlice []map[string]any) (StorageOpWrites, erro // @summary Remove one or more objects by their collection/keyname and optional user. // @param objectIds(type=nkruntime.StorageDeleteRequest[]) An array of object identifiers to be deleted. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) storageDelete(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) storageDelete(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { keysIn := f.Argument(0) if keysIn == goja.Undefined() { @@ -5029,7 +5029,7 @@ func (n *runtimeJavascriptNakamaModule) storageDelete(r *goja.Runtime) func(goja // @return storageWriteAcks(nkruntime.StorageWriteAck[]) A list of acks with the version of the written objects. // @return walletUpdateAcks(nkruntime.WalletUpdateResult[]) A list of wallet updates results. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) multiUpdate(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) multiUpdate(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { // Process account update inputs. var accountUpdates []*accountUpdate @@ -5415,7 +5415,7 @@ func (n *runtimeJavascriptNakamaModule) multiUpdate(r *goja.Runtime) func(goja.F // @param metadata(type=object, optional=true) The metadata you want associated to the leaderboard. Some good examples are weather conditions for a racing game. // @param enableRanks(type=bool, optional=true, default=false) Whether to enable rank values for the leaderboard. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) leaderboardCreate(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) leaderboardCreate(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { id := getJsString(r, f.Argument(0)) if id == "" { @@ -5506,7 +5506,7 @@ func (n *runtimeJavascriptNakamaModule) leaderboardCreate(r *goja.Runtime) func( // @summary Delete a leaderboard and all scores that belong to it. // @param id(type=string) The unique identifier for the leaderboard to delete. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) leaderboardDelete(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) leaderboardDelete(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { id := getJsString(r, f.Argument(0)) if id == "" { @@ -5528,7 +5528,7 @@ func (n *runtimeJavascriptNakamaModule) leaderboardDelete(r *goja.Runtime) func( // @param cursor(type=string, optional=true, default="") Pagination cursor from previous result. Don't set to start fetching from the beginning. // @return leaderboardList(nkruntime.LeaderboardList[]) A list of leaderboard results and possibly a cursor. If cursor is empty/null there are no further results. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) leaderboardList(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) leaderboardList(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { limit := 10 if f.Argument(0) != goja.Undefined() && f.Argument(0) != goja.Null() { @@ -5584,7 +5584,7 @@ func (n *runtimeJavascriptNakamaModule) leaderboardList(r *goja.Runtime) func(go // @summary Disable a leaderboard rank cache freeing its allocated resources. If already disabled is a NOOP. // @param id(type=string) The leaderboard id. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) leaderboardRanksDisable(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) leaderboardRanksDisable(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { id := getJsString(r, f.Argument(0)) @@ -5608,7 +5608,7 @@ func (n *runtimeJavascriptNakamaModule) leaderboardRanksDisable(r *goja.Runtime) // @return nextCursor(string) An optional next page cursor that can be used to retrieve the next page of records (if any). Will be set to "" or null when fetching last available page. // @return prevCursor(string) An optional previous page cursor that can be used to retrieve the previous page of records (if any). // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) leaderboardRecordsList(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) leaderboardRecordsList(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { id := getJsString(r, f.Argument(0)) if id == "" { @@ -5666,7 +5666,7 @@ func (n *runtimeJavascriptNakamaModule) leaderboardRecordsList(r *goja.Runtime) // @param overrideExpiry(type=number, optional=true) Records with expiry in the past are not returned unless within this defined limit. Must be equal or greater than 0. // @return leaderboardListCursor(string) A string cursor to be used with leaderboardRecordsList. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) leaderboardRecordsListCursorFromRank(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) leaderboardRecordsListCursorFromRank(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { leaderboardId := getJsString(r, f.Argument(0)) rank := getJsInt(r, f.Argument(1)) @@ -5734,7 +5734,7 @@ func (n *runtimeJavascriptNakamaModule) leaderboardRecordsListCursorFromRank(r * // @param metadata(type=object, optional=true) The metadata you want associated to this submission. Some good examples are weather conditions for a racing game. // @return record(nkruntime.LeaderboardRecord) The newly created leaderboard record. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) leaderboardRecordWrite(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) leaderboardRecordWrite(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { id := getJsString(r, f.Argument(0)) if id == "" { @@ -5806,7 +5806,7 @@ func (n *runtimeJavascriptNakamaModule) leaderboardRecordWrite(r *goja.Runtime) // @param id(type=string) The unique identifier for the leaderboard to delete from. // @param owner(type=string) The owner of the score to delete. Mandatory field. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) leaderboardRecordDelete(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) leaderboardRecordDelete(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { id := getJsString(r, f.Argument(0)) if id == "" { @@ -5831,7 +5831,7 @@ func (n *runtimeJavascriptNakamaModule) leaderboardRecordDelete(r *goja.Runtime) // @param ids(type=string[]) The array of leaderboard ids. // @return leaderboards(nkruntime.Leaderboard[]) The leaderboard records according to ID. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) leaderboardsGetId(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) leaderboardsGetId(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { leaderboardIdsIn := f.Argument(0) if leaderboardIdsIn == goja.Undefined() || leaderboardIdsIn == goja.Null() { @@ -5867,7 +5867,7 @@ func (n *runtimeJavascriptNakamaModule) leaderboardsGetId(r *goja.Runtime) func( // @param overrideExpiry(type=number, optional=true, default=0) Optionally retrieve records from previous resets by specifying the reset point in time in UTC seconds. Must be equal or greater than 0. // @return records(nkruntime.LeaderboardRecordList) The leaderboard records according to ID and possibly a cursor. If cursor is empty/null there are no further results. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) leaderboardRecordsHaystack(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) leaderboardRecordsHaystack(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { id := getJsString(r, f.Argument(0)) if id == "" { @@ -5915,7 +5915,7 @@ func (n *runtimeJavascriptNakamaModule) leaderboardRecordsHaystack(r *goja.Runti // @param passwordOverride(type=string, optional=true) Override the iap.apple.shared_password provided in your configuration. // @return validation(nkruntime.ValidatePurchaseResponse) The resulting successfully validated purchases. Any previously validated purchases are returned with a seenBefore flag. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) purchaseValidateApple(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) purchaseValidateApple(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { password := n.config.GetIAP().Apple.SharedPassword if f.Argument(3) != goja.Undefined() { @@ -5963,7 +5963,7 @@ func (n *runtimeJavascriptNakamaModule) purchaseValidateApple(r *goja.Runtime) f // @param persist(type=bool, optional=true, default=true) Persist the purchase so that seenBefore can be computed to protect against replay attacks. // @return validation(nkruntime.ValidatePurchaseResponse) The resulting successfully validated purchases. Any previously validated purchases are returned with a seenBefore flag. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) purchaseValidateGoogle(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) purchaseValidateGoogle(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { clientEmail := n.config.GetIAP().Google.ClientEmail privateKey := n.config.GetIAP().Google.PrivateKey @@ -6016,7 +6016,7 @@ func (n *runtimeJavascriptNakamaModule) purchaseValidateGoogle(r *goja.Runtime) // @param persist(type=bool, optional=true, default=true) Persist the purchase so that seenBefore can be computed to protect against replay attacks. // @return validation(nkruntime.ValidatePurchaseResponse) The resulting successfully validated purchases. Any previously validated purchases are returned with a seenBefore flag. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) purchaseValidateHuawei(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) purchaseValidateHuawei(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { if n.config.GetIAP().Huawei.ClientID == "" || n.config.GetIAP().Huawei.ClientSecret == "" || @@ -6066,7 +6066,7 @@ func (n *runtimeJavascriptNakamaModule) purchaseValidateHuawei(r *goja.Runtime) // @param persist(type=bool, optional=true, default=true) Persist the purchase so that seenBefore can be computed to protect against replay attacks. // @return validation(nkruntime.ValidatePurchaseResponse) The resulting successfully validated purchases. Any previously validated purchases are returned with a seenBefore flag. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) purchaseValidateFacebookInstant(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) purchaseValidateFacebookInstant(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { if n.config.GetIAP().FacebookInstant.AppSecret == "" { panic(r.NewGoError(errors.New("facebook instant IAP is not configured"))) @@ -6107,7 +6107,7 @@ func (n *runtimeJavascriptNakamaModule) purchaseValidateFacebookInstant(r *goja. // @param transactionId(type=string) Transaction ID of the purchase to look up. // @return purchase(nkruntime.ValidatedPurchaseAroundOwner) A validated purchase. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) purchaseGetByTransactionId(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) purchaseGetByTransactionId(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { transactionID := getJsString(r, f.Argument(0)) if transactionID == "" { @@ -6130,7 +6130,7 @@ func (n *runtimeJavascriptNakamaModule) purchaseGetByTransactionId(r *goja.Runti // @param cursor(type=string, optional=true, default="") Pagination cursor from previous result. Don't set to start fetching from the beginning. // @return listPurchases(nkruntime.ValidatedPurchaseList) A page of stored validated purchases and possibly a cursor. If cursor is empty/null there are no further results. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) purchasesList(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) purchasesList(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { userIDStr := "" if f.Argument(0) != goja.Undefined() && f.Argument(0) != goja.Null() { @@ -6189,7 +6189,7 @@ func (n *runtimeJavascriptNakamaModule) purchasesList(r *goja.Runtime) func(goja // @param passwordOverride(type=string, optional=true) Override the iap.apple.shared_password provided in your configuration. // @return validation(nkruntime.ValidateSubscriptionResponse) The resulting successfully validated subscription. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) subscriptionValidateApple(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) subscriptionValidateApple(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { password := n.config.GetIAP().Apple.SharedPassword if f.Argument(3) != goja.Undefined() { @@ -6237,7 +6237,7 @@ func (n *runtimeJavascriptNakamaModule) subscriptionValidateApple(r *goja.Runtim // @param persist(type=bool, optional=true, default=true) Persist the subscription. // @return validation(nkruntime.ValidateSubscriptionResponse) The resulting successfully validated subscriptions. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) subscriptionValidateGoogle(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) subscriptionValidateGoogle(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { clientEmail := n.config.GetIAP().Google.ClientEmail privateKey := n.config.GetIAP().Google.PrivateKey @@ -6294,7 +6294,7 @@ func (n *runtimeJavascriptNakamaModule) subscriptionValidateGoogle(r *goja.Runti // @param subscriptionId(type=string) Transaction ID of the purchase to look up. // @return subscription(nkruntime.ValidatedSubscription) A validated subscription. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) subscriptionGetByProductId(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) subscriptionGetByProductId(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { userID := getJsString(r, f.Argument(0)) if userID == "" { @@ -6326,7 +6326,7 @@ func (n *runtimeJavascriptNakamaModule) subscriptionGetByProductId(r *goja.Runti // @param cursor(type=string, optional=true, default="") Pagination cursor from previous result. Don't set to start fetching from the beginning. // @return listSubscriptions(nkruntime.SubscriptionList) A page of stored validated subscriptions and possibly a cursor. If cursor is empty/null there are no further results. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) subscriptionsList(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) subscriptionsList(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { userIDStr := "" if f.Argument(0) != goja.Undefined() && f.Argument(0) != goja.Null() { @@ -6396,7 +6396,7 @@ func (n *runtimeJavascriptNakamaModule) subscriptionsList(r *goja.Runtime) func( // @param joinRequired(type=bool, optional=true, default=false) Whether the tournament needs to be joined before a record write is allowed. // @param enableRanks(type=bool, optional=true, default=false) Whether to enable rank values for the tournament. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) tournamentCreate(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) tournamentCreate(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { id := getJsString(r, f.Argument(0)) if id == "" { @@ -6544,7 +6544,7 @@ func (n *runtimeJavascriptNakamaModule) tournamentCreate(r *goja.Runtime) func(g // @summary Delete a tournament and all records that belong to it. // @param id(type=string) The unique identifier for the tournament to delete. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) tournamentDelete(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) tournamentDelete(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { id := getJsString(r, f.Argument(0)) if id == "" { @@ -6565,7 +6565,7 @@ func (n *runtimeJavascriptNakamaModule) tournamentDelete(r *goja.Runtime) func(g // @param owner(type=string) The owner of the records to increment the count for. // @param count(type=number) The number of attempt counts to increment. Can be negative to decrease count. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) tournamentAddAttempt(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) tournamentAddAttempt(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { id := getJsString(r, f.Argument(0)) if id == "" { @@ -6598,7 +6598,7 @@ func (n *runtimeJavascriptNakamaModule) tournamentAddAttempt(r *goja.Runtime) fu // @param ownerId(type=string) The owner of the record. // @param username(type=string) The username of the record owner. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) tournamentJoin(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) tournamentJoin(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { id := getJsString(r, f.Argument(0)) if id == "" { @@ -6632,7 +6632,7 @@ func (n *runtimeJavascriptNakamaModule) tournamentJoin(r *goja.Runtime) func(goj // @param ids(type=string[]) The table array of tournament ids. // @return result(nkruntime.Tournament[]) Array of tournament records. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) tournamentsGetId(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) tournamentsGetId(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { tournamentIdsIn := f.Argument(0) if tournamentIdsIn == goja.Undefined() || tournamentIdsIn == goja.Null() { @@ -6678,7 +6678,7 @@ func (n *runtimeJavascriptNakamaModule) tournamentsGetId(r *goja.Runtime) func(g // @return prevCursor(string) An optional previous page cursor that can be used to retrieve the previous page of records (if any). // @return nextCursor(string) An optional next page cursor that can be used to retrieve the next page of records (if any). Will be set to "" or null when fetching last available page. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) tournamentRecordsList(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) tournamentRecordsList(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { id := getJsString(r, f.Argument(0)) if id == "" { @@ -6804,7 +6804,7 @@ func leaderboardRecordToJsMap(r *goja.Runtime, record *api.LeaderboardRecord) ma // @param cursor(type=string, optional=true, default="") Pagination cursor from previous result. Don't set to start fetching from the beginning. // @return tournamentList(nkruntime.TournamentList[]) A list of tournament results and possibly a cursor. If cursor is empty/null there are no further results. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) tournamentList(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) tournamentList(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { var categoryStart int if f.Argument(0) != goja.Undefined() && f.Argument(0) != goja.Null() { @@ -6900,7 +6900,7 @@ func (n *runtimeJavascriptNakamaModule) tournamentList(r *goja.Runtime) func(goj // @summary Disable a tournament rank cache freeing its allocated resources. If already disabled is a NOOP. // @param id(type=string) The tournament id. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) tournamentRanksDisable(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) tournamentRanksDisable(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { id := getJsString(r, f.Argument(0)) @@ -6922,7 +6922,7 @@ func (n *runtimeJavascriptNakamaModule) tournamentRanksDisable(r *goja.Runtime) // @param metadata(type=object) The metadata you want associated to this submission. Some good examples are weather conditions for a racing game. // @return result(nkruntime.LeaderboardRecord) The newly created leaderboard record. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) tournamentRecordWrite(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) tournamentRecordWrite(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { id := getJsString(r, f.Argument(0)) if id == "" { @@ -6987,7 +6987,7 @@ func (n *runtimeJavascriptNakamaModule) tournamentRecordWrite(r *goja.Runtime) f // @param id(type=string) The unique identifier for the tournament to delete from. // @param owner(type=string) The owner of the score to delete. Mandatory field. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) tournamentRecordDelete(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) tournamentRecordDelete(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { id := getJsString(r, f.Argument(0)) if id == "" { @@ -7016,7 +7016,7 @@ func (n *runtimeJavascriptNakamaModule) tournamentRecordDelete(r *goja.Runtime) // @param expiry(type=number, optional=true, default=0) Time since epoch in seconds. Must be greater than 0. // @return tournamentRecordsHaystack(nkruntime.LeaderboardRecord) A list of tournament records and possibly a cursor. If cursor is empty/null there are no further results. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) tournamentRecordsHaystack(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) tournamentRecordsHaystack(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { id := getJsString(r, f.Argument(0)) if id == "" { @@ -7064,7 +7064,7 @@ func (n *runtimeJavascriptNakamaModule) tournamentRecordsHaystack(r *goja.Runtim // @param groupIds(type=string[]) An array of strings of the IDs for the groups to get. // @return getGroups(nkruntime.Group[]) An array of groups with their fields. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) groupsGetId(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) groupsGetId(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { groupIdsIn := f.Argument(0) if groupIdsIn == goja.Undefined() || groupIdsIn == goja.Null() { @@ -7122,7 +7122,7 @@ func (n *runtimeJavascriptNakamaModule) groupsGetId(r *goja.Runtime) func(goja.F // @param maxCount(type=number, optional=true, default=100) Maximum number of members to have in the group. // @return createGroup(nkruntime.Group) The groupId of the newly created group. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) groupCreate(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) groupCreate(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { userIDString := getJsString(r, f.Argument(0)) if userIDString == "" { @@ -7231,7 +7231,7 @@ func (n *runtimeJavascriptNakamaModule) groupCreate(r *goja.Runtime) func(goja.F // @param metadata(type=object, optional=true) Custom information to store for this group. Use nil if field is not being updated. // @param maxCount(type=number, optional=true) Maximum number of members to have in the group. Use 0, nil/null if field is not being updated. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) groupUpdate(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) groupUpdate(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { groupIDStr := getJsString(r, f.Argument(0)) groupID, err := uuid.FromString(groupIDStr) @@ -7317,7 +7317,7 @@ func (n *runtimeJavascriptNakamaModule) groupUpdate(r *goja.Runtime) func(goja.F // @summary Delete a group. // @param groupId(type=string) The ID of the group to delete. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) groupDelete(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) groupDelete(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { groupIDStr := getJsString(r, f.Argument(0)) groupID, err := uuid.FromString(groupIDStr) @@ -7339,7 +7339,7 @@ func (n *runtimeJavascriptNakamaModule) groupDelete(r *goja.Runtime) func(goja.F // @param userIds(type=string[]) Table array of user IDs to kick. // @param callerId(type=string, optional=true) User ID of the caller, will apply permissions checks of the user. If empty defaults to system user and permission checks are bypassed. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) groupUsersKick(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) groupUsersKick(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { groupIDStr := getJsString(r, f.Argument(0)) groupID, err := uuid.FromString(groupIDStr) @@ -7394,7 +7394,7 @@ func (n *runtimeJavascriptNakamaModule) groupUsersKick(r *goja.Runtime) func(goj // @param cursor(type=string, optional=true, default="") Pagination cursor from previous result. Don't set to start fetching from the beginning. // @return groupUsers(nkruntime.GroupUserList) The user information for members, admins and superadmins for the group. Also users who sent a join request. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) groupUsersList(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) groupUsersList(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { groupIDStr := getJsString(r, f.Argument(0)) groupID, err := uuid.FromString(groupIDStr) @@ -7500,7 +7500,7 @@ func (n *runtimeJavascriptNakamaModule) groupUsersList(r *goja.Runtime) func(goj // @return userGroups(nkruntime.UserGroupList) A table of groups with their fields. // @return cursor(string) An optional next page cursor that can be used to retrieve the next page of records (if any). // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) userGroupsList(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) userGroupsList(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { userIDStr := getJsString(r, f.Argument(0)) userID, err := uuid.FromString(userIDStr) @@ -7591,7 +7591,7 @@ func (n *runtimeJavascriptNakamaModule) userGroupsList(r *goja.Runtime) func(goj // @return friends(nkruntime.FriendList) The user information for users that are friends of the current user. // @return cursor(string) An optional next page cursor that can be used to retrieve the next page of records (if any). Will be set to "" or null when fetching last available page. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) friendsList(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) friendsList(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { userIDString := getJsString(r, f.Argument(0)) if userIDString == "" { @@ -7665,7 +7665,7 @@ func (n *runtimeJavascriptNakamaModule) friendsList(r *goja.Runtime) func(goja.F // @return friends(nkruntime.FriendsOfFriendsList) The user information for users that are friends of friends of the current user. // @return cursor(string) An optional next page cursor that can be used to retrieve the next page of records (if any). Will be set to "" or null when fetching last available page. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) friendsOfFriendsList(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) friendsOfFriendsList(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { userIDString := getJsString(r, f.Argument(0)) if userIDString == "" { @@ -7726,7 +7726,7 @@ func (n *runtimeJavascriptNakamaModule) friendsOfFriendsList(r *goja.Runtime) fu // @param ids(type=[]string) Table array of IDs of the users you want to add as friends. // @param usernames(type=[]string) Table array of usernames of the users you want to add as friends. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) friendsAdd(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) friendsAdd(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { userIDString := getJsString(r, f.Argument(0)) userID, err := uuid.FromString(userIDString) @@ -7805,7 +7805,7 @@ func (n *runtimeJavascriptNakamaModule) friendsAdd(r *goja.Runtime) func(goja.Fu // @param ids(type=[]string) Table array of IDs of the users you want to delete as friends. // @param usernames(type=[]string) Table array of usernames of the users you want to delete as friends. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) friendsDelete(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) friendsDelete(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { userIDString := getJsString(r, f.Argument(0)) userID, err := uuid.FromString(userIDString) @@ -7884,7 +7884,7 @@ func (n *runtimeJavascriptNakamaModule) friendsDelete(r *goja.Runtime) func(goja // @param ids(type=[]string) Table array of IDs of the users you want to block as friends. // @param usernames(type=[]string) Table array of usernames of the users you want to block as friends. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) friendsBlock(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) friendsBlock(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { userIDString := getJsString(r, f.Argument(0)) userID, err := uuid.FromString(userIDString) @@ -7963,7 +7963,7 @@ func (n *runtimeJavascriptNakamaModule) friendsBlock(r *goja.Runtime) func(goja. // @param userId(type=string) The user ID to add to this group. // @param username(type=string) The username of the user to add to this group. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) groupUserJoin(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) groupUserJoin(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { groupIDString := getJsString(r, f.Argument(0)) if groupIDString == "" { @@ -8002,7 +8002,7 @@ func (n *runtimeJavascriptNakamaModule) groupUserJoin(r *goja.Runtime) func(goja // @param userId(type=string) The user ID to remove from this group. // @param username(type=string) The username of the user to remove from this group. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) groupUserLeave(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) groupUserLeave(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { groupIDString := getJsString(r, f.Argument(0)) if groupIDString == "" { @@ -8041,7 +8041,7 @@ func (n *runtimeJavascriptNakamaModule) groupUserLeave(r *goja.Runtime) func(goj // @param userIds(type=string[]) Table array of user IDs to add to this group. // @param callerId(type=string, optional=true) User ID of the caller, will apply permissions checks of the user. If empty defaults to system user and permission checks are bypassed. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) groupUsersAdd(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) groupUsersAdd(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { groupIDString := getJsString(r, f.Argument(0)) if groupIDString == "" { @@ -8100,7 +8100,7 @@ func (n *runtimeJavascriptNakamaModule) groupUsersAdd(r *goja.Runtime) func(goja // @param userIds(string[]) Table array of user IDs to ban from this group. // @param callerId(type=string, optional=true) User ID of the caller, will apply permissions checks of the user. If empty defaults to system user and permission checks are bypassed. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) groupUsersBan(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) groupUsersBan(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { groupIDString := getJsString(r, f.Argument(0)) if groupIDString == "" { @@ -8159,7 +8159,7 @@ func (n *runtimeJavascriptNakamaModule) groupUsersBan(r *goja.Runtime) func(goja // @param userIds(type=string[]) Table array of user IDs to promote. // @param callerId(type=string, optional=true) User ID of the caller, will apply permissions checks of the user. If empty defaults to system user and permission checks are bypassed. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) groupUsersPromote(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) groupUsersPromote(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { groupIDString := getJsString(r, f.Argument(0)) if groupIDString == "" { @@ -8218,7 +8218,7 @@ func (n *runtimeJavascriptNakamaModule) groupUsersPromote(r *goja.Runtime) func( // @param userIds(type=string[]) Table array of user IDs to demote. // @param callerId(type=string, optional=true) User ID of the caller, will apply permissions checks of the user. If empty defaults to system user and permission checks are bypassed. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) groupUsersDemote(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) groupUsersDemote(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { groupIDString := getJsString(r, f.Argument(0)) if groupIDString == "" { @@ -8282,7 +8282,7 @@ func (n *runtimeJavascriptNakamaModule) groupUsersDemote(r *goja.Runtime) func(g // @return groups(nkruntime.GroupList) A list of groups. // @return cursor(string) An optional next page cursor that can be used to retrieve the next page of records (if any). Will be set to "" or null when fetching last available page. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) groupsList(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) groupsList(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { var name string if !goja.IsUndefined(f.Argument(0)) && !goja.IsNull(f.Argument(0)) { @@ -8351,7 +8351,7 @@ func (n *runtimeJavascriptNakamaModule) groupsList(r *goja.Runtime) func(goja.Fu // @param count(type=number) The number of groups to fetch. // @return groups(nkruntime.Group[]) A list of group record objects. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) groupsGetRandom(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) groupsGetRandom(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { count := getJsInt(r, f.Argument(0)) @@ -8382,7 +8382,7 @@ func (n *runtimeJavascriptNakamaModule) groupsGetRandom(r *goja.Runtime) func(go // @param relPath(type=string) Relative path to the file to be read. // @return fileRead(string) The read file contents. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) fileRead(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) fileRead(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { relPath := getJsString(r, f.Argument(0)) if relPath == "" { @@ -8406,7 +8406,7 @@ func (n *runtimeJavascriptNakamaModule) fileRead(r *goja.Runtime) func(goja.Func } } -func (n *runtimeJavascriptNakamaModule) localcacheGet(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) localcacheGet(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { key := getJsString(r, f.Argument(0)) if key == "" { @@ -8427,7 +8427,7 @@ func (n *runtimeJavascriptNakamaModule) localcacheGet(r *goja.Runtime) func(goja } } -func (n *runtimeJavascriptNakamaModule) localcachePut(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) localcachePut(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { key := getJsString(r, f.Argument(0)) if key == "" { @@ -8462,7 +8462,7 @@ func (n *runtimeJavascriptNakamaModule) localcachePut(r *goja.Runtime) func(goja } } -func (n *runtimeJavascriptNakamaModule) localcacheDelete(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) localcacheDelete(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { key := getJsString(r, f.Argument(0)) if key == "" { @@ -8475,7 +8475,7 @@ func (n *runtimeJavascriptNakamaModule) localcacheDelete(r *goja.Runtime) func(g } } -func (n *runtimeJavascriptNakamaModule) localcacheClear(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) localcacheClear(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { n.localCache.Clear() @@ -8492,7 +8492,7 @@ func (n *runtimeJavascriptNakamaModule) localcacheClear(r *goja.Runtime) func(go // @param persist(type=bool, optional=true, default=true) Whether to record this message in the channel history. // @return channelMessageSend(nkruntime.ChannelMessageAck) Message sent ack containing the following variables: 'channelId', 'messageId', 'code', 'username', 'createTime', 'updateTime', and 'persistent'. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) channelMessageSend(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) channelMessageSend(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { channelId := getJsString(r, f.Argument(0)) @@ -8565,7 +8565,7 @@ func (n *runtimeJavascriptNakamaModule) channelMessageSend(r *goja.Runtime) func // @param persist(type=bool, optional=true, default=true) Whether to record this message in the channel history. // @return channelMessageUpdate(nkruntime.ChannelMessageAck) Message updated ack containing the following variables: 'channelId', 'messageId', 'code', 'username', 'createTime', 'updateTime', and 'persistent'. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) channelMessageUpdate(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) channelMessageUpdate(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { channelId := getJsString(r, f.Argument(0)) @@ -8642,7 +8642,7 @@ func (n *runtimeJavascriptNakamaModule) channelMessageUpdate(r *goja.Runtime) fu // @param persist(type=bool, optional=true, default=true) Whether to record this message in the channel history. // @return channelMessageRemove(nkruntime.ChannelMessageAck) Message removed ack containing the following variables: 'channelId', 'messageId', 'code', 'username', 'createTime', 'updateTime', and 'persistent'. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) channelMessageRemove(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) channelMessageRemove(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { channelId := getJsString(r, f.Argument(0)) @@ -8702,7 +8702,7 @@ func (n *runtimeJavascriptNakamaModule) channelMessageRemove(r *goja.Runtime) fu // @param cursor(type=string, optional=true, default="") Pagination cursor from previous result. Don't set to start fetching from the beginning. // @return channelMessagesList(nkruntime.ChannelMessageList) Messages from the specified channel and possibly a cursor. If cursor is empty/null there are no further results. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) channelMessagesList(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) channelMessagesList(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { channelId := getJsString(r, f.Argument(0)) @@ -8770,7 +8770,7 @@ func (n *runtimeJavascriptNakamaModule) channelMessagesList(r *goja.Runtime) fun // @param chanType(type=nkruntime.ChannelType) The type of channel, either Room (1), Direct (2), or Group (3). // @return channelId(string) The generated ID representing a channel. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) channelIdBuild(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) channelIdBuild(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { senderID := uuid.Nil senderIDIn := f.Argument(0) @@ -8802,7 +8802,7 @@ func (n *runtimeJavascriptNakamaModule) channelIdBuild(r *goja.Runtime) func(goj } } -func (n *runtimeJavascriptNakamaModule) satoriConstructor(r *goja.Runtime) (*goja.Object, error) { +func (n *RuntimeJavascriptNakamaModule) satoriConstructor(r *goja.Runtime) (*goja.Object, error) { mappings := map[string]func(goja.FunctionCall) goja.Value{ "authenticate": n.satoriAuthenticate(r), "propertiesGet": n.satoriPropertiesGet(r), @@ -8831,7 +8831,7 @@ func (n *runtimeJavascriptNakamaModule) satoriConstructor(r *goja.Runtime) (*goj // @summary Get the Satori client. // @return satori(*nkruntime.Satori) The satori client. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) getSatori(r *goja.Object) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) getSatori(r *goja.Object) func(goja.FunctionCall) goja.Value { return func(goja.FunctionCall) goja.Value { return r } @@ -8843,7 +8843,7 @@ func (n *runtimeJavascriptNakamaModule) getSatori(r *goja.Object) func(goja.Func // @param properties(type=nkruntime.AuthPropertiesUpdate, optional=true, default=null) Opt. Properties to update. // @param ip(type=string, optional=true, default="") An optional client IP address to pass on to Satori for geo-IP lookup. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) satoriAuthenticate(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) satoriAuthenticate(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { id := getJsString(r, f.Argument(0)) @@ -8884,7 +8884,7 @@ func (n *runtimeJavascriptNakamaModule) satoriAuthenticate(r *goja.Runtime) func // @param id(type=string) The identifier of the identity. // @return properties(type=nkruntime.Properties) The identity properties. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) satoriPropertiesGet(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) satoriPropertiesGet(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { id := getJsString(r, f.Argument(0)) @@ -8907,7 +8907,7 @@ func (n *runtimeJavascriptNakamaModule) satoriPropertiesGet(r *goja.Runtime) fun // @param id(type=string) The identifier of the identity. // @param properties(type=nkruntime.PropertiesUpdate) The identity properties to update. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) satoriPropertiesUpdate(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) satoriPropertiesUpdate(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { id := getJsString(r, f.Argument(0)) @@ -8949,7 +8949,7 @@ func (n *runtimeJavascriptNakamaModule) satoriPropertiesUpdate(r *goja.Runtime) // @param id(type=string) The identifier of the identity. // @param events(type=nkruntime.Event[]) An array of events to publish. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) satoriPublishEvents(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) satoriPublishEvents(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { identifier := getJsString(r, f.Argument(0)) @@ -9025,7 +9025,7 @@ func (n *runtimeJavascriptNakamaModule) satoriPublishEvents(r *goja.Runtime) fun // @param names(type=string[], optional=true, default=[]) Optional list of experiment names to filter. // @return experiments(*nkruntime.Experiment[]) The experiment list. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) satoriExperimentsList(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) satoriExperimentsList(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { identifier := getJsString(r, f.Argument(0)) @@ -9064,7 +9064,7 @@ func (n *runtimeJavascriptNakamaModule) satoriExperimentsList(r *goja.Runtime) f // @param names(type=string[], optional=true, default=[]) Optional list of flag names to filter. // @return flags(*nkruntime.Flag[]) The flag list. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) satoriFlagsList(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) satoriFlagsList(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { identifier := getJsString(r, f.Argument(0)) @@ -9104,7 +9104,7 @@ func (n *runtimeJavascriptNakamaModule) satoriFlagsList(r *goja.Runtime) func(go // @param names(type=string[], optional=true, default=[]) Optional list of live event names to filter. // @return liveEvents(*nkruntime.LiveEvent[]) The live event list. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) satoriLiveEventsList(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) satoriLiveEventsList(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { identifier := getJsString(r, f.Argument(0)) @@ -9153,7 +9153,7 @@ func (n *runtimeJavascriptNakamaModule) satoriLiveEventsList(r *goja.Runtime) fu // @param cursor(type=string, optional=true, default="") A pagination cursor, if any. // @return messages(*nkruntime.Message[]) The message list. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) satoriMessagesList(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) satoriMessagesList(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { identifier := getJsString(r, f.Argument(0)) @@ -9215,7 +9215,7 @@ func (n *runtimeJavascriptNakamaModule) satoriMessagesList(r *goja.Runtime) func // @param readTime(type=int) The time the message was read at the client. // @param consumeTime(type=int, optiona=true, default=0) The time the message was consumed by the identity. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) satoriMessageUpdate(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) satoriMessageUpdate(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { identifier := getJsString(r, f.Argument(0)) @@ -9241,7 +9241,7 @@ func (n *runtimeJavascriptNakamaModule) satoriMessageUpdate(r *goja.Runtime) fun // @param id(type=string) The identifier of the identity. // @param messageId(type=string) The identifier of the message. // @return error(error) An optional error value if an error occurred. -func (n *runtimeJavascriptNakamaModule) satoriMessageDelete(r *goja.Runtime) func(goja.FunctionCall) goja.Value { +func (n *RuntimeJavascriptNakamaModule) satoriMessageDelete(r *goja.Runtime) func(goja.FunctionCall) goja.Value { return func(f goja.FunctionCall) goja.Value { identifier := getJsString(r, f.Argument(0)) diff --git a/server/runtime_lua.go b/server/runtime_lua.go index dd2a0be2fc..f73a608e87 100644 --- a/server/runtime_lua.go +++ b/server/runtime_lua.go @@ -1354,7 +1354,7 @@ func (rp *RuntimeProviderLua) Rpc(ctx context.Context, id string, headers, query // Set context value used for logging vmCtx := context.WithValue(ctx, ctxLoggerFields{}, map[string]string{"rpc_id": id}) - vmCtx = NewRuntimeGoContext(ctx, r.node, r.version, r.env, RuntimeExecutionModeRPC, headers, queryParams, expiry, userID, username, vars, sessionID, clientIP, clientPort, lang) + vmCtx = NewRuntimeGoContext(vmCtx, r.node, r.version, r.env, RuntimeExecutionModeRPC, headers, queryParams, expiry, userID, username, vars, sessionID, clientIP, clientPort, lang) r.vm.SetContext(vmCtx) result, fnErr, code, isCustomErr := r.InvokeFunction(RuntimeExecutionModeRPC, lf, headers, queryParams, userID, username, vars, expiry, sessionID, clientIP, clientPort, lang, payload) r.vm.SetContext(context.Background()) @@ -1415,7 +1415,7 @@ func (rp *RuntimeProviderLua) BeforeRt(ctx context.Context, id string, logger *z // Set context value used for logging vmCtx := context.WithValue(ctx, ctxLoggerFields{}, map[string]string{"api_id": strings.TrimPrefix(id, RTAPI_PREFIX_LOWERCASE), "mode": RuntimeExecutionModeBefore.String()}) - vmCtx = NewRuntimeGoContext(ctx, r.node, r.version, r.env, RuntimeExecutionModeBefore, nil, nil, expiry, userID, username, vars, sessionID, clientIP, clientPort, lang) + vmCtx = NewRuntimeGoContext(vmCtx, r.node, r.version, r.env, RuntimeExecutionModeBefore, nil, nil, expiry, userID, username, vars, sessionID, clientIP, clientPort, lang) r.vm.SetContext(vmCtx) result, fnErr, _, isCustomErr := r.InvokeFunction(RuntimeExecutionModeBefore, lf, nil, nil, userID, username, vars, expiry, sessionID, clientIP, clientPort, lang, envelopeMap) r.vm.SetContext(context.Background()) @@ -1492,7 +1492,7 @@ func (rp *RuntimeProviderLua) AfterRt(ctx context.Context, id string, logger *za // Set context value used for logging vmCtx := context.WithValue(ctx, ctxLoggerFields{}, map[string]string{"api_id": strings.TrimPrefix(id, RTAPI_PREFIX_LOWERCASE), "mode": RuntimeExecutionModeAfter.String()}) - vmCtx = NewRuntimeGoContext(ctx, r.node, r.version, r.env, RuntimeExecutionModeAfter, nil, nil, expiry, userID, username, vars, sessionID, clientIP, clientPort, lang) + vmCtx = NewRuntimeGoContext(vmCtx, r.node, r.version, r.env, RuntimeExecutionModeAfter, nil, nil, expiry, userID, username, vars, sessionID, clientIP, clientPort, lang) r.vm.SetContext(vmCtx) _, fnErr, _, isCustomErr := r.InvokeFunction(RuntimeExecutionModeAfter, lf, nil, nil, userID, username, vars, expiry, sessionID, clientIP, clientPort, lang, outMap, inMap) r.vm.SetContext(context.Background()) @@ -1550,7 +1550,7 @@ func (rp *RuntimeProviderLua) BeforeReq(ctx context.Context, id string, logger * // Set context value used for logging vmCtx := context.WithValue(ctx, ctxLoggerFields{}, map[string]string{"api_id": strings.TrimPrefix(id, API_PREFIX_LOWERCASE), "mode": RuntimeExecutionModeBefore.String()}) - vmCtx = NewRuntimeGoContext(ctx, r.node, r.version, r.env, RuntimeExecutionModeBefore, nil, nil, expiry, userID, username, vars, "", clientIP, clientPort, "") + vmCtx = NewRuntimeGoContext(vmCtx, r.node, r.version, r.env, RuntimeExecutionModeBefore, nil, nil, expiry, userID, username, vars, "", clientIP, clientPort, "") r.vm.SetContext(vmCtx) result, fnErr, code, isCustomErr := r.InvokeFunction(RuntimeExecutionModeBefore, lf, nil, nil, userID, username, vars, expiry, "", clientIP, clientPort, "", reqMap) r.vm.SetContext(context.Background()) @@ -1646,7 +1646,7 @@ func (rp *RuntimeProviderLua) AfterReq(ctx context.Context, id string, logger *z // Set context value used for logging vmCtx := context.WithValue(ctx, ctxLoggerFields{}, map[string]string{"api_id": strings.TrimPrefix(id, API_PREFIX_LOWERCASE), "mode": RuntimeExecutionModeAfter.String()}) - vmCtx = NewRuntimeGoContext(ctx, r.node, r.version, r.env, RuntimeExecutionModeAfter, nil, nil, expiry, userID, username, vars, "", clientIP, clientPort, "") + vmCtx = NewRuntimeGoContext(vmCtx, r.node, r.version, r.env, RuntimeExecutionModeAfter, nil, nil, expiry, userID, username, vars, "", clientIP, clientPort, "") r.vm.SetContext(vmCtx) _, fnErr, _, isCustomErr := r.InvokeFunction(RuntimeExecutionModeAfter, lf, nil, nil, userID, username, vars, expiry, "", clientIP, clientPort, "", resMap, reqMap) r.vm.SetContext(context.Background()) @@ -1709,7 +1709,7 @@ func (rp *RuntimeProviderLua) MatchmakerMatched(ctx context.Context, entries []* // Set context value used for logging vmCtx := context.WithValue(ctx, ctxLoggerFields{}, map[string]string{"mode": RuntimeExecutionModeMatchmaker.String()}) - vmCtx = NewRuntimeGoContext(ctx, r.node, r.version, r.env, RuntimeExecutionModeMatchmaker, nil, nil, 0, "", "", nil, "", "", "", "") + vmCtx = NewRuntimeGoContext(vmCtx, r.node, r.version, r.env, RuntimeExecutionModeMatchmaker, nil, nil, 0, "", "", nil, "", "", "", "") r.vm.SetContext(vmCtx) retValue, err, _, _ := r.invokeFunction(r.vm, lf, luaCtx, entriesTable) r.vm.SetContext(context.Background()) @@ -1800,7 +1800,7 @@ func (rp *RuntimeProviderLua) TournamentEnd(ctx context.Context, tournament *api // Set context value used for logging vmCtx := context.WithValue(ctx, ctxLoggerFields{}, map[string]string{"mode": RuntimeExecutionModeTournamentEnd.String()}) - vmCtx = NewRuntimeGoContext(ctx, r.node, r.version, r.env, RuntimeExecutionModeTournamentEnd, nil, nil, 0, "", "", nil, "", "", "", "") + vmCtx = NewRuntimeGoContext(vmCtx, r.node, r.version, r.env, RuntimeExecutionModeTournamentEnd, nil, nil, 0, "", "", nil, "", "", "", "") r.vm.SetContext(vmCtx) retValue, err, _, _ := r.invokeFunction(r.vm, lf, luaCtx, tournamentTable, lua.LNumber(end), lua.LNumber(reset)) r.vm.SetContext(context.Background()) @@ -1872,7 +1872,7 @@ func (rp *RuntimeProviderLua) TournamentReset(ctx context.Context, tournament *a // Set context value used for logging vmCtx := context.WithValue(ctx, ctxLoggerFields{}, map[string]string{"mode": RuntimeExecutionModeTournamentReset.String()}) - vmCtx = NewRuntimeGoContext(ctx, r.node, r.version, r.env, RuntimeExecutionModeTournamentReset, nil, nil, 0, "", "", nil, "", "", "", "") + vmCtx = NewRuntimeGoContext(vmCtx, r.node, r.version, r.env, RuntimeExecutionModeTournamentReset, nil, nil, 0, "", "", nil, "", "", "", "") r.vm.SetContext(vmCtx) retValue, err, _, _ := r.invokeFunction(r.vm, lf, luaCtx, tournamentTable, lua.LNumber(end), lua.LNumber(reset)) r.vm.SetContext(context.Background()) @@ -1926,7 +1926,7 @@ func (rp *RuntimeProviderLua) LeaderboardReset(ctx context.Context, leaderboard // Set context value used for logging vmCtx := context.WithValue(ctx, ctxLoggerFields{}, map[string]string{"mode": RuntimeExecutionModeLeaderboardReset.String()}) - vmCtx = NewRuntimeGoContext(ctx, r.node, r.version, r.env, RuntimeExecutionModeLeaderboardReset, nil, nil, 0, "", "", nil, "", "", "", "") + vmCtx = NewRuntimeGoContext(vmCtx, r.node, r.version, r.env, RuntimeExecutionModeLeaderboardReset, nil, nil, 0, "", "", nil, "", "", "", "") r.vm.SetContext(vmCtx) retValue, err, _, _ := r.invokeFunction(r.vm, lf, luaCtx, leaderboardTable, lua.LNumber(reset)) r.vm.SetContext(context.Background()) @@ -1959,7 +1959,7 @@ func (rp *RuntimeProviderLua) Shutdown(ctx context.Context) { // Set context value used for logging vmCtx := context.WithValue(ctx, ctxLoggerFields{}, map[string]string{"mode": RuntimeExecutionModeShutdown.String()}) - vmCtx = NewRuntimeGoContext(ctx, r.node, r.version, r.env, RuntimeExecutionModeShutdown, nil, nil, 0, "", "", nil, "", "", "", "") + vmCtx = NewRuntimeGoContext(vmCtx, r.node, r.version, r.env, RuntimeExecutionModeShutdown, nil, nil, 0, "", "", nil, "", "", "", "") r.vm.SetContext(vmCtx) _, err, _, _ = r.invokeFunction(r.vm, lf, luaCtx) r.vm.SetContext(context.Background()) @@ -1987,7 +1987,7 @@ func (rp *RuntimeProviderLua) PurchaseNotificationApple(ctx context.Context, pur // Set context value used for logging vmCtx := context.WithValue(ctx, ctxLoggerFields{}, map[string]string{"mode": RuntimeExecutionModePurchaseNotificationApple.String()}) - vmCtx = NewRuntimeGoContext(ctx, r.node, r.version, r.env, RuntimeExecutionModePurchaseNotificationApple, nil, nil, 0, "", "", nil, "", "", "", "") + vmCtx = NewRuntimeGoContext(vmCtx, r.node, r.version, r.env, RuntimeExecutionModePurchaseNotificationApple, nil, nil, 0, "", "", nil, "", "", "", "") r.vm.SetContext(vmCtx) retValue, err, _, _ := r.invokeFunction(r.vm, lf, luaCtx, purchaseTable, lua.LString(providerPayload)) r.vm.SetContext(context.Background()) @@ -2021,7 +2021,7 @@ func (rp *RuntimeProviderLua) SubscriptionNotificationApple(ctx context.Context, // Set context value used for logging vmCtx := context.WithValue(ctx, ctxLoggerFields{}, map[string]string{"mode": RuntimeExecutionModeSubscriptionNotificationApple.String()}) - vmCtx = NewRuntimeGoContext(ctx, r.node, r.version, r.env, RuntimeExecutionModeSubscriptionNotificationApple, nil, nil, 0, "", "", nil, "", "", "", "") + vmCtx = NewRuntimeGoContext(vmCtx, r.node, r.version, r.env, RuntimeExecutionModeSubscriptionNotificationApple, nil, nil, 0, "", "", nil, "", "", "", "") r.vm.SetContext(vmCtx) retValue, err, _, _ := r.invokeFunction(r.vm, lf, luaCtx, subscriptionTable, lua.LString(providerPayload)) r.vm.SetContext(context.Background()) @@ -2055,7 +2055,7 @@ func (rp *RuntimeProviderLua) PurchaseNotificationGoogle(ctx context.Context, pu // Set context value used for logging vmCtx := context.WithValue(ctx, ctxLoggerFields{}, map[string]string{"mode": RuntimeExecutionModePurchaseNotificationGoogle.String()}) - vmCtx = NewRuntimeGoContext(ctx, r.node, r.version, r.env, RuntimeExecutionModePurchaseNotificationGoogle, nil, nil, 0, "", "", nil, "", "", "", "") + vmCtx = NewRuntimeGoContext(vmCtx, r.node, r.version, r.env, RuntimeExecutionModePurchaseNotificationGoogle, nil, nil, 0, "", "", nil, "", "", "", "") r.vm.SetContext(vmCtx) retValue, err, _, _ := r.invokeFunction(r.vm, lf, luaCtx, purchaseTable, lua.LString(providerPayload)) r.vm.SetContext(context.Background()) @@ -2089,7 +2089,7 @@ func (rp *RuntimeProviderLua) SubscriptionNotificationGoogle(ctx context.Context // Set context value used for logging vmCtx := context.WithValue(ctx, ctxLoggerFields{}, map[string]string{"mode": RuntimeExecutionModeSubscriptionNotificationGoogle.String()}) - vmCtx = NewRuntimeGoContext(ctx, r.node, r.version, r.env, RuntimeExecutionModeSubscriptionNotificationGoogle, nil, nil, 0, "", "", nil, "", "", "", "") + vmCtx = NewRuntimeGoContext(vmCtx, r.node, r.version, r.env, RuntimeExecutionModeSubscriptionNotificationGoogle, nil, nil, 0, "", "", nil, "", "", "", "") r.vm.SetContext(vmCtx) retValue, err, _, _ := r.invokeFunction(r.vm, lf, luaCtx, subscriptionTable, lua.LString(providerPayload)) r.vm.SetContext(context.Background()) @@ -2146,7 +2146,7 @@ func (rp *RuntimeProviderLua) StorageIndexFilter(ctx context.Context, indexName // Set context value used for logging vmCtx := context.WithValue(ctx, ctxLoggerFields{}, map[string]string{"mode": RuntimeExecutionModeStorageIndexFilter.String()}) - vmCtx = NewRuntimeGoContext(ctx, r.node, r.version, r.env, RuntimeExecutionModeStorageIndexFilter, nil, nil, 0, "", "", nil, "", "", "", "") + vmCtx = NewRuntimeGoContext(vmCtx, r.node, r.version, r.env, RuntimeExecutionModeStorageIndexFilter, nil, nil, 0, "", "", nil, "", "", "", "") r.vm.SetContext(vmCtx) retValue, err, _, _ := r.invokeFunction(r.vm, lf, luaCtx, writeTable) r.vm.SetContext(context.Background()) diff --git a/server/runtime_lua_nakama.go b/server/runtime_lua_nakama.go index dc99979316..8d937bdab9 100644 --- a/server/runtime_lua_nakama.go +++ b/server/runtime_lua_nakama.go @@ -325,6 +325,7 @@ func (n *RuntimeLuaNakamaModule) Loader(l *lua.LState) int { "channel_messages_list": n.channelMessagesList, "channel_id_build": n.channelIdBuild, "storage_index_list": n.storageIndexList, + "get_config": n.getConfig, "get_satori": n.getSatori, } @@ -2468,7 +2469,7 @@ func (n *RuntimeLuaNakamaModule) accountGetId(l *lua.LState) int { metadataMap := make(map[string]interface{}) err = json.Unmarshal([]byte(account.User.Metadata), &metadataMap) if err != nil { - l.RaiseError(fmt.Sprintf("failed to convert metadata to json: %s", err.Error())) + l.RaiseError("failed to convert metadata to json: %s", err.Error()) return 0 } metadataTable := RuntimeLuaConvertMap(l, metadataMap) @@ -2476,7 +2477,7 @@ func (n *RuntimeLuaNakamaModule) accountGetId(l *lua.LState) int { userTable, err := userToLuaTable(l, account.User) if err != nil { - l.RaiseError(fmt.Sprintf("failed to convert user data to lua table: %s", err.Error())) + l.RaiseError("failed to convert user data to lua table: %s", err.Error()) return 0 } accountTable.RawSetString("user", userTable) @@ -2484,7 +2485,7 @@ func (n *RuntimeLuaNakamaModule) accountGetId(l *lua.LState) int { walletMap := make(map[string]int64) err = json.Unmarshal([]byte(account.Wallet), &walletMap) if err != nil { - l.RaiseError(fmt.Sprintf("failed to convert wallet to json: %s", err.Error())) + l.RaiseError("failed to convert wallet to json: %s", err.Error()) return 0 } walletTable := RuntimeLuaConvertMapInt64(l, walletMap) @@ -2598,7 +2599,7 @@ func (n *RuntimeLuaNakamaModule) accountsGetId(l *lua.LState) int { metadataMap := make(map[string]interface{}) err = json.Unmarshal([]byte(account.User.Metadata), &metadataMap) if err != nil { - l.RaiseError(fmt.Sprintf("failed to convert metadata to json: %s", err.Error())) + l.RaiseError("failed to convert metadata to json: %s", err.Error()) return 0 } metadataTable := RuntimeLuaConvertMap(l, metadataMap) @@ -10733,6 +10734,115 @@ func (n *RuntimeLuaNakamaModule) storageIndexList(l *lua.LState) int { return 2 } +// @group configuration +// @summary Get a subset of the Nakama configuration values. +// @return config(table) A number of Nakama configuration values. +// @return error(error) An optional error value if an error occurred. +func (n *RuntimeLuaNakamaModule) getConfig(l *lua.LState) int { + rnc, err := n.config.GetRuntimeConfig() + if err != nil { + l.RaiseError("failed to get config: %s", err.Error()) + return 0 + } + + cfgObj := l.CreateTable(0, 10) + cfgObj.RawSetString("name", lua.LString(rnc.GetName())) + cfgObj.RawSetString("shutdown_grace_sec", lua.LNumber(rnc.GetShutdownGraceSec())) + + lgCfg := l.CreateTable(0, 1) + lgCfg.RawSetString("level", lua.LString(rnc.GetLogger().GetLevel())) + cfgObj.RawSetString("logger", lgCfg) + + sessCfg := l.CreateTable(0, 8) + sessCfg.RawSetString("encryption_key", lua.LString(rnc.GetSession().GetEncryptionKey())) + sessCfg.RawSetString("token_expiry_sec", lua.LNumber(rnc.GetSession().GetTokenExpirySec())) + sessCfg.RawSetString("refresh_encryption_key", lua.LString(rnc.GetSession().GetRefreshEncryptionKey())) + sessCfg.RawSetString("refresh_token_expiry_sec", lua.LNumber(rnc.GetSession().GetRefreshTokenExpirySec())) + sessCfg.RawSetString("single_socket", lua.LBool(rnc.GetSession().GetSingleSocket())) + sessCfg.RawSetString("single_match", lua.LBool(rnc.GetSession().GetSingleMatch())) + sessCfg.RawSetString("single_party", lua.LBool(rnc.GetSession().GetSingleParty())) + sessCfg.RawSetString("single_session", lua.LBool(rnc.GetSession().GetSingleSession())) + cfgObj.RawSetString("session", sessCfg) + + socketCfg := l.CreateTable(0, 4) + socketCfg.RawSetString("server_key", lua.LString(rnc.GetSocket().GetServerKey())) + socketCfg.RawSetString("port", lua.LNumber(rnc.GetSocket().GetPort())) + socketCfg.RawSetString("address", lua.LString(rnc.GetSocket().GetAddress())) + socketCfg.RawSetString("protocol", lua.LString(rnc.GetSocket().GetProtocol())) + cfgObj.RawSetString("socket", socketCfg) + + // Social + steamCfg := l.CreateTable(0, 2) + steamCfg.RawSetString("publisher_key", lua.LString(rnc.GetSocial().GetSteam().GetPublisherKey())) + steamCfg.RawSetString("app_id", lua.LNumber(rnc.GetSocial().GetSteam().GetAppID())) + + fbInstantCfg := l.CreateTable(0, 1) + fbInstantCfg.RawSetString("app_secret", lua.LString(rnc.GetSocial().GetFacebookInstantGame().GetAppSecret())) + + fbLimitedCfg := l.CreateTable(0, 1) + fbLimitedCfg.RawSetString("app_id", lua.LString(rnc.GetSocial().GetFacebookLimitedLogin().GetAppId())) + + appleCfg := l.CreateTable(0, 1) + appleCfg.RawSetString("bundle_id", lua.LString(rnc.GetSocial().GetApple().GetBundleId())) + + socialCfg := l.CreateTable(0, 4) + socialCfg.RawSetString("steam", steamCfg) + socialCfg.RawSetString("facebook_instant_game", fbInstantCfg) + socialCfg.RawSetString("facebook_limited_login", fbLimitedCfg) + socialCfg.RawSetString("apple", appleCfg) + cfgObj.RawSetString("social", socialCfg) + + runtimeCfg := l.CreateTable(0, 2) + envTable := l.CreateTable(0, len(rnc.GetRuntime().GetEnv())) + for _, e := range rnc.GetRuntime().GetEnv() { + envTable.Append(lua.LString(e)) + } + runtimeCfg.RawSetString("env", envTable) + runtimeCfg.RawSetString("http_key", lua.LString(rnc.GetRuntime().GetHTTPKey())) + cfgObj.RawSetString("runtime", runtimeCfg) + + // IAP + iapAppleCfg := l.CreateTable(0, 2) + iapAppleCfg.RawSetString("shared_password", lua.LString(rnc.GetIAP().GetApple().GetSharedPassword())) + iapAppleCfg.RawSetString("notifications_endpoint_id", lua.LString(rnc.GetIAP().GetApple().GetNotificationsEndpointId())) + + iapGoogleCfg := l.CreateTable(0, 5) + iapGoogleCfg.RawSetString("client_email", lua.LString(rnc.GetIAP().GetGoogle().GetClientEmail())) + iapGoogleCfg.RawSetString("private_key", lua.LString(rnc.GetIAP().GetGoogle().GetPrivateKey())) + iapGoogleCfg.RawSetString("notifications_endpoint_id", lua.LString(rnc.GetIAP().GetGoogle().GetNotificationsEndpointId())) + iapGoogleCfg.RawSetString("refund_check_period_min", lua.LNumber(rnc.GetIAP().GetGoogle().GetRefundCheckPeriodMin())) + iapGoogleCfg.RawSetString("package_name", lua.LString(rnc.GetIAP().GetGoogle().GetPackageName())) + + iapHuaweiCfg := l.CreateTable(0, 3) + iapHuaweiCfg.RawSetString("public_key", lua.LString(rnc.GetIAP().GetHuawei().GetPublicKey())) + iapHuaweiCfg.RawSetString("client_id", lua.LString(rnc.GetIAP().GetHuawei().GetClientID())) + iapHuaweiCfg.RawSetString("client_secret", lua.LString(rnc.GetIAP().GetHuawei().GetClientSecret())) + + iapFacebookInstantCfg := l.CreateTable(0, 1) + iapFacebookInstantCfg.RawSetString("app_secret", lua.LString(rnc.GetIAP().GetFacebookInstant().GetAppSecret())) + iapCfg := l.CreateTable(0, 4) + iapCfg.RawSetString("apple", iapAppleCfg) + iapCfg.RawSetString("google", iapGoogleCfg) + iapCfg.RawSetString("huawei", iapHuaweiCfg) + iapCfg.RawSetString("facebook_instant", iapFacebookInstantCfg) + cfgObj.RawSetString("iap", iapCfg) + + googleAuthCfg := l.CreateTable(0, 1) + googleAuthCfg.RawSetString("credentials_json", lua.LString(rnc.GetGoogleAuth().GetCredentialsJSON())) + cfgObj.RawSetString("google_auth", googleAuthCfg) + + satoriCfg := l.CreateTable(0, 4) + satoriCfg.RawSetString("url", lua.LString(rnc.GetSatori().GetUrl())) + satoriCfg.RawSetString("api_key_name", lua.LString(rnc.GetSatori().GetApiKeyName())) + satoriCfg.RawSetString("api_key", lua.LString(rnc.GetSatori().GetApiKey())) + satoriCfg.RawSetString("signing_key", lua.LString(rnc.GetSatori().GetSigningKey())) + cfgObj.RawSetString("satori", satoriCfg) + + l.Push(cfgObj) + + return 1 +} + // @group satori // @summary Get the Satori client. // @return satori(table) The satori client. diff --git a/vendor/github.com/heroiclabs/nakama-common/runtime/config.go b/vendor/github.com/heroiclabs/nakama-common/runtime/config.go new file mode 100644 index 0000000000..6784eaffab --- /dev/null +++ b/vendor/github.com/heroiclabs/nakama-common/runtime/config.go @@ -0,0 +1,130 @@ +// Copyright 2024 The Nakama Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package runtime + +// Config interface is the Nakama core configuration. +type Config interface { + GetName() string + GetShutdownGraceSec() int + GetLogger() LoggerConfig + GetSession() SessionConfig + GetSocket() SocketConfig + GetSocial() SocialConfig + GetRuntime() RuntimeConfig + GetIAP() IAPConfig + GetGoogleAuth() GoogleAuthConfig + GetSatori() SatoriConfig +} + +// LoggerConfig is configuration relevant to logging levels and output. +type LoggerConfig interface { + GetLevel() string +} + +// SessionConfig is configuration relevant to the session. +type SessionConfig interface { + GetEncryptionKey() string + GetTokenExpirySec() int64 + GetRefreshEncryptionKey() string + GetRefreshTokenExpirySec() int64 + GetSingleSocket() bool + GetSingleMatch() bool + GetSingleParty() bool + GetSingleSession() bool +} + +// SocketConfig is configuration relevant to the transport socket and protocol. +type SocketConfig interface { + GetServerKey() string + GetPort() int + GetAddress() string + GetProtocol() string +} + +// SocialConfig is configuration relevant to the social authentication providers. +type SocialConfig interface { + GetSteam() SocialConfigSteam + GetFacebookInstantGame() SocialConfigFacebookInstantGame + GetFacebookLimitedLogin() SocialConfigFacebookLimitedLogin + GetApple() SocialConfigApple +} + +// SocialConfigSteam is configuration relevant to Steam. +type SocialConfigSteam interface { + GetPublisherKey() string + GetAppID() int +} + +// SocialConfigFacebookInstantGame is configuration relevant to Facebook Instant Games. +type SocialConfigFacebookInstantGame interface { + GetAppSecret() string +} + +// SocialConfigFacebookLimitedLogin is configuration relevant to Facebook Limited Login. +type SocialConfigFacebookLimitedLogin interface { + GetAppId() string +} + +// SocialConfigApple is configuration relevant to Apple Sign In. +type SocialConfigApple interface { + GetBundleId() string +} + +// RuntimeConfig is configuration relevant to the Runtimes. +type RuntimeConfig interface { + GetEnv() []string + GetHTTPKey() string +} + +type IAPConfig interface { + GetApple() IAPAppleConfig + GetGoogle() IAPGoogleConfig + GetHuawei() IAPHuaweiConfig + GetFacebookInstant() IAPFacebookInstantConfig +} + +type IAPAppleConfig interface { + GetSharedPassword() string + GetNotificationsEndpointId() string +} + +type IAPGoogleConfig interface { + GetClientEmail() string + GetPrivateKey() string + GetNotificationsEndpointId() string + GetRefundCheckPeriodMin() int + GetPackageName() string +} + +type SatoriConfig interface { + GetUrl() string + GetApiKeyName() string + GetApiKey() string + GetSigningKey() string +} + +type IAPHuaweiConfig interface { + GetPublicKey() string + GetClientID() string + GetClientSecret() string +} + +type IAPFacebookInstantConfig interface { + GetAppSecret() string +} + +type GoogleAuthConfig interface { + GetCredentialsJSON() string +} diff --git a/vendor/github.com/heroiclabs/nakama-common/runtime/runtime.go b/vendor/github.com/heroiclabs/nakama-common/runtime/runtime.go index fb4900c0c1..d46c5da43b 100644 --- a/vendor/github.com/heroiclabs/nakama-common/runtime/runtime.go +++ b/vendor/github.com/heroiclabs/nakama-common/runtime/runtime.go @@ -316,6 +316,10 @@ It is made available to the InitModule function as an input parameter when the f NOTE: You must not cache the reference to this and reuse it as a later point as this could have unintended side effects. */ type Initializer interface { + /* + GetConfig returns a read only subset of the Nakama configuration values. + */ + GetConfig() (Config, error) /* RegisterRpc registers a function with the given ID. This ID can be used within client code to send an RPC message to execute the function and return the result. Results are always returned as a JSON string (or optionally empty string). diff --git a/vendor/modules.txt b/vendor/modules.txt index 4d3ce0f401..6f37c88566 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -139,7 +139,7 @@ github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2/internal/genopena github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2/options github.com/grpc-ecosystem/grpc-gateway/v2/runtime github.com/grpc-ecosystem/grpc-gateway/v2/utilities -# github.com/heroiclabs/nakama-common v1.34.1-0.20241121105602-e24311ad3419 +# github.com/heroiclabs/nakama-common v1.34.1-0.20241123094823-fd6420e8b69d ## explicit; go 1.19 github.com/heroiclabs/nakama-common/api github.com/heroiclabs/nakama-common/rtapi