{"id":38054127,"url":"https://github.com/dimchat/dkd-py","last_synced_at":"2026-01-20T17:34:31.806Z","repository":{"id":49765724,"uuid":"165545518","full_name":"dimchat/dkd-py","owner":"dimchat","description":"Dao Ke Dao (道可道) -- Message Module","archived":false,"fork":false,"pushed_at":"2025-09-22T21:06:28.000Z","size":384,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-12-12T15:55:38.322Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dimchat.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2019-01-13T19:30:26.000Z","updated_at":"2025-09-22T21:06:31.000Z","dependencies_parsed_at":"2025-07-21T16:13:58.155Z","dependency_job_id":"bd078f26-744a-4f1c-8f79-99566253a11e","html_url":"https://github.com/dimchat/dkd-py","commit_stats":{"total_commits":93,"total_committers":1,"mean_commits":93.0,"dds":0.0,"last_synced_commit":"a03c78b38e942b8d1539853b46417b4366c104f5"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/dimchat/dkd-py","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dimchat%2Fdkd-py","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dimchat%2Fdkd-py/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dimchat%2Fdkd-py/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dimchat%2Fdkd-py/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dimchat","download_url":"https://codeload.github.com/dimchat/dkd-py/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dimchat%2Fdkd-py/sbom","scorecard":{"id":343255,"data":{"date":"2025-08-11","repo":{"name":"github.com/dimchat/dkd-py","commit":"1485287ff91337bb035d45649fa384937b86ceea"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.6,"checks":[{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Maintained","score":4,"reason":"5 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 4","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}}]},"last_synced_at":"2025-08-18T06:28:27.260Z","repository_id":49765724,"created_at":"2025-08-18T06:28:27.260Z","updated_at":"2025-08-18T06:28:27.260Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28482267,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-16T11:59:17.896Z","status":"ssl_error","status_checked_at":"2026-01-16T11:55:55.838Z","response_time":107,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":[],"created_at":"2026-01-16T20:21:34.015Z","updated_at":"2026-01-16T20:21:39.463Z","avatar_url":"https://github.com/dimchat.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Dao Ke Dao (道可道) -- Message Module (Python)\n\n[![License](https://img.shields.io/github/license/dimchat/dkd-py)](https://github.com/dimchat/dkd-py/blob/master/LICENSE)\n[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/dimchat/dkd-py/pulls)\n[![Platform](https://img.shields.io/badge/Platform-Python%203-brightgreen.svg)](https://github.com/dimchat/dkd-py/wiki)\n[![Issues](https://img.shields.io/github/issues/dimchat/dkd-py)](https://github.com/dimchat/dkd-py/issues)\n[![Repo Size](https://img.shields.io/github/repo-size/dimchat/dkd-py)](https://github.com/dimchat/dkd-py/archive/refs/heads/master.zip)\n[![Tags](https://img.shields.io/github/tag/dimchat/dkd-py)](https://github.com/dimchat/dkd-py/tags)\n[![Version](https://img.shields.io/pypi/v/dkd)](https://pypi.org/project/dkd)\n\n[![Watchers](https://img.shields.io/github/watchers/dimchat/dkd-py)](https://github.com/dimchat/dkd-py/watchers)\n[![Forks](https://img.shields.io/github/forks/dimchat/dkd-py)](https://github.com/dimchat/dkd-py/forks)\n[![Stars](https://img.shields.io/github/stars/dimchat/dkd-py)](https://github.com/dimchat/dkd-py/stargazers)\n[![Followers](https://img.shields.io/github/followers/dimchat)](https://github.com/orgs/dimchat/followers)\n\nThis [document](https://github.com/moky/DIMP/blob/master/DaoKeDao-Message.md) introduces a common **Message Module** for decentralized instant messaging.\n\n## Features\n\n- [Envelope](#envelope)\n    - Sender\n    - Receiver\n    - Time (same value from content.time)\n- [Content](#content)\n    - [Type](#content-type)\n    - Serial Number\n    - Time\n    - Group _(Optional)_\n- [Message](#message)\n    - [Instant Message](#instant-message)\n    - [Secure Message](#secure-message)\n    - [Reliable Message](#reliable-message)\n\n## Envelope\n\n### Message Envelope\n\n```javascript\n/* example */\n{\n    \"sender\"   : \"moki@4WDfe3zZ4T7opFSi3iDAKiuTnUHjxmXekk\",\n    \"receiver\" : \"hulk@4YeVEN3aUnvC1DNUufCq1bs9zoBSJTzVEj\",\n    \"time\"     : 1545405083\n}\n```\n\n## Content\n\n```javascript\n/* example */\n{\n    \"type\"     : 0x01,      // message type\n    \"sn\"       : 412968873, // serial number (message ID in conversation)\n    \n    \"text\"     : \"Hey guy!\"\n}\n```\n\n### Content Type\n\n```python\nclass ContentType(IntEnum):\n\n    ANY = 0x00        # 0000 0000 (Undefined)\n\n    TEXT = 0x01       # 0000 0001\n\n    FILE = 0x10       # 0001 0000\n    IMAGE = 0x12      # 0001 0010\n    AUDIO = 0x14      # 0001 0100\n    VIDEO = 0x16      # 0001 0110\n\n    # Web Page\n    PAGE = 0x20       # 0010 0000\n\n    # Name Card\n    NAME_CARD = 0x33  # 0011 0011\n\n    # Quote a message before and reply it with text\n    QUOTE = 0x37      # 0011 0111\n\n    # Money\n    MONEY = 0x40          # 0100 0000\n    TRANSFER = 0x41       # 0100 0001\n    LUCKY_MONEY = 0x42    # 0100 0010\n    CLAIM_PAYMENT = 0x48  # 0100 1000 (Claim for Payment)\n    SPLIT_BILL = 0x49     # 0100 1001 (Split the Bill)\n\n    # Command\n    COMMAND = 0x88        # 1000 1000\n    HISTORY = 0x89        # 1000 1001 (Entity History Command)\n\n    # Application Customized\n    APPLICATION = 0xA0       # 1010 0000 (Application 0nly, Reserved)\n    # APPLICATION_1 = 0xA1   # 1010 0001 (Reserved)\n    # ...                    # 1010 ???? (Reserved)\n    # APPLICATION_15 = 0xAF  # 1010 1111 (Reserved)\n\n    # CUSTOMIZED_0 = 0xC0    # 1100 0000 (Reserved)\n    # CUSTOMIZED_1 = 0xC1    # 1100 0001 (Reserved)\n    # ...                    # 1100 ???? (Reserved)\n    ARRAY = 0xCA             # 1100 1010 (Content Array)\n    # ...                    # 1100 ???? (Reserved)\n    CUSTOMIZED = 0xCC        # 1100 1100 (Customized Content)\n    # ...                    # 1100 ???? (Reserved)\n    COMBINE_FORWARD = 0xCF   # 1100 1111 (Combine and Forward)\n\n    # Top-Secret message forward by proxy (MTA)\n    FORWARD = 0xFF           # 1111 1111\n```\n\n## Message\n\nWhen the user want to send out a message, the client needs TWO steps before sending it:\n\n1. Encrypt the ```Instant Message``` to ```Secure Message```;\n2. Sign the ```Secure Message``` to ```Reliable Message```.\n\nAccordingly, when the client received a message, it needs TWO steps to extract the content:\n\n1. Verify the ```Reliable Message``` to ```Secure Message```;\n2. Decrypt the ```Secure Message``` to ```Instant Message```.\n\n```javascript\n    Message Transforming\n    ~~~~~~~~~~~~~~~~~~~~\n\n    Instant Message  \u003c--\u003e  Secure Message  \u003c--\u003e  Reliable Message\n    +-------------+        +------------+        +--------------+\n    |  sender     |        |  sender    |        |  sender      |\n    |  receiver   |        |  receiver  |        |  receiver    |\n    |  time       |        |  time      |        |  time        |\n    |             |        |            |        |              |\n    |  content    |        |  data      |        |  data        |\n    +-------------+        |  key/keys  |        |  key/keys    |\n                           +------------+        |  signature   |\n                                                 +--------------+\n    Algorithm:\n        data      = password.encrypt(content)\n        key       = receiver.public_key.encrypt(password)\n        signature = sender.private_key.sign(data)\n\n```\n\n### Instant Message\n\n```javascript\n/* example */\n{\n    //-------- head (envelope) --------\n    \"sender\"   : \"moki@4WDfe3zZ4T7opFSi3iDAKiuTnUHjxmXekk\",\n    \"receiver\" : \"hulk@4YeVEN3aUnvC1DNUufCq1bs9zoBSJTzVEj\",\n    \"time\"     : 1545405083,\n    \n    //-------- body (content) ---------\n    \"content\"  : {\n        \"type\" : 0x01,      // message type\n        \"sn\"   : 412968873, // serial number (ID)\n        \"text\" : \"Hey guy!\"\n    }\n}\n```\n\ncontent -\u003e JsON string: ```{\"sn\":412968873,\"text\":\"Hey guy!\",\"type\":1}```\n\n### Secure Message\n\n```javascript\n/**\n *  Algorithm:\n *      string = json(content);\n *      PW     = random();\n *      data   = encrpyt(string, PW);      // Symmetric\n *      key    = encrypt(PW, receiver.PK); // Asymmetric\n */\n{\n    //-------- head (envelope) --------\n    \"sender\"   : \"moki@4WDfe3zZ4T7opFSi3iDAKiuTnUHjxmXekk\",\n    \"receiver\" : \"hulk@4YeVEN3aUnvC1DNUufCq1bs9zoBSJTzVEj\",\n    \"time\"     : 1545405083,\n    \n    //-------- body (content) ---------\n    \"data\"     : \"9cjCKG99ULCCxbL2mkc/MgF1saeRqJaCc+S12+HCqmsuF7TWK61EwTQWZSKskUeF\",\n    \"key\"      : \"WH/wAcu+HfpaLq+vRblNnYufkyjTm4FgYyzW3wBDeRtXs1TeDmRxKVu7nQI/sdIALGLXrY+O5mlRfhU8f8TuIBilZUlX/eIUpL4uSDYKVLaRG9pOcrCHKevjUpId9x/8KBEiMIL5LB0Vo7sKrvrqosCnIgNfHbXMKvMzwcqZEU8=\"\n}\n```\n\n### Reliable Message\n\n```javascript\n/**\n *  Algorithm:\n *      signature = sign(data, sender.SK);\n */\n{\n    //-------- head (envelope) --------\n    \"sender\"   : \"moki@4WDfe3zZ4T7opFSi3iDAKiuTnUHjxmXekk\",\n    \"receiver\" : \"hulk@4YeVEN3aUnvC1DNUufCq1bs9zoBSJTzVEj\",\n    \"time\"     : 1545405083,\n    \n    //-------- body (content) ---------\n    \"data\"      : \"9cjCKG99ULCCxbL2mkc/MgF1saeRqJaCc+S12+HCqmsuF7TWK61EwTQWZSKskUeF\",\n    \"key\"       : \"WH/wAcu+HfpaLq+vRblNnYufkyjTm4FgYyzW3wBDeRtXs1TeDmRxKVu7nQI/sdIALGLXrY+O5mlRfhU8f8TuIBilZUlX/eIUpL4uSDYKVLaRG9pOcrCHKevjUpId9x/8KBEiMIL5LB0Vo7sKrvrqosCnIgNfHbXMKvMzwcqZEU8=\",\n    \"signature\" : \"Yo+hchWsQlWHtc8iMGS7jpn/i9pOLNq0E3dTNsx80QdBboTLeKoJYAg/lI+kZL+g7oWJYpD4qKemOwzI+9pxdMuZmPycG+0/VM3HVSMcguEOqOH9SElp/fYVnm4aSjAJk2vBpARzMT0aRNp/jTFLawmMDuIlgWhBfXvH7bT7rDI=\"\n}\n```\n\n(All data encode with **BASE64** algorithm as default)\n\n----\n\nCopyright \u0026copy; 2018-2025 Albert Moky\n[![Followers](https://img.shields.io/github/followers/moky)](https://github.com/moky?tab=followers)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdimchat%2Fdkd-py","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdimchat%2Fdkd-py","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdimchat%2Fdkd-py/lists"}