|
1 | 1 | {
|
2 | 2 | "cells": [
|
3 | 3 | {
|
4 |
| - "cell_type": "code", |
5 |
| - "execution_count": null, |
| 4 | + "cell_type": "markdown", |
6 | 5 | "metadata": {},
|
7 |
| - "outputs": [], |
8 | 6 | "source": [
|
9 |
| - "%autoawait\n", |
10 |
| - "import time\n", |
11 |
| - "import asyncio" |
| 7 | + "# Out of Band Protocol - Sender\n", |
| 8 | + "\n", |
| 9 | + "The out of band protocol allows agents to exchange messages without requiring a DIDComm channel. This can be used to establish a connection, request a presentation or issue a credential. \n", |
| 10 | + "\n", |
| 11 | + "The RFC is described [here](https://github.com/hyperledger/aries-rfcs/tree/master/features/0434-outofband)\n", |
| 12 | + "\n" |
| 13 | + ] |
| 14 | + }, |
| 15 | + { |
| 16 | + "cell_type": "markdown", |
| 17 | + "metadata": {}, |
| 18 | + "source": [ |
| 19 | + "## 1. Initialise the Controller" |
12 | 20 | ]
|
13 | 21 | },
|
14 | 22 | {
|
15 | 23 | "cell_type": "code",
|
16 |
| - "execution_count": null, |
| 24 | + "execution_count": 2, |
17 | 25 | "metadata": {},
|
18 | 26 | "outputs": [],
|
19 | 27 | "source": [
|
| 28 | + "%autoawait\n", |
| 29 | + "import time\n", |
| 30 | + "import asyncio\n", |
| 31 | + "import json\n", |
20 | 32 | "from aries_basic_controller.aries_controller import AriesAgentController\n",
|
21 | 33 | " \n",
|
22 | 34 | "WEBHOOK_HOST = \"0.0.0.0\"\n",
|
|
34 | 46 | ]
|
35 | 47 | },
|
36 | 48 | {
|
37 |
| - "cell_type": "code", |
38 |
| - "execution_count": null, |
| 49 | + "cell_type": "markdown", |
39 | 50 | "metadata": {},
|
40 |
| - "outputs": [], |
41 | 51 | "source": [
|
42 |
| - "\n", |
43 |
| - "loop = asyncio.get_event_loop()\n", |
44 |
| - "loop.create_task(agent_controller.listen_webhooks())\n", |
45 |
| - "\n", |
46 |
| - "agent_controller.register_listeners([], defaults=True)" |
| 52 | + "## 2. Configure Listeners for Connection Webhooks" |
47 | 53 | ]
|
48 | 54 | },
|
49 | 55 | {
|
50 | 56 | "cell_type": "code",
|
51 |
| - "execution_count": null, |
| 57 | + "execution_count": 3, |
52 | 58 | "metadata": {},
|
53 | 59 | "outputs": [],
|
54 |
| - "source": [] |
| 60 | + "source": [ |
| 61 | + "loop = asyncio.get_event_loop()\n", |
| 62 | + "loop.create_task(agent_controller.listen_webhooks())\n", |
| 63 | + "\n", |
| 64 | + "def connections_handler(payload):\n", |
| 65 | + " print(\"Connection Webhook : \", payload)\n", |
| 66 | + " \n", |
| 67 | + "connections_listener = {\n", |
| 68 | + " \"topic\": \"connections\",\n", |
| 69 | + " \"handler\": connections_handler\n", |
| 70 | + "}\n", |
| 71 | + "\n", |
| 72 | + "\n", |
| 73 | + "agent_controller.register_listeners([connections_listener], defaults=True)" |
| 74 | + ] |
55 | 75 | },
|
56 | 76 | {
|
57 | 77 | "cell_type": "markdown",
|
58 | 78 | "metadata": {},
|
59 | 79 | "source": [
|
60 |
| - "## 4a. Use the controller to create an out of band connection invitation" |
| 80 | + "## 3. Create an out of band connection invitation" |
61 | 81 | ]
|
62 | 82 | },
|
63 | 83 | {
|
64 | 84 | "cell_type": "code",
|
65 |
| - "execution_count": null, |
| 85 | + "execution_count": 4, |
66 | 86 | "metadata": {},
|
67 |
| - "outputs": [], |
| 87 | + "outputs": [ |
| 88 | + { |
| 89 | + "name": "stdout", |
| 90 | + "output_type": "stream", |
| 91 | + "text": [ |
| 92 | + "{'@type': 'did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/out-of-band/1.0/invitation', '@id': '4a611f31-396a-4e94-bdfb-820d81bde452', 'request~attach': [], 'handshake_protocols': ['https://didcomm.org/connections/1.0/invitation', 'did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/connections/1.0/invitation'], 'label': 'Alice', 'service': [{'id': '#inline', 'type': 'did-communication', 'recipientKeys': ['did:key:z6MkuU5tbz5eQ5e5w2NCB1rHFWX5dbMvu8G1yoiY7M9Zd7cH'], 'routingKeys': [], 'serviceEndpoint': 'http://172.17.0.1:8020'}]}\n" |
| 93 | + ] |
| 94 | + } |
| 95 | + ], |
68 | 96 | "source": [
|
69 | 97 | "payload = {\n",
|
70 | 98 | " \"include_handshake\": True,\n",
|
71 | 99 | " \"use_public_did\": False\n",
|
72 | 100 | "}\n",
|
73 |
| - "print(json.dumps(payload))\n", |
74 | 101 | "\n",
|
75 | 102 | "# Create an out of band Invitation\n",
|
76 |
| - "oob_invite = await agent_controller.oob.create_invitation(json.dumps(payload))\n", |
77 |
| - "print(json.dumps(oob_invite))" |
| 103 | + "oob_invite = await agent_controller.oob.create_invitation(payload)\n", |
| 104 | + "print(oob_invite[\"invitation\"])" |
| 105 | + ] |
| 106 | + }, |
| 107 | + { |
| 108 | + "cell_type": "markdown", |
| 109 | + "metadata": {}, |
| 110 | + "source": [ |
| 111 | + "## 4. Copy Invitation Across to Bob's [Notebook](http://localhost:8889/notebooks/Part%208%20-%20Out%20of%20Band%20Protocol.ipynb)" |
| 112 | + ] |
| 113 | + }, |
| 114 | + { |
| 115 | + "cell_type": "markdown", |
| 116 | + "metadata": {}, |
| 117 | + "source": [ |
| 118 | + "## 10. Accept Connection Request for the OOB Connection" |
| 119 | + ] |
| 120 | + }, |
| 121 | + { |
| 122 | + "cell_type": "code", |
| 123 | + "execution_count": 8, |
| 124 | + "metadata": {}, |
| 125 | + "outputs": [ |
| 126 | + { |
| 127 | + "name": "stdout", |
| 128 | + "output_type": "stream", |
| 129 | + "text": [ |
| 130 | + "{'created_at': '2020-10-30 11:18:20.340874Z', 'invitation_id': '5765c0f0-0618-4164-a88f-cfc43824bb59', 'trace': False, 'updated_at': '2020-10-30 11:18:20.340874Z', 'state': 'initial', 'invitation': {'@type': 'did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/out-of-band/1.0/invitation', '@id': '4a611f31-396a-4e94-bdfb-820d81bde452', 'request~attach': [], 'handshake_protocols': ['https://didcomm.org/connections/1.0/invitation', 'did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/connections/1.0/invitation'], 'label': 'Alice', 'service': [{'id': '#inline', 'type': 'did-communication', 'recipientKeys': ['did:key:z6MkuU5tbz5eQ5e5w2NCB1rHFWX5dbMvu8G1yoiY7M9Zd7cH'], 'routingKeys': [], 'serviceEndpoint': 'http://172.17.0.1:8020'}]}}\n" |
| 131 | + ] |
| 132 | + } |
| 133 | + ], |
| 134 | + "source": [ |
| 135 | + "print(oob_invite)" |
78 | 136 | ]
|
| 137 | + }, |
| 138 | + { |
| 139 | + "cell_type": "code", |
| 140 | + "execution_count": 9, |
| 141 | + "metadata": {}, |
| 142 | + "outputs": [ |
| 143 | + { |
| 144 | + "data": { |
| 145 | + "text/plain": [ |
| 146 | + "{'results': [{'routing_state': 'none',\n", |
| 147 | + " 'accept': 'auto',\n", |
| 148 | + " 'invitation_mode': 'once',\n", |
| 149 | + " 'my_did': '4J8kyCXH4mHE7UW3E6oqyt',\n", |
| 150 | + " 'created_at': '2020-10-30 11:18:20.316265Z',\n", |
| 151 | + " 'connection_id': '1e539413-8da2-4e2d-94cf-2620015e3ed5',\n", |
| 152 | + " 'initiator': 'self',\n", |
| 153 | + " 'updated_at': '2020-10-30 11:19:27.696692Z',\n", |
| 154 | + " 'their_label': 'Bob',\n", |
| 155 | + " 'their_did': 'p79aZieUZCrLJgxM7Kvkc',\n", |
| 156 | + " 'invitation_key': 'G1pr1jqD4Y9cpXXVVStSQQy5p265VF1fHnocH5BYhtpu',\n", |
| 157 | + " 'state': 'response'}]}" |
| 158 | + ] |
| 159 | + }, |
| 160 | + "execution_count": 9, |
| 161 | + "metadata": {}, |
| 162 | + "output_type": "execute_result" |
| 163 | + } |
| 164 | + ], |
| 165 | + "source": [ |
| 166 | + "await agent_controller.connections.get_connections()" |
| 167 | + ] |
| 168 | + }, |
| 169 | + { |
| 170 | + "cell_type": "code", |
| 171 | + "execution_count": null, |
| 172 | + "metadata": {}, |
| 173 | + "outputs": [], |
| 174 | + "source": [] |
79 | 175 | }
|
80 | 176 | ],
|
81 | 177 | "metadata": {
|
|
0 commit comments