Skip to content
This repository has been archived by the owner on Aug 26, 2024. It is now read-only.

Commit

Permalink
Expose an API endpoint to access the issuer and get a VC (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-tbd authored Jun 17, 2024
1 parent 268bf17 commit 3f294e7
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ import {
import { HttpServerShutdownHandler } from './http-shutdown-handler.js'
import { TbdexHttpServer } from '@tbdex/http-server'
import { DidDht } from '@web5/dids'

import { BearerDid } from '@web5/dids'
import { createOrLoadDid } from './example/utils.js'
import { VerifiableCredential } from '@web5/credentials'

await Postgres.connect()

Expand Down Expand Up @@ -74,7 +76,22 @@ httpApi.onSubmitClose(async (ctx, close) => {
await ExchangeRepository.addMessage({ message: close as Close })
})

httpApi.api.post('/get-vc', async function(req, res) {

This comment has been minimized.

Copy link
@michaelneale

michaelneale Jun 21, 2024

Contributor
const issuer : BearerDid = await createOrLoadDid('issuer.json')

// Create a sanctions credential so that the PFI knows that Alice is legit.
const vc = await VerifiableCredential.create({
type : 'SanctionCredential',
issuer : issuer.uri,
subject : req.body.did,
data : {
'beep': 'boop'
}
})

const vcJwt = await vc.sign({ did: issuer})
res.send(vcJwt)
})

const server = httpApi.listen(config.port, () => {
log.info(`Mock PFI listening on port ${config.port}`)
Expand Down

0 comments on commit 3f294e7

Please sign in to comment.