@agentunion/fastaun 0.3.4 → 0.3.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/CHANGELOG.md +108 -106
- package/_packed_docs/CHANGELOG.md +108 -106
- package/_packed_docs/INDEX.md +16 -16
- package/_packed_docs/KITE_DOCS_GUIDE.md +7 -7
- package/_packed_docs/design/E2EE_V2/347/256/200/345/214/226/344/270/2721DH/345/212/240Per-AID_Wrap/346/226/271/346/241/210.md +124 -0
- package/_packed_docs/sdk/04-/350/277/236/346/216/245/344/270/216/350/256/244/350/257/201.md +469 -454
- package/_packed_docs/sdk/06-API/346/211/213/345/206/214.md +1475 -1410
- package/dist/auth.js +1 -1
- package/dist/client.d.ts +4 -0
- package/dist/client.js +50 -5
- package/dist/client.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/namespaces/auth.d.ts +2 -0
- package/dist/namespaces/auth.js +5 -0
- package/dist/namespaces/auth.js.map +1 -1
- package/dist/v2/e2ee/encrypt-p2p.js +1 -1
- package/package.json +1 -1
package/dist/auth.js
CHANGED
|
@@ -26,7 +26,7 @@ const _noopLogger = {
|
|
|
26
26
|
debug: () => { },
|
|
27
27
|
};
|
|
28
28
|
const AUN_SDK_LANG = 'typescript';
|
|
29
|
-
const AUN_SDK_VERSION = '0.3.
|
|
29
|
+
const AUN_SDK_VERSION = '0.3.5';
|
|
30
30
|
// ── 签名验证辅助 ──────────────────────────────────────────────
|
|
31
31
|
/**
|
|
32
32
|
* 验证签名:支持 ECDSA P-256 (SHA256)、ECDSA P-384 (SHA384)、Ed25519。
|
package/dist/client.d.ts
CHANGED
|
@@ -87,6 +87,8 @@ export declare class AUNClient {
|
|
|
87
87
|
private _pushedSeqs;
|
|
88
88
|
/** 已解密但因 seq 空洞暂缓发布的应用层消息(按 namespace -> seq) */
|
|
89
89
|
private _pendingOrderedMsgs;
|
|
90
|
+
/** P2P pull 进行中到达的纯通知 push 上界;pull gate 释放后需要补拉一次。 */
|
|
91
|
+
private _pendingP2pPullUpper;
|
|
90
92
|
/** 缺 sender IK 时暂存原始 V2 消息,后台补齐 IK 后重试解密。 */
|
|
91
93
|
private _v2SenderIKPending;
|
|
92
94
|
/** sender IK 后台补齐任务去重。 */
|
|
@@ -278,6 +280,8 @@ export declare class AUNClient {
|
|
|
278
280
|
private _fillP2pGap;
|
|
279
281
|
/** 只按硬上限裁剪 published guard,不能按 contiguousSeq 清理。 */
|
|
280
282
|
private _prunePushedSeqs;
|
|
283
|
+
private _recordPendingP2pPull;
|
|
284
|
+
private _schedulePendingP2pPullIfNeeded;
|
|
281
285
|
private _markPublishedSeq;
|
|
282
286
|
private _enqueueOrderedMessage;
|
|
283
287
|
private _isInstanceScopedMessageEvent;
|
package/dist/client.js
CHANGED
|
@@ -444,6 +444,8 @@ export class AUNClient {
|
|
|
444
444
|
_pushedSeqs = new Map();
|
|
445
445
|
/** 已解密但因 seq 空洞暂缓发布的应用层消息(按 namespace -> seq) */
|
|
446
446
|
_pendingOrderedMsgs = new Map();
|
|
447
|
+
/** P2P pull 进行中到达的纯通知 push 上界;pull gate 释放后需要补拉一次。 */
|
|
448
|
+
_pendingP2pPullUpper = new Map();
|
|
447
449
|
/** 缺 sender IK 时暂存原始 V2 消息,后台补齐 IK 后重试解密。 */
|
|
448
450
|
_v2SenderIKPending = new Map();
|
|
449
451
|
/** sender IK 后台补齐任务去重。 */
|
|
@@ -1992,6 +1994,38 @@ export class AUNClient {
|
|
|
1992
1994
|
this._pushedSeqs.set(ns, new Set(keep));
|
|
1993
1995
|
}
|
|
1994
1996
|
}
|
|
1997
|
+
_recordPendingP2pPull(ns, seq) {
|
|
1998
|
+
if (!ns || seq <= 0)
|
|
1999
|
+
return;
|
|
2000
|
+
const previous = this._pendingP2pPullUpper.get(ns) ?? 0;
|
|
2001
|
+
if (seq > previous) {
|
|
2002
|
+
this._pendingP2pPullUpper.set(ns, seq);
|
|
2003
|
+
}
|
|
2004
|
+
this._clientLog.debug(`P2P pending pull upper recorded: ns=${ns}, seq=${seq}, previous=${previous}, contiguous=${this._seqTracker.getContiguousSeq(ns)}`);
|
|
2005
|
+
}
|
|
2006
|
+
_schedulePendingP2pPullIfNeeded(ns, reason) {
|
|
2007
|
+
if (!ns)
|
|
2008
|
+
return false;
|
|
2009
|
+
const upperSeq = this._pendingP2pPullUpper.get(ns) ?? 0;
|
|
2010
|
+
if (upperSeq <= 0) {
|
|
2011
|
+
this._pendingP2pPullUpper.delete(ns);
|
|
2012
|
+
return false;
|
|
2013
|
+
}
|
|
2014
|
+
const contig = this._seqTracker.getContiguousSeq(ns);
|
|
2015
|
+
if (upperSeq <= contig) {
|
|
2016
|
+
this._pendingP2pPullUpper.delete(ns);
|
|
2017
|
+
this._clientLog.debug(`P2P pending pull upper already covered: ns=${ns}, upper_seq=${upperSeq}, contiguous=${contig}, reason=${reason}`);
|
|
2018
|
+
return false;
|
|
2019
|
+
}
|
|
2020
|
+
if (this._state !== 'connected' || this._closing) {
|
|
2021
|
+
this._clientLog.debug(`P2P pending pull postponed: ns=${ns}, upper_seq=${upperSeq}, contiguous=${contig}, state=${this._state}, closing=${this._closing}, reason=${reason}`);
|
|
2022
|
+
return false;
|
|
2023
|
+
}
|
|
2024
|
+
this._pendingP2pPullUpper.delete(ns);
|
|
2025
|
+
this._clientLog.info(`P2P pending push follow-up pull scheduled: ns=${ns}, upper_seq=${upperSeq}, contiguous=${contig}, reason=${reason}`);
|
|
2026
|
+
void this._fillP2pGap();
|
|
2027
|
+
return true;
|
|
2028
|
+
}
|
|
1995
2029
|
_markPublishedSeq(ns, seq) {
|
|
1996
2030
|
let pushed = this._pushedSeqs.get(ns);
|
|
1997
2031
|
if (!pushed) {
|
|
@@ -2242,6 +2276,9 @@ export class AUNClient {
|
|
|
2242
2276
|
return;
|
|
2243
2277
|
gate.inflight = false;
|
|
2244
2278
|
gate.startedAt = 0;
|
|
2279
|
+
if (key.startsWith('p2p:')) {
|
|
2280
|
+
this._schedulePendingP2pPullIfNeeded(key, 'pull-gate-release');
|
|
2281
|
+
}
|
|
2245
2282
|
}
|
|
2246
2283
|
_pullGateKeyForCall(method, params) {
|
|
2247
2284
|
if (method === 'message.pull' || method === 'message.v2.pull') {
|
|
@@ -2423,12 +2460,16 @@ export class AUNClient {
|
|
|
2423
2460
|
this._releasePullGate(key, token);
|
|
2424
2461
|
}
|
|
2425
2462
|
}
|
|
2426
|
-
async _tryRunBackgroundPull(key, operation, followupOnMessages = false) {
|
|
2427
|
-
if (key && this._isPullResponseProcessing(key))
|
|
2463
|
+
async _tryRunBackgroundPull(key, operation, followupOnMessages = false, onBusy) {
|
|
2464
|
+
if (key && this._isPullResponseProcessing(key)) {
|
|
2465
|
+
onBusy?.();
|
|
2428
2466
|
return false;
|
|
2467
|
+
}
|
|
2429
2468
|
const token = this._tryAcquirePullGate(key);
|
|
2430
|
-
if (token === null)
|
|
2469
|
+
if (token === null) {
|
|
2470
|
+
onBusy?.();
|
|
2431
2471
|
return false;
|
|
2472
|
+
}
|
|
2432
2473
|
let count = 0;
|
|
2433
2474
|
try {
|
|
2434
2475
|
count = await this._withBackgroundRpc(operation);
|
|
@@ -3420,6 +3461,7 @@ export class AUNClient {
|
|
|
3420
3461
|
this._gapFillDone.clear();
|
|
3421
3462
|
this._pushedSeqs.clear();
|
|
3422
3463
|
this._pendingOrderedMsgs.clear();
|
|
3464
|
+
this._pendingP2pPullUpper.clear();
|
|
3423
3465
|
this._v2SenderIKPending.clear();
|
|
3424
3466
|
this._v2SenderIKFetching.clear();
|
|
3425
3467
|
this._groupSynced.clear();
|
|
@@ -3432,6 +3474,7 @@ export class AUNClient {
|
|
|
3432
3474
|
this._gapFillDone.clear();
|
|
3433
3475
|
this._pushedSeqs.clear();
|
|
3434
3476
|
this._pendingOrderedMsgs.clear();
|
|
3477
|
+
this._pendingP2pPullUpper.clear();
|
|
3435
3478
|
this._v2SenderIKPending.clear();
|
|
3436
3479
|
this._v2SenderIKFetching.clear();
|
|
3437
3480
|
this._groupSynced.clear();
|
|
@@ -5694,8 +5737,10 @@ export class AUNClient {
|
|
|
5694
5737
|
void this._tryRunBackgroundPull(ns, async () => {
|
|
5695
5738
|
const operationBefore = this._seqTracker.getContiguousSeq(ns);
|
|
5696
5739
|
const dedupKey = `p2p_pull:${ns}`;
|
|
5697
|
-
if (this._gapFillDone.has(dedupKey))
|
|
5740
|
+
if (this._gapFillDone.has(dedupKey)) {
|
|
5741
|
+
this._recordPendingP2pPull(ns, pushSeq);
|
|
5698
5742
|
return 0;
|
|
5743
|
+
}
|
|
5699
5744
|
this._gapFillDone.set(dedupKey, Date.now());
|
|
5700
5745
|
try {
|
|
5701
5746
|
const pulled = await this.pullV2(0, 50, { gateLocked: true });
|
|
@@ -5708,7 +5753,7 @@ export class AUNClient {
|
|
|
5708
5753
|
finally {
|
|
5709
5754
|
this._gapFillDone.delete(dedupKey);
|
|
5710
5755
|
}
|
|
5711
|
-
}, true).catch((exc) => {
|
|
5756
|
+
}, true, () => this._recordPendingP2pPull(ns, pushSeq)).catch((exc) => {
|
|
5712
5757
|
const newContig = this._seqTracker.getContiguousSeq(ns);
|
|
5713
5758
|
this._clientLog.warn(`V2 push auto-pull failed: contiguous_seq=${contigBefore}->${newContig} err=${formatCaughtError(exc)}`);
|
|
5714
5759
|
});
|