@arkadiuminc/sdk 2.35.3 → 2.36.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -28,10 +28,12 @@ interface AuthUIManagerContract {
28
28
  openAuthRequest: ReturnType<typeof createStore<boolean>>;
29
29
  openAuthForm(): Promise<void>;
30
30
  }
31
+ export declare function getAvatarLink(avatarName: string, extension: string): string;
31
32
  export declare abstract class Auth {
32
33
  private backendApi;
33
34
  protected userProfileReader: UserProfileReaderContract;
34
35
  protected authUIManager: AuthUIManagerContract | undefined;
36
+ private userId?;
35
37
  constructor(backendApi: Backend, host: IHost);
36
38
  init(): Promise<void>;
37
39
  isUserAuthorized(): Promise<boolean>;
@@ -40,6 +42,7 @@ export declare abstract class Auth {
40
42
  onAuthStatusChange(observer: any): () => void;
41
43
  openAuthForm(): Promise<void>;
42
44
  onOpenAuthForm(observer: any): (() => void) | undefined;
45
+ getUserId(): Promise<string | undefined>;
43
46
  }
44
47
  export declare class AuthArena extends Auth {
45
48
  constructor(backendApi: Backend, host: IHost, rpcProvider: RpcProvider);
@@ -0,0 +1,88 @@
1
+ import { Presence } from '@heroiclabs/nakama-js';
2
+ import { NakamaProvider } from '../nakama/nakama-provider';
3
+ import { NakamaService } from '../nakama/nakama-service';
4
+ import { NotificationsArena, Notification } from '../notifications';
5
+ import { FriendsArena } from '../friends';
6
+
7
+ declare enum ChatType {
8
+ Direct = "direct",
9
+ Public = "public"
10
+ }
11
+ export interface JoinChatResponse {
12
+ id: string;
13
+ user_id_one?: string;
14
+ user_id_two?: string;
15
+ room_name?: string;
16
+ self: Presence;
17
+ presences: Presence[];
18
+ }
19
+ export declare type ChatChannel = {
20
+ id: string;
21
+ name: string;
22
+ target: string;
23
+ type: ChatType;
24
+ presences: ChatPresence[];
25
+ messages: ChatMessage[];
26
+ };
27
+ export declare type ChatPresence = {
28
+ chatId: string;
29
+ userId: string;
30
+ sessionId: string;
31
+ username: string;
32
+ };
33
+ export declare type ChatMessage = {
34
+ id?: string;
35
+ chatId?: string;
36
+ content?: object;
37
+ senderId?: string;
38
+ username?: string;
39
+ createTime?: string;
40
+ updateTime?: string;
41
+ };
42
+ export declare type GetChatMessagesParams = {
43
+ chatId: string;
44
+ fromCache?: boolean;
45
+ limit?: number;
46
+ };
47
+ export declare type ChatPresencesListener = (presence: ChatPresence[]) => void;
48
+ export declare type ChatMessageListener = (message: ChatMessage) => void;
49
+ export declare type ChatInviteListener = (invite: Notification) => void;
50
+ export declare class ChatArena extends NakamaService {
51
+ private _notificationsService;
52
+ private _friendsService;
53
+ private _chatList;
54
+ private _autoJoinChat;
55
+ private _chatMessagesCursor?;
56
+ private readonly _delayBeforeProcessing;
57
+ private _notificationListenerRemover;
58
+ private _chatPresencesListener?;
59
+ private _chatMessageListener?;
60
+ private _chatInviteListener?;
61
+ constructor(nakamaProvider: NakamaProvider, _notificationsService: NotificationsArena, _friendsService: FriendsArena);
62
+ setAutoJoinChat(isEnabled: boolean): void;
63
+ getJoinedChats(): ChatChannel[];
64
+ getChatMessages({ chatId, fromCache, limit }: GetChatMessagesParams): Promise<ChatMessage[]>;
65
+ joinDirectChat(userId: string): Promise<ChatChannel>;
66
+ private joinChat;
67
+ sendMessageWithFriendId(userId: string, data: object): Promise<void>;
68
+ sendMessageWithChatId(chatId: string, data: object): Promise<void>;
69
+ leaveChat(chatId: string): Promise<void>;
70
+ private removeChatPresence;
71
+ private addChatPresences;
72
+ private addChatPresence;
73
+ private addChatMessage;
74
+ private addChatMessages;
75
+ private handleJoinChatInvitation;
76
+ private mapNakamaChannelMessageToChatMessage;
77
+ private onChannelPresenceChanged;
78
+ subscribeChatPresenceListener(listener: ChatPresencesListener): void;
79
+ removeChatPresenceListener(): void;
80
+ private onChannelMessageChanged;
81
+ subscribeChatMessageListener(listener: ChatMessageListener): void;
82
+ removeChatMessageListener(): void;
83
+ private onChatInviteNotification;
84
+ subscribeChatInviteListener(listener: ChatInviteListener): void;
85
+ removeChatInviteListener(): void;
86
+ protected onSocketConnectionChanged(isConnected: boolean): void;
87
+ }
88
+ export {};
@@ -0,0 +1,59 @@
1
+ import { NakamaProvider } from '../nakama/nakama-provider';
2
+ import { Auth } from '../auth/index';
3
+ import { NakamaService } from '../nakama/nakama-service';
4
+ import { NotificationsArena, NotificationListener } from '../notifications';
5
+
6
+ export declare const FRIEND_STATE_FRIENDS: number;
7
+ export declare const FRIEND_STATE_SENT_REQUEST: number;
8
+ export declare const FRIEND_STATE_RECEIVED_REQUEST: number;
9
+ export declare const FRIEND_STATE_BLOCKED: number;
10
+ export declare enum FriendshipState {
11
+ None = "none",
12
+ Friends = "friends",
13
+ RequestSent = "request_sent",
14
+ RequestReceived = "request_received",
15
+ Blocked = "blocked"
16
+ }
17
+ declare type Friend = {
18
+ avatarUrl?: string;
19
+ displayName?: string;
20
+ id?: string;
21
+ online?: boolean;
22
+ username?: string;
23
+ friendshipState?: FriendshipState;
24
+ status?: any;
25
+ };
26
+ export declare class FriendsArena extends NakamaService {
27
+ private _auth;
28
+ private _notificationsService;
29
+ private _friendsOnlineListener?;
30
+ private _friendsJoinedListener?;
31
+ private _friendsLeftListener?;
32
+ private _friendStatus;
33
+ private _notificationListenerRemovers;
34
+ constructor(nakamaProvider: NakamaProvider, _auth: Auth, _notificationsService: NotificationsArena);
35
+ private compressUUID;
36
+ private decompressUUID;
37
+ getFriendlyId(): Promise<string>;
38
+ getFriendlyIdWithEagleId(eagleId: any): string;
39
+ sendFriendRequestWithFriendlyId(friendlyId: string): Promise<void>;
40
+ sendFriendRequestWithUserId(userId: string): Promise<void>;
41
+ private sendFriendRequest;
42
+ acceptFriendRequest(friendId: string): Promise<void>;
43
+ rejectFriendRequest(friendId: string): Promise<void>;
44
+ removeFriend(friendId: string): Promise<void>;
45
+ getFriends(): Promise<Array<Friend>>;
46
+ getOnlineFriends(): Promise<Array<Friend>>;
47
+ isFriend(userId: string): Promise<boolean>;
48
+ private followFriends;
49
+ private unfollowFriends;
50
+ private onStatusPresenceChanged;
51
+ protected onSocketConnectionChanged(isConnected: boolean): void;
52
+ subscribeFriendRequestNotificationListener(listener: NotificationListener): void;
53
+ subscribeFriendRequestAcceptedNotificationListener(listener: NotificationListener): void;
54
+ subscribeFriendsOnlineListener(listener: (onlineFriends: Array<Friend>) => void): void;
55
+ subscribeFriendsJoinedListener(listener: (joinedFriends: Array<Friend>) => void): void;
56
+ subscribeFriendsLeftListener(listener: (leftFriends: Array<Friend>) => void): void;
57
+ blockFriend(friendId: string): Promise<boolean>;
58
+ }
59
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,62 @@
1
+ import { Client as NakamaClient, Session as NakamaSession, Socket as NakamaSocket } from '@heroiclabs/nakama-js';
2
+ import { ApiEnv } from '../backend/backend.api';
3
+ import { IHost } from '../host';
4
+ import { Auth } from '../auth';
5
+ import { ApiAccount } from '@heroiclabs/nakama-js/dist/api.gen';
6
+
7
+ export declare type RpcGetNkUserByEagleIdParams = {
8
+ EagleUserId: string | number;
9
+ };
10
+ export declare type RpcGetNkUserByEagleUserNameParams = {
11
+ EagleUserName: string | number;
12
+ };
13
+ export interface RpcGetNkUserResponse {
14
+ CustomId: string;
15
+ UserId: string;
16
+ UserName: string;
17
+ message: string | null;
18
+ }
19
+ export interface NakamaContext {
20
+ client: NakamaClient | null;
21
+ session: NakamaSession | null;
22
+ socket: NakamaSocket | null;
23
+ }
24
+ export declare class NakamaProvider {
25
+ private host;
26
+ private auth;
27
+ private _ctx;
28
+ private _socketListeners;
29
+ private userSessionDeferred?;
30
+ private wasEagleSubscribed;
31
+ private env;
32
+ private gameId;
33
+ private _isConnected;
34
+ private RPC_GET_USER_BY_EAGLE_ID;
35
+ constructor(host: IHost, auth: Auth);
36
+ init(env: ApiEnv): void;
37
+ private getGameId;
38
+ isUserAuthorized(): boolean;
39
+ private getNakamaClient;
40
+ private subscribeToEagleAuthChanges;
41
+ private getNakamaVars;
42
+ private initNakamaSession;
43
+ private initNakamaSessionViaEagle;
44
+ /**
45
+ * this method is called when the user is logged in
46
+ * CAUTION: this method is called from eagle login status change, therefore it can't throw
47
+ */
48
+ private onEagleLogin;
49
+ /**
50
+ * this method is called when the user is logged out
51
+ * CAUTION: this method is called from eagle login status change, therefore it can't throw
52
+ */
53
+ private onEagleLogout;
54
+ getAccount(): Promise<ApiAccount | null>;
55
+ private isNakamaUserLinkedToEagle;
56
+ getContext(): NakamaContext;
57
+ rpcGetNkUserByEagleId(eagleId: string): Promise<RpcGetNkUserResponse | undefined>;
58
+ createSocket(): Promise<void>;
59
+ subscribeSocketListener(listener: (isConnected: boolean) => void): void;
60
+ private onSocketConnect;
61
+ private onSocketDisconnect;
62
+ }
@@ -0,0 +1,9 @@
1
+ import { NakamaProvider, NakamaContext } from '../nakama/nakama-provider';
2
+
3
+ export declare abstract class NakamaService {
4
+ protected _ctx: NakamaContext;
5
+ constructor(nakamaProvider: NakamaProvider);
6
+ isSupported(): boolean;
7
+ protected createSocket(): Promise<void>;
8
+ protected abstract onSocketConnectionChanged(isConnected: boolean): any;
9
+ }
@@ -0,0 +1,41 @@
1
+ import { NakamaProvider } from '../nakama/nakama-provider';
2
+ import { NakamaService } from '../nakama/nakama-service';
3
+
4
+ export declare const NOTIFICATION_TYPE_CHAT_INVITE: number;
5
+ export declare const NOTIFICATION_TYPE_FRIEND_REQUEST: number;
6
+ export declare const NOTIFICATION_TYPE_FRIEND_REQUEST_ACCEPTED: number;
7
+ export declare enum NotificationType {
8
+ All = "all",
9
+ ChatInvite = "chat_invite",
10
+ FriendRequest = "friend_request",
11
+ FriendRequestAccepted = "friend_request_accepted"
12
+ }
13
+ export declare type Notification = {
14
+ type: NotificationType;
15
+ content?: {};
16
+ id?: string;
17
+ senderId?: string;
18
+ subject?: string;
19
+ };
20
+ export declare type GetNotificationParams = {
21
+ fromCache?: boolean;
22
+ limit?: number;
23
+ };
24
+ export declare type NotificationListener = (notification: Notification) => void;
25
+ export declare type NotificationListenerRemover = () => void;
26
+ export declare class NotificationsArena extends NakamaService {
27
+ private _notifications;
28
+ private _notificationListeners;
29
+ private _notificationCursor;
30
+ constructor(nakamaProvider: NakamaProvider);
31
+ getNotifications({ fromCache, limit }?: GetNotificationParams): Promise<Notification[]>;
32
+ deleteNotification(notificationId: string): Promise<boolean>;
33
+ private addNotificationToList;
34
+ private addNotificationsToList;
35
+ private removeNotificationFromList;
36
+ private mapNakamaNotificationToNotification;
37
+ private onNotificationReceived;
38
+ subscribeNotificationListener(listener: NotificationListener): NotificationListenerRemover;
39
+ subscribeNotificationTypeListener(listener: NotificationListener, type: NotificationType): NotificationListenerRemover;
40
+ protected onSocketConnectionChanged(isConnected: boolean): void;
41
+ }
@@ -12,6 +12,9 @@ import { WalletArena } from './api/features/wallet';
12
12
  import { DebugProviderArena } from './api/core/debug-provider';
13
13
  import { SupportV1 } from './api/features/support-v1/support-v1';
14
14
  import { LeaderboardArena } from './api/features/leaderboard';
15
+ import { FriendsArena } from './api/features/friends';
16
+ import { NotificationsArena } from './api/features/notifications';
17
+ import { ChatArena } from './api/features/chat';
15
18
 
16
19
  import * as MockUserUtils from './api/utils/mockUser';
17
20
  /** @hidden */
@@ -29,13 +32,16 @@ export declare class ArkadiumArenaSdk {
29
32
  debug: DebugProviderArena;
30
33
  private supportV1;
31
34
  private leaderboard;
35
+ friends: FriendsArena;
36
+ notifications: NotificationsArena;
37
+ chats: ChatArena;
32
38
  private currentEnv;
33
39
  private currentTarget;
34
40
  private gamePingSender;
35
41
  private gamePingListener;
36
42
  $pingNotification: Observable<number>;
37
43
  version: string;
38
- constructor(rpcProvider: RpcProvider, backendApi: Backend, host: HostArena, lifecycle: GameLifecycleArena, ads: AdsArena, auth: AuthArena, analytics: AnalyticsApiContract, timeoutTester: TimeoutTesterContract, persistence: PersistenceArena, wallet: WalletArena, debug: DebugProviderArena, supportV1: SupportV1, leaderboard: LeaderboardArena);
44
+ constructor(rpcProvider: RpcProvider, backendApi: Backend, host: HostArena, lifecycle: GameLifecycleArena, ads: AdsArena, auth: AuthArena, analytics: AnalyticsApiContract, timeoutTester: TimeoutTesterContract, persistence: PersistenceArena, wallet: WalletArena, debug: DebugProviderArena, supportV1: SupportV1, leaderboard: LeaderboardArena, friends: FriendsArena, notifications: NotificationsArena, chats: ChatArena);
39
45
  setEnv(e: ApiEnv): void;
40
46
  initialize(env: ApiEnv, isGameSide: boolean, sessionStorage?: SessionStorageType | null): Promise<void>;
41
47
  private envDiscoverListener;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arkadiuminc/sdk",
3
- "version": "2.35.3",
3
+ "version": "2.36.1",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "main": "dist/pkg/arkadium-sdk.umd.js",
@@ -96,6 +96,7 @@
96
96
  "vitest": "^1.4.0"
97
97
  },
98
98
  "dependencies": {
99
+ "@heroiclabs/nakama-js": "^2.8.0",
99
100
  "@microsoft/applicationinsights-web": "^3.0.4",
100
101
  "jsonpack": "^1.1.5",
101
102
  "nanoid": "^5.0.4",