diff --git a/.gitignore b/.gitignore index c4e5160..b2209d2 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,6 @@ build __pycache__/ .vscode/ -*/logs +logs/ -*/results +results/ diff --git a/playground/issuer/example.env b/playground/issuer/example.env deleted file mode 100644 index d478206..0000000 --- a/playground/issuer/example.env +++ /dev/null @@ -1,82 +0,0 @@ - -# These are dummy values that can be used to get started quickly -# Replace these with real values when deploying to a real environment - -# For postgres DB which hosts the wallets -WALLET_DB_HOST=alice-wallet-db -WALLET_DB_PORT=5432 -WALLET_DB_USER=postgres -WALLET_DB_PASS=dbpass -WALLET_DB_ADMIN_USER=postgres -WALLET_DB_ADMIN_PASS=dbpass - -# These values are only used locally by docker-compose to set up the DB container - should match values above -POSTGRES_PASSWORD=dbpass -POSTGRES_USER=postgres -POSTGRES_DB=alice_wallet - -# for tails server -# ACAPY_TAILS_SERVER_BASE_URL=http://tails-server:6543 - -# for aca-py -HTTP_PORT=3020 -WEBHOOK_PORT=3010 -ADMIN_PORT=3021 -ADMIN_URL=http://alice-agent:3021 -ACAPY_OUTBOUND_TRANSPORT=http -ACAPY_ADMIN=[0.0.0.0,3021] - -# Only used if run ./manage production -# Typically you will want to update 0.0.0.0 to some public IP -ACAPY_ENDPOINT=http://0.0.0.0:3020 - -ACAPY_WEBHOOK_URL=http://alice-business-logic:3010 -ACAPY_ADMIN_API_KEY=adminApiKey - -# DO NOT USE IN INSECURE MODE -# ACAPY_ADMIN_INSECURE_MODE=true - -ACAPY_LABEL=Alice -ACAPY_WALLET_NAME=Alice_Name -ACAPY_WALLET_KEY=alice_key -ACAPY_WALLET_TYPE=indy -ACAPY_WALLET_STORAGE_TYPE=postgres_storage -# ACAPY_WALLET_SEED=00000000000000000000000AliceAny1 -ACAPY_WALLET_STORAGE_CONFIG={"url":"alice-wallet-db:5432","wallet_scheme":"MultiWalletSingleTable"} -ACAPY_WALLET_STORAGE_CREDS={"account":"postgres","password":"dbpass","admin_account":"postgres","admin_password":"dbpass"} -ACAPY_WALLET_LOCAL_DID=true -ACAPY_LOG_LEVEL=info -ACAPY_AUTO_PROVISION=true - - -## Local Network -# ACAPY_GENESIS_FILE=/home/indy/von-local-genesis-txns - -# Sovrin StagingNet -ACAPY_GENESIS_URL=https://raw.githubusercontent.com/sovrin-foundation/sovrin/master/sovrin/pool_transactions_sandbox_genesis - - -# Multi-tenant Configuration -# ACAPY_MULTITENANT=true -# ACAPY_MULTITENANT_ADMIN=true -# ACAPY_MULTITENANT_JWT_SECRET=jwtSecret - - -# Name of ngrok container if exposing agent endpoint over ngrok -NGROK_NAME= ngrok-alice - - - -# Optional Helper Configurations - See https://github.com/hyperledger/aries-cloudagent-python/blob/main/aries_cloudagent/config/argparse.py -ACAPY_AUTO_ACCEPT_INVITES=true -ACAPY_AUTO_ACCEPT_REQUESTS=true -ACAPY_AUTO_PING_CONNECTION=true -ACAPY_AUTO_RESPOND_MESSAGES=true -ACAPY_AUTO_RESPOND_CREDENTIAL_PROPOSAL=false -ACAPY_AUTO_RESPOND_CREDENTIAL_OFFER=false -ACAPY_AUTO_RESPOND_CREDENTIAL_REQUEST=false -ACAPY_AUTO_RESPOND_PRESENTATION_PROPOSAL=false -ACAPY_AUTO_RESPOND_PRESENTATION_REQUEST=false -ACAPY_AUTO_STORE_CREDENTIAL=false -ACAPY_AUTO_VERIFY_PRESENTATION=false -ACAPY_PRESERVE_EXCHANGE_RECORDS=true \ No newline at end of file diff --git a/playground/issuer/notebooks/0. init_alice_as_issuer.ipynb b/playground/issuer/notebooks/0. init_alice_as_issuer.ipynb deleted file mode 100644 index f1f42c5..0000000 --- a/playground/issuer/notebooks/0. init_alice_as_issuer.ipynb +++ /dev/null @@ -1,389 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "id": "d1c11860", - "metadata": {}, - "source": [ - "# Initialising Your Agent as an Issuing Authority\n", - "\n", - "See \"./recipes/issue_credential/issuer_initialisation.ipynb\" for template\n", - "\n", - "The steps include:\n", - "\n", - "* Writing your DID to the Sovrin StagingNet\n", - "* Accepting the Transaction Author Agreement\n", - "* Authoring schema to the ledger\n", - "* Authoring credential definitions for the schema this agent intends to issue\n", - "* Persisting Identifiers for use throughout the playground.\n", - "\n", - "It is recommended that this initialisation notebook be run **once**. If you are following the default docker-compose services then your agents wallet storage will be persisted in a postgres database as long as you run `./manage stop` rather than `./manage down`. \n", - "\n" - ] - }, - { - "cell_type": "markdown", - "id": "582355a5", - "metadata": {}, - "source": [ - "### Imports" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "id": "627e41f8", - "metadata": {}, - "outputs": [], - "source": [ - "from aries_cloudcontroller import AriesAgentController\n", - "import os\n", - "from termcolor import colored" - ] - }, - { - "cell_type": "markdown", - "id": "de7f886b", - "metadata": {}, - "source": [ - "### Initialise the Agent Controller" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "0688b679", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Initialising a controller with admin api at http://alice-agent:3021 and an api key of alicesSecretApiKey\n" - ] - } - ], - "source": [ - "api_key = os.getenv(\"ACAPY_ADMIN_API_KEY\")\n", - "admin_url = os.getenv(\"ADMIN_URL\")\n", - "\n", - "print(f\"Initialising a controller with admin api at {admin_url} and an api key of {api_key}\")\n", - "agent_controller = AriesAgentController(admin_url,api_key)" - ] - }, - { - "cell_type": "markdown", - "id": "4318968f", - "metadata": {}, - "source": [ - "## Write DID to the Public Ledger\n", - "\n", - "Note: if defined a ACAPY_WALLET_SEED value for your agent then this function will return a DID, but this DID still needs to be written to the ledger. If you did not define a seed you will need to create a DID first." - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "id": "585aedbc", - "metadata": {}, - "outputs": [], - "source": [ - "public_did_response = await agent_controller.wallet.get_public_did()" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "id": "d1577357", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "DID {'did': 'J1y6c8mp32uBxVHkRiLM71', 'verkey': 'AGvykEU7F32mPyAzGfM86aqhRVKnENJzNb8uoVYF1wAt', 'posture': 'wallet_only'}\n" - ] - } - ], - "source": [ - "if public_did_response[\"result\"]:\n", - " did_obj = public_did_response[\"result\"]\n", - "else:\n", - " create_did_response = await agent_controller.wallet.create_did()\n", - " did_obj = create_did_response['result']\n", - "print(\"DID\", did_obj)" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "id": "68584897", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "{'statusCode': 200, 'headers': {'Access-Control-Allow-Origin': '*'}, 'body': '{\"statusCode\": 200, \"J1y6c8mp32uBxVHkRiLM71\": {\"status\": \"Success\", \"statusCode\": 200, \"reason\": \"Successfully wrote NYM identified by J1y6c8mp32uBxVHkRiLM71 to the ledger with role ENDORSER\"}}'}\n" - ] - } - ], - "source": [ - "# write new DID to Sovrin Stagingnet\n", - "import requests\n", - "import json \n", - "\n", - "url = 'https://selfserve.sovrin.org/nym'\n", - "\n", - "payload = {\"network\":\"stagingnet\",\"did\": did_obj[\"did\"],\"verkey\":did_obj[\"verkey\"],\"paymentaddr\":\"\"}\n", - "\n", - "# Adding empty header as parameters are being sent in payload\n", - "headers = {}\n", - "\n", - "r = requests.post(url, data=json.dumps(payload), headers=headers)\n", - "print(r.json())" - ] - }, - { - "cell_type": "markdown", - "id": "5551d128", - "metadata": {}, - "source": [ - "## Accept Transaction Author Agreement\n", - "\n", - "Although the Sovrin StagingNet is permissionless, before DID's have the authority to write to the ledger they must accept something called a transaction author agreement by signing it using the DID they have on the ledger.\n", - "\n", - "As a global public ledger, the Sovrin Ledger and all its participants are subject to privacy and data protection regulations such as the EU General Data Protection Regulation (GDPR). These regulations require that the participants be explicit about responsibilities for Personal Data.\n", - "\n", - "To clarify these responsibilities and provide protection for all parties, the Sovrin Governance Framework Working Group developed an agreement between Transaction Authors and the Sovrin Foundation. The TAA can be found at Sovrin.org. It ensures that users are aware of and consent to the fact that all data written to the Sovrin Ledger cannot be removed, even if the original author of the transaction requests its removal.\n", - "\n", - "The TAA outlines the policies that users must follow when interacting with the Sovrin Ledger. When a user’s client software is preparing a transaction for submission to the network, it must include a demonstration that the user had the opportunity to review the current TAA and accept it. This is done by including some additional fields in the ledger write transaction: \n", - "\n", - "* A hash of the agreement\n", - "* A date when the agreement was accepted, and\n", - "* A string indicating the user interaction that was followed to obtain the acceptance.\n", - "\n", - "The Indy client API used by Sovrin has been extended to allow users to review current and past agreements and to indicate acceptance through an approved user interaction pattern. - source: https://sovrin.org/preparing-for-the-sovrin-transaction-author-agreement/\n", - "\n", - "For more details on TAA please read more at the following links:\n", - "* [Preparing for the Sovrin Transaction Author Agreement](https://sovrin.org/preparing-for-the-sovrin-transaction-author-agreement/)\n", - "* [How the recent approval of the Sovrin Governance Framework v2 affects Transaction Authors\n", - "](https://sovrin.org/how-the-recent-approval-of-the-sovrin-governance-framework-v2-affects-transaction-authors/)\n", - "* [TAA v2](https://github.com/sovrin-foundation/sovrin/blob/master/TAA/TAA.md)\n", - "* [TAA Acceptance Mechanism List (AML)](https://github.com/sovrin-foundation/sovrin/blob/master/TAA/AML.md)" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "id": "9b21d953", - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "{}" - ] - }, - "execution_count": 6, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "taa_response = await agent_controller.ledger.get_taa()\n", - "TAA = taa_response['result']['taa_record']\n", - "TAA['mechanism'] = \"service_agreement\"\n", - "await agent_controller.ledger.accept_taa(TAA)" - ] - }, - { - "cell_type": "markdown", - "id": "af15da68", - "metadata": {}, - "source": [ - "## Assign Agent Public DID if Not Set\n", - "\n", - "Will only be ran if ACAPY_WALLET_SEED not initially set." - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "id": "b9179c0a", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Successfully intialised agent with Public DID : J1y6c8mp32uBxVHkRiLM71\n" - ] - } - ], - "source": [ - "if did_obj[\"posture\"] != \"public\":\n", - " response = await agent_controller.wallet.assign_public_did(did_obj[\"did\"])\n", - "print(\"Successfully intialised agent with Public DID : \", did_obj[\"did\"])" - ] - }, - { - "cell_type": "markdown", - "id": "e1470468", - "metadata": {}, - "source": [ - "## Writing Schema (We Have Already Written one for This Example)\n", - "\n", - "Write as many schema to the ledger as you like. Be sure to store each schema_id, you will need these when it comes to authoring credential defintition transactions and issuing credentials against this schema.\n", - "\n", - "Uncomment and copy the below cell as many times as you need. Be sure to update any arugments surrounded by <> with your own details." - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "id": "25cf9bcf", - "metadata": {}, - "outputs": [], - "source": [ - "# # Define you schema name - must be unique on the ledger\n", - "# schema_name = \"aca-acc-jupyter-plyaground\"\n", - "# # Can version the schema if you wish to update it\n", - "# schema_version = \"0.0.1\"\n", - "# # Define any list of attributes you wish to include in your schema\n", - "# attributes = [\"example\"]\n", - "\n", - "# response = await agent_controller.schema.write_schema(schema_name, attributes, schema_version)\n", - "# schema_id = response[\"schema_id\"]" - ] - }, - { - "cell_type": "markdown", - "id": "85fc6d55", - "metadata": {}, - "source": [ - "## Use External Schema\n", - "\n", - "You do not have to author the schema for the credentials you wish to issue, instead you can identify extisting schema on the ledger that you want to issue against. To do this you must set the schema identifier for any schema you want to use and these MUST be on the ledger your agent is pointing to." - ] - }, - { - "cell_type": "code", - "execution_count": 10, - "id": "d13181fe", - "metadata": {}, - "outputs": [], - "source": [ - "schema_id = \"J1y6c8mp32uBxVHkRiLM71:2:aca-acc-jupyter-plyaground:0.0.1\"" - ] - }, - { - "cell_type": "markdown", - "id": "58126f36", - "metadata": {}, - "source": [ - "## Writing Credential Definitions\n", - "\n", - "For all schema you intend to issue credentials against your agent must author a credential definition transaction to the public ledger. This specifies the public cryptographic material your agent will use to sign all credentials issued against a specific schema. \n", - "\n", - "Again uncomment and copy this cell as often as you need. Remebering to update the arguments in <> to specify your schema identifiers. Store each credential definition identifier in a unique variable." - ] - }, - { - "cell_type": "code", - "execution_count": 11, - "id": "ec55ee75", - "metadata": {}, - "outputs": [], - "source": [ - "# Tag and group specific credential definitions\n", - "tag = \"default\"\n", - "\n", - "# Make Cred Def support revocation. Credentials issued using this definition will be able to be revoked.\n", - "support_revocation = False\n", - "\n", - "cred_def_response = await agent_controller.definitions.write_cred_def(schema_id, tag, support_revocation)\n", - "cred_def_id = cred_def_response[\"credential_definition_id\"]" - ] - }, - { - "cell_type": "markdown", - "id": "c6fa64bb", - "metadata": {}, - "source": [ - "## Persist Identifiers for use throughout other business logic notebooks associated with this agent\n", - "\n", - "The schema_id and cred_def_id value pairs are required whenever issuing credentials, and also can be used to constrain acceptable proof requests. In a real application these values might be stored in environment variables or most likely in a database. For notebooks we have found it easier to store as string values in a cell and then load these values into the jupyter store so that they can be fetched across multiple notebooks.\n", - "\n", - "As such you are recommended to print out each of the schema and cred def identifiers used by your agent and copy them across to **Alice.ipynb**. Your main business logic notebook where you should store them in a variable and save them to the jupyter store. Remember, you should only be running this notebook once so having this logic in here will not be useful.\n" - ] - }, - { - "cell_type": "code", - "execution_count": 21, - "id": "260b4fbc", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "schema_id=J1y6c8mp32uBxVHkRiLM71:2:aca-acc-jupyter-plyaground:0.0.1\n", - "cred_def_id=J1y6c8mp32uBxVHkRiLM71:3:CL:216776:default\n" - ] - } - ], - "source": [ - "print(f\"schema_id='{schema_id}'\")\n", - "print(f\"cred_def_id='{cred_def_id}'\")" - ] - }, - { - "cell_type": "markdown", - "id": "a7c06b13", - "metadata": {}, - "source": [ - "## Terminate Controller\n" - ] - }, - { - "cell_type": "code", - "execution_count": 27, - "id": "1dcddca4", - "metadata": {}, - "outputs": [], - "source": [ - "await agent_controller.terminate()" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "da62f524", - "metadata": {}, - "outputs": [], - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.7.6" - } - }, - "nbformat": 4, - "nbformat_minor": 5 -} diff --git a/playground/issuer/notebooks/1. Alice.ipynb b/playground/issuer/notebooks/1. Alice.ipynb deleted file mode 100644 index 6afc86a..0000000 --- a/playground/issuer/notebooks/1. Alice.ipynb +++ /dev/null @@ -1,742 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "id": "776c19d9", - "metadata": {}, - "source": [ - "# ACA-Py & ACC-Py Basic Template\n", - "\n", - "## Copy this template into the root folder of your notebook workspace to get started" - ] - }, - { - "cell_type": "markdown", - "id": "69869712", - "metadata": {}, - "source": [ - "### Imports" - ] - }, - { - "cell_type": "code", - "execution_count": 14, - "id": "6afc43fe", - "metadata": {}, - "outputs": [], - "source": [ - "from aries_cloudcontroller import AriesAgentController\n", - "import os\n", - "import time\n", - "from termcolor import colored" - ] - }, - { - "cell_type": "markdown", - "id": "5c5b2270", - "metadata": {}, - "source": [ - "### Initialise the Agent Controller" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "1314ac33", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Initialising a controller with admin api at http://alice-agent:3021 and an api key of alicesSecretApiKey\n" - ] - } - ], - "source": [ - "api_key = os.getenv(\"ACAPY_ADMIN_API_KEY\")\n", - "admin_url = os.getenv(\"ADMIN_URL\")\n", - "\n", - "print(f\"Initialising a controller with admin api at {admin_url} and an api key of {api_key}\")\n", - "agent_controller = AriesAgentController(admin_url,api_key)" - ] - }, - { - "cell_type": "markdown", - "id": "b179048e", - "metadata": {}, - "source": [ - "### Start a Webhook Server" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "id": "b2eb6390", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Listening for webhooks from agent at http://0.0.0.0:3010\n" - ] - } - ], - "source": [ - "webhook_port = int(os.getenv(\"WEBHOOK_PORT\"))\n", - "webhook_host = \"0.0.0.0\"\n", - "\n", - "await agent_controller.init_webhook_server(webhook_host, webhook_port)\n", - "\n", - "print(f\"Listening for webhooks from agent at http://{webhook_host}:{webhook_port}\")" - ] - }, - { - "cell_type": "markdown", - "id": "05847b70", - "metadata": {}, - "source": [ - "## Register Agent Event Listeners\n", - "\n", - "You can see some examples within the webhook_listeners recipe. Copy any relevant cells across and customise as needed." - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "id": "53849470", - "metadata": {}, - "outputs": [], - "source": [ - "listeners = []\n", - "\n", - "# Receive connection messages\n", - "def connections_handler(payload):\n", - " state = payload['state']\n", - " connection_id = payload[\"connection_id\"]\n", - " their_role = payload[\"their_role\"]\n", - " routing_state = payload[\"routing_state\"]\n", - " \n", - " print(\"----------------------------------------------------------\")\n", - " print(\"Connection Webhook Event Received\")\n", - " print(\"Connection ID : \", connection_id)\n", - " print(\"State : \", state)\n", - " print(\"Routing State : \", routing_state)\n", - " print(\"Their Role : \", their_role)\n", - " print(\"----------------------------------------------------------\")\n", - "\n", - " if state == \"invitation\":\n", - " # Your business logic\n", - " print(\"invitation\")\n", - " elif state == \"request\":\n", - " # Your business logic\n", - " print(\"request\")\n", - "\n", - " elif state == \"response\":\n", - " # Your business logic\n", - " print(\"response\")\n", - " elif state == \"active\":\n", - " # Your business logic\n", - " print(colored(\"Connection ID: {0} is now active.\".format(connection_id), \"green\", attrs=[\"bold\"]))\n", - "\n", - "\n", - "\n", - "connection_listener = {\n", - " \"handler\": connections_handler,\n", - " \"topic\": \"connections\"\n", - "}\n", - "\n", - "listeners.append(connection_listener)\n", - "\n", - "def issuer_handler(payload):\n", - " connection_id = payload['connection_id']\n", - " exchange_id = payload['credential_exchange_id']\n", - " state = payload['state']\n", - " role = payload['role']\n", - " print(\"\\n---------------------------------------------------\\n\")\n", - " print(\"Handle Issue Credential Webhook\")\n", - " print(f\"Connection ID : {connection_id}\")\n", - " print(f\"Credential exchange ID : {exchange_id}\")\n", - " print(\"Agent Protocol Role : \", role)\n", - " print(\"Protocol State : \", state )\n", - " print(\"\\n---------------------------------------------------\\n\")\n", - " \n", - " \n", - " if state == \"offer_sent\":\n", - " proposal = payload[\"credential_proposal_dict\"]\n", - " attributes = proposal['credential_proposal']['attributes']\n", - " print(f\"Offering : \\n {attributes}\")\n", - " ## YOUR LOGIC HERE\n", - " elif state == \"request_received\":\n", - " print(\"Request for credential received\")\n", - " ## YOUR LOGIC HERE\n", - " elif state == \"credential_sent\":\n", - " print(\"Credential Sent\")\n", - " ## YOUR LOGIC HERE\n", - " \n", - "issuer_listener = {\n", - " \"topic\": \"issue_credential\",\n", - " \"handler\": issuer_handler\n", - "}\n", - "\n", - "listeners.append(issuer_listener)\n", - "\n", - "\n", - "def verifier_proof_handler(payload):\n", - " role = payload[\"role\"]\n", - " connection_id = payload[\"connection_id\"]\n", - " pres_ex_id = payload[\"presentation_exchange_id\"]\n", - " state = payload[\"state\"]\n", - " print(\"\\n---------------------------------------------------------------------\\n\")\n", - " print(\"Handle present-proof\")\n", - " print(\"Connection ID : \", connection_id)\n", - " print(\"Presentation Exchange ID : \", pres_ex_id)\n", - " print(\"Protocol State : \", state)\n", - " print(\"Agent Role : \", role)\n", - " print(\"Initiator : \", payload[\"initiator\"])\n", - " print(\"\\n---------------------------------------------------------------------\\n\")\n", - " \n", - "\n", - " if state == \"request_sent\":\n", - " print(\"Presentation Request\\n\")\n", - " print(payload[\"presentation_request\"])\n", - " print(\"\\nThe presentation request is encoded in base64 and packaged into a DIDComm Message\\n\")\n", - " print(payload[\"presentation_request_dict\"])\n", - " print(\"\\nNote the type defines the protocol present-proof and the message request-presentation\\n\")\n", - " print(payload[\"presentation_request_dict\"][\"@type\"])\n", - " elif state == \"presentation_received\":\n", - " print(\"Presentation Received\")\n", - " else:\n", - " print(f\"Presentation Verified? {payload['verified']} \\n\")\n", - " \n", - "verifier_listener = {\n", - " \"topic\": \"present_proof\",\n", - " \"handler\": verifier_proof_handler\n", - "}\n", - "\n", - "listeners.append(verifier_listener)\n", - "\n", - "agent_controller.register_listeners(listeners)" - ] - }, - { - "cell_type": "markdown", - "id": "29e7da15", - "metadata": {}, - "source": [ - "## Store Schema and Cred Def ID's" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "id": "ad5c2efc", - "metadata": {}, - "outputs": [], - "source": [ - "schema_id=\"J1y6c8mp32uBxVHkRiLM71:2:aca-acc-jupyter-plyaground:0.0.1\"\n", - "cred_def_id=\"J1y6c8mp32uBxVHkRiLM71:3:CL:216776:default\"" - ] - }, - { - "cell_type": "markdown", - "id": "e6f9247b", - "metadata": {}, - "source": [ - "## Accept Invitation\n", - "\n", - "Copy an invitation object from another agent playing the role inviter (see the inviter_template recipe)" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "id": "9faeed21", - "metadata": {}, - "outputs": [], - "source": [ - "invitation = {'@type': 'did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/connections/1.0/invitation', '@id': 'e743b38b-fab7-4315-92a7-1b7b6cab0f95', 'recipientKeys': ['36CZQj9EpiGbPG926PU7GrnApdqJgpGE91dKQHWHEzZS'], 'serviceEndpoint': 'https://588d5381c2e8.ngrok.io', 'label': 'Bob'}\n" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "id": "174a5cb5", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "----------------------------------------------------------\n", - "Connection Webhook Event Received\n", - "Connection ID : 48a27664-2266-4382-9001-ced139060721\n", - "State : invitation\n", - "Routing State : none\n", - "Their Role : inviter\n", - "----------------------------------------------------------\n", - "invitation\n" - ] - } - ], - "source": [ - "auto_accept=\"false\"\n", - "alias=None\n", - "\n", - "invite_response = await agent_controller.connections.receive_invitation(invitation, alias, auto_accept)\n", - "connection_id = invite_response[\"connection_id\"]" - ] - }, - { - "cell_type": "code", - "execution_count": 10, - "id": "a199813d", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "----------------------------------------------------------\n", - "Connection Webhook Event Received\n", - "Connection ID : 48a27664-2266-4382-9001-ced139060721\n", - "State : request\n", - "Routing State : none\n", - "Their Role : inviter\n", - "----------------------------------------------------------\n", - "request\n", - "----------------------------------------------------------\n", - "Connection Webhook Event Received\n", - "Connection ID : 48a27664-2266-4382-9001-ced139060721\n", - "State : response\n", - "Routing State : none\n", - "Their Role : inviter\n", - "----------------------------------------------------------\n", - "response\n", - "----------------------------------------------------------\n", - "Connection Webhook Event Received\n", - "Connection ID : 48a27664-2266-4382-9001-ced139060721\n", - "State : active\n", - "Routing State : none\n", - "Their Role : inviter\n", - "----------------------------------------------------------\n", - "\u001b[1m\u001b[32mConnection ID: 48a27664-2266-4382-9001-ced139060721 is now active.\u001b[0m\n" - ] - } - ], - "source": [ - "# Label for the connection\n", - "my_label = None\n", - "# Endpoint you expect to recieve messages at\n", - "my_endpoint = None\n", - "\n", - "accept_response = await agent_controller.connections.accept_invitation(connection_id, my_label, my_endpoint)" - ] - }, - { - "cell_type": "markdown", - "id": "5aacb749", - "metadata": {}, - "source": [ - "## Populate Credential Attributes\n", - "\n", - "Before you can issue a credential, you must define the values that will be issued in this credential. The attribute names **MUST** match those in the schem identified by the value.\n", - "\n", - "Make sure to change all code enclosed with <>.\n" - ] - }, - { - "cell_type": "code", - "execution_count": 11, - "id": "4e1ad552", - "metadata": {}, - "outputs": [ - { - "name": "stdin", - "output_type": "stream", - "text": [ - "Whatever you want. This can be any string. Including a serialized JSON, or a base64 encoded image: sOME DATA\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[{'name': 'example', 'value': 'sOME DATA'}]\n" - ] - } - ], - "source": [ - "example=input(\"Whatever you want. This can be any string. Including a serialized JSON, or a base64 encoded image: \")\n", - "credential_attributes = [\n", - " {\"name\": \"example\", \"value\": example},\n", - "]\n", - "print(credential_attributes)" - ] - }, - { - "cell_type": "markdown", - "id": "f8f853ef", - "metadata": {}, - "source": [ - "## Send Credential\n", - "\n", - "This is the easiest way to issue a credential because it automates the rest of the protocol steps. \n", - "\n", - "Note: The `connection_id` must be in the active state before a credential can be sent." - ] - }, - { - "cell_type": "code", - "execution_count": 12, - "id": "dff3252d", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n", - "---------------------------------------------------\n", - "\n", - "Handle Issue Credential Webhook\n", - "Connection ID : 48a27664-2266-4382-9001-ced139060721\n", - "Credential exchange ID : 05efd17c-dab7-4ae4-b232-9a392db07f7f\n", - "Agent Protocol Role : issuer\n", - "Protocol State : offer_sent\n", - "\n", - "---------------------------------------------------\n", - "\n", - "Offering : \n", - " [{'name': 'example', 'value': 'sOME DATA'}]\n", - "\n", - "---------------------------------------------------\n", - "\n", - "Handle Issue Credential Webhook\n", - "Connection ID : 48a27664-2266-4382-9001-ced139060721\n", - "Credential exchange ID : 05efd17c-dab7-4ae4-b232-9a392db07f7f\n", - "Agent Protocol Role : issuer\n", - "Protocol State : request_received\n", - "\n", - "---------------------------------------------------\n", - "\n", - "Request for credential received\n", - "\n", - "---------------------------------------------------\n", - "\n", - "Handle Issue Credential Webhook\n", - "Connection ID : 48a27664-2266-4382-9001-ced139060721\n", - "Credential exchange ID : 05efd17c-dab7-4ae4-b232-9a392db07f7f\n", - "Agent Protocol Role : issuer\n", - "Protocol State : credential_issued\n", - "\n", - "---------------------------------------------------\n", - "\n" - ] - } - ], - "source": [ - "# Do you want the ACA-Py instance to trace it's processes (for testing/timing analysis)\n", - "trace = False\n", - "comment = \"\"\n", - "# Remove credential record after issued?\n", - "auto_remove = True\n", - "\n", - "# Change and to correct pair. Cred_def_id must identify a definition to which your agent has corresponding private issuing key.\n", - "send_cred_response = await agent_controller.issuer.send_credential(connection_id, schema_id, cred_def_id, credential_attributes, comment, auto_remove, trace)\n", - "\n", - "# Note last three args are optional.\n", - "# await agent_controller.issuer.send_credential(connection_id, , \"\n", - "\n", - "# cred_def_id = \"\"\n", - "\n", - "# Define the list of attributes and restrictions under which each attribute was issued that a prover must satisfy with a presentation\n", - "# NOTE: if identifying a schema or credential definition then the attribute name must be contained within the corresponding schema.\n", - "req_attrs = [\n", - " {\"name\": \"example\", \"restrictions\": [{\"schema_id\": schema_id, \"cred_def_id\": cred_def_id}]},\n", - "]\n", - "\n", - "# We could extend this to request the name attribute aswell if we wanted.\n", - "\n", - "\n", - "indy_proof_request = {\n", - " \"name\": \"Proof of Data Owner\",\n", - " \"version\": \"1.0\",\n", - " \"requested_attributes\": {\n", - " # They generally follow this uuid pattern. Unique identifier for attribute within context of this proof request\n", - " # Note that req_attr['name'] gets the attribute name of each object. E.g. domain and name in this case\n", - " f\"0_{req_attr['name']}_uuid\":\n", - " req_attr for req_attr in req_attrs\n", - " },\n", - " # Predicates allow us to specify range proofs or set membership on attributes. For example greater than 10.\n", - " # We will ignore these for now.\n", - " \"requested_predicates\": {\n", - "# f\"0_{req_pred['name']}_GE_uuid\":\n", - "# req_pred for req_pred in req_preds\n", - " },\n", - " # You can also request the entire proof request be non-revoked\n", - "# \"non_revoked\": {\"to\": int(time.time())}\n", - "}" - ] - }, - { - "cell_type": "code", - "execution_count": 24, - "id": "18514237", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n", - "---------------------------------------------------------------------\n", - "\n", - "Handle present-proof\n", - "Connection ID : 48a27664-2266-4382-9001-ced139060721\n", - "Presentation Exchange ID : edc84101-5d86-4e8a-a0a1-6a7cb2127675\n", - "Protocol State : request_sent\n", - "Agent Role : verifier\n", - "Initiator : self\n", - "\n", - "---------------------------------------------------------------------\n", - "\n", - "Presentation Request\n", - "\n", - "{'name': 'Proof of Data Owner', 'version': '1.0', 'requested_attributes': {'0_example_uuid': {'name': 'example', 'restrictions': [{'schema_id': 'J1y6c8mp32uBxVHkRiLM71:2:aca-acc-jupyter-plyaground:0.0.1', 'cred_def_id': 'J1y6c8mp32uBxVHkRiLM71:3:CL:216776:default'}]}}, 'requested_predicates': {}, 'nonce': '43448558002334650989233'}\n", - "\n", - "The presentation request is encoded in base64 and packaged into a DIDComm Message\n", - "\n", - "{'@type': 'did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/present-proof/1.0/request-presentation', '@id': 'bb9dc7d4-4a59-4e5f-80c7-fca8eac74eba', 'request_presentations~attach': [{'@id': 'libindy-request-presentation-0', 'mime-type': 'application/json', 'data': {'base64': 'eyJuYW1lIjogIlByb29mIG9mIERhdGEgT3duZXIiLCAidmVyc2lvbiI6ICIxLjAiLCAicmVxdWVzdGVkX2F0dHJpYnV0ZXMiOiB7IjBfZXhhbXBsZV91dWlkIjogeyJuYW1lIjogImV4YW1wbGUiLCAicmVzdHJpY3Rpb25zIjogW3sic2NoZW1hX2lkIjogIkoxeTZjOG1wMzJ1QnhWSGtSaUxNNzE6MjphY2EtYWNjLWp1cHl0ZXItcGx5YWdyb3VuZDowLjAuMSIsICJjcmVkX2RlZl9pZCI6ICJKMXk2YzhtcDMydUJ4VkhrUmlMTTcxOjM6Q0w6MjE2Nzc2OmRlZmF1bHQifV19fSwgInJlcXVlc3RlZF9wcmVkaWNhdGVzIjoge30sICJub25jZSI6ICI0MzQ0ODU1ODAwMjMzNDY1MDk4OTIzMyJ9'}}], 'comment': 'Some optional comment'}\n", - "\n", - "Note the type defines the protocol present-proof and the message request-presentation\n", - "\n", - "did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/present-proof/1.0/request-presentation\n", - "\n", - "---------------------------------------------------\n", - "\n", - "Handle Issue Credential Webhook\n", - "Connection ID : 48a27664-2266-4382-9001-ced139060721\n", - "Credential exchange ID : 05efd17c-dab7-4ae4-b232-9a392db07f7f\n", - "Agent Protocol Role : issuer\n", - "Protocol State : credential_acked\n", - "\n", - "---------------------------------------------------\n", - "\n", - "\n", - "---------------------------------------------------------------------\n", - "\n", - "Handle present-proof\n", - "Connection ID : 48a27664-2266-4382-9001-ced139060721\n", - "Presentation Exchange ID : edc84101-5d86-4e8a-a0a1-6a7cb2127675\n", - "Protocol State : presentation_received\n", - "Agent Role : verifier\n", - "Initiator : self\n", - "\n", - "---------------------------------------------------------------------\n", - "\n", - "Presentation Received\n" - ] - } - ], - "source": [ - "proof_request = {\n", - " \"comment\": \"Some optional comment\",\n", - " \"connection_id\": connection_id,\n", - " \"proof_request\": indy_proof_request,\n", - " # Do you want your agent to trace this request (for debugging)\n", - " \"trace\": False\n", - "}\n", - "\n", - "proof_request_response = await agent_controller.proofs.send_request(proof_request)" - ] - }, - { - "cell_type": "markdown", - "id": "7d62d3a1", - "metadata": {}, - "source": [ - "## Get Presentation Exchange Record\n", - "\n", - "This record keeps track of the current state of the presentation protocol, which must be in the `presentation_received` state before the presentation can be verified.\n", - "\n", - "Note: This could also happen in the webhook logic." - ] - }, - { - "cell_type": "code", - "execution_count": 26, - "id": "275d5f3c", - "metadata": {}, - "outputs": [], - "source": [ - "presentation_exchange_id = proof_request_response[\"presentation_exchange_id\"]" - ] - }, - { - "cell_type": "markdown", - "id": "b6509207", - "metadata": {}, - "source": [ - "## Verify Presentation\n", - "\n", - "Only if it is in the right state. \n", - "\n", - "Note: Verifying a presentation moves the state to `verified` regardless of whether the presentation request has been satisfied. To check this you must refer to the `verified` property on the response." - ] - }, - { - "cell_type": "code", - "execution_count": 27, - "id": "fb87b776", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n", - "---------------------------------------------------------------------\n", - "\n", - "Handle present-proof\n", - "Connection ID : 48a27664-2266-4382-9001-ced139060721\n", - "Presentation Exchange ID : edc84101-5d86-4e8a-a0a1-6a7cb2127675\n", - "Protocol State : verified\n", - "Agent Role : verifier\n", - "Initiator : self\n", - "\n", - "---------------------------------------------------------------------\n", - "\n", - "Presentation Verified? true \n", - "\n" - ] - } - ], - "source": [ - "verified_response = await agent_controller.proofs.verify_presentation(presentation_exchange_id)\n", - "\n", - "verified = verified_response[\"verified\"]" - ] - }, - { - "cell_type": "markdown", - "id": "c6c07422", - "metadata": { - "tags": [] - }, - "source": [ - "## Parsing Disclosed Attribute Values from Presentation\n", - "\n", - "A presentation object contains three classes of attributes. \n", - "* Revealed Attributes: Attributes that were signed by an issuer and have been revealed in the presentation process\n", - "* Self Attested Attributes: Attributes that the prover has self attested to in the presentation object.\n", - "* Predicate proofs: Attribute values that have been proven to meet some statement. (TODO: Show how you can parse this information)" - ] - }, - { - "cell_type": "markdown", - "id": "d6cc83be", - "metadata": {}, - "source": [ - "### Parse Revealed Attributes" - ] - }, - { - "cell_type": "code", - "execution_count": 32, - "id": "53970f93", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n", - "Attribute : {'sub_proof_index': 0, 'raw': 'sOME DATA', 'encoded': '54601064853684362018060759795266104659214728646083330886433293175925246179662'}\n", - "Attribute Name : Raw Value\n", - "example : sOME DATA\n" - ] - } - ], - "source": [ - "for (name, val) in verified_response['presentation']['requested_proof']['revealed_attrs'].items():\n", - " ## This is the actual data that you want. It's a little hidden\n", - " print(\"\\nAttribute : \", val)\n", - " \n", - " attr_name = verified_response[\"presentation_request\"][\"requested_attributes\"][name][\"name\"]\n", - " print(\"Attribute Name : Raw Value\")\n", - " print(f\"{attr_name} : {val['raw']}\")" - ] - }, - { - "cell_type": "markdown", - "id": "24e119a0", - "metadata": {}, - "source": [ - "## Terminate Controller\n", - "\n", - "Whenever you have finished with this notebook, be sure to terminate the controller. This is especially important if your business logic runs across multiple notebooks." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "7d88721e", - "metadata": {}, - "outputs": [], - "source": [ - "await agent_controller.terminate()" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "12d87d7e", - "metadata": {}, - "outputs": [], - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.7.6" - } - }, - "nbformat": 4, - "nbformat_minor": 5 -} diff --git a/playground/issuer/notebooks/Alice invitation.ipynb b/playground/issuer/notebooks/Alice invitation.ipynb deleted file mode 100644 index 63cfb80..0000000 --- a/playground/issuer/notebooks/Alice invitation.ipynb +++ /dev/null @@ -1,373 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "id": "34b70bdc", - "metadata": {}, - "source": [ - "# ACA-Py & ACC-Py Basic Template\n", - "\n", - "## Copy this template into the root folder of your notebook workspace to get started" - ] - }, - { - "cell_type": "markdown", - "id": "b3757add", - "metadata": {}, - "source": [ - "### Imports" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "id": "a8146d79", - "metadata": {}, - "outputs": [], - "source": [ - "from aries_cloudcontroller import AriesAgentController\n", - "import os\n", - "from termcolor import colored" - ] - }, - { - "cell_type": "markdown", - "id": "808fbe8d", - "metadata": {}, - "source": [ - "### Initialise the Agent Controller" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "89d882b3", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Initialising a controller with admin api at http://bob-agent:3021 and an api key of adminApiKey\n" - ] - } - ], - "source": [ - "api_key = os.getenv(\"ACAPY_ADMIN_API_KEY\")\n", - "admin_url = os.getenv(\"ADMIN_URL\")\n", - "\n", - "print(f\"Initialising a controller with admin api at {admin_url} and an api key of {api_key}\")\n", - "agent_controller = AriesAgentController(admin_url,api_key)" - ] - }, - { - "cell_type": "markdown", - "id": "9e0eb8d0", - "metadata": {}, - "source": [ - "### Start a Webhook Server" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "id": "cd6d9f2c", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Listening for webhooks from agent at http://0.0.0.0:3010\n" - ] - } - ], - "source": [ - "webhook_port = int(os.getenv(\"WEBHOOK_PORT\"))\n", - "webhook_host = \"0.0.0.0\"\n", - "\n", - "await agent_controller.init_webhook_server(webhook_host, webhook_port)\n", - "\n", - "print(f\"Listening for webhooks from agent at http://{webhook_host}:{webhook_port}\")" - ] - }, - { - "cell_type": "markdown", - "id": "bbb24e7f", - "metadata": {}, - "source": [ - "## Register Agent Event Listeners\n", - "\n", - "You can see some examples within the webhook_listeners recipe. Copy any relevant cells across and customise as needed." - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "id": "cffb7ea0", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Subscribing too: connections\n" - ] - } - ], - "source": [ - "listeners = []\n", - "\n", - "# Receive connection messages\n", - "def connections_handler(payload):\n", - " state = payload['state']\n", - " connection_id = payload[\"connection_id\"]\n", - " their_role = payload[\"their_role\"]\n", - " routing_state = payload[\"routing_state\"]\n", - " \n", - " print(\"----------------------------------------------------------\")\n", - " print(\"Connection Webhook Event Received\")\n", - " print(\"Connection ID : \", connection_id)\n", - " print(\"State : \", state)\n", - " print(\"Routing State : \", routing_state)\n", - " print(\"Their Role : \", their_role)\n", - " print(\"----------------------------------------------------------\")\n", - "\n", - " if state == \"invitation\":\n", - " # Your business logic\n", - " print(\"invitation\")\n", - " elif state == \"request\":\n", - " # Your business logic\n", - " print(\"request\")\n", - "\n", - " elif state == \"response\":\n", - " # Your business logic\n", - " print(\"response\")\n", - " elif state == \"active\":\n", - " # Your business logic\n", - " print(colored(\"Connection ID: {0} is now active.\".format(connection_id), \"green\", attrs=[\"bold\"]))\n", - "\n", - "\n", - "\n", - "connection_listener = {\n", - " \"handler\": connections_handler,\n", - " \"topic\": \"connections\"\n", - "}\n", - "\n", - "listeners.append(connection_listener)\n", - "\n", - "agent_controller.register_listeners(listeners)" - ] - }, - { - "cell_type": "markdown", - "id": "d7689eea", - "metadata": {}, - "source": [ - "## Create Invitation\n", - "\n", - "Note the current arguments specified are in their default configurations. " - ] - }, - { - "cell_type": "code", - "execution_count": 12, - "id": "a0485795", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "----------------------------------------------------------\n", - "Connection Webhook Event Received\n", - "Connection ID : b85c8880-e5ac-4219-9838-2ef64491af4d\n", - "State : invitation\n", - "Routing State : none\n", - "Their Role : invitee\n", - "----------------------------------------------------------\n", - "invitation\n" - ] - } - ], - "source": [ - "# Alias for invited connection\n", - "alias = None\n", - "auto_accept = False\n", - "# Use public DID?\n", - "public = \"false\"\n", - "# Should this invitation be usable by multiple invitees?\n", - "multi_use = \"false\"\n", - "\n", - "invitation_response = await agent_controller.connections.create_invitation(alias, auto_accept, public, multi_use)\n", - "# Is equivalent to above. Arguments are optionally\n", - "# invitation_response = await agent_controller.connections.create_invitation()\n", - "\n", - "\n", - "\n", - "# You probably want to keep this somewhere so you can enage in other protocols with this connection.\n", - "connection_id = invitation_response[\"connection_id\"]\n" - ] - }, - { - "cell_type": "markdown", - "id": "4eeb8c93", - "metadata": {}, - "source": [ - "## Share Invitation Object with External Agent\n", - "\n", - "Typically in this jupyter notebook playground that involves copying it across to another agent's business logic notebook where they are the invitee. (see invitee_template recipe)" - ] - }, - { - "cell_type": "code", - "execution_count": 13, - "id": "e20f6f9a", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "{'@type': 'did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/connections/1.0/invitation', '@id': '8770a9f4-d38f-4c14-b9e8-a3d4f7aea9e0', 'serviceEndpoint': 'https://d3df60a216ea.ngrok.io', 'label': 'Bob', 'recipientKeys': ['9dbE6UbNjYyDW3XXhVTmufWH5FF9TVmWwChh9tc7xi7T']}\n" - ] - } - ], - "source": [ - "invitation = invitation_response[\"invitation\"]\n", - "## Copy this output\n", - "print(invitation)" - ] - }, - { - "cell_type": "markdown", - "id": "2bc54798", - "metadata": {}, - "source": [ - "## Accept Invitation Response\n", - "\n", - "Note: You may not need to run this cell. It depends if this agent has the ACAPY_AUTO_ACCEPT_REQUESTS=true flag set." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "ba966cc2", - "metadata": {}, - "outputs": [], - "source": [ - "# Endpoint you expect to recieve messages at\n", - "my_endpoint = None\n", - "accept_request_response = await agent_controller.connections.accept_request(connection_id, my_endpoint)" - ] - }, - { - "cell_type": "markdown", - "id": "05c91096", - "metadata": {}, - "source": [ - "## Send Trust Ping\n", - "\n", - "Once connection moves to response state one agent, either inviter or invitee needs to send a trust ping.\n", - "\n", - "Note: you may not need to run this cell. It depends one of the agents has the ACAPY_AUTO_PING_CONNECTION=true flag set." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "e43238dc", - "metadata": {}, - "outputs": [], - "source": [ - "comment = \"Some Optional Comment\"\n", - "message = await agent_controller.messaging.trust_ping(connection_id, comment)" - ] - }, - { - "cell_type": "markdown", - "id": "d58f14f6", - "metadata": {}, - "source": [ - "## Your Own Business Logic\n", - "\n", - "Now you should have an established, active connection you can write any custom logic you want to engage with protocols with the connection" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "4402d876", - "metadata": {}, - "outputs": [], - "source": [ - "## Custom Logic" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "d6e7345b", - "metadata": {}, - "outputs": [], - "source": [] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "8f617b59", - "metadata": {}, - "outputs": [], - "source": [] - }, - { - "cell_type": "markdown", - "id": "038b2c24", - "metadata": {}, - "source": [ - "## Terminate Controller\n", - "\n", - "Whenever you have finished with this notebook, be sure to terminate the controller. This is especially important if your business logic runs across multiple notebooks." - ] - }, - { - "cell_type": "code", - "execution_count": 16, - "id": "caeb5e3a", - "metadata": {}, - "outputs": [], - "source": [ - "await agent_controller.terminate()" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "a82047b4", - "metadata": {}, - "outputs": [], - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.7.6" - } - }, - "nbformat": 4, - "nbformat_minor": 5 -}