Skip to content

Commit

Permalink
feat: added peer label to connection record
Browse files Browse the repository at this point in the history
Signed-off-by: James Ebert <[email protected]>
  • Loading branch information
JamesKEbert committed Apr 28, 2021
1 parent bfd0cc3 commit 970e80d
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "aries-framework-javascript",
"version": "0.0.1-datatransfer.1",
"version": "0.0.1-datatransfer.2",
"license": "Apache-2.0",
"main": "build/src/index.js",
"types": "build/src/index.d.ts",
Expand Down
4 changes: 3 additions & 1 deletion src/modules/connections/__tests__/ConnectionService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,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 @@ -302,7 +303,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 @@ -343,6 +344,7 @@ describe('ConnectionService', () => {
expect(processedConnection.theirDid).toBe(theirDid)
// TODO: we should transform theirDidDoc to didDoc instance after retrieving from persistence
expect(processedConnection.theirDidDoc).toEqual(theirDidDoc)
expect(processedConnection.theirLabel).toBe('test-label')
expect(processedConnection.tags.theirKey).toBe(theirVerkey)
expect(processedConnection.tags.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 @@ -22,6 +22,7 @@ interface ConnectionProps {
role: ConnectionRole
endpoint?: string
alias?: string
theirLabel?: string
autoAcceptConnection?: boolean
}

Expand All @@ -47,6 +48,7 @@ export class ConnectionRecord extends BaseRecord implements ConnectionStoragePro
public role: ConnectionRole
public endpoint?: string
public alias?: string
public theirLabel?: string
public autoAcceptConnection?: boolean
public tags: ConnectionTags

Expand All @@ -64,6 +66,7 @@ export class ConnectionRecord extends BaseRecord implements ConnectionStoragePro
this.role = props.role
this.endpoint = props.endpoint
this.alias = props.alias
this.theirLabel = props.theirLabel
this.autoAcceptConnection = props.autoAcceptConnection
this.tags = props.tags
this.invitation = props.invitation
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 @@ -114,6 +114,7 @@ export class ConnectionService extends EventEmitter {
role: ConnectionRole.Invitee,
state: ConnectionState.Invited,
alias: config?.alias,
theirLabel: invitation.label,
autoAcceptConnection: config?.autoAcceptConnection,
invitation,
tags: {
Expand Down Expand Up @@ -186,6 +187,7 @@ export class ConnectionService extends EventEmitter {

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

if (!connectionRecord.theirKey) {
throw new Error(`Connection with id ${connectionRecord.id} has no recipient keys.`)
Expand Down Expand Up @@ -353,6 +355,7 @@ export class ConnectionService extends EventEmitter {
state: ConnectionState
invitation?: ConnectionInvitationMessage
alias?: string
theirLabel?: string
autoAcceptConnection?: boolean
tags?: ConnectionTags
}): Promise<ConnectionRecord> {
Expand Down Expand Up @@ -394,6 +397,7 @@ export class ConnectionService extends EventEmitter {
},
invitation: options.invitation,
alias: options.alias,
theirLabel: options.theirLabel,
autoAcceptConnection: options.autoAcceptConnection,
})

Expand Down

0 comments on commit 970e80d

Please sign in to comment.