@verana-labs/vs-agent-sdk 2.0.0-dev.8 → 2.0.0-dev.80

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.
Files changed (182) hide show
  1. package/README.md +0 -2
  2. package/build/adminApi/AdminApiError.d.ts +28 -0
  3. package/build/adminApi/AdminApiError.js +60 -0
  4. package/build/adminApi/AdminApiError.js.map +1 -0
  5. package/build/adminApi/didcommModules.d.ts +2 -0
  6. package/build/adminApi/didcommModules.js +8 -0
  7. package/build/adminApi/didcommModules.js.map +1 -0
  8. package/build/adminApi/index.d.ts +4 -0
  9. package/build/adminApi/index.js +21 -0
  10. package/build/adminApi/index.js.map +1 -0
  11. package/build/adminApi/moduleEndpoint.d.ts +8 -0
  12. package/build/adminApi/moduleEndpoint.js +28 -0
  13. package/build/adminApi/moduleEndpoint.js.map +1 -0
  14. package/build/adminApi/pagination/PageDto.d.ts +7 -0
  15. package/build/adminApi/pagination/PageDto.js +50 -0
  16. package/build/adminApi/pagination/PageDto.js.map +1 -0
  17. package/build/adminApi/pagination/PaginationQueryDto.d.ts +11 -0
  18. package/build/adminApi/pagination/PaginationQueryDto.js +46 -0
  19. package/build/adminApi/pagination/PaginationQueryDto.js.map +1 -0
  20. package/build/adminApi/pagination/cursor.d.ts +28 -0
  21. package/build/adminApi/pagination/cursor.js +64 -0
  22. package/build/adminApi/pagination/cursor.js.map +1 -0
  23. package/build/adminApi/pagination/index.d.ts +4 -0
  24. package/build/adminApi/pagination/index.js +21 -0
  25. package/build/adminApi/pagination/index.js.map +1 -0
  26. package/build/adminApi/pagination/paginate.d.ts +27 -0
  27. package/build/adminApi/pagination/paginate.js +77 -0
  28. package/build/adminApi/pagination/paginate.js.map +1 -0
  29. package/build/agent/VsAgent.d.ts +22 -34
  30. package/build/agent/VsAgent.js +84 -205
  31. package/build/agent/VsAgent.js.map +1 -1
  32. package/build/agent/createVsAgent.d.ts +5 -6
  33. package/build/agent/createVsAgent.js +3 -5
  34. package/build/agent/createVsAgent.js.map +1 -1
  35. package/build/blockchain/AnonCredsTrustService.d.ts +62 -0
  36. package/build/blockchain/AnonCredsTrustService.js +256 -0
  37. package/build/blockchain/AnonCredsTrustService.js.map +1 -0
  38. package/build/blockchain/AuthorizationService.d.ts +5 -3
  39. package/build/blockchain/AuthorizationService.js +17 -29
  40. package/build/blockchain/AuthorizationService.js.map +1 -1
  41. package/build/blockchain/IndexerWebSocketService.d.ts +7 -1
  42. package/build/blockchain/IndexerWebSocketService.js +68 -36
  43. package/build/blockchain/IndexerWebSocketService.js.map +1 -1
  44. package/build/blockchain/VeranaChainService.d.ts +38 -27
  45. package/build/blockchain/VeranaChainService.js +169 -177
  46. package/build/blockchain/VeranaChainService.js.map +1 -1
  47. package/build/blockchain/VeranaIndexerService.d.ts +14 -1
  48. package/build/blockchain/VeranaIndexerService.js +122 -8
  49. package/build/blockchain/VeranaIndexerService.js.map +1 -1
  50. package/build/blockchain/feePreflight.d.ts +32 -0
  51. package/build/blockchain/feePreflight.js +89 -0
  52. package/build/blockchain/feePreflight.js.map +1 -0
  53. package/build/blockchain/handlers/authorizationHandlers.js +2 -2
  54. package/build/blockchain/handlers/authorizationHandlers.js.map +1 -1
  55. package/build/blockchain/handlers/defaultHandlers.js +6 -1
  56. package/build/blockchain/handlers/defaultHandlers.js.map +1 -1
  57. package/build/blockchain/handlers/index.d.ts +1 -0
  58. package/build/blockchain/handlers/index.js +1 -0
  59. package/build/blockchain/handlers/index.js.map +1 -1
  60. package/build/blockchain/handlers/selfIssuanceHandlers.d.ts +13 -0
  61. package/build/blockchain/handlers/selfIssuanceHandlers.js +76 -0
  62. package/build/blockchain/handlers/selfIssuanceHandlers.js.map +1 -0
  63. package/build/blockchain/handlers/stateMutations.d.ts +26 -3
  64. package/build/blockchain/handlers/stateMutations.js +317 -41
  65. package/build/blockchain/handlers/stateMutations.js.map +1 -1
  66. package/build/blockchain/index.d.ts +4 -0
  67. package/build/blockchain/index.js +4 -0
  68. package/build/blockchain/index.js.map +1 -1
  69. package/build/blockchain/indexerMappers.d.ts +3 -0
  70. package/build/blockchain/indexerMappers.js +53 -0
  71. package/build/blockchain/indexerMappers.js.map +1 -0
  72. package/build/blockchain/triggerResolver.d.ts +26 -0
  73. package/build/blockchain/triggerResolver.js +120 -0
  74. package/build/blockchain/triggerResolver.js.map +1 -0
  75. package/build/blockchain/types.d.ts +13 -70
  76. package/build/blockchain/types.js.map +1 -1
  77. package/build/bootstrap/EcsBootstrapService.d.ts +13 -3
  78. package/build/bootstrap/EcsBootstrapService.js +172 -94
  79. package/build/bootstrap/EcsBootstrapService.js.map +1 -1
  80. package/build/connections/ParentConnectionModule.d.ts +20 -0
  81. package/build/connections/ParentConnectionModule.js +56 -0
  82. package/build/connections/ParentConnectionModule.js.map +1 -0
  83. package/build/credentials/FullTailsFileService.d.ts +0 -1
  84. package/build/credentials/FullTailsFileService.js +0 -49
  85. package/build/credentials/FullTailsFileService.js.map +1 -1
  86. package/build/did/CachedDocumentLoader.d.ts +3 -0
  87. package/build/did/CachedDocumentLoader.js +7 -1
  88. package/build/did/CachedDocumentLoader.js.map +1 -1
  89. package/build/did/CachedWebDidResolver.d.ts +0 -4
  90. package/build/did/CachedWebDidResolver.js +1 -5
  91. package/build/did/CachedWebDidResolver.js.map +1 -1
  92. package/build/did/artifactServices.d.ts +12 -0
  93. package/build/did/artifactServices.js +48 -0
  94. package/build/did/artifactServices.js.map +1 -0
  95. package/build/did/legacyDidWeb.d.ts +6 -4
  96. package/build/did/legacyDidWeb.js +17 -14
  97. package/build/did/legacyDidWeb.js.map +1 -1
  98. package/build/did/publicDid.d.ts +4 -0
  99. package/build/did/publicDid.js +19 -0
  100. package/build/did/publicDid.js.map +1 -0
  101. package/build/events/BaseMessageEvents.js +139 -5
  102. package/build/events/BaseMessageEvents.js.map +1 -1
  103. package/build/events/ConnectionEvents.js +150 -86
  104. package/build/events/ConnectionEvents.js.map +1 -1
  105. package/build/events/VsAgentEvents.d.ts +11 -9
  106. package/build/events/VsAgentEvents.js +8 -1
  107. package/build/events/VsAgentEvents.js.map +1 -1
  108. package/build/events/VtFlowEvents.d.ts +1 -1
  109. package/build/events/VtFlowEvents.js +29 -17
  110. package/build/events/VtFlowEvents.js.map +1 -1
  111. package/build/index.d.ts +7 -1
  112. package/build/index.js +15 -2
  113. package/build/index.js.map +1 -1
  114. package/build/plugins/setupBaseDidComm.js +9 -12
  115. package/build/plugins/setupBaseDidComm.js.map +1 -1
  116. package/build/transports/VsAgentWsInboundTransport.d.ts +1 -1
  117. package/build/transports/VsAgentWsInboundTransport.js +20 -14
  118. package/build/transports/VsAgentWsInboundTransport.js.map +1 -1
  119. package/build/types.d.ts +14 -13
  120. package/build/types.js +1 -2
  121. package/build/types.js.map +1 -1
  122. package/build/utils/agent.d.ts +29 -4
  123. package/build/utils/agent.js +91 -22
  124. package/build/utils/agent.js.map +1 -1
  125. package/build/utils/boundedFetch.d.ts +13 -0
  126. package/build/utils/boundedFetch.js +47 -0
  127. package/build/utils/boundedFetch.js.map +1 -0
  128. package/build/utils/didReadiness.d.ts +9 -0
  129. package/build/utils/didReadiness.js +42 -0
  130. package/build/utils/didReadiness.js.map +1 -0
  131. package/build/utils/ecsClaims.d.ts +46 -0
  132. package/build/utils/ecsClaims.js +115 -0
  133. package/build/utils/ecsClaims.js.map +1 -0
  134. package/build/utils/ecsService.d.ts +8 -0
  135. package/build/utils/ecsService.js +23 -0
  136. package/build/utils/ecsService.js.map +1 -0
  137. package/build/utils/index.d.ts +7 -0
  138. package/build/utils/index.js +7 -0
  139. package/build/utils/index.js.map +1 -1
  140. package/build/utils/publishedDidRecord.d.ts +15 -0
  141. package/build/utils/publishedDidRecord.js +83 -0
  142. package/build/utils/publishedDidRecord.js.map +1 -0
  143. package/build/utils/selfIssuedEcsCredential.d.ts +8 -0
  144. package/build/utils/selfIssuedEcsCredential.js +153 -0
  145. package/build/utils/selfIssuedEcsCredential.js.map +1 -0
  146. package/build/utils/setupSelfTr.d.ts +35 -74
  147. package/build/utils/setupSelfTr.js +93 -312
  148. package/build/utils/setupSelfTr.js.map +1 -1
  149. package/build/utils/trustCredentialStore.d.ts +78 -9
  150. package/build/utils/trustCredentialStore.js +324 -136
  151. package/build/utils/trustCredentialStore.js.map +1 -1
  152. package/build/utils/typeMetadata.d.ts +43 -0
  153. package/build/utils/typeMetadata.js +77 -0
  154. package/build/utils/typeMetadata.js.map +1 -0
  155. package/build/utils/util.d.ts +19 -0
  156. package/build/utils/util.js +24 -0
  157. package/build/utils/util.js.map +1 -1
  158. package/build/utils/vcdm2.d.ts +34 -0
  159. package/build/utils/vcdm2.js +60 -0
  160. package/build/utils/vcdm2.js.map +1 -0
  161. package/build/utils/vtjscResolver.d.ts +23 -0
  162. package/build/utils/vtjscResolver.js +53 -0
  163. package/build/utils/vtjscResolver.js.map +1 -0
  164. package/build/vtFlow/VtFlowOrchestrator.d.ts +107 -15
  165. package/build/vtFlow/VtFlowOrchestrator.js +678 -116
  166. package/build/vtFlow/VtFlowOrchestrator.js.map +1 -1
  167. package/build/vtFlow/assertVerifiableService.d.ts +1 -0
  168. package/build/vtFlow/assertVerifiableService.js +45 -5
  169. package/build/vtFlow/assertVerifiableService.js.map +1 -1
  170. package/build/vtFlow/ecsIssuanceExemption.d.ts +12 -0
  171. package/build/vtFlow/ecsIssuanceExemption.js +84 -0
  172. package/build/vtFlow/ecsIssuanceExemption.js.map +1 -0
  173. package/build/vtFlow/index.d.ts +1 -0
  174. package/build/vtFlow/index.js +1 -0
  175. package/build/vtFlow/index.js.map +1 -1
  176. package/package.json +18 -12
  177. package/build/did/migrateWebVhLog.d.ts +0 -34
  178. package/build/did/migrateWebVhLog.js +0 -230
  179. package/build/did/migrateWebVhLog.js.map +0 -1
  180. package/build/did/migrateWebVhVersionTime.d.ts +0 -9
  181. package/build/did/migrateWebVhVersionTime.js +0 -191
  182. package/build/did/migrateWebVhVersionTime.js.map +0 -1
