@enbox/agent 0.4.0 → 0.5.1
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/dist/browser.mjs +9 -9
- package/dist/browser.mjs.map +4 -4
- package/dist/esm/dwn-api.js +15 -1
- package/dist/esm/dwn-api.js.map +1 -1
- package/dist/esm/enbox-connect-protocol.js +0 -20
- package/dist/esm/enbox-connect-protocol.js.map +1 -1
- package/dist/esm/enbox-user-agent.js +1 -7
- package/dist/esm/enbox-user-agent.js.map +1 -1
- package/dist/esm/hd-identity-vault.js +11 -0
- package/dist/esm/hd-identity-vault.js.map +1 -1
- package/dist/esm/index.js +0 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/sync-engine-level.js +58 -3
- package/dist/esm/sync-engine-level.js.map +1 -1
- package/dist/esm/sync-messages.js +3 -2
- package/dist/esm/sync-messages.js.map +1 -1
- package/dist/esm/test-harness.js +2 -3
- package/dist/esm/test-harness.js.map +1 -1
- package/dist/esm/types/dwn.js.map +1 -1
- package/dist/types/dwn-api.d.ts.map +1 -1
- package/dist/types/enbox-connect-protocol.d.ts +13 -27
- package/dist/types/enbox-connect-protocol.d.ts.map +1 -1
- package/dist/types/enbox-user-agent.d.ts +3 -7
- package/dist/types/enbox-user-agent.d.ts.map +1 -1
- package/dist/types/hd-identity-vault.d.ts +7 -0
- package/dist/types/hd-identity-vault.d.ts.map +1 -1
- package/dist/types/index.d.ts +0 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/sync-engine-level.d.ts.map +1 -1
- package/dist/types/sync-messages.d.ts.map +1 -1
- package/dist/types/test-harness.d.ts.map +1 -1
- package/dist/types/types/agent.d.ts +2 -7
- package/dist/types/types/agent.d.ts.map +1 -1
- package/dist/types/types/dwn.d.ts +0 -10
- package/dist/types/types/dwn.d.ts.map +1 -1
- package/dist/types/types/sync.d.ts +6 -0
- package/dist/types/types/sync.d.ts.map +1 -1
- package/package.json +6 -6
- package/src/dwn-api.ts +17 -1
- package/src/enbox-connect-protocol.ts +14 -39
- package/src/enbox-user-agent.ts +4 -14
- package/src/hd-identity-vault.ts +21 -0
- package/src/index.ts +0 -2
- package/src/sync-engine-level.ts +62 -3
- package/src/sync-messages.ts +3 -2
- package/src/test-harness.ts +2 -3
- package/src/types/agent.ts +3 -14
- package/src/types/dwn.ts +1 -13
- package/src/types/sync.ts +7 -0
- package/src/utils.ts +1 -1
- package/dist/esm/connect.js +0 -176
- package/dist/esm/connect.js.map +0 -1
- package/dist/esm/sync-api.js +0 -64
- package/dist/esm/sync-api.js.map +0 -1
- package/dist/types/connect.d.ts +0 -84
- package/dist/types/connect.d.ts.map +0 -1
- package/dist/types/sync-api.d.ts +0 -40
- package/dist/types/sync-api.d.ts.map +0 -1
- package/src/connect.ts +0 -276
- package/src/sync-api.ts +0 -75
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dwn.d.ts","sourceRoot":"","sources":["../../../src/types/dwn.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEjD,OAAO,KAAK,EACV,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,iBAAiB,EACjB,wBAAwB,EACxB,wBAAwB,EACxB,sBAAsB,EACtB,mBAAmB,EACnB,iBAAiB,EACjB,yBAAyB,EACzB,yBAAyB,EACzB,qBAAqB,EACrB,qBAAqB,EACrB,mBAAmB,EACnB,oBAAoB,EACpB,oBAAoB,EACpB,mBAAmB,EACnB,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,gBAAgB,EAChB,uBAAuB,EACvB,uBAAuB,EACvB,qBAAqB,EACrB,mBAAmB,EACnB,mBAAmB,EACnB,oBAAoB,EACrB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,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AW,EACX,0BAA0B,IAAI,6BAA6B,EAC3D,mBAAmB,IAAI,sBAAsB,EAC7C,eAAe,IAAI,kBAAkB,EACrC,iBAAiB,IAAI,oBAAoB,EACzC,mBAAmB,IAAI,sBAAsB,GAC9C,MAAM,mBAAmB,CAAC;AAG3B,YAAY,EACV,8BAA8B,IAAI,iCAAiC,EACnE,aAAa,IAAI,SAAS,EAC1B,mBAAmB,IAAI,sBAAsB,EAC7C,uBAAuB,IAAI,0BAA0B,EACrD,gBAAgB,IAAI,mBAAmB,EACvC,oBAAoB,IAAI,uBAAuB,EAC/C,mBAAmB,IAAI,sBAAsB,EAC7C,qBAAqB,IAAI,wBAAwB,EACjD,eAAe,IAAI,kBAAkB,EACrC,kBAAkB,IAAI,qBAAqB,EAC3C,uBAAuB,IAAI,0BAA0B,EACrD,YAAY,IAAI,eAAe,EAC/B,sBAAsB,IAAI,yBAAyB,EACnD,oBAAoB,IAAI,uBAAuB,EAC/C,mBAAmB,IAAI,sBAAsB,GAC9C,MAAM,mBAAmB,CAAC"}
|
|
@@ -104,5 +104,11 @@ export interface SyncEngine {
|
|
|
104
104
|
* @throws {Error} if the sync operation fails to stop before the timeout.
|
|
105
105
|
*/
|
|
106
106
|
stopSync(timeout?: number): Promise<void>;
|
|
107
|
+
/**
|
|
108
|
+
* Release all resources held by the sync engine (LevelDB handles, timers,
|
|
109
|
+
* WebSocket subscriptions). After calling `close()`, the engine should not
|
|
110
|
+
* be reused.
|
|
111
|
+
*/
|
|
112
|
+
close(): Promise<void>;
|
|
107
113
|
}
|
|
108
114
|
//# sourceMappingURL=sync.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../../../src/types/sync.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAErD;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC;;OAEG;IACH,WAAW,CAAC,EAAE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,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,mBAAmB,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5F;;;;;OAKG;IACH,IAAI,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACjD;;;;;;OAMG;IACH,SAAS,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAClD;;;;;OAKG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE1C;;;;OAIG;IACH,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@enbox/agent",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/esm/index.js",
|
|
6
6
|
"module": "./dist/esm/index.js",
|
|
@@ -71,11 +71,11 @@
|
|
|
71
71
|
},
|
|
72
72
|
"dependencies": {
|
|
73
73
|
"@scure/bip39": "1.2.2",
|
|
74
|
-
"@enbox/dwn-clients": "0.1
|
|
75
|
-
"@enbox/dwn-sdk-js": "0.
|
|
76
|
-
"@enbox/common": "0.0
|
|
77
|
-
"@enbox/crypto": "0.0
|
|
78
|
-
"@enbox/dids": "0.0
|
|
74
|
+
"@enbox/dwn-clients": "0.2.1",
|
|
75
|
+
"@enbox/dwn-sdk-js": "0.2.0",
|
|
76
|
+
"@enbox/common": "0.1.0",
|
|
77
|
+
"@enbox/crypto": "0.1.0",
|
|
78
|
+
"@enbox/dids": "0.1.0",
|
|
79
79
|
"abstract-level": "1.0.4",
|
|
80
80
|
"ed25519-keygen": "0.4.11",
|
|
81
81
|
"level": "8.0.1",
|
package/src/dwn-api.ts
CHANGED
|
@@ -1183,8 +1183,24 @@ export class AgentDwnApi {
|
|
|
1183
1183
|
};
|
|
1184
1184
|
|
|
1185
1185
|
} else {
|
|
1186
|
-
//
|
|
1186
|
+
// Prefer a locally-stored BearerDid when the agent controls this DID.
|
|
1187
|
+
// This avoids an unnecessary DID resolution round-trip during signing,
|
|
1188
|
+
// which can fail if the resolver path encounters malformed cached data.
|
|
1187
1189
|
try {
|
|
1190
|
+
const localDid = await this.agent.did.get({ didUri: author });
|
|
1191
|
+
if (localDid) {
|
|
1192
|
+
const signer = await localDid.getSigner();
|
|
1193
|
+
|
|
1194
|
+
return {
|
|
1195
|
+
algorithm : signer.algorithm,
|
|
1196
|
+
keyId : signer.keyId,
|
|
1197
|
+
sign : async (data: Uint8Array): Promise<Uint8Array> => {
|
|
1198
|
+
return await signer.sign({ data });
|
|
1199
|
+
}
|
|
1200
|
+
};
|
|
1201
|
+
}
|
|
1202
|
+
|
|
1203
|
+
// Otherwise, use the author's DID to determine the signing method.
|
|
1188
1204
|
const signingMethod = await this.agent.did.getSigningMethod({ didUri: author });
|
|
1189
1205
|
|
|
1190
1206
|
if (!signingMethod.publicKeyJwk) {
|
|
@@ -13,11 +13,24 @@
|
|
|
13
13
|
* and ECDH (Ed25519 → X25519 + HKDF) for key agreement.
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
|
-
import type { ConnectPermissionRequest } from './connect.js';
|
|
17
16
|
import type { EnboxAgent } from './types/agent.js';
|
|
18
17
|
import type { RequireOnly } from '@enbox/common';
|
|
19
18
|
import type { DidDocument, PortableDid } from '@enbox/dids';
|
|
20
19
|
import type { DwnDataEncodedRecordsWriteMessage, DwnPermissionScope, DwnProtocolDefinition } from './types/dwn.js';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* The protocols of permissions requested, along with the definition and permission scopes for each protocol.
|
|
23
|
+
*/
|
|
24
|
+
export type ConnectPermissionRequest = {
|
|
25
|
+
/**
|
|
26
|
+
* The definition of the protocol the permissions are being requested for.
|
|
27
|
+
* In the event that the protocol is not already installed, the wallet will install this given protocol definition.
|
|
28
|
+
*/
|
|
29
|
+
protocolDefinition: DwnProtocolDefinition;
|
|
30
|
+
|
|
31
|
+
/** The scope of the permissions being requested for the given protocol */
|
|
32
|
+
permissionScopes: DwnPermissionScope[];
|
|
33
|
+
};
|
|
21
34
|
import type {
|
|
22
35
|
JoseHeaderParams,
|
|
23
36
|
Jwk } from '@enbox/crypto';
|
|
@@ -139,22 +152,6 @@ export type ConnectEndpoint =
|
|
|
139
152
|
| 'callback'
|
|
140
153
|
| 'token';
|
|
141
154
|
|
|
142
|
-
// ---------------------------------------------------------------------------
|
|
143
|
-
// Deprecated type aliases — kept temporarily for migration
|
|
144
|
-
// ---------------------------------------------------------------------------
|
|
145
|
-
|
|
146
|
-
/** @deprecated Use {@link EnboxConnectRequest} instead. */
|
|
147
|
-
export type EnboxConnectAuthRequest = EnboxConnectRequest;
|
|
148
|
-
|
|
149
|
-
/** @deprecated Use {@link EnboxConnectResponse} instead. */
|
|
150
|
-
export type EnboxConnectAuthResponse = EnboxConnectResponse;
|
|
151
|
-
|
|
152
|
-
/** @deprecated Use {@link ConnectPushedRequest} instead. */
|
|
153
|
-
export type PushedAuthRequest = ConnectPushedRequest;
|
|
154
|
-
|
|
155
|
-
/** @deprecated Use {@link ConnectPushedResponse} instead. */
|
|
156
|
-
export type PushedAuthResponse = ConnectPushedResponse;
|
|
157
|
-
|
|
158
155
|
// ---------------------------------------------------------------------------
|
|
159
156
|
// URL building
|
|
160
157
|
// ---------------------------------------------------------------------------
|
|
@@ -754,25 +751,3 @@ export const EnboxConnectProtocol = {
|
|
|
754
751
|
createPermissionGrants,
|
|
755
752
|
submitConnectResponse,
|
|
756
753
|
};
|
|
757
|
-
|
|
758
|
-
// ---------------------------------------------------------------------------
|
|
759
|
-
// Deprecated aliases — migration aid from the old `Oidc` namespace
|
|
760
|
-
// ---------------------------------------------------------------------------
|
|
761
|
-
|
|
762
|
-
/** @deprecated Use {@link EnboxConnectProtocol} instead. */
|
|
763
|
-
export const Oidc = {
|
|
764
|
-
createAuthRequest : createConnectRequest,
|
|
765
|
-
encryptAuthRequest : encryptRequest,
|
|
766
|
-
getAuthRequest : getConnectRequest,
|
|
767
|
-
decryptAuthRequest : decryptRequest,
|
|
768
|
-
createPermissionGrants,
|
|
769
|
-
createResponseObject : createConnectResponse,
|
|
770
|
-
encryptAuthResponse : encryptResponse,
|
|
771
|
-
decryptAuthResponse : decryptResponse,
|
|
772
|
-
deriveSharedKey,
|
|
773
|
-
signJwt,
|
|
774
|
-
verifyJwt,
|
|
775
|
-
buildOidcUrl : buildConnectUrl,
|
|
776
|
-
generateCodeChallenge : undefined as never, // Removed — PKCE was never functional.
|
|
777
|
-
submitAuthResponse : submitConnectResponse,
|
|
778
|
-
};
|
package/src/enbox-user-agent.ts
CHANGED
|
@@ -3,6 +3,7 @@ import type { BearerDid } from '@enbox/dids';
|
|
|
3
3
|
import type { EnboxPlatformAgent } from './types/agent.js';
|
|
4
4
|
import type { EnboxRpc } from '@enbox/dwn-clients';
|
|
5
5
|
import type { LocalDwnStrategy } from './local-dwn.js';
|
|
6
|
+
import type { SyncEngine } from './types/sync.js';
|
|
6
7
|
import type { DidInterface, DidRequest, DidResponse } from './did-api.js';
|
|
7
8
|
import type { DwnInterface, DwnResponse, ProcessDwnRequest, SendDwnRequest } from './types/dwn.js';
|
|
8
9
|
import type { ProcessVcRequest, SendVcRequest, VcResponse } from './types/vc.js';
|
|
@@ -13,7 +14,6 @@ import { AgentDidResolverCache } from './agent-did-resolver-cache.js';
|
|
|
13
14
|
import { AgentDwnApi } from './dwn-api.js';
|
|
14
15
|
import { AgentIdentityApi } from './identity-api.js';
|
|
15
16
|
import { AgentPermissionsApi } from './permissions-api.js';
|
|
16
|
-
import { AgentSyncApi } from './sync-api.js';
|
|
17
17
|
import { DwnDidStore } from './store-did.js';
|
|
18
18
|
import { DwnIdentityStore } from './store-identity.js';
|
|
19
19
|
import { DwnKeyStore } from './store-key.js';
|
|
@@ -85,7 +85,7 @@ export type AgentParams<TKeyManager extends AgentKeyManager = LocalKeyManager> =
|
|
|
85
85
|
/** Remote procedure call (RPC) client used to communicate with other Enbox services. */
|
|
86
86
|
rpcClient: EnboxRpc;
|
|
87
87
|
/** Facilitates data synchronization of DWN records between nodes. */
|
|
88
|
-
syncApi:
|
|
88
|
+
syncApi: SyncEngine;
|
|
89
89
|
};
|
|
90
90
|
|
|
91
91
|
export type CreateUserAgentParams = Partial<AgentParams> & {
|
|
@@ -110,7 +110,7 @@ export class EnboxUserAgent<TKeyManager extends AgentKeyManager = LocalKeyManage
|
|
|
110
110
|
public keyManager: TKeyManager;
|
|
111
111
|
public permissions: AgentPermissionsApi;
|
|
112
112
|
public rpc: EnboxRpc;
|
|
113
|
-
public sync:
|
|
113
|
+
public sync: SyncEngine;
|
|
114
114
|
public vault: HdIdentityVault;
|
|
115
115
|
|
|
116
116
|
private _agentDid?: BearerDid;
|
|
@@ -202,7 +202,7 @@ export class EnboxUserAgent<TKeyManager extends AgentKeyManager = LocalKeyManage
|
|
|
202
202
|
|
|
203
203
|
rpcClient ??= new EnboxRpcClient();
|
|
204
204
|
|
|
205
|
-
syncApi ??= new
|
|
205
|
+
syncApi ??= new SyncEngineLevel({ dataPath });
|
|
206
206
|
|
|
207
207
|
// Instantiate the Agent using the provided or default components.
|
|
208
208
|
return new EnboxUserAgent({
|
|
@@ -284,13 +284,3 @@ export class EnboxUserAgent<TKeyManager extends AgentKeyManager = LocalKeyManage
|
|
|
284
284
|
this.agentDid = await this.vault.getDid();
|
|
285
285
|
}
|
|
286
286
|
}
|
|
287
|
-
|
|
288
|
-
// ---------------------------------------------------------------------------
|
|
289
|
-
// Deprecated aliases — migration aid
|
|
290
|
-
// ---------------------------------------------------------------------------
|
|
291
|
-
|
|
292
|
-
/** @deprecated Use {@link EnboxUserAgent} instead. Will be removed in a future version. */
|
|
293
|
-
export const Web5UserAgent = EnboxUserAgent;
|
|
294
|
-
|
|
295
|
-
/** @deprecated Use {@link EnboxUserAgent} instead. Will be removed in a future version. */
|
|
296
|
-
export type Web5UserAgent = EnboxUserAgent;
|
package/src/hd-identity-vault.ts
CHANGED
|
@@ -150,6 +150,14 @@ export class HdIdentityVault implements IdentityVault<{ InitializeResult: string
|
|
|
150
150
|
/** The cryptographic key used to encrypt and decrypt the vault's content securely. */
|
|
151
151
|
private _contentEncryptionKey: Jwk | undefined;
|
|
152
152
|
|
|
153
|
+
/**
|
|
154
|
+
* Cached initialization state. Once read from the store, avoids redundant LevelDB reads on
|
|
155
|
+
* subsequent checks. The `initialized` flag is write-once (false → true) and never reverts,
|
|
156
|
+
* making it safe to cache indefinitely. Mirrors the pattern used by {@link _contentEncryptionKey}
|
|
157
|
+
* for the synchronous {@link isLocked} check.
|
|
158
|
+
*/
|
|
159
|
+
private _cachedInitialized: boolean | undefined;
|
|
160
|
+
|
|
153
161
|
/**
|
|
154
162
|
* Constructs an instance of `HdIdentityVault`, initializing the key derivation factor and data
|
|
155
163
|
* store. It sets the default key derivation work factor and initializes the internal data store,
|
|
@@ -337,6 +345,13 @@ export class HdIdentityVault implements IdentityVault<{ InitializeResult: string
|
|
|
337
345
|
throw new Error('HdIdentityVault: Invalid IdentityVaultStatus object in store');
|
|
338
346
|
}
|
|
339
347
|
|
|
348
|
+
// Only cache the `true` state — `initialized` is write-once (false → true) and never reverts,
|
|
349
|
+
// so a cached `true` is always valid. Leaving `false` uncached ensures a subsequent
|
|
350
|
+
// `isInitialized()` call after `initialize()` correctly reads the updated store.
|
|
351
|
+
if (vaultStatus.initialized) {
|
|
352
|
+
this._cachedInitialized = true;
|
|
353
|
+
}
|
|
354
|
+
|
|
340
355
|
return vaultStatus;
|
|
341
356
|
}
|
|
342
357
|
|
|
@@ -595,6 +610,9 @@ export class HdIdentityVault implements IdentityVault<{ InitializeResult: string
|
|
|
595
610
|
* @returns A promise that resolves to `true` if the vault has been initialized, otherwise `false`.
|
|
596
611
|
*/
|
|
597
612
|
public async isInitialized(): Promise<boolean> {
|
|
613
|
+
if (this._cachedInitialized === true) {
|
|
614
|
+
return true;
|
|
615
|
+
}
|
|
598
616
|
return this.getStatus().then(({ initialized }) => initialized);
|
|
599
617
|
}
|
|
600
618
|
|
|
@@ -851,6 +869,9 @@ export class HdIdentityVault implements IdentityVault<{ InitializeResult: string
|
|
|
851
869
|
// Write the changes to the store.
|
|
852
870
|
await this._store.set('vaultStatus', JSON.stringify(vaultStatus));
|
|
853
871
|
|
|
872
|
+
// Update the in-memory cache so subsequent reads skip the store.
|
|
873
|
+
this._cachedInitialized = vaultStatus.initialized;
|
|
874
|
+
|
|
854
875
|
return true;
|
|
855
876
|
}
|
|
856
877
|
}
|
package/src/index.ts
CHANGED
|
@@ -31,10 +31,8 @@ export * from './store-data.js';
|
|
|
31
31
|
export * from './store-did.js';
|
|
32
32
|
export * from './store-identity.js';
|
|
33
33
|
export * from './store-key.js';
|
|
34
|
-
export * from './sync-api.js';
|
|
35
34
|
export * from './sync-engine-level.js';
|
|
36
35
|
export * from './test-harness.js';
|
|
37
36
|
export * from './utils.js';
|
|
38
|
-
export * from './connect.js';
|
|
39
37
|
export * from './enbox-connect-protocol.js';
|
|
40
38
|
export * from './enbox-user-agent.js';
|
package/src/sync-engine-level.ts
CHANGED
|
@@ -29,6 +29,57 @@ export type SyncEngineLevelParams = {
|
|
|
29
29
|
*/
|
|
30
30
|
const MAX_DIFF_DEPTH = 16;
|
|
31
31
|
|
|
32
|
+
/**
|
|
33
|
+
* Maximum number of concurrent remote HTTP requests during a tree diff.
|
|
34
|
+
* The binary tree walk fans out in parallel — without a limit, depth N
|
|
35
|
+
* produces 2^N concurrent requests, which can exhaust server rate limits.
|
|
36
|
+
*/
|
|
37
|
+
const REMOTE_CONCURRENCY = 4;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Counting semaphore for bounding concurrent async operations.
|
|
41
|
+
* Used by the tree walk to limit in-flight remote HTTP requests.
|
|
42
|
+
*/
|
|
43
|
+
class Semaphore {
|
|
44
|
+
private _permits: number;
|
|
45
|
+
private readonly _waiting: (() => void)[] = [];
|
|
46
|
+
|
|
47
|
+
constructor(permits: number) {
|
|
48
|
+
this._permits = permits;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** Wait until a permit is available, then consume one. */
|
|
52
|
+
async acquire(): Promise<void> {
|
|
53
|
+
if (this._permits > 0) {
|
|
54
|
+
this._permits--;
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
return new Promise<void>((resolve) => {
|
|
58
|
+
this._waiting.push(resolve);
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** Release a permit, waking the next waiter if any. */
|
|
63
|
+
release(): void {
|
|
64
|
+
const next = this._waiting.shift();
|
|
65
|
+
if (next) {
|
|
66
|
+
next();
|
|
67
|
+
} else {
|
|
68
|
+
this._permits++;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** Acquire a permit, run the task, then release regardless of outcome. */
|
|
73
|
+
async run<T>(fn: () => Promise<T>): Promise<T> {
|
|
74
|
+
await this.acquire();
|
|
75
|
+
try {
|
|
76
|
+
return await fn();
|
|
77
|
+
} finally {
|
|
78
|
+
this.release();
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
32
83
|
/**
|
|
33
84
|
* Key for the subscription cursor sublevel. Cursors are keyed by
|
|
34
85
|
* `{did}^{dwnUrl}[^{protocol}]` and store an opaque EventLog cursor string.
|
|
@@ -834,11 +885,17 @@ export class SyncEngineLevel implements SyncEngine {
|
|
|
834
885
|
// Hoist permission grant lookup — resolved once and reused for all subtree/leaf requests.
|
|
835
886
|
const permissionGrantId = await this.getSyncPermissionGrantId(did, delegateDid, protocol);
|
|
836
887
|
|
|
888
|
+
// Gate remote HTTP requests through a semaphore so the binary tree walk
|
|
889
|
+
// doesn't produce an exponential burst of concurrent requests. Local
|
|
890
|
+
// DWN requests (in-process) are not gated.
|
|
891
|
+
const remoteSemaphore = new Semaphore(REMOTE_CONCURRENCY);
|
|
892
|
+
|
|
837
893
|
const walk = async (prefix: string): Promise<void> => {
|
|
838
894
|
// Get subtree hashes for this prefix from local and remote.
|
|
895
|
+
// Only the remote request is gated by the semaphore.
|
|
839
896
|
const [localHash, remoteHash] = await Promise.all([
|
|
840
897
|
this.getLocalSubtreeHash(did, prefix, delegateDid, protocol, permissionGrantId),
|
|
841
|
-
this.getRemoteSubtreeHash(did, dwnUrl, prefix, delegateDid, protocol, permissionGrantId),
|
|
898
|
+
remoteSemaphore.run(() => this.getRemoteSubtreeHash(did, dwnUrl, prefix, delegateDid, protocol, permissionGrantId)),
|
|
842
899
|
]);
|
|
843
900
|
|
|
844
901
|
// If hashes match, this subtree is identical — skip.
|
|
@@ -857,7 +914,9 @@ export class SyncEngineLevel implements SyncEngine {
|
|
|
857
914
|
return;
|
|
858
915
|
}
|
|
859
916
|
if (localHash === emptyHash && remoteHash !== emptyHash) {
|
|
860
|
-
const remoteLeaves = await
|
|
917
|
+
const remoteLeaves = await remoteSemaphore.run(
|
|
918
|
+
() => this.getRemoteLeaves(did, dwnUrl, prefix, delegateDid, protocol, permissionGrantId),
|
|
919
|
+
);
|
|
861
920
|
onlyRemote.push(...remoteLeaves);
|
|
862
921
|
return;
|
|
863
922
|
}
|
|
@@ -866,7 +925,7 @@ export class SyncEngineLevel implements SyncEngine {
|
|
|
866
925
|
if (prefix.length >= MAX_DIFF_DEPTH) {
|
|
867
926
|
const [localLeaves, remoteLeaves] = await Promise.all([
|
|
868
927
|
this.getLocalLeaves(did, prefix, delegateDid, protocol, permissionGrantId),
|
|
869
|
-
this.getRemoteLeaves(did, dwnUrl, prefix, delegateDid, protocol, permissionGrantId),
|
|
928
|
+
remoteSemaphore.run(() => this.getRemoteLeaves(did, dwnUrl, prefix, delegateDid, protocol, permissionGrantId)),
|
|
870
929
|
]);
|
|
871
930
|
|
|
872
931
|
const localSet = new Set(localLeaves);
|
package/src/sync-messages.ts
CHANGED
|
@@ -123,8 +123,9 @@ export async function fetchRemoteMessages({ did, dwnUrl, delegateDid, protocol,
|
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
125
|
|
|
126
|
-
// Fetch messages in parallel with bounded concurrency.
|
|
127
|
-
|
|
126
|
+
// Fetch messages in parallel with bounded concurrency. Keep this low
|
|
127
|
+
// to avoid bursting through the remote server's rate limits during sync.
|
|
128
|
+
const CONCURRENCY = 4;
|
|
128
129
|
let cursor = 0;
|
|
129
130
|
|
|
130
131
|
while (cursor < messageCids.length) {
|
package/src/test-harness.ts
CHANGED
|
@@ -16,7 +16,6 @@ import { AgentDidResolverCache } from './agent-did-resolver-cache.js';
|
|
|
16
16
|
import { AgentDwnApi } from './dwn-api.js';
|
|
17
17
|
import { AgentIdentityApi } from './identity-api.js';
|
|
18
18
|
import { AgentPermissionsApi } from './permissions-api.js';
|
|
19
|
-
import { AgentSyncApi } from './sync-api.js';
|
|
20
19
|
import { EnboxRpcClient } from '@enbox/dwn-clients';
|
|
21
20
|
import { HdIdentityVault } from './hd-identity-vault.js';
|
|
22
21
|
import { LocalKeyManager } from './local-key-manager.js';
|
|
@@ -107,6 +106,7 @@ export class PlatformAgentTestHarness {
|
|
|
107
106
|
await this.dwnResumableTaskStore.clear();
|
|
108
107
|
await this.syncStore.clear();
|
|
109
108
|
await this.vaultStore.clear();
|
|
109
|
+
(this.agent.vault as any)['_cachedInitialized'] = undefined;
|
|
110
110
|
await this.agent.permissions.clear();
|
|
111
111
|
this.dwnStores.clear();
|
|
112
112
|
|
|
@@ -282,8 +282,7 @@ export class PlatformAgentTestHarness {
|
|
|
282
282
|
|
|
283
283
|
// Instantiate Agent's Sync API using a custom LevelDB-backed store.
|
|
284
284
|
const syncStore = new Level(testDataPath('SYNC_STORE'));
|
|
285
|
-
const
|
|
286
|
-
const syncApi = new AgentSyncApi({ syncEngine });
|
|
285
|
+
const syncApi = new SyncEngineLevel({ db: syncStore });
|
|
287
286
|
|
|
288
287
|
// Create EnboxPlatformAgent instance
|
|
289
288
|
const agent = new agentClass({
|
package/src/types/agent.ts
CHANGED
|
@@ -5,10 +5,9 @@ import type { AgentDwnApi } from '../dwn-api.js';
|
|
|
5
5
|
import type { AgentIdentityApi } from '../identity-api.js';
|
|
6
6
|
import type { AgentKeyManager } from './key-manager.js';
|
|
7
7
|
import type { AgentPermissionsApi } from '../permissions-api.js';
|
|
8
|
-
import type { AgentSyncApi } from '../sync-api.js';
|
|
9
8
|
import type { EnboxRpc } from '@enbox/dwn-clients';
|
|
10
9
|
import type { IdentityVault } from './identity-vault.js';
|
|
11
|
-
import type {
|
|
10
|
+
import type { SyncEngine } from './sync.js';
|
|
12
11
|
import type { AgentDidApi, DidInterface, DidRequest, DidResponse } from '../did-api.js';
|
|
13
12
|
import type { DwnInterface, DwnResponse, ProcessDwnRequest, SendDwnRequest } from './dwn.js';
|
|
14
13
|
import type { ProcessVcRequest, SendVcRequest, VcResponse } from './vc.js';
|
|
@@ -168,7 +167,7 @@ export interface EnboxPlatformAgent<TKeyManager extends AgentKeyManager = AgentK
|
|
|
168
167
|
* The synchronization API, responsible for managing the consistency and real-time update of the
|
|
169
168
|
* agent's data with the state of the distributed network.
|
|
170
169
|
*/
|
|
171
|
-
sync:
|
|
170
|
+
sync: SyncEngine;
|
|
172
171
|
|
|
173
172
|
/**
|
|
174
173
|
* An instance of {@link IdentityVault}, providing secure storage and management of an Enbox Agent's
|
|
@@ -193,14 +192,4 @@ export interface EnboxPlatformAgent<TKeyManager extends AgentKeyManager = AgentK
|
|
|
193
192
|
* normal operation and readiness to process requests.
|
|
194
193
|
*/
|
|
195
194
|
start(params: unknown): Promise<unknown>;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
// ---------------------------------------------------------------------------
|
|
199
|
-
// Deprecated aliases — migration aid
|
|
200
|
-
// ---------------------------------------------------------------------------
|
|
201
|
-
|
|
202
|
-
/** @deprecated Use {@link EnboxAgent} instead. Will be removed in a future version. */
|
|
203
|
-
export type Web5Agent = EnboxAgent;
|
|
204
|
-
|
|
205
|
-
/** @deprecated Use {@link EnboxPlatformAgent} instead. Will be removed in a future version. */
|
|
206
|
-
export type Web5PlatformAgent<TKeyManager extends AgentKeyManager = LocalKeyManager> = EnboxPlatformAgent<TKeyManager>;
|
|
195
|
+
}
|
package/src/types/dwn.ts
CHANGED
|
@@ -72,19 +72,7 @@ import {
|
|
|
72
72
|
*
|
|
73
73
|
* @see {@link https://github.com/enboxorg/dwn-spec | Enbox DWN Specification}
|
|
74
74
|
*/
|
|
75
|
-
export interface DwnDidService extends DidService {
|
|
76
|
-
/**
|
|
77
|
-
* @deprecated Optional legacy field. Resolve encryption keys from the DID document's
|
|
78
|
-
* `keyAgreement` verification methods instead.
|
|
79
|
-
*/
|
|
80
|
-
enc?: string | string[];
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* @deprecated Optional legacy field. Resolve signing keys from the DID document's
|
|
84
|
-
* `authentication` or `assertionMethod` verification methods instead.
|
|
85
|
-
*/
|
|
86
|
-
sig?: string | string[];
|
|
87
|
-
}
|
|
75
|
+
export interface DwnDidService extends DidService {}
|
|
88
76
|
|
|
89
77
|
export enum DwnInterface {
|
|
90
78
|
MessagesRead = DwnInterfaceName.Messages + DwnMethodName.Read,
|
package/src/types/sync.ts
CHANGED
|
@@ -106,4 +106,11 @@ export interface SyncEngine {
|
|
|
106
106
|
* @throws {Error} if the sync operation fails to stop before the timeout.
|
|
107
107
|
*/
|
|
108
108
|
stopSync(timeout?: number): Promise<void>;
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Release all resources held by the sync engine (LevelDB handles, timers,
|
|
112
|
+
* WebSocket subscriptions). After calling `close()`, the engine should not
|
|
113
|
+
* be reused.
|
|
114
|
+
*/
|
|
115
|
+
close(): Promise<void>;
|
|
109
116
|
}
|
package/src/utils.ts
CHANGED