@enbox/api 0.3.1 → 0.4.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/README.md +63 -0
- package/dist/browser.mjs +11 -28
- package/dist/browser.mjs.map +4 -4
- package/dist/esm/advanced.js +1 -1
- package/dist/esm/define-protocol.js +3 -3
- package/dist/esm/did-api.js +1 -1
- package/dist/esm/did-api.js.map +1 -1
- package/dist/esm/dwn-api.js +6 -6
- package/dist/esm/dwn-api.js.map +1 -1
- package/dist/esm/dwn-reader-api.js +2 -2
- package/dist/esm/enbox.js +205 -0
- package/dist/esm/enbox.js.map +1 -0
- package/dist/esm/index.js +16 -15
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/protocol.js +2 -2
- package/dist/esm/protocol.js.map +1 -1
- package/dist/esm/record-data.js +79 -5
- package/dist/esm/record-data.js.map +1 -1
- package/dist/esm/record.js +49 -10
- package/dist/esm/record.js.map +1 -1
- package/dist/esm/repository.js +7 -7
- package/dist/esm/repository.js.map +1 -1
- package/dist/esm/typed-enbox.js +583 -0
- package/dist/esm/typed-enbox.js.map +1 -0
- package/dist/esm/typed-live-query.js +1 -1
- package/dist/esm/typed-record.js +370 -46
- package/dist/esm/typed-record.js.map +1 -1
- package/dist/esm/utils.js +25 -0
- package/dist/esm/utils.js.map +1 -1
- package/dist/esm/vc-api.js.map +1 -1
- package/dist/types/advanced.d.ts +1 -1
- package/dist/types/define-protocol.d.ts +3 -3
- package/dist/types/did-api.d.ts +4 -4
- package/dist/types/did-api.d.ts.map +1 -1
- package/dist/types/dwn-api.d.ts +12 -7
- package/dist/types/dwn-api.d.ts.map +1 -1
- package/dist/types/dwn-reader-api.d.ts +2 -2
- package/dist/types/enbox.d.ts +202 -0
- package/dist/types/enbox.d.ts.map +1 -0
- package/dist/types/grant-revocation.d.ts +2 -2
- package/dist/types/grant-revocation.d.ts.map +1 -1
- package/dist/types/index.d.ts +16 -15
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/live-query.d.ts +2 -2
- package/dist/types/live-query.d.ts.map +1 -1
- package/dist/types/permission-grant.d.ts +2 -2
- package/dist/types/permission-grant.d.ts.map +1 -1
- package/dist/types/permission-request.d.ts +2 -2
- package/dist/types/permission-request.d.ts.map +1 -1
- package/dist/types/protocol-types.d.ts +2 -2
- package/dist/types/protocol.d.ts +7 -7
- package/dist/types/protocol.d.ts.map +1 -1
- package/dist/types/record-data.d.ts +17 -0
- package/dist/types/record-data.d.ts.map +1 -1
- package/dist/types/record.d.ts +24 -10
- package/dist/types/record.d.ts.map +1 -1
- package/dist/types/repository-types.d.ts +19 -11
- package/dist/types/repository-types.d.ts.map +1 -1
- package/dist/types/repository.d.ts +7 -7
- package/dist/types/repository.d.ts.map +1 -1
- package/dist/types/typed-enbox.d.ts +613 -0
- package/dist/types/typed-enbox.d.ts.map +1 -0
- package/dist/types/typed-live-query.d.ts +1 -1
- package/dist/types/typed-record.d.ts +427 -53
- package/dist/types/typed-record.d.ts.map +1 -1
- package/dist/types/utils.d.ts +23 -0
- package/dist/types/utils.d.ts.map +1 -1
- package/dist/types/vc-api.d.ts +3 -3
- package/dist/types/vc-api.d.ts.map +1 -1
- package/package.json +12 -11
- package/src/advanced.ts +1 -1
- package/src/define-protocol.ts +3 -3
- package/src/did-api.ts +5 -5
- package/src/dwn-api.ts +22 -17
- package/src/dwn-reader-api.ts +2 -2
- package/src/enbox.ts +281 -0
- package/src/grant-revocation.ts +3 -3
- package/src/index.ts +17 -16
- package/src/live-query.ts +2 -2
- package/src/permission-grant.ts +4 -4
- package/src/permission-request.ts +3 -3
- package/src/protocol-types.ts +2 -2
- package/src/protocol.ts +8 -8
- package/src/record-data.ts +86 -5
- package/src/record.ts +54 -13
- package/src/repository-types.ts +19 -7
- package/src/repository.ts +15 -15
- package/src/typed-enbox.ts +1169 -0
- package/src/typed-live-query.ts +1 -1
- package/src/typed-record.ts +431 -53
- package/src/utils.ts +27 -0
- package/src/vc-api.ts +4 -4
- package/dist/esm/typed-web5.js +0 -339
- package/dist/esm/typed-web5.js.map +0 -1
- package/dist/esm/web5.js +0 -410
- package/dist/esm/web5.js.map +0 -1
- package/dist/types/typed-web5.d.ts +0 -221
- package/dist/types/typed-web5.d.ts.map +0 -1
- package/dist/types/web5.d.ts +0 -346
- package/dist/types/web5.d.ts.map +0 -1
- package/src/typed-web5.ts +0 -598
- package/src/web5.ts +0 -754
package/dist/types/did-api.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { DidCreateParams, DidMessageResult, DidResolveParams,
|
|
1
|
+
import type { DidCreateParams, DidMessageResult, DidResolveParams, EnboxAgent, ResponseStatus } from '@enbox/agent';
|
|
2
2
|
import { DidInterface } from '@enbox/agent';
|
|
3
3
|
/**
|
|
4
4
|
* Parameters for creating a DID, specifying the method, options for the DID method, and whether to
|
|
@@ -32,21 +32,21 @@ export type DidResolveResponse = DidMessageResult[DidInterface.Resolve];
|
|
|
32
32
|
*/
|
|
33
33
|
export declare class DidApi {
|
|
34
34
|
/**
|
|
35
|
-
* Holds the instance of a {@link
|
|
35
|
+
* Holds the instance of a {@link EnboxAgent} that represents the current execution context for
|
|
36
36
|
* the `DidApi`. This agent is used to process DID requests.
|
|
37
37
|
*/
|
|
38
38
|
private agent;
|
|
39
39
|
/** The DID of the tenant under which DID operations are being performed. */
|
|
40
40
|
private connectedDid;
|
|
41
41
|
constructor(options: {
|
|
42
|
-
agent:
|
|
42
|
+
agent: EnboxAgent;
|
|
43
43
|
connectedDid: string;
|
|
44
44
|
});
|
|
45
45
|
/**
|
|
46
46
|
* Initiates the creation of a Decentralized Identifier (DID) using the specified method, options,
|
|
47
47
|
* and storage preference.
|
|
48
48
|
*
|
|
49
|
-
* This method sends a request to the
|
|
49
|
+
* This method sends a request to the Enbox Agent to create a new DID based on the provided method,
|
|
50
50
|
* with method-specific options. It also specifies whether the newly created DID should be stored.
|
|
51
51
|
*
|
|
52
52
|
* @param request - The request parameters for creating a DID, including the method, options, and
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"did-api.d.ts","sourceRoot":"","sources":["../../src/did-api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,
|
|
1
|
+
{"version":3,"file":"did-api.d.ts","sourceRoot":"","sources":["../../src/did-api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAEpH,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C;;;;;;;GAOG;AACH,MAAM,MAAM,gBAAgB,GAAG,IAAI,CAAC,eAAe,EAAE,QAAQ,GAAG,SAAS,GAAG,OAAO,CAAC,CAAC;AAErF;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GAAG,cAAc,GAAG;IAC/C,gGAAgG;IAChG,GAAG,CAAC,EAAE,gBAAgB,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;CAC7C,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,kBAAkB,GAAG,gBAAgB,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;AAExE;;;;GAIG;AACH,qBAAa,MAAM;IACjB;;;OAGG;IACH,OAAO,CAAC,KAAK,CAAa;IAE1B,4EAA4E;IAC5E,OAAO,CAAC,YAAY,CAAS;gBAEjB,OAAO,EAAE;QAAE,KAAK,EAAE,UAAU,CAAC;QAAC,YAAY,EAAE,MAAM,CAAA;KAAE;IAKhE;;;;;;;;;;;OAWG;IACU,MAAM,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAS1E;;;;;OAKG;IACU,OAAO,CAClB,MAAM,EAAE,gBAAgB,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC,EAAE,gBAAgB,CAAC,SAAS,CAAC,GACxE,OAAO,CAAC,kBAAkB,CAAC;CAQ/B"}
|
package/dist/types/dwn-api.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* NOTE: Added reference types here to avoid a `pnpm` bug during build.
|
|
3
3
|
* https://github.com/enboxorg/enbox/pull/507
|
|
4
4
|
*/
|
|
5
|
-
import type { CreateGrantParams, CreateRequestParams, DwnMessageParams, DwnPaginationCursor, DwnResponseStatus, FetchPermissionRequestParams, FetchPermissionsParams
|
|
5
|
+
import type { CreateGrantParams, CreateRequestParams, DwnMessageParams, DwnPaginationCursor, DwnResponseStatus, EnboxAgent, FetchPermissionRequestParams, FetchPermissionsParams } from '@enbox/agent';
|
|
6
6
|
import { DwnInterface } from '@enbox/agent';
|
|
7
7
|
import { LiveQuery } from './live-query.js';
|
|
8
8
|
import { PermissionGrant } from './permission-grant.js';
|
|
@@ -123,10 +123,13 @@ export type RecordsReadRequest = Omit<DwnMessageParams[DwnInterface.RecordsRead]
|
|
|
123
123
|
/**
|
|
124
124
|
* Encapsulates the response from a record read operation, combining the general operation status
|
|
125
125
|
* with the specific record that was retrieved.
|
|
126
|
+
*
|
|
127
|
+
* When the status code is not in the 2xx range (e.g. 401, 404), `record` will be `undefined`.
|
|
128
|
+
* Always check `status.code` before accessing the record.
|
|
126
129
|
*/
|
|
127
130
|
export type RecordsReadResponse = DwnResponseStatus & {
|
|
128
|
-
/** The record retrieved by the read operation. */
|
|
129
|
-
record
|
|
131
|
+
/** The record retrieved by the read operation, or `undefined` if the request failed. */
|
|
132
|
+
record?: Record;
|
|
130
133
|
};
|
|
131
134
|
/**
|
|
132
135
|
* Represents a request to subscribe to records from a Decentralized Web Node (DWN).
|
|
@@ -178,16 +181,18 @@ export type RecordsWriteRequest = Omit<Partial<DwnMessageParams[DwnInterface.Rec
|
|
|
178
181
|
export type RecordsWriteResponse = DwnResponseStatus & {
|
|
179
182
|
/**
|
|
180
183
|
* The `Record` instance representing the record that was successfully written to the
|
|
181
|
-
* DWN as a result of the write operation.
|
|
184
|
+
* DWN as a result of the write operation, or `undefined` if the write failed.
|
|
185
|
+
*
|
|
186
|
+
* Always check `status.code` before accessing the record.
|
|
182
187
|
*/
|
|
183
|
-
record
|
|
188
|
+
record?: Record;
|
|
184
189
|
};
|
|
185
190
|
/**
|
|
186
191
|
* Interface to interact with DWN Records and Protocols
|
|
187
192
|
*/
|
|
188
193
|
export declare class DwnApi {
|
|
189
194
|
/**
|
|
190
|
-
* Holds the instance of a {@link
|
|
195
|
+
* Holds the instance of a {@link EnboxAgent} that represents the current execution context for
|
|
191
196
|
* the `DwnApi`. This agent is used to process DWN requests.
|
|
192
197
|
*/
|
|
193
198
|
private agent;
|
|
@@ -198,7 +203,7 @@ export declare class DwnApi {
|
|
|
198
203
|
/** Holds the instance of {@link AgentPermissionsApi} that helps when dealing with permissions protocol records */
|
|
199
204
|
private permissionsApi;
|
|
200
205
|
constructor(options: {
|
|
201
|
-
agent:
|
|
206
|
+
agent: EnboxAgent;
|
|
202
207
|
connectedDid: string;
|
|
203
208
|
delegateDid?: string;
|
|
204
209
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dwn-api.d.ts","sourceRoot":"","sources":["../../src/dwn-api.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EACV,iBAAiB,EACjB,mBAAmB,EAEnB,gBAAgB,EAChB,mBAAmB,EAEnB,iBAAiB,EACjB,4BAA4B,EAC5B,sBAAsB,
|
|
1
|
+
{"version":3,"file":"dwn-api.d.ts","sourceRoot":"","sources":["../../src/dwn-api.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EACV,iBAAiB,EACjB,mBAAmB,EAEnB,gBAAgB,EAChB,mBAAmB,EAEnB,iBAAiB,EACjB,UAAU,EACV,4BAA4B,EAC5B,sBAAsB,EACH,MAAM,cAAc,CAAC;AAQ1C,OAAO,EAAE,YAAY,EAAmB,MAAM,cAAc,CAAC;AAG7D,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,C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AAE,IAAI,CAAC,iBAAiB,EAAE,QAAQ,CAAC,KAAK,OAAO,CAAC,eAAe,CAAC,CAAC;QAChF,aAAa,EAAE,CAAC,OAAO,CAAC,EAAE,oBAAoB,KAAK,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAAC;QAChF,WAAW,EAAE,CAAC,OAAO,CAAC,EAAE,kBAAkB,KAAK,OAAO,CAAC,eAAe,EAAE,CAAC,CAAC;KACzE,CAyFJ;IAED;;OAEG;IACH,IAAI,SAAS,IAAI;QACb,SAAS,EAAE,CAAC,OAAO,EAAE,yBAAyB,KAAK,OAAO,CAAC,0BAA0B,CAAC,CAAC;QACvF,KAAK,EAAE,CAAC,OAAO,EAAE,qBAAqB,KAAK,OAAO,CAAC,sBAAsB,CAAC,CAAC;KAC1E,CAsGJ;IAED;;OAEG;IACH,IAAI,OAAO,IAAI;QACX,MAAM,EAAE,CAAC,OAAO,EAAE,oBAAoB,KAAK,OAAO,CAAC,iBAAiB,CAAC,CAAC;QACtE,KAAK,EAAE,CAAC,OAAO,EAAE,mBAAmB,KAAK,OAAO,CAAC,oBAAoB,CAAC,CAAC;QACvE,IAAI,EAAE,CAAC,OAAO,EAAE,kBAAkB,KAAK,OAAO,CAAC,mBAAmB,CAAC,CAAC;QACpE,SAAS,EAAE,CAAC,OAAO,EAAE,uBAAuB,KAAK,OAAO,CAAC,wBAAwB,CAAC,CAAC;QACnF,KAAK,EAAE,CAAC,OAAO,EAAE,mBAAmB,KAAK,OAAO,CAAC,oBAAoB,CAAC,CAAC;KACtE,CA4aJ;CACF"}
|
|
@@ -99,11 +99,11 @@ export type ReaderProtocolsQueryResponse = DwnResponseStatus & {
|
|
|
99
99
|
* on every call (remote-only). All messages are unsigned, so only published
|
|
100
100
|
* records and protocols are accessible.
|
|
101
101
|
*
|
|
102
|
-
* Obtain an instance via {@link
|
|
102
|
+
* Obtain an instance via {@link Enbox.anonymous | `Enbox.anonymous()`}.
|
|
103
103
|
*
|
|
104
104
|
* @example
|
|
105
105
|
* ```ts
|
|
106
|
-
* const { dwn } =
|
|
106
|
+
* const { dwn } = Enbox.anonymous();
|
|
107
107
|
*
|
|
108
108
|
* const { records } = await dwn.records.query({
|
|
109
109
|
* from: 'did:dht:alice...',
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NOTE: Added reference types here to avoid a `pnpm` bug during build.
|
|
3
|
+
* https://github.com/enboxorg/enbox/pull/507
|
|
4
|
+
*/
|
|
5
|
+
import type { AuthSession } from '@enbox/auth';
|
|
6
|
+
import type { DidMethodResolver } from '@enbox/dids';
|
|
7
|
+
import type { EnboxAgent } from '@enbox/agent';
|
|
8
|
+
import type { ProtocolDefinition } from '@enbox/dwn-sdk-js';
|
|
9
|
+
import type { SchemaMap, TypedProtocol } from './protocol-types.js';
|
|
10
|
+
import { DidApi } from './did-api.js';
|
|
11
|
+
import { DwnReaderApi } from './dwn-reader-api.js';
|
|
12
|
+
import { TypedEnbox } from './typed-enbox.js';
|
|
13
|
+
import { VcApi } from './vc-api.js';
|
|
14
|
+
/**
|
|
15
|
+
* Options for creating an anonymous (read-only) Enbox instance via {@link Enbox.anonymous}.
|
|
16
|
+
*
|
|
17
|
+
* @beta
|
|
18
|
+
*/
|
|
19
|
+
export type EnboxAnonymousOptions = {
|
|
20
|
+
/** Override the default DID method resolvers. Defaults to `[DidDht, DidJwk, DidKey, DidWeb]`. */
|
|
21
|
+
didResolvers?: DidMethodResolver[];
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* The result of calling {@link Enbox.anonymous}.
|
|
25
|
+
*
|
|
26
|
+
* Contains only a read-only `dwn` property — no `did`, `vc`, or `agent`.
|
|
27
|
+
*
|
|
28
|
+
* @beta
|
|
29
|
+
*/
|
|
30
|
+
export type EnboxAnonymousApi = {
|
|
31
|
+
/** A read-only DWN API for querying public data on remote DWNs. */
|
|
32
|
+
dwn: DwnReaderApi;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Parameters for constructing an {@link Enbox} instance.
|
|
36
|
+
*
|
|
37
|
+
* These are the minimal primitives needed to interact with the DWN network.
|
|
38
|
+
* Typically obtained from an {@link AuthSession} via `@enbox/auth`.
|
|
39
|
+
*/
|
|
40
|
+
export type EnboxParams = {
|
|
41
|
+
/**
|
|
42
|
+
* A {@link EnboxAgent} instance that handles DIDs, DWNs and VCs requests. The agent manages the
|
|
43
|
+
* user keys and identities, and is responsible to sign and verify messages.
|
|
44
|
+
*/
|
|
45
|
+
agent: EnboxAgent;
|
|
46
|
+
/** The DID of the tenant under which all DID, DWN, and VC requests are being performed. */
|
|
47
|
+
connectedDid: string;
|
|
48
|
+
/** The DID that will be signing messages using grants from the connectedDid. */
|
|
49
|
+
delegateDid?: string;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* The main Enbox API interface. It provides protocol-scoped access to
|
|
53
|
+
* Decentralized Web Nodes (DWNs), Decentralized Identifiers (DIDs),
|
|
54
|
+
* and Verifiable Credentials (VCs).
|
|
55
|
+
*
|
|
56
|
+
* Authentication and identity management are handled externally by
|
|
57
|
+
* `@enbox/auth`. Use {@link Enbox.connect} to create an instance from
|
|
58
|
+
* an {@link AuthSession} or raw parameters.
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```ts
|
|
62
|
+
* import { AuthManager } from '@enbox/auth';
|
|
63
|
+
* import { Enbox } from '@enbox/api';
|
|
64
|
+
*
|
|
65
|
+
* const auth = await AuthManager.create({ sync: '15s' });
|
|
66
|
+
* const session = await auth.connect();
|
|
67
|
+
*
|
|
68
|
+
* const enbox = Enbox.connect({ session });
|
|
69
|
+
* const social = enbox.using(SocialProtocol);
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
export declare class Enbox {
|
|
73
|
+
/**
|
|
74
|
+
* A {@link EnboxAgent} instance that handles DIDs, DWNs and VCs requests. The agent manages the
|
|
75
|
+
* user keys and identities, and is responsible to sign and verify messages.
|
|
76
|
+
*/
|
|
77
|
+
agent: EnboxAgent;
|
|
78
|
+
/** Exposed instance to the DID APIs, allow users to create and resolve DIDs. */
|
|
79
|
+
did: DidApi;
|
|
80
|
+
/** Internal DWN API instance. Use {@link Enbox.using} for protocol-scoped access. */
|
|
81
|
+
private _dwn;
|
|
82
|
+
/**
|
|
83
|
+
* Cache of {@link TypedEnbox} instances keyed by protocol URI.
|
|
84
|
+
*
|
|
85
|
+
* Ensures that `enbox.using(Protocol)` returns the **same** `TypedEnbox`
|
|
86
|
+
* instance for a given protocol across multiple call sites, avoiding
|
|
87
|
+
* redundant protocol installations and duplicated internal state.
|
|
88
|
+
*/
|
|
89
|
+
private _typedInstances;
|
|
90
|
+
/** Exposed instance to the VC APIs, allow users to issue, present and verify VCs. */
|
|
91
|
+
vc: VcApi;
|
|
92
|
+
constructor({ agent, connectedDid, delegateDid }: EnboxParams);
|
|
93
|
+
/**
|
|
94
|
+
* Returns a {@link TypedEnbox} instance scoped to the given protocol.
|
|
95
|
+
*
|
|
96
|
+
* This is the **primary developer interface** for interacting with
|
|
97
|
+
* protocol-backed records. It auto-injects the protocol URI, protocolPath,
|
|
98
|
+
* and schema into every operation, and provides compile-time path
|
|
99
|
+
* autocompletion plus typed data payloads via the schema map.
|
|
100
|
+
*
|
|
101
|
+
* Instances are **cached by protocol URI** — calling `using()` multiple
|
|
102
|
+
* times with the same protocol returns the same `TypedEnbox` instance,
|
|
103
|
+
* so auto-configure only runs once and all call sites share state.
|
|
104
|
+
*
|
|
105
|
+
* @param protocol - A typed protocol created via `defineProtocol()`.
|
|
106
|
+
* @returns A `TypedEnbox` instance bound to the given protocol.
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* ```ts
|
|
110
|
+
* const social = enbox.using(SocialProtocol);
|
|
111
|
+
*
|
|
112
|
+
* await social.configure();
|
|
113
|
+
*
|
|
114
|
+
* const { record } = await social.records.write('friend', {
|
|
115
|
+
* data: { did: 'did:example:alice', alias: 'Alice' },
|
|
116
|
+
* });
|
|
117
|
+
*
|
|
118
|
+
* const { records } = await social.records.query('friend');
|
|
119
|
+
* ```
|
|
120
|
+
*/
|
|
121
|
+
using<D extends ProtocolDefinition, M extends SchemaMap>(protocol: TypedProtocol<D, M>): TypedEnbox<D, M>;
|
|
122
|
+
/**
|
|
123
|
+
* Stops DWN sync and clears the cached {@link TypedEnbox} instances.
|
|
124
|
+
*
|
|
125
|
+
* Call this when the application is shutting down or the user is
|
|
126
|
+
* disconnecting to cleanly release background resources. After calling
|
|
127
|
+
* `disconnect()`, the `Enbox` instance should not be reused.
|
|
128
|
+
*
|
|
129
|
+
* @param timeout - Maximum milliseconds to wait for an in-progress sync
|
|
130
|
+
* cycle to finish before force-stopping. Defaults to `2000`.
|
|
131
|
+
*
|
|
132
|
+
* @example
|
|
133
|
+
* ```ts
|
|
134
|
+
* await enbox.disconnect();
|
|
135
|
+
* ```
|
|
136
|
+
*
|
|
137
|
+
* @beta
|
|
138
|
+
*/
|
|
139
|
+
disconnect(timeout?: number): Promise<void>;
|
|
140
|
+
/**
|
|
141
|
+
* Creates a lightweight, read-only Enbox instance for querying public DWN data.
|
|
142
|
+
*
|
|
143
|
+
* No identity, vault, password, or signing keys are required. The returned
|
|
144
|
+
* API supports querying and reading published records and protocols from any
|
|
145
|
+
* remote DWN, using **unsigned** (anonymous) DWN messages.
|
|
146
|
+
*
|
|
147
|
+
* @param options - Optional configuration overrides.
|
|
148
|
+
* @returns An {@link EnboxAnonymousApi} with a read-only `dwn` property.
|
|
149
|
+
*
|
|
150
|
+
* @example
|
|
151
|
+
* ```ts
|
|
152
|
+
* const { dwn } = Enbox.anonymous();
|
|
153
|
+
*
|
|
154
|
+
* const { records } = await dwn.records.query({
|
|
155
|
+
* from: 'did:dht:alice...',
|
|
156
|
+
* filter: { protocol: 'https://social.example/posts', protocolPath: 'post' },
|
|
157
|
+
* });
|
|
158
|
+
*
|
|
159
|
+
* for (const record of records) {
|
|
160
|
+
* console.log(record.id, await record.data.text());
|
|
161
|
+
* }
|
|
162
|
+
* ```
|
|
163
|
+
*
|
|
164
|
+
* @beta
|
|
165
|
+
*/
|
|
166
|
+
static anonymous(options?: EnboxAnonymousOptions): EnboxAnonymousApi;
|
|
167
|
+
/**
|
|
168
|
+
* Creates an {@link Enbox} instance from an {@link AuthSession} or raw parameters.
|
|
169
|
+
*
|
|
170
|
+
* This is a thin factory — all authentication, identity management, vault
|
|
171
|
+
* initialization, DWN registration, and sync setup are handled externally
|
|
172
|
+
* by `@enbox/auth` via {@link AuthSession}.
|
|
173
|
+
*
|
|
174
|
+
* @param params - Either `{ session }` with an {@link AuthSession} from
|
|
175
|
+
* `@enbox/auth`, or raw `{ agent, connectedDid, delegateDid? }` parameters.
|
|
176
|
+
* @returns A new {@link Enbox} instance ready for use.
|
|
177
|
+
*
|
|
178
|
+
* @example
|
|
179
|
+
* ```ts
|
|
180
|
+
* // Using an AuthSession from @enbox/auth
|
|
181
|
+
* import { AuthManager } from '@enbox/auth';
|
|
182
|
+
* const auth = await AuthManager.create({ sync: '15s' });
|
|
183
|
+
* const session = await auth.connect();
|
|
184
|
+
* const enbox = Enbox.connect({ session });
|
|
185
|
+
*
|
|
186
|
+
* // Using raw parameters
|
|
187
|
+
* const enbox = Enbox.connect({ agent, connectedDid: did });
|
|
188
|
+
* ```
|
|
189
|
+
*/
|
|
190
|
+
static connect(params: {
|
|
191
|
+
session: AuthSession;
|
|
192
|
+
} | EnboxParams): Enbox;
|
|
193
|
+
}
|
|
194
|
+
/** @deprecated Use {@link Enbox} instead. Will be removed in a future version. */
|
|
195
|
+
export declare const Web5: typeof Enbox;
|
|
196
|
+
/** @deprecated Use {@link EnboxParams} instead. */
|
|
197
|
+
export type Web5Params = EnboxParams;
|
|
198
|
+
/** @deprecated Use {@link EnboxAnonymousOptions} instead. */
|
|
199
|
+
export type Web5AnonymousOptions = EnboxAnonymousOptions;
|
|
200
|
+
/** @deprecated Use {@link EnboxAnonymousApi} instead. */
|
|
201
|
+
export type Web5AnonymousApi = EnboxAnonymous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FAAqF;IACrF,OAAO,CAAC,IAAI,CAAS;IAErB;;;;;;OAMG;IACH,OAAO,CAAC,eAAe,CAAgE;IAEvF,qFAAqF;IAC9E,EAAE,EAAE,KAAK,CAAC;gBAEL,EAAE,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,EAAE,WAAW;IAO7D;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;IACI,KAAK,CAAC,CAAC,SAAS,kBAAkB,EAAE,CAAC,SAAS,SAAS,EAC5D,QAAQ,EAAE,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,GAC5B,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC;IAenB;;;;;;;;;;;;;;;;OAgBG;IACU,UAAU,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAUxD;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;WACW,SAAS,CAAC,OAAO,CAAC,EAAE,qBAAqB,GAAG,iBAAiB;IAc3E;;;;;;;;;;;;;;;;;;;;;;OAsBG;WACW,OAAO,CAAC,MAAM,EAAE;QAAE,OAAO,EAAE,WAAW,CAAA;KAAE,GAAG,WAAW,GAAG,KAAK;CAW7E;AAMD,kFAAkF;AAClF,eAAO,MAAM,IAAI,cAAQ,CAAC;AAE1B,mDAAmD;AACnD,MAAM,MAAM,UAAU,GAAG,WAAW,CAAC;AAErC,6DAA6D;AAC7D,MAAM,MAAM,oBAAoB,GAAG,qBAAqB,CAAC;AAEzD,yDAAyD;AACzD,MAAM,MAAM,gBAAgB,GAAG,iBAAiB,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { DwnDataEncodedRecordsWriteMessage, DwnResponseStatus,
|
|
1
|
+
import type { DwnDataEncodedRecordsWriteMessage, DwnResponseStatus, EnboxAgent } from '@enbox/agent';
|
|
2
2
|
/**
|
|
3
3
|
* Represents the structured data model of a GrantRevocation record, encapsulating the essential fields that define.
|
|
4
4
|
*/
|
|
@@ -36,7 +36,7 @@ export declare class PermissionGrantRevocation implements GrantRevocationModel {
|
|
|
36
36
|
/** parses the grant revocation given am agent, connectedDid and data encoded records write message */
|
|
37
37
|
static parse({ connectedDid, agent, message }: {
|
|
38
38
|
connectedDid: string;
|
|
39
|
-
agent:
|
|
39
|
+
agent: EnboxAgent;
|
|
40
40
|
message: DwnDataEncodedRecordsWriteMessage;
|
|
41
41
|
}): Promise<PermissionGrantRevocation>;
|
|
42
42
|
/** The agent to use for this instantiation of the grant revocation */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grant-revocation.d.ts","sourceRoot":"","sources":["../../src/grant-revocation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iCAAiC,EAAE,iBAAiB,
|
|
1
|
+
{"version":3,"file":"grant-revocation.d.ts","sourceRoot":"","sources":["../../src/grant-revocation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iCAAiC,EAAE,iBAAiB,EAAE,UAAU,EAAkB,MAAM,cAAc,CAAC;AAKrH;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,wDAAwD;IACxD,UAAU,EAAE,iCAAiC,CAAC;CAC/C;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,mFAAmF;IACnF,YAAY,EAAE,MAAM,CAAC;IACrB,wDAAwD;IACxD,OAAO,EAAE,iCAAiC,CAAC;CAC5C;AAED;;;;;;;GAOG;AACH,qBAAa,yBAA0B,YAAW,oBAAoB;IACpE,0EAA0E;IAC1E,OAAO,CAAC,YAAY,CAAsB;IAC1C,oFAAoF;IACpF,OAAO,CAAC,aAAa,CAAS;IAC9B,4FAA4F;IAC5F,OAAO,CAAC,QAAQ,CAAoC;IAEpD,OAAO;IAQP,sDAAsD;IACtD,IAAI,MAAM,IAAI,MAAM,GAAG,SAAS,CAE/B;IAED,uGAAuG;WAC1F,KAAK,CAAC,EAAE,YAAY,EAAE,KAAK,EAAE,OAAO,EAAE,EAAC;QAClD,YAAY,EAAE,MAAM,CAAC;QACrB,KAAK,EAAE,UAAU,CAAC;QAClB,OAAO,EAAE,iCAAiC,CAAC;KAC5C,GAAG,OAAO,CAAC,yBAAyB,CAAC;IAKtC,sEAAsE;IACtE,OAAO,KAAK,KAAK,GAEhB;IAED,8GAA8G;IAC9G,IAAI,UAAU,IAAI,iCAAiC,CAElD;IAED;;;;;;;;OAQG;IACG,IAAI,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAmBvD;;;;;;;OAOG;IACG,KAAK,CAAC,gBAAgB,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,iBAAiB,CAAC;CAgBpE"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Enbox SDK — high-level API for Decentralized Web Nodes, DIDs, and VCs.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* - Verifiable Credentials
|
|
7
|
-
* - DWeb Node personal datastores
|
|
4
|
+
* The SDK provides protocol-scoped access to DWN records with compile-time
|
|
5
|
+
* type safety, DID management, and Verifiable Credential operations.
|
|
8
6
|
*
|
|
9
|
-
*
|
|
10
|
-
* these pillar technologies to provide a simple library that is as close to
|
|
11
|
-
* effortless as possible.
|
|
7
|
+
* Authentication and identity management are handled by `@enbox/auth`.
|
|
12
8
|
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* import { AuthManager } from '@enbox/auth';
|
|
12
|
+
* import { Enbox } from '@enbox/api';
|
|
13
|
+
*
|
|
14
|
+
* const auth = await AuthManager.create({ sync: '15s' });
|
|
15
|
+
* const session = await auth.connect();
|
|
16
|
+
* const enbox = Enbox.connect({ session });
|
|
17
|
+
* ```
|
|
18
18
|
*
|
|
19
19
|
* [Link to GitHub Repo](https://github.com/enboxorg/enbox)
|
|
20
20
|
*
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
export * from './define-protocol.js';
|
|
24
24
|
export * from './did-api.js';
|
|
25
25
|
export * from './dwn-reader-api.js';
|
|
26
|
+
export * from './enbox.js';
|
|
26
27
|
export * from './grant-revocation.js';
|
|
27
28
|
export * from './live-query.js';
|
|
28
29
|
export * from './permission-grant.js';
|
|
@@ -35,11 +36,11 @@ export * from './record-data.js';
|
|
|
35
36
|
export * from './record-types.js';
|
|
36
37
|
export * from './repository.js';
|
|
37
38
|
export * from './repository-types.js';
|
|
39
|
+
export * from './typed-enbox.js';
|
|
38
40
|
export * from './typed-live-query.js';
|
|
39
41
|
export * from './typed-record.js';
|
|
40
|
-
export * from './typed-web5.js';
|
|
41
42
|
export * from './vc-api.js';
|
|
42
|
-
export * from './web5.js';
|
|
43
43
|
import * as utils from './utils.js';
|
|
44
44
|
export { utils };
|
|
45
|
+
export { isOk } from './utils.js';
|
|
45
46
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,cAAc,sBAAsB,CAAC;AACrC,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,cAAc,sBAAsB,CAAC;AACrC,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC;AACpC,cAAc,YAAY,CAAC;AAC3B,cAAc,uBAAuB,CAAC;AACtC,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAE5B,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,KAAK,EAAE,CAAC;AACjB,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { DwnMessageSubscription,
|
|
1
|
+
import type { DwnMessageSubscription, EnboxAgent, PermissionsApi } from '@enbox/agent';
|
|
2
2
|
import type { PaginationCursor, RecordsQueryReplyEntry } from '@enbox/dwn-sdk-js';
|
|
3
3
|
import { Record } from './record.js';
|
|
4
4
|
/**
|
|
@@ -30,7 +30,7 @@ export declare class RecordChangeEvent extends CustomEvent<RecordChange> {
|
|
|
30
30
|
*/
|
|
31
31
|
export type LiveQueryOptions = {
|
|
32
32
|
/** The agent instance used to construct Record objects. */
|
|
33
|
-
agent:
|
|
33
|
+
agent: EnboxAgent;
|
|
34
34
|
/** The DID of the connected user. */
|
|
35
35
|
connectedDid: string;
|
|
36
36
|
/** Optional delegate DID for permission-delegated access. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"live-query.d.ts","sourceRoot":"","sources":["../../src/live-query.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,
|
|
1
|
+
{"version":3,"file":"live-query.d.ts","sourceRoot":"","sources":["../../src/live-query.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACvF,OAAO,KAAK,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAIlF,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAE9D;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,2DAA2D;IAC3D,IAAI,EAAE,gBAAgB,CAAC;IAEvB,yCAAyC;IACzC,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF;;;;;;GAMG;AACH,qBAAa,iBAAkB,SAAQ,WAAW,CAAC,YAAY,CAAC;gBAClD,MAAM,EAAE,YAAY;CAGjC;AAED;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,2DAA2D;IAC3D,KAAK,EAAE,UAAU,CAAC;IAElB,qCAAqC;IACrC,YAAY,EAAE,MAAM,CAAC;IAErB,6DAA6D;IAC7D,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,yDAAyD;IACzD,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,iEAAiE;IACjE,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,oEAAoE;IACpE,cAAc,CAAC,EAAE,cAAc,CAAC;IAEhC,6DAA6D;IAC7D,cAAc,EAAE,sBAAsB,EAAE,CAAC;IAEzC,uEAAuE;IACvE,MAAM,CAAC,EAAE,gBAAgB,CAAC;IAE1B,8CAA8C;IAC9C,YAAY,EAAE,sBAAsB,CAAC;C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M,IAAI;IACxE,EAAE,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,GAAG,MAAM,IAAI;IAClE,EAAE,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,GAAG,MAAM,IAAI;IAClE,EAAE,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,GAAG,MAAM,IAAI;IAClE,EAAE,CAAC,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI;IAC1D,EAAE,CAAC,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,CAAC,MAAM,EAAE;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,GAAG,MAAM,IAAI;IACrF,EAAE,CAAC,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI;IACzD,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI;IAuBlD;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAO7B"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { DwnDataEncodedRecordsWriteMessage, DwnPermissionConditions, DwnPermissionScope, DwnResponseStatus,
|
|
1
|
+
import type { DwnDataEncodedRecordsWriteMessage, DwnPermissionConditions, DwnPermissionScope, DwnResponseStatus, EnboxAgent } from '@enbox/agent';
|
|
2
2
|
import { DwnPermissionGrant } from '@enbox/agent';
|
|
3
3
|
import { PermissionGrantRevocation } from './grant-revocation.js';
|
|
4
4
|
/**
|
|
@@ -55,7 +55,7 @@ export interface PermissionGrantOptions {
|
|
|
55
55
|
/** The underlying DWN `RecordsWrite` message along with encoded data that represent the grant */
|
|
56
56
|
message: DwnDataEncodedRecordsWriteMessage;
|
|
57
57
|
/** The agent to use when interacting with the underlying DWN record representing the grant */
|
|
58
|
-
agent:
|
|
58
|
+
agent: EnboxAgent;
|
|
59
59
|
}
|
|
60
60
|
/**
|
|
61
61
|
* The `PermissionGrant` class encapsulates a permissions protocol `grant` record, providing a more
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"permission-grant.d.ts","sourceRoot":"","sources":["../../src/permission-grant.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iCAAiC,EACjC,uBAAuB,EACvB,kBAAkB,EAClB,iBAAiB,
|
|
1
|
+
{"version":3,"file":"permission-grant.d.ts","sourceRoot":"","sources":["../../src/permission-grant.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iCAAiC,EACjC,uBAAuB,EACvB,kBAAkB,EAClB,iBAAiB,EACjB,UAAU,EAEX,MAAM,cAAc,CAAC;AAGtB,OAAO,EAGL,kBAAkB,EACnB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAElE;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC;;OAEG;IACH,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAEzB;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAEzB;;OAEG;IACH,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAE7B;;OAEG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAE9B;;OAEG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAE5B;;OAEG;IACH,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAE7B;;OAEG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;IAE7B;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,kBAAkB,CAAC;IAEnC;;O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;;;;;;OAQG;IACG,IAAI,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAmBvD;;;;;;;OAOG;IACG,KAAK,CAAC,WAAW,GAAE,OAAe,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAkBrE;;;;;;;;OAQG;IACG,MAAM,CAAC,KAAK,GAAE,OAAe,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAkBhE;;;;;;;OAOG;IACG,MAAM,CAAC,KAAK,GAAE,OAAc,GAAG,OAAO,CAAC,yBAAyB,CAAC;IAcvE;;;;;;;;OAQG;IACH,SAAS,CAAC,MAAM,GAAE,OAAe,GAAG,OAAO,CAAC,OAAO,CAAC;IASpD;;OAEG;IACH,MAAM,IAAI,kBAAkB;CAc7B"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { DwnDataEncodedRecordsWriteMessage, DwnPermissionConditions, DwnPermissionScope, DwnResponseStatus,
|
|
1
|
+
import type { DwnDataEncodedRecordsWriteMessage, DwnPermissionConditions, DwnPermissionScope, DwnResponseStatus, EnboxAgent } from '@enbox/agent';
|
|
2
2
|
import { PermissionGrant } from './permission-grant.js';
|
|
3
3
|
/**
|
|
4
4
|
* Represents the structured data model of a PermissionsRequest record, encapsulating the essential fields that define
|
|
@@ -52,7 +52,7 @@ export declare class PermissionRequest implements PermissionRequestModel {
|
|
|
52
52
|
/** parses the request given an agent, connectedDid and data encoded records write message */
|
|
53
53
|
static parse({ connectedDid, agent, message }: {
|
|
54
54
|
connectedDid: string;
|
|
55
|
-
agent:
|
|
55
|
+
agent: EnboxAgent;
|
|
56
56
|
message: DwnDataEncodedRecordsWriteMessage;
|
|
57
57
|
}): PermissionRequest;
|
|
58
58
|
/** The agent to use for this instantiation of the request */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"permission-request.d.ts","sourceRoot":"","sources":["../../src/permission-request.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iCAAiC,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AAI,EAAE,IAAI,MAAM,CAEf;IAED,8CAA8C;IAC9C,IAAI,SAAS,IAAI,MAAM,CAEtB;IAED,uDAAuD;IACvD,IAAI,WAAW,IAAI,MAAM,GAAG,SAAS,CAEpC;IAED,mFAAmF;IACnF,IAAI,SAAS,IAAI,OAAO,GAAG,SAAS,CAEnC;IAED,0EAA0E;IAC1E,IAAI,KAAK,IAAI,kBAAkB,CAE9B;IAED,oEAAoE;IACpE,IAAI,UAAU,IAAI,uBAAuB,GAAG,SAAS,CAEpD;IAED,iGAAiG;IACjG,IAAI,UAAU,IAAI,iCAAiC,CAElD;IAED;;;;;;;;OAQG;IACG,IAAI,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAmBvD;;;;;;;OAOG;IACG,KAAK,IAAI,OAAO,CAAC,iBAAiB,CAAC;IAgBzC;;;;;;;;OAQG;IACG,KAAK,CAAC,WAAW,EAAE,MAAM,EAAE,KAAK,GAAE,OAAc,GAAG,OAAO,CAAC,eAAe,CAAC;IAkBjF;;OAEG;IACH,MAAM,IAAI,sBAAsB;CAGjC"}
|
|
@@ -64,7 +64,7 @@ export type TagKeys<Tags extends ProtocolTagsDefinition> = Exclude<Extract<keyof
|
|
|
64
64
|
/**
|
|
65
65
|
* A mapping from protocol type names to their TypeScript data shapes.
|
|
66
66
|
*
|
|
67
|
-
* Used as a type parameter to `defineProtocol()` and `
|
|
67
|
+
* Used as a type parameter to `defineProtocol()` and `TypedEnbox` so that
|
|
68
68
|
* the protocol definition JSON stays JSON-compatible while TypeScript types
|
|
69
69
|
* are tracked separately.
|
|
70
70
|
*
|
|
@@ -80,7 +80,7 @@ export type SchemaMap = Record<string, unknown>;
|
|
|
80
80
|
/**
|
|
81
81
|
* The return type of `defineProtocol()`. Bundles the raw protocol definition
|
|
82
82
|
* with its inferred path strings and schema type map for downstream use
|
|
83
|
-
* by `
|
|
83
|
+
* by `TypedEnbox`.
|
|
84
84
|
*/
|
|
85
85
|
export type TypedProtocol<D extends ProtocolDefinition = ProtocolDefinition, M extends SchemaMap = SchemaMap> = {
|
|
86
86
|
/** The raw DWN protocol definition (JSON-compatible). */
|
package/dist/types/protocol.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* NOTE: Added reference types here to avoid a `pnpm` bug during build.
|
|
3
3
|
* https://github.com/enboxorg/enbox/pull/507
|
|
4
4
|
*/
|
|
5
|
-
import type { DwnMessage, DwnResponseStatus,
|
|
5
|
+
import type { DwnMessage, DwnResponseStatus, EnboxAgent } from '@enbox/agent';
|
|
6
6
|
import { DwnInterface } from '@enbox/agent';
|
|
7
7
|
/**
|
|
8
8
|
* Represents metadata associated with a protocol, including the author and an optional message CID.
|
|
@@ -20,24 +20,24 @@ export type ProtocolMetadata = {
|
|
|
20
20
|
/**
|
|
21
21
|
* Encapsulates a DWN Protocol with its associated metadata and configuration.
|
|
22
22
|
*
|
|
23
|
-
* This class
|
|
23
|
+
* This class primarily exists to provide developers with a convenient way to configure/install
|
|
24
24
|
* protocols on remote DWNs.
|
|
25
25
|
*/
|
|
26
26
|
export declare class Protocol {
|
|
27
|
-
/** The {@link
|
|
27
|
+
/** The {@link EnboxAgent} instance that handles DWNs requests. */
|
|
28
28
|
private _agent;
|
|
29
|
-
/** The ProtocolsConfigureMessage containing the detailed configuration for the protocol. */
|
|
30
|
-
private _metadata;
|
|
31
29
|
/** Metadata associated with the protocol, including the author and optional message CID. */
|
|
30
|
+
private _metadata;
|
|
31
|
+
/** The ProtocolsConfigureMessage containing the detailed configuration for the protocol. */
|
|
32
32
|
private _protocolsConfigureMessage;
|
|
33
33
|
/**
|
|
34
34
|
* Constructs a new instance of the Protocol class.
|
|
35
35
|
*
|
|
36
|
-
* @param agent - The
|
|
36
|
+
* @param agent - The EnboxAgent instance used for network interactions.
|
|
37
37
|
* @param protocolsConfigureMessage - The configuration message containing the protocol details.
|
|
38
38
|
* @param metadata - Metadata associated with the protocol, including the author and optional message CID.
|
|
39
39
|
*/
|
|
40
|
-
constructor(agent:
|
|
40
|
+
constructor(agent: EnboxAgent, protocolsConfigureMessage: DwnMessage[DwnInterface.ProtocolsConfigure], metadata: ProtocolMetadata);
|
|
41
41
|
/**
|
|
42
42
|
* Retrieves the protocol definition from the protocol's configuration message.
|
|
43
43
|
* @returns The protocol definition.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../../src/protocol.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,iBAAiB,EAAE,
|
|
1
|
+
{"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../../src/protocol.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE9E,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,kCAAkC;IAClC,MAAM,EAAE,MAAM,CAAC;IAEf;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF;;;;;GAKG;AACH,qBAAa,QAAQ;IACnB,kEAAkE;IAClE,OAAO,CAAC,MAAM,CAAa;IAE3B,4FAA4F;IAC5F,OAAO,CAAC,SAAS,CAAmB;IAEpC,4FAA4F;IAC5F,OAAO,CAAC,0BAA0B,CAA8C;IAEhF;;;;;;OAMG;gBACS,KAAK,EAAE,UAAU,EAAE,yBAAyB,EAAE,UAAU,CAAC,YAAY,CAAC,kBAAkB,CAAC,EAAE,QAAQ,EAAE,gBAAgB;IAMjI;;;OAGG;IACH,IAAI,UAAU,IAAI,UAAU,CAAC,YAAY,CAAC,kBAAkB,CAAC,CAAC,YAAY,CAAC,CAAC,YAAY,CAAC,CAExF;IAED;;;OAGG;IACH,MAAM,IAAI,UAAU,CAAC,YAAY,CAAC,kBAAkB,CAAC;IAIrD;;;;;OAKG;IACG,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC;CAUvD"}
|
|
@@ -5,6 +5,10 @@
|
|
|
5
5
|
* evaluated `stream()` function with convenience accessors that mirror the
|
|
6
6
|
* Fetch `Response` API (`blob()`, `bytes()`, `json()`, `text()`).
|
|
7
7
|
*
|
|
8
|
+
* Data is **cached after first read** so that subsequent calls to any accessor
|
|
9
|
+
* return the same data without re-fetching. Concurrent calls are safe — only
|
|
10
|
+
* one fetch is performed and all callers share the result.
|
|
11
|
+
*
|
|
8
12
|
* Extracted from `record.ts` so the convenience-method boilerplate lives in
|
|
9
13
|
* its own module while the stream-resolution logic (which is tightly coupled
|
|
10
14
|
* to `Record` internals) stays inside the `Record` class.
|
|
@@ -18,6 +22,10 @@
|
|
|
18
22
|
* formats, plus `then`/`catch` so the object can be awaited directly to
|
|
19
23
|
* obtain the underlying `ReadableStream`.
|
|
20
24
|
*
|
|
25
|
+
* Data is cached after the first read so that repeated calls (e.g.,
|
|
26
|
+
* `data.json()` followed by `data.text()`) do not trigger redundant
|
|
27
|
+
* network requests.
|
|
28
|
+
*
|
|
21
29
|
* @beta
|
|
22
30
|
*/
|
|
23
31
|
export type RecordData = {
|
|
@@ -39,6 +47,15 @@ export type RecordData = {
|
|
|
39
47
|
/**
|
|
40
48
|
* Create a {@link RecordData} wrapper around a `stream` provider function.
|
|
41
49
|
*
|
|
50
|
+
* The first call to any accessor (`blob`, `bytes`, `json`, `text`, `stream`)
|
|
51
|
+
* consumes the underlying stream and caches the raw bytes (up to
|
|
52
|
+
* {@link DATA_CACHE_LIMIT}). Subsequent calls reconstruct a fresh stream
|
|
53
|
+
* from the cache, preventing the common footgun of stale data after stream
|
|
54
|
+
* consumption.
|
|
55
|
+
*
|
|
56
|
+
* Concurrent calls are safe: if multiple accessors are called simultaneously,
|
|
57
|
+
* only one stream fetch is performed and all callers share the result.
|
|
58
|
+
*
|
|
42
59
|
* @param streamFn - A function that returns a `Promise<ReadableStream>` for the record data.
|
|
43
60
|
* @param dataFormat - The MIME type used when constructing Blobs.
|
|
44
61
|
* @returns A {@link RecordData} object with convenience accessors.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"record-data.d.ts","sourceRoot":"","sources":["../../src/record-data.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;
|
|
1
|
+
{"version":3,"file":"record-data.d.ts","sourceRoot":"","sources":["../../src/record-data.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAWH;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB,oCAAoC;IACpC,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1B,qCAAqC;IACrC,KAAK,EAAE,MAAM,OAAO,CAAC,UAAU,CAAC,CAAC;IACjC,8BAA8B;IAC9B,IAAI,EAAE,CAAC,CAAC,GAAG,OAAO,OAAO,OAAO,CAAC,CAAC,CAAC,CAAC;IACpC,0CAA0C;IAC1C,IAAI,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;IAC5B,kDAAkD;IAClD,MAAM,EAAE,MAAM,OAAO,CAAC,cAAc,CAAC,CAAC;IACtC,0EAA0E;IAC1E,IAAI,EAAE,CACJ,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,cAAc,GAAG,WAAW,CAAC,cAAc,CAAC,EACrF,UAAU,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,WAAW,CAAC,KAAK,CAAC,KAC7C,OAAO,CAAC,cAAc,CAAC,CAAC;IAC7B,uCAAuC;IACvC,KAAK,EAAE,CAAC,UAAU,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,WAAW,CAAC,KAAK,CAAC,KAAK,OAAO,CAAC,cAAc,CAAC,CAAC;CACtF,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,OAAO,CAAC,cAAc,CAAC,EAAE,UAAU,EAAE,MAAM,GAAG,SAAS,GAAG,UAAU,CA6JpH"}
|