@enbox/api 0.0.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/LICENSE +201 -0
- package/README.md +585 -0
- package/dist/browser.js +2226 -0
- package/dist/browser.js.map +7 -0
- package/dist/browser.mjs +2226 -0
- package/dist/browser.mjs.map +7 -0
- package/dist/cjs/did-api.js +126 -0
- package/dist/cjs/did-api.js.map +1 -0
- package/dist/cjs/dwn-api.js +804 -0
- package/dist/cjs/dwn-api.js.map +1 -0
- package/dist/cjs/grant-revocation.js +183 -0
- package/dist/cjs/grant-revocation.js.map +1 -0
- package/dist/cjs/index.js +63 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/permission-grant.js +365 -0
- package/dist/cjs/permission-grant.js.map +1 -0
- package/dist/cjs/permission-request.js +272 -0
- package/dist/cjs/permission-request.js.map +1 -0
- package/dist/cjs/protocol.js +110 -0
- package/dist/cjs/protocol.js.map +1 -0
- package/dist/cjs/record.js +1127 -0
- package/dist/cjs/record.js.map +1 -0
- package/dist/cjs/subscription-util.js +86 -0
- package/dist/cjs/subscription-util.js.map +1 -0
- package/dist/cjs/utils.js +127 -0
- package/dist/cjs/utils.js.map +1 -0
- package/dist/cjs/vc-api.js +64 -0
- package/dist/cjs/vc-api.js.map +1 -0
- package/dist/cjs/web5.js +471 -0
- package/dist/cjs/web5.js.map +1 -0
- package/dist/esm/did-api.js +69 -0
- package/dist/esm/did-api.js.map +1 -0
- package/dist/esm/dwn-api.js +573 -0
- package/dist/esm/dwn-api.js.map +1 -0
- package/dist/esm/grant-revocation.js +109 -0
- package/dist/esm/grant-revocation.js.map +1 -0
- package/dist/esm/index.js +34 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/permission-grant.js +233 -0
- package/dist/esm/permission-grant.js.map +1 -0
- package/dist/esm/permission-request.js +166 -0
- package/dist/esm/permission-request.js.map +1 -0
- package/dist/esm/protocol.js +67 -0
- package/dist/esm/protocol.js.map +1 -0
- package/dist/esm/record.js +814 -0
- package/dist/esm/record.js.map +1 -0
- package/dist/esm/subscription-util.js +35 -0
- package/dist/esm/subscription-util.js.map +1 -0
- package/dist/esm/utils.js +120 -0
- package/dist/esm/utils.js.map +1 -0
- package/dist/esm/vc-api.js +30 -0
- package/dist/esm/vc-api.js.map +1 -0
- package/dist/esm/web5.js +281 -0
- package/dist/esm/web5.js.map +1 -0
- package/dist/types/did-api.d.ts +66 -0
- package/dist/types/did-api.d.ts.map +1 -0
- package/dist/types/dwn-api.d.ts +336 -0
- package/dist/types/dwn-api.d.ts.map +1 -0
- package/dist/types/grant-revocation.d.ts +66 -0
- package/dist/types/grant-revocation.d.ts.map +1 -0
- package/dist/types/index.d.ts +34 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/permission-grant.d.ts +157 -0
- package/dist/types/permission-grant.d.ts.map +1 -0
- package/dist/types/permission-request.d.ts +108 -0
- package/dist/types/permission-request.d.ts.map +1 -0
- package/dist/types/protocol.d.ts +59 -0
- package/dist/types/protocol.d.ts.map +1 -0
- package/dist/types/record.d.ts +441 -0
- package/dist/types/record.d.ts.map +1 -0
- package/dist/types/subscription-util.d.ts +19 -0
- package/dist/types/subscription-util.d.ts.map +1 -0
- package/dist/types/utils.d.ts +85 -0
- package/dist/types/utils.d.ts.map +1 -0
- package/dist/types/vc-api.d.ts +24 -0
- package/dist/types/vc-api.d.ts.map +1 -0
- package/dist/types/web5.d.ts +219 -0
- package/dist/types/web5.d.ts.map +1 -0
- package/package.json +111 -0
- package/src/did-api.ts +90 -0
- package/src/dwn-api.ts +952 -0
- package/src/grant-revocation.ts +124 -0
- package/src/index.ts +35 -0
- package/src/permission-grant.ts +327 -0
- package/src/permission-request.ts +214 -0
- package/src/protocol.ts +87 -0
- package/src/record.ts +1125 -0
- package/src/subscription-util.ts +42 -0
- package/src/utils.ts +128 -0
- package/src/vc-api.ts +30 -0
- package/src/web5.ts +516 -0
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NOTE: Added reference types here to avoid a `pnpm` bug during build.
|
|
3
|
+
* https://github.com/TBD54566975/web5-js/pull/507
|
|
4
|
+
*/
|
|
5
|
+
import type { CreateGrantParams, CreateRequestParams, FetchPermissionRequestParams, FetchPermissionsParams } from '@enbox/agent';
|
|
6
|
+
import { Web5Agent, DwnMessageParams, DwnMessageSubscription, DwnResponseStatus, DwnPaginationCursor } from '@enbox/agent';
|
|
7
|
+
import { DwnInterface } from '@enbox/agent';
|
|
8
|
+
import { Record } from './record.js';
|
|
9
|
+
import { Protocol } from './protocol.js';
|
|
10
|
+
import { PermissionGrant } from './permission-grant.js';
|
|
11
|
+
import { PermissionRequest } from './permission-request.js';
|
|
12
|
+
/**
|
|
13
|
+
* Represents the request payload for fetching permission requests from a Decentralized Web Node (DWN).
|
|
14
|
+
*
|
|
15
|
+
* Optionally, specify a remote DWN target in the `from` property to fetch requests from.
|
|
16
|
+
*/
|
|
17
|
+
export type FetchRequestsRequest = Omit<FetchPermissionRequestParams, 'author' | 'target' | 'remote'> & {
|
|
18
|
+
/** Optional DID specifying the remote target DWN tenant to be queried. */
|
|
19
|
+
from?: string;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Represents the request payload for fetching permission grants from a Decentralized Web Node (DWN).
|
|
23
|
+
*
|
|
24
|
+
* Optionally, specify a remote DWN target in the `from` property to fetch requests from.
|
|
25
|
+
* Optionally, specify whether to check if the grant is revoked in the `checkRevoked` property.
|
|
26
|
+
*/
|
|
27
|
+
export type FetchGrantsRequest = Omit<FetchPermissionsParams, 'author' | 'target' | 'remote'> & {
|
|
28
|
+
/** Optional DID specifying the remote target DWN tenant to be queried. */
|
|
29
|
+
from?: string;
|
|
30
|
+
/** Optionally check if the grant has been revoked. */
|
|
31
|
+
checkRevoked?: boolean;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Represents the request payload for configuring a protocol on a Decentralized Web Node (DWN).
|
|
35
|
+
*
|
|
36
|
+
* This request type is used to specify the configuration options for the protocol.
|
|
37
|
+
*/
|
|
38
|
+
export type ProtocolsConfigureRequest = {
|
|
39
|
+
/** Configuration options for the protocol. */
|
|
40
|
+
message: Omit<DwnMessageParams[DwnInterface.ProtocolsConfigure], 'signer'>;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Encapsulates the response from a protocol configuration request to a Decentralized Web Node (DWN).
|
|
44
|
+
*
|
|
45
|
+
* This response type combines the general operation status with the details of the protocol that
|
|
46
|
+
* was configured, if the operation was successful.
|
|
47
|
+
*
|
|
48
|
+
* @beta
|
|
49
|
+
*/
|
|
50
|
+
export type ProtocolsConfigureResponse = DwnResponseStatus & {
|
|
51
|
+
/** The configured protocol, if successful. */
|
|
52
|
+
protocol?: Protocol;
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Defines the request structure for querying protocols from a Decentralized Web Node (DWN).
|
|
56
|
+
*
|
|
57
|
+
* This request type is used to specify the target DWN from which protocols should be queried and
|
|
58
|
+
* any additional query filters or options. If the `from` property is not provided, the query will
|
|
59
|
+
* target the local DWN. If the `from` property is provided, the query will target the specified
|
|
60
|
+
* remote DWN.
|
|
61
|
+
*/
|
|
62
|
+
export type ProtocolsQueryRequest = {
|
|
63
|
+
/** Optional DID specifying the remote target DWN tenant to be queried. */
|
|
64
|
+
from?: string;
|
|
65
|
+
/** Query filters and options that influence the results returned. */
|
|
66
|
+
message: Omit<DwnMessageParams[DwnInterface.ProtocolsQuery], 'signer'>;
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* Wraps the response from a protocols query, including the operation status and the list of
|
|
70
|
+
* protocols.
|
|
71
|
+
*/
|
|
72
|
+
export type ProtocolsQueryResponse = DwnResponseStatus & {
|
|
73
|
+
/** Array of protocols matching the query. */
|
|
74
|
+
protocols: Protocol[];
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* Type alias for {@link RecordsWriteRequest}
|
|
78
|
+
*/
|
|
79
|
+
export type RecordsCreateRequest = RecordsWriteRequest;
|
|
80
|
+
/**
|
|
81
|
+
* Type alias for {@link RecordsWriteResponse}
|
|
82
|
+
*/
|
|
83
|
+
export type RecordsCreateResponse = RecordsWriteResponse;
|
|
84
|
+
/**
|
|
85
|
+
* Represents a request to create a new record based on an existing one.
|
|
86
|
+
*
|
|
87
|
+
* This request type allows specifying the new data for the record, along with any additional
|
|
88
|
+
* message parameters required for the write operation.
|
|
89
|
+
*/
|
|
90
|
+
export type RecordsCreateFromRequest = {
|
|
91
|
+
/** The DID of the entity authoring the record. */
|
|
92
|
+
author: string;
|
|
93
|
+
/** The new data for the record. */
|
|
94
|
+
data: unknown;
|
|
95
|
+
/** ptional additional parameters for the record write operation */
|
|
96
|
+
message?: Omit<DwnMessageParams[DwnInterface.RecordsWrite], 'signer'>;
|
|
97
|
+
/** The existing record instance that is being used as a basis for the new record. */
|
|
98
|
+
record: Record;
|
|
99
|
+
};
|
|
100
|
+
/**
|
|
101
|
+
* Defines a request to delete a record from the Decentralized Web Node (DWN).
|
|
102
|
+
*
|
|
103
|
+
* This request type optionally specifies the target from which the record should be deleted and the
|
|
104
|
+
* message parameters for the delete operation. If the `from` property is not provided, the record
|
|
105
|
+
* will be deleted from the local DWN.
|
|
106
|
+
*/
|
|
107
|
+
export type RecordsDeleteRequest = {
|
|
108
|
+
/** Optional DID specifying the remote target DWN tenant the record will be deleted from. */
|
|
109
|
+
from?: string;
|
|
110
|
+
/** Records must be scoped to a specific protocol */
|
|
111
|
+
protocol?: string;
|
|
112
|
+
/** The parameters for the delete operation. */
|
|
113
|
+
message: Omit<DwnMessageParams[DwnInterface.RecordsDelete], 'signer'>;
|
|
114
|
+
};
|
|
115
|
+
/**
|
|
116
|
+
* Encapsulates a request to query records from a Decentralized Web Node (DWN).
|
|
117
|
+
*
|
|
118
|
+
* This request type is used to specify the criteria for querying records, including query
|
|
119
|
+
* parameters, and optionally the target DWN to query from. If the `from` property is not provided,
|
|
120
|
+
* the query will target the local DWN.
|
|
121
|
+
*/
|
|
122
|
+
export type RecordsQueryRequest = {
|
|
123
|
+
/** Optional DID specifying the remote target DWN tenant to query from and return results. */
|
|
124
|
+
from?: string;
|
|
125
|
+
/** Records must be scoped to a specific protocol */
|
|
126
|
+
protocol?: string;
|
|
127
|
+
/** The parameters for the query operation, detailing the criteria for selecting records. */
|
|
128
|
+
message: Omit<DwnMessageParams[DwnInterface.RecordsQuery], 'signer'>;
|
|
129
|
+
};
|
|
130
|
+
/**
|
|
131
|
+
* Represents the response from a records query operation, including status, records, and an
|
|
132
|
+
* optional pagination cursor.
|
|
133
|
+
*/
|
|
134
|
+
export type RecordsQueryResponse = DwnResponseStatus & {
|
|
135
|
+
/** Array of records matching the query. */
|
|
136
|
+
records?: Record[];
|
|
137
|
+
/** If there are additional results, the messageCid of the last record will be returned as a pagination cursor. */
|
|
138
|
+
cursor?: DwnPaginationCursor;
|
|
139
|
+
};
|
|
140
|
+
/**
|
|
141
|
+
* Represents a request to read a specific record from a Decentralized Web Node (DWN).
|
|
142
|
+
*
|
|
143
|
+
* This request type is used to specify the target DWN from which the record should be read and any
|
|
144
|
+
* additional parameters for the read operation. It's useful for fetching the details of a single
|
|
145
|
+
* record by its identifier or other criteria.
|
|
146
|
+
*/
|
|
147
|
+
export type RecordsReadRequest = {
|
|
148
|
+
/** Optional DID specifying the remote target DWN tenant the record will be read from. */
|
|
149
|
+
from?: string;
|
|
150
|
+
/** Records must be scoped to a specific protocol */
|
|
151
|
+
protocol?: string;
|
|
152
|
+
/** The parameters for the read operation, detailing the criteria for selecting the record. */
|
|
153
|
+
message: Omit<DwnMessageParams[DwnInterface.RecordsRead], 'signer'>;
|
|
154
|
+
};
|
|
155
|
+
/**
|
|
156
|
+
* Encapsulates the response from a record read operation, combining the general operation status
|
|
157
|
+
* with the specific record that was retrieved.
|
|
158
|
+
*/
|
|
159
|
+
export type RecordsReadResponse = DwnResponseStatus & {
|
|
160
|
+
/** The record retrieved by the read operation. */
|
|
161
|
+
record: Record;
|
|
162
|
+
};
|
|
163
|
+
/** Subscription handler for Records */
|
|
164
|
+
export type RecordsSubscriptionHandler = (record: Record) => void;
|
|
165
|
+
/**
|
|
166
|
+
* Represents a request to subscribe to records from a Decentralized Web Node (DWN).
|
|
167
|
+
*
|
|
168
|
+
* This request type is used to specify the target DWN from which records matching the subscription
|
|
169
|
+
* criteria should be emitted. It's useful for being notified in real time when records are written, deleted or modified.
|
|
170
|
+
*/
|
|
171
|
+
export type RecordsSubscribeRequest = {
|
|
172
|
+
/** Optional DID specifying the remote target DWN tenant to subscribe from. */
|
|
173
|
+
from?: string;
|
|
174
|
+
/** Records must be scoped to a specific protocol */
|
|
175
|
+
protocol?: string;
|
|
176
|
+
/** The parameters for the subscription operation, detailing the criteria for the subscription filter */
|
|
177
|
+
message: Omit<DwnMessageParams[DwnInterface.RecordsSubscribe], 'signer'>;
|
|
178
|
+
/** The handler to process the subscription events */
|
|
179
|
+
subscriptionHandler: RecordsSubscriptionHandler;
|
|
180
|
+
};
|
|
181
|
+
/** Encapsulates the response from a DWN RecordsSubscriptionRequest */
|
|
182
|
+
export type RecordsSubscribeResponse = DwnResponseStatus & {
|
|
183
|
+
/**
|
|
184
|
+
* Represents the subscription that was created. Includes an ID and the close method to stop the subscription.
|
|
185
|
+
*
|
|
186
|
+
* */
|
|
187
|
+
subscription?: DwnMessageSubscription;
|
|
188
|
+
};
|
|
189
|
+
/**
|
|
190
|
+
* Defines a request to write (create) a record to a Decentralized Web Node (DWN).
|
|
191
|
+
*
|
|
192
|
+
* This request type allows specifying the data for the new or updated record, along with any
|
|
193
|
+
* additional message parameters required for the write operation, and an optional flag to indicate
|
|
194
|
+
* whether the record should be immediately stored.
|
|
195
|
+
*
|
|
196
|
+
* @param data -
|
|
197
|
+
* @param message - , excluding the signer.
|
|
198
|
+
* @param store -
|
|
199
|
+
*/
|
|
200
|
+
export type RecordsWriteRequest = {
|
|
201
|
+
/** The data payload for the record, which can be of any type. */
|
|
202
|
+
data: unknown;
|
|
203
|
+
/** Optional additional parameters for the record write operation. */
|
|
204
|
+
message?: Omit<Partial<DwnMessageParams[DwnInterface.RecordsWrite]>, 'signer'>;
|
|
205
|
+
/**
|
|
206
|
+
* Optional flag indicating whether the record should be immediately stored. If true, the record
|
|
207
|
+
* is persisted in the DWN as part of the write operation. If false, the record is created,
|
|
208
|
+
* signed, and returned but not persisted.
|
|
209
|
+
*/
|
|
210
|
+
store?: boolean;
|
|
211
|
+
};
|
|
212
|
+
/**
|
|
213
|
+
* Encapsulates the response from a record write operation to a Decentralized Web Node (DWN).
|
|
214
|
+
*
|
|
215
|
+
* This request type combines the general operation status with the details of the record that was
|
|
216
|
+
* written, if the operation was successful.
|
|
217
|
+
*
|
|
218
|
+
* The response includes a status object that contains the HTTP-like status code and detail message
|
|
219
|
+
* indicating the success or failure of the write operation. If the operation was successful and a
|
|
220
|
+
* record was created or updated, the `record` property will contain an instance of the `Record`
|
|
221
|
+
* class representing the written record. This allows the caller to access the written record's
|
|
222
|
+
* details and perform additional operations using the provided {@link Record} instance methods.
|
|
223
|
+
*/
|
|
224
|
+
export type RecordsWriteResponse = DwnResponseStatus & {
|
|
225
|
+
/**
|
|
226
|
+
* The `Record` instance representing the record that was successfully written to the
|
|
227
|
+
* DWN as a result of the write operation.
|
|
228
|
+
*/
|
|
229
|
+
record?: Record;
|
|
230
|
+
};
|
|
231
|
+
/**
|
|
232
|
+
* Interface to interact with DWN Records and Protocols
|
|
233
|
+
*/
|
|
234
|
+
export declare class DwnApi {
|
|
235
|
+
/**
|
|
236
|
+
* Holds the instance of a {@link Web5Agent} that represents the current execution context for
|
|
237
|
+
* the `DwnApi`. This agent is used to process DWN requests.
|
|
238
|
+
*/
|
|
239
|
+
private agent;
|
|
240
|
+
/** The DID of the DWN tenant under which operations are being performed. */
|
|
241
|
+
private connectedDid;
|
|
242
|
+
/** (optional) The DID of the signer when signing with permissions */
|
|
243
|
+
private delegateDid?;
|
|
244
|
+
/** Holds the instance of {@link AgentPermissionsApi} that helps when dealing with permissions protocol records */
|
|
245
|
+
private permissionsApi;
|
|
246
|
+
constructor(options: {
|
|
247
|
+
agent: Web5Agent;
|
|
248
|
+
connectedDid: string;
|
|
249
|
+
delegateDid?: string;
|
|
250
|
+
});
|
|
251
|
+
/**
|
|
252
|
+
* API to interact with Grants
|
|
253
|
+
*
|
|
254
|
+
* NOTE: This is an EXPERIMENTAL API that will change behavior.
|
|
255
|
+
*
|
|
256
|
+
* Currently only supports issuing requests, grants, revokes and queries on behalf without permissions or impersonation.
|
|
257
|
+
* If the agent is connected to a delegateDid, the delegateDid will be used to sign/author the underlying records.
|
|
258
|
+
* If the agent is not connected to a delegateDid, the connectedDid will be used to sign/author the underlying records.
|
|
259
|
+
*
|
|
260
|
+
* @beta
|
|
261
|
+
*/
|
|
262
|
+
get permissions(): {
|
|
263
|
+
/**
|
|
264
|
+
* Request permission for a specific scope.
|
|
265
|
+
*/
|
|
266
|
+
request: (request: Omit<CreateRequestParams, 'author'>) => Promise<PermissionRequest>;
|
|
267
|
+
/**
|
|
268
|
+
* Grant permission for a specific scope to a grantee DID.
|
|
269
|
+
*/
|
|
270
|
+
grant: (request: Omit<CreateGrantParams, 'author'>) => Promise<PermissionGrant>;
|
|
271
|
+
/**
|
|
272
|
+
* Query permission requests. You can filter by protocol and specify if you want to query a remote DWN.
|
|
273
|
+
*/
|
|
274
|
+
queryRequests: (request?: FetchRequestsRequest) => Promise<PermissionRequest[]>;
|
|
275
|
+
/**
|
|
276
|
+
* Query permission grants. You can filter by grantee, grantor, protocol and specify if you want to query a remote DWN.
|
|
277
|
+
*/
|
|
278
|
+
queryGrants: (request?: FetchGrantsRequest) => Promise<PermissionGrant[]>;
|
|
279
|
+
};
|
|
280
|
+
/**
|
|
281
|
+
* API to interact with DWN protocols (e.g., `dwn.protocols.configure()`).
|
|
282
|
+
*/
|
|
283
|
+
get protocols(): {
|
|
284
|
+
/**
|
|
285
|
+
* Configure method, used to setup a new protocol (or update) with the passed definitions
|
|
286
|
+
*/
|
|
287
|
+
configure: (request: ProtocolsConfigureRequest) => Promise<ProtocolsConfigureResponse>;
|
|
288
|
+
/**
|
|
289
|
+
* Query the available protocols
|
|
290
|
+
*/
|
|
291
|
+
query: (request: ProtocolsQueryRequest) => Promise<ProtocolsQueryResponse>;
|
|
292
|
+
};
|
|
293
|
+
/**
|
|
294
|
+
* API to interact with DWN records (e.g., `dwn.records.create()`).
|
|
295
|
+
*/
|
|
296
|
+
get records(): {
|
|
297
|
+
/**
|
|
298
|
+
* Alias for the `write` method
|
|
299
|
+
*/
|
|
300
|
+
create: (request: RecordsCreateRequest) => Promise<RecordsCreateResponse>;
|
|
301
|
+
/**
|
|
302
|
+
* Write a record based on an existing one (useful for updating an existing record)
|
|
303
|
+
*/
|
|
304
|
+
createFrom: (request: RecordsCreateFromRequest) => Promise<RecordsWriteResponse>;
|
|
305
|
+
/**
|
|
306
|
+
* Delete a record
|
|
307
|
+
*/
|
|
308
|
+
delete: (request: RecordsDeleteRequest) => Promise<DwnResponseStatus>;
|
|
309
|
+
/**
|
|
310
|
+
* Query a single or multiple records based on the given filter
|
|
311
|
+
*/
|
|
312
|
+
query: (request: RecordsQueryRequest) => Promise<RecordsQueryResponse>;
|
|
313
|
+
/**
|
|
314
|
+
* Read a single record based on the given filter
|
|
315
|
+
*/
|
|
316
|
+
read: (request: RecordsReadRequest) => Promise<RecordsReadResponse>;
|
|
317
|
+
/**
|
|
318
|
+
* Subscribes to records based on the given filter and emits events to the `subscriptionHandler`.
|
|
319
|
+
*
|
|
320
|
+
* @param request must include the `message` with the subscription filter and the `subscriptionHandler` to process the events.
|
|
321
|
+
* @returns the subscription status and the subscription object used to close the subscription.
|
|
322
|
+
*/
|
|
323
|
+
subscribe: (request: RecordsSubscribeRequest) => Promise<RecordsSubscribeResponse>;
|
|
324
|
+
/**
|
|
325
|
+
* Writes a record to the DWN
|
|
326
|
+
*
|
|
327
|
+
* As a convenience, the Record instance returned will cache a copy of the data. This is done
|
|
328
|
+
* to maintain consistency with other DWN methods, like RecordsQuery, that include relatively
|
|
329
|
+
* small data payloads when returning RecordsWrite message properties. Regardless of data
|
|
330
|
+
* size, methods such as `record.data.stream()` will return the data when called even if it
|
|
331
|
+
* requires fetching from the DWN datastore.
|
|
332
|
+
*/
|
|
333
|
+
write: (request: RecordsWriteRequest) => Promise<RecordsWriteResponse>;
|
|
334
|
+
};
|
|
335
|
+
}
|
|
336
|
+
//# sourceMappingURL=dwn-api.d.ts.map
|
|
@@ -0,0 +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,EACnB,4BAA4B,EAC5B,sBAAsB,EACvB,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,SAAS,EAGT,gBAAgB,EAChB,sBAAsB,EACtB,iBAAiB,EAEjB,mBAAmB,EAEpB,MAAM,cAAc,CAAC;AAGtB,OAAO,EAAE,YAAY,EAAmB,MAAM,cAAc,CAAC;AAE7D,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAG5D;;;;GAIG;AACH,MAAM,MAAM,oBAAoB,GAAG,IAAI,CAAC,4BAA4B,EAAE,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAC,GAAG;IACtG,0EAA0E;IAC1E,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,kBAAkB,GAAG,IAAI,CAAC,sBAAsB,EAAE,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAC,GAAG;IAC9F,0EAA0E;IAC1E,IAAI,CAAC,EA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xF;;WAEG;yBACmB,KAAK,iBAAiB,EAAE,QAAQ,CAAC,KAAG,QAAQ,eAAe,CAAC;QAclF;;WAEG;kCAC2B,oBAAoB,KAAO,QAAQ,iBAAiB,EAAE,CAAC;QAqBrF;;WAEG;gCACyB,kBAAkB,KAAQ,QAAQ,eAAe,EAAE,CAAC;MAgCnF;IAED;;OAEG;IACH,IAAI,SAAS;QAET;;WAEG;6BACwB,yBAAyB,KAAG,QAAQ,0BAA0B,CAAC;QAuC1F;;WAEG;yBACoB,qBAAqB,KAAG,QAAQ,sBAAsB,CAAC;MAmDjF;IAED;;OAEG;IACH,IAAI,OAAO;QAGP;;WAEG;0BACqB,oBAAoB,KAAG,QAAQ,qBAAqB,CAAC;QAI7E;;WAEG;8BACyB,wBAAwB,KAAG,QAAQ,oBAAoB,CAAC;QA+BpF;;WAEG;0BACqB,oBAAoB,KAAG,QAAQ,iBAAiB,CAAC;QA8CzE;;WAEG;yBACoB,mBAAmB,KAAG,QAAQ,oBAAoB,CAAC;QAyF1E;;WAEG;wBACmB,kBAAkB,KAAG,QAAQ,mBAAmB,CAAC;QAwFvE;;;;;WAKG;6BACwB,uBAAuB,KAAG,QAAQ,wBAAwB,CAAC;QAuEtF;;;;;;;;WAQG;yBACoB,mBAAmB,KAAG,QAAQ,oBAAoB,CAAC;MA8D7E;CACF"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { DwnDataEncodedRecordsWriteMessage, DwnResponseStatus, Web5Agent } from '@enbox/agent';
|
|
2
|
+
/**
|
|
3
|
+
* Represents the structured data model of a GrantRevocation record, encapsulating the essential fields that define.
|
|
4
|
+
*/
|
|
5
|
+
export interface GrantRevocationModel {
|
|
6
|
+
/** The DWN message used to construct this revocation */
|
|
7
|
+
rawMessage: DwnDataEncodedRecordsWriteMessage;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Represents the options for creating a new GrantRevocation instance.
|
|
11
|
+
*/
|
|
12
|
+
export interface GrantRevocationOptions {
|
|
13
|
+
/** The DID of the DWN tenant under which record operations are being performed. */
|
|
14
|
+
connectedDid: string;
|
|
15
|
+
/** The DWN message used to construct this revocation */
|
|
16
|
+
message: DwnDataEncodedRecordsWriteMessage;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* The `PermissionGrantRevocation` class encapsulates a permissions protocol `grant/revocation` record, providing a more
|
|
20
|
+
* developer-friendly interface for working with Decentralized Web Node (DWN) records.
|
|
21
|
+
*
|
|
22
|
+
* Methods are provided to manage the grant revocation's lifecycle, including writing to remote DWNs.
|
|
23
|
+
*
|
|
24
|
+
* @beta
|
|
25
|
+
*/
|
|
26
|
+
export declare class PermissionGrantRevocation implements GrantRevocationModel {
|
|
27
|
+
/** The PermissionsAPI used to interact with the underlying revocation */
|
|
28
|
+
private _permissions;
|
|
29
|
+
/** The DID to use as the author and default target for the underlying revocation */
|
|
30
|
+
private _connectedDid;
|
|
31
|
+
/** The DWN `RecordsWrite` message, along with encodedData that represents the revocation */
|
|
32
|
+
private _message;
|
|
33
|
+
private constructor();
|
|
34
|
+
/** The author of the underlying revocation message */
|
|
35
|
+
get author(): string;
|
|
36
|
+
/** parses the grant revocation given am agent, connectedDid and data encoded records write message */
|
|
37
|
+
static parse({ connectedDid, agent, message }: {
|
|
38
|
+
connectedDid: string;
|
|
39
|
+
agent: Web5Agent;
|
|
40
|
+
message: DwnDataEncodedRecordsWriteMessage;
|
|
41
|
+
}): Promise<PermissionGrantRevocation>;
|
|
42
|
+
/** The agent to use for this instantiation of the grant revocation */
|
|
43
|
+
private get agent();
|
|
44
|
+
/** The raw `RecordsWrite` DWN message with encoded data that was used to instantiate this grant revocation */
|
|
45
|
+
get rawMessage(): DwnDataEncodedRecordsWriteMessage;
|
|
46
|
+
/**
|
|
47
|
+
* Send the current grant revocation to a remote DWN by specifying their DID
|
|
48
|
+
* If no DID is specified, the target is assumed to be the owner (connectedDID).
|
|
49
|
+
*
|
|
50
|
+
* @param target - the optional DID to send the grant revocation to, if none is set it is sent to the connectedDid
|
|
51
|
+
* @returns the status of the send grant revocation request
|
|
52
|
+
*
|
|
53
|
+
* @beta
|
|
54
|
+
*/
|
|
55
|
+
send(target?: string): Promise<DwnResponseStatus>;
|
|
56
|
+
/**
|
|
57
|
+
* Stores the current grant revocation to the owner's DWN.
|
|
58
|
+
*
|
|
59
|
+
* @param importGrant - if true, the grant revocation will signed by the owner before storing it to the owner's DWN. Defaults to false.
|
|
60
|
+
* @returns the status of the store request
|
|
61
|
+
*
|
|
62
|
+
* @beta
|
|
63
|
+
*/
|
|
64
|
+
store(importRevocation?: boolean): Promise<DwnResponseStatus>;
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=grant-revocation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grant-revocation.d.ts","sourceRoot":"","sources":["../../src/grant-revocation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,iCAAiC,EAAE,iBAAiB,EAAmC,SAAS,EAAE,MAAM,cAAc,CAAC;AAIrJ;;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,WAET;IAED,uGAAuG;WAC1F,KAAK,CAAC,EAAE,YAAY,EAAE,KAAK,EAAE,OAAO,EAAE,EAAC;QAClD,YAAY,EAAE,MAAM,CAAC;QACrB,KAAK,EAAE,SAAS,CAAC;QACjB,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"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Making developing with Web5 components at least 5 times easier to work with.
|
|
3
|
+
*
|
|
4
|
+
* Web5 consists of the following components:
|
|
5
|
+
* - Decentralized Identifiers
|
|
6
|
+
* - Verifiable Credentials
|
|
7
|
+
* - DWeb Node personal datastores
|
|
8
|
+
*
|
|
9
|
+
* The SDK sets out to gather the most oft used functionality from all three of
|
|
10
|
+
* these pillar technologies to provide a simple library that is as close to
|
|
11
|
+
* effortless as possible.
|
|
12
|
+
*
|
|
13
|
+
* The SDK is currently still under active development, but having entered the
|
|
14
|
+
* Tech Preview phase there is now a drive to avoid unnecessary changes unless
|
|
15
|
+
* backwards compatibility is provided. Additional functionality will be added
|
|
16
|
+
* in the lead up to 1.0 final, and modifications will be made to address
|
|
17
|
+
* issues and community feedback.
|
|
18
|
+
*
|
|
19
|
+
* [Link to GitHub Repo](https://github.com/TBD54566975/web5-js)
|
|
20
|
+
*
|
|
21
|
+
* @packageDocumentation
|
|
22
|
+
*/
|
|
23
|
+
export * from './did-api.js';
|
|
24
|
+
export * from './dwn-api.js';
|
|
25
|
+
export * from './grant-revocation.js';
|
|
26
|
+
export * from './permission-grant.js';
|
|
27
|
+
export * from './permission-request.js';
|
|
28
|
+
export * from './protocol.js';
|
|
29
|
+
export * from './record.js';
|
|
30
|
+
export * from './vc-api.js';
|
|
31
|
+
export * from './web5.js';
|
|
32
|
+
import * as utils from './utils.js';
|
|
33
|
+
export { utils };
|
|
34
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAE1B,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,KAAK,EAAE,CAAC"}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import type { DwnDataEncodedRecordsWriteMessage, DwnPermissionConditions, DwnPermissionScope, DwnResponseStatus, Web5Agent } from '@enbox/agent';
|
|
2
|
+
import { DwnPermissionGrant } from '@enbox/agent';
|
|
3
|
+
import { PermissionGrantRevocation } from './grant-revocation.js';
|
|
4
|
+
/**
|
|
5
|
+
* Represents the structured data model of a PermissionGrant record, encapsulating the essential fields that define
|
|
6
|
+
*/
|
|
7
|
+
export interface PermissionGrantModel {
|
|
8
|
+
/**
|
|
9
|
+
* The ID of the permission grant, which is the record ID DWN message.
|
|
10
|
+
*/
|
|
11
|
+
readonly id: string;
|
|
12
|
+
/**
|
|
13
|
+
* The grantor of the permission.
|
|
14
|
+
*/
|
|
15
|
+
readonly grantor: string;
|
|
16
|
+
/**
|
|
17
|
+
* The grantee of the permission.
|
|
18
|
+
*/
|
|
19
|
+
readonly grantee: string;
|
|
20
|
+
/**
|
|
21
|
+
* The date at which the grant was given.
|
|
22
|
+
*/
|
|
23
|
+
readonly dateGranted: string;
|
|
24
|
+
/**
|
|
25
|
+
* Optional string that communicates what the grant would be used for
|
|
26
|
+
*/
|
|
27
|
+
readonly description?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Optional CID of a permission request. This is optional because grants may be given without being officially requested
|
|
30
|
+
*/
|
|
31
|
+
readonly requestId?: string;
|
|
32
|
+
/**
|
|
33
|
+
* Timestamp at which this grant will no longer be active.
|
|
34
|
+
*/
|
|
35
|
+
readonly dateExpires: string;
|
|
36
|
+
/**
|
|
37
|
+
* Whether this grant is delegated or not. If `true`, the `grantedTo` will be able to act as the `grantedTo` within the scope of this grant.
|
|
38
|
+
*/
|
|
39
|
+
readonly delegated?: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* The scope of the allowed access.
|
|
42
|
+
*/
|
|
43
|
+
readonly scope: DwnPermissionScope;
|
|
44
|
+
/**
|
|
45
|
+
* Optional conditions that must be met when the grant is used.
|
|
46
|
+
*/
|
|
47
|
+
readonly conditions?: DwnPermissionConditions;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Represents the options for creating a new PermissionGrant instance.
|
|
51
|
+
*/
|
|
52
|
+
export interface PermissionGrantOptions {
|
|
53
|
+
/** The DID to use when interacting with the underlying DWN record representing the grant */
|
|
54
|
+
connectedDid: string;
|
|
55
|
+
/** The underlying DWN `RecordsWrite` message along with encoded data that represent the grant */
|
|
56
|
+
message: DwnDataEncodedRecordsWriteMessage;
|
|
57
|
+
/** The agent to use when interacting with the underlying DWN record representing the grant */
|
|
58
|
+
agent: Web5Agent;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* The `PermissionGrant` class encapsulates a permissions protocol `grant` record, providing a more
|
|
62
|
+
* developer-friendly interface for working with Decentralized Web Node (DWN) records.
|
|
63
|
+
*
|
|
64
|
+
* Methods are provided to revoke, check if isRevoked, and manage the grant's lifecycle, including writing to remote DWNs.
|
|
65
|
+
*
|
|
66
|
+
* @beta
|
|
67
|
+
*/
|
|
68
|
+
export declare class PermissionGrant implements PermissionGrantModel {
|
|
69
|
+
/** The PermissionsAPI used to interact with the underlying permission grant */
|
|
70
|
+
private _permissions;
|
|
71
|
+
/** The DID to use as the author and default target for the underlying permission grant */
|
|
72
|
+
private _connectedDid;
|
|
73
|
+
/** The underlying DWN `RecordsWrite` message along with encoded data that represent the grant */
|
|
74
|
+
private _message;
|
|
75
|
+
/** The parsed grant object */
|
|
76
|
+
private _grant;
|
|
77
|
+
private constructor();
|
|
78
|
+
/** parses the grant given an agent, connectedDid and data encoded records write message */
|
|
79
|
+
static parse(options: PermissionGrantOptions): Promise<PermissionGrant>;
|
|
80
|
+
/** The agent to use for this instantiation of the grant */
|
|
81
|
+
private get agent();
|
|
82
|
+
/** The grant's ID, which is also the underlying record's ID */
|
|
83
|
+
get id(): string;
|
|
84
|
+
/** The DID which granted the permission */
|
|
85
|
+
get grantor(): string;
|
|
86
|
+
/** The DID which the permission was granted to */
|
|
87
|
+
get grantee(): string;
|
|
88
|
+
/** The date the permission was granted */
|
|
89
|
+
get dateGranted(): string;
|
|
90
|
+
/** (optional) Description of the permission grant */
|
|
91
|
+
get description(): string | undefined;
|
|
92
|
+
/** (optional) The Id of the PermissionRequest if one was used */
|
|
93
|
+
get requestId(): string | undefined;
|
|
94
|
+
/** The date on which the permission expires */
|
|
95
|
+
get dateExpires(): string;
|
|
96
|
+
/** Whether or not the permission grant can be used to impersonate the grantor */
|
|
97
|
+
get delegated(): boolean | undefined;
|
|
98
|
+
/** The permission scope under which the grant is valid */
|
|
99
|
+
get scope(): DwnPermissionScope;
|
|
100
|
+
/** The conditions under which the grant is valid */
|
|
101
|
+
get conditions(): DwnPermissionConditions;
|
|
102
|
+
/** The raw `RecordsWrite` DWN message with encoded data that was used to instantiate this grant */
|
|
103
|
+
get rawMessage(): DwnDataEncodedRecordsWriteMessage;
|
|
104
|
+
/**
|
|
105
|
+
* Send the current grant to a remote DWN by specifying their DID
|
|
106
|
+
* If no DID is specified, the target is assumed to be the owner (connectedDID).
|
|
107
|
+
*
|
|
108
|
+
* @param target - the optional DID to send the grant to, if none is set it is sent to the connectedDid
|
|
109
|
+
* @returns the status of the send grant request
|
|
110
|
+
*
|
|
111
|
+
* @beta
|
|
112
|
+
*/
|
|
113
|
+
send(target?: string): Promise<DwnResponseStatus>;
|
|
114
|
+
/**
|
|
115
|
+
* Stores the current grant to the owner's DWN.
|
|
116
|
+
*
|
|
117
|
+
* @param importGrant - if true, the grant will signed by the owner before storing it to the owner's DWN. Defaults to false.
|
|
118
|
+
* @returns the status of the store request
|
|
119
|
+
*
|
|
120
|
+
* @beta
|
|
121
|
+
*/
|
|
122
|
+
store(importGrant?: boolean): Promise<DwnResponseStatus>;
|
|
123
|
+
/**
|
|
124
|
+
* Signs the current grant as the owner and optionally stores it to the owner's DWN.
|
|
125
|
+
* This is useful when importing a grant that was signed by someone else into your own DWN.
|
|
126
|
+
*
|
|
127
|
+
* @param store - if true, the grant will be stored to the owner's DWN after signing. Defaults to true.
|
|
128
|
+
* @returns the status of the import request
|
|
129
|
+
*
|
|
130
|
+
* @beta
|
|
131
|
+
*/
|
|
132
|
+
import(store?: boolean): Promise<DwnResponseStatus>;
|
|
133
|
+
/**
|
|
134
|
+
* Revokes the grant and optionally stores the revocation to the owner's DWN.
|
|
135
|
+
*
|
|
136
|
+
* @param store - if true, the revocation will be stored to the owner's DWN. Defaults to true.
|
|
137
|
+
* @returns {PermissionGrantRevocation} the grant revocation object
|
|
138
|
+
*
|
|
139
|
+
* @beta
|
|
140
|
+
*/
|
|
141
|
+
revoke(store?: boolean): Promise<PermissionGrantRevocation>;
|
|
142
|
+
/**
|
|
143
|
+
* Checks if the grant has been revoked.
|
|
144
|
+
*
|
|
145
|
+
* @param remote - if true, the check will be made against the remote DWN. Defaults to false.
|
|
146
|
+
* @returns true if the grant has been revoked, false otherwise.
|
|
147
|
+
* @throws if there is an error checking the revocation status.
|
|
148
|
+
*
|
|
149
|
+
* @beta
|
|
150
|
+
*/
|
|
151
|
+
isRevoked(remote?: boolean): Promise<boolean>;
|
|
152
|
+
/**
|
|
153
|
+
* @returns the JSON representation of the grant
|
|
154
|
+
*/
|
|
155
|
+
toJSON(): DwnPermissionGrant;
|
|
156
|
+
}
|
|
157
|
+
//# sourceMappingURL=permission-grant.d.ts.map
|
|
@@ -0,0 +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,EAEjB,SAAS,EACV,MAAM,cAAc,CAAC;AAGtB,OAAO,EAGL,kBAAkB,EACnB,MAAM,cAAc,CAAC;AACtB,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;;OAEG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,uBAAuB,CAAC;CAC/C;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,4FAA4F;IAC5F,YAAY,EAAE,MAAM,CAAC;IACrB,iGAAiG;IACjG,OAAO,EA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