@enbox/agent 0.1.8 → 0.2.0
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 +11 -11
- package/dist/browser.mjs.map +4 -4
- package/dist/esm/anonymous-dwn-api.js +1 -1
- package/dist/esm/anonymous-dwn-api.js.map +1 -1
- package/dist/esm/connect.js +4 -10
- package/dist/esm/connect.js.map +1 -1
- package/dist/esm/dwn-api.js +144 -195
- package/dist/esm/dwn-api.js.map +1 -1
- package/dist/esm/dwn-protocol-cache.js +149 -0
- package/dist/esm/dwn-protocol-cache.js.map +1 -0
- package/dist/esm/dwn-record-upgrade.js +3 -3
- package/dist/esm/dwn-record-upgrade.js.map +1 -1
- package/dist/esm/hd-identity-vault.js +6 -5
- package/dist/esm/hd-identity-vault.js.map +1 -1
- package/dist/esm/identity-api.js +0 -2
- package/dist/esm/identity-api.js.map +1 -1
- package/dist/esm/oidc.js +2 -1
- package/dist/esm/oidc.js.map +1 -1
- package/dist/esm/permissions-api.js +24 -6
- package/dist/esm/permissions-api.js.map +1 -1
- package/dist/esm/prototyping/crypto/jose/jwe-flattened.js +1 -1
- package/dist/esm/prototyping/crypto/jose/jwe-flattened.js.map +1 -1
- package/dist/esm/prototyping/crypto/jose/jwe.js +11 -3
- package/dist/esm/prototyping/crypto/jose/jwe.js.map +1 -1
- package/dist/esm/store-data-protocols.js +2 -2
- package/dist/esm/store-data-protocols.js.map +1 -1
- package/dist/esm/sync-api.js +3 -0
- package/dist/esm/sync-api.js.map +1 -1
- package/dist/esm/sync-engine-level.js +447 -29
- package/dist/esm/sync-engine-level.js.map +1 -1
- package/dist/esm/test-harness.js +3 -5
- package/dist/esm/test-harness.js.map +1 -1
- package/dist/esm/types/dwn.js.map +1 -1
- package/dist/types/anonymous-dwn-api.d.ts +3 -3
- package/dist/types/anonymous-dwn-api.d.ts.map +1 -1
- package/dist/types/connect.d.ts.map +1 -1
- package/dist/types/dwn-api.d.ts +11 -18
- package/dist/types/dwn-api.d.ts.map +1 -1
- package/dist/types/dwn-protocol-cache.d.ts +76 -0
- package/dist/types/dwn-protocol-cache.d.ts.map +1 -0
- package/dist/types/hd-identity-vault.d.ts.map +1 -1
- package/dist/types/identity-api.d.ts.map +1 -1
- package/dist/types/oidc.d.ts.map +1 -1
- package/dist/types/permissions-api.d.ts.map +1 -1
- package/dist/types/prototyping/crypto/jose/jwe-flattened.d.ts.map +1 -1
- package/dist/types/prototyping/crypto/jose/jwe.d.ts +12 -2
- package/dist/types/prototyping/crypto/jose/jwe.d.ts.map +1 -1
- package/dist/types/sync-api.d.ts +3 -4
- package/dist/types/sync-api.d.ts.map +1 -1
- package/dist/types/sync-engine-level.d.ts +63 -5
- package/dist/types/sync-engine-level.d.ts.map +1 -1
- package/dist/types/test-harness.d.ts.map +1 -1
- package/dist/types/types/dwn.d.ts +18 -19
- package/dist/types/types/dwn.d.ts.map +1 -1
- package/dist/types/types/sync.d.ts +47 -5
- package/dist/types/types/sync.d.ts.map +1 -1
- package/package.json +6 -6
- package/src/anonymous-dwn-api.ts +4 -4
- package/src/connect.ts +4 -10
- package/src/dwn-api.ts +192 -250
- package/src/dwn-protocol-cache.ts +216 -0
- package/src/dwn-record-upgrade.ts +3 -3
- package/src/hd-identity-vault.ts +6 -5
- package/src/identity-api.ts +0 -2
- package/src/oidc.ts +2 -1
- package/src/permissions-api.ts +28 -6
- package/src/prototyping/crypto/jose/jwe-flattened.ts +4 -1
- package/src/prototyping/crypto/jose/jwe.ts +24 -2
- package/src/store-data-protocols.ts +2 -2
- package/src/sync-api.ts +7 -3
- package/src/sync-engine-level.ts +509 -32
- package/src/test-harness.ts +3 -5
- package/src/types/dwn.ts +19 -21
- package/src/types/sync.ts +56 -5
|
@@ -1,43 +1,42 @@
|
|
|
1
1
|
import type { DidService } from '@enbox/dids';
|
|
2
2
|
import type { RequireOnly } from '@enbox/common';
|
|
3
|
-
import type { GenericMessageReply, MessagesReadMessage, MessagesReadOptions, MessagesReadReply, MessagesSubscribeMessage, MessagesSubscribeOptions, MessagesSubscribeReply, MessagesSyncMessage, MessagesSyncReply,
|
|
3
|
+
import type { GenericMessageReply, MessagesReadMessage, MessagesReadOptions, MessagesReadReply, MessagesSubscribeMessage, MessagesSubscribeOptions, MessagesSubscribeReply, MessagesSyncMessage, MessagesSyncReply, ProtocolsConfigureMessage, ProtocolsConfigureOptions, ProtocolsQueryMessage, ProtocolsQueryOptions, ProtocolsQueryReply, RecordsDeleteMessage, RecordsDeleteOptions, RecordsQueryMessage, RecordsQueryOptions, RecordsQueryReply, RecordsReadMessage, RecordsReadOptions, RecordsReadReply, RecordsSubscribeMessage, RecordsSubscribeOptions, RecordsSubscribeReply, RecordsWriteMessage, RecordsWriteOptions, SubscriptionListener } from '@enbox/dwn-sdk-js';
|
|
4
4
|
import type { MessagesSyncOptions } from '@enbox/dwn-sdk-js';
|
|
5
5
|
import { MessagesRead, MessagesSubscribe, MessagesSync, ProtocolsConfigure, ProtocolsQuery, RecordsDelete, RecordsQuery, RecordsRead, RecordsSubscribe, RecordsWrite } from '@enbox/dwn-sdk-js';
|
|
6
6
|
/**
|
|
7
7
|
* Represents a Decentralized Web Node (DWN) service in a DID Document.
|
|
8
8
|
*
|
|
9
9
|
* A DWN DID service is a specialized type of DID service with the `type` set to
|
|
10
|
-
* `DecentralizedWebNode`.
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
10
|
+
* `DecentralizedWebNode`. Encryption and signing keys are resolved from the DID document's
|
|
11
|
+
* verification methods, not from the service entry.
|
|
12
|
+
*
|
|
13
|
+
* The `enc` and `sig` properties are optional legacy fields that may be present on existing
|
|
14
|
+
* DID documents for backward compatibility. New implementations should resolve keys from the
|
|
15
|
+
* DID document's verification methods by purpose (`keyAgreement` for encryption,
|
|
16
|
+
* `authentication`/`assertionMethod` for signing).
|
|
16
17
|
*
|
|
17
18
|
* @example
|
|
18
19
|
* ```ts
|
|
19
20
|
* const service: DwnDidService = {
|
|
20
21
|
* id: 'did:example:123#dwn',
|
|
21
22
|
* type: 'DecentralizedWebNode',
|
|
22
|
-
* serviceEndpoint: 'https://enbox-dwn.fly.dev'
|
|
23
|
-
* enc: 'did:example:123#key-1',
|
|
24
|
-
* sig: 'did:example:123#key-2'
|
|
23
|
+
* serviceEndpoint: 'https://enbox-dwn.fly.dev'
|
|
25
24
|
* }
|
|
26
25
|
* ```
|
|
27
26
|
*
|
|
28
|
-
* @see {@link https://
|
|
27
|
+
* @see {@link https://github.com/enboxorg/dwn-spec | Enbox DWN Specification}
|
|
29
28
|
*/
|
|
30
29
|
export interface DwnDidService extends DidService {
|
|
31
30
|
/**
|
|
32
|
-
*
|
|
33
|
-
*
|
|
31
|
+
* @deprecated Optional legacy field. Resolve encryption keys from the DID document's
|
|
32
|
+
* `keyAgreement` verification methods instead.
|
|
34
33
|
*/
|
|
35
34
|
enc?: string | string[];
|
|
36
35
|
/**
|
|
37
|
-
*
|
|
38
|
-
* or
|
|
36
|
+
* @deprecated Optional legacy field. Resolve signing keys from the DID document's
|
|
37
|
+
* `authentication` or `assertionMethod` verification methods instead.
|
|
39
38
|
*/
|
|
40
|
-
sig
|
|
39
|
+
sig?: string | string[];
|
|
41
40
|
}
|
|
42
41
|
export declare enum DwnInterface {
|
|
43
42
|
MessagesRead = "MessagesRead",
|
|
@@ -101,8 +100,8 @@ export interface DwnMessageReply {
|
|
|
101
100
|
[DwnInterface.RecordsWrite]: GenericMessageReply;
|
|
102
101
|
}
|
|
103
102
|
export interface MessageHandler {
|
|
104
|
-
[DwnInterface.MessagesSubscribe]:
|
|
105
|
-
[DwnInterface.RecordsSubscribe]:
|
|
103
|
+
[DwnInterface.MessagesSubscribe]: SubscriptionListener;
|
|
104
|
+
[DwnInterface.RecordsSubscribe]: SubscriptionListener;
|
|
106
105
|
[DwnInterface.MessagesRead]: undefined;
|
|
107
106
|
[DwnInterface.MessagesSync]: undefined;
|
|
108
107
|
[DwnInterface.ProtocolsConfigure]: undefined;
|
|
@@ -177,5 +176,5 @@ export type DwnMessageWithData<T extends DwnInterface> = {
|
|
|
177
176
|
dataStream?: ReadableStream<Uint8Array>;
|
|
178
177
|
};
|
|
179
178
|
export { DateSort as DwnDateSort, DwnConstant, ContentEncryptionAlgorithm as DwnContentEncryptionAlgorithm, KeyDerivationScheme as DwnKeyDerivationScheme, PermissionGrant as DwnPermissionGrant, PermissionRequest as DwnPermissionRequest, PermissionsProtocol as DwnPermissionsProtocol, } from '@enbox/dwn-sdk-js';
|
|
180
|
-
export type { DataEncodedRecordsWriteMessage as DwnDataEncodedRecordsWriteMessage, MessageSigner as DwnSigner, MessageSubscription as DwnMessageSubscription,
|
|
179
|
+
export type { DataEncodedRecordsWriteMessage as DwnDataEncodedRecordsWriteMessage, MessageSigner as DwnSigner, MessageSubscription as DwnMessageSubscription, MessagesPermissionScope as DwnMessagesPermissionScope, PaginationCursor as DwnPaginationCursor, PermissionConditions as DwnPermissionConditions, PermissionGrantData as DwnPermissionGrantData, PermissionRequestData as DwnPermissionRequestData, PermissionScope as DwnPermissionScope, ProtocolDefinition as DwnProtocolDefinition, ProtocolPermissionScope as DwnProtocolPermissionScope, PublicKeyJwk as DwnPublicKeyJwk, RecordsPermissionScope as DwnRecordsPermissionScope, SubscriptionListener as DwnSubscriptionListener, SubscriptionMessage as DwnSubscriptionMessage, } from '@enbox/dwn-sdk-js';
|
|
181
180
|
//# sourceMappingURL=dwn.d.ts.map
|
|
@@ -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,EACx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7C,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"}
|
|
@@ -12,11 +12,53 @@ export type SyncIdentityOptions = {
|
|
|
12
12
|
*/
|
|
13
13
|
protocols: string[];
|
|
14
14
|
};
|
|
15
|
+
/**
|
|
16
|
+
* Connectivity state of the sync engine.
|
|
17
|
+
*/
|
|
18
|
+
export type SyncConnectivityState = 'online' | 'offline' | 'unknown';
|
|
19
|
+
/**
|
|
20
|
+
* Describes the sync mode: `'poll'` for periodic SMT reconciliation,
|
|
21
|
+
* `'live'` for `MessagesSubscribe`-based real-time sync with SMT fallback.
|
|
22
|
+
*/
|
|
23
|
+
export type SyncMode = 'poll' | 'live';
|
|
24
|
+
/**
|
|
25
|
+
* Parameters for {@link SyncEngine.startSync}.
|
|
26
|
+
*/
|
|
27
|
+
export type StartSyncParams = {
|
|
28
|
+
/**
|
|
29
|
+
* The sync mode to use. Default: `'poll'`.
|
|
30
|
+
*
|
|
31
|
+
* - `'live'`: Opens `MessagesSubscribe` WebSocket subscriptions to remote
|
|
32
|
+
* DWNs for real-time pull, and listens to the local EventLog for immediate
|
|
33
|
+
* push. Falls back to SMT reconciliation on cold start or long disconnect.
|
|
34
|
+
* An infrequent SMT integrity check still runs at `interval`.
|
|
35
|
+
*
|
|
36
|
+
* - `'poll'`: Legacy mode. Performs a full SMT set-reconciliation sync on a
|
|
37
|
+
* fixed interval. No WebSocket subscriptions are used.
|
|
38
|
+
*/
|
|
39
|
+
mode?: SyncMode;
|
|
40
|
+
/**
|
|
41
|
+
* The interval at which the sync operation should be performed.
|
|
42
|
+
* Accepts any value recognised by `ms()`, e.g. `'30s'`, `'2m'`, `'10m'`.
|
|
43
|
+
*
|
|
44
|
+
* In `'live'` mode this controls the frequency of the SMT integrity check.
|
|
45
|
+
* In `'poll'` mode this controls the polling frequency.
|
|
46
|
+
*
|
|
47
|
+
* Default: `'2m'` (in poll mode), `'5m'` (in live mode).
|
|
48
|
+
*/
|
|
49
|
+
interval?: string;
|
|
50
|
+
};
|
|
15
51
|
export interface SyncEngine {
|
|
16
52
|
/**
|
|
17
53
|
* The agent that the SyncEngine is attached to.
|
|
18
54
|
*/
|
|
19
55
|
agent: Web5PlatformAgent;
|
|
56
|
+
/**
|
|
57
|
+
* Current connectivity state as observed by the sync engine.
|
|
58
|
+
* Updated when WebSocket subscriptions connect/disconnect or when the
|
|
59
|
+
* browser `online`/`offline` events fire.
|
|
60
|
+
*/
|
|
61
|
+
readonly connectivityState: SyncConnectivityState;
|
|
20
62
|
/**
|
|
21
63
|
* Register an identity to be managed by the SyncEngine for syncing.
|
|
22
64
|
* The options can define specific protocols that should only be synced, or a delegate DID that should be used to sign the sync messages.
|
|
@@ -48,13 +90,13 @@ export interface SyncEngine {
|
|
|
48
90
|
*/
|
|
49
91
|
sync(direction?: 'push' | 'pull'): Promise<void>;
|
|
50
92
|
/**
|
|
51
|
-
* Starts
|
|
93
|
+
* Starts sync. In `'live'` mode opens real-time subscriptions with SMT
|
|
94
|
+
* fallback; in `'poll'` mode uses periodic SMT reconciliation.
|
|
52
95
|
*
|
|
53
|
-
*
|
|
96
|
+
* Subsequent calls update the mode/interval. Calling with a different mode
|
|
97
|
+
* tears down the previous mode's resources before starting the new one.
|
|
54
98
|
*/
|
|
55
|
-
startSync(params:
|
|
56
|
-
interval: string;
|
|
57
|
-
}): Promise<void>;
|
|
99
|
+
startSync(params: StartSyncParams): Promise<void>;
|
|
58
100
|
/**
|
|
59
101
|
* Stops the periodic sync operation, will complete the current sync operation if one is already in progress.
|
|
60
102
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../../../src/types/sync.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEpD;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,SAAS,EAAE,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../../../src/types/sync.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEpD;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG,QAAQ,GAAG,SAAS,GAAG,SAAS,CAAC;AAErE;;;GAGG;AACH,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,MAAM,CAAC;AAEvC;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B;;;;;;;;;;OAUG;IACH,IAAI,CAAC,EAAE,QAAQ,CAAC;IAEhB;;;;;;;;OAQG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,WAAW,UAAU;IACzB;;OAEG;IACH,KAAK,EAAE,iBAAiB,CAAC;IAEzB;;;;OAIG;IACH,QAAQ,CAAC,iBAAiB,EAAE,qBAAqB,CAAC;IAElD;;;OAGG;IACH,gBAAgB,CAAC,MAAM,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,mBAAmB,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACxF;;OAEG;IACH,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/C;;OAEG;IACH,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,GAAG,SAAS,CAAC,CAAC;IAC1E;;OAEG;IACH,qBAAqB,CAAC,MAAM,EAAE;QAAE,GAAG,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;CAC3C"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@enbox/agent",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
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.0.
|
|
75
|
-
"@enbox/dwn-sdk-js": "0.0
|
|
76
|
-
"@enbox/common": "0.0.
|
|
77
|
-
"@enbox/crypto": "0.0.
|
|
78
|
-
"@enbox/dids": "0.0.
|
|
74
|
+
"@enbox/dwn-clients": "0.0.7",
|
|
75
|
+
"@enbox/dwn-sdk-js": "0.1.0",
|
|
76
|
+
"@enbox/common": "0.0.5",
|
|
77
|
+
"@enbox/crypto": "0.0.6",
|
|
78
|
+
"@enbox/dids": "0.0.7",
|
|
79
79
|
"abstract-level": "1.0.4",
|
|
80
80
|
"ed25519-keygen": "0.4.11",
|
|
81
81
|
"level": "8.0.0",
|
package/src/anonymous-dwn-api.ts
CHANGED
|
@@ -11,7 +11,7 @@ import type {
|
|
|
11
11
|
RecordsQueryReply,
|
|
12
12
|
RecordsReadReply,
|
|
13
13
|
RecordsSubscribeReply,
|
|
14
|
-
|
|
14
|
+
SubscriptionListener,
|
|
15
15
|
} from '@enbox/dwn-sdk-js';
|
|
16
16
|
import type { DwnRpcRequest, Web5Rpc } from '@enbox/dwn-clients';
|
|
17
17
|
|
|
@@ -154,13 +154,13 @@ export class AnonymousDwnApi {
|
|
|
154
154
|
*
|
|
155
155
|
* @param target - The DID whose DWN to subscribe to.
|
|
156
156
|
* @param params - Subscribe parameters (filter).
|
|
157
|
-
* @param handler - Callback for incoming
|
|
157
|
+
* @param handler - Callback for incoming subscription messages (events and EOSE).
|
|
158
158
|
* @returns The raw `RecordsSubscribeReply` from the remote DWN.
|
|
159
159
|
*/
|
|
160
160
|
public async recordsSubscribe(
|
|
161
161
|
target: string,
|
|
162
162
|
params: AnonymousRecordsSubscribeParams,
|
|
163
|
-
handler:
|
|
163
|
+
handler: SubscriptionListener,
|
|
164
164
|
): Promise<RecordsSubscribeReply> {
|
|
165
165
|
const recordsSubscribe = await RecordsSubscribe.create({
|
|
166
166
|
filter : params.filter,
|
|
@@ -221,7 +221,7 @@ export class AnonymousDwnApi {
|
|
|
221
221
|
target: string,
|
|
222
222
|
message: unknown,
|
|
223
223
|
data?: Blob,
|
|
224
|
-
subscriptionHandler?:
|
|
224
|
+
subscriptionHandler?: SubscriptionListener,
|
|
225
225
|
): Promise<TReply> {
|
|
226
226
|
const dwnEndpointUrls = await getDwnServiceEndpointUrls(target, this._didResolver);
|
|
227
227
|
const errorMessages: { url: string; message: string }[] = [];
|
package/src/connect.ts
CHANGED
|
@@ -84,6 +84,7 @@ async function initClient({
|
|
|
84
84
|
headers : {
|
|
85
85
|
'Content-Type': 'application/x-www-form-urlencoded',
|
|
86
86
|
},
|
|
87
|
+
signal: AbortSignal.timeout(30_000),
|
|
87
88
|
});
|
|
88
89
|
|
|
89
90
|
if (!parResponse.ok) {
|
|
@@ -112,7 +113,7 @@ async function initClient({
|
|
|
112
113
|
});
|
|
113
114
|
|
|
114
115
|
// subscribe to receiving a response from the wallet with default TTL. receive ciphertext of {@link Web5ConnectAuthResponse}
|
|
115
|
-
const authResponse = await pollWithTtl(() => fetch(tokenUrl));
|
|
116
|
+
const authResponse = await pollWithTtl(() => fetch(tokenUrl, { signal: AbortSignal.timeout(30_000) }));
|
|
116
117
|
|
|
117
118
|
if (authResponse) {
|
|
118
119
|
const jwe = await authResponse?.text();
|
|
@@ -224,19 +225,12 @@ function createPermissionRequestForProtocol({ definition, permissions }: Protoco
|
|
|
224
225
|
method : DwnMethodName.Query,
|
|
225
226
|
});
|
|
226
227
|
|
|
227
|
-
//
|
|
228
|
+
// A Messages.Read grant is a unified scope that covers MessagesRead, MessagesSync, and MessagesSubscribe.
|
|
229
|
+
// This single grant enables sync and real-time subscriptions for the protocol.
|
|
228
230
|
requests.push({
|
|
229
231
|
protocol : definition.protocol,
|
|
230
232
|
interface : DwnInterfaceName.Messages,
|
|
231
233
|
method : DwnMethodName.Read,
|
|
232
|
-
}, {
|
|
233
|
-
protocol : definition.protocol,
|
|
234
|
-
interface : DwnInterfaceName.Messages,
|
|
235
|
-
method : DwnMethodName.Sync,
|
|
236
|
-
}, {
|
|
237
|
-
protocol : definition.protocol,
|
|
238
|
-
interface : DwnInterfaceName.Messages,
|
|
239
|
-
method : DwnMethodName.Subscribe,
|
|
240
234
|
});
|
|
241
235
|
|
|
242
236
|
// We also request any additional permissions the user has requested for this protocol
|