Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ require (
github.com/gorilla/mux v1.8.1
github.com/gorilla/websocket v1.5.3
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.4
github.com/heroiclabs/nakama-common v1.44.2
github.com/heroiclabs/nakama-common v1.44.3-0.20260227093501-82654fd671a4
github.com/heroiclabs/sql-migrate v0.0.0-20241125131053-95a7949783b0
github.com/jackc/pgerrcode v0.0.0-20250907135507-afb5586c32a6
github.com/jackc/pgx/v5 v5.8.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/ad
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.4 h1:kEISI/Gx67NzH3nJxAmY/dGac80kKZgZt134u7Y/k1s=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.4/go.mod h1:6Nz966r3vQYCqIzWsuEl9d7cf7mRhtDmm++sOxlnfxI=
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
github.com/heroiclabs/nakama-common v1.44.2 h1:aynrv/lFSI/1N54JxQ81FD80Iw7OL1yLrySwUemOOBU=
github.com/heroiclabs/nakama-common v1.44.2/go.mod h1:/KLxEy4+JdasHJLPt+tAXJJ8eXywWr/J+Q+KY+/vg7E=
github.com/heroiclabs/nakama-common v1.44.3-0.20260227093501-82654fd671a4 h1:f6d6H/N00meKbdP1xJfaF2gUxBKGH9uZ7WUniSH8Er0=
github.com/heroiclabs/nakama-common v1.44.3-0.20260227093501-82654fd671a4/go.mod h1:/KLxEy4+JdasHJLPt+tAXJJ8eXywWr/J+Q+KY+/vg7E=
github.com/heroiclabs/sql-migrate v0.0.0-20241125131053-95a7949783b0 h1:hHJcYOP6L2/wZIEnYjjkJM+rOk/bK0uaYkDAejYpLhI=
github.com/heroiclabs/sql-migrate v0.0.0-20241125131053-95a7949783b0/go.mod h1:uwcmopkVQIfb/JQqul5zmGI9ounclRC08j9S9lLcpRQ=
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
Expand Down
72 changes: 57 additions & 15 deletions internal/satori/satori.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ func (s *SatoriClient) Authenticate(ctx context.Context, id string, defaultPrope
defer res.Body.Close()

switch res.StatusCode {
case 200:
case http.StatusOK:
resBody, err := io.ReadAll(res.Body)
if err != nil {
return nil, err
Expand All @@ -328,6 +328,48 @@ func (s *SatoriClient) Authenticate(ctx context.Context, id string, defaultPrope
}
}

// @group satori
// @summary Delete an identity and all its associated data.
// @param ctx(type=context.Context) The context object represents information about the server and requester.
// @param id(type=string) The identifier of the identity.
// @return error(error) An optional error value if an error occurred.
func (s *SatoriClient) IdentityDelete(ctx context.Context, id string) error {
if s.invalidConfig {
return runtime.ErrSatoriConfigurationInvalid
}

url := s.url.JoinPath("/v1/identity").String()

sessionToken, err := s.generateToken(ctx, id)
if err != nil {
return err
}

req, err := http.NewRequestWithContext(ctx, http.MethodDelete, url, nil)
if err != nil {
return err
}
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", sessionToken))

res, err := s.httpc.Do(req)
if err != nil {
return err
}

defer res.Body.Close()

switch res.StatusCode {
case http.StatusOK:
return nil
default:
resBody, readErr := io.ReadAll(res.Body)
if readErr != nil {
return fmt.Errorf("%d status code", res.StatusCode)
}
return fmt.Errorf("%d status code: %s", res.StatusCode, strings.TrimSpace(string(resBody)))
}
}

// @group satori
// @summary Get identity properties.
// @param ctx(type=context.Context) The context object represents information about the server and requester.
Expand Down Expand Up @@ -369,7 +411,7 @@ func (s *SatoriClient) PropertiesGet(ctx context.Context, id string) (*runtime.P
defer res.Body.Close()

switch res.StatusCode {
case 200:
case http.StatusOK:
resBody, err := io.ReadAll(res.Body)
if err != nil {
return nil, err
Expand Down Expand Up @@ -433,7 +475,7 @@ func (s *SatoriClient) PropertiesUpdate(ctx context.Context, id string, properti
defer res.Body.Close()

switch res.StatusCode {
case 200:
case http.StatusOK:
return nil
default:
return fmt.Errorf("%d status code", res.StatusCode)
Expand Down Expand Up @@ -507,7 +549,7 @@ func (s *SatoriClient) EventsPublish(ctx context.Context, id string, events []*r
defer res.Body.Close()

switch res.StatusCode {
case 200:
case http.StatusOK:
return nil
default:
errBody, err := io.ReadAll(res.Body)
Expand Down Expand Up @@ -568,7 +610,7 @@ func (s *SatoriClient) ServerEventsPublish(ctx context.Context, events []*runtim
defer res.Body.Close()

switch res.StatusCode {
case 200:
case http.StatusOK:
return nil
default:
errBody, err := io.ReadAll(res.Body)
Expand Down Expand Up @@ -639,7 +681,7 @@ func (s *SatoriClient) ExperimentsList(ctx context.Context, id string, names, la
}

switch res.StatusCode {
case 200:
case http.StatusOK:
var experiments *runtime.ExperimentList
if err = json.Unmarshal(resBody, &experiments); err != nil {
return nil, err
Expand Down Expand Up @@ -748,7 +790,7 @@ func (s *SatoriClient) FlagsList(ctx context.Context, id string, names, labels [
}

switch res.StatusCode {
case 200:
case http.StatusOK:
var flags *runtime.FlagList
if err = json.Unmarshal(resBody, &flags); err != nil {
return nil, err
Expand Down Expand Up @@ -851,7 +893,7 @@ func (s *SatoriClient) FlagsOverridesList(ctx context.Context, id string, names,
}

switch res.StatusCode {
case 200:
case http.StatusOK:
var flagOverrides *runtime.FlagOverridesList
if err = json.Unmarshal(resBody, &flagOverrides); err != nil {
return nil, err
Expand Down Expand Up @@ -1010,7 +1052,7 @@ func (s *SatoriClient) LiveEventsList(ctx context.Context, id string, names, lab
}

switch res.StatusCode {
case 200:
case http.StatusOK:
var liveEvents *runtime.LiveEventList
if err = json.Unmarshal(resBody, &liveEvents); err != nil {
return nil, err
Expand Down Expand Up @@ -1076,7 +1118,7 @@ func (s *SatoriClient) LiveEventJoin(ctx context.Context, id, liveEventId string
}

switch res.StatusCode {
case 200:
case http.StatusOK:
return nil
default:
if len(resBody) > 0 {
Expand Down Expand Up @@ -1140,7 +1182,7 @@ func (s *SatoriClient) MessagesList(ctx context.Context, id string, limit int, f
}

switch res.StatusCode {
case 200:
case http.StatusOK:
var messages runtime.MessageList
if err = json.Unmarshal(resBody, &messages); err != nil {
return nil, err
Expand Down Expand Up @@ -1198,7 +1240,7 @@ func (s *SatoriClient) MessageUpdate(ctx context.Context, id, messageId string,
defer res.Body.Close()

switch res.StatusCode {
case 200:
case http.StatusOK:
return nil
default:
errBody, err := io.ReadAll(res.Body)
Expand Down Expand Up @@ -1245,7 +1287,7 @@ func (s *SatoriClient) MessageDelete(ctx context.Context, id, messageId string)
defer res.Body.Close()

switch res.StatusCode {
case 200:
case http.StatusOK:
return nil
default:
errBody, err := io.ReadAll(res.Body)
Expand Down Expand Up @@ -1312,7 +1354,7 @@ func (s *SatoriClient) ConsoleMessageTemplatesList(ctx context.Context, in *cons
defer res.Body.Close()

switch res.StatusCode {
case 200:
case http.StatusOK:
resBody, err := io.ReadAll(res.Body)
if err != nil {
return nil, err
Expand Down Expand Up @@ -1483,7 +1525,7 @@ func (s *SatoriClient) ConsoleDirectMessageSend(ctx context.Context, templateId
defer res.Body.Close()

switch res.StatusCode {
case 200:
case http.StatusOK:
resBody, err := io.ReadAll(res.Body)
if err != nil {
return nil, err
Expand Down
18 changes: 18 additions & 0 deletions server/runtime_javascript_nakama.go
Original file line number Diff line number Diff line change
Expand Up @@ -8975,6 +8975,7 @@ func (n *RuntimeJavascriptNakamaModule) channelIdBuild(r *goja.Runtime) func(goj
func (n *RuntimeJavascriptNakamaModule) satoriConstructor(r *goja.Runtime) (*goja.Object, error) {
mappings := map[string]func(goja.FunctionCall) goja.Value{
"authenticate": n.satoriAuthenticate(r),
"identityDelete": n.satoriIdentityDelete(r),
"propertiesGet": n.satoriPropertiesGet(r),
"propertiesUpdate": n.satoriPropertiesUpdate(r),
"eventsPublish": n.satoriPublishEvents(r),
Expand Down Expand Up @@ -9065,6 +9066,23 @@ func (n *RuntimeJavascriptNakamaModule) satoriAuthenticate(r *goja.Runtime) func
}
}

// @group satori
// @summary Delete an identity and all its associated data.
// @param id(type=string) The identifier of the identity.
// @return error(error) An optional error value if an error occurred.
func (n *RuntimeJavascriptNakamaModule) satoriIdentityDelete(r *goja.Runtime) func(goja.FunctionCall) goja.Value {
return func(f goja.FunctionCall) goja.Value {
id := getJsString(r, f.Argument(0))

if err := n.satori.IdentityDelete(n.ctx, id); err != nil {
n.logger.Error("Failed to Satori Identity Delete.", zap.Error(err))
panic(r.NewGoError(fmt.Errorf("failed to satori identity delete: %s", err.Error())))
}

return nil
}
}

// @group satori
// @summary Get identity properties.
// @param id(type=string) The identifier of the identity.
Expand Down
16 changes: 16 additions & 0 deletions server/runtime_lua_nakama.go
Original file line number Diff line number Diff line change
Expand Up @@ -11047,6 +11047,7 @@ func (n *RuntimeLuaNakamaModule) getConfig(l *lua.LState) int {
func (n *RuntimeLuaNakamaModule) getSatori(l *lua.LState) int {
satoriFunctions := map[string]lua.LGFunction{
"authenticate": n.satoriAuthenticate,
"identity_delete": n.satoriIdentityDelete,
"properties_get": n.satoriPropertiesGet,
"properties_update": n.satoriPropertiesUpdate,
"events_publish": n.satoriEventsPublish,
Expand Down Expand Up @@ -11120,6 +11121,21 @@ func (n *RuntimeLuaNakamaModule) satoriAuthenticate(l *lua.LState) int {
return 1
}

// @group satori
// @summary Delete an identity and all its associated data.
// @param identifier(type=string) The identifier of the identity.
// @return error(error) An optional error value if an error occurred.
func (n *RuntimeLuaNakamaModule) satoriIdentityDelete(l *lua.LState) int {
identifier := l.CheckString(1)

if err := n.satori.IdentityDelete(l.Context(), identifier); err != nil {
l.RaiseError("failed to satori identity delete: %v", err.Error())
return 0
}

return 0
}

// @group satori
// @summary Get identity properties.
// @param identifier(type=string) The identifier of the identity.
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.44.2
# github.com/heroiclabs/nakama-common v1.44.3-0.20260227093501-82654fd671a4
## explicit; go 1.25.5
github.com/heroiclabs/nakama-common/api
github.com/heroiclabs/nakama-common/rtapi
Expand Down
Loading