Skip to content

Commit

Permalink
feat: added their label to the connection record (#370)
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesKEbert authored Jul 8, 2021
1 parent a78d203 commit 353e1d8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/modules/connections/__tests__/ConnectionService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ describe('ConnectionService', () => {

describe('processInvitation', () => {
it('returns a connection record containing the information from the connection invitation', async () => {
expect.assertions(9)
expect.assertions(10)

const recipientKey = 'key-1'
const invitation = new ConnectionInvitationMessage({
Expand All @@ -151,6 +151,7 @@ describe('ConnectionService', () => {
expect(connection.invitation).toMatchObject(invitation)
expect(connection.alias).toBeUndefined()
expect(connectionAlias.alias).toBe('test-alias')
expect(connection.theirLabel).toBe('test label')
})

it('returns a connection record with the autoAcceptConnection parameter from the config', async () => {
Expand Down Expand Up @@ -235,7 +236,7 @@ describe('ConnectionService', () => {

describe('processRequest', () => {
it('returns a connection record containing the information from the connection request', async () => {
expect.assertions(5)
expect.assertions(6)

const connectionRecord = getMockConnection({
state: ConnectionState.Invited,
Expand Down Expand Up @@ -276,6 +277,7 @@ describe('ConnectionService', () => {
expect(processedConnection.theirDid).toBe(theirDid)
expect(processedConnection.theirDidDoc).toEqual(theirDidDoc)
expect(processedConnection.theirKey).toBe(theirVerkey)
expect(processedConnection.theirLabel).toBe('test-label')
expect(processedConnection.threadId).toBe(connectionRequest.id)
})

Expand Down
3 changes: 3 additions & 0 deletions src/modules/connections/repository/ConnectionRecord.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export interface ConnectionRecordProps {
verkey: Verkey
theirDid?: Did
theirDidDoc?: DidDoc
theirLabel?: string
invitation?: ConnectionInvitationMessage
state: ConnectionState
role: ConnectionRole
Expand Down Expand Up @@ -53,6 +54,7 @@ export class ConnectionRecord
@Type(() => DidDoc)
public theirDidDoc?: DidDoc
public theirDid?: string
public theirLabel?: string

@Type(() => ConnectionInvitationMessage)
public invitation?: ConnectionInvitationMessage
Expand All @@ -75,6 +77,7 @@ export class ConnectionRecord
this.verkey = props.verkey
this.theirDid = props.theirDid
this.theirDidDoc = props.theirDidDoc
this.theirLabel = props.theirLabel
this.state = props.state
this.role = props.role
this.alias = props.alias
Expand Down
4 changes: 4 additions & 0 deletions src/modules/connections/services/ConnectionService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ export class ConnectionService {
role: ConnectionRole.Invitee,
state: ConnectionState.Invited,
alias: config?.alias,
theirLabel: invitation.label,
autoAcceptConnection: config?.autoAcceptConnection,
invitation,
tags: {
Expand Down Expand Up @@ -190,6 +191,7 @@ export class ConnectionService {

connectionRecord.theirDid = message.connection.did
connectionRecord.theirDidDoc = message.connection.didDoc
connectionRecord.theirLabel = message.label
connectionRecord.threadId = message.id

if (!connectionRecord.theirKey) {
Expand Down Expand Up @@ -423,6 +425,7 @@ export class ConnectionService {
state: ConnectionState
invitation?: ConnectionInvitationMessage
alias?: string
theirLabel?: string
autoAcceptConnection?: boolean
tags?: CustomConnectionTags
}): Promise<ConnectionRecord> {
Expand Down Expand Up @@ -472,6 +475,7 @@ export class ConnectionService {
tags: options.tags,
invitation: options.invitation,
alias: options.alias,
theirLabel: options.theirLabel,
autoAcceptConnection: options.autoAcceptConnection,
})

Expand Down

0 comments on commit 353e1d8

Please sign in to comment.