heroiclabs / nakama-common Goto Github PK
View Code? Open in Web Editor NEWThe runtime framework for Nakama server.
Home Page: https://github.com/heroiclabs/nakama
License: Apache License 2.0
The runtime framework for Nakama server.
Home Page: https://github.com/heroiclabs/nakama
License: Apache License 2.0
userId: string
but should be groupId: string
https://github.com/heroiclabs/nakama-common/blob/master/index.d.ts#L3843
I tried to create a simple default tournament but it didn't work. Then I have to take all codes from your example from docs but it turn into error too. It logged out nothing but error map[]
Is there something wrong with your example, my code, or you guys hide some tricks behind the example? Or this is a bug then i have to wait? And by the way, other features are running fine.
edgeCount is currently defined as a string it would be ideal to have it come down as an int64
We should expose ErrStorageRejectedVersion and ErrStorageRejectedPermission to the runtime to allow better error handling if either is returned.
Hello, I am receiving this error after the registration.
initializer.registerAfterDeleteNotifications(afterDeleteNotifications);
nakama | {"level":"error","ts":"2022-05-06T08:02:23.102Z","caller":"server/runtime_javascript.go:1524","msg":"Failed to eval JavaScript modules.","error":"TypeError: Object has no member 'registerAfterDeleteNotifications'\n\tat InitModule (index.js:365:49(107))\n\tat native\n"}
Should i change the name or it should be remove from the project?
Right now, the type for the state is:
export interface MatchState {
[key: string]: any;
}
It would be great if this was customizable by the user. This would require adding making all the handlers generic accepting that type. It should be easy to make sure that a set of all handlers is coherent, because they're all passed together to registerMatch
, which could simply fill in that type when typechecking.
To maintain backwards compatibility, I think it could be possible to leave this type in and make it the default value for the generic.
hi,
First of all: I've built the current source code, so I have the latest changes regarding Base64.
I have string I wish to base64 decode. "D-piPuEUcFN8I_ZlwW0BVChQvWG446bwmFTMlWXTZ44="
When I use TypeScript implementation result string has 31 chars length.
nk.base64UrlDecode(s).length==31
When I use (https://go.dev/play/) and type the same code as in nakama runtime, result string is 32 chars length
len(base64.URLEncoding.DecodeString(s))==32
There are some errors:
error strings should not be capitalizedST1005
error strings should not end with punctuation or newlinesST1005
ErrStorageRejectedVersion = errors.New("Storage write rejected - version check failed.")
ErrStorageRejectedPermission = errors.New("Storage write rejected - permission denied.")
error strings should not be capitalizedST1005
ErrInvalidChannelTarget = errors.New("Invalid channel target")
ErrInvalidChannelType = errors.New("Invalid channel type")
I was checking the new release 3.13.1 with runtime 1.24.0 to see if #88 is now fixed.
My test code still is:
nk.base64UrlEncode(nk.hmacSha256Hash('testpayload', 'testsecret'), false)
I noticed two things:
base64Encode
now accepts a string | ArrayBuffer
while base64UrlEncode
still only accepts string
.base64encode
and base64UrlEncode
it looks like both use url-encoding internally.Side note: it would be nice to have jwt verification built in (as we also do have jwtGenerate
)
Declared Uint8Array
- https://github.com/formatCvt/nakama-common/blob/master/index.d.ts#L244 (and other places)
Expected ArrayBuffer
- https://github.com/heroiclabs/nakama/blob/4290fa76c46d28b51a3856c55f999c76215be453/server/runtime_javascript_match_core.go#L567 (and other places)
We should replace Uint8Array with ArrayBuffer
Looks like in "ValidatedPurchase" ts interface, "providerResponse" should be declared instead of "providerPayload", cause there is no such field in arriving object. Besides, go api contains reference to "providerResponse" field as well.
I noticed that the documentation mentions a "recorded" Parameter in the accountDeleteId
method.
However, in the typescript method signature, this parameter is missing:
accountDeleteId(userId: string): void;
Edit: I am using nakama-runtime version v1.23.0
i noticed a new commit here 143e8d8 adding MatchSignal. The template has not been updated to support this perhaps?
i do the recommended npm install and then npx tsc and get this now:
C:\Users\user\projects\nakama\server\nakama-project-template>npx tsc
main.ts:23:43 - error TS2345: Argument of type '{ matchInit: nkruntime.MatchInitFunction; matchJoinAttempt: nkruntime.MatchJoinAttemptFunction; matchJoin: nkruntime.MatchJoinFunction; matchLeave: nkruntime.MatchLeaveFunction; matchLoop: nkruntime.MatchLoopFunction; matchTerminate: nkruntime.MatchTerminateFunction; }' is not assignable to parameter of type 'MatchHandler'.
Property 'matchSignal' is missing in type '{ matchInit: nkruntime.MatchInitFunction; matchJoinAttempt: nkruntime.MatchJoinAttemptFunction; matchJoin: nkruntime.MatchJoinFunction; matchLeave: nkruntime.MatchLeaveFunction; matchLoop: nkruntime.MatchLoopFunction; matchTerminate: nkruntime.MatchTerminateFunction; }' but required in type 'MatchHandler'.
23 initializer.registerMatch(moduleName, {
~
24 matchInit,
~~~~~~~~~~~~~~~~~~
...
29 matchTerminate,
~~~~~~~~~~~~~~~~~~~~~~~
30 });
~~~~~
node_modules/nakama-runtime/index.d.ts:804:9
804 matchSignal: MatchSignalFunction;
~~~~~~~~~~~
'matchSignal' is declared here.
Found 1 error.
In Typescript
nk.base64UrlEncode(nk.hmacSha256Hash('testpayload', 'testsecret'), false)
generates
77-977-9XV5277-9Zm7vv71S77-9C--_ve-_vXMuIO-_vX3vv73vv73vv70WD--_vRjvv70QdCEDFg
.
Using Go directly
mac := hmac.New(sha256.New, []byte("testsecret"))
_, err := mac.Write([]byte("testpayload"))
log.Print(base64.RawURLEncoding.EncodeToString(mac.Sum(nil)))
generate a different string (which seems to be the correct one):
lJJdXnaVZm7GUuwL-KRzLiCRfbT7kBYPtxjCEHQhAxY
.
Do I use the API in a wrong way or is there some encoding issue going on?
My dependencies:
nakama-runtime: "github:heroiclabs/nakama-common#v1.23.0"
docker image: registry.heroiclabs.com/heroiclabs/nakama:3.12.0
There are some functions that exist but are not declared in Typescript.
Here's a list of those I encountered so far, but there could be more. They are all methods of the nkruntime.Nakama
object.
localcacheGet()
localcachePut()
localcacheDelete()
cronNext()
Please add the missing definitions to the .d.ts file.
Parameter duration
should be optional.
https://github.com/heroiclabs/nakama-common/blob/v1.15.0/index.d.ts#L3705
Nakama image: heroiclabs/nakama-enterprise:3.13.1-r1-mc
Nakama runtime version: 1.24.0
The documentation and the interface clearly states that a string would be returned. Instead a Uint8Array is returned.
.lua, .so, and .js Are the current runtime authoring options.
Wazero runs wasm with no cgo and is V1 now. The no cgo is great be Ayse builds are easy.
it will allow devs to write their logic in any language that compiles to wasm . Rust, go. Typescript, python, c, c#, and many more.
In index.d.ts, MatchInitFunction, params has wrong type:
current: params: {[key: string]: string})
should be: params: {[key: string]: any})
because it is not string, it returns an object. Maybe you forgot to align it.
Also, please update documentation:
https://heroiclabs.com/docs/nakama/server-framework/typescript-runtime/function-reference/match-handler/
By the way, in Go documentation it is set correctly:
params map[string]interface{}
Thanks in advance!
The typescript setup guide tells the user to add "typeRoots": ["./node_modules"]
to the tsconfig.json
. This seems a little dangerous to me and from my PoV this could also be solved by using Type-Only imports from Typescript 3.8.
I went ahead and changed declare namespace nkruntime
(see https://github.com/heroiclabs/nakama-common/blob/master/index.d.ts#L15) to export namespace nkruntime
and then a corresponding import { nkruntime } from "nakama-runtime";
in my typescript file.
For me this works fine and nicely streamlines the development to be less "unusual".
Line 2225 in 49493e3
Is it missed or it is intended?
Can I use 'delete'
method in a nk.httpRequest()
?
nakama 3.17.1
nakama-runtime 1.28.1
nkruntime.Context.vars undefined in my setup, but typescript definition don't allow optional
index.d.ts has method "authenticateGamecenter", it's not compiling, cause it should be "authenticateGameCenter" (with capital "C")
I think this line should be changed.
nakama-common/runtime/runtime.go
Line 995 in 036a5bd
WalletUpdate(ctx context.Context, userID string, changeset map[string]int64, metadata map[string]interface{}, updateLedger bool) (updated map[string]int64, previous map[string]int64, err error)
to
WalletUpdate(ctx context.Context, userID string, changeset map[string]int64, metadata map[string]interface{}, updateLedger bool) (*WalletUpdateResult, error)
Exported interface Group
is missing the metadata
property.
https://github.com/heroiclabs/nakama-common/blob/master/index.d.ts#L2443-L2455
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.