{"id":19901941,"url":"https://github.com/hyperledger-aries/aries-staticagent-python","last_synced_at":"2025-05-02T23:32:06.701Z","repository":{"id":34943815,"uuid":"192852366","full_name":"hyperledger/aries-staticagent-python","owner":"hyperledger","description":"Aries Static Agent library for Python","archived":false,"fork":false,"pushed_at":"2023-06-09T19:55:27.000Z","size":469,"stargazers_count":20,"open_issues_count":6,"forks_count":17,"subscribers_count":10,"default_branch":"main","last_synced_at":"2024-04-24T01:22:37.844Z","etag":null,"topics":["hacktoberfest","python"],"latest_commit_sha":null,"homepage":"https://wiki.hyperledger.org/display/aries","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hyperledger.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-06-20T05:09:22.000Z","updated_at":"2024-08-13T21:48:23.275Z","dependencies_parsed_at":"2024-08-15T09:03:36.344Z","dependency_job_id":null,"html_url":"https://github.com/hyperledger/aries-staticagent-python","commit_stats":{"total_commits":234,"total_committers":7,"mean_commits":33.42857142857143,"dds":"0.43162393162393164","last_synced_commit":"ecc65515d49b35c0d3f454fa01935b17460311cd"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyperledger%2Faries-staticagent-python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyperledger%2Faries-staticagent-python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyperledger%2Faries-staticagent-python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyperledger%2Faries-staticagent-python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hyperledger","download_url":"https://codeload.github.com/hyperledger/aries-staticagent-python/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224341304,"owners_count":17295272,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hacktoberfest","python"],"created_at":"2024-11-12T20:16:41.585Z","updated_at":"2025-05-02T23:32:04.710Z","avatar_url":"https://github.com/hyperledger.png","language":"Python","readme":"# DEPRECATED Static Agent Library\n\n## Deprecation Notice\n\nThis library is deprecated. The Aries and DIDComm community are pursing support for DIDComm v2, which this library does not support. Much of how we think about DIDComm connections and how to manage those connections has evolved since this library was in use. It is therefore recommended to seek out other libraries.\n\nOne such library can be found here: https://github.com/Indicio-tech/didcomm-messaging-python\n\nThe didcomm-messaging-python library is focused on DIDComm v2 but contains an updated version of the `crypto` module of this library, providing the core pack and unpack operations for DIDComm v1. It also contains more complete interfaces for building out a more complete DIDComm v1 agent. These interfaces may be deprecated in the future as DIDComm v2 is adopted.\n\n# Static Agent Library\n\nThis repo contains an example Aries Static Agent Library in Python.\n\nA static agent is a form of agent that can speak DIDComm at a basic level but its keys and\nconnections are configured statically. Static Agents have a direct relationship with a single full\nagent. Static Agents do not have a wallet.\n\nExamples of static agents may include:\n- Remote administration interface for an agent\n- IoT devices\n- [Relays][1]\n- OpenAPI to DIDComm translator\n\nA static agent's configuration minimally consists of:\n- Its own public and private key\n- The public key of its full agent counterpart\n- The endpoint of its full agent counterpart\n\n_**It is up to you to secure your static agent's configuration.**_ The examples included in this\nrepository use command line arguments or environment variables to configure the agent for simplicity\nand demonstration purposes only. _**This is not recommended for production environments.**_\n\nThis library makes as few assumptions about it's running environment as possible. This includes\nfew dependencies, assumptions about web frameworks, etc.\n\n[1]: https://github.com/hyperledger/aries-rfcs/tree/master/concepts/0046-mediators-and-relays#summary\n\n## Quick Start Guide\n\n### Requirements\n\n- Python 3.6 or higher\n\n### Running the included examples\n\nYou will need to pair the static agent with a full agent capable of basic DIDComm to complete the\nexamples. The [Indy Python Reference Agent][3] can be used as the full agent for these examples.\n\nCreate and activate python virtual environment:\n```sh\n$ python3 -m venv env\n$ source env/bin/activate\n```\n\nInstall dependencies and the library into the virtual environment:\n```sh\n$ pip install -e .\n```\n\n\u003e If you want to run the included tests, install the `test` feature with pip:\n\u003e `pip install -e .[test]`\n\nExecute `keygen()`:\n```sh\n$ python -c \"import aries_staticagent; aries_staticagent.keygen()\"\n\nFor full agent:\n        DID: \u003cBase58 encoded DID\u003e\n        VK: \u003cBase58 encoded verkey\u003e\n\nFor static agent:\n        VK: \u003cthe same Base58 encoded verkey\u003e\n        SK: \u003cBase58 encoded sigkey\u003e\n```\n\nAs the output implies, the first section is intended to be entered in on the full agent to configure\na static connection. The second section is used to configure the static agent. The `verkey` (VK) in\nthe first and second section are the _same_ key, representing the key the static agent will use\nfor the connection. The `keygen` script does _not_ generate the keys that the full agent will use.\n\nIf using the [Indy Python Reference Agent][3], open the web interface and\nclick `Add Static Connection`. Enter the information output by `keygen.py` and a label of your\nchoice. The endpoint of the static agent is optional and must match the hostname and port you\nconfigure for the static agent if running the web server example. After clicking `Add`, a new\ndialogue window will open with the information needed to now start up the static agent.\n\nIf you are using another agent that supports configuring a static connection, follow the\ninstructions provided by that agent.\n\nStart the static agent (in this case, `exapmles/cron.py`):\n```sh\n$ python examples/cron.py --endpoint \u003cthe endpoint of the full agent\u003e \\\n$ --endpointkey \u003cthe verkey output by the full agent\u003e \\\n$ --mypublickey \u003cthe verkey output by keygen.py\u003e \\\n$ --myprivatekey \u003cthe sigkey output by keygen.py\u003e\n```\n\nIn the full agent's BasicMessages, you should now see a message sent from the static agent script.\n\n\u003e TODO: Include screencast of running the example with the Indy Python Reference Agent\n\n[2]: https://download.libsodium.org/doc/installation\n[3]: https://github.com/hyperledger/indy-agent/tree/master/python\n\n## Using the library\n\nRefer to the `examples` directory for complete working examples of using this library.\n\n### Setting up a Static Agent Connection\n\n```python\nfrom aries_staticagent import Connection\n\n# endpoint, endpointkey, mypublickey, myprivatekey key are obtained through some form of static\n# configuration\n\nconn = Connection((mypublickey, myprivatekey), their_vk=endpointkey, endpoint=endpoint)\n```\n\nThis will open a static connection with the full agent reachable at `endpoint` and messages packed\nfor `endpointkey`.\n\n### Sending a message to the Full Agent\n\nWith the static agent connection `a`, to send messages to the full agent:\n\n```python\nconn.send({\n    \"@type\": \"https://didcomm.org/basicmessage/1.0/message\",\n    \"~l10n\": {\"locale\": \"en\"},\n    \"sent_time\": utils.timestamp(),\n    \"content\": \"The Cron Script has been executed.\"\n})\n```\n\nAn asynchronous method is also provided:\n```python\nawait conn.send_async({\n    \"@type\": \"https://didcomm.org/basicmessage/1.0/message\",\n    \"~l10n\": {\"locale\": \"en\"},\n    \"sent_time\": utils.timestamp(),\n    \"content\": \"The Cron Script has been executed.\"\n})\n```\n\n### Receiving messages from the Full Agent\n\nTransport mechanisms are completely decoupled from the Static Agent Library. This is intended to\nallow library consumers to choose which transport is appropriate for their use case. The\n`examples/webserver_aiohttp.py` example shows how one might use the `aiohttp` library as an inbound\ntransport mechanism for the static agent:\n\n```python\nfrom aiohttp import web\nfrom aries_staticagent import Connection, utils\n\n# ... Configuration omitted\n\n# Create static agent connection\nconn = Connection((args.mypublickey, args.myprivatekey), their_vk=args.endpointkey, endpoint=args.endpoint)\n\n# Register a handler for the basicmessage/1.0/message message type\n@conn.route(\"https://didcomm.org/basicmessage/1.0/message\")\nasync def basic_message(msg, conn):\n    # Respond to the received basic message by sending another basic message back\n    await conn.send_async({\n        \"@type\": \"https://didcomm.org/basicmessage/1.0/message\",\n        \"~l10n\": {\"locale\": \"en\"},\n        \"sent_time\": utils.timestamp(),\n        \"content\": \"You said: {}\".format(msg['content'])\n    })\n\n\n# aiohttp request handler\nasync def handle(request):\n    # Read request body and pass to Connection.handle\n    await conn.handle(await request.read())\n    raise web.HTTPAccepted()\n\n# Register aiohttp request handler\napp = web.Application()\napp.add_routes([web.post('/', handle)])\n\n# Start the web server\nweb.run_app(app, port=args.port)\n```\n\nAs seen in this example, registering a handler for a DIDComm message is done using the\n`@conn.route('\u003cmessage_type\u003e')` decorator. Passing raw, unpackaged messages to the static agent\nconnection over the decoupled transport mechanism is done by calling `conn.handle(\u003craw message\u003e)`.\n\nStatic agents can only unpack messages sent by the full agent.\n\n## License\n\n[Apache License Version 2.0](https://github.com/hyperledger/aries-staticagent-python/blob/main/LICENSE)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhyperledger-aries%2Faries-staticagent-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhyperledger-aries%2Faries-staticagent-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhyperledger-aries%2Faries-staticagent-python/lists"}