mezon-js 2.12.92 → 2.12.94

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/api.gen.ts CHANGED
@@ -390,6 +390,12 @@ export interface ApiAccountApp {
390
390
  vars?: Record<string, string>;
391
391
  }
392
392
 
393
+ export interface ApiAccountSMS {
394
+ phoneno: string;
395
+ //Extra information that will be bundled in the session token.
396
+ vars?: Record<string, string>;
397
+ }
398
+
393
399
  /** Send an email with password to the server. Used with authenticate/link/unlink. */
394
400
  export interface ApiAccountEmail {
395
401
  //A valid RFC-5322 email address.
@@ -515,6 +521,16 @@ export interface ApiAuditLog {
515
521
  user_id?: string;
516
522
  }
517
523
 
524
+ /** Authenticate against the server with email+password. */
525
+ export interface ApiAuthenticateSMSRequest {
526
+ //The email account details.
527
+ account?: ApiAccountSMS;
528
+ //Register the account if the user does not already exist.
529
+ create?: boolean;
530
+ //Set the username on the account at register. Must be unique.
531
+ username?: string;
532
+ }
533
+
518
534
  /** Authenticate against the server with email+password. */
519
535
  export interface ApiAuthenticateEmailRequest {
520
536
  //The email account details.
@@ -1022,6 +1038,8 @@ export interface ApiClanProfile {
1022
1038
  nick_name?: string;
1023
1039
  //
1024
1040
  user_id?: string;
1041
+ //
1042
+ about?: string;
1025
1043
  }
1026
1044
 
1027
1045
  /** */
@@ -3627,6 +3645,44 @@ export class MezonApi {
3627
3645
  ]);
3628
3646
  }
3629
3647
 
3648
+ /** Authenticate a user with an SMS against the server. */
3649
+ AuthenticateSMSOTPRequest(
3650
+ basicAuthUsername: string,
3651
+ basicAuthPassword: string,
3652
+ body:ApiAuthenticateSMSRequest,
3653
+ options: any = {}): Promise<ApiLinkAccountConfirmRequest> {
3654
+
3655
+ if (body === null || body === undefined) {
3656
+ throw new Error("'body' is a required parameter but is null or undefined.");
3657
+ }
3658
+ const urlPath = "/v2/account/authenticate/smsotp";
3659
+ const queryParams = new Map<string, any>();
3660
+
3661
+ let bodyJson : string = "";
3662
+ bodyJson = JSON.stringify(body || {});
3663
+
3664
+ const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
3665
+ const fetchOptions = buildFetchOptions("POST", options, bodyJson);
3666
+ if (basicAuthUsername) {
3667
+ fetchOptions.headers["Authorization"] = "Basic " + encode(basicAuthUsername + ":" + basicAuthPassword);
3668
+ }
3669
+
3670
+ return Promise.race([
3671
+ fetch(fullUrl, fetchOptions).then((response) => {
3672
+ if (response.status == 204) {
3673
+ return response;
3674
+ } else if (response.status >= 200 && response.status < 300) {
3675
+ return response.json();
3676
+ } else {
3677
+ throw response;
3678
+ }
3679
+ }),
3680
+ new Promise((_, reject) =>
3681
+ setTimeout(reject, this.timeoutMs, "Request timed out.")
3682
+ ),
3683
+ ]);
3684
+ }
3685
+
3630
3686
  /** Authenticate a user with an email+password against the server. */
3631
3687
  AuthenticateEmailOTPRequest(
3632
3688
  basicAuthUsername: string,
package/client.ts CHANGED
@@ -610,6 +610,27 @@ export class Client {
610
610
  });
611
611
  }
612
612
 
613
+ /** Authenticate a user with an email+otp against the server. */
614
+ authenticateSMSOTPRequest(
615
+ phoneno: string,
616
+ username?: string,
617
+ vars?: Record<string, string>
618
+ ): Promise<ApiLinkAccountConfirmRequest> {
619
+ const request = {
620
+ username: username,
621
+ account: {
622
+ phoneno: phoneno,
623
+ vars: vars,
624
+ }
625
+ };
626
+
627
+ return this.apiClient
628
+ .AuthenticateSMSOTPRequest(this.serverkey, "", request, username)
629
+ .then((response: ApiLinkAccountConfirmRequest) => {
630
+ return Promise.resolve(response);
631
+ });
632
+ }
633
+
613
634
  /** Authenticate a user with an email+otp against the server. */
