Skip to content

feat: Added API to delete connection, and added patch for multi-tenancy OOB connection #232

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

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions patches/@credo-ts+core+0.5.3+007+outofband-connection-fix.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
diff --git a/node_modules/@credo-ts/core/build/modules/oob/OutOfBandApi.js b/node_modules/@credo-ts/core/build/modules/oob/OutOfBandApi.js
index 141bc8d..e84e210 100644
--- a/node_modules/@credo-ts/core/build/modules/oob/OutOfBandApi.js
+++ b/node_modules/@credo-ts/core/build/modules/oob/OutOfBandApi.js
@@ -432,17 +432,30 @@ let OutOfBandApi = class OutOfBandApi {
}
else {
// Wait until the connection is ready and then pass the messages to the agent for further processing
- this.connectionsApi
- .returnWhenIsConnected(connectionRecord.id, { timeoutMs })
- .then((connectionRecord) => this.emitWithConnection(outOfBandRecord, connectionRecord, messages))
- .catch((error) => {
+ // this.connectionsApi
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
+ // this.connectionsApi
+ Remove the commented code if not necessary

+ // .returnWhenIsConnected(connectionRecord.id, { timeoutMs })
+ // .then((connectionRecord) => this.emitWithConnection(outOfBandRecord, connectionRecord, messages))
+ // .catch((error) => {
+ // if (error instanceof rxjs_1.EmptyError) {
+ // this.logger.warn(`Agent unsubscribed before connection got into ${connections_1.DidExchangeState.Completed} state`, error);
+ // }
+ // else {
+ // this.logger.error('Promise waiting for the connection to be complete failed.', error);
+ // }
+ // });
+
+ try{
+ connectionRecord = await this.connectionsApi.returnWhenIsConnected(connectionRecord.id, { timeoutMs })
+ await this.emitWithConnection(outOfBandRecord, connectionRecord, messages);
+
+ }catch(error){
if (error instanceof rxjs_1.EmptyError) {
this.logger.warn(`Agent unsubscribed before connection got into ${connections_1.DidExchangeState.Completed} state`, error);
}
else {
this.logger.error('Promise waiting for the connection to be complete failed.', error);
}
- });
+ }
}
}
return { outOfBandRecord, connectionRecord };
16 changes: 16 additions & 0 deletions src/controllers/multi-tenancy/MultiTenancyController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,22 @@ export class MultiTenancyController extends Controller {
}
}

@Example<ConnectionRecordProps>(ConnectionRecordExample)
@Security('apiKey')
@Delete('/connections/:connectionId/:tenantId')
public async deleteConnectionById(@Path('tenantId') tenantId: string, @Path('connectionId') connectionId: RecordId) {
try {
const connectionRecord = await this.agent.modules.tenants.withTenantAgent({ tenantId }, async (tenantAgent) => {
const connection = await tenantAgent.connections.deleteById(connectionId)
return JsonTransformer.toJSON(connection)
})

return connectionRecord
} catch (error) {
throw ErrorHandlingService.handle(error)
}
}

@Security('apiKey')
@Post('/create-invitation/:tenantId')
public async createInvitation(
Expand Down