dimp 2.3.3__tar.gz → 2.3.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. {dimp-2.3.3 → dimp-2.3.4}/PKG-INFO +12 -58
  2. {dimp-2.3.3 → dimp-2.3.4}/README.md +11 -57
  3. {dimp-2.3.3 → dimp-2.3.4}/dimp/__init__.py +6 -8
  4. {dimp-2.3.3 → dimp-2.3.4}/dimp/crypto/__init__.py +4 -4
  5. {dimp-2.3.3 → dimp-2.3.4}/dimp/crypto/keys.py +11 -11
  6. {dimp-2.3.3 → dimp-2.3.4}/dimp/crypto/pnf.py +1 -1
  7. {dimp-2.3.3 → dimp-2.3.4}/dimp/dkd/__init__.py +7 -7
  8. {dimp-2.3.3/dimp/plugins → dimp-2.3.4/dimp/ext}/__init__.py +2 -2
  9. {dimp-2.3.3 → dimp-2.3.4}/dimp/mkm/meta.py +1 -1
  10. {dimp-2.3.3 → dimp-2.3.4}/dimp/msg/envelope.py +4 -4
  11. {dimp-2.3.3 → dimp-2.3.4}/dimp/protocol/__init__.py +4 -4
  12. dimp-2.3.3/dimp/protocol/customized.py → dimp-2.3.4/dimp/protocol/app.py +28 -6
  13. {dimp-2.3.3 → dimp-2.3.4}/dimp/protocol/base.py +1 -1
  14. {dimp-2.3.3 → dimp-2.3.4}/dimp/protocol/commands.py +1 -4
  15. {dimp-2.3.3 → dimp-2.3.4}/dimp/protocol/contents.py +1 -4
  16. {dimp-2.3.3 → dimp-2.3.4}/dimp/protocol/groups.py +3 -35
  17. {dimp-2.3.3 → dimp-2.3.4}/dimp.egg-info/PKG-INFO +12 -58
  18. {dimp-2.3.3 → dimp-2.3.4}/dimp.egg-info/SOURCES.txt +3 -3
  19. dimp-2.3.4/dimp.egg-info/requires.txt +2 -0
  20. {dimp-2.3.3 → dimp-2.3.4}/setup.py +3 -3
  21. dimp-2.3.3/dimp.egg-info/requires.txt +0 -2
  22. {dimp-2.3.3 → dimp-2.3.4}/LICENSE +0 -0
  23. {dimp-2.3.3 → dimp-2.3.4}/dimp/crypto/algorithms.py +0 -0
  24. {dimp-2.3.3 → dimp-2.3.4}/dimp/crypto/ted.py +0 -0
  25. {dimp-2.3.3 → dimp-2.3.4}/dimp/mkm/__init__.py +0 -0
  26. {dimp-2.3.3 → dimp-2.3.4}/dimp/mkm/docs.py +0 -0
  27. {dimp-2.3.3 → dimp-2.3.4}/dimp/mkm/document.py +0 -0
  28. {dimp-2.3.3 → dimp-2.3.4}/dimp/msg/__init__.py +0 -0
  29. {dimp-2.3.3 → dimp-2.3.4}/dimp/msg/base.py +0 -0
  30. {dimp-2.3.3 → dimp-2.3.4}/dimp/msg/instant.py +0 -0
  31. {dimp-2.3.3 → dimp-2.3.4}/dimp/msg/reliable.py +0 -0
  32. {dimp-2.3.3 → dimp-2.3.4}/dimp/msg/secure.py +0 -0
  33. /dimp-2.3.3/dimp/protocol/money.py → /dimp-2.3.4/dimp/protocol/assets.py +0 -0
  34. {dimp-2.3.3 → dimp-2.3.4}/dimp/protocol/docs.py +0 -0
  35. {dimp-2.3.3 → dimp-2.3.4}/dimp/protocol/files.py +0 -0
  36. {dimp-2.3.3 → dimp-2.3.4}/dimp/protocol/forward.py +0 -0
  37. {dimp-2.3.3 → dimp-2.3.4}/dimp/protocol/helpers.py +0 -0
  38. {dimp-2.3.3 → dimp-2.3.4}/dimp/protocol/quote.py +0 -0
  39. {dimp-2.3.3 → dimp-2.3.4}/dimp/protocol/receipt.py +0 -0
  40. {dimp-2.3.3 → dimp-2.3.4}/dimp/protocol/types.py +0 -0
  41. {dimp-2.3.3 → dimp-2.3.4}/dimp.egg-info/dependency_links.txt +0 -0
  42. {dimp-2.3.3 → dimp-2.3.4}/dimp.egg-info/top_level.txt +0 -0
  43. {dimp-2.3.3 → dimp-2.3.4}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: dimp
3
- Version: 2.3.3
3
+ Version: 2.3.4
4
4
  Summary: Decentralized Instant Messaging Protocol
5
5
  Home-page: https://github.com/dimchat/core-py
6
6
  Author: Albert Moky
@@ -18,7 +18,7 @@ License-File: LICENSE
18
18
  [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/dimchat/core-py/pulls)
