Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(rest): add docker and postgres sample #265

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@
"eslint-plugin-prettier": "^5.1.3",
"jest": "^29.7.0",
"prettier": "^3.2.5",
"rimraf": "^5.0.5",
"ts-jest": "^29.1.2",
"ts-node": "^10.9.2",
"tsconfig-paths": "^4.2.0",
"typescript": "~5.3.3",
"rimraf": "^5.0.5"
"typescript": "~5.3.3"
},
"engines": {
"node": ">= 18"
Expand Down
2 changes: 1 addition & 1 deletion packages/push-notifications/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"test": "jest"
},
"devDependencies": {
"@hyperledger/aries-askar-nodejs": "^0.2.0",
"@hyperledger/aries-askar-nodejs": "^0.2.1",
"@credo-ts/askar": "^0.5.0",
"@credo-ts/core": "^0.5.0",
"@credo-ts/node": "^0.5.0",
Expand Down
22 changes: 11 additions & 11 deletions packages/rest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,17 @@
"test": "jest"
},
"dependencies": {
"@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",
"@credo-ts/anoncreds": "^0.5.3",
"@credo-ts/askar": "^0.5.3",
"@credo-ts/cheqd": "^0.5.3",
"@credo-ts/core": "^0.5.3",
"@credo-ts/indy-vdr": "^0.5.3",
"@credo-ts/node": "^0.5.3",
"@credo-ts/openid4vc": "^0.5.3",
"@credo-ts/tenants": "^0.5.3",
"@hyperledger/anoncreds-nodejs": "^0.2.2",
"@hyperledger/aries-askar-nodejs": "^0.2.1",
"@hyperledger/indy-vdr-nodejs": "^0.2.2",
"@types/ref-array-di": "^1.2.8",
"@types/ws": "^7.4.7",
"body-parser": "^1.20.0",
Expand Down
8 changes: 3 additions & 5 deletions packages/rest/samples/cliConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
],
"cheqdLedger": [
{
"network": "mainnet",
"cosmosPayerSeed": "bird cage swing"
"network": "mainnet"
},
{
"network": "testnet"
Expand All @@ -33,17 +32,16 @@
"inboundTransport": [
{
"transport": "http",
"port": 5000
"port": 6000
},
{
"transport": "ws",
"port": 5001
"port": 6001
}
],
"outboundTransport": ["http", "ws"],
"autoAcceptMediationRequests": false,
"connectionImageUrl": "https://image.com/image.png",
"webhookUrl": "https://my-webhook-server",
"adminPort": 3000,
"multiTenant": true
}
47 changes: 47 additions & 0 deletions packages/rest/samples/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
version: '3.8'

volumes:
postgres:

services:
credo:
image: ghcr.io/openwallet-foundation/credo-rest:0.10.0
depends_on:
- postgres
ports:
# Admin API
- 3000:3000

# DIDComm
- 6000:6000
- 6001:6001

# Use the local config file in the container
volumes:
- ./cliConfig.json:/cliConfig.json
command: ['--config', '/cliConfig.json']

# This dynamically loads the wallet id, wallet key and agent endpoint (so you can use ngrok)
# you also want to dynamically inject postgres connection details in prod
env_file:
- path: docker.env.local
required: true

environment:
# Configure credo to use postgres as storage
CREDO_REST_POSTGRES_HOST: postgres:5432
CREDO_REST_POSTGRES_USERNAME: postgres
CREDO_REST_POSTGRES_PASSWORD: postgres
CREDO_REST_STORAGE_TYPE: postgres

# Postgres (when deploying you probably want to use a managed service for this)
postgres:
image: postgres:15-alpine
ports:
- '5432:5432'
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DATABASE: postgres
volumes:
- postgres:/var/lib/postgresql/data
11 changes: 11 additions & 0 deletions packages/rest/samples/docker.env.local
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
CREDO_REST_WALLET_ID=your_wallet_id
CREDO_REST_WALLET_KEY=your_wallet_key

# You can use ngrok (ngrok http 3001) to expose your local server to the internet
# and interact with Paradym and other agents.
# CREDO_REST_ENDPOINT=https://d297-217-123-18-26.ngrok-free.app
CREDO_REST_ENDPOINT=http://localhost:6001

# You can configure credo to send webhooks to your server
# Or, during development e.g. use https://rbaskets.in/web
# CREDO_REST_WEBHOOK_URL=https://webhook.site/fbcd1feb-da81-447b-8888-e34cad509143
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ describe('OpenId4VcVerificationSessionsController', () => {
),
},
authorizationRequest: expect.stringContaining(
`openid://?request_uri=${encodeURIComponent(`http://localhost:4848/siop/publicVerifierId/authorization-requests/`)}`,
`openid4vp://?request_uri=${encodeURIComponent(`http://localhost:4848/siop/publicVerifierId/authorization-requests/`)}`,
),
})

Expand Down
1 change: 1 addition & 0 deletions packages/rest/src/utils/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ export function getAgentModules(options: {

if (firstCredential.format === 'vc+sd-jwt') {
return {
credentialSupportedId: firstCredential.credentialSupportedId,
format: 'vc+sd-jwt',
issuer: firstCredential.issuer,
holder: holderBinding,
Expand Down
Loading
Loading