Skip to content

Commit

Permalink
Corrected adding HTTP service
Browse files Browse the repository at this point in the history
  • Loading branch information
Artemkaaas committed Aug 22, 2022
1 parent 677eaa0 commit 8f6140c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 25 deletions.
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@sicpa-dlab/aries-framework-core",
"main": "build/index",
"types": "build/index",
"version": "0.1.52",
"version": "0.1.53",
"files": [
"build"
],
Expand Down
45 changes: 21 additions & 24 deletions packages/core/src/modules/dids/services/DidService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,40 +134,37 @@ export class DidService {
.addAuthentication(getEd25519VerificationMethod({ controller: '', id: '', key: params.ed25519Key }))
.addKeyAgreement(getX25519VerificationMethod({ controller: '', id: '', key: params.x25519Key }))

for (const transport of params.transports) {
if (transport === Transports.HTTP || transport === Transports.HTTPS) {
if (params.needMediation) {
mediator = await this.mediationRecipientService.findDefaultMediator()
if (mediator && mediator.endpoint && params.needMediation) {
didDocumentBuilder.addService(
new DidCommV2Service({
id: transport,
serviceEndpoint: mediator.endpoint,
routingKeys: mediator.routingKeys,
})
)
}
} else if (params.endpoint) {
if (params.transports.includes(Transports.HTTP) || params.transports.includes(Transports.HTTPS)) {
if (params.needMediation) {
mediator = await this.mediationRecipientService.findDefaultMediator()
if (mediator && mediator.endpoint && params.needMediation) {
didDocumentBuilder.addService(
new DidCommV2Service({
id: transport,
serviceEndpoint: params.endpoint,
routingKeys: [],
id: Transports.HTTP,
serviceEndpoint: mediator.endpoint,
routingKeys: mediator.routingKeys,
})
)
}
}

if (transport === Transports.NFC) {
didDocumentBuilder.addService(new DidCommV2Service({ id: Transports.NFC, serviceEndpoint: Transports.NFC }))
}
if (transport === Transports.Nearby) {
} else if (params.endpoint) {
didDocumentBuilder.addService(
new DidCommV2Service({ id: Transports.Nearby, serviceEndpoint: Transports.Nearby })
new DidCommV2Service({
id: Transports.HTTP,
serviceEndpoint: params.endpoint,
routingKeys: [],
})
)
}
}

if (params.transports.includes(Transports.NFC)) {
didDocumentBuilder.addService(new DidCommV2Service({ id: Transports.NFC, serviceEndpoint: Transports.NFC }))
}

if (params.transports.includes(Transports.Nearby)) {
didDocumentBuilder.addService(new DidCommV2Service({ id: Transports.Nearby, serviceEndpoint: Transports.Nearby }))
}

const didDocument = didDocumentBuilder.build()
const didPeer =
didDocument.service.length > 0
Expand Down

0 comments on commit 8f6140c

Please sign in to comment.