Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@heroiclabs/nakama-js

Package Overview
Dependencies
Maintainers
3
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@heroiclabs/nakama-js - npm Package Compare versions

Comparing version 2.0.1 to 2.1.0

.rpt2_cache/rpt2_1578bdcd82cae470804869a3f326b53e35317502/code/cache/349b5023013db4cd6300e92ca8a618a974f4c7de

202

dist/api.gen.d.ts

@@ -21,5 +21,11 @@ export interface ConfigurationParameters {

}
export interface WriteTournamentRecordRequestTournamentRecordWrite {
metadata?: string;
score?: string;
subscore?: string;
}
export interface ApiAccount {
custom_id?: string;
devices?: Array<ApiAccountDevice>;
disable_time?: string;
email?: string;

@@ -30,7 +36,13 @@ user?: ApiUser;

}
export interface ApiAccountApple {
token?: string;
vars?: Map<string, string>;
}
export interface ApiAccountCustom {
id?: string;
vars?: Map<string, string>;
}
export interface ApiAccountDevice {
id?: string;
vars?: Map<string, string>;
}

@@ -40,6 +52,12 @@ export interface ApiAccountEmail {

password?: string;
vars?: Map<string, string>;
}
export interface ApiAccountFacebook {
token?: string;
vars?: Map<string, string>;
}
export interface ApiAccountFacebookInstantGame {
signed_player_info?: string;
vars?: Map<string, string>;
}
export interface ApiAccountGameCenter {

@@ -52,8 +70,11 @@ bundle_id?: string;

timestamp_seconds?: string;
vars?: Map<string, string>;
}
export interface ApiAccountGoogle {
token?: string;
vars?: Map<string, string>;
}
export interface ApiAccountSteam {
token?: string;
vars?: Map<string, string>;
}

@@ -65,6 +86,10 @@ export interface ApiChannelMessage {

create_time?: string;
group_id?: string;
message_id?: string;
persistent?: boolean;
room_name?: string;
sender_id?: string;
update_time?: string;
user_id_one?: string;
user_id_two?: string;
username?: string;

@@ -81,2 +106,3 @@ }

lang_tag?: string;
max_count?: number;
name?: string;

@@ -93,7 +119,15 @@ open?: boolean;

}
export interface ApiEvent {
external?: boolean;
name?: string;
properties?: Map<string, string>;
timestamp?: string;
}
export interface ApiFriend {
state?: number;
update_time?: string;
user?: ApiUser;
}
export interface ApiFriends {
export interface ApiFriendList {
cursor?: string;
friends?: Array<ApiFriend>;

@@ -120,2 +154,3 @@ }

export interface ApiGroupUserList {
cursor?: string;
group_users?: Array<GroupUserListGroupUser>;

@@ -127,2 +162,3 @@ }

leaderboard_id?: string;
max_num_score?: number;
metadata?: string;

@@ -181,3 +217,2 @@ num_score?: number;

token?: string;
udp_token?: string;
}

