@red-isbe/isbe-service-did-registry 1.0.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/LICENSE +202 -0
- package/README.md +129 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +26 -0
- package/dist/index.js.map +1 -0
- package/dist/src/ServiceDidRegistryContext.d.ts +40 -0
- package/dist/src/ServiceDidRegistryContext.d.ts.map +1 -0
- package/dist/src/ServiceDidRegistryContext.js +42 -0
- package/dist/src/ServiceDidRegistryContext.js.map +1 -0
- package/dist/src/ServiceDidRegistryQueries.d.ts +127 -0
- package/dist/src/ServiceDidRegistryQueries.d.ts.map +1 -0
- package/dist/src/ServiceDidRegistryQueries.js +226 -0
- package/dist/src/ServiceDidRegistryQueries.js.map +1 -0
- package/dist/src/ServiceDidRegistryTransactions.d.ts +90 -0
- package/dist/src/ServiceDidRegistryTransactions.d.ts.map +1 -0
- package/dist/src/ServiceDidRegistryTransactions.js +134 -0
- package/dist/src/ServiceDidRegistryTransactions.js.map +1 -0
- package/dist/src/ServiceDidTransactionExecutor.d.ts +31 -0
- package/dist/src/ServiceDidTransactionExecutor.d.ts.map +1 -0
- package/dist/src/ServiceDidTransactionExecutor.js +37 -0
- package/dist/src/ServiceDidTransactionExecutor.js.map +1 -0
- package/dist/src/abi/IServiceDidRegistry.abi.d.ts +578 -0
- package/dist/src/abi/IServiceDidRegistry.abi.d.ts.map +1 -0
- package/dist/src/abi/IServiceDidRegistry.abi.js +741 -0
- package/dist/src/abi/IServiceDidRegistry.abi.js.map +1 -0
- package/dist/src/serviceDid.types.d.ts +78 -0
- package/dist/src/serviceDid.types.d.ts.map +1 -0
- package/dist/src/serviceDid.types.js +16 -0
- package/dist/src/serviceDid.types.js.map +1 -0
- package/dist/src/types.d.ts +35 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +16 -0
- package/dist/src/types.js.map +1 -0
- package/dist/src/utils/blockchain.utils.d.ts +49 -0
- package/dist/src/utils/blockchain.utils.d.ts.map +1 -0
- package/dist/src/utils/blockchain.utils.js +102 -0
- package/dist/src/utils/blockchain.utils.js.map +1 -0
- package/dist/src/utils/did.utils.d.ts +20 -0
- package/dist/src/utils/did.utils.d.ts.map +1 -0
- package/dist/src/utils/did.utils.js +57 -0
- package/dist/src/utils/did.utils.js.map +1 -0
- package/dist/src/utils/serviceDid.utils.d.ts +71 -0
- package/dist/src/utils/serviceDid.utils.d.ts.map +1 -0
- package/dist/src/utils/serviceDid.utils.js +142 -0
- package/dist/src/utils/serviceDid.utils.js.map +1 -0
- package/dist/src/utils/serviceDocument.utils.d.ts +61 -0
- package/dist/src/utils/serviceDocument.utils.d.ts.map +1 -0
- package/dist/src/utils/serviceDocument.utils.js +101 -0
- package/dist/src/utils/serviceDocument.utils.js.map +1 -0
- package/package.json +45 -0
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Comunidad de Madrid & Alastria
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
*
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { didToHex, hexToDid } from "./utils/did.utils.js";
|
|
17
|
+
import { buildServiceDid, parseServiceDid, serviceDidToHex, signingKeyAddress, } from "./utils/serviceDid.utils.js";
|
|
18
|
+
import { ServiceDidRegistryContext } from "./ServiceDidRegistryContext.js";
|
|
19
|
+
import { parseServiceDocument, } from "./utils/serviceDocument.utils.js";
|
|
20
|
+
/** secp256k1, the curve the Case network operates on. */
|
|
21
|
+
export const ELLIPTIC_TYPE_SECP256K1 = 1;
|
|
22
|
+
/** P-256, the curve the Bare network operates on. */
|
|
23
|
+
export const ELLIPTIC_TYPE_P256 = 2;
|
|
24
|
+
/**
|
|
25
|
+
* Read surface of the Service DID Registry, and the resolver for the
|
|
26
|
+
* `did:isbe:svc:` sub-namespace.
|
|
27
|
+
*/
|
|
28
|
+
export class ServiceDidRegistryQueries {
|
|
29
|
+
constructor(configManager) {
|
|
30
|
+
this.configManager = configManager;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Reads a service identity.
|
|
34
|
+
*
|
|
35
|
+
* Reverts on-chain for an identifier that was never registered; use
|
|
36
|
+
* `isServiceDidActive` to probe without an exception. Expired and deactivated
|
|
37
|
+
* records are returned verbatim, so the caller applies its own validity policy.
|
|
38
|
+
*/
|
|
39
|
+
async getServiceDid(serviceDid) {
|
|
40
|
+
const iface = this.configManager.contract.interface;
|
|
41
|
+
const data = iface.encodeFunctionData("getServiceDid", [
|
|
42
|
+
serviceDidToHex(serviceDid),
|
|
43
|
+
]);
|
|
44
|
+
const addr = await this.configManager.contract.getAddress();
|
|
45
|
+
const raw = await this.configManager.provider.call({ to: addr, data });
|
|
46
|
+
const [record] = iface.decodeFunctionResult("getServiceDid", raw);
|
|
47
|
+
return this.toRecord(record);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Lists the service identities of a controller.
|
|
51
|
+
*
|
|
52
|
+
* Pages start at one, matching the registry's other paginated getters, and `total`
|
|
53
|
+
* comes back alongside the page — which is why there is no separate count call.
|
|
54
|
+
*/
|
|
55
|
+
async getServiceDidsByController(controllerDid, page = 1, pageSize = 10) {
|
|
56
|
+
const iface = this.configManager.contract.interface;
|
|
57
|
+
const data = iface.encodeFunctionData("getServiceDidsByController", [
|
|
58
|
+
didToHex(controllerDid),
|
|
59
|
+
page,
|
|
60
|
+
pageSize,
|
|
61
|
+
]);
|
|
62
|
+
const addr = await this.configManager.contract.getAddress();
|
|
63
|
+
const raw = await this.configManager.provider.call({ to: addr, data });
|
|
64
|
+
const decoded = iface.decodeFunctionResult("getServiceDidsByController", raw);
|
|
65
|
+
return {
|
|
66
|
+
items: Array.from(decoded[0]).map((item) => this.toRecord(item)),
|
|
67
|
+
total: decoded[1].toString(),
|
|
68
|
+
howMany: decoded[2].toString(),
|
|
69
|
+
prev: decoded[3].toString(),
|
|
70
|
+
next: decoded[4].toString(),
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Reports whether a service identity is usable right now.
|
|
75
|
+
*
|
|
76
|
+
* False for an unknown identifier as well as for one deactivated or past its expiry,
|
|
77
|
+
* so it never throws. It does not evaluate the parent: that cascade belongs to
|
|
78
|
+
* `toDidDocumentW3C`.
|
|
79
|
+
*/
|
|
80
|
+
async isServiceDidActive(serviceDid) {
|
|
81
|
+
const fn = this.configManager.contract["isServiceDidActive"];
|
|
82
|
+
return await fn(serviceDidToHex(serviceDid));
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Address derived from the signing key of a service identity.
|
|
86
|
+
*
|
|
87
|
+
* Only meaningful when the key is on the curve the network operates on. For any
|
|
88
|
+
* other curve no account can transact with it, and it must not be published as a
|
|
89
|
+
* `blockchainAccountId`.
|
|
90
|
+
*/
|
|
91
|
+
async signingKeyAddressOf(serviceDid) {
|
|
92
|
+
const fn = this.configManager.contract["signingKeyAddressOf"];
|
|
93
|
+
return await fn(serviceDidToHex(serviceDid));
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Reads the free-form fields of a service identity, or `null` when it has none.
|
|
97
|
+
*
|
|
98
|
+
* Also `null` against a registry deployed before documents existed, where the call
|
|
99
|
+
* itself fails: resolution keeps working there, it just has no extra fields to add.
|
|
100
|
+
*/
|
|
101
|
+
async getServiceDocument(serviceDid) {
|
|
102
|
+
const fn = this.configManager.contract["getServiceDocument"];
|
|
103
|
+
if (typeof fn !== "function")
|
|
104
|
+
return null;
|
|
105
|
+
try {
|
|
106
|
+
return parseServiceDocument(await fn(serviceDidToHex(serviceDid)));
|
|
107
|
+
}
|
|
108
|
+
catch {
|
|
109
|
+
return null;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Resolves a service identity into a W3C DID Document.
|
|
114
|
+
*
|
|
115
|
+
* Three things can make an identity resolve as no longer valid, and they are checked
|
|
116
|
+
* in this order: it was deactivated, it passed its expiry, or its controlling
|
|
117
|
+
* organisation stopped being operative. The last one is only evaluated when the
|
|
118
|
+
* caller supplies `isControllerActive`.
|
|
119
|
+
*
|
|
120
|
+
* The verification method depends on the curve, not on the network: a key on the
|
|
121
|
+
* network's own curve yields `EcdsaSecp256k1RecoveryMethod2020` with a
|
|
122
|
+
* `blockchainAccountId`, and any other curve yields `JsonWebKey2020` carrying the
|
|
123
|
+
* coordinates. Emitting a `blockchainAccountId` for a key no account can use would
|
|
124
|
+
* point a verifier at an address that can never sign.
|
|
125
|
+
*
|
|
126
|
+
* The service's free-form fields, if any, are added to the document. They can never
|
|
127
|
+
* override what the registry asserts: the identifier, the controller, the keys and
|
|
128
|
+
* the deactivation status always come from the record.
|
|
129
|
+
*/
|
|
130
|
+
async toDidDocumentW3C(serviceDid, options = {}) {
|
|
131
|
+
const record = await this.getServiceDid(serviceDid);
|
|
132
|
+
const extra = await this.getServiceDocument(serviceDid);
|
|
133
|
+
// Spread first, so every member the registry derives is written over it.
|
|
134
|
+
const document = { ...(extra ?? {}), ...(await this.buildDocument(record)) };
|
|
135
|
+
const reason = await this.inactiveReason(record, options);
|
|
136
|
+
return reason ? { ...document, deactivated: true, reason } : document;
|
|
137
|
+
}
|
|
138
|
+
/** Derives the identifier a controller and nonce produce, without a network call. */
|
|
139
|
+
computeServiceDid(controllerDid, nonce) {
|
|
140
|
+
return buildServiceDid(controllerDid, nonce);
|
|
141
|
+
}
|
|
142
|
+
async inactiveReason(record, options) {
|
|
143
|
+
if (record.deactivated)
|
|
144
|
+
return "deactivated";
|
|
145
|
+
const expiresAt = BigInt(record.expiresAt);
|
|
146
|
+
const now = BigInt(options.now ?? Math.floor(Date.now() / 1000));
|
|
147
|
+
if (expiresAt !== 0n && now >= expiresAt)
|
|
148
|
+
return "expired";
|
|
149
|
+
if (options.isControllerActive) {
|
|
150
|
+
const active = await options.isControllerActive(record.controllerDid);
|
|
151
|
+
if (!active)
|
|
152
|
+
return "controller-inactive";
|
|
153
|
+
}
|
|
154
|
+
return undefined;
|
|
155
|
+
}
|
|
156
|
+
async buildDocument(record) {
|
|
157
|
+
const keyId = `${record.serviceDid}#key-1`;
|
|
158
|
+
const onNetworkCurve = record.ellipticType === this.configManager.networkEllipticType;
|
|
159
|
+
// The context has to follow the branch, not the other way round: neither
|
|
160
|
+
// `EcdsaSecp256k1RecoveryMethod2020` nor `blockchainAccountId` is defined by the
|
|
161
|
+
// JWS 2020 suite, and a strict JSON-LD processor drops terms it cannot resolve —
|
|
162
|
+
// a document that looks right as plain JSON would lose its key on expansion.
|
|
163
|
+
const verificationMethod = onNetworkCurve
|
|
164
|
+
? {
|
|
165
|
+
id: keyId,
|
|
166
|
+
type: "EcdsaSecp256k1RecoveryMethod2020",
|
|
167
|
+
controller: record.serviceDid,
|
|
168
|
+
blockchainAccountId: `eip155:${(await this.configManager.provider.getNetwork()).chainId.toString()}:${record.signingKeyAddress}`,
|
|
169
|
+
}
|
|
170
|
+
: {
|
|
171
|
+
id: keyId,
|
|
172
|
+
type: "JsonWebKey2020",
|
|
173
|
+
controller: record.serviceDid,
|
|
174
|
+
publicKeyJwk: {
|
|
175
|
+
kty: "EC",
|
|
176
|
+
crv: record.ellipticType === ELLIPTIC_TYPE_P256
|
|
177
|
+
? "P-256"
|
|
178
|
+
: "secp256k1",
|
|
179
|
+
x: hexToBase64Url(record.pubKeyX),
|
|
180
|
+
y: hexToBase64Url(record.pubKeyY),
|
|
181
|
+
},
|
|
182
|
+
};
|
|
183
|
+
const suiteContext = onNetworkCurve
|
|
184
|
+
? "https://w3id.org/security/suites/secp256k1recovery-2020/v2"
|
|
185
|
+
: "https://w3id.org/security/suites/jws-2020/v1";
|
|
186
|
+
return {
|
|
187
|
+
"@context": ["https://www.w3.org/ns/did/v1", suiteContext],
|
|
188
|
+
id: record.serviceDid,
|
|
189
|
+
controller: [record.controllerDid],
|
|
190
|
+
verificationMethod: [verificationMethod],
|
|
191
|
+
authentication: [keyId],
|
|
192
|
+
assertionMethod: [keyId],
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Maps the on-chain struct into the shape this library returns.
|
|
197
|
+
*
|
|
198
|
+
* The readable identifier is rebuilt from the controller and the nonce rather than
|
|
199
|
+
* from the record's own key: a service identifier is a full digest, so the DID string
|
|
200
|
+
* cannot be recovered from it. Storing the nonce is what makes this possible.
|
|
201
|
+
*/
|
|
202
|
+
toRecord(decoded) {
|
|
203
|
+
const controllerDid = hexToDid(decoded.controllerDid, this.configManager.modelDeployId);
|
|
204
|
+
return {
|
|
205
|
+
serviceDid: buildServiceDid(controllerDid, BigInt(decoded.nonce)),
|
|
206
|
+
controllerDid,
|
|
207
|
+
pubKeyX: decoded.pubKeyX,
|
|
208
|
+
pubKeyY: decoded.pubKeyY,
|
|
209
|
+
signingKeyAddress: signingKeyAddress(decoded.pubKeyX, decoded.pubKeyY),
|
|
210
|
+
labelHash: decoded.labelHash,
|
|
211
|
+
expiresAt: decoded.expiresAt.toString(),
|
|
212
|
+
ellipticType: Number(decoded.ellipticType),
|
|
213
|
+
nonce: decoded.nonce.toString(),
|
|
214
|
+
deactivated: Boolean(decoded.deactivated),
|
|
215
|
+
exists: Boolean(decoded.exists),
|
|
216
|
+
registeredAt: decoded.registeredAt.toString(),
|
|
217
|
+
updatedAt: decoded.updatedAt.toString(),
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
/** Re-exported so a caller can parse a service DID without importing the utils path. */
|
|
222
|
+
export { parseServiceDid, serviceDidToHex };
|
|
223
|
+
function hexToBase64Url(hex) {
|
|
224
|
+
return Buffer.from(hex.slice(2), "hex").toString("base64url");
|
|
225
|
+
}
|
|
226
|
+
//# sourceMappingURL=ServiceDidRegistryQueries.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ServiceDidRegistryQueries.js","sourceRoot":"","sources":["../../src/ServiceDidRegistryQueries.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;EAcE;AAEF,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EACL,eAAe,EACf,eAAe,EACf,eAAe,EACf,iBAAiB,GAClB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAC3E,OAAO,EACL,oBAAoB,GAErB,MAAM,kCAAkC,CAAC;AAQ1C,yDAAyD;AACzD,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,CAAC;AACzC,qDAAqD;AACrD,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC;AAuBpC;;;GAGG;AACH,MAAM,OAAO,yBAAyB;IAGpC,YAAY,aAAwC;QAClD,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;IACrC,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,aAAa,CAAC,UAAkB;QACpC,MAAM,KAAK,GAAG,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,SAAS,CAAC;QACpD,MAAM,IAAI,GAAG,KAAK,CAAC,kBAAkB,CAAC,eAAe,EAAE;YACrD,eAAe,CAAC,UAAU,CAAC;SAC5B,CAAC,CAAC;QACH,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC;QAC5D,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,QAAQ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ACjC,CAAC;QAEF,OAAO;YACL,UAAU,EAAE,eAAe,CAAC,aAAa,EAAE,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;YACjE,aAAa;YACb,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,iBAAiB,EAAE,iBAAiB,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC;YACtE,SAAS,EAAE,OAAO,CAAC,SAAS;YAC5B,SAAS,EAAE,OAAO,CAAC,SAAS,CAAC,QAAQ,EAAE;YACvC,YAAY,EAAE,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC;YAC1C,KAAK,EAAE,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE;YAC/B,WAAW,EAAE,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC;YACzC,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC;YAC/B,YAAY,EAAE,OAAO,CAAC,YAAY,CAAC,QAAQ,EAAE;YAC7C,SAAS,EAAE,OAAO,CAAC,SAAS,CAAC,QAAQ,EAAE;SACxC,CAAC;IACJ,CAAC;CACF;AAED,wFAAwF;AACxF,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,CAAC;AAE5C,SAAS,cAAc,CAAC,GAAW;IACjC,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;AAChE,CAAC"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Comunidad de Madrid & Alastria
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
*
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { type ServiceDocument } from "./utils/serviceDocument.utils.js";
|
|
17
|
+
import { ServiceDidRegistryContext } from "./ServiceDidRegistryContext.js";
|
|
18
|
+
/**
|
|
19
|
+
* Builders for the write surface of the Service DID Registry.
|
|
20
|
+
*
|
|
21
|
+
* Every method returns an unsigned transaction. This library never holds a key and
|
|
22
|
+
* never broadcasts: the caller signs and sends. Authorisation is enforced on-chain —
|
|
23
|
+
* the registry requires the sender to hold an active capability invocation on a
|
|
24
|
+
* controller of the parent DID — so a transaction built for a DID the signer does not
|
|
25
|
+
* control simply reverts.
|
|
26
|
+
*/
|
|
27
|
+
export declare class ServiceDidRegistryTransactions {
|
|
28
|
+
private configManager;
|
|
29
|
+
constructor(configManager: ServiceDidRegistryContext);
|
|
30
|
+
/**
|
|
31
|
+
* Registers a service identity under an organisational DID.
|
|
32
|
+
*
|
|
33
|
+
* The identifier is derived on-chain from the parent and its next nonce, so it is
|
|
34
|
+
* not known until the transaction is mined: read it from the `ServiceDidRegistered`
|
|
35
|
+
* event. Two concurrent registrations by the same controller consume different
|
|
36
|
+
* nonces, which is why anticipating the value is not safe.
|
|
37
|
+
*
|
|
38
|
+
* @param controllerDid Parent DID, as did:isbe:<network>:<segment>
|
|
39
|
+
* @param publicKey Signing public key, 64 or 65 bytes hex
|
|
40
|
+
* @param ellipticType 1 = secp256k1, 2 = P-256
|
|
41
|
+
* @param label Human-readable label; only its digest reaches the chain
|
|
42
|
+
* @param expiresAt Unix timestamp of expiry, or 0 to never expire
|
|
43
|
+
* @param from Address that will sign, an active controller of `controllerDid`
|
|
44
|
+
* @param document Optional free-form fields of the service — an endpoint, a name, a
|
|
45
|
+
* description — stored on-chain and added to its DID Document. Public and
|
|
46
|
+
* permanent in the chain history. Without it, or with `{}`, the plain
|
|
47
|
+
* `registerServiceDid` is used
|
|
48
|
+
* @throws ServiceDocumentError when `document` is not storable as given
|
|
49
|
+
*/
|
|
50
|
+
buildRegisterServiceDidTx(controllerDid: string, publicKey: string, ellipticType: number, label: string | undefined, expiresAt: number | bigint | undefined, from: string, document?: ServiceDocument | null): Promise<object>;
|
|
51
|
+
/**
|
|
52
|
+
* Sets or replaces the free-form fields of a service identity.
|
|
53
|
+
*
|
|
54
|
+
* The whole document is replaced, not merged: send every field that should remain.
|
|
55
|
+
* `null` or `{}` clears it. The previous content stays in the chain history.
|
|
56
|
+
*
|
|
57
|
+
* @throws ServiceDocumentError when `document` is not storable as given
|
|
58
|
+
*/
|
|
59
|
+
buildUpdateServiceDocumentTx(serviceDid: string, document: ServiceDocument | null, from: string): Promise<object>;
|
|
60
|
+
/**
|
|
61
|
+
* Replaces the signing key of a service identity.
|
|
62
|
+
*
|
|
63
|
+
* The replacement is atomic and has no overlap: signatures made with the previous
|
|
64
|
+
* key stop validating the moment the transaction is mined. The key rotated away from
|
|
65
|
+
* stays bound to this service's controller: its other services may still use it, a
|
|
66
|
+
* service of any other controller never can.
|
|
67
|
+
*/
|
|
68
|
+
buildRotateSigningKeyTx(serviceDid: string, newPublicKey: string, newEllipticType: number, from: string): Promise<object>;
|
|
69
|
+
/**
|
|
70
|
+
* Changes the expiry of a service identity.
|
|
71
|
+
*
|
|
72
|
+
* A valid expiry is either 0 — never expires — or a timestamp in the future. Bringing
|
|
73
|
+
* an identity to an end right now is not possible this way; that is what
|
|
74
|
+
* `buildDeactivateServiceDidTx` is for, and it cannot be undone.
|
|
75
|
+
*/
|
|
76
|
+
buildUpdateExpiryTx(serviceDid: string, newExpiresAt: number | bigint | undefined, from: string): Promise<object>;
|
|
77
|
+
/**
|
|
78
|
+
* Deactivates a service identity, permanently.
|
|
79
|
+
*
|
|
80
|
+
* There is no reactivation: a service that needs to come back is registered again
|
|
81
|
+
* and receives a fresh identifier.
|
|
82
|
+
*/
|
|
83
|
+
buildDeactivateServiceDidTx(serviceDid: string, from: string): Promise<object>;
|
|
84
|
+
/**
|
|
85
|
+
* Stamps the facet version. Restricted to the diamond's default admin and callable
|
|
86
|
+
* once; it configures no state of its own.
|
|
87
|
+
*/
|
|
88
|
+
buildInitializeServiceDidRegistryTx(from: string): Promise<object>;
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=ServiceDidRegistryTransactions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ServiceDidRegistryTransactions.d.ts","sourceRoot":"","sources":["../../src/ServiceDidRegistryTransactions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;EAcE;AAOF,OAAO,EAEL,KAAK,eAAe,EACrB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAE3E;;;;;;;;GAQG;AACH,qBAAa,8BAA8B;IACzC,OAAO,CAAC,aAAa,CAA4B;gBAErC,aAAa,EAAE,yBAAyB;IAIpD;;;;;;;;;;;;;;;;;;;OAmBG;IACG,yBAAyB,CAC7B,aAAa,EAAE,MAAM,EACrB,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,MAAM,EACpB,KAAK,EAAE,MAAM,GAAG,SAAS,EACzB,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,EACtC,IAAI,EAAE,MAAM,EACZ,QAAQ,CAAC,EAAE,eAAe,GAAG,IAAI,GAChC,OAAO,CAAC,MAAM,CAAC;IA6BlB;;;;;;;OAOG;IACG,4BAA4B,CAChC,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,eAAe,GAAG,IAAI,EAChC,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,MAAM,CAAC;IAUlB;;;;;;;OAOG;IACG,uBAAuB,CAC3B,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,MAAM,EACpB,eAAe,EAAE,MAAM,EACvB,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,MAAM,CAAC;IAclB;;;;;;OAMG;IACG,mBAAmB,CACvB,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,EACzC,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,MAAM,CAAC;IAUlB;;;;;OAKG;IACG,2BAA2B,CAC/B,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,MAAM,CAAC;IAUlB;;;OAGG;IACG,mCAAmC,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CASzE"}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Comunidad de Madrid & Alastria
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
*
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { keccak256, toUtf8Bytes } from "ethers";
|
|
17
|
+
import { buildRawTransaction } from "./utils/blockchain.utils.js";
|
|
18
|
+
import { validateAndNormalizeHexPublicKey } from "./utils/blockchain.utils.js";
|
|
19
|
+
import { didToHex } from "./utils/did.utils.js";
|
|
20
|
+
import { serviceDidToHex } from "./utils/serviceDid.utils.js";
|
|
21
|
+
import { serializeServiceDocument, } from "./utils/serviceDocument.utils.js";
|
|
22
|
+
import { ServiceDidRegistryContext } from "./ServiceDidRegistryContext.js";
|
|
23
|
+
/**
|
|
24
|
+
* Builders for the write surface of the Service DID Registry.
|
|
25
|
+
*
|
|
26
|
+
* Every method returns an unsigned transaction. This library never holds a key and
|
|
27
|
+
* never broadcasts: the caller signs and sends. Authorisation is enforced on-chain —
|
|
28
|
+
* the registry requires the sender to hold an active capability invocation on a
|
|
29
|
+
* controller of the parent DID — so a transaction built for a DID the signer does not
|
|
30
|
+
* control simply reverts.
|
|
31
|
+
*/
|
|
32
|
+
export class ServiceDidRegistryTransactions {
|
|
33
|
+
constructor(configManager) {
|
|
34
|
+
this.configManager = configManager;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Registers a service identity under an organisational DID.
|
|
38
|
+
*
|
|
39
|
+
* The identifier is derived on-chain from the parent and its next nonce, so it is
|
|
40
|
+
* not known until the transaction is mined: read it from the `ServiceDidRegistered`
|
|
41
|
+
* event. Two concurrent registrations by the same controller consume different
|
|
42
|
+
* nonces, which is why anticipating the value is not safe.
|
|
43
|
+
*
|
|
44
|
+
* @param controllerDid Parent DID, as did:isbe:<network>:<segment>
|
|
45
|
+
* @param publicKey Signing public key, 64 or 65 bytes hex
|
|
46
|
+
* @param ellipticType 1 = secp256k1, 2 = P-256
|
|
47
|
+
* @param label Human-readable label; only its digest reaches the chain
|
|
48
|
+
* @param expiresAt Unix timestamp of expiry, or 0 to never expire
|
|
49
|
+
* @param from Address that will sign, an active controller of `controllerDid`
|
|
50
|
+
* @param document Optional free-form fields of the service — an endpoint, a name, a
|
|
51
|
+
* description — stored on-chain and added to its DID Document. Public and
|
|
52
|
+
* permanent in the chain history. Without it, or with `{}`, the plain
|
|
53
|
+
* `registerServiceDid` is used
|
|
54
|
+
* @throws ServiceDocumentError when `document` is not storable as given
|
|
55
|
+
*/
|
|
56
|
+
async buildRegisterServiceDidTx(controllerDid, publicKey, ellipticType, label, expiresAt, from, document) {
|
|
57
|
+
// Validated before anything else: no point converting keys for a document that
|
|
58
|
+
// cannot be stored.
|
|
59
|
+
const serializedDocument = serializeServiceDocument(document);
|
|
60
|
+
const args = [
|
|
61
|
+
didToHex(controllerDid),
|
|
62
|
+
validateAndNormalizeHexPublicKey(publicKey),
|
|
63
|
+
ellipticType,
|
|
64
|
+
labelToHash(label),
|
|
65
|
+
expiresAt ?? 0,
|
|
66
|
+
];
|
|
67
|
+
return serializedDocument
|
|
68
|
+
? await buildRawTransaction(this.configManager.contract, "registerServiceDidWithDocument", [...args, serializedDocument], this.configManager.provider, from)
|
|
69
|
+
: await buildRawTransaction(this.configManager.contract, "registerServiceDid", args, this.configManager.provider, from);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Sets or replaces the free-form fields of a service identity.
|
|
73
|
+
*
|
|
74
|
+
* The whole document is replaced, not merged: send every field that should remain.
|
|
75
|
+
* `null` or `{}` clears it. The previous content stays in the chain history.
|
|
76
|
+
*
|
|
77
|
+
* @throws ServiceDocumentError when `document` is not storable as given
|
|
78
|
+
*/
|
|
79
|
+
async buildUpdateServiceDocumentTx(serviceDid, document, from) {
|
|
80
|
+
return await buildRawTransaction(this.configManager.contract, "updateServiceDocument", [serviceDidToHex(serviceDid), serializeServiceDocument(document)], this.configManager.provider, from);
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Replaces the signing key of a service identity.
|
|
84
|
+
*
|
|
85
|
+
* The replacement is atomic and has no overlap: signatures made with the previous
|
|
86
|
+
* key stop validating the moment the transaction is mined. The key rotated away from
|
|
87
|
+
* stays bound to this service's controller: its other services may still use it, a
|
|
88
|
+
* service of any other controller never can.
|
|
89
|
+
*/
|
|
90
|
+
async buildRotateSigningKeyTx(serviceDid, newPublicKey, newEllipticType, from) {
|
|
91
|
+
return await buildRawTransaction(this.configManager.contract, "rotateSigningKey", [
|
|
92
|
+
serviceDidToHex(serviceDid),
|
|
93
|
+
validateAndNormalizeHexPublicKey(newPublicKey),
|
|
94
|
+
newEllipticType,
|
|
95
|
+
], this.configManager.provider, from);
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Changes the expiry of a service identity.
|
|
99
|
+
*
|
|
100
|
+
* A valid expiry is either 0 — never expires — or a timestamp in the future. Bringing
|
|
101
|
+
* an identity to an end right now is not possible this way; that is what
|
|
102
|
+
* `buildDeactivateServiceDidTx` is for, and it cannot be undone.
|
|
103
|
+
*/
|
|
104
|
+
async buildUpdateExpiryTx(serviceDid, newExpiresAt, from) {
|
|
105
|
+
return await buildRawTransaction(this.configManager.contract, "updateExpiry", [serviceDidToHex(serviceDid), newExpiresAt ?? 0], this.configManager.provider, from);
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Deactivates a service identity, permanently.
|
|
109
|
+
*
|
|
110
|
+
* There is no reactivation: a service that needs to come back is registered again
|
|
111
|
+
* and receives a fresh identifier.
|
|
112
|
+
*/
|
|
113
|
+
async buildDeactivateServiceDidTx(serviceDid, from) {
|
|
114
|
+
return await buildRawTransaction(this.configManager.contract, "deactivateServiceDid", [serviceDidToHex(serviceDid)], this.configManager.provider, from);
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Stamps the facet version. Restricted to the diamond's default admin and callable
|
|
118
|
+
* once; it configures no state of its own.
|
|
119
|
+
*/
|
|
120
|
+
async buildInitializeServiceDidRegistryTx(from) {
|
|
121
|
+
return await buildRawTransaction(this.configManager.contract, "initializeServiceDidRegistry", [], this.configManager.provider, from);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Reduces a label to the digest the contract stores.
|
|
126
|
+
*
|
|
127
|
+
* The text itself is deliberately not sent: it is a search aid for the portal, not a
|
|
128
|
+
* security property, and keeping it off-chain makes the cost of a registration
|
|
129
|
+
* independent of how long the label is. An absent label hashes to the empty digest.
|
|
130
|
+
*/
|
|
131
|
+
function labelToHash(label) {
|
|
132
|
+
return keccak256(toUtf8Bytes(label ?? ""));
|
|
133
|
+
}
|
|
134
|
+
//# sourceMappingURL=ServiceDidRegistryTransactions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ServiceDidRegistryTransactions.js","sourceRoot":"","sources":["../../src/ServiceDidRegistryTransactions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;EAcE;AAEF,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,gCAAgC,EAAE,MAAM,6BAA6B,CAAC;AAC/E,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EACL,wBAAwB,GAEzB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAE3E;;;;;;;;GAQG;AACH,MAAM,OAAO,8BAA8B;IAGzC,YAAY,aAAwC;QAClD,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;IACrC,CAAC;IAED;;;;;;;;;;;;;;;;;;;OAmBG;IACH,KAAK,CAAC,yBAAyB,CAC7B,aAAqB,EACrB,SAAiB,EACjB,YAAoB,EACpB,KAAyB,EACzB,SAAsC,EACtC,IAAY,EACZ,QAAiC;QAEjC,+EAA+E;QAC/E,oBAAoB;QACpB,MAAM,kBAAkB,GAAG,wBAAwB,CAAC,QAAQ,CAAC,CAAC;QAC9D,MAAM,IAAI,GAAc;YACtB,QAAQ,CAAC,aAAa,CAAC;YACvB,gCAAgC,CAAC,SAAS,CAAC;YAC3C,YAAY;YACZ,WAAW,CAAC,KAAK,CAAC;YAClB,SAAS,IAAI,CAAC;SACf,CAAC;QAEF,OAAO,kBAAkB;YACvB,CAAC,CAAC,MAAM,mBAAmB,CACvB,IAAI,CAAC,aAAa,CAAC,QAAQ,EAC3B,gCAAgC,EAChC,CAAC,GAAG,IAAI,EAAE,kBAAkB,CAAC,E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B,IAAY;QAEZ,OAAO,MAAM,mBAAmB,CAC9B,IAAI,CAAC,aAAa,CAAC,QAAQ,EAC3B,sBAAsB,EACtB,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC,EAC7B,IAAI,CAAC,aAAa,CAAC,QAAQ,EAC3B,IAAI,CACL,CAAC;IACJ,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,mCAAmC,CAAC,IAAY;QACpD,OAAO,MAAM,mBAAmB,CAC9B,IAAI,CAAC,aAAa,CAAC,QAAQ,EAC3B,8BAA8B,EAC9B,EAAE,EACF,IAAI,CAAC,aAAa,CAAC,QAAQ,EAC3B,IAAI,CACL,CAAC;IACJ,CAAC;CACF;AAED;;;;;;GAMG;AACH,SAAS,WAAW,CAAC,KAAyB;IAC5C,OAAO,SAAS,CAAC,WAAW,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,CAAC;AAC7C,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Comunidad de Madrid & Alastria
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
*
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { ServiceDidRegistryContext } from "./ServiceDidRegistryContext.js";
|
|
17
|
+
/**
|
|
18
|
+
* Broadcasts transactions that were signed elsewhere.
|
|
19
|
+
*
|
|
20
|
+
* Nothing in this package holds a key. The builders return an unsigned transaction, the
|
|
21
|
+
* caller signs it wherever the key lives, and this is the only place that touches the
|
|
22
|
+
* network — refusing anything not addressed to this registry.
|
|
23
|
+
*/
|
|
24
|
+
export declare class ServiceDidTransactionExecutor {
|
|
25
|
+
private context;
|
|
26
|
+
constructor(context: ServiceDidRegistryContext);
|
|
27
|
+
sendSignedTransaction(signedRawTransaction: string): Promise<string>;
|
|
28
|
+
/** Returns `null` when the timeout elapses: sent, not yet confirmed. */
|
|
29
|
+
waitForReceipt(tx_hash: string, timeout: number): Promise<any | null>;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=ServiceDidTransactionExecutor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ServiceDidTransactionExecutor.d.ts","sourceRoot":"","sources":["../../src/ServiceDidTransactionExecutor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;EAcE;AAEF,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAM3E;;;;;;GAMG;AACH,qBAAa,6BAA6B;IACxC,OAAO,CAAC,OAAO,CAA4B;gBAE/B,OAAO,EAAE,yBAAyB;IAIxC,qBAAqB,CAAC,oBAAoB,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAQ1E,wEAAwE;IAClE,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,GAAG,IAAI,CAAC;CAG5E"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Comunidad de Madrid & Alastria
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
*
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { ServiceDidRegistryContext } from "./ServiceDidRegistryContext.js";
|
|
17
|
+
import { sendSignedTransaction, waitForReceipt, } from "./utils/blockchain.utils.js";
|
|
18
|
+
/**
|
|
19
|
+
* Broadcasts transactions that were signed elsewhere.
|
|
20
|
+
*
|
|
21
|
+
* Nothing in this package holds a key. The builders return an unsigned transaction, the
|
|
22
|
+
* caller signs it wherever the key lives, and this is the only place that touches the
|
|
23
|
+
* network — refusing anything not addressed to this registry.
|
|
24
|
+
*/
|
|
25
|
+
export class ServiceDidTransactionExecutor {
|
|
26
|
+
constructor(context) {
|
|
27
|
+
this.context = context;
|
|
28
|
+
}
|
|
29
|
+
async sendSignedTransaction(signedRawTransaction) {
|
|
30
|
+
return await sendSignedTransaction(signedRawTransaction, this.context.provider, this.context.contract);
|
|
31
|
+
}
|
|
32
|
+
/** Returns `null` when the timeout elapses: sent, not yet confirmed. */
|
|
33
|
+
async waitForReceipt(tx_hash, timeout) {
|
|
34
|
+
return await waitForReceipt(tx_hash, timeout, this.context.provider);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=ServiceDidTransactionExecutor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ServiceDidTransactionExecutor.js","sourceRoot":"","sources":["../../src/ServiceDidTransactionExecutor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;EAcE;AAEF,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAC3E,OAAO,EACL,qBAAqB,EACrB,cAAc,GACf,MAAM,6BAA6B,CAAC;AAErC;;;;;;GAMG;AACH,MAAM,OAAO,6BAA6B;IAGxC,YAAY,OAAkC;QAC5C,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED,KAAK,CAAC,qBAAqB,CAAC,oBAA4B;QACtD,OAAO,MAAM,qBAAqB,CAChC,oBAAoB,EACpB,IAAI,CAAC,OAAO,CAAC,QAAQ,EACrB,IAAI,CAAC,OAAO,CAAC,QAAQ,CACtB,CAAC;IACJ,CAAC;IAED,wEAAwE;IACxE,KAAK,CAAC,cAAc,CAAC,OAAe,EAAE,OAAe;QACnD,OAAO,MAAM,cAAc,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACvE,CAAC;CACF"}
|