@verana-labs/vs-agent-sdk 2.0.0-dev.9 → 2.0.0-pr.767.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.
Files changed (172) 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 +17 -34
  30. package/build/agent/VsAgent.js +75 -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 +26 -19
  45. package/build/blockchain/VeranaChainService.js +136 -152
  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/handlers/authorizationHandlers.js +2 -2
  51. package/build/blockchain/handlers/authorizationHandlers.js.map +1 -1
  52. package/build/blockchain/handlers/defaultHandlers.js +6 -1
  53. package/build/blockchain/handlers/defaultHandlers.js.map +1 -1
  54. package/build/blockchain/handlers/index.d.ts +1 -0
  55. package/build/blockchain/handlers/index.js +1 -0
  56. package/build/blockchain/handlers/index.js.map +1 -1
  57. package/build/blockchain/handlers/selfIssuanceHandlers.d.ts +13 -0
  58. package/build/blockchain/handlers/selfIssuanceHandlers.js +76 -0
  59. package/build/blockchain/handlers/selfIssuanceHandlers.js.map +1 -0
  60. package/build/blockchain/handlers/stateMutations.d.ts +26 -3
  61. package/build/blockchain/handlers/stateMutations.js +315 -41
  62. package/build/blockchain/handlers/stateMutations.js.map +1 -1
  63. package/build/blockchain/index.d.ts +2 -0
  64. package/build/blockchain/index.js +2 -0
  65. package/build/blockchain/index.js.map +1 -1
  66. package/build/blockchain/indexerMappers.d.ts +3 -0
  67. package/build/blockchain/indexerMappers.js +53 -0
  68. package/build/blockchain/indexerMappers.js.map +1 -0
  69. package/build/blockchain/types.d.ts +13 -69
  70. package/build/blockchain/types.js.map +1 -1
  71. package/build/bootstrap/EcsBootstrapService.d.ts +13 -4
  72. package/build/bootstrap/EcsBootstrapService.js +166 -109
  73. package/build/bootstrap/EcsBootstrapService.js.map +1 -1
  74. package/build/connections/ParentConnectionModule.d.ts +20 -0
  75. package/build/connections/ParentConnectionModule.js +56 -0
  76. package/build/connections/ParentConnectionModule.js.map +1 -0
  77. package/build/credentials/FullTailsFileService.d.ts +0 -1
  78. package/build/credentials/FullTailsFileService.js +0 -49
  79. package/build/credentials/FullTailsFileService.js.map +1 -1
  80. package/build/did/CachedDocumentLoader.d.ts +3 -0
  81. package/build/did/CachedDocumentLoader.js +7 -1
  82. package/build/did/CachedDocumentLoader.js.map +1 -1
  83. package/build/did/CachedWebDidResolver.d.ts +0 -4
  84. package/build/did/CachedWebDidResolver.js +1 -5
  85. package/build/did/CachedWebDidResolver.js.map +1 -1
  86. package/build/did/artifactServices.d.ts +12 -0
  87. package/build/did/artifactServices.js +48 -0
  88. package/build/did/artifactServices.js.map +1 -0
  89. package/build/did/legacyDidWeb.d.ts +6 -4
  90. package/build/did/legacyDidWeb.js +17 -14
  91. package/build/did/legacyDidWeb.js.map +1 -1
  92. package/build/did/publicDid.d.ts +4 -0
  93. package/build/did/publicDid.js +19 -0
  94. package/build/did/publicDid.js.map +1 -0
  95. package/build/events/BaseMessageEvents.js +139 -5
  96. package/build/events/BaseMessageEvents.js.map +1 -1
  97. package/build/events/ConnectionEvents.js +154 -86
  98. package/build/events/ConnectionEvents.js.map +1 -1
  99. package/build/events/VsAgentEvents.d.ts +11 -9
  100. package/build/events/VsAgentEvents.js +8 -1
  101. package/build/events/VsAgentEvents.js.map +1 -1
  102. package/build/events/VtFlowEvents.d.ts +1 -1
  103. package/build/events/VtFlowEvents.js +29 -17
  104. package/build/events/VtFlowEvents.js.map +1 -1
  105. package/build/index.d.ts +7 -1
  106. package/build/index.js +15 -2
  107. package/build/index.js.map +1 -1
  108. package/build/plugins/setupBaseDidComm.js +9 -12
  109. package/build/plugins/setupBaseDidComm.js.map +1 -1
  110. package/build/transports/VsAgentWsInboundTransport.d.ts +1 -1
  111. package/build/transports/VsAgentWsInboundTransport.js +20 -14
  112. package/build/transports/VsAgentWsInboundTransport.js.map +1 -1
  113. package/build/types.d.ts +14 -13
  114. package/build/types.js +1 -2
  115. package/build/types.js.map +1 -1
  116. package/build/utils/agent.d.ts +29 -4
  117. package/build/utils/agent.js +91 -22
  118. package/build/utils/agent.js.map +1 -1
  119. package/build/utils/boundedFetch.d.ts +13 -0
  120. package/build/utils/boundedFetch.js +47 -0
  121. package/build/utils/boundedFetch.js.map +1 -0
  122. package/build/utils/didReadiness.js +5 -2
  123. package/build/utils/didReadiness.js.map +1 -1
  124. package/build/utils/ecsClaims.d.ts +46 -0
  125. package/build/utils/ecsClaims.js +115 -0
  126. package/build/utils/ecsClaims.js.map +1 -0
  127. package/build/utils/ecsService.d.ts +8 -0
  128. package/build/utils/ecsService.js +23 -0
  129. package/build/utils/ecsService.js.map +1 -0
  130. package/build/utils/index.d.ts +6 -0
  131. package/build/utils/index.js +6 -0
  132. package/build/utils/index.js.map +1 -1
  133. package/build/utils/selfIssuedEcsCredential.d.ts +8 -0
  134. package/build/utils/selfIssuedEcsCredential.js +158 -0
  135. package/build/utils/selfIssuedEcsCredential.js.map +1 -0
  136. package/build/utils/setupSelfTr.d.ts +35 -74
  137. package/build/utils/setupSelfTr.js +93 -312
  138. package/build/utils/setupSelfTr.js.map +1 -1
  139. package/build/utils/trustCredentialStore.d.ts +78 -9
  140. package/build/utils/trustCredentialStore.js +319 -126
  141. package/build/utils/trustCredentialStore.js.map +1 -1
  142. package/build/utils/typeMetadata.d.ts +43 -0
  143. package/build/utils/typeMetadata.js +77 -0
  144. package/build/utils/typeMetadata.js.map +1 -0
  145. package/build/utils/util.d.ts +19 -0
  146. package/build/utils/util.js +24 -0
  147. package/build/utils/util.js.map +1 -1
  148. package/build/utils/vcdm2.d.ts +34 -0
  149. package/build/utils/vcdm2.js +60 -0
  150. package/build/utils/vcdm2.js.map +1 -0
  151. package/build/utils/vtjscResolver.d.ts +23 -0
  152. package/build/utils/vtjscResolver.js +54 -0
  153. package/build/utils/vtjscResolver.js.map +1 -0
  154. package/build/vtFlow/VtFlowOrchestrator.d.ts +107 -14
  155. package/build/vtFlow/VtFlowOrchestrator.js +734 -109
  156. package/build/vtFlow/VtFlowOrchestrator.js.map +1 -1
  157. package/build/vtFlow/assertVerifiableService.d.ts +1 -0
  158. package/build/vtFlow/assertVerifiableService.js +45 -5
  159. package/build/vtFlow/assertVerifiableService.js.map +1 -1
  160. package/build/vtFlow/ecsIssuanceExemption.d.ts +12 -0
  161. package/build/vtFlow/ecsIssuanceExemption.js +84 -0
  162. package/build/vtFlow/ecsIssuanceExemption.js.map +1 -0
  163. package/build/vtFlow/index.d.ts +1 -0
  164. package/build/vtFlow/index.js +1 -0
  165. package/build/vtFlow/index.js.map +1 -1
  166. package/package.json +18 -12
  167. package/build/did/migrateWebVhLog.d.ts +0 -34
  168. package/build/did/migrateWebVhLog.js +0 -230
  169. package/build/did/migrateWebVhLog.js.map +0 -1
  170. package/build/did/migrateWebVhVersionTime.d.ts +0 -9
  171. package/build/did/migrateWebVhVersionTime.js +0 -191
  172. package/build/did/migrateWebVhVersionTime.js.map +0 -1
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.toParticipant = toParticipant;
4
+ exports.toCredentialSchema = toCredentialSchema;
5
+ const types_1 = require("./types");
6
+ const ROLE = {
7
+ [types_1.ParticipantRole.Issuer]: 1,
8
+ [types_1.ParticipantRole.Verifier]: 2,
9
+ [types_1.ParticipantRole.IssuerGrantor]: 3,
10
+ [types_1.ParticipantRole.VerifierGrantor]: 4,
11
+ [types_1.ParticipantRole.Ecosystem]: 5,
12
+ [types_1.ParticipantRole.Holder]: 6,
13
+ };
14
+ const OP_STATE = {
15
+ PENDING: types_1.ValidationState.PENDING,
16
+ VALIDATED: types_1.ValidationState.VALIDATED,
17
+ TERMINATED: types_1.ValidationState.TERMINATED,
18
+ };
19
+ const ONBOARDING_MODE = {
20
+ OPEN: 1,
21
+ ECOSYSTEM_ONBOARDING_PROCESS: 2,
22
+ GRANTOR_ONBOARDING_PROCESS: 3,
23
+ };
24
+ const date = (v) => (v ? new Date(v) : undefined);
25
+ function toParticipant(dto) {
26
+ var _a, _b, _c, _d, _e;
27
+ return {
28
+ id: dto.id,
29
+ schemaId: dto.schema_id,
30
+ role: (_a = ROLE[dto.role]) !== null && _a !== void 0 ? _a : 0,
31
+ did: (_b = dto.did) !== null && _b !== void 0 ? _b : '',
32
+ corporation: '',
33
+ validatorParticipantId: (_c = dto.validator_participant_id) !== null && _c !== void 0 ? _c : 0,
34
+ opState: dto.op_state ? ((_d = OP_STATE[dto.op_state]) !== null && _d !== void 0 ? _d : types_1.ValidationState.UNSPECIFIED) : undefined,
35
+ opSummaryDigest: (_e = dto.op_summary_digest) !== null && _e !== void 0 ? _e : '',
36
+ revoked: date(dto.revoked),
37
+ slashed: date(dto.slashed),
38
+ };
39
+ }
40
+ function toCredentialSchema(dto) {
41
+ var _a, _b, _c, _d;
42
+ return {
43
+ id: dto.id,
44
+ ecosystemId: dto.ecosystem_id,
45
+ jsonSchema: dto.json_schema,
46
+ digestAlgorithm: dto.digest_algorithm,
47
+ issuerOnboardingMode: (_b = ONBOARDING_MODE[(_a = dto.issuer_onboarding_mode) !== null && _a !== void 0 ? _a : '']) !== null && _b !== void 0 ? _b : 0,
48
+ verifierOnboardingMode: (_d = ONBOARDING_MODE[(_c = dto.verifier_onboarding_mode) !== null && _c !== void 0 ? _c : '']) !== null && _d !== void 0 ? _d : 0,
49
+ holderOnboardingMode: 0,
50
+ archived: date(dto.archived),
51
+ };
52
+ }
53
+ //# sourceMappingURL=indexerMappers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"indexerMappers.js","sourceRoot":"","sources":["../../src/blockchain/indexerMappers.ts"],"names":[],"mappings":";;AAgCA,sCAaC;AAED,gDAWC;AA1DD,mCAOgB;AAEhB,MAAM,IAAI,GAA2B;IACnC,CAAC,uBAAe,CAAC,MAAM,CAAC,EAAE,CAAC;IAC3B,CAAC,uBAAe,CAAC,QAAQ,CAAC,EAAE,CAAC;IAC7B,CAAC,uBAAe,CAAC,aAAa,CAAC,EAAE,CAAC;IAClC,CAAC,uBAAe,CAAC,eAAe,CAAC,EAAE,CAAC;IACpC,CAAC,uBAAe,CAAC,SAAS,CAAC,EAAE,CAAC;IAC9B,CAAC,uBAAe,CAAC,MAAM,CAAC,EAAE,CAAC;CAC5B,CAAA;AAED,MAAM,QAAQ,GAAoC;IAChD,OAAO,EAAE,uBAAe,CAAC,OAAO;IAChC,SAAS,EAAE,uBAAe,CAAC,SAAS;IACpC,UAAU,EAAE,uBAAe,CAAC,UAAU;CACvC,CAAA;AAED,MAAM,eAAe,GAA2B;IAC9C,IAAI,EAAE,CAAC;IACP,4BAA4B,EAAE,CAAC;IAC/B,0BAA0B,EAAE,CAAC;CAC9B,CAAA;AAED,MAAM,IAAI,GAAG,CAAC,CAA4B,EAAoB,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAA;AAE9F,SAAgB,aAAa,CAAC,GAAmB;;IAC/C,OAAO;QACL,EAAE,EAAE,GAAG,CAAC,EAAE;QACV,QAAQ,EAAE,GAAG,CAAC,SAAS;QACvB,IAAI,EAAE,MAAA,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,mCAAI,CAAC;QACzB,GAAG,EAAE,MAAA,GAAG,CAAC,GAAG,mCAAI,EAAE;QAClB,WAAW,EAAE,EAAE;QACf,sBAAsB,EAAE,MAAA,GAAG,CAAC,wBAAwB,mCAAI,CAAC;QACzD,OAAO,EAAE,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,MAAA,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,mCAAI,uBAAe,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS;QAC3F,eAAe,EAAE,MAAA,GAAG,CAAC,iBAAiB,mCAAI,EAAE;QAC5C,OAAO,EAAE,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC;QAC1B,OAAO,EAAE,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC;KAC3B,CAAA;AACH,CAAC;AAED,SAAgB,kBAAkB,CAAC,GAAwB;;IACzD,OAAO;QACL,EAAE,EAAE,GAAG,CAAC,EAAE;QACV,WAAW,EAAE,GAAG,CAAC,YAAY;QAC7B,UAAU,EAAE,GAAG,CAAC,WAAW;QAC3B,eAAe,EAAE,GAAG,CAAC,gBAAgB;QACrC,oBAAoB,EAAE,MAAA,eAAe,CAAC,MAAA,GAAG,CAAC,sBAAsB,mCAAI,EAAE,CAAC,mCAAI,CAAC;QAC5E,sBAAsB,EAAE,MAAA,eAAe,CAAC,MAAA,GAAG,CAAC,wBAAwB,mCAAI,EAAE,CAAC,mCAAI,CAAC;QAChF,oBAAoB,EAAE,CAAC;QACvB,QAAQ,EAAE,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC;KAC7B,CAAA;AACH,CAAC"}
@@ -57,6 +57,10 @@ export interface IndexerSubscribeMessage {
57
57
  dids?: string[];
58
58
  corporationId?: number;
59
59
  }