@@ -211,2 +246,31 @@ export interface ApiStorageObject {

}
export interface ApiTournament {
can_enter?: boolean;
category?: number;
create_time?: string;
description?: string;
duration?: number;
end_active?: number;
end_time?: string;
id?: string;
max_num_score?: number;
max_size?: number;
metadata?: string;
next_reset?: number;
size?: number;
sort_order?: number;
start_active?: number;
start_time?: string;
title?: string;
}
export interface ApiTournamentList {
cursor?: string;
tournaments?: Array<ApiTournament>;
}
export interface ApiTournamentRecordList {
next_cursor?: string;
owner_records?: Array<ApiLeaderboardRecord>;
prev_cursor?: string;
records?: Array<ApiLeaderboardRecord>;
}
export interface ApiUpdateAccountRequest {

@@ -229,2 +293,3 @@ avatar_url?: string;

export interface ApiUser {
apple_id?: string;
avatar_url?: string;

@@ -235,2 +300,3 @@ create_time?: string;

facebook_id?: string;
facebook_instant_game_id?: string;
gamecenter_id?: string;

@@ -249,2 +315,3 @@ google_id?: string;

export interface ApiUserGroupList {
cursor?: string;
user_groups?: Array<UserGroupListUserGroup>;

@@ -266,60 +333,85 @@ }

}
export interface ProtobufEmpty {
export interface ProtobufAny {
type_url?: string;
value?: string;
}
export declare const NakamaApi: (configuration?: ConfigurationParameters) => {
healthcheck(options?: any): Promise<ProtobufEmpty>;
export interface RpcStatus {
code?: number;
details?: Array<ProtobufAny>;
message?: string;
}
export declare class NakamaApi {
configuration: ConfigurationParameters;
constructor(configuration: ConfigurationParameters);
doFetch(urlPath: string, method: string, queryParams: any, body?: any, options?: any): Promise<any>;
healthcheck(options?: any): Promise<any>;
getAccount(options?: any): Promise<ApiAccount>;
updateAccount(body: ApiUpdateAccountRequest, options?: any): Promise<ProtobufEmpty>;
authenticateCustom(body: ApiAccountCustom, options?: any): Promise<ApiSession>;
authenticateDevice(body: ApiAccountDevice, options?: any): Promise<ApiSession>;
authenticateEmail(body: ApiAccountEmail, options?: any): Promise<ApiSession>;
authenticateFacebook(body: ApiAccountFacebook, options?: any): Promise<ApiSession>;
authenticateGameCenter(body: ApiAccountGameCenter, options?: any): Promise<ApiSession>;
authenticateGoogle(body: ApiAccountGoogle, options?: any): Promise<ApiSession>;
authenticateSteam(body: ApiAccountSteam, options?: any): Promise<ApiSession>;
linkCustom(body: ApiAccountCustom, options?: any): Promise<ProtobufEmpty>;
linkDevice(body: ApiAccountDevice, options?: any): Promise<ProtobufEmpty>;
linkEmail(body: ApiAccountEmail, options?: any): Promise<ProtobufEmpty>;
linkFacebook(body: ApiAccountFacebook, options?: any): Promise<ProtobufEmpty>;
linkGameCenter(body: ApiAccountGameCenter, options?: any): Promise<ProtobufEmpty>;
linkGoogle(body: ApiAccountGoogle, options?: any): Promise<ProtobufEmpty>;
linkSteam(body: ApiAccountSteam, options?: any): Promise<ProtobufEmpty>;
unlinkCustom(body: ApiAccountCustom, options?: any): Promise<ProtobufEmpty>;
unlinkDevice(body: ApiAccountDevice, options?: any): Promise<ProtobufEmpty>;
unlinkEmail(body: ApiAccountEmail, options?: any): Promise<ProtobufEmpty>;
unlinkFacebook(body: ApiAccountFacebook, options?: any): Promise<ProtobufEmpty>;
unlinkGameCenter(body: ApiAccountGameCenter, options?: any): Promise<ProtobufEmpty>;
unlinkGoogle(body: ApiAccountGoogle, options?: any): Promise<ProtobufEmpty>;
unlinkSteam(body: ApiAccountSteam, options?: any): Promise<ProtobufEmpty>;
listChannelMessages(channelId: string, limit?: number | undefined, forward?: boolean | undefined, cursor?: string | undefined, options?: any): Promise<ApiChannelMessageList>;
deleteFriends(ids?: string[] | undefined, usernames?: string[] | undefined, options?: any): Promise<ProtobufEmpty>;
listFriends(options?: any): Promise<ApiFriends>;
addFriends(options?: any): Promise<ProtobufEmpty>;
blockFriends(options?: any): Promise<ProtobufEmpty>;
importFacebookFriends(body: ApiAccountFacebook, options?: any): Promise<ProtobufEmpty>;
listGroups(name?: string | undefined, cursor?: string | undefined, limit?: number | undefined, options?: any): Promise<ApiGroupList>;
updateAccount(body: ApiUpdateAccountRequest, options?: any): Promise<any>;
authenticateApple(body: ApiAccountApple, create?: boolean, username?: string, options?: any): Promise<ApiSession>;
authenticateCustom(body: ApiAccountCustom, create?: boolean, username?: string, options?: any): Promise<ApiSession>;
authenticateDevice(body: ApiAccountDevice, create?: boolean, username?: string, options?: any): Promise<ApiSession>;
authenticateEmail(body: ApiAccountEmail, create?: boolean, username?: string, options?: any): Promise<ApiSession>;
authenticateFacebook(body: ApiAccountFacebook, create?: boolean, username?: string, sync?: boolean, options?: any): Promise<ApiSession>;
authenticateFacebookInstantGame(body: ApiAccountFacebookInstantGame, create?: boolean, username?: string, options?: any): Promise<ApiSession>;
authenticateGameCenter(body: ApiAccountGameCenter, create?: boolean, username?: string, options?: any): Promise<ApiSession>;
authenticateGoogle(body: ApiAccountGoogle, create?: boolean, username?: string, options?: any): Promise<ApiSession>;
authenticateSteam(body: ApiAccountSteam, create?: boolean, username?: string, options?: any): Promise<ApiSession>;
linkApple(body: ApiAccountApple, options?: any): Promise<any>;
linkCustom(body: ApiAccountCustom, options?: any): Promise<any>;
linkDevice(body: ApiAccountDevice, options?: any): Promise<any>;
linkEmail(body: ApiAccountEmail, options?: any): Promise<any>;
linkFacebook(body: ApiAccountFacebook, sync?: boolean, options?: any): Promise<any>;
linkFacebookInstantGame(body: ApiAccountFacebookInstantGame, options?: any): Promise<any>;
linkGameCenter(body: ApiAccountGameCenter, options?: any): Promise<any>;
linkGoogle(body: ApiAccountGoogle, options?: any): Promise<any>;
linkSteam(body: ApiAccountSteam, options?: any): Promise<any>;
unlinkApple(body: ApiAccountApple, options?: any): Promise<any>;
unlinkCustom(body: ApiAccountCustom, options?: any): Promise<any>;
unlinkDevice(body: ApiAccountDevice, options?: any): Promise<any>;
unlinkEmail(body: ApiAccountEmail, options?: any): Promise<any>;
unlinkFacebook(body: ApiAccountFacebook, options?: any): Promise<any>;
unlinkFacebookInstantGame(body: ApiAccountFacebookInstantGame, options?: any): Promise<any>;
unlinkGameCenter(body: ApiAccountGameCenter, options?: any): Promise<any>;
unlinkGoogle(body: ApiAccountGoogle, options?: any): Promise<any>;
unlinkSteam(body: ApiAccountSteam, options?: any): Promise<any>;
listChannelMessages(channelId: string, limit?: number, forward?: boolean, cursor?: string, options?: any): Promise<ApiChannelMessageList>;
event(body: ApiEvent, options?: any): Promise<any>;
deleteFriends(ids?: Array<string>, usernames?: Array<string>, options?: any): Promise<any>;
listFriends(limit?: number, state?: number, cursor?: string, options?: any): Promise<ApiFriendList>;
addFriends(ids?: Array<string>, usernames?: Array<string>, options?: any): Promise<any>;
blockFriends(ids?: Array<string>, usernames?: Array<string>, options?: any): Promise<any>;
importFacebookFriends(body: ApiAccountFacebook, reset?: boolean, options?: any): Promise<any>;
listGroups(name?: string, cursor?: string, limit?: number, options?: any): Promise<ApiGroupList>;
createGroup(body: ApiCreateGroupRequest, options?: any): Promise<ApiGroup>;
deleteGroup(groupId: string, options?: any): Promise<ProtobufEmpty>;
updateGroup(groupId: string, body: ApiUpdateGroupRequest, options?: any): Promise<ProtobufEmpty>;
addGroupUsers(groupId: string, options?: any): Promise<ProtobufEmpty>;
joinGroup(groupId: string, options?: any): Promise<ProtobufEmpty>;
kickGroupUsers(groupId: string, options?: any): Promise<ProtobufEmpty>;
leaveGroup(groupId: string, options?: any): Promise<ProtobufEmpty>;
promoteGroupUsers(groupId: string, options?: any): Promise<ProtobufEmpty>;
listGroupUsers(groupId: string, options?: any): Promise<ApiGroupUserList>;
deleteLeaderboardRecord(leaderboardId: string, options?: any): Promise<ProtobufEmpty>;
listLeaderboardRecords(leaderboardId: string, ownerIds?: string[] | undefined, limit?: number | undefined, cursor?: string | undefined, options?: any): Promise<ApiLeaderboardRecordList>;
deleteGroup(groupId: string, options?: any): Promise<any>;
updateGroup(groupId: string, body: ApiUpdateGroupRequest, options?: any): Promise<any>;
addGroupUsers(groupId: string, userIds?: Array<string>, options?: any): Promise<any>;
banGroupUsers(groupId: string, userIds?: Array<string>, options?: any): Promise<any>;
demoteGroupUsers(groupId: string, userIds: Array<string>, options?: any): Promise<any>;
joinGroup(groupId: string, options?: any): Promise<any>;
kickGroupUsers(groupId: string, userIds?: Array<string>, options?: any): Promise<any>;
leaveGroup(groupId: string, options?: any): Promise<any>;
promoteGroupUsers(groupId: string, userIds?: Array<string>, options?: any): Promise<any>;
listGroupUsers(groupId: string, limit?: number, state?: number, cursor?: string, options?: any): Promise<ApiGroupUserList>;
deleteLeaderboardRecord(leaderboardId: string, options?: any): Promise<any>;
listLeaderboardRecords(leaderboardId: string, ownerIds?: Array<string>, limit?: number, cursor?: string, expiry?: string, options?: any): Promise<ApiLeaderboardRecordList>;
writeLeaderboardRecord(leaderboardId: string, body: WriteLeaderboardRecordRequestLeaderboardRecordWrite, options?: any): Promise<ApiLeaderboardRecord>;
listMatches(limit?: number | undefined, authoritative?: boolean | undefined, label?: string | undefined, minSize?: number | undefined, maxSize?: number | undefined, options?: any): Promise<ApiMatchList>;
deleteNotifications(ids?: string[] | undefined, options?: any): Promise<ProtobufEmpty>;
listNotifications(limit?: number | undefined, cacheableCursor?: string | undefined, options?: any): Promise<ApiNotificationList>;
rpcFunc2(id: string, payload?: string | undefined, httpKey?: string | undefined, options?: any): Promise<ApiRpc>;
rpcFunc(id: string, body: string, options?: any): Promise<ApiRpc>;
listLeaderboardRecordsAroundOwner(leaderboardId: string, ownerId: string, limit?: number, expiry?: string, options?: any): Promise<ApiLeaderboardRecordList>;
listMatches(limit?: number, authoritative?: boolean, label?: string, minSize?: number, maxSize?: number, query?: string, options?: any): Promise<ApiMatchList>;
deleteNotifications(ids?: Array<string>, options?: any): Promise<any>;
listNotifications(limit?: number, cacheableCursor?: string, options?: any): Promise<ApiNotificationList>;
rpcFunc2(id: string, payload?: string, httpKey?: string, options?: any): Promise<ApiRpc>;
rpcFunc(id: string, body: string, httpKey?: string, options?: any): Promise<ApiRpc>;
readStorageObjects(body: ApiReadStorageObjectsRequest, options?: any): Promise<ApiStorageObjects>;
writeStorageObjects(body: ApiWriteStorageObjectsRequest, options?: any): Promise<ApiStorageObjectAcks>;
deleteStorageObjects(body: ApiDeleteStorageObjectsRequest, options?: any): Promise<ProtobufEmpty>;
listStorageObjects(collection: string, userId?: string | undefined, limit?: number | undefined, cursor?: string | undefined, options?: any): Promise<ApiStorageObjectList>;
listStorageObjects2(collection: string, userId: string, limit?: number | undefined, cursor?: string | undefined, options?: any): Promise<ApiStorageObjectList>;
getUsers(ids?: string[] | undefined, usernames?: string[] | undefined, facebookIds?: string[] | undefined, options?: any): Promise<ApiUsers>;
listUserGroups(userId: string, options?: any): Promise<ApiUserGroupList>;
};
deleteStorageObjects(body: ApiDeleteStorageObjectsRequest, options?: any): Promise<any>;
listStorageObjects(collection: string, userId?: string, limit?: number, cursor?: string, options?: any): Promise<ApiStorageObjectList>;
listStorageObjects2(collection: string, userId: string, limit?: number, cursor?: string, options?: any): Promise<ApiStorageObjectList>;
listTournaments(categoryStart?: number, categoryEnd?: number, startTime?: number, endTime?: number, limit?: number, cursor?: string, options?: any): Promise<ApiTournamentList>;
listTournamentRecords(tournamentId: string, ownerIds?: Array<string>, limit?: number, cursor?: string, expiry?: string, options?: any): Promise<ApiTournamentRecordList>;
writeTournamentRecord(tournamentId: string, body: WriteTournamentRecordRequestTournamentRecordWrite, options?: any): Promise<ApiLeaderboardRecord>;
joinTournament(tournamentId: string, options?: any): Promise<any>;
listTournamentRecordsAroundOwner(tournamentId: string, ownerId: string, limit?: number, expiry?: string, options?: any): Promise<ApiTournamentRecordList>;
getUsers(ids?: Array<string>, usernames?: Array<string>, facebookIds?: Array<string>, options?: any): Promise<ApiUsers>;
listUserGroups(userId: string, limit?: number, state?: number, cursor?: string, options?: any): Promise<ApiUserGroupList>;
}

@@ -1,45 +0,5 @@

import { ApiAccount, ApiAccountCustom, ApiAccountDevice, ApiAccountEmail, ApiAccountFacebook, ApiAccountGoogle, ApiAccountGameCenter, ApiAccountSteam, ApiCreateGroupRequest, ApiDeleteStorageObjectsRequest, ApiMatchList, ApiReadStorageObjectsRequest, ApiStorageObjectAcks, ApiUpdateAccountRequest, ApiUpdateGroupRequest } from "./api.gen";
import { ApiAccount, ApiAccountCustom, ApiAccountDevice, ApiAccountEmail, ApiAccountFacebook, ApiAccountFacebookInstantGame, ApiAccountGoogle, ApiAccountGameCenter, ApiAccountSteam, ApiCreateGroupRequest, ApiDeleteStorageObjectsRequest, ApiEvent, ApiMatchList, ApiReadStorageObjectsRequest, ApiStorageObjectAcks, ApiUpdateAccountRequest, ApiUpdateGroupRequest, ApiAccountApple } from "./api.gen";
import { Session } from "./session";
import { Socket } from "./socket";
export interface AccountCustom {
username?: string;
create?: boolean;
id?: string;
}
export interface AccountDevice {
username?: string;
create?: boolean;
id?: string;
}
export interface AccountEmail {
username?: string;
create?: boolean;
email?: string;
password?: string;
}
export interface AccountFacebook {
username?: string;
create?: boolean;
token?: string;
}
export interface AccountGameCenter {
username?: string;
create?: boolean;
bundle_id?: string;
player_id?: string;
public_key_url?: string;
salt?: string;
signature?: string;
timestamp_seconds?: string;
}
export interface AccountGoogle {
username?: string;
create?: boolean;
token?: string;
}
export interface AccountSteam {
username?: string;
create?: boolean;
token?: string;
}
import { WebSocketAdapter } from "./web_socket_adapter";
export interface RpcResponse {

@@ -61,2 +21,3 @@ id?: string;

username?: string;
max_num_score?: number;
}

@@ -69,2 +30,36 @@ export interface LeaderboardRecordList {

}
export interface Tournament {
id?: string;
title?: string;
description?: string;
duration?: number;
category?: number;
sort_order?: number;
size?: number;
max_size?: number;
max_num_score?: number;
can_enter?: boolean;
end_active?: number;
next_reset?: number;
metadata?: object;
create_time?: string;
start_time?: string;
end_time?: string;
start_active?: number;
}
export interface TournamentList {
tournaments?: Array<Tournament>;
cursor?: string;
}
export interface TournamentRecordList {
next_cursor?: string;
owner_records?: Array<LeaderboardRecord>;
prev_cursor?: string;
records?: Array<LeaderboardRecord>;
}
export interface WriteTournamentRecord {
metadata?: object;
score?: string;
subscore?: string;
}
export interface WriteLeaderboardRecord {

@@ -106,7 +101,11 @@ metadata?: object;

create_time?: string;
group_id?: string;
message_id?: string;
persistent?: boolean;
room_name?: string;
reference_id?: string;
sender_id?: string;
update_time?: string;
user_id_one?: string;
user_id_two?: string;
username?: string;

@@ -146,2 +145,3 @@ }

friends?: Array<Friend>;
cursor?: string;
}

@@ -154,2 +154,3 @@ export interface GroupUser {

group_users?: Array<GroupUser>;
cursor?: string;
}

@@ -180,2 +181,3 @@ export interface Group {

user_groups?: Array<UserGroup>;
cursor?: string;
}

@@ -199,20 +201,22 @@ export interface Notification {

readonly port: string;
useSSL: boolean;
timeout: number;
verbose: boolean;
readonly useSSL: boolean;
readonly timeout: number;
private readonly apiClient;
private readonly configuration;
constructor(serverkey?: string, host?: string, port?: string, useSSL?: boolean, timeout?: number, verbose?: boolean);
constructor(serverkey?: string, host?: string, port?: string, useSSL?: boolean, timeout?: number);
addGroupUsers(session: Session, groupId: string, ids?: Array<string>): Promise<boolean>;
addFriends(session: Session, ids?: Array<string>, usernames?: Array<string>): Promise<boolean>;
authenticateCustom(request: AccountCustom): Promise<Session>;
authenticateDevice(request: AccountDevice): Promise<Session>;
authenticateEmail(request: AccountEmail): Promise<Session>;
authenticateFacebook(request: AccountFacebook): Promise<Session>;
authenticateGoogle(request: AccountGoogle): Promise<Session>;
authenticateGameCenter(request: AccountGameCenter): Promise<Session>;
authenticateSteam(request: AccountSteam): Promise<Session>;
authenticateApple(token: string, create?: boolean, username?: string, vars?: Map<string, string>, options?: any): Promise<Session>;
authenticateCustom(id: string, create?: boolean, username?: string, vars?: Map<string, string>, options?: any): Promise<Session>;
authenticateDevice(id: string, vars?: Map<string, string>): Promise<Session>;
authenticateEmail(email: string, password: string, vars?: Map<string, string>): Promise<Session>;
authenticateFacebookInstantGame(signedPlayerInfo: string, create?: boolean, username?: string, vars?: Map<string, string>, options?: any): Promise<Session>;
authenticateFacebook(token: string, create?: boolean, username?: string, sync?: boolean, vars?: Map<string, string>, options?: any): Promise<Session>;
authenticateGoogle(token: string, create?: boolean, username?: string, vars?: Map<string, string>, options?: any): Promise<Session>;
authenticateGameCenter(token: string, vars?: Map<string, string>): Promise<Session>;
authenticateSteam(token: string, vars?: Map<string, string>): Promise<Session>;
banGroupUsers(session: Session, groupId: string, ids?: Array<string>): Promise<boolean>;
blockFriends(session: Session, ids?: Array<string>, usernames?: Array<string>): Promise<boolean>;
createGroup(session: Session, request: ApiCreateGroupRequest): Promise<Group>;
createSocket(useSSL?: boolean, verbose?: boolean): Socket;
createSocket(useSSL?: boolean, verbose?: boolean, adapter?: WebSocketAdapter): Socket;
deleteFriends(session: Session, ids?: Array<string>, usernames?: Array<string>): Promise<boolean>;

@@ -222,2 +226,4 @@ deleteGroup(session: Session, groupId: string): Promise<boolean>;

deleteStorageObjects(session: Session, request: ApiDeleteStorageObjectsRequest): Promise<boolean>;
demoteGroupUsers(session: Session, groupId: string, ids: Array<string>): Promise<boolean>;
emitEvent(session: Session, request: ApiEvent): Promise<boolean>;
getAccount(session: Session): Promise<ApiAccount>;

@@ -227,8 +233,10 @@ importFacebookFriends(session: Session, request: ApiAccountFacebook): Promise<boolean>;

joinGroup(session: Session, groupId: string): Promise<boolean>;
joinTournament(session: Session, tournamentId: string): Promise<boolean>;
kickGroupUsers(session: Session, groupId: string, ids?: Array<string>): Promise<boolean>;
leaveGroup(session: Session, groupId: string): Promise<boolean>;
listChannelMessages(session: Session, channelId: string, limit?: number, forward?: boolean, cursor?: string): Promise<ChannelMessageList>;
listGroupUsers(session: Session, groupId: string): Promise<GroupUserList>;
listUserGroups(session: Session, userId: string): Promise<UserGroupList>;
listGroupUsers(session: Session, groupId: string, state?: number, limit?: number, cursor?: string): Promise<GroupUserList>;
listUserGroups(session: Session, userId: string, state?: number, limit?: number, cursor?: string): Promise<UserGroupList>;
listGroups(session: Session, name?: string, cursor?: string, limit?: number): Promise<GroupList>;
linkApple(session: Session, request: ApiAccountApple): Promise<boolean>;
linkCustom(session: Session, request: ApiAccountCustom): Promise<boolean>;

@@ -238,10 +246,15 @@ linkDevice(session: Session, request: ApiAccountDevice): Promise<boolean>;

linkFacebook(session: Session, request: ApiAccountFacebook): Promise<boolean>;
linkFacebookInstantGame(session: Session, request: ApiAccountFacebookInstantGame): Promise<boolean>;
linkGoogle(session: Session, request: ApiAccountGoogle): Promise<boolean>;
linkGameCenter(session: Session, request: ApiAccountGameCenter): Promise<boolean>;
linkSteam(session: Session, request: ApiAccountSteam): Promise<boolean>;
listFriends(session: Session): Promise<Friends>;
listLeaderboardRecords(session: Session, leaderboardId: string, ownerIds?: Array<string>, limit?: number, cursor?: string): Promise<LeaderboardRecordList>;
listMatches(session: Session, limit?: number, authoritative?: boolean, label?: string, minSize?: number, maxSize?: number): Promise<ApiMatchList>;
listFriends(session: Session, state?: number, limit?: number, cursor?: string): Promise<Friends>;
listLeaderboardRecords(session: Session, leaderboardId: string, ownerIds?: Array<string>, limit?: number, cursor?: string, expiry?: string): Promise<LeaderboardRecordList>;
listLeaderboardRecordsAroundOwner(session: Session, leaderboardId: string, ownerId: string, limit?: number, expiry?: string): Promise<LeaderboardRecordList>;
listMatches(session: Session, limit?: number, authoritative?: boolean, label?: string, minSize?: number, maxSize?: number, query?: string): Promise<ApiMatchList>;
listNotifications(session: Session, limit?: number, cacheableCursor?: string): Promise<NotificationList>;
listStorageObjects(session: Session, collection: string, userId?: string, limit?: number, cursor?: string): Promise<StorageObjectList>;
listTournaments(session: Session, categoryStart?: number, categoryEnd?: number, startTime?: number, endTime?: number, limit?: number, cursor?: string): Promise<TournamentList>;
listTournamentRecords(session: Session, tournamentId: string, ownerIds?: Array<string>, limit?: number, cursor?: string, expiry?: string): Promise<TournamentRecordList>;
listTournamentRecordsAroundOwner(session: Session, tournamentId: string, ownerId: string, limit?: number, expiry?: string): Promise<TournamentRecordList>;
promoteGroupUsers(session: Session, groupId: string, ids?: Array<string>): Promise<boolean>;

@@ -251,2 +264,3 @@ readStorageObjects(session: Session, request: ApiReadStorageObjectsRequest): Promise<StorageObjects>;

rpcGet(id: string, session?: Session, httpKey?: string, input?: object): Promise<RpcResponse>;
unlinkApple(session: Session, request: ApiAccountApple): Promise<boolean>;
unlinkCustom(session: Session, request: ApiAccountCustom): Promise<boolean>;

@@ -256,2 +270,3 @@ unlinkDevice(session: Session, request: ApiAccountDevice): Promise<boolean>;

unlinkFacebook(session: Session, request: ApiAccountFacebook): Promise<boolean>;
unlinkFacebookInstantGame(session: Session, request: ApiAccountFacebookInstantGame): Promise<boolean>;
unlinkGoogle(session: Session, request: ApiAccountGoogle): Promise<boolean>;

@@ -264,2 +279,3 @@ unlinkGameCenter(session: Session, request: ApiAccountGameCenter): Promise<boolean>;

writeStorageObjects(session: Session, objects: Array<WriteStorageObject>): Promise<ApiStorageObjectAcks>;
writeTournamentRecord(session: Session, tournamentId: string, request: WriteTournamentRecord): Promise<LeaderboardRecord>;
}

@@ -5,1 +5,4 @@ import "Base64";

export * from "./session";
export * from "./socket";
export * from "./web_socket_adapter";
export { ChannelMessage } from "./client";

@@ -0,1 +1,10 @@

export interface ISession {
readonly token: string;
readonly created_at: number;
readonly expires_at: number;
readonly username: string;
readonly user_id: string;
readonly vars: object;
isexpired(currenttime: number): boolean;
}
export declare class Session {

@@ -7,5 +16,6 @@ readonly token: string;

readonly user_id: string;
private constructor();
readonly vars: object;
constructor(token: string, created_at: number, expires_at: number, username: string, user_id: string, vars: object);
isexpired(currenttime: number): boolean;
static restore(jwt: string): Session;
}
import { ApiRpc } from "./api.gen";
import { Session } from "./session";
import { Notification } from "./client";
import { WebSocketAdapter } from "./web_socket_adapter";
declare type RequireKeys<T, K extends keyof T> = Omit<Partial<T>, K> & Pick<T, K>;
export interface Presence {
user_id: string;
session_id: string;
username: string;
node: string;
}
export interface Channel {
id: string;
presences: [{}];
self: {};
presences: Presence[];
self: Presence;
}

@@ -28,6 +36,10 @@ export interface ChannelJoin {

username: string;
content: {};
content: any;
create_time: string;
update_time: string;
persistent: boolean;
group_id: string;
room_name: string;
user_id_one: string;
user_id_two: string;
}

@@ -46,3 +58,3 @@ export interface ChannelMessageAck {

channel_id: string;
content: {};
content: any;
};

@@ -54,3 +66,3 @@ }

