-
Notifications
You must be signed in to change notification settings - Fork 208
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor!: didcomm module #2127
refactor!: didcomm module #2127
Conversation
🦋 Changeset detectedLatest commit: ba42e98 The changes in this PR will be included in the next version bump. This PR includes changesets to release 15 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Signed-off-by: Ariel Gentile <[email protected]>
d26f24e
to
ededb58
Compare
Signed-off-by: Ariel Gentile <[email protected]>
Signed-off-by: Ariel Gentile <[email protected]>
Signed-off-by: Ariel Gentile <[email protected]>
…t < ES2020) Signed-off-by: Ariel Gentile <[email protected]>
Signed-off-by: Ariel Gentile <[email protected]>
Signed-off-by: Ariel Gentile <[email protected]>
Signed-off-by: Ariel Gentile <[email protected]>
Signed-off-by: Ariel Gentile <[email protected]>
Signed-off-by: Ariel Gentile <[email protected]>
Signed-off-by: Ariel Gentile <[email protected]>
Signed-off-by: Ariel Gentile <[email protected]>
Signed-off-by: Ariel Gentile <[email protected]>
Signed-off-by: Ariel Gentile <[email protected]>
Signed-off-by: Ariel Gentile <[email protected]>
Signed-off-by: Ariel Gentile <[email protected]>
Signed-off-by: Ariel Gentile <[email protected]>
I've updated the description and marked this PR as ready for review. Both tests and demos are working, so I think it is in a status where it can be safe to merge. There is a good number of things to do yet before the official 0.6.0 release but I think it is a good start. |
…ns that now all DIDComm related modules (e.g. proofs, credentials) must be explicitly added when creating an `Agent` instance. Therefore, their API will be accesable under `agent.modules.[moduleAPI]` instead of `agent.[moduleAPI]`. Some `Agent` DIDComm-related properties and methods where also moved to the API of a new DIDComm module (e.g. `agent.registerInboundTransport` turned into `agent.modules.didcomm.registerInboundTransport`). **Example of DIDComm Agent** Previously: ```ts const config = { label: name, endpoints: ['https://myendpoint'], walletConfig: { id: name, key: name, }, } satisfies InitConfig const agent = new Agent({ config, dependencies: agentDependencies, modules: { connections: new ConnectionsModule({ autoAcceptConnections: true, }) }) this.agent.registerInboundTransport(new HttpInboundTransport({ port })) this.agent.registerOutboundTransport(new HttpOutboundTransport()) ``` Now: ```ts ```ts const config = { label: name, walletConfig: { id: name, key: name, }, } satisfies InitConfig const agent = new Agent({ config, dependencies: agentDependencies, modules: { ...getDefaultDidcommModules({ endpoints: ['https://myendpoint'] }), connections: new ConnectionsModule({ autoAcceptConnections: true, }) }) this.agent.modules.didcomm.registerInboundTransport(new HttpInboundTransport({ port })) this.agent.modules.didcomm.registerOutboundTransport(new HttpOutboundTransport()) ``` Signed-off-by: Ariel Gentile <[email protected]>
Signed-off-by: Ariel Gentile <[email protected]>
Signed-off-by: Ariel Gentile <[email protected]>
'@credo-ts/node': minor | ||
--- | ||
|
||
DIDComm has been extracted out of the Core. This means that now all DIDComm related modules (e.g. proofs, credentials) must be explicitly added when creating an `Agent` instance. Therefore, their API will be accesable under `agent.modules.[moduleAPI]` instead of `agent.[moduleAPI]`. Some `Agent` DIDComm-related properties and methods where also moved to the API of a new DIDComm module (e.g. `agent.registerInboundTransport` turned into `agent.modules.didcomm.registerInboundTransport`). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not for this PR, but I think before 0.6 we should look at making:
agent.didcomm
possible (nesting is getting quite large)- nest didcomm modules under
agent.didcomm
, also becauseagent.credentials
/agent.modules.credentials
is misleading, since it's didcomm specific. I think registerin - Adopting the conenctions / oob modules into the didcomm module by default, and you can configure it in the didcomm module config again. I think this simplifies setup.
- Registering custom didcomm protocols on the didcomm module rather than the agent? This may solve some of the initialization and feature registry issues. We can create a
DidcommModule
interface that has special feature registry etc. - Rename modules to have DIDcomm prefix (DidCommConnectionsModule, DidCommMessageHandlerRegistry). This will help with identifiying for what feature a class is
- Add inbound / outbound transports to the config? I always found it a bit weird you can't just add this to the didcomm config
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah good ideas there! Initially I made a "DidCommModule" but I decided to leave it for a further PR to not overcomplicate it. But for sure it is something that makes sense, especially to have a tidy Agent API.
Same thing about the transport config, which is something not so evident for developers.
packages/core/src/modules/dids/methods/peer/createPeerDidDocumentFromServices.ts
Show resolved
Hide resolved
@@ -19,18 +18,19 @@ export class SubjectInboundTransport implements InboundTransport { | |||
this.ourSubject = ourSubject | |||
} | |||
|
|||
public async start(agent: Agent) { | |||
public async start(agent: AgentContext) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it not possible to provide the agent here anymore?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem is that we start transports at DIDComm module's initialize(), which receives the AgentContext as an argument. Before this PR we started transport in Agent
so we were able to call transport.start(this)
.
Do you see a potential issue on this change, besides the fact that it breaks the API?
@@ -28,18 +28,20 @@ describe('TenantRecordService', () => { | |||
jest.clearAllMocks() | |||
}) | |||
|
|||
// FIXME: connectionImageUrl is now part of DIDComm module. Tenants records do not currently |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the new crypto api i've also been looking to solve this problem, and how i tried to solve it is that each module can hook into the the storing process of the tenant config. It's a bit tricky though, as it makes all modules somewhat intertwined with the tenants module ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, maybe tenants could become a core feature? 🤔
Left some comments, but all are fine to fix later. Very nice work!! 🙌 Maybe we can open an issue and add your + mine comments so we can keep track of todos? |
Signed-off-by: Ariel Gentile <[email protected]>
Signed-off-by: Ariel Gentile <[email protected]>
Signed-off-by: Ariel Gentile <[email protected]> Signed-off-by: Sai Ranjit Tummalapalli <[email protected]>
Initial work on extracting DIDComm out of core. This PR moves all DIDComm-related modules to a dedicated didcomm package, where they are located alongside a base
DidCommModule
that exposes and API and config to set up basic DIDComm features (e.g. register inbound/outbound transports, endpoints and DIDComm flags).To not overcomplicate this big refactoring, no further API and usage changes where applied, so most changes to use DIDComm in an Agent are:
getDefaultDidcommModules()
can help to facilitate typical Agent creation before doing a further refactoringagent.modules.didcomm.xxx
.modules
to all calls to DIDComm related modules (e.g.agent.proofs.method()
toagent.modules.proofs.method()
)And those are pretty much the changes required to use it coming from previous code base.
Some notes I took:
register()
. So protocol and other features are actually registered at each module's initialize()` method. Not a big problem I think but it is a new measure to take into accountmediationRecipient
needs to be explicitly initialized (i.e. call its initialize() API method). Otherwise, provisioning and pickup will not worknode
package depends on didcomm, due to the definition of HTTP and WebSocket Inbound transports. We can create a separate package for that, or leave this work for a full refactor of this package (and react-native), since most of them are used on DIDComm and AnonCreds related modules