dimples 1.4.2__tar.gz → 1.5.1__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 (177) hide show
  1. {dimples-1.4.2 → dimples-1.5.1}/PKG-INFO +6 -6
  2. {dimples-1.4.2 → dimples-1.5.1}/README.md +5 -5
  3. {dimples-1.4.2 → dimples-1.5.1}/dimples/__init__.py +11 -3
  4. {dimples-1.4.2 → dimples-1.5.1}/dimples/client/checker.py +1 -1
  5. {dimples-1.4.2 → dimples-1.5.1}/dimples/client/cpu/creator.py +8 -6
  6. {dimples-1.4.2 → dimples-1.5.1}/dimples/client/cpu/group.py +6 -6
  7. {dimples-1.4.2 → dimples-1.5.1}/dimples/client/cpu/grp_invite.py +3 -3
  8. {dimples-1.4.2 → dimples-1.5.1}/dimples/client/cpu/grp_query.py +4 -4
  9. {dimples-1.4.2 → dimples-1.5.1}/dimples/client/cpu/grp_quit.py +4 -4
  10. {dimples-1.4.2 → dimples-1.5.1}/dimples/client/cpu/grp_reset.py +8 -8
  11. {dimples-1.4.2 → dimples-1.5.1}/dimples/client/cpu/grp_resign.py +2 -2
  12. {dimples-1.4.2 → dimples-1.5.1}/dimples/client/facebook.py +6 -26
  13. {dimples-1.4.2 → dimples-1.5.1}/dimples/client/network/session.py +1 -1
  14. {dimples-1.4.2 → dimples-1.5.1}/dimples/client/packer.py +1 -1
  15. {dimples-1.4.2 → dimples-1.5.1}/dimples/common/__init__.py +5 -2
  16. {dimples-1.4.2 → dimples-1.5.1}/dimples/common/ans.py +58 -1
  17. dimples-1.5.1/dimples/common/archivist.py +106 -0
  18. {dimples-1.4.2 → dimples-1.5.1}/dimples/common/compat/__init__.py +2 -2
  19. {dimples-1.4.2 → dimples-1.5.1}/dimples/common/compat/address.py +2 -1
  20. dimples-1.5.1/dimples/common/compat/compatible.py +390 -0
  21. {dimples-1.4.2 → dimples-1.5.1}/dimples/common/compat/entity.py +2 -1
  22. {dimples-1.4.2 → dimples-1.5.1}/dimples/common/compat/loader.py +51 -5
  23. {dimples-1.4.2 → dimples-1.5.1}/dimples/common/compat/meta.py +1 -21
  24. {dimples-1.4.2 → dimples-1.5.1}/dimples/common/dbi/session.py +24 -16
  25. {dimples-1.4.2 → dimples-1.5.1}/dimples/common/facebook.py +71 -16
  26. {dimples-1.4.2 → dimples-1.5.1}/dimples/common/messenger.py +21 -13
  27. {dimples-1.4.2 → dimples-1.5.1}/dimples/common/packer.py +2 -0
  28. {dimples-1.4.2 → dimples-1.5.1}/dimples/common/protocol/__init__.py +2 -2
  29. {dimples-1.4.2 → dimples-1.5.1}/dimples/common/protocol/block.py +1 -1
  30. {dimples-1.4.2 → dimples-1.5.1}/dimples/common/protocol/customized.py +2 -2
  31. {dimples-1.4.2 → dimples-1.5.1}/dimples/common/protocol/group.py +1 -1
  32. {dimples-1.4.2 → dimples-1.5.1}/dimples/common/protocol/login.py +7 -7
  33. {dimples-1.4.2 → dimples-1.5.1}/dimples/common/protocol/mute.py +1 -1
  34. {dimples-1.4.2 → dimples-1.5.1}/dimples/common/protocol/password.py +3 -2
  35. dimples-1.5.1/dimples/common/protocol/roles.py +105 -0
  36. {dimples-1.4.2 → dimples-1.5.1}/dimples/common/protocol/version.py +8 -8
  37. {dimples-1.4.2 → dimples-1.5.1}/dimples/common/register.py +8 -6
  38. {dimples-1.4.2 → dimples-1.5.1}/dimples/database/dos/document.py +6 -2
  39. {dimples-1.4.2 → dimples-1.5.1}/dimples/database/dos/group.py +3 -3
  40. {dimples-1.4.2 → dimples-1.5.1}/dimples/database/dos/station.py +2 -2
  41. {dimples-1.4.2 → dimples-1.5.1}/dimples/database/dos/user.py +1 -1
  42. {dimples-1.4.2 → dimples-1.5.1}/dimples/database/redis/group.py +3 -3
  43. {dimples-1.4.2 → dimples-1.5.1}/dimples/database/redis/station.py +2 -2
  44. {dimples-1.4.2 → dimples-1.5.1}/dimples/database/redis/user.py +1 -1
  45. {dimples-1.4.2 → dimples-1.5.1}/dimples/database/t_cipherkey.py +2 -1
  46. {dimples-1.4.2 → dimples-1.5.1}/dimples/database/t_document.py +5 -2
  47. {dimples-1.4.2 → dimples-1.5.1}/dimples/edge/messenger.py +2 -2
  48. {dimples-1.4.2 → dimples-1.5.1}/dimples/edge/octopus.py +2 -2
  49. {dimples-1.4.2 → dimples-1.5.1}/dimples/edge/shared.py +1 -1
  50. {dimples-1.4.2 → dimples-1.5.1}/dimples/emitter.py +9 -7
  51. {dimples-1.4.2 → dimples-1.5.1}/dimples/group/admin.py +2 -2
  52. {dimples-1.4.2 → dimples-1.5.1}/dimples/group/builder.py +1 -1
  53. {dimples-1.4.2 → dimples-1.5.1}/dimples/group/delegate.py +1 -1
  54. {dimples-1.4.2 → dimples-1.5.1}/dimples/group/emitter.py +1 -1
  55. {dimples-1.4.2 → dimples-1.5.1}/dimples/group/manager.py +1 -1
  56. {dimples-1.4.2 → dimples-1.5.1}/dimples/register/base.py +16 -11
  57. {dimples-1.4.2 → dimples-1.5.1}/dimples/register/ext.py +11 -9
  58. {dimples-1.4.2 → dimples-1.5.1}/dimples/register/shared.py +2 -2
  59. {dimples-1.4.2 → dimples-1.5.1}/dimples/server/checker.py +2 -2
  60. {dimples-1.4.2 → dimples-1.5.1}/dimples/server/cpu/creator.py +4 -4
  61. {dimples-1.4.2 → dimples-1.5.1}/dimples/server/cpu/document.py +5 -2
  62. {dimples-1.4.2 → dimples-1.5.1}/dimples/server/cpu/login.py +6 -3
  63. {dimples-1.4.2 → dimples-1.5.1}/dimples/server/cpu/report.py +2 -2
  64. {dimples-1.4.2 → dimples-1.5.1}/dimples/server/deliver.py +4 -1
  65. {dimples-1.4.2 → dimples-1.5.1}/dimples/server/dispatcher.py +4 -4
  66. {dimples-1.4.2 → dimples-1.5.1}/dimples/server/facebook.py +1 -23
  67. {dimples-1.4.2 → dimples-1.5.1}/dimples/server/session.py +1 -1
  68. {dimples-1.4.2 → dimples-1.5.1}/dimples/server/trace.py +14 -7
  69. {dimples-1.4.2 → dimples-1.5.1}/dimples/station/shared.py +1 -1
  70. {dimples-1.4.2 → dimples-1.5.1}/dimples/utils/__init__.py +5 -1
  71. {dimples-1.4.2 → dimples-1.5.1}/dimples/utils/config.py +9 -9
  72. dimples-1.5.1/dimples/utils/thanos.py +83 -0
  73. {dimples-1.4.2 → dimples-1.5.1}/dimples.egg-info/PKG-INFO +6 -6
  74. {dimples-1.4.2 → dimples-1.5.1}/dimples.egg-info/SOURCES.txt +3 -1
  75. {dimples-1.4.2 → dimples-1.5.1}/dimples.egg-info/requires.txt +3 -2
  76. {dimples-1.4.2 → dimples-1.5.1}/setup.py +6 -6
  77. dimples-1.4.2/dimples/common/archivist.py +0 -141
  78. dimples-1.4.2/dimples/common/compat/compatible.py +0 -234
  79. {dimples-1.4.2 → dimples-1.5.1}/LICENSE +0 -0
  80. {dimples-1.4.2 → dimples-1.5.1}/dimples/client/__init__.py +0 -0
  81. {dimples-1.4.2 → dimples-1.5.1}/dimples/client/checkpoint.py +0 -0
  82. {dimples-1.4.2 → dimples-1.5.1}/dimples/client/cpu/__init__.py +0 -0
  83. {dimples-1.4.2 → dimples-1.5.1}/dimples/client/cpu/commands.py +0 -0
  84. {dimples-1.4.2 → dimples-1.5.1}/dimples/client/cpu/customized.py +0 -0
  85. {dimples-1.4.2 → dimples-1.5.1}/dimples/client/cpu/grp_expel.py +0 -0
  86. {dimples-1.4.2 → dimples-1.5.1}/dimples/client/cpu/grp_join.py +0 -0
  87. {dimples-1.4.2 → dimples-1.5.1}/dimples/client/cpu/handshake.py +0 -0
  88. {dimples-1.4.2 → dimples-1.5.1}/dimples/client/messenger.py +0 -0
  89. {dimples-1.4.2 → dimples-1.5.1}/dimples/client/network/__init__.py +0 -0
  90. {dimples-1.4.2 → dimples-1.5.1}/dimples/client/network/state.py +0 -0
  91. {dimples-1.4.2 → dimples-1.5.1}/dimples/client/network/transition.py +0 -0
  92. {dimples-1.4.2 → dimples-1.5.1}/dimples/client/processor.py +0 -0
  93. {dimples-1.4.2 → dimples-1.5.1}/dimples/client/terminal.py +0 -0
  94. {dimples-1.4.2 → dimples-1.5.1}/dimples/common/anonymous.py +0 -0
  95. {dimples-1.4.2 → dimples-1.5.1}/dimples/common/checker.py +0 -0
  96. {dimples-1.4.2 → dimples-1.5.1}/dimples/common/compat/network.py +0 -0
  97. {dimples-1.4.2 → dimples-1.5.1}/dimples/common/dbi/__init__.py +0 -0
  98. {dimples-1.4.2 → dimples-1.5.1}/dimples/common/dbi/account.py +0 -0
  99. {dimples-1.4.2 → dimples-1.5.1}/dimples/common/dbi/message.py +0 -0
  100. {dimples-1.4.2 → dimples-1.5.1}/dimples/common/processer.py +0 -0
  101. {dimples-1.4.2 → dimples-1.5.1}/dimples/common/protocol/ans.py +0 -0
  102. {dimples-1.4.2 → dimples-1.5.1}/dimples/common/protocol/handshake.py +0 -0
  103. {dimples-1.4.2 → dimples-1.5.1}/dimples/common/protocol/report.py +0 -0
  104. {dimples-1.4.2 → dimples-1.5.1}/dimples/common/protocol/utils.py +0 -0
  105. {dimples-1.4.2 → dimples-1.5.1}/dimples/common/queue.py +0 -0
  106. {dimples-1.4.2 → dimples-1.5.1}/dimples/common/session.py +0 -0
  107. {dimples-1.4.2 → dimples-1.5.1}/dimples/conn/__init__.py +0 -0
  108. {dimples-1.4.2 → dimples-1.5.1}/dimples/conn/flexible.py +0 -0
  109. {dimples-1.4.2 → dimples-1.5.1}/dimples/conn/gate.py +0 -0
  110. {dimples-1.4.2 → dimples-1.5.1}/dimples/conn/gatekeeper.py +0 -0
  111. {dimples-1.4.2 → dimples-1.5.1}/dimples/conn/mars.py +0 -0
  112. {dimples-1.4.2 → dimples-1.5.1}/dimples/conn/mtp.py +0 -0
  113. {dimples-1.4.2 → dimples-1.5.1}/dimples/conn/protocol/__init__.py +0 -0
  114. {dimples-1.4.2 → dimples-1.5.1}/dimples/conn/protocol/mars.py +0 -0
  115. {dimples-1.4.2 → dimples-1.5.1}/dimples/conn/protocol/ws.py +0 -0
  116. {dimples-1.4.2 → dimples-1.5.1}/dimples/conn/queue.py +0 -0
  117. {dimples-1.4.2 → dimples-1.5.1}/dimples/conn/seeker.py +0 -0
  118. {dimples-1.4.2 → dimples-1.5.1}/dimples/conn/session.py +0 -0
  119. {dimples-1.4.2 → dimples-1.5.1}/dimples/conn/ws.py +0 -0
  120. {dimples-1.4.2 → dimples-1.5.1}/dimples/database/__init__.py +0 -0
  121. {dimples-1.4.2 → dimples-1.5.1}/dimples/database/account.py +0 -0
  122. {dimples-1.4.2 → dimples-1.5.1}/dimples/database/dos/__init__.py +0 -0
  123. {dimples-1.4.2 → dimples-1.5.1}/dimples/database/dos/base.py +0 -0
  124. {dimples-1.4.2 → dimples-1.5.1}/dimples/database/dos/group_history.py +0 -0
  125. {dimples-1.4.2 → dimples-1.5.1}/dimples/database/dos/group_keys.py +0 -0
  126. {dimples-1.4.2 → dimples-1.5.1}/dimples/database/dos/login.py +0 -0
  127. {dimples-1.4.2 → dimples-1.5.1}/dimples/database/dos/meta.py +0 -0
  128. {dimples-1.4.2 → dimples-1.5.1}/dimples/database/dos/private.py +0 -0
  129. {dimples-1.4.2 → dimples-1.5.1}/dimples/database/message.py +0 -0
  130. {dimples-1.4.2 → dimples-1.5.1}/dimples/database/redis/__init__.py +0 -0
  131. {dimples-1.4.2 → dimples-1.5.1}/dimples/database/redis/base.py +0 -0
  132. {dimples-1.4.2 → dimples-1.5.1}/dimples/database/redis/document.py +0 -0
  133. {dimples-1.4.2 → dimples-1.5.1}/dimples/database/redis/grp_history.py +0 -0
  134. {dimples-1.4.2 → dimples-1.5.1}/dimples/database/redis/grp_keys.py +0 -0
  135. {dimples-1.4.2 → dimples-1.5.1}/dimples/database/redis/login.py +0 -0
  136. {dimples-1.4.2 → dimples-1.5.1}/dimples/database/redis/message.py +0 -0
  137. {dimples-1.4.2 → dimples-1.5.1}/dimples/database/redis/meta.py +0 -0
  138. {dimples-1.4.2 → dimples-1.5.1}/dimples/database/session.py +0 -0
  139. {dimples-1.4.2 → dimples-1.5.1}/dimples/database/t_base.py +0 -0
  140. {dimples-1.4.2 → dimples-1.5.1}/dimples/database/t_group.py +0 -0
  141. {dimples-1.4.2 → dimples-1.5.1}/dimples/database/t_group_history.py +0 -0
  142. {dimples-1.4.2 → dimples-1.5.1}/dimples/database/t_group_keys.py +0 -0
  143. {dimples-1.4.2 → dimples-1.5.1}/dimples/database/t_login.py +0 -0
  144. {dimples-1.4.2 → dimples-1.5.1}/dimples/database/t_message.py +0 -0
  145. {dimples-1.4.2 → dimples-1.5.1}/dimples/database/t_meta.py +0 -0
  146. {dimples-1.4.2 → dimples-1.5.1}/dimples/database/t_private.py +0 -0
  147. {dimples-1.4.2 → dimples-1.5.1}/dimples/database/t_station.py +0 -0
  148. {dimples-1.4.2 → dimples-1.5.1}/dimples/database/t_user.py +0 -0
  149. {dimples-1.4.2 → dimples-1.5.1}/dimples/edge/__init__.py +0 -0
  150. {dimples-1.4.2 → dimples-1.5.1}/dimples/edge/start.py +0 -0
  151. {dimples-1.4.2 → dimples-1.5.1}/dimples/group/__init__.py +0 -0
  152. {dimples-1.4.2 → dimples-1.5.1}/dimples/group/helper.py +0 -0
  153. {dimples-1.4.2 → dimples-1.5.1}/dimples/group/packer.py +0 -0
  154. {dimples-1.4.2 → dimples-1.5.1}/dimples/group/shared.py +0 -0
  155. {dimples-1.4.2 → dimples-1.5.1}/dimples/register/__init__.py +0 -0
  156. {dimples-1.4.2 → dimples-1.5.1}/dimples/register/run.py +0 -0
  157. {dimples-1.4.2 → dimples-1.5.1}/dimples/server/__init__.py +0 -0
  158. {dimples-1.4.2 → dimples-1.5.1}/dimples/server/cpu/__init__.py +0 -0
  159. {dimples-1.4.2 → dimples-1.5.1}/dimples/server/cpu/ans.py +0 -0
  160. {dimples-1.4.2 → dimples-1.5.1}/dimples/server/cpu/handshake.py +0 -0
  161. {dimples-1.4.2 → dimples-1.5.1}/dimples/server/dis_roamer.py +0 -0
  162. {dimples-1.4.2 → dimples-1.5.1}/dimples/server/messenger.py +0 -0
  163. {dimples-1.4.2 → dimples-1.5.1}/dimples/server/packer.py +0 -0
  164. {dimples-1.4.2 → dimples-1.5.1}/dimples/server/processor.py +0 -0
  165. {dimples-1.4.2 → dimples-1.5.1}/dimples/server/push.py +0 -0
  166. {dimples-1.4.2 → dimples-1.5.1}/dimples/server/session_center.py +0 -0
  167. {dimples-1.4.2 → dimples-1.5.1}/dimples/station/__init__.py +0 -0
  168. {dimples-1.4.2 → dimples-1.5.1}/dimples/station/handler.py +0 -0
  169. {dimples-1.4.2 → dimples-1.5.1}/dimples/station/start.py +0 -0
  170. {dimples-1.4.2 → dimples-1.5.1}/dimples/utils/cache.py +0 -0
  171. {dimples-1.4.2 → dimples-1.5.1}/dimples/utils/checker.py +0 -0
  172. {dimples-1.4.2 → dimples-1.5.1}/dimples/utils/http.py +0 -0
  173. {dimples-1.4.2 → dimples-1.5.1}/dimples/utils/log.py +0 -0
  174. {dimples-1.4.2 → dimples-1.5.1}/dimples.egg-info/dependency_links.txt +0 -0
  175. {dimples-1.4.2 → dimples-1.5.1}/dimples.egg-info/entry_points.txt +0 -0
  176. {dimples-1.4.2 → dimples-1.5.1}/dimples.egg-info/top_level.txt +0 -0
  177. {dimples-1.4.2 → dimples-1.5.1}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: dimples