message_id: string;
content: {};
content: any;
};

@@ -66,19 +78,25 @@ }

channel_id: string;
joins: [{}];
leaves: [{}];
joins: Presence[];
leaves: Presence[];
}
export interface StreamId {
mode: number;
subject: string;
descriptor: string;
label: string;
}
export interface StreamData {
stream: {};
stream_presence: {};
stream: StreamId;
stream_presence: Presence;
data: string;
}
export interface StreamPresenceEvent {
stream: {};
joins: [{}];
leaves: [{}];
stream: StreamId;
joins: Presence[];
leaves: Presence[];
}
export interface MatchPresenceEvent {
match_id: string;
joins: [{}];
leaves: [{}];
joins: Presence[];
leaves: Presence[];
}

@@ -90,4 +108,4 @@ export interface MatchmakerAdd {

query: string;
string_properties: {};
numeric_properties: {};
string_properties?: Record<string, string>;
numeric_properties?: Record<string, number>;
};

@@ -100,2 +118,7 @@ }

}
export interface MatchmakerUser {
presence: Presence;
string_properties?: Record<string, string>;
numeric_properties?: Record<string, number>;
}
export interface MatchmakerMatched {

@@ -105,5 +128,13 @@ ticket: string;

token: string;
users: [{}];
self: {};
users: MatchmakerUser[];
self: MatchmakerUser;
}
export interface Match {
match_id: string;
authoritative: boolean;
label?: string;
size: number;
presences: Presence[];
self: Presence;
}
export interface CreateMatch {

@@ -114,4 +145,5 @@ match_create: {};

match_join: {
match_id: string;
token: string;
match_id?: string;
token?: string;
metadata?: {};
};

@@ -125,9 +157,10 @@ }

