Skip to content

Commit

Permalink
Changes from review
Browse files Browse the repository at this point in the history
1. refactored module instantiation to a helper function
2. configured correct types to support v1 and v2 credential and proof protocols and correct formats
3. proof controller updated to take parameters like agent
4. re-enabled oob proof api as create-request

Signed-off-by: Matthew Dean <matthew.dean@digicatapult.org.uk>
  • Loading branch information
mattdean-digicatapult committed Aug 23, 2023
1 parent 044d9da commit 039948d
Show file tree
Hide file tree
Showing 10 changed files with 1,440 additions and 757 deletions.
1 change: 0 additions & 1 deletion packages/rest/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ const parsed = yargs
})
.option('indy-ledger', {
array: true,
// TODO: this default is invalid, fixme
default: [],
coerce: (items: unknown[]) => items.map((i) => (typeof i === 'string' ? JSON.parse(i) : i)),
})
Expand Down
54 changes: 13 additions & 41 deletions packages/rest/src/cliAgent.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,19 @@
import type { InitConfig } from '@aries-framework/core'
import type { WalletConfig } from '@aries-framework/core/build/types'
import type { InitConfig, WalletConfig } from '@aries-framework/core'
import type { IndyVdrPoolConfig } from '@aries-framework/indy-vdr'

import { AnonCredsModule } from '@aries-framework/anoncreds'
import { AnonCredsRsModule } from '@aries-framework/anoncreds-rs'
import { AskarModule } from '@aries-framework/askar'
import {
HttpOutboundTransport,
WsOutboundTransport,
LogLevel,
Agent,
ConnectionsModule,
ProofsModule,
CredentialsModule,
AutoAcceptCredential,
AutoAcceptProof,
MediatorModule,
} from '@aries-framework/core'
import { IndyVdrAnonCredsRegistry, IndyVdrModule } from '@aries-framework/indy-vdr'
import { agentDependencies, HttpInboundTransport, WsInboundTransport } from '@aries-framework/node'
import { anoncreds } from '@hyperledger/anoncreds-nodejs'
import { ariesAskar } from '@hyperledger/aries-askar-nodejs'
import { indyVdr } from '@hyperledger/indy-vdr-nodejs'
import { readFile } from 'fs/promises'

import { setupServer } from './server'
import { getAgentModules } from './utils/agent'
import { TsLogger } from './utils/logger'

export type Transports = 'ws' | 'http'
Expand All @@ -46,7 +35,7 @@ const outboundTransportMapping = {
export interface AriesRestConfig {
label: string
walletConfig: WalletConfig
indyLedgers: [IndyVdrPoolConfig, ...IndyVdrPoolConfig[]]
indyLedgers: IndyVdrPoolConfig[]
endpoints?: string[]
autoAcceptConnections?: boolean
autoAcceptCredentials?: AutoAcceptCredential
Expand Down Expand Up @@ -93,36 +82,19 @@ export async function runRestAgent(restConfig: AriesRestConfig) {
logger,
}

const maybeLedgers = indyLedgers.length > 0 ? (indyLedgers as [IndyVdrPoolConfig, ...IndyVdrPoolConfig[]]) : undefined
const modules = getAgentModules({
autoAcceptConnections,
autoAcceptProofs,
autoAcceptCredentials,
autoAcceptMediationRequests,
indyLedgers: maybeLedgers,
})

const agent = new Agent({
config: agentConfig,
dependencies: agentDependencies,
modules: {
connections: new ConnectionsModule({
autoAcceptConnections,
}),
proofs: new ProofsModule({
autoAcceptProofs,
}),
credentials: new CredentialsModule({
autoAcceptCredentials,
}),
indyVdr: new IndyVdrModule({
indyVdr,
networks: indyLedgers,
}),
anoncreds: new AnonCredsModule({
registries: [new IndyVdrAnonCredsRegistry()],
}),
anoncredsRs: new AnonCredsRsModule({
anoncreds,
}),
askar: new AskarModule({
ariesAskar,
}),
mediator: new MediatorModule({
autoAcceptMediationRequests,
}),
},
modules,
})

// Register outbound transports
Expand Down
Loading

0 comments on commit 039948d

Please sign in to comment.