Skip to content

Commit

Permalink
Merge branch 'main' into pex-service
Browse files Browse the repository at this point in the history
  • Loading branch information
berendsliedrecht authored Dec 15, 2023
2 parents 103af28 + edf493d commit d956e05
Show file tree
Hide file tree
Showing 30 changed files with 1,135 additions and 171 deletions.
2 changes: 1 addition & 1 deletion packages/core/src/agent/__tests__/Agent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ describe('Agent', () => {
'https://didcomm.org/coordinate-mediation/1.0',
'https://didcomm.org/issue-credential/2.0',
'https://didcomm.org/present-proof/2.0',
'https://didcomm.org/didexchange/1.0',
'https://didcomm.org/didexchange/1.1',
'https://didcomm.org/discover-features/1.0',
'https://didcomm.org/discover-features/2.0',
'https://didcomm.org/messagepickup/1.0',
Expand Down
12 changes: 11 additions & 1 deletion packages/core/src/modules/connections/ConnectionsApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,14 @@ export class ConnectionsApi {
imageUrl?: string
protocol: HandshakeProtocol
routing?: Routing
ourDid?: string
}
) {
const { protocol, label, alias, imageUrl, autoAcceptConnection } = config
const { protocol, label, alias, imageUrl, autoAcceptConnection, ourDid } = config

if (ourDid && !config.routing) {
throw new AriesFrameworkError('If an external did is specified, routing configuration must be defined as well')
}

const routing =
config.routing ||
Expand All @@ -106,8 +111,13 @@ export class ConnectionsApi {
alias,
routing,
autoAcceptConnection,
ourDid,
})
} else if (protocol === HandshakeProtocol.Connections) {
if (ourDid) {
throw new AriesFrameworkError('Using an externally defined did for connections protocol is unsupported')
}

result = await this.connectionService.createRequest(this.agentContext, outOfBandRecord, {
label,
alias,
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/modules/connections/ConnectionsModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export class ConnectionsModule implements Module {
roles: [ConnectionRole.Invitee, ConnectionRole.Inviter],
}),
new Protocol({
id: 'https://didcomm.org/didexchange/1.0',
id: 'https://didcomm.org/didexchange/1.1',
roles: [DidExchangeRole.Requester, DidExchangeRole.Responder],
})
)
Expand Down
23 changes: 23 additions & 0 deletions packages/core/src/modules/connections/ConnectionsModuleConfig.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { PeerDidNumAlgo } from '../dids'

/**
* ConnectionsModuleConfigOptions defines the interface for the options of the ConnectionsModuleConfig class.
* This can contain optional parameters that have default values in the config class itself.
Expand All @@ -13,15 +15,26 @@ export interface ConnectionsModuleConfigOptions {
* @default false
*/
autoAcceptConnections?: boolean

/**
* Peer did num algo to use in requests for DID exchange protocol (RFC 0023). It will be also used by default
* in responses in case that the request does not use a peer did.
*
* @default PeerDidNumAlgo.GenesisDoc
*/
peerNumAlgoForDidExchangeRequests?: PeerDidNumAlgo
}

export class ConnectionsModuleConfig {
#autoAcceptConnections?: boolean
#peerNumAlgoForDidExchangeRequests?: PeerDidNumAlgo

private options: ConnectionsModuleConfigOptions

public constructor(options?: ConnectionsModuleConfigOptions) {
this.options = options ?? {}
this.#autoAcceptConnections = this.options.autoAcceptConnections
this.#peerNumAlgoForDidExchangeRequests = this.options.peerNumAlgoForDidExchangeRequests
}

/** See {@link ConnectionsModuleConfigOptions.autoAcceptConnections} */
Expand All @@ -33,4 +46,14 @@ export class ConnectionsModuleConfig {
public set autoAcceptConnections(autoAcceptConnections: boolean) {
this.#autoAcceptConnections = autoAcceptConnections
}

/** See {@link ConnectionsModuleConfigOptions.peerNumAlgoForDidExchangeRequests} */
public get peerNumAlgoForDidExchangeRequests() {
return this.#peerNumAlgoForDidExchangeRequests ?? PeerDidNumAlgo.GenesisDoc
}

/** See {@link ConnectionsModuleConfigOptions.peerNumAlgoForDidExchangeRequests} */
public set peerNumAlgoForDidExchangeRequests(peerNumAlgoForDidExchangeRequests: PeerDidNumAlgo) {
this.#peerNumAlgoForDidExchangeRequests = peerNumAlgoForDidExchangeRequests
}
}
Loading

0 comments on commit d956e05

Please sign in to comment.