3
- Version: 1.4.2
3
+ Version: 1.5.1
4
4
  Summary: DIMP Library for Edges and Stations
5
5
  Home-page: https://github.com/dimchat/demo-py
6
6
  Author: Albert Moky
@@ -36,12 +36,12 @@ License-File: LICENSE
36
36
  # 'pycryptodome', # 3.14.1
37
37
  # 'base58', # 1.0.3
38
38
  # 'ecdsa', # 0.16.1
39
- 'dimplugins>=2.2.2',
39
+ 'dimplugins>=2.3.0',
40
40
 
41
- 'dimsdk>=2.2.2',
42
- # 'dimp>=2.2.2',
43
- # 'dkd>=2.2.2',
44
- # 'mkm>=2.2.2',
41
+ 'dimsdk>=2.3.0',
42
+ # 'dimp>=2.3.0',
43
+ # 'dkd>=2.3.0',
44
+ # 'mkm>=2.3.0',
45
45
 
46
46
  'startrek>=2.2.2',
47
47
  'tcp>=2.2.2',
@@ -22,12 +22,12 @@
22
22
  # 'pycryptodome', # 3.14.1
23
23
  # 'base58', # 1.0.3
24
24
  # 'ecdsa', # 0.16.1
25
- 'dimplugins>=2.2.2',
25
+ 'dimplugins>=2.3.0',
26
26
 
