@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,108 @@
|
|
|
1
|
+
import { DwnDataEncodedRecordsWriteMessage, DwnPermissionConditions, DwnPermissionScope, DwnResponseStatus, Web5Agent } from '@enbox/agent';
|
|
2
|
+
import { PermissionGrant } from './permission-grant.js';
|
|
3
|
+
/**
|
|
4
|
+
* Represents the structured data model of a PermissionsRequest record, encapsulating the essential fields that define
|
|
5
|
+
* the request's data and payload within a Decentralized Web Node (DWN).
|
|
6
|
+
*/
|
|
7
|
+
export interface PermissionRequestModel {
|
|
8
|
+
/**
|
|
9
|
+
* The ID of the permission request, which is the record ID DWN message.
|
|
10
|
+
*/
|
|
11
|
+
readonly id: string;
|
|
12
|
+
/**
|
|
13
|
+
* The requester for of the permission.
|
|
14
|
+
*/
|
|
15
|
+
readonly requester: string;
|
|
16
|
+
/**
|
|
17
|
+
* Optional string that communicates what the requested grant would be used for.
|
|
18
|
+
*/
|
|
19
|
+
readonly description?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Whether the requested grant is delegated or not.
|
|
22
|
+
* If `true`, the `requestor` will be able to act as the grantor of the permission within the scope of the requested grant.
|
|
23
|
+
*/
|
|
24
|
+
readonly delegated?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* The scope of the allowed access.
|
|
27
|
+
*/
|
|
28
|
+
readonly scope: DwnPermissionScope;
|
|
29
|
+
/**
|
|
30
|
+
* Optional conditions that must be met when the requested grant is used.
|
|
31
|
+
*/
|
|
32
|
+
readonly conditions?: DwnPermissionConditions;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* The `PermissionRequest` class encapsulates a permissions protocol `request` record, providing a more
|
|
36
|
+
* developer-friendly interface for working with Decentralized Web Node (DWN) records.
|
|
37
|
+
*
|
|
38
|
+
* Methods are provided to grant the request and manage the request's lifecycle, including writing to remote DWNs.
|
|
39
|
+
*
|
|
40
|
+
* @beta
|
|
41
|
+
*/
|
|
42
|
+
export declare class PermissionRequest implements PermissionRequestModel {
|
|
43
|
+
/** The PermissionsAPI used to interact with the underlying permission request */
|
|
44
|
+
private _permissions;
|
|
45
|
+
/** The DID to use as the author and default target for the underlying permission request */
|
|
46
|
+
private _connectedDid;
|
|
47
|
+
/** The underlying DWN `RecordsWrite` message along with encoded data that represent the request */
|
|
48
|
+
private _message;
|
|
49
|
+
/** The parsed permission request object */
|
|
50
|
+
private _request;
|
|
51
|
+
private constructor();
|
|
52
|
+
/** parses the request given an agent, connectedDid and data encoded records write message */
|
|
53
|
+
static parse({ connectedDid, agent, message }: {
|
|
54
|
+
connectedDid: string;
|
|
55
|
+
agent: Web5Agent;
|
|
56
|
+
message: DwnDataEncodedRecordsWriteMessage;
|
|
57
|
+
}): Promise<PermissionRequest>;
|
|
58
|
+
/** The agent to use for this instantiation of the request */
|
|
59
|
+
private get agent();
|
|
60
|
+
/** The request's ID, which is also the underlying record's ID */
|
|
61
|
+
get id(): string;
|
|
62
|
+
/** The DID that is requesting a permission */
|
|
63
|
+
get requester(): string;
|
|
64
|
+
/** (optional) Description of the permission request */
|
|
65
|
+
get description(): string;
|
|
66
|
+
/** Whether or not the permission request can be used to impersonate the grantor */
|
|
67
|
+
get delegated(): boolean;
|
|
68
|
+
/** The permission scope under which the requested grant would be valid */
|
|
69
|
+
get scope(): DwnPermissionScope;
|
|
70
|
+
/** The conditions under which the requested grant would be valid */
|
|
71
|
+
get conditions(): DwnPermissionConditions;
|
|
72
|
+
/** The `RecordsWrite` DWN message with encoded data that was used to instantiate this request */
|
|
73
|
+
get rawMessage(): DwnDataEncodedRecordsWriteMessage;
|
|
74
|
+
/**
|
|
75
|
+
* Send the current permission request to a remote DWN by specifying their DID
|
|
76
|
+
* If no DID is specified, the target is assumed to be the owner (connectedDID).
|
|
77
|
+
*
|
|
78
|
+
* @param target - the optional DID to send the permission request to, if none is set it is sent to the connectedDid
|
|
79
|
+
* @returns the status of the send permission request
|
|
80
|
+
*
|
|
81
|
+
* @beta
|
|
82
|
+
*/
|
|
83
|
+
send(target?: string): Promise<DwnResponseStatus>;
|
|
84
|
+
/**
|
|
85
|
+
* Stores the current permission request to the owner's DWN.
|
|
86
|
+
*
|
|
87
|
+
* @param importGrant - if true, the permission request will signed by the owner before storing it to the owner's DWN. Defaults to false.
|
|
88
|
+
* @returns the status of the store request
|
|
89
|
+
*
|
|
90
|
+
* @beta
|
|
91
|
+
*/
|
|
92
|
+
store(): Promise<DwnResponseStatus>;
|
|
93
|
+
/**
|
|
94
|
+
* Grants the permission request to the requester.
|
|
95
|
+
*
|
|
96
|
+
* @param dateExpires - the date when the permission grant will expire.
|
|
97
|
+
* @param store - if true, the permission grant will be stored in the owner's DWN. Defaults to true.
|
|
98
|
+
* @returns {PermissionGrant} the granted permission.
|
|
99
|
+
*
|
|
100
|
+
* @beta
|
|
101
|
+
*/
|
|
102
|
+
grant(dateExpires: string, store?: boolean): Promise<PermissionGrant>;
|
|
103
|
+
/**
|
|
104
|
+
* @returns the JSON representation of the permission request
|
|
105
|
+
*/
|
|
106
|
+
toJSON(): PermissionRequestModel;
|
|
107
|
+
}
|
|
108
|
+
//# sourceMappingURL=permission-request.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"permission-request.d.ts","sourceRoot":"","sources":["../../src/permission-request.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,iCAAiC,EAAE,uBAAuB,EAAwB,kBAAkB,EAAE,iBAAiB,EAAkB,SAAS,EAAE,MAAM,cAAc,CAAC;AAGvM,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD;;;GAGG;AACH,MAAM,WAAW,sBAAsB;IACrC;;OAEG;IACH,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAE3B;;OAEG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAE9B;;;OAGG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;IAE7B;;OAEG;IACH,QAAQ,CAA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,0 +1,59 @@
|
|
|
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 { DwnMessage, DwnResponseStatus, Web5Agent } from '@enbox/agent';
|
|
6
|
+
import { DwnInterface } from '@enbox/agent';
|
|
7
|
+
/**
|
|
8
|
+
* Represents metadata associated with a protocol, including the author and an optional message CID.
|
|
9
|
+
*/
|
|
10
|
+
export type ProtocolMetadata = {
|
|
11
|
+
/** The author of the protocol. */
|
|
12
|
+
author: string;
|
|
13
|
+
/**
|
|
14
|
+
* The Content Identifier (CID) of a ProtocolsConfigure message.
|
|
15
|
+
*
|
|
16
|
+
* This is an optional field, and is used by {@link Protocol.send}.
|
|
17
|
+
*/
|
|
18
|
+
messageCid?: string;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Encapsulates a DWN Protocol with its associated metadata and configuration.
|
|
22
|
+
*
|
|
23
|
+
* This class primarly exists to provide developers with a convenient way to configure/install
|
|
24
|
+
* protocols on remote DWNs.
|
|
25
|
+
*/
|
|
26
|
+
export declare class Protocol {
|
|
27
|
+
/** The {@link Web5Agent} instance that handles DWNs requests. */
|
|
28
|
+
private _agent;
|
|
29
|
+
/** The ProtocolsConfigureMessage containing the detailed configuration for the protocol. */
|
|
30
|
+
private _metadata;
|
|
31
|
+
/** Metadata associated with the protocol, including the author and optional message CID. */
|
|
32
|
+
private _protocolsConfigureMessage;
|
|
33
|
+
/**
|
|
34
|
+
* Constructs a new instance of the Protocol class.
|
|
35
|
+
*
|
|
36
|
+
* @param agent - The Web5Agent instance used for network interactions.
|
|
37
|
+
* @param protocolsConfigureMessage - The configuration message containing the protocol details.
|
|
38
|
+
* @param metadata - Metadata associated with the protocol, including the author and optional message CID.
|
|
39
|
+
*/
|
|
40
|
+
constructor(agent: Web5Agent, protocolsConfigureMessage: DwnMessage[DwnInterface.ProtocolsConfigure], metadata: ProtocolMetadata);
|
|
41
|
+
/**
|
|
42
|
+
* Retrieves the protocol definition from the protocol's configuration message.
|
|
43
|
+
* @returns The protocol definition.
|
|
44
|
+
*/
|
|
45
|
+
get definition(): import("@enbox/agent").DwnProtocolDefinition;
|
|
46
|
+
/**
|
|
47
|
+
* Serializes the protocol's configuration message to JSON.
|
|
48
|
+
* @returns The serialized JSON object of the protocol's configuration message.
|
|
49
|
+
*/
|
|
50
|
+
toJSON(): import("@enbox/dwn-sdk-js").ProtocolsConfigureMessage;
|
|
51
|
+
/**
|
|
52
|
+
* Sends the protocol configuration to a remote DWN identified by the target DID.
|
|
53
|
+
*
|
|
54
|
+
* @param target - The DID of the target DWN to which the protocol configuration will be installed.
|
|
55
|
+
* @returns A promise that resolves to an object containing the status of the send operation.
|
|
56
|
+
*/
|
|
57
|
+
send(target: string): Promise<DwnResponseStatus>;
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=protocol.d.ts.map
|
|
@@ -0,0 +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,SAAS,EAAE,MAAM,cAAc,CAAC;AAE7E,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,iEAAiE;IACjE,OAAO,CAAC,MAAM,CAAY;IAE1B,4FAA4F;IAC5F,OAAO,CAAC,SAAS,CAAmB;IAEpC,4FAA4F;IAC5F,OAAO,CAAC,0BAA0B,CAA8C;IAEhF;;;;;;OAMG;gBACS,KAAK,EAAE,SAAS,EAAE,yBAAyB,EAAE,UAAU,CAAC,YAAY,CAAC,kBAAkB,CAAC,EAAE,QAAQ,EAAE,gBAAgB;IAMhI;;;OAGG;IACH,IAAI,UAAU,iDAEb;IAED;;;OAGG;IACH,MAAM;IAIN;;;;;OAKG;IACG,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC;CAUvD"}
|
|
@@ -0,0 +1,441 @@
|
|
|
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 { Readable } from '@enbox/common';
|
|
6
|
+
import { Web5Agent, DwnInterface, DwnMessage, DwnResponseStatus, DwnMessageDescriptor, DwnDateSort, DwnPaginationCursor, PermissionsApi } from '@enbox/agent';
|
|
7
|
+
/**
|
|
8
|
+
* Represents Immutable Record properties that cannot be changed after the record is created.
|
|
9
|
+
*
|
|
10
|
+
* @beta
|
|
11
|
+
* */
|
|
12
|
+
export type ImmutableRecordProperties = Pick<DwnMessageDescriptor[DwnInterface.RecordsWrite], 'dateCreated' | 'parentId' | 'protocol' | 'protocolPath' | 'recipient' | 'schema'>;
|
|
13
|
+
/**
|
|
14
|
+
* Represents Optional Record properties that depend on the Record's current state.
|
|
15
|
+
*
|
|
16
|
+
* @beta
|
|
17
|
+
*/
|
|
18
|
+
export type OptionalRecordProperties = Pick<DwnMessage[DwnInterface.RecordsWrite], 'authorization' | 'attestation' | 'encryption' | 'contextId'> & Pick<DwnMessageDescriptor[DwnInterface.RecordsWrite], 'dataFormat' | 'dataCid' | 'dataSize' | 'datePublished' | 'published' | 'tags'>;
|
|
19
|
+
/**
|
|
20
|
+
* Represents the structured data model of a record, encapsulating the essential fields that define
|
|
21
|
+
* the record's metadata and payload within a Decentralized Web Node (DWN).
|
|
22
|
+
*
|
|
23
|
+
* @beta
|
|
24
|
+
*/
|
|
25
|
+
export type RecordModel = ImmutableRecordProperties & OptionalRecordProperties & {
|
|
26
|
+
/** The logical author of the record. */
|
|
27
|
+
author: string;
|
|
28
|
+
/** The unique identifier of the record. */
|
|
29
|
+
recordId?: string;
|
|
30
|
+
/** The timestamp indicating when the record was last modified. */
|
|
31
|
+
messageTimestamp?: string;
|
|
32
|
+
/** The protocol role under which this record is written. */
|
|
33
|
+
protocolRole?: RecordOptions['protocolRole'];
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Options for configuring a {@link Record} instance, extending the base `RecordsWriteMessage` with
|
|
37
|
+
* additional properties.
|
|
38
|
+
*
|
|
39
|
+
* This type combines the standard fields required for writing DWN records with additional metadata
|
|
40
|
+
* and configuration options used specifically in the {@link Record} class.
|
|
41
|
+
*
|
|
42
|
+
* @beta
|
|
43
|
+
*/
|
|
44
|
+
export type RecordOptions = DwnMessage[DwnInterface.RecordsWrite | DwnInterface.RecordsDelete] & {
|
|
45
|
+
/** The DID that signed the record. */
|
|
46
|
+
author: string;
|
|
47
|
+
/** The attestation signature(s) for the record. */
|
|
48
|
+
attestation?: DwnMessage[DwnInterface.RecordsWrite]['attestation'];
|
|
49
|
+
/** The encryption information for the record. */
|
|
50
|
+
encryption?: DwnMessage[DwnInterface.RecordsWrite]['encryption'];
|
|
51
|
+
/** The contextId associated with the record. */
|
|
52
|
+
contextId?: string;
|
|
53
|
+
/** The unique identifier of the record */
|
|
54
|
+
recordId?: string;
|
|
55
|
+
/** The DID of the DWN tenant under which record operations are being performed. */
|
|
56
|
+
connectedDid: string;
|
|
57
|
+
/** The optional DID that will sign the records on behalf of the connectedDid */
|
|
58
|
+
delegateDid?: string;
|
|
59
|
+
/** The data of the record, either as a Base64 URL encoded string or a Blob. */
|
|
60
|
+
encodedData?: string | Blob;
|
|
61
|
+
/**
|
|
62
|
+
* A stream of data, conforming to the `Readable` or `ReadableStream` interface, providing a
|
|
63
|
+
* mechanism to read the record's data sequentially. This is particularly useful for handling
|
|
64
|
+
* large datasets that should not be loaded entirely in memory, allowing for efficient, chunked
|
|
65
|
+
* processing of the record's data.
|
|
66
|
+
*/
|
|
67
|
+
data?: Readable | ReadableStream;
|
|
68
|
+
/** The initial `RecordsWriteMessage` that represents the initial state/version of the record. */
|
|
69
|
+
initialWrite?: DwnMessage[DwnInterface.RecordsWrite];
|
|
70
|
+
/** The protocol role under which this record is written. */
|
|
71
|
+
protocolRole?: string;
|
|
72
|
+
/** The remote tenant DID if the record was queried or read from a remote DWN. */
|
|
73
|
+
remoteOrigin?: string;
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Parameters for updating a DWN record.
|
|
77
|
+
*
|
|
78
|
+
* This type specifies the set of properties that can be updated on an existing record. It is used
|
|
79
|
+
* to convey the new state or changes to be applied to the record.
|
|
80
|
+
*
|
|
81
|
+
* @beta
|
|
82
|
+
*/
|
|
83
|
+
export type RecordUpdateParams = {
|
|
84
|
+
/**
|
|
85
|
+
* The new data for the record, which can be of any type. This data will replace the existing
|
|
86
|
+
* data of the record. It's essential to ensure that this data is compatible with the record's
|
|
87
|
+
* schema or data format expectations.
|
|
88
|
+
*/
|
|
89
|
+
data?: unknown;
|
|
90
|
+
/**
|
|
91
|
+
* The Content Identifier (CID) of the data. Updating this value changes the reference to the data
|
|
92
|
+
* associated with the record.
|
|
93
|
+
*/
|
|
94
|
+
dataCid?: DwnMessageDescriptor[DwnInterface.RecordsWrite]['dataCid'];
|
|
95
|
+
/** Whether or not to store the updated message. */
|
|
96
|
+
store?: boolean;
|
|
97
|
+
/** The data format/MIME type of the supplied data */
|
|
98
|
+
dataFormat?: string;
|
|
99
|
+
/** The size of the data in bytes. */
|
|
100
|
+
dataSize?: DwnMessageDescriptor[DwnInterface.RecordsWrite]['dataSize'];
|
|
101
|
+
/** The timestamp indicating when the record was last modified. */
|
|
102
|
+
dateModified?: DwnMessageDescriptor[DwnInterface.RecordsWrite]['messageTimestamp'];
|
|
103
|
+
/** The timestamp indicating when the record was published. */
|
|
104
|
+
datePublished?: DwnMessageDescriptor[DwnInterface.RecordsWrite]['datePublished'];
|
|
105
|
+
/** The protocol role under which this record is written. */
|
|
106
|
+
protocolRole?: RecordOptions['protocolRole'];
|
|
107
|
+
/** The published status of the record. */
|
|
108
|
+
published?: DwnMessageDescriptor[DwnInterface.RecordsWrite]['published'];
|
|
109
|
+
/** The tags associated with the updated record */
|
|
110
|
+
tags?: DwnMessageDescriptor[DwnInterface.RecordsWrite]['tags'];
|
|
111
|
+
};
|
|
112
|
+
/**
|
|
113
|
+
* Parameters for deleting a DWN record.
|
|
114
|
+
*
|
|
115
|
+
* This type specifies the set of properties that are used when deleting an existing record. It is used
|
|
116
|
+
* to convey the new state or changes to be applied to the record.
|
|
117
|
+
*
|
|
118
|
+
* @beta
|
|
119
|
+
*/
|
|
120
|
+
export type RecordDeleteParams = {
|
|
121
|
+
/** Whether or not to store the message. */
|
|
122
|
+
store?: boolean;
|
|
123
|
+
/** Whether or not to sign the delete as an owner in order to import it. */
|
|
124
|
+
signAsOwner?: boolean;
|
|
125
|
+
/** Whether or not to prune any children this record may have. */
|
|
126
|
+
prune?: DwnMessageDescriptor[DwnInterface.RecordsDelete]['prune'];
|
|
127
|
+
/** The timestamp indicating when the record was deleted. */
|
|
128
|
+
dateModified?: DwnMessageDescriptor[DwnInterface.RecordsDelete]['messageTimestamp'];
|
|
129
|
+
/** The protocol role under which this record will be deleted. */
|
|
130
|
+
protocolRole?: string;
|
|
131
|
+
};
|
|
132
|
+
/**
|
|
133
|
+
* The `Record` class encapsulates a single record's data and metadata, providing a more
|
|
134
|
+
* developer-friendly interface for working with Decentralized Web Node (DWN) records.
|
|
135
|
+
*
|
|
136
|
+
* Methods are provided to read, update, and manage the record's lifecycle, including writing to
|
|
137
|
+
* remote DWNs.
|
|
138
|
+
*
|
|
139
|
+
* Note: The `messageTimestamp` of the most recent RecordsWrite message is
|
|
140
|
+
* logically equivalent to the date/time at which a Record was most
|
|
141
|
+
* recently modified. Since this Record class implementation is
|
|
142
|
+
* intended to simplify the developer experience of working with
|
|
143
|
+
* logical records (and not individual DWN messages) the
|
|
144
|
+
* `messageTimestamp` is mapped to `dateModified`.
|
|
145
|
+
*
|
|
146
|
+
* @beta
|
|
147
|
+
*/
|
|
148
|
+
export declare class Record implements RecordModel {
|
|
149
|
+
/**
|
|
150
|
+
* Cache to minimize the amount of redundant two-phase commits we do in store() and send()
|
|
151
|
+
* Retains awareness of the last 100 records stored/sent for up to 100 target DIDs each.
|
|
152
|
+
*/
|
|
153
|
+
private static _sendCache;
|
|
154
|
+
/** The {@link Web5Agent} instance that handles DWNs requests. */
|
|
155
|
+
private _agent;
|
|
156
|
+
/** The DID of the DWN tenant under which operations are being performed. */
|
|
157
|
+
private _connectedDid;
|
|
158
|
+
/** The optional DID that is delegated to act on behalf of the connectedDid */
|
|
159
|
+
private _delegateDid?;
|
|
160
|
+
/** cache for fetching a permission {@link PermissionGrant}, keyed by a specific MessageType and protocol */
|
|
161
|
+
private _permissionsApi;
|
|
162
|
+
/** Encoded data of the record, if available. */
|
|
163
|
+
private _encodedData?;
|
|
164
|
+
/** Stream of the record's data. */
|
|
165
|
+
private _readableStream?;
|
|
166
|
+
/** The origin DID if the record was fetched from a remote DWN. */
|
|
167
|
+
private _remoteOrigin?;
|
|
168
|
+
/** The DID of the entity that most recently authored or deleted the record. */
|
|
169
|
+
private _author;
|
|
170
|
+
/** The DID of the entity that originally created the record. */
|
|
171
|
+
private _creator;
|
|
172
|
+
/** Attestation JWS signature. */
|
|
173
|
+
private _attestation?;
|
|
174
|
+
/** Authorization signature(s). */
|
|
175
|
+
private _authorization?;
|
|
176
|
+
/** Context ID associated with the record. */
|
|
177
|
+
private _contextId?;
|
|
178
|
+
/** Descriptor detailing the record's schema, format, and other metadata. */
|
|
179
|
+
private _descriptor;
|
|
180
|
+
/** Encryption details for the record, if the data is encrypted. */
|
|
181
|
+
private _encryption?;
|
|
182
|
+
/** Initial state of the record before any updates. */
|
|
183
|
+
private _initialWrite;
|
|
184
|
+
/** Flag indicating if the initial write has been stored, to prevent duplicates. */
|
|
185
|
+
private _initialWriteStored;
|
|
186
|
+
/** Flag indicating if the initial write has been signed by the owner. */
|
|
187
|
+
private _initialWriteSigned;
|
|
188
|
+
/** Unique identifier of the record. */
|
|
189
|
+
private _recordId;
|
|
190
|
+
/** Role under which the record is written. */
|
|
191
|
+
private _protocolRole?;
|
|
192
|
+
/** The `RecordsWriteMessage` descriptor unless the record is in a deleted state */
|
|
193
|
+
private get _recordsWriteDescriptor();
|
|
194
|
+
/** The `RecordsWrite` descriptor from the current record or the initial write if the record is in a delete state. */
|
|
195
|
+
private get _immutableProperties();
|
|
196
|
+
/** Record's ID */
|
|
197
|
+
get id(): string;
|
|
198
|
+
/** Record's context ID. If the record is deleted, the context Id comes from the initial write */
|
|
199
|
+
get contextId(): string;
|
|
200
|
+
/** Record's creation date */
|
|
201
|
+
get dateCreated(): string;
|
|
202
|
+
/** Record's parent ID */
|
|
203
|
+
get parentId(): string;
|
|
204
|
+
/** Record's protocol */
|
|
205
|
+
get protocol(): string;
|
|
206
|
+
/** Record's protocol path */
|
|
207
|
+
get protocolPath(): string;
|
|
208
|
+
/** Record's recipient */
|
|
209
|
+
get recipient(): string;
|
|
210
|
+
/** Record's schema */
|
|
211
|
+
get schema(): string;
|
|
212
|
+
/** Record's data format */
|
|
213
|
+
get dataFormat(): string;
|
|
214
|
+
/** Record's CID */
|
|
215
|
+
get dataCid(): string;
|
|
216
|
+
/** Record's data size */
|
|
217
|
+
get dataSize(): number;
|
|
218
|
+
/** Record's published date */
|
|
219
|
+
get datePublished(): string;
|
|
220
|
+
/** Record's published status (true/false) */
|
|
221
|
+
get published(): boolean;
|
|
222
|
+
/** Tags of the record */
|
|
223
|
+
get tags(): import("@enbox/dwn-sdk-js").RecordsWriteTags;
|
|
224
|
+
/** DID that is the logical author of the Record. */
|
|
225
|
+
get author(): string;
|
|
226
|
+
/** DID that is the original creator of the Record. */
|
|
227
|
+
get creator(): string;
|
|
228
|
+
/** Record's modified date */
|
|
229
|
+
get dateModified(): string;
|
|
230
|
+
/** Record's encryption */
|
|
231
|
+
get encryption(): DwnMessage[DwnInterface.RecordsWrite]['encryption'];
|
|
232
|
+
/** Record's signatures attestation */
|
|
233
|
+
get authorization(): DwnMessage[DwnInterface.RecordsWrite | DwnInterface.RecordsDelete]['authorization'];
|
|
234
|
+
/** Record's signatures attestation */
|
|
235
|
+
get attestation(): DwnMessage[DwnInterface.RecordsWrite]['attestation'] | undefined;
|
|
236
|
+
/** Role under which the author is writing the record */
|
|
237
|
+
get protocolRole(): string;
|
|
238
|
+
/** Record's deleted state (true/false) */
|
|
239
|
+
get deleted(): boolean;
|
|
240
|
+
/** Record's initial write if the record has been updated */
|
|
241
|
+
get initialWrite(): RecordOptions['initialWrite'];
|
|
242
|
+
/**
|
|
243
|
+
* Returns a copy of the raw `RecordsWriteMessage` that was used to create the current `Record` instance.
|
|
244
|
+
*/
|
|
245
|
+
get rawMessage(): DwnMessage[DwnInterface.RecordsWrite] | DwnMessage[DwnInterface.RecordsDelete];
|
|
246
|
+
constructor(agent: Web5Agent, options: RecordOptions, permissionsApi?: PermissionsApi);
|
|
247
|
+
/**
|
|
248
|
+
* Returns the data of the current record.
|
|
249
|
+
* If the record data is not available, it attempts to fetch the data from the DWN.
|
|
250
|
+
* @returns a data stream with convenience methods such as `blob()`, `json()`, `text()`, and `stream()`, similar to the fetch API response
|
|
251
|
+
* @throws `Error` if the record has already been deleted.
|
|
252
|
+
*
|
|
253
|
+
* @beta
|
|
254
|
+
*/
|
|
255
|
+
get data(): {
|
|
256
|
+
/**
|
|
257
|
+
* Returns the data of the current record as a `Blob`.
|
|
258
|
+
*
|
|
259
|
+
* @returns A promise that resolves to a Blob containing the record's data.
|
|
260
|
+
* @throws If the record data is not available or cannot be converted to a `Blob`.
|
|
261
|
+
*
|
|
262
|
+
* @beta
|
|
263
|
+
*/
|
|
264
|
+
blob(): Promise<Blob>;
|
|
265
|
+
/**
|
|
266
|
+
* Returns the data of the current record as a `Uint8Array`.
|
|
267
|
+
*
|
|
268
|
+
* @returns A Promise that resolves to a `Uint8Array` containing the record's data bytes.
|
|
269
|
+
* @throws If the record data is not available or cannot be converted to a byte array.
|
|
270
|
+
*
|
|
271
|
+
* @beta
|
|
272
|
+
*/
|
|
273
|
+
bytes(): Promise<Uint8Array>;
|
|
274
|
+
/**
|
|
275
|
+
* Parses the data of the current record as JSON and returns it as a JavaScript object.
|
|
276
|
+
*
|
|
277
|
+
* @returns A Promise that resolves to a JavaScript object parsed from the record's JSON data.
|
|
278
|
+
* @throws If the record data is not available, not in JSON format, or cannot be parsed.
|
|
279
|
+
*
|
|
280
|
+
* @beta
|
|
281
|
+
*/
|
|
282
|
+
json(): Promise<any>;
|
|
283
|
+
/**
|
|
284
|
+
* Returns the data of the current record as a `string`.
|
|
285
|
+
*
|
|
286
|
+
* @returns A promise that resolves to a `string` containing the record's text data.
|
|
287
|
+
* @throws If the record data is not available or cannot be converted to text.
|
|
288
|
+
*
|
|
289
|
+
* @beta
|
|
290
|
+
*/
|
|
291
|
+
text(): Promise<string>;
|
|
292
|
+
/**
|
|
293
|
+
* Provides a `Readable` stream containing the record's data.
|
|
294
|
+
*
|
|
295
|
+
* @returns A promise that resolves to a Node.js `Readable` stream of the record's data.
|
|
296
|
+
* @throws If the record data is not available in-memory and cannot be fetched.
|
|
297
|
+
*
|
|
298
|
+
* @beta
|
|
299
|
+
*/
|
|
300
|
+
stream(): Promise<Readable>;
|
|
301
|
+
/**
|
|
302
|
+
* Attaches callbacks for the resolution and/or rejection of the `Promise` returned by
|
|
303
|
+
* `stream()`.
|
|
304
|
+
*
|
|
305
|
+
* This method is a proxy to the `then` method of the `Promise` returned by `stream()`,
|
|
306
|
+
* allowing for a seamless integration with promise-based workflows.
|
|
307
|
+
* @param onFulfilled - A function to asynchronously execute when the `stream()` promise
|
|
308
|
+
* becomes fulfilled.
|
|
309
|
+
* @param onRejected - A function to asynchronously execute when the `stream()` promise
|
|
310
|
+
* becomes rejected.
|
|
311
|
+
* @returns A `Promise` for the completion of which ever callback is executed.
|
|
312
|
+
*/
|
|
313
|
+
then(onFulfilled?: (value: Readable) => Readable | PromiseLike<Readable>, onRejected?: (reason: any) => PromiseLike<never>): any;
|
|
314
|
+
/**
|
|
315
|
+
* Attaches a rejection handler callback to the `Promise` returned by the `stream()` method.
|
|
316
|
+
* This method is a shorthand for `.then(undefined, onRejected)`, specifically designed for handling
|
|
317
|
+
* rejection cases in the promise chain initiated by accessing the record's data. It ensures that
|
|
318
|
+
* errors during data retrieval or processing can be caught and handled appropriately.
|
|
319
|
+
*
|
|
320
|
+
* @param onRejected - A function to asynchronously execute when the `stream()` promise
|
|
321
|
+
* becomes rejected.
|
|
322
|
+
* @returns A `Promise` that resolves to the value of the callback if it is called, or to its
|
|
323
|
+
* original fulfillment value if the promise is instead fulfilled.
|
|
324
|
+
*/
|
|
325
|
+
catch(onRejected?: (reason: any) => PromiseLike<never>): any;
|
|
326
|
+
};
|
|
327
|
+
/**
|
|
328
|
+
* Stores the current record state as well as any initial write to the owner's DWN.
|
|
329
|
+
*
|
|
330
|
+
* @param importRecord - if true, the record will signed by the owner before storing it to the owner's DWN. Defaults to false.
|
|
331
|
+
* @returns the status of the store request
|
|
332
|
+
*
|
|
333
|
+
* @beta
|
|
334
|
+
*/
|
|
335
|
+
store(importRecord?: boolean): Promise<DwnResponseStatus>;
|
|
336
|
+
/**
|
|
337
|
+
* Signs the current record state as well as any initial write and optionally stores it to the owner's DWN.
|
|
338
|
+
* This is useful when importing a record that was signed by someone else into your own DWN.
|
|
339
|
+
*
|
|
340
|
+
* @param store - if true, the record will be stored to the owner's DWN after signing. Defaults to true.
|
|
341
|
+
* @returns the status of the import request
|
|
342
|
+
*
|
|
343
|
+
* @beta
|
|
344
|
+
*/
|
|
345
|
+
import(store?: boolean): Promise<DwnResponseStatus>;
|
|
346
|
+
/**
|
|
347
|
+
* Send the current record to a remote DWN by specifying their DID
|
|
348
|
+
* If no DID is specified, the target is assumed to be the owner (connectedDID).
|
|
349
|
+
*
|
|
350
|
+
* If an initial write is present and the Record class send cache has no awareness of it, the initial write is sent first
|
|
351
|
+
* (vs waiting for the regular DWN sync)
|
|
352
|
+
*
|
|
353
|
+
* @param target - the optional DID to send the record to, if none is set it is sent to the connectedDid
|
|
354
|
+
* @returns the status of the send record request
|
|
355
|
+
* @throws `Error` if the record has already been deleted.
|
|
356
|
+
*
|
|
357
|
+
* @beta
|
|
358
|
+
*/
|
|
359
|
+
send(target?: string): Promise<DwnResponseStatus>;
|
|
360
|
+
/**
|
|
361
|
+
* Returns a JSON representation of the Record instance.
|
|
362
|
+
* It's called by `JSON.stringify(...)` automatically.
|
|
363
|
+
*/
|
|
364
|
+
toJSON(): RecordModel;
|
|
365
|
+
/**
|
|
366
|
+
* Convenience method to return the string representation of the Record instance.
|
|
367
|
+
* Called automatically in string concatenation, String() type conversion, and template literals.
|
|
368
|
+
*/
|
|
369
|
+
toString(): string;
|
|
370
|
+
/**
|
|
371
|
+
* Returns a pagination cursor for the current record given a sort order.
|
|
372
|
+
*
|
|
373
|
+
* @param sort the sort order to use for the pagination cursor.
|
|
374
|
+
* @returns A promise that resolves to a pagination cursor for the current record.
|
|
375
|
+
*/
|
|
376
|
+
paginationCursor(sort: DwnDateSort): Promise<DwnPaginationCursor | undefined>;
|
|
377
|
+
/**
|
|
378
|
+
* Update the current record on the DWN.
|
|
379
|
+
* @param params - Parameters to update the record.
|
|
380
|
+
* @returns the status of the update request
|
|
381
|
+
* @throws `Error` if the record has already been deleted.
|
|
382
|
+
*
|
|
383
|
+
* @beta
|
|
384
|
+
*/
|
|
385
|
+
update({ dateModified, data, protocolRole, store, ...params }: RecordUpdateParams): Promise<DwnResponseStatus>;
|
|
386
|
+
/**
|
|
387
|
+
* Delete the current record on the DWN.
|
|
388
|
+
* @param params - Parameters to delete the record.
|
|
389
|
+
* @returns the status of the delete request
|
|
390
|
+
*/
|
|
391
|
+
delete(deleteParams?: RecordDeleteParams): Promise<DwnResponseStatus>;
|
|
392
|
+
/**
|
|
393
|
+
* Process the initial write, if it hasn't already been processed, with the options set for storing and/or signing as the owner.
|
|
394
|
+
*/
|
|
395
|
+
private processInitialWriteIfNeeded;
|
|
396
|
+
/**
|
|
397
|
+
* Handles the various conditions around there being an initial write, whether to store initial/current state,
|
|
398
|
+
* and whether to add an owner signature to the initial write to enable storage when protocol rules require it.
|
|
399
|
+
*/
|
|
400
|
+
private processRecord;
|
|
401
|
+
/**
|
|
402
|
+
* Fetches the record's data from the specified DWN.
|
|
403
|
+
*
|
|
404
|
+
* This private method is called when the record data is not available in-memory
|
|
405
|
+
* and needs to be fetched from either a local or a remote DWN.
|
|
406
|
+
* It makes a read request to the specified DWN and processes the response to provide
|
|
407
|
+
* a Node.js `Readable` stream of the record's data.
|
|
408
|
+
*
|
|
409
|
+
* @param params - Parameters for fetching the record's data.
|
|
410
|
+
* @param params.target - The DID of the DWN to fetch the data from.
|
|
411
|
+
* @param params.isRemote - Indicates whether the target DWN is a remote node.
|
|
412
|
+
* @returns A Promise that resolves to a Node.js `Readable` stream of the record's data.
|
|
413
|
+
* @throws If there is an error while fetching or processing the data from the DWN.
|
|
414
|
+
*
|
|
415
|
+
* @beta
|
|
416
|
+
*/
|
|
417
|
+
private readRecordData;
|
|
418
|
+
/**
|
|
419
|
+
* Verifies if the properties to be mutated are mutable.
|
|
420
|
+
*
|
|
421
|
+
* This private method is used to ensure that only mutable properties of the `Record` instance
|
|
422
|
+
* are being changed. It checks whether the properties specified for mutation are among the
|
|
423
|
+
* set of properties that are allowed to be modified. If any of the properties to be mutated
|
|
424
|
+
* are not in the set of mutable properties, the method throws an error.
|
|
425
|
+
*
|
|
426
|
+
* @param propertiesToMutate - An iterable of property names that are intended to be mutated.
|
|
427
|
+
* @param mutableDescriptorProperties - A set of property names that are allowed to be mutated.
|
|
428
|
+
*
|
|
429
|
+
* @throws If any of the properties in `propertiesToMutate` are not in `mutableDescriptorProperties`.
|
|
430
|
+
*
|
|
431
|
+
* @beta
|
|
432
|
+
*/
|
|
433
|
+
private static verifyPermittedMutation;
|
|
434
|
+
/**
|
|
435
|
+
* Checks if the descriptor is a RecordsDelete descriptor.
|
|
436
|
+
*
|
|
437
|
+
* @param descriptor a RecordsWrite or RecordsDelete descriptor
|
|
438
|
+
*/
|
|
439
|
+
private isRecordsDeleteDescriptor;
|
|
440
|
+
}
|
|
441
|
+
//# sourceMappingURL=record.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"record.d.ts","sourceRoot":"","sources":["../../src/record.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EACL,SAAS,EACT,YAAY,EACZ,UAAU,EAEV,iBAAiB,EAEjB,oBAAoB,EAGpB,WAAW,EACX,mBAAmB,EAGnB,cAAc,EAGf,MAAM,cAAc,CAAC;AAOtB;;;;KAIK;AACL,MAAM,MAAM,yBAAyB,GACnC,IAAI,CAAC,oBAAoB,CAAC,YAAY,CAAC,YAAY,CAAC,EAAE,aAAa,GAAG,UAAU,GAAG,UAAU,GAAG,cAAc,GAAG,WAAW,GAAG,QAAQ,CAAC,CAAC;AAE3I;;;;EAIE;AACF,MAAM,MAAM,wBAAwB,GAClC,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,YAAY,CAAC,EAAE,eAAe,GAAG,aAAa,GAAG,YAAY,GAAG,WAAW,CAAE,GAC1G,IAAI,CAAC,oBAAoB,CAAC,YAAY,CAAC,YAAY,CAAC,EAAE,YAAY,GAAG,SAAS,GAAG,UAAU,GAAG,eAAe,GAAG,WAAW,GAAG,MAAM,CAAC,CAAC;AAExI;;;;;GAKG;AACH,MAAM,MAAM,WAAW,GAAG,yBAAyB,GAAG,wBAAwB,GAAG;IAE/E,wCAAwC;IACxC,MAAM,EAAE,MAAM,CAAC;IAEf,2CAA2C;IAC3C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,kEAAkE;IAClE,gBAAgB,CAAC,EAAE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IACH,OAAO,CAAC,MAAM,CAAC,uBAAuB;IAQtC;;;;OAIG;IACH,OAAO,CAAC,yBAAyB;CAGlC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { DwnRecordSubscriptionHandler, PermissionsApi, Web5Agent } from '@enbox/agent';
|
|
2
|
+
import { RecordsSubscribeRequest } from './dwn-api.js';
|
|
3
|
+
/**
|
|
4
|
+
* Utility class for dealing with subscriptions.
|
|
5
|
+
*/
|
|
6
|
+
export declare class SubscriptionUtil {
|
|
7
|
+
/**
|
|
8
|
+
* Creates a record subscription handler that can be used to process incoming {Record} messages.
|
|
9
|
+
*/
|
|
10
|
+
static recordSubscriptionHandler({ agent, connectedDid, request, delegateDid, protocolRole, permissionsApi }: {
|
|
11
|
+
agent: Web5Agent;
|
|
12
|
+
connectedDid: string;
|
|
13
|
+
delegateDid?: string;
|
|
14
|
+
protocolRole?: string;
|
|
15
|
+
permissionsApi?: PermissionsApi;
|
|
16
|
+
request: RecordsSubscribeRequest;
|
|
17
|
+
}): DwnRecordSubscriptionHandler;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=subscription-util.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subscription-util.d.ts","sourceRoot":"","sources":["../../src/subscription-util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAmB,cAAc,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACxG,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAGvD;;GAEG;AACH,qBAAa,gBAAgB;IAC3B;;OAEG;IACH,MAAM,CAAC,yBAAyB,CAAC,EAAE,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,cAAc,EAAE,EAAC;QAC3G,KAAK,EAAE,SAAS,CAAC;QACjB,YAAY,EAAE,MAAM,CAAC;QACrB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,cAAc,CAAC,EAAE,cAAc,CAAC;QAChC,OAAO,EAAE,uBAAuB,CAAC;KAClC,GAAG,4BAA4B;CAuBjC"}
|