export interface MatchData {
match_data_send: {
match_id: string;
op_code: number;
data: {};
presence: [{}];
};
match_id: string;
op_code: number;
data: any;
presences: Presence[];
}
export interface MatchDataSend {
match_data_send: RequireKeys<MatchData, "match_id" | "op_code" | "data">;
}
export interface Rpc {

@@ -137,16 +170,22 @@ rpc: ApiRpc;

export interface Status {
presences: object;
presences: Presence[];
}
export interface StatusFollow {
user_ids: Array<string>;
status_follow: {
user_ids: string[];
};
}
export interface StatusPresenceEvent {
joins: [{}];
leaves: [{}];
joins: Presence[];
leaves: Presence[];
}
export interface StatusUnfollow {
user_ids: Array<string>;
status_unfollow: {
user_ids: string[];
};
}
export interface StatusUpdate {
status: string;
status_update: {
status?: string;
};
}

@@ -156,2 +195,18 @@ export interface Socket {

disconnect(fireDisconnectEvent: boolean): void;
send(message: ChannelJoin | ChannelLeave | ChannelMessageSend | ChannelMessageUpdate | ChannelMessageRemove | CreateMatch | JoinMatch | LeaveMatch | MatchDataSend | MatchmakerAdd | MatchmakerRemove | Rpc | StatusFollow | StatusUnfollow | StatusUpdate): Promise<any>;
addMatchmaker(query: string, minCount: number, maxCount: number, stringProperties?: Record<string, string>, numericProperties?: Record<string, number>): Promise<MatchmakerMatched>;
createMatch(): Promise<Match>;
followUsers(user_ids: string[]): Promise<Status>;
joinChat(target: string, type: number, persistence: boolean, hidden: boolean): Promise<Channel>;
joinMatch(match_id?: string, token?: string, metadata?: {}): Promise<Match>;
leaveChat(channel_id: string): Promise<void>;
leaveMatch(matchId: string): Promise<void>;
removeChatMessage(channel_id: string, message_id: string): Promise<ChannelMessageAck>;
removeMatchmaker(ticket: string): Promise<void>;
rpc(id?: string, payload?: string, http_key?: string): Promise<ApiRpc>;
sendMatchState(matchId: string, opCode: number, data: any, presence?: Presence[]): Promise<void>;
unfollowUsers(user_ids: string[]): Promise<void>;
updateChatMessage(channel_id: string, message_id: string, content: any): Promise<ChannelMessageAck>;
updateStatus(status?: string): Promise<void>;
writeChatMessage(channel_id: string, content: any): Promise<ChannelMessageAck>;
ondisconnect: (evt: Event) => void;

@@ -178,5 +233,6 @@ onerror: (evt: Event) => void;

verbose: boolean;
private socket?;
readonly adapter: WebSocketAdapter;
private readonly cIds;
constructor(host: string, port: string, useSSL?: boolean, verbose?: boolean);
private nextCid;
constructor(host: string, port: string, useSSL?: boolean, verbose?: boolean, adapter?: WebSocketAdapter);
generatecid(): string;

@@ -196,3 +252,19 @@ connect(session: Session, createStatus?: boolean): Promise<Session>;

onstreamdata(streamData: StreamData): void;
send(message: ChannelJoin | ChannelLeave | ChannelMessageSend | ChannelMessageUpdate | ChannelMessageRemove | CreateMatch | JoinMatch | LeaveMatch | MatchData | MatchmakerAdd | MatchmakerRemove | Rpc | StatusFollow | StatusUnfollow | StatusUpdate): Promise<{}>;
send(message: ChannelJoin | ChannelLeave | ChannelMessageSend | ChannelMessageUpdate | ChannelMessageRemove | CreateMatch | JoinMatch | LeaveMatch | MatchDataSend | MatchmakerAdd | MatchmakerRemove | Rpc | StatusFollow | StatusUnfollow | StatusUpdate): Promise<any>;
addMatchmaker(query: string, minCount: number, maxCount: number, stringProperties?: Record<string, string>, numericProperties?: Record<string, number>): Promise<MatchmakerMatched>;
createMatch(): Promise<Match>;
followUsers(userIds: string[]): Promise<Status>;
joinChat(target: string, type: number, persistence: boolean, hidden: boolean): Promise<Channel>;
joinMatch(match_id?: string, token?: string, metadata?: {}): Promise<Match>;
leaveChat(channel_id: string): Promise<void>;
leaveMatch(matchId: string): Promise<void>;
removeChatMessage(channel_id: string, message_id: string): Promise<ChannelMessageAck>;
removeMatchmaker(ticket: string): Promise<void>;
rpc(id?: string, payload?: string, http_key?: string): Promise<ApiRpc>;
sendMatchState(matchId: string, opCode: number, data: any, presences?: Presence[]): Promise<void>;
unfollowUsers(user_ids: string[]): Promise<void>;
updateChatMessage(channel_id: string, message_id: string, content: any): Promise<ChannelMessageAck>;
updateStatus(status?: string): Promise<void>;
writeChatMessage(channel_id: string, content: any): Promise<ChannelMessageAck>;
}
export {};
{
"name": "@heroiclabs/nakama-js",
"version": "2.0.1",
"description": "JavaScript client for Nakama server written in TypeScript.",
"keywords": [
"app server",
"client library",
"game server",
"nakama",
"realtime",
"realtime chat"
],
"homepage": "https://heroiclabs.com",
"bugs": "https://github.com/heroiclabs/nakama-js/issues",
"main": "dist/nakama-js.cjs.js",
"types": "dist/index.d.ts",
"module": "dist/nakama-js.esm.js",
"browser": "dist/nakama-js.umd.js",
"repository": "https://github.com/heroiclabs/nakama-js",
"author": "Chris Molozian <chris@heroiclabs.com>",
"contributors": [
"Andrei Mihu <andrei@heroiclabs.com>",
"Mo Firouz <mo@heroiclabs.com>"
],
"license": "Apache-2.0",
"private": false,
"version": "2.1.0",
"scripts": {
"build": "rollup -c",
"dev": "rollup -c -w",
"test": "jest"
"build": "node build.js"
},
"files": [
"dist",
"src"
],
"devDependencies": {
"chalk": "^2.3.0",
"jest": "^22.1.4",
"jest-environment-node": "^22.1.4",
"mkdirp": "^0.5.1",
"puppeteer": "^1.0.0",
"rimraf": "^2.6.2",
"rollup": "^0.55.1",
"rollup-plugin-typescript2": "^0.10.0",
"typedoc": "^0.10.0",
"typescript": "^2.6.2"
},
"description": "JavaScript client for Nakama server written in TypeScript.",
"main": "packages/nakama-js/dist/nakama-js.cjs.js",
"types": "packages/nakama-js/dist/index.d.ts",
"module": "packages/nakama-js/dist/nakama-js.esm.js",
"browser": "packages/nakama-js/dist/nakama-js.iife.js",
"dependencies": {
"Base64": "^1.0.1",
"Base64": "1.0.1",
"whatwg-fetch": "^2.0.3"
},
"devDependencies": {
"tslib": "^2.0.3"
}
}
}