27
- 'dimsdk>=2.2.2',
28
- # 'dimp>=2.2.2',
29
- # 'dkd>=2.2.2',
30
- # 'mkm>=2.2.2',
27
+ 'dimsdk>=2.3.0',
28
+ # 'dimp>=2.3.0',
29
+ # 'dkd>=2.3.0',
30
+ # 'mkm>=2.3.0',
31
31
 
32
32
  'startrek>=2.2.2',
33
33
  'tcp>=2.2.2',
@@ -108,6 +108,12 @@ __all__ = [
108
108
  'BaseDataWrapper',
109
109
  'BaseFileWrapper',
110
110
 
111
+ #
112
+ # Algorithm
113
+ #
114
+ 'AsymmetricAlgorithms', 'SymmetricAlgorithms',
115
+ 'EncodeAlgorithms',
116
+
111
117
  #
112
118
  # MingKeMing
113
119
  #
@@ -118,6 +124,8 @@ __all__ = [
118
124
  'Meta',
119
125
  'Document', 'Visa', 'Bulletin',
120
126
 
127
+ 'MetaType', 'DocumentType',
128
+
121
129
  'AddressFactory',
122
130
  'IDFactory',
123
131
  'MetaFactory',
@@ -211,7 +219,7 @@ __all__ = [
211
219
 
212
220
  'ServiceProvider', 'Station', 'Bot',
213
221
 
214
- 'MemberType',
222
+ # 'MemberType',
215
223
 
216
224
  'MetaUtils', 'DocumentUtils',
217
225
 
@@ -238,7 +246,7 @@ __all__ = [
238
246
  'TwinsHelper',
239
247
 
240
248
  'AddressNameService',
241
- 'Archivist',
249
+ # 'Archivist',
242
250
  'Facebook', 'Messenger',
243
251
  'MessageProcessor', 'MessagePacker',
244
252
 
@@ -322,7 +330,7 @@ __all__ = [
322
330
  #
323
331
  ####################################
324
332
 
325
- 'MetaType',
333
+ 'MetaVersion',
326
334
  'Password',
327
335
  'BroadcastUtils',
328
336
 
@@ -246,6 +246,6 @@ class ClientChecker(EntityChecker, Logging):
246
246
  self.debug(msg='visa response not expired yet: %s' % receiver)
247
247
  return False
248
248
  self.info(msg='push visa document: %s => %s' % (me, receiver))
249
- content = DocumentCommand.response(document=visa, identifier=me)
249
+ content = DocumentCommand.response(identifier=me, meta=None, documents=[visa])
250
250
  _, r_msg = await messenger.send_content(content=content, sender=me, receiver=receiver, priority=1)
251
251
  return r_msg is not None
@@ -28,7 +28,7 @@
28
28
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
29
29
  """
30
30
 
31
- from typing import Optional, Union
31
+ from typing import Optional
32
32
 
33
33
  from dimsdk import ContentType
34
34
  from dimsdk import Command, GroupCommand
@@ -55,18 +55,20 @@ from .customized import CustomizedContentProcessor
55
55
  class ClientContentProcessorCreator(BaseContentProcessorCreator):
56
56
 
57
57
  # Override
58
- def create_content_processor(self, msg_type: Union[int, ContentType]) -> Optional[ContentProcessor]:
58
+ def create_content_processor(self, msg_type: str) -> Optional[ContentProcessor]:
59
59
  # application customized
60
- if msg_type == ContentType.APPLICATION.value or msg_type == ContentType.CUSTOMIZED.value:
60
+ if msg_type == ContentType.APPLICATION or msg_type == 'application':
61
61
  return CustomizedContentProcessor(facebook=self.facebook, messenger=self.messenger)
62
- # history
63
- if msg_type == ContentType.HISTORY.value:
62
+ if msg_type == ContentType.CUSTOMIZED or msg_type == 'customized':
63
+ return CustomizedContentProcessor(facebook=self.facebook, messenger=self.messenger)
64
+ # history command
65
+ if msg_type == ContentType.HISTORY or msg_type == 'history':
64
66
  return HistoryCommandProcessor(facebook=self.facebook, messenger=self.messenger)
65
67
  # others
66
68
  return super().create_content_processor(msg_type=msg_type)
67
69
 
68
70
  # Override
69
- def create_command_processor(self, msg_type: Union[int, ContentType], cmd: str) -> Optional[ContentProcessor]:
71
+ def create_command_processor(self, msg_type: str, cmd: str) -> Optional[ContentProcessor]:
70
72
  # receipt
71
73
  if cmd == Command.RECEIPT:
72
74
  return ReceiptCommandProcessor(facebook=self.facebook, messenger=self.messenger)
@@ -169,10 +169,10 @@ class GroupCommandProcessor(HistoryCommandProcessor):
169
169
  if expired:
170
170
  text = 'Command expired.'
171
171
  errors = self._respond_receipt(text=text, content=content, envelope=r_msg.envelope, extra={
172
- 'template': 'Group command expired: ${cmd}, group: ${ID}.',
172
+ 'template': 'Group command expired: ${cmd}, group: ${gid}.',
173
173
  'replacements': {
174
174
  'cmd': content.cmd,
175
- 'ID': str(group),
175
+ 'gid': str(group),
176
176
  }
177
177
  })
178
178
  group = None
@@ -189,9 +189,9 @@ class GroupCommandProcessor(HistoryCommandProcessor):
189
189
  if len(members) == 0:
190
190
  text = 'Command error.'
191
191
  errors = self._respond_receipt(text=text, content=content, envelope=r_msg.envelope, extra={
192
- 'template': 'Group members empty: ${ID}.',
192
+ 'template': 'Group members empty: ${gid}.',
193
193
  'replacements': {
194
- 'ID': str(group),
194
+ 'gid': str(group),
195
195
  }
196
196
  })
197
197
  else:
@@ -209,9 +209,9 @@ class GroupCommandProcessor(HistoryCommandProcessor):
209
209
  # TODO: query group members?
210
210
  text = 'Group empty.'
211
211
  errors = self._respond_receipt(text=text, content=content, envelope=r_msg.envelope, extra={
212
- 'template': 'Group empty: ${ID}.',
212
+ 'template': 'Group empty: ${gid}.',
213
213
  'replacements': {
214
- 'ID': str(group),
214
+ 'gid': str(group),
215
215
  }
216
216
  })
217
217
  else:
@@ -83,9 +83,9 @@ class InviteCommandProcessor(GroupCommandProcessor):
83
83
  if not is_member:
84
84
  text = 'Permission denied.'
85
85
  return self._respond_receipt(text=text, content=content, envelope=r_msg.envelope, extra={
86
- 'template': 'Not allowed to invite member into group: ${ID}',
86
+ 'template': 'Not allowed to invite member into group: ${gid}',
87
87
  'replacements': {
88
- 'ID': str(group),
88
+ 'gid': str(group),
89
89
  }
90
90
  })
91
91
 
@@ -117,7 +117,7 @@ class InviteCommandProcessor(GroupCommandProcessor):
117
117
  # if we received the 'invite' command here, maybe it was confused,
118
118
  # anyway, we just append the new members directly.
119
119
  self.warning(msg='invited by administrator: %s, group: %s' % (sender, group))
120
- content['added'] = ID.revert(added_list)
120
+ content['added'] = ID.revert(identifiers=added_list)
121
121
  else:
122
122
  # DB error?
123
123
  assert False, 'failed to save members for group: %s' % group
@@ -72,9 +72,9 @@ class QueryCommandProcessor(GroupCommandProcessor):
72
72
  if not can_query:
73
73
  text = 'Permission denied.'
74
74
  return self._respond_receipt(text=text, content=content, envelope=r_msg.envelope, extra={
75
- 'template': 'Not allowed to query members of group: ${ID}',
75
+ 'template': 'Not allowed to query members of group: ${gid}',
76
76
  'replacements': {
77
- 'ID': str(group),
77
+ 'gid': str(group),
78
78
  }
79
79
  })
80
80
 
@@ -90,9 +90,9 @@ class QueryCommandProcessor(GroupCommandProcessor):
90
90
  # group history not updated
91
91
  text = 'Group history not updated.'
92
92
  return self._respond_receipt(text=text, content=content, envelope=r_msg.envelope, extra={
93
- 'template': 'Group history not updated: ${ID}, last time: ${time}',
93
+ 'template': 'Group history not updated: ${gid}, last time: ${time}',
94
94
  'replacements': {
95
- 'ID': str(group),
95
+ 'gid': str(group),
96
96
  'time': last_time.timestamp,
97
97
  }
98
98
  })
@@ -72,17 +72,17 @@ class QuitCommandProcessor(GroupCommandProcessor):
72
72
  if is_owner:
73
73
  text = 'Permission denied.'
74
74
  return self._respond_receipt(text=text, content=content, envelope=r_msg.envelope, extra={
75
- 'template': 'Owner cannot quit from group: ${ID}',
75
+ 'template': 'Owner cannot quit from group: ${gid}',
76
76
  'replacements': {
77
- 'ID': str(group),
77
+ 'gid': str(group),
78
78
  }
79
79
  })
80
80
  if is_admin:
81
81
  text = 'Permission denied.'
82
82
  return self._respond_receipt(text=text, content=content, envelope=r_msg.envelope, extra={
83
- 'template': 'Administrator cannot quit from group: ${ID}',
83
+ 'template': 'Administrator cannot quit from group: ${gid}',
84
84
  'replacements': {
85
- 'ID': str(group),
85
+ 'gid': str(group),
86
86
  }
87
87
  })
88
88
  if is_member:
@@ -77,18 +77,18 @@ class ResetCommandProcessor(GroupCommandProcessor):
77
77
  if not can_reset:
78
78
  text = 'Permission denied.'
79
79
  return self._respond_receipt(text=text, content=content, envelope=r_msg.envelope, extra={
80
- 'template': 'Not allowed to reset members of group: ${ID}',
80
+ 'template': 'Not allowed to reset members of group: ${gid}',
81
81
  'replacements': {
82
- 'ID': str(group),
82
+ 'gid': str(group),
83
83
  }
84
84
  })
85
85
  # 2.1. check owner
86
86
  if owner != new_members[0]:
87
87
  text = 'Permission denied.'
88
88
  return self._respond_receipt(text=text, content=content, envelope=r_msg.envelope, extra={
89
- 'template': 'Owner must be the first member of group: ${ID}',
89
+ 'template': 'Owner must be the first member of group: ${gid}',
90
90
  'replacements': {
91
- 'ID': str(group),
91
+ 'gid': str(group),
92
92
  }
93
93
  })
94
94
  # 2.2. check admins
@@ -100,9 +100,9 @@ class ResetCommandProcessor(GroupCommandProcessor):
100
100
  if expel_admin:
101
101
  text = 'Permission denied.'
102
102
  return self._respond_receipt(text=text, content=content, envelope=r_msg.envelope, extra={
103
- 'template': 'Not allowed to expel administrator of group: ${ID}',
103
+ 'template': 'Not allowed to expel administrator of group: ${gid}',
104
104
  'replacements': {
105
- 'ID': str(group),
105
+ 'gid': str(group),
106
106
  }
107
107
  })
108
108
 
@@ -118,9 +118,9 @@ class ResetCommandProcessor(GroupCommandProcessor):
118
118
  elif await self._save_members(members=new_members, group=group):
119
119
  self.info(msg='new members saved in group: %s' % group)
120
120
  if len(add_list) > 0:
121
- content['added'] = ID.revert(add_list)
121
+ content['added'] = ID.revert(identifiers=add_list)
122
122
  if len(remove_list) > 0:
123
- content['removed'] = ID.revert(remove_list)
123
+ content['removed'] = ID.revert(identifiers=remove_list)
124
124
  else:
125
125
  # DB error?
126
126
  assert False, 'failed to save members for group: %s' % group
@@ -71,9 +71,9 @@ class ResignCommandProcessor(GroupCommandProcessor):
71
71
  if is_owner:
72
72
  text = 'Permission denied.'
73
73
  return self._respond_receipt(text=text, content=content, envelope=r_msg.envelope, extra={
74
- 'template': 'Owner cannot resign from group: ${ID}',
74
+ 'template': 'Owner cannot resign from group: ${gid}',
75
75
  'replacements': {
76
- 'ID': str(group),
76
+ 'gid': str(group),
77
77
  }
78
78
  })
79
79
  if is_admin:
@@ -34,7 +34,7 @@ from typing import Optional, List
34
34
 
35
35
  from dimsdk import EntityType
36
36
  from dimsdk import ID, Document, Bulletin
37
- from dimsdk import User, Group
37
+ from dimsdk import Group
38
38
 
39
39
  from ..utils import Runner
40
40
  from ..common import BroadcastUtils
@@ -45,31 +45,11 @@ from ..group import SharedGroupManager
45
45
  class ClientFacebook(CommonFacebook):
46
46
 
47
47
  # Override
48
- def cache_group(self, group: Group):
49
- group.data_source = SharedGroupManager()
50
- super().cache_group(group=group)
51
-
52
- # Override
53
- async def select_user(self, receiver: ID) -> Optional[User]:
54
- if receiver.is_user:
55
- return await super().select_user(receiver=receiver)
56
- # group message(recipient not designated)
57
- assert receiver.is_group, 'receiver error: %s' % receiver
58
- # the messenger will check group info before decrypting message,
59
- # so we can trust that the group's meta & members MUST exist here.
60
- users = await self.archivist.local_users
61
- if users is None or len(users) == 0:
62
- self.error(msg='local users should not be empty')
63
- return None
64
- elif receiver.is_broadcast:
65
- # broadcast message can decrypt by anyone, so just return current user
66
- return users[0]
67
- members = await self.get_members(identifier=receiver)
68
- # assert len(members) > 0, 'members not found: %s' % receiver
69
- for item in users:
70
- if item.identifier in members:
71
- # DISCUSS: set this item to be current user?
72
- return item
48
+ async def get_group(self, identifier: ID) -> Optional[Group]:
49
+ group = await super().get_group(identifier=identifier)
50
+ if group is not None:
51
+ group.data_source = SharedGroupManager()
52
+ return group
73
53
 
74
54
  # Override
75
55
  async def save_document(self, document: Document) -> bool:
@@ -61,7 +61,7 @@ class ClientSession(BaseSession):
61
61
  A random string generated by station.
62
62
  It will be set after handshake success.
63
63
 
64
- 'ID' - Local User ID
64
+ 'did' - Local User ID
65
65
  It will be set before connecting to remote station.
66
66
  When it's empty, the session state would be 'Default'.
67
67
 
@@ -90,7 +90,7 @@ class ClientMessagePacker(CommonMessagePacker):
90
90
  error = {
91
91
  'message': 'encrypt keys not found',
92
92
  'group': str(receiver),
93
- 'members': ID.revert(array=waiting),
93
+ 'members': ID.revert(identifiers=waiting),
94
94
  }
95
95
  self.messenger.suspend_instant_message(msg=msg, error=error)
96
96
  # perhaps some members have already disappeared,
@@ -34,6 +34,7 @@ from .dbi import *
34
34
 
35
35
  from .anonymous import Anonymous
36
36
  from .register import Register
37
+ from .ans import AddressNameService
37
38
  from .ans import AddressNameServer, ANSFactory
38
39
 
39
40
  from .checker import EntityChecker
@@ -48,7 +49,7 @@ from .session import Transmitter, Session
48
49
 
49
50
  __all__ = [
50
51
 
51
- 'MetaType',
52
+ 'MetaVersion',
52
53
  'Password',
53
54
  'BroadcastUtils',
54
55
 
@@ -91,7 +92,9 @@ __all__ = [
91
92
  #
92
93
 
93
94
  'Anonymous',
94
- 'AddressNameServer', 'ANSFactory',
95
+ 'AddressNameService',
96
+ 'AddressNameServer',
97
+ 'ANSFactory',
95
98
 
96
99
  'EntityChecker',
97
100
  'CommonArchivist',
@@ -30,11 +30,68 @@
30
30
  A map for short name to ID, just like DNS
31
31
  """
32
32
 
33
+ from abc import ABC, abstractmethod
33
34
  from typing import Optional, List, Dict
34
35
 
35
36
  from dimsdk import Address, ID, IDFactory
36
37
  from dimsdk import ANYONE, EVERYONE, FOUNDER
37
- from dimsdk import AddressNameService
38
+
39
+
40
+ class AddressNameService(ABC):
41
+
42
+ #
43
+ # Reserved names
44
+ #
45
+ KEYWORDS = [
46
+ "all", "everyone", "anyone", "owner", "founder",
47
+ # --------------------------------
48
+ "dkd", "mkm", "dimp", "dim", "dimt",
49
+ "rsa", "ecc", "aes", "des", "btc", "eth",
50
+ # --------------------------------
51
+ "crypto", "key", "symmetric", "asymmetric",
52
+ "public", "private", "secret", "password",
53
+ "id", "address", "meta",
54
+ "tai", "document", "profile", "visa", "bulletin",
55
+ "entity", "user", "group", "contact",
56
+ # --------------------------------
57
+ "member", "admin", "administrator", "assistant",
58
+ "main", "polylogue", "chatroom",
59
+ "social", "organization",
60
+ "company", "school", "government", "department",
61
+ "provider", "station", "thing", "bot", "robot",
62
+ # --------------------------------
63
+ "message", "instant", "secure", "reliable",
64
+ "envelope", "sender", "receiver", "time",
65
+ "content", "forward", "command", "history",
66
+ "keys", "data", "signature",
67
+ # --------------------------------
68
+ "type", "serial", "sn",
69
+ "text", "file", "image", "audio", "video", "page",
70
+ "handshake", "receipt", "block", "mute",
71
+ "register", "suicide", "found", "abdicate",
72
+ "invite", "expel", "join", "quit", "reset", "query",
73
+ "hire", "fire", "resign",
74
+ # --------------------------------
75
+ "server", "client", "terminal", "local", "remote",
76
+ "barrack", "cache", "transceiver",
77
+ "ans", "facebook", "store", "messenger",
78
+ "root", "supervisor",
79
+ ]
80
+
81
+ @abstractmethod
82
+ def is_reserved(self, name: str) -> bool:
83
+ # return name in self.KEYWORDS
84
+ raise NotImplemented
85
+
86
+ @abstractmethod
87
+ def identifier(self, name: str) -> Optional[ID]:
88
+ """ Get ID by short name """
89
+ raise NotImplemented
90
+
91
+ @abstractmethod
92
+ def names(self, identifier: ID) -> List[str]:
93
+ """ Get all short names mapping to the same ID """
94
+ raise NotImplemented
38
95
 
39
96
 
40
97
  class AddressNameServer(AddressNameService):
@@ -0,0 +1,106 @@
1
+ # -*- coding: utf-8 -*-
2
+ #
3
+ # DIM-SDK : Decentralized Instant Messaging Software Development Kit
4
+ #
5
+ # Written in 2023 by Moky <albert.moky@gmail.com>
6
+ #
7
+ # ==============================================================================
8
+ # MIT License
9
+ #
10
+ # Copyright (c) 2023 Albert Moky
11
+ #
12
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
13
+ # of this software and associated documentation files (the "Software"), to deal
14
+ # in the Software without restriction, including without limitation the rights
15
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16
+ # copies of the Software, and to permit persons to whom the Software is
17
+ # furnished to do so, subject to the following conditions:
18
+ #
19
+ # The above copyright notice and this permission notice shall be included in all
20
+ # copies or substantial portions of the Software.
21
+ #
22
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28
+ # SOFTWARE.
29
+ # ==============================================================================
30
+
31
+ import weakref
32
+ from typing import List, Optional
33
+
34
+ from dimsdk import ID
35
+ from dimsdk import User, Group
36
+ from dimsdk import Facebook
37
+ from dimsdk import Barrack
38
+
39
+ from ..utils import Logging
40
+ from ..utils import ThanosCache
41
+
42
+ from .dbi import AccountDBI
43
+
44
+
45
+ class CommonArchivist(Barrack, Logging):
46
+
47
+ def __init__(self, facebook: Facebook, database: AccountDBI):
48
+ super().__init__()
49
+ self.__barrack = weakref.ref(facebook)
50
+ self.__database = database
51
+ # memory caches
52
+ self.__user_cache = ThanosCache() # ID -> User
53
+ self.__group_cache = ThanosCache() # ID -> Group
54
+
55
+ @property
56
+ def facebook(self) -> Optional[Facebook]:
57
+ return self.__barrack()
58
+
59
+ @property
60
+ def database(self) -> AccountDBI:
61
+ return self.__database
62
+
63
+ def reduce_memory(self):
64
+ cnt1 = self.__user_cache.reduce_memory()
65
+ cnt2 = self.__group_cache.reduce_memory()
66
+ return cnt1 + cnt2
67
+
68
+ #
69
+ # Barrack
70
+ #
71
+
72
+ # Override
73
+ def cache_user(self, user: User):
74
+ if user.data_source is None:
75
+ user.data_source = self.facebook
76
+ self.__user_cache.put(key=user.identifier, value=user)
77
+
78
+ # Override
79
+ def cache_group(self, group: Group):
80
+ if group.data_source is None:
81
+ group.data_source = self.facebook
82
+ self.__group_cache.put(key=group.identifier, value=group)
83
+
84
+ # Override
85
+ def get_user(self, identifier: ID):
86
+ return self.__user_cache.get(key=identifier)
87
+
88
+ # Override
89
+ def get_group(self, identifier: ID):
90
+ return self.__group_cache.get(key=identifier)
91
+
92
+ @property # Override
93
+ async def local_users(self) -> List[User]:
94
+ facebook = self.facebook
95
+ array = await self.database.get_local_users()
96
+ if facebook is None or array is None:
97
+ return []
98
+ all_users = []
99
+ for item in array:
100
+ # assert await facebook.private_key_for_signature(identifier=item) is not None
101
+ user = await facebook.get_user(identifier=item)
102
+ if user is not None:
103
+ all_users.append(user)
104
+ else:
105
+ assert False, 'failed to create user: %s' % item
106
+ return all_users
@@ -41,7 +41,7 @@ from .meta import CompatibleMetaFactory
41
41
  from .loader import CommonLoader
42
42
  from .loader import CommonPluginLoader
43
43
 
44
- from .compatible import Compatible
44
+ from .compatible import Compatible, CompatibleIncoming, CompatibleOutgoing
45
45
 
46
46
 
47
47
  __all__ = [
@@ -59,6 +59,6 @@ __all__ = [
59
59
  'CommonLoader',
60
60
  'CommonPluginLoader',
61
61
 
62
- 'Compatible',
62
+ 'Compatible', 'CompatibleIncoming', 'CompatibleOutgoing',
63
63
 
64
64
  ]
@@ -30,13 +30,14 @@
30
30
 
31
31
  from typing import Optional
32
32
 
33
- from dimsdk.core import thanos
34
33
  from dimsdk import ConstantString
35
34
  from dimsdk import EntityType
36
35
  from dimsdk import Address, ANYWHERE, EVERYWHERE
37
36
  from dimplugins import BTCAddress, ETHAddress
38
37
  from dimplugins import BaseAddressFactory
39
38
 
39
+ from ...utils.thanos import thanos
40
+
40
41
 
41
42
  class CompatibleAddressFactory(BaseAddressFactory):
42
43