19
19
  [![Platform](https://img.shields.io/badge/Platform-Python%203-brightgreen.svg)](https://github.com/dimchat/core-py/wiki)
20
20
  [![Issues](https://img.shields.io/github/issues/dimchat/core-py)](https://github.com/dimchat/core-py/issues)
21
- [![Repo Size](https://img.shields.io/github/repo-size/dimchat/core-py)](https://github.com/dimchat/core-py/archive/refs/heads/main.zip)
21
+ [![Repo Size](https://img.shields.io/github/repo-size/dimchat/core-py)](https://github.com/dimchat/core-py/archive/refs/heads/master.zip)
22
22
  [![Tags](https://img.shields.io/github/tag/dimchat/core-py)](https://github.com/dimchat/core-py/tags)
23
23
  [![Version](https://img.shields.io/pypi/v/dimp)](https://pypi.org/project/dimp)
24
24
 
@@ -36,7 +36,7 @@ License-File: LICENSE
36
36
 
37
37
  ## Examples
38
38
 
39
- ### extends Command
39
+ ### Extends Command
40
40
 
41
41
  * _Handshake Command Protocol_
42
42
  0. (C-S) handshake start
@@ -172,94 +172,48 @@ class BaseHandshakeCommand(BaseCommand, HandshakeCommand):
172
172
  return handshake_state(title=self.title, session=self.session)
173
173
  ```
174
174
 
175
- ### extends Content
175
+ ### Extends Content
176
176
 
177
177
  ```python
178
- from abc import ABC, abstractmethod
179
178
  from typing import Any, Dict
180
179
 
181
- from dimp import ContentType
182
- from dimp import Content
183
- from dimp import BaseContent
180
+ from dimp import *
184
181
 
185
182
 
186
- class AppContent(Content, ABC):
183
+ class ApplicationContent(BaseContent, AppContent):
187
184
  """
188
185
  Application Customized message
189
186
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
190
187
 
191
188
  data format: {
192
- type : 0xA0,
189
+ type : i2s(0xA0),
193
190
  sn : 123,
194
191
 
195
192
  app : "{APP_ID}", // application (e.g.: "chat.dim.sechat")
196
- mod : "{MODULE}", // module name (e.g.: "drift_bottle")
197
- act : "{ACTION}", // action name (e.g.: "throw")
198
193
  extra : info // action parameters
199
194
  }
200
195
  """
201
196
 
202
- @property
203
- @abstractmethod
204
- def application(self) -> str:
205
- """ App ID """
206
- raise NotImplemented
207
-
208
- @property
209
- @abstractmethod
210
- def module(self) -> str:
211
- """ Module Name """
212
- raise NotImplemented
213
-
214
- @property
215
- @abstractmethod
216
- def action(self) -> str:
217
- """ Action Name """
218
- raise NotImplemented
219
-
220
- #
221
- # Factory
222
- #
223
- @classmethod
224
- def create(cls, app: str, mod: str, act: str):
225
- return ApplicationContent(app=app, mod=mod, act=act)
226
-
227
-
228
- class ApplicationContent(BaseContent, AppContent):
229
-
230
197
  def __init__(self, content: Dict[str, Any] = None,
231
- msg_type: str = None,
232
- app: str = None, mod: str = None, act: str = None):
198
+ msg_type: str = None, app: str = None):
233
199
  if content is None:
234
- # 1. new content with type, application, module & action
235
- assert app is not None and mod is not None and act is not None, \
236
- 'customized content error: %s, %s, %s, %s' % (msg_type, app, mod, act)
200
+ # 1. new content with type, app_id
201
+ assert app is not None, 'customized content error: %s, %s' % (msg_type, app)
237
202
  if msg_type is None:
238
203
  msg_type = ContentType.APPLICATION
239
204
  super().__init__(None, msg_type)
240
205
  self['app'] = app
241
- self['mod'] = mod
242
- self['act'] = act
243
206
  else:
244
207
  # 2. content info from network
245
- assert msg_type is None and app is None and mod is None and act is None, \
246
- 'params error: %s, %s, %s, %s, %s' % (content, msg_type, app, mod, act)
208
+ assert msg_type is None and app is None, 'params error: %s, %s, %s' % (content, msg_type, app)
247
209
  super().__init__(content)
248
210
 
249
211
  @property # Override
250
212
  def application(self) -> str:
251
213
  return self.get_str(key='app', default='')
252
-
253
- @property # Override
254
- def module(self) -> str:
255
- return self.get_str(key='mod', default='')
256
-
257
- @property # Override
258
- def action(self) -> str:
259
- return self.get_str(key='act', default='')
260
214
  ```
261
215
 
262
- ### extends ID Address
216
+ ### Extends ID Address
263
217
 
264
218
  * Examples in [dim plugins](https://pypi.org/project/dimplugins)
265
219
 
@@ -4,7 +4,7 @@
4
4
  [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/dimchat/core-py/pulls)
5
5
  [![Platform](https://img.shields.io/badge/Platform-Python%203-brightgreen.svg)](https://github.com/dimchat/core-py/wiki)
6
6
  [![Issues](https://img.shields.io/github/issues/dimchat/core-py)](https://github.com/dimchat/core-py/issues)
7
- [![Repo Size](https://img.shields.io/github/repo-size/dimchat/core-py)](https://github.com/dimchat/core-py/archive/refs/heads/main.zip)
7
+ [![Repo Size](https://img.shields.io/github/repo-size/dimchat/core-py)](https://github.com/dimchat/core-py/archive/refs/heads/master.zip)
8
8
  [![Tags](https://img.shields.io/github/tag/dimchat/core-py)](https://github.com/dimchat/core-py/tags)
9
9
  [![Version](https://img.shields.io/pypi/v/dimp)](https://pypi.org/project/dimp)
10
10
 
@@ -22,7 +22,7 @@
22
22
 
23
23
  ## Examples
24
24
 
25
- ### extends Command
25
+ ### Extends Command
26
26
 
27
27
  * _Handshake Command Protocol_
28
28
  0. (C-S) handshake start
@@ -158,94 +158,48 @@ class BaseHandshakeCommand(BaseCommand, HandshakeCommand):
158
158
  return handshake_state(title=self.title, session=self.session)
159
159
  ```
160
160
 
161
- ### extends Content
161
+ ### Extends Content
162
162
 
163
163
  ```python
164
- from abc import ABC, abstractmethod
165
164
  from typing import Any, Dict
166
165
 
167
- from dimp import ContentType
168
- from dimp import Content
169
- from dimp import BaseContent
166
+ from dimp import *
170
167
 
171
168
 
172
- class AppContent(Content, ABC):
169
+ class ApplicationContent(BaseContent, AppContent):
173
170
  """
174
171
  Application Customized message
175
172
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
176
173
 
177
174
  data format: {
178
- type : 0xA0,
175
+ type : i2s(0xA0),
179
176
  sn : 123,
180
177
 
181
178
  app : "{APP_ID}", // application (e.g.: "chat.dim.sechat")
182
- mod : "{MODULE}", // module name (e.g.: "drift_bottle")
183
- act : "{ACTION}", // action name (e.g.: "throw")
184
179
  extra : info // action parameters
185
180
  }
186
181
  """
187
182
 
188
- @property
189
- @abstractmethod
190
- def application(self) -> str:
191
- """ App ID """
192
- raise NotImplemented
193
-
194
- @property
195
- @abstractmethod
196
- def module(self) -> str:
197
- """ Module Name """
198
- raise NotImplemented
199
-
200
- @property
201
- @abstractmethod
202
- def action(self) -> str:
203
- """ Action Name """
204
- raise NotImplemented
205
-
206
- #
207
- # Factory
208
- #
209
- @classmethod
210
- def create(cls, app: str, mod: str, act: str):
211
- return ApplicationContent(app=app, mod=mod, act=act)
212
-
213
-
214
- class ApplicationContent(BaseContent, AppContent):
215
-
216
183
  def __init__(self, content: Dict[str, Any] = None,
217
- msg_type: str = None,
218
- app: str = None, mod: str = None, act: str = None):
184
+ msg_type: str = None, app: str = None):
219
185
  if content is None:
220
- # 1. new content with type, application, module & action
221
- assert app is not None and mod is not None and act is not None, \
222
- 'customized content error: %s, %s, %s, %s' % (msg_type, app, mod, act)
186
+ # 1. new content with type, app_id
187
+ assert app is not None, 'customized content error: %s, %s' % (msg_type, app)
223
188
  if msg_type is None:
224
189
  msg_type = ContentType.APPLICATION
225
190
  super().__init__(None, msg_type)
226
191
  self['app'] = app
227
- self['mod'] = mod
228
- self['act'] = act
229
192
  else:
230
193
  # 2. content info from network
231
- assert msg_type is None and app is None and mod is None and act is None, \
232
- 'params error: %s, %s, %s, %s, %s' % (content, msg_type, app, mod, act)
194
+ assert msg_type is None and app is None, 'params error: %s, %s, %s' % (content, msg_type, app)
233
195
  super().__init__(content)
234
196
 
235
197
  @property # Override
236
198
  def application(self) -> str:
237
199
  return self.get_str(key='app', default='')
238
-
239
- @property # Override
240
- def module(self) -> str:
241
- return self.get_str(key='mod', default='')
242
-
243
- @property # Override
244
- def action(self) -> str:
245
- return self.get_str(key='act', default='')
246
200
  ```
247
201
 
248
- ### extends ID Address
202
+ ### Extends ID Address
249
203
 
250
204
  * Examples in [dim plugins](https://pypi.org/project/dimplugins)
251
205
 
@@ -65,7 +65,6 @@ __all__ = [
65
65
  'DataCoder', 'Hex', 'Base58', 'Base64',
66
66
  'ObjectCoder', 'JSON',
67
67
  'MapCoder', 'JSONMap',
68
- 'ListCoder', 'JSONList',
69
68
  'StringCoder', 'UTF8',
70
69
 
71
70
  'hex_encode', 'hex_decode',
@@ -81,10 +80,9 @@ __all__ = [
81
80
  # Digest
82
81
  #
83
82
 
84
- 'DataDigester',
85
- 'MD5', 'SHA1', 'SHA256', 'KECCAK256', 'RIPEMD160',
86
-
87
- 'md5', 'sha1', 'sha256', 'keccak256', 'ripemd160',
83
+ 'MessageDigester',
84
+ 'SHA256', 'KECCAK256', 'RIPEMD160',
85
+ 'sha256', 'keccak256', 'ripemd160',
88
86
 
89
87
  #
90
88
  # Crypto
@@ -159,7 +157,7 @@ __all__ = [
159
157
 
160
158
  # group history
161
159
  'HistoryCommand', 'GroupCommand',
162
- 'InviteCommand', 'ExpelCommand', 'JoinCommand', 'QuitCommand', 'QueryCommand', 'ResetCommand',
160
+ 'InviteCommand', 'ExpelCommand', 'JoinCommand', 'QuitCommand', 'ResetCommand',
163
161
  'HireCommand', 'FireCommand', 'ResignCommand',
164
162
 
165
163
  # extend contents
@@ -178,8 +176,8 @@ __all__ = [
178
176
 
179
177
  # extend group history
180
178
  'BaseHistoryCommand', 'BaseGroupCommand',
181
- 'InviteGroupCommand', 'ExpelGroupCommand', 'JoinGroupCommand',
182
- 'QuitGroupCommand', 'QueryGroupCommand', 'ResetGroupCommand',
179
+ 'InviteGroupCommand', 'ExpelGroupCommand',
180
+ 'JoinGroupCommand', 'QuitGroupCommand', 'ResetGroupCommand',
183
181
  'HireGroupCommand', 'FireGroupCommand', 'ResignGroupCommand',
184
182
 
185
183
  #
@@ -42,12 +42,12 @@ from .pnf import BaseFileWrapper
42
42
  __all__ = [
43
43
 
44
44
  #
45
- # Data Digest
45
+ # Digest
46
46
  #
47
47
 
48
- 'DataDigester',
49
- 'MD5', 'SHA1', 'SHA256', 'KECCAK256', 'RIPEMD160',
50
- 'md5', 'sha1', 'sha256', 'keccak256', 'ripemd160',
48
+ 'MessageDigester',
49
+ 'SHA256', 'KECCAK256', 'RIPEMD160',
50
+ 'sha256', 'keccak256', 'ripemd160',
51
51
 
52
52
  #
53
53
  # Crypto
@@ -34,7 +34,7 @@ from typing import Dict
34
34
  from mkm.types import Mapper, Dictionary
35
35
  from mkm.crypto import CryptographyKey, EncryptKey, DecryptKey, SignKey, VerifyKey
36
36
  from mkm.crypto import SymmetricKey, AsymmetricKey, PublicKey, PrivateKey
37
- from mkm.plugins import SharedCryptoExtensions
37
+ from mkm.ext import SharedCryptoExtensions
38
38
 
39
39
 
40
40
  """
@@ -46,8 +46,8 @@ from mkm.plugins import SharedCryptoExtensions
46
46
  # noinspection PyAbstractClass
47
47
  class BaseKey(Dictionary, CryptographyKey, ABC):
48
48
 
49
- def __init__(self, key: Dict):
50
- super().__init__(dictionary=key)
49
+ # def __init__(self, key: Dict):
50
+ # super().__init__(key)
51
51
 
52
52
  @property # Override
53
53
  def algorithm(self) -> str:
@@ -97,8 +97,8 @@ class BaseKey(Dictionary, CryptographyKey, ABC):
97
97
  # noinspection PyAbstractClass
98
98
  class BaseSymmetricKey(Dictionary, SymmetricKey, ABC):
99
99
 
100
- def __init__(self, key: Dict):
101
- super().__init__(dictionary=key)
100
+ # def __init__(self, key: Dict):
101
+ # super().__init__(key)
102
102
 
103
103
  # Override
104
104
  def __eq__(self, other) -> bool:
@@ -136,8 +136,8 @@ class BaseSymmetricKey(Dictionary, SymmetricKey, ABC):
136
136
  # noinspection PyAbstractClass
137
137
  class BaseAsymmetricKey(Dictionary, AsymmetricKey, ABC):
138
138
 
139
- def __init__(self, key: Dict):
140
- super().__init__(dictionary=key)
139
+ # def __init__(self, key: Dict):
140
+ # super().__init__(key)
141
141
 
142
142
  @property # Override
143
143
  def algorithm(self) -> str:
@@ -147,8 +147,8 @@ class BaseAsymmetricKey(Dictionary, AsymmetricKey, ABC):
147
147
  # noinspection PyAbstractClass
148
148
  class BasePublicKey(Dictionary, PublicKey, ABC):
149
149
 
150
- def __init__(self, key: Dict):
151
- super().__init__(dictionary=key)
150
+ # def __init__(self, key: Dict):
151
+ # super().__init__(key)
152
152
 
153
153
  @property # Override
154
154
  def algorithm(self) -> str:
@@ -162,8 +162,8 @@ class BasePublicKey(Dictionary, PublicKey, ABC):
162
162
  # noinspection PyAbstractClass
163
163
  class BasePrivateKey(Dictionary, PrivateKey, ABC):
164
164
 
165
- def __init__(self, key: Dict):
166
- super().__init__(dictionary=key)
165
+ # def __init__(self, key: Dict):
166
+ # super().__init__(key)
167
167
 
168
168
  # Override
169
169
  def __eq__(self, other) -> bool:
@@ -127,7 +127,7 @@ class BaseFileWrapper(Dictionary):
127
127
  if remote is None:
128
128
  self.pop('URL', None)
129
129
  else:
130
- # convert URI to str
130
+ # TODO: convert URI to str
131
131
  self['URL'] = remote
132
132
  self.__url = remote
133
133
 
@@ -35,17 +35,17 @@ from ..protocol.base import BaseContent
35
35
  from ..protocol.contents import BaseTextContent, WebPageContent, NameCardContent
36
36
  from ..protocol.forward import SecretContent, CombineForwardContent, ListContent
37
37
  from ..protocol.files import BaseFileContent, ImageFileContent, AudioFileContent, VideoFileContent
38
- from ..protocol.money import BaseMoneyContent, TransferMoneyContent
38
+ from ..protocol.assets import BaseMoneyContent, TransferMoneyContent
39
39
  from ..protocol.quote import BaseQuoteContent
40
- from ..protocol.customized import AppCustomizedContent
40
+ from ..protocol.app import AppCustomizedContent
41
41
 
42
42
  from ..protocol.base import BaseCommand
43
43
  from ..protocol.commands import BaseMetaCommand, BaseDocumentCommand
44
44
  from ..protocol.receipt import BaseReceiptCommand
45
45
 
46
46
  from ..protocol.groups import BaseHistoryCommand, BaseGroupCommand
47
- from ..protocol.groups import InviteGroupCommand, ExpelGroupCommand, JoinGroupCommand
48
- from ..protocol.groups import QuitGroupCommand, QueryGroupCommand, ResetGroupCommand
47
+ from ..protocol.groups import InviteGroupCommand, ExpelGroupCommand
48
+ from ..protocol.groups import JoinGroupCommand, QuitGroupCommand, ResetGroupCommand
49
49
  from ..protocol.groups import HireGroupCommand, FireGroupCommand, ResignGroupCommand
50
50
 
51
51
  # from ..protocol.base import CommandHelper
@@ -78,7 +78,7 @@ __all__ = [
78
78
 
79
79
  # group history
80
80
  'HistoryCommand', 'GroupCommand',
81
- 'InviteCommand', 'ExpelCommand', 'JoinCommand', 'QuitCommand', 'QueryCommand', 'ResetCommand',
81
+ 'InviteCommand', 'ExpelCommand', 'JoinCommand', 'QuitCommand', 'ResetCommand',
82
82
  'HireCommand', 'FireCommand', 'ResignCommand',
83
83
 
84
84
  #
@@ -109,8 +109,8 @@ __all__ = [
109
109
 
110
110
  # group history
111
111
  'BaseHistoryCommand', 'BaseGroupCommand',
112
- 'InviteGroupCommand', 'ExpelGroupCommand', 'JoinGroupCommand',
113
- 'QuitGroupCommand', 'QueryGroupCommand', 'ResetGroupCommand',
112
+ 'InviteGroupCommand', 'ExpelGroupCommand',
113
+ 'JoinGroupCommand', 'QuitGroupCommand', 'ResetGroupCommand',
114
114
  'HireGroupCommand', 'FireGroupCommand', 'ResignGroupCommand',
115
115
 
116
116
  #
@@ -28,8 +28,8 @@
28
28
  # SOFTWARE.
29
29
  # ==============================================================================
30
30
 
31
- from mkm.plugins import *
32
- from dkd.plugins import *
31
+ from mkm.ext import *
32
+ from dkd.ext import *
33
33
 
34
34
  from ..protocol.base import CommandHelper
35
35
  # from ..protocol.helpers import CommandExtensions
@@ -35,7 +35,7 @@ from mkm.format import utf8_encode
35
35
  from mkm.format import TransportableData
36
36
  from mkm.crypto import VerifyKey, PublicKey
37
37
  from mkm.types import Dictionary
38
- from mkm.plugins import SharedAccountExtensions
38
+ from mkm.ext import SharedAccountExtensions
39
39
  from mkm import Meta
40
40
 
41
41
 
@@ -107,12 +107,12 @@ class MessageEnvelope(Dictionary, Envelope):
107
107
 
108
108
  @property # Override
109
109
  def group(self) -> Optional[ID]:
110
- identifier = self.get('group')
111
- return ID.parse(identifier=identifier)
110
+ gid = self.get('group')
111
+ return ID.parse(identifier=gid)
112
112
 
113
113
  @group.setter # Override
114
- def group(self, value: ID):
115
- self.set_string(key='group', value=value)
114
+ def group(self, gid: ID):
115
+ self.set_string(key='group', value=gid)
116
116
 
117
117
  @property # Override
118
118
  def type(self) -> Optional[str]:
@@ -50,16 +50,16 @@ from .docs import Visa, Bulletin
50
50
  from .contents import TextContent, PageContent, NameCard
51
51
  from .forward import ForwardContent, CombineContent, ArrayContent
52
52
  from .files import FileContent, ImageContent, AudioContent, VideoContent
53
- from .money import MoneyContent, TransferContent
53
+ from .assets import MoneyContent, TransferContent
54
54
  from .quote import QuoteContent
55
- from .customized import CustomizedContent
55
+ from .app import CustomizedContent
56
56
 
57
57
  from .base import Command, CommandFactory
58
58
  from .commands import MetaCommand, DocumentCommand
59
59
  from .receipt import ReceiptCommand
60
60
 
61
61
  from .groups import HistoryCommand, GroupCommand
62
- from .groups import InviteCommand, ExpelCommand, JoinCommand, QuitCommand, QueryCommand, ResetCommand
62
+ from .groups import InviteCommand, ExpelCommand, JoinCommand, QuitCommand, ResetCommand
63
63
  from .groups import HireCommand, FireCommand, ResignCommand
64
64
 
65
65
  # from .base import CommandHelper, GeneralCommandHelper, SharedCommandExtensions
@@ -118,7 +118,7 @@ __all__ = [
118
118
 
119
119
  # group history
120
120
  'HistoryCommand', 'GroupCommand',
121
- 'InviteCommand', 'ExpelCommand', 'JoinCommand', 'QuitCommand', 'QueryCommand', 'ResetCommand',
121
+ 'InviteCommand', 'ExpelCommand', 'JoinCommand', 'QuitCommand', 'ResetCommand',
122
122
  'HireCommand', 'FireCommand', 'ResignCommand',
123
123
 
124
124
  #
@@ -37,18 +37,16 @@ from .types import ContentType
37
37
  from .base import BaseContent
38
38
 
39
39
 
40
- class CustomizedContent(Content, ABC):
40
+ class AppContent(Content, ABC):
41
41
  """
42
- Application Customized message
43
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
42
+ Content for Application 0nly
43
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
44
44
 
45
45
  data format: {
46
- type : i2s(0xCC),
46
+ type : i2s(0xA0),
47
47
  sn : 123,
48
48
 
49
49
  app : "{APP_ID}", // application (e.g.: "chat.dim.sechat")
50
- mod : "{MODULE}", // module name (e.g.: "drift_bottle")
51
- act : "{ACTION}", // action name (e.g.: "throw")
52
50
  extra : info // action parameters
53
51
  }
54
52
  """
@@ -59,6 +57,23 @@ class CustomizedContent(Content, ABC):
59
57
  """ App ID """
60
58
  raise NotImplemented
61
59
 
60
+
61
+ class CustomizedContent(AppContent, ABC):
62
+ """
63
+ Application Customized message
64
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
65
+
66
+ data format: {
67
+ type : i2s(0xCC),
68
+ sn : 123,
69
+
70
+ app : "{APP_ID}", // application (e.g.: "chat.dim.sechat")
71
+ mod : "{MODULE}", // module name (e.g.: "drift_bottle")
72
+ act : "{ACTION}", // action name (e.g.: "throw")
73
+ extra : info // action parameters
74
+ }
75
+ """
76
+
62
77
  @property
63
78
  @abstractmethod
64
79
  def module(self) -> str:
@@ -79,6 +94,13 @@ class CustomizedContent(Content, ABC):
79
94
  return AppCustomizedContent(app=app, mod=mod, act=act)
80
95
 
81
96
 
97
+ ###############################
98
+ # #
99
+ # DaoKeDao Implementation #
100
+ # #
101
+ ###############################
102
+
103
+
82
104
  class AppCustomizedContent(BaseContent, CustomizedContent):
83
105
 
84
106
  def __init__(self, content: Dict = None,
@@ -37,7 +37,7 @@ from mkm.types import Dictionary
37
37
  from mkm import ID
38
38
  from dkd import Content
39
39
  from dkd import InstantMessage
40
- from dkd.plugins import SharedMessageExtensions
40
+ from dkd.ext import SharedMessageExtensions
41
41
 
42
42
  from .helpers import CommandExtensions
43
43
  from .types import ContentType
@@ -192,7 +192,6 @@ class BaseMetaCommand(BaseCommand, MetaCommand):
192
192
  'params error: %s, %s, %s, %s' % (content, cmd, identifier, meta)
193
193
  super().__init__(content)
194
194
  # lazy load
195
- self.__id = identifier
196
195
  self.__meta = meta
197
196
 
198
197
  #
@@ -200,9 +199,7 @@ class BaseMetaCommand(BaseCommand, MetaCommand):
200
199
  #
201
200
  @property # Override
202
201
  def identifier(self) -> ID:
203
- if self.__id is None:
204
- self.__id = ID.parse(identifier=self.get('did'))
205
- return self.__id
202
+ return ID.parse(identifier=self.get('did'))
206
203
 
207
204
  #
208
205
  # Meta
@@ -369,14 +369,11 @@ class NameCardContent(BaseContent, NameCard):
369
369
  'params error: %s, %s, %s, %s' % (content, identifier, name, avatar)
370
370
  super().__init__(content=content)
371
371
  # lazy load
372
- self.__id = identifier
373
372
  self.__avatar = avatar
374
373
 
375
374
  @property # Override
376
375
  def identifier(self) -> ID:
377
- if self.__id is None:
378
- self.__id = ID.parse(identifier=self.get('did'))
379
- return self.__id
376
+ return ID.parse(identifier=self.get('did'))
380
377
 
381
378
  @property # Override
382
379
  def name(self) -> str:
@@ -40,7 +40,6 @@
40
40
  from abc import ABC, abstractmethod
41
41
  from typing import Optional, List, Dict
42
42
 
43
- from mkm.types import DateTime
44
43
  from mkm import ID
45
44
 
46
45
  from .types import ContentType
@@ -81,7 +80,7 @@ class GroupCommand(HistoryCommand, ABC):
81
80
  sn : 123,
82
81
 
83
82
  command : "reset", // "invite", "quit", "query", ...
84
- time : 0, // timestamp
83
+ time : 123.456, // command timestamp
85
84
 
86
85
  group : "{GROUP_ID}",
87
86
  member : "{MEMBER_ID}",
@@ -95,11 +94,11 @@ class GroupCommand(HistoryCommand, ABC):
95
94
  ABDICATE = "abdicate"
96
95
  # member
97
96
  INVITE = "invite"
98
- EXPEL = "expel" # Deprecated (use 'reset' instead)
97
+ EXPEL = "expel" # Deprecated (use 'reset' instead)
99
98
  JOIN = "join"
100
99
  QUIT = "quit"
100
+ # QUERY = "query" # Deprecated
101
101
  RESET = "reset"
102
- QUERY = "query" # (not history command)
103
102
  # administrator/assistant
104
103
  HIRE = "hire"
105
104
  FIRE = "fire"
@@ -158,10 +157,6 @@ class GroupCommand(HistoryCommand, ABC):
158
157
  def quit(cls, group: ID):
159
158
  return QuitGroupCommand(group=group)
160
159
 
161
- @classmethod
162
- def query(cls, group: ID, last_time: DateTime = None):
163
- return QueryGroupCommand(group=group, last_time=last_time)
164
-
165
160
  @classmethod
166
161
  def reset(cls, group: ID, members: List[ID]):
167
162
  return ResetGroupCommand(group=group, members=members)
@@ -202,20 +197,6 @@ class QuitCommand(GroupCommand, ABC):
202
197
  pass
203
198
 
204
199
 
205
- class QueryCommand(GroupCommand, ABC):
206
- """
207
- NOTICE:
208
- This command is just for querying group info,
209
- should not be saved in group history
210
- """
211
-
212
- @property
213
- @abstractmethod
214
- def last_time(self) -> Optional[DateTime]:
215
- """ Last group history time for querying """
216
- raise NotImplemented
217
-
218
-
219
200
  # noinspection PyAbstractClass
220
201
  class ResetCommand(GroupCommand, ABC):
221
202
  pass
@@ -375,19 +356,6 @@ class QuitGroupCommand(BaseGroupCommand, QuitCommand):
375
356
  super().__init__(content, cmd=cmd, group=group)
376
357
 
377
358
 
378
- class QueryGroupCommand(BaseGroupCommand, QueryCommand):
379
-
380
- def __init__(self, content: Dict = None, group: ID = None, last_time: DateTime = None):
381
- cmd = GroupCommand.QUERY if content is None else None
382
- super().__init__(content, cmd=cmd, group=group)
383
- if last_time is not None:
384
- self.set_datetime(key='last_time', value=last_time)
385
-
386
- @property # Override
387
- def last_time(self) -> Optional[DateTime]:
388
- return self.get_datetime(key='last_time')
389
-
390
-
391
359
  class ResetGroupCommand(BaseGroupCommand, ResetCommand):
392
360
 
393
361
  def __init__(self, content: Dict = None, group: ID = None, members: List[ID] = None):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: dimp
3
- Version: 2.3.3
3
+ Version: 2.3.4
4
4
  Summary: Decentralized Instant Messaging Protocol
5
5
  Home-page: https://github.com/dimchat/core-py
6
6
  Author: Albert Moky
@@ -18,7 +18,7 @@ License-File: LICENSE
18
18
  [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/dimchat/core-py/pulls)
19
19
  [![Platform](https://img.shields.io/badge/Platform-Python%203-brightgreen.svg)](https://github.com/dimchat/core-py/wiki)
20
20
  [![Issues](https://img.shields.io/github/issues/dimchat/core-py)](https://github.com/dimchat/core-py/issues)
21
- [![Repo Size](https://img.shields.io/github/repo-size/dimchat/core-py)](https://github.com/dimchat/core-py/archive/refs/heads/main.zip)
21
+ [![Repo Size](https://img.shields.io/github/repo-size/dimchat/core-py)](https://github.com/dimchat/core-py/archive/refs/heads/master.zip)
22
22
  [![Tags](https://img.shields.io/github/tag/dimchat/core-py)](https://github.com/dimchat/core-py/tags)
23
23
  [![Version](https://img.shields.io/pypi/v/dimp)](https://pypi.org/project/dimp)
24
24
 
@@ -36,7 +36,7 @@ License-File: LICENSE
36
36
 
37
37
  ## Examples
38
38
 
39
- ### extends Command
39
+ ### Extends Command
40
40
 
41
41
  * _Handshake Command Protocol_
42
42
  0. (C-S) handshake start
@@ -172,94 +172,48 @@ class BaseHandshakeCommand(BaseCommand, HandshakeCommand):
172
172
  return handshake_state(title=self.title, session=self.session)
173
173
  ```
174
174
 
175
- ### extends Content
175
+ ### Extends Content
176
176
 
177
177
  ```python
178
- from abc import ABC, abstractmethod
179
178
  from typing import Any, Dict
180
179
 
181
- from dimp import ContentType
182
- from dimp import Content
183
- from dimp import BaseContent
180
+ from dimp import *
184
181
 
185
182
 
186
- class AppContent(Content, ABC):
183
+ class ApplicationContent(BaseContent, AppContent):
187
184
  """
188
185
  Application Customized message
189
186
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
190
187
 
191
188
  data format: {
192
- type : 0xA0,
189
+ type : i2s(0xA0),
193
190
  sn : 123,
194
191
 
195
192
  app : "{APP_ID}", // application (e.g.: "chat.dim.sechat")
196
- mod : "{MODULE}", // module name (e.g.: "drift_bottle")
197
- act : "{ACTION}", // action name (e.g.: "throw")
198
193
  extra : info // action parameters
199
194
  }
200
195
  """
201
196
 
202
- @property
203
- @abstractmethod
204
- def application(self) -> str:
205
- """ App ID """
206
- raise NotImplemented
207
-
208
- @property
209
- @abstractmethod
210
- def module(self) -> str:
211
- """ Module Name """
212
- raise NotImplemented
213
-
214
- @property
215
- @abstractmethod
216
- def action(self) -> str:
217
- """ Action Name """
218
- raise NotImplemented
219
-
220
- #
221
- # Factory
222
- #
223
- @classmethod
224
- def create(cls, app: str, mod: str, act: str):
225
- return ApplicationContent(app=app, mod=mod, act=act)
226
-
227
-
228
- class ApplicationContent(BaseContent, AppContent):
229
-
230
197
  def __init__(self, content: Dict[str, Any] = None,
231
- msg_type: str = None,
232
- app: str = None, mod: str = None, act: str = None):
198
+ msg_type: str = None, app: str = None):
233
199
  if content is None:
234
- # 1. new content with type, application, module & action
235
- assert app is not None and mod is not None and act is not None, \
236
- 'customized content error: %s, %s, %s, %s' % (msg_type, app, mod, act)
200
+ # 1. new content with type, app_id
201
+ assert app is not None, 'customized content error: %s, %s' % (msg_type, app)
237
202
  if msg_type is None:
238
203
  msg_type = ContentType.APPLICATION
239
204
  super().__init__(None, msg_type)
240
205
  self['app'] = app
241
- self['mod'] = mod
242
- self['act'] = act
243
206
  else:
244
207
  # 2. content info from network
245
- assert msg_type is None and app is None and mod is None and act is None, \
246
- 'params error: %s, %s, %s, %s, %s' % (content, msg_type, app, mod, act)
208
+ assert msg_type is None and app is None, 'params error: %s, %s, %s' % (content, msg_type, app)
247
209
  super().__init__(content)
248
210
 
249
211
  @property # Override
250
212
  def application(self) -> str:
251
213
  return self.get_str(key='app', default='')
252
-
253
- @property # Override
254
- def module(self) -> str:
255
- return self.get_str(key='mod', default='')
256
-
257
- @property # Override
258
- def action(self) -> str:
259
- return self.get_str(key='act', default='')
260
214
  ```
261
215
 
262
- ### extends ID Address
216
+ ### Extends ID Address
263
217
 
264
218
  * Examples in [dim plugins](https://pypi.org/project/dimplugins)
265
219
 
@@ -13,6 +13,7 @@ dimp/crypto/keys.py
13
13
  dimp/crypto/pnf.py
14
14
  dimp/crypto/ted.py
15
15
  dimp/dkd/__init__.py
16
+ dimp/ext/__init__.py
16
17
  dimp/mkm/__init__.py
17
18
  dimp/mkm/docs.py
18
19
  dimp/mkm/document.py
@@ -23,18 +24,17 @@ dimp/msg/envelope.py
23
24
  dimp/msg/instant.py
24
25
  dimp/msg/reliable.py
25
26
  dimp/msg/secure.py
26
- dimp/plugins/__init__.py
27
27
  dimp/protocol/__init__.py
28
+ dimp/protocol/app.py
29
+ dimp/protocol/assets.py
28
30
  dimp/protocol/base.py
29
31
  dimp/protocol/commands.py
30
32
  dimp/protocol/contents.py
31
- dimp/protocol/customized.py
32
33
  dimp/protocol/docs.py
33
34
  dimp/protocol/files.py
34
35
  dimp/protocol/forward.py
35
36
  dimp/protocol/groups.py
36
37
  dimp/protocol/helpers.py
37
- dimp/protocol/money.py
38
38
  dimp/protocol/quote.py
39
39
  dimp/protocol/receipt.py
40
40
  dimp/protocol/types.py
@@ -0,0 +1,2 @@
1
+ dkd>=2.3.4
2
+ mkm>=2.3.4
@@ -14,7 +14,7 @@ import io
14
14
 
15
15
  from setuptools import setup, find_packages
16
16
 
17
- __version__ = '2.3.3'
17
+ __version__ = '2.3.4'
18
18
  __author__ = 'Albert Moky'
19
19
  __contact__ = 'albert.moky@gmail.com'
20
20
 
@@ -38,7 +38,7 @@ setup(
38
38
  'Operating System :: OS Independent',
39
39
  ],
40
40
  install_requires=[
41
- 'dkd>=2.3.3',
42
- 'mkm>=2.3.3',
41
+ 'dkd>=2.3.4',
42
+ 'mkm>=2.3.4',
43
43
  ]
44
44
  )
@@ -1,2 +0,0 @@
1
- dkd>=2.3.3
2
- mkm>=2.3.3
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes