diff --git a/CHANGELOG.md b/CHANGELOG.md index 0982f20..85926e6 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 GetConf runtime API. ## [1.34.0] - 2024-10-21 ### Added diff --git a/index.d.ts b/index.d.ts index 54805d0..43ee6db 100644 --- a/index.d.ts +++ b/index.d.ts @@ -3239,6 +3239,113 @@ declare namespace nkruntime { persistent: boolean } + export interface Config { + name: string + shutdown_grace_sec: number + logger: ConfigLogger + session: ConfigSession + socket: ConfigSocket + social: ConfigSocial + runtime: ConfigRuntime + iap: ConfigIAP + google_auth: ConfigGoogleAuth + satori: ConfigSatori + } + + export interface ConfigLogger { + level: string + } + + export interface ConfigSession { + encryption_key: string + token_expiry_sec: number + refresh_encryption_key: string + refresh_token_expiry_sec: number + single_socket: boolean + single_match: boolean + single_party: boolean + single_session: boolean + } + + export interface ConfigSocket { + server_key: string + port: number + address: string + protocol: string + } + + export interface ConfigSocial { + steam: ConfigSteam + facebookInstantGame: ConfigFacebookInstantGame + facebookLimitedLogin: ConfigFacebookLimitedLogin + apple: ConfigApple + } + + export interface ConfigSteam { + publisher_key: string + app_id: string + } + + export interface ConfigFacebookInstantGame { + app_secret: string + } + + export interface ConfigFacebookLimitedLogin { + app_id: string + } + + export interface ConfigApple { + bundle_id: string + } + + export interface ConfigRuntime { + env: string[] + http_key: string + } + + export interface ConfigIAP { + apple: ConfigIAPApple + google: ConfigIAPGoogle + huawei: ConfigIAPHuawei + facebook_instant: ConfigIAPFacebookInstant + } + + export interface ConfigIAPApple { + shared_password: string + notifications_endpoint_id: string + } + + export interface ConfigIAPGoogle { + client_email: string + private_key: string + notifications_endpoint_id: string + refund_check_period_min: number + package_name: string + } + + export interface ConfigIAPHuawei { + public_key: string + client_id: string + client_secret: string + } + + export interface ConfigIAPFacebookInstant { + public_key: string + client_id: string + client_secret: string + } + + export interface ConfigGoogleAuth { + credentials_json: string + } + + export interface ConfigSatori { + url: string + api_key_name: string + api_key: string + signing_key: string + } + const enum PresenceReason { PresenceReasonUnknown = 0, PresenceReasonJoin = 1, @@ -3257,6 +3364,14 @@ declare namespace nkruntime { * The server APIs available in the game server. */ export interface Nakama { + /** + * Get subset of Nakama configs. + * + * @returns Object containing config values. + * @throws {TypeError} + */ + getConfig(): Config; + /** * Convert binary data to string. * diff --git a/runtime/config.go b/runtime/config.go new file mode 100644 index 0000000..6784eaf --- /dev/null +++ b/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/runtime/runtime.go b/runtime/runtime.go index fb4900c..deb7e52 100644 --- a/runtime/runtime.go +++ b/runtime/runtime.go @@ -1213,6 +1213,7 @@ type NakamaModule interface { StatusFollow(sessionID string, userIDs []string) error StatusUnfollow(sessionID string, userIDs []string) error + GetConfig() (Config, error) GetSatori() Satori GetFleetManager() FleetManager }