Skip to content

Commit

Permalink
feat: allow override peerDidNumAlgo
Browse files Browse the repository at this point in the history
Signed-off-by: Ariel Gentile <gentilester@gmail.com>
  • Loading branch information
genaris committed Sep 22, 2023
1 parent 7d5495a commit 05191e9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
6 changes: 4 additions & 2 deletions packages/core/src/modules/connections/ConnectionsApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { ConnectionType } from './models'
import type { ConnectionRecord } from './repository/ConnectionRecord'
import type { Routing } from './services'
import type { Query } from '../../storage/StorageService'
import type { PeerDidNumAlgo } from '../dids'
import type { OutOfBandRecord } from '../oob/repository'

import { AgentContext } from '../../agent'
Expand Down Expand Up @@ -91,9 +92,10 @@ export class ConnectionsApi {
imageUrl?: string
protocol: HandshakeProtocol
routing?: Routing
peerDidNumAlgo?: PeerDidNumAlgo
}
) {
const { protocol, label, alias, imageUrl, autoAcceptConnection } = config
const { protocol, label, alias, imageUrl, autoAcceptConnection, peerDidNumAlgo } = config

const routing =
config.routing ||
Expand All @@ -106,7 +108,7 @@ export class ConnectionsApi {
alias,
routing,
autoAcceptConnection,
peerNumAlgo: this.config.peerNumAlgoForDidExchangeRequests,
peerNumAlgo: peerDidNumAlgo ?? this.config.peerNumAlgoForDidExchangeRequests,
})
} else if (protocol === HandshakeProtocol.Connections) {
result = await this.connectionService.createRequest(this.agentContext, outOfBandRecord, {
Expand Down
7 changes: 6 additions & 1 deletion packages/core/src/modules/oob/OutOfBandApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type { Attachment } from '../../decorators/attachment/Attachment'
import type { Query } from '../../storage/StorageService'
import type { PlaintextMessage } from '../../types'
import type { ConnectionInvitationMessage, ConnectionRecord, Routing } from '../connections'
import type { PeerDidNumAlgo } from '../dids'

import { catchError, EmptyError, first, firstValueFrom, map, of, timeout } from 'rxjs'

Expand Down Expand Up @@ -77,6 +78,7 @@ interface BaseReceiveOutOfBandInvitationConfig {
routing?: Routing
acceptInvitationTimeoutMs?: number
isImplicit?: boolean
peerDidNumAlgo?: PeerDidNumAlgo
}

export type ReceiveOutOfBandInvitationConfig = Omit<BaseReceiveOutOfBandInvitationConfig, 'isImplicit'>
Expand Down Expand Up @@ -460,6 +462,7 @@ export class OutOfBandApi {
reuseConnection,
routing,
timeoutMs: config.acceptInvitationTimeoutMs,
peerDidNumAlgo: config.peerDidNumAlgo,
})
}

Expand Down Expand Up @@ -495,12 +498,13 @@ export class OutOfBandApi {
*/
routing?: Routing
timeoutMs?: number
peerDidNumAlgo?: PeerDidNumAlgo
}
) {
const outOfBandRecord = await this.outOfBandService.getById(this.agentContext, outOfBandId)

const { outOfBandInvitation } = outOfBandRecord
const { label, alias, imageUrl, autoAcceptConnection, reuseConnection } = config
const { label, alias, imageUrl, autoAcceptConnection, reuseConnection, peerDidNumAlgo } = config
const services = outOfBandInvitation.getServices()
const messages = outOfBandInvitation.getRequests()
const timeoutMs = config.timeoutMs ?? 20000
Expand Down Expand Up @@ -566,6 +570,7 @@ export class OutOfBandApi {
autoAcceptConnection,
protocol: handshakeProtocol,
routing,
peerDidNumAlgo,
})
}

Expand Down

0 comments on commit 05191e9

Please sign in to comment.