mezon-js 2.12.3 → 2.12.5
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 +21 -6
- package/dist/client.d.ts +4 -4
- package/dist/mezon-js.cjs.js +16 -7
- package/dist/mezon-js.esm.mjs +16 -7
- package/dist/session.d.ts +3 -3
- package/package.json +1 -1
- package/session.ts +3 -3
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
|
-
|
568
|
-
|
569
|
-
|
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
|
|
@@ -604,6 +610,7 @@ export class Client {
|
|
604
610
|
apiSession.token || "",
|
605
611
|
apiSession.refresh_token || "",
|
606
612
|
apiSession.created || false,
|
613
|
+
apiSession.api_url || "",
|
607
614
|
false
|
608
615
|
);
|
609
616
|
});
|
@@ -631,14 +638,21 @@ export class Client {
|
|
631
638
|
return new Session(
|
632
639
|
apiSession.token || "",
|
633
640
|
apiSession.refresh_token || "",
|
634
|
-
apiSession.created || false,
|
635
|
-
|
641
|
+
apiSession.created || false,
|
642
|
+
apiSession.api_url || "",
|
643
|
+
false,
|
636
644
|
);
|
637
645
|
});
|
638
646
|
}
|
639
647
|
|
640
648
|
/** set base path */
|
641
|
-
setBasePath(
|
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}`;
|
642
656
|
return this.apiClient
|
643
657
|
.setBasePath(basePath);
|
644
658
|
}
|
@@ -3932,6 +3946,7 @@ export class Client {
|
|
3932
3946
|
apiSession.token || "",
|
3933
3947
|
apiSession.refresh_token || "",
|
3934
3948
|
apiSession.created || false,
|
3949
|
+
apiSession.api_url || "",
|
3935
3950
|
apiSession.is_remember || false
|
3936
3951
|
);
|
3937
3952
|
}
|
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(
|
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. */
|
package/dist/mezon-js.cjs.js
CHANGED
@@ -6664,8 +6664,9 @@ var MezonApi = class {
|
|
6664
6664
|
|
6665
6665
|
// session.ts
|
6666
6666
|
var Session = class _Session {
|
6667
|
-
constructor(token, refresh_token, created, is_remember) {
|
6667
|
+
constructor(token, refresh_token, created, api_url, is_remember) {
|
6668
6668
|
this.created = created;
|
6669
|
+
this.api_url = api_url;
|
6669
6670
|
this.token = token;
|
6670
6671
|
this.refresh_token = refresh_token;
|
6671
6672
|
this.created_at = Math.floor((/* @__PURE__ */ new Date()).getTime() / 1e3);
|
@@ -6702,8 +6703,8 @@ var Session = class _Session {
|
|
6702
6703
|
this.user_id = tokenDecoded["uid"];
|
6703
6704
|
this.vars = tokenDecoded["vrs"];
|
6704
6705
|
}
|
6705
|
-
static restore(token, refreshToken, isRemember) {
|
6706
|
-
return new _Session(token, refreshToken, false, isRemember);
|
6706
|
+
static restore(token, refreshToken, api_url, isRemember) {
|
6707
|
+
return new _Session(token, refreshToken, false, api_url, isRemember);
|
6707
6708
|
}
|
6708
6709
|
};
|
6709
6710
|
|
@@ -7852,13 +7853,13 @@ var WebrtcSignalingType = /* @__PURE__ */ ((WebrtcSignalingType2) => {
|
|
7852
7853
|
var Client = class {
|
7853
7854
|
constructor(serverkey = DEFAULT_SERVER_KEY, host = DEFAULT_HOST, port = DEFAULT_PORT, useSSL = false, timeout = DEFAULT_TIMEOUT_MS, autoRefreshSession = true) {
|
7854
7855
|
this.serverkey = serverkey;
|
7855
|
-
this.host = host;
|
7856
|
-
this.port = port;
|
7857
|
-
this.useSSL = useSSL;
|
7858
7856
|
this.timeout = timeout;
|
7859
7857
|
this.autoRefreshSession = autoRefreshSession;
|
7860
7858
|
/** thre refreshTokenPromise */
|
7861
7859
|
this.refreshTokenPromise = null;
|
7860
|
+
this.host = host;
|
7861
|
+
this.port = port;
|
7862
|
+
this.useSSL = useSSL;
|
7862
7863
|
const scheme = useSSL ? "https://" : "http://";
|
7863
7864
|
const basePath = `${scheme}${host}:${port}`;
|
7864
7865
|
this.apiClient = new MezonApi(serverkey, timeout, basePath);
|
@@ -7882,6 +7883,7 @@ var Client = class {
|
|
7882
7883
|
apiSession.token || "",
|
7883
7884
|
apiSession.refresh_token || "",
|
7884
7885
|
apiSession.created || false,
|
7886
|
+
apiSession.api_url || "",
|
7885
7887
|
false
|
7886
7888
|
);
|
7887
7889
|
});
|
@@ -7901,12 +7903,18 @@ var Client = class {
|
|
7901
7903
|
apiSession.token || "",
|
7902
7904
|
apiSession.refresh_token || "",
|
7903
7905
|
apiSession.created || false,
|
7906
|
+
apiSession.api_url || "",
|
7904
7907
|
false
|
7905
7908
|
);
|
7906
7909
|
});
|
7907
7910
|
}
|
7908
7911
|
/** set base path */
|
7909
|
-
setBasePath(
|
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}`;
|
7910
7918
|
return this.apiClient.setBasePath(basePath);
|
7911
7919
|
}
|
7912
7920
|
/** Add users to a channel, or accept their join requests. */
|
@@ -9868,6 +9876,7 @@ var Client = class {
|
|
9868
9876
|
apiSession.token || "",
|
9869
9877
|
apiSession.refresh_token || "",
|
9870
9878
|
apiSession.created || false,
|
9879
|
+
apiSession.api_url || "",
|
9871
9880
|
apiSession.is_remember || false
|
9872
9881
|
);
|
9873
9882
|
});
|
package/dist/mezon-js.esm.mjs
CHANGED
@@ -6630,8 +6630,9 @@ var MezonApi = class {
|
|
6630
6630
|
|
6631
6631
|
// session.ts
|
6632
6632
|
var Session = class _Session {
|
6633
|
-
constructor(token, refresh_token, created, is_remember) {
|
6633
|
+
constructor(token, refresh_token, created, api_url, is_remember) {
|
6634
6634
|
this.created = created;
|
6635
|
+
this.api_url = api_url;
|
6635
6636
|
this.token = token;
|
6636
6637
|
this.refresh_token = refresh_token;
|
6637
6638
|
this.created_at = Math.floor((/* @__PURE__ */ new Date()).getTime() / 1e3);
|
@@ -6668,8 +6669,8 @@ var Session = class _Session {
|
|
6668
6669
|
this.user_id = tokenDecoded["uid"];
|
6669
6670
|
this.vars = tokenDecoded["vrs"];
|
6670
6671
|
}
|
6671
|
-
static restore(token, refreshToken, isRemember) {
|
6672
|
-
return new _Session(token, refreshToken, false, isRemember);
|
6672
|
+
static restore(token, refreshToken, api_url, isRemember) {
|
6673
|
+
return new _Session(token, refreshToken, false, api_url, isRemember);
|
6673
6674
|
}
|
6674
6675
|
};
|
6675
6676
|
|
@@ -7818,13 +7819,13 @@ var WebrtcSignalingType = /* @__PURE__ */ ((WebrtcSignalingType2) => {
|
|
7818
7819
|
var Client = class {
|
7819
7820
|
constructor(serverkey = DEFAULT_SERVER_KEY, host = DEFAULT_HOST, port = DEFAULT_PORT, useSSL = false, timeout = DEFAULT_TIMEOUT_MS, autoRefreshSession = true) {
|
7820
7821
|
this.serverkey = serverkey;
|
7821
|
-
this.host = host;
|
7822
|
-
this.port = port;
|
7823
|
-
this.useSSL = useSSL;
|
7824
7822
|
this.timeout = timeout;
|
7825
7823
|
this.autoRefreshSession = autoRefreshSession;
|
7826
7824
|
/** thre refreshTokenPromise */
|
7827
7825
|
this.refreshTokenPromise = null;
|
7826
|
+
this.host = host;
|
7827
|
+
this.port = port;
|
7828
|
+
this.useSSL = useSSL;
|
7828
7829
|
const scheme = useSSL ? "https://" : "http://";
|
7829
7830
|
const basePath = `${scheme}${host}:${port}`;
|
7830
7831
|
this.apiClient = new MezonApi(serverkey, timeout, basePath);
|
@@ -7848,6 +7849,7 @@ var Client = class {
|
|
7848
7849
|
apiSession.token || "",
|
7849
7850
|
apiSession.refresh_token || "",
|
7850
7851
|
apiSession.created || false,
|
7852
|
+
apiSession.api_url || "",
|
7851
7853
|
false
|
7852
7854
|
);
|
7853
7855
|
});
|
@@ -7867,12 +7869,18 @@ var Client = class {
|
|
7867
7869
|
apiSession.token || "",
|
7868
7870
|
apiSession.refresh_token || "",
|
7869
7871
|
apiSession.created || false,
|
7872
|
+
apiSession.api_url || "",
|
7870
7873
|
false
|
7871
7874
|
);
|
7872
7875
|
});
|
7873
7876
|
}
|
7874
7877
|
/** set base path */
|
7875
|
-
setBasePath(
|
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}`;
|
7876
7884
|
return this.apiClient.setBasePath(basePath);
|
7877
7885
|
}
|
7878
7886
|
/** Add users to a channel, or accept their join requests. */
|
@@ -9834,6 +9842,7 @@ var Client = class {
|
|
9834
9842
|
apiSession.token || "",
|
9835
9843
|
apiSession.refresh_token || "",
|
9836
9844
|
apiSession.created || false,
|
9845
|
+
apiSession.api_url || "",
|
9837
9846
|
apiSession.is_remember || false
|
9838
9847
|
);
|
9839
9848
|
});
|
package/dist/session.d.ts
CHANGED
@@ -42,6 +42,7 @@ export interface ISession {
|
|
42
42
|
}
|
43
43
|
export declare class Session implements ISession {
|
44
44
|
readonly created: boolean;
|
45
|
+
readonly api_url: string;
|
45
46
|
token: string;
|
46
47
|
readonly created_at: number;
|
47
48
|
expires_at?: number;
|
@@ -51,10 +52,9 @@ export declare class Session implements ISession {
|
|
51
52
|
user_id?: string;
|
52
53
|
vars?: object;
|
53
54
|
is_remember?: boolean;
|
54
|
-
api_url
|
55
|
-
constructor(token: string, refresh_token: string, created: boolean, is_remember: boolean);
|
55
|
+
constructor(token: string, refresh_token: string, created: boolean, api_url: string, is_remember: boolean);
|
56
56
|
isexpired(currenttime: number): boolean;
|
57
57
|
isrefreshexpired(currenttime: number): boolean;
|
58
58
|
update(token: string, refreshToken: string, isRemember: boolean): void;
|
59
|
-
static restore(token: string, refreshToken: string, isRemember: boolean): Session;
|
59
|
+
static restore(token: string, refreshToken: string, api_url: string, isRemember: boolean): Session;
|
60
60
|
}
|
package/package.json
CHANGED
package/session.ts
CHANGED
@@ -57,12 +57,12 @@ export class Session implements ISession {
|
|
57
57
|
user_id?: string;
|
58
58
|
vars?: object;
|
59
59
|
is_remember?: boolean;
|
60
|
-
api_url?: string;
|
61
60
|
|
62
61
|
constructor(
|
63
62
|
token: string,
|
64
63
|
refresh_token: string,
|
65
64
|
readonly created: boolean,
|
65
|
+
readonly api_url: string,
|
66
66
|
is_remember: boolean) {
|
67
67
|
this.token = token;
|
68
68
|
this.refresh_token = refresh_token;
|
@@ -113,7 +113,7 @@ export class Session implements ISession {
|
|
113
113
|
this.vars = tokenDecoded['vrs'];
|
114
114
|
}
|
115
115
|
|
116
|
-
static restore(token: string, refreshToken: string, isRemember: boolean): Session {
|
117
|
-
return new Session(token, refreshToken, false, isRemember);
|
116
|
+
static restore(token: string, refreshToken: string, api_url: string, isRemember: boolean): Session {
|
117
|
+
return new Session(token, refreshToken, false, api_url, isRemember);
|
118
118
|
}
|
119
119
|
}
|