mezon-js 2.11.46 → 2.12.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.
package/client.ts CHANGED
@@ -17,13 +17,7 @@
17
17
  import {
18
18
  ApiAccount,
19
19
  ApiAccountMezon,
20
- ApiAccountDevice,
21
20
  ApiAccountEmail,
22
- ApiAccountFacebook,
23
- ApiAccountFacebookInstantGame,
24
- ApiAccountGoogle,
25
- ApiAccountGameCenter,
26
- ApiAccountSteam,
27
21
  ApiChannelMessageList,
28
22
  ApiChannelDescList,
29
23
  ApiChannelDescription,
@@ -49,8 +43,6 @@ import {
49
43
  ApiUsers,
50
44
  MezonApi,
51
45
  ApiSession,
52
- ApiAccountApple,
53
- ApiLinkSteamRequest,
54
46
  ApiClanDescProfile,
55
47
  ApiClanProfile,
56
48
  ApiChannelUserList,
@@ -584,75 +576,9 @@ export class Client {
584
576
  this.apiClient = new MezonApi(serverkey, basePath, timeout);
585
577
  }
586
578
 
587
- /** Add users to a channel, or accept their join requests. */
588
- async addChannelUsers(
589
- session: Session,
590
- channelId: string,
591
- ids?: Array<string>
592
- ): Promise<boolean> {
593
- if (
594
- this.autoRefreshSession &&
595
- session.refresh_token &&
596
- session.isexpired(Date.now() / 1000)
597
- ) {
598
- await this.sessionRefresh(session);
599
- }
600
-
601
- return this.apiClient
602
- .addChannelUsers(session.token, channelId, ids)
603
- .then((response: any) => {
604
- return response !== undefined;
605
- });
606
- }
607
-
608
- /** Add friends by ID or username to a user's account. */
609
- async addFriends(
610
- session: Session,
611
- ids?: Array<string>,
612
- usernames?: Array<string>
613
- ): Promise<boolean> {
614
- if (
615
- this.autoRefreshSession &&
616
- session.refresh_token &&
617
- session.isexpired(Date.now() / 1000)
618
- ) {
619
- await this.sessionRefresh(session);
620
- }
621
-
622
- return this.apiClient
623
- .addFriends(session.token, ids, usernames)
624
- .then((response: any) => {
625
- return response !== undefined;
626
- });
627
- }
628
-
629
- /** Authenticate a user with an Apple ID against the server. */
630
- async authenticateApple(
631
- token: string,
632
- create?: boolean,
633
- username?: string,
634
- vars: Record<string, string> = {},
635
- options: any = {}
636
- ) {
637
- const request = {
638
- token: token,
639
- vars: vars,
640
- };
641
-
642
- return this.apiClient
643
- .authenticateApple(this.serverkey, "", request, create, username, options)
644
- .then((apiSession: ApiSession) => {
645
- return new Session(
646
- apiSession.token || "",
647
- apiSession.refresh_token || "",
648
- apiSession.created || false,
649
- false
650
- );
651
- });
652
- }
653
-
654
579
  /** Authenticate a user with a custom id against the server. */
655
580
  authenticateMezon(
581
+ basePath: string,
656
582
  token: string,
657
583
  create?: boolean,
658
584
  username?: string,
@@ -666,6 +592,7 @@ export class Client {
666
592
  };
667
593
  return this.apiClient
668
594
  .authenticateMezon(
595
+ basePath,
669
596
  this.serverkey,
670
597
  "",
671
598
  request,
@@ -684,32 +611,9 @@ export class Client {
684
611
  });
685
612
  }
686
613
 
687
- /** Authenticate a user with a device id against the server. */
688
- authenticateDevice(
689
- id: string,
690
- create?: boolean,
691
- username?: string,
692
- vars?: Record<string, string>
693
- ): Promise<Session> {
694
- const request = {
695
- id: id,
696
- vars: vars,
697
- };
698
-
699
- return this.apiClient
700
- .authenticateDevice(this.serverkey, "", request, create, username)
701
- .then((apiSession: ApiSession) => {
702
- return new Session(
703
- apiSession.token || "",
704
- apiSession.refresh_token || "",
705
- apiSession.created || false,
706
- false
707
- );
708
- });
709
- }
710
-
711
614
  /** Authenticate a user with an email+password against the server. */
712
615
  authenticateEmail(
616
+ basePath: string,
713
617
  email: string,
714
618
  password: string,
715
619
  username?: string,
@@ -725,7 +629,7 @@ export class Client {
725
629
  };
726
630
 
727
631
  return this.apiClient
728
- .authenticateEmail(this.serverkey, "", request, username)
632
+ .authenticateEmail(basePath, this.serverkey, "", request, username)
729
633
  .then((apiSession: ApiSession) => {
730
634
  return new Session(
731
635
  apiSession.token || "",
@@ -736,165 +640,45 @@ export class Client {
736
640
  });
737
641
  }
738
642
 
739
- /** Authenticate a user with a Facebook Instant Game token against the server. */
740
- authenticateFacebookInstantGame(
741
- signedPlayerInfo: string,
742
- create?: boolean,
743
- username?: string,
744
- vars?: Record<string, string>,
745
- options: any = {}
746
- ): Promise<Session> {
747
- const request = {
748
- signed_player_info: signedPlayerInfo,
749
- vars: vars,
750
- };
751
-
752
- return this.apiClient
753
- .authenticateFacebookInstantGame(
754
- this.serverkey,
755
- "",
756
- { signed_player_info: request.signed_player_info, vars: request.vars },
757
- create,
758
- username,
759
- options
760
- )
761
- .then((apiSession: ApiSession) => {
762
- return new Session(
763
- apiSession.token || "",
764
- apiSession.refresh_token || "",
765
- apiSession.created || false,
766
- false
767
- );
768
- });
769
- }
770
-
771
- /** Authenticate a user with a Facebook OAuth token against the server. */
772
- authenticateFacebook(
773
- token: string,
774
- create?: boolean,
775
- username?: string,
776
- sync?: boolean,
777
- vars?: Record<string, string>,
778
- options: any = {}
779
- ): Promise<Session> {
780
- const request = {
781
- token: token,
782
- vars: vars,
783
- };
643
+ /** Add users to a channel, or accept their join requests. */
644
+ async addChannelUsers(
645
+ session: Session,
646
+ channelId: string,
647
+ ids?: Array<string>
648
+ ): Promise<boolean> {
649
+ if (
650
+ this.autoRefreshSession &&
651
+ session.refresh_token &&
652
+ session.isexpired(Date.now() / 1000)
653
+ ) {
654
+ await this.sessionRefresh(session);
655
+ }
784
656
 
785
657
  return this.apiClient
786
- .authenticateFacebook(
787
- this.serverkey,
788
- "",
789
- request,
790
- create,
791
- username,
792
- sync,
793
- options
794
- )
795
- .then((apiSession: ApiSession) => {
796
- return new Session(
797
- apiSession.token || "",
798
- apiSession.refresh_token || "",
799
- apiSession.created || false,
800
- false
801
- );
658
+ .addChannelUsers(session.token, channelId, ids)
659
+ .then((response: any) => {
660
+ return response !== undefined;
802
661
  });
803
662
  }
804
663
 
805
- /** Authenticate a user with Google against the server. */
806
- async authenticateGoogle(
807
- token: string,
808
- create?: boolean,
809
- username?: string,
810
- vars?: Record<string, string>,
811
- options: any = {}
812
- ): Promise<Session> {
813
- const request: ApiAccountGoogle = {
814
- token,
815
- vars,
816
- };
817
-
818
- const apiSession = await this.apiClient.authenticateGoogle(
819
- this.serverkey,
820
- "",
821
- request,
822
- create,
823
- username,
824
- options
825
- );
826
-
827
- return new Session(
828
- apiSession.token || "",
829
- apiSession.refresh_token || "",
830
- apiSession.created || false,
831
- false
832
- );
833
- }
834
-
835
- /** Authenticate a user with GameCenter against the server. */
836
- async authenticateGameCenter(
837
- bundleId: string,
838
- playerId: string,
839
- publicKeyUrl: string,
840
- salt: string,
841
- signature: string,
842
- timestamp: number,
843
- username?: string,
844
- create?: boolean,
845
- vars?: Record<string, string>,
846
- options: any = {}
847
- ): Promise<Session> {
848
- const request: ApiAccountGameCenter = {
849
- bundle_id: bundleId,
850
- player_id: playerId,
851
- public_key_url: publicKeyUrl,
852
- salt,
853
- signature,
854
- timestamp_seconds: timestamp,
855
- vars,
856
- };
857
-
858
- const apiSession = await this.apiClient.authenticateGameCenter(
859
- this.serverkey,
860
- "",
861
- request,
862
- create,
863
- username,
864
- options
865
- );
866
-
867
- return new Session(
868
- apiSession.token || "",
869
- apiSession.refresh_token || "",
870
- apiSession.created || false,
871
- false
872
- );
873
- }
874
-
875
- /** Authenticate a user with Steam against the server. */
876
- async authenticateSteam(
877
- token: string,
878
- create?: boolean,
879
- username?: string,
880
- sync?: boolean,
881
- vars?: Record<string, string>
882
- ): Promise<Session> {
883
- const request = {
884
- token: token,
885
- vars: vars,
886
- sync: sync,
887
- };
664
+ /** Add friends by ID or username to a user's account. */
665
+ async addFriends(
666
+ session: Session,
667
+ ids?: Array<string>,
668
+ usernames?: Array<string>
669
+ ): Promise<boolean> {
670
+ if (
671
+ this.autoRefreshSession &&
672
+ session.refresh_token &&
673
+ session.isexpired(Date.now() / 1000)
674
+ ) {
675
+ await this.sessionRefresh(session);
676
+ }
888
677
 
889
678
  return this.apiClient
890
- .authenticateSteam(this.serverkey, "", request, create, username)
891
- .then((apiSession: ApiSession) => {
892
- return new Session(
893
- apiSession.token || "",
894
- apiSession.refresh_token || "",
895
- apiSession.created || false,
896
- false
897
- );
679
+ .addFriends(session.token, ids, usernames)
680
+ .then((response: any) => {
681
+ return response !== undefined;
898
682
  });
899
683
  }
900
684
 
@@ -1312,47 +1096,6 @@ export class Client {
1312
1096
  return this.apiClient.getAccount(session.token);
1313
1097
  }
1314
1098
 
1315
- /** Import Facebook friends and add them to a user's account. */
1316
- async importFacebookFriends(
1317
- session: Session,
1318
- request: ApiAccountFacebook
1319
- ): Promise<boolean> {
1320
- if (
1321
- this.autoRefreshSession &&
1322
- session.refresh_token &&
1323
- session.isexpired(Date.now() / 1000)
1324
- ) {
1325
- await this.sessionRefresh(session);
1326
- }
1327
-
1328
- return this.apiClient
1329
- .importFacebookFriends(session.token, request)
1330
- .then((response: any) => {
1331
- return response !== undefined;
1332
- });
1333
- }
1334
-
1335
- /** Import Steam friends and add them to a user's account. */
1336
- async importSteamFriends(
1337
- session: Session,
1338
- request: ApiAccountSteam,
1339
- reset: boolean
1340
- ): Promise<boolean> {
1341
- if (
1342
- this.autoRefreshSession &&
1343
- session.refresh_token &&
1344
- session.isexpired(Date.now() / 1000)
1345
- ) {
1346
- await this.sessionRefresh(session);
1347
- }
1348
-
1349
- return this.apiClient
1350
- .importSteamFriends(session.token, request, reset)
1351
- .then((response: any) => {
1352
- return response !== undefined;
1353
- });
1354
- }
1355
-
1356
1099
  /** Fetch zero or more users by ID and/or username. */
1357
1100
  async getUsers(
1358
1101
  session: Session,
@@ -1997,26 +1740,6 @@ export class Client {
1997
1740
  });
1998
1741
  }
1999
1742
 
2000
- /** Add an Apple ID to the social profiles on the current user's account. */
2001
- async linkApple(
2002
- session: Session,
2003
- request: ApiAccountApple
2004
- ): Promise<boolean> {
2005
- if (
2006
- this.autoRefreshSession &&
2007
- session.refresh_token &&
2008
- session.isexpired(Date.now() / 1000)
2009
- ) {
2010
- await this.sessionRefresh(session);
2011
- }
2012
-
2013
- return this.apiClient
2014
- .linkApple(session.token, request)
2015
- .then((response: any) => {
2016
- return response !== undefined;
2017
- });
2018
- }
2019
-
2020
1743
  //
2021
1744
  async closeDirectMess(
2022
1745
  session: Session,
@@ -2076,26 +1799,6 @@ export class Client {
2076
1799
  });
2077
1800
  }
2078
1801
 
2079
- /** Add a device ID to the social profiles on the current user's account. */
2080
- async linkDevice(
2081
- session: Session,
2082
- request: ApiAccountDevice
2083
- ): Promise<boolean> {
2084
- if (
2085
- this.autoRefreshSession &&
2086
- session.refresh_token &&
2087
- session.isexpired(Date.now() / 1000)
2088
- ) {
2089
- await this.sessionRefresh(session);
2090
- }
2091
-
2092
- return this.apiClient
2093
- .linkDevice(session.token, request)
2094
- .then((response: any) => {
2095
- return response !== undefined;
2096
- });
2097
- }
2098
-
2099
1802
  /** Add an email+password to the social profiles on the current user's account. */
2100
1803
  async linkEmail(
2101
1804
  session: Session,
@@ -2116,106 +1819,6 @@ export class Client {
2116
1819
  });
2117
1820
  }
2118
1821
 
2119
- /** Add Facebook to the social profiles on the current user's account. */
2120
- async linkFacebook(
2121
- session: Session,
2122
- request: ApiAccountFacebook
2123
- ): Promise<boolean> {
2124
- if (
2125
- this.autoRefreshSession &&
2126
- session.refresh_token &&
2127
- session.isexpired(Date.now() / 1000)
2128
- ) {
2129
- await this.sessionRefresh(session);
2130
- }
2131
-
2132
- return this.apiClient
2133
- .linkFacebook(session.token, request)
2134
- .then((response: any) => {
2135
- return response !== undefined;
2136
- });
2137
- }
2138
-
2139
- /** Add Facebook Instant to the social profiles on the current user's account. */
2140
- async linkFacebookInstantGame(
2141
- session: Session,
2142
- request: ApiAccountFacebookInstantGame
2143
- ): Promise<boolean> {
2144
- if (
2145
- this.autoRefreshSession &&
2146
- session.refresh_token &&
2147
- session.isexpired(Date.now() / 1000)
2148
- ) {
2149
- await this.sessionRefresh(session);
2150
- }
2151
-
2152
- return this.apiClient
2153
- .linkFacebookInstantGame(session.token, request)
2154
- .then((response: any) => {
2155
- return response !== undefined;
2156
- });
2157
- }
2158
-
2159
- /** Add Google to the social profiles on the current user's account. */
2160
- async linkGoogle(
2161
- session: Session,
2162
- request: ApiAccountGoogle
2163
- ): Promise<boolean> {
2164
- if (
2165
- this.autoRefreshSession &&
2166
- session.refresh_token &&
2167
- session.isexpired(Date.now() / 1000)
2168
- ) {
2169
- await this.sessionRefresh(session);
2170
- }
2171
-
2172
- return this.apiClient
2173
- .linkGoogle(session.token, request)
2174
- .then((response: any) => {
2175
- return response !== undefined;
2176
- });
2177
- }
2178
-
2179
- /** Add GameCenter to the social profiles on the current user's account. */
2180
- async linkGameCenter(
2181
- session: Session,
2182
- request: ApiAccountGameCenter
2183
- ): Promise<boolean> {
2184
- if (
2185
- this.autoRefreshSession &&
2186
- session.refresh_token &&
2187
- session.isexpired(Date.now() / 1000)
2188
- ) {
2189
- await this.sessionRefresh(session);
2190
- }
2191
-
2192
- return this.apiClient
2193
- .linkGameCenter(session.token, request)
2194
- .then((response: any) => {
2195
- return response !== undefined;
2196
- });
2197
- }
2198
-
2199
- /** Add Steam to the social profiles on the current user's account. */
2200
- async linkSteam(
2201
- session: Session,
2202
- request: ApiLinkSteamRequest
2203
- ): Promise<boolean> {
2204
- if (
2205
- this.autoRefreshSession &&
2206
- session.refresh_token &&
2207
- session.isexpired(Date.now() / 1000)
2208
- ) {
2209
- await this.sessionRefresh(session);
2210
- }
2211
-
2212
- return this.apiClient
2213
- .linkSteam(session.token, request)
2214
- .then((response: any) => {
2215
- return response !== undefined;
2216
- });
2217
- }
2218
-
2219
1822
  /** List all friends for the current user. */
2220
1823
  async listFriends(
2221
1824
  session: Session,
@@ -2461,26 +2064,6 @@ export class Client {
2461
2064
  return this.refreshTokenPromise;
2462
2065
  }
2463
2066
 
2464
- /** Remove the Apple ID from the social profiles on the current user's account. */
2465
- async unlinkApple(
2466
- session: Session,
2467
- request: ApiAccountApple
2468
- ): Promise<boolean> {
2469
- if (
2470
- this.autoRefreshSession &&
2471
- session.refresh_token &&
2472
- session.isexpired(Date.now() / 1000)
2473
- ) {
2474
- await this.sessionRefresh(session);
2475
- }
2476
-
2477
- return this.apiClient
2478
- .unlinkApple(session.token, request)
2479
- .then((response: any) => {
2480
- return response !== undefined;
2481
- });
2482
- }
2483
-
2484
2067
  /** Remove custom ID from the social profiles on the current user's account. */
2485
2068
  async unlinkCustom(
2486
2069
  session: Session,
@@ -2501,26 +2084,6 @@ export class Client {
2501
2084
  });
2502
2085
  }
2503
2086
 
2504
- /** Remove a device ID from the social profiles on the current user's account. */
2505
- async unlinkDevice(
2506
- session: Session,
2507
- request: ApiAccountDevice
2508
- ): Promise<boolean> {
2509
- if (
2510
- this.autoRefreshSession &&
2511
- session.refresh_token &&
2512
- session.isexpired(Date.now() / 1000)
2513
- ) {
2514
- await this.sessionRefresh(session);
2515
- }
2516
-
2517
- return this.apiClient
2518
- .unlinkDevice(session.token, request)
2519
- .then((response: any) => {
2520
- return response !== undefined;
2521
- });
2522
- }
2523
-
2524
2087
  /** Remove an email+password from the social profiles on the current user's account. */
2525
2088
  async unlinkEmail(
2526
2089
  session: Session,
@@ -2541,105 +2104,6 @@ export class Client {
2541
2104
  });
2542
2105
  }
2543
2106
 
2544
- /** Remove Facebook from the social profiles on the current user's account. */
2545
- async unlinkFacebook(
2546
- session: Session,
2547
- request: ApiAccountFacebook
2548
- ): Promise<boolean> {
2549
- if (
2550
- this.autoRefreshSession &&
2551
- session.refresh_token &&
2552
- session.isexpired(Date.now() / 1000)
2553
- ) {
2554
- await this.sessionRefresh(session);
2555
- }
2556
-
2557
- return this.apiClient
2558
- .unlinkFacebook(session.token, request)
2559
- .then((response: any) => {
2560
- return response !== undefined;
2561
- });
2562
- }
2563
-
2564
- /** Remove Facebook Instant social profiles from the current user's account. */
2565
- async unlinkFacebookInstantGame(
2566
- session: Session,
2567
- request: ApiAccountFacebookInstantGame
2568
- ): Promise<boolean> {
2569
- if (
2570
- this.autoRefreshSession &&
2571
- session.refresh_token &&
2572
- session.isexpired(Date.now() / 1000)
2573
- ) {
2574
- await this.sessionRefresh(session);
2575
- }
2576
-
2577
- return this.apiClient
2578
- .unlinkFacebookInstantGame(session.token, request)
2579
- .then((response: any) => {
2580
- return response !== undefined;
2581
- });
2582
- }
2583
-
2584
- /** Remove Google from the social profiles on the current user's account. */
2585
- async unlinkGoogle(
2586
- session: Session,
2587
- request: ApiAccountGoogle
2588
- ): Promise<boolean> {
2589
- if (
2590
- this.autoRefreshSession &&
2591
- session.refresh_token &&
2592
- session.isexpired(Date.now() / 1000)
2593
- ) {
2594
- await this.sessionRefresh(session);
2595
- }
2596
-
2597
- return this.apiClient
2598
- .unlinkGoogle(session.token, request)
2599
- .then((response: any) => {
2600
- return response !== undefined;
2601
- });
2602
- }
2603
-
2604
- /** Remove GameCenter from the social profiles on the current user's account. */
2605
- async unlinkGameCenter(
2606
- session: Session,
2607
- request: ApiAccountGameCenter
2608
- ): Promise<boolean> {
2609
- if (
2610
- this.autoRefreshSession &&
2611
- session.refresh_token &&
2612
- session.isexpired(Date.now() / 1000)
2613
- ) {
2614
- await this.sessionRefresh(session);
2615
- }
2616
-
2617
- return this.apiClient
2618
- .unlinkGameCenter(session.token, request)
2619
- .then((response: any) => {
2620
- return response !== undefined;
2621
- });
2622
- }
2623
-
2624
- /** Remove Steam from the social profiles on the current user's account. */
2625
- async unlinkSteam(
2626
- session: Session,
2627
- request: ApiAccountSteam
2628
- ): Promise<boolean> {
2629
- if (
2630
- this.autoRefreshSession &&
2631
- session.refresh_token &&
2632
- session.isexpired(Date.now() / 1000)
2633
- ) {
2634
- await this.sessionRefresh(session);
2635
- }
2636
- return this.apiClient
2637
- .unlinkSteam(session.token, request)
2638
- .then((response: any) => {
2639
- return response !== undefined;
2640
- });
2641
- }
2642
-
2643
2107
  /** Update fields in the current user's account. */
2644
2108
  async updateAccount(
2645
2109
  session: Session,
@@ -4437,8 +3901,9 @@ export class Client {
4437
3901
  });
4438
3902
  }
4439
3903
 
4440
- async createQRLogin(requet: ApiLoginRequest): Promise<ApiLoginIDResponse> {
3904
+ async createQRLogin(basePath: string, requet: ApiLoginRequest): Promise<ApiLoginIDResponse> {
4441
3905
  const apiSession = await this.apiClient.createQRLogin(
3906
+ basePath,
4442
3907
  this.serverkey,
4443
3908
  "",
4444
3909
  requet
@@ -4451,9 +3916,11 @@ export class Client {
4451
3916
  }
4452
3917
 
4453
3918
  async checkLoginRequest(
3919
+ basePath: string,
4454
3920
  requet: ApiConfirmLoginRequest
4455
3921
  ): Promise<Session | null> {
4456
3922
  const apiSession = await this.apiClient.checkLoginRequest(
3923
+ basePath,
4457
3924
  this.serverkey,
4458
3925
  "",
4459
3926
  requet
@@ -4470,6 +3937,7 @@ export class Client {
4470
3937
  }
4471
3938
 
4472
3939
  async confirmLogin(
3940
+ basePath: string,
4473
3941
  session: Session,
4474
3942
  body: ApiConfirmLoginRequest
4475
3943
  ): Promise<any> {
@@ -4482,7 +3950,7 @@ export class Client {
4482
3950
  }
4483
3951
 
4484
3952
  return this.apiClient
4485
- .confirmLogin(session.token, body)
3953
+ .confirmLogin(basePath, session.token, body)
4486
3954
  .then((response: any) => {
4487
3955
  return response;
4488
3956
  });