mezon-js 2.12.2 → 2.12.3

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
@@ -3157,11 +3157,18 @@ export interface ApiUserEventRequest {
3157
3157
  }
3158
3158
 
3159
3159
  export class MezonApi {
3160
+ basePath: string;
3160
3161
  constructor(
3161
3162
  readonly serverKey: string,
3162
- readonly basePath: string,
3163
- readonly timeoutMs: number
3164
- ) {}
3163
+ readonly timeoutMs: number,
3164
+ basePath: string,
3165
+ ) {
3166
+ this.basePath = basePath
3167
+ }
3168
+
3169
+ setBasePath(basePath: string) {
3170
+ this.basePath = basePath;
3171
+ }
3165
3172
 
3166
3173
  /** A healthcheck which load balancers can use to check the service. */
3167
3174
  healthcheck(bearerToken: string, options: any = {}): Promise<any> {
@@ -3291,7 +3298,6 @@ export class MezonApi {
3291
3298
 
3292
3299
  /** */
3293
3300
  checkLoginRequest(
3294
- basePath: string,
3295
3301
  basicAuthUsername: string,
3296
3302
  basicAuthPassword: string,
3297
3303
  body: ApiConfirmLoginRequest,
@@ -3308,7 +3314,7 @@ export class MezonApi {
3308
3314
  let bodyJson: string = "";
3309
3315
  bodyJson = JSON.stringify(body || {});
3310
3316
 
3311
- const fullUrl = this.buildFullUrl(basePath, urlPath, queryParams);
3317
+ const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
3312
3318
  const fetchOptions = buildFetchOptions("POST", options, bodyJson);
3313
3319
  if (basicAuthUsername) {
3314
3320
  fetchOptions.headers["Authorization"] =
@@ -3333,7 +3339,6 @@ export class MezonApi {
3333
3339
 
3334
3340
  /** */
3335
3341
  confirmLogin(
3336
- basePath: string,
3337
3342
  bearerToken: string,
3338
3343
  body: ApiConfirmLoginRequest,
3339
3344
  options: any = {}
@@ -3349,7 +3354,7 @@ export class MezonApi {
3349
3354
  let bodyJson: string = "";
3350
3355
  bodyJson = JSON.stringify(body || {});
3351
3356
 
3352
- const fullUrl = this.buildFullUrl(basePath, urlPath, queryParams);
3357
+ const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
3353
3358
  const fetchOptions = buildFetchOptions("POST", options, bodyJson);
3354
3359
  if (bearerToken) {
3355
3360
  fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
@@ -3373,7 +3378,6 @@ export class MezonApi {
3373
3378
 
3374
3379
  /** */
3375
3380
  createQRLogin(
3376
- basePath: string,
3377
3381
  basicAuthUsername: string,
3378
3382
  basicAuthPassword: string,
3379
3383
  body: ApiLoginRequest,
@@ -3390,7 +3394,7 @@ export class MezonApi {
3390
3394
  let bodyJson: string = "";
3391
3395
  bodyJson = JSON.stringify(body || {});
3392
3396
 
3393
- const fullUrl = this.buildFullUrl(basePath, urlPath, queryParams);
3397
+ const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
3394
3398
  const fetchOptions = buildFetchOptions("POST", options, bodyJson);
3395
3399
  if (basicAuthUsername) {
3396
3400
  fetchOptions.headers["Authorization"] =
@@ -3416,7 +3420,6 @@ export class MezonApi {
3416
3420
 
3417
3421
  /** Authenticate a user with an email+password against the server. */
3418
3422
  authenticateEmail(
3419
- basePath: string,
3420
3423
  basicAuthUsername: string,
3421
3424
  basicAuthPassword: string,
3422
3425
  body:ApiAuthenticateEmailRequest,
@@ -3431,7 +3434,7 @@ export class MezonApi {
3431
3434
  let bodyJson : string = "";
3432
3435
  bodyJson = JSON.stringify(body || {});
3433
3436
 
3434
- const fullUrl = this.buildFullUrl(basePath, urlPath, queryParams);
3437
+ const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
3435
3438
  const fetchOptions = buildFetchOptions("POST", options, bodyJson);
3436
3439
  if (basicAuthUsername) {
3437
3440
  fetchOptions.headers["Authorization"] = "Basic " + encode(basicAuthUsername + ":" + basicAuthPassword);
@@ -3455,7 +3458,6 @@ export class MezonApi {
3455
3458
 
3456
3459
  /** Authenticate a user with Mezon against the server. */
3457
3460
  authenticateMezon(
3458
- basePath: string,
3459
3461
  basicAuthUsername: string,
3460
3462
  basicAuthPassword: string,
3461
3463
  account:ApiAccountMezon,
@@ -3477,7 +3479,7 @@ export class MezonApi {
3477
3479
  let bodyJson : string = "";
3478
3480
  bodyJson = JSON.stringify(account || {});
3479
3481
 
3480
- const fullUrl = this.buildFullUrl(basePath, urlPath, queryParams);
3482
+ const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
3481
3483
  const fetchOptions = buildFetchOptions("POST", options, bodyJson);
3482
3484
  if (basicAuthUsername) {
3483
3485
  fetchOptions.headers["Authorization"] = "Basic " + encode(basicAuthUsername + ":" + basicAuthPassword);
package/client.ts CHANGED
@@ -573,12 +573,11 @@ export class Client {
573
573
  const scheme = useSSL ? "https://" : "http://";
574
574
  const basePath = `${scheme}${host}:${port}`;
575
575
 
576
- this.apiClient = new MezonApi(serverkey, basePath, timeout);
576
+ this.apiClient = new MezonApi(serverkey, timeout, basePath);
577
577
  }
578
578
 
579
579
  /** Authenticate a user with a custom id against the server. */
580
580
  authenticateMezon(
581
- basePath: string,
582
581
  token: string,
583
582
  create?: boolean,
584
583
  username?: string,
@@ -592,7 +591,6 @@ export class Client {
592
591
  };
593
592
  return this.apiClient
594
593
  .authenticateMezon(
595
- basePath,
596
594
  this.serverkey,
597
595
  "",
598
596
  request,
@@ -613,7 +611,6 @@ export class Client {
613
611
 
614
612
  /** Authenticate a user with an email+password against the server. */
615
613
  authenticateEmail(
616
- basePath: string,
617
614
  email: string,
618
615
  password: string,
619
616
  username?: string,
@@ -629,7 +626,7 @@ export class Client {
629
626
  };
630
627
 
631
628
  return this.apiClient
632
- .authenticateEmail(basePath, this.serverkey, "", request, username)
629
+ .authenticateEmail(this.serverkey, "", request, username)
633
630
  .then((apiSession: ApiSession) => {
634
631
  return new Session(
635
632
  apiSession.token || "",
@@ -640,6 +637,12 @@ export class Client {
640
637
  });
641
638
  }
642
639
 
640
+ /** set base path */
641
+ setBasePath(basePath: string) {
642
+ return this.apiClient
643
+ .setBasePath(basePath);
644
+ }
645
+
643
646
  /** Add users to a channel, or accept their join requests. */
644
647
  async addChannelUsers(
645
648
  session: Session,
@@ -3901,9 +3904,8 @@ export class Client {
3901
3904
  });
3902
3905
  }
3903
3906
 
3904
- async createQRLogin(basePath: string, requet: ApiLoginRequest): Promise<ApiLoginIDResponse> {
3907
+ async createQRLogin(requet: ApiLoginRequest): Promise<ApiLoginIDResponse> {
3905
3908
  const apiSession = await this.apiClient.createQRLogin(
3906
- basePath,
3907
3909
  this.serverkey,
3908
3910
  "",
3909
3911
  requet
@@ -3916,11 +3918,9 @@ export class Client {
3916
3918
  }
3917
3919
 
3918
3920
  async checkLoginRequest(
3919
- basePath: string,
3920
3921
  requet: ApiConfirmLoginRequest
3921
3922
  ): Promise<Session | null> {
3922
3923
  const apiSession = await this.apiClient.checkLoginRequest(
3923
- basePath,
3924
3924
  this.serverkey,
3925
3925
  "",
3926
3926
  requet
@@ -3937,7 +3937,6 @@ export class Client {
3937
3937
  }
3938
3938
 
3939
3939
  async confirmLogin(
3940
- basePath: string,
3941
3940
  session: Session,
3942
3941
  body: ApiConfirmLoginRequest
3943
3942
  ): Promise<any> {
@@ -3950,7 +3949,7 @@ export class Client {
3950
3949
  }
3951
3950
 
3952
3951
  return this.apiClient
3953
- .confirmLogin(basePath, session.token, body)
3952
+ .confirmLogin(session.token, body)
3954
3953
  .then((response: any) => {
3955
3954
  return response;
3956
3955
  });
package/dist/api.gen.d.ts CHANGED
@@ -1809,9 +1809,10 @@ export interface ApiUserEventRequest {
1809
1809
  }
1810
1810
  export declare class MezonApi {
1811
1811
  readonly serverKey: string;
1812
- readonly basePath: string;
1813
1812
  readonly timeoutMs: number;
1814
- constructor(serverKey: string, basePath: string, timeoutMs: number);
1813
+ basePath: string;
1814
+ constructor(serverKey: string, timeoutMs: number, basePath: string);
1815
+ setBasePath(basePath: string): void;
1815
1816
  /** A healthcheck which load balancers can use to check the service. */
1816
1817
  healthcheck(bearerToken: string, options?: any): Promise<any>;
1817
1818
  /** Delete the current user's account. */
@@ -1821,15 +1822,15 @@ export declare class MezonApi {
1821
1822
  /** Update fields in the current user's account. */
1822
1823
  updateAccount(bearerToken: string, body: ApiUpdateAccountRequest, options?: any): Promise<any>;
1823
1824
  /** */
1824
- checkLoginRequest(basePath: string, basicAuthUsername: string, basicAuthPassword: string, body: ApiConfirmLoginRequest, options?: any): Promise<ApiSession>;
1825
+ checkLoginRequest(basicAuthUsername: string, basicAuthPassword: string, body: ApiConfirmLoginRequest, options?: any): Promise<ApiSession>;
1825
1826
  /** */
1826
- confirmLogin(basePath: string, bearerToken: string, body: ApiConfirmLoginRequest, options?: any): Promise<any>;
1827
+ confirmLogin(bearerToken: string, body: ApiConfirmLoginRequest, options?: any): Promise<any>;
1827
1828
  /** */
1828
- createQRLogin(basePath: string, basicAuthUsername: string, basicAuthPassword: string, body: ApiLoginRequest, options?: any): Promise<ApiLoginIDResponse>;
1829
+ createQRLogin(basicAuthUsername: string, basicAuthPassword: string, body: ApiLoginRequest, options?: any): Promise<ApiLoginIDResponse>;
1829
1830
  /** Authenticate a user with an email+password against the server. */
1830
- authenticateEmail(basePath: string, basicAuthUsername: string, basicAuthPassword: string, body: ApiAuthenticateEmailRequest, options?: any): Promise<ApiSession>;
1831
+ authenticateEmail(basicAuthUsername: string, basicAuthPassword: string, body: ApiAuthenticateEmailRequest, options?: any): Promise<ApiSession>;
1831
1832
  /** Authenticate a user with Mezon against the server. */
1832
- authenticateMezon(basePath: string, basicAuthUsername: string, basicAuthPassword: string, account: ApiAccountMezon, create?: boolean, username?: string, isRemember?: boolean, options?: any): Promise<ApiSession>;
1833
+ authenticateMezon(basicAuthUsername: string, basicAuthPassword: string, account: ApiAccountMezon, create?: boolean, username?: string, isRemember?: boolean, options?: any): Promise<ApiSession>;
1833
1834
  /** Add an email+password to the social profiles on the current user's account. */
1834
1835
  linkEmail(bearerToken: string, body: ApiAccountEmail, options?: any): Promise<any>;
1835
1836
  /** Add a mezon ID to the social profiles on the current user's account. */
package/dist/client.d.ts CHANGED
@@ -353,9 +353,11 @@ export declare class Client {
353
353
  private refreshTokenPromise;
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
- authenticateMezon(basePath: string, token: string, create?: boolean, username?: string, isRemember?: boolean, vars?: Record<string, string>, options?: any): Promise<Session>;
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
- authenticateEmail(basePath: string, email: string, password: string, username?: string, vars?: Record<string, string>): Promise<Session>;
358
+ authenticateEmail(email: string, password: string, username?: string, vars?: Record<string, string>): Promise<Session>;
359
+ /** set base path */
360
+ setBasePath(basePath: string): void;
359
361
  /** Add users to a channel, or accept their join requests. */
360
362
  addChannelUsers(session: Session, channelId: string, ids?: Array<string>): Promise<boolean>;
361
363
  /** Add friends by ID or username to a user's account. */
@@ -572,9 +574,9 @@ export declare class Client {
572
574
  /** List activity */
573
575
  listActivity(session: Session): Promise<ApiListUserActivity>;
574
576
  createActiviy(session: Session, request: ApiCreateActivityRequest): Promise<ApiUserActivity>;
575
- createQRLogin(basePath: string, requet: ApiLoginRequest): Promise<ApiLoginIDResponse>;
576
- checkLoginRequest(basePath: string, requet: ApiConfirmLoginRequest): Promise<Session | null>;
577
- confirmLogin(basePath: string, session: Session, body: ApiConfirmLoginRequest): Promise<any>;
577
+ createQRLogin(requet: ApiLoginRequest): Promise<ApiLoginIDResponse>;
578
+ checkLoginRequest(requet: ApiConfirmLoginRequest): Promise<Session | null>;
579
+ confirmLogin(session: Session, body: ApiConfirmLoginRequest): Promise<any>;
578
580
  getChanEncryptionMethod(session: Session, channelId: string): Promise<ApiChanEncryptionMethod>;
579
581
  setChanEncryptionMethod(session: Session, channelId: string, method: string): Promise<any>;
580
582
  getPubKeys(session: Session, userIds: Array<string>): Promise<ApiGetPubKeysResponse>;
@@ -728,10 +728,13 @@ function safeJSONParse(jsonStr) {
728
728
 
729
729
  // api.gen.ts
730
730
  var MezonApi = class {
731
- constructor(serverKey, basePath, timeoutMs) {
731
+ constructor(serverKey, timeoutMs, basePath) {
732
732
  this.serverKey = serverKey;
733
- this.basePath = basePath;
734
733
  this.timeoutMs = timeoutMs;
734
+ this.basePath = basePath;
735
+ }
736
+ setBasePath(basePath) {
737
+ this.basePath = basePath;
735
738
  }
736
739
  /** A healthcheck which load balancers can use to check the service. */
737
740
  healthcheck(bearerToken, options = {}) {
@@ -840,7 +843,7 @@ var MezonApi = class {
840
843
  ]);
841
844
  }
842
845
  /** */
843
- checkLoginRequest(basePath, basicAuthUsername, basicAuthPassword, body, options = {}) {
846
+ checkLoginRequest(basicAuthUsername, basicAuthPassword, body, options = {}) {
844
847
  if (body === null || body === void 0) {
845
848
  throw new Error(
846
849
  "'body' is a required parameter but is null or undefined."
@@ -850,7 +853,7 @@ var MezonApi = class {
850
853
  const queryParams = /* @__PURE__ */ new Map();
851
854
  let bodyJson = "";
852
855
  bodyJson = JSON.stringify(body || {});
853
- const fullUrl = this.buildFullUrl(basePath, urlPath, queryParams);
856
+ const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
854
857
  const fetchOptions = buildFetchOptions("POST", options, bodyJson);
855
858
  if (basicAuthUsername) {
856
859
  fetchOptions.headers["Authorization"] = "Basic " + encode(basicAuthUsername + ":" + basicAuthPassword);
@@ -871,7 +874,7 @@ var MezonApi = class {
871
874
  ]);
872
875
  }
873
876
  /** */
874
- confirmLogin(basePath, bearerToken, body, options = {}) {
877
+ confirmLogin(bearerToken, body, options = {}) {
875
878
  if (body === null || body === void 0) {
876
879
  throw new Error(
877
880
  "'body' is a required parameter but is null or undefined."
@@ -881,7 +884,7 @@ var MezonApi = class {
881
884
  const queryParams = /* @__PURE__ */ new Map();
882
885
  let bodyJson = "";
883
886
  bodyJson = JSON.stringify(body || {});
884
- const fullUrl = this.buildFullUrl(basePath, urlPath, queryParams);
887
+ const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
885
888
  const fetchOptions = buildFetchOptions("POST", options, bodyJson);
886
889
  if (bearerToken) {
887
890
  fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
@@ -902,7 +905,7 @@ var MezonApi = class {
902
905
  ]);
903
906
  }
904
907
  /** */
905
- createQRLogin(basePath, basicAuthUsername, basicAuthPassword, body, options = {}) {
908
+ createQRLogin(basicAuthUsername, basicAuthPassword, body, options = {}) {
906
909
  if (body === null || body === void 0) {
907
910
  throw new Error(
908
911
  "'body' is a required parameter but is null or undefined."
@@ -912,7 +915,7 @@ var MezonApi = class {
912
915
  const queryParams = /* @__PURE__ */ new Map();
913
916
  let bodyJson = "";
914
917
  bodyJson = JSON.stringify(body || {});
915
- const fullUrl = this.buildFullUrl(basePath, urlPath, queryParams);
918
+ const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
916
919
  const fetchOptions = buildFetchOptions("POST", options, bodyJson);
917
920
  if (basicAuthUsername) {
918
921
  fetchOptions.headers["Authorization"] = "Basic " + encode(basicAuthUsername + ":" + basicAuthPassword);
@@ -933,7 +936,7 @@ var MezonApi = class {
933
936
  ]);
934
937
  }
935
938
  /** Authenticate a user with an email+password against the server. */
936
- authenticateEmail(basePath, basicAuthUsername, basicAuthPassword, body, options = {}) {
939
+ authenticateEmail(basicAuthUsername, basicAuthPassword, body, options = {}) {
937
940
  if (body === null || body === void 0) {
938
941
  throw new Error("'body' is a required parameter but is null or undefined.");
939
942
  }
@@ -941,7 +944,7 @@ var MezonApi = class {
941
944
  const queryParams = /* @__PURE__ */ new Map();
942
945
  let bodyJson = "";
943
946
  bodyJson = JSON.stringify(body || {});
944
- const fullUrl = this.buildFullUrl(basePath, urlPath, queryParams);
947
+ const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
945
948
  const fetchOptions = buildFetchOptions("POST", options, bodyJson);
946
949
  if (basicAuthUsername) {
947
950
  fetchOptions.headers["Authorization"] = "Basic " + encode(basicAuthUsername + ":" + basicAuthPassword);
@@ -962,7 +965,7 @@ var MezonApi = class {
962
965
  ]);
963
966
  }
964
967
  /** Authenticate a user with Mezon against the server. */
965
- authenticateMezon(basePath, basicAuthUsername, basicAuthPassword, account, create, username, isRemember, options = {}) {
968
+ authenticateMezon(basicAuthUsername, basicAuthPassword, account, create, username, isRemember, options = {}) {
966
969
  if (account === null || account === void 0) {
967
970
  throw new Error("'account' is a required parameter but is null or undefined.");
968
971
  }
@@ -973,7 +976,7 @@ var MezonApi = class {
973
976
  queryParams.set("is_remember", isRemember);
974
977
  let bodyJson = "";
975
978
  bodyJson = JSON.stringify(account || {});
976
- const fullUrl = this.buildFullUrl(basePath, urlPath, queryParams);
979
+ const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
977
980
  const fetchOptions = buildFetchOptions("POST", options, bodyJson);
978
981
  if (basicAuthUsername) {
979
982
  fetchOptions.headers["Authorization"] = "Basic " + encode(basicAuthUsername + ":" + basicAuthPassword);
@@ -7858,16 +7861,15 @@ var Client = class {
7858
7861
  this.refreshTokenPromise = null;
7859
7862
  const scheme = useSSL ? "https://" : "http://";
7860
7863
  const basePath = `${scheme}${host}:${port}`;
7861
- this.apiClient = new MezonApi(serverkey, basePath, timeout);
7864
+ this.apiClient = new MezonApi(serverkey, timeout, basePath);
7862
7865
  }
7863
7866
  /** Authenticate a user with a custom id against the server. */
7864
- authenticateMezon(basePath, token, create, username, isRemember, vars = {}, options = {}) {
7867
+ authenticateMezon(token, create, username, isRemember, vars = {}, options = {}) {
7865
7868
  const request = {
7866
7869
  token,
7867
7870
  vars
7868
7871
  };
7869
7872
  return this.apiClient.authenticateMezon(
7870
- basePath,
7871
7873
  this.serverkey,
7872
7874
  "",
7873
7875
  request,
@@ -7885,7 +7887,7 @@ var Client = class {
7885
7887
  });
7886
7888
  }
7887
7889
  /** Authenticate a user with an email+password against the server. */
7888
- authenticateEmail(basePath, email, password, username, vars) {
7890
+ authenticateEmail(email, password, username, vars) {
7889
7891
  const request = {
7890
7892
  username,
7891
7893
  account: {
@@ -7894,7 +7896,7 @@ var Client = class {
7894
7896
  vars
7895
7897
  }
7896
7898
  };
7897
- return this.apiClient.authenticateEmail(basePath, this.serverkey, "", request, username).then((apiSession) => {
7899
+ return this.apiClient.authenticateEmail(this.serverkey, "", request, username).then((apiSession) => {
7898
7900
  return new Session(
7899
7901
  apiSession.token || "",
7900
7902
  apiSession.refresh_token || "",
@@ -7903,6 +7905,10 @@ var Client = class {
7903
7905
  );
7904
7906
  });
7905
7907
  }
7908
+ /** set base path */
7909
+ setBasePath(basePath) {
7910
+ return this.apiClient.setBasePath(basePath);
7911
+ }
7906
7912
  /** Add users to a channel, or accept their join requests. */
7907
7913
  addChannelUsers(session, channelId, ids) {
7908
7914
  return __async(this, null, function* () {
@@ -9834,10 +9840,9 @@ var Client = class {
9834
9840
  });
9835
9841
  });
9836
9842
  }
9837
- createQRLogin(basePath, requet) {
9843
+ createQRLogin(requet) {
9838
9844
  return __async(this, null, function* () {
9839
9845
  const apiSession = yield this.apiClient.createQRLogin(
9840
- basePath,
9841
9846
  this.serverkey,
9842
9847
  "",
9843
9848
  requet
@@ -9849,10 +9854,9 @@ var Client = class {
9849
9854
  return response;
9850
9855
  });
9851
9856
  }
9852
- checkLoginRequest(basePath, requet) {
9857
+ checkLoginRequest(requet) {
9853
9858
  return __async(this, null, function* () {
9854
9859
  const apiSession = yield this.apiClient.checkLoginRequest(
9855
- basePath,
9856
9860
  this.serverkey,
9857
9861
  "",
9858
9862
  requet
@@ -9868,12 +9872,12 @@ var Client = class {
9868
9872
  );
9869
9873
  });
9870
9874
  }
9871
- confirmLogin(basePath, session, body) {
9875
+ confirmLogin(session, body) {
9872
9876
  return __async(this, null, function* () {
9873
9877
  if (this.autoRefreshSession && session.refresh_token && session.isexpired(Date.now() / 1e3)) {
9874
9878
  yield this.sessionRefresh(session);
9875
9879
  }
9876
- return this.apiClient.confirmLogin(basePath, session.token, body).then((response) => {
9880
+ return this.apiClient.confirmLogin(session.token, body).then((response) => {
9877
9881
  return response;
9878
9882
  });
9879
9883
  });
@@ -694,10 +694,13 @@ function safeJSONParse(jsonStr) {
694
694
 
695
695
  // api.gen.ts
696
696
  var MezonApi = class {
697
- constructor(serverKey, basePath, timeoutMs) {
697
+ constructor(serverKey, timeoutMs, basePath) {
698
698
  this.serverKey = serverKey;
699
- this.basePath = basePath;
700
699
  this.timeoutMs = timeoutMs;
700
+ this.basePath = basePath;
701
+ }
702
+ setBasePath(basePath) {
703
+ this.basePath = basePath;
701
704
  }
702
705
  /** A healthcheck which load balancers can use to check the service. */
703
706
  healthcheck(bearerToken, options = {}) {
@@ -806,7 +809,7 @@ var MezonApi = class {
806
809
  ]);
807
810
  }
808
811
  /** */
809
- checkLoginRequest(basePath, basicAuthUsername, basicAuthPassword, body, options = {}) {
812
+ checkLoginRequest(basicAuthUsername, basicAuthPassword, body, options = {}) {
810
813
  if (body === null || body === void 0) {
811
814
  throw new Error(
812
815
  "'body' is a required parameter but is null or undefined."
@@ -816,7 +819,7 @@ var MezonApi = class {
816
819
  const queryParams = /* @__PURE__ */ new Map();
817
820
  let bodyJson = "";
818
821
  bodyJson = JSON.stringify(body || {});
819
- const fullUrl = this.buildFullUrl(basePath, urlPath, queryParams);
822
+ const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
820
823
  const fetchOptions = buildFetchOptions("POST", options, bodyJson);
821
824
  if (basicAuthUsername) {
822
825
  fetchOptions.headers["Authorization"] = "Basic " + encode(basicAuthUsername + ":" + basicAuthPassword);
@@ -837,7 +840,7 @@ var MezonApi = class {
837
840
  ]);
838
841
  }
839
842
  /** */
840
- confirmLogin(basePath, bearerToken, body, options = {}) {
843
+ confirmLogin(bearerToken, body, options = {}) {
841
844
  if (body === null || body === void 0) {
842
845
  throw new Error(
843
846
  "'body' is a required parameter but is null or undefined."
@@ -847,7 +850,7 @@ var MezonApi = class {
847
850
  const queryParams = /* @__PURE__ */ new Map();
848
851
  let bodyJson = "";
849
852
  bodyJson = JSON.stringify(body || {});
850
- const fullUrl = this.buildFullUrl(basePath, urlPath, queryParams);
853
+ const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
851
854
  const fetchOptions = buildFetchOptions("POST", options, bodyJson);
852
855
  if (bearerToken) {
853
856
  fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
@@ -868,7 +871,7 @@ var MezonApi = class {
868
871
  ]);
869
872
  }
870
873
  /** */
871
- createQRLogin(basePath, basicAuthUsername, basicAuthPassword, body, options = {}) {
874
+ createQRLogin(basicAuthUsername, basicAuthPassword, body, options = {}) {
872
875
  if (body === null || body === void 0) {
873
876
  throw new Error(
874
877
  "'body' is a required parameter but is null or undefined."
@@ -878,7 +881,7 @@ var MezonApi = class {
878
881
  const queryParams = /* @__PURE__ */ new Map();
879
882
  let bodyJson = "";
880
883
  bodyJson = JSON.stringify(body || {});
881
- const fullUrl = this.buildFullUrl(basePath, urlPath, queryParams);
884
+ const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
882
885
  const fetchOptions = buildFetchOptions("POST", options, bodyJson);
883
886
  if (basicAuthUsername) {
884
887
  fetchOptions.headers["Authorization"] = "Basic " + encode(basicAuthUsername + ":" + basicAuthPassword);
@@ -899,7 +902,7 @@ var MezonApi = class {
899
902
  ]);
900
903
  }
901
904
  /** Authenticate a user with an email+password against the server. */
902
- authenticateEmail(basePath, basicAuthUsername, basicAuthPassword, body, options = {}) {
905
+ authenticateEmail(basicAuthUsername, basicAuthPassword, body, options = {}) {
903
906
  if (body === null || body === void 0) {
904
907
  throw new Error("'body' is a required parameter but is null or undefined.");
905
908
  }
@@ -907,7 +910,7 @@ var MezonApi = class {
907
910
  const queryParams = /* @__PURE__ */ new Map();
908
911
  let bodyJson = "";
909
912
  bodyJson = JSON.stringify(body || {});
910
- const fullUrl = this.buildFullUrl(basePath, urlPath, queryParams);
913
+ const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
911
914
  const fetchOptions = buildFetchOptions("POST", options, bodyJson);
912
915
  if (basicAuthUsername) {
913
916
  fetchOptions.headers["Authorization"] = "Basic " + encode(basicAuthUsername + ":" + basicAuthPassword);
@@ -928,7 +931,7 @@ var MezonApi = class {
928
931
  ]);
929
932
  }
930
933
  /** Authenticate a user with Mezon against the server. */
931
- authenticateMezon(basePath, basicAuthUsername, basicAuthPassword, account, create, username, isRemember, options = {}) {
934
+ authenticateMezon(basicAuthUsername, basicAuthPassword, account, create, username, isRemember, options = {}) {
932
935
  if (account === null || account === void 0) {
933
936
  throw new Error("'account' is a required parameter but is null or undefined.");
934
937
  }
@@ -939,7 +942,7 @@ var MezonApi = class {
939
942
  queryParams.set("is_remember", isRemember);
940
943
  let bodyJson = "";
941
944
  bodyJson = JSON.stringify(account || {});
942
- const fullUrl = this.buildFullUrl(basePath, urlPath, queryParams);
945
+ const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
943
946
  const fetchOptions = buildFetchOptions("POST", options, bodyJson);
944
947
  if (basicAuthUsername) {
945
948
  fetchOptions.headers["Authorization"] = "Basic " + encode(basicAuthUsername + ":" + basicAuthPassword);
@@ -7824,16 +7827,15 @@ var Client = class {
7824
7827
  this.refreshTokenPromise = null;
7825
7828
  const scheme = useSSL ? "https://" : "http://";
7826
7829
  const basePath = `${scheme}${host}:${port}`;
7827
- this.apiClient = new MezonApi(serverkey, basePath, timeout);
7830
+ this.apiClient = new MezonApi(serverkey, timeout, basePath);
7828
7831
  }
7829
7832
  /** Authenticate a user with a custom id against the server. */
7830
- authenticateMezon(basePath, token, create, username, isRemember, vars = {}, options = {}) {
7833
+ authenticateMezon(token, create, username, isRemember, vars = {}, options = {}) {
7831
7834
  const request = {
7832
7835
  token,
7833
7836
  vars
7834
7837
  };
7835
7838
  return this.apiClient.authenticateMezon(
7836
- basePath,
7837
7839
  this.serverkey,
7838
7840
  "",
7839
7841
  request,
@@ -7851,7 +7853,7 @@ var Client = class {
7851
7853
  });
7852
7854
  }
7853
7855
  /** Authenticate a user with an email+password against the server. */
7854
- authenticateEmail(basePath, email, password, username, vars) {
7856
+ authenticateEmail(email, password, username, vars) {
7855
7857
  const request = {
7856
7858
  username,
7857
7859
  account: {
@@ -7860,7 +7862,7 @@ var Client = class {
7860
7862
  vars
7861
7863
  }
7862
7864
  };
7863
- return this.apiClient.authenticateEmail(basePath, this.serverkey, "", request, username).then((apiSession) => {
7865
+ return this.apiClient.authenticateEmail(this.serverkey, "", request, username).then((apiSession) => {
7864
7866
  return new Session(
7865
7867
  apiSession.token || "",
7866
7868
  apiSession.refresh_token || "",
@@ -7869,6 +7871,10 @@ var Client = class {
7869
7871
  );
7870
7872
  });
7871
7873
  }
7874
+ /** set base path */
7875
+ setBasePath(basePath) {
7876
+ return this.apiClient.setBasePath(basePath);
7877
+ }
7872
7878
  /** Add users to a channel, or accept their join requests. */
7873
7879
  addChannelUsers(session, channelId, ids) {
7874
7880
  return __async(this, null, function* () {
@@ -9800,10 +9806,9 @@ var Client = class {
9800
9806
  });
9801
9807
  });
9802
9808
  }
9803
- createQRLogin(basePath, requet) {
9809
+ createQRLogin(requet) {
9804
9810
  return __async(this, null, function* () {
9805
9811
  const apiSession = yield this.apiClient.createQRLogin(
9806
- basePath,
9807
9812
  this.serverkey,
9808
9813
  "",
9809
9814
  requet
@@ -9815,10 +9820,9 @@ var Client = class {
9815
9820
  return response;
9816
9821
  });
9817
9822
  }
9818
- checkLoginRequest(basePath, requet) {
9823
+ checkLoginRequest(requet) {
9819
9824
  return __async(this, null, function* () {
9820
9825
  const apiSession = yield this.apiClient.checkLoginRequest(
9821
- basePath,
9822
9826
  this.serverkey,
9823
9827
  "",
9824
9828
  requet
@@ -9834,12 +9838,12 @@ var Client = class {
9834
9838
  );
9835
9839
  });
9836
9840
  }
9837
- confirmLogin(basePath, session, body) {
9841
+ confirmLogin(session, body) {
9838
9842
  return __async(this, null, function* () {
9839
9843
  if (this.autoRefreshSession && session.refresh_token && session.isexpired(Date.now() / 1e3)) {
9840
9844
  yield this.sessionRefresh(session);
9841
9845
  }
9842
- return this.apiClient.confirmLogin(basePath, session.token, body).then((response) => {
9846
+ return this.apiClient.confirmLogin(session.token, body).then((response) => {
9843
9847
  return response;
9844
9848
  });
9845
9849
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mezon-js",
3
3
 
4
- "version": "2.12.2",
4
+ "version": "2.12.3",
5
5
 
6
6
  "scripts": {
7
7
  "build": "npx tsc && npx rollup -c --bundleConfigAsCjs && node build.mjs"