mezon-js 2.12.4 → 2.12.6

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
@@ -3340,6 +3340,7 @@ export class MezonApi {
3340
3340
  /** */
3341
3341
  confirmLogin(
3342
3342
  bearerToken: string,
3343
+ basePath: string,
3343
3344
  body: ApiConfirmLoginRequest,
3344
3345
  options: any = {}
3345
3346
  ): Promise<any> {
@@ -3354,7 +3355,7 @@ export class MezonApi {
3354
3355
  let bodyJson: string = "";
3355
3356
  bodyJson = JSON.stringify(body || {});
3356
3357
 
3357
- const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
3358
+ const fullUrl = this.buildFullUrl(basePath, urlPath, queryParams);
3358
3359
  const fetchOptions = buildFetchOptions("POST", options, bodyJson);
3359
3360
  if (bearerToken) {
3360
3361
  fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
package/client.ts CHANGED
@@ -561,15 +561,21 @@ export class Client {
561
561
 
562
562
  /** thre refreshTokenPromise */
563
563
  private refreshTokenPromise: Promise<Session> | null = null;
564
+ host: string;
565
+ port: string;
566
+ useSSL: boolean;
564
567
 
565
568
  constructor(
566
569
  readonly serverkey = DEFAULT_SERVER_KEY,
567
- readonly host = DEFAULT_HOST,
568
- readonly port = DEFAULT_PORT,
569
- readonly useSSL = false,
570
+ host = DEFAULT_HOST,
571
+ port = DEFAULT_PORT,
572
+ useSSL = false,
570
573
  readonly timeout = DEFAULT_TIMEOUT_MS,
571
574
  readonly autoRefreshSession = true
572
575
  ) {
576
+ this.host = host;
577
+ this.port = port;
578
+ this.useSSL = useSSL;
573
579
  const scheme = useSSL ? "https://" : "http://";
574
580
  const basePath = `${scheme}${host}:${port}`;
575
581
 
@@ -640,7 +646,13 @@ export class Client {
640
646
  }
641
647
 
642
648
  /** set base path */
643
- setBasePath(basePath: string) {
649
+ setBasePath(host: string, port: string, useSSL: boolean) {
650
+ this.host = host;
651
+ this.port = port;
652
+ this.useSSL = useSSL;
653
+
654
+ const scheme = useSSL ? "https://" : "http://";
655
+ const basePath = `${scheme}${host}:${port}`;
644
656
  return this.apiClient
645
657
  .setBasePath(basePath);
646
658
  }
@@ -3941,6 +3953,7 @@ export class Client {
3941
3953
 
3942
3954
  async confirmLogin(
3943
3955
  session: Session,
3956
+ basePath: string,
3944
3957
  body: ApiConfirmLoginRequest
3945
3958
  ): Promise<any> {
3946
3959
  if (
@@ -3952,7 +3965,7 @@ export class Client {
3952
3965
  }
3953
3966
 
3954
3967
  return this.apiClient
3955
- .confirmLogin(session.token, body)
3968
+ .confirmLogin(session.token, basePath, body)
3956
3969
  .then((response: any) => {
3957
3970
  return response;
3958
3971
  });
package/dist/api.gen.d.ts CHANGED
@@ -1824,7 +1824,7 @@ export declare class MezonApi {
1824
1824
  /** */
1825
1825
  checkLoginRequest(basicAuthUsername: string, basicAuthPassword: string, body: ApiConfirmLoginRequest, options?: any): Promise<ApiSession>;
1826
1826
  /** */
1827
- confirmLogin(bearerToken: string, body: ApiConfirmLoginRequest, options?: any): Promise<any>;
1827
+ confirmLogin(bearerToken: string, basePath: string, body: ApiConfirmLoginRequest, options?: any): Promise<any>;
1828
1828
  /** */
1829
1829
  createQRLogin(basicAuthUsername: string, basicAuthPassword: string, body: ApiLoginRequest, options?: any): Promise<ApiLoginIDResponse>;
1830
1830
  /** Authenticate a user with an email+password against the server. */
package/dist/client.d.ts CHANGED
@@ -342,22 +342,22 @@ export interface ApiUpdateRoleRequest {
342
342
  /** A client for Mezon server. */
343
343
  export declare class Client {
344
344
  readonly serverkey: string;
345
- readonly host: string;
346
- readonly port: string;
347
- readonly useSSL: boolean;
348
345
  readonly timeout: number;
349
346
  readonly autoRefreshSession: boolean;
350
347
  /** The low level API client for Mezon server. */
351
348
  private readonly apiClient;
352
349
  /** thre refreshTokenPromise */
353
350
  private refreshTokenPromise;
351
+ host: string;
352
+ port: string;
353
+ useSSL: boolean;
354
354
  constructor(serverkey?: string, host?: string, port?: string, useSSL?: boolean, timeout?: number, autoRefreshSession?: boolean);
355
355
  /** Authenticate a user with a custom id against the server. */
356
356
  authenticateMezon(token: string, create?: boolean, username?: string, isRemember?: boolean, vars?: Record<string, string>, options?: any): Promise<Session>;
357
357
  /** Authenticate a user with an email+password against the server. */
358
358
  authenticateEmail(email: string, password: string, username?: string, vars?: Record<string, string>): Promise<Session>;
359
359
  /** set base path */
360
- setBasePath(basePath: string): void;
360
+ setBasePath(host: string, port: string, useSSL: boolean): void;
361
361
  /** Add users to a channel, or accept their join requests. */
362
362
  addChannelUsers(session: Session, channelId: string, ids?: Array<string>): Promise<boolean>;
363
363
  /** Add friends by ID or username to a user's account. */
@@ -576,7 +576,7 @@ export declare class Client {
576
576
  createActiviy(session: Session, request: ApiCreateActivityRequest): Promise<ApiUserActivity>;
577
577
  createQRLogin(requet: ApiLoginRequest): Promise<ApiLoginIDResponse>;
578
578
  checkLoginRequest(requet: ApiConfirmLoginRequest): Promise<Session | null>;
579
- confirmLogin(session: Session, body: ApiConfirmLoginRequest): Promise<any>;
579
+ confirmLogin(session: Session, basePath: string, body: ApiConfirmLoginRequest): Promise<any>;
580
580
  getChanEncryptionMethod(session: Session, channelId: string): Promise<ApiChanEncryptionMethod>;
581
581
  setChanEncryptionMethod(session: Session, channelId: string, method: string): Promise<any>;
582
582
  getPubKeys(session: Session, userIds: Array<string>): Promise<ApiGetPubKeysResponse>;
@@ -874,7 +874,7 @@ var MezonApi = class {
874
874
  ]);
875
875
  }
876
876
  /** */
877
- confirmLogin(bearerToken, body, options = {}) {
877
+ confirmLogin(bearerToken, basePath, body, options = {}) {
878
878
  if (body === null || body === void 0) {
879
879
  throw new Error(
880
880
  "'body' is a required parameter but is null or undefined."
@@ -884,7 +884,7 @@ var MezonApi = class {
884
884
  const queryParams = /* @__PURE__ */ new Map();
885
885
  let bodyJson = "";
886
886
  bodyJson = JSON.stringify(body || {});
887
- const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
887
+ const fullUrl = this.buildFullUrl(basePath, urlPath, queryParams);
888
888
  const fetchOptions = buildFetchOptions("POST", options, bodyJson);
889
889
  if (bearerToken) {
890
890
  fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
@@ -7853,13 +7853,13 @@ var WebrtcSignalingType = /* @__PURE__ */ ((WebrtcSignalingType2) => {
7853
7853
  var Client = class {
7854
7854
  constructor(serverkey = DEFAULT_SERVER_KEY, host = DEFAULT_HOST, port = DEFAULT_PORT, useSSL = false, timeout = DEFAULT_TIMEOUT_MS, autoRefreshSession = true) {
7855
7855
  this.serverkey = serverkey;
7856
- this.host = host;
7857
- this.port = port;
7858
- this.useSSL = useSSL;
7859
7856
  this.timeout = timeout;
7860
7857
  this.autoRefreshSession = autoRefreshSession;
7861
7858
  /** thre refreshTokenPromise */
7862
7859
  this.refreshTokenPromise = null;
7860
+ this.host = host;
7861
+ this.port = port;
7862
+ this.useSSL = useSSL;
7863
7863
  const scheme = useSSL ? "https://" : "http://";
7864
7864
  const basePath = `${scheme}${host}:${port}`;
7865
7865
  this.apiClient = new MezonApi(serverkey, timeout, basePath);
@@ -7909,7 +7909,12 @@ var Client = class {
7909
7909
  });
7910
7910
  }
7911
7911
  /** set base path */
7912
- setBasePath(basePath) {
7912
+ setBasePath(host, port, useSSL) {
7913
+ this.host = host;
7914
+ this.port = port;
7915
+ this.useSSL = useSSL;
7916
+ const scheme = useSSL ? "https://" : "http://";
7917
+ const basePath = `${scheme}${host}:${port}`;
7913
7918
  return this.apiClient.setBasePath(basePath);
7914
7919
  }
7915
7920
  /** Add users to a channel, or accept their join requests. */
@@ -9876,12 +9881,12 @@ var Client = class {
9876
9881
  );
9877
9882
  });
9878
9883
  }
9879
- confirmLogin(session, body) {
9884
+ confirmLogin(session, basePath, body) {
9880
9885
  return __async(this, null, function* () {
9881
9886
  if (this.autoRefreshSession && session.refresh_token && session.isexpired(Date.now() / 1e3)) {
9882
9887
  yield this.sessionRefresh(session);
9883
9888
  }
9884
- return this.apiClient.confirmLogin(session.token, body).then((response) => {
9889
+ return this.apiClient.confirmLogin(session.token, basePath, body).then((response) => {
9885
9890
  return response;
9886
9891
  });
9887
9892
  });
@@ -840,7 +840,7 @@ var MezonApi = class {
840
840
  ]);
841
841
  }
842
842
  /** */
843
- confirmLogin(bearerToken, body, options = {}) {
843
+ confirmLogin(bearerToken, basePath, body, options = {}) {
844
844
  if (body === null || body === void 0) {
845
845
  throw new Error(
846
846
  "'body' is a required parameter but is null or undefined."
@@ -850,7 +850,7 @@ var MezonApi = class {
850
850
  const queryParams = /* @__PURE__ */ new Map();
851
851
  let bodyJson = "";
852
852
  bodyJson = JSON.stringify(body || {});
853
- const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
853
+ const fullUrl = this.buildFullUrl(basePath, urlPath, queryParams);
854
854
  const fetchOptions = buildFetchOptions("POST", options, bodyJson);
855
855
  if (bearerToken) {
856
856
  fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
@@ -7819,13 +7819,13 @@ var WebrtcSignalingType = /* @__PURE__ */ ((WebrtcSignalingType2) => {
7819
7819
  var Client = class {
7820
7820
  constructor(serverkey = DEFAULT_SERVER_KEY, host = DEFAULT_HOST, port = DEFAULT_PORT, useSSL = false, timeout = DEFAULT_TIMEOUT_MS, autoRefreshSession = true) {
7821
7821
  this.serverkey = serverkey;
7822
- this.host = host;
7823
- this.port = port;
7824
- this.useSSL = useSSL;
7825
7822
  this.timeout = timeout;
7826
7823
  this.autoRefreshSession = autoRefreshSession;
7827
7824
  /** thre refreshTokenPromise */
7828
7825
  this.refreshTokenPromise = null;
7826
+ this.host = host;
7827
+ this.port = port;
7828
+ this.useSSL = useSSL;
7829
7829
  const scheme = useSSL ? "https://" : "http://";
7830
7830
  const basePath = `${scheme}${host}:${port}`;
7831
7831
  this.apiClient = new MezonApi(serverkey, timeout, basePath);
@@ -7875,7 +7875,12 @@ var Client = class {
7875
7875
  });
7876
7876
  }
7877
7877
  /** set base path */
7878
- setBasePath(basePath) {
7878
+ setBasePath(host, port, useSSL) {
7879
+ this.host = host;
7880
+ this.port = port;
7881
+ this.useSSL = useSSL;
7882
+ const scheme = useSSL ? "https://" : "http://";
7883
+ const basePath = `${scheme}${host}:${port}`;
7879
7884
  return this.apiClient.setBasePath(basePath);
7880
7885
  }
7881
7886
  /** Add users to a channel, or accept their join requests. */
@@ -9842,12 +9847,12 @@ var Client = class {
9842
9847
  );
9843
9848
  });
9844
9849
  }
9845
- confirmLogin(session, body) {
9850
+ confirmLogin(session, basePath, body) {
9846
9851
  return __async(this, null, function* () {
9847
9852
  if (this.autoRefreshSession && session.refresh_token && session.isexpired(Date.now() / 1e3)) {
9848
9853
  yield this.sessionRefresh(session);
9849
9854
  }
9850
- return this.apiClient.confirmLogin(session.token, body).then((response) => {
9855
+ return this.apiClient.confirmLogin(session.token, basePath, body).then((response) => {
9851
9856
  return response;
9852
9857
  });
9853
9858
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mezon-js",
3
3
 
4
- "version": "2.12.4",
4
+ "version": "2.12.6",
5
5
 
6
6
  "scripts": {
7
7
  "build": "npx tsc && npx rollup -c --bundleConfigAsCjs && node build.mjs"