@@ -0,0 +1,46 @@
1
+ import type { Logger } from '@credo-ts/core';
2
+ export interface EcsClaims {
3
+ localResources?: Record<string, string>;
4
+ org?: Record<string, string | undefined>;
5
+ persona?: Record<string, string | undefined>;
6
+ service?: Record<string, string | undefined>;
7
+ }
8
+ export declare const ECS_CLAIMS_VARIABLES: {
9
+ readonly org: {
10
+ readonly name: "ECS_CLAIMS_ORG_NAME";
11
+ readonly logoUri: "ECS_CLAIMS_ORG_LOGO_URI";
12
+ readonly registryId: "ECS_CLAIMS_ORG_REGISTRY_ID";
13
+ readonly registryUri: "ECS_CLAIMS_ORG_REGISTRY_URI";
14
+ readonly address: "ECS_CLAIMS_ORG_ADDRESS";
15
+ readonly countryCode: "ECS_CLAIMS_ORG_COUNTRY_CODE";
16
+ readonly legalJurisdiction: "ECS_CLAIMS_ORG_LEGAL_JURISDICTION";
17
+ readonly organizationKind: "ECS_CLAIMS_ORG_ORGANIZATION_KIND";
18
+ readonly lei: "ECS_CLAIMS_ORG_LEI";
19
+ };
20
+ readonly persona: {
21
+ readonly name: "ECS_CLAIMS_PERSONA_NAME";
22
+ readonly description: "ECS_CLAIMS_PERSONA_DESCRIPTION";
23
+ readonly descriptionFormat: "ECS_CLAIMS_PERSONA_DESCRIPTION_FORMAT";
24
+ readonly avatarUri: "ECS_CLAIMS_PERSONA_AVATAR_URI";
25
+ readonly controllerCountryCode: "ECS_CLAIMS_PERSONA_CONTROLLER_COUNTRY_CODE";
26
+ readonly controllerJurisdiction: "ECS_CLAIMS_PERSONA_CONTROLLER_JURISDICTION";
27
+ };
28
+ readonly service: {
29
+ readonly name: "ECS_CLAIMS_SERVICE_NAME";
30
+ readonly type: "ECS_CLAIMS_SERVICE_TYPE";
31
+ readonly description: "ECS_CLAIMS_SERVICE_DESCRIPTION";
32
+ readonly descriptionFormat: "ECS_CLAIMS_SERVICE_DESCRIPTION_FORMAT";
33
+ readonly logoUri: "ECS_CLAIMS_SERVICE_LOGO_URI";
34
+ readonly minimumAgeRequired: "ECS_CLAIMS_SERVICE_MINIMUM_AGE_REQUIRED";
35
+ readonly termsAndConditionsUri: "ECS_CLAIMS_SERVICE_TERMS_AND_CONDITIONS_URI";
36
+ readonly privacyPolicyUri: "ECS_CLAIMS_SERVICE_PRIVACY_POLICY_URI";
37
+ };
38
+ };
39
+ export declare function readEcsClaimsFromEnv(): Required<Pick<EcsClaims, 'org' | 'persona' | 'service'>>;
40
+ export declare function digestOfUri(uri: string, variable: string, logger?: Logger): Promise<string>;
41
+ /**
42
+ * Compose the claims of one ECS credential from the configured variables, deriving `id` and
43
+ * every paired `*DigestSri`. Returns undefined when the operator configured no claim, so the
44
+ * caller can omit the `claims` field entirely.
45
+ */
46
+ export declare function composeEcsClaims(claims: EcsClaims, schemaKey: string, logger?: Logger): Promise<Record<string, unknown> | undefined>;
@@ -0,0 +1,115 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.ECS_CLAIMS_VARIABLES = void 0;
7
+ exports.readEcsClaimsFromEnv = readEcsClaimsFromEnv;
8
+ exports.digestOfUri = digestOfUri;
9
+ exports.composeEcsClaims = composeEcsClaims;
10
+ const axios_1 = __importDefault(require("axios"));
11
+ const boundedFetch_1 = require("./boundedFetch");
12
+ // the URI claim each derived digest claim is computed from
13
+ const DIGEST_OF = {
14
+ logoDigestSri: 'logoUri',
15
+ avatarDigestSri: 'avatarUri',
16
+ termsAndConditionsDigestSri: 'termsAndConditionsUri',
17
+ privacyPolicyDigestSri: 'privacyPolicyUri',
18
+ };
19
+ // [VSA-VTI-CFG-ENV-ECS] variable of each claim the agent reads
20
+ exports.ECS_CLAIMS_VARIABLES = {
21
+ org: {
22
+ name: 'ECS_CLAIMS_ORG_NAME',
23
+ logoUri: 'ECS_CLAIMS_ORG_LOGO_URI',
24
+ registryId: 'ECS_CLAIMS_ORG_REGISTRY_ID',
25
+ registryUri: 'ECS_CLAIMS_ORG_REGISTRY_URI',
26
+ address: 'ECS_CLAIMS_ORG_ADDRESS',
27
+ countryCode: 'ECS_CLAIMS_ORG_COUNTRY_CODE',
28
+ legalJurisdiction: 'ECS_CLAIMS_ORG_LEGAL_JURISDICTION',
29
+ organizationKind: 'ECS_CLAIMS_ORG_ORGANIZATION_KIND',
30
+ lei: 'ECS_CLAIMS_ORG_LEI',
31
+ },
32
+ persona: {
33
+ name: 'ECS_CLAIMS_PERSONA_NAME',
34
+ description: 'ECS_CLAIMS_PERSONA_DESCRIPTION',
35
+ descriptionFormat: 'ECS_CLAIMS_PERSONA_DESCRIPTION_FORMAT',
36
+ avatarUri: 'ECS_CLAIMS_PERSONA_AVATAR_URI',
37
+ controllerCountryCode: 'ECS_CLAIMS_PERSONA_CONTROLLER_COUNTRY_CODE',
38
+ controllerJurisdiction: 'ECS_CLAIMS_PERSONA_CONTROLLER_JURISDICTION',
39
+ },
40
+ service: {
41
+ name: 'ECS_CLAIMS_SERVICE_NAME',
42
+ type: 'ECS_CLAIMS_SERVICE_TYPE',
43
+ description: 'ECS_CLAIMS_SERVICE_DESCRIPTION',
44
+ descriptionFormat: 'ECS_CLAIMS_SERVICE_DESCRIPTION_FORMAT',
45
+ logoUri: 'ECS_CLAIMS_SERVICE_LOGO_URI',
46
+ minimumAgeRequired: 'ECS_CLAIMS_SERVICE_MINIMUM_AGE_REQUIRED',
47
+ termsAndConditionsUri: 'ECS_CLAIMS_SERVICE_TERMS_AND_CONDITIONS_URI',
48
+ privacyPolicyUri: 'ECS_CLAIMS_SERVICE_PRIVACY_POLICY_URI',
49
+ },
50
+ };
51
+ function readEcsClaimsFromEnv() {
52
+ const read = (variables) => Object.fromEntries(Object.entries(variables).map(([claim, name]) => { var _a; return [claim, ((_a = process.env[name]) === null || _a === void 0 ? void 0 : _a.trim()) || undefined]; }));
53
+ return {
54
+ org: read(exports.ECS_CLAIMS_VARIABLES.org),
55
+ persona: read(exports.ECS_CLAIMS_VARIABLES.persona),
56
+ service: read(exports.ECS_CLAIMS_VARIABLES.service),
57
+ };
58
+ }
59
+ const DIGEST_TIMEOUT_MS = 5000;
60
+ const DIGEST_ATTEMPTS = 4;
61
+ const DIGEST_BASE_DELAY_MS = 500;
62
+ const sleep = (ms) => new Promise(resolve => setTimeout(resolve, ms));
63
+ async function digestOfUri(uri, variable, logger) {
64
+ let lastError;
65
+ for (let attempt = 1; attempt <= DIGEST_ATTEMPTS; attempt++) {
66
+ try {
67
+ const response = await axios_1.default.get(uri, { responseType: 'arraybuffer', timeout: DIGEST_TIMEOUT_MS });
68
+ return (0, boundedFetch_1.digestOfBytes)(Buffer.from(response.data));
69
+ }
70
+ catch (error) {
71
+ lastError = error;
72
+ if (attempt < DIGEST_ATTEMPTS)
73
+ await sleep(DIGEST_BASE_DELAY_MS * 2 ** (attempt - 1));
74
+ }
75
+ }
76
+ const message = `cannot compute the digest of ${variable} (${uri}): ${lastError === null || lastError === void 0 ? void 0 : lastError.message}`;
77
+ logger === null || logger === void 0 ? void 0 : logger.error(`[ecs-claims] ${message}`);
78
+ throw new Error(message);
79
+ }
80
+ const GROUP_OF = {
81
+ 'ecs-service': 'service',
82
+ 'ecs-persona': 'persona',
83
+ 'ecs-org': 'org',
84
+ };
85
+ const groupOf = (claims, schemaKey) => {
86
+ const group = GROUP_OF[schemaKey];
87
+ return group ? claims[group] : undefined;
88
+ };
89
+ /**
90
+ * Compose the claims of one ECS credential from the configured variables, deriving `id` and
91
+ * every paired `*DigestSri`. Returns undefined when the operator configured no claim, so the
92
+ * caller can omit the `claims` field entirely.
93
+ */
94
+ async function composeEcsClaims(claims, schemaKey, logger) {
95
+ var _a;
96
+ const configured = groupOf(claims, schemaKey);
97
+ const set = Object.entries(configured !== null && configured !== void 0 ? configured : {}).filter(([, v]) => v !== undefined && v !== '');
98
+ if (set.length === 0)
99
+ return undefined;
100
+ const composed = {};
101
+ for (const [claim, value] of set) {
102
+ composed[claim] = claim === 'minimumAgeRequired' ? Number(value) : value;
103
+ }
104
+ for (const [digestClaim, uriClaim] of Object.entries(DIGEST_OF)) {
105
+ const uri = composed[uriClaim];
106
+ if (typeof uri !== 'string')
107
+ continue;
108
+ const group = GROUP_OF[schemaKey];
109
+ const variable = (group && exports.ECS_CLAIMS_VARIABLES[group][uriClaim]) || uriClaim;
110
+ const local = (_a = claims.localResources) === null || _a === void 0 ? void 0 : _a[uri];
111
+ composed[digestClaim] = local ? (0, boundedFetch_1.digestOfBytes)(local) : await digestOfUri(uri, variable, logger);
112
+ }
113
+ return composed;
114
+ }
115
+ //# sourceMappingURL=ecsClaims.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ecsClaims.js","sourceRoot":"","sources":["../../src/utils/ecsClaims.ts"],"names":[],"mappings":";;;;;;AAyDA,oDAUC;AAQD,kCAcC;AAkBD,4CAsBC;AA/HD,kDAAyB;AAEzB,iDAA8C;AAY9C,2DAA2D;AAC3D,MAAM,SAAS,GAA2B;IACxC,aAAa,EAAE,SAAS;IACxB,eAAe,EAAE,WAAW;IAC5B,2BAA2B,EAAE,uBAAuB;IACpD,sBAAsB,EAAE,kBAAkB;CAC3C,CAAA;AAED,+DAA+D;AAClD,QAAA,oBAAoB,GAAG;IAClC,GAAG,EAAE;QACH,IAAI,EAAE,qBAAqB;QAC3B,OAAO,EAAE,yBAAyB;QAClC,UAAU,EAAE,4BAA4B;QACxC,WAAW,EAAE,6BAA6B;QAC1C,OAAO,EAAE,wBAAwB;QACjC,WAAW,EAAE,6BAA6B;QAC1C,iBAAiB,EAAE,mCAAmC;QACtD,gBAAgB,EAAE,kCAAkC;QACpD,GAAG,EAAE,oBAAoB;KAC1B;IACD,OAAO,EAAE;QACP,IAAI,EAAE,yBAAyB;QAC/B,WAAW,EAAE,gCAAgC;QAC7C,iBAAiB,EAAE,uCAAuC;QAC1D,SAAS,EAAE,+BAA+B;QAC1C,qBAAqB,EAAE,4CAA4C;QACnE,sBAAsB,EAAE,4CAA4C;KACrE;IACD,OAAO,EAAE;QACP,IAAI,EAAE,yBAAyB;QAC/B,IAAI,EAAE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3
+ name?: string;
4
+ description?: string;
5
+ logoUri?: string;
6
+ }
7
+ export declare function ecsServiceClaims(agent: VsAgent): Promise<EcsServiceClaims | undefined>;
8
+ export declare function agentDisplayName(agent: VsAgent): Promise<string>;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ecsServiceClaims = ecsServiceClaims;
4
+ exports.agentDisplayName = agentDisplayName;
5
+ const vs_agent_model_1 = require("@verana-labs/vs-agent-model");
6
+ const setupSelfTr_1 = require("./setupSelfTr");
7
+ // Read at call time, not at startup: the credential is published asynchronously after boot
8
+ async function ecsServiceClaims(agent) {
9
+ var _a, _b;
10
+ if (!agent.did)
11
+ return undefined;
12
+ const [didRecord] = await agent.dids.getCreatedDids({ did: agent.did });
13
+ const metadata = didRecord === null || didRecord === void 0 ? void 0 : didRecord.metadata.get('_vt/vtc');
14
+ if (!metadata)
15
+ return undefined;
16
+ const serviceId = `${agent.did}#${(0, setupSelfTr_1.linkedVpFragment)(vs_agent_model_1.ECS.SERVICE)}`;
17
+ return (_b = (_a = Object.values(metadata).find(entry => entry.didDocumentServiceId === serviceId)) === null || _a === void 0 ? void 0 : _a.credential) === null || _b === void 0 ? void 0 : _b.credentialSubject;
18
+ }
19
+ async function agentDisplayName(agent) {
20
+ var _a, _b;
21
+ return (_b = (_a = (await ecsServiceClaims(agent))) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : new URL(agent.publicApiBaseUrl).host;
22
+ }
23
+ //# sourceMappingURL=ecsService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ecsService.js","sourceRoot":"","sources":["../../src/utils/ecsService.ts"],"names":[],"mappings":";;AAkBA,4CAUC;AAED,4CAEC;AA9BD,gEAAiD;AAEjD,+CAAgD;AAahD,2FAA2F;AACpF,KAAK,UAAU,gBAAgB,CAAC,KAAc;;IACnD,IAAI,CAAC,KAAK,CAAC,GAAG;QAAE,OAAO,SAAS,CAAA;IAEhC,MAAM,CAAC,SAAS,CAAC,GAAG,MAAM,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,EAAE,CAAC,CAAA;IACvE,MAAM,QAAQ,GAAG,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAyC,CAAA;IAC3F,IAAI,CAAC,QAAQ;QAAE,OAAO,SAAS,CAAA;IAE/B,MAAM,SAAS,GAAG,GAAG,KAAK,CAAC,GAAG,IAAI,IAAA,8BAAgB,EAAC,oBAAG,CAAC,OAAO,CAAC,EAAE,CAAA;IACjE,OAAO,MAAA,MAAA,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,oBAAoB,KAAK,SAAS,CAAC,0CAAE,UAAU,0CAC9F,iBAAiD,CAAA;AACvD,CAAC;AAEM,KAAK,UAAU,gBAAgB,CAAC,KAAc;;IACnD,OAAO,MAAA,MAAA,CAAC,MAAM,gBAAgB,CAAC,KAAK,CAAC,CAAC,0CAAE,IAAI,mCAAI,IAAI,GAAG,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC,IAAI,CAAA;AACtF,CAAC"}
@@ -1,5 +1,12 @@
1
1
  export * from './agent';
2
+ export * from './boundedFetch';
2
3
  export * from './data';
4
+ export * from './ecsClaims';
5
+ export * from './ecsService';
6
+ export * from './publishedDidRecord';
3
7
  export * from './setupSelfTr';
4
8
  export * from './trustCredentialStore';
9
+ export * from './typeMetadata';
5
10
  export * from './util';
11
+ export * from './vcdm2';
12
+ export * from './vtjscResolver';
@@ -15,8 +15,15 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./agent"), exports);
18
+ __exportStar(require("./boundedFetch"), exports);
18
19
  __exportStar(require("./data"), exports);
20
+ __exportStar(require("./ecsClaims"), exports);
21
+ __exportStar(require("./ecsService"), exports);
22
+ __exportStar(require("./publishedDidRecord"), exports);
19
23
  __exportStar(require("./setupSelfTr"), exports);
20
24
  __exportStar(require("./trustCredentialStore"), exports);
25
+ __exportStar(require("./typeMetadata"), exports);
21
26
  __exportStar(require("./util"), exports);
27
+ __exportStar(require("./vcdm2"), exports);
28
+ __exportStar(require("./vtjscResolver"), exports);
22
29
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAuB;AACvB,yCAAsB;AACtB,gDAA6B;AAC7B,yDAAsC;AACtC,yCAAsB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAuB;AACvB,iDAA8B;AAC9B,yCAAsB;AACtB,8CAA2B;AAC3B,+CAA4B;AAC5B,uDAAoC;AACpC,gDAA6B;AAC7B,yDAAsC;AACtC,iDAA8B;AAC9B,yCAAsB;AACtB,0CAAuB;AACvB,kDAA+B"}
@@ -0,0 +1,15 @@
1
+ import { DidRecord } from '@credo-ts/core';
2
+ import { VsAgent } from '../agent/VsAgent';
3
+ /**
4
+ * The one write point of the published Verifiable Trust material: the `_vt/vtc` and `_vt/jsc`
5
+ * metadata of the DID record and the DID Document that announces them. [VSA-VT-LVP-5] asks for a
6
+ * `TriggerResolver` after each change of a `LinkedVerifiablePresentation` entry, so the decision
7
+ * lives here rather than in each caller: the stored record is compared with the one written. The DID
8
+ * Document is published only when it changed, so a metadata-only write adds no `did:webvh` version.
9
+ */
10
+ export declare function updateDidRecord(agent: VsAgent, didRecord: DidRecord): Promise<void>;
11
+ /**
12
+ * What a trust resolver reads of the agent: its `LinkedVerifiablePresentation` entries, and the
13
+ * presentations behind them. Two records with the same fingerprint resolve the same way.
14
+ */
15
+ export declare function publicationFingerprint(didRecord: DidRecord | null): string;
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updateDidRecord = updateDidRecord;
4
+ exports.publicationFingerprint = publicationFingerprint;
5
+ const core_1 = require("@credo-ts/core");
6
+ const triggerResolver_1 = require("../blockchain/triggerResolver");
7
+ const adminApiService_1 = require("../did/adminApiService");
8
+ /**
9
+ * The one write point of the published Verifiable Trust material: the `_vt/vtc` and `_vt/jsc`
10
+ * metadata of the DID record and the DID Document that announces them. [VSA-VT-LVP-5] asks for a
11
+ * `TriggerResolver` after each change of a `LinkedVerifiablePresentation` entry, so the decision
12
+ * lives here rather than in each caller: the stored record is compared with the one written. The DID
13
+ * Document is published only when it changed, so a metadata-only write adds no `did:webvh` version.
14
+ */
15
+ async function updateDidRecord(agent, didRecord) {
16
+ const repo = agent.context.dependencyManager.resolve(core_1.DidRepository);
17
+ (0, adminApiService_1.applyAdminApiServiceEntry)(didRecord.didDocument, agent.adminApiServiceEndpoint);
18
+ const stored = await storedRecord(agent, repo, didRecord.id);
19
+ const publishedBefore = publicationFingerprint(stored);
20
+ const documentBefore = documentFingerprint(stored);
21
+ await repo.update(agent.context, didRecord);
22
+ if (documentFingerprint(didRecord) !== documentBefore) {
23
+ await agent.dids.update({ did: didRecord.did, didDocument: didRecord.didDocument });
24
+ }
25
+ if (publicationFingerprint(didRecord) !== publishedBefore) {
26
+ (0, triggerResolver_1.scheduleTriggerResolverForOwnDid)(agent, 'the published Verifiable Trust material changed');
27
+ }
28
+ }
29
+ async function storedRecord(agent, repo, id) {
30
+ try {
31
+ return await repo.findById(agent.context, id);
32
+ }
33
+ catch (error) {
34
+ agent.config.logger.debug(`[trust-credential] cannot read the stored DID record: ${error.message}`);
35
+ return null;
36
+ }
37
+ }
38
+ function stableStringify(value) {
39
+ var _a;
40
+ if (Array.isArray(value))
41
+ return `[${value.map(stableStringify).join(',')}]`;
42
+ if (value && typeof value === 'object') {
43
+ const entries = Object.entries(value)
44
+ .filter(([, v]) => v !== undefined)
45
+ .sort(([a], [b]) => a.localeCompare(b));
46
+ return `{${entries.map(([k, v]) => `${JSON.stringify(k)}:${stableStringify(v)}`).join(',')}}`;
47
+ }
48
+ return (_a = JSON.stringify(value)) !== null && _a !== void 0 ? _a : 'null';
49
+ }
50
+ // a document saved as a class instance reads back from storage as JSON, so both go through JSON
51
+ function asJson(value) {
52
+ return value === undefined ? undefined : JSON.parse(JSON.stringify(value));
53
+ }
54
+ /** What the agent serves as its DID Document. Two records with the same fingerprint serve the same. */
55
+ function documentFingerprint(didRecord) {
56
+ if (!(didRecord === null || didRecord === void 0 ? void 0 : didRecord.didDocument))
57
+ return '';
58
+ return stableStringify(asJson(didRecord.didDocument));
59
+ }
60
+ /**
61
+ * What a trust resolver reads of the agent: its `LinkedVerifiablePresentation` entries, and the
62
+ * presentations behind them. Two records with the same fingerprint resolve the same way.
63
+ */
64
+ function publicationFingerprint(didRecord) {
65
+ var _a, _b;
66
+ if (!didRecord)
67
+ return '';
68
+ const services = ((_b = (_a = didRecord.didDocument) === null || _a === void 0 ? void 0 : _a.service) !== null && _b !== void 0 ? _b : [])
69
+ .filter(service => service.type === 'LinkedVerifiablePresentation')
70
+ .map(service => ({ id: service.id, serviceEndpoint: service.serviceEndpoint }))
71
+ .sort((a, b) => a.id.localeCompare(b.id));
72
+ const presentations = ['_vt/vtc', '_vt/jsc'].map(key => {
73
+ var _a;
74
+ return Object.entries((_a = didRecord.metadata.get(key)) !== null && _a !== void 0 ? _a : {})
75
+ .map(([schemaId, entry]) => ({
76
+ schemaId,
77
+ presentation: entry.verifiablePresentation,
78
+ }))
79
+ .sort((a, b) => a.schemaId.localeCompare(b.schemaId));
80
+ });
81
+ return stableStringify(asJson({ services, presentations }));
82
+ }
83
+ //# sourceMappingURL=publishedDidRecord.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"publishedDidRecord.js","sourceRoot":"","sources":["../../src/utils/publishedDidRecord.ts"],"names":[],"mappings":";;AAa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,CAAC,CAAC,CAAA;AAC7D,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { W3cCredentialSchema } from '@credo-ts/core';
2
+ import { VsAgent } from '../agent/VsAgent';
3
+ import { EcsClaims } from './ecsClaims';
4
+ /** The linked presentation as published: VC Data Model 2.0 JSON secured with Data Integrity proofs */
5
+ export type SelfIssuedEcsPresentation = Record<string, unknown> & {
6
+ verifiableCredential: Record<string, unknown>[];
7
+ };
8
+ export declare function publishSelfIssuedEcsPresentation(agent: VsAgent, id: string, ecsSchemas: Record<string, string>, schemaKey: string, type: string[], credentialSchema: W3cCredentialSchema, ecsClaims: EcsClaims, beforePublish?: (verifiablePresentation: SelfIssuedEcsPresentation) => Promise<void>, validUntil?: string): Promise<SelfIssuedEcsPresentation>;
@@ -0,0 +1,153 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.publishSelfIssuedEcsPresentation = publishSelfIssuedEcsPresentation;
4
+ const core_1 = require("@credo-ts/core");
5
+ const vs_agent_model_1 = require("@verana-labs/vs-agent-model");
6
+ const setupSelfTr_1 = require("./setupSelfTr");
7
+ const publishedDidRecord_1 = require("./publishedDidRecord");
8
+ const vcdm2_1 = require("./vcdm2");
9
+ const buildIntegrityData = (data) => {
10
+ return (0, setupSelfTr_1.generateDigestSRI)(JSON.stringify((0, setupSelfTr_1.sortKeysDeep)(data)));
11
+ };
12
+ function storedCredentialIsCurrent(credential, credentialSchemaId, did, didRecord, validUntil) {
13
+ var _a, _b, _c;
14
+ if (!credential)
15
+ return false;
16
+ // a credential published by an older agent as data model 1.1 is rebuilt on upgrade
17
+ if (!(0, vcdm2_1.isDataIntegrityVcdm2Credential)(credential))
18
+ return false;
19
+ const issuer = typeof credential.issuer === 'string' ? credential.issuer : (_a = credential.issuer) === null || _a === void 0 ? void 0 : _a.id;
20
+ if (issuer !== did)
21
+ return false;
22
+ const schema = Array.isArray(credential.credentialSchema)
23
+ ? credential.credentialSchema[0]
24
+ : credential.credentialSchema;
25
+ if ((schema === null || schema === void 0 ? void 0 : schema.id) !== credentialSchemaId)
26
+ return false;
27
+ if (credential.validUntil !== validUntil)
28
+ return false;
29
+ const proofs = !credential.proof
30
+ ? []
31
+ : Array.isArray(credential.proof)
32
+ ? credential.proof
33
+ : [credential.proof];
34
+ if (proofs.length === 0)
35
+ return false;
36
+ const assertionMethods = new Set(((_c = (_b = didRecord.didDocument) === null || _b === void 0 ? void 0 : _b.assertionMethod) !== null && _c !== void 0 ? _c : []).map(entry => typeof entry === 'string' ? entry : entry.id));
37
+ return proofs.every(proof => !!proof.verificationMethod && assertionMethods.has(proof.verificationMethod));
38
+ }
39
+ /**
40
+ * Issues the ECS credential to the agent itself and wraps it in the linked presentation, both
41
+ * secured with a DataIntegrityProof by the DID Document assertion key.
42
+ */
43
+ async function signSelfIssuedEcsCredential(agent, didRecord, presentationId, type, claims, credentialSchema, validUntil) {
44
+ const unsignedCredential = (0, vcdm2_1.createW3cV2Credential)({
45
+ id: agent.did,
46
+ type,
47
+ issuer: agent.did,
48
+ credentialSubject: Object.assign(Object.assign({}, claims), { id: agent.did }),
49
+ credentialSchema: { id: credentialSchema.id, type: credentialSchema.type },
50
+ validUntil,
51
+ });
52
+ const verificationMethodId = (0, setupSelfTr_1.getVerificationMethodId)(agent.config.logger, didRecord);
53
+ const signedCredential = await (0, setupSelfTr_1.signerW3c)(agent, unsignedCredential, verificationMethodId);
54
+ const presentation = (0, setupSelfTr_1.createPresentation)({
55
+ id: presentationId,
56
+ holder: agent.did,
57
+ verifiableCredential: [signedCredential],
58
+ });
59
+ const signedPresentation = await (0, setupSelfTr_1.signerW3c)(agent, presentation, verificationMethodId);
60
+ return signedPresentation.securedPresentation;
61
+ }
62
+ async function publishSelfIssuedEcsPresentation(agent, id, ecsSchemas, schemaKey, type, credentialSchema, ecsClaims, beforePublish, validUntil) {
63
+ var _a, _b, _c, _d, _e, _f, _g;
64
+ if (!agent.did)
65
+ throw Error('The DID must be set up');
66
+ const [didRecord] = await agent.dids.getCreatedDids({ did: agent.did });
67
+ const didDocument = didRecord.didDocument;
68
+ if (!didDocument)
69
+ throw Error('The DID Document must be set up');
70
+ const claims = await (0, setupSelfTr_1.getClaims)(agent.config.logger, ecsSchemas, { id: agent.did }, schemaKey, ecsClaims);
71
+ if (!validUntil && (0, vs_agent_model_1.ecsRequiresValidUntil)(schemaKey)) {
72
+ throw new Error(`Not issuing the ${schemaKey} credential: its VTJSC requires validUntil and the ISSUER participant has no effective_until, which SetParticipantEffectiveUntil sets`);
73
+ }
74
+ const didDocumentServiceId = `${agent.did}#${(0, setupSelfTr_1.linkedVpFragment)(schemaKey)}`;
75
+ const integrityData = buildIntegrityData({ id, type, credentialSchema, claims });
76
+ const record = (_a = didRecord.metadata.get('_vt/vtc')) !== null && _a !== void 0 ? _a : {};
77
+ const metadata = record[credentialSchema.id];
78
+ const superseded = Object.entries(record).some(([storedSchemaId, entry]) => {
79
+ var _a;
80
+ return storedSchemaId !== credentialSchema.id &&
81
+ ((_a = entry === null || entry === void 0 ? void 0 : entry.verifiablePresentation) === null || _a === void 0 ? void 0 : _a.id) === id &&
82
+ (entry === null || entry === void 0 ? void 0 : entry.attached) !== false;
83
+ });
84
+ const attached = ((_b = metadata === null || metadata === void 0 ? void 0 : metadata.attached) !== null && _b !== void 0 ? _b : true) && !superseded;
85
+ if ((metadata === null || metadata === void 0 ? void 0 : metadata.integrityData) === integrityData &&
86
+ storedCredentialIsCurrent(metadata === null || metadata === void 0 ? void 0 : metadata.credential, credentialSchema.id, agent.did, didRecord, validUntil)) {
87
+ // the presentation is already public, so a failed beforePublish step still needs a retry here
88
+ if (attached)
89
+ await (beforePublish === null || beforePublish === void 0 ? void 0 : beforePublish(metadata.verifiablePresentation));
90
+ return metadata.verifiablePresentation;
91
+ }
92
+ const verifiablePresentation = await signSelfIssuedEcsCredential(agent, didRecord, id, type, claims, credentialSchema, validUntil);
93
+ // nothing is persisted yet, so a failure here leaves no public presentation behind
94
+ if (attached)
95
+ await (beforePublish === null || beforePublish === void 0 ? void 0 : beforePublish(verifiablePresentation));
96
+ // Update linked VP when the presentation has changed. Match by fragment or by the file the
97
+ // endpoint ends with: a `contains` test also matches the host, so an agent at a host such as
98
+ // ecs-org-issuer.example rewrote its DIDComm endpoint and every other ECS linked VP onto this one.
99
+ const linkedVpFile = `/${schemaKey}-vtc-vp.json`;
100
+ if (attached)
101
+ didDocument.service = (_c = didDocument.service) === null || _c === void 0 ? void 0 : _c.map(s => {
102
+ if (typeof s.serviceEndpoint !== 'string')
103
+ return s;
104
+ if (s.type !== 'LinkedVerifiablePresentation' || s.id === `${agent.did}#whois`)
105
+ return s;
106
+ if (s.id !== didDocumentServiceId && !s.serviceEndpoint.endsWith(linkedVpFile))
107
+ return s;
108
+ s.id = didDocumentServiceId;
109
+ s.serviceEndpoint = id;
110
+ return s;
111
+ });
112
+ // Resolvers only discover the credential through the [VT-CRED-W3C-LINKED-VP] fragment, and
113
+ // #whois does not match it. The rename above only covers documents that already carry the
114
+ // service, so publish it here when nothing declared it yet.
115
+ if (attached && !((_d = didDocument.service) === null || _d === void 0 ? void 0 : _d.some(s => s.id === didDocumentServiceId))) {
116
+ didDocument.service = [
117
+ ...((_e = didDocument.service) !== null && _e !== void 0 ? _e : []),
118
+ new core_1.DidDocumentService({
119
+ id: didDocumentServiceId,
120
+ serviceEndpoint: id,
121
+ type: 'LinkedVerifiablePresentation',
122
+ }),
123
+ ];
124
+ }
125
+ const whoisId = `${agent.did}#whois`;
126
+ if (attached && schemaKey === 'ecs-service') {
127
+ const whois = (_f = didDocument.service) === null || _f === void 0 ? void 0 : _f.find(s => s.id === whoisId);
128
+ if (whois) {
129
+ whois.serviceEndpoint = id;
130
+ }
131
+ else {
132
+ didDocument.service = [
133
+ ...((_g = didDocument.service) !== null && _g !== void 0 ? _g : []),
134
+ new core_1.DidDocumentService({ id: whoisId, serviceEndpoint: id, type: 'LinkedVerifiablePresentation' }),
135
+ ];
136
+ }
137
+ }
138
+ const [credential] = verifiablePresentation.verifiableCredential;
139
+ record[credentialSchema.id] = {
140
+ credential,
141
+ verifiablePresentation,
142
+ didDocumentServiceId,
143
+ integrityData,
144
+ attached,
145
+ };
146
+ didRecord.metadata.set('_vt/vtc', record);
147
+ // the write point publishes the document when it changed, and triggers the resolver when the
148
+ // published material did ([VSA-VT-LVP-5]): an ECS credential re-issued under the same URL changes
149
+ // the presentation a resolver reads, without changing the entry that announces it
150
+ await (0, publishedDidRecord_1.updateDidRecord)(agent, didRecord);
151
+ return verifiablePresentation;
152
+ }
153
+ //# sourceMappingURL=selfIssuedEcsCredential.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"selfIssuedEcsCredential.js","sourceRoot":"","sources":["../../src/utils/selfIssuedEcsCredential.ts"],"names":[],"mappings":";;AAoGA,4EAwGC;AA5MD,yCAAmF;AACnF,gEAAmE;AAInE,+CAQsB;AACtB,6DAAsD;AACtD,mCAA+E;AAE/E,MAAM,kBAAkB,GAAG,CAAC,IAA6B,EAAE,EAAE;IAC3D,OAAO,IAAA,+BAAiB,EAAC,IAAI,CAAC,SAAS,CAAC,IAAA,0BAAY,EAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AAC9D,CAAC,CAAA;AASD,SAAS,yBAAyB,CAChC,UAAkD,EAClD,kBAA0B,EAC1B,GAAW,EACX,SAAoB,EACpB,UAA8B;;IAE9B,IAAI,CAAC,UAAU;QAAE,OAAO,KAAK,CAAA;IAC7B,mFAAmF;IACnF,IAAI,CAAC,IAAA,sCAA8B,EAAC,UAAU,CAAC;QAAE,OAAO,KAAK,CAAA;IAE7D,MAAM,MAAM,GAAG,OAAO,UAAU,CAAC,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,MAAA,UAAU,CAAC,MAAM,0CAAE,EAAE,CAAA;IAChG,IAAI,MAAM,KAAK,GAAG;QAAE,OAAO,KAAK,CAAA;IAEhC,MAAM,MAAM,GAAG,KAAK,CAAC,OAAO,CAAC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