Skip to content

Commit

Permalink
feat: anoncreds w3c migration (#1744)
Browse files Browse the repository at this point in the history
* feat: w3c migration + data integrity issuance protocol alpha

Signed-off-by: Martin Auer <[email protected]>
Co-authored-by: Karim Stekelenburg <[email protected]>
  • Loading branch information
auer-martin and karimStekelenburg authored Feb 23, 2024
1 parent 4f58925 commit d7c2bbb
Show file tree
Hide file tree
Showing 100 changed files with 6,920 additions and 1,041 deletions.
2 changes: 2 additions & 0 deletions packages/anoncreds/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
"test": "jest"
},
"dependencies": {
"@astronautlabs/jsonpath": "^1.1.2",
"@credo-ts/core": "0.4.2",
"big-integer": "^1.6.51",
"bn.js": "^5.2.1",
"class-transformer": "0.5.1",
"class-validator": "0.14.1",
Expand Down
4 changes: 2 additions & 2 deletions packages/anoncreds/src/AnonCredsApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -601,8 +601,8 @@ export class AnonCredsApi {
}
}

public async getCredential(credentialId: string) {
return this.anonCredsHolderService.getCredential(this.agentContext, { credentialId })
public async getCredential(id: string) {
return this.anonCredsHolderService.getCredential(this.agentContext, { id })
}

public async getCredentials(options: GetCredentialsOptions) {
Expand Down
11 changes: 11 additions & 0 deletions packages/anoncreds/src/AnonCredsModule.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import type { AnonCredsModuleConfigOptions } from './AnonCredsModuleConfig'
import type { DependencyManager, Module, Update } from '@credo-ts/core'

import { AnonCredsDataIntegrityServiceSymbol } from '@credo-ts/core'

import { AnonCredsApi } from './AnonCredsApi'
import { AnonCredsModuleConfig } from './AnonCredsModuleConfig'
import { AnonCredsRsHolderService, AnonCredsRsIssuerService, AnonCredsRsVerifierService } from './anoncreds-rs'
import { AnonCredsDataIntegrityService } from './anoncreds-rs/AnonCredsDataIntegrityService'
import {
AnonCredsCredentialDefinitionPrivateRepository,
AnonCredsKeyCorrectnessProofRepository,
Expand All @@ -16,6 +19,7 @@ import { AnonCredsSchemaRepository } from './repository/AnonCredsSchemaRepositor
import { AnonCredsHolderServiceSymbol, AnonCredsIssuerServiceSymbol, AnonCredsVerifierServiceSymbol } from './services'
import { AnonCredsRegistryService } from './services/registry/AnonCredsRegistryService'
import { updateAnonCredsModuleV0_3_1ToV0_4 } from './updates/0.3.1-0.4'
import { updateAnonCredsModuleV0_4ToV0_5 } from './updates/0.4-0.5'

/**
* @public
Expand Down Expand Up @@ -47,6 +51,8 @@ export class AnonCredsModule implements Module {
dependencyManager.registerSingleton(AnonCredsHolderServiceSymbol, AnonCredsRsHolderService)
dependencyManager.registerSingleton(AnonCredsIssuerServiceSymbol, AnonCredsRsIssuerService)
dependencyManager.registerSingleton(AnonCredsVerifierServiceSymbol, AnonCredsRsVerifierService)

dependencyManager.registerSingleton(AnonCredsDataIntegrityServiceSymbol, AnonCredsDataIntegrityService)
}

public updates = [
Expand All @@ -55,5 +61,10 @@ export class AnonCredsModule implements Module {
toVersion: '0.4',
doUpdate: updateAnonCredsModuleV0_3_1ToV0_4,
},
{
fromVersion: '0.4',
toVersion: '0.5',
doUpdate: updateAnonCredsModuleV0_4ToV0_5,
},
] satisfies Update[]
}
10 changes: 9 additions & 1 deletion packages/anoncreds/src/__tests__/AnonCredsModule.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import type { AnonCredsRegistry } from '../services'
import type { DependencyManager } from '@credo-ts/core'

import { AnonCredsDataIntegrityServiceSymbol } from '@credo-ts/core'

import { anoncreds } from '../../tests/helpers'
import { AnonCredsModule } from '../AnonCredsModule'
import { AnonCredsModuleConfig } from '../AnonCredsModuleConfig'
import { AnonCredsRsHolderService, AnonCredsRsIssuerService, AnonCredsRsVerifierService } from '../anoncreds-rs'
import { AnonCredsDataIntegrityService } from '../anoncreds-rs/AnonCredsDataIntegrityService'
import {
AnonCredsSchemaRepository,
AnonCredsCredentialDefinitionRepository,
Expand Down Expand Up @@ -32,7 +35,7 @@ describe('AnonCredsModule', () => {
})
anonCredsModule.register(dependencyManager)

expect(dependencyManager.registerSingleton).toHaveBeenCalledTimes(11)
expect(dependencyManager.registerSingleton).toHaveBeenCalledTimes(12)
expect(dependencyManager.registerSingleton).toHaveBeenCalledWith(AnonCredsRegistryService)
expect(dependencyManager.registerSingleton).toHaveBeenCalledWith(AnonCredsSchemaRepository)
expect(dependencyManager.registerSingleton).toHaveBeenCalledWith(AnonCredsCredentialDefinitionRepository)
Expand All @@ -57,6 +60,11 @@ describe('AnonCredsModule', () => {
AnonCredsRsVerifierService
)

expect(dependencyManager.registerSingleton).toHaveBeenCalledWith(
AnonCredsDataIntegrityServiceSymbol,
AnonCredsDataIntegrityService
)

expect(dependencyManager.registerInstance).toHaveBeenCalledTimes(1)
expect(dependencyManager.registerInstance).toHaveBeenCalledWith(AnonCredsModuleConfig, anonCredsModule.config)
})
Expand Down
Loading

0 comments on commit d7c2bbb

Please sign in to comment.