@credo-ts/askar-to-drizzle-storage-migration 0.6.0-alpha-20251010171953 → 0.6.0-alpha-20251010222303

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.
@@ -2,7 +2,6 @@ const require_rolldown_runtime = require('../../../_virtual/rolldown_runtime.js'
2
2
  const require_decorateMetadata = require('../../../_virtual/_@oxc-project_runtime@0.94.0/helpers/decorateMetadata.js');
3
3
  const require_decorate = require('../../../_virtual/_@oxc-project_runtime@0.94.0/helpers/decorate.js');
4
4
  const require_DidCommModuleConfig = require('./DidCommModuleConfig.js');
5
- const require_DidCommMessageSender = require('./DidCommMessageSender.js');
6
5
  const require_DidCommConnectionsApi = require('./modules/connections/DidCommConnectionsApi.js');
7
6
  const require_DidCommFeatureRegistry = require('./DidCommFeatureRegistry.js');
8
7
  const require_DidCommMessageHandlerRegistry = require('./DidCommMessageHandlerRegistry.js');
@@ -15,18 +14,15 @@ const require_DidCommMediationRecipientApi = require('./modules/routing/DidCommM
15
14
  const require_DidCommCredentialsApi = require('./modules/credentials/DidCommCredentialsApi.js');
16
15
  const require_DidCommProofsApi = require('./modules/proofs/DidCommProofsApi.js');
17
16
  require('./modules/index.js');
18
- const require_DidCommMessageReceiver = require('./DidCommMessageReceiver.js');
19
17
  let __credo_ts_core = require("@credo-ts/core");
20
18
  __credo_ts_core = require_rolldown_runtime.__toESM(__credo_ts_core);
21
19
 
22
20
  //#region ../didcomm/src/DidCommApi.ts
23
- var _ref, _ref2, _ref3, _ref4, _ref5, _ref6;
21
+ var _ref, _ref2, _ref3, _ref4;
24
22
  let DidCommApi = class DidCommApi$1 {
25
- constructor(agentContext, messageHandlerRegistry, messageSender, messageReceiver, featureRegistry, config) {
23
+ constructor(agentContext, messageHandlerRegistry, featureRegistry, config) {
26
24
  this.agentContext = agentContext;
27
25
  this.messageHandlerRegistry = messageHandlerRegistry;
28
- this.messageSender = messageSender;
29
- this.messageReceiver = messageReceiver;
30
26
  this.featureRegistry = featureRegistry;
31
27
  this.config = config;
32
28
  this.connections = this.agentContext.resolve(require_DidCommConnectionsApi.DidCommConnectionsApi);
@@ -40,22 +36,23 @@ let DidCommApi = class DidCommApi$1 {
40
36
  this.mediationRecipient = this.apiOrUndefined(this.config.enabledModules.mediationRecipient, require_DidCommMediationRecipientApi.DidCommMediationRecipientApi);
41
37
  }
42
38
  registerInboundTransport(inboundTransport) {
43
- this.messageReceiver.registerInboundTransport(inboundTransport);
39
+ this.config.inboundTransports.push(inboundTransport);
44
40
  }
45
41
  async unregisterInboundTransport(inboundTransport) {
46
- await this.messageReceiver.unregisterInboundTransport(inboundTransport);
42
+ this.config.inboundTransports = this.config.inboundTransports.filter((transport) => transport !== inboundTransport);
43
+ await inboundTransport.stop();
47
44
  }
48
45
  get inboundTransports() {
49
- return this.messageReceiver.inboundTransports;
46
+ return this.config.inboundTransports;
50
47
  }
51
48
  registerOutboundTransport(outboundTransport) {
52
- this.messageSender.registerOutboundTransport(outboundTransport);
49
+ this.config.outboundTransports.push(outboundTransport);
53
50
  }
54
51
  async unregisterOutboundTransport(outboundTransport) {
55
- await this.messageSender.unregisterOutboundTransport(outboundTransport);
52
+ this.config.outboundTransports = this.config.outboundTransports.filter((transport) => transport !== outboundTransport);
56
53
  }
57
54
  get outboundTransports() {
58
- return this.messageSender.outboundTransports;
55
+ return this.config.outboundTransports;
59
56
  }
60
57
  /**
61
58
  * Agent's feature registry
@@ -89,10 +86,8 @@ let DidCommApi = class DidCommApi$1 {
89
86
  DidCommApi = require_decorate.__decorate([(0, __credo_ts_core.injectable)(), require_decorateMetadata.__decorateMetadata("design:paramtypes", [
90
87
  typeof (_ref = typeof __credo_ts_core.AgentContext !== "undefined" && __credo_ts_core.AgentContext) === "function" ? _ref : Object,
91
88
  typeof (_ref2 = typeof require_DidCommMessageHandlerRegistry.DidCommMessageHandlerRegistry !== "undefined" && require_DidCommMessageHandlerRegistry.DidCommMessageHandlerRegistry) === "function" ? _ref2 : Object,
92
- typeof (_ref3 = typeof require_DidCommMessageSender.DidCommMessageSender !== "undefined" && require_DidCommMessageSender.DidCommMessageSender) === "function" ? _ref3 : Object,
93
- typeof (_ref4 = typeof require_DidCommMessageReceiver.DidCommMessageReceiver !== "undefined" && require_DidCommMessageReceiver.DidCommMessageReceiver) === "function" ? _ref4 : Object,
94
- typeof (_ref5 = typeof require_DidCommFeatureRegistry.DidCommFeatureRegistry !== "undefined" && require_DidCommFeatureRegistry.DidCommFeatureRegistry) === "function" ? _ref5 : Object,
95
- typeof (_ref6 = typeof require_DidCommModuleConfig.DidCommModuleConfig !== "undefined" && require_DidCommModuleConfig.DidCommModuleConfig) === "function" ? _ref6 : Object
89
+ typeof (_ref3 = typeof require_DidCommFeatureRegistry.DidCommFeatureRegistry !== "undefined" && require_DidCommFeatureRegistry.DidCommFeatureRegistry) === "function" ? _ref3 : Object,
90
+ typeof (_ref4 = typeof require_DidCommModuleConfig.DidCommModuleConfig !== "undefined" && require_DidCommModuleConfig.DidCommModuleConfig) === "function" ? _ref4 : Object
96
91
  ])], DidCommApi);
97
92
 
98
93
  //#endregion
@@ -1,7 +1,6 @@
1
1
  import { __decorateMetadata } from "../../../_virtual/_@oxc-project_runtime@0.94.0/helpers/decorateMetadata.mjs";
2
2
  import { __decorate } from "../../../_virtual/_@oxc-project_runtime@0.94.0/helpers/decorate.mjs";
3
3
  import { DidCommModuleConfig } from "./DidCommModuleConfig.mjs";
4
- import { DidCommMessageSender } from "./DidCommMessageSender.mjs";
5
4
  import { DidCommConnectionsApi } from "./modules/connections/DidCommConnectionsApi.mjs";
6
5
  import { DidCommFeatureRegistry } from "./DidCommFeatureRegistry.mjs";
7
6
  import { DidCommMessageHandlerRegistry } from "./DidCommMessageHandlerRegistry.mjs";
@@ -14,17 +13,14 @@ import { DidCommMediationRecipientApi } from "./modules/routing/DidCommMediation
14
13
  import { DidCommCredentialsApi } from "./modules/credentials/DidCommCredentialsApi.mjs";
15
14
  import { DidCommProofsApi } from "./modules/proofs/DidCommProofsApi.mjs";
16
15
  import "./modules/index.mjs";
17
- import { DidCommMessageReceiver } from "./DidCommMessageReceiver.mjs";
18
16
  import { AgentContext, injectable } from "@credo-ts/core";
19
17
 
20
18
  //#region ../didcomm/src/DidCommApi.ts
21
- var _ref, _ref2, _ref3, _ref4, _ref5, _ref6;
19
+ var _ref, _ref2, _ref3, _ref4;
22
20
  let DidCommApi = class DidCommApi$1 {
23
- constructor(agentContext, messageHandlerRegistry, messageSender, messageReceiver, featureRegistry, config) {
21
+ constructor(agentContext, messageHandlerRegistry, featureRegistry, config) {
24
22
  this.agentContext = agentContext;
25
23
  this.messageHandlerRegistry = messageHandlerRegistry;
26
- this.messageSender = messageSender;
27
- this.messageReceiver = messageReceiver;
28
24
  this.featureRegistry = featureRegistry;
29
25
  this.config = config;
30
26
  this.connections = this.agentContext.resolve(DidCommConnectionsApi);
@@ -38,22 +34,23 @@ let DidCommApi = class DidCommApi$1 {
38
34
  this.mediationRecipient = this.apiOrUndefined(this.config.enabledModules.mediationRecipient, DidCommMediationRecipientApi);
39
35
  }
40
36
  registerInboundTransport(inboundTransport) {
41
- this.messageReceiver.registerInboundTransport(inboundTransport);
37
+ this.config.inboundTransports.push(inboundTransport);
42
38
  }
43
39
  async unregisterInboundTransport(inboundTransport) {
44
- await this.messageReceiver.unregisterInboundTransport(inboundTransport);
40
+ this.config.inboundTransports = this.config.inboundTransports.filter((transport) => transport !== inboundTransport);
41
+ await inboundTransport.stop();
45
42
  }
46
43
  get inboundTransports() {
47
- return this.messageReceiver.inboundTransports;
44
+ return this.config.inboundTransports;
48
45
  }
49
46
  registerOutboundTransport(outboundTransport) {
50
- this.messageSender.registerOutboundTransport(outboundTransport);
47
+ this.config.outboundTransports.push(outboundTransport);
51
48
  }
52
49
  async unregisterOutboundTransport(outboundTransport) {
53
- await this.messageSender.unregisterOutboundTransport(outboundTransport);
50
+ this.config.outboundTransports = this.config.outboundTransports.filter((transport) => transport !== outboundTransport);
54
51
  }
55
52
  get outboundTransports() {
56
- return this.messageSender.outboundTransports;
53
+ return this.config.outboundTransports;
57
54
  }
58
55
  /**
59
56
  * Agent's feature registry
@@ -87,10 +84,8 @@ let DidCommApi = class DidCommApi$1 {
87
84
  DidCommApi = __decorate([injectable(), __decorateMetadata("design:paramtypes", [
88
85
  typeof (_ref = typeof AgentContext !== "undefined" && AgentContext) === "function" ? _ref : Object,
89
86
  typeof (_ref2 = typeof DidCommMessageHandlerRegistry !== "undefined" && DidCommMessageHandlerRegistry) === "function" ? _ref2 : Object,
90
- typeof (_ref3 = typeof DidCommMessageSender !== "undefined" && DidCommMessageSender) === "function" ? _ref3 : Object,
91
- typeof (_ref4 = typeof DidCommMessageReceiver !== "undefined" && DidCommMessageReceiver) === "function" ? _ref4 : Object,
92
- typeof (_ref5 = typeof DidCommFeatureRegistry !== "undefined" && DidCommFeatureRegistry) === "function" ? _ref5 : Object,
93
- typeof (_ref6 = typeof DidCommModuleConfig !== "undefined" && DidCommModuleConfig) === "function" ? _ref6 : Object
87
+ typeof (_ref3 = typeof DidCommFeatureRegistry !== "undefined" && DidCommFeatureRegistry) === "function" ? _ref3 : Object,
88
+ typeof (_ref4 = typeof DidCommModuleConfig !== "undefined" && DidCommModuleConfig) === "function" ? _ref4 : Object
94
89
  ])], DidCommApi);
95
90
 
96
91
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"DidCommApi.mjs","names":["DidCommApi","agentContext: AgentContext","messageHandlerRegistry: DidCommMessageHandlerRegistry","messageSender: DidCommMessageSender","messageReceiver: DidCommMessageReceiver","featureRegistry: DidCommFeatureRegistry","config: DidCommModuleConfig"],"sources":["../../../../../didcomm/src/DidCommApi.ts"],"sourcesContent":["import type { DidCommMessageHandler, DidCommMessageHandlerMiddleware } from './handlers'\nimport type { DidCommInboundTransport, DidCommOutboundTransport } from './transport'\n\nimport { AgentContext, type InjectionToken, injectable } from '@credo-ts/core'\n\nimport { DidCommFeatureRegistry } from './DidCommFeatureRegistry'\nimport { DidCommMessageHandlerRegistry } from './DidCommMessageHandlerRegistry'\nimport { DidCommMessageReceiver } from './DidCommMessageReceiver'\nimport { DidCommMessageSender } from './DidCommMessageSender'\nimport { DidCommModuleConfig, type DidCommModuleConfigOptions } from './DidCommModuleConfig'\nimport {\n type DefaultDidCommMessagePickupProtocols,\n type DefaultDidCommProofProtocols,\n DidCommBasicMessagesApi,\n DidCommConnectionsApi,\n type DidCommCredentialProtocol,\n DidCommDiscoverFeaturesApi,\n DidCommMessagePickupApi,\n type DidCommMessagePickupModuleConfigOptions,\n type DidCommMessagePickupProtocol,\n DidCommOutOfBandApi,\n type DidCommProofProtocol,\n DidCommProofsApi,\n type DidCommProofsModuleConfigOptions,\n} from './modules'\nimport { DidCommCredentialsApi } from './modules/credentials/DidCommCredentialsApi'\nimport type { DefaultDidCommCredentialProtocols } from './modules/credentials/DidCommCredentialsModule'\nimport type { DidCommCredentialsModuleConfigOptions } from './modules/credentials/DidCommCredentialsModuleConfig'\nimport { DidCommMediationRecipientApi } from './modules/routing/DidCommMediationRecipientApi'\nimport { DidCommMediatorApi } from './modules/routing/DidCommMediatorApi'\n\ntype ApiOrUndefined<Config, Api> = Config extends false ? never : Api\n\n@injectable()\nexport class DidCommApi<Options extends DidCommModuleConfigOptions> {\n public connections = this.agentContext.resolve(DidCommConnectionsApi)\n public oob = this.agentContext.resolve(DidCommOutOfBandApi)\n public discovery = this.agentContext.resolve(DidCommDiscoverFeaturesApi)\n public proofs: ApiOrUndefined<\n Options['proofs'],\n DidCommProofsApi<\n Options['proofs'] extends DidCommProofsModuleConfigOptions<DidCommProofProtocol[]>\n ? Options['proofs']['proofProtocols']\n : DefaultDidCommProofProtocols\n >\n > = this.apiOrUndefined(this.config.enabledModules.proofs, DidCommProofsApi)\n\n public credentials: ApiOrUndefined<\n Options['credentials'],\n DidCommCredentialsApi<\n Options['credentials'] extends DidCommCredentialsModuleConfigOptions<DidCommCredentialProtocol[]>\n ? Options['credentials']['credentialProtocols']\n : DefaultDidCommCredentialProtocols\n >\n > = this.apiOrUndefined(this.config.enabledModules.credentials, DidCommCredentialsApi)\n\n public messagePickup: ApiOrUndefined<\n Options['messagePickup'],\n DidCommMessagePickupApi<\n Options['messagePickup'] extends DidCommMessagePickupModuleConfigOptions<DidCommMessagePickupProtocol[]>\n ? Options['messagePickup']['protocols']\n : DefaultDidCommMessagePickupProtocols\n >\n > = this.apiOrUndefined(this.config.enabledModules.messagePickup, DidCommMessagePickupApi)\n\n public basicMessages: ApiOrUndefined<Options['basicMessages'], DidCommBasicMessagesApi> = this.apiOrUndefined(\n this.config.enabledModules.basicMessages,\n DidCommBasicMessagesApi\n )\n\n public mediator: ApiOrUndefined<Options['mediator'], DidCommMediatorApi> = this.apiOrUndefined(\n this.config.enabledModules.mediator,\n DidCommMediatorApi\n )\n\n public mediationRecipient: ApiOrUndefined<Options['mediationRecipient'], DidCommMediationRecipientApi> =\n this.apiOrUndefined(this.config.enabledModules.mediationRecipient, DidCommMediationRecipientApi)\n\n public constructor(\n public agentContext: AgentContext,\n private messageHandlerRegistry: DidCommMessageHandlerRegistry,\n private messageSender: DidCommMessageSender,\n private messageReceiver: DidCommMessageReceiver,\n private featureRegistry: DidCommFeatureRegistry,\n public config: DidCommModuleConfig\n ) {}\n\n public registerInboundTransport(inboundTransport: DidCommInboundTransport) {\n this.messageReceiver.registerInboundTransport(inboundTransport)\n }\n\n public async unregisterInboundTransport(inboundTransport: DidCommInboundTransport) {\n await this.messageReceiver.unregisterInboundTransport(inboundTransport)\n }\n\n public get inboundTransports() {\n return this.messageReceiver.inboundTransports\n }\n\n public registerOutboundTransport(outboundTransport: DidCommOutboundTransport) {\n this.messageSender.registerOutboundTransport(outboundTransport)\n }\n\n public async unregisterOutboundTransport(outboundTransport: DidCommOutboundTransport) {\n await this.messageSender.unregisterOutboundTransport(outboundTransport)\n }\n\n public get outboundTransports() {\n return this.messageSender.outboundTransports\n }\n\n /**\n * Agent's feature registry\n */\n public registerMessageHandlers(messageHandlers: DidCommMessageHandler[]) {\n for (const messageHandler of messageHandlers) {\n this.messageHandlerRegistry.registerMessageHandler(messageHandler)\n }\n }\n\n public registerMessageHandlerMiddleware(messageHandlerMiddleware: DidCommMessageHandlerMiddleware) {\n this.messageHandlerRegistry.registerMessageHandlerMiddleware(messageHandlerMiddleware)\n }\n\n public get fallbackMessageHandler() {\n return this.messageHandlerRegistry.fallbackMessageHandler\n }\n\n public get messageHandlerMiddlewares() {\n return this.messageHandlerRegistry.messageHandlerMiddlewares\n }\n\n /**\n * Sets the fallback message handler, the message handler that will be called if no handler\n * is registered for an incoming message type.\n */\n public setFallbackMessageHandler(fallbackMessageHandler: DidCommMessageHandler['handle']) {\n this.messageHandlerRegistry.setFallbackMessageHandler(fallbackMessageHandler)\n }\n\n public get features() {\n return this.featureRegistry\n }\n\n private apiOrUndefined(isEnabled: boolean, apiClass: InjectionToken) {\n if (isEnabled) {\n return this.agentContext.resolve(apiClass)\n }\n\n return undefined\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAkCO,uBAAMA,aAAuD;CA4ClE,AAAO,YACL,AAAOC,cACP,AAAQC,wBACR,AAAQC,eACR,AAAQC,iBACR,AAAQC,iBACR,AAAOC,QACP;EANO;EACC;EACA;EACA;EACA;EACD;OAjDF,cAAc,KAAK,aAAa,QAAQ,sBAAsB;OAC9D,MAAM,KAAK,aAAa,QAAQ,oBAAoB;OACpD,YAAY,KAAK,aAAa,QAAQ,2BAA2B;OACjE,SAOH,KAAK,eAAe,KAAK,OAAO,eAAe,QAAQ,iBAAiB;OAErE,cAOH,KAAK,eAAe,KAAK,OAAO,eAAe,aAAa,sBAAsB;OAE/E,gBAOH,KAAK,eAAe,KAAK,OAAO,eAAe,eAAe,wBAAwB;OAEnF,gBAAmF,KAAK,eAC7F,KAAK,OAAO,eAAe,eAC3B,wBACD;OAEM,WAAoE,KAAK,eAC9E,KAAK,OAAO,eAAe,UAC3B,mBACD;OAEM,qBACL,KAAK,eAAe,KAAK,OAAO,eAAe,oBAAoB,6BAA6B;;CAWlG,AAAO,yBAAyB,kBAA2C;AACzE,OAAK,gBAAgB,yBAAyB,iBAAiB;;CAGjE,MAAa,2BAA2B,kBAA2C;AACjF,QAAM,KAAK,gBAAgB,2BAA2B,iBAAiB;;CAGzE,IAAW,oBAAoB;AAC7B,SAAO,KAAK,gBAAgB;;CAG9B,AAAO,0BAA0B,mBAA6C;AAC5E,OAAK,cAAc,0BAA0B,kBAAkB;;CAGjE,MAAa,4BAA4B,mBAA6C;AACpF,QAAM,KAAK,cAAc,4BAA4B,kBAAkB;;CAGzE,IAAW,qBAAqB;AAC9B,SAAO,KAAK,cAAc;;;;;CAM5B,AAAO,wBAAwB,iBAA0C;AACvE,OAAK,MAAM,kBAAkB,gBAC3B,MAAK,uBAAuB,uBAAuB,eAAe;;CAItE,AAAO,iCAAiC,0BAA2D;AACjG,OAAK,uBAAuB,iCAAiC,yBAAyB;;CAGxF,IAAW,yBAAyB;AAClC,SAAO,KAAK,uBAAuB;;CAGrC,IAAW,4BAA4B;AACrC,SAAO,KAAK,uBAAuB;;;;;;CAOrC,AAAO,0BAA0B,wBAAyD;AACxF,OAAK,uBAAuB,0BAA0B,uBAAuB;;CAG/E,IAAW,WAAW;AACpB,SAAO,KAAK;;CAGd,AAAQ,eAAe,WAAoB,UAA0B;AACnE,MAAI,UACF,QAAO,KAAK,aAAa,QAAQ,SAAS;;;yBAjH/C,YAAY"}
1
+ {"version":3,"file":"DidCommApi.mjs","names":["DidCommApi","agentContext: AgentContext","messageHandlerRegistry: DidCommMessageHandlerRegistry","featureRegistry: DidCommFeatureRegistry","config: DidCommModuleConfig"],"sources":["../../../../../didcomm/src/DidCommApi.ts"],"sourcesContent":["import type { DidCommMessageHandler, DidCommMessageHandlerMiddleware } from './handlers'\nimport type { DidCommInboundTransport, DidCommOutboundTransport } from './transport'\n\nimport { AgentContext, type InjectionToken, injectable } from '@credo-ts/core'\n\nimport { DidCommFeatureRegistry } from './DidCommFeatureRegistry'\nimport { DidCommMessageHandlerRegistry } from './DidCommMessageHandlerRegistry'\nimport { DidCommModuleConfig, type DidCommModuleConfigOptions } from './DidCommModuleConfig'\nimport {\n type DefaultDidCommMessagePickupProtocols,\n type DefaultDidCommProofProtocols,\n DidCommBasicMessagesApi,\n DidCommConnectionsApi,\n type DidCommCredentialProtocol,\n DidCommDiscoverFeaturesApi,\n DidCommMessagePickupApi,\n type DidCommMessagePickupModuleConfigOptions,\n type DidCommMessagePickupProtocol,\n DidCommOutOfBandApi,\n type DidCommProofProtocol,\n DidCommProofsApi,\n type DidCommProofsModuleConfigOptions,\n} from './modules'\nimport { DidCommCredentialsApi } from './modules/credentials/DidCommCredentialsApi'\nimport type { DefaultDidCommCredentialProtocols } from './modules/credentials/DidCommCredentialsModule'\nimport type { DidCommCredentialsModuleConfigOptions } from './modules/credentials/DidCommCredentialsModuleConfig'\nimport { DidCommMediationRecipientApi } from './modules/routing/DidCommMediationRecipientApi'\nimport { DidCommMediatorApi } from './modules/routing/DidCommMediatorApi'\n\ntype ApiOrUndefined<Config, Api> = Config extends false ? never : Api\n\n@injectable()\nexport class DidCommApi<Options extends DidCommModuleConfigOptions> {\n public connections = this.agentContext.resolve(DidCommConnectionsApi)\n public oob = this.agentContext.resolve(DidCommOutOfBandApi)\n public discovery = this.agentContext.resolve(DidCommDiscoverFeaturesApi)\n public proofs: ApiOrUndefined<\n Options['proofs'],\n DidCommProofsApi<\n Options['proofs'] extends DidCommProofsModuleConfigOptions<DidCommProofProtocol[]>\n ? Options['proofs']['proofProtocols']\n : DefaultDidCommProofProtocols\n >\n > = this.apiOrUndefined(this.config.enabledModules.proofs, DidCommProofsApi)\n\n public credentials: ApiOrUndefined<\n Options['credentials'],\n DidCommCredentialsApi<\n Options['credentials'] extends DidCommCredentialsModuleConfigOptions<DidCommCredentialProtocol[]>\n ? Options['credentials']['credentialProtocols']\n : DefaultDidCommCredentialProtocols\n >\n > = this.apiOrUndefined(this.config.enabledModules.credentials, DidCommCredentialsApi)\n\n public messagePickup: ApiOrUndefined<\n Options['messagePickup'],\n DidCommMessagePickupApi<\n Options['messagePickup'] extends DidCommMessagePickupModuleConfigOptions<DidCommMessagePickupProtocol[]>\n ? Options['messagePickup']['protocols']\n : DefaultDidCommMessagePickupProtocols\n >\n > = this.apiOrUndefined(this.config.enabledModules.messagePickup, DidCommMessagePickupApi)\n\n public basicMessages: ApiOrUndefined<Options['basicMessages'], DidCommBasicMessagesApi> = this.apiOrUndefined(\n this.config.enabledModules.basicMessages,\n DidCommBasicMessagesApi\n )\n\n public mediator: ApiOrUndefined<Options['mediator'], DidCommMediatorApi> = this.apiOrUndefined(\n this.config.enabledModules.mediator,\n DidCommMediatorApi\n )\n\n public mediationRecipient: ApiOrUndefined<Options['mediationRecipient'], DidCommMediationRecipientApi> =\n this.apiOrUndefined(this.config.enabledModules.mediationRecipient, DidCommMediationRecipientApi)\n\n public constructor(\n public agentContext: AgentContext,\n private messageHandlerRegistry: DidCommMessageHandlerRegistry,\n private featureRegistry: DidCommFeatureRegistry,\n public config: DidCommModuleConfig\n ) {}\n\n public registerInboundTransport(inboundTransport: DidCommInboundTransport) {\n this.config.inboundTransports.push(inboundTransport)\n }\n\n public async unregisterInboundTransport(inboundTransport: DidCommInboundTransport) {\n this.config.inboundTransports = this.config.inboundTransports.filter((transport) => transport !== inboundTransport)\n await inboundTransport.stop()\n }\n\n public get inboundTransports() {\n return this.config.inboundTransports\n }\n\n public registerOutboundTransport(outboundTransport: DidCommOutboundTransport) {\n this.config.outboundTransports.push(outboundTransport)\n }\n\n public async unregisterOutboundTransport(outboundTransport: DidCommOutboundTransport) {\n this.config.outboundTransports = this.config.outboundTransports.filter(\n (transport) => transport !== outboundTransport\n )\n }\n\n public get outboundTransports() {\n return this.config.outboundTransports\n }\n\n /**\n * Agent's feature registry\n */\n public registerMessageHandlers(messageHandlers: DidCommMessageHandler[]) {\n for (const messageHandler of messageHandlers) {\n this.messageHandlerRegistry.registerMessageHandler(messageHandler)\n }\n }\n\n public registerMessageHandlerMiddleware(messageHandlerMiddleware: DidCommMessageHandlerMiddleware) {\n this.messageHandlerRegistry.registerMessageHandlerMiddleware(messageHandlerMiddleware)\n }\n\n public get fallbackMessageHandler() {\n return this.messageHandlerRegistry.fallbackMessageHandler\n }\n\n public get messageHandlerMiddlewares() {\n return this.messageHandlerRegistry.messageHandlerMiddlewares\n }\n\n /**\n * Sets the fallback message handler, the message handler that will be called if no handler\n * is registered for an incoming message type.\n */\n public setFallbackMessageHandler(fallbackMessageHandler: DidCommMessageHandler['handle']) {\n this.messageHandlerRegistry.setFallbackMessageHandler(fallbackMessageHandler)\n }\n\n public get features() {\n return this.featureRegistry\n }\n\n private apiOrUndefined(isEnabled: boolean, apiClass: InjectionToken) {\n if (isEnabled) {\n return this.agentContext.resolve(apiClass)\n }\n\n return undefined\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAgCO,uBAAMA,aAAuD;CA4ClE,AAAO,YACL,AAAOC,cACP,AAAQC,wBACR,AAAQC,iBACR,AAAOC,QACP;EAJO;EACC;EACA;EACD;OA/CF,cAAc,KAAK,aAAa,QAAQ,sBAAsB;OAC9D,MAAM,KAAK,aAAa,QAAQ,oBAAoB;OACpD,YAAY,KAAK,aAAa,QAAQ,2BAA2B;OACjE,SAOH,KAAK,eAAe,KAAK,OAAO,eAAe,QAAQ,iBAAiB;OAErE,cAOH,KAAK,eAAe,KAAK,OAAO,eAAe,aAAa,sBAAsB;OAE/E,gBAOH,KAAK,eAAe,KAAK,OAAO,eAAe,eAAe,wBAAwB;OAEnF,gBAAmF,KAAK,eAC7F,KAAK,OAAO,eAAe,eAC3B,wBACD;OAEM,WAAoE,KAAK,eAC9E,KAAK,OAAO,eAAe,UAC3B,mBACD;OAEM,qBACL,KAAK,eAAe,KAAK,OAAO,eAAe,oBAAoB,6BAA6B;;CASlG,AAAO,yBAAyB,kBAA2C;AACzE,OAAK,OAAO,kBAAkB,KAAK,iBAAiB;;CAGtD,MAAa,2BAA2B,kBAA2C;AACjF,OAAK,OAAO,oBAAoB,KAAK,OAAO,kBAAkB,QAAQ,cAAc,cAAc,iBAAiB;AACnH,QAAM,iBAAiB,MAAM;;CAG/B,IAAW,oBAAoB;AAC7B,SAAO,KAAK,OAAO;;CAGrB,AAAO,0BAA0B,mBAA6C;AAC5E,OAAK,OAAO,mBAAmB,KAAK,kBAAkB;;CAGxD,MAAa,4BAA4B,mBAA6C;AACpF,OAAK,OAAO,qBAAqB,KAAK,OAAO,mBAAmB,QAC7D,cAAc,cAAc,kBAC9B;;CAGH,IAAW,qBAAqB;AAC9B,SAAO,KAAK,OAAO;;;;;CAMrB,AAAO,wBAAwB,iBAA0C;AACvE,OAAK,MAAM,kBAAkB,gBAC3B,MAAK,uBAAuB,uBAAuB,eAAe;;CAItE,AAAO,iCAAiC,0BAA2D;AACjG,OAAK,uBAAuB,iCAAiC,yBAAyB;;CAGxF,IAAW,yBAAyB;AAClC,SAAO,KAAK,uBAAuB;;CAGrC,IAAW,4BAA4B;AACrC,SAAO,KAAK,uBAAuB;;;;;;CAOrC,AAAO,0BAA0B,wBAAyD;AACxF,OAAK,uBAAuB,0BAA0B,uBAAuB;;CAG/E,IAAW,WAAW;AACpB,SAAO,KAAK;;CAGd,AAAQ,eAAe,WAAoB,UAA0B;AACnE,MAAI,UACF,QAAO,KAAK,aAAa,QAAQ,SAAS;;;yBAlH/C,YAAY"}
@@ -27,7 +27,6 @@ __credo_ts_core = require_rolldown_runtime.__toESM(__credo_ts_core);
27
27
  var _ref, _ref2, _ref3, _ref4, _ref5, _ref6;
28
28
  let DidCommMessageReceiver = class DidCommMessageReceiver$1 {
29
29
  constructor(envelopeService, transportService, messageSender, connectionService, dispatcher, messageHandlerRegistry, agentContextProvider, logger) {
30
- this._inboundTransports = [];
31
30
  this.envelopeService = envelopeService;
32
31
  this.transportService = transportService;
33
32
  this.messageSender = messageSender;
@@ -36,17 +35,6 @@ let DidCommMessageReceiver = class DidCommMessageReceiver$1 {
36
35
  this.messageHandlerRegistry = messageHandlerRegistry;
37
36
  this.agentContextProvider = agentContextProvider;
38
37
  this.logger = logger;
39
- this._inboundTransports = [];
40
- }
41
- get inboundTransports() {
42
- return this._inboundTransports;
43
- }
44
- registerInboundTransport(inboundTransport) {
45
- this._inboundTransports.push(inboundTransport);
46
- }
47
- async unregisterInboundTransport(inboundTransport) {
48
- this._inboundTransports = this._inboundTransports.filter((transport) => transport !== inboundTransport);
49
- await inboundTransport.stop();
50
38
  }
51
39
  /**
52
40
  * Receive and handle an inbound DIDComm message. It will determine the agent context, decrypt the message, transform it
@@ -25,7 +25,6 @@ import { CredoError, InjectionSymbols, JsonTransformer, inject, injectable } fro
25
25
  var _ref, _ref2, _ref3, _ref4, _ref5, _ref6;
26
26
  let DidCommMessageReceiver = class DidCommMessageReceiver$1 {
27
27
  constructor(envelopeService, transportService, messageSender, connectionService, dispatcher, messageHandlerRegistry, agentContextProvider, logger) {
28
- this._inboundTransports = [];
29
28
  this.envelopeService = envelopeService;
30
29
  this.transportService = transportService;
31
30
  this.messageSender = messageSender;
@@ -34,17 +33,6 @@ let DidCommMessageReceiver = class DidCommMessageReceiver$1 {
34
33
  this.messageHandlerRegistry = messageHandlerRegistry;
35
34
  this.agentContextProvider = agentContextProvider;
36
35
  this.logger = logger;
37
- this._inboundTransports = [];
38
- }
39
- get inboundTransports() {
40
- return this._inboundTransports;
41
- }
42
- registerInboundTransport(inboundTransport) {
43
- this._inboundTransports.push(inboundTransport);
44
- }
45
- async unregisterInboundTransport(inboundTransport) {
46
- this._inboundTransports = this._inboundTransports.filter((transport) => transport !== inboundTransport);
47
- await inboundTransport.stop();
48
36
  }
49
37
  /**
50
38
  * Receive and handle an inbound DIDComm message. It will determine the agent context, decrypt the message, transform it
@@ -1 +1 @@
1
- {"version":3,"file":"DidCommMessageReceiver.mjs","names":["DidCommMessageReceiver","agentContextProvider: AgentContextProvider","logger: Logger","message: DidCommMessage","messageTransformed: DidCommMessage"],"sources":["../../../../../didcomm/src/DidCommMessageReceiver.ts"],"sourcesContent":["import type { AgentContext } from '@credo-ts/core'\nimport type { DecryptedDidCommMessageContext } from './DidCommEnvelopeService'\nimport type { DidCommTransportSession } from './DidCommTransportService'\nimport type { DidCommConnectionRecord } from './modules/connections/repository'\nimport type { DidCommInboundTransport } from './transport'\nimport type { DidCommEncryptedMessage, DidCommPlaintextMessage } from './types'\n\nimport {\n type AgentContextProvider,\n CredoError,\n InjectionSymbols,\n JsonTransformer,\n type Logger,\n inject,\n injectable,\n} from '@credo-ts/core'\n\nimport { DidCommDispatcher } from './DidCommDispatcher'\nimport { DidCommEnvelopeService } from './DidCommEnvelopeService'\nimport { DidCommMessage } from './DidCommMessage'\nimport { DidCommMessageHandlerRegistry } from './DidCommMessageHandlerRegistry'\nimport { DidCommMessageSender } from './DidCommMessageSender'\nimport { DidCommTransportService } from './DidCommTransportService'\nimport { DidCommProblemReportError } from './errors'\nimport { DidCommProblemReportMessage } from './messages'\nimport { DidCommInboundMessageContext, DidCommOutboundMessageContext, DidCommProblemReportReason } from './models'\nimport { DidCommConnectionService } from './modules/connections/services'\nimport { isValidJweStructure } from './util/JWE'\nimport { canHandleMessageType, parseMessageType, replaceLegacyDidSovPrefixOnMessage } from './util/messageType'\n\n@injectable()\nexport class DidCommMessageReceiver {\n private envelopeService: DidCommEnvelopeService\n private transportService: DidCommTransportService\n private messageSender: DidCommMessageSender\n private dispatcher: DidCommDispatcher\n private logger: Logger\n private connectionService: DidCommConnectionService\n private messageHandlerRegistry: DidCommMessageHandlerRegistry\n private agentContextProvider: AgentContextProvider\n private _inboundTransports: DidCommInboundTransport[] = []\n\n public constructor(\n envelopeService: DidCommEnvelopeService,\n transportService: DidCommTransportService,\n messageSender: DidCommMessageSender,\n connectionService: DidCommConnectionService,\n dispatcher: DidCommDispatcher,\n messageHandlerRegistry: DidCommMessageHandlerRegistry,\n @inject(InjectionSymbols.AgentContextProvider) agentContextProvider: AgentContextProvider,\n @inject(InjectionSymbols.Logger) logger: Logger\n ) {\n this.envelopeService = envelopeService\n this.transportService = transportService\n this.messageSender = messageSender\n this.connectionService = connectionService\n this.dispatcher = dispatcher\n this.messageHandlerRegistry = messageHandlerRegistry\n this.agentContextProvider = agentContextProvider\n this.logger = logger\n this._inboundTransports = []\n }\n\n public get inboundTransports() {\n return this._inboundTransports\n }\n\n public registerInboundTransport(inboundTransport: DidCommInboundTransport) {\n this._inboundTransports.push(inboundTransport)\n }\n\n public async unregisterInboundTransport(inboundTransport: DidCommInboundTransport) {\n this._inboundTransports = this._inboundTransports.filter((transport) => transport !== inboundTransport)\n await inboundTransport.stop()\n }\n\n /**\n * Receive and handle an inbound DIDComm message. It will determine the agent context, decrypt the message, transform it\n * to it's corresponding message class and finally dispatch it to the dispatcher.\n *\n * @param inboundMessage the message to receive and handle\n */\n public async receiveMessage(\n inboundMessage: unknown,\n {\n session,\n connection,\n contextCorrelationId,\n receivedAt,\n }: {\n session?: DidCommTransportSession\n connection?: DidCommConnectionRecord\n contextCorrelationId?: string\n receivedAt?: Date\n } = {}\n ) {\n this.logger.debug('Agent received message')\n\n // Find agent context for the inbound message\n const agentContext = await this.agentContextProvider.getContextForInboundMessage(inboundMessage, {\n contextCorrelationId,\n })\n\n try {\n if (this.isEncryptedMessage(inboundMessage)) {\n await this.receiveEncryptedMessage(agentContext, inboundMessage as DidCommEncryptedMessage, session, receivedAt)\n } else if (this.isPlaintextMessage(inboundMessage)) {\n await this.receivePlaintextMessage(agentContext, inboundMessage, connection, receivedAt)\n } else {\n throw new CredoError('Unable to parse incoming message: unrecognized format')\n }\n } finally {\n // Always end the session for the agent context after handling the message.\n await agentContext.endSession()\n }\n }\n\n private async receivePlaintextMessage(\n agentContext: AgentContext,\n plaintextMessage: DidCommPlaintextMessage,\n connection?: DidCommConnectionRecord,\n receivedAt?: Date\n ) {\n const message = await this.transformAndValidate(agentContext, plaintextMessage)\n const messageContext = new DidCommInboundMessageContext(message, { connection, agentContext, receivedAt })\n await this.dispatcher.dispatch(messageContext)\n }\n\n private async receiveEncryptedMessage(\n agentContext: AgentContext,\n encryptedMessage: DidCommEncryptedMessage,\n session?: DidCommTransportSession,\n receivedAt?: Date\n ) {\n const decryptedMessage = await this.decryptMessage(agentContext, encryptedMessage)\n const { plaintextMessage, senderKey, recipientKey } = decryptedMessage\n\n this.logger.info(\n `Received message with type '${plaintextMessage['@type']}', recipient key ${recipientKey?.fingerprint} and sender key ${senderKey?.fingerprint}`,\n plaintextMessage\n )\n\n const connection = await this.findConnectionByMessageKeys(agentContext, decryptedMessage)\n\n const message = await this.transformAndValidate(agentContext, plaintextMessage, connection)\n\n const messageContext = new DidCommInboundMessageContext(message, {\n // Only make the connection available in message context if the connection is ready\n // To prevent unwanted usage of unready connections. Connections can still be retrieved from\n // Storage if the specific protocol allows an unready connection to be used.\n connection: connection?.isReady ? connection : undefined,\n senderKey,\n recipientKey,\n agentContext,\n receivedAt,\n encryptedMessage,\n })\n\n // We want to save a session if there is a chance of returning outbound message via inbound transport.\n // That can happen when inbound message has `return_route` set to `all` or `thread`.\n // If `return_route` defines just `thread`, we decide later whether to use session according to outbound message `threadId`.\n if (senderKey && recipientKey && message.hasAnyReturnRoute() && session) {\n this.logger.debug(`Storing session for inbound message '${message.id}'`)\n const keys = {\n recipientKeys: [senderKey],\n routingKeys: [],\n senderKey: recipientKey,\n }\n session.keys = keys\n session.inboundMessage = message\n // We allow unready connections to be attached to the session as we want to be able to\n // use return routing to make connections. This is especially useful for creating connections\n // with mediators when you don't have a public endpoint yet.\n session.connectionId = connection?.id\n messageContext.sessionId = session.id\n this.transportService.saveSession(session)\n } else if (session) {\n // No need to wait for session to stay open if we're not actually going to respond to the message.\n await session.close()\n }\n\n await this.dispatcher.dispatch(messageContext)\n }\n\n /**\n * Decrypt a message using the envelope service.\n *\n * @param message the received inbound message to decrypt\n */\n private async decryptMessage(\n agentContext: AgentContext,\n message: DidCommEncryptedMessage\n ): Promise<DecryptedDidCommMessageContext> {\n try {\n return await this.envelopeService.unpackMessage(agentContext, message)\n } catch (error) {\n this.logger.error('Error while decrypting message', {\n error,\n encryptedMessage: message,\n errorMessage: error instanceof Error ? error.message : error,\n })\n throw error\n }\n }\n\n private isPlaintextMessage(message: unknown): message is DidCommPlaintextMessage {\n if (typeof message !== 'object' || message == null) {\n return false\n }\n // If the message has a @type field we assume the message is in plaintext and it is not encrypted.\n return '@type' in message\n }\n\n private isEncryptedMessage(message: unknown): message is DidCommEncryptedMessage {\n // If the message does has valid JWE structure, we can assume the message is encrypted.\n return isValidJweStructure(message)\n }\n\n private async transformAndValidate(\n agentContext: AgentContext,\n plaintextMessage: DidCommPlaintextMessage,\n connection?: DidCommConnectionRecord | null\n ): Promise<DidCommMessage> {\n let message: DidCommMessage\n try {\n message = await this.transformMessage(plaintextMessage)\n } catch (error) {\n if (connection) await this.sendProblemReportMessage(agentContext, error.message, connection, plaintextMessage)\n throw error\n }\n return message\n }\n\n private async findConnectionByMessageKeys(\n agentContext: AgentContext,\n { recipientKey, senderKey }: DecryptedDidCommMessageContext\n ): Promise<DidCommConnectionRecord | null> {\n // We only fetch connections that are sent in AuthCrypt mode\n if (!recipientKey || !senderKey) return null\n\n // Try to find the did records that holds the sender and recipient keys\n return this.connectionService.findByKeys(agentContext, {\n senderKey,\n recipientKey,\n })\n }\n\n /**\n * Transform an plaintext DIDComm message into it's corresponding message class. Will look at all message types in the registered handlers.\n *\n * @param message the plaintext message for which to transform the message in to a class instance\n */\n private async transformMessage(message: DidCommPlaintextMessage): Promise<DidCommMessage> {\n // replace did:sov:BzCbsNYhMrjHiqZDTUASHg;spec prefix for message type with https://didcomm.org\n replaceLegacyDidSovPrefixOnMessage(message)\n\n const messageType = message['@type']\n const MessageClass = this.messageHandlerRegistry.getMessageClassForMessageType(messageType) ?? DidCommMessage\n\n // Cast the plain JSON object to specific instance of Message extended from DidCommMessage\n let messageTransformed: DidCommMessage\n try {\n messageTransformed = JsonTransformer.fromJSON(message, MessageClass)\n } catch (error) {\n this.logger.error(`Error validating message ${message['@type']}`, {\n errors: error,\n message: JSON.stringify(message),\n })\n throw new DidCommProblemReportError(`Error validating message ${message['@type']}`, {\n problemCode: DidCommProblemReportReason.MessageParseFailure,\n })\n }\n return messageTransformed\n }\n\n /**\n * Send the problem report message (https://didcomm.org/notification/1.0/problem-report) to the recipient.\n * @param message error message to send\n * @param connection connection to send the message to\n * @param plaintextMessage received inbound message\n */\n private async sendProblemReportMessage(\n agentContext: AgentContext,\n message: string,\n connection: DidCommConnectionRecord,\n plaintextMessage: DidCommPlaintextMessage\n ) {\n const messageType = parseMessageType(plaintextMessage['@type'])\n if (canHandleMessageType(DidCommProblemReportMessage, messageType)) {\n throw new CredoError(`Not sending problem report in response to problem report: ${message}`)\n }\n const problemReportMessage = new DidCommProblemReportMessage({\n description: {\n en: message,\n code: DidCommProblemReportReason.MessageParseFailure,\n },\n })\n problemReportMessage.setThread({\n parentThreadId: plaintextMessage['@id'],\n })\n const outboundMessageContext = new DidCommOutboundMessageContext(problemReportMessage, { agentContext, connection })\n if (outboundMessageContext) {\n await this.messageSender.sendMessage(outboundMessageContext)\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA+BO,mCAAMA,yBAAuB;CAWlC,AAAO,YACL,iBACA,kBACA,eACA,mBACA,YACA,wBACA,AAA+CC,sBAC/C,AAAiCC,QACjC;OAXM,qBAAgD,EAAE;AAYxD,OAAK,kBAAkB;AACvB,OAAK,mBAAmB;AACxB,OAAK,gBAAgB;AACrB,OAAK,oBAAoB;AACzB,OAAK,aAAa;AAClB,OAAK,yBAAyB;AAC9B,OAAK,uBAAuB;AAC5B,OAAK,SAAS;AACd,OAAK,qBAAqB,EAAE;;CAG9B,IAAW,oBAAoB;AAC7B,SAAO,KAAK;;CAGd,AAAO,yBAAyB,kBAA2C;AACzE,OAAK,mBAAmB,KAAK,iBAAiB;;CAGhD,MAAa,2BAA2B,kBAA2C;AACjF,OAAK,qBAAqB,KAAK,mBAAmB,QAAQ,cAAc,cAAc,iBAAiB;AACvG,QAAM,iBAAiB,MAAM;;;;;;;;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F,SAAM,IAAI,0BAA0B,4BAA4B,QAAQ,YAAY,EAClF,aAAa,2BAA2B,qBACzC,CAAC;;AAEJ,SAAO;;;;;;;;CAST,MAAc,yBACZ,cACA,SACA,YACA,kBACA;AAEA,MAAI,qBAAqB,6BADL,iBAAiB,iBAAiB,SAAS,CACG,CAChE,OAAM,IAAI,WAAW,6DAA6D,UAAU;EAE9F,MAAM,uBAAuB,IAAI,4BAA4B,EAC3D,aAAa;GACX,IAAI;GACJ,MAAM,2BAA2B;GAClC,EACF,CAAC;AACF,uBAAqB,UAAU,EAC7B,gBAAgB,iBAAiB,QAClC,CAAC;EACF,MAAM,yBAAyB,IAAI,8BAA8B,sBAAsB;GAAE;GAAc;GAAY,CAAC;AACpH,MAAI,uBACF,OAAM,KAAK,cAAc,YAAY,uBAAuB;;;;CAhRjE,YAAY;oBAmBR,OAAO,iBAAiB,qBAAqB;oBAC7C,OAAO,iBAAiB,OAAO"}
1
+ {"version":3,"file":"DidCommMessageReceiver.mjs","names":["DidCommMessageReceiver","agentContextProvider: AgentContextProvider","logger: Logger","message: DidCommMessage","messageTransformed: DidCommMessage"],"sources":["../../../../../didcomm/src/DidCommMessageReceiver.ts"],"sourcesContent":["import type { AgentContext } from '@credo-ts/core'\nimport type { DecryptedDidCommMessageContext } from './DidCommEnvelopeService'\nimport type { DidCommTransportSession } from './DidCommTransportService'\nimport type { DidCommConnectionRecord } from './modules/connections/repository'\nimport type { DidCommEncryptedMessage, DidCommPlaintextMessage } from './types'\n\nimport {\n type AgentContextProvider,\n CredoError,\n InjectionSymbols,\n JsonTransformer,\n type Logger,\n inject,\n injectable,\n} from '@credo-ts/core'\n\nimport { DidCommDispatcher } from './DidCommDispatcher'\nimport { DidCommEnvelopeService } from './DidCommEnvelopeService'\nimport { DidCommMessage } from './DidCommMessage'\nimport { DidCommMessageHandlerRegistry } from './DidCommMessageHandlerRegistry'\nimport { DidCommMessageSender } from './DidCommMessageSender'\nimport { DidCommTransportService } from './DidCommTransportService'\nimport { DidCommProblemReportError } from './errors'\nimport { DidCommProblemReportMessage } from './messages'\nimport { DidCommInboundMessageContext, DidCommOutboundMessageContext, DidCommProblemReportReason } from './models'\nimport { DidCommConnectionService } from './modules/connections/services'\nimport { isValidJweStructure } from './util/JWE'\nimport { canHandleMessageType, parseMessageType, replaceLegacyDidSovPrefixOnMessage } from './util/messageType'\n\n@injectable()\nexport class DidCommMessageReceiver {\n private envelopeService: DidCommEnvelopeService\n private transportService: DidCommTransportService\n private messageSender: DidCommMessageSender\n private dispatcher: DidCommDispatcher\n private logger: Logger\n private connectionService: DidCommConnectionService\n private messageHandlerRegistry: DidCommMessageHandlerRegistry\n private agentContextProvider: AgentContextProvider\n\n public constructor(\n envelopeService: DidCommEnvelopeService,\n transportService: DidCommTransportService,\n messageSender: DidCommMessageSender,\n connectionService: DidCommConnectionService,\n dispatcher: DidCommDispatcher,\n messageHandlerRegistry: DidCommMessageHandlerRegistry,\n @inject(InjectionSymbols.AgentContextProvider) agentContextProvider: AgentContextProvider,\n @inject(InjectionSymbols.Logger) logger: Logger\n ) {\n this.envelopeService = envelopeService\n this.transportService = transportService\n this.messageSender = messageSender\n this.connectionService = connectionService\n this.dispatcher = dispatcher\n this.messageHandlerRegistry = messageHandlerRegistry\n this.agentContextProvider = agentContextProvider\n this.logger = logger\n }\n\n /**\n * Receive and handle an inbound DIDComm message. It will determine the agent context, decrypt the message, transform it\n * to it's corresponding message class and finally dispatch it to the dispatcher.\n *\n * @param inboundMessage the message to receive and handle\n */\n public async receiveMessage(\n inboundMessage: unknown,\n {\n session,\n connection,\n contextCorrelationId,\n receivedAt,\n }: {\n session?: DidCommTransportSession\n connection?: DidCommConnectionRecord\n contextCorrelationId?: string\n receivedAt?: Date\n } = {}\n ) {\n this.logger.debug('Agent received message')\n\n // Find agent context for the inbound message\n const agentContext = await this.agentContextProvider.getContextForInboundMessage(inboundMessage, {\n contextCorrelationId,\n })\n\n try {\n if (this.isEncryptedMessage(inboundMessage)) {\n await this.receiveEncryptedMessage(agentContext, inboundMessage as DidCommEncryptedMessage, session, receivedAt)\n } else if (this.isPlaintextMessage(inboundMessage)) {\n await this.receivePlaintextMessage(agentContext, inboundMessage, connection, receivedAt)\n } else {\n throw new CredoError('Unable to parse incoming message: unrecognized format')\n }\n } finally {\n // Always end the session for the agent context after handling the message.\n await agentContext.endSession()\n }\n }\n\n private async receivePlaintextMessage(\n agentContext: AgentContext,\n plaintextMessage: DidCommPlaintextMessage,\n connection?: DidCommConnectionRecord,\n receivedAt?: Date\n ) {\n const message = await this.transformAndValidate(agentContext, plaintextMessage)\n const messageContext = new DidCommInboundMessageContext(message, { connection, agentContext, receivedAt })\n await this.dispatcher.dispatch(messageContext)\n }\n\n private async receiveEncryptedMessage(\n agentContext: AgentContext,\n encryptedMessage: DidCommEncryptedMessage,\n session?: DidCommTransportSession,\n receivedAt?: Date\n ) {\n const decryptedMessage = await this.decryptMessage(agentContext, encryptedMessage)\n const { plaintextMessage, senderKey, recipientKey } = decryptedMessage\n\n this.logger.info(\n `Received message with type '${plaintextMessage['@type']}', recipient key ${recipientKey?.fingerprint} and sender key ${senderKey?.fingerprint}`,\n plaintextMessage\n )\n\n const connection = await this.findConnectionByMessageKeys(agentContext, decryptedMessage)\n\n const message = await this.transformAndValidate(agentContext, plaintextMessage, connection)\n\n const messageContext = new DidCommInboundMessageContext(message, {\n // Only make the connection available in message context if the connection is ready\n // To prevent unwanted usage of unready connections. Connections can still be retrieved from\n // Storage if the specific protocol allows an unready connection to be used.\n connection: connection?.isReady ? connection : undefined,\n senderKey,\n recipientKey,\n agentContext,\n receivedAt,\n encryptedMessage,\n })\n\n // We want to save a session if there is a chance of returning outbound message via inbound transport.\n // That can happen when inbound message has `return_route` set to `all` or `thread`.\n // If `return_route` defines just `thread`, we decide later whether to use session according to outbound message `threadId`.\n if (senderKey && recipientKey && message.hasAnyReturnRoute() && session) {\n this.logger.debug(`Storing session for inbound message '${message.id}'`)\n const keys = {\n recipientKeys: [senderKey],\n routingKeys: [],\n senderKey: recipientKey,\n }\n session.keys = keys\n session.inboundMessage = message\n // We allow unready connections to be attached to the session as we want to be able to\n // use return routing to make connections. This is especially useful for creating connections\n // with mediators when you don't have a public endpoint yet.\n session.connectionId = connection?.id\n messageContext.sessionId = session.id\n this.transportService.saveSession(session)\n } else if (session) {\n // No need to wait for session to stay open if we're not actually going to respond to the message.\n await session.close()\n }\n\n await this.dispatcher.dispatch(messageContext)\n }\n\n /**\n * Decrypt a message using the envelope service.\n *\n * @param message the received inbound message to decrypt\n */\n private async decryptMessage(\n agentContext: AgentContext,\n message: DidCommEncryptedMessage\n ): Promise<DecryptedDidCommMessageContext> {\n try {\n return await this.envelopeService.unpackMessage(agentContext, message)\n } catch (error) {\n this.logger.error('Error while decrypting message', {\n error,\n encryptedMessage: message,\n errorMessage: error instanceof Error ? error.message : error,\n })\n throw error\n }\n }\n\n private isPlaintextMessage(message: unknown): message is DidCommPlaintextMessage {\n if (typeof message !== 'object' || message == null) {\n return false\n }\n // If the message has a @type field we assume the message is in plaintext and it is not encrypted.\n return '@type' in message\n }\n\n private isEncryptedMessage(message: unknown): message is DidCommEncryptedMessage {\n // If the message does has valid JWE structure, we can assume the message is encrypted.\n return isValidJweStructure(message)\n }\n\n private async transformAndValidate(\n agentContext: AgentContext,\n plaintextMessage: DidCommPlaintextMessage,\n connection?: DidCommConnectionRecord | null\n ): Promise<DidCommMessage> {\n let message: DidCommMessage\n try {\n message = await this.transformMessage(plaintextMessage)\n } catch (error) {\n if (connection) await this.sendProblemReportMessage(agentContext, error.message, connection, plaintextMessage)\n throw error\n }\n return message\n }\n\n private async findConnectionByMessageKeys(\n agentContext: AgentContext,\n { recipientKey, senderKey }: DecryptedDidCommMessageContext\n ): Promise<DidCommConnectionRecord | null> {\n // We only fetch connections that are sent in AuthCrypt mode\n if (!recipientKey || !senderKey) return null\n\n // Try to find the did records that holds the sender and recipient keys\n return this.connectionService.findByKeys(agentContext, {\n senderKey,\n recipientKey,\n })\n }\n\n /**\n * Transform an plaintext DIDComm message into it's corresponding message class. Will look at all message types in the registered handlers.\n *\n * @param message the plaintext message for which to transform the message in to a class instance\n */\n private async transformMessage(message: DidCommPlaintextMessage): Promise<DidCommMessage> {\n // replace did:sov:BzCbsNYhMrjHiqZDTUASHg;spec prefix for message type with https://didcomm.org\n replaceLegacyDidSovPrefixOnMessage(message)\n\n const messageType = message['@type']\n const MessageClass = this.messageHandlerRegistry.getMessageClassForMessageType(messageType) ?? DidCommMessage\n\n // Cast the plain JSON object to specific instance of Message extended from DidCommMessage\n let messageTransformed: DidCommMessage\n try {\n messageTransformed = JsonTransformer.fromJSON(message, MessageClass)\n } catch (error) {\n this.logger.error(`Error validating message ${message['@type']}`, {\n errors: error,\n message: JSON.stringify(message),\n })\n throw new DidCommProblemReportError(`Error validating message ${message['@type']}`, {\n problemCode: DidCommProblemReportReason.MessageParseFailure,\n })\n }\n return messageTransformed\n }\n\n /**\n * Send the problem report message (https://didcomm.org/notification/1.0/problem-report) to the recipient.\n * @param message error message to send\n * @param connection connection to send the message to\n * @param plaintextMessage received inbound message\n */\n private async sendProblemReportMessage(\n agentContext: AgentContext,\n message: string,\n connection: DidCommConnectionRecord,\n plaintextMessage: DidCommPlaintextMessage\n ) {\n const messageType = parseMessageType(plaintextMessage['@type'])\n if (canHandleMessageType(DidCommProblemReportMessage, messageType)) {\n throw new CredoError(`Not sending problem report in response to problem report: ${message}`)\n }\n const problemReportMessage = new DidCommProblemReportMessage({\n description: {\n en: message,\n code: DidCommProblemReportReason.MessageParseFailure,\n },\n })\n problemReportMessage.setThread({\n parentThreadId: plaintextMessage['@id'],\n })\n const outboundMessageContext = new DidCommOutboundMessageContext(problemReportMessage, { agentContext, connection })\n if (outboundMessageContext) {\n await this.messageSender.sendMessage(outboundMessageContext)\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA8BO,mCAAMA,yBAAuB;CAUlC,AAAO,YACL,iBACA,kBACA,eACA,mBACA,YACA,wBACA,AAA+CC,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Y,IAAI;EAG/F,IAAIC;AACJ,MAAI;AACF,wBAAqB,gBAAgB,SAAS,SAAS,aAAa;WAC7D,OAAO;AACd,QAAK,OAAO,MAAM,4BAA4B,QAAQ,YAAY;IAChE,QAAQ;IACR,SAAS,KAAK,UAAU,QAAQ;IACjC,CAAC;AACF,SAAM,IAAI,0BAA0B,4BAA4B,QAAQ,YAAY,EAClF,aAAa,2BAA2B,qBACzC,CAAC;;AAEJ,SAAO;;;;;;;;CAST,MAAc,yBACZ,cACA,SACA,YACA,kBACA;AAEA,MAAI,qBAAqB,6BADL,iBAAiB,iBAAiB,SAAS,CACG,CAChE,OAAM,IAAI,WAAW,6DAA6D,UAAU;EAE9F,MAAM,uBAAuB,IAAI,4BAA4B,EAC3D,aAAa;GACX,IAAI;GACJ,MAAM,2BAA2B;GAClC,EACF,CAAC;AACF,uBAAqB,UAAU,EAC7B,gBAAgB,iBAAiB,QAClC,CAAC;EACF,MAAM,yBAAyB,IAAI,8BAA8B,sBAAsB;GAAE;GAAc;GAAY,CAAC;AACpH,MAAI,uBACF,OAAM,KAAK,cAAc,YAAY,uBAAuB;;;;CAjQjE,YAAY;oBAkBR,OAAO,iBAAiB,qBAAqB;oBAC7C,OAAO,iBAAiB,OAAO"}
@@ -20,23 +20,11 @@ __credo_ts_core = require_rolldown_runtime.__toESM(__credo_ts_core);
20
20
  var _ref, _ref2, _ref3, _ref4, _ref5;
21
21
  let DidCommMessageSender = class DidCommMessageSender$1 {
22
22
  constructor(envelopeService, transportService, didCommModuleConfig, didCommDocumentService, eventEmitter) {
23
- this._outboundTransports = [];
24
23
  this.envelopeService = envelopeService;
25
24
  this.transportService = transportService;
26
- this.queueTransportRepository = didCommModuleConfig.queueTransportRepository;
25
+ this.didCommModuleConfig = didCommModuleConfig;
27
26
  this.didCommDocumentService = didCommDocumentService;
28
27
  this.eventEmitter = eventEmitter;
29
- this._outboundTransports = [];
30
- }
31
- get outboundTransports() {
32
- return this._outboundTransports;
33
- }
34
- registerOutboundTransport(outboundTransport) {
35
- this._outboundTransports.push(outboundTransport);
36
- }
37
- async unregisterOutboundTransport(outboundTransport) {
38
- this._outboundTransports = this.outboundTransports.filter((transport) => transport !== outboundTransport);
39
- await outboundTransport.stop();
40
28
  }
41
29
  async packMessage(agentContext, { keys, message, endpoint }) {
42
30
  return {
@@ -63,12 +51,12 @@ let DidCommMessageSender = class DidCommMessageSender$1 {
63
51
  agentContext.config.logger.debug(`Sending packed message via session failed with error: ${error.message}.`, error);
64
52
  }
65
53
  const { services, queueService } = await this.retrieveServicesByConnection(agentContext, connection, options?.transportPriority);
66
- if (this.outboundTransports.length === 0 && !queueService) throw new __credo_ts_core.CredoError("Agent has no outbound transport!");
54
+ if (this.didCommModuleConfig.outboundTransports.length === 0 && !queueService) throw new __credo_ts_core.CredoError("Agent has no outbound transport!");
67
55
  for await (const service of services) {
68
56
  agentContext.config.logger.debug("Sending outbound message to service:", { service });
69
57
  try {
70
58
  const protocolScheme = __credo_ts_core.utils.getProtocolScheme(service.serviceEndpoint);
71
- for (const transport of this.outboundTransports) if (transport.supportedSchemes.includes(protocolScheme)) {
59
+ for (const transport of this.didCommModuleConfig.outboundTransports) if (transport.supportedSchemes.includes(protocolScheme)) {
72
60
  await transport.sendMessage({
73
61
  payload: encryptedMessage,
74
62
  endpoint: service.serviceEndpoint,
@@ -86,7 +74,7 @@ let DidCommMessageSender = class DidCommMessageSender$1 {
86
74
  }
87
75
  if (queueService) {
88
76
  agentContext.config.logger.debug(`Queue packed message for connection ${connection.id} (${connection.theirLabel})`);
89
- await this.queueTransportRepository.addMessage(agentContext, {
77
+ await this.didCommModuleConfig.queueTransportRepository.addMessage(agentContext, {
90
78
  connectionId: connection.id,
91
79
  recipientDids: [(0, __credo_ts_core.verkeyToDidKey)(recipientKey)],
92
80
  payload: encryptedMessage
@@ -191,7 +179,7 @@ let DidCommMessageSender = class DidCommMessageSender$1 {
191
179
  senderKey: senderVerificationMethod.publicJwk
192
180
  };
193
181
  const encryptedMessage = await this.envelopeService.packMessage(agentContext, message, keys$1);
194
- await this.queueTransportRepository.addMessage(agentContext, {
182
+ await this.didCommModuleConfig.queueTransportRepository.addMessage(agentContext, {
195
183
  connectionId: connection.id,
196
184
  recipientDids: keys$1.recipientKeys.map((item) => new __credo_ts_core.DidKey(item).did),
197
185
  payload: encryptedMessage
@@ -235,7 +223,7 @@ let DidCommMessageSender = class DidCommMessageSender$1 {
235
223
  const { agentContext, message, serviceParams, connection } = outboundMessageContext;
236
224
  if (!serviceParams) throw new __credo_ts_core.CredoError("No service parameters found in outbound message context");
237
225
  const { service, senderKey, returnRoute } = serviceParams;
238
- if (this.outboundTransports.length === 0) throw new __credo_ts_core.CredoError("Agent has no outbound transport!");
226
+ if (this.didCommModuleConfig.outboundTransports.length === 0) throw new __credo_ts_core.CredoError("Agent has no outbound transport!");
239
227
  agentContext.config.logger.debug("Sending outbound message to service:", {
240
228
  messageId: message.id,
241
229
  service: {
@@ -266,7 +254,7 @@ let DidCommMessageSender = class DidCommMessageSender$1 {
266
254
  });
267
255
  outboundPackage.endpoint = service.serviceEndpoint;
268
256
  outboundPackage.connectionId = connection?.id;
269
- for (const transport of this.outboundTransports) {
257
+ for (const transport of this.didCommModuleConfig.outboundTransports) {
270
258
  const protocolScheme = __credo_ts_core.utils.getProtocolScheme(service.serviceEndpoint);
271
259
  if (!protocolScheme) agentContext.config.logger.warn("Service does not have a protocol scheme.");
272
260
  else if (transport.supportedSchemes.includes(protocolScheme)) {
@@ -18,23 +18,11 @@ import { AgentContext, CredoError, DidKey, DidsApi, EventEmitter, Kms, MessageVa
18
18
  var _ref, _ref2, _ref3, _ref4, _ref5;
19
19
  let DidCommMessageSender = class DidCommMessageSender$1 {
20
20
  constructor(envelopeService, transportService, didCommModuleConfig, didCommDocumentService, eventEmitter) {
21
- this._outboundTransports = [];
22
21
  this.envelopeService = envelopeService;
23
22
  this.transportService = transportService;
24
- this.queueTransportRepository = didCommModuleConfig.queueTransportRepository;
23
+ this.didCommModuleConfig = didCommModuleConfig;
25
24
  this.didCommDocumentService = didCommDocumentService;
26
25
  this.eventEmitter = eventEmitter;
27
- this._outboundTransports = [];
28
- }
29
- get outboundTransports() {
30
- return this._outboundTransports;
31
- }
32
- registerOutboundTransport(outboundTransport) {
33
- this._outboundTransports.push(outboundTransport);
34
- }
35
- async unregisterOutboundTransport(outboundTransport) {
36
- this._outboundTransports = this.outboundTransports.filter((transport) => transport !== outboundTransport);
37
- await outboundTransport.stop();
38
26
  }
39
27
  async packMessage(agentContext, { keys, message, endpoint }) {
40
28
  return {
@@ -61,12 +49,12 @@ let DidCommMessageSender = class DidCommMessageSender$1 {
61
49
  agentContext.config.logger.debug(`Sending packed message via session failed with error: ${error.message}.`, error);
62
50
  }
63
51
  const { services, queueService } = await this.retrieveServicesByConnection(agentContext, connection, options?.transportPriority);
64
- if (this.outboundTransports.length === 0 && !queueService) throw new CredoError("Agent has no outbound transport!");
52
+ if (this.didCommModuleConfig.outboundTransports.length === 0 && !queueService) throw new CredoError("Agent has no outbound transport!");
65
53
  for await (const service of services) {
66
54
  agentContext.config.logger.debug("Sending outbound message to service:", { service });
67
55
  try {
68
56
  const protocolScheme = utils.getProtocolScheme(service.serviceEndpoint);
69
- for (const transport of this.outboundTransports) if (transport.supportedSchemes.includes(protocolScheme)) {
57
+ for (const transport of this.didCommModuleConfig.outboundTransports) if (transport.supportedSchemes.includes(protocolScheme)) {
70
58
  await transport.sendMessage({
71
59
  payload: encryptedMessage,
72
60
  endpoint: service.serviceEndpoint,
@@ -84,7 +72,7 @@ let DidCommMessageSender = class DidCommMessageSender$1 {
84
72
  }
85
73
  if (queueService) {
86
74
  agentContext.config.logger.debug(`Queue packed message for connection ${connection.id} (${connection.theirLabel})`);
87
- await this.queueTransportRepository.addMessage(agentContext, {
75
+ await this.didCommModuleConfig.queueTransportRepository.addMessage(agentContext, {
88
76
  connectionId: connection.id,
89
77
  recipientDids: [verkeyToDidKey(recipientKey)],
90
78
  payload: encryptedMessage
@@ -189,7 +177,7 @@ let DidCommMessageSender = class DidCommMessageSender$1 {
189
177
  senderKey: senderVerificationMethod.publicJwk
190
178
  };
191
179
  const encryptedMessage = await this.envelopeService.packMessage(agentContext, message, keys$1);
192
- await this.queueTransportRepository.addMessage(agentContext, {
180
+ await this.didCommModuleConfig.queueTransportRepository.addMessage(agentContext, {
193
181
  connectionId: connection.id,
194
182
  recipientDids: keys$1.recipientKeys.map((item) => new DidKey(item).did),
195
183
  payload: encryptedMessage
@@ -233,7 +221,7 @@ let DidCommMessageSender = class DidCommMessageSender$1 {
233
221
  const { agentContext, message, serviceParams, connection } = outboundMessageContext;
234
222
  if (!serviceParams) throw new CredoError("No service parameters found in outbound message context");
235
223
  const { service, senderKey, returnRoute } = serviceParams;
236
- if (this.outboundTransports.length === 0) throw new CredoError("Agent has no outbound transport!");
224
+ if (this.didCommModuleConfig.outboundTransports.length === 0) throw new CredoError("Agent has no outbound transport!");
237
225
  agentContext.config.logger.debug("Sending outbound message to service:", {
238
226
  messageId: message.id,
239
227
  service: {
@@ -264,7 +252,7 @@ let DidCommMessageSender = class DidCommMessageSender$1 {
264
252
  });
265
253
  outboundPackage.endpoint = service.serviceEndpoint;
266
254
  outboundPackage.connectionId = connection?.id;
267
- for (const transport of this.outboundTransports) {
255
+ for (const transport of this.didCommModuleConfig.outboundTransports) {
268
256
  const protocolScheme = utils.getProtocolScheme(service.serviceEndpoint);
269
257
  if (!protocolScheme) agentContext.config.logger.warn("Service does not have a protocol scheme.");
270
258
  else if (transport.supportedSchemes.includes(protocolScheme)) {
@@ -1 +1 @@
1
- {"version":3,"file":"DidCommMessageSender.mjs","names":["DidCommMessageSender","errors: Error[]","services: ResolvedDidCommService[]","queueService: ResolvedDidCommService | undefined","keys","session: DidCommTransportSession | undefined","didCommServices: ResolvedDidCommService[]"],"sources":["../../../../../didcomm/src/DidCommMessageSender.ts"],"sourcesContent":["import type { EnvelopeKeys } from './DidCommEnvelopeService'\nimport type { DidCommMessageSentEvent } from './DidCommEvents'\nimport type { DidCommMessage } from './DidCommMessage'\nimport type { DidCommTransportSession } from './DidCommTransportService'\nimport type { DidCommConnectionRecord } from './modules/connections/repository'\nimport type { DidCommOutOfBandRecord } from './modules/oob/repository'\nimport type { DidCommOutboundTransport } from './transport/DidCommOutboundTransport'\nimport type { DidCommEncryptedMessage, DidCommOutboundPackage } from './types'\n\nimport {\n AgentContext,\n CredoError,\n DidKey,\n DidsApi,\n EventEmitter,\n Kms,\n MessageValidator,\n type ResolvedDidCommService,\n didKeyToEd25519PublicJwk,\n getPublicJwkFromVerificationMethod,\n injectable,\n utils,\n verkeyToDidKey,\n} from '@credo-ts/core'\n\nimport { DidCommEnvelopeService } from './DidCommEnvelopeService'\nimport { DidCommEventTypes } from './DidCommEvents'\nimport { DidCommModuleConfig } from './DidCommModuleConfig'\nimport { DidCommTransportService } from './DidCommTransportService'\nimport { DID_COMM_TRANSPORT_QUEUE } from './constants'\nimport { ReturnRouteTypes } from './decorators/transport/TransportDecorator'\nimport { MessageSendingError } from './errors'\nimport { DidCommOutboundMessageContext, OutboundMessageSendStatus } from './models'\nimport { DidCommDocumentService } from './services/DidCommDocumentService'\nimport type { DidCommQueueTransportRepository } from './transport'\n\nexport interface TransportPriorityOptions {\n schemes: string[]\n restrictive?: boolean\n}\n\n@injectable()\nexport class DidCommMessageSender {\n private envelopeService: DidCommEnvelopeService\n private transportService: DidCommTransportService\n private queueTransportRepository: DidCommQueueTransportRepository\n private didCommDocumentService: DidCommDocumentService\n private eventEmitter: EventEmitter\n private _outboundTransports: DidCommOutboundTransport[] = []\n\n public constructor(\n envelopeService: DidCommEnvelopeService,\n transportService: DidCommTransportService,\n didCommModuleConfig: DidCommModuleConfig,\n didCommDocumentService: DidCommDocumentService,\n eventEmitter: EventEmitter\n ) {\n this.envelopeService = envelopeService\n this.transportService = transportService\n this.queueTransportRepository = didCommModuleConfig.queueTransportRepository\n this.didCommDocumentService = didCommDocumentService\n this.eventEmitter = eventEmitter\n this._outboundTransports = []\n }\n\n public get outboundTransports() {\n return this._outboundTransports\n }\n\n public registerOutboundTransport(outboundTransport: DidCommOutboundTransport) {\n this._outboundTransports.push(outboundTransport)\n }\n\n public async unregisterOutboundTransport(outboundTransport: DidCommOutboundTransport) {\n this._outboundTransports = this.outboundTransports.filter((transport) => transport !== outboundTransport)\n await outboundTransport.stop()\n }\n\n public async packMessage(\n agentContext: AgentContext,\n {\n keys,\n message,\n endpoint,\n }: {\n keys: EnvelopeKeys\n message: DidCommMessage\n endpoint: string\n }\n ): Promise<DidCommOutboundPackage> {\n const encryptedMessage = await this.envelopeService.packMessage(agentContext, message, keys)\n\n return {\n payload: encryptedMessage,\n responseRequested: message.hasAnyReturnRoute(),\n endpoint,\n }\n }\n\n private async sendMessageToSession(\n agentContext: AgentContext,\n session: DidCommTransportSession,\n message: DidCommMessage\n ) {\n agentContext.config.logger.debug(`Packing message and sending it via existing session ${session.type}...`)\n if (!session.keys) {\n throw new CredoError(`There are no keys for the given ${session.type} transport session.`)\n }\n const encryptedMessage = await this.envelopeService.packMessage(agentContext, message, session.keys)\n agentContext.config.logger.debug('Sending message')\n await session.send(agentContext, encryptedMessage)\n }\n\n public async sendPackage(\n agentContext: AgentContext,\n {\n connection,\n encryptedMessage,\n recipientKey,\n options,\n }: {\n connection: DidCommConnectionRecord\n recipientKey: string\n encryptedMessage: DidCommEncryptedMessage\n options?: { transportPriority?: TransportPriorityOptions }\n }\n ) {\n const errors: Error[] = []\n\n // Try to send to already open session\n const session = this.transportService.findSessionByConnectionId(connection.id)\n if (session?.inboundMessage?.hasReturnRouting()) {\n try {\n await session.send(agentContext, encryptedMessage)\n return\n } catch (error) {\n errors.push(error)\n agentContext.config.logger.debug(\n `Sending packed message via session failed with error: ${error.message}.`,\n error\n )\n }\n }\n\n // Retrieve DIDComm services\n const { services, queueService } = await this.retrieveServicesByConnection(\n agentContext,\n connection,\n options?.transportPriority\n )\n\n if (this.outboundTransports.length === 0 && !queueService) {\n throw new CredoError('Agent has no outbound transport!')\n }\n\n // Loop trough all available services and try to send the message\n for await (const service of services) {\n agentContext.config.logger.debug('Sending outbound message to service:', { service })\n try {\n const protocolScheme = utils.getProtocolScheme(service.serviceEndpoint)\n for (const transport of this.outboundTransports) {\n if (transport.supportedSchemes.includes(protocolScheme)) {\n await transport.sendMessage({\n payload: encryptedMessage,\n endpoint: service.serviceEndpoint,\n connectionId: connection.id,\n })\n break\n }\n }\n return\n } catch (error) {\n agentContext.config.logger.debug(\n `Sending outbound message to service with id ${service.id} failed with the following error:`,\n {\n message: error.message,\n error: error,\n }\n )\n }\n }\n\n // We didn't succeed to send the message over open session, or directly to serviceEndpoint\n // If the other party shared a queue service endpoint in their did doc we queue the message\n if (queueService) {\n agentContext.config.logger.debug(\n `Queue packed message for connection ${connection.id} (${connection.theirLabel})`\n )\n await this.queueTransportRepository.addMessage(agentContext, {\n connectionId: connection.id,\n recipientDids: [verkeyToDidKey(recipientKey)],\n payload: encryptedMessage,\n })\n return\n }\n\n // Message is undeliverable\n agentContext.config.logger.error(\n `Message is undeliverable to connection ${connection.id} (${connection.theirLabel})`,\n {\n message: encryptedMessage,\n errors,\n connection,\n }\n )\n throw new CredoError(`Message is undeliverable to connection ${connection.id} (${connection.theirLabel})`)\n }\n\n public async sendMessage(\n outboundMessageContext: DidCommOutboundMessageContext,\n options?: {\n transportPriority?: TransportPriorityOptions\n }\n ) {\n const { agentContext, connection, outOfBand, message } = outboundMessageContext\n const errors: Error[] = []\n\n if (outboundMessageContext.isOutboundServiceMessage()) {\n return this.sendMessageToService(outboundMessageContext)\n }\n\n if (!connection) {\n agentContext.config.logger.error('Outbound message has no associated connection')\n this.emitMessageSentEvent(outboundMessageContext, OutboundMessageSendStatus.Undeliverable)\n throw new MessageSendingError('Outbound message has no associated connection', {\n outboundMessageContext,\n })\n }\n\n agentContext.config.logger.debug('Send outbound message', {\n message,\n connectionId: connection.id,\n })\n\n const session = this.findSessionForOutboundContext(outboundMessageContext)\n\n if (session) {\n agentContext.config.logger.debug(\n `Found session with return routing for message '${message.id}' (connection '${connection.id}'`\n )\n\n try {\n await this.sendMessageToSession(agentContext, session, message)\n this.emitMessageSentEvent(outboundMessageContext, OutboundMessageSendStatus.SentToSession)\n return\n } catch (error) {\n errors.push(error)\n agentContext.config.logger.debug(\n `Sending an outbound message via session failed with error: ${error.message}.`,\n error\n )\n }\n }\n\n // Retrieve DIDComm services\n let services: ResolvedDidCommService[] = []\n let queueService: ResolvedDidCommService | undefined\n\n try {\n ;({ services, queueService } = await this.retrieveServicesByConnection(\n agentContext,\n connection,\n options?.transportPriority,\n outOfBand\n ))\n } catch (error) {\n agentContext.config.logger.error(`Unable to retrieve services for connection '${connection.id}. ${error.message}`)\n this.emitMessageSentEvent(outboundMessageContext, OutboundMessageSendStatus.Undeliverable)\n throw new MessageSendingError(`Unable to retrieve services for connection '${connection.id}`, {\n outboundMessageContext,\n cause: error,\n })\n }\n\n if (!connection.did) {\n agentContext.config.logger.error(\n `Unable to send message using connection '${connection.id}' that doesn't have a did`\n )\n this.emitMessageSentEvent(outboundMessageContext, OutboundMessageSendStatus.Undeliverable)\n throw new MessageSendingError(\n `Unable to send message using connection '${connection.id}' that doesn't have a did`,\n { outboundMessageContext }\n )\n }\n\n const dids = agentContext.resolve(DidsApi)\n const { didDocument, keys } = await dids.resolveCreatedDidDocumentWithKeys(connection.did).catch((error) => {\n agentContext.config.logger.error(\n `Unable to send message using connection '${connection.id}', unable to resolve did`,\n {\n error,\n }\n )\n this.emitMessageSentEvent(outboundMessageContext, OutboundMessageSendStatus.Undeliverable)\n throw new MessageSendingError(\n `Unable to send message using connection '${connection.id}'. Unble to resolve did`,\n { outboundMessageContext, cause: error }\n )\n })\n\n const authentication = didDocument.authentication\n ?.map((a) => {\n const verificationMethod = typeof a === 'string' ? didDocument.dereferenceVerificationMethod(a) : a\n const publicJwk = getPublicJwkFromVerificationMethod(verificationMethod)\n const kmsKeyId = keys?.find((key) => verificationMethod.id.endsWith(key.didDocumentRelativeKeyId))?.kmsKeyId\n\n // Set stored key id, or fallback to legacy key id\n publicJwk.keyId = kmsKeyId ?? publicJwk.legacyKeyId\n\n return { verificationMethod, publicJwk, kmsKeyId }\n })\n .filter((v): v is typeof v & { publicJwk: Kms.PublicJwk<Kms.Ed25519PublicJwk> } =>\n v.publicJwk.is(Kms.Ed25519PublicJwk)\n )\n\n // We take the first one with a kms key id. Otherwise we pick the first\n const senderVerificationMethod = authentication?.find((a) => a.kmsKeyId !== undefined) ?? authentication?.[0]\n if (!senderVerificationMethod) {\n throw new MessageSendingError(\n `Unable to determine sender key for did ${connection.did}, no available Ed25519 keys`,\n {\n outboundMessageContext,\n }\n )\n }\n\n // If the returnRoute is already set we won't override it. This allows to set the returnRoute manually if this is desired.\n const shouldAddReturnRoute =\n message.transport?.returnRoute === undefined && !this.transportService.hasInboundEndpoint(didDocument)\n\n // Loop trough all available services and try to send the message\n for await (const service of services) {\n try {\n // Enable return routing if the our did document does not have any inbound endpoint for given sender key\n await this.sendToService(\n new DidCommOutboundMessageContext(message, {\n agentContext,\n serviceParams: {\n service,\n senderKey: senderVerificationMethod.publicJwk,\n returnRoute: shouldAddReturnRoute,\n },\n connection,\n })\n )\n this.emitMessageSentEvent(outboundMessageContext, OutboundMessageSendStatus.SentToTransport)\n return\n } catch (error) {\n errors.push(error)\n agentContext.config.logger.debug(\n `Sending outbound message to service with id ${service.id} failed with the following error:`,\n {\n message: error.message,\n error: error,\n }\n )\n }\n }\n\n // We didn't succeed to send the message over open session, or directly to serviceEndpoint\n // If the other party shared a queue service endpoint in their did doc we queue the message\n if (queueService && message.allowQueueTransport) {\n agentContext.config.logger.debug(`Queue message for connection ${connection.id} (${connection.theirLabel})`)\n\n const keys = {\n recipientKeys: queueService.recipientKeys,\n routingKeys: queueService.routingKeys,\n senderKey: senderVerificationMethod.publicJwk,\n }\n\n const encryptedMessage = await this.envelopeService.packMessage(agentContext, message, keys)\n await this.queueTransportRepository.addMessage(agentContext, {\n connectionId: connection.id,\n recipientDids: keys.recipientKeys.map((item) => new DidKey(item).did),\n payload: encryptedMessage,\n })\n\n this.emitMessageSentEvent(outboundMessageContext, OutboundMessageSendStatus.QueuedForPickup)\n\n return\n }\n\n // Message is undeliverable\n agentContext.config.logger.error(\n `Message is undeliverable to connection ${connection.id} (${connection.theirLabel})`,\n {\n message,\n errors,\n connection,\n }\n )\n this.emitMessageSentEvent(outboundMessageContext, OutboundMessageSendStatus.Undeliverable)\n\n throw new MessageSendingError(\n `Message is undeliverable to connection ${connection.id} (${connection.theirLabel}). \\n\\nReasons:\\n\\t- ${errors.map((e) => e.message).join('\\n\\t-')}`,\n { outboundMessageContext }\n )\n }\n\n private async sendMessageToService(outboundMessageContext: DidCommOutboundMessageContext) {\n const session = this.findSessionForOutboundContext(outboundMessageContext)\n\n if (session) {\n outboundMessageContext.agentContext.config.logger.debug(\n `Found session with return routing for message '${outboundMessageContext.message.id}'`\n )\n try {\n await this.sendMessageToSession(outboundMessageContext.agentContext, session, outboundMessageContext.message)\n this.emitMessageSentEvent(outboundMessageContext, OutboundMessageSendStatus.SentToSession)\n return\n } catch (error) {\n outboundMessageContext.agentContext.config.logger.debug(\n `Sending an outbound message via session failed with error: ${error.message}.`,\n error\n )\n }\n }\n\n // If there is no session try sending to service instead\n try {\n await this.sendToService(outboundMessageContext)\n this.emitMessageSentEvent(outboundMessageContext, OutboundMessageSendStatus.SentToTransport)\n } catch (error) {\n outboundMessageContext.agentContext.config.logger.error(\n `Message is undeliverable to service with id ${outboundMessageContext.serviceParams?.service.id}: ${error.message}`,\n {\n message: outboundMessageContext.message,\n error,\n }\n )\n this.emitMessageSentEvent(outboundMessageContext, OutboundMessageSendStatus.Undeliverable)\n\n throw new MessageSendingError(\n `Message is undeliverable to service with id ${outboundMessageContext.serviceParams?.service.id}: ${error.message}`,\n { outboundMessageContext }\n )\n }\n }\n\n private async sendToService(outboundMessageContext: DidCommOutboundMessageContext) {\n const { agentContext, message, serviceParams, connection } = outboundMessageContext\n\n if (!serviceParams) {\n throw new CredoError('No service parameters found in outbound message context')\n }\n const { service, senderKey, returnRoute } = serviceParams\n\n if (this.outboundTransports.length === 0) {\n throw new CredoError('Agent has no outbound transport!')\n }\n\n agentContext.config.logger.debug('Sending outbound message to service:', {\n messageId: message.id,\n service: { ...service, recipientKeys: 'omitted...', routingKeys: 'omitted...' },\n })\n\n const keys = {\n recipientKeys: service.recipientKeys,\n routingKeys: service.routingKeys,\n senderKey,\n }\n\n // Set return routing for message if requested\n if (returnRoute) {\n message.setReturnRouting(ReturnRouteTypes.all)\n }\n\n try {\n MessageValidator.validateSync(message)\n } catch (error) {\n agentContext.config.logger.error(\n `Aborting sending outbound message ${message.type} to ${service.serviceEndpoint}. Message validation failed`,\n {\n errors: error,\n message: message.toJSON(),\n }\n )\n\n throw error\n }\n\n const outboundPackage = await this.packMessage(agentContext, { message, keys, endpoint: service.serviceEndpoint })\n outboundPackage.endpoint = service.serviceEndpoint\n outboundPackage.connectionId = connection?.id\n for (const transport of this.outboundTransports) {\n const protocolScheme = utils.getProtocolScheme(service.serviceEndpoint)\n if (!protocolScheme) {\n agentContext.config.logger.warn('Service does not have a protocol scheme.')\n } else if (transport.supportedSchemes.includes(protocolScheme)) {\n await transport.sendMessage(outboundPackage)\n return\n }\n }\n throw new MessageSendingError(`Unable to send message to service: ${service.serviceEndpoint}`, {\n outboundMessageContext,\n })\n }\n\n private findSessionForOutboundContext(outboundContext: DidCommOutboundMessageContext) {\n let session: DidCommTransportSession | undefined = undefined\n\n // Use session id from outbound context if present, or use the session from the inbound message context\n const sessionId = outboundContext.sessionId ?? outboundContext.inboundMessageContext?.sessionId\n\n // Try to find session by id\n if (sessionId) {\n session = this.transportService.findSessionById(sessionId)\n }\n\n // Try to find session by connection id\n if (!session && outboundContext.connection?.id) {\n session = this.transportService.findSessionByConnectionId(outboundContext.connection.id)\n }\n\n return session?.inboundMessage?.hasAnyReturnRoute() ? session : null\n }\n\n private async retrieveServicesByConnection(\n agentContext: AgentContext,\n connection: DidCommConnectionRecord,\n transportPriority?: TransportPriorityOptions,\n outOfBand?: DidCommOutOfBandRecord\n ) {\n agentContext.config.logger.debug(\n `Retrieving services for connection '${connection.id}' (${connection.theirLabel})`,\n {\n transportPriority,\n connection,\n }\n )\n\n let didCommServices: ResolvedDidCommService[] = []\n\n if (connection.theirDid) {\n agentContext.config.logger.debug(`Resolving services for connection theirDid ${connection.theirDid}.`)\n didCommServices = await this.didCommDocumentService.resolveServicesFromDid(agentContext, connection.theirDid)\n } else if (outOfBand) {\n agentContext.config.logger.debug(`Resolving services from out-of-band record ${outOfBand.id}.`)\n if (connection.isRequester) {\n for (const service of outOfBand.outOfBandInvitation.getServices()) {\n // Resolve dids to DIDDocs to retrieve services\n if (typeof service === 'string') {\n agentContext.config.logger.debug(`Resolving services for did ${service}.`)\n didCommServices.push(...(await this.didCommDocumentService.resolveServicesFromDid(agentContext, service)))\n } else {\n // Out of band inline service contains keys encoded as did:key references\n didCommServices.push({\n id: service.id,\n recipientKeys: service.recipientKeys.map(didKeyToEd25519PublicJwk),\n routingKeys: service.routingKeys?.map(didKeyToEd25519PublicJwk) || [],\n serviceEndpoint: service.serviceEndpoint,\n })\n }\n }\n }\n }\n\n // Separate queue service out\n let services = didCommServices.filter((s) => !isDidCommTransportQueue(s.serviceEndpoint))\n const queueService = didCommServices.find((s) => isDidCommTransportQueue(s.serviceEndpoint))\n\n // If restrictive will remove services not listed in schemes list\n if (transportPriority?.restrictive) {\n services = services.filter((service) => {\n const serviceSchema = utils.getProtocolScheme(service.serviceEndpoint)\n return transportPriority.schemes.includes(serviceSchema)\n })\n }\n\n // If transport priority is set we will sort services by our priority\n if (transportPriority?.schemes) {\n services = services.sort((a, b) => {\n const aScheme = utils.getProtocolScheme(a.serviceEndpoint)\n const bScheme = utils.getProtocolScheme(b.serviceEndpoint)\n return transportPriority?.schemes.indexOf(aScheme) - transportPriority?.schemes.indexOf(bScheme)\n })\n }\n\n agentContext.config.logger.debug(\n `Retrieved ${services.length} services for message to connection '${connection.id}'(${connection.theirLabel})'`,\n { hasQueueService: queueService !== undefined, transportPriority }\n )\n return { services, queueService }\n }\n\n private emitMessageSentEvent(\n outboundMessageContext: DidCommOutboundMessageContext,\n status: OutboundMessageSendStatus\n ) {\n const { agentContext } = outboundMessageContext\n this.eventEmitter.emit<DidCommMessageSentEvent>(agentContext, {\n type: DidCommEventTypes.DidCommMessageSent,\n payload: {\n message: outboundMessageContext,\n status,\n },\n })\n }\n}\n\nexport function isDidCommTransportQueue(serviceEndpoint: string): serviceEndpoint is typeof DID_COMM_TRANSPORT_QUEUE {\n return serviceEndpoint === DID_COMM_TRANSPORT_QUEUE\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AA0CO,iCAAMA,uBAAqB;CAQhC,AAAO,YACL,iBACA,kBACA,qBACA,wBACA,cACA;OARM,sBAAkD,EAAE;AAS1D,OAAK,kBAAkB;AACvB,OAAK,mBAAmB;AACxB,OAAK,2BAA2B,oBAAoB;AACpD,OAAK,yBAAyB;AAC9B,OAAK,eAAe;AACpB,OAAK,sBAAsB,EAAE;;CAG/B,IAAW,qBAAqB;AAC9B,SAAO,KAAK;;CAGd,AAAO,0BAA0B,mBAA6C;AAC5E,OAAK,oBAAoB,KAAK,kBAAkB;;CAGlD,MAAa,4BAA4B,mBAA6C;AACpF,OAAK,sBAAsB,KAAK,mBAAmB,QAAQ,cAAc,cAAc,kBAAkB;AACzG,QAAM,kBAAkB,MAAM;;CAGhC,MAAa,YACX,cACA,EACE,MACA,SACA,YAM+B;AAGjC,SAAO;GACL,SAHuB,MAAM,KAAK,gBAAgB,YAAY,cAAc,SAAS,KAAK;GAI1F,mBAAmB,QAAQ,mBAAmB;GAC9C;GACD;;CAGH,MAAc,qBACZ,cACA,SACA,SACA;AACA,eAAa,OAAO,OAAO,MAAM,uDAAuD,QAAQ,KAAK,KAAK;AAC1G,MAAI,CAAC,QAAQ,KACX,OAAM,IAAI,WAAW,mCAAmC,QAAQ,KAAK,qBAAqB;EAE5F,MAAM,mBAAmB,MAAM,KAAK,gBAAgB,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queueService: ResolvedDidCommService | undefined","keys","session: DidCommTransportSession | undefined","didCommServices: ResolvedDidCommService[]"],"sources":["../../../../../didcomm/src/DidCommMessageSender.ts"],"sourcesContent":["import type { EnvelopeKeys } from './DidCommEnvelopeService'\nimport type { DidCommMessageSentEvent } from './DidCommEvents'\nimport type { DidCommMessage } from './DidCommMessage'\nimport type { DidCommTransportSession } from './DidCommTransportService'\nimport type { DidCommConnectionRecord } from './modules/connections/repository'\nimport type { DidCommOutOfBandRecord } from './modules/oob/repository'\nimport type { DidCommEncryptedMessage, DidCommOutboundPackage } from './types'\n\nimport {\n AgentContext,\n CredoError,\n DidKey,\n DidsApi,\n EventEmitter,\n Kms,\n MessageValidator,\n type ResolvedDidCommService,\n didKeyToEd25519PublicJwk,\n getPublicJwkFromVerificationMethod,\n injectable,\n utils,\n verkeyToDidKey,\n} from '@credo-ts/core'\n\nimport { DidCommEnvelopeService } from './DidCommEnvelopeService'\nimport { DidCommEventTypes } from './DidCommEvents'\nimport { DidCommModuleConfig } from './DidCommModuleConfig'\nimport { DidCommTransportService } from './DidCommTransportService'\nimport { DID_COMM_TRANSPORT_QUEUE } from './constants'\nimport { ReturnRouteTypes } from './decorators/transport/TransportDecorator'\nimport { MessageSendingError } from './errors'\nimport { DidCommOutboundMessageContext, OutboundMessageSendStatus } from './models'\nimport { DidCommDocumentService } from './services/DidCommDocumentService'\n\nexport interface TransportPriorityOptions {\n schemes: string[]\n restrictive?: boolean\n}\n\n@injectable()\nexport class DidCommMessageSender {\n private envelopeService: DidCommEnvelopeService\n private transportService: DidCommTransportService\n private didCommModuleConfig: DidCommModuleConfig\n private didCommDocumentService: DidCommDocumentService\n private eventEmitter: EventEmitter\n\n public constructor(\n envelopeService: DidCommEnvelopeService,\n transportService: DidCommTransportService,\n didCommModuleConfig: DidCommModuleConfig,\n didCommDocumentService: DidCommDocumentService,\n eventEmitter: EventEmitter\n ) {\n this.envelopeService = envelopeService\n this.transportService = transportService\n this.didCommModuleConfig = didCommModuleConfig\n this.didCommDocumentService = didCommDocumentService\n this.eventEmitter = eventEmitter\n }\n\n public async packMessage(\n agentContext: AgentContext,\n {\n keys,\n message,\n endpoint,\n }: {\n keys: EnvelopeKeys\n message: DidCommMessage\n endpoint: string\n }\n ): Promise<DidCommOutboundPackage> {\n const encryptedMessage = await this.envelopeService.packMessage(agentContext, message, keys)\n\n return {\n payload: encryptedMessage,\n responseRequested: message.hasAnyReturnRoute(),\n endpoint,\n }\n }\n\n private async sendMessageToSession(\n agentContext: AgentContext,\n session: DidCommTransportSession,\n message: DidCommMessage\n ) {\n agentContext.config.logger.debug(`Packing message and sending it via existing session ${session.type}...`)\n if (!session.keys) {\n throw new CredoError(`There are no keys for the given ${session.type} transport session.`)\n }\n const encryptedMessage = await this.envelopeService.packMessage(agentContext, message, session.keys)\n agentContext.config.logger.debug('Sending message')\n await session.send(agentContext, encryptedMessage)\n }\n\n public async sendPackage(\n agentContext: AgentContext,\n {\n connection,\n encryptedMessage,\n recipientKey,\n options,\n }: {\n connection: DidCommConnectionRecord\n recipientKey: string\n encryptedMessage: DidCommEncryptedMessage\n options?: { transportPriority?: TransportPriorityOptions }\n }\n ) {\n const errors: Error[] = []\n\n // Try to send to already open session\n const session = this.transportService.findSessionByConnectionId(connection.id)\n if (session?.inboundMessage?.hasReturnRouting()) {\n try {\n await session.send(agentContext, encryptedMessage)\n return\n } catch (error) {\n errors.push(error)\n agentContext.config.logger.debug(\n `Sending packed message via session failed with error: ${error.message}.`,\n error\n )\n }\n }\n\n // Retrieve DIDComm services\n const { services, queueService } = await this.retrieveServicesByConnection(\n agentContext,\n connection,\n options?.transportPriority\n )\n\n if (this.didCommModuleConfig.outboundTransports.length === 0 && !queueService) {\n throw new CredoError('Agent has no outbound transport!')\n }\n\n // Loop trough all available services and try to send the message\n for await (const service of services) {\n agentContext.config.logger.debug('Sending outbound message to service:', { service })\n try {\n const protocolScheme = utils.getProtocolScheme(service.serviceEndpoint)\n for (const transport of this.didCommModuleConfig.outboundTransports) {\n if (transport.supportedSchemes.includes(protocolScheme)) {\n await transport.sendMessage({\n payload: encryptedMessage,\n endpoint: service.serviceEndpoint,\n connectionId: connection.id,\n })\n break\n }\n }\n return\n } catch (error) {\n agentContext.config.logger.debug(\n `Sending outbound message to service with id ${service.id} failed with the following error:`,\n {\n message: error.message,\n error: error,\n }\n )\n }\n }\n\n // We didn't succeed to send the message over open session, or directly to serviceEndpoint\n // If the other party shared a queue service endpoint in their did doc we queue the message\n if (queueService) {\n agentContext.config.logger.debug(\n `Queue packed message for connection ${connection.id} (${connection.theirLabel})`\n )\n await this.didCommModuleConfig.queueTransportRepository.addMessage(agentContext, {\n connectionId: connection.id,\n recipientDids: [verkeyToDidKey(recipientKey)],\n payload: encryptedMessage,\n })\n return\n }\n\n // Message is undeliverable\n agentContext.config.logger.error(\n `Message is undeliverable to connection ${connection.id} (${connection.theirLabel})`,\n {\n message: encryptedMessage,\n errors,\n connection,\n }\n )\n throw new CredoError(`Message is undeliverable to connection ${connection.id} (${connection.theirLabel})`)\n }\n\n public async sendMessage(\n outboundMessageContext: DidCommOutboundMessageContext,\n options?: {\n transportPriority?: TransportPriorityOptions\n }\n ) {\n const { agentContext, connection, outOfBand, message } = outboundMessageContext\n const errors: Error[] = []\n\n if (outboundMessageContext.isOutboundServiceMessage()) {\n return this.sendMessageToService(outboundMessageContext)\n }\n\n if (!connection) {\n agentContext.config.logger.error('Outbound message has no associated connection')\n this.emitMessageSentEvent(outboundMessageContext, OutboundMessageSendStatus.Undeliverable)\n throw new MessageSendingError('Outbound message has no associated connection', {\n outboundMessageContext,\n })\n }\n\n agentContext.config.logger.debug('Send outbound message', {\n message,\n connectionId: connection.id,\n })\n\n const session = this.findSessionForOutboundContext(outboundMessageContext)\n\n if (session) {\n agentContext.config.logger.debug(\n `Found session with return routing for message '${message.id}' (connection '${connection.id}'`\n )\n\n try {\n await this.sendMessageToSession(agentContext, session, message)\n this.emitMessageSentEvent(outboundMessageContext, OutboundMessageSendStatus.SentToSession)\n return\n } catch (error) {\n errors.push(error)\n agentContext.config.logger.debug(\n `Sending an outbound message via session failed with error: ${error.message}.`,\n error\n )\n }\n }\n\n // Retrieve DIDComm services\n let services: ResolvedDidCommService[] = []\n let queueService: ResolvedDidCommService | undefined\n\n try {\n ;({ services, queueService } = await this.retrieveServicesByConnection(\n agentContext,\n connection,\n options?.transportPriority,\n outOfBand\n ))\n } catch (error) {\n agentContext.config.logger.error(`Unable to retrieve services for connection '${connection.id}. ${error.message}`)\n this.emitMessageSentEvent(outboundMessageContext, OutboundMessageSendStatus.Undeliverable)\n throw new MessageSendingError(`Unable to retrieve services for connection '${connection.id}`, {\n outboundMessageContext,\n cause: error,\n })\n }\n\n if (!connection.did) {\n agentContext.config.logger.error(\n `Unable to send message using connection '${connection.id}' that doesn't have a did`\n )\n this.emitMessageSentEvent(outboundMessageContext, OutboundMessageSendStatus.Undeliverable)\n throw new MessageSendingError(\n `Unable to send message using connection '${connection.id}' that doesn't have a did`,\n { outboundMessageContext }\n )\n }\n\n const dids = agentContext.resolve(DidsApi)\n const { didDocument, keys } = await dids.resolveCreatedDidDocumentWithKeys(connection.did).catch((error) => {\n agentContext.config.logger.error(\n `Unable to send message using connection '${connection.id}', unable to resolve did`,\n {\n error,\n }\n )\n this.emitMessageSentEvent(outboundMessageContext, OutboundMessageSendStatus.Undeliverable)\n throw new MessageSendingError(\n `Unable to send message using connection '${connection.id}'. Unble to resolve did`,\n { outboundMessageContext, cause: error }\n )\n })\n\n const authentication = didDocument.authentication\n ?.map((a) => {\n const verificationMethod = typeof a === 'string' ? didDocument.dereferenceVerificationMethod(a) : a\n const publicJwk = getPublicJwkFromVerificationMethod(verificationMethod)\n const kmsKeyId = keys?.find((key) => verificationMethod.id.endsWith(key.didDocumentRelativeKeyId))?.kmsKeyId\n\n // Set stored key id, or fallback to legacy key id\n publicJwk.keyId = kmsKeyId ?? publicJwk.legacyKeyId\n\n return { verificationMethod, publicJwk, kmsKeyId }\n })\n .filter((v): v is typeof v & { publicJwk: Kms.PublicJwk<Kms.Ed25519PublicJwk> } =>\n v.publicJwk.is(Kms.Ed25519PublicJwk)\n )\n\n // We take the first one with a kms key id. Otherwise we pick the first\n const senderVerificationMethod = authentication?.find((a) => a.kmsKeyId !== undefined) ?? authentication?.[0]\n if (!senderVerificationMethod) {\n throw new MessageSendingError(\n `Unable to determine sender key for did ${connection.did}, no available Ed25519 keys`,\n {\n outboundMessageContext,\n }\n )\n }\n\n // If the returnRoute is already set we won't override it. This allows to set the returnRoute manually if this is desired.\n const shouldAddReturnRoute =\n message.transport?.returnRoute === undefined && !this.transportService.hasInboundEndpoint(didDocument)\n\n // Loop trough all available services and try to send the message\n for await (const service of services) {\n try {\n // Enable return routing if the our did document does not have any inbound endpoint for given sender key\n await this.sendToService(\n new DidCommOutboundMessageContext(message, {\n agentContext,\n serviceParams: {\n service,\n senderKey: senderVerificationMethod.publicJwk,\n returnRoute: shouldAddReturnRoute,\n },\n connection,\n })\n )\n this.emitMessageSentEvent(outboundMessageContext, OutboundMessageSendStatus.SentToTransport)\n return\n } catch (error) {\n errors.push(error)\n agentContext.config.logger.debug(\n `Sending outbound message to service with id ${service.id} failed with the following error:`,\n {\n message: error.message,\n error: error,\n }\n )\n }\n }\n\n // We didn't succeed to send the message over open session, or directly to serviceEndpoint\n // If the other party shared a queue service endpoint in their did doc we queue the message\n if (queueService && message.allowQueueTransport) {\n agentContext.config.logger.debug(`Queue message for connection ${connection.id} (${connection.theirLabel})`)\n\n const keys = {\n recipientKeys: queueService.recipientKeys,\n routingKeys: queueService.routingKeys,\n senderKey: senderVerificationMethod.publicJwk,\n }\n\n const encryptedMessage = await this.envelopeService.packMessage(agentContext, message, keys)\n await this.didCommModuleConfig.queueTransportRepository.addMessage(agentContext, {\n connectionId: connection.id,\n recipientDids: keys.recipientKeys.map((item) => new DidKey(item).did),\n payload: encryptedMessage,\n })\n\n this.emitMessageSentEvent(outboundMessageContext, OutboundMessageSendStatus.QueuedForPickup)\n\n return\n }\n\n // Message is undeliverable\n agentContext.config.logger.error(\n `Message is undeliverable to connection ${connection.id} (${connection.theirLabel})`,\n {\n message,\n errors,\n connection,\n }\n )\n this.emitMessageSentEvent(outboundMessageContext, OutboundMessageSendStatus.Undeliverable)\n\n throw new MessageSendingError(\n `Message is undeliverable to connection ${connection.id} (${connection.theirLabel}). \\n\\nReasons:\\n\\t- ${errors.map((e) => e.message).join('\\n\\t-')}`,\n { outboundMessageContext }\n )\n }\n\n private async sendMessageToService(outboundMessageContext: DidCommOutboundMessageContext) {\n const session = this.findSessionForOutboundContext(outboundMessageContext)\n\n if (session) {\n outboundMessageContext.agentContext.config.logger.debug(\n `Found session with return routing for message '${outboundMessageContext.message.id}'`\n )\n try {\n await this.sendMessageToSession(outboundMessageContext.agentContext, session, outboundMessageContext.message)\n this.emitMessageSentEvent(outboundMessageContext, OutboundMessageSendStatus.SentToSession)\n return\n } catch (error) {\n outboundMessageContext.agentContext.config.logger.debug(\n `Sending an outbound message via session failed with error: ${error.message}.`,\n error\n )\n }\n }\n\n // If there is no session try sending to service instead\n try {\n await this.sendToService(outboundMessageContext)\n this.emitMessageSentEvent(outboundMessageContext, OutboundMessageSendStatus.SentToTransport)\n } catch (error) {\n outboundMessageContext.agentContext.config.logger.error(\n `Message is undeliverable to service with id ${outboundMessageContext.serviceParams?.service.id}: ${error.message}`,\n {\n message: outboundMessageContext.message,\n error,\n }\n )\n this.emitMessageSentEvent(outboundMessageContext, OutboundMessageSendStatus.Undeliverable)\n\n throw new MessageSendingError(\n `Message is undeliverable to service with id ${outboundMessageContext.serviceParams?.service.id}: ${error.message}`,\n { outboundMessageContext }\n )\n }\n }\n\n private async sendToService(outboundMessageContext: DidCommOutboundMessageContext) {\n const { agentContext, message, serviceParams, connection } = outboundMessageContext\n\n if (!serviceParams) {\n throw new CredoError('No service parameters found in outbound message context')\n }\n const { service, senderKey, returnRoute } = serviceParams\n\n if (this.didCommModuleConfig.outboundTransports.length === 0) {\n throw new CredoError('Agent has no outbound transport!')\n }\n\n agentContext.config.logger.debug('Sending outbound message to service:', {\n messageId: message.id,\n service: { ...service, recipientKeys: 'omitted...', routingKeys: 'omitted...' },\n })\n\n const keys = {\n recipientKeys: service.recipientKeys,\n routingKeys: service.routingKeys,\n senderKey,\n }\n\n // Set return routing for message if requested\n if (returnRoute) {\n message.setReturnRouting(ReturnRouteTypes.all)\n }\n\n try {\n MessageValidator.validateSync(message)\n } catch (error) {\n agentContext.config.logger.error(\n `Aborting sending outbound message ${message.type} to ${service.serviceEndpoint}. Message validation failed`,\n {\n errors: error,\n message: message.toJSON(),\n }\n )\n\n throw error\n }\n\n const outboundPackage = await this.packMessage(agentContext, { message, keys, endpoint: service.serviceEndpoint })\n outboundPackage.endpoint = service.serviceEndpoint\n outboundPackage.connectionId = connection?.id\n for (const transport of this.didCommModuleConfig.outboundTransports) {\n const protocolScheme = utils.getProtocolScheme(service.serviceEndpoint)\n if (!protocolScheme) {\n agentContext.config.logger.warn('Service does not have a protocol scheme.')\n } else if (transport.supportedSchemes.includes(protocolScheme)) {\n await transport.sendMessage(outboundPackage)\n return\n }\n }\n throw new MessageSendingError(`Unable to send message to service: ${service.serviceEndpoint}`, {\n outboundMessageContext,\n })\n }\n\n private findSessionForOutboundContext(outboundContext: DidCommOutboundMessageContext) {\n let session: DidCommTransportSession | undefined = undefined\n\n // Use session id from outbound context if present, or use the session from the inbound message context\n const sessionId = outboundContext.sessionId ?? outboundContext.inboundMessageContext?.sessionId\n\n // Try to find session by id\n if (sessionId) {\n session = this.transportService.findSessionById(sessionId)\n }\n\n // Try to find session by connection id\n if (!session && outboundContext.connection?.id) {\n session = this.transportService.findSessionByConnectionId(outboundContext.connection.id)\n }\n\n return session?.inboundMessage?.hasAnyReturnRoute() ? session : null\n }\n\n private async retrieveServicesByConnection(\n agentContext: AgentContext,\n connection: DidCommConnectionRecord,\n transportPriority?: TransportPriorityOptions,\n outOfBand?: DidCommOutOfBandRecord\n ) {\n agentContext.config.logger.debug(\n `Retrieving services for connection '${connection.id}' (${connection.theirLabel})`,\n {\n transportPriority,\n connection,\n }\n )\n\n let didCommServices: ResolvedDidCommService[] = []\n\n if (connection.theirDid) {\n agentContext.config.logger.debug(`Resolving services for connection theirDid ${connection.theirDid}.`)\n didCommServices = await this.didCommDocumentService.resolveServicesFromDid(agentContext, connection.theirDid)\n } else if (outOfBand) {\n agentContext.config.logger.debug(`Resolving services from out-of-band record ${outOfBand.id}.`)\n if (connection.isRequester) {\n for (const service of outOfBand.outOfBandInvitation.getServices()) {\n // Resolve dids to DIDDocs to retrieve services\n if (typeof service === 'string') {\n agentContext.config.logger.debug(`Resolving services for did ${service}.`)\n didCommServices.push(...(await this.didCommDocumentService.resolveServicesFromDid(agentContext, service)))\n } else {\n // Out of band inline service contains keys encoded as did:key references\n didCommServices.push({\n id: service.id,\n recipientKeys: service.recipientKeys.map(didKeyToEd25519PublicJwk),\n routingKeys: service.routingKeys?.map(didKeyToEd25519PublicJwk) || [],\n serviceEndpoint: service.serviceEndpoint,\n })\n }\n }\n }\n }\n\n // Separate queue service out\n let services = didCommServices.filter((s) => !isDidCommTransportQueue(s.serviceEndpoint))\n const queueService = didCommServices.find((s) => isDidCommTransportQueue(s.serviceEndpoint))\n\n // If restrictive will remove services not listed in schemes list\n if (transportPriority?.restrictive) {\n services = services.filter((service) => {\n const serviceSchema = utils.getProtocolScheme(service.serviceEndpoint)\n return transportPriority.schemes.includes(serviceSchema)\n })\n }\n\n // If transport priority is set we will sort services by our priority\n if (transportPriority?.schemes) {\n services = services.sort((a, b) => {\n const aScheme = utils.getProtocolScheme(a.serviceEndpoint)\n const bScheme = utils.getProtocolScheme(b.serviceEndpoint)\n return transportPriority?.schemes.indexOf(aScheme) - transportPriority?.schemes.indexOf(bScheme)\n })\n }\n\n agentContext.config.logger.debug(\n `Retrieved ${services.length} services for message to connection '${connection.id}'(${connection.theirLabel})'`,\n { hasQueueService: queueService !== undefined, transportPriority }\n )\n return { services, queueService }\n }\n\n private emitMessageSentEvent(\n outboundMessageContext: DidCommOutboundMessageContext,\n status: OutboundMessageSendStatus\n ) {\n const { agentContext } = outboundMessageContext\n this.eventEmitter.emit<DidCommMessageSentEvent>(agentContext, {\n type: DidCommEventTypes.DidCommMessageSent,\n payload: {\n message: outboundMessageContext,\n status,\n },\n })\n }\n}\n\nexport function isDidCommTransportQueue(serviceEndpoint: string): serviceEndpoint is typeof DID_COMM_TRANSPORT_QUEUE {\n return serviceEndpoint === DID_COMM_TRANSPORT_QUEUE\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAwCO,iCAAMA,uBAAqB;CAOhC,AAAO,YACL,iBACA,kBACA,qBACA,wBACA,cACA;AACA,OAAK,kBAAkB;AACvB,OAAK,mBAAmB;AACxB,OAAK,sBAAsB;AAC3B,OAAK,yBAAyB;AAC9B,OAAK,eAAe;;CAGtB,MAAa,YACX,cACA,EACE,MACA,SACA,YAM+B;AAGjC,SAAO;GACL,SAHuB,MAAM,KAAK,gBAAgB,YAAY,cAAc,SAAS,KAAK;GAI1F,mBAAmB,QAAQ,mBAAmB;GAC9C;GACD;;CAGH,MAAc,qBACZ,cACA,SACA,SACA;AACA,eAAa,OAAO,OAAO,MAAM,uDAAuD,QAAQ,KAAK,KAAK;AAC1G,MAAI,CAAC,QAAQ,KACX,OAAM,IAAI,WAAW,mCAAmC,QAAQ,KAAK,qBAAqB;EAE5F,MAAM,mBAAmB,MAAM,KAAK,gBAAgB,YAAY,cAAc,SAAS,QAAQ,KAAK;AACpG,eAAa,OAAO,OAAO,MAAM,kBAAkB;AACnD,QAAM,QAAQ,KAAK,cAAc,iBAAiB;;CAGpD,MAAa,YACX,cACA,EACE,YACA,kBACA,cACA,WAOF;EACA,MAAMC,SAAkB,EAAE;EAG1B,MAAM,UAAU,KAAK,iBAAiB,0BAA0B,WAAW,GAAG;AAC9E,MAAI,SAAS,gBAAgB,kBAAkB,CAC7C,KAAI;AACF,SAAM,QAAQ,KAAK,cAAc,iBAAiB;AAClD;WACO,OAAO;AACd,UAAO,KAAK,MA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Ae,gBAAgB,MAAM,MAAM,wBAAwB,EAAE,gBAAgB,CAAC;AAG5F,MAAI,mBAAmB,YACrB,YAAW,SAAS,QAAQ,YAAY;GACtC,MAAM,gBAAgB,MAAM,kBAAkB,QAAQ,gBAAgB;AACtE,UAAO,kBAAkB,QAAQ,SAAS,cAAc;IACxD;AAIJ,MAAI,mBAAmB,QACrB,YAAW,SAAS,MAAM,GAAG,MAAM;GACjC,MAAM,UAAU,MAAM,kBAAkB,EAAE,gBAAgB;GAC1D,MAAM,UAAU,MAAM,kBAAkB,EAAE,gBAAgB;AAC1D,UAAO,mBAAmB,QAAQ,QAAQ,QAAQ,GAAG,mBAAmB,QAAQ,QAAQ,QAAQ;IAChG;AAGJ,eAAa,OAAO,OAAO,MACzB,aAAa,SAAS,OAAO,uCAAuC,WAAW,GAAG,IAAI,WAAW,WAAW,KAC5G;GAAE,iBAAiB,iBAAiB;GAAW;GAAmB,CACnE;AACD,SAAO;GAAE;GAAU;GAAc;;CAGnC,AAAQ,qBACN,wBACA,QACA;EACA,MAAM,EAAE,iBAAiB;AACzB,OAAK,aAAa,KAA8B,cAAc;GAC5D,MAAM,kBAAkB;GACxB,SAAS;IACP,SAAS;IACT;IACD;GACF,CAAC;;;mCA5hBL,YAAY;;;;;;;AAgiBb,SAAgB,wBAAwB,iBAA6E;AACnH,QAAO,oBAAoB"}
@@ -8,6 +8,8 @@ var DidCommModuleConfig = class {
8
8
  constructor(options) {
9
9
  this.options = options ?? {};
10
10
  this._endpoints = options?.endpoints;
11
+ this._inboundTransports = options?.transports?.inbound ?? [];
12
+ this._outboundTransports = options?.transports?.outbound ?? [];
11
13
  this._queueTransportRepository = options?.queueTransportRepository ?? new require_InMemoryQueueTransportRepository.InMemoryQueueTransportRepository();
12
14
  this.enabledModules = {
13
15
  connections: true,
@@ -31,6 +33,18 @@ var DidCommModuleConfig = class {
31
33
  get useDidSovPrefixWhereAllowed() {
32
34
  return this.options.useDidSovPrefixWhereAllowed ?? false;
33
35
  }
36
+ get inboundTransports() {
37
+ return this._inboundTransports;
38
+ }
39
+ set inboundTransports(inboundTransports) {
40
+ this._inboundTransports = inboundTransports;
41
+ }
42
+ get outboundTransports() {
43
+ return this._outboundTransports;
44
+ }
45
+ set outboundTransports(outboundTransports) {
46
+ this._outboundTransports = outboundTransports;
47
+ }
34
48
  get processDidCommMessagesConcurrently() {
35
49
  return this.options.processDidCommMessagesConcurrently ?? false;
36
50
  }
@@ -8,6 +8,8 @@ var DidCommModuleConfig = class {
8
8
  constructor(options) {
9
9
  this.options = options ?? {};
10
10
  this._endpoints = options?.endpoints;
11
+ this._inboundTransports = options?.transports?.inbound ?? [];
12
+ this._outboundTransports = options?.transports?.outbound ?? [];
11
13
  this._queueTransportRepository = options?.queueTransportRepository ?? new InMemoryQueueTransportRepository();
12
14
  this.enabledModules = {
13
15
  connections: true,
@@ -31,6 +33,18 @@ var DidCommModuleConfig = class {
31
33
  get useDidSovPrefixWhereAllowed() {
32
34
  return this.options.useDidSovPrefixWhereAllowed ?? false;
33
35
  }
36
+ get inboundTransports() {
37
+ return this._inboundTransports;
38
+ }
39
+ set inboundTransports(inboundTransports) {
40
+ this._inboundTransports = inboundTransports;
41
+ }
42
+ get outboundTransports() {
43
+ return this._outboundTransports;
44
+ }
45
+ set outboundTransports(outboundTransports) {
46
+ this._outboundTransports = outboundTransports;
47
+ }
34
48
  get processDidCommMessagesConcurrently() {
35
49
  return this.options.processDidCommMessagesConcurrently ?? false;
36
50
  }
@@ -1 +1 @@
1
- {"version":3,"file":"DidCommModuleConfig.mjs","names":[],"sources":["../../../../../didcomm/src/DidCommModuleConfig.ts"],"sourcesContent":["import { DID_COMM_TRANSPORT_QUEUE } from './constants'\nimport type {\n DidCommConnectionsModuleConfigOptions,\n DidCommCredentialProtocol,\n DidCommMessagePickupModuleConfigOptions,\n DidCommMessagePickupProtocol,\n DidCommProofsModuleConfigOptions,\n} from './modules'\nimport type { DidCommCredentialsModuleConfigOptions } from './modules/credentials/DidCommCredentialsModuleConfig'\nimport type { DidCommDiscoverFeaturesModuleConfigOptions } from './modules/discover-features/DidCommDiscoverFeaturesModuleConfig'\nimport type { DidCommProofProtocol } from './modules/proofs/protocol/DidCommProofProtocol'\nimport type { DidCommMediationRecipientModuleConfigOptions } from './modules/routing/DidCommMediationRecipientModuleConfig'\nimport type { DidCommMediatorModuleConfigOptions } from './modules/routing/DidCommMediatorModuleConfig'\nimport { type DidCommQueueTransportRepository, InMemoryQueueTransportRepository } from './transport'\nimport { DidCommMimeType } from './types'\n\nexport interface DidCommModuleConfigOptions {\n endpoints?: string[]\n useDidSovPrefixWhereAllowed?: boolean\n processDidCommMessagesConcurrently?: boolean\n didCommMimeType?: string\n useDidKeyInProtocols?: boolean\n queueTransportRepository?: DidCommQueueTransportRepository\n\n /**\n * Configuration for the connection module.\n *\n * The connection module is always enabled\n */\n connections?: DidCommConnectionsModuleConfigOptions\n\n /**\n * Configuration for the discover features module.\n *\n * The discover features module is always enabled\n */\n discovery?: DidCommDiscoverFeaturesModuleConfigOptions\n\n /**\n * Configuration for the credentials module\n *\n * The credentials module is enabled by default with\n * the V2ProofsProtocol and the XProofFormatService\n *\n * You can disable the module by passing `false`, or provide a\n * custom configuration to override the default\n *\n * @default true\n */\n credentials?: boolean | DidCommCredentialsModuleConfigOptions<DidCommCredentialProtocol[]>\n\n /**\n * Configuration for the proofs module\n *\n * The proofs module is enabled by default with\n * the V2CredentialsProtocol and the XXCredentialFormatService\n *\n * You can disable the module by passing `false`, or provide a\n * custom configuration to override the default\n *\n * @default true\n */\n proofs?: boolean | DidCommProofsModuleConfigOptions<DidCommProofProtocol[]>\n\n /**\n * Configuration to enable to basic messages module\n *\n * The basic messages module is enabled by default,\n * but can be disabled by passing `false`\n *\n * @default true\n */\n basicMessages?: boolean\n\n /**\n * Configuration for the message pickup module\n *\n * The message pickup module is enabled by default with\n * the V1PickupProtocol and the V2PickupProtocol\n *\n * You can disable the module by passing `false`, or provide a\n * custom configuration to override the default\n *\n * @default true\n */\n messagePickup?: boolean | DidCommMessagePickupModuleConfigOptions<DidCommMessagePickupProtocol[]>\n\n /**\n * Configuration or the mediator module\n *\n * The mediator module is enabled by default,\n * but can be disabled by passing `false`\n *\n * @default true\n */\n mediator?: boolean | DidCommMediatorModuleConfigOptions\n\n /**\n * Configuration for the mediation recipient module\n *\n * The mediator module is enabled by default,\n * but can be disabled by passing `false`\n *\n * @default true\n */\n mediationRecipient?: boolean | DidCommMediationRecipientModuleConfigOptions\n}\n\nexport class DidCommModuleConfig<Options extends DidCommModuleConfigOptions = DidCommModuleConfigOptions> {\n private options: Options\n private _endpoints?: string[]\n private _queueTransportRepository: DidCommQueueTransportRepository\n\n public readonly enabledModules: {\n oob: true\n connections: true\n discovery: true\n credentials: Options['credentials'] extends false ? false : true\n proofs: Options['proofs'] extends false ? false : true\n messagePickup: Options['messagePickup'] extends false ? false : true\n mediator: Options['mediator'] extends false ? false : true\n mediationRecipient: Options['mediationRecipient'] extends false ? false : true\n basicMessages: Options['basicMessages'] extends false ? false : true\n }\n\n public constructor(options?: Options) {\n this.options = (options ?? {}) as Options\n this._endpoints = options?.endpoints\n this._queueTransportRepository = options?.queueTransportRepository ?? new InMemoryQueueTransportRepository()\n\n this.enabledModules = {\n connections: true,\n oob: true,\n discovery: true,\n proofs: this.options.proofs !== false,\n credentials: this.options.credentials !== false,\n messagePickup: this.options.messagePickup !== false,\n mediator: this.options.mediator !== false,\n mediationRecipient: this.options.mediationRecipient !== false,\n basicMessages: this.options.basicMessages !== false,\n } as this['enabledModules']\n }\n\n public get endpoints(): [string, ...string[]] {\n // if endpoints is not set, return queue endpoint\n // https://github.com/hyperledger/aries-rfcs/issues/405#issuecomment-582612875\n if (!this._endpoints || this._endpoints.length === 0) {\n return [DID_COMM_TRANSPORT_QUEUE]\n }\n\n return this._endpoints as [string, ...string[]]\n }\n\n public set endpoints(endpoints: string[]) {\n this._endpoints = endpoints\n }\n\n public get useDidSovPrefixWhereAllowed() {\n return this.options.useDidSovPrefixWhereAllowed ?? false\n }\n\n public get processDidCommMessagesConcurrently() {\n return this.options.processDidCommMessagesConcurrently ?? false\n }\n\n public get didCommMimeType() {\n return this.options.didCommMimeType ?? DidCommMimeType.V1\n }\n\n /**\n * Encode keys in did:key format instead of 'naked' keys, as stated in Aries RFC 0360.\n *\n * This setting will not be taken into account if the other party has previously used naked keys\n * in a given protocol (i.e. it does not support Aries RFC 0360).\n */\n public get useDidKeyInProtocols() {\n return this.options.useDidKeyInProtocols ?? true\n }\n\n /**\n * Allows to specify a custom queue transport queue. It defaults to an in-memory queue\n *\n */\n public get queueTransportRepository() {\n return this._queueTransportRepository\n }\n}\n"],"mappings":";;;;;;AA4GA,IAAa,sBAAb,MAA0G;CAiBxG,AAAO,YAAY,SAAmB;AACpC,OAAK,UAAW,WAAW,EAAE;AAC7B,OAAK,aAAa,SAAS;AAC3B,OAAK,4BAA4B,SAAS,4BAA4B,IAAI,kCAAkC;AAE5G,OAAK,iBAAiB;GACpB,aAAa;GACb,KAAK;GACL,WAAW;GACX,QAAQ,KAAK,QAAQ,WAAW;GAChC,aAAa,KAAK,QAAQ,gBAAgB;GAC1C,eAAe,KAAK,QAAQ,kBAAkB;GAC9C,UAAU,KAAK,QAAQ,aAAa;GACpC,oBAAoB,KAAK,QAAQ,uBAAuB;GACxD,eAAe,KAAK,QAAQ,kBAAkB;GAC/C;;CAGH,IAAW,YAAmC;AAG5C,MAAI,CAAC,KAAK,cAAc,KAAK,WAAW,WAAW,EACjD,QAAO,CAAC,yBAAyB;AAGnC,SAAO,KAAK;;CAGd,IAAW,UAAU,WAAqB;AACxC,OAAK,aAAa;;CAGpB,IAAW,8BAA8B;AACvC,SAAO,KAAK,QAAQ,+BAA+B;;CAGrD,IAAW,qCAAqC;AAC9C,SAAO,KAAK,QAAQ,sCAAsC;;CAG5D,IAAW,kBAAkB;AAC3B,SAAO,KAAK,QAAQ,mBAAmB,gBAAgB;;;;;;;;CASzD,IAAW,uBAAuB;AAChC,SAAO,KAAK,QAAQ,wBAAwB;;;;;;CAO9C,IAAW,2BAA2B;AACpC,SAAO,KAAK"}
1
+ {"version":3,"file":"DidCommModuleConfig.mjs","names":[],"sources":["../../../../../didcomm/src/DidCommModuleConfig.ts"],"sourcesContent":["import { DID_COMM_TRANSPORT_QUEUE } from './constants'\nimport type {\n DidCommConnectionsModuleConfigOptions,\n DidCommCredentialProtocol,\n DidCommMessagePickupModuleConfigOptions,\n DidCommMessagePickupProtocol,\n DidCommProofsModuleConfigOptions,\n} from './modules'\nimport type { DidCommCredentialsModuleConfigOptions } from './modules/credentials/DidCommCredentialsModuleConfig'\nimport type { DidCommDiscoverFeaturesModuleConfigOptions } from './modules/discover-features/DidCommDiscoverFeaturesModuleConfig'\nimport type { DidCommProofProtocol } from './modules/proofs/protocol/DidCommProofProtocol'\nimport type { DidCommMediationRecipientModuleConfigOptions } from './modules/routing/DidCommMediationRecipientModuleConfig'\nimport type { DidCommMediatorModuleConfigOptions } from './modules/routing/DidCommMediatorModuleConfig'\nimport {\n type DidCommInboundTransport,\n type DidCommOutboundTransport,\n type DidCommQueueTransportRepository,\n InMemoryQueueTransportRepository,\n} from './transport'\nimport { DidCommMimeType } from './types'\n\nexport interface DidCommModuleConfigOptions {\n endpoints?: string[]\n transports?: {\n inbound?: DidCommInboundTransport[]\n outbound?: DidCommOutboundTransport[]\n }\n useDidSovPrefixWhereAllowed?: boolean\n processDidCommMessagesConcurrently?: boolean\n didCommMimeType?: string\n useDidKeyInProtocols?: boolean\n queueTransportRepository?: DidCommQueueTransportRepository\n\n /**\n * Configuration for the connection module.\n *\n * The connection module is always enabled\n */\n connections?: DidCommConnectionsModuleConfigOptions\n\n /**\n * Configuration for the discover features module.\n *\n * The discover features module is always enabled\n */\n discovery?: DidCommDiscoverFeaturesModuleConfigOptions\n\n /**\n * Configuration for the credentials module\n *\n * The credentials module is enabled by default with\n * the V2ProofsProtocol and the XProofFormatService\n *\n * You can disable the module by passing `false`, or provide a\n * custom configuration to override the default\n *\n * @default true\n */\n credentials?: boolean | DidCommCredentialsModuleConfigOptions<DidCommCredentialProtocol[]>\n\n /**\n * Configuration for the proofs module\n *\n * The proofs module is enabled by default with\n * the V2CredentialsProtocol and the XXCredentialFormatService\n *\n * You can disable the module by passing `false`, or provide a\n * custom configuration to override the default\n *\n * @default true\n */\n proofs?: boolean | DidCommProofsModuleConfigOptions<DidCommProofProtocol[]>\n\n /**\n * Configuration to enable to basic messages module\n *\n * The basic messages module is enabled by default,\n * but can be disabled by passing `false`\n *\n * @default true\n */\n basicMessages?: boolean\n\n /**\n * Configuration for the message pickup module\n *\n * The message pickup module is enabled by default with\n * the V1PickupProtocol and the V2PickupProtocol\n *\n * You can disable the module by passing `false`, or provide a\n * custom configuration to override the default\n *\n * @default true\n */\n messagePickup?: boolean | DidCommMessagePickupModuleConfigOptions<DidCommMessagePickupProtocol[]>\n\n /**\n * Configuration or the mediator module\n *\n * The mediator module is enabled by default,\n * but can be disabled by passing `false`\n *\n * @default true\n */\n mediator?: boolean | DidCommMediatorModuleConfigOptions\n\n /**\n * Configuration for the mediation recipient module\n *\n * The mediator module is enabled by default,\n * but can be disabled by passing `false`\n *\n * @default true\n */\n mediationRecipient?: boolean | DidCommMediationRecipientModuleConfigOptions\n}\n\nexport class DidCommModuleConfig<Options extends DidCommModuleConfigOptions = DidCommModuleConfigOptions> {\n private options: Options\n private _endpoints?: string[]\n private _inboundTransports: DidCommInboundTransport[]\n private _outboundTransports: DidCommOutboundTransport[]\n private _queueTransportRepository: DidCommQueueTransportRepository\n\n public readonly enabledModules: {\n oob: true\n connections: true\n discovery: true\n credentials: Options['credentials'] extends false ? false : true\n proofs: Options['proofs'] extends false ? false : true\n messagePickup: Options['messagePickup'] extends false ? false : true\n mediator: Options['mediator'] extends false ? false : true\n mediationRecipient: Options['mediationRecipient'] extends false ? false : true\n basicMessages: Options['basicMessages'] extends false ? false : true\n }\n\n public constructor(options?: Options) {\n this.options = (options ?? {}) as Options\n this._endpoints = options?.endpoints\n this._inboundTransports = options?.transports?.inbound ?? []\n this._outboundTransports = options?.transports?.outbound ?? []\n this._queueTransportRepository = options?.queueTransportRepository ?? new InMemoryQueueTransportRepository()\n\n this.enabledModules = {\n connections: true,\n oob: true,\n discovery: true,\n proofs: this.options.proofs !== false,\n credentials: this.options.credentials !== false,\n messagePickup: this.options.messagePickup !== false,\n mediator: this.options.mediator !== false,\n mediationRecipient: this.options.mediationRecipient !== false,\n basicMessages: this.options.basicMessages !== false,\n } as this['enabledModules']\n }\n\n public get endpoints(): [string, ...string[]] {\n // if endpoints is not set, return queue endpoint\n // https://github.com/hyperledger/aries-rfcs/issues/405#issuecomment-582612875\n if (!this._endpoints || this._endpoints.length === 0) {\n return [DID_COMM_TRANSPORT_QUEUE]\n }\n\n return this._endpoints as [string, ...string[]]\n }\n\n public set endpoints(endpoints: string[]) {\n this._endpoints = endpoints\n }\n\n public get useDidSovPrefixWhereAllowed() {\n return this.options.useDidSovPrefixWhereAllowed ?? false\n }\n\n public get inboundTransports() {\n return this._inboundTransports\n }\n\n public set inboundTransports(inboundTransports: DidCommInboundTransport[]) {\n this._inboundTransports = inboundTransports\n }\n\n public get outboundTransports() {\n return this._outboundTransports\n }\n\n public set outboundTransports(outboundTransports: DidCommOutboundTransport[]) {\n this._outboundTransports = outboundTransports\n }\n\n public get processDidCommMessagesConcurrently() {\n return this.options.processDidCommMessagesConcurrently ?? false\n }\n\n public get didCommMimeType() {\n return this.options.didCommMimeType ?? DidCommMimeType.V1\n }\n\n /**\n * Encode keys in did:key format instead of 'naked' keys, as stated in Aries RFC 0360.\n *\n * This setting will not be taken into account if the other party has previously used naked keys\n * in a given protocol (i.e. it does not support Aries RFC 0360).\n */\n public get useDidKeyInProtocols() {\n return this.options.useDidKeyInProtocols ?? true\n }\n\n /**\n * Allows to specify a custom queue transport queue. It defaults to an in-memory queue\n *\n */\n public get queueTransportRepository() {\n return this._queueTransportRepository\n }\n}\n"],"mappings":";;;;;;AAqHA,IAAa,sBAAb,MAA0G;CAmBxG,AAAO,YA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20251010222303",
12
12
  "files": [
13
13
  "build"
14
14
  ],
@@ -23,9 +23,9 @@
23
23
  "directory": "packages/askar-to-drizzle-storage-migration"
24
24
  },
25
25
  "dependencies": {
26
- "@credo-ts/askar": "0.6.0-alpha-20251010171953",
27
- "@credo-ts/drizzle-storage": "0.6.0-alpha-20251010171953",
28
- "@credo-ts/core": "0.6.0-alpha-20251010171953"
26
+ "@credo-ts/askar": "0.6.0-alpha-20251010222303",
27
+ "@credo-ts/drizzle-storage": "0.6.0-alpha-20251010222303",
28
+ "@credo-ts/core": "0.6.0-alpha-20251010222303"
29
29
  },
30
30
  "peerDependencies": {
31
31
  "@openwallet-foundation/askar-shared": "^0.4.2"