Skip to content

Commit

Permalink
feat(rest)!: openid4vc (#260)
Browse files Browse the repository at this point in the history
Signed-off-by: Timo Glastra <timo@animo.id>
  • Loading branch information
TimoGlastra authored Mar 30, 2024
1 parent 3849aec commit e3e4026
Show file tree
Hide file tree
Showing 79 changed files with 16,966 additions and 6,983 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/continuous-deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ on:
branches:
- main
workflow_dispatch:
inputs:
tag:
description: 'Tag to give to the docker image'
required: true

env:
IMAGE_NAME: ghcr.io/openwallet-foundation/credo-rest
Expand All @@ -33,6 +37,11 @@ jobs:
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: ${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=tag,enable=${GITHUB_REF#refs/tags/rest-v*}
type=raw,value=${GITHUB_REF#refs/tags/rest-v},enable=${GITHUB_REF#refs/tags/rest-v*}
type=raw,value=${{ inputs.tag }},enable=${{ github.event_name == 'workflow_dispatch' }}
- name: Build and push Docker image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
Expand Down
5 changes: 3 additions & 2 deletions packages/rest/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@
</p>
<br />

The Credo REST API is the most convenient way for self-sovereign identity (SSI) developers to interact with SSI agents.
The Credo REST API is the most convenient way to get started with Credo in the cloud.

-**Endpoints** to create connections, issue credentials, and request proofs.
-**Endpoints** to work with both DIDComm and OpenID4VC.
- 💻 **CLI** that makes it super easy to start an instance of the REST API.
- 🌐 **Interoperable** with all major Aries implementations.
- 🧑 **Multi-tenant** Use the same agent and server for as many tenants as you want. Each tenant has its own separate encrypted storage.

### Quick start

Expand Down
19 changes: 1 addition & 18 deletions packages/rest/bin/credo-rest.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,4 @@
#!/usr/bin/env node
/* eslint-disable @typescript-eslint/no-var-requires, no-undef */

var process = require('process')

const { runCliServer } = require('../build/cli')
let shutdownAgent

process.on('SIGINT', async () => {
try {
if (shutdownAgent) {
await shutdownAgent()
}
} finally {
process.exit(0)
}
})

runCliServer().then(({ shutdown }) => {
shutdownAgent = shutdown
})
require('../build/cli')
18 changes: 12 additions & 6 deletions packages/rest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,25 @@
"scripts": {
"tsoa": "tsoa spec-and-routes",
"dev": "yarn tsoa && tsnd --respawn samples/sampleWithApp.ts",
"sample": "yarn tsoa && tsnd --respawn samples/sample.ts",
"sample:with-app": "yarn tsoa && tsnd --respawn samples/sampleWithApp.ts",
"sample:cli-config": "yarn tsoa && tsnd --respawn src/cli.ts --config ./samples/cliConfig.json",
"sample:cli": "yarn tsoa && sh samples/sampleCli.sh",
"build": "yarn run clean && yarn run compile",
"clean": "rimraf -rf ./build",
"compile": "yarn tsoa && tsc -p tsconfig.build.json",
"prepublishOnly": "yarn run build",
"test": "jest"
},
"dependencies": {
"@credo-ts/anoncreds": "^0.5.0",
"@credo-ts/askar": "^0.5.0",
"@credo-ts/core": "^0.5.0",
"@credo-ts/indy-vdr": "^0.5.0",
"@credo-ts/node": "^0.5.0",
"@credo-ts/tenants": "^0.5.0",
"@credo-ts/anoncreds": "^0.5.1",
"@credo-ts/askar": "^0.5.1",
"@credo-ts/cheqd": "^0.5.1",
"@credo-ts/core": "^0.5.1",
"@credo-ts/indy-vdr": "^0.5.1",
"@credo-ts/node": "^0.5.1",
"@credo-ts/openid4vc": "^0.5.1",
"@credo-ts/tenants": "^0.5.1",
"@hyperledger/anoncreds-nodejs": "^0.2.1",
"@hyperledger/aries-askar-nodejs": "^0.2.0",
"@hyperledger/indy-vdr-nodejs": "^0.2.0",
Expand Down
20 changes: 17 additions & 3 deletions packages/rest/samples/cliConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,23 @@
"walletKey": "walletKey",
"indyLedger": [
{
"genesisTransactions": "{\"genesisTransactions\":\"{\"reqSignature\":{},\"txn\":{\"data\":{\"data\":{\"alias\":\"Node1\",\"blskey\":\"4N8aUNHSgjQVgkpm8nhNEfDf6txHznoYREg9kirmJrkivgL4oSEimFF6nsQ6M41QvhM2Z33nves5vfSn9n1UwNFJBYtWVnHYMATn76vLuL3zU88KyeAYcHfsih3He6UHcXDxcaecHVz6jhCYz1P2UZn2bDVruL5wXpehgBfBaLKm3Ba\",\"blskey_pop\":\"RahHYiCvoNCtPTrVtP7nMC5eTYrsUA8WjXbdhNc8debh1agE9bGiJxWBXYNFbnJXoXhWFMvyqhqhRoq737YQemH5ik9oL7R4NTTCz2LEZhkgLJzB3QRQqJyBNyv7acbdHrAT8nQ9UkLbaVL9NBpnWXBTw4LEMePaSHEw66RzPNdAX1\",\"client_ip\":\"138.197.138.255\",\"client_port\":9702,\"node_ip\":\"138.197.138.255\",\"node_port\":9701,\"services\":[\"VALIDATOR\"]},\"dest\":\"Gw6pDLhcBcoQesN72qfotTgFa7cbuqZpkX3Xo6pLhPhv\"},\"metadata\":{\"from\":\"Th7MpTaRZVRYnPiabds81Y\"},\"type\":\"0\"},\"txnMetadata\":{\"seqNo\":1,\"txnId\":\"fea82e10e894419fe2bea7d96296a6d46f50f93f9eeda954ec461b2ed2950b62\"},\"ver\":\"1\"}\n{\"reqSignature\":{},\"txn\":{\"data\":{\"data\":{\"alias\":\"Node2\",\"blskey\":\"37rAPpXVoxzKhz7d9gkUe52XuXryuLXoM6P6LbWDB7LSbG62Lsb33sfG7zqS8TK1MXwuCHj1FKNzVpsnafmqLG1vXN88rt38mNFs9TENzm4QHdBzsvCuoBnPH7rpYYDo9DZNJePaDvRvqJKByCabubJz3XXKbEeshzpz4Ma5QYpJqjk\",\"blskey_pop\":\"Qr658mWZ2YC8JXGXwMDQTzuZCWF7NK9EwxphGmcBvCh6ybUuLxbG65nsX4JvD4SPNtkJ2w9ug1yLTj6fgmuDg41TgECXjLCij3RMsV8CwewBVgVN67wsA45DFWvqvLtu4rjNnE9JbdFTc1Z4WCPA3Xan44K1HoHAq9EVeaRYs8zoF5\",\"client_ip\":\"138.197.138.255\",\"client_port\":9704,\"node_ip\":\"138.197.138.255\",\"node_port\":9703,\"services\":[\"VALIDATOR\"]},\"dest\":\"8ECVSk179mjsjKRLWiQtssMLgp6EPhWXtaYyStWPSGAb\"},\"metadata\":{\"from\":\"EbP4aYNeTHL6q385GuVpRV\"},\"type\":\"0\"},\"txnMetadata\":{\"seqNo\":2,\"txnId\":\"1ac8aece2a18ced660fef8694b61aac3af08ba875ce3026a160acbc3a3af35fc\"},\"ver\":\"1\"}\n{\"reqSignature\":{},\"txn\":{\"data\":{\"data\":{\"alias\":\"Node3\",\"blskey\":\"3WFpdbg7C5cnLYZwFZevJqhubkFALBfCBBok15GdrKMUhUjGsk3jV6QKj6MZgEubF7oqCafxNdkm7eswgA4sdKTRc82tLGzZBd6vNqU8dupzup6uYUf32KTHTPQbuUM8Yk4QFXjEf2Usu2TJcNkdgpyeUSX42u5LqdDDpNSWUK5deC5\",\"blskey_pop\":\"QwDeb2CkNSx6r8QC8vGQK3GRv7Yndn84TGNijX8YXHPiagXajyfTjoR87rXUu4G4QLk2cF8NNyqWiYMus1623dELWwx57rLCFqGh7N4ZRbGDRP4fnVcaKg1BcUxQ866Ven4gw8y4N56S5HzxXNBZtLYmhGHvDtk6PFkFwCvxYrNYjh\",\"client_ip\":\"138.197.138.255\",\"client_port\":9706,\"node_ip\":\"138.197.138.255\",\"node_port\":9705,\"services\":[\"VALIDATOR\"]},\"dest\":\"DKVxG2fXXTU8yT5N7hGEbXB3dfdAnYv1JczDUHpmDxya\"},\"metadata\":{\"from\":\"4cU41vWW82ArfxJxHkzXPG\"},\"type\":\"0\"},\"txnMetadata\":{\"seqNo\":3,\"txnId\":\"7e9f355dffa78ed24668f0e0e369fd8c224076571c51e2ea8be5f26479edebe4\"},\"ver\":\"1\"}\n{\"reqSignature\":{},\"txn\":{\"data\":{\"data\":{\"alias\":\"Node4\",\"blskey\":\"2zN3bHM1m4rLz54MJHYSwvqzPchYp8jkHswveCLAEJVcX6Mm1wHQD1SkPYMzUDTZvWvhuE6VNAkK3KxVeEmsanSmvjVkReDeBEMxeDaayjcZjFGPydyey1qxBHmTvAnBKoPydvuTAqx5f7YNNRAdeLmUi99gERUU7TD8KfAa6MpQ9bw\",\"blskey_pop\":\"RPLagxaR5xdimFzwmzYnz4ZhWtYQEj8iR5ZU53T2gitPCyCHQneUn2Huc4oeLd2B2HzkGnjAff4hWTJT6C7qHYB1Mv2wU5iHHGFWkhnTX9WsEAbunJCV2qcaXScKj4tTfvdDKfLiVuU2av6hbsMztirRze7LvYBkRHV3tGwyCptsrP\",\"client_ip\":\"138.197.138.255\",\"client_port\":9708,\"node_ip\":\"138.197.138.255\",\"node_port\":9707,\"services\":[\"VALIDATOR\"]},\"dest\":\"4PS3EDQ3dW1tci1Bp6543CfuuebjFrg36kLAUcskGfaA\"},\"metadata\":{\"from\":\"TWwCRQRZ2ZHMJFn9TzLp7W\"},\"type\":\"0\"},\"txnMetadata\":{\"seqNo\":4,\"txnId\":\"aa5e817d7cc626170eca175822029339a444eb0ee8f0bd20d3b0b76e566fb008\"},\"ver\":\"1\"}\"}",
"id": "BCovrin Test Network",
"isProduction": false
"genesisTransactions": "{\"reqSignature\":{},\"txn\":{\"data\":{\"data\":{\"alias\":\"Node1\",\"blskey\":\"4N8aUNHSgjQVgkpm8nhNEfDf6txHznoYREg9kirmJrkivgL4oSEimFF6nsQ6M41QvhM2Z33nves5vfSn9n1UwNFJBYtWVnHYMATn76vLuL3zU88KyeAYcHfsih3He6UHcXDxcaecHVz6jhCYz1P2UZn2bDVruL5wXpehgBfBaLKm3Ba\",\"blskey_pop\":\"RahHYiCvoNCtPTrVtP7nMC5eTYrsUA8WjXbdhNc8debh1agE9bGiJxWBXYNFbnJXoXhWFMvyqhqhRoq737YQemH5ik9oL7R4NTTCz2LEZhkgLJzB3QRQqJyBNyv7acbdHrAT8nQ9UkLbaVL9NBpnWXBTw4LEMePaSHEw66RzPNdAX1\",\"client_ip\":\"138.197.138.255\",\"client_port\":9702,\"node_ip\":\"138.197.138.255\",\"node_port\":9701,\"services\":[\"VALIDATOR\"]},\"dest\":\"Gw6pDLhcBcoQesN72qfotTgFa7cbuqZpkX3Xo6pLhPhv\"},\"metadata\":{\"from\":\"Th7MpTaRZVRYnPiabds81Y\"},\"type\":\"0\"},\"txnMetadata\":{\"seqNo\":1,\"txnId\":\"fea82e10e894419fe2bea7d96296a6d46f50f93f9eeda954ec461b2ed2950b62\"},\"ver\":\"1\"}{\"reqSignature\":{},\"txn\":{\"data\":{\"data\":{\"alias\":\"Node2\",\"blskey\":\"37rAPpXVoxzKhz7d9gkUe52XuXryuLXoM6P6LbWDB7LSbG62Lsb33sfG7zqS8TK1MXwuCHj1FKNzVpsnafmqLG1vXN88rt38mNFs9TENzm4QHdBzsvCuoBnPH7rpYYDo9DZNJePaDvRvqJKByCabubJz3XXKbEeshzpz4Ma5QYpJqjk\",\"blskey_pop\":\"Qr658mWZ2YC8JXGXwMDQTzuZCWF7NK9EwxphGmcBvCh6ybUuLxbG65nsX4JvD4SPNtkJ2w9ug1yLTj6fgmuDg41TgECXjLCij3RMsV8CwewBVgVN67wsA45DFWvqvLtu4rjNnE9JbdFTc1Z4WCPA3Xan44K1HoHAq9EVeaRYs8zoF5\",\"client_ip\":\"138.197.138.255\",\"client_port\":9704,\"node_ip\":\"138.197.138.255\",\"node_port\":9703,\"services\":[\"VALIDATOR\"]},\"dest\":\"8ECVSk179mjsjKRLWiQtssMLgp6EPhWXtaYyStWPSGAb\"},\"metadata\":{\"from\":\"EbP4aYNeTHL6q385GuVpRV\"},\"type\":\"0\"},\"txnMetadata\":{\"seqNo\":2,\"txnId\":\"1ac8aece2a18ced660fef8694b61aac3af08ba875ce3026a160acbc3a3af35fc\"},\"ver\":\"1\"}{\"reqSignature\":{},\"txn\":{\"data\":{\"data\":{\"alias\":\"Node3\",\"blskey\":\"3WFpdbg7C5cnLYZwFZevJqhubkFALBfCBBok15GdrKMUhUjGsk3jV6QKj6MZgEubF7oqCafxNdkm7eswgA4sdKTRc82tLGzZBd6vNqU8dupzup6uYUf32KTHTPQbuUM8Yk4QFXjEf2Usu2TJcNkdgpyeUSX42u5LqdDDpNSWUK5deC5\",\"blskey_pop\":\"QwDeb2CkNSx6r8QC8vGQK3GRv7Yndn84TGNijX8YXHPiagXajyfTjoR87rXUu4G4QLk2cF8NNyqWiYMus1623dELWwx57rLCFqGh7N4ZRbGDRP4fnVcaKg1BcUxQ866Ven4gw8y4N56S5HzxXNBZtLYmhGHvDtk6PFkFwCvxYrNYjh\",\"client_ip\":\"138.197.138.255\",\"client_port\":9706,\"node_ip\":\"138.197.138.255\",\"node_port\":9705,\"services\":[\"VALIDATOR\"]},\"dest\":\"DKVxG2fXXTU8yT5N7hGEbXB3dfdAnYv1JczDUHpmDxya\"},\"metadata\":{\"from\":\"4cU41vWW82ArfxJxHkzXPG\"},\"type\":\"0\"},\"txnMetadata\":{\"seqNo\":3,\"txnId\":\"7e9f355dffa78ed24668f0e0e369fd8c224076571c51e2ea8be5f26479edebe4\"},\"ver\":\"1\"}{\"reqSignature\":{},\"txn\":{\"data\":{\"data\":{\"alias\":\"Node4\",\"blskey\":\"2zN3bHM1m4rLz54MJHYSwvqzPchYp8jkHswveCLAEJVcX6Mm1wHQD1SkPYMzUDTZvWvhuE6VNAkK3KxVeEmsanSmvjVkReDeBEMxeDaayjcZjFGPydyey1qxBHmTvAnBKoPydvuTAqx5f7YNNRAdeLmUi99gERUU7TD8KfAa6MpQ9bw\",\"blskey_pop\":\"RPLagxaR5xdimFzwmzYnz4ZhWtYQEj8iR5ZU53T2gitPCyCHQneUn2Huc4oeLd2B2HzkGnjAff4hWTJT6C7qHYB1Mv2wU5iHHGFWkhnTX9WsEAbunJCV2qcaXScKj4tTfvdDKfLiVuU2av6hbsMztirRze7LvYBkRHV3tGwyCptsrP\",\"client_ip\":\"138.197.138.255\",\"client_port\":9708,\"node_ip\":\"138.197.138.255\",\"node_port\":9707,\"services\":[\"VALIDATOR\"]},\"dest\":\"4PS3EDQ3dW1tci1Bp6543CfuuebjFrg36kLAUcskGfaA\"},\"metadata\":{\"from\":\"TWwCRQRZ2ZHMJFn9TzLp7W\"},\"type\":\"0\"},\"txnMetadata\":{\"seqNo\":4,\"txnId\":\"aa5e817d7cc626170eca175822029339a444eb0ee8f0bd20d3b0b76e566fb008\"},\"ver\":\"1\"}",
"indyNamespace": "bcovrin:test",
"isProduction": false,
"connectOnStartup": true,
"transactionAuthorAgreement": {
"version": "1.0",
"acceptanceMechanism": "service_agreement"
}
}
],
"cheqdLedger": [
{
"network": "mainnet",
"cosmosPayerSeed": "bird cage swing"
},
{
"network": "testnet"
}
],
"endpoint": ["http://localhost:5000", "ws://localhost:5001"],
Expand Down
37 changes: 24 additions & 13 deletions packages/rest/samples/sample.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,32 @@
import type { ServerConfig } from '../src/utils/ServerConfig'
import type { CredoRestAgentConfig } from '../src'

import { startServer } from '../src/index'
import { setupAgent } from '../src/utils/agent'
import { LogLevel } from '@credo-ts/core'

import { setupApp } from '../src'

const run = async () => {
const agent = await setupAgent({
httpInboundTransportPort: 3001,
endpoints: ['http://localhost:3001'],
name: 'Aries Test Agent',
})
const { start } = await setupApp({
adminPort: 3000,
enableCors: true,

const conf: ServerConfig = {
port: 3000,
cors: true,
}
agent: {
label: 'Aries Test Agent',
inboundTransports: [
{
transport: 'http',
port: 3001,
},
],
logLevel: LogLevel.debug,
endpoints: ['http://localhost:3001'],
walletConfig: {
id: 'test-agent',
key: 'test-agent',
},
} satisfies CredoRestAgentConfig,
})

await startServer(agent, conf)
start()
}

run()
13 changes: 13 additions & 0 deletions packages/rest/samples/sampleCli.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
tsnd --respawn src/cli.ts \
--label "Sample CLI" \
--wallet-id "sampleWallet" \
--wallet-key "sampleWalletKey" \
--admin-port 3000 \
--inbound-transport http 5000 \
--inbound-transport ws 5001 \
--outbound-transport http \
--outbound-transport ws \
--endpoint http://localhost:3000 \
--multi-tenant \
--indy-ledger "{\"genesisTransactions\":\"{\\\"reqSignature\\\":{},\\\"txn\\\":{\\\"data\\\":{\\\"data\\\":{\\\"alias\\\":\\\"Node1\\\",\\\"blskey\\\":\\\"4N8aUNHSgjQVgkpm8nhNEfDf6txHznoYREg9kirmJrkivgL4oSEimFF6nsQ6M41QvhM2Z33nves5vfSn9n1UwNFJBYtWVnHYMATn76vLuL3zU88KyeAYcHfsih3He6UHcXDxcaecHVz6jhCYz1P2UZn2bDVruL5wXpehgBfBaLKm3Ba\\\",\\\"blskey_pop\\\":\\\"RahHYiCvoNCtPTrVtP7nMC5eTYrsUA8WjXbdhNc8debh1agE9bGiJxWBXYNFbnJXoXhWFMvyqhqhRoq737YQemH5ik9oL7R4NTTCz2LEZhkgLJzB3QRQqJyBNyv7acbdHrAT8nQ9UkLbaVL9NBpnWXBTw4LEMePaSHEw66RzPNdAX1\\\",\\\"client_ip\\\":\\\"138.197.138.255\\\",\\\"client_port\\\":9702,\\\"node_ip\\\":\\\"138.197.138.255\\\",\\\"node_port\\\":9701,\\\"services\\\":[\\\"VALIDATOR\\\"]},\\\"dest\\\":\\\"Gw6pDLhcBcoQesN72qfotTgFa7cbuqZpkX3Xo6pLhPhv\\\"},\\\"metadata\\\":{\\\"from\\\":\\\"Th7MpTaRZVRYnPiabds81Y\\\"},\\\"type\\\":\\\"0\\\"},\\\"txnMetadata\\\":{\\\"seqNo\\\":1,\\\"txnId\\\":\\\"fea82e10e894419fe2bea7d96296a6d46f50f93f9eeda954ec461b2ed2950b62\\\"},\\\"ver\\\":\\\"1\\\"}{\\\"reqSignature\\\":{},\\\"txn\\\":{\\\"data\\\":{\\\"data\\\":{\\\"alias\\\":\\\"Node2\\\",\\\"blskey\\\":\\\"37rAPpXVoxzKhz7d9gkUe52XuXryuLXoM6P6LbWDB7LSbG62Lsb33sfG7zqS8TK1MXwuCHj1FKNzVpsnafmqLG1vXN88rt38mNFs9TENzm4QHdBzsvCuoBnPH7rpYYDo9DZNJePaDvRvqJKByCabubJz3XXKbEeshzpz4Ma5QYpJqjk\\\",\\\"blskey_pop\\\":\\\"Qr658mWZ2YC8JXGXwMDQTzuZCWF7NK9EwxphGmcBvCh6ybUuLxbG65nsX4JvD4SPNtkJ2w9ug1yLTj6fgmuDg41TgECXjLCij3RMsV8CwewBVgVN67wsA45DFWvqvLtu4rjNnE9JbdFTc1Z4WCPA3Xan44K1HoHAq9EVeaRYs8zoF5\\\",\\\"client_ip\\\":\\\"138.197.138.255\\\",\\\"client_port\\\":9704,\\\"node_ip\\\":\\\"138.197.138.255\\\",\\\"node_port\\\":9703,\\\"services\\\":[\\\"VALIDATOR\\\"]},\\\"dest\\\":\\\"8ECVSk179mjsjKRLWiQtssMLgp6EPhWXtaYyStWPSGAb\\\"},\\\"metadata\\\":{\\\"from\\\":\\\"EbP4aYNeTHL6q385GuVpRV\\\"},\\\"type\\\":\\\"0\\\"},\\\"txnMetadata\\\":{\\\"seqNo\\\":2,\\\"txnId\\\":\\\"1ac8aece2a18ced660fef8694b61aac3af08ba875ce3026a160acbc3a3af35fc\\\"},\\\"ver\\\":\\\"1\\\"}{\\\"reqSignature\\\":{},\\\"txn\\\":{\\\"data\\\":{\\\"data\\\":{\\\"alias\\\":\\\"Node3\\\",\\\"blskey\\\":\\\"3WFpdbg7C5cnLYZwFZevJqhubkFALBfCBBok15GdrKMUhUjGsk3jV6QKj6MZgEubF7oqCafxNdkm7eswgA4sdKTRc82tLGzZBd6vNqU8dupzup6uYUf32KTHTPQbuUM8Yk4QFXjEf2Usu2TJcNkdgpyeUSX42u5LqdDDpNSWUK5deC5\\\",\\\"blskey_pop\\\":\\\"QwDeb2CkNSx6r8QC8vGQK3GRv7Yndn84TGNijX8YXHPiagXajyfTjoR87rXUu4G4QLk2cF8NNyqWiYMus1623dELWwx57rLCFqGh7N4ZRbGDRP4fnVcaKg1BcUxQ866Ven4gw8y4N56S5HzxXNBZtLYmhGHvDtk6PFkFwCvxYrNYjh\\\",\\\"client_ip\\\":\\\"138.197.138.255\\\",\\\"client_port\\\":9706,\\\"node_ip\\\":\\\"138.197.138.255\\\",\\\"node_port\\\":9705,\\\"services\\\":[\\\"VALIDATOR\\\"]},\\\"dest\\\":\\\"DKVxG2fXXTU8yT5N7hGEbXB3dfdAnYv1JczDUHpmDxya\\\"},\\\"metadata\\\":{\\\"from\\\":\\\"4cU41vWW82ArfxJxHkzXPG\\\"},\\\"type\\\":\\\"0\\\"},\\\"txnMetadata\\\":{\\\"seqNo\\\":3,\\\"txnId\\\":\\\"7e9f355dffa78ed24668f0e0e369fd8c224076571c51e2ea8be5f26479edebe4\\\"},\\\"ver\\\":\\\"1\\\"}{\\\"reqSignature\\\":{},\\\"txn\\\":{\\\"data\\\":{\\\"data\\\":{\\\"alias\\\":\\\"Node4\\\",\\\"blskey\\\":\\\"2zN3bHM1m4rLz54MJHYSwvqzPchYp8jkHswveCLAEJVcX6Mm1wHQD1SkPYMzUDTZvWvhuE6VNAkK3KxVeEmsanSmvjVkReDeBEMxeDaayjcZjFGPydyey1qxBHmTvAnBKoPydvuTAqx5f7YNNRAdeLmUi99gERUU7TD8KfAa6MpQ9bw\\\",\\\"blskey_pop\\\":\\\"RPLagxaR5xdimFzwmzYnz4ZhWtYQEj8iR5ZU53T2gitPCyCHQneUn2Huc4oeLd2B2HzkGnjAff4hWTJT6C7qHYB1Mv2wU5iHHGFWkhnTX9WsEAbunJCV2qcaXScKj4tTfvdDKfLiVuU2av6hbsMztirRze7LvYBkRHV3tGwyCptsrP\\\",\\\"client_ip\\\":\\\"138.197.138.255\\\",\\\"client_port\\\":9708,\\\"node_ip\\\":\\\"138.197.138.255\\\",\\\"node_port\\\":9707,\\\"services\\\":[\\\"VALIDATOR\\\"]},\\\"dest\\\":\\\"4PS3EDQ3dW1tci1Bp6543CfuuebjFrg36kLAUcskGfaA\\\"},\\\"metadata\\\":{\\\"from\\\":\\\"TWwCRQRZ2ZHMJFn9TzLp7W\\\"},\\\"type\\\":\\\"0\\\"},\\\"txnMetadata\\\":{\\\"seqNo\\\":4,\\\"txnId\\\":\\\"aa5e817d7cc626170eca175822029339a444eb0ee8f0bd20d3b0b76e566fb008\\\"},\\\"ver\\\":\\\"1\\\"}\",\"indyNamespace\":\"bcovrin:test\",\"isProduction\":false,\"connectOnStartup\":true,\"transactionAuthorAgreement\":{\"version\":\"1.0\",\"acceptanceMechanism\":\"service_agreement\"}}" \
--cheqd-ledger "{\"network\":\"mainnet\",\"cosmosPayerSeed\":\"bird cage swing\"}"
42 changes: 25 additions & 17 deletions packages/rest/samples/sampleWithApp.ts
Original file line number Diff line number Diff line change
@@ -1,36 +1,44 @@
import type { ServerConfig } from '../src/utils/ServerConfig'

import { LogLevel } from '@credo-ts/core'
import bodyParser from 'body-parser'
import express from 'express'

import { startServer } from '../src/index'
import { setupAgent } from '../src/utils/agent'
import { createRestAgent, setupApp } from '../src/index'

const run = async () => {
const endpoint = process.env.AGENT_ENDPOINT ?? 'http://localhost:3001'

const agent = await setupAgent({
httpInboundTransportPort: 3001,
endpoints: [endpoint],
name: 'Aries Test Agent',
const agent = await createRestAgent({
label: 'Aries Test Agent',
inboundTransports: [
{
transport: 'http',
port: 3001,
},
],
logLevel: LogLevel.debug,
endpoints: ['http://localhost:3001'],
walletConfig: {
id: 'test-agent',
key: 'test-agent',
},
})

const app = express()
const jsonParser = bodyParser.json()

app.post('/greeting', jsonParser, (req, res) => {
app.get('/greeting', jsonParser, (_, res) => {
const config = agent.config

res.send(`Hello, ${config.label}!`)
})

const conf: ServerConfig = {
port: 3000,
webhookUrl: 'http://localhost:5000/agent-events',
app: app,
}
const { start } = await setupApp({
baseApp: app,
adminPort: 3000,
enableCors: true,

agent,
})

await startServer(agent, conf)
start()
}

run()
Loading

0 comments on commit e3e4026

Please sign in to comment.