Skip to content

Commit

Permalink
feat: add out-of-band methods to delete and fetch records (#16)
Browse files Browse the repository at this point in the history
* feat: add oob methods to delete and fetch records

Signed-off-by: Sai Ranjit Tummalapalli <[email protected]>

* docs: update docs

Signed-off-by: Sai Ranjit Tummalapalli <[email protected]>

---------

Signed-off-by: Sai Ranjit Tummalapalli <[email protected]>
  • Loading branch information
sairanjit authored Nov 16, 2023
1 parent 25ee5eb commit 09061b7
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 18 deletions.
46 changes: 32 additions & 14 deletions packages/ssi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,19 @@
[![npm](https://img.shields.io/npm/v/@adeya/ssi.svg)](https://www.npmjs.com/package/@adeya/ssi)
[![npm](https://img.shields.io/npm/v/@adeya/ssi/alpha.svg)](https://www.npmjs.com/package/@adeya/ssi)

- [Installing](#installing)
- [Usage](#usage)
- [API](#api)
- [Agent](#agent)
- [Wallet](#wallet)
- [Connections](#connections)
- [Credentials](#credentials)
- [Proofs](#proofs)
- [BasicMessages](#basicmessages)
- [PushNotifications](#pushnotifications)
- [Hooks](#hooks)
- [@adeya/ssi](#adeyassi)
- [Installing](#installing)
- [Peer Dependencies](#peer-dependencies)
- [Usage](#usage)
- [API](#api)
- [Agent](#agent)
- [Wallet](#wallet)
- [Connections](#connections)
- [Credentials](#credentials)
- [Proofs](#proofs)
- [BasicMessages](#basicmessages)
- [PushNotifications](#pushnotifications)
- [Hooks](#hooks)

## Installing

Expand Down Expand Up @@ -201,12 +203,28 @@ import { findOutOfBandRecordById } from '@adeya/ssi'
const record = await findOutOfBandRecordById(agent, recordId)
```

- deleteConnectionById - Delete a connection by id.
- findByReceivedInvitationId - Find an out of band record by received invitation id.

```ts
import { deleteConnectionById } from '@adeya/ssi'
import { findByReceivedInvitationId } from '@adeya/ssi'

await deleteConnectionById(agent, connectionId)
const record = await findByReceivedInvitationId(agent, receivedInvitationId)
```

- deleteConnectionRecordById - Delete a connection record by id.

```ts
import { deleteConnectionRecordById } from '@adeya/ssi'

await deleteConnectionRecordById(agent, connectionId)
```

- deleteOobRecordById - Delete a out-of-band record by id.

```ts
import { deleteOobRecordById } from '@adeya/ssi'

await deleteOobRecordById(agent, outOfBandId)
```

### Credentials
Expand Down
26 changes: 24 additions & 2 deletions packages/ssi/src/connections/connections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,12 +176,34 @@ export const findOutOfBandRecordById = async (agent: Agent, connectionId: string
}

/**
* Deletes a connection by its ID.
* Finds an out-of-band record by its invitation ID.
*
* @param agent The agent instance to use for finding the out-of-band record.
* @param receivedInvitationId The ID of the invitation to find.
* @returns A Promise that resolves to the out-of-band record with the given ID.
*/
export const findByReceivedInvitationId = async (agent: Agent, receivedInvitationId: string) => {
return agent.oob.findByReceivedInvitationId(receivedInvitationId)
}

/**
* Deletes a connection record by its ID.
*
* @param connectionId The ID of the connection to be deleted.
* @returns A boolean indicating whether the connection was successfully deleted or not.
*/
export const deleteConnectionById = async (agent: Agent, connectionId: string) => {
export const deleteConnectionRecordById = async (agent: Agent, connectionId: string) => {
await agent.connections.deleteById(connectionId)
return true
}

/**
* Deletes an out-of-band record by its ID.
*
* @param outOfBandId The ID of the out-of-band record to be deleted.
* @returns A boolean indicating whether the out-of-band record was successfully deleted or not.
*/
export const deleteOobRecordById = async (agent: Agent, outOfBandId: string) => {
await agent.oob.deleteById(outOfBandId)
return true
}
6 changes: 4 additions & 2 deletions packages/ssi/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ import {
V2ProofProtocol,
ConnectionsModule,
Agent,
BasicMessageRepository
BasicMessageRepository,
AriesFrameworkError
} from '@aries-framework/core'
import {
GetCredentialsForRequestReturn,
Expand Down Expand Up @@ -129,7 +130,8 @@ export {
V2ProofProtocol,
ConnectionsModule,
Agent,
BasicMessageRepository
BasicMessageRepository,
AriesFrameworkError
}
// Anoncreds
export {
Expand Down

0 comments on commit 09061b7

Please sign in to comment.