@agentunion/fastaun 0.5.21 → 0.5.22
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 +58 -1
- package/_packed_docs/CHANGELOG.md +58 -1
- package/_packed_docs/INDEX.md +465 -453
- package/_packed_docs/KITE_DOCS_GUIDE.md +168 -164
- 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 +307 -67
- package/_packed_docs/aun/346/265/213/350/257/225/350/277/220/350/241/214/346/214/207/345/215/227.md +41 -15
- package/_packed_docs/protocol/06-/346/234/215/345/212/241/345/215/217/350/256/256.md +5 -5
- package/_packed_docs/protocol/11-Storage-/345/255/220/345/215/217/350/256/256.md +30 -8
- package/_packed_docs/protocol/Ownership/345/215/217/350/256/256/345/256/232/344/271/2112.1.md +669 -666
- package/_packed_docs/sdk/0.5.22-SDK/345/272/224/347/224/250/351/233/206/346/210/220/346/214/207/345/215/227.md +212 -0
- package/_packed_docs/sdk/0.5.22-SDK/345/274/200/345/217/221/344/270/216/347/247/273/346/244/215/346/214/207/345/215/227.md +199 -0
- package/_packed_docs/sdk/06-API/346/211/213/345/206/214.md +16 -0
- package/_packed_docs/sdk/09-group-rpc-manual.md +10 -0
- package/_packed_docs/sdk/09-storage-rpc-manual.md +64 -7
- package/_packed_docs/sdk/09-/345/207/255/350/257/201/346/234/215/345/212/241RPC/346/211/213/345/206/214.md +3 -1
- package/_packed_docs/sdk/09-/347/273/204/347/273/207/346/234/215/345/212/241RPC/346/211/213/345/206/214.md +2 -0
- package/_packed_docs/sdk/AUN_DOCS_GUIDE.md +138 -134
- package/_packed_docs/sdk/INDEX.md +255 -239
- package/_packed_docs/sdk/Ownership-SDK/347/274/226/346/216/222/346/214/207/345/215/2272.1.md +939 -930
- package/_packed_docs/sdk/Ownership2.1-SDK/345/272/224/347/224/250/351/233/206/346/210/220/346/214/207/345/215/227.md +312 -363
- package/_packed_docs/sdk/Ownership2.1-SDK/345/274/200/345/217/221/344/270/216/347/247/273/346/244/215/346/214/207/345/215/227.md +322 -553
- package/_packed_docs/sdk/Ownership2.1-TDD/345/210/206/351/230/266/346/256/265/345/256/236/346/226/275/350/256/241/345/210/222.md +4 -4
- package/_packed_docs/sdk/Ownership2.1/350/257/246/347/273/206/350/256/276/350/256/241.md +484 -480
- package/_packed_docs/sdk//345/207/255/350/257/201/344/270/216/347/273/204/347/273/207/346/234/215/345/212/241SDK/345/272/224/347/224/250/351/233/206/346/210/220/346/214/207/345/215/227.md +190 -97
- package/_packed_docs/sdk//345/207/255/350/257/201/344/270/216/347/273/204/347/273/207/346/234/215/345/212/241SDK/345/274/200/345/217/221/344/270/216/347/247/273/346/244/215/346/214/207/345/215/227.md +158 -127
- package/dist/agent-md.d.ts +1 -1
- package/dist/agent-md.js +11 -4
- package/dist/agent-md.js.map +1 -1
- package/dist/auth.d.ts +1 -0
- package/dist/auth.js +18 -2
- package/dist/auth.js.map +1 -1
- package/dist/client/delivery.d.ts +28 -0
- package/dist/client/delivery.js +399 -44
- package/dist/client/delivery.js.map +1 -1
- package/dist/client/group-state.js +3 -0
- package/dist/client/group-state.js.map +1 -1
- package/dist/client/rpc-pipeline.js +28 -2
- package/dist/client/rpc-pipeline.js.map +1 -1
- package/dist/client/v2-e2ee.js +109 -39
- package/dist/client/v2-e2ee.js.map +1 -1
- package/dist/client.js +38 -10
- package/dist/client.js.map +1 -1
- package/dist/group-fs.d.ts +1 -0
- package/dist/group-fs.js +37 -19
- package/dist/group-fs.js.map +1 -1
- package/dist/org-protocol.d.ts +1 -0
- package/dist/org-protocol.js +54 -7
- package/dist/org-protocol.js.map +1 -1
- package/dist/ownership-v21.d.ts +21 -3
- package/dist/ownership-v21.js +135 -37
- package/dist/ownership-v21.js.map +1 -1
- package/dist/ownership-workflow.d.ts +7 -2
- package/dist/ownership-workflow.js +173 -17
- package/dist/ownership-workflow.js.map +1 -1
- package/dist/storage/lowlevel.d.ts +6 -0
- package/dist/storage/lowlevel.js +24 -7
- package/dist/storage/lowlevel.js.map +1 -1
- package/dist/storage/read-cache.d.ts +70 -0
- package/dist/storage/read-cache.js +625 -0
- package/dist/storage/read-cache.js.map +1 -0
- package/dist/storage/vfs.d.ts +2 -0
- package/dist/storage/vfs.js +50 -15
- package/dist/storage/vfs.js.map +1 -1
- package/dist/tools/cross-sdk-agent.d.ts +21 -1
- package/dist/tools/cross-sdk-agent.js +301 -19
- package/dist/tools/cross-sdk-agent.js.map +1 -1
- package/dist/transport.js +6 -2
- 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
|
@@ -495,10 +495,10 @@ export class AUNClient {
|
|
|
495
495
|
currentType: () => this.getType(),
|
|
496
496
|
now: () => Math.trunc(Date.now() / 1000),
|
|
497
497
|
readAgentMdFresh: (subAid) => this._agentMdManager.readOwnershipFresh(subAid),
|
|
498
|
-
submitAgentMdRaw: (subAid, raw, condition, assertActive) => this._agentMdManager.submitOwnershipRaw(subAid, raw, condition, assertActive),
|
|
498
|
+
submitAgentMdRaw: (subAid, raw, condition, assertActive, stage) => this._agentMdManager.submitOwnershipRaw(subAid, raw, condition, assertActive, stage),
|
|
499
499
|
readOwnerMd: (ownerAid, subAid) => this._getOwnershipStorage().readOwnerMd(ownerAid, subAid),
|
|
500
500
|
writeOwnerMd: (ownerAid, subAid, raw, original, assertActive) => this._getOwnershipStorage().writeOwnerMd(ownerAid, subAid, raw, original, assertActive),
|
|
501
|
-
deleteOwnerMd: (ownerAid, subAid) => this._getOwnershipStorage().deleteOwnerMd(ownerAid, subAid),
|
|
501
|
+
deleteOwnerMd: (ownerAid, subAid, expectedVersion) => this._getOwnershipStorage().deleteOwnerMd(ownerAid, subAid, expectedVersion),
|
|
502
502
|
resolveCertificate: async (aid, fingerprint, purpose) => this._auth.resolveOwnershipCertificate(await this._resolveOwnershipCertificateGateway(aid), aid, fingerprint, purpose),
|
|
503
503
|
});
|
|
504
504
|
}
|
|
@@ -506,7 +506,7 @@ export class AUNClient {
|
|
|
506
506
|
return this._ownershipWorkflow ??= new OwnershipWorkflow({
|
|
507
507
|
currentAid: () => this._aid, store: this._tokenStore, files: this._getOwnershipFiles(),
|
|
508
508
|
currentType: () => this.getType(),
|
|
509
|
-
send: (to, payload) => this.call('message.send', { to, encrypt: true, payload: payload }),
|
|
509
|
+
send: (to, payload, messageId) => this.call('message.send', { to, encrypt: true, message_id: messageId, payload: payload }),
|
|
510
510
|
emit: (event, payload) => this._dispatcher.enqueue(event, payload),
|
|
511
511
|
});
|
|
512
512
|
}
|
|
@@ -647,11 +647,11 @@ export class AUNClient {
|
|
|
647
647
|
_credentialCurrent(input) {
|
|
648
648
|
return this._getCredentialRenewal().current(input);
|
|
649
649
|
}
|
|
650
|
-
async _resumeCredentialRenewalAfterConnect(guard) {
|
|
650
|
+
async _resumeCredentialRenewalAfterConnect(guard, syncRevocations = false) {
|
|
651
651
|
if (!this._aid || (guard && !guard.current()))
|
|
652
652
|
return;
|
|
653
653
|
await this._safeAsync(guard ? this._credentialRenewalSigner(this._aid, guard) : this._credentialRenewalSigner(this._aid));
|
|
654
|
-
if (!guard || guard.current())
|
|
654
|
+
if (syncRevocations && (!guard || guard.current()))
|
|
655
655
|
await this._safeAsync(this._getCredentialRenewal()._syncRevocations?.(guard) ?? Promise.resolve());
|
|
656
656
|
if (!guard || guard.current())
|
|
657
657
|
await this._getCredentialRenewal().resume(guard);
|
|
@@ -665,11 +665,15 @@ export class AUNClient {
|
|
|
665
665
|
this._credentialRenewalAbort = abort;
|
|
666
666
|
const current = () => this._credentialRenewalAbort === abort && !abort.signal.aborted && aid === this._aid && version === this._serviceEventIdentityVersion && ['ready', 'connected'].includes(this._state) && !this._closing && !this._disconnecting;
|
|
667
667
|
const guard = { current, signal: abort.signal };
|
|
668
|
+
let nextRevocationSync = Date.now() + 3_600_000;
|
|
668
669
|
const scan = async () => {
|
|
669
670
|
const task = this._credentialRenewalScan.then(async () => {
|
|
670
671
|
if (!current())
|
|
671
672
|
return;
|
|
672
|
-
|
|
673
|
+
const syncRevocations = Date.now() >= nextRevocationSync;
|
|
674
|
+
if (syncRevocations)
|
|
675
|
+
nextRevocationSync = Date.now() + 3_600_000;
|
|
676
|
+
await this._resumeCredentialRenewalAfterConnect(guard, syncRevocations);
|
|
673
677
|
});
|
|
674
678
|
this._credentialRenewalScan = task.catch(() => { });
|
|
675
679
|
await this._safeAsync(task);
|
|
@@ -701,10 +705,14 @@ export class AUNClient {
|
|
|
701
705
|
const version = this._serviceEventIdentityVersion;
|
|
702
706
|
const signal = this._serviceEventIdentityAbort.signal;
|
|
703
707
|
const expiresAt = Number(payload?.expires_at);
|
|
704
|
-
const
|
|
708
|
+
const transport = this._transport, connectionGeneration = transport?._connectionGeneration, workerGeneration = transport?._workerGeneration;
|
|
709
|
+
const current = () => version === this._serviceEventIdentityVersion && targetAid === (this._identity?.aid ?? '') && transport === this._transport && connectionGeneration === this._transport?._connectionGeneration && workerGeneration === this._transport?._workerGeneration && Date.now() / 1000 < expiresAt;
|
|
705
710
|
const verified = await verifyServiceEvent(event, payload, { targetAid, resolveEventCertificate: (aid, fingerprint) => this._fetchServiceEventCertificate(aid, fingerprint), resolveCredentialService: this.resolveCredentialService });
|
|
706
711
|
if (!current())
|
|
707
712
|
throw new ValidationError('service event receiver identity changed');
|
|
713
|
+
if (['credential.revoked', 'credential.revocationList'].includes(event.replace(/^event\//, ''))) {
|
|
714
|
+
await this._getCredentialRenewal()._receiveRevocations(payload, { current, signal });
|
|
715
|
+
}
|
|
708
716
|
if (event.replace(/^event\//, '') === 'org.member.changed' && isJsonObject(payload) && Object.hasOwn(payload, 'membership_package')) {
|
|
709
717
|
await this._getCredentialRenewal().importMembershipPackage(payload, { current, signal });
|
|
710
718
|
if (!current())
|
|
@@ -1614,6 +1622,9 @@ export class AUNClient {
|
|
|
1614
1622
|
if (!isJsonObject(raw))
|
|
1615
1623
|
continue;
|
|
1616
1624
|
const group = raw;
|
|
1625
|
+
const status = String(group.status ?? '').trim().toLowerCase();
|
|
1626
|
+
if (status && status !== 'active')
|
|
1627
|
+
continue;
|
|
1617
1628
|
const role = String(group.role ?? group.my_role ?? '').trim().toLowerCase();
|
|
1618
1629
|
const groupId = String(group.group_id ?? group.groupId ?? group.group_aid ?? group.groupAid ?? '').trim();
|
|
1619
1630
|
const groupAid = String(group.group_aid ?? group.groupAid ?? groupId).trim();
|
|
@@ -1753,7 +1764,7 @@ export class AUNClient {
|
|
|
1753
1764
|
await this.createOrg(creation.source_params, { aidStore: store });
|
|
1754
1765
|
continue;
|
|
1755
1766
|
}
|
|
1756
|
-
if (transfer?.owner_aid === this._aid) {
|
|
1767
|
+
if (transfer?.owner_aid === this._aid && transfer.phase !== 'completed') {
|
|
1757
1768
|
await this.completeOrgTransfer(transfer.source_params, { aidStore: store });
|
|
1758
1769
|
continue;
|
|
1759
1770
|
}
|
|
@@ -1817,8 +1828,14 @@ export class AUNClient {
|
|
|
1817
1828
|
let pending = (typeof tokenStore._loadMetadataStrict === 'function' ? tokenStore._loadMetadataStrict(orgAid) : tokenStore.loadMetadata(orgAid))?.org_identity_transfer;
|
|
1818
1829
|
if (pending != null && !isJsonObject(pending))
|
|
1819
1830
|
throw ownershipFailure('persistence_unavailable', 'Org transfer checkpoint is invalid');
|
|
1831
|
+
if (pending?.phase === 'completed' && pending.transfer_id !== transferId)
|
|
1832
|
+
pending = undefined;
|
|
1820
1833
|
if (pending && (pending.transfer_id !== transferId || pending.owner_aid !== owner.aid || pending.input_hash !== inputHash))
|
|
1821
1834
|
throw ownershipFailure('conflict', 'pending Org transfer context changed');
|
|
1835
|
+
if (pending?.phase === 'completed') {
|
|
1836
|
+
localStore.clearPendingGroupBind(pendingKey);
|
|
1837
|
+
return pending.result;
|
|
1838
|
+
}
|
|
1822
1839
|
if (!pending)
|
|
1823
1840
|
await this._verifyOrgTransferMaterials(params, owner.aid);
|
|
1824
1841
|
let keyPair = localStore.loadPendingGroupBind(pendingKey);
|
|
@@ -1879,7 +1896,7 @@ export class AUNClient {
|
|
|
1879
1896
|
}
|
|
1880
1897
|
const result = await this.call('org.lifecycle.transferAccept', await this._resumeOrgRequest('org.lifecycle.transferAccept', pending.finalize_params, target));
|
|
1881
1898
|
await this._uploadOrgAgentMd(store, orgAid, pending.source_params);
|
|
1882
|
-
tokenStore.saveMetadata(orgAid, { org_identity_transfer:
|
|
1899
|
+
tokenStore.saveMetadata(orgAid, { org_identity_transfer: { transfer_id: transferId, owner_aid: owner.aid, input_hash: inputHash, phase: 'completed', result } });
|
|
1883
1900
|
localStore.clearPendingGroupBind(pendingKey);
|
|
1884
1901
|
return result;
|
|
1885
1902
|
}
|
|
@@ -2132,7 +2149,13 @@ export class AUNClient {
|
|
|
2132
2149
|
entityIdentityGetter: (aid, type) => this._freshEntityCertificate(aid, type),
|
|
2133
2150
|
entitySignerResolver: (aid, fingerprint) => this._freshEntitySigner(aid, fingerprint),
|
|
2134
2151
|
gatewayResolver: (aid) => identityStore._resolveGateway(aid),
|
|
2135
|
-
accessTokenResolver: (
|
|
2152
|
+
accessTokenResolver: async () => {
|
|
2153
|
+
const state = identityStore._tokenStore?.loadInstanceState?.(identity.aid, store.deviceId, store.slotId) ?? {};
|
|
2154
|
+
const token = AuthFlow._getCachedAccessToken(state);
|
|
2155
|
+
if (token && String(state.refresh_token ?? '') && !this._auth._validateCachedCredentials(identityStore._authIdentityFromAid(identity)))
|
|
2156
|
+
return token;
|
|
2157
|
+
return identityStore._uploadAgentMdToken(identity, await identityStore._resolveGateway(identity.aid));
|
|
2158
|
+
},
|
|
2136
2159
|
aidValidator: (aid) => identityStore._registerFlow.validateAidName(aid),
|
|
2137
2160
|
});
|
|
2138
2161
|
return await manager.resumePendingUpload(groupAid);
|
|
@@ -2607,6 +2630,11 @@ export class AUNClient {
|
|
|
2607
2630
|
const tStart = Date.now();
|
|
2608
2631
|
this._clientLog.debug(`on enter: event=${event}`);
|
|
2609
2632
|
const result = this._dispatcher.subscribe(event, handler);
|
|
2633
|
+
if (event === 'message.received' || event === 'message.recalled' || event === 'message.batch') {
|
|
2634
|
+
if (this._p2pPeerPullEnabled)
|
|
2635
|
+
this._delivery.refreshPendingPeers();
|
|
2636
|
+
this._delivery.requestBackgroundPullRecovery();
|
|
2637
|
+
}
|
|
2610
2638
|
this._clientLog.debug(`on exit: elapsed=${Date.now() - tStart}ms event=${event}`);
|
|
2611
2639
|
return result;
|
|
2612
2640
|
}
|