mezon-js 2.10.98 → 2.10.99
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 +29 -7
- package/dist/client.d.ts +3 -1
- package/dist/mezon-js.cjs.js +27 -8
- package/dist/mezon-js.esm.mjs +27 -8
- package/package.json +1 -1
package/client.ts
CHANGED
@@ -561,6 +561,9 @@ export class Client {
|
|
561
561
|
/** The low level API client for Mezon server. */
|
562
562
|
private readonly apiClient: MezonApi;
|
563
563
|
|
564
|
+
/** thre refreshTokenPromise */
|
565
|
+
private refreshTokenPromise: Promise<Session> | null = null;
|
566
|
+
|
564
567
|
constructor(
|
565
568
|
readonly serverkey = DEFAULT_SERVER_KEY,
|
566
569
|
readonly host = DEFAULT_HOST,
|
@@ -2404,12 +2407,31 @@ export class Client {
|
|
2404
2407
|
);
|
2405
2408
|
}
|
2406
2409
|
|
2407
|
-
|
2408
|
-
|
2409
|
-
|
2410
|
+
if (this.refreshTokenPromise) {
|
2411
|
+
return this.refreshTokenPromise; // Reuse existing promise
|
2412
|
+
}
|
2413
|
+
|
2414
|
+
this.refreshTokenPromise = new Promise<Session>(async (resolve, reject) => {
|
2415
|
+
try {
|
2416
|
+
const apiSession = await this.apiClient.sessionRefresh(
|
2417
|
+
this.serverkey,
|
2418
|
+
"",
|
2419
|
+
{
|
2420
|
+
token: session.refresh_token,
|
2421
|
+
vars: vars,
|
2422
|
+
}
|
2423
|
+
);
|
2424
|
+
session.update(apiSession.token!, apiSession.refresh_token!);
|
2425
|
+
this.refreshTokenPromise = null; // Reset the promise
|
2426
|
+
resolve(session);
|
2427
|
+
} catch (error) {
|
2428
|
+
console.error("Session refresh failed:", error);
|
2429
|
+
this.refreshTokenPromise = null; // Reset promise on error
|
2430
|
+
reject(error);
|
2431
|
+
}
|
2410
2432
|
});
|
2411
|
-
|
2412
|
-
return
|
2433
|
+
|
2434
|
+
return this.refreshTokenPromise;
|
2413
2435
|
}
|
2414
2436
|
|
2415
2437
|
/** Remove the Apple ID from the social profiles on the current user's account. */
|
@@ -4134,7 +4156,7 @@ export class Client {
|
|
4134
4156
|
type?: number,
|
4135
4157
|
limit?: number,
|
4136
4158
|
page?: number,
|
4137
|
-
|
4159
|
+
channelLabel?: string
|
4138
4160
|
): Promise<ApiChannelSettingListResponse> {
|
4139
4161
|
if (
|
4140
4162
|
this.autoRefreshSession &&
|
@@ -4156,7 +4178,7 @@ export class Client {
|
|
4156
4178
|
type,
|
4157
4179
|
limit,
|
4158
4180
|
page,
|
4159
|
-
|
4181
|
+
channelLabel
|
4160
4182
|
)
|
4161
4183
|
.then((response: any) => {
|
4162
4184
|
return Promise.resolve(response);
|
package/dist/client.d.ts
CHANGED
@@ -347,6 +347,8 @@ export declare class Client {
|
|
347
347
|
expiredTimespanMs: number;
|
348
348
|
/** The low level API client for Mezon server. */
|
349
349
|
private readonly apiClient;
|
350
|
+
/** thre refreshTokenPromise */
|
351
|
+
private refreshTokenPromise;
|
350
352
|
constructor(serverkey?: string, host?: string, port?: string, useSSL?: boolean, timeout?: number, autoRefreshSession?: boolean);
|
351
353
|
/** Add users to a channel, or accept their join requests. */
|
352
354
|
addChannelUsers(session: Session, channelId: string, ids?: Array<string>): Promise<boolean>;
|
@@ -600,7 +602,7 @@ export declare class Client {
|
|
600
602
|
/** List Threads. */
|
601
603
|
listThreadDescs(session: Session, channelId: string, limit?: number, state?: number, clanId?: string, threadId?: string, page?: number): Promise<ApiChannelDescList>;
|
602
604
|
leaveThread(session: Session, channelId: string): Promise<any>;
|
603
|
-
getChannelSettingInClan(session: Session, clanId: string, parentId?: string, categoryId?: string, privateChannel?: number, active?: number, status?: number, type?: number, limit?: number, page?: number,
|
605
|
+
getChannelSettingInClan(session: Session, clanId: string, parentId?: string, categoryId?: string, privateChannel?: number, active?: number, status?: number, type?: number, limit?: number, page?: number, channelLabel?: string): Promise<ApiChannelSettingListResponse>;
|
604
606
|
getChannelCanvasList(session: Session, channelId: string, clanId?: string, limit?: number, page?: number): Promise<ApiChannelCanvasListResponse>;
|
605
607
|
getChannelCanvasDetail(session: Session, id: string, clanId?: string, channelId?: string): Promise<any>;
|
606
608
|
editChannelCanvases(session: Session, request: ApiEditChannelCanvasRequest): Promise<any>;
|
package/dist/mezon-js.cjs.js
CHANGED
@@ -8352,6 +8352,8 @@ var Client = class {
|
|
8352
8352
|
this.autoRefreshSession = autoRefreshSession;
|
8353
8353
|
/** The expired timespan used to check session lifetime. */
|
8354
8354
|
this.expiredTimespanMs = DEFAULT_EXPIRED_TIMESPAN_MS;
|
8355
|
+
/** thre refreshTokenPromise */
|
8356
|
+
this.refreshTokenPromise = null;
|
8355
8357
|
const scheme = useSSL ? "https://" : "http://";
|
8356
8358
|
const basePath = `${scheme}${host}:${port}`;
|
8357
8359
|
this.apiClient = new MezonApi(serverkey, basePath, timeout);
|
@@ -9506,12 +9508,29 @@ var Client = class {
|
|
9506
9508
|
"Session refresh lifetime too short, please set '--session.refresh_token_expiry_sec' option. See the documentation for more info: https://mezon.vn/docs/mezon/getting-started/configuration/#session"
|
9507
9509
|
);
|
9508
9510
|
}
|
9509
|
-
|
9510
|
-
|
9511
|
-
|
9512
|
-
|
9513
|
-
|
9514
|
-
|
9511
|
+
if (this.refreshTokenPromise) {
|
9512
|
+
return this.refreshTokenPromise;
|
9513
|
+
}
|
9514
|
+
this.refreshTokenPromise = new Promise((resolve, reject) => __async(this, null, function* () {
|
9515
|
+
try {
|
9516
|
+
const apiSession = yield this.apiClient.sessionRefresh(
|
9517
|
+
this.serverkey,
|
9518
|
+
"",
|
9519
|
+
{
|
9520
|
+
token: session.refresh_token,
|
9521
|
+
vars
|
9522
|
+
}
|
9523
|
+
);
|
9524
|
+
session.update(apiSession.token, apiSession.refresh_token);
|
9525
|
+
this.refreshTokenPromise = null;
|
9526
|
+
resolve(session);
|
9527
|
+
} catch (error) {
|
9528
|
+
console.error("Session refresh failed:", error);
|
9529
|
+
this.refreshTokenPromise = null;
|
9530
|
+
reject(error);
|
9531
|
+
}
|
9532
|
+
}));
|
9533
|
+
return this.refreshTokenPromise;
|
9515
9534
|
});
|
9516
9535
|
}
|
9517
9536
|
/** Remove the Apple ID from the social profiles on the current user's account. */
|
@@ -10469,7 +10488,7 @@ var Client = class {
|
|
10469
10488
|
});
|
10470
10489
|
});
|
10471
10490
|
}
|
10472
|
-
getChannelSettingInClan(session, clanId, parentId, categoryId, privateChannel, active, status, type, limit, page,
|
10491
|
+
getChannelSettingInClan(session, clanId, parentId, categoryId, privateChannel, active, status, type, limit, page, channelLabel) {
|
10473
10492
|
return __async(this, null, function* () {
|
10474
10493
|
if (this.autoRefreshSession && session.refresh_token && session.isexpired((Date.now() + this.expiredTimespanMs) / 1e3)) {
|
10475
10494
|
yield this.sessionRefresh(session);
|
@@ -10485,7 +10504,7 @@ var Client = class {
|
|
10485
10504
|
type,
|
10486
10505
|
limit,
|
10487
10506
|
page,
|
10488
|
-
|
10507
|
+
channelLabel
|
10489
10508
|
).then((response) => {
|
10490
10509
|
return Promise.resolve(response);
|
10491
10510
|
});
|
package/dist/mezon-js.esm.mjs
CHANGED
@@ -8318,6 +8318,8 @@ var Client = class {
|
|
8318
8318
|
this.autoRefreshSession = autoRefreshSession;
|
8319
8319
|
/** The expired timespan used to check session lifetime. */
|
8320
8320
|
this.expiredTimespanMs = DEFAULT_EXPIRED_TIMESPAN_MS;
|
8321
|
+
/** thre refreshTokenPromise */
|
8322
|
+
this.refreshTokenPromise = null;
|
8321
8323
|
const scheme = useSSL ? "https://" : "http://";
|
8322
8324
|
const basePath = `${scheme}${host}:${port}`;
|
8323
8325
|
this.apiClient = new MezonApi(serverkey, basePath, timeout);
|
@@ -9472,12 +9474,29 @@ var Client = class {
|
|
9472
9474
|
"Session refresh lifetime too short, please set '--session.refresh_token_expiry_sec' option. See the documentation for more info: https://mezon.vn/docs/mezon/getting-started/configuration/#session"
|
9473
9475
|
);
|
9474
9476
|
}
|
9475
|
-
|
9476
|
-
|
9477
|
-
|
9478
|
-
|
9479
|
-
|
9480
|
-
|
9477
|
+
if (this.refreshTokenPromise) {
|
9478
|
+
return this.refreshTokenPromise;
|
9479
|
+
}
|
9480
|
+
this.refreshTokenPromise = new Promise((resolve, reject) => __async(this, null, function* () {
|
9481
|
+
try {
|
9482
|
+
const apiSession = yield this.apiClient.sessionRefresh(
|
9483
|
+
this.serverkey,
|
9484
|
+
"",
|
9485
|
+
{
|
9486
|
+
token: session.refresh_token,
|
9487
|
+
vars
|
9488
|
+
}
|
9489
|
+
);
|
9490
|
+
session.update(apiSession.token, apiSession.refresh_token);
|
9491
|
+
this.refreshTokenPromise = null;
|
9492
|
+
resolve(session);
|
9493
|
+
} catch (error) {
|
9494
|
+
console.error("Session refresh failed:", error);
|
9495
|
+
this.refreshTokenPromise = null;
|
9496
|
+
reject(error);
|
9497
|
+
}
|
9498
|
+
}));
|
9499
|
+
return this.refreshTokenPromise;
|
9481
9500
|
});
|
9482
9501
|
}
|
9483
9502
|
/** Remove the Apple ID from the social profiles on the current user's account. */
|
@@ -10435,7 +10454,7 @@ var Client = class {
|
|
10435
10454
|
});
|
10436
10455
|
});
|
10437
10456
|
}
|
10438
|
-
getChannelSettingInClan(session, clanId, parentId, categoryId, privateChannel, active, status, type, limit, page,
|
10457
|
+
getChannelSettingInClan(session, clanId, parentId, categoryId, privateChannel, active, status, type, limit, page, channelLabel) {
|
10439
10458
|
return __async(this, null, function* () {
|
10440
10459
|
if (this.autoRefreshSession && session.refresh_token && session.isexpired((Date.now() + this.expiredTimespanMs) / 1e3)) {
|
10441
10460
|
yield this.sessionRefresh(session);
|
@@ -10451,7 +10470,7 @@ var Client = class {
|
|
10451
10470
|
type,
|
10452
10471
|
limit,
|
10453
10472
|
page,
|
10454
|
-
|
10473
|
+
channelLabel
|
10455
10474
|
).then((response) => {
|
10456
10475
|
return Promise.resolve(response);
|
10457
10476
|
});
|