{"id":32306356,"url":"https://github.com/dimchat/dkd-dart","last_synced_at":"2026-02-20T09:31:47.451Z","repository":{"id":150730385,"uuid":"623033302","full_name":"dimchat/dkd-dart","owner":"dimchat","description":"Dao Ke Dao (道可道) -- Message Module (Dart)","archived":false,"fork":false,"pushed_at":"2026-01-02T20:34:00.000Z","size":165,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2026-01-09T10:23:07.928Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Dart","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":"CHANGELOG.md","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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-04-03T14:58:45.000Z","updated_at":"2026-01-02T20:34:05.000Z","dependencies_parsed_at":"2024-12-17T15:33:28.923Z","dependency_job_id":null,"html_url":"https://github.com/dimchat/dkd-dart","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/dimchat/dkd-dart","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dimchat%2Fdkd-dart","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dimchat%2Fdkd-dart/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dimchat%2Fdkd-dart/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dimchat%2Fdkd-dart/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dimchat","download_url":"https://codeload.github.com/dimchat/dkd-dart/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dimchat%2Fdkd-dart/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29647670,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-20T09:27:29.698Z","status":"ssl_error","status_checked_at":"2026-02-20T09:26:12.373Z","response_time":59,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: 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":"2025-10-23T07:02:12.358Z","updated_at":"2026-02-20T09:31:47.446Z","avatar_url":"https://github.com/dimchat.png","language":"Dart","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Dao Ke Dao (道可道) -- Message Module (Dart)\n\n[![License](https://img.shields.io/github/license/dimchat/dkd-dart)](https://github.com/dimchat/dkd-dart/blob/main/LICENSE)\n[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/dimchat/dkd-dart/pulls)\n[![Platform](https://img.shields.io/badge/Platform-Dart%203-brightgreen.svg)](https://github.com/dimchat/dkd-dart/wiki)\n[![Issues](https://img.shields.io/github/issues/dimchat/dkd-dart)](https://github.com/dimchat/dkd-dart/issues)\n[![Repo Size](https://img.shields.io/github/repo-size/dimchat/dkd-dart)](https://github.com/dimchat/dkd-dart/archive/refs/heads/main.zip)\n[![Tags](https://img.shields.io/github/tag/dimchat/dkd-dart)](https://github.com/dimchat/dkd-dart/tags)\n[![Version](https://img.shields.io/pub/v/dkd)](https://pub.dev/packages/dkd)\n\n[![Watchers](https://img.shields.io/github/watchers/dimchat/dkd-dart)](https://github.com/dimchat/dkd-dart/watchers)\n[![Forks](https://img.shields.io/github/forks/dimchat/dkd-dart)](https://github.com/dimchat/dkd-dart/forks)\n[![Stars](https://img.shields.io/github/stars/dimchat/dkd-dart)](https://github.com/dimchat/dkd-dart/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\"     : \"1\",       // message type\n    \"sn\"       : 412968873, // serial number (message ID in conversation)\n    \n    \"text\"     : \"Hey guy!\"\n}\n```\n\n### Content Type\n\n```dart\nclass ContentType {\n\n  static const ANY       = '${0x00}'; // 0000 0000 (Undefined)\n\n  static const TEXT      = '${0x01}'; // 0000 0001\n\n  static const FILE      = '${0x10}'; // 0001 0000\n  static const IMAGE     = '${0x12}'; // 0001 0010\n  static const AUDIO     = '${0x14}'; // 0001 0100\n  static const VIDEO     = '${0x16}'; // 0001 0110\n\n  /// Web Page\n  static const PAGE      = '${0x20}'; // 0010 0000\n\n  /// Name Card\n  static const NAME_CARD = '${0x33}'; // 0011 0011\n\n  /// Quote a message before and reply it with text\n  static const QUOTE     = '${0x37}'; // 0011 0111\n\n  static const MONEY         = '${0x40}'; // 0100 0000\n  static const TRANSFER      = '${0x41}'; // 0100 0001\n  static const LUCKY_MONEY   = '${0x42}'; // 0100 0010\n  static const CLAIM_PAYMENT = '${0x48}'; // 0100 1000 (Claim for Payment)\n  static const SPLIT_BILL    = '${0x49}'; // 0100 1001 (Split the Bill)\n\n  static const COMMAND       = '${0x88}'; // 1000 1000\n  static const HISTORY       = '${0x89}'; // 1000 1001 (Entity History Command)\n\n  /// Application Customized\n  static const APPLICATION       = '${0xA0}'; // 1010 0000 (Application 0nly, Reserved)\n  // static const APPLICATION_1  = '${0xA1}'; // 1010 0001 (Reserved)\n  //              ...                         // 1010 ???? (Reserved)\n  // static const APPLICATION_15 = '${0xAF}'; // 1010 1111 (Reserved)\n\n  // static const CUSTOMIZED_0   = '${0xC0}'; // 1100 0000 (Reserved)\n  // static const CUSTOMIZED_1   = '${0xC1}'; // 1100 0001 (Reserved)\n  //           ......                         // 1100 ???? (Reserved)\n  static const ARRAY             = '${0xCA}'; // 1100 1010 (Content Array)\n  //           ...                            // 1100 ???? (Reserved)\n  static const CUSTOMIZED        = '${0xCC}'; // 1100 1100 (Customized Content)\n  //           ...                            // 1100 ???? (Reserved)\n  static const COMBINE_FORWARD   = '${0xCF}'; // 1100 1111 (Combine and Forward)\n\n  /// Top-Secret message forward by proxy (MTA)\n  static const FORWARD           = '${0xFF}'; // 1111 1111\n\n}\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```\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### 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\" : \"1\",       // 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; 2023-2026 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-dart","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdimchat%2Fdkd-dart","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdimchat%2Fdkd-dart/lists"}