@verana-labs/vs-agent-sdk 1.12.0-dev.2 → 1.12.0-dev.21

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 (78) hide show
  1. package/README.md +35 -46
  2. package/build/agent/VsAgent.d.ts +6 -0
  3. package/build/agent/VsAgent.js +25 -13
  4. package/build/agent/VsAgent.js.map +1 -1
  5. package/build/agent/createVsAgent.d.ts +1 -0
  6. package/build/agent/createVsAgent.js +1 -0
  7. package/build/agent/createVsAgent.js.map +1 -1
  8. package/build/blockchain/IndexerWebSocketService.d.ts +15 -13
  9. package/build/blockchain/IndexerWebSocketService.js +207 -103
  10. package/build/blockchain/IndexerWebSocketService.js.map +1 -1
  11. package/build/blockchain/VeranaChainService.d.ts +33 -11
  12. package/build/blockchain/VeranaChainService.js +246 -55
  13. package/build/blockchain/VeranaChainService.js.map +1 -1
  14. package/build/blockchain/VeranaHelpers.js +3 -2
  15. package/build/blockchain/VeranaHelpers.js.map +1 -1
  16. package/build/blockchain/VeranaIndexerService.d.ts +9 -5
  17. package/build/blockchain/VeranaIndexerService.js +41 -23
  18. package/build/blockchain/VeranaIndexerService.js.map +1 -1
  19. package/build/blockchain/handlers/IndexerHandlerRegistry.d.ts +5 -3
  20. package/build/blockchain/handlers/IndexerHandlerRegistry.js +6 -0
  21. package/build/blockchain/handlers/IndexerHandlerRegistry.js.map +1 -1
  22. package/build/blockchain/handlers/defaultHandlers.d.ts +4 -1
  23. package/build/blockchain/handlers/defaultHandlers.js +76 -44
  24. package/build/blockchain/handlers/defaultHandlers.js.map +1 -1
  25. package/build/blockchain/handlers/stateMutations.d.ts +17 -4
  26. package/build/blockchain/handlers/stateMutations.js +229 -31
  27. package/build/blockchain/handlers/stateMutations.js.map +1 -1
  28. package/build/blockchain/indexerSync.d.ts +10 -0
  29. package/build/blockchain/indexerSync.js +34 -0
  30. package/build/blockchain/indexerSync.js.map +1 -0
  31. package/build/blockchain/types.d.ts +291 -49
  32. package/build/blockchain/types.js +27 -1
  33. package/build/blockchain/types.js.map +1 -1
  34. package/build/credentials/FullTailsFileService.d.ts +4 -4
  35. package/build/credentials/FullTailsFileService.js +78 -71
  36. package/build/credentials/FullTailsFileService.js.map +1 -1
  37. package/build/did/adminApiService.d.ts +2 -0
  38. package/build/did/adminApiService.js +17 -0
  39. package/build/did/adminApiService.js.map +1 -0
  40. package/build/did/migrateWebVhVersionTime.d.ts +9 -0
  41. package/build/did/migrateWebVhVersionTime.js +191 -0
  42. package/build/did/migrateWebVhVersionTime.js.map +1 -0
  43. package/build/events/VsAgentEvents.d.ts +16 -2
  44. package/build/events/VsAgentEvents.js +2 -0
  45. package/build/events/VsAgentEvents.js.map +1 -1
  46. package/build/events/VtFlowEvents.d.ts +3 -0
  47. package/build/events/VtFlowEvents.js +35 -0
  48. package/build/events/VtFlowEvents.js.map +1 -0
  49. package/build/events/index.d.ts +1 -0
  50. package/build/events/index.js +1 -0
  51. package/build/events/index.js.map +1 -1
  52. package/build/index.d.ts +4 -4
  53. package/build/index.js +9 -6
  54. package/build/index.js.map +1 -1
  55. package/build/plugins/setupBaseDidComm.d.ts +3 -1
  56. package/build/plugins/setupBaseDidComm.js +3 -1
  57. package/build/plugins/setupBaseDidComm.js.map +1 -1
  58. package/build/types.d.ts +2 -0
  59. package/build/types.js +3 -1
  60. package/build/types.js.map +1 -1
  61. package/build/utils/trustCredentialStore.js +2 -0
  62. package/build/utils/trustCredentialStore.js.map +1 -1
  63. package/build/utils/util.d.ts +5 -1
  64. package/build/utils/util.js +17 -5
  65. package/build/utils/util.js.map +1 -1
  66. package/build/vtFlow/VtFlowOrchestrator.d.ts +41 -0
  67. package/build/vtFlow/VtFlowOrchestrator.js +285 -0
  68. package/build/vtFlow/VtFlowOrchestrator.js.map +1 -0
  69. package/build/vtFlow/assertVerifiableService.d.ts +8 -0
  70. package/build/vtFlow/assertVerifiableService.js +28 -0
  71. package/build/vtFlow/assertVerifiableService.js.map +1 -0
  72. package/build/vtFlow/credentialDigest.d.ts +3 -0
  73. package/build/vtFlow/credentialDigest.js +23 -0
  74. package/build/vtFlow/credentialDigest.js.map +1 -0
  75. package/build/vtFlow/index.d.ts +2 -0
  76. package/build/vtFlow/index.js +19 -0
  77. package/build/vtFlow/index.js.map +1 -0
  78. package/package.json +16 -12
