|
2 | 2 | "cells": [
|
3 | 3 | {
|
4 | 4 | "cell_type": "code",
|
5 |
| - "execution_count": 6, |
| 5 | + "execution_count": 2, |
6 | 6 | "metadata": {},
|
7 | 7 | "outputs": [
|
8 | 8 | {
|
|
22 | 22 | },
|
23 | 23 | {
|
24 | 24 | "cell_type": "code",
|
25 |
| - "execution_count": 2, |
| 25 | + "execution_count": 3, |
26 | 26 | "metadata": {},
|
27 | 27 | "outputs": [],
|
28 | 28 | "source": [
|
|
47 | 47 | "execution_count": 4,
|
48 | 48 | "metadata": {},
|
49 | 49 | "outputs": [],
|
| 50 | + "source": [ |
| 51 | + "from aries_basic_controller.aries_controller import AriesAgentController\n", |
| 52 | + " \n", |
| 53 | + "WEBHOOK_HOST = \"0.0.0.0\"\n", |
| 54 | + "WEBHOOK_PORT = 8052\n", |
| 55 | + "WEBHOOK_BASE = \"\"\n", |
| 56 | + "ADMIN_URL = \"http://bob-agent:8051\"\n", |
| 57 | + "\n", |
| 58 | + "# Based on the aca-py agent you wish to control\n", |
| 59 | + "bob_agent_controller = AriesAgentController(webhook_host=WEBHOOK_HOST, webhook_port=WEBHOOK_PORT,\n", |
| 60 | + " webhook_base=WEBHOOK_BASE, admin_url=ADMIN_URL)\n" |
| 61 | + ] |
| 62 | + }, |
| 63 | + { |
| 64 | + "cell_type": "code", |
| 65 | + "execution_count": 5, |
| 66 | + "metadata": {}, |
| 67 | + "outputs": [], |
50 | 68 | "source": [
|
51 | 69 | "\n",
|
52 | 70 | "loop = asyncio.get_event_loop()\n",
|
|
64 | 82 | },
|
65 | 83 | {
|
66 | 84 | "cell_type": "code",
|
67 |
| - "execution_count": 12, |
| 85 | + "execution_count": 11, |
68 | 86 | "metadata": {},
|
69 | 87 | "outputs": [
|
70 | 88 | {
|
71 | 89 | "name": "stdout",
|
72 | 90 | "output_type": "stream",
|
73 | 91 | "text": [
|
74 |
| - "{\"include_handshake\": true, \"use_public_did\": false}\n", |
75 |
| - "{\"state\": \"initial\", \"invitation\": {\"@type\": \"did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/out-of-band/1.0/invitation\", \"@id\": \"40ea3b1e-4589-477d-84ae-c28e9fa490ac\", \"label\": \"Alice\", \"request~attach\": [], \"handshake_protocols\": [\"https://didcomm.org/connections/1.0/invitation\", \"did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/connections/1.0/invitation\"], \"service\": [{\"id\": \"#inline\", \"type\": \"did-communication\", \"recipientKeys\": [\"did:key:z6Mkjh4wVVG9PN3tkRxhw9yLqjfxWEeHoqbnxcEhciPHHq9w\"], \"routingKeys\": [], \"serviceEndpoint\": \"http://192.168.65.3:8020\"}]}, \"created_at\": \"2020-10-30 11:32:45.079505Z\", \"invitation_id\": \"722c4c0e-0d29-4bff-a910-dd4d7d922c18\", \"updated_at\": \"2020-10-30 11:32:45.079505Z\", \"trace\": false}\n", |
76 |
| - "\n", |
77 |
| - "\n", |
78 |
| - "{\n", |
79 |
| - " \"state\": \"initial\",\n", |
80 |
| - " \"invitation\": {\n", |
81 |
| - " \"@type\": \"did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/out-of-band/1.0/invitation\",\n", |
82 |
| - " \"@id\": \"40ea3b1e-4589-477d-84ae-c28e9fa490ac\",\n", |
83 |
| - " \"label\": \"Alice\",\n", |
84 |
| - " \"request~attach\": [],\n", |
85 |
| - " \"handshake_protocols\": [\n", |
86 |
| - " \"https://didcomm.org/connections/1.0/invitation\",\n", |
87 |
| - " \"did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/connections/1.0/invitation\"\n", |
88 |
| - " ],\n", |
89 |
| - " \"service\": [\n", |
90 |
| - " {\n", |
91 |
| - " \"id\": \"#inline\",\n", |
92 |
| - " \"type\": \"did-communication\",\n", |
93 |
| - " \"recipientKeys\": [\n", |
94 |
| - " \"did:key:z6Mkjh4wVVG9PN3tkRxhw9yLqjfxWEeHoqbnxcEhciPHHq9w\"\n", |
95 |
| - " ],\n", |
96 |
| - " \"routingKeys\": [],\n", |
97 |
| - " \"serviceEndpoint\": \"http://192.168.65.3:8020\"\n", |
98 |
| - " }\n", |
99 |
| - " ]\n", |
100 |
| - " },\n", |
101 |
| - " \"created_at\": \"2020-10-30 11:32:45.079505Z\",\n", |
102 |
| - " \"invitation_id\": \"722c4c0e-0d29-4bff-a910-dd4d7d922c18\",\n", |
103 |
| - " \"updated_at\": \"2020-10-30 11:32:45.079505Z\",\n", |
104 |
| - " \"trace\": false\n", |
105 |
| - "}\n" |
| 92 | + "{\"@type\": \"did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/out-of-band/1.0/invitation\", \"@id\": \"5048931e-5f1b-4f71-82a1-43d32c0c9d3d\", \"handshake_protocols\": [\"https://didcomm.org/connections/1.0/invitation\", \"did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/connections/1.0/invitation\"], \"request~attach\": [], \"label\": \"Alice\", \"service\": [{\"id\": \"#inline\", \"type\": \"did-communication\", \"recipientKeys\": [\"did:key:z6Mkey7uyZQCVotLBXQhJfbNNEw8RaMJEWTMfQbj7RumDXJx\"], \"routingKeys\": [], \"serviceEndpoint\": \"http://192.168.65.3:8020\"}]}\n" |
106 | 93 | ]
|
107 | 94 | }
|
108 | 95 | ],
|
|
111 | 98 | " \"include_handshake\": True,\n",
|
112 | 99 | " \"use_public_did\": False\n",
|
113 | 100 | "}\n",
|
114 |
| - "print(json.dumps(payload))\n", |
115 | 101 | "\n",
|
116 | 102 | "# Create an out of band Invitation\n",
|
117 | 103 | "oob_invite = await agent_controller.oob.create_invitation(json.dumps(payload))\n",
|
118 |
| - "print(json.dumps(oob_invite))\n", |
119 |
| - "print('\\n')\n", |
120 |
| - "print(json.dumps(oob_invite, indent=2))" |
| 104 | + "oob_invite_message = json.dumps(oob_invite['invitation'])\n", |
| 105 | + "print(oob_invite_message)" |
| 106 | + ] |
| 107 | + }, |
| 108 | + { |
| 109 | + "cell_type": "code", |
| 110 | + "execution_count": 14, |
| 111 | + "metadata": { |
| 112 | + "scrolled": false |
| 113 | + }, |
| 114 | + "outputs": [ |
| 115 | + { |
| 116 | + "name": "stdout", |
| 117 | + "output_type": "stream", |
| 118 | + "text": [ |
| 119 | + "{\"@type\": \"did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/out-of-band/1.0/invitation\", \"@id\": \"5048931e-5f1b-4f71-82a1-43d32c0c9d3d\", \"handshake_protocols\": [\"https://didcomm.org/connections/1.0/invitation\", \"did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/connections/1.0/invitation\"], \"request~attach\": [], \"label\": \"Alice\", \"service\": [{\"id\": \"#inline\", \"type\": \"did-communication\", \"recipientKeys\": [\"did:key:z6Mkey7uyZQCVotLBXQhJfbNNEw8RaMJEWTMfQbj7RumDXJx\"], \"routingKeys\": [], \"serviceEndpoint\": \"http://192.168.65.3:8020\"}]}\n" |
| 120 | + ] |
| 121 | + }, |
| 122 | + { |
| 123 | + "ename": "ClientResponseError", |
| 124 | + "evalue": "500, message='Internal Server Error', url=URL('http://bob-agent:8051/out-of-band/receive-invitation')", |
| 125 | + "output_type": "error", |
| 126 | + "traceback": [ |
| 127 | + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", |
| 128 | + "\u001b[0;31mClientResponseError\u001b[0m Traceback (most recent call last)", |
| 129 | + "\u001b[0;32m<ipython-input-14-31dc93f5c43e>\u001b[0m in \u001b[0;36masync-def-wrapper\u001b[0;34m()\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mjson\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdumps\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0moob_invite_accept\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", |
| 130 | + "\u001b[0;32m/aries_basic_controller/controllers/oob.py\u001b[0m in \u001b[0;36mreceive_invitation\u001b[0;34m(self, data)\u001b[0m\n\u001b[1;32m 19\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 20\u001b[0m \u001b[0;32masync\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0mreceive_invitation\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mdata\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 21\u001b[0;31m \u001b[0mresponse\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;32mawait\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0madmin_POST\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34mf\"/out-of-band/receive-invitation\"\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mdata\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mdata\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 22\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mresponse\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", |
| 131 | + "\u001b[0;32m/aries_basic_controller/controllers/base.py\u001b[0m in \u001b[0;36madmin_POST\u001b[0;34m(self, path, json_data, text, params, data)\u001b[0m\n\u001b[1;32m 94\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0;34m\" with data: \\n{}\"\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mformat\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mrepr_json\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mjson_data\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mjson_data\u001b[0m \u001b[0;32melse\u001b[0m \u001b[0;34m\"\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 95\u001b[0m )\n\u001b[0;32m---> 96\u001b[0;31m \u001b[0mresponse\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;32mawait\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0madmin_request\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"POST\"\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mpath\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mjson_data\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mtext\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mparams\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mdata\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 97\u001b[0m EVENT_LOGGER.debug(\n\u001b[1;32m 98\u001b[0m \u001b[0;34m\"Response from POST %s received: \\n%s\"\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mpath\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mrepr_json\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mresponse\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", |
| 132 | + "\u001b[0;32m/aries_basic_controller/controllers/base.py\u001b[0m in \u001b[0;36madmin_request\u001b[0;34m(self, method, path, json_data, text, params, data)\u001b[0m\n\u001b[1;32m 61\u001b[0m \u001b[0mmethod\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0madmin_url\u001b[0m \u001b[0;34m+\u001b[0m \u001b[0mpath\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mjson\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mjson_data\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mparams\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mparams\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mdata\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mdata\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 62\u001b[0m ) as resp:\n\u001b[0;32m---> 63\u001b[0;31m \u001b[0mresp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mraise_for_status\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 64\u001b[0m \u001b[0mresp_text\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;32mawait\u001b[0m \u001b[0mresp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mtext\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 65\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0mresp_text\u001b[0m \u001b[0;32mand\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0mtext\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", |
| 133 | + "\u001b[0;32m/opt/conda/lib/python3.7/site-packages/aiohttp/client_reqrep.py\u001b[0m in \u001b[0;36mraise_for_status\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 944\u001b[0m \u001b[0mstatus\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mstatus\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 945\u001b[0m \u001b[0mmessage\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mreason\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 946\u001b[0;31m headers=self.headers)\n\u001b[0m\u001b[1;32m 947\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 948\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0m_cleanup_writer\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;34m->\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", |
| 134 | + "\u001b[0;31mClientResponseError\u001b[0m: 500, message='Internal Server Error', url=URL('http://bob-agent:8051/out-of-band/receive-invitation')" |
| 135 | + ] |
| 136 | + }, |
| 137 | + { |
| 138 | + "name": "stderr", |
| 139 | + "output_type": "stream", |
| 140 | + "text": [ |
| 141 | + "ERROR:asyncio:Task exception was never retrieved\n", |
| 142 | + "future: <Task finished coro=<run_in_terminal.<locals>.run() done, defined at /opt/conda/lib/python3.7/site-packages/prompt_toolkit/application/run_in_terminal.py:50> exception=UnsupportedOperation('fileno')>\n", |
| 143 | + "Traceback (most recent call last):\n", |
| 144 | + " File \"/opt/conda/lib/python3.7/site-packages/prompt_toolkit/application/run_in_terminal.py\", line 55, in run\n", |
| 145 | + " return func()\n", |
| 146 | + " File \"/aries_basic_controller/helpers/utils.py\", line 120, in <lambda>\n", |
| 147 | + " run_in_terminal(lambda: print_ext(*msg, color=color, **kwargs))\n", |
| 148 | + " File \"/aries_basic_controller/helpers/utils.py\", line 103, in print_ext\n", |
| 149 | + " print_formatted(FormattedText(msg), **kwargs)\n", |
| 150 | + " File \"/aries_basic_controller/helpers/utils.py\", line 83, in print_formatted\n", |
| 151 | + " prompt_toolkit.print_formatted_text(*args, **kwargs)\n", |
| 152 | + " File \"/opt/conda/lib/python3.7/site-packages/prompt_toolkit/shortcuts/utils.py\", line 112, in print_formatted_text\n", |
| 153 | + " output = get_app_session().output\n", |
| 154 | + " File \"/opt/conda/lib/python3.7/site-packages/prompt_toolkit/application/current.py\", line 70, in output\n", |
| 155 | + " self._output = create_output()\n", |
| 156 | + " File \"/opt/conda/lib/python3.7/site-packages/prompt_toolkit/output/defaults.py\", line 75, in create_output\n", |
| 157 | + " stdout, term=term_from_env, default_color_depth=color_depth_from_env\n", |
| 158 | + " File \"/opt/conda/lib/python3.7/site-packages/prompt_toolkit/output/vt100.py\", line 458, in from_pty\n", |
| 159 | + " fd = stdout.fileno()\n", |
| 160 | + "io.UnsupportedOperation: fileno\n" |
| 161 | + ] |
| 162 | + } |
| 163 | + ], |
| 164 | + "source": [ |
| 165 | + "# Accept an out of band Invitation\n", |
| 166 | + "print(oob_invite_message)\n", |
| 167 | + "oob_invite_accept = await bob_agent_controller.oob.receive_invitation(oob_invite_message)\n", |
| 168 | + "print(json.dumps(oob_invite_accept))" |
121 | 169 | ]
|
122 | 170 | },
|
123 | 171 | {
|
|
0 commit comments