mezon-js 2.12.1 → 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 +16 -13
- package/client.ts +10 -11
- package/dist/api.gen.d.ts +9 -7
- package/dist/client.d.ts +7 -5
- package/dist/mezon-js.cjs.js +27 -23
- package/dist/mezon-js.esm.mjs +27 -23
- package/dist/session.d.ts +1 -0
- package/package.json +1 -1
- package/session.ts +1 -0
package/api.gen.ts
CHANGED
@@ -2326,6 +2326,7 @@ export interface ApiSession {
|
|
2326
2326
|
token?: string;
|
2327
2327
|
// Whether to enable "Remember Me" for extended session duration.
|
2328
2328
|
is_remember?: boolean;
|
2329
|
+
api_url?: string;
|
2329
2330
|
}
|
2330
2331
|
|
2331
2332
|
/** Log out a session, invalidate a refresh token, or log out all sessions/refresh tokens for a user. */
|
@@ -3156,11 +3157,18 @@ export interface ApiUserEventRequest {
|
|
3156
3157
|
}
|
3157
3158
|
|
3158
3159
|
export class MezonApi {
|
3160
|
+
basePath: string;
|
3159
3161
|
constructor(
|
3160
3162
|
readonly serverKey: string,
|
3161
|
-
readonly
|
3162
|
-
|
3163
|
-
) {
|
3163
|
+
readonly timeoutMs: number,
|
3164
|
+
basePath: string,
|
3165
|
+
) {
|
3166
|
+
this.basePath = basePath
|
3167
|
+
}
|
3168
|
+
|
3169
|
+
setBasePath(basePath: string) {
|
3170
|
+
this.basePath = basePath;
|
3171
|
+
}
|
3164
3172
|
|
3165
3173
|
/** A healthcheck which load balancers can use to check the service. */
|
3166
3174
|
healthcheck(bearerToken: string, options: any = {}): Promise<any> {
|
@@ -3290,7 +3298,6 @@ export class MezonApi {
|
|
3290
3298
|
|
3291
3299
|
/** */
|
3292
3300
|
checkLoginRequest(
|
3293
|
-
basePath: string,
|
3294
3301
|
basicAuthUsername: string,
|
3295
3302
|
basicAuthPassword: string,
|
3296
3303
|
body: ApiConfirmLoginRequest,
|
@@ -3307,7 +3314,7 @@ export class MezonApi {
|
|
3307
3314
|
let bodyJson: string = "";
|
3308
3315
|
bodyJson = JSON.stringify(body || {});
|
3309
3316
|
|
3310
|
-
const fullUrl = this.buildFullUrl(basePath, urlPath, queryParams);
|
3317
|
+
const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
|
3311
3318
|
const fetchOptions = buildFetchOptions("POST", options, bodyJson);
|
3312
3319
|
if (basicAuthUsername) {
|
3313
3320
|
fetchOptions.headers["Authorization"] =
|
@@ -3332,7 +3339,6 @@ export class MezonApi {
|
|
3332
3339
|
|
3333
3340
|
/** */
|
3334
3341
|
confirmLogin(
|
3335
|
-
basePath: string,
|
3336
3342
|
bearerToken: string,
|
3337
3343
|
body: ApiConfirmLoginRequest,
|
3338
3344
|
options: any = {}
|
@@ -3348,7 +3354,7 @@ export class MezonApi {
|
|
3348
3354
|
let bodyJson: string = "";
|
3349
3355
|
bodyJson = JSON.stringify(body || {});
|
3350
3356
|
|
3351
|
-
const fullUrl = this.buildFullUrl(basePath, urlPath, queryParams);
|
3357
|
+
const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
|
3352
3358
|
const fetchOptions = buildFetchOptions("POST", options, bodyJson);
|
3353
3359
|
if (bearerToken) {
|
3354
3360
|
fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
|
@@ -3372,7 +3378,6 @@ export class MezonApi {
|
|
3372
3378
|
|
3373
3379
|
/** */
|
3374
3380
|
createQRLogin(
|
3375
|
-
basePath: string,
|
3376
3381
|
basicAuthUsername: string,
|
3377
3382
|
basicAuthPassword: string,
|
3378
3383
|
body: ApiLoginRequest,
|
@@ -3389,7 +3394,7 @@ export class MezonApi {
|
|
3389
3394
|
let bodyJson: string = "";
|
3390
3395
|
bodyJson = JSON.stringify(body || {});
|
3391
3396
|
|
3392
|
-
const fullUrl = this.buildFullUrl(basePath, urlPath, queryParams);
|
3397
|
+
const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
|
3393
3398
|
const fetchOptions = buildFetchOptions("POST", options, bodyJson);
|
3394
3399
|
if (basicAuthUsername) {
|
3395
3400
|
fetchOptions.headers["Authorization"] =
|
@@ -3415,7 +3420,6 @@ export class MezonApi {
|
|
3415
3420
|
|
3416
3421
|
/** Authenticate a user with an email+password against the server. */
|
3417
3422
|
authenticateEmail(
|
3418
|
-
basePath: string,
|
3419
3423
|
basicAuthUsername: string,
|
3420
3424
|
basicAuthPassword: string,
|
3421
3425
|
body:ApiAuthenticateEmailRequest,
|
@@ -3430,7 +3434,7 @@ export class MezonApi {
|
|
3430
3434
|
let bodyJson : string = "";
|
3431
3435
|
bodyJson = JSON.stringify(body || {});
|
3432
3436
|
|
3433
|
-
const fullUrl = this.buildFullUrl(basePath, urlPath, queryParams);
|
3437
|
+
const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
|
3434
3438
|
const fetchOptions = buildFetchOptions("POST", options, bodyJson);
|
3435
3439
|
if (basicAuthUsername) {
|
3436
3440
|
fetchOptions.headers["Authorization"] = "Basic " + encode(basicAuthUsername + ":" + basicAuthPassword);
|
@@ -3454,7 +3458,6 @@ export class MezonApi {
|
|
3454
3458
|
|
3455
3459
|
/** Authenticate a user with Mezon against the server. */
|
3456
3460
|
authenticateMezon(
|
3457
|
-
basePath: string,
|
3458
3461
|
basicAuthUsername: string,
|
3459
3462
|
basicAuthPassword: string,
|
3460
3463
|
account:ApiAccountMezon,
|
@@ -3476,7 +3479,7 @@ export class MezonApi {
|
|
3476
3479
|
let bodyJson : string = "";
|
3477
3480
|
bodyJson = JSON.stringify(account || {});
|
3478
3481
|
|
3479
|
-
const fullUrl = this.buildFullUrl(basePath, urlPath, queryParams);
|
3482
|
+
const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
|
3480
3483
|
const fetchOptions = buildFetchOptions("POST", options, bodyJson);
|
3481
3484
|
if (basicAuthUsername) {
|
3482
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,
|
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(
|
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(
|
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(
|
3952
|
+
.confirmLogin(session.token, body)
|
3954
3953
|
.then((response: any) => {
|
3955
3954
|
return response;
|
3956
3955
|
});
|
package/dist/api.gen.d.ts
CHANGED
@@ -1330,6 +1330,7 @@ export interface ApiSession {
|
|
1330
1330
|
refresh_token?: string;
|
1331
1331
|
token?: string;
|
1332
1332
|
is_remember?: boolean;
|
1333
|
+
api_url?: string;
|
1333
1334
|
}
|
1334
1335
|
/** Log out a session, invalidate a refresh token, or log out all sessions/refresh tokens for a user. */
|
1335
1336
|
export interface ApiSessionLogoutRequest {
|
@@ -1808,9 +1809,10 @@ export interface ApiUserEventRequest {
|
|
1808
1809
|
}
|
1809
1810
|
export declare class MezonApi {
|
1810
1811
|
readonly serverKey: string;
|
1811
|
-
readonly basePath: string;
|
1812
1812
|
readonly timeoutMs: number;
|
1813
|
-
|
1813
|
+
basePath: string;
|
1814
|
+
constructor(serverKey: string, timeoutMs: number, basePath: string);
|
1815
|
+
setBasePath(basePath: string): void;
|
1814
1816
|
/** A healthcheck which load balancers can use to check the service. */
|
1815
1817
|
healthcheck(bearerToken: string, options?: any): Promise<any>;
|
1816
1818
|
/** Delete the current user's account. */
|
@@ -1820,15 +1822,15 @@ export declare class MezonApi {
|
|
1820
1822
|
/** Update fields in the current user's account. */
|
1821
1823
|
updateAccount(bearerToken: string, body: ApiUpdateAccountRequest, options?: any): Promise<any>;
|
1822
1824
|
/** */
|
1823
|
-
checkLoginRequest(
|
1825
|
+
checkLoginRequest(basicAuthUsername: string, basicAuthPassword: string, body: ApiConfirmLoginRequest, options?: any): Promise<ApiSession>;
|
1824
1826
|
/** */
|
1825
|
-
confirmLogin(
|
1827
|
+
confirmLogin(bearerToken: string, body: ApiConfirmLoginRequest, options?: any): Promise<any>;
|
1826
1828
|
/** */
|
1827
|
-
createQRLogin(
|
1829
|
+
createQRLogin(basicAuthUsername: string, basicAuthPassword: string, body: ApiLoginRequest, options?: any): Promise<ApiLoginIDResponse>;
|
1828
1830
|
/** Authenticate a user with an email+password against the server. */
|
1829
|
-
authenticateEmail(
|
1831
|
+
authenticateEmail(basicAuthUsername: string, basicAuthPassword: string, body: ApiAuthenticateEmailRequest, options?: any): Promise<ApiSession>;
|
1830
1832
|
/** Authenticate a user with Mezon against the server. */
|
1831
|
-
authenticateMezon(
|
1833
|
+
authenticateMezon(basicAuthUsername: string, basicAuthPassword: string, account: ApiAccountMezon, create?: boolean, username?: string, isRemember?: boolean, options?: any): Promise<ApiSession>;
|
1832
1834
|
/** Add an email+password to the social profiles on the current user's account. */
|
1833
1835
|
linkEmail(bearerToken: string, body: ApiAccountEmail, options?: any): Promise<any>;
|
1834
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(
|
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(
|
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(
|
576
|
-
checkLoginRequest(
|
577
|
-
confirmLogin(
|
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>;
|
package/dist/mezon-js.cjs.js
CHANGED
@@ -728,10 +728,13 @@ function safeJSONParse(jsonStr) {
|
|
728
728
|
|
729
729
|
// api.gen.ts
|
730
730
|
var MezonApi = class {
|
731
|
-
constructor(serverKey,
|
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(
|
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(
|
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(
|
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(
|
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(
|
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,
|
7864
|
+
this.apiClient = new MezonApi(serverkey, timeout, basePath);
|
7862
7865
|
}
|
7863
7866
|
/** Authenticate a user with a custom id against the server. */
|
7864
|
-
authenticateMezon(
|
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(
|
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(
|
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(
|
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(
|
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(
|
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(
|
9880
|
+
return this.apiClient.confirmLogin(session.token, body).then((response) => {
|
9877
9881
|
return response;
|
9878
9882
|
});
|
9879
9883
|
});
|
package/dist/mezon-js.esm.mjs
CHANGED
@@ -694,10 +694,13 @@ function safeJSONParse(jsonStr) {
|
|
694
694
|
|
695
695
|
// api.gen.ts
|
696
696
|
var MezonApi = class {
|
697
|
-
constructor(serverKey,
|
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(
|
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(
|
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(
|
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(
|
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(
|
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,
|
7830
|
+
this.apiClient = new MezonApi(serverkey, timeout, basePath);
|
7828
7831
|
}
|
7829
7832
|
/** Authenticate a user with a custom id against the server. */
|
7830
|
-
authenticateMezon(
|
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(
|
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(
|
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(
|
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(
|
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(
|
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(
|
9846
|
+
return this.apiClient.confirmLogin(session.token, body).then((response) => {
|
9843
9847
|
return response;
|
9844
9848
|
});
|
9845
9849
|
});
|
package/dist/session.d.ts
CHANGED
@@ -51,6 +51,7 @@ export declare class Session implements ISession {
|
|
51
51
|
user_id?: string;
|
52
52
|
vars?: object;
|
53
53
|
is_remember?: boolean;
|
54
|
+
api_url?: string;
|
54
55
|
constructor(token: string, refresh_token: string, created: boolean, is_remember: boolean);
|
55
56
|
isexpired(currenttime: number): boolean;
|
56
57
|
isrefreshexpired(currenttime: number): boolean;
|
package/package.json
CHANGED