@agentunion/fastaun-browser 0.4.2 → 0.4.3
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 +14 -0
- package/_packed_docs/0.4.0_/345/267/256/345/274/202/346/240/270/345/256/236/345/206/263/347/255/226/350/256/260/345/275/225.md +302 -0
- package/_packed_docs/AUN_SDK_0.4.0_/350/256/276/350/256/241/345/257/271/346/257/224/345/210/206/346/236/220.md +194 -0
- package/_packed_docs/CHANGELOG.md +14 -0
- package/_packed_docs/sdk/01-/345/277/253/351/200/237/345/274/200/345/247/213.md +6 -2
- package/_packed_docs/sdk/03-/346/240/270/345/277/203/346/246/202/345/277/265.md +1 -1
- package/_packed_docs/sdk/04-/350/277/236/346/216/245/344/270/216/350/256/244/350/257/201.md +3 -1
- package/_packed_docs/sdk/06-API/346/211/213/345/206/214.md +62 -15
- package/_packed_docs/sdk/README.md +5 -5
- package/dist/aid-store.d.ts.map +1 -1
- package/dist/aid-store.js +5 -6
- package/dist/aid-store.js.map +1 -1
- package/dist/bundle.js +63 -47
- package/dist/client.d.ts +6 -16
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +44 -44
- package/dist/client.js.map +1 -1
- package/dist/config.d.ts +4 -7
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +18 -1
- package/dist/config.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/keystore/indexeddb.js +5 -5
- package/dist/keystore/indexeddb.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.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type AUNConfig } from './config.js';
|
|
2
2
|
import { type EventHandler, type Subscription } from './events.js';
|
|
3
3
|
import { GatewayDiscovery } from './discovery.js';
|
|
4
|
-
import { ConnectionState, type RpcParams, type RpcResult } from './types.js';
|
|
4
|
+
import { ConnectionState, type JsonObject, type RpcParams, type RpcResult } from './types.js';
|
|
5
5
|
import { AID } from './aid.js';
|
|
6
6
|
export interface ConnectionOptions {
|
|
7
7
|
auto_reconnect?: boolean;
|
|
@@ -11,21 +11,11 @@ export interface ConnectionOptions {
|
|
|
11
11
|
retry_max_attempts?: number;
|
|
12
12
|
heartbeat_interval?: number;
|
|
13
13
|
call_timeout?: number;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
verify_ssl?: boolean;
|
|
20
|
-
verifySSL?: boolean;
|
|
21
|
-
verifySsl?: boolean;
|
|
22
|
-
require_forward_secrecy?: boolean;
|
|
23
|
-
requireForwardSecrecy?: boolean;
|
|
24
|
-
replay_window_seconds?: number;
|
|
25
|
-
replayWindowSeconds?: number;
|
|
26
|
-
debug?: boolean;
|
|
27
|
-
protected_headers?: Record<string, unknown> | null;
|
|
28
|
-
aid?: never;
|
|
14
|
+
connection_kind?: string;
|
|
15
|
+
short_ttl_ms?: number;
|
|
16
|
+
delivery_mode?: JsonObject;
|
|
17
|
+
extra_info?: JsonObject;
|
|
18
|
+
background_sync?: boolean;
|
|
29
19
|
}
|
|
30
20
|
/**
|
|
31
21
|
* AUN Core SDK 客户端 — 浏览器版本。
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAOA,OAAO,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAOA,OAAO,EAAqF,KAAK,SAAS,EAAE,MAAM,aAAa,CAAC;AAChI,OAAO,EAAsC,KAAK,YAAY,EAAE,KAAK,YAAY,EAAE,MAAM,aAAa,CAAC;AAEvG,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAqClD,OAAO,EAEL,eAAe,EAGf,KAAK,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mBAAmB;IAiB3B,OAAO,CAAC,gBAAgB;YAQV,kBAAkB;IAmBhC,iBAAiB;IACjB,OAAO,CAAC,MAAM;CAKf"}
|
package/dist/client.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
// - HTTP 使用 fetch() 而非 Node http
|
|
5
5
|
// - 无文件系统(IndexedDB via keystore)
|
|
6
6
|
// - 后台任务使用 setTimeout/setInterval
|
|
7
|
-
import { createConfig, getDeviceId, normalizeInstanceId } from './config.js';
|
|
7
|
+
import { createConfig, getDeviceId, normalizeInstanceId, normalizeSlotId, slotIsolationKey } from './config.js';
|
|
8
8
|
import { EventDispatcher } from './events.js';
|
|
9
9
|
import { normalizeGroupId } from './group-id.js';
|
|
10
10
|
import { GatewayDiscovery } from './discovery.js';
|
|
@@ -609,22 +609,6 @@ function normalizeDeliveryModeConfig(raw, opts = {}) {
|
|
|
609
609
|
affinity_ttl_ms: affinityTtlMs,
|
|
610
610
|
};
|
|
611
611
|
}
|
|
612
|
-
function assertClientOptions(value, label) {
|
|
613
|
-
if (value == null)
|
|
614
|
-
return;
|
|
615
|
-
if (typeof value !== 'object' || Array.isArray(value) || value instanceof AID) {
|
|
616
|
-
throw new ValidationError(`${label} must be an options object`);
|
|
617
|
-
}
|
|
618
|
-
}
|
|
619
|
-
function clientOptionsConfig(options) {
|
|
620
|
-
const raw = { ...(options ?? {}) };
|
|
621
|
-
if (Object.prototype.hasOwnProperty.call(raw, 'aid')) {
|
|
622
|
-
throw new ValidationError('AUNClient options must not include aid; pass an AID object as the first argument');
|
|
623
|
-
}
|
|
624
|
-
delete raw.debug;
|
|
625
|
-
delete raw.protected_headers;
|
|
626
|
-
return raw;
|
|
627
|
-
}
|
|
628
612
|
/**
|
|
629
613
|
* AUN Core SDK 客户端 — 浏览器版本。
|
|
630
614
|
*
|
|
@@ -748,17 +732,16 @@ export class AUNClient {
|
|
|
748
732
|
_logDiscovery;
|
|
749
733
|
_logEvents;
|
|
750
734
|
constructor(aid) {
|
|
751
|
-
const inputAid = aid
|
|
735
|
+
const inputAid = (aid !== null && aid !== undefined && typeof aid.aunPath === 'string' && typeof aid.isPrivateKeyValid === 'function') ? aid : null;
|
|
752
736
|
if (typeof aid === 'string') {
|
|
753
737
|
throw new ValidationError('AUNClient aid must be an AID object, not a string');
|
|
754
738
|
}
|
|
755
|
-
const
|
|
756
|
-
const rawConfig = clientOptionsConfig(options);
|
|
739
|
+
const rawConfig = {};
|
|
757
740
|
if (inputAid)
|
|
758
741
|
rawConfig.aun_path = inputAid.aunPath;
|
|
759
|
-
const _debug = false;
|
|
742
|
+
const _debug = inputAid ? inputAid.debug : false;
|
|
760
743
|
this.configModel = createConfig(rawConfig);
|
|
761
|
-
const initAid = inputAid ? inputAid.aid : null;
|
|
744
|
+
const initAid = (inputAid && inputAid.isPrivateKeyValid()) ? inputAid.aid : null;
|
|
762
745
|
this.config = {
|
|
763
746
|
aun_path: this.configModel.aunPath,
|
|
764
747
|
root_ca_path: this.configModel.rootCaPem,
|
|
@@ -803,19 +786,16 @@ export class AUNClient {
|
|
|
803
786
|
});
|
|
804
787
|
});
|
|
805
788
|
if (inputAid) {
|
|
806
|
-
if (
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
}
|
|
817
|
-
if (options?.protected_headers !== undefined) {
|
|
818
|
-
this.setProtectedHeaders(options.protected_headers);
|
|
789
|
+
if (inputAid.isPrivateKeyValid()) {
|
|
790
|
+
this._currentAid = inputAid;
|
|
791
|
+
this._identity = {
|
|
792
|
+
aid: inputAid.aid,
|
|
793
|
+
private_key_pem: inputAid._privateKeyPem ?? '',
|
|
794
|
+
public_key_der_b64: inputAid.publicKey,
|
|
795
|
+
cert: inputAid.certPem,
|
|
796
|
+
};
|
|
797
|
+
this._state = 'disconnected';
|
|
798
|
+
}
|
|
819
799
|
}
|
|
820
800
|
// 注入 logger 到各子模块(构造时未传 logger,构造后通过 setLogger 注入)
|
|
821
801
|
this._auth.setLogger(this._logAuth);
|
|
@@ -1062,7 +1042,7 @@ export class AUNClient {
|
|
|
1062
1042
|
*/
|
|
1063
1043
|
async publishAgentMd(content) {
|
|
1064
1044
|
const target = this._agentMdOwnerAid();
|
|
1065
|
-
if (!target) {
|
|
1045
|
+
if (!target || !this._currentAid) {
|
|
1066
1046
|
throw new ValidationError('publishAgentMd requires local AID');
|
|
1067
1047
|
}
|
|
1068
1048
|
if (content !== undefined && content !== null) {
|
|
@@ -1600,6 +1580,7 @@ export class AUNClient {
|
|
|
1600
1580
|
cert: aid.certPem,
|
|
1601
1581
|
};
|
|
1602
1582
|
this._auth._aid = aid.aid;
|
|
1583
|
+
this._slotId = aid.slotId || 'default';
|
|
1603
1584
|
this._state = 'disconnected';
|
|
1604
1585
|
this._closing = false;
|
|
1605
1586
|
}
|
|
@@ -1695,6 +1676,16 @@ export class AUNClient {
|
|
|
1695
1676
|
/** 连接到 Gateway;身份来自构造函数或 loadIdentity(aid),认证由 SDK 内部自动完成。 */
|
|
1696
1677
|
async connect(opts) {
|
|
1697
1678
|
const tStart = Date.now();
|
|
1679
|
+
if (opts !== undefined && typeof opts === 'object') {
|
|
1680
|
+
const raw = opts;
|
|
1681
|
+
if ('access_token' in raw || 'aid' in raw || 'token' in raw) {
|
|
1682
|
+
throw new ValidationError('connect options must not include access_token/aid; these are managed internally');
|
|
1683
|
+
}
|
|
1684
|
+
}
|
|
1685
|
+
const target = this._currentAid?.aid ?? this._aid ?? '';
|
|
1686
|
+
if (!target || !this._currentAid?.isPrivateKeyValid()) {
|
|
1687
|
+
throw new StateError('connect requires a loaded AID with a valid private key');
|
|
1688
|
+
}
|
|
1698
1689
|
const options = {};
|
|
1699
1690
|
if (opts?.auto_reconnect !== undefined)
|
|
1700
1691
|
options.auto_reconnect = opts.auto_reconnect;
|
|
@@ -1713,11 +1704,17 @@ export class AUNClient {
|
|
|
1713
1704
|
max_attempts: opts.retry_max_attempts ?? 0,
|
|
1714
1705
|
};
|
|
1715
1706
|
}
|
|
1707
|
+
if (opts?.connection_kind !== undefined)
|
|
1708
|
+
options.connection_kind = opts.connection_kind;
|
|
1709
|
+
if (opts?.short_ttl_ms !== undefined)
|
|
1710
|
+
options.short_ttl_ms = opts.short_ttl_ms;
|
|
1711
|
+
if (opts?.delivery_mode !== undefined)
|
|
1712
|
+
options.delivery_mode = opts.delivery_mode;
|
|
1713
|
+
if (opts?.extra_info !== undefined)
|
|
1714
|
+
options.extra_info = opts.extra_info;
|
|
1715
|
+
if (opts?.background_sync !== undefined)
|
|
1716
|
+
options.background_sync = opts.background_sync;
|
|
1716
1717
|
this._clientLog.debug(`connect enter: state=${this._state} aid=${this._aid ?? '-'}`);
|
|
1717
|
-
const target = this._currentAid?.aid ?? this._aid ?? '';
|
|
1718
|
-
if (!target || !this._currentAid?.isPrivateKeyValid()) {
|
|
1719
|
-
throw new StateError('connect requires a loaded AID with a valid private key');
|
|
1720
|
-
}
|
|
1721
1718
|
const publicState = this.state;
|
|
1722
1719
|
const allowed = new Set([
|
|
1723
1720
|
ConnectionState.STANDBY,
|
|
@@ -2790,7 +2787,7 @@ export class AUNClient {
|
|
|
2790
2787
|
}
|
|
2791
2788
|
if ('slot_id' in message) {
|
|
2792
2789
|
const targetSlotId = String(message.slot_id ?? '').trim();
|
|
2793
|
-
if (targetSlotId !== this._slotId) {
|
|
2790
|
+
if (slotIsolationKey(targetSlotId) !== slotIsolationKey(this._slotId)) {
|
|
2794
2791
|
return false;
|
|
2795
2792
|
}
|
|
2796
2793
|
}
|
|
@@ -3717,8 +3714,9 @@ export class AUNClient {
|
|
|
3717
3714
|
this._clientLog.warn(`V2 session init failed (non-fatal): ${String(exc)}`);
|
|
3718
3715
|
}
|
|
3719
3716
|
// connect/reconnect 成功后自动触发一次 P2P message.pull,补齐离线期间积压
|
|
3720
|
-
|
|
3721
|
-
|
|
3717
|
+
if (this._sessionOptions?.background_sync !== false) {
|
|
3718
|
+
this._safeAsync(this._fillP2pGap());
|
|
3719
|
+
}
|
|
3722
3720
|
this._clientLog.debug(`_connectOnce exit: elapsed=${Date.now() - tStart}ms aid=${this._aid ?? '-'}`);
|
|
3723
3721
|
}
|
|
3724
3722
|
catch (err) {
|
|
@@ -3839,7 +3837,7 @@ export class AUNClient {
|
|
|
3839
3837
|
delete request.access_token;
|
|
3840
3838
|
request.gateway = gateway;
|
|
3841
3839
|
request.device_id = this._deviceId;
|
|
3842
|
-
request.slot_id =
|
|
3840
|
+
request.slot_id = normalizeSlotId(request.slot_id ?? this._slotId, this._slotId || 'default');
|
|
3843
3841
|
let deliveryModeRaw = request.delivery_mode;
|
|
3844
3842
|
if (deliveryModeRaw == null) {
|
|
3845
3843
|
deliveryModeRaw = { ...this._defaultConnectDeliveryMode };
|
|
@@ -3914,6 +3912,8 @@ export class AUNClient {
|
|
|
3914
3912
|
if (isJsonObject(params.timeouts)) {
|
|
3915
3913
|
Object.assign(options.timeouts, params.timeouts);
|
|
3916
3914
|
}
|
|
3915
|
+
if ('background_sync' in params)
|
|
3916
|
+
options.background_sync = Boolean(params.background_sync);
|
|
3917
3917
|
return options;
|
|
3918
3918
|
}
|
|
3919
3919
|
// ── 内部:后台任务 ────────────────────────────────
|