@@ -6,3 +6,3 @@ Nakama JavaScript client

[Nakama](https://github.com/heroiclabs/nakama) is an open-source server designed to power modern games and apps. Features include user accounts, chat, social, matchmaker, realtime multiplayer, and [much more](https://heroiclabs.com).
[Nakama](https://github.com/heroiclabs/nakama) is an open-source server designed to power modern games and apps. Features include user accounts, chat, social, matchmaker, realtime multiplayer, and much [more](https://heroiclabs.com).

@@ -19,3 +19,3 @@ This client implements the full API and socket options with the server. It's written in TypeScript with minimal dependencies to be compatible with all modern browsers and React Native.

2. Import the client into your project. It's available on NPM and can be also be added to a project with Bower or other package managers.
2. Import the client into your project. It's [available on NPM](https://www.npmjs.com/package/@heroiclabs/nakama-js) and can be also be added to a project with Bower or other package managers.

@@ -28,13 +28,30 @@ ```shell

Optionally, if you would like to use the Protocol Buffers wire format with your sockets, you can import the adapter found in this package:
```shell
yarn add "@heroiclabs/nakama-js-protobuf"
```
3. Use the connection credentials to build a client object.
```js
// <script src="path/to/nakama-js.umd.js"></script>
var client = new nakamajs.Client("defaultkey", "127.0.0.1", 7350);
client.ssl = false; // enable if server is run with an SSL certificate
// <script src="path/to/nakama-js.iife.js"></script>
var useSSL = false; // Enable if server is run with an SSL certificate.
var client = new nakamajs.Client("defaultkey", "127.0.0.1", 7350, useSSL);
```
If you are including the optional protocol buffer adapter, pass the adapter to the Client object:
```js
// <script src="path/to/nakama-js.iife.js"></script>
// <script src="path/to/nakama-js-protobuf.iife.js"></script>
var useSSL = false; // Enable if server is run with an SSL certificate.
var client = new nakamajs.Client("defaultkey", "127.0.0.1", 7350, useSSL, new nakamajsprotobuf.WebSocketAdapterPb());
```
## Usage
The client object has many methods to execute various features in the server and also create sockets to open connections with the server.
The client object has many methods to execute various features in the server or open realtime socket connections with the server.

@@ -48,3 +65,3 @@ ### Authenticate

var password = "batsignal";
const session = await client.authenticateEmail({ email: email, password: password });
const session = await client.authenticateEmail(email, password);
console.info(session);

@@ -79,3 +96,3 @@ ```

The client includes lots of builtin APIs for various features of the game server. These can be accessed with the methods which return Promise objects. It is also possible to call RPC functions for custom logic registered with the server as well as with a socket object.
The client includes lots of builtin APIs for various features of the game server. These can be accessed with the methods which return Promise objects. It can also call custom logic as RPC functions on the server. These can also be executed with a socket object.

@@ -96,3 +113,3 @@ All requests are sent with a session object which authorizes the client.

```js
const secure = false; // enable if server is run with an SSL certificate
const secure = false; // Enable if server is run with an SSL certificate
const trace = false;

@@ -116,15 +133,13 @@ const socket = client.createSocket(secure, trace);

// 1 = room, 2 = Direct Message, 3 = Group
const type : number = 1;
const roomname = "mychannel";
const channel = await socket.send({ channel_join: {
type: 1, // 1 = room, 2 = Direct Message, 3 = Group
target: roomname,
persistence: false,
hidden: false
} });
const persistence : boolean = false;
const hidden : boolean = false;
const channel = await socket.joinChat(type, roomname, persistence, hidden);
const message = { "hello": "world" };
socket.send({ channel_message_send: {
channel_id: channel.channel.id,
content: message
} });
socket.writeChatMessage(channel.channel.id, message);
```

@@ -134,10 +149,15 @@

The development roadmap is managed as GitHub issues and pull requests are welcome. If you're interested to enhance the code please open an issue to discuss the changes or drop in and discuss it in the [community chat](https://gitter.im/heroiclabs/nakama).
The development roadmap is managed as GitHub issues and pull requests are welcome. If you're interested in enhancing the code please open an issue to discuss the changes or drop in and discuss it in the [community forum](https://forum.heroiclabs.com).
### Source Builds
The codebase is written in TypeScript with tests in JavaScript and can be built with [Rollup.js](https://rollupjs.org/guide/en). All dependencies are managed with NPM.
Ensure you are using Node v12.18.1.
The codebase is multi-package monorepo written in TypeScript and can be built with [esbuild](https://github.com/evanw/esbuild). All dependencies are managed with Yarn.
To build from source, install dependencies and build the `nakama-js` and `nakama-js-protobuf` subrepositories:
```shell
yarn install && yarn build
yarn workspace @heroiclabs/nakama-js install && yarn workspace @heroiclabs/nakama-js build
yarn workspace @heroiclabs/nakama-js-protobuf install && yarn workspace @heroiclabs/nakama-js-protobuf build
```

@@ -149,7 +169,25 @@

Tests are run against each workspace bundle; if you have made source code changes, you should `yarn workspace <workspace> build` prior to running tests.
```shell
docker-compose -f ./docker-compose.yml up
yarn build && yarn test
yarn test
```
### Protocol Buffer Web Socket Adapter
To update the generated Typescript required for using the protocol buffer adapter, run the following:
```shell
npx protoc \
--plugin="./node_modules/.bin/protoc-gen-ts_proto" \
--proto_path=$GOPATH/src \
--ts_proto_out=packages/nakama-js-protobuf \
--ts_proto_opt=snakeToCamel=false \
--ts_proto_opt=useOptionals=true \
--ts_proto_opt=oneof=unions \
$GOPATH/src/github.com/heroiclabs/nakama-common/api/api.proto \
$GOPATH/src/github.com/heroiclabs/nakama-common/rtapi/realtime.proto
```
### Release Process

@@ -160,7 +198,9 @@

```shell
yarn run build && yarn publish --access=public
yarn workspace <workspace> run build && yarn workspace <workspace> npm publish --access=public
```
You can use `yarn workspaces foreach <cmd>` to do this for each NPM package distributed by this repository.
### License
This project is licensed under the [Apache-2 License](https://github.com/heroiclabs/nakama-js/blob/master/LICENSE).

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc