@agentunion/fastaun 0.5.16 → 0.5.18
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 +336 -260
- package/_packed_docs/CHANGELOG.md +336 -260
- package/_packed_docs/INDEX.md +36 -5
- package/_packed_docs/KITE_DOCS_GUIDE.md +13 -5
- package/_packed_docs/agent.md/SCHEMA.md +52 -33
- package/_packed_docs/aun/345/210/206/345/270/203/345/274/217/346/265/213/350/257/225/350/277/220/350/241/214/346/214/207/345/215/227.md +1170 -1164
- package/_packed_docs/aun/346/265/213/350/257/225/350/277/220/350/241/214/346/214/207/345/215/227.md +1215 -1213
- package/_packed_docs/protocol/01-/350/272/253/344/273/275/344/270/216/345/207/255/350/257/201/345/215/217/350/256/256-auth.md +95 -6
- package/_packed_docs/protocol/06-/346/234/215/345/212/241/345/215/217/350/256/256.md +58 -43
- package/_packed_docs/protocol/07-/351/224/231/350/257/257/347/240/201/344/270/216/347/212/266/346/200/201/346/234/272.md +19 -4
- package/_packed_docs/protocol/10-Group-/345/255/220/345/215/217/350/256/256.md +80 -17
- package/_packed_docs/protocol/11-Storage-/345/255/220/345/215/217/350/256/256.md +25 -2
- package/_packed_docs/sdk/06-API/346/211/213/345/206/214.md +69 -10
- package/_packed_docs/sdk/07-/351/224/231/350/257/257/345/244/204/347/220/206.md +7 -4
- package/_packed_docs/sdk/09-group-rpc-manual.md +167 -35
- package/_packed_docs/sdk/09-message-rpc-manual.md +72 -42
- package/_packed_docs/sdk/09-storage-rpc-manual.md +48 -18
- package/_packed_docs/sdk/AUN_DOCS_GUIDE.md +16 -12
- package/_packed_docs/sdk/INDEX.md +14 -13
- package/dist/agent-md-schema.js +2 -0
- package/dist/agent-md-schema.js.map +1 -1
- package/dist/agent-md.d.ts +3 -1
- package/dist/agent-md.js +10 -2
- package/dist/agent-md.js.map +1 -1
- package/dist/aid-store.d.ts +58 -0
- package/dist/aid-store.js +234 -3
- package/dist/aid-store.js.map +1 -1
- package/dist/aid.d.ts +17 -1
- package/dist/aid.js +48 -2
- package/dist/aid.js.map +1 -1
- package/dist/client/delivery.d.ts +19 -0
- package/dist/client/delivery.js +264 -31
- package/dist/client/delivery.js.map +1 -1
- package/dist/client/group-state.d.ts +4 -0
- package/dist/client/group-state.js +63 -0
- package/dist/client/group-state.js.map +1 -1
- package/dist/client/rpc-pipeline.js +29 -14
- package/dist/client/rpc-pipeline.js.map +1 -1
- package/dist/client/v2-e2ee.d.ts +17 -2
- package/dist/client/v2-e2ee.js +971 -520
- package/dist/client/v2-e2ee.js.map +1 -1
- package/dist/client.d.ts +3 -0
- package/dist/client.js +120 -19
- package/dist/client.js.map +1 -1
- package/dist/facades.d.ts +7 -0
- package/dist/facades.js +11 -0
- package/dist/facades.js.map +1 -1
- package/dist/group-fs.js +7 -5
- package/dist/group-fs.js.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/ownership-proof.d.ts +40 -0
- package/dist/ownership-proof.js +140 -0
- package/dist/ownership-proof.js.map +1 -0
- package/dist/storage/vfs.d.ts +1 -0
- package/dist/storage/vfs.js +61 -6
- package/dist/storage/vfs.js.map +1 -1
- package/dist/tools/cross-sdk-agent.js +31 -1
- package/dist/tools/cross-sdk-agent.js.map +1 -1
- package/dist/types.d.ts +16 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +14 -14
package/dist/client.d.ts
CHANGED
|
@@ -140,6 +140,9 @@ export declare class AUNClient {
|
|
|
140
140
|
private _pushProcessQueues;
|
|
141
141
|
/** P2P pull 进行中到达的纯通知 push 上界;pull gate 释放后需要补拉一次。 */
|
|
142
142
|
private _pendingP2pPullUpper;
|
|
143
|
+
/** P2P pending pull 的延迟重试定时器及次数,覆盖服务端异步落库窗口。 */
|
|
144
|
+
private _pendingP2pPullTimers;
|
|
145
|
+
private _pendingP2pPullRetries;
|
|
143
146
|
/** 缺 sender IK 时暂存原始 V2 消息,后台补齐 IK 后重试解密。 */
|
|
144
147
|
private _v2SenderIKPending;
|
|
145
148
|
/** sender IK 后台补齐任务去重。 */
|
package/dist/client.js
CHANGED
|
@@ -120,6 +120,8 @@ const DEFAULT_SESSION_OPTIONS = {
|
|
|
120
120
|
const RECONNECT_MIN_BASE_DELAY_MS = 1_000;
|
|
121
121
|
const RECONNECT_MAX_BASE_DELAY_MS = 64_000;
|
|
122
122
|
const TOKEN_REFRESH_CHECK_INTERVAL_MS = 30_000;
|
|
123
|
+
const PENDING_P2P_PULL_DELAY_MS = 100;
|
|
124
|
+
const PENDING_P2P_PULL_MAX_RETRIES = 20;
|
|
123
125
|
const MAX_NOTIFY_PAYLOAD_SIZE = 64 * 1024;
|
|
124
126
|
// P1-23: 非幂等方法使用更长超时(35s),避免 SDK 10s 超时 < gateway 30s 处理时间
|
|
125
127
|
const NON_IDEMPOTENT_TIMEOUT_MS = 35_000;
|
|
@@ -207,7 +209,7 @@ const SIGNED_METHODS = new Set([
|
|
|
207
209
|
'collab.tag.create', 'collab.tag.restore',
|
|
208
210
|
'collab.tag.rm', 'collab.tag.prune',
|
|
209
211
|
'group.commit_state',
|
|
210
|
-
'group.ban', 'group.unban',
|
|
212
|
+
'group.ban', 'group.unban', 'group.block', 'group.unblock', 'group.report_status',
|
|
211
213
|
'group.dissolve', 'group.suspend', 'group.resume',
|
|
212
214
|
]);
|
|
213
215
|
function clampReconnectDelayMs(value, fallback, upper = RECONNECT_MAX_BASE_DELAY_MS) {
|
|
@@ -334,6 +336,7 @@ function createAgentMdManagerForRuntime(opts) {
|
|
|
334
336
|
return new AgentMdManager({
|
|
335
337
|
aunPath: opts.config().aunPath,
|
|
336
338
|
verifySsl: opts.config().verifySsl,
|
|
339
|
+
onChanged: (aid) => opts.dispatcher().enqueue('agentmd.changed', aid),
|
|
337
340
|
discoveryPort: opts.config().discoveryPort,
|
|
338
341
|
uploadViaGatewayHost: true,
|
|
339
342
|
logger: opts.logger(),
|
|
@@ -493,6 +496,9 @@ export class AUNClient {
|
|
|
493
496
|
_pushProcessQueues = new Map();
|
|
494
497
|
/** P2P pull 进行中到达的纯通知 push 上界;pull gate 释放后需要补拉一次。 */
|
|
495
498
|
_pendingP2pPullUpper = new Map();
|
|
499
|
+
/** P2P pending pull 的延迟重试定时器及次数,覆盖服务端异步落库窗口。 */
|
|
500
|
+
_pendingP2pPullTimers = new Map();
|
|
501
|
+
_pendingP2pPullRetries = new Map();
|
|
496
502
|
/** 缺 sender IK 时暂存原始 V2 消息,后台补齐 IK 后重试解密。 */
|
|
497
503
|
_v2SenderIKPending = new Map();
|
|
498
504
|
/** sender IK 后台补齐任务去重。 */
|
|
@@ -608,6 +614,7 @@ export class AUNClient {
|
|
|
608
614
|
this._agentMdManager = createAgentMdManagerForRuntime({
|
|
609
615
|
config: () => this._configModel,
|
|
610
616
|
logger: () => this._logger.for('aun_core.agent_md'),
|
|
617
|
+
dispatcher: () => this._dispatcher,
|
|
611
618
|
ownerAid: () => this._aid,
|
|
612
619
|
currentAid: () => this._currentAid,
|
|
613
620
|
gateway: {
|
|
@@ -893,6 +900,7 @@ export class AUNClient {
|
|
|
893
900
|
this._agentMdManager = createAgentMdManagerForRuntime({
|
|
894
901
|
config: () => this._configModel,
|
|
895
902
|
logger: () => this._logger.for('aun_core.agent_md'),
|
|
903
|
+
dispatcher: () => this._dispatcher,
|
|
896
904
|
ownerAid: () => this._aid,
|
|
897
905
|
currentAid: () => this._currentAid,
|
|
898
906
|
gateway: {
|
|
@@ -1111,14 +1119,22 @@ export class AUNClient {
|
|
|
1111
1119
|
continue;
|
|
1112
1120
|
const group = raw;
|
|
1113
1121
|
const role = String(group.role ?? group.my_role ?? '').trim().toLowerCase();
|
|
1114
|
-
if (role !== 'owner')
|
|
1115
|
-
continue;
|
|
1116
1122
|
const groupId = String(group.group_id ?? group.groupId ?? group.group_aid ?? group.groupAid ?? '').trim();
|
|
1117
1123
|
const groupAid = String(group.group_aid ?? group.groupAid ?? groupId).trim();
|
|
1118
1124
|
if (!groupId || !groupAid)
|
|
1119
1125
|
continue;
|
|
1126
|
+
const keystore = store._keystore;
|
|
1127
|
+
const pendingTransfer = keystore && typeof keystore.loadPendingGroupBind === 'function'
|
|
1128
|
+
? keystore.loadPendingGroupBind(`complete:${groupId}`)
|
|
1129
|
+
: null;
|
|
1130
|
+
if (role !== 'owner' && !pendingTransfer)
|
|
1131
|
+
continue;
|
|
1120
1132
|
try {
|
|
1121
1133
|
await this._runGroupIdentityOperation(groupId, async () => {
|
|
1134
|
+
if (pendingTransfer) {
|
|
1135
|
+
await this.completeGroupTransfer({ group_id: groupId, group_aid: groupAid }, { aidStore: store });
|
|
1136
|
+
return;
|
|
1137
|
+
}
|
|
1122
1138
|
const loaded = store.load(groupAid);
|
|
1123
1139
|
if (!loaded.ok || !loaded.data?.aid?.isPrivateKeyValid()) {
|
|
1124
1140
|
await this.bindGroupAid({ group_id: groupId, group_aid: groupAid }, { aidStore: store });
|
|
@@ -1175,6 +1191,23 @@ export class AUNClient {
|
|
|
1175
1191
|
if (!isNamed) {
|
|
1176
1192
|
delete payload.public_key;
|
|
1177
1193
|
delete payload.curve;
|
|
1194
|
+
const keystore = store._keystore;
|
|
1195
|
+
const pendingName = String(payload.name ?? '').trim().toLowerCase();
|
|
1196
|
+
const pendingKey = `create-anonymous:${crypto.createHash('sha256').update(pendingName, 'utf8').digest('hex')}`;
|
|
1197
|
+
let keyPair = null;
|
|
1198
|
+
if (keystore && typeof keystore.loadPendingGroupBind === 'function') {
|
|
1199
|
+
keyPair = keystore.loadPendingGroupBind(pendingKey);
|
|
1200
|
+
}
|
|
1201
|
+
if (!keyPair || !keyPair.public_key_der_b64 || !keyPair.private_key_pem) {
|
|
1202
|
+
keyPair = new CryptoProvider().generateIdentity();
|
|
1203
|
+
if (keystore && typeof keystore.savePendingGroupBind === 'function') {
|
|
1204
|
+
keystore.savePendingGroupBind(pendingKey, keyPair);
|
|
1205
|
+
}
|
|
1206
|
+
}
|
|
1207
|
+
if (!keyPair?.public_key_der_b64 || !keyPair.private_key_pem) {
|
|
1208
|
+
throw new ValidationError('createGroup: failed to generate or load key pair');
|
|
1209
|
+
}
|
|
1210
|
+
payload._create_request_id = `anon:${crypto.createHash('sha256').update(keyPair.public_key_der_b64, 'utf8').digest('hex')}`;
|
|
1178
1211
|
const created = await this.call('group.create', payload);
|
|
1179
1212
|
const createdMap = isJsonObject(created) ? created : {};
|
|
1180
1213
|
const createdGroup = isJsonObject(createdMap.group) ? createdMap.group : {};
|
|
@@ -1182,6 +1215,9 @@ export class AUNClient {
|
|
|
1182
1215
|
if (!groupId) {
|
|
1183
1216
|
throw new ValidationError('group.create response missing group.group_id');
|
|
1184
1217
|
}
|
|
1218
|
+
if (keystore && typeof keystore.savePendingGroupBind === 'function') {
|
|
1219
|
+
keystore.savePendingGroupBind(`bind:${groupId}`, keyPair);
|
|
1220
|
+
}
|
|
1185
1221
|
const bindParams = { group_id: groupId };
|
|
1186
1222
|
for (const key of ['name', 'description', 'group_description', 'avatar', 'group_agent_md', 'groupAgentMd', 'content']) {
|
|
1187
1223
|
if (key in payload)
|
|
@@ -1193,15 +1229,28 @@ export class AUNClient {
|
|
|
1193
1229
|
const result = { ...createdMap, ...boundMap, group: { ...createdGroup, ...boundGroup } };
|
|
1194
1230
|
const postprocessParams = { ...payload };
|
|
1195
1231
|
delete postprocessParams._defer_group_ready_postprocess;
|
|
1232
|
+
delete postprocessParams._create_request_id;
|
|
1196
1233
|
const processed = await this._groupState.postprocessResult('group.create', postprocessParams, result);
|
|
1197
|
-
|
|
1234
|
+
const completed = await this._inviteInitialGroupMembers(processed, groupId, initialMembers);
|
|
1235
|
+
if (keystore && typeof keystore.clearPendingGroupBind === 'function') {
|
|
1236
|
+
keystore.clearPendingGroupBind(pendingKey);
|
|
1237
|
+
}
|
|
1238
|
+
return completed;
|
|
1198
1239
|
}
|
|
1199
|
-
const
|
|
1240
|
+
const groupName = String(payload.group_name).trim().toLowerCase();
|
|
1241
|
+
const pendingKey = `create:${groupName}`;
|
|
1200
1242
|
const keystore = store._keystore;
|
|
1201
1243
|
let keyPair = null;
|
|
1202
1244
|
if (keystore && typeof keystore.loadPendingGroupBind === 'function') {
|
|
1203
1245
|
keyPair = keystore.loadPendingGroupBind(pendingKey);
|
|
1204
1246
|
}
|
|
1247
|
+
if ((!keyPair || !keyPair.public_key_der_b64 || !keyPair.private_key_pem)
|
|
1248
|
+
&& keystore && typeof keystore.loadIdentity === 'function') {
|
|
1249
|
+
const ownerAid = String(this._aid ?? '').trim();
|
|
1250
|
+
const dot = ownerAid.indexOf('.');
|
|
1251
|
+
if (dot >= 0)
|
|
1252
|
+
keyPair = keystore.loadIdentity(`${groupName}.${ownerAid.slice(dot + 1).toLowerCase()}`);
|
|
1253
|
+
}
|
|
1205
1254
|
if (!keyPair || !keyPair.public_key_der_b64 || !keyPair.private_key_pem) {
|
|
1206
1255
|
keyPair = new CryptoProvider().generateIdentity();
|
|
1207
1256
|
if (keystore && typeof keystore.savePendingGroupBind === 'function') {
|
|
@@ -1832,6 +1881,7 @@ export class AUNClient {
|
|
|
1832
1881
|
const previous = this._pendingP2pPullUpper.get(ns) ?? 0;
|
|
1833
1882
|
if (seq > previous) {
|
|
1834
1883
|
this._pendingP2pPullUpper.set(ns, seq);
|
|
1884
|
+
this._pendingP2pPullRetries.delete(ns);
|
|
1835
1885
|
}
|
|
1836
1886
|
this._clientLog.debug(`P2P pending pull upper recorded: ns=${ns}, seq=${seq}, previous=${previous}, contiguous=${this._seqTracker.getContiguousSeq(ns)}`);
|
|
1837
1887
|
}
|
|
@@ -1846,6 +1896,7 @@ export class AUNClient {
|
|
|
1846
1896
|
const contig = this._seqTracker.getContiguousSeq(ns);
|
|
1847
1897
|
if (upperSeq <= contig) {
|
|
1848
1898
|
this._pendingP2pPullUpper.delete(ns);
|
|
1899
|
+
this._pendingP2pPullRetries.delete(ns);
|
|
1849
1900
|
this._clientLog.debug(`P2P pending pull upper already covered: ns=${ns}, upper_seq=${upperSeq}, contiguous=${contig}, reason=${reason}`);
|
|
1850
1901
|
return false;
|
|
1851
1902
|
}
|
|
@@ -1853,11 +1904,49 @@ export class AUNClient {
|
|
|
1853
1904
|
this._clientLog.debug(`P2P pending pull postponed: ns=${ns}, upper_seq=${upperSeq}, contiguous=${contig}, state=${this._state}, closing=${this._closing}, reason=${reason}`);
|
|
1854
1905
|
return false;
|
|
1855
1906
|
}
|
|
1856
|
-
if (this.
|
|
1907
|
+
if (this._sessionOptions.background_sync === false)
|
|
1908
|
+
return false;
|
|
1909
|
+
if (this._rpcPipeline?.hasPullActivity?.(ns, false) || this._pendingP2pPullTimers.has(ns))
|
|
1910
|
+
return false;
|
|
1911
|
+
const retries = (this._pendingP2pPullRetries.get(ns) ?? 0) + 1;
|
|
1912
|
+
if (retries > PENDING_P2P_PULL_MAX_RETRIES) {
|
|
1913
|
+
this._pendingP2pPullUpper.delete(ns);
|
|
1914
|
+
this._pendingP2pPullRetries.delete(ns);
|
|
1915
|
+
this._clientLog.warn(`P2P pending pull retries exhausted: ns=${ns}, upper_seq=${upperSeq}, contiguous=${contig}, reason=${reason}`);
|
|
1857
1916
|
return false;
|
|
1858
|
-
|
|
1859
|
-
this.
|
|
1860
|
-
this.
|
|
1917
|
+
}
|
|
1918
|
+
this._pendingP2pPullRetries.set(ns, retries);
|
|
1919
|
+
this._clientLog.info(`P2P pending push follow-up pull scheduled: ns=${ns}, upper_seq=${upperSeq}, contiguous=${contig}, retry=${retries}, reason=${reason}`);
|
|
1920
|
+
const timer = setTimeout(() => {
|
|
1921
|
+
this._pendingP2pPullTimers.delete(ns);
|
|
1922
|
+
const currentUpper = this._pendingP2pPullUpper.get(ns) ?? 0;
|
|
1923
|
+
if (currentUpper <= 0 || currentUpper <= this._seqTracker.getContiguousSeq(ns)) {
|
|
1924
|
+
this._pendingP2pPullUpper.delete(ns);
|
|
1925
|
+
this._pendingP2pPullRetries.delete(ns);
|
|
1926
|
+
return;
|
|
1927
|
+
}
|
|
1928
|
+
// 暂时移除上界,避免 synthetic push 被 hasPullActivity 当成自身的 pending pull 拦截。
|
|
1929
|
+
this._pendingP2pPullUpper.delete(ns);
|
|
1930
|
+
const retry = this._onV2PushNotification({ seq: currentUpper }, 'v2')
|
|
1931
|
+
.then(() => {
|
|
1932
|
+
if (this._seqTracker.getContiguousSeq(ns) < currentUpper) {
|
|
1933
|
+
const pending = this._pendingP2pPullUpper.get(ns) ?? 0;
|
|
1934
|
+
if (currentUpper > pending)
|
|
1935
|
+
this._pendingP2pPullUpper.set(ns, currentUpper);
|
|
1936
|
+
}
|
|
1937
|
+
})
|
|
1938
|
+
.catch((error) => {
|
|
1939
|
+
const pending = this._pendingP2pPullUpper.get(ns) ?? 0;
|
|
1940
|
+
if (currentUpper > pending)
|
|
1941
|
+
this._pendingP2pPullUpper.set(ns, currentUpper);
|
|
1942
|
+
throw error;
|
|
1943
|
+
})
|
|
1944
|
+
.finally(() => {
|
|
1945
|
+
this._schedulePendingP2pPullIfNeeded(ns, 'pending-pull-retry-complete');
|
|
1946
|
+
});
|
|
1947
|
+
this._safeAsync(retry);
|
|
1948
|
+
}, PENDING_P2P_PULL_DELAY_MS);
|
|
1949
|
+
this._pendingP2pPullTimers.set(ns, timer);
|
|
1861
1950
|
return true;
|
|
1862
1951
|
}
|
|
1863
1952
|
_markPublishedSeq(ns, seq) {
|
|
@@ -2169,6 +2258,10 @@ export class AUNClient {
|
|
|
2169
2258
|
}
|
|
2170
2259
|
const paramsHash = String(cs.params_hash ?? '');
|
|
2171
2260
|
const timestamp = String(cs.timestamp ?? '');
|
|
2261
|
+
const signedAt = Number(timestamp) * 1000;
|
|
2262
|
+
if (!/^\d+$/.test(timestamp) || !Number.isSafeInteger(Number(timestamp)) || signedAt < new Date(certObj.validFrom).getTime() || signedAt > new Date(certObj.validTo).getTime()) {
|
|
2263
|
+
return false;
|
|
2264
|
+
}
|
|
2172
2265
|
const signData = Buffer.from(`${method}|${sigAid}|${timestamp}|${paramsHash}`, 'utf-8');
|
|
2173
2266
|
const sigB64 = String(cs.signature ?? '');
|
|
2174
2267
|
const pubKey = certObj.publicKey;
|
|
@@ -2397,6 +2490,10 @@ export class AUNClient {
|
|
|
2397
2490
|
this._pushedSeqs.clear();
|
|
2398
2491
|
this._pendingOrderedMsgs.clear();
|
|
2399
2492
|
this._pendingP2pPullUpper.clear();
|
|
2493
|
+
for (const timer of this._pendingP2pPullTimers.values())
|
|
2494
|
+
clearTimeout(timer);
|
|
2495
|
+
this._pendingP2pPullTimers.clear();
|
|
2496
|
+
this._pendingP2pPullRetries.clear();
|
|
2400
2497
|
this._v2SenderIKPending.clear();
|
|
2401
2498
|
this._v2SenderIKFetching.clear();
|
|
2402
2499
|
this._groupSynced.clear();
|
|
@@ -2413,6 +2510,10 @@ export class AUNClient {
|
|
|
2413
2510
|
this._pushedSeqs.clear();
|
|
2414
2511
|
this._pendingOrderedMsgs.clear();
|
|
2415
2512
|
this._pendingP2pPullUpper.clear();
|
|
2513
|
+
for (const timer of this._pendingP2pPullTimers.values())
|
|
2514
|
+
clearTimeout(timer);
|
|
2515
|
+
this._pendingP2pPullTimers.clear();
|
|
2516
|
+
this._pendingP2pPullRetries.clear();
|
|
2416
2517
|
this._v2SenderIKPending.clear();
|
|
2417
2518
|
this._v2SenderIKFetching.clear();
|
|
2418
2519
|
this._groupSynced.clear();
|
|
@@ -3023,8 +3124,8 @@ export class AUNClient {
|
|
|
3023
3124
|
return await this._v2E2EE.pullV2(afterSeq, limit, opts);
|
|
3024
3125
|
}
|
|
3025
3126
|
/** V2 P2P ack,并触发旧 SPK 销毁自检。 */
|
|
3026
|
-
async _ackV2(upToSeq) {
|
|
3027
|
-
return await this._v2E2EE.ackV2(upToSeq);
|
|
3127
|
+
async _ackV2(upToSeq, opts) {
|
|
3128
|
+
return await this._v2E2EE.ackV2(upToSeq, opts);
|
|
3028
3129
|
}
|
|
3029
3130
|
/** V2 Group 加密发送,推测性缓存失败后刷新 bootstrap 重试一次。 */
|
|
3030
3131
|
async _sendGroupV2(groupId, payload, opts) {
|
|
@@ -3134,7 +3235,6 @@ export class AUNClient {
|
|
|
3134
3235
|
seq: msg.seq,
|
|
3135
3236
|
timestamp: (msg.t_server ?? msg.timestamp),
|
|
3136
3237
|
device_id: String(msg.device_id ?? ''),
|
|
3137
|
-
slot_id: String(msg.slot_id ?? ''),
|
|
3138
3238
|
_decrypt_error: String(formatCaughtError(exc)),
|
|
3139
3239
|
_decrypt_stage: 'spk_lookup',
|
|
3140
3240
|
_envelope_type: String(envelope.type ?? ''),
|
|
@@ -3175,7 +3275,6 @@ export class AUNClient {
|
|
|
3175
3275
|
seq: msg.seq,
|
|
3176
3276
|
timestamp: (msg.t_server ?? msg.timestamp),
|
|
3177
3277
|
device_id: String(msg.device_id ?? ''),
|
|
3178
|
-
slot_id: String(msg.slot_id ?? ''),
|
|
3179
3278
|
_decrypt_error: 'sender_ik_not_found',
|
|
3180
3279
|
_decrypt_stage: 'sender_ik',
|
|
3181
3280
|
_envelope_type: String(envelope.type ?? ''),
|
|
@@ -3205,7 +3304,6 @@ export class AUNClient {
|
|
|
3205
3304
|
seq: msg.seq,
|
|
3206
3305
|
timestamp: (msg.t_server ?? msg.timestamp),
|
|
3207
3306
|
device_id: String(msg.device_id ?? ''),
|
|
3208
|
-
slot_id: String(msg.slot_id ?? ''),
|
|
3209
3307
|
_decrypt_error: String(formatCaughtError(exc)),
|
|
3210
3308
|
_decrypt_stage: 'decrypt',
|
|
3211
3309
|
_envelope_type: String(envelope.type ?? ''),
|
|
@@ -3235,12 +3333,15 @@ export class AUNClient {
|
|
|
3235
3333
|
encrypted: true,
|
|
3236
3334
|
e2ee,
|
|
3237
3335
|
};
|
|
3336
|
+
if (senderDeviceId)
|
|
3337
|
+
result.sender_device_id = senderDeviceId;
|
|
3238
3338
|
const explicitDirection = String(msg.direction ?? '').trim();
|
|
3239
|
-
|
|
3339
|
+
if (explicitDirection)
|
|
3340
|
+
result.direction = explicitDirection;
|
|
3341
|
+
else if (fromAid && fromAid !== this._aid)
|
|
3342
|
+
result.direction = 'inbound';
|
|
3240
3343
|
if (msg.device_id !== undefined)
|
|
3241
3344
|
result.device_id = msg.device_id;
|
|
3242
|
-
if (msg.slot_id !== undefined)
|
|
3243
|
-
result.slot_id = msg.slot_id;
|
|
3244
3345
|
attachGatewayProximity(result, msg);
|
|
3245
3346
|
this._attachV2EnvelopeMetadata(result, e2ee);
|
|
3246
3347
|
if (groupIdForKeys)
|
|
@@ -3437,8 +3538,8 @@ export class AUNClient {
|
|
|
3437
3538
|
return this._delivery.onRawGroupV2MessageCreated(data, expectedVersion, inlineGeneration);
|
|
3438
3539
|
}
|
|
3439
3540
|
/** Push 通知带 payload 时的就地解密(复用 _decryptV2Message) */
|
|
3440
|
-
async _decryptV2PushMessage(data) {
|
|
3441
|
-
return await this._v2E2EE.decryptV2PushMessage(data);
|
|
3541
|
+
async _decryptV2PushMessage(data, deferStatus) {
|
|
3542
|
+
return await this._v2E2EE.decryptV2PushMessage(data, deferStatus);
|
|
3442
3543
|
}
|
|
3443
3544
|
/** 按当前 AID 发现 Gateway;用于 authenticate()/connect() 的新入口。 */
|
|
3444
3545
|
async _resolveGatewayForAid(aid) {
|