@@ -1 +1 @@
1
- {"version":3,"file":"util.js","sourceRoot":"","sources":["../../src/utils/util.ts"],"names":[],"mappings":";;;AA6IA,8BAMC;AAnJY,QAAA,oBAAoB,GAAG;;;2wBAGuuB,CAAA;AAE9vB,QAAA,kBAAkB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsIjC,CAAA;AAEM,KAAK,UAAU,SAAS,CAAI,GAAW;IAC5C,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,CAAA;IAC5B,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;QACZ,MAAM,IAAI,KAAK,CAAC,mBAAmB,GAAG,KAAK,GAAG,CAAC,UAAU,EAAE,CAAC,CAAA;IAC9D,CAAC;IACD,OAAO,GAAG,CAAC,IAAI,EAAgB,CAAA;AACjC,CAAC"}
1
+ {"version":3,"file":"util.js","sourceRoot":"","sources":["../../src/utils/util.ts"],"names":[],"mappings":";;;AAkJA,8BAkBC;AApKY,QAAA,oBAAoB,GAAG;;;2wBAGuuB,CAAA;AAE9vB,QAAA,kBAAkB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsIjC,CAAA;AAOM,KAAK,UAAU,SAAS,CAC7B,GAAW,EACX,GAA8D;IAE9D,MAAM,SAAS,GAAG,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,SAAS,CAAA;IAChE,MAAM,aAAa,GAAG,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,CAAC,aAAa,KAAK,IAAI,CAAA;IAC3E,MAAM,UAAU,GAAG,SAAS,CAAC,CAAC,CAAC,IAAI,eAAe,EAAE,CAAC,CAAC,CAAC,SAAS,CAAA;IAChE,MAAM,KAAK,GAAG,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,EAAE,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;IACtF,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAA;QACpF,IAAI,aAAa,IAAI,GAAG,CAAC,MAAM,KAAK,GAAG;YAAE,OAAO,SAAS,CAAA;QACzD,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;YACZ,MAAM,IAAI,KAAK,CAAC,mBAAmB,GAAG,KAAK,GAAG,CAAC,UAAU,EAAE,CAAC,CAAA;QAC9D,CAAC;QACD,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,CAAM,CAAA;IAChC,CAAC;YAAS,CAAC;QACT,IAAI,KAAK;YAAE,YAAY,CAAC,KAAK,CAAC,CAAA;IAChC,CAAC;AACH,CAAC"}
@@ -0,0 +1,41 @@
1
+ import { VtFlowRecord } from '@verana-labs/credo-ts-didcomm-vt-flow';
2
+ import { BaseAgentModules, VsAgent } from '../agent';
3
+ import { VeranaIndexerService } from '../blockchain/VeranaIndexerService';
4
+ export interface VtFlowOrchestratorOptions {
5
+ publicApiBaseUrl?: string;
6
+ indexer?: VeranaIndexerService;
7
+ }
8
+ export interface StartOnboardingProcessInput {
9
+ applicantParticipantId: number;
10
+ participantSessionId?: string;
11
+ claims?: Record<string, unknown>;
12
+ }
13
+ export interface ValidateAndOfferCredentialInput {
14
+ vtFlowRecordId: string;
15
+ credentialType?: string[];
16
+ credentialContext?: string[];
17
+ credentialSchemaId: string;
18
+ agentParticipantId?: number;
19
+ walletAgentParticipantId?: number;
20
+ }
21
+ export interface AcceptCredentialInput {
22
+ vtFlowRecordId: string;
23
+ }
24
+ export declare class VtFlowOrchestrator {
25
+ private readonly agent;
26
+ private readonly options;
27
+ constructor(agent: VsAgent<BaseAgentModules>, options?: VtFlowOrchestratorOptions);
28
+ startOnboardingProcess(input: StartOnboardingProcessInput): Promise<VtFlowRecord>;
29
+ validateAndOfferCredential(input: ValidateAndOfferCredentialInput): Promise<VtFlowRecord>;
30
+ acceptCredential(input: AcceptCredentialInput): Promise<VtFlowRecord>;
31
+ verifyOfferedCredential(vtFlowRecordId: string): Promise<void>;
32
+ onCredentialCompleted(vtFlowRecordId: string): Promise<void>;
33
+ private triggerResolver;
34
+ private getOfferedCredentialJson;
35
+ private requireIndexer;
36
+ publishCredentialAsLinkedVp(vtFlowRecordId: string): Promise<void>;
37
+ private extractSchemaBaseId;
38
+ rotateRequesterDidToPeer(connectionId: string): Promise<void>;
39
+ private resolveVtFlowApi;
40
+ private requireChain;
41
+ }
@@ -0,0 +1,285 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.VtFlowOrchestrator = void 0;
4
+ const core_1 = require("@credo-ts/core");
5
+ const credo_ts_didcomm_vt_flow_1 = require("@verana-labs/credo-ts-didcomm-vt-flow");
6
+ const types_1 = require("../blockchain/types");
7
+ const types_2 = require("../types");
8
+ const utils_1 = require("../utils");
9
+ const credentialDigest_1 = require("./credentialDigest");
10
+ class VtFlowOrchestrator {
11
+ constructor(agent, options = {}) {
12
+ this.agent = agent;
13
+ this.options = options;
14
+ }
15
+ async startOnboardingProcess(input) {
16
+ var _a, _b;
17
+ const chain = this.requireChain();
18
+ if (!this.agent.did)
19
+ throw new Error('Agent has no public DID');
20
+ const holderParticipant = await chain.getParticipant(input.applicantParticipantId);
21
+ if (!holderParticipant) {
22
+ throw new Error(`Applicant participant ${input.applicantParticipantId} not found on chain`);
23
+ }
24
+ if (holderParticipant.did !== this.agent.did) {
25
+ throw new Error(`Applicant participant ${input.applicantParticipantId} does not belong to this agent`);
26
+ }
27
+ if (holderParticipant.role !== types_2.ISSUER_PARTICIPANT_TYPE) {
28
+ throw new Error(`Participant ${input.applicantParticipantId} is not an ISSUER participant`);
29
+ }
30
+ if (!holderParticipant.validatorParticipantId) {
31
+ throw new Error(`Applicant participant ${input.applicantParticipantId} has no validator_participant_id`);
32
+ }
33
+ const validatorParticipant = await chain.getParticipant(Number(holderParticipant.validatorParticipantId));
34
+ if (!(validatorParticipant === null || validatorParticipant === void 0 ? void 0 : validatorParticipant.did)) {
35
+ throw new Error(`Validator participant ${holderParticipant.validatorParticipantId} not resolvable`);
36
+ }
37
+ if (validatorParticipant.revoked || validatorParticipant.slashed) {
38
+ throw new Error(`Validator participant ${validatorParticipant.id} is not active`);
39
+ }
40
+ // Renewals resend the OR with the same session id so the validator re-attaches the finished flow.
41
+ const vtFlowApi = this.resolveVtFlowApi();
42
+ const [latest] = (await vtFlowApi.findAllByQuery({
43
+ participantId: String(holderParticipant.id),
44
+ role: credo_ts_didcomm_vt_flow_1.VtFlowRole.Applicant,
45
+ flowVariant: credo_ts_didcomm_vt_flow_1.VtFlowVariant.OnboardingProcess,
46
+ }))
47
+ .filter(record => !(0, credo_ts_didcomm_vt_flow_1.isVtFlowTerminalState)(record.state))
48
+ .sort((a, b) => b.createdAt.getTime() - a.createdAt.getTime());
49
+ if (latest && latest.state !== credo_ts_didcomm_vt_flow_1.VtFlowState.Completed && latest.state !== credo_ts_didcomm_vt_flow_1.VtFlowState.CredRevoked) {
50
+ this.agent.config.logger.info(`[vt-flow] onboarding flow ${latest.id} for participant ${holderParticipant.id} is already in progress (state ${latest.state}); not resending`);
51
+ return latest;
52
+ }
53
+ const existing = latest;
54
+ let connectionId;
55
+ if (existing) {
56
+ const connection = await this.agent.didcomm.connections.findById(existing.connectionId);
57
+ if (connection === null || connection === void 0 ? void 0 : connection.isReady)
58
+ connectionId = connection.id;
59
+ }
60
+ if (!connectionId) {
61
+ const { connectionRecord } = await this.agent.didcomm.oob.receiveImplicitInvitation({
62
+ did: validatorParticipant.did,
63
+ ourDid: this.agent.did,
64
+ label: this.agent.label,
65
+ didCommVersion: 'v2',
66
+ });
67
+ if (!connectionRecord)
68
+ throw new Error('Failed to establish DIDComm connection to validator');
69
+ const ready = await this.agent.didcomm.connections.returnWhenIsConnected(connectionRecord.id);
70
+ connectionId = ready.id;
71
+ }
72
+ return vtFlowApi.sendOnboardingRequest({
73
+ connectionId,
74
+ participantSessionId: (_b = (_a = input.participantSessionId) !== null && _a !== void 0 ? _a : existing === null || existing === void 0 ? void 0 : existing.participantSessionId) !== null && _b !== void 0 ? _b : core_1.utils.uuid(),
75
+ participantId: String(holderParticipant.id),
76
+ agentParticipantId: '0',
77
+ walletAgentParticipantId: '0',
78
+ claims: input.claims,
79
+ });
80
+ }
81
+ async validateAndOfferCredential(input) {
82
+ var _a, _b, _c, _d, _e, _f;
83
+ const chain = this.requireChain();
84
+ if (!this.agent.did)
85
+ throw new Error('Agent has no public DID');
86
+ const vtFlowApi = this.resolveVtFlowApi();
87
+ const record = await vtFlowApi.findById(input.vtFlowRecordId);
88
+ if (!record)
89
+ throw new Error(`vt-flow record ${input.vtFlowRecordId} not found`);
90
+ if (record.role !== credo_ts_didcomm_vt_flow_1.VtFlowRole.Validator)
91
+ throw new Error('Record is not validator-side');
92
+ if (record.variant !== credo_ts_didcomm_vt_flow_1.VtFlowVariant.OnboardingProcess) {
93
+ throw new Error(`Record variant is '${record.variant}', expected OnboardingProcess`);
94
+ }
95
+ if (record.state !== credo_ts_didcomm_vt_flow_1.VtFlowState.AwaitingOr) {
96
+ throw new Error(`Record state is '${record.state}', expected '${credo_ts_didcomm_vt_flow_1.VtFlowState.AwaitingOr}'`);
97
+ }
98
+ if (!record.participantId)
99
+ throw new Error('Record has no participantId');
100
+ const holderParticipantId = Number(record.participantId);
101
+ const holderParticipant = await chain.getParticipant(holderParticipantId);
102
+ if (!holderParticipant)
103
+ throw new Error(`Holder participant ${holderParticipantId} not found on chain`);
104
+ if (!holderParticipant.did)
105
+ throw new Error('Holder participant has no DID');
106
+ const didRecords = await this.agent.dids.getCreatedDids({ did: this.agent.did });
107
+ const didRecord = didRecords[0];
108
+ if (!didRecord)
109
+ throw new Error('Agent DID record not found');
110
+ const schemaRef = `vpr:verana:${chain.getChainId}/cs/v1/js/${input.credentialSchemaId}`;
111
+ const { data } = await (0, utils_1.findMetadataEntry)(didRecord, '_vt/jsc', '', schemaRef);
112
+ const claims = ((_a = record.claims) !== null && _a !== void 0 ? _a : {});
113
+ const unsignedCredential = (0, utils_1.createCredential)({
114
+ id: `${this.agent.did}#${core_1.utils.uuid()}`,
115
+ type: (_b = input.credentialType) !== null && _b !== void 0 ? _b : ['VerifiableCredential', 'VerifiableTrustCredential'],
116
+ issuer: this.agent.did,
117
+ credentialSubject: { id: holderParticipant.did, claims },
118
+ });
119
+ if (input.credentialContext)
120
+ unsignedCredential.context = input.credentialContext;
121
+ unsignedCredential.credentialSchema = {
122
+ id: (_d = (_c = data.verifiableCredential) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.id,
123
+ type: 'JsonSchemaCredential',
124
+ };
125
+ const unsignedCredentialJson = core_1.JsonTransformer.toJSON(unsignedCredential);
126
+ const digest = (0, credentialDigest_1.credentialContentDigest)(unsignedCredentialJson);
127
+ // The chain requires a null op_summary_digest for HOLDER participants (MOD-PP-MSG-3).
128
+ await chain.setParticipantOPToValidated({
129
+ id: holderParticipantId,
130
+ opSummaryDigest: holderParticipant.role === types_2.HOLDER_PARTICIPANT_TYPE ? undefined : digest,
131
+ corporation: holderParticipant.corporation,
132
+ });
133
+ await chain.createOrUpdateParticipantSession({
134
+ id: record.participantSessionId,
135
+ issuerParticipantId: Number(holderParticipant.validatorParticipantId),
136
+ agentParticipantId: (_e = input.agentParticipantId) !== null && _e !== void 0 ? _e : 0,
137
+ walletAgentParticipantId: (_f = input.walletAgentParticipantId) !== null && _f !== void 0 ? _f : 0,
138
+ digest,
139
+ });
140
+ await vtFlowApi.acceptOnboardingRequest(record.id);
141
+ await vtFlowApi.markValidated(record.id);
142
+ const { record: offered } = await vtFlowApi.offerCredentialForSession({
143
+ vtFlowRecordId: record.id,
144
+ credentialFormats: {
145
+ jsonld: {
146
+ credential: unsignedCredentialJson,
147
+ options: { proofType: 'Ed25519Signature2020', proofPurpose: 'assertionMethod' },
148
+ },
149
+ },
150
+ });
151
+ return offered;
152
+ }
153
+ async acceptCredential(input) {
154
+ const vtFlowApi = this.resolveVtFlowApi();
155
+ const record = await vtFlowApi.findById(input.vtFlowRecordId);
156
+ if (!record)
157
+ throw new Error(`vt-flow record ${input.vtFlowRecordId} not found`);
158
+ if (record.role !== credo_ts_didcomm_vt_flow_1.VtFlowRole.Applicant)
159
+ throw new Error('Record is not applicant-side');
160
+ if (record.state !== credo_ts_didcomm_vt_flow_1.VtFlowState.CredOffered) {
161
+ throw new Error(`Record state is '${record.state}', expected '${credo_ts_didcomm_vt_flow_1.VtFlowState.CredOffered}'`);
162
+ }
163
+ await this.verifyOfferedCredential(input.vtFlowRecordId);
164
+ return vtFlowApi.acceptReceivedCredential(input.vtFlowRecordId);
165
+ }
166
+ async verifyOfferedCredential(vtFlowRecordId) {
167
+ var _a, _b;
168
+ const vtFlowApi = this.resolveVtFlowApi();
169
+ const record = await vtFlowApi.findById(vtFlowRecordId);
170
+ if (!record)
171
+ throw new Error(`vt-flow record ${vtFlowRecordId} not found`);
172
+ if (record.role !== credo_ts_didcomm_vt_flow_1.VtFlowRole.Applicant)
173
+ throw new Error('Record is not applicant-side');
174
+ if (!record.credentialExchangeRecordId) {
175
+ throw new Error('Record has no credentialExchangeRecordId; nothing to verify');
176
+ }
177
+ const indexer = this.requireIndexer();
178
+ const session = await indexer.getParticipantSession(record.participantSessionId);
179
+ if (!session) {
180
+ throw new Error(`ParticipantSession ${record.participantSessionId} not found on indexer`);
181
+ }
182
+ const issuerParticipantId = (_b = (_a = session.session_records) === null || _a === void 0 ? void 0 : _a.find(r => r.issuer_participant_id != null)) === null || _b === void 0 ? void 0 : _b.issuer_participant_id;
183
+ if (issuerParticipantId == null) {
184
+ throw new Error(`ParticipantSession ${record.participantSessionId} has no issuer_participant_id`);
185
+ }
186
+ const issuer = await indexer.getParticipant(issuerParticipantId);
187
+ if (!issuer)
188
+ throw new Error(`Issuer participant ${issuerParticipantId} not found on indexer`);
189
+ if (issuer.role !== types_1.ParticipantRole.Issuer) {
190
+ throw new Error(`Issuer participant ${issuerParticipantId} is not an ISSUER (role=${issuer.role})`);
191
+ }
192
+ if (issuer.participant_state !== types_1.ParticipantState.Active) {
193
+ throw new Error(`Issuer participant ${issuerParticipantId} is not active (state=${issuer.participant_state})`);
194
+ }
195
+ if (record.schemaId != null && Number(issuer.schema_id) !== Number(record.schemaId)) {
196
+ throw new Error(`Issuer participant schema ${issuer.schema_id} does not match credential schema ${record.schemaId}`);
197
+ }
198
+ const credentialJson = await this.getOfferedCredentialJson(record.credentialExchangeRecordId);
199
+ const digest = (0, credentialDigest_1.credentialContentDigest)(credentialJson);
200
+ const anchored = await indexer.getDigest(digest);
201
+ if (!anchored) {
202
+ throw new Error(`Credential digest ${digest} is not anchored on-chain`);
203
+ }
204
+ }
205
+ async onCredentialCompleted(vtFlowRecordId) {
206
+ const vtFlowApi = this.resolveVtFlowApi();
207
+ const record = await vtFlowApi.findById(vtFlowRecordId);
208
+ if (!record)
209
+ return;
210
+ if (record.role !== credo_ts_didcomm_vt_flow_1.VtFlowRole.Applicant)
211
+ return;
212
+ if (!this.options.publicApiBaseUrl)
213
+ return;
214
+ await this.publishCredentialAsLinkedVp(vtFlowRecordId);
215
+ await this.triggerResolver(record);
216
+ }
217
+ async triggerResolver(record) {
218
+ const chain = this.agent.veranaChain;
219
+ if (!chain || !chain.autoTriggerResolverEnabled)
220
+ return;
221
+ if (record.participantId == null)
222
+ return;
223
+ await chain.triggerResolver(Number(record.participantId));
224
+ }
225
+ async getOfferedCredentialJson(credentialExchangeRecordId) {
226
+ var _a;
227
+ const formatData = await this.agent.didcomm.credentials.getFormatData(credentialExchangeRecordId);
228
+ const credentialJson = (_a = formatData.credential) === null || _a === void 0 ? void 0 : _a.jsonld;
229
+ if (!credentialJson)
230
+ throw new Error('Offered credential has no JSON-LD body to verify');
231
+ return credentialJson;
232
+ }
233
+ requireIndexer() {
234
+ if (!this.options.indexer) {
235
+ throw new Error('Agent has no indexer configured (set VERANA_INDEXER_BASE_URL)');
236
+ }
237
+ return this.options.indexer;
238
+ }
239
+ async publishCredentialAsLinkedVp(vtFlowRecordId) {
240
+ var _a, _b;
241
+ if (!this.options.publicApiBaseUrl) {
242
+ throw new Error('publicApiBaseUrl is required to publish a LinkedVerifiablePresentation');
243
+ }
244
+ const vtFlowApi = this.resolveVtFlowApi();
245
+ const record = await vtFlowApi.findById(vtFlowRecordId);
246
+ if (!record)
247
+ throw new Error(`vt-flow record ${vtFlowRecordId} not found`);
248
+ if (record.role !== credo_ts_didcomm_vt_flow_1.VtFlowRole.Applicant)
249
+ throw new Error('Record is not applicant-side');
250
+ if (!record.credentialExchangeRecordId) {
251
+ throw new Error(`vt-flow record ${vtFlowRecordId} has no credentialExchangeRecordId`);
252
+ }
253
+ const formatData = await this.agent.didcomm.credentials.getFormatData(record.credentialExchangeRecordId);
254
+ const jsonld = (_a = formatData.credential) === null || _a === void 0 ? void 0 : _a.jsonld;
255
+ if (!jsonld) {
256
+ throw new Error(`No jsonld credential in exchange ${record.credentialExchangeRecordId}`);
257
+ }
258
+ const schemaRef = (_b = jsonld.credentialSchema) === null || _b === void 0 ? void 0 : _b.id;
259
+ const schemaBaseId = schemaRef ? this.extractSchemaBaseId(schemaRef) : undefined;
260
+ if (!schemaBaseId) {
261
+ throw new Error(`Cannot publish Linked VP: credential has no extractable schema base id (credentialSchema.id=${schemaRef !== null && schemaRef !== void 0 ? schemaRef : 'undefined'})`);
262
+ }
263
+ const w3cCredential = core_1.JsonTransformer.fromJSON(jsonld, core_1.W3cJsonLdVerifiableCredential);
264
+ await (0, utils_1.createVtc)(this.agent, this.options.publicApiBaseUrl, schemaBaseId, w3cCredential);
265
+ }
266
+ extractSchemaBaseId(jscUrl) {
267
+ var _a;
268
+ const match = jscUrl.match(/schemas-([a-z0-9-]+?)-(?:jsc|c-vp)\.json/i);
269
+ return (_a = match === null || match === void 0 ? void 0 : match[1]) === null || _a === void 0 ? void 0 : _a.toLowerCase();
270
+ }
271
+ async rotateRequesterDidToPeer(connectionId) {
272
+ await this.agent.didcomm.connections.rotate({ connectionId });
273
+ }
274
+ resolveVtFlowApi() {
275
+ return this.agent.dependencyManager.resolve(credo_ts_didcomm_vt_flow_1.VtFlowApi);
276
+ }
277
+ requireChain() {
278
+ if (!this.agent.veranaChain) {
279
+ throw new Error('Agent has no veranaChain configured');
280
+ }
281
+ return this.agent.veranaChain;
282
+ }
283
+ }
284
+ exports.VtFlowOrchestrator = VtFlowOrchestrator;
285
+ //# sourceMappingURL=VtFlowOrchestrator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"VtFlowOrchestrator.js","sourceRoot":"","sources":["../../src/vtFlow/VtFlowOrchestrator.ts"],"names":[],"mappings":";;;AAEA,yCAAsF;AAEtF,oFAO8C;AAI9C,+CAAuE;AACvE,oCAA2E;AAC3E,oCAAyE;AAEzE,yDAA4D;AA0B5D,MAAa,kBAAkB;IAC7B,YACmB,KAAgC,EAChC,UAAqC,EAAE;QADvC,UAAK,GAAL,KAAK,CAA2B;QAChC,YAAO,GAAP,OAAO,CAAgC;IACvD,CAAC;IAEJ,KAAK,CAAC,sBAAsB,CAAC,KAA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,CAAC,CAAC,CAAC,SAAS,CAAA;QAChF,IAAI,CAAC,YAAY,EAAE,CAAC;YAClB,MAAM,IAAI,KAAK,CACb,+FAA+F,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,WAAW,GAAG,CAC3H,CAAA;QACH,CAAC;QACD,MAAM,aAAa,GAAG,sBAAe,CAAC,QAAQ,CAAC,MAAM,EAAE,oCAA6B,CAAC,CAAA;QACrF,MAAM,IAAA,iBAAS,EAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,gBAAgB,EAAE,YAAY,EAAE,aAAa,CAAC,CAAA;IACzF,CAAC;IAEO,mBAAmB,CAAC,MAAc;;QACxC,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,2CAA2C,CAAC,CAAA;QACvE,OAAO,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAG,CAAC,CAAC,0CAAE,WAAW,EAAE,CAAA;IAClC,CAAC;IAED,KAAK,CAAC,wBAAwB,CAAC,YAAoB;QACjD,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,MAAM,CAAC,EAAE,YAAY,EAAE,CAAC,CAAA;IAC/D,CAAC;IAEO,gBAAgB;QACtB,OAAO,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,OAAO,CAAC,oCAAS,CAAC,CAAA;IACxD,CAAC;IAEO,YAAY;QAClB,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC;YAC5B,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAA;QACxD,CAAC;QACD,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,CAAA;IAC/B,CAAC;CACF;AApSD,gDAoSC"}
@@ -0,0 +1,8 @@
1
+ import type { BaseLogger } from '@credo-ts/core';
2
+ import type { VtFlowAssertVerifiableServiceHook } from '@verana-labs/credo-ts-didcomm-vt-flow';
3
+ import type { ResolverConfig } from '@verana-labs/verre';
4
+ export interface AssertVerifiableServiceOptions {
5
+ verifiablePublicRegistries: NonNullable<ResolverConfig['verifiablePublicRegistries']>;
6
+ logger?: BaseLogger;
7
+ }
8
+ export declare function assertVerifiableService(options: AssertVerifiableServiceOptions): VtFlowAssertVerifiableServiceHook;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.assertVerifiableService = assertVerifiableService;
4
+ const verre_1 = require("@verana-labs/verre");
5
+ // VS-CONN-VS gate: delegates trust resolution to `@verana-labs/verre` (`resolveDID`)
6
+ function assertVerifiableService(options) {
7
+ let cache;
8
+ return async ({ agentContext, peerDid }) => {
9
+ var _a, _b;
10
+ const logger = (_a = options.logger) !== null && _a !== void 0 ? _a : agentContext.config.logger;
11
+ try {
12
+ cache !== null && cache !== void 0 ? cache : (cache = new verre_1.InMemoryCache());
13
+ const { verified, outcome, metadata } = await (0, verre_1.resolveDID)(peerDid, {
14
+ verifiablePublicRegistries: options.verifiablePublicRegistries,
15
+ cache,
16
+ });
17
+ if (!verified) {
18
+ logger.warn(`[vt-flow] VS-CONN-VS rejected '${peerDid}': ${outcome} ${(_b = metadata === null || metadata === void 0 ? void 0 : metadata.errorMessage) !== null && _b !== void 0 ? _b : ''}`);
19
+ }
20
+ return verified;
21
+ }
22
+ catch (error) {
23
+ logger.warn(`[vt-flow] VS-CONN-VS resolution failed for '${peerDid}': ${error.message}`);
24
+ return false;
25
+ }
26
+ };
27
+ }
28
+ //# sourceMappingURL=assertVerifiableService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assertVerifiableService.js","sourceRoot":"","sources":["../../src/vtFlow/assertVerifiableService.ts"],"names":[],"mappings":";;AAYA,0DAqBC;AA7BD,8CAA8D;AAO9D,qFAAqF;AACrF,SAAgB,uBAAuB,CACrC,OAAuC;IAEvC,IAAI,KAA8B,CAAA;IAClC,OAAO,KAAK,EAAE,EAAE,YAAY,EAAE,OAAO,EAAE,EAAE,EAAE;;QACzC,MAAM,MAAM,GAAG,MAAA,OAAO,CAAC,MAAM,mCAAI,YAAY,CAAC,MAAM,CAAC,MAAM,CAAA;QAC3D,IAAI,CAAC;YACH,KAAK,aAAL,KAAK,cAAL,KAAK,IAAL,KAAK,GAAK,IAAI,qBAAa,EAAE,EAAA;YAC7B,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,MAAM,IAAA,kBAAU,EAAC,OAAO,EAAE;gBAChE,0BAA0B,EAAE,OAAO,CAAC,0BAA0B;gBAC9D,KAAK;aACN,CAAC,CAAA;YACF,IAAI,CAAC,QAAQ,EAAE,CAAC;gBACd,MAAM,CAAC,IAAI,CAAC,kCAAkC,OAAO,MAAM,OAAO,IAAI,MAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,YAAY,mCAAI,EAAE,EAAE,CAAC,CAAA;YACvG,CAAC;YACD,OAAO,QAAQ,CAAA;QACjB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,CAAC,IAAI,CAAC,+CAA+C,OAAO,MAAO,KAAe,CAAC,OAAO,EAAE,CAAC,CAAA;YACnG,OAAO,KAAK,CAAA;QACd,CAAC;IACH,CAAC,CAAA;AACH,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { type JsonCredential } from '@credo-ts/didcomm';
2
+ export declare function canonicalJson(value: unknown): string;
3
+ export declare function credentialContentDigest(credential: JsonCredential): string;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.canonicalJson = canonicalJson;
4
+ exports.credentialContentDigest = credentialContentDigest;
5
+ const utils_1 = require("../utils");
6
+ function canonicalJson(value) {
7
+ if (value === null || typeof value !== 'object')
8
+ return JSON.stringify(value);
9
+ if (Array.isArray(value))
10
+ return `[${value.map(canonicalJson).join(',')}]`;
11
+ const obj = value;
12
+ return `{${Object.keys(obj)
13
+ .sort()
14
+ .map(k => `${JSON.stringify(k)}:${canonicalJson(obj[k])}`)
15
+ .join(',')}}`;
16
+ }
17
+ // Excludes the proof so re-signing at issuance (new proof bytes) does not change the digest.
18
+ function credentialContentDigest(credential) {
19
+ const content = Object.assign({}, credential);
20
+ delete content.proof;
21
+ return (0, utils_1.generateDigestSRI)(canonicalJson(content));
22
+ }
23
+ //# sourceMappingURL=credentialDigest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"credentialDigest.js","sourceRoot":"","sources":["../../src/vtFlow/credentialDigest.ts"],"names":[],"mappings":";;AAIA,sCAQC;AAGD,0DAIC;AAjBD,oCAA4C;AAE5C,SAAgB,aAAa,CAAC,KAAc;IAC1C,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAA;IAC7E,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,IAAI,KAAK,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAA;IAC1E,MAAM,GAAG,GAAG,KAAgC,CAAA;IAC5C,OAAO,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;SACxB,IAAI,EAAE;SACN,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;SACzD,IAAI,CAAC,GAAG,CAAC,GAAG,CAAA;AACjB,CAAC;AAED,6FAA6F;AAC7F,SAAgB,uBAAuB,CAAC,UAA0B;IAChE,MAAM,OAAO,qBAAQ,UAAU,CAAE,CAAA;IACjC,OAAO,OAAO,CAAC,KAAK,CAAA;IACpB,OAAO,IAAA,yBAAiB,EAAC,aAAa,CAAC,OAAO,CAAC,CAAC,CAAA;AAClD,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './VtFlowOrchestrator';
2
+ export * from './assertVerifiableService';
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./VtFlowOrchestrator"), exports);
18
+ __exportStar(require("./assertVerifiableService"), exports);
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/vtFlow/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uDAAoC;AACpC,4DAAyC"}
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "default": "./build/index.js"
10
10
  }
