Skip to content

Commit

Permalink
Merge branch 'main' into feat/indy-credential-format-service
Browse files Browse the repository at this point in the history
  • Loading branch information
genaris authored Jan 29, 2023
2 parents 78883dd + e8d6ac3 commit e2b2378
Show file tree
Hide file tree
Showing 41 changed files with 995 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ describeSkipNode17And18('credentials, BBS+ signature', () => {
'Faber Agent Credentials LD BBS+',
'Alice Agent Credentials LD BBS+'
))
wallet = faberAgent.injectionContainer.resolve<Wallet>(InjectionSymbols.Wallet)
wallet = faberAgent.dependencyManager.resolve<Wallet>(InjectionSymbols.Wallet)
await wallet.createKey({ keyType: KeyType.Ed25519, seed })
const key = await wallet.createKey({ keyType: KeyType.Bls12381g2, seed })

Expand Down
3 changes: 3 additions & 0 deletions packages/core/src/agent/BaseAgent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,9 @@ export abstract class BaseAgent<AgentModules extends ModulesMap = EmptyModuleMap
})
}

/**
* @deprecated The injectionContainer property has been deprecated in favour of the dependencyManager property.
*/
public get injectionContainer() {
return this.dependencyManager.container
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ describe('credentials', () => {
aliceAgent.events
.observable<CredentialStateChangedEvent>(CredentialEventTypes.CredentialStateChanged)
.subscribe(aliceReplay)
wallet = faberAgent.injectionContainer.resolve<Wallet>(InjectionSymbols.Wallet)
wallet = faberAgent.dependencyManager.resolve<Wallet>(InjectionSymbols.Wallet)

await wallet.createKey({ seed, keyType: KeyType.Ed25519 })

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ describe('credentials', () => {
AutoAcceptCredential.Always
))

wallet = faberAgent.injectionContainer.resolve<Wallet>(InjectionSymbols.Wallet)
wallet = faberAgent.dependencyManager.resolve<Wallet>(InjectionSymbols.Wallet)
await wallet.createKey({ seed, keyType: KeyType.Ed25519 })
signCredentialOptions = {
credential: TEST_LD_DOCUMENT,
Expand Down Expand Up @@ -142,7 +142,7 @@ describe('credentials', () => {
'alice agent: content-approved v2 jsonld',
AutoAcceptCredential.ContentApproved
))
wallet = faberAgent.injectionContainer.resolve<Wallet>(InjectionSymbols.Wallet)
wallet = faberAgent.dependencyManager.resolve<Wallet>(InjectionSymbols.Wallet)
await wallet.createKey({ seed, keyType: KeyType.Ed25519 })
signCredentialOptions = {
credential: TEST_LD_DOCUMENT,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ describe('credentials', () => {
'Faber Agent Credentials LD',
'Alice Agent Credentials LD'
))
wallet = faberAgent.injectionContainer.resolve<Wallet>(InjectionSymbols.Wallet)
wallet = faberAgent.dependencyManager.resolve<Wallet>(InjectionSymbols.Wallet)
await wallet.createKey({ seed, keyType: KeyType.Ed25519 })
signCredentialOptions = {
credential: inputDocAsJson,
Expand Down Expand Up @@ -312,7 +312,6 @@ describe('credentials', () => {
threadId: faberCredentialRecord.threadId,
state: CredentialState.OfferReceived,
})
// didCommMessageRepository = faberAgent.injectionContainer.resolve(DidCommMessageRepository)
didCommMessageRepository = faberAgent.dependencyManager.resolve(DidCommMessageRepository)

const offerMessage = await didCommMessageRepository.findAgentMessage(faberAgent.context, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ describe('dids', () => {
const ed25519PublicKeyBase58 = TypedArrayEncoder.toBase58(publicKeyEd25519)
const indyDid = indyDidFromPublicKeyBase58(ed25519PublicKeyBase58)

const wallet = agent.injectionContainer.resolve<Wallet>(InjectionSymbols.Wallet)
const wallet = agent.dependencyManager.resolve<Wallet>(InjectionSymbols.Wallet)
// eslint-disable-next-line @typescript-eslint/no-non-null-asserted-optional-chain, @typescript-eslint/no-non-null-assertion
const submitterDid = `did:sov:${wallet.publicDid?.did!}`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ describe('Present Proof', () => {
testLogger.test('Faber waits for presentation from Alice')
faberProofExchangeRecord = await faberProofExchangeRecordPromise

didCommMessageRepository = faberAgent.injectionContainer.resolve<DidCommMessageRepository>(DidCommMessageRepository)
didCommMessageRepository = faberAgent.dependencyManager.resolve<DidCommMessageRepository>(DidCommMessageRepository)

let proposal = await didCommMessageRepository.findAgentMessage(faberAgent.context, {
associatedRecordId: faberProofExchangeRecord.id,
Expand Down Expand Up @@ -159,7 +159,7 @@ describe('Present Proof', () => {
testLogger.test('Alice waits for proof request from Faber')
aliceProofExchangeRecord = await aliceProofExchangeRecordPromise

didCommMessageRepository = faberAgent.injectionContainer.resolve<DidCommMessageRepository>(DidCommMessageRepository)
didCommMessageRepository = faberAgent.dependencyManager.resolve<DidCommMessageRepository>(DidCommMessageRepository)

let request = await didCommMessageRepository.findAgentMessage(faberAgent.context, {
associatedRecordId: faberProofExchangeRecord.id,
Expand Down Expand Up @@ -212,7 +212,7 @@ describe('Present Proof', () => {
testLogger.test('Faber waits for presentation from Alice')
faberProofExchangeRecord = await faberProofExchangeRecordPromise

didCommMessageRepository = faberAgent.injectionContainer.resolve<DidCommMessageRepository>(DidCommMessageRepository)
didCommMessageRepository = faberAgent.dependencyManager.resolve<DidCommMessageRepository>(DidCommMessageRepository)

proposal = await didCommMessageRepository.findAgentMessage(faberAgent.context, {
associatedRecordId: faberProofExchangeRecord.id,
Expand Down Expand Up @@ -266,7 +266,7 @@ describe('Present Proof', () => {
testLogger.test('Alice waits for proof request from Faber')
aliceProofExchangeRecord = await aliceProofExchangeRecordPromise

didCommMessageRepository = faberAgent.injectionContainer.resolve<DidCommMessageRepository>(DidCommMessageRepository)
didCommMessageRepository = faberAgent.dependencyManager.resolve<DidCommMessageRepository>(DidCommMessageRepository)

request = await didCommMessageRepository.findAgentMessage(faberAgent.context, {
associatedRecordId: faberProofExchangeRecord.id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ describe('Present Proof', () => {

faberProofExchangeRecord = await faberProofExchangeRecordPromise

didCommMessageRepository = faberAgent.injectionContainer.resolve<DidCommMessageRepository>(DidCommMessageRepository)
didCommMessageRepository = faberAgent.dependencyManager.resolve<DidCommMessageRepository>(DidCommMessageRepository)

const proposal = await didCommMessageRepository.findAgentMessage(faberAgent.context, {
associatedRecordId: faberProofExchangeRecord.id,
Expand Down Expand Up @@ -118,7 +118,7 @@ describe('Present Proof', () => {
testLogger.test('Alice waits for proof request from Faber')
aliceProofExchangeRecord = await aliceProofExchangeRecordPromise

didCommMessageRepository = faberAgent.injectionContainer.resolve<DidCommMessageRepository>(DidCommMessageRepository)
didCommMessageRepository = faberAgent.dependencyManager.resolve<DidCommMessageRepository>(DidCommMessageRepository)

const request = await didCommMessageRepository.findAgentMessage(faberAgent.context, {
associatedRecordId: faberProofExchangeRecord.id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ describe('Present Proof', () => {
testLogger.test('Faber waits for presentation from Alice')
faberProofExchangeRecord = await faberProofExchangeRecordPromise

didCommMessageRepository = faberAgent.injectionContainer.resolve<DidCommMessageRepository>(DidCommMessageRepository)
didCommMessageRepository = faberAgent.dependencyManager.resolve<DidCommMessageRepository>(DidCommMessageRepository)

const proposal = await didCommMessageRepository.findAgentMessage(faberAgent.context, {
associatedRecordId: faberProofExchangeRecord.id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ describe('Present Proof', () => {
testLogger.test('Faber waits for presentation from Alice')
faberProofExchangeRecord = await faberProofExchangeRecordPromise

didCommMessageRepository = faberAgent.injectionContainer.resolve<DidCommMessageRepository>(DidCommMessageRepository)
didCommMessageRepository = faberAgent.dependencyManager.resolve<DidCommMessageRepository>(DidCommMessageRepository)

const proposal = await didCommMessageRepository.findAgentMessage(faberAgent.context, {
associatedRecordId: faberProofExchangeRecord.id,
Expand Down Expand Up @@ -120,7 +120,7 @@ describe('Present Proof', () => {
testLogger.test('Alice waits for proof request from Faber')
aliceProofExchangeRecord = await aliceProofExchangeRecordPromise

didCommMessageRepository = faberAgent.injectionContainer.resolve<DidCommMessageRepository>(DidCommMessageRepository)
didCommMessageRepository = faberAgent.dependencyManager.resolve<DidCommMessageRepository>(DidCommMessageRepository)

const request = await didCommMessageRepository.findAgentMessage(faberAgent.context, {
associatedRecordId: faberProofExchangeRecord.id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ describe('Present Proof', () => {
testLogger.test('Faber waits for presentation from Alice')
faberProofExchangeRecord = await faberProofExchangeRecordPromise

didCommMessageRepository = faberAgent.injectionContainer.resolve<DidCommMessageRepository>(DidCommMessageRepository)
didCommMessageRepository = faberAgent.dependencyManager.resolve<DidCommMessageRepository>(DidCommMessageRepository)

let proposal = await didCommMessageRepository.findAgentMessage(faberAgent.context, {
associatedRecordId: faberProofExchangeRecord.id,
Expand Down Expand Up @@ -188,7 +188,7 @@ describe('Present Proof', () => {
testLogger.test('Alice waits for proof request from Faber')
aliceProofExchangeRecord = await aliceProofExchangeRecordPromise

didCommMessageRepository = faberAgent.injectionContainer.resolve<DidCommMessageRepository>(DidCommMessageRepository)
didCommMessageRepository = faberAgent.dependencyManager.resolve<DidCommMessageRepository>(DidCommMessageRepository)

let request = await didCommMessageRepository.findAgentMessage(faberAgent.context, {
associatedRecordId: faberProofExchangeRecord.id,
Expand Down Expand Up @@ -241,7 +241,7 @@ describe('Present Proof', () => {
testLogger.test('Faber waits for presentation from Alice')
faberProofExchangeRecord = await faberProofExchangeRecordPromise

didCommMessageRepository = faberAgent.injectionContainer.resolve<DidCommMessageRepository>(DidCommMessageRepository)
didCommMessageRepository = faberAgent.dependencyManager.resolve<DidCommMessageRepository>(DidCommMessageRepository)

proposal = await didCommMessageRepository.findAgentMessage(faberAgent.context, {
associatedRecordId: faberProofExchangeRecord.id,
Expand Down Expand Up @@ -319,7 +319,7 @@ describe('Present Proof', () => {
testLogger.test('Alice waits for proof request from Faber')
aliceProofExchangeRecord = await aliceProofExchangeRecordPromise

didCommMessageRepository = faberAgent.injectionContainer.resolve<DidCommMessageRepository>(DidCommMessageRepository)
didCommMessageRepository = faberAgent.dependencyManager.resolve<DidCommMessageRepository>(DidCommMessageRepository)

request = await didCommMessageRepository.findAgentMessage(faberAgent.context, {
associatedRecordId: faberProofExchangeRecord.id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ describe('Present Proof', () => {
testLogger.test('Faber waits for presentation from Alice')
faberProofExchangeRecord = await faberPresentationRecordPromise

didCommMessageRepository = faberAgent.injectionContainer.resolve<DidCommMessageRepository>(DidCommMessageRepository)
didCommMessageRepository = faberAgent.dependencyManager.resolve<DidCommMessageRepository>(DidCommMessageRepository)

const proposal = await didCommMessageRepository.findAgentMessage(faberAgent.context, {
associatedRecordId: faberProofExchangeRecord.id,
Expand Down Expand Up @@ -118,7 +118,7 @@ describe('Present Proof', () => {
testLogger.test('Alice waits for proof request from Faber')
aliceProofExchangeRecord = await alicePresentationRecordPromise

didCommMessageRepository = faberAgent.injectionContainer.resolve<DidCommMessageRepository>(DidCommMessageRepository)
didCommMessageRepository = faberAgent.dependencyManager.resolve<DidCommMessageRepository>(DidCommMessageRepository)

const request = await didCommMessageRepository.findAgentMessage(faberAgent.context, {
associatedRecordId: faberProofExchangeRecord.id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ describe('Present Proof', () => {
testLogger.test('Faber waits for presentation from Alice')
faberPresentationRecord = await faberPresentationRecordPromise

didCommMessageRepository = faberAgent.injectionContainer.resolve<DidCommMessageRepository>(DidCommMessageRepository)
didCommMessageRepository = faberAgent.dependencyManager.resolve<DidCommMessageRepository>(DidCommMessageRepository)

const proposal = await didCommMessageRepository.findAgentMessage(faberAgent.context, {
associatedRecordId: faberPresentationRecord.id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ describe('Present Proof', () => {
testLogger.test('Faber waits for presentation from Alice')
faberProofExchangeRecord = await faberPresentationRecordPromise

didCommMessageRepository = faberAgent.injectionContainer.resolve<DidCommMessageRepository>(DidCommMessageRepository)
didCommMessageRepository = faberAgent.dependencyManager.resolve<DidCommMessageRepository>(DidCommMessageRepository)

const proposal = await didCommMessageRepository.findAgentMessage(faberAgent.context, {
associatedRecordId: faberProofExchangeRecord.id,
Expand Down Expand Up @@ -114,7 +114,7 @@ describe('Present Proof', () => {
testLogger.test('Alice waits for proof request from Faber')
aliceProofExchangeRecord = await alicePresentationRecordPromise

didCommMessageRepository = faberAgent.injectionContainer.resolve<DidCommMessageRepository>(DidCommMessageRepository)
didCommMessageRepository = faberAgent.dependencyManager.resolve<DidCommMessageRepository>(DidCommMessageRepository)

const request = await didCommMessageRepository.findAgentMessage(faberAgent.context, {
associatedRecordId: faberProofExchangeRecord.id,
Expand Down
8 changes: 4 additions & 4 deletions packages/core/src/storage/migration/__tests__/0.1.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ describe('UpdateAssistant | v0.1 - v0.2', () => {
dependencyManager
)

const fileSystem = agent.injectionContainer.resolve<FileSystem>(InjectionSymbols.FileSystem)
const fileSystem = agent.dependencyManager.resolve<FileSystem>(InjectionSymbols.FileSystem)

const updateAssistant = new UpdateAssistant(agent, {
v0_1ToV0_2: {
Expand Down Expand Up @@ -110,7 +110,7 @@ describe('UpdateAssistant | v0.1 - v0.2', () => {
dependencyManager
)

const fileSystem = agent.injectionContainer.resolve<FileSystem>(InjectionSymbols.FileSystem)
const fileSystem = agent.dependencyManager.resolve<FileSystem>(InjectionSymbols.FileSystem)

const updateAssistant = new UpdateAssistant(agent, {
v0_1ToV0_2: {
Expand Down Expand Up @@ -174,7 +174,7 @@ describe('UpdateAssistant | v0.1 - v0.2', () => {
dependencyManager
)

const fileSystem = agent.injectionContainer.resolve<FileSystem>(InjectionSymbols.FileSystem)
const fileSystem = agent.dependencyManager.resolve<FileSystem>(InjectionSymbols.FileSystem)

const updateAssistant = new UpdateAssistant(agent, {
v0_1ToV0_2: {
Expand Down Expand Up @@ -242,7 +242,7 @@ describe('UpdateAssistant | v0.1 - v0.2', () => {
dependencyManager
)

const fileSystem = agent.injectionContainer.resolve<FileSystem>(InjectionSymbols.FileSystem)
const fileSystem = agent.dependencyManager.resolve<FileSystem>(InjectionSymbols.FileSystem)

const updateAssistant = new UpdateAssistant(agent, {
v0_1ToV0_2: {
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/storage/migration/__tests__/0.2.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ describe('UpdateAssistant | v0.2 - v0.3.1', () => {
dependencyManager
)

const fileSystem = agent.injectionContainer.resolve<FileSystem>(InjectionSymbols.FileSystem)
const fileSystem = agent.dependencyManager.resolve<FileSystem>(InjectionSymbols.FileSystem)

const updateAssistant = new UpdateAssistant(agent, {
v0_1ToV0_2: {
Expand Down Expand Up @@ -119,7 +119,7 @@ describe('UpdateAssistant | v0.2 - v0.3.1', () => {
dependencyManager
)

const fileSystem = agent.injectionContainer.resolve<FileSystem>(InjectionSymbols.FileSystem)
const fileSystem = agent.dependencyManager.resolve<FileSystem>(InjectionSymbols.FileSystem)

// We need to manually initialize the wallet as we're using the in memory wallet service
// When we call agent.initialize() it will create the wallet and store the current framework
Expand Down Expand Up @@ -170,7 +170,7 @@ describe('UpdateAssistant | v0.2 - v0.3.1', () => {
dependencyManager
)

const fileSystem = agent.injectionContainer.resolve<FileSystem>(InjectionSymbols.FileSystem)
const fileSystem = agent.dependencyManager.resolve<FileSystem>(InjectionSymbols.FileSystem)

// We need to manually initialize the wallet as we're using the in memory wallet service
// When we call agent.initialize() it will create the wallet and store the current framework
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/storage/migration/__tests__/0.3.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ describe('UpdateAssistant | v0.3 - v0.3.1', () => {
dependencyManager
)

const fileSystem = agent.injectionContainer.resolve<FileSystem>(InjectionSymbols.FileSystem)
const fileSystem = agent.dependencyManager.resolve<FileSystem>(InjectionSymbols.FileSystem)

const updateAssistant = new UpdateAssistant(agent, {
v0_1ToV0_2: {
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/storage/migration/__tests__/backup.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ describe('UpdateAssistant | Backup', () => {
// Expect an update is needed
expect(await updateAssistant.isUpToDate()).toBe(false)

const fileSystem = agent.injectionContainer.resolve<FileSystem>(InjectionSymbols.FileSystem)
const fileSystem = agent.dependencyManager.resolve<FileSystem>(InjectionSymbols.FileSystem)
// Backup should not exist before update
expect(await fileSystem.exists(backupPath)).toBe(false)

Expand Down Expand Up @@ -128,7 +128,7 @@ describe('UpdateAssistant | Backup', () => {
},
])

const fileSystem = agent.injectionContainer.resolve<FileSystem>(InjectionSymbols.FileSystem)
const fileSystem = agent.dependencyManager.resolve<FileSystem>(InjectionSymbols.FileSystem)
// Backup should not exist before update
expect(await fileSystem.exists(backupPath)).toBe(false)

Expand Down
3 changes: 3 additions & 0 deletions packages/core/tests/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import type { Awaited, WalletConfig } from '../src/types'
import type { CredDef, Schema } from 'indy-sdk'
import type { Observable } from 'rxjs'

import { readFileSync } from 'fs'
import path from 'path'
import { firstValueFrom, ReplaySubject, Subject } from 'rxjs'
import { catchError, filter, map, timeout } from 'rxjs/operators'
Expand Down Expand Up @@ -83,6 +84,8 @@ export const genesisPath = process.env.GENESIS_TXN_PATH
? path.resolve(process.env.GENESIS_TXN_PATH)
: path.join(__dirname, '../../../network/genesis/local-genesis.txn')

export const genesisTransactions = readFileSync(genesisPath).toString('utf-8')

export const publicDidSeed = process.env.TEST_AGENT_PUBLIC_DID_SEED ?? '000000000000000000000000Trustee9'
const taaVersion = (process.env.TEST_AGENT_TAA_VERSION ?? '1') as `${number}.${number}` | `${number}`
const taaAcceptanceMechanism = process.env.TEST_AGENT_TAA_ACCEPTANCE_MECHANISM ?? 'accept'
Expand Down
Loading

0 comments on commit e2b2378

Please sign in to comment.