web-dc-api 0.0.86 → 0.0.87
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/dist/dc.min.js +1 -1
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +1 -1
- package/lib/common/define.ts +1 -1
- package/lib/modules/auth-module.ts +20 -5
- package/package.json +1 -1
package/lib/common/define.ts
CHANGED
|
@@ -235,6 +235,11 @@ export class AuthModule implements DCModule, IAuthOperations {
|
|
|
235
235
|
if (mnemonic) {
|
|
236
236
|
// 登录成功,清空临时私钥
|
|
237
237
|
this.context.privateKey = null;
|
|
238
|
+
this.context.publicKey = undefined;
|
|
239
|
+
//清空原来连接的token信息,原来是基于临时私钥登录的
|
|
240
|
+
client.token = "";
|
|
241
|
+
this.context.connectedDc.client.token = "";
|
|
242
|
+
|
|
238
243
|
if (this.context.appInfo?.appId) {
|
|
239
244
|
const accountManager = new AccountManager(this.context);
|
|
240
245
|
|
|
@@ -484,18 +489,28 @@ export class AuthModule implements DCModule, IAuthOperations {
|
|
|
484
489
|
this.tokenTask = true;
|
|
485
490
|
|
|
486
491
|
// 300秒一次心跳维持连接
|
|
487
|
-
const period =
|
|
492
|
+
const period = 1000;
|
|
488
493
|
let count = 0;
|
|
494
|
+
let waitCount = 0;
|
|
489
495
|
|
|
490
496
|
// 启动ticker
|
|
491
497
|
logger.info("开始定时验证Token有效性任务");
|
|
492
498
|
(async () => {
|
|
493
499
|
while (this.tokenTask) {
|
|
494
|
-
|
|
495
|
-
logger.info(`Token验证任务: 执行次数 ${count}`);
|
|
500
|
+
waitCount ++;
|
|
496
501
|
try {
|
|
497
|
-
|
|
498
|
-
|
|
502
|
+
if (this.context.connectedDc.client?.token == "" || waitCount >= 300) {
|
|
503
|
+
await this.getTokenWithDCConnectInfo(this.context.connectedDc);
|
|
504
|
+
}
|
|
505
|
+
if (this.context.AccountBackupDc.client?.token == "" || waitCount >= 300) {
|
|
506
|
+
await this.getTokenWithDCConnectInfo(this.context.AccountBackupDc);
|
|
507
|
+
}
|
|
508
|
+
if (waitCount >= 300) {
|
|
509
|
+
waitCount = 0;
|
|
510
|
+
count++;
|
|
511
|
+
}
|
|
512
|
+
console.log(`第${count}次Token验证完成`);
|
|
513
|
+
|
|
499
514
|
} catch (error) {
|
|
500
515
|
logger.error("Token验证任务执行失败:", error);
|
|
501
516
|
}
|