Skip to content

Commit

Permalink
refactor: change hardcoded URLs to constants
Browse files Browse the repository at this point in the history
Signed-off-by: Karim <karim@animo.id>
  • Loading branch information
karimStekelenburg authored and TimoGlastra committed Jul 3, 2022
1 parent b1c9749 commit e53ee42
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions packages/core/src/modules/dids/domain/keyDidDocument.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import type { VerificationMethod } from './verificationMethod/VerificationMethod'

import { KeyType, Key } from '../../../crypto'
import { ED25519_SUITE_CONTEXT_URL_2018 } from '../../../crypto/signature-suites/ed25519/constants'
import { SECURITY_CONTEXT_BBS_URL, SECURITY_X25519_CONTEXT_URL } from '../../vc/constants'

import { DidDocumentBuilder } from './DidDocumentBuilder'
import { getBls12381g1VerificationMethod } from './key-type/bls12381g1'
Expand Down Expand Up @@ -31,7 +33,7 @@ function getBls12381g1DidDoc(did: string, key: Key) {
key,
verificationMethod,
})
.addContext('https://w3id.org/security/bbs/v1')
.addContext(SECURITY_CONTEXT_BBS_URL)
.build()
}

Expand All @@ -49,7 +51,7 @@ function getBls12381g1g2DidDoc(did: string, key: Key) {
.addCapabilityInvocation(verificationMethod.id)
}

return didDocumentBuilder.addContext('https://w3id.org/security/bbs/v1').build()
return didDocumentBuilder.addContext(SECURITY_CONTEXT_BBS_URL).build()
}

function getEd25519DidDoc(did: string, key: Key) {
Expand All @@ -66,8 +68,8 @@ function getEd25519DidDoc(did: string, key: Key) {
const didDocBuilder = getSignatureKeyBase({ did, key, verificationMethod })

didDocBuilder
.addContext('https://w3id.org/security/suites/ed25519-2018/v1')
.addContext('https://w3id.org/security/suites/x25519-2019/v1')
.addContext(ED25519_SUITE_CONTEXT_URL_2018)
.addContext(SECURITY_X25519_CONTEXT_URL)
.addKeyAgreement(x25519VerificationMethod)

return didDocBuilder.build()
Expand All @@ -78,7 +80,7 @@ function getX25519DidDoc(did: string, key: Key) {

const document = new DidDocumentBuilder(did)
.addKeyAgreement(verificationMethod)
.addContext('https://w3id.org/security/suites/x25519-2019/v1')
.addContext(SECURITY_X25519_CONTEXT_URL)
.build()

return document
Expand All @@ -92,7 +94,7 @@ function getBls12381g2DidDoc(did: string, key: Key) {
key,
verificationMethod,
})
.addContext('https://w3id.org/security/bbs/v1')
.addContext(SECURITY_CONTEXT_BBS_URL)
.build()
}

Expand Down

0 comments on commit e53ee42

Please sign in to comment.