Skip to content

Commit

Permalink
handle issuer property as string
Browse files Browse the repository at this point in the history
  • Loading branch information
jchartrand committed Oct 7, 2024
1 parent a91d51d commit df74001
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions src/issue.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,24 @@ const getIssuerInstance = async (instanceId) => {
return ISSUER_INSTANCES[instanceId]
}

const issue = async (unsignedVerifiableCredential, issuerId) => {
const { issuerInstance, didDocument } = await getIssuerInstance(issuerId)
unsignedVerifiableCredential.issuer.id = didDocument.id
const signedCredential = await issuerInstance.issueCredential({
const issue = async (unsignedVerifiableCredential, instanceId) => {
const {
issuerInstance,
didDocument: { id: issuerId }
} = await getIssuerInstance(instanceId)
addIssuerId(unsignedVerifiableCredential, issuerId)
const signedVerifiableCredential = await issuerInstance.issueCredential({
credential: unsignedVerifiableCredential
})
return signedCredential
return signedVerifiableCredential
}

const addIssuerId = (vc, issuerId) => {
if (vc.issuer && typeof vc.issuer === 'string') {
vc.issuer = issuerId
} else {
;(vc.issuer ??= {}).id = issuerId
}
}

const buildIssuerInstance = async (seed, method, url) => {
Expand Down

0 comments on commit df74001

Please sign in to comment.