11
11
  },
12
- "version": "1.12.0-dev.2",
12
+ "version": "1.12.0-dev.21",
13
13
  "repository": {
14
14
  "type": "git",
15
15
  "url": "https://github.com/verana-labs/vs-agent"
@@ -26,28 +26,31 @@
26
26
  "@cosmjs/proto-signing": "^0.32.3",
27
27
  "@cosmjs/stargate": "^0.32.3",
28
28
  "@cosmjs/tendermint-rpc": "^0.32.4",
29
- "@credo-ts/anoncreds": "0.7.1-pr-2704-20260610194233",
30
- "@credo-ts/askar": "0.7.1-pr-2704-20260610194233",
31
- "@credo-ts/core": "0.7.1-pr-2704-20260610194233",
32
- "@credo-ts/didcomm": "0.7.1-pr-2704-20260610194233",
33
- "@credo-ts/webvh": "0.7.1-pr-2704-20260610194233",
29
+ "@credo-ts/anoncreds": "0.7.1-pr-2704-20260630143332",
30
+ "@credo-ts/askar": "0.7.1-pr-2704-20260630143332",
31
+ "@credo-ts/core": "0.7.1-pr-2704-20260630143332",
32
+ "@credo-ts/didcomm": "0.7.1-pr-2704-20260630143332",
33
+ "@credo-ts/webvh": "0.7.1-pr-2704-20260630143332",
34
34
  "@hyperledger/anoncreds-nodejs": "^0.4.0",
35
35
  "@openwallet-foundation/askar-nodejs": "^0.6.0",
36
- "@verana-labs/verana-types": "0.10.1-dev.11",
36
+ "@verana-labs/verana-types": "0.10.1-dev.16",
37
+ "@verana-labs/verre": "0.3.2-dev.1",
37
38
  "ajv": "^8.17.1",
38
39
  "ajv-formats": "^3.0.1",
39
40
  "axios": "^1.7.9",
40
41
  "credo-ts-didweb-anoncreds": "0.0.2-alpha.5",
41
- "didwebvh-ts": "^2.7.4",
42
+ "didwebvh-ts": "^2.8.0",
42
43
  "express": "^4.18.1",
43
44
  "tsyringe": "4.8.0",
44
- "@verana-labs/vs-agent-model": "1.12.0-dev.2"
45
+ "@verana-labs/credo-ts-didcomm-vt-flow": "1.12.0-dev.21",
46
+ "@verana-labs/vs-agent-model": "1.12.0-dev.21"
45
47
  },
46
48
  "peerDependencies": {
47
- "@credo-ts/core": "0.7.1-pr-2704-20260610194233",
48
- "@credo-ts/node": "0.7.1-pr-2704-20260610194233"
49
+ "@credo-ts/core": "0.7.1-pr-2704-20260630143332",
50
+ "@credo-ts/node": "0.7.1-pr-2704-20260630143332"
49
51
  },
50
52
  "devDependencies": {
53
+ "testcontainers": "^12.0.3",
51
54
  "ts-node-dev": "^2.0.0"
52
55
  },
53
56
  "scripts": {
@@ -55,6 +58,7 @@
55
58
  "clean": "rimraf -rf ./build",
56
59
  "compile": "tsc -p tsconfig.build.json",
57
60
  "version": "pnpm version --allow-same-version",
58
- "test": "vitest"
61
+ "test": "vitest",
62
+ "test:e2e": "RUN_FLOW_E2E=1 vitest run tests/e2e"
59
63
  }
60
64
  }