Skip to content

Commit

Permalink
feat(credentials): credential module config
Browse files Browse the repository at this point in the history
Signed-off-by: Timo Glastra <timo@animo.id>
  • Loading branch information
TimoGlastra committed Jul 13, 2022
1 parent 310185b commit 7cb7ed3
Show file tree
Hide file tree
Showing 8 changed files with 672 additions and 633 deletions.
4 changes: 3 additions & 1 deletion packages/core/src/agent/Agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,9 @@ export class Agent extends BaseAgent {
// Register all modules
dependencyManager.registerModules(
ConnectionsModule,
CredentialsModule,
new CredentialsModule({
autoAcceptCredentials: this.agentConfig.autoAcceptCredentials,
}),
ProofsModule,
MediatorModule,
RecipientModule,
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/agent/BaseAgent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type { TransportSession } from './TransportService'
import { AriesFrameworkError } from '../error'
import { BasicMessagesModule } from '../modules/basic-messages/BasicMessagesModule'
import { ConnectionsModule } from '../modules/connections/ConnectionsModule'
import { CredentialsModule } from '../modules/credentials/CredentialsModule'
import { CredentialsApi } from '../modules/credentials/CredentialsApi'
import { DidsModule } from '../modules/dids/DidsModule'
import { DiscoverFeaturesModule } from '../modules/discover-features'
import { GenericRecordsModule } from '../modules/generic-records/GenericRecordsModule'
Expand Down Expand Up @@ -45,7 +45,7 @@ export abstract class BaseAgent {
public readonly genericRecords: GenericRecordsModule
public readonly ledger: LedgerModule
public readonly questionAnswer!: QuestionAnswerModule
public readonly credentials: CredentialsModule
public readonly credentials: CredentialsApi
public readonly mediationRecipient: RecipientModule
public readonly mediator: MediatorModule
public readonly discovery: DiscoverFeaturesModule
Expand Down Expand Up @@ -82,7 +82,7 @@ export abstract class BaseAgent {

// We set the modules in the constructor because that allows to set them as read-only
this.connections = this.dependencyManager.resolve(ConnectionsModule)
this.credentials = this.dependencyManager.resolve(CredentialsModule) as CredentialsModule
this.credentials = this.dependencyManager.resolve(CredentialsApi) as CredentialsApi
this.proofs = this.dependencyManager.resolve(ProofsModule)
this.mediator = this.dependencyManager.resolve(MediatorModule)
this.mediationRecipient = this.dependencyManager.resolve(RecipientModule)
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/agent/__tests__/Agent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { ConnectionRepository } from '../../modules/connections/repository/Conne
import { ConnectionService } from '../../modules/connections/services/ConnectionService'
import { TrustPingService } from '../../modules/connections/services/TrustPingService'
import { CredentialRepository } from '../../modules/credentials'
import { CredentialsModule } from '../../modules/credentials/CredentialsModule'
import { CredentialsApi } from '../../modules/credentials/CredentialsApi'
import { IndyLedgerService } from '../../modules/ledger'
import { LedgerModule } from '../../modules/ledger/LedgerModule'
import { ProofRepository, ProofService } from '../../modules/proofs'
Expand Down Expand Up @@ -119,7 +119,7 @@ describe('Agent', () => {
expect(container.resolve(ProofService)).toBeInstanceOf(ProofService)
expect(container.resolve(ProofRepository)).toBeInstanceOf(ProofRepository)

expect(container.resolve(CredentialsModule)).toBeInstanceOf(CredentialsModule)
expect(container.resolve(CredentialsApi)).toBeInstanceOf(CredentialsApi)
expect(container.resolve(CredentialRepository)).toBeInstanceOf(CredentialRepository)

expect(container.resolve(BasicMessagesModule)).toBeInstanceOf(BasicMessagesModule)
Expand Down Expand Up @@ -161,7 +161,7 @@ describe('Agent', () => {
expect(container.resolve(ProofService)).toBe(container.resolve(ProofService))
expect(container.resolve(ProofRepository)).toBe(container.resolve(ProofRepository))

expect(container.resolve(CredentialsModule)).toBe(container.resolve(CredentialsModule))
expect(container.resolve(CredentialsApi)).toBe(container.resolve(CredentialsApi))
expect(container.resolve(CredentialRepository)).toBe(container.resolve(CredentialRepository))

expect(container.resolve(BasicMessagesModule)).toBe(container.resolve(BasicMessagesModule))
Expand Down
Loading

0 comments on commit 7cb7ed3

Please sign in to comment.