Skip to content
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

fix(oob): set connection alias when creating invitation #1047

Merged
merged 2 commits into from
Oct 8, 2022
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ export class DidExchangeProtocol {
protocol: HandshakeProtocol.DidExchange,
role: DidExchangeRole.Responder,
state: DidExchangeState.RequestReceived,
alias: outOfBandRecord.alias,
theirDid: message.did,
theirLabel: message.label,
threadId: message.threadId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ export class ConnectionService {
protocol: HandshakeProtocol.Connections,
role: DidExchangeRole.Responder,
state: DidExchangeState.RequestReceived,
alias: outOfBandRecord.alias,
theirLabel: message.label,
imageUrl: message.imageUrl,
outOfBandId: outOfBandRecord.id,
Expand Down
5 changes: 3 additions & 2 deletions packages/core/src/modules/oob/OutOfBandModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const didCommProfiles = ['didcomm/aip1', 'didcomm/aip2;env=rfc19']

export interface CreateOutOfBandInvitationConfig {
label?: string
alias?: string
alias?: string // alias for a connection record to be created
imageUrl?: string
goalCode?: string
goal?: string
Expand All @@ -61,7 +61,7 @@ export interface CreateOutOfBandInvitationConfig {

export interface CreateLegacyInvitationConfig {
label?: string
alias?: string
alias?: string // alias for a connection record to be created
imageUrl?: string
multiUseInvitation?: boolean
autoAcceptConnection?: boolean
Expand Down Expand Up @@ -208,6 +208,7 @@ export class OutOfBandModule {
mediatorId: routing.mediatorId,
role: OutOfBandRole.Sender,
state: OutOfBandState.AwaitResponse,
alias: config.alias,
outOfBandInvitation: outOfBandInvitation,
reusable: multiUseInvitation,
autoAcceptConnection,
Expand Down
3 changes: 3 additions & 0 deletions packages/core/src/modules/oob/repository/OutOfBandRecord.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export interface OutOfBandRecordProps {
outOfBandInvitation: OutOfBandInvitation
role: OutOfBandRole
state: OutOfBandState
alias?: string
autoAcceptConnection?: boolean
reusable?: boolean
mediatorId?: string
Expand All @@ -38,6 +39,7 @@ export class OutOfBandRecord extends BaseRecord<DefaultOutOfBandRecordTags, Cust
public outOfBandInvitation!: OutOfBandInvitation
public role!: OutOfBandRole
public state!: OutOfBandState
public alias?: string
public reusable!: boolean
public autoAcceptConnection?: boolean
public mediatorId?: string
Expand All @@ -55,6 +57,7 @@ export class OutOfBandRecord extends BaseRecord<DefaultOutOfBandRecordTags, Cust
this.outOfBandInvitation = props.outOfBandInvitation
this.role = props.role
this.state = props.state
this.alias = props.alias
this.autoAcceptConnection = props.autoAcceptConnection
this.reusable = props.reusable ?? false
this.mediatorId = props.mediatorId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
"theirLabel": "Agent: PopulateWallet2",
"state": "complete",
"role": "invitee",
"alias": "connection alias",
"invitation": {
"@type": "https://didcomm.org/connections/1.0/invitation",
"@id": "d56fd7af-852e-458e-b750-7a4f4e53d6e6",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -787,6 +787,7 @@ Object {
"z6MkfiPMPxCQeSDZGMkCvm1Y2rBoPsmw4ZHMv71jXtcWRRiM",
],
},
"alias": "connection alias",
"autoAcceptConnection": undefined,
"createdAt": "2022-04-30T13:02:21.577Z",
"id": "1-4e4f-41d9-94c4-f49351b811f1",
Expand Down Expand Up @@ -850,6 +851,7 @@ Object {
"z6MktCZAQNGvWb4WHAjwBqPtXhZdDYorbSJkGW9vj1uhw1HD",
],
},
"alias": undefined,
"autoAcceptConnection": undefined,
"createdAt": "2022-04-30T13:02:21.608Z",
"id": "2-4e4f-41d9-94c4-f49351b811f1",
Expand Down Expand Up @@ -913,6 +915,7 @@ Object {
"z6Mkt1tsp15cnDD7wBCFgehiR2SxHX1aPxt4sueE24twH9Bd",
],
},
"alias": undefined,
"autoAcceptConnection": false,
"createdAt": "2022-04-30T13:02:21.628Z",
"id": "3-4e4f-41d9-94c4-f49351b811f1",
Expand Down Expand Up @@ -976,6 +979,7 @@ Object {
"z6Mkmod8vp2nURVktVC5ceQeyr2VUz26iu2ZANLNVg9pMawa",
],
},
"alias": undefined,
"autoAcceptConnection": undefined,
"createdAt": "2022-04-30T13:02:21.635Z",
"id": "4-4e4f-41d9-94c4-f49351b811f1",
Expand Down Expand Up @@ -1039,6 +1043,7 @@ Object {
"z6MkjDJL4X7YGoH6gjamhZR2NzowPZqtJfX5kPuNuWiVdjMr",
],
},
"alias": undefined,
"autoAcceptConnection": false,
"createdAt": "2022-04-30T13:02:21.641Z",
"id": "5-4e4f-41d9-94c4-f49351b811f1",
Expand Down Expand Up @@ -1097,6 +1102,7 @@ Object {
},
"type": "OutOfBandRecord",
"value": Object {
"alias": undefined,
"autoAcceptConnection": true,
"createdAt": "2022-04-30T13:02:21.646Z",
"id": "6-4e4f-41d9-94c4-f49351b811f1",
Expand Down Expand Up @@ -1160,6 +1166,7 @@ Object {
"z6MkuWTEmH1mUo6W96zSWyH612hFHowRzNEscPYBL2CCMyC2",
],
},
"alias": undefined,
"autoAcceptConnection": true,
"createdAt": "2022-04-30T13:02:21.653Z",
"id": "7-4e4f-41d9-94c4-f49351b811f1",
Expand Down Expand Up @@ -1254,6 +1261,7 @@ Object {
},
"type": "ConnectionRecord",
"value": Object {
"alias": "connection alias",
"createdAt": "2022-04-30T13:02:21.577Z",
"did": "did:peer:1zQmRAfQ6J5qk4qcbHyoStFVkhusazLT9xQcFhdC9dhhQ1cJ",
"id": "8f4908ee-15ad-4058-9106-eda26eae735c",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@ export async function migrateToOobRecord(
oobRecord = new OutOfBandRecord({
role: oobRole,
state: oobState,
alias: connectionRecord.alias,
autoAcceptConnection: connectionRecord.autoAcceptConnection,
outOfBandInvitation,
reusable: oldMultiUseInvitation,
Expand Down
10 changes: 7 additions & 3 deletions packages/core/tests/oob.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ describe('out of band', () => {
goal: 'To make a connection',
goalCode: 'p2p-messaging',
label: 'Faber College',
alias: `Faber's connection with Alice`,
}

const issueCredentialConfig = {
Expand Down Expand Up @@ -158,10 +159,11 @@ describe('out of band', () => {
expect(outOfBandRecord.autoAcceptConnection).toBe(true)
expect(outOfBandRecord.role).toBe(OutOfBandRole.Sender)
expect(outOfBandRecord.state).toBe(OutOfBandState.AwaitResponse)
expect(outOfBandRecord.alias).toBe(makeConnectionConfig.alias)
expect(outOfBandRecord.reusable).toBe(false)
expect(outOfBandRecord.outOfBandInvitation.goal).toBe('To make a connection')
expect(outOfBandRecord.outOfBandInvitation.goalCode).toBe('p2p-messaging')
expect(outOfBandRecord.outOfBandInvitation.label).toBe('Faber College')
expect(outOfBandRecord.outOfBandInvitation.goal).toBe(makeConnectionConfig.goal)
expect(outOfBandRecord.outOfBandInvitation.goalCode).toBe(makeConnectionConfig.goalCode)
expect(outOfBandRecord.outOfBandInvitation.label).toBe(makeConnectionConfig.label)
})

test('create OOB message only with handshake', async () => {
Expand Down Expand Up @@ -290,6 +292,7 @@ describe('out of band', () => {

expect(aliceFaberConnection).toBeConnectedWith(faberAliceConnection!)
expect(faberAliceConnection).toBeConnectedWith(aliceFaberConnection)
expect(faberAliceConnection.alias).toBe(makeConnectionConfig.alias)
})

test(`make a connection with ${HandshakeProtocol.Connections} based on OOB invitation encoded in URL`, async () => {
Expand All @@ -311,6 +314,7 @@ describe('out of band', () => {

expect(aliceFaberConnection).toBeConnectedWith(faberAliceConnection)
expect(faberAliceConnection).toBeConnectedWith(aliceFaberConnection)
expect(faberAliceConnection.alias).toBe(makeConnectionConfig.alias)
})

test('make a connection based on old connection invitation encoded in URL', async () => {
Expand Down