Skip to content

Commit c416278

Browse files
Misc. cleanup
Signed-off-by: Alexander Shenshin <alexander.shenshin@dsr-corporation.com>
1 parent 956bccb commit c416278

13 files changed

Lines changed: 69 additions & 77 deletions

File tree

heka-identity-service/src/common/agent/agent-modules.provider.ts

Lines changed: 27 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,10 @@ import {
2121
import {
2222
DidCommAutoAcceptCredential,
2323
DidCommAutoAcceptProof,
24-
DidCommConnectionsModule,
2524
DidCommCredentialV2Protocol,
26-
DidCommCredentialsModule,
2725
DidCommDifPresentationExchangeProofFormatService,
2826
DidCommModule,
29-
DidCommOutOfBandModule,
3027
DidCommProofV2Protocol,
31-
DidCommProofsModule,
3228
} from '@credo-ts/didcomm'
3329
import { HederaAnonCredsRegistry, HederaDidRegistrar, HederaDidResolver, HederaModule } from '@credo-ts/hedera'
3430
import {
@@ -82,32 +78,32 @@ function getTenantModulesMap(appConfig: ConfigType<typeof AppConfig>, agencyConf
8278
return {
8379
didcomm: new DidCommModule({
8480
...agencyConfig.didCommConfig,
81+
messagePickup: true,
82+
connections: {
83+
autoAcceptConnections: true,
84+
},
85+
credentials: {
86+
autoAcceptCredentials: DidCommAutoAcceptCredential.ContentApproved,
87+
credentialProtocols: [
88+
new DidCommCredentialV2Protocol({
89+
credentialFormats: [
90+
credentialFormatService,
91+
legacyIndyCredentialFormatService,
92+
dataIntegrityCredentialFormatService,
93+
// new JsonLdCredentialFormatService()
94+
],
95+
}),
96+
],
97+
},
98+
proofs: {
99+
autoAcceptProofs: DidCommAutoAcceptProof.ContentApproved,
100+
proofProtocols: [
101+
new DidCommProofV2Protocol({
102+
proofFormats: [legacyIndyProofFormatService, proofFormatService, presentationExchangeProofFormatService],
103+
}),
104+
],
105+
},
85106
}),
86-
connections: new DidCommConnectionsModule({
87-
autoAcceptConnections: true,
88-
}),
89-
credentials: new DidCommCredentialsModule({
90-
autoAcceptCredentials: DidCommAutoAcceptCredential.ContentApproved,
91-
credentialProtocols: [
92-
new DidCommCredentialV2Protocol({
93-
credentialFormats: [
94-
credentialFormatService,
95-
legacyIndyCredentialFormatService,
96-
dataIntegrityCredentialFormatService,
97-
// new JsonLdCredentialFormatService()
98-
],
99-
}),
100-
],
101-
}),
102-
proofs: new DidCommProofsModule({
103-
autoAcceptProofs: DidCommAutoAcceptProof.ContentApproved,
104-
proofProtocols: [
105-
new DidCommProofV2Protocol({
106-
proofFormats: [legacyIndyProofFormatService, proofFormatService, presentationExchangeProofFormatService],
107-
}),
108-
],
109-
}),
110-
oob: new DidCommOutOfBandModule(),
111107
dids: new DidsModule({
112108
resolvers: didResolvers,
113109
registrars: didRegistrars,
@@ -125,9 +121,8 @@ function getTenantModulesMap(appConfig: ConfigType<typeof AppConfig>, agencyConf
125121
askar,
126122
store: agencyConfig.askarStoreConfig,
127123
}),
128-
openId4Vc: new OpenId4VcModule({
129-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
130-
app: agencyConfig.oidConfig.app as any,
124+
openid4vc: new OpenId4VcModule({
125+
app: agencyConfig.oidConfig.app,
131126
issuer: {
132127
baseUrl: agencyConfig.oidConfig.issuanceEndpoint,
133128
credentialRequestToCredentialMapper: createCredentialRequestToCredentialMapper(

heka-identity-service/src/connection/connection.service.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import {
1717
export class ConnectionService {
1818
public constructor(private readonly userService: UserService) {}
1919
public async find(tenantAgent: TenantAgent): Promise<ConnectionRecordDto[]> {
20-
const connectionRecords = await tenantAgent.modules.connections.getAll()
20+
const connectionRecords = await tenantAgent.didcomm.connections.getAll()
2121
return connectionRecords.map((record) => new ConnectionRecordDto(record))
2222
}
2323

@@ -35,7 +35,7 @@ export class ConnectionService {
3535
}
3636
const didcommConfig = tenantAgent.dependencyManager.resolve(DidCommModuleConfig)
3737

38-
const outOfBandRecord = await tenantAgent.modules.oob.createInvitation(config)
38+
const outOfBandRecord = await tenantAgent.didcomm.oob.createInvitation(config)
3939

4040
const invitationUrl = outOfBandRecord.outOfBandInvitation.toUrl({ domain: didcommConfig.endpoints[0] })
4141
return new CreateInvitationResponseDto(outOfBandRecord.id, invitationUrl)
@@ -47,7 +47,7 @@ export class ConnectionService {
4747
alias: req.alias,
4848
}
4949

50-
const { connectionRecord } = await tenantAgent.modules.oob.receiveInvitationFromUrl(req.invitationUrl, config)
50+
const { connectionRecord } = await tenantAgent.didcomm.oob.receiveInvitationFromUrl(req.invitationUrl, config)
5151

5252
// It is expected that connectionRecord is created
5353
// because ConnectionsModule is configured with autoAcceptConnections=true
@@ -59,12 +59,12 @@ export class ConnectionService {
5959
}
6060

6161
public async get(tenantAgent: TenantAgent, id: string): Promise<ConnectionRecordDto | null> {
62-
const connectionRecord = await tenantAgent.modules.connections.findById(id)
62+
const connectionRecord = await tenantAgent.didcomm.connections.findById(id)
6363
if (connectionRecord) {
6464
return new ConnectionRecordDto(connectionRecord)
6565
}
6666

67-
const connectionRecordsByOobId = await tenantAgent.modules.connections.findAllByOutOfBandId(id)
67+
const connectionRecordsByOobId = await tenantAgent.didcomm.connections.findAllByOutOfBandId(id)
6868
if (connectionRecordsByOobId.length) {
6969
return new ConnectionRecordDto(connectionRecordsByOobId[0])
7070
}

heka-identity-service/src/credential-v2/credential-v2.service.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export class CredentialV2Service {
103103
if (!request.connectionId) {
104104
throw new UnprocessableEntityException(`Connection ID must me specified for Aries protocol`)
105105
}
106-
const connectionRecord = await tenantAgent.modules.connections.findById(request.connectionId)
106+
const connectionRecord = await tenantAgent.didcomm.connections.findById(request.connectionId)
107107
if (!connectionRecord) {
108108
throw new UnprocessableEntityException(`Referenced connection with ID=${request.connectionId} not found`)
109109
}
@@ -249,7 +249,7 @@ export class CredentialV2Service {
249249
if (!request.connectionId) {
250250
throw new UnprocessableEntityException(`Connection ID must me specified for Aries protocol`)
251251
}
252-
const connectionRecord = await tenantAgent.modules.connections.findById(request.connectionId)
252+
const connectionRecord = await tenantAgent.didcomm.connections.findById(request.connectionId)
253253
if (!connectionRecord) {
254254
throw new UnprocessableEntityException(`Referenced connection with ID=${request.connectionId} not found`)
255255
}
@@ -406,6 +406,5 @@ export class CredentialV2Service {
406406
},
407407
}
408408
}
409-
throw new Error(`Unsupported Aries proof format: ${template.credentialFormat}`)
410409
}
411410
}

heka-identity-service/src/credential-v2/dto/proof-by-template.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { IsNotEmpty, IsOptional, IsString, IsUUID } from 'class-validator'
55

66
import { CredentialValue } from 'credential-v2/dto/offer-by-template'
77

8-
export type CredentialDidCommProofState = OpenId4VcVerificationSessionState | DidCommProofState
8+
export type CredentialProofState = OpenId4VcVerificationSessionState | DidCommProofState
99

1010
export class ProofByVerificationTemplateRequest {
1111
@ApiProperty({ description: 'ID of issuance template' })
@@ -46,7 +46,7 @@ export class ProofByVerificationTemplateResponse {
4646
{ type: 'string', enum: Object.values(DidCommCredentialState) },
4747
],
4848
})
49-
public state!: CredentialDidCommProofState
49+
public state!: CredentialProofState
5050

5151
public constructor(partial?: Partial<ProofByVerificationTemplateRequest>) {
5252
Object.assign(this, partial)

heka-identity-service/src/credential/credential.service.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export class CredentialService {
3535
}
3636

3737
public async find(tenantAgent: TenantAgent, threadId?: string): Promise<CredentialRecordDto[]> {
38-
const credentialRecords = await tenantAgent.modules.credentials.findAllByQuery({ threadId })
38+
const credentialRecords = await tenantAgent.didcomm.credentials.findAllByQuery({ threadId })
3939
return credentialRecords.map((record) => new CredentialRecordDto(record))
4040
}
4141

@@ -44,7 +44,7 @@ export class CredentialService {
4444
}
4545

4646
public async offer(tenantAgent: TenantAgent, req: CredentialOfferDto): Promise<CredentialRecordDto> {
47-
const connectionRecord = await tenantAgent.modules.connections.findById(req.connectionId)
47+
const connectionRecord = await tenantAgent.didcomm.connections.findById(req.connectionId)
4848
if (!connectionRecord) {
4949
throw new UnprocessableEntityException(`Referenced connection with ID=${req.connectionId} not found`)
5050
}
@@ -80,7 +80,7 @@ export class CredentialService {
8080
revocationRegistryDefinitionId,
8181
revocationRegistryIndex,
8282
})
83-
const credentialRecord = await tenantAgent.modules.credentials.offerCredential({
83+
const credentialRecord = await tenantAgent.didcomm.credentials.offerCredential({
8484
connectionId: req.connectionId,
8585
comment: req.comment,
8686
protocolVersion: 'v2',
@@ -97,28 +97,28 @@ export class CredentialService {
9797
}
9898

9999
public async get(tenantAgent: TenantAgent, id: string): Promise<CredentialRecordDto> {
100-
const credentialRecord = await tenantAgent.modules.credentials.findById(id)
100+
const credentialRecord = await tenantAgent.didcomm.credentials.findById(id)
101101
if (!credentialRecord) {
102102
throw new NotFoundException('Credential record not found')
103103
}
104104
return new CredentialRecordDto(credentialRecord)
105105
}
106106

107107
public async accept(tenantAgent: TenantAgent, id: string): Promise<CredentialRecordDto> {
108-
let credentialRecord = await tenantAgent.modules.credentials.findById(id)
108+
let credentialRecord = await tenantAgent.didcomm.credentials.findById(id)
109109
if (!credentialRecord) {
110110
throw new NotFoundException('Credential record not found')
111111
}
112112
if (credentialRecord.state === DidCommCredentialState.Done) {
113113
throw new ConflictException('Credential is already accepted')
114114
}
115115

116-
credentialRecord = await tenantAgent.modules.credentials.acceptOffer({ credentialExchangeRecordId: id })
116+
credentialRecord = await tenantAgent.didcomm.credentials.acceptOffer({ credentialExchangeRecordId: id })
117117
return new CredentialRecordDto(credentialRecord)
118118
}
119119

120120
public async revoke(tenantAgent: TenantAgent, id: string): Promise<void> {
121-
const credential = await tenantAgent.modules.credentials.getById(id)
121+
const credential = await tenantAgent.didcomm.credentials.getById(id)
122122

123123
const revocationRegistryId = credential.getTag('anonCredsRevocationRegistryId') as string
124124
const revocationIndexStr = credential.getTag('anonCredsCredentialRevocationId') as string

heka-identity-service/src/openid4vc/issuance-sessions/issuance-session.service.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export class OpenId4VcIssuanceSessionService {
3333
tenantAgent: TenantAgent,
3434
req: OpenId4VcIssuanceSessionsCreateOfferDto,
3535
): Promise<OpenId4VcIssuanceSessionsCreateOfferResponse> {
36-
const issuer = await tenantAgent.modules.openId4Vc.issuer.getIssuerByIssuerId(req.publicIssuerId)
36+
const issuer = await tenantAgent.openid4vc.issuer.getIssuerByIssuerId(req.publicIssuerId)
3737

3838
// TODO: It is better to we move setting credential status to `credentialRequestToCredentialMapper`
3939
// to change status list when credential really requested but how??
@@ -129,7 +129,7 @@ export class OpenId4VcIssuanceSessionService {
129129
mappedCredentials.push(credentialIssuanceMeta)
130130
}
131131

132-
const { credentialOffer, issuanceSession } = await tenantAgent.modules.openId4Vc.issuer.createCredentialOffer({
132+
const { credentialOffer, issuanceSession } = await tenantAgent.openid4vc.issuer.createCredentialOffer({
133133
baseUri: req.baseUri,
134134
credentialConfigurationIds: req.credentials.map((c) => c.credentialSupportedId),
135135
issuerId: req.publicIssuerId,
@@ -177,7 +177,7 @@ export class OpenId4VcIssuanceSessionService {
177177
tenantAgent: TenantAgent,
178178
issuanceSessionId: string,
179179
): Promise<OpenId4VcIssuanceSessionRecordDto> {
180-
const issuanceSession = await tenantAgent.modules.openId4Vc.issuer.getIssuanceSessionById(issuanceSessionId)
180+
const issuanceSession = await tenantAgent.openid4vc.issuer.getIssuanceSessionById(issuanceSessionId)
181181

182182
return OpenId4VcIssuanceSessionRecordDto.fromOpenId4VcIssuanceSessionRecord(issuanceSession)
183183
}
@@ -198,7 +198,7 @@ export class OpenId4VcIssuanceSessionService {
198198
tenantAgent: TenantAgent,
199199
issuanceSessionId: string,
200200
): Promise<void> {
201-
const issuanceSession = await tenantAgent.modules.openId4Vc.issuer.getIssuanceSessionById(issuanceSessionId)
201+
const issuanceSession = await tenantAgent.openid4vc.issuer.getIssuanceSessionById(issuanceSessionId)
202202

203203
const credentials = issuanceSession.issuanceMetadata?.credentials as CredentialIssuanceMetadata[]
204204
if (!credentials) throw new Error('Credential not found')

heka-identity-service/src/openid4vc/issuer/issuer.service.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ export class OpenId4VcIssuerService {
2828
tenantAgent: TenantAgent,
2929
options: OpenId4VcIssuersCreateDto,
3030
): Promise<OpenId4VcIssuerRecordDto> {
31-
const allIssuers = await tenantAgent.modules.openId4Vc.issuer.getAllIssuers()
31+
const allIssuers = await tenantAgent.openid4vc.issuer.getAllIssuers()
3232
const existingIssuers = allIssuers.filter((i) => i.issuerId === options.publicIssuerId)
3333
if (existingIssuers.length) {
3434
throw new ConflictException(`Issuer with DID ${options.publicIssuerId} has been already created`)
3535
}
3636

37-
const issuer = await tenantAgent.modules.openId4Vc.issuer.createIssuer({
37+
const issuer = await tenantAgent.openid4vc.issuer.createIssuer({
3838
issuerId: options.publicIssuerId,
3939
credentialConfigurationsSupported: this.parseCredentialsSupported(tenantAgent, options.credentialsSupported),
4040
display: options.display,
@@ -43,7 +43,7 @@ export class OpenId4VcIssuerService {
4343
}
4444

4545
public async find(tenantAgent: TenantAgent, publicIssuerId: string): Promise<OpenId4VcIssuerRecordDto[]> {
46-
const allIssuers = await tenantAgent.modules.openId4Vc.issuer.getAllIssuers()
46+
const allIssuers = await tenantAgent.openid4vc.issuer.getAllIssuers()
4747
const issuers = allIssuers.filter((i) => i.issuerId === publicIssuerId)
4848
return issuers.map((issuer) => OpenId4VcIssuerRecordDto.fromOpenIdVcIssuerRecord(issuer))
4949
}
@@ -53,7 +53,7 @@ export class OpenId4VcIssuerService {
5353
issuerId: string,
5454
req: OpenId4VcIssuersUpdateMetadataDto,
5555
): Promise<OpenId4VcIssuerRecordDto> {
56-
const issuer = await tenantAgent.modules.openId4Vc.issuer.getIssuerByIssuerId(issuerId)
56+
const issuer = await tenantAgent.openid4vc.issuer.getIssuerByIssuerId(issuerId)
5757

5858
let credentialConfigurationsSupported = {}
5959
let display: OpenId4VciCredentialIssuerMetadataDisplay[] = []
@@ -89,21 +89,21 @@ export class OpenId4VcIssuerService {
8989
}
9090

9191
// FIXME: should return the updated record, now we fetch (AGAIN!!)
92-
await tenantAgent.modules.openId4Vc.issuer.updateIssuerMetadata({
92+
await tenantAgent.openid4vc.issuer.updateIssuerMetadata({
9393
issuerId,
9494
credentialConfigurationsSupported,
9595
display,
9696
})
9797

98-
const updatedIssuer = await tenantAgent.modules.openId4Vc.issuer.getIssuerByIssuerId(issuerId)
98+
const updatedIssuer = await tenantAgent.openid4vc.issuer.getIssuerByIssuerId(issuerId)
9999
return OpenId4VcIssuerRecordDto.fromOpenIdVcIssuerRecord(updatedIssuer)
100100
}
101101

102102
public async supportedCredentials(
103103
tenantAgent: TenantAgent,
104104
query: FindSupportedCredentialsDto,
105105
): Promise<OpenId4VciCredentialConfigurationSupportedWithId[]> {
106-
const issuer = await tenantAgent.modules.openId4Vc.issuer.getIssuerByIssuerId(query.publicIssuerId)
106+
const issuer = await tenantAgent.openid4vc.issuer.getIssuerByIssuerId(query.publicIssuerId)
107107

108108
return Object.entries(issuer.credentialConfigurationsSupported)
109109
.reduce<CredoCredentialConfigurationSupportedWithId[]>(

heka-identity-service/src/openid4vc/verification-sessions/verification-session.service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export class OpenId4VcVerificationSessionService {
2828
}
2929

3030
const { authorizationRequest, verificationSession } =
31-
await tenantAgent.modules.openId4Vc.verifier.createAuthorizationRequest({
31+
await tenantAgent.openid4vc.verifier.createAuthorizationRequest({
3232
requestSigner: {
3333
method: 'did',
3434
didUrl: didDocument.verificationMethod[0].id,
@@ -83,7 +83,7 @@ export class OpenId4VcVerificationSessionService {
8383

8484
if (verificationSessionRecord.state === OpenId4VcVerificationSessionState.ResponseVerified) {
8585
const verifiedAuthorizationResponse =
86-
await tenantAgent.modules.openId4Vc.verifier.getVerifiedAuthorizationResponse(verificationSessionId)
86+
await tenantAgent.openid4vc.verifier.getVerifiedAuthorizationResponse(verificationSessionId)
8787

8888
const presentations = verifiedAuthorizationResponse.presentationExchange?.presentations
8989
if (!presentations?.length) {

heka-identity-service/src/openid4vc/verifier/verifier.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export class OpenId4VcVerifierService {
1919
throw new ConflictException(`Verifier with DID ${options.publicVerifierId} has been already created`)
2020
}
2121

22-
const verifier = await tenantAgent.modules.openId4Vc.verifier.createVerifier({
22+
const verifier = await tenantAgent.openid4vc.verifier.createVerifier({
2323
verifierId: options.publicVerifierId,
2424
})
2525
return OpenId4VcVerifierRecordDto.fromOpenId4VcVerifierRecord(verifier)

0 commit comments

Comments
 (0)