@credo-ts/anoncreds 0.6.0-pr-2143-20250106173054 → 0.6.0-pr-2195-20250217183709
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/AnonCredsApi.js +7 -4
- package/build/AnonCredsApi.js.map +1 -1
- package/build/AnonCredsModuleConfig.js +2 -4
- package/build/AnonCredsModuleConfig.js.map +1 -1
- package/build/anoncreds-rs/AnonCredsDataIntegrityService.js +13 -14
- package/build/anoncreds-rs/AnonCredsDataIntegrityService.js.map +1 -1
- package/build/anoncreds-rs/AnonCredsRsHolderService.js +22 -28
- package/build/anoncreds-rs/AnonCredsRsHolderService.js.map +1 -1
- package/build/anoncreds-rs/AnonCredsRsIssuerService.js +23 -17
- package/build/anoncreds-rs/AnonCredsRsIssuerService.js.map +1 -1
- package/build/anoncreds-rs/AnonCredsRsVerifierService.js +6 -7
- package/build/anoncreds-rs/AnonCredsRsVerifierService.js.map +1 -1
- package/build/anoncreds-rs/utils.js +3 -3
- package/build/anoncreds-rs/utils.js.map +1 -1
- package/build/formats/AnonCredsCredentialFormat.d.ts +1 -1
- package/build/formats/AnonCredsCredentialFormatService.d.ts +3 -2
- package/build/formats/AnonCredsCredentialFormatService.js +26 -39
- package/build/formats/AnonCredsCredentialFormatService.js.map +1 -1
- package/build/formats/AnonCredsProofFormat.d.ts +1 -1
- package/build/formats/AnonCredsProofFormatService.d.ts +2 -1
- package/build/formats/AnonCredsProofFormatService.js +26 -27
- package/build/formats/AnonCredsProofFormatService.js.map +1 -1
- package/build/formats/DataIntegrityCredentialFormatService.d.ts +3 -2
- package/build/formats/DataIntegrityCredentialFormatService.js +82 -83
- package/build/formats/DataIntegrityCredentialFormatService.js.map +1 -1
- package/build/formats/LegacyIndyCredentialFormat.d.ts +1 -1
- package/build/formats/LegacyIndyCredentialFormatService.d.ts +3 -2
- package/build/formats/LegacyIndyCredentialFormatService.js +19 -32
- package/build/formats/LegacyIndyCredentialFormatService.js.map +1 -1
- package/build/formats/LegacyIndyProofFormat.d.ts +1 -1
- package/build/formats/LegacyIndyProofFormatService.d.ts +2 -1
- package/build/formats/LegacyIndyProofFormatService.js +28 -30
- package/build/formats/LegacyIndyProofFormatService.js.map +1 -1
- package/build/models/AnonCredsProofRequest.js +2 -3
- package/build/models/AnonCredsProofRequest.js.map +1 -1
- package/build/models/AnonCredsRequestedAttribute.js +1 -2
- package/build/models/AnonCredsRequestedAttribute.js.map +1 -1
- package/build/models/AnonCredsRequestedPredicate.js +1 -2
- package/build/models/AnonCredsRequestedPredicate.js.map +1 -1
- package/build/models/AnonCredsRestriction.js +2 -3
- package/build/models/AnonCredsRestriction.js.map +1 -1
- package/build/protocols/credentials/v1/V1CredentialProtocol.d.ts +4 -3
- package/build/protocols/credentials/v1/V1CredentialProtocol.js +159 -155
- package/build/protocols/credentials/v1/V1CredentialProtocol.js.map +1 -1
- package/build/protocols/credentials/v1/errors/V1CredentialProblemReportError.d.ts +2 -2
- package/build/protocols/credentials/v1/errors/V1CredentialProblemReportError.js +2 -2
- package/build/protocols/credentials/v1/errors/V1CredentialProblemReportError.js.map +1 -1
- package/build/protocols/credentials/v1/handlers/V1CredentialAckHandler.d.ts +1 -1
- package/build/protocols/credentials/v1/handlers/V1CredentialProblemReportHandler.d.ts +1 -1
- package/build/protocols/credentials/v1/handlers/V1IssueCredentialHandler.d.ts +2 -2
- package/build/protocols/credentials/v1/handlers/V1IssueCredentialHandler.js +2 -1
- package/build/protocols/credentials/v1/handlers/V1IssueCredentialHandler.js.map +1 -1
- package/build/protocols/credentials/v1/handlers/V1OfferCredentialHandler.d.ts +2 -2
- package/build/protocols/credentials/v1/handlers/V1OfferCredentialHandler.js +2 -2
- package/build/protocols/credentials/v1/handlers/V1OfferCredentialHandler.js.map +1 -1
- package/build/protocols/credentials/v1/handlers/V1ProposeCredentialHandler.d.ts +2 -2
- package/build/protocols/credentials/v1/handlers/V1ProposeCredentialHandler.js +2 -2
- package/build/protocols/credentials/v1/handlers/V1ProposeCredentialHandler.js.map +1 -1
- package/build/protocols/credentials/v1/handlers/V1RequestCredentialHandler.d.ts +2 -2
- package/build/protocols/credentials/v1/handlers/V1RequestCredentialHandler.js +2 -1
- package/build/protocols/credentials/v1/handlers/V1RequestCredentialHandler.js.map +1 -1
- package/build/protocols/credentials/v1/messages/V1CredentialAckMessage.d.ts +3 -3
- package/build/protocols/credentials/v1/messages/V1CredentialAckMessage.js +4 -4
- package/build/protocols/credentials/v1/messages/V1CredentialAckMessage.js.map +1 -1
- package/build/protocols/credentials/v1/messages/V1CredentialPreview.d.ts +3 -3
- package/build/protocols/credentials/v1/messages/V1CredentialPreview.js +8 -7
- package/build/protocols/credentials/v1/messages/V1CredentialPreview.js.map +1 -1
- package/build/protocols/credentials/v1/messages/V1CredentialProblemReportMessage.d.ts +3 -3
- package/build/protocols/credentials/v1/messages/V1CredentialProblemReportMessage.js +4 -4
- package/build/protocols/credentials/v1/messages/V1CredentialProblemReportMessage.js.map +1 -1
- package/build/protocols/credentials/v1/messages/V1IssueCredentialMessage.d.ts +2 -2
- package/build/protocols/credentials/v1/messages/V1IssueCredentialMessage.js +8 -10
- package/build/protocols/credentials/v1/messages/V1IssueCredentialMessage.js.map +1 -1
- package/build/protocols/credentials/v1/messages/V1OfferCredentialMessage.d.ts +2 -2
- package/build/protocols/credentials/v1/messages/V1OfferCredentialMessage.js +7 -8
- package/build/protocols/credentials/v1/messages/V1OfferCredentialMessage.js.map +1 -1
- package/build/protocols/credentials/v1/messages/V1ProposeCredentialMessage.d.ts +3 -3
- package/build/protocols/credentials/v1/messages/V1ProposeCredentialMessage.js +5 -6
- package/build/protocols/credentials/v1/messages/V1ProposeCredentialMessage.js.map +1 -1
- package/build/protocols/credentials/v1/messages/V1RequestCredentialMessage.d.ts +2 -2
- package/build/protocols/credentials/v1/messages/V1RequestCredentialMessage.js +7 -8
- package/build/protocols/credentials/v1/messages/V1RequestCredentialMessage.js.map +1 -1
- package/build/protocols/proofs/v1/V1ProofProtocol.d.ts +4 -3
- package/build/protocols/proofs/v1/V1ProofProtocol.js +147 -156
- package/build/protocols/proofs/v1/V1ProofProtocol.js.map +1 -1
- package/build/protocols/proofs/v1/errors/V1PresentationProblemReportError.d.ts +2 -2
- package/build/protocols/proofs/v1/errors/V1PresentationProblemReportError.js +2 -2
- package/build/protocols/proofs/v1/errors/V1PresentationProblemReportError.js.map +1 -1
- package/build/protocols/proofs/v1/handlers/V1PresentationAckHandler.d.ts +1 -1
- package/build/protocols/proofs/v1/handlers/V1PresentationHandler.d.ts +2 -2
- package/build/protocols/proofs/v1/handlers/V1PresentationHandler.js +2 -1
- package/build/protocols/proofs/v1/handlers/V1PresentationHandler.js.map +1 -1
- package/build/protocols/proofs/v1/handlers/V1PresentationProblemReportHandler.d.ts +1 -1
- package/build/protocols/proofs/v1/handlers/V1ProposePresentationHandler.d.ts +2 -2
- package/build/protocols/proofs/v1/handlers/V1ProposePresentationHandler.js +2 -2
- package/build/protocols/proofs/v1/handlers/V1ProposePresentationHandler.js.map +1 -1
- package/build/protocols/proofs/v1/handlers/V1RequestPresentationHandler.d.ts +2 -2
- package/build/protocols/proofs/v1/handlers/V1RequestPresentationHandler.js +2 -2
- package/build/protocols/proofs/v1/handlers/V1RequestPresentationHandler.js.map +1 -1
- package/build/protocols/proofs/v1/messages/V1PresentationAckMessage.d.ts +3 -3
- package/build/protocols/proofs/v1/messages/V1PresentationAckMessage.js +4 -4
- package/build/protocols/proofs/v1/messages/V1PresentationAckMessage.js.map +1 -1
- package/build/protocols/proofs/v1/messages/V1PresentationMessage.d.ts +2 -2
- package/build/protocols/proofs/v1/messages/V1PresentationMessage.js +9 -11
- package/build/protocols/proofs/v1/messages/V1PresentationMessage.js.map +1 -1
- package/build/protocols/proofs/v1/messages/V1PresentationProblemReportMessage.d.ts +3 -3
- package/build/protocols/proofs/v1/messages/V1PresentationProblemReportMessage.js +4 -4
- package/build/protocols/proofs/v1/messages/V1PresentationProblemReportMessage.js.map +1 -1
- package/build/protocols/proofs/v1/messages/V1ProposePresentationMessage.d.ts +2 -2
- package/build/protocols/proofs/v1/messages/V1ProposePresentationMessage.js +5 -6
- package/build/protocols/proofs/v1/messages/V1ProposePresentationMessage.js.map +1 -1
- package/build/protocols/proofs/v1/messages/V1RequestPresentationMessage.d.ts +2 -2
- package/build/protocols/proofs/v1/messages/V1RequestPresentationMessage.js +8 -10
- package/build/protocols/proofs/v1/messages/V1RequestPresentationMessage.js.map +1 -1
- package/build/protocols/proofs/v1/models/V1PresentationPreview.d.ts +1 -1
- package/build/protocols/proofs/v1/models/V1PresentationPreview.js +6 -6
- package/build/protocols/proofs/v1/models/V1PresentationPreview.js.map +1 -1
- package/build/repository/AnonCredsCredentialDefinitionPrivateRecord.js +6 -4
- package/build/repository/AnonCredsCredentialDefinitionPrivateRecord.js.map +1 -1
- package/build/repository/AnonCredsCredentialDefinitionRecord.js +11 -4
- package/build/repository/AnonCredsCredentialDefinitionRecord.js.map +1 -1
- package/build/repository/AnonCredsCredentialRecord.js +12 -4
- package/build/repository/AnonCredsCredentialRecord.js.map +1 -1
- package/build/repository/AnonCredsKeyCorrectnessProofRecord.js +6 -4
- package/build/repository/AnonCredsKeyCorrectnessProofRecord.js.map +1 -1
- package/build/repository/AnonCredsLinkSecretRecord.js +5 -3
- package/build/repository/AnonCredsLinkSecretRecord.js.map +1 -1
- package/build/repository/AnonCredsRevocationRegistryDefinitionPrivateRecord.js +8 -4
- package/build/repository/AnonCredsRevocationRegistryDefinitionPrivateRecord.js.map +1 -1
- package/build/repository/AnonCredsRevocationRegistryDefinitionRecord.js +7 -4
- package/build/repository/AnonCredsRevocationRegistryDefinitionRecord.js.map +1 -1
- package/build/repository/AnonCredsSchemaRecord.js +11 -4
- package/build/repository/AnonCredsSchemaRecord.js.map +1 -1
- package/build/services/tails/BasicTailsFileService.js +2 -3
- package/build/services/tails/BasicTailsFileService.js.map +1 -1
- package/build/updates/0.3.1-0.4/credentialExchangeRecord.d.ts +2 -1
- package/build/updates/0.3.1-0.4/credentialExchangeRecord.js +2 -2
- package/build/updates/0.3.1-0.4/credentialExchangeRecord.js.map +1 -1
- package/build/updates/0.3.1-0.4/linkSecret.js +2 -3
- package/build/updates/0.3.1-0.4/linkSecret.js.map +1 -1
- package/build/updates/0.4-0.5/anonCredsCredentialRecord.js +4 -4
- package/build/updates/0.4-0.5/anonCredsCredentialRecord.js.map +1 -1
- package/build/utils/bytesToBigint.d.ts +1 -0
- package/build/utils/bytesToBigint.js +14 -0
- package/build/utils/bytesToBigint.js.map +1 -0
- package/build/utils/composeAutoAccept.d.ts +1 -1
- package/build/utils/composeAutoAccept.js +3 -5
- package/build/utils/composeAutoAccept.js.map +1 -1
- package/build/utils/createRequestFromPreview.js +3 -4
- package/build/utils/createRequestFromPreview.js.map +1 -1
- package/build/utils/credential.d.ts +1 -1
- package/build/utils/credential.js +10 -10
- package/build/utils/credential.js.map +1 -1
- package/build/utils/credentialPreviewAttributes.d.ts +1 -1
- package/build/utils/credentialPreviewAttributes.js +1 -1
- package/build/utils/credentialPreviewAttributes.js.map +1 -1
- package/build/utils/getCredentialsForAnonCredsRequest.js +2 -3
- package/build/utils/getCredentialsForAnonCredsRequest.js.map +1 -1
- package/build/utils/getRevocationRegistries.js +13 -5
- package/build/utils/getRevocationRegistries.js.map +1 -1
- package/build/utils/indyIdentifiers.js +23 -12
- package/build/utils/indyIdentifiers.js.map +1 -1
- package/build/utils/proofRequest.js +7 -10
- package/build/utils/proofRequest.js.map +1 -1
- package/build/utils/w3cAnonCredsUtils.js +29 -21
- package/build/utils/w3cAnonCredsUtils.js.map +1 -1
- package/package.json +4 -5
|
@@ -2,11 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.V1CredentialProtocol = void 0;
|
|
4
4
|
const core_1 = require("@credo-ts/core");
|
|
5
|
+
const didcomm_1 = require("@credo-ts/didcomm");
|
|
5
6
|
const AnonCredsCredentialProposal_1 = require("../../../models/AnonCredsCredentialProposal");
|
|
6
7
|
const utils_1 = require("../../../utils");
|
|
7
8
|
const handlers_1 = require("./handlers");
|
|
8
9
|
const messages_1 = require("./messages");
|
|
9
|
-
class V1CredentialProtocol extends
|
|
10
|
+
class V1CredentialProtocol extends didcomm_1.BaseCredentialProtocol {
|
|
10
11
|
constructor({ indyCredentialFormat }) {
|
|
11
12
|
super();
|
|
12
13
|
/**
|
|
@@ -19,9 +20,9 @@ class V1CredentialProtocol extends core_1.BaseCredentialProtocol {
|
|
|
19
20
|
/**
|
|
20
21
|
* Registers the protocol implementation (handlers, feature registry) on the agent.
|
|
21
22
|
*/
|
|
22
|
-
register(
|
|
23
|
+
register(messageHandlerRegistry, featureRegistry) {
|
|
23
24
|
// Register message handlers for the Issue Credential V1 Protocol
|
|
24
|
-
|
|
25
|
+
messageHandlerRegistry.registerMessageHandlers([
|
|
25
26
|
new handlers_1.V1ProposeCredentialHandler(this),
|
|
26
27
|
new handlers_1.V1OfferCredentialHandler(this),
|
|
27
28
|
new handlers_1.V1RequestCredentialHandler(this),
|
|
@@ -30,7 +31,7 @@ class V1CredentialProtocol extends core_1.BaseCredentialProtocol {
|
|
|
30
31
|
new handlers_1.V1CredentialProblemReportHandler(this),
|
|
31
32
|
]);
|
|
32
33
|
// Register Issue Credential V1 in feature registry, with supported roles
|
|
33
|
-
featureRegistry.register(new
|
|
34
|
+
featureRegistry.register(new didcomm_1.Protocol({
|
|
34
35
|
id: 'https://didcomm.org/issue-credential/1.0',
|
|
35
36
|
roles: ['holder', 'issuer'],
|
|
36
37
|
}));
|
|
@@ -45,8 +46,8 @@ class V1CredentialProtocol extends core_1.BaseCredentialProtocol {
|
|
|
45
46
|
*/
|
|
46
47
|
async createProposal(agentContext, { connectionRecord, credentialFormats, comment, autoAcceptCredential, }) {
|
|
47
48
|
this.assertOnlyIndyFormat(credentialFormats);
|
|
48
|
-
const credentialRepository = agentContext.dependencyManager.resolve(
|
|
49
|
-
const didCommMessageRepository = agentContext.dependencyManager.resolve(
|
|
49
|
+
const credentialRepository = agentContext.dependencyManager.resolve(didcomm_1.CredentialRepository);
|
|
50
|
+
const didCommMessageRepository = agentContext.dependencyManager.resolve(didcomm_1.DidCommMessageRepository);
|
|
50
51
|
if (!credentialFormats.indy) {
|
|
51
52
|
throw new core_1.CredoError('Missing indy credential format in v1 create proposal call.');
|
|
52
53
|
}
|
|
@@ -54,12 +55,12 @@ class V1CredentialProtocol extends core_1.BaseCredentialProtocol {
|
|
|
54
55
|
// The linking with previews does work, so it shouldn't be too much work to re-enable this.
|
|
55
56
|
const { linkedAttachments } = credentialFormats.indy;
|
|
56
57
|
// Create record
|
|
57
|
-
const credentialRecord = new
|
|
58
|
+
const credentialRecord = new didcomm_1.CredentialExchangeRecord({
|
|
58
59
|
connectionId: connectionRecord.id,
|
|
59
60
|
threadId: core_1.utils.uuid(),
|
|
60
|
-
state:
|
|
61
|
-
role:
|
|
62
|
-
linkedAttachments: linkedAttachments
|
|
61
|
+
state: didcomm_1.CredentialState.ProposalSent,
|
|
62
|
+
role: didcomm_1.CredentialRole.Holder,
|
|
63
|
+
linkedAttachments: linkedAttachments?.map((linkedAttachment) => linkedAttachment.attachment),
|
|
63
64
|
autoAcceptCredential,
|
|
64
65
|
protocolVersion: 'v1',
|
|
65
66
|
});
|
|
@@ -76,13 +77,18 @@ class V1CredentialProtocol extends core_1.BaseCredentialProtocol {
|
|
|
76
77
|
})
|
|
77
78
|
: undefined;
|
|
78
79
|
// Create message
|
|
79
|
-
const message = new messages_1.V1ProposeCredentialMessage(
|
|
80
|
+
const message = new messages_1.V1ProposeCredentialMessage({
|
|
81
|
+
...indyCredentialProposal,
|
|
82
|
+
id: credentialRecord.threadId,
|
|
83
|
+
credentialPreview: credentialProposal,
|
|
84
|
+
comment,
|
|
85
|
+
});
|
|
80
86
|
await didCommMessageRepository.saveAgentMessage(agentContext, {
|
|
81
87
|
agentMessage: message,
|
|
82
|
-
role:
|
|
88
|
+
role: didcomm_1.DidCommMessageRole.Sender,
|
|
83
89
|
associatedRecordId: credentialRecord.id,
|
|
84
90
|
});
|
|
85
|
-
credentialRecord.credentialAttributes = credentialProposal
|
|
91
|
+
credentialRecord.credentialAttributes = credentialProposal?.attributes;
|
|
86
92
|
await credentialRepository.save(agentContext, credentialRecord);
|
|
87
93
|
this.emitStateChangedEvent(agentContext, credentialRecord, null);
|
|
88
94
|
return { credentialRecord, message };
|
|
@@ -99,32 +105,32 @@ class V1CredentialProtocol extends core_1.BaseCredentialProtocol {
|
|
|
99
105
|
*/
|
|
100
106
|
async processProposal(messageContext) {
|
|
101
107
|
const { message: proposalMessage, connection, agentContext } = messageContext;
|
|
102
|
-
const credentialRepository = agentContext.dependencyManager.resolve(
|
|
103
|
-
const didCommMessageRepository = agentContext.dependencyManager.resolve(
|
|
108
|
+
const credentialRepository = agentContext.dependencyManager.resolve(didcomm_1.CredentialRepository);
|
|
109
|
+
const didCommMessageRepository = agentContext.dependencyManager.resolve(didcomm_1.DidCommMessageRepository);
|
|
104
110
|
// TODO: with this method, we should update the credential protocol to use the ConnectionApi, so it
|
|
105
111
|
// only depends on the public api, rather than the internal API (this helps with breaking changes)
|
|
106
|
-
const connectionService = agentContext.dependencyManager.resolve(
|
|
112
|
+
const connectionService = agentContext.dependencyManager.resolve(didcomm_1.ConnectionService);
|
|
107
113
|
agentContext.config.logger.debug(`Processing credential proposal with message id ${proposalMessage.id}`);
|
|
108
114
|
let credentialRecord = await this.findByProperties(messageContext.agentContext, {
|
|
109
115
|
threadId: proposalMessage.threadId,
|
|
110
|
-
role:
|
|
111
|
-
connectionId: connection
|
|
116
|
+
role: didcomm_1.CredentialRole.Issuer,
|
|
117
|
+
connectionId: connection?.id,
|
|
112
118
|
});
|
|
113
119
|
// Credential record already exists, this is a response to an earlier message sent by us
|
|
114
120
|
if (credentialRecord) {
|
|
115
121
|
agentContext.config.logger.debug('Credential record already exists for incoming proposal');
|
|
116
122
|
// Assert
|
|
117
123
|
credentialRecord.assertProtocolVersion('v1');
|
|
118
|
-
credentialRecord.assertState(
|
|
124
|
+
credentialRecord.assertState(didcomm_1.CredentialState.OfferSent);
|
|
119
125
|
const lastReceivedMessage = await didCommMessageRepository.findAgentMessage(messageContext.agentContext, {
|
|
120
126
|
associatedRecordId: credentialRecord.id,
|
|
121
127
|
messageClass: messages_1.V1ProposeCredentialMessage,
|
|
122
|
-
role:
|
|
128
|
+
role: didcomm_1.DidCommMessageRole.Receiver,
|
|
123
129
|
});
|
|
124
130
|
const lastSentMessage = await didCommMessageRepository.getAgentMessage(messageContext.agentContext, {
|
|
125
131
|
associatedRecordId: credentialRecord.id,
|
|
126
132
|
messageClass: messages_1.V1OfferCredentialMessage,
|
|
127
|
-
role:
|
|
133
|
+
role: didcomm_1.DidCommMessageRole.Sender,
|
|
128
134
|
});
|
|
129
135
|
await connectionService.assertConnectionOrOutOfBandExchange(messageContext, {
|
|
130
136
|
lastReceivedMessage,
|
|
@@ -133,17 +139,17 @@ class V1CredentialProtocol extends core_1.BaseCredentialProtocol {
|
|
|
133
139
|
});
|
|
134
140
|
await this.indyCredentialFormat.processProposal(messageContext.agentContext, {
|
|
135
141
|
credentialRecord,
|
|
136
|
-
attachment: new
|
|
137
|
-
data: new
|
|
142
|
+
attachment: new didcomm_1.Attachment({
|
|
143
|
+
data: new didcomm_1.AttachmentData({
|
|
138
144
|
json: core_1.JsonTransformer.toJSON(this.rfc0592ProposalFromV1ProposeMessage(proposalMessage)),
|
|
139
145
|
}),
|
|
140
146
|
}),
|
|
141
147
|
});
|
|
142
148
|
// Update record
|
|
143
|
-
await this.updateState(messageContext.agentContext, credentialRecord,
|
|
149
|
+
await this.updateState(messageContext.agentContext, credentialRecord, didcomm_1.CredentialState.ProposalReceived);
|
|
144
150
|
await didCommMessageRepository.saveOrUpdateAgentMessage(messageContext.agentContext, {
|
|
145
151
|
agentMessage: proposalMessage,
|
|
146
|
-
role:
|
|
152
|
+
role: didcomm_1.DidCommMessageRole.Receiver,
|
|
147
153
|
associatedRecordId: credentialRecord.id,
|
|
148
154
|
});
|
|
149
155
|
}
|
|
@@ -152,11 +158,11 @@ class V1CredentialProtocol extends core_1.BaseCredentialProtocol {
|
|
|
152
158
|
// Assert
|
|
153
159
|
await connectionService.assertConnectionOrOutOfBandExchange(messageContext);
|
|
154
160
|
// No credential record exists with thread id
|
|
155
|
-
credentialRecord = new
|
|
156
|
-
connectionId: connection
|
|
161
|
+
credentialRecord = new didcomm_1.CredentialExchangeRecord({
|
|
162
|
+
connectionId: connection?.id,
|
|
157
163
|
threadId: proposalMessage.threadId,
|
|
158
|
-
state:
|
|
159
|
-
role:
|
|
164
|
+
state: didcomm_1.CredentialState.ProposalReceived,
|
|
165
|
+
role: didcomm_1.CredentialRole.Issuer,
|
|
160
166
|
protocolVersion: 'v1',
|
|
161
167
|
});
|
|
162
168
|
// Save record
|
|
@@ -164,7 +170,7 @@ class V1CredentialProtocol extends core_1.BaseCredentialProtocol {
|
|
|
164
170
|
this.emitStateChangedEvent(messageContext.agentContext, credentialRecord, null);
|
|
165
171
|
await didCommMessageRepository.saveAgentMessage(messageContext.agentContext, {
|
|
166
172
|
agentMessage: proposalMessage,
|
|
167
|
-
role:
|
|
173
|
+
role: didcomm_1.DidCommMessageRole.Receiver,
|
|
168
174
|
associatedRecordId: credentialRecord.id,
|
|
169
175
|
});
|
|
170
176
|
}
|
|
@@ -176,28 +182,27 @@ class V1CredentialProtocol extends core_1.BaseCredentialProtocol {
|
|
|
176
182
|
* @returns Object containing proposal message and associated credential record
|
|
177
183
|
*/
|
|
178
184
|
async acceptProposal(agentContext, { credentialRecord, credentialFormats, comment, autoAcceptCredential, }) {
|
|
179
|
-
var _a;
|
|
180
185
|
// Assert
|
|
181
186
|
credentialRecord.assertProtocolVersion('v1');
|
|
182
|
-
credentialRecord.assertState(
|
|
187
|
+
credentialRecord.assertState(didcomm_1.CredentialState.ProposalReceived);
|
|
183
188
|
if (credentialFormats)
|
|
184
189
|
this.assertOnlyIndyFormat(credentialFormats);
|
|
185
|
-
const didCommMessageRepository = agentContext.dependencyManager.resolve(
|
|
190
|
+
const didCommMessageRepository = agentContext.dependencyManager.resolve(didcomm_1.DidCommMessageRepository);
|
|
186
191
|
const proposalMessage = await didCommMessageRepository.getAgentMessage(agentContext, {
|
|
187
192
|
associatedRecordId: credentialRecord.id,
|
|
188
193
|
messageClass: messages_1.V1ProposeCredentialMessage,
|
|
189
|
-
role:
|
|
194
|
+
role: didcomm_1.DidCommMessageRole.Receiver,
|
|
190
195
|
});
|
|
191
196
|
// NOTE: We set the credential attributes from the proposal on the record as we've 'accepted' them
|
|
192
197
|
// and can now use them to create the offer in the format services. It may be overwritten later on
|
|
193
198
|
// if the user provided other attributes in the credentialFormats array.
|
|
194
|
-
credentialRecord.credentialAttributes =
|
|
199
|
+
credentialRecord.credentialAttributes = proposalMessage.credentialPreview?.attributes;
|
|
195
200
|
const { attachment, previewAttributes } = await this.indyCredentialFormat.acceptProposal(agentContext, {
|
|
196
201
|
attachmentId: messages_1.INDY_CREDENTIAL_OFFER_ATTACHMENT_ID,
|
|
197
202
|
credentialFormats,
|
|
198
203
|
credentialRecord,
|
|
199
|
-
proposalAttachment: new
|
|
200
|
-
data: new
|
|
204
|
+
proposalAttachment: new didcomm_1.Attachment({
|
|
205
|
+
data: new didcomm_1.AttachmentData({
|
|
201
206
|
json: core_1.JsonTransformer.toJSON(this.rfc0592ProposalFromV1ProposeMessage(proposalMessage)),
|
|
202
207
|
}),
|
|
203
208
|
}),
|
|
@@ -215,11 +220,11 @@ class V1CredentialProtocol extends core_1.BaseCredentialProtocol {
|
|
|
215
220
|
});
|
|
216
221
|
message.setThread({ threadId: credentialRecord.threadId, parentThreadId: credentialRecord.parentThreadId });
|
|
217
222
|
credentialRecord.credentialAttributes = message.credentialPreview.attributes;
|
|
218
|
-
credentialRecord.autoAcceptCredential = autoAcceptCredential
|
|
219
|
-
await this.updateState(agentContext, credentialRecord,
|
|
223
|
+
credentialRecord.autoAcceptCredential = autoAcceptCredential ?? credentialRecord.autoAcceptCredential;
|
|
224
|
+
await this.updateState(agentContext, credentialRecord, didcomm_1.CredentialState.OfferSent);
|
|
220
225
|
await didCommMessageRepository.saveOrUpdateAgentMessage(agentContext, {
|
|
221
226
|
agentMessage: message,
|
|
222
|
-
role:
|
|
227
|
+
role: didcomm_1.DidCommMessageRole.Sender,
|
|
223
228
|
associatedRecordId: credentialRecord.id,
|
|
224
229
|
});
|
|
225
230
|
return { credentialRecord, message };
|
|
@@ -235,9 +240,9 @@ class V1CredentialProtocol extends core_1.BaseCredentialProtocol {
|
|
|
235
240
|
async negotiateProposal(agentContext, { credentialFormats, credentialRecord, comment, autoAcceptCredential, }) {
|
|
236
241
|
// Assert
|
|
237
242
|
credentialRecord.assertProtocolVersion('v1');
|
|
238
|
-
credentialRecord.assertState(
|
|
243
|
+
credentialRecord.assertState(didcomm_1.CredentialState.ProposalReceived);
|
|
239
244
|
this.assertOnlyIndyFormat(credentialFormats);
|
|
240
|
-
const didCommMessageRepository = agentContext.dependencyManager.resolve(
|
|
245
|
+
const didCommMessageRepository = agentContext.dependencyManager.resolve(didcomm_1.DidCommMessageRepository);
|
|
241
246
|
const { attachment, previewAttributes } = await this.indyCredentialFormat.createOffer(agentContext, {
|
|
242
247
|
attachmentId: messages_1.INDY_CREDENTIAL_OFFER_ATTACHMENT_ID,
|
|
243
248
|
credentialFormats,
|
|
@@ -256,11 +261,11 @@ class V1CredentialProtocol extends core_1.BaseCredentialProtocol {
|
|
|
256
261
|
});
|
|
257
262
|
message.setThread({ threadId: credentialRecord.threadId, parentThreadId: credentialRecord.parentThreadId });
|
|
258
263
|
credentialRecord.credentialAttributes = message.credentialPreview.attributes;
|
|
259
|
-
credentialRecord.autoAcceptCredential = autoAcceptCredential
|
|
260
|
-
await this.updateState(agentContext, credentialRecord,
|
|
264
|
+
credentialRecord.autoAcceptCredential = autoAcceptCredential ?? credentialRecord.autoAcceptCredential;
|
|
265
|
+
await this.updateState(agentContext, credentialRecord, didcomm_1.CredentialState.OfferSent);
|
|
261
266
|
await didCommMessageRepository.saveOrUpdateAgentMessage(agentContext, {
|
|
262
267
|
agentMessage: message,
|
|
263
|
-
role:
|
|
268
|
+
role: didcomm_1.DidCommMessageRole.Sender,
|
|
264
269
|
associatedRecordId: credentialRecord.id,
|
|
265
270
|
});
|
|
266
271
|
return { credentialRecord, message };
|
|
@@ -274,21 +279,20 @@ class V1CredentialProtocol extends core_1.BaseCredentialProtocol {
|
|
|
274
279
|
*
|
|
275
280
|
*/
|
|
276
281
|
async createOffer(agentContext, { credentialFormats, autoAcceptCredential, comment, connectionRecord, }) {
|
|
277
|
-
var _a, _b;
|
|
278
282
|
// Assert
|
|
279
283
|
this.assertOnlyIndyFormat(credentialFormats);
|
|
280
|
-
const credentialRepository = agentContext.dependencyManager.resolve(
|
|
281
|
-
const didCommMessageRepository = agentContext.dependencyManager.resolve(
|
|
284
|
+
const credentialRepository = agentContext.dependencyManager.resolve(didcomm_1.CredentialRepository);
|
|
285
|
+
const didCommMessageRepository = agentContext.dependencyManager.resolve(didcomm_1.DidCommMessageRepository);
|
|
282
286
|
if (!credentialFormats.indy) {
|
|
283
287
|
throw new core_1.CredoError('Missing indy credential format data for v1 create offer');
|
|
284
288
|
}
|
|
285
289
|
// Create record
|
|
286
|
-
const credentialRecord = new
|
|
287
|
-
connectionId: connectionRecord
|
|
290
|
+
const credentialRecord = new didcomm_1.CredentialExchangeRecord({
|
|
291
|
+
connectionId: connectionRecord?.id,
|
|
288
292
|
threadId: core_1.utils.uuid(),
|
|
289
|
-
linkedAttachments:
|
|
290
|
-
state:
|
|
291
|
-
role:
|
|
293
|
+
linkedAttachments: credentialFormats.indy.linkedAttachments?.map((linkedAttachments) => linkedAttachments.attachment),
|
|
294
|
+
state: didcomm_1.CredentialState.OfferSent,
|
|
295
|
+
role: didcomm_1.CredentialRole.Issuer,
|
|
292
296
|
autoAcceptCredential,
|
|
293
297
|
protocolVersion: 'v1',
|
|
294
298
|
});
|
|
@@ -308,12 +312,12 @@ class V1CredentialProtocol extends core_1.BaseCredentialProtocol {
|
|
|
308
312
|
}),
|
|
309
313
|
comment,
|
|
310
314
|
offerAttachments: [attachment],
|
|
311
|
-
attachments:
|
|
315
|
+
attachments: credentialFormats.indy.linkedAttachments?.map((linkedAttachments) => linkedAttachments.attachment),
|
|
312
316
|
});
|
|
313
317
|
await didCommMessageRepository.saveAgentMessage(agentContext, {
|
|
314
318
|
associatedRecordId: credentialRecord.id,
|
|
315
319
|
agentMessage: message,
|
|
316
|
-
role:
|
|
320
|
+
role: didcomm_1.DidCommMessageRole.Sender,
|
|
317
321
|
});
|
|
318
322
|
credentialRecord.credentialAttributes = message.credentialPreview.attributes;
|
|
319
323
|
await credentialRepository.save(agentContext, credentialRecord);
|
|
@@ -331,18 +335,17 @@ class V1CredentialProtocol extends core_1.BaseCredentialProtocol {
|
|
|
331
335
|
*
|
|
332
336
|
*/
|
|
333
337
|
async processOffer(messageContext) {
|
|
334
|
-
var _a;
|
|
335
338
|
const { message: offerMessage, connection, agentContext } = messageContext;
|
|
336
|
-
const credentialRepository = agentContext.dependencyManager.resolve(
|
|
337
|
-
const didCommMessageRepository = agentContext.dependencyManager.resolve(
|
|
339
|
+
const credentialRepository = agentContext.dependencyManager.resolve(didcomm_1.CredentialRepository);
|
|
340
|
+
const didCommMessageRepository = agentContext.dependencyManager.resolve(didcomm_1.DidCommMessageRepository);
|
|
338
341
|
// TODO: with this method, we should update the credential protocol to use the ConnectionApi, so it
|
|
339
342
|
// only depends on the public api, rather than the internal API (this helps with breaking changes)
|
|
340
|
-
const connectionService = agentContext.dependencyManager.resolve(
|
|
343
|
+
const connectionService = agentContext.dependencyManager.resolve(didcomm_1.ConnectionService);
|
|
341
344
|
agentContext.config.logger.debug(`Processing credential offer with id ${offerMessage.id}`);
|
|
342
345
|
let credentialRecord = await this.findByProperties(agentContext, {
|
|
343
346
|
threadId: offerMessage.threadId,
|
|
344
|
-
role:
|
|
345
|
-
connectionId: connection
|
|
347
|
+
role: didcomm_1.CredentialRole.Holder,
|
|
348
|
+
connectionId: connection?.id,
|
|
346
349
|
});
|
|
347
350
|
const offerAttachment = offerMessage.getOfferAttachmentById(messages_1.INDY_CREDENTIAL_OFFER_ATTACHMENT_ID);
|
|
348
351
|
if (!offerAttachment) {
|
|
@@ -352,16 +355,16 @@ class V1CredentialProtocol extends core_1.BaseCredentialProtocol {
|
|
|
352
355
|
const lastSentMessage = await didCommMessageRepository.getAgentMessage(messageContext.agentContext, {
|
|
353
356
|
associatedRecordId: credentialRecord.id,
|
|
354
357
|
messageClass: messages_1.V1ProposeCredentialMessage,
|
|
355
|
-
role:
|
|
358
|
+
role: didcomm_1.DidCommMessageRole.Sender,
|
|
356
359
|
});
|
|
357
360
|
const lastReceivedMessage = await didCommMessageRepository.findAgentMessage(messageContext.agentContext, {
|
|
358
361
|
associatedRecordId: credentialRecord.id,
|
|
359
362
|
messageClass: messages_1.V1OfferCredentialMessage,
|
|
360
|
-
role:
|
|
363
|
+
role: didcomm_1.DidCommMessageRole.Receiver,
|
|
361
364
|
});
|
|
362
365
|
// Assert
|
|
363
366
|
credentialRecord.assertProtocolVersion('v1');
|
|
364
|
-
credentialRecord.assertState(
|
|
367
|
+
credentialRecord.assertState(didcomm_1.CredentialState.ProposalSent);
|
|
365
368
|
await connectionService.assertConnectionOrOutOfBandExchange(messageContext, {
|
|
366
369
|
lastReceivedMessage,
|
|
367
370
|
lastSentMessage,
|
|
@@ -373,22 +376,22 @@ class V1CredentialProtocol extends core_1.BaseCredentialProtocol {
|
|
|
373
376
|
});
|
|
374
377
|
await didCommMessageRepository.saveOrUpdateAgentMessage(messageContext.agentContext, {
|
|
375
378
|
agentMessage: offerMessage,
|
|
376
|
-
role:
|
|
379
|
+
role: didcomm_1.DidCommMessageRole.Receiver,
|
|
377
380
|
associatedRecordId: credentialRecord.id,
|
|
378
381
|
});
|
|
379
|
-
await this.updateState(messageContext.agentContext, credentialRecord,
|
|
382
|
+
await this.updateState(messageContext.agentContext, credentialRecord, didcomm_1.CredentialState.OfferReceived);
|
|
380
383
|
return credentialRecord;
|
|
381
384
|
}
|
|
382
385
|
else {
|
|
383
386
|
// Assert
|
|
384
387
|
await connectionService.assertConnectionOrOutOfBandExchange(messageContext);
|
|
385
388
|
// No credential record exists with thread id
|
|
386
|
-
credentialRecord = new
|
|
387
|
-
connectionId: connection
|
|
389
|
+
credentialRecord = new didcomm_1.CredentialExchangeRecord({
|
|
390
|
+
connectionId: connection?.id,
|
|
388
391
|
threadId: offerMessage.threadId,
|
|
389
|
-
parentThreadId:
|
|
390
|
-
state:
|
|
391
|
-
role:
|
|
392
|
+
parentThreadId: offerMessage.thread?.parentThreadId,
|
|
393
|
+
state: didcomm_1.CredentialState.OfferReceived,
|
|
394
|
+
role: didcomm_1.CredentialRole.Holder,
|
|
392
395
|
protocolVersion: 'v1',
|
|
393
396
|
});
|
|
394
397
|
await this.indyCredentialFormat.processOffer(messageContext.agentContext, {
|
|
@@ -398,7 +401,7 @@ class V1CredentialProtocol extends core_1.BaseCredentialProtocol {
|
|
|
398
401
|
// Save in repository
|
|
399
402
|
await didCommMessageRepository.saveAgentMessage(messageContext.agentContext, {
|
|
400
403
|
agentMessage: offerMessage,
|
|
401
|
-
role:
|
|
404
|
+
role: didcomm_1.DidCommMessageRole.Receiver,
|
|
402
405
|
associatedRecordId: credentialRecord.id,
|
|
403
406
|
});
|
|
404
407
|
await credentialRepository.save(messageContext.agentContext, credentialRecord);
|
|
@@ -414,15 +417,14 @@ class V1CredentialProtocol extends core_1.BaseCredentialProtocol {
|
|
|
414
417
|
*
|
|
415
418
|
*/
|
|
416
419
|
async acceptOffer(agentContext, { credentialRecord, credentialFormats, comment, autoAcceptCredential, }) {
|
|
417
|
-
var _a, _b;
|
|
418
420
|
// Assert credential
|
|
419
421
|
credentialRecord.assertProtocolVersion('v1');
|
|
420
|
-
credentialRecord.assertState(
|
|
421
|
-
const didCommMessageRepository = agentContext.dependencyManager.resolve(
|
|
422
|
+
credentialRecord.assertState(didcomm_1.CredentialState.OfferReceived);
|
|
423
|
+
const didCommMessageRepository = agentContext.dependencyManager.resolve(didcomm_1.DidCommMessageRepository);
|
|
422
424
|
const offerMessage = await didCommMessageRepository.getAgentMessage(agentContext, {
|
|
423
425
|
associatedRecordId: credentialRecord.id,
|
|
424
426
|
messageClass: messages_1.V1OfferCredentialMessage,
|
|
425
|
-
role:
|
|
427
|
+
role: didcomm_1.DidCommMessageRole.Receiver,
|
|
426
428
|
});
|
|
427
429
|
const offerAttachment = offerMessage.getOfferAttachmentById(messages_1.INDY_CREDENTIAL_OFFER_ATTACHMENT_ID);
|
|
428
430
|
if (!offerAttachment) {
|
|
@@ -437,18 +439,18 @@ class V1CredentialProtocol extends core_1.BaseCredentialProtocol {
|
|
|
437
439
|
const requestMessage = new messages_1.V1RequestCredentialMessage({
|
|
438
440
|
comment,
|
|
439
441
|
requestAttachments: [attachment],
|
|
440
|
-
attachments:
|
|
442
|
+
attachments: offerMessage.appendedAttachments?.filter((attachment) => (0, didcomm_1.isLinkedAttachment)(attachment)),
|
|
441
443
|
});
|
|
442
444
|
requestMessage.setThread({ threadId: credentialRecord.threadId, parentThreadId: credentialRecord.parentThreadId });
|
|
443
445
|
credentialRecord.credentialAttributes = offerMessage.credentialPreview.attributes;
|
|
444
|
-
credentialRecord.autoAcceptCredential = autoAcceptCredential
|
|
445
|
-
credentialRecord.linkedAttachments =
|
|
446
|
+
credentialRecord.autoAcceptCredential = autoAcceptCredential ?? credentialRecord.autoAcceptCredential;
|
|
447
|
+
credentialRecord.linkedAttachments = offerMessage.appendedAttachments?.filter((attachment) => (0, didcomm_1.isLinkedAttachment)(attachment));
|
|
446
448
|
await didCommMessageRepository.saveOrUpdateAgentMessage(agentContext, {
|
|
447
449
|
agentMessage: requestMessage,
|
|
448
450
|
associatedRecordId: credentialRecord.id,
|
|
449
|
-
role:
|
|
451
|
+
role: didcomm_1.DidCommMessageRole.Sender,
|
|
450
452
|
});
|
|
451
|
-
await this.updateState(agentContext, credentialRecord,
|
|
453
|
+
await this.updateState(agentContext, credentialRecord, didcomm_1.CredentialState.RequestSent);
|
|
452
454
|
return { message: requestMessage, credentialRecord };
|
|
453
455
|
}
|
|
454
456
|
/**
|
|
@@ -462,12 +464,11 @@ class V1CredentialProtocol extends core_1.BaseCredentialProtocol {
|
|
|
462
464
|
*
|
|
463
465
|
*/
|
|
464
466
|
async negotiateOffer(agentContext, { credentialFormats, credentialRecord, autoAcceptCredential, comment, }) {
|
|
465
|
-
var _a;
|
|
466
467
|
// Assert
|
|
467
468
|
credentialRecord.assertProtocolVersion('v1');
|
|
468
|
-
credentialRecord.assertState(
|
|
469
|
+
credentialRecord.assertState(didcomm_1.CredentialState.OfferReceived);
|
|
469
470
|
this.assertOnlyIndyFormat(credentialFormats);
|
|
470
|
-
const didCommMessageRepository = agentContext.dependencyManager.resolve(
|
|
471
|
+
const didCommMessageRepository = agentContext.dependencyManager.resolve(didcomm_1.DidCommMessageRepository);
|
|
471
472
|
if (!credentialRecord.connectionId) {
|
|
472
473
|
throw new core_1.CredoError(`No connectionId found for credential record '${credentialRecord.id}'. Connection-less issuance does not support negotiation.`);
|
|
473
474
|
}
|
|
@@ -489,18 +490,22 @@ class V1CredentialProtocol extends core_1.BaseCredentialProtocol {
|
|
|
489
490
|
})
|
|
490
491
|
: undefined;
|
|
491
492
|
// Create message
|
|
492
|
-
const message = new messages_1.V1ProposeCredentialMessage(
|
|
493
|
+
const message = new messages_1.V1ProposeCredentialMessage({
|
|
494
|
+
...indyCredentialProposal,
|
|
495
|
+
credentialPreview: credentialProposal,
|
|
496
|
+
comment,
|
|
497
|
+
});
|
|
493
498
|
message.setThread({ threadId: credentialRecord.threadId, parentThreadId: credentialRecord.parentThreadId });
|
|
494
499
|
await didCommMessageRepository.saveOrUpdateAgentMessage(agentContext, {
|
|
495
500
|
agentMessage: message,
|
|
496
|
-
role:
|
|
501
|
+
role: didcomm_1.DidCommMessageRole.Sender,
|
|
497
502
|
associatedRecordId: credentialRecord.id,
|
|
498
503
|
});
|
|
499
504
|
// Update record
|
|
500
|
-
credentialRecord.credentialAttributes =
|
|
501
|
-
credentialRecord.linkedAttachments = linkedAttachments
|
|
502
|
-
credentialRecord.autoAcceptCredential = autoAcceptCredential
|
|
503
|
-
await this.updateState(agentContext, credentialRecord,
|
|
505
|
+
credentialRecord.credentialAttributes = message.credentialPreview?.attributes;
|
|
506
|
+
credentialRecord.linkedAttachments = linkedAttachments?.map((attachment) => attachment.attachment);
|
|
507
|
+
credentialRecord.autoAcceptCredential = autoAcceptCredential ?? credentialRecord.autoAcceptCredential;
|
|
508
|
+
await this.updateState(agentContext, credentialRecord, didcomm_1.CredentialState.ProposalSent);
|
|
504
509
|
return { credentialRecord, message };
|
|
505
510
|
}
|
|
506
511
|
/**
|
|
@@ -512,32 +517,32 @@ class V1CredentialProtocol extends core_1.BaseCredentialProtocol {
|
|
|
512
517
|
}
|
|
513
518
|
async processRequest(messageContext) {
|
|
514
519
|
const { message: requestMessage, connection, agentContext } = messageContext;
|
|
515
|
-
const didCommMessageRepository = agentContext.dependencyManager.resolve(
|
|
520
|
+
const didCommMessageRepository = agentContext.dependencyManager.resolve(didcomm_1.DidCommMessageRepository);
|
|
516
521
|
// TODO: with this method, we should update the credential protocol to use the ConnectionApi, so it
|
|
517
522
|
// only depends on the public api, rather than the internal API (this helps with breaking changes)
|
|
518
|
-
const connectionService = agentContext.dependencyManager.resolve(
|
|
523
|
+
const connectionService = agentContext.dependencyManager.resolve(didcomm_1.ConnectionService);
|
|
519
524
|
agentContext.config.logger.debug(`Processing credential request with id ${requestMessage.id}`);
|
|
520
525
|
const credentialRecord = await this.getByProperties(messageContext.agentContext, {
|
|
521
526
|
threadId: requestMessage.threadId,
|
|
522
|
-
role:
|
|
527
|
+
role: didcomm_1.CredentialRole.Issuer,
|
|
523
528
|
});
|
|
524
529
|
agentContext.config.logger.trace('Credential record found when processing credential request', credentialRecord);
|
|
525
530
|
const proposalMessage = await didCommMessageRepository.findAgentMessage(messageContext.agentContext, {
|
|
526
531
|
associatedRecordId: credentialRecord.id,
|
|
527
532
|
messageClass: messages_1.V1ProposeCredentialMessage,
|
|
528
|
-
role:
|
|
533
|
+
role: didcomm_1.DidCommMessageRole.Receiver,
|
|
529
534
|
});
|
|
530
535
|
const offerMessage = await didCommMessageRepository.findAgentMessage(messageContext.agentContext, {
|
|
531
536
|
associatedRecordId: credentialRecord.id,
|
|
532
537
|
messageClass: messages_1.V1OfferCredentialMessage,
|
|
533
|
-
role:
|
|
538
|
+
role: didcomm_1.DidCommMessageRole.Sender,
|
|
534
539
|
});
|
|
535
540
|
// Assert
|
|
536
541
|
credentialRecord.assertProtocolVersion('v1');
|
|
537
|
-
credentialRecord.assertState(
|
|
542
|
+
credentialRecord.assertState(didcomm_1.CredentialState.OfferSent);
|
|
538
543
|
await connectionService.assertConnectionOrOutOfBandExchange(messageContext, {
|
|
539
|
-
lastReceivedMessage: proposalMessage
|
|
540
|
-
lastSentMessage: offerMessage
|
|
544
|
+
lastReceivedMessage: proposalMessage ?? undefined,
|
|
545
|
+
lastSentMessage: offerMessage ?? undefined,
|
|
541
546
|
expectedConnectionId: credentialRecord.connectionId,
|
|
542
547
|
});
|
|
543
548
|
// This makes sure that the sender of the incoming message is authorized to do so.
|
|
@@ -545,7 +550,7 @@ class V1CredentialProtocol extends core_1.BaseCredentialProtocol {
|
|
|
545
550
|
await connectionService.matchIncomingMessageToRequestMessageInOutOfBandExchange(messageContext, {
|
|
546
551
|
expectedConnectionId: credentialRecord.connectionId,
|
|
547
552
|
});
|
|
548
|
-
credentialRecord.connectionId = connection
|
|
553
|
+
credentialRecord.connectionId = connection?.id;
|
|
549
554
|
}
|
|
550
555
|
const requestAttachment = requestMessage.getRequestAttachmentById(messages_1.INDY_CREDENTIAL_REQUEST_ATTACHMENT_ID);
|
|
551
556
|
if (!requestAttachment) {
|
|
@@ -557,10 +562,10 @@ class V1CredentialProtocol extends core_1.BaseCredentialProtocol {
|
|
|
557
562
|
});
|
|
558
563
|
await didCommMessageRepository.saveAgentMessage(messageContext.agentContext, {
|
|
559
564
|
agentMessage: requestMessage,
|
|
560
|
-
role:
|
|
565
|
+
role: didcomm_1.DidCommMessageRole.Receiver,
|
|
561
566
|
associatedRecordId: credentialRecord.id,
|
|
562
567
|
});
|
|
563
|
-
await this.updateState(messageContext.agentContext, credentialRecord,
|
|
568
|
+
await this.updateState(messageContext.agentContext, credentialRecord, didcomm_1.CredentialState.RequestReceived);
|
|
564
569
|
return credentialRecord;
|
|
565
570
|
}
|
|
566
571
|
/**
|
|
@@ -572,19 +577,19 @@ class V1CredentialProtocol extends core_1.BaseCredentialProtocol {
|
|
|
572
577
|
async acceptRequest(agentContext, { credentialRecord, credentialFormats, comment, autoAcceptCredential, }) {
|
|
573
578
|
// Assert
|
|
574
579
|
credentialRecord.assertProtocolVersion('v1');
|
|
575
|
-
credentialRecord.assertState(
|
|
580
|
+
credentialRecord.assertState(didcomm_1.CredentialState.RequestReceived);
|
|
576
581
|
if (credentialFormats)
|
|
577
582
|
this.assertOnlyIndyFormat(credentialFormats);
|
|
578
|
-
const didCommMessageRepository = agentContext.dependencyManager.resolve(
|
|
583
|
+
const didCommMessageRepository = agentContext.dependencyManager.resolve(didcomm_1.DidCommMessageRepository);
|
|
579
584
|
const offerMessage = await didCommMessageRepository.getAgentMessage(agentContext, {
|
|
580
585
|
associatedRecordId: credentialRecord.id,
|
|
581
586
|
messageClass: messages_1.V1OfferCredentialMessage,
|
|
582
|
-
role:
|
|
587
|
+
role: didcomm_1.DidCommMessageRole.Sender,
|
|
583
588
|
});
|
|
584
589
|
const requestMessage = await didCommMessageRepository.getAgentMessage(agentContext, {
|
|
585
590
|
associatedRecordId: credentialRecord.id,
|
|
586
591
|
messageClass: messages_1.V1RequestCredentialMessage,
|
|
587
|
-
role:
|
|
592
|
+
role: didcomm_1.DidCommMessageRole.Receiver,
|
|
588
593
|
});
|
|
589
594
|
const offerAttachment = offerMessage.getOfferAttachmentById(messages_1.INDY_CREDENTIAL_OFFER_ATTACHMENT_ID);
|
|
590
595
|
const requestAttachment = requestMessage.getRequestAttachmentById(messages_1.INDY_CREDENTIAL_REQUEST_ATTACHMENT_ID);
|
|
@@ -608,10 +613,10 @@ class V1CredentialProtocol extends core_1.BaseCredentialProtocol {
|
|
|
608
613
|
await didCommMessageRepository.saveAgentMessage(agentContext, {
|
|
609
614
|
agentMessage: issueMessage,
|
|
610
615
|
associatedRecordId: credentialRecord.id,
|
|
611
|
-
role:
|
|
616
|
+
role: didcomm_1.DidCommMessageRole.Sender,
|
|
612
617
|
});
|
|
613
|
-
credentialRecord.autoAcceptCredential = autoAcceptCredential
|
|
614
|
-
await this.updateState(agentContext, credentialRecord,
|
|
618
|
+
credentialRecord.autoAcceptCredential = autoAcceptCredential ?? credentialRecord.autoAcceptCredential;
|
|
619
|
+
await this.updateState(agentContext, credentialRecord, didcomm_1.CredentialState.CredentialIssued);
|
|
615
620
|
return { message: issueMessage, credentialRecord };
|
|
616
621
|
}
|
|
617
622
|
/**
|
|
@@ -624,28 +629,28 @@ class V1CredentialProtocol extends core_1.BaseCredentialProtocol {
|
|
|
624
629
|
async processCredential(messageContext) {
|
|
625
630
|
const { message: issueMessage, connection, agentContext } = messageContext;
|
|
626
631
|
agentContext.config.logger.debug(`Processing credential with id ${issueMessage.id}`);
|
|
627
|
-
const didCommMessageRepository = agentContext.dependencyManager.resolve(
|
|
632
|
+
const didCommMessageRepository = agentContext.dependencyManager.resolve(didcomm_1.DidCommMessageRepository);
|
|
628
633
|
// TODO: with this method, we should update the credential protocol to use the ConnectionApi, so it
|
|
629
634
|
// only depends on the public api, rather than the internal API (this helps with breaking changes)
|
|
630
|
-
const connectionService = agentContext.dependencyManager.resolve(
|
|
635
|
+
const connectionService = agentContext.dependencyManager.resolve(didcomm_1.ConnectionService);
|
|
631
636
|
const credentialRecord = await this.getByProperties(messageContext.agentContext, {
|
|
632
637
|
threadId: issueMessage.threadId,
|
|
633
|
-
role:
|
|
634
|
-
connectionId: connection
|
|
638
|
+
role: didcomm_1.CredentialRole.Holder,
|
|
639
|
+
connectionId: connection?.id,
|
|
635
640
|
});
|
|
636
641
|
const requestCredentialMessage = await didCommMessageRepository.findAgentMessage(messageContext.agentContext, {
|
|
637
642
|
associatedRecordId: credentialRecord.id,
|
|
638
643
|
messageClass: messages_1.V1RequestCredentialMessage,
|
|
639
|
-
role:
|
|
644
|
+
role: didcomm_1.DidCommMessageRole.Sender,
|
|
640
645
|
});
|
|
641
646
|
const offerCredentialMessage = await didCommMessageRepository.findAgentMessage(messageContext.agentContext, {
|
|
642
647
|
associatedRecordId: credentialRecord.id,
|
|
643
648
|
messageClass: messages_1.V1OfferCredentialMessage,
|
|
644
|
-
role:
|
|
649
|
+
role: didcomm_1.DidCommMessageRole.Receiver,
|
|
645
650
|
});
|
|
646
651
|
// Assert
|
|
647
652
|
credentialRecord.assertProtocolVersion('v1');
|
|
648
|
-
credentialRecord.assertState(
|
|
653
|
+
credentialRecord.assertState(didcomm_1.CredentialState.RequestSent);
|
|
649
654
|
await connectionService.assertConnectionOrOutOfBandExchange(messageContext, {
|
|
650
655
|
lastReceivedMessage: offerCredentialMessage,
|
|
651
656
|
lastSentMessage: requestCredentialMessage,
|
|
@@ -655,11 +660,11 @@ class V1CredentialProtocol extends core_1.BaseCredentialProtocol {
|
|
|
655
660
|
if (!issueAttachment) {
|
|
656
661
|
throw new core_1.CredoError('Missing indy credential attachment in processCredential');
|
|
657
662
|
}
|
|
658
|
-
const requestAttachment = requestCredentialMessage
|
|
663
|
+
const requestAttachment = requestCredentialMessage?.getRequestAttachmentById(messages_1.INDY_CREDENTIAL_REQUEST_ATTACHMENT_ID);
|
|
659
664
|
if (!requestAttachment) {
|
|
660
665
|
throw new core_1.CredoError('Missing indy credential request attachment in processCredential');
|
|
661
666
|
}
|
|
662
|
-
const offerAttachment = offerCredentialMessage
|
|
667
|
+
const offerAttachment = offerCredentialMessage?.getOfferAttachmentById(messages_1.INDY_CREDENTIAL_OFFER_ATTACHMENT_ID);
|
|
663
668
|
if (!offerAttachment) {
|
|
664
669
|
throw new core_1.CredoError('Missing indy credential request attachment in processCredential');
|
|
665
670
|
}
|
|
@@ -671,10 +676,10 @@ class V1CredentialProtocol extends core_1.BaseCredentialProtocol {
|
|
|
671
676
|
});
|
|
672
677
|
await didCommMessageRepository.saveAgentMessage(messageContext.agentContext, {
|
|
673
678
|
agentMessage: issueMessage,
|
|
674
|
-
role:
|
|
679
|
+
role: didcomm_1.DidCommMessageRole.Receiver,
|
|
675
680
|
associatedRecordId: credentialRecord.id,
|
|
676
681
|
});
|
|
677
|
-
await this.updateState(messageContext.agentContext, credentialRecord,
|
|
682
|
+
await this.updateState(messageContext.agentContext, credentialRecord, didcomm_1.CredentialState.CredentialReceived);
|
|
678
683
|
return credentialRecord;
|
|
679
684
|
}
|
|
680
685
|
/**
|
|
@@ -686,14 +691,14 @@ class V1CredentialProtocol extends core_1.BaseCredentialProtocol {
|
|
|
686
691
|
*/
|
|
687
692
|
async acceptCredential(agentContext, { credentialRecord }) {
|
|
688
693
|
credentialRecord.assertProtocolVersion('v1');
|
|
689
|
-
credentialRecord.assertState(
|
|
694
|
+
credentialRecord.assertState(didcomm_1.CredentialState.CredentialReceived);
|
|
690
695
|
// Create message
|
|
691
696
|
const ackMessage = new messages_1.V1CredentialAckMessage({
|
|
692
|
-
status:
|
|
697
|
+
status: didcomm_1.AckStatus.OK,
|
|
693
698
|
threadId: credentialRecord.threadId,
|
|
694
699
|
});
|
|
695
700
|
ackMessage.setThread({ threadId: credentialRecord.threadId, parentThreadId: credentialRecord.parentThreadId });
|
|
696
|
-
await this.updateState(agentContext, credentialRecord,
|
|
701
|
+
await this.updateState(agentContext, credentialRecord, didcomm_1.CredentialState.Done);
|
|
697
702
|
return { message: ackMessage, credentialRecord };
|
|
698
703
|
}
|
|
699
704
|
/**
|
|
@@ -706,35 +711,35 @@ class V1CredentialProtocol extends core_1.BaseCredentialProtocol {
|
|
|
706
711
|
async processAck(messageContext) {
|
|
707
712
|
const { message: ackMessage, connection, agentContext } = messageContext;
|
|
708
713
|
agentContext.config.logger.debug(`Processing credential ack with id ${ackMessage.id}`);
|
|
709
|
-
const didCommMessageRepository = agentContext.dependencyManager.resolve(
|
|
714
|
+
const didCommMessageRepository = agentContext.dependencyManager.resolve(didcomm_1.DidCommMessageRepository);
|
|
710
715
|
// TODO: with this method, we should update the credential protocol to use the ConnectionApi, so it
|
|
711
716
|
// only depends on the public api, rather than the internal API (this helps with breaking changes)
|
|
712
|
-
const connectionService = agentContext.dependencyManager.resolve(
|
|
717
|
+
const connectionService = agentContext.dependencyManager.resolve(didcomm_1.ConnectionService);
|
|
713
718
|
const credentialRecord = await this.getByProperties(messageContext.agentContext, {
|
|
714
719
|
threadId: ackMessage.threadId,
|
|
715
|
-
role:
|
|
716
|
-
connectionId: connection
|
|
720
|
+
role: didcomm_1.CredentialRole.Issuer,
|
|
721
|
+
connectionId: connection?.id,
|
|
717
722
|
});
|
|
718
723
|
const requestCredentialMessage = await didCommMessageRepository.getAgentMessage(messageContext.agentContext, {
|
|
719
724
|
associatedRecordId: credentialRecord.id,
|
|
720
725
|
messageClass: messages_1.V1RequestCredentialMessage,
|
|
721
|
-
role:
|
|
726
|
+
role: didcomm_1.DidCommMessageRole.Receiver,
|
|
722
727
|
});
|
|
723
728
|
const issueCredentialMessage = await didCommMessageRepository.getAgentMessage(messageContext.agentContext, {
|
|
724
729
|
associatedRecordId: credentialRecord.id,
|
|
725
730
|
messageClass: messages_1.V1IssueCredentialMessage,
|
|
726
|
-
role:
|
|
731
|
+
role: didcomm_1.DidCommMessageRole.Sender,
|
|
727
732
|
});
|
|
728
733
|
// Assert
|
|
729
734
|
credentialRecord.assertProtocolVersion('v1');
|
|
730
|
-
credentialRecord.assertState(
|
|
735
|
+
credentialRecord.assertState(didcomm_1.CredentialState.CredentialIssued);
|
|
731
736
|
await connectionService.assertConnectionOrOutOfBandExchange(messageContext, {
|
|
732
737
|
lastReceivedMessage: requestCredentialMessage,
|
|
733
738
|
lastSentMessage: issueCredentialMessage,
|
|
734
739
|
expectedConnectionId: credentialRecord.connectionId,
|
|
735
740
|
});
|
|
736
741
|
// Update record
|
|
737
|
-
await this.updateState(messageContext.agentContext, credentialRecord,
|
|
742
|
+
await this.updateState(messageContext.agentContext, credentialRecord, didcomm_1.CredentialState.Done);
|
|
738
743
|
return credentialRecord;
|
|
739
744
|
}
|
|
740
745
|
/**
|
|
@@ -748,7 +753,7 @@ class V1CredentialProtocol extends core_1.BaseCredentialProtocol {
|
|
|
748
753
|
const message = new messages_1.V1CredentialProblemReportMessage({
|
|
749
754
|
description: {
|
|
750
755
|
en: description,
|
|
751
|
-
code:
|
|
756
|
+
code: didcomm_1.CredentialProblemReportReason.IssuanceAbandoned,
|
|
752
757
|
},
|
|
753
758
|
});
|
|
754
759
|
return { message, credentialRecord };
|
|
@@ -756,12 +761,12 @@ class V1CredentialProtocol extends core_1.BaseCredentialProtocol {
|
|
|
756
761
|
// AUTO RESPOND METHODS
|
|
757
762
|
async shouldAutoRespondToProposal(agentContext, options) {
|
|
758
763
|
const { credentialRecord, proposalMessage } = options;
|
|
759
|
-
const credentialsModuleConfig = agentContext.dependencyManager.resolve(
|
|
764
|
+
const credentialsModuleConfig = agentContext.dependencyManager.resolve(didcomm_1.CredentialsModuleConfig);
|
|
760
765
|
const autoAccept = (0, utils_1.composeCredentialAutoAccept)(credentialRecord.autoAcceptCredential, credentialsModuleConfig.autoAcceptCredentials);
|
|
761
766
|
// Handle always / never cases
|
|
762
|
-
if (autoAccept ===
|
|
767
|
+
if (autoAccept === didcomm_1.AutoAcceptCredential.Always)
|
|
763
768
|
return true;
|
|
764
|
-
if (autoAccept ===
|
|
769
|
+
if (autoAccept === didcomm_1.AutoAcceptCredential.Never)
|
|
765
770
|
return false;
|
|
766
771
|
const offerMessage = await this.findOfferMessage(agentContext, credentialRecord.id);
|
|
767
772
|
// Do not auto accept if missing properties
|
|
@@ -780,12 +785,12 @@ class V1CredentialProtocol extends core_1.BaseCredentialProtocol {
|
|
|
780
785
|
}
|
|
781
786
|
async shouldAutoRespondToOffer(agentContext, options) {
|
|
782
787
|
const { credentialRecord, offerMessage } = options;
|
|
783
|
-
const credentialsModuleConfig = agentContext.dependencyManager.resolve(
|
|
788
|
+
const credentialsModuleConfig = agentContext.dependencyManager.resolve(didcomm_1.CredentialsModuleConfig);
|
|
784
789
|
const autoAccept = (0, utils_1.composeCredentialAutoAccept)(credentialRecord.autoAcceptCredential, credentialsModuleConfig.autoAcceptCredentials);
|
|
785
790
|
// Handle always / never cases
|
|
786
|
-
if (autoAccept ===
|
|
791
|
+
if (autoAccept === didcomm_1.AutoAcceptCredential.Always)
|
|
787
792
|
return true;
|
|
788
|
-
if (autoAccept ===
|
|
793
|
+
if (autoAccept === didcomm_1.AutoAcceptCredential.Never)
|
|
789
794
|
return false;
|
|
790
795
|
const proposalMessage = await this.findProposalMessage(agentContext, credentialRecord.id);
|
|
791
796
|
// Do not auto accept if missing properties
|
|
@@ -804,12 +809,12 @@ class V1CredentialProtocol extends core_1.BaseCredentialProtocol {
|
|
|
804
809
|
}
|
|
805
810
|
async shouldAutoRespondToRequest(agentContext, options) {
|
|
806
811
|
const { credentialRecord, requestMessage } = options;
|
|
807
|
-
const credentialsModuleConfig = agentContext.dependencyManager.resolve(
|
|
812
|
+
const credentialsModuleConfig = agentContext.dependencyManager.resolve(didcomm_1.CredentialsModuleConfig);
|
|
808
813
|
const autoAccept = (0, utils_1.composeCredentialAutoAccept)(credentialRecord.autoAcceptCredential, credentialsModuleConfig.autoAcceptCredentials);
|
|
809
814
|
// Handle always / never cases
|
|
810
|
-
if (autoAccept ===
|
|
815
|
+
if (autoAccept === didcomm_1.AutoAcceptCredential.Always)
|
|
811
816
|
return true;
|
|
812
|
-
if (autoAccept ===
|
|
817
|
+
if (autoAccept === didcomm_1.AutoAcceptCredential.Never)
|
|
813
818
|
return false;
|
|
814
819
|
const offerMessage = await this.findOfferMessage(agentContext, credentialRecord.id);
|
|
815
820
|
if (!offerMessage)
|
|
@@ -826,22 +831,22 @@ class V1CredentialProtocol extends core_1.BaseCredentialProtocol {
|
|
|
826
831
|
}
|
|
827
832
|
async shouldAutoRespondToCredential(agentContext, options) {
|
|
828
833
|
const { credentialRecord, credentialMessage } = options;
|
|
829
|
-
const credentialsModuleConfig = agentContext.dependencyManager.resolve(
|
|
834
|
+
const credentialsModuleConfig = agentContext.dependencyManager.resolve(didcomm_1.CredentialsModuleConfig);
|
|
830
835
|
const autoAccept = (0, utils_1.composeCredentialAutoAccept)(credentialRecord.autoAcceptCredential, credentialsModuleConfig.autoAcceptCredentials);
|
|
831
836
|
// Handle always / never cases
|
|
832
|
-
if (autoAccept ===
|
|
837
|
+
if (autoAccept === didcomm_1.AutoAcceptCredential.Always)
|
|
833
838
|
return true;
|
|
834
|
-
if (autoAccept ===
|
|
839
|
+
if (autoAccept === didcomm_1.AutoAcceptCredential.Never)
|
|
835
840
|
return false;
|
|
836
841
|
const requestMessage = await this.findRequestMessage(agentContext, credentialRecord.id);
|
|
837
842
|
const offerMessage = await this.findOfferMessage(agentContext, credentialRecord.id);
|
|
838
843
|
const credentialAttachment = credentialMessage.getCredentialAttachmentById(messages_1.INDY_CREDENTIAL_ATTACHMENT_ID);
|
|
839
844
|
if (!credentialAttachment)
|
|
840
845
|
return false;
|
|
841
|
-
const requestAttachment = requestMessage
|
|
846
|
+
const requestAttachment = requestMessage?.getRequestAttachmentById(messages_1.INDY_CREDENTIAL_REQUEST_ATTACHMENT_ID);
|
|
842
847
|
if (!requestAttachment)
|
|
843
848
|
return false;
|
|
844
|
-
const offerAttachment = offerMessage
|
|
849
|
+
const offerAttachment = offerMessage?.getOfferAttachmentById(messages_1.INDY_CREDENTIAL_OFFER_ATTACHMENT_ID);
|
|
845
850
|
return this.indyCredentialFormat.shouldAutoRespondToCredential(agentContext, {
|
|
846
851
|
credentialRecord,
|
|
847
852
|
credentialAttachment,
|
|
@@ -850,35 +855,34 @@ class V1CredentialProtocol extends core_1.BaseCredentialProtocol {
|
|
|
850
855
|
});
|
|
851
856
|
}
|
|
852
857
|
async findProposalMessage(agentContext, credentialExchangeId) {
|
|
853
|
-
const didCommMessageRepository = agentContext.dependencyManager.resolve(
|
|
858
|
+
const didCommMessageRepository = agentContext.dependencyManager.resolve(didcomm_1.DidCommMessageRepository);
|
|
854
859
|
return await didCommMessageRepository.findAgentMessage(agentContext, {
|
|
855
860
|
associatedRecordId: credentialExchangeId,
|
|
856
861
|
messageClass: messages_1.V1ProposeCredentialMessage,
|
|
857
862
|
});
|
|
858
863
|
}
|
|
859
864
|
async findOfferMessage(agentContext, credentialExchangeId) {
|
|
860
|
-
const didCommMessageRepository = agentContext.dependencyManager.resolve(
|
|
865
|
+
const didCommMessageRepository = agentContext.dependencyManager.resolve(didcomm_1.DidCommMessageRepository);
|
|
861
866
|
return await didCommMessageRepository.findAgentMessage(agentContext, {
|
|
862
867
|
associatedRecordId: credentialExchangeId,
|
|
863
868
|
messageClass: messages_1.V1OfferCredentialMessage,
|
|
864
869
|
});
|
|
865
870
|
}
|
|
866
871
|
async findRequestMessage(agentContext, credentialExchangeId) {
|
|
867
|
-
const didCommMessageRepository = agentContext.dependencyManager.resolve(
|
|
872
|
+
const didCommMessageRepository = agentContext.dependencyManager.resolve(didcomm_1.DidCommMessageRepository);
|
|
868
873
|
return await didCommMessageRepository.findAgentMessage(agentContext, {
|
|
869
874
|
associatedRecordId: credentialExchangeId,
|
|
870
875
|
messageClass: messages_1.V1RequestCredentialMessage,
|
|
871
876
|
});
|
|
872
877
|
}
|
|
873
878
|
async findCredentialMessage(agentContext, credentialExchangeId) {
|
|
874
|
-
const didCommMessageRepository = agentContext.dependencyManager.resolve(
|
|
879
|
+
const didCommMessageRepository = agentContext.dependencyManager.resolve(didcomm_1.DidCommMessageRepository);
|
|
875
880
|
return await didCommMessageRepository.findAgentMessage(agentContext, {
|
|
876
881
|
associatedRecordId: credentialExchangeId,
|
|
877
882
|
messageClass: messages_1.V1IssueCredentialMessage,
|
|
878
883
|
});
|
|
879
884
|
}
|
|
880
885
|
async getFormatData(agentContext, credentialExchangeId) {
|
|
881
|
-
var _a, _b, _c, _d, _e;
|
|
882
886
|
// TODO: we could looking at fetching all record using a single query and then filtering based on the type of the message.
|
|
883
887
|
const [proposalMessage, offerMessage, requestMessage, credentialMessage] = await Promise.all([
|
|
884
888
|
this.findProposalMessage(agentContext, credentialExchangeId),
|
|
@@ -889,17 +893,17 @@ class V1CredentialProtocol extends core_1.BaseCredentialProtocol {
|
|
|
889
893
|
const indyProposal = proposalMessage
|
|
890
894
|
? core_1.JsonTransformer.toJSON(this.rfc0592ProposalFromV1ProposeMessage(proposalMessage))
|
|
891
895
|
: undefined;
|
|
892
|
-
const indyOffer =
|
|
893
|
-
const indyRequest =
|
|
894
|
-
const indyCredential =
|
|
896
|
+
const indyOffer = offerMessage?.indyCredentialOffer ?? undefined;
|
|
897
|
+
const indyRequest = requestMessage?.indyCredentialRequest ?? undefined;
|
|
898
|
+
const indyCredential = credentialMessage?.indyCredential ?? undefined;
|
|
895
899
|
return {
|
|
896
|
-
proposalAttributes:
|
|
900
|
+
proposalAttributes: proposalMessage?.credentialPreview?.attributes,
|
|
897
901
|
proposal: proposalMessage
|
|
898
902
|
? {
|
|
899
903
|
indy: indyProposal,
|
|
900
904
|
}
|
|
901
905
|
: undefined,
|
|
902
|
-
offerAttributes:
|
|
906
|
+
offerAttributes: offerMessage?.credentialPreview?.attributes,
|
|
903
907
|
offer: offerMessage
|
|
904
908
|
? {
|
|
905
909
|
indy: indyOffer,
|