liangzimixin 0.3.74 → 0.3.75
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/index.cjs +20 -1
- package/dist/index.d.cts +10 -0
- package/dist/setup-entry.cjs +20 -1
- package/package.json +1 -1
- package/scripts/liangzimixin_install.bat +1 -1
- package/scripts/liangzimixin_install.sh +1 -1
package/dist/index.cjs
CHANGED
|
@@ -20575,6 +20575,16 @@ var TokenManager = class {
|
|
|
20575
20575
|
isAuthorized() {
|
|
20576
20576
|
return this.cachedToken !== null;
|
|
20577
20577
|
}
|
|
20578
|
+
/**
|
|
20579
|
+
* 失效当前内存缓存的 Token — 下次 getValidToken() 将重新获取。
|
|
20580
|
+
* 用于出站 HTTP 收到 401 时主动清除可能已过期的 Token。
|
|
20581
|
+
* 注意: 不清除文件存储,_acquireToken 会重新获取并覆盖。
|
|
20582
|
+
*/
|
|
20583
|
+
invalidate() {
|
|
20584
|
+
this.cachedToken = null;
|
|
20585
|
+
this.currentTokenData = null;
|
|
20586
|
+
log21.info("Token invalidated (will re-acquire on next call)");
|
|
20587
|
+
}
|
|
20578
20588
|
/** 废置并清除所有令牌 (包括文件存储和内存缓存) */
|
|
20579
20589
|
async revokeAndClear() {
|
|
20580
20590
|
this.clearRefreshTimer();
|
|
@@ -20978,6 +20988,8 @@ var MessagePipe = class _MessagePipe {
|
|
|
20978
20988
|
crypto;
|
|
20979
20989
|
/** 获取最新 access_token 的回调 (用于 HMAC 验签和出站 Bearer 认证) */
|
|
20980
20990
|
tokenFn;
|
|
20991
|
+
/** 失效当前 Token 缓存的回调 — 收到 401 时调用,强制下次 tokenFn 重新获取 */
|
|
20992
|
+
invalidateTokenFn;
|
|
20981
20993
|
/** 消息服务 API 基础地址 (用于出站发送/撤回) */
|
|
20982
20994
|
messageServiceBaseUrl;
|
|
20983
20995
|
/** L4 层注册的入站消息回调 */
|
|
@@ -20997,6 +21009,7 @@ var MessagePipe = class _MessagePipe {
|
|
|
20997
21009
|
this.dedup = deps.dedup;
|
|
20998
21010
|
this.crypto = deps.crypto;
|
|
20999
21011
|
this.tokenFn = deps.tokenFn;
|
|
21012
|
+
this.invalidateTokenFn = deps.invalidateTokenFn;
|
|
21000
21013
|
this.messageServiceBaseUrl = deps.messageServiceBaseUrl;
|
|
21001
21014
|
this.quantumAccount = deps.quantumAccount;
|
|
21002
21015
|
this.encryptionMode = deps.encryptionMode;
|
|
@@ -21300,6 +21313,11 @@ var MessagePipe = class _MessagePipe {
|
|
|
21300
21313
|
url: url2,
|
|
21301
21314
|
body
|
|
21302
21315
|
});
|
|
21316
|
+
if (resp.status === 401 && this.invalidateTokenFn) {
|
|
21317
|
+
log25.warn(`${logTag}:token-expired, invalidating cached token for retry`);
|
|
21318
|
+
this.invalidateTokenFn();
|
|
21319
|
+
return { code: -1, msg: `HTTP ${resp.status}`, _retryable: true };
|
|
21320
|
+
}
|
|
21303
21321
|
return { code: -1, msg: `HTTP ${resp.status}`, _retryable: resp.status >= 500 };
|
|
21304
21322
|
}
|
|
21305
21323
|
const result = await resp.json();
|
|
@@ -21335,7 +21353,7 @@ var MessagePipe = class _MessagePipe {
|
|
|
21335
21353
|
const result = await this._callMessageApiOnce(url2, body, logTag);
|
|
21336
21354
|
if (result && "_retryable" in result) {
|
|
21337
21355
|
if (result._retryable) {
|
|
21338
|
-
log25.warn(`${logTag}:retrying after
|
|
21356
|
+
log25.warn(`${logTag}:retrying after ${result.msg}`, { url: url2 });
|
|
21339
21357
|
await new Promise((r) => setTimeout(r, 1e3));
|
|
21340
21358
|
try {
|
|
21341
21359
|
const retryResult = await this._callMessageApiOnce(url2, body, `${logTag}:retry`);
|
|
@@ -22261,6 +22279,7 @@ async function startPlugin(accountConfig, internalOverrides) {
|
|
|
22261
22279
|
dedup,
|
|
22262
22280
|
crypto: cryptoEngine,
|
|
22263
22281
|
tokenFn: () => tokenManager.getValidToken(),
|
|
22282
|
+
invalidateTokenFn: () => tokenManager.invalidate(),
|
|
22264
22283
|
messageServiceBaseUrl: config2.message.messageServiceBaseUrl,
|
|
22265
22284
|
quantumAccount: accountConfig.quantumAccount,
|
|
22266
22285
|
encryptionMode: accountConfig.encryptionMode,
|
package/dist/index.d.cts
CHANGED
|
@@ -650,6 +650,12 @@ declare class TokenManager {
|
|
|
650
650
|
hasScope(scope: string): boolean;
|
|
651
651
|
/** 检查是否已授权 (是否持有有效令牌) */
|
|
652
652
|
isAuthorized(): boolean;
|
|
653
|
+
/**
|
|
654
|
+
* 失效当前内存缓存的 Token — 下次 getValidToken() 将重新获取。
|
|
655
|
+
* 用于出站 HTTP 收到 401 时主动清除可能已过期的 Token。
|
|
656
|
+
* 注意: 不清除文件存储,_acquireToken 会重新获取并覆盖。
|
|
657
|
+
*/
|
|
658
|
+
invalidate(): void;
|
|
653
659
|
/** 废置并清除所有令牌 (包括文件存储和内存缓存) */
|
|
654
660
|
revokeAndClear(): Promise<void>;
|
|
655
661
|
/** 清理定时器和并发锁 — 优雅关闭时调用 */
|
|
@@ -866,6 +872,8 @@ declare class MessagePipe {
|
|
|
866
872
|
private readonly crypto;
|
|
867
873
|
/** 获取最新 access_token 的回调 (用于 HMAC 验签和出站 Bearer 认证) */
|
|
868
874
|
private readonly tokenFn;
|
|
875
|
+
/** 失效当前 Token 缓存的回调 — 收到 401 时调用,强制下次 tokenFn 重新获取 */
|
|
876
|
+
private readonly invalidateTokenFn?;
|
|
869
877
|
/** 消息服务 API 基础地址 (用于出站发送/撤回) */
|
|
870
878
|
private readonly messageServiceBaseUrl;
|
|
871
879
|
/** L4 层注册的入站消息回调 */
|
|
@@ -886,6 +894,8 @@ declare class MessagePipe {
|
|
|
886
894
|
crypto: CryptoEngine;
|
|
887
895
|
/** TokenManager.getValidToken — 用于验签和出站认证 */
|
|
888
896
|
tokenFn: () => Promise<string>;
|
|
897
|
+
/** TokenManager.invalidate — 收到 401 时清除 Token 缓存 */
|
|
898
|
+
invalidateTokenFn?: () => void;
|
|
889
899
|
/** 消息服务 API 基础地址 */
|
|
890
900
|
messageServiceBaseUrl: string;
|
|
891
901
|
/** 量子账户标识 — 用于判断是否具备解密能力 */
|
package/dist/setup-entry.cjs
CHANGED
|
@@ -19461,6 +19461,16 @@ var TokenManager = class {
|
|
|
19461
19461
|
isAuthorized() {
|
|
19462
19462
|
return this.cachedToken !== null;
|
|
19463
19463
|
}
|
|
19464
|
+
/**
|
|
19465
|
+
* 失效当前内存缓存的 Token — 下次 getValidToken() 将重新获取。
|
|
19466
|
+
* 用于出站 HTTP 收到 401 时主动清除可能已过期的 Token。
|
|
19467
|
+
* 注意: 不清除文件存储,_acquireToken 会重新获取并覆盖。
|
|
19468
|
+
*/
|
|
19469
|
+
invalidate() {
|
|
19470
|
+
this.cachedToken = null;
|
|
19471
|
+
this.currentTokenData = null;
|
|
19472
|
+
log12.info("Token invalidated (will re-acquire on next call)");
|
|
19473
|
+
}
|
|
19464
19474
|
/** 废置并清除所有令牌 (包括文件存储和内存缓存) */
|
|
19465
19475
|
async revokeAndClear() {
|
|
19466
19476
|
this.clearRefreshTimer();
|
|
@@ -19864,6 +19874,8 @@ var MessagePipe = class _MessagePipe {
|
|
|
19864
19874
|
crypto;
|
|
19865
19875
|
/** 获取最新 access_token 的回调 (用于 HMAC 验签和出站 Bearer 认证) */
|
|
19866
19876
|
tokenFn;
|
|
19877
|
+
/** 失效当前 Token 缓存的回调 — 收到 401 时调用,强制下次 tokenFn 重新获取 */
|
|
19878
|
+
invalidateTokenFn;
|
|
19867
19879
|
/** 消息服务 API 基础地址 (用于出站发送/撤回) */
|
|
19868
19880
|
messageServiceBaseUrl;
|
|
19869
19881
|
/** L4 层注册的入站消息回调 */
|
|
@@ -19883,6 +19895,7 @@ var MessagePipe = class _MessagePipe {
|
|
|
19883
19895
|
this.dedup = deps.dedup;
|
|
19884
19896
|
this.crypto = deps.crypto;
|
|
19885
19897
|
this.tokenFn = deps.tokenFn;
|
|
19898
|
+
this.invalidateTokenFn = deps.invalidateTokenFn;
|
|
19886
19899
|
this.messageServiceBaseUrl = deps.messageServiceBaseUrl;
|
|
19887
19900
|
this.quantumAccount = deps.quantumAccount;
|
|
19888
19901
|
this.encryptionMode = deps.encryptionMode;
|
|
@@ -20186,6 +20199,11 @@ var MessagePipe = class _MessagePipe {
|
|
|
20186
20199
|
url: url2,
|
|
20187
20200
|
body
|
|
20188
20201
|
});
|
|
20202
|
+
if (resp.status === 401 && this.invalidateTokenFn) {
|
|
20203
|
+
log16.warn(`${logTag}:token-expired, invalidating cached token for retry`);
|
|
20204
|
+
this.invalidateTokenFn();
|
|
20205
|
+
return { code: -1, msg: `HTTP ${resp.status}`, _retryable: true };
|
|
20206
|
+
}
|
|
20189
20207
|
return { code: -1, msg: `HTTP ${resp.status}`, _retryable: resp.status >= 500 };
|
|
20190
20208
|
}
|
|
20191
20209
|
const result = await resp.json();
|
|
@@ -20221,7 +20239,7 @@ var MessagePipe = class _MessagePipe {
|
|
|
20221
20239
|
const result = await this._callMessageApiOnce(url2, body, logTag);
|
|
20222
20240
|
if (result && "_retryable" in result) {
|
|
20223
20241
|
if (result._retryable) {
|
|
20224
|
-
log16.warn(`${logTag}:retrying after
|
|
20242
|
+
log16.warn(`${logTag}:retrying after ${result.msg}`, { url: url2 });
|
|
20225
20243
|
await new Promise((r) => setTimeout(r, 1e3));
|
|
20226
20244
|
try {
|
|
20227
20245
|
const retryResult = await this._callMessageApiOnce(url2, body, `${logTag}:retry`);
|
|
@@ -21224,6 +21242,7 @@ async function startPlugin(accountConfig, internalOverrides) {
|
|
|
21224
21242
|
dedup,
|
|
21225
21243
|
crypto: cryptoEngine,
|
|
21226
21244
|
tokenFn: () => tokenManager.getValidToken(),
|
|
21245
|
+
invalidateTokenFn: () => tokenManager.invalidate(),
|
|
21227
21246
|
messageServiceBaseUrl: config2.message.messageServiceBaseUrl,
|
|
21228
21247
|
quantumAccount: accountConfig.quantumAccount,
|
|
21229
21248
|
encryptionMode: accountConfig.encryptionMode,
|
package/package.json
CHANGED
|
@@ -7,7 +7,7 @@ REM liangzimixin install script (Windows)
|
|
|
7
7
|
REM Usage: liangzimixin_install.bat <appId> <appSecret> [quantumAccount]
|
|
8
8
|
REM ============================================================
|
|
9
9
|
|
|
10
|
-
set "SCRIPT_VERSION=0.3.
|
|
10
|
+
set "SCRIPT_VERSION=0.3.75"
|
|
11
11
|
set "NPM_PACKAGE=liangzimixin"
|
|
12
12
|
|
|
13
13
|
set "SKIP_SELF_UPDATE=0"
|
|
@@ -6,7 +6,7 @@ set -euo pipefail
|
|
|
6
6
|
# 用法: ./liangzimixin_install.sh <appId> <appSecret> [quantumAccount]
|
|
7
7
|
# ============================================================
|
|
8
8
|
|
|
9
|
-
SCRIPT_VERSION="0.3.
|
|
9
|
+
SCRIPT_VERSION="0.3.75"
|
|
10
10
|
NPM_PACKAGE="liangzimixin"
|
|
11
11
|
|
|
12
12
|
# ── 颜色 ──────────────────────────────────────────────────────
|