614
635
  authenticateEmailOTPRequest(
615
636
  email: string,
package/dist/api.gen.d.ts CHANGED
@@ -222,6 +222,10 @@ export interface ApiAccountApp {
222
222
  token?: string;
223
223
  vars?: Record<string, string>;
224
224
  }
225
+ export interface ApiAccountSMS {
226
+ phoneno: string;
227
+ vars?: Record<string, string>;
228
+ }
225
229
  /** Send an email with password to the server. Used with authenticate/link/unlink. */
226
230
  export interface ApiAccountEmail {
227
231
  email?: string;
@@ -296,6 +300,12 @@ export interface ApiAuditLog {
296
300
  user_id?: string;
297
301
  }
298
302
  /** Authenticate against the server with email+password. */
303
+ export interface ApiAuthenticateSMSRequest {
304
+ account?: ApiAccountSMS;
305
+ create?: boolean;
306
+ username?: string;
307
+ }
308
+ /** Authenticate against the server with email+password. */
299
309
  export interface ApiAuthenticateEmailRequest {
300
310
  account?: ApiAccountEmail;
301
311
  create?: boolean;
@@ -578,6 +588,7 @@ export interface ApiClanProfile {
578
588
  clan_id?: string;
579
589
  nick_name?: string;
580
590
  user_id?: string;
591
+ about?: string;
581
592
  }
582
593
  /** */
583
594
  export interface ApiClanSticker {
@@ -1948,6 +1959,8 @@ export declare class MezonApi {
1948
1959
  confirmLogin(bearerToken: string, basePath: string, body: ApiConfirmLoginRequest, options?: any): Promise<any>;
1949
1960
  /** */
1950
1961
  createQRLogin(basicAuthUsername: string, basicAuthPassword: string, body: ApiLoginRequest, options?: any): Promise<ApiLoginIDResponse>;
1962
+ /** Authenticate a user with an SMS against the server. */
1963
+ AuthenticateSMSOTPRequest(basicAuthUsername: string, basicAuthPassword: string, body: ApiAuthenticateSMSRequest, options?: any): Promise<ApiLinkAccountConfirmRequest>;
1951
1964
  /** Authenticate a user with an email+password against the server. */
1952
1965
  AuthenticateEmailOTPRequest(basicAuthUsername: string, basicAuthPassword: string, body: ApiAuthenticateEmailRequest, options?: any): Promise<ApiLinkAccountConfirmRequest>;
1953
1966
  /** Authenticate a user with an email+password against the server. */
package/dist/client.d.ts CHANGED
@@ -335,6 +335,8 @@ export declare class Client {
335
335
  /** Authenticate a user with a custom id against the server. */
336
336
  authenticateMezon(token: string, create?: boolean, username?: string, isRemember?: boolean, vars?: Record<string, string>, options?: any): Promise<Session>;
337
337
  /** Authenticate a user with an email+otp against the server. */
338
+ authenticateSMSOTPRequest(phoneno: string, username?: string, vars?: Record<string, string>): Promise<ApiLinkAccountConfirmRequest>;
339
+ /** Authenticate a user with an email+otp against the server. */
338
340
  authenticateEmailOTPRequest(email: string, username?: string, vars?: Record<string, string>): Promise<ApiLinkAccountConfirmRequest>;
339
341
  confirmEmailOTP(request: ApiLinkAccountConfirmRequest): Promise<Session>;
340
342
  /** Authenticate a user with an email+password against the server. */
@@ -934,6 +934,35 @@ var MezonApi = class {
934
934
  )
935
935
  ]);
936
936
  }
937
+ /** Authenticate a user with an SMS against the server. */
938
+ AuthenticateSMSOTPRequest(basicAuthUsername, basicAuthPassword, body, options = {}) {
939
+ if (body === null || body === void 0) {
940
+ throw new Error("'body' is a required parameter but is null or undefined.");
941
+ }
942
+ const urlPath = "/v2/account/authenticate/smsotp";
943
+ const queryParams = /* @__PURE__ */ new Map();
944
+ let bodyJson = "";
945
+ bodyJson = JSON.stringify(body || {});
946
+ const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
947
+ const fetchOptions = buildFetchOptions("POST", options, bodyJson);
948
+ if (basicAuthUsername) {
949
+ fetchOptions.headers["Authorization"] = "Basic " + encode(basicAuthUsername + ":" + basicAuthPassword);
950
+ }
951
+ return Promise.race([
952
+ fetch(fullUrl, fetchOptions).then((response) => {
953
+ if (response.status == 204) {
954
+ return response;
955
+ } else if (response.status >= 200 && response.status < 300) {
956
+ return response.json();
957
+ } else {
958
+ throw response;
959
+ }
960
+ }),
961
+ new Promise(
962
+ (_, reject) => setTimeout(reject, this.timeoutMs, "Request timed out.")
963
+ )
964
+ ]);
965
+ }
937
966
  /** Authenticate a user with an email+password against the server. */
938
967
  AuthenticateEmailOTPRequest(basicAuthUsername, basicAuthPassword, body, options = {}) {
939
968
  if (body === null || body === void 0) {
@@ -7340,6 +7369,8 @@ var _DefaultSocket = class _DefaultSocket {
7340
7369
  this.onblockfriend(message.block_friend);
7341
7370
  } else if (message.un_block_friend) {
7342
7371
  this.onunblockfriend(message.un_block_friend);
7372
+ } else if (message.add_friend) {
7373
+ this.onaddfriend(message.add_friend);
7343
7374
  } else if (message.remove_friend) {
7344
7375
  this.onremovefriend(message.remove_friend);
7345
7376
  } else if (message.user_clan_removed_event) {
@@ -7518,6 +7549,11 @@ var _DefaultSocket = class _DefaultSocket {
7518
7549
  console.log(user);
7519
7550
  }
7520
7551
  }
7552
+ onaddfriend(user) {
7553
+ if (this.verbose && window && window.console) {
7554
+ console.log(user);
7555
+ }
7556
+ }
7521
7557
  onremovefriend(user) {
7522
7558
  if (this.verbose && window && window.console) {
7523
7559
  console.log(user);
@@ -8326,6 +8362,19 @@ var Client = class {
8326
8362
  });
8327
8363
  }
8328
8364
  /** Authenticate a user with an email+otp against the server. */
8365
+ authenticateSMSOTPRequest(phoneno, username, vars) {
8366
+ const request = {
8367
+ username,
8368
+ account: {
8369
+ phoneno,
8370
+ vars
8371
+ }
8372
+ };
8373
+ return this.apiClient.AuthenticateSMSOTPRequest(this.serverkey, "", request, username).then((response) => {
8374
+ return Promise.resolve(response);
8375
+ });
8376
+ }
8377
+ /** Authenticate a user with an email+otp against the server. */
8329
8378
  authenticateEmailOTPRequest(email, username, vars) {
8330
8379
  const request = {
8331
8380
  username,
@@ -900,6 +900,35 @@ var MezonApi = class {
900
900
  )
901
901
  ]);
902
902
  }
903
+ /** Authenticate a user with an SMS against the server. */
904
+ AuthenticateSMSOTPRequest(basicAuthUsername, basicAuthPassword, body, options = {}) {
905
+ if (body === null || body === void 0) {
906
+ throw new Error("'body' is a required parameter but is null or undefined.");
907
+ }
908
+ const urlPath = "/v2/account/authenticate/smsotp";
909
+ const queryParams = /* @__PURE__ */ new Map();
910
+ let bodyJson = "";
911
+ bodyJson = JSON.stringify(body || {});
912
+ const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
913
+ const fetchOptions = buildFetchOptions("POST", options, bodyJson);
914
+ if (basicAuthUsername) {
915
+ fetchOptions.headers["Authorization"] = "Basic " + encode(basicAuthUsername + ":" + basicAuthPassword);
916
+ }
917
+ return Promise.race([
918
+ fetch(fullUrl, fetchOptions).then((response) => {
919
+ if (response.status == 204) {
920
+ return response;
921
+ } else if (response.status >= 200 && response.status < 300) {
922
+ return response.json();
923
+ } else {
924
+ throw response;
925
+ }
926
+ }),
927
+ new Promise(
928
+ (_, reject) => setTimeout(reject, this.timeoutMs, "Request timed out.")
929
+ )
930
+ ]);
931
+ }
903
932
  /** Authenticate a user with an email+password against the server. */
904
933
  AuthenticateEmailOTPRequest(basicAuthUsername, basicAuthPassword, body, options = {}) {
905
934
  if (body === null || body === void 0) {
@@ -7306,6 +7335,8 @@ var _DefaultSocket = class _DefaultSocket {
7306
7335
  this.onblockfriend(message.block_friend);
7307
7336
  } else if (message.un_block_friend) {
7308
7337
  this.onunblockfriend(message.un_block_friend);
7338
+ } else if (message.add_friend) {
7339
+ this.onaddfriend(message.add_friend);
7309
7340
  } else if (message.remove_friend) {
7310
7341
  this.onremovefriend(message.remove_friend);
7311
7342
  } else if (message.user_clan_removed_event) {
@@ -7484,6 +7515,11 @@ var _DefaultSocket = class _DefaultSocket {
7484
7515
  console.log(user);
7485
7516
  }
7486
7517
  }
7518
+ onaddfriend(user) {
7519
+ if (this.verbose && window && window.console) {
7520
+ console.log(user);
7521
+ }
7522
+ }
7487
7523
  onremovefriend(user) {
7488
7524
  if (this.verbose && window && window.console) {
7489
7525
  console.log(user);
@@ -8292,6 +8328,19 @@ var Client = class {
8292
8328
  });
8293
8329
  }
8294
8330
  /** Authenticate a user with an email+otp against the server. */
8331
+ authenticateSMSOTPRequest(phoneno, username, vars) {
8332
+ const request = {
8333
+ username,
8334
+ account: {
8335
+ phoneno,
8336
+ vars
8337
+ }
8338
+ };
8339
+ return this.apiClient.AuthenticateSMSOTPRequest(this.serverkey, "", request, username).then((response) => {
8340
+ return Promise.resolve(response);
8341
+ });
8342
+ }
8343
+ /** Authenticate a user with an email+otp against the server. */
8295
8344
  authenticateEmailOTPRequest(email, username, vars) {
8296
8345
  const request = {
8297
8346
  username,
package/dist/socket.d.ts CHANGED
@@ -649,6 +649,12 @@ export interface UserEmojiUsage {
649
649
  clan_id: string;
650
650
  create_time: string;
651
651
  }
652
+ export interface AddFriend {
653
+ user_id: string;
654
+ username: string;
655
+ display_name: string;
656
+ avatar: string;
657
+ }
652
658
  export interface RemoveFriend {
653
659
  user_id: string;
654
660
  }
@@ -987,6 +993,7 @@ export interface Socket {
987
993
  onuserprofileupdate: (user: UserProfileUpdatedEvent) => void;
988
994
  /** Receive channel removed user event */
989
995
  onuserchannelremoved: (user: UserChannelRemovedEvent) => void;
996
+ onaddfriend: (user: AddFriend) => void;
990
997
  onremovefriend: (user: RemoveFriend) => void;
991
998
  onblockfriend: (user: BlockFriend) => void;
992
999
  onunblockfriend: (user: UnblockFriend) => void;
@@ -1076,6 +1083,7 @@ export declare class DefaultSocket implements Socket {
1076
1083
  onuserclanadded(user: AddClanUserEvent): void;
1077
1084
  onuserprofileupdate(user: UserProfileUpdatedEvent): void;
1078
1085
  onuserchannelremoved(user: UserChannelRemovedEvent): void;
1086
+ onaddfriend(user: AddFriend): void;
1079
1087
  onremovefriend(user: RemoveFriend): void;
1080
1088
  onblockfriend(user: BlockFriend): void;
1081
1089
  onunblockfriend(user: UnblockFriend): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mezon-js",
3
- "version": "2.12.92",
3
+ "version": "2.12.94",
4
4
  "scripts": {
5
5
  "build": "npx tsc && npx rollup -c --bundleConfigAsCjs && node build.mjs"
6
6
  },
package/socket.ts CHANGED
@@ -1000,6 +1000,17 @@ export interface UserEmojiUsage {
1000
1000
  clan_id: string;
1001
1001
  create_time: string;
1002
1002
  }
1003
+
1004
+ export interface AddFriend {
1005
+ //
1006
+ user_id: string;// user id
1007
+ // username
1008
+ username: string;
1009
+ // display name
1010
+ display_name: string;
1011
+ // avatar
1012
+ avatar: string;
1013
+ }
1003
1014
  export interface RemoveFriend {
1004
1015
  //
1005
1016
  user_id: string;
@@ -1674,6 +1685,8 @@ export interface Socket {
1674
1685
  /** Receive channel removed user event */
1675
1686
  onuserchannelremoved: (user: UserChannelRemovedEvent) => void;
1676
1687
 
1688
+ onaddfriend: (user: AddFriend) => void;
1689
+
1677
1690
  onremovefriend: (user: RemoveFriend) => void;
1678
1691
 
1679
1692
  onblockfriend: (user: BlockFriend) => void;
@@ -1969,6 +1982,8 @@ export class DefaultSocket implements Socket {
1969
1982
  this.onblockfriend(<BlockFriend>message.block_friend);
1970
1983
  } else if (message.un_block_friend) {
1971
1984
  this.onunblockfriend(<BlockFriend>message.un_block_friend);
1985
+ } else if (message.add_friend) {
1986
+ this.onaddfriend(<AddFriend>message.add_friend);
1972
1987
  } else if (message.remove_friend) {
1973
1988
  this.onremovefriend(<RemoveFriend>message.remove_friend);
1974
1989
  } else if (message.user_clan_removed_event) {
@@ -2166,6 +2181,12 @@ export class DefaultSocket implements Socket {
2166
2181
  }
2167
2182
  }
2168
2183
 
2184
+ onaddfriend(user: AddFriend) {
2185
+ if (this.verbose && window && window.console) {
2186
+ console.log(user);
2187
+ }
2188
+ }
2189
+
2169
2190
  onremovefriend(user: RemoveFriend) {
2170
2191
  if (this.verbose && window && window.console) {
2171
2192
  console.log(user);