@agentunion/fastaun 0.5.10 → 0.5.11
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 +32 -0
- package/_packed_docs/CHANGELOG.md +32 -0
- package/_packed_docs/INDEX.md +3 -3
- package/_packed_docs/KITE_DOCS_GUIDE.md +1 -1
- package/_packed_docs/sdk/06-API/346/211/213/345/206/214.md +59 -0
- package/_packed_docs/sdk/AUN_DOCS_GUIDE.md +3 -2
- package/_packed_docs/sdk/INDEX.md +2 -1
- package/dist/client/delivery.d.ts +18 -4
- package/dist/client/delivery.js +179 -29
- package/dist/client/delivery.js.map +1 -1
- package/dist/client/rpc-pipeline.js +18 -4
- package/dist/client/rpc-pipeline.js.map +1 -1
- package/dist/client/v2-e2ee.d.ts +2 -0
- package/dist/client/v2-e2ee.js +193 -42
- package/dist/client/v2-e2ee.js.map +1 -1
- package/dist/client.d.ts +1 -0
- package/dist/client.js +63 -3
- package/dist/client.js.map +1 -1
- package/dist/transport.d.ts +4 -0
- package/dist/transport.js +141 -44
- package/dist/transport.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/dist/client.js
CHANGED
|
@@ -1068,6 +1068,62 @@ export class AUNClient {
|
|
|
1068
1068
|
await this._agentMdManager.upload(agentMd);
|
|
1069
1069
|
return true;
|
|
1070
1070
|
}
|
|
1071
|
+
async _checkIdentityAdmissionAfterConnect() {
|
|
1072
|
+
const aid = String(this._aid ?? this._currentAid?.aid ?? '').trim();
|
|
1073
|
+
if (!aid)
|
|
1074
|
+
return;
|
|
1075
|
+
try {
|
|
1076
|
+
const checked = await this._agentMdManager.check(aid);
|
|
1077
|
+
if (!checked.remote_found) {
|
|
1078
|
+
const content = this._agentMdManager.readContent(aid) || buildDefaultAgentMd(aid);
|
|
1079
|
+
await this._agentMdManager.upload(content);
|
|
1080
|
+
}
|
|
1081
|
+
}
|
|
1082
|
+
catch (exc) {
|
|
1083
|
+
this._clientLog.warn(`post-connect agent.md check failed: ${formatCaughtError(exc)}`);
|
|
1084
|
+
}
|
|
1085
|
+
const store = this._aidStore;
|
|
1086
|
+
if (!store)
|
|
1087
|
+
return;
|
|
1088
|
+
let listed;
|
|
1089
|
+
try {
|
|
1090
|
+
listed = await this.call('group.list_my', {});
|
|
1091
|
+
}
|
|
1092
|
+
catch (exc) {
|
|
1093
|
+
this._clientLog.warn(`post-connect group identity check failed: ${formatCaughtError(exc)}`);
|
|
1094
|
+
return;
|
|
1095
|
+
}
|
|
1096
|
+
const result = isJsonObject(listed) ? listed : {};
|
|
1097
|
+
const groups = Array.isArray(result.groups) ? result.groups : (Array.isArray(result.items) ? result.items : []);
|
|
1098
|
+
for (const raw of groups) {
|
|
1099
|
+
if (!isJsonObject(raw))
|
|
1100
|
+
continue;
|
|
1101
|
+
const group = raw;
|
|
1102
|
+
const role = String(group.role ?? group.my_role ?? '').trim().toLowerCase();
|
|
1103
|
+
if (role !== 'owner')
|
|
1104
|
+
continue;
|
|
1105
|
+
const groupId = String(group.group_id ?? group.groupId ?? group.group_aid ?? group.groupAid ?? '').trim();
|
|
1106
|
+
const groupAid = String(group.group_aid ?? group.groupAid ?? groupId).trim();
|
|
1107
|
+
if (!groupId || !groupAid)
|
|
1108
|
+
continue;
|
|
1109
|
+
try {
|
|
1110
|
+
await this._runGroupIdentityOperation(groupId, async () => {
|
|
1111
|
+
const loaded = store.load(groupAid);
|
|
1112
|
+
if (!loaded.ok || !loaded.data?.aid?.isPrivateKeyValid()) {
|
|
1113
|
+
await this.bindGroupAid({ group_id: groupId, group_aid: groupAid }, { aidStore: store });
|
|
1114
|
+
return;
|
|
1115
|
+
}
|
|
1116
|
+
const checked = await this._agentMdManager.check(groupAid);
|
|
1117
|
+
if (!checked.remote_found) {
|
|
1118
|
+
await this._uploadGroupAgentMd(store, groupAid, {}, {});
|
|
1119
|
+
}
|
|
1120
|
+
});
|
|
1121
|
+
}
|
|
1122
|
+
catch (exc) {
|
|
1123
|
+
this._clientLog.warn(`post-connect group identity check failed: group=${groupId} err=${formatCaughtError(exc)}`);
|
|
1124
|
+
}
|
|
1125
|
+
}
|
|
1126
|
+
}
|
|
1071
1127
|
async _runGroupIdentityOperation(groupId, operation) {
|
|
1072
1128
|
const aid = String(this._aid ?? '').trim();
|
|
1073
1129
|
const dot = aid.indexOf('.');
|
|
@@ -1949,8 +2005,8 @@ export class AUNClient {
|
|
|
1949
2005
|
async _publishOrderedMessage(event, ns, seq, payload, source = 'push') {
|
|
1950
2006
|
return this._delivery.publishOrderedMessage(event, ns, seq, payload, source);
|
|
1951
2007
|
}
|
|
1952
|
-
async _publishPulledMessage(event, ns, seq, payload, persist = true) {
|
|
1953
|
-
return this._delivery.publishPulledMessage(event, ns, seq, payload, persist);
|
|
2008
|
+
async _publishPulledMessage(event, ns, seq, payload, persist = true, source = 'pull') {
|
|
2009
|
+
return this._delivery.publishPulledMessage(event, ns, seq, payload, persist, source);
|
|
1954
2010
|
}
|
|
1955
2011
|
_markOrderedSeqDelivered(ns, seq) {
|
|
1956
2012
|
if (!ns || !Number.isFinite(seq) || !Number.isInteger(seq) || seq <= 0)
|
|
@@ -2517,6 +2573,7 @@ export class AUNClient {
|
|
|
2517
2573
|
this._clientLog.warn(`schedule post-connect P2P gap fill failed: ${formatCaughtError(exc)}`);
|
|
2518
2574
|
});
|
|
2519
2575
|
}
|
|
2576
|
+
this._safeAsync(this._checkIdentityAdmissionAfterConnect());
|
|
2520
2577
|
this._clientLog.debug(`_connectOnce exit: elapsed=${Date.now() - tStart}ms gateway=${gatewayUrl}, aid=${this._aid ?? ''}`);
|
|
2521
2578
|
}
|
|
2522
2579
|
catch (err) {
|
|
@@ -2730,7 +2787,7 @@ export class AUNClient {
|
|
|
2730
2787
|
return await this._v2E2EE.ackGroupV2(groupId, upToSeq, groupAid);
|
|
2731
2788
|
}
|
|
2732
2789
|
/** 解密单条 V2 pull 消息。缺 sender IK 时先入 pending,后台补齐后重试。 */
|
|
2733
|
-
async _decryptV2Message(msg, allowPending = true, emitUndecryptable = true, rotateKeys = true, observeAgentMd = true, deferStatus, deferKeyFetch = false) {
|
|
2790
|
+
async _decryptV2Message(msg, allowPending = true, emitUndecryptable = true, rotateKeys = true, observeAgentMd = true, deferStatus, deferKeyFetch = false, source = 'pull') {
|
|
2734
2791
|
const session = this._v2Session;
|
|
2735
2792
|
if (!session)
|
|
2736
2793
|
return null;
|
|
@@ -2823,6 +2880,7 @@ export class AUNClient {
|
|
|
2823
2880
|
_envelope_type: String(envelope.type ?? ''),
|
|
2824
2881
|
_suite: String(envelope.suite ?? ''),
|
|
2825
2882
|
_spk_id: spkId,
|
|
2883
|
+
source,
|
|
2826
2884
|
};
|
|
2827
2885
|
this._attachV2EnvelopeMetadata(event, e2eeMeta);
|
|
2828
2886
|
this._logMessageDebug('decrypt-fail', 'v2.decrypt', undecryptableEvent, event);
|
|
@@ -2862,6 +2920,7 @@ export class AUNClient {
|
|
|
2862
2920
|
_decrypt_stage: 'sender_ik',
|
|
2863
2921
|
_envelope_type: String(envelope.type ?? ''),
|
|
2864
2922
|
_suite: String(envelope.suite ?? ''),
|
|
2923
|
+
source,
|
|
2865
2924
|
};
|
|
2866
2925
|
this._attachV2EnvelopeMetadata(event, e2eeMeta);
|
|
2867
2926
|
this._logMessageDebug('decrypt-fail', 'v2.decrypt', undecryptableEvent, event);
|
|
@@ -2891,6 +2950,7 @@ export class AUNClient {
|
|
|
2891
2950
|
_decrypt_stage: 'decrypt',
|
|
2892
2951
|
_envelope_type: String(envelope.type ?? ''),
|
|
2893
2952
|
_suite: String(envelope.suite ?? ''),
|
|
2953
|
+
source,
|
|
2894
2954
|
};
|
|
2895
2955
|
this._attachV2EnvelopeMetadata(event, e2eeMeta);
|
|
2896
2956
|
this._logMessageDebug('decrypt-fail', 'v2.decrypt', undecryptableEvent, event);
|