60
+ export interface IndexerSubscribedMessage {
61
+ type: 'subscribed';
62
+ block: number;
63
+ }
60
64
  export interface IndexerEventsResponse {
61
65
  events: IndexerEventRecord[];
62
66
  count: number;
@@ -131,6 +135,7 @@ export interface CredentialSchemaDto {
131
135
  digest_algorithm: string;
132
136
  issuer_onboarding_mode?: string;
133
137
  verifier_onboarding_mode?: string;
138
+ holder_validation_validity_period?: number;
134
139
  archived: string | null;
135
140
  created: string;
136
141
  modified: string;
@@ -162,10 +167,16 @@ export interface ParticipantDto {
162
167
  op_state?: string;
163
168
  revoked: string | null;
164
169
  slashed: string | null;
165
- effective_until?: string;
170
+ effective_from?: string | null;
171
+ effective_until?: string | null;
166
172
  modified: string;
167
173
  validator_participant_id?: number | null;
168
174
  op_summary_digest?: string;
175
+ validation_fees?: number;
176
+ issuance_fees?: number;
177
+ verification_fees?: number;
178
+ issuance_fee_discount?: number;
179
+ verification_fee_discount?: number;
169
180
  }
170
181
  export interface CorporationDto {
171
182
  id: number;
@@ -191,18 +202,6 @@ export interface DigestDto {
191
202
  digest: string;
192
203
  created: string;
193
204
  }
194
- export interface RawParticipant {
195
- id: number;
196
- schemaId: number;
197
- role: number;
198
- did: string;
199
- corporationId?: number;
200
- validatorParticipantId: number;
201
- opState?: number;
202
- opSummaryDigest?: string;
203
- revoked: Date | undefined;
204
- slashed: Date | undefined;
205
- }
206
205
  export interface Ecosystem {
207
206
  id: number;
208
207
  did: string;
@@ -220,10 +219,6 @@ export interface CredentialSchema {
220
219
  holderOnboardingMode: number;
221
220
  archived: Date | undefined;
222
221
  }
223
- export interface StoredDigest {
224
- digest: string;
225
- created: Date | undefined;
226
- }
227
222
  export interface OperatorAuthorization {
228
223
  id: number;
229
224
  corporationId: number;
@@ -249,64 +244,13 @@ export interface VsOperatorAuthorization {
249
244
  vsOperator: string;
250
245
  records: ParticipantAuthorizationRecord[];
251
246
  }
252
- export interface ParticipantQueryClient {
253
- GetParticipant(req: {
254
- id: number;
255
- }): Promise<{
256
- participant?: RawParticipant;
257
- }>;
258
- FindParticipantsWithDID(req: object): Promise<{
259
- participants: RawParticipant[];
260
- }>;
261
- GetParticipantSession(req: {
262
- id: string;
263
- }): Promise<{
264
- session?: unknown;
265
- }>;
266
- }
267
- export interface EcosystemQueryClient {
268
- GetEcosystem(req: {
269
- id: number;
270
- }): Promise<{
271
- ecosystem?: Ecosystem;
272
- }>;
273
- }
274
- export interface CredentialSchemaQueryClient {
275
- GetCredentialSchema(req: {
276
- id: number;
277
- }): Promise<{
278
- schema?: CredentialSchema;
279
- }>;
280
- }
281
- export interface DigestQueryClient {
282
- GetDigest(req: {
283
- digest: string;
284
- }): Promise<{
285
- digest?: StoredDigest;
286
- }>;
287
- }
288
- export interface DelegationQueryClient {
289
- ListOperatorAuthorizations(req: {
290
- corporationId: number;
291
- operator: string;
292
- responseMaxSize: number;
293
- }): Promise<{
294
- operatorAuthorizations: OperatorAuthorization[];
295
- }>;
296
- ListVSOperatorAuthorizations(req: {
297
- corporationId: number;
298
- vsOperator: string;
299
- responseMaxSize: number;
300
- }): Promise<{
301
- vsOperatorAuthorizations: VsOperatorAuthorization[];
302
- }>;
303
- }
304
247
  export interface VeranaChainConfig {
305
248
  rpcUrl: string;
306
249
  chainId?: string;
307
250
  mnemonic: string;
308
251
  logger: BaseLogger;
309
252
  gasPrice?: string;
253
+ gasAdjustment?: number;
310
254
  corporationAddress?: string;
311
255
  autoTriggerResolver?: boolean;
312
256
  }
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/blockchain/types.ts"],"names":[],"mappings":";;;AAEA,IAAY,eAKX;AALD,WAAY,eAAe;IACzB,mEAAe,CAAA;IACf,2DAAW,CAAA;IACX,+DAAa,CAAA;IACb,iEAAc,CAAA;AAChB,CAAC,EALW,eAAe,+BAAf,eAAe,QAK1B;AAeY,QAAA,oBAAoB,GAAG,QAAQ,CAAA;AAC/B,QAAA,SAAS,GAAG,8BAA8B,CAAA;AA0IvD,IAAY,eAOX;AAPD,WAAY,eAAe;IACzB,oCAAiB,CAAA;IACjB,wCAAqB,CAAA;IACrB,mDAAgC,CAAA;IAChC,uDAAoC,CAAA;IACpC,0CAAuB,CAAA;IACvB,oCAAiB,CAAA;AACnB,CAAC,EAPW,eAAe,+BAAf,eAAe,QAO1B;AAED,IAAY,gBAQX;AARD,WAAY,gBAAgB;IAC1B,qCAAiB,CAAA;IACjB,qCAAiB,CAAA;IACjB,yCAAqB,CAAA;IACrB,uCAAmB,CAAA;IACnB,uCAAmB,CAAA;IACnB,uCAAmB,CAAA;IACnB,qCAAiB,CAAA;AACnB,CAAC,EARW,gBAAgB,gCAAhB,gBAAgB,QAQ3B"}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/blockchain/types.ts"],"names":[],"mappings":";;;AAEA,IAAY,eAKX;AALD,WAAY,eAAe;IACzB,mEAAe,CAAA;IACf,2DAAW,CAAA;IACX,+DAAa,CAAA;IACb,iEAAc,CAAA;AAChB,CAAC,EALW,eAAe,+BAAf,eAAe,QAK1B;AAeY,QAAA,oBAAoB,GAAG,QAAQ,CAAA;AAC/B,QAAA,SAAS,GAAG,8BAA8B,CAAA;AAgJvD,IAAY,eAOX;AAPD,WAAY,eAAe;IACzB,oCAAiB,CAAA;IACjB,wCAAqB,CAAA;IACrB,mDAAgC,CAAA;IAChC,uDAAoC,CAAA;IACpC,0CAAuB,CAAA;IACvB,oCAAiB,CAAA;AACnB,CAAC,EAPW,eAAe,+BAAf,eAAe,QAO1B;AAED,IAAY,gBAQX;AARD,WAAY,gBAAgB;IAC1B,qCAAiB,CAAA;IACjB,qCAAiB,CAAA;IACjB,yCAAqB,CAAA;IACrB,uCAAmB,CAAA;IACnB,uCAAmB,CAAA;IACnB,uCAAmB,CAAA;IACnB,qCAAiB,CAAA;AACnB,CAAC,EARW,gBAAgB,gCAAhB,gBAAgB,QAQ3B"}
@@ -16,10 +16,19 @@ export declare class EcsBootstrapService {
16
16
  run(): Promise<void>;
17
17
  private runStandalone;
18
18
  private preflight;
19
+ private operatorSkipReason;
19
20
  private acceptPendingOffers;
21
+ /**
22
+ * StartParticipantOP pays a trust deposit, and it cannot be undone. The onboarding request that
23
+ * must follow it travels over DIDComm from the chain event handler, which catches its own
24
+ * failure. The indexer marks that block processed all the same and never replays it, so an
25
+ * unreachable validator leaves the entry at PENDING for ever. This boot step closes that gap.
26
+ */
27
+ private resumePendingOnboardings;
28
+ private resumeOnboarding;
29
+ private isSelfValidated;
20
30
  private discoverEcsSchemas;
21
31
  private discoverFromEcosystem;
22
- private classifySchema;
23
32
  private ensureHolderParticipant;
24
33
  private findOwnActiveRoot;
25
34
  private ensureSelfIssuedParticipant;
@@ -28,7 +37,7 @@ export declare class EcsBootstrapService {
28
37
  private triggerResolverBestEffort;
29
38
  private isUsableParticipant;
30
39
  private runDelegated;
31
- private requestDelegatedServiceCredential;
32
- private findParentServiceSchemaId;
33
- private awaitDelegatedOutcome;
40
+ private findParentServiceIssuer;
41
+ private assertTrustedEcosystem;
42
+ private onboardingClaims;
34
43
  }
@@ -1,28 +1,18 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.EcsBootstrapService = void 0;
4
+ const didcomm_1 = require("@credo-ts/didcomm");
4
5
  const credo_ts_didcomm_vt_flow_1 = require("@verana-labs/credo-ts-didcomm-vt-flow");
5
6
  const vs_agent_model_1 = require("@verana-labs/vs-agent-model");
6
7
  const blockchain_1 = require("../blockchain");
7
8
  const types_1 = require("../types");
8
9
  const didReadiness_1 = require("../utils/didReadiness");
10
+ const VtFlowOrchestrator_1 = require("../vtFlow/VtFlowOrchestrator");
11
+ const ecsClaims_1 = require("../utils/ecsClaims");
9
12
  const START_OP_MSG = '/verana.pp.v1.MsgStartParticipantOP';
10
13
  const SELF_CREATE_MSG = '/verana.pp.v1.MsgSelfCreateParticipant';
11
14
  const ISSUER_ONBOARDING_MODE_OPEN = 1;
12
15
  const ISSUER_ONBOARDING_MODE_GRANTOR = 3;
13
- const ECS_TITLE_BY_TYPE = {
14
- ServiceCredential: vs_agent_model_1.ECS.SERVICE,
15
- OrganizationCredential: vs_agent_model_1.ECS.ORG,
16
- PersonaCredential: vs_agent_model_1.ECS.PERSONA,
17
- UserAgentCredential: vs_agent_model_1.ECS.USER_AGENT,
18
- BadgeCredential: vs_agent_model_1.ECS.BADGE,
19
- };
20
- const DELEGATED_OUTCOME_TIMEOUT_MS = 15 * 60000;
21
- // Thin safety net for any remaining transient failure (e.g. a network blip from
22
- // the parent's vantage point), on top of the readiness wait in waitUntilOwnDidIsPubliclyResolvable.
23
- const DELEGATED_REQUEST_MAX_ATTEMPTS = 2;
24
- const DELEGATED_REQUEST_ATTEMPT_TIMEOUT_MS = 60000;
25
- const DELEGATED_REQUEST_RETRY_DELAY_MS = 5000;
26
16
  class EcsBootstrapService {
27
17
  constructor(agent, indexer, options, logger) {
28
18
  this.agent = agent;
@@ -31,6 +21,10 @@ class EcsBootstrapService {
31
21
  this.logger = logger;
32
22
  }
33
23
  async run() {
24
+ // Both repair steps sign nothing on chain, so they run before any gate, in either mode, and
25
+ // also for a deployment whose participants the Corporation operator provisions out of band.
26
+ await this.acceptPendingOffers();
27
+ await this.resumePendingOnboardings();
34
28
  if (this.options.mode === 'delegated')
35
29
  return this.runDelegated();
36
30
  return this.runStandalone();
@@ -38,12 +32,11 @@ class EcsBootstrapService {
38
32
  async runStandalone() {
39
33
  const skip = await this.preflight();
40
34
  if (skip) {
41
- this.logger.info(`[EcsBootstrap] standalone bootstrap skipped: ${skip}`);
35
+ this.logger.info(`[EcsBootstrap] standalone bootstrap skipped: ${skip}; this agent expects its participants to be provisioned out of band`);
42
36
  return;
43
37
  }
44
38
  const chain = this.agent.veranaChain;
45
39
  const indexer = this.indexer;
46
- await this.acceptPendingOffers();
47
40
  const { credential, credentialType, service } = await this.discoverEcsSchemas(indexer);
48
41
  await this.ensureHolderParticipant(chain, indexer, credential, credentialType);
49
42
  await this.ensureServiceIssuer(chain, indexer, service);
@@ -59,9 +52,15 @@ class EcsBootstrapService {
59
52
  return 'the Verana indexer is not configured';
60
53
  if (!((_a = this.options.trustedEcosystemDids) === null || _a === void 0 ? void 0 : _a.length))
61
54
  return 'TRUSTED_ECS_ECOSYSTEM_DIDS is not set';
62
- const operatorAuths = await chain.listOperatorAuthorizations();
63
- if (!operatorAuths.some(a => a.msgTypes.includes(START_OP_MSG))) {
64
- return `operator ${chain.address} has no OperatorAuthorization covering MsgStartParticipantOP`;
55
+ return this.operatorSkipReason(chain);
56
+ }
57
+ // StartParticipantOP costs a trust deposit and a fee, so both the authorization and the funds
58
+ // must be there. Neither is a misconfiguration: the operator may provision the entry itself.
59
+ async operatorSkipReason(chain) {
60
+ var _a, _b;
61
+ const operatorAuths = (_b = (await ((_a = this.indexer) === null || _a === void 0 ? void 0 : _a.listOperatorAuthorizations(chain.address)))) !== null && _b !== void 0 ? _b : [];
62
+ if (!operatorAuths.some(auth => auth.msgTypes.includes(START_OP_MSG))) {
63
+ return `operator ${chain.address} holds no OperatorAuthorization covering MsgStartParticipantOP`;
65
64
  }
66
65
  const balance = await chain.getBalance();
67
66
  if (Number(balance.amount) === 0) {
@@ -78,12 +77,33 @@ class EcsBootstrapService {
78
77
  role: credo_ts_didcomm_vt_flow_1.VtFlowRole.Applicant,
79
78
  });
80
79
  for (const record of pending) {
80
+ const connection = await this.agent.didcomm.connections.findById(record.connectionId);
81
+ if (!(connection === null || connection === void 0 ? void 0 : connection.isReady) && record.applicantParticipantId) {
82
+ try {
83
+ await new VtFlowOrchestrator_1.VtFlowOrchestrator(this.agent).startOnboardingProcess({
84
+ applicantParticipantId: Number(record.applicantParticipantId),
85
+ });
86
+ this.logger.info(`[EcsBootstrap] reconnected flow ${record.id} so the validator can offer again`);
87
+ }
88
+ catch (error) {
89
+ this.logger.warn(`[EcsBootstrap] could not reconnect flow ${record.id}: ${error.message}`);
90
+ }
91
+ continue;
92
+ }
81
93
  if (!record.credentialExchangeRecordId)
82
94
  continue;
83
95
  try {
84
- await this.agent.didcomm.credentials.acceptOffer({
85
- credentialExchangeRecordId: record.credentialExchangeRecordId,
86
- });
96
+ const exchange = await this.agent.didcomm.credentials.getById(record.credentialExchangeRecordId);
97
+ if (exchange.state === didcomm_1.DidCommCredentialState.CredentialReceived) {
98
+ const { verifyCredential } = this.agent.dependencyManager.resolve(credo_ts_didcomm_vt_flow_1.VtFlowModuleConfig);
99
+ const agentContext = this.agent.context;
100
+ if (await (verifyCredential === null || verifyCredential === void 0 ? void 0 : verifyCredential({ agentContext, record, credentialExchangeRecord: exchange }))) {
101
+ await this.agent.didcomm.credentials.acceptCredential({ credentialExchangeRecordId: exchange.id });
102
+ this.logger.info(`[EcsBootstrap] accepted the verified credential of flow ${record.id}`);
103
+ }
104
+ continue;
105
+ }
106
+ await api.acceptCredentialOffer(record.id);
87
107
  this.logger.info(`[EcsBootstrap] re-accepted the pending credential offer for flow ${record.id}`);
88
108
  }
89
109
  catch (error) {
@@ -91,6 +111,64 @@ class EcsBootstrapService {
91
111
  }
92
112
  }
93
113
  }
114
+ /**
115
+ * StartParticipantOP pays a trust deposit, and it cannot be undone. The onboarding request that
116
+ * must follow it travels over DIDComm from the chain event handler, which catches its own
117
+ * failure. The indexer marks that block processed all the same and never replays it, so an
118
+ * unreachable validator leaves the entry at PENDING for ever. This boot step closes that gap.
119
+ */
120
+ async resumePendingOnboardings() {
121
+ if (!this.indexer || !this.agent.did)
122
+ return;
123
+ const own = await this.indexer.listParticipants({ did: this.agent.did }).catch(() => []);
124
+ for (const participant of own) {
125
+ if (participant.op_state !== 'PENDING' || participant.revoked || participant.slashed)
126
+ continue;
127
+ try {
128
+ await this.resumeOnboarding(participant);
129
+ }
130
+ catch (error) {
131
+ this.logger.warn(`[EcsBootstrap] could not resume the onboarding of participant ${participant.id}: ${error.message}`);
132
+ }
133
+ }
134
+ }
135
+ async resumeOnboarding(participant) {
136
+ // A flow that a peer ended on purpose is not an interruption; only an error deserves a retry.
137
+ const api = this.agent.dependencyManager.resolve(credo_ts_didcomm_vt_flow_1.VtFlowApi);
138
+ const [latest] = (await api.findAllByQuery({
139
+ applicantParticipantId: String(participant.id),
140
+ role: credo_ts_didcomm_vt_flow_1.VtFlowRole.Applicant,
141
+ flowVariant: credo_ts_didcomm_vt_flow_1.VtFlowVariant.OnboardingProcess,
142
+ })).sort((a, b) => b.createdAt.getTime() - a.createdAt.getTime());
143
+ if (latest && (0, credo_ts_didcomm_vt_flow_1.isVtFlowTerminalState)(latest.state) && latest.state !== credo_ts_didcomm_vt_flow_1.VtFlowState.Error)
144
+ return;
145
+ // The agent validates its own entry when it controls the ECOSYSTEM root of the schema, so
146
+ // there is no peer to send a request to: the interrupted step is the chain outcome itself.
147
+ if (await this.isSelfValidated(participant)) {
148
+ const chain = this.agent.veranaChain;
149
+ if (!chain)
150
+ return;
151
+ await chain.setParticipantOPToValidated({
152
+ id: participant.id,
153
+ validationFees: 0,
154
+ issuanceFees: 0,
155
+ verificationFees: 0,
156
+ });
157
+ await this.triggerResolverBestEffort(chain, participant.id);
158
+ this.logger.info(`[EcsBootstrap] validated the interrupted self-issued participant ${participant.id}`);
159
+ return;
160
+ }
161
+ await (0, didReadiness_1.waitUntilOwnDidIsPubliclyResolvable)(this.agent, this.logger);
162
+ const claims = await this.onboardingClaims(participant.schema_id);
163
+ const record = await new VtFlowOrchestrator_1.VtFlowOrchestrator(this.agent).startOnboardingProcess(Object.assign({ applicantParticipantId: participant.id }, (claims ? { claims } : {})));
164
+ this.logger.info(`[EcsBootstrap] checked the onboarding of participant ${participant.id} (flow ${record.id}, state ${record.state})`);
165
+ }
166
+ async isSelfValidated(participant) {
167
+ if (participant.validator_participant_id == null)
168
+ return false;
169
+ const validator = await this.indexer.getParticipant(participant.validator_participant_id).catch(() => undefined);
170
+ return (validator === null || validator === void 0 ? void 0 : validator.did) === this.agent.did;
171
+ }
94
172
  // WL-ECS: only ecosystems on the configured allowlist may provide the essential credential schemas.
95
173
  async discoverEcsSchemas(indexer) {
96
174
  const ecosystems = await indexer.listEcosystems();
@@ -114,7 +192,7 @@ class EcsBootstrapService {
114
192
  const schemas = await indexer.listCredentialSchemas(ecosystemId);
115
193
  const classified = await Promise.all(schemas
116
194
  .filter(schema => !schema.archived)
117
- .map(async (schema) => ({ schema, type: await this.classifySchema(schema) })));
195
+ .map(async (schema) => ({ schema, type: await (0, vs_agent_model_1.classifyEcsSchema)(schema.json_schema) })));
118
196
  const byType = (type) => { var _a; return (_a = classified.find(c => c.type === type)) === null || _a === void 0 ? void 0 : _a.schema; };
119
197
  const service = byType(vs_agent_model_1.ECS.SERVICE);
120
198
  if (!service)
@@ -126,20 +204,6 @@ class EcsBootstrapService {
126
204
  throw new Error('no ECS Organization or Persona credential schema');
127
205
  return { credential, credentialType: org ? vs_agent_model_1.ECS.ORG : vs_agent_model_1.ECS.PERSONA, service };
128
206
  }
129
- async classifySchema(schema) {
130
- var _a;
131
- try {
132
- const parsed = JSON.parse(schema.json_schema);
133
- const byDigest = await (0, vs_agent_model_1.identifySchema)(parsed);
134
- if (byDigest)
135
- return byDigest;
136
- const title = typeof parsed.title === 'string' ? parsed.title : '';
137
- return (_a = ECS_TITLE_BY_TYPE[title]) !== null && _a !== void 0 ? _a : null;
138
- }
139
- catch (_b) {
140
- return null;
141
- }
142
- }
143
207
  async ensureHolderParticipant(chain, indexer, schema, credentialType) {
144
208
  // If this agent controls the schema's ECOSYSTEM root, it has no external ISSUER to seek a
145
209
  // HOLDER credential from — it must become the ISSUER itself (see ensureSelfIssuedParticipant).
@@ -222,11 +286,14 @@ class EcsBootstrapService {
222
286
  this.logger.info(`[EcsBootstrap] reusing Service ISSUER participant ${usable.id}`);
223
287
  return;
224
288
  }
225
- const onChainSchema = await chain.getCredentialSchema(schema.id);
289
+ const onChainSchema = await indexer
290
+ .getCredentialSchema(schema.id)
291
+ .then(blockchain_1.toCredentialSchema)
292
+ .catch(() => undefined);
226
293
  if (!onChainSchema)
227
294
  throw new Error(`Service schema ${schema.id} not found on chain`);
228
295
  if (onChainSchema.issuerOnboardingMode === ISSUER_ONBOARDING_MODE_OPEN) {
229
- const operatorAuths = await chain.listOperatorAuthorizations();
296
+ const operatorAuths = await indexer.listOperatorAuthorizations(chain.address);
230
297
  if (!operatorAuths.some(a => a.msgTypes.includes(SELF_CREATE_MSG))) {
231
298
  throw new Error(`operator ${chain.address} has no OperatorAuthorization covering MsgSelfCreateParticipant (required for OPEN issuer onboarding)`);
232
299
  }
@@ -288,101 +355,91 @@ class EcsBootstrapService {
288
355
  throw new Error('delegated bootstrap requires a public DID');
289
356
  if (!this.indexer)
290
357
  throw new Error('delegated bootstrap requires the Verana indexer');
358
+ const chain = this.agent.veranaChain;
359
+ if (!chain)
360
+ throw new Error('delegated bootstrap requires the Verana chain');
291
361
  if (!this.options.verifyPeer) {
292
362
  throw new Error(`cannot verify parent VS ${parentDid}: verifiable public registries are not configured (set VERANA_CHAIN_ID)`);
293
363
  }
294
- await (0, didReadiness_1.waitUntilOwnDidIsPubliclyResolvable)(this.agent, this.logger);
295
364
  const verified = await this.options.verifyPeer(parentDid).catch(() => false);
296
365
  if (!verified) {
297
366
  throw new Error(`parent VS ${parentDid} is not a Verifiable Service`);
298
367
  }
299
- const schemaId = await this.findParentServiceSchemaId(parentDid);
300
- let lastError;
301
- for (let attempt = 1; attempt <= DELEGATED_REQUEST_MAX_ATTEMPTS; attempt++) {
302
- try {
303
- await this.requestDelegatedServiceCredential(parentDid, schemaId, attempt);
304
- return;
305
- }
306
- catch (error) {
307
- lastError = error;
308
- this.logger.warn(`[EcsBootstrap] delegated issuance attempt ${attempt}/${DELEGATED_REQUEST_MAX_ATTEMPTS} failed: ${lastError.message}`);
309
- if (attempt < DELEGATED_REQUEST_MAX_ATTEMPTS) {
310
- await new Promise(resolve => setTimeout(resolve, DELEGATED_REQUEST_RETRY_DELAY_MS));
311
- }
368
+ const validator = await this.findParentServiceIssuer(parentDid);
369
+ await this.assertTrustedEcosystem(validator.schema_id);
370
+ // An existing entry means the process already ran, or the operator provisioned it.
371
+ const own = await this.indexer.listParticipants({
372
+ did: this.agent.did,
373
+ role: blockchain_1.ParticipantRole.Holder,
374
+ schemaId: validator.schema_id,
375
+ });
376
+ const existing = own.find(participant => this.isUsableParticipant(participant));
377
+ if (existing) {
378
+ // The parent named by AGENT_DELEGATED_PARENT_VS_DID must be the validator of the entry;
379
+ // any other validator would issue the Service credential of another accountable party.
380
+ if (Number(existing.validator_participant_id) !== validator.id) {
381
+ throw new Error(`HOLDER participant ${existing.id} for the ECS Service schema ${validator.schema_id} names validator ${existing.validator_participant_id}, not the parent VS ${parentDid} (validator ${validator.id})`);
312
382
  }
383
+ this.logger.info(`[EcsBootstrap] HOLDER participant ${existing.id} for the ECS Service schema ${validator.schema_id} already exists; the onboarding process continues on its own`);
384
+ return;
313
385
  }
314
- throw lastError !== null && lastError !== void 0 ? lastError : new Error(`parent VS ${parentDid} did not complete the issuance in time`);
315
- }
316
- async requestDelegatedServiceCredential(parentDid, schemaId, attempt) {
317
- let connectionId;
318
- try {
319
- const { connectionRecord } = await this.agent.didcomm.oob.receiveImplicitInvitation({
320
- did: parentDid,
321
- ourDid: this.agent.did,
322
- label: this.agent.label,
323
- didCommVersion: 'v2',
324
- });
325
- if (!connectionRecord)
326
- throw new Error('no connection record returned');
327
- const ready = await this.agent.didcomm.connections.returnWhenIsConnected(connectionRecord.id);
328
- connectionId = ready.id;
329
- }
330
- catch (error) {
331
- throw new Error(`parent VS ${parentDid} is unreachable: ${error.message}`);
386
+ // [VSA-VTI-FLOW-OP-NEW] step 1: the applicant submits StartParticipantOP. The agent then
387
+ // reacts to its own chain event and sends the onboarding request, so nothing is awaited here.
388
+ // Direct Issuance does not apply: it needs holder_onboarding_mode = PERMISSIONLESS, and the
389
+ // ECS Service schema uses ISSUER_ONBOARDING_PROCESS.
390
+ const skip = await this.operatorSkipReason(chain);
391
+ if (skip) {
392
+ this.logger.info(`[EcsBootstrap] delegated bootstrap skipped: ${skip}; this agent expects its HOLDER participant to be provisioned out of band, with validator ${validator.id}`);
393
+ return;
332
394
  }
333
- const api = this.agent.dependencyManager.resolve(credo_ts_didcomm_vt_flow_1.VtFlowApi);
334
- const record = await api.sendIssuanceRequest({
335
- connectionId,
336
- schemaId: String(schemaId),
337
- agentParticipantId: '0',
338
- walletAgentParticipantId: '0',
395
+ const { participantId } = await chain.startParticipantOP({
396
+ role: types_1.HOLDER_PARTICIPANT_TYPE,
397
+ validatorParticipantId: validator.id,
398
+ did: this.agent.did,
339
399
  });
340
- this.logger.info(`[EcsBootstrap] requested the Service credential (schema ${schemaId}) from parent VS ${parentDid} (attempt ${attempt}/${DELEGATED_REQUEST_MAX_ATTEMPTS})`);
341
- const isLastAttempt = attempt === DELEGATED_REQUEST_MAX_ATTEMPTS;
342
- const timeoutMs = isLastAttempt ? DELEGATED_OUTCOME_TIMEOUT_MS : DELEGATED_REQUEST_ATTEMPT_TIMEOUT_MS;
343
- await this.awaitDelegatedOutcome(record.id, parentDid, timeoutMs);
400
+ this.logger.info(`[EcsBootstrap] started HOLDER onboarding ${participantId} for the ECS Service schema ${validator.schema_id} with parent VS ${parentDid} (validator ${validator.id})`);
344
401
  }
345
- async findParentServiceSchemaId(parentDid) {
402
+ async findParentServiceIssuer(parentDid) {
346
403
  const participants = await this.indexer.listParticipants({
347
404
  did: parentDid,
348
405
  role: blockchain_1.ParticipantRole.Issuer,
349
406
  participantState: blockchain_1.ParticipantState.Active,
350
407
  });
351
408
  for (const participant of participants) {
409
+ if (participant.revoked || participant.slashed)
410
+ continue;
352
411
  const schema = await this.indexer.getCredentialSchema(participant.schema_id).catch(() => undefined);
353
412
  if (!schema)
354
413
  continue;
355
- if ((await this.classifySchema(schema)) === vs_agent_model_1.ECS.SERVICE)
356
- return schema.id;
414
+ if ((await (0, vs_agent_model_1.classifyEcsSchema)(schema.json_schema)) === vs_agent_model_1.ECS.SERVICE)
415
+ return participant;
357
416
  }
358
417
  throw new Error(`parent VS ${parentDid} holds no active ISSUER participant for an ECS Service schema`);
359
418
  }
360
- awaitDelegatedOutcome(recordId, parentDid, timeoutMs) {
361
- return new Promise((resolve, reject) => {
362
- const listener = ({ payload }) => {
363
- if (payload.vtFlowRecordId !== recordId)
364
- return;
365
- if (payload.state === credo_ts_didcomm_vt_flow_1.VtFlowState.Completed) {
366
- cleanup();
367
- resolve();
368
- }
369
- else if (payload.state === credo_ts_didcomm_vt_flow_1.VtFlowState.TerminatedByValidator ||
370
- payload.state === credo_ts_didcomm_vt_flow_1.VtFlowState.Error) {
371
- cleanup();
372
- reject(new Error(`parent VS ${parentDid} rejected the Service credential request`));
373
- }
374
- };
375
- const cleanup = () => {
376
- clearTimeout(timer);
377
- this.agent.events.off(credo_ts_didcomm_vt_flow_1.VtFlowEventTypes.VtFlowStateChanged, listener);
378
- };
379
- const timer = setTimeout(() => {
380
- cleanup();
381
- reject(new Error(`parent VS ${parentDid} did not complete the issuance in time`));
382
- }, timeoutMs);
383
- timer.unref();
384
- this.agent.events.on(credo_ts_didcomm_vt_flow_1.VtFlowEventTypes.VtFlowStateChanged, listener);
385
- });
419
+ // WL-ECS: an allowlist is optional in delegated mode, but it binds the flow once the operator sets it.
420
+ async assertTrustedEcosystem(schemaId) {
421
+ var _a;
422
+ const trusted = this.options.trustedEcosystemDids;
423
+ if (!(trusted === null || trusted === void 0 ? void 0 : trusted.length))
424
+ return;
425
+ const schema = await this.indexer.getCredentialSchema(schemaId).catch(() => undefined);
426
+ const ecosystem = schema
427
+ ? await this.indexer.getEcosystem(schema.ecosystem_id).catch(() => undefined)
428
+ : undefined;
429
+ if (!ecosystem || ecosystem.archived || !trusted.includes(ecosystem.did)) {
430
+ throw new Error(`the ECS Service schema ${schemaId} belongs to ecosystem ${(_a = ecosystem === null || ecosystem === void 0 ? void 0 : ecosystem.did) !== null && _a !== void 0 ? _a : '<unresolvable>'}, which TRUSTED_ECS_ECOSYSTEM_DIDS does not list`);
431
+ }
432
+ }
433
+ async onboardingClaims(schemaId) {
434
+ if (!this.agent.ecsClaims || !this.agent.did)
435
+ return undefined;
436
+ const schema = await this.agent.indexer.getCredentialSchema(schemaId);
437
+ const ecsKey = schema && (await (0, vs_agent_model_1.classifyEcsSchema)(schema.json_schema));
438
+ if (!ecsKey) {
439
+ this.agent.config.logger.info(`[ecs-claims] schema ${schemaId} is not an ECS schema, sending no claims`);
440
+ return undefined;
441
+ }
442
+ return await (0, ecsClaims_1.composeEcsClaims)(this.agent.ecsClaims, ecsKey, this.agent.config.logger);
386
443
  }
387
444
  }
388
445
  exports.EcsBootstrapService = EcsBootstrapService;