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: add mediation with public did example #151

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
108 changes: 108 additions & 0 deletions examples/mediation-public-did/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
version: "3"
services:
alice:
#image: ghcr.io/hyperledger/aries-cloudagent-python:py3.9-0.12.1
image: acapy-test
ports:
- "3001:3001"
environment:
RUST_LOG: warn
command: >
start
--label Alice
--inbound-transport http 0.0.0.0 3000
--outbound-transport http
--endpoint http://alice:3000
--admin 0.0.0.0 3001
--admin-insecure-mode
--wallet-type askar
--wallet-name alice
--wallet-key insecure
--auto-provision
--log-level debug
--debug-webhooks
--genesis-url https://raw.githubusercontent.com/Indicio-tech/indicio-network/main/genesis_files/pool_transactions_testnet_genesis
healthcheck:
test: curl -s -o /dev/null -w '%{http_code}' "http://localhost:3001/status/live" | grep "200" > /dev/null
start_period: 30s
interval: 7s
timeout: 5s
retries: 5

bob:
image: ghcr.io/hyperledger/aries-cloudagent-python:py3.9-0.12.1
ports:
- "3002:3001"
environment:
RUST_LOG: warn
command: >
start
--label Bob
--inbound-transport http 0.0.0.0 3000
--outbound-transport http
--endpoint http://bob:3000
--admin 0.0.0.0 3001
--admin-insecure-mode
--no-ledger
--wallet-type askar
--wallet-name bob
--wallet-key insecure
--auto-provision
--log-level debug
--debug-webhooks
--monitor-revocation-notification
healthcheck:
test: curl -s -o /dev/null -w '%{http_code}' "http://localhost:3001/status/live" | grep "200" > /dev/null
start_period: 30s
interval: 7s
timeout: 5s
retries: 5

mediator:
image: ghcr.io/hyperledger/aries-cloudagent-python:py3.9-0.12.1
ports:
- "3003:3001"
environment:
RUST_LOG: warn
command: >
start
--label Mediator
--inbound-transport http 0.0.0.0 3000
--outbound-transport http
--endpoint http://mediator:3000
--admin 0.0.0.0 3001
--admin-insecure-mode
--no-ledger
--wallet-type askar
--wallet-name mediator
--wallet-key insecure
--auto-provision
--log-level debug
--debug-webhooks
--enable-undelivered-queue
healthcheck:
test: curl -s -o /dev/null -w '%{http_code}' "http://localhost:3001/status/live" | grep "200" > /dev/null
start_period: 30s
interval: 7s
timeout: 5s
retries: 5

example:
container_name: controller
build:
context: ../..
environment:
- ALICE=http://alice:3001
- BOB=http://bob:3001
- MEDIATOR=http://mediator:3001
volumes:
- ../../acapy_controller:/usr/src/app/acapy_controller:z
- ./example.py:/usr/src/app/example.py:ro,z
command: python -m example
depends_on:
alice:
condition: service_healthy
bob:
condition: service_healthy
mediator:
condition: service_healthy
57 changes: 57 additions & 0 deletions examples/mediation-public-did/example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
"""Minimal reproducible example script.

This script is for you to use to reproduce a bug or demonstrate a feature.
"""

import asyncio
from os import getenv

from acapy_controller import Controller
from acapy_controller.logging import logging_to_stdout
from acapy_controller.protocols import (
connection,
didexchange,
indy_anoncred_onboard,
request_mediation_v1,
trustping,
)

ALICE = getenv("ALICE", "http://alice:3001")
BOB = getenv("BOB", "http://bob:3001")
MEDIATOR = getenv("MEDIATOR", "http://mediator:3001")


async def main():
"""Test Controller protocols."""
alice = Controller(base_url=ALICE)
bob = Controller(base_url=BOB)
mediator = Controller(base_url=MEDIATOR)

async with alice, bob, mediator:
public_did = await indy_anoncred_onboard(alice)
# await alice.get(f"/resolver/resolve/did:sov:{public_did.did}")
ma, am = await didexchange(mediator, alice)
mam, amm = await request_mediation_v1(
mediator, alice, ma.connection_id, am.connection_id
)
await alice.put(f"/mediation/{amm.mediation_id}/default-mediator")
await alice.post(
"/wallet/set-did-endpoint",
json={
"did": public_did.did,
"mediation_id": amm.mediation_id,
},
)
await alice.get(f"/resolver/resolve/did:sov:{public_did.did}")
return

ab, ba = await didexchange(alice, bob)
await trustping(alice, ab)

ab, ba = await connection(alice, bob)
await trustping(alice, ab)


if __name__ == "__main__":
logging_to_stdout()
asyncio.run(main())
Loading