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.
@@ -22,7 +22,7 @@ const walletOpenVersion =
22
22
  let _baseUrl = "";
23
23
  let _walletOrigin = "";
24
24
  if (true) {
25
- _baseUrl = "/v0_0_15";
25
+ _baseUrl = "/v0_0_16";
26
26
  _walletOrigin = "https://wallet.dcnetio.com";
27
27
 
28
28
  if(walletOpenOrgin) {
@@ -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 = 300000;
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
- count++;
495
- logger.info(`Token验证任务: 执行次数 ${count}`);
500
+ waitCount ++;
496
501
  try {
497
- await this.getTokenWithDCConnectInfo(this.context.connectedDc);
498
- await this.getTokenWithDCConnectInfo(this.context.AccountBackupDc);
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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "web-dc-api",
3
- "version": "0.0.86",
3
+ "version": "0.0.87",
4
4
  "description": "web相关的dcapi",
5
5
  "type": "module",
6
6
  "browser": "dist/dc.min.js",