dimp 2.3.4__tar.gz → 2.4.0__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.
- {dimp-2.3.4 → dimp-2.4.0}/PKG-INFO +84 -20
- {dimp-2.3.4 → dimp-2.4.0}/README.md +83 -19
- {dimp-2.3.4 → dimp-2.4.0}/dimp/__init__.py +142 -62
- {dimp-2.3.4 → dimp-2.4.0}/dimp/crypto/__init__.py +9 -21
- {dimp-2.3.4 → dimp-2.4.0}/dimp/crypto/algorithms.py +0 -15
- {dimp-2.3.4 → dimp-2.4.0}/dimp/dkd/__init__.py +48 -43
- {dimp-2.3.4/dimp/msg → dimp-2.4.0/dimp/dkd}/base.py +8 -7
- {dimp-2.3.4/dimp/msg → dimp-2.4.0/dimp/dkd}/envelope.py +6 -7
- {dimp-2.3.4/dimp/msg → dimp-2.4.0/dimp/dkd}/instant.py +35 -25
- {dimp-2.3.4/dimp/msg → dimp-2.4.0/dimp/dkd}/reliable.py +15 -14
- {dimp-2.3.4/dimp/msg → dimp-2.4.0/dimp/dkd}/secure.py +24 -37
- {dimp-2.3.4 → dimp-2.4.0}/dimp/ext/__init__.py +40 -25
- dimp-2.4.0/dimp/format/__init__.py +110 -0
- dimp-2.4.0/dimp/format/base.py +208 -0
- dimp-2.4.0/dimp/format/data.py +113 -0
- dimp-2.4.0/dimp/format/duri.py +284 -0
- dimp-2.4.0/dimp/format/embed.py +224 -0
- dimp-2.4.0/dimp/format/file.py +245 -0
- dimp-2.4.0/dimp/format/file_wrapper.py +158 -0
- dimp-2.4.0/dimp/format/pnf.py +182 -0
- dimp-2.4.0/dimp/format/pnf_wrapper.py +222 -0
- {dimp-2.3.4 → dimp-2.4.0}/dimp/mkm/__init__.py +24 -22
- {dimp-2.3.4 → dimp-2.4.0}/dimp/mkm/docs.py +47 -55
- {dimp-2.3.4 → dimp-2.4.0}/dimp/mkm/document.py +43 -52
- {dimp-2.3.4 → dimp-2.4.0}/dimp/mkm/meta.py +35 -21
- dimp-2.4.0/dimp/protocol/__init__.py +187 -0
- {dimp-2.3.4 → dimp-2.4.0}/dimp/protocol/assets.py +12 -12
- {dimp-2.3.4 → dimp-2.4.0}/dimp/protocol/base.py +96 -89
- {dimp-2.3.4 → dimp-2.4.0}/dimp/protocol/commands.py +14 -14
- {dimp-2.3.4 → dimp-2.4.0}/dimp/protocol/contents.py +71 -46
- {dimp-2.3.4 → dimp-2.4.0}/dimp/protocol/docs.py +39 -17
- {dimp-2.3.4 → dimp-2.4.0}/dimp/protocol/files.py +141 -86
- {dimp-2.3.4 → dimp-2.4.0}/dimp/protocol/forward.py +33 -43
- dimp-2.4.0/dimp/protocol/groups.py +257 -0
- {dimp-2.3.4 → dimp-2.4.0}/dimp/protocol/quote.py +90 -34
- {dimp-2.3.4 → dimp-2.4.0}/dimp/protocol/receipt.py +17 -33
- {dimp-2.3.4 → dimp-2.4.0}/dimp/protocol/types.py +12 -61
- dimp-2.4.0/dimp/protocol/version.py +78 -0
- {dimp-2.3.4 → dimp-2.4.0}/dimp.egg-info/PKG-INFO +84 -20
- {dimp-2.3.4 → dimp-2.4.0}/dimp.egg-info/SOURCES.txt +16 -12
- dimp-2.4.0/dimp.egg-info/requires.txt +2 -0
- {dimp-2.3.4 → dimp-2.4.0}/setup.py +3 -3
- dimp-2.3.4/dimp/crypto/keys.py +0 -194
- dimp-2.3.4/dimp/crypto/pnf.py +0 -150
- dimp-2.3.4/dimp/crypto/ted.py +0 -154
- dimp-2.3.4/dimp/msg/__init__.py +0 -68
- dimp-2.3.4/dimp/protocol/__init__.py +0 -130
- dimp-2.3.4/dimp/protocol/app.py +0 -135
- dimp-2.3.4/dimp/protocol/groups.py +0 -466
- dimp-2.3.4/dimp/protocol/helpers.py +0 -41
- dimp-2.3.4/dimp.egg-info/requires.txt +0 -2
- {dimp-2.3.4 → dimp-2.4.0}/LICENSE +0 -0
- {dimp-2.3.4 → dimp-2.4.0}/dimp.egg-info/dependency_links.txt +0 -0
- {dimp-2.3.4 → dimp-2.4.0}/dimp.egg-info/top_level.txt +0 -0
- {dimp-2.3.4 → dimp-2.4.0}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: dimp
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.4.0
|
|
4
4
|
Summary: Decentralized Instant Messaging Protocol
|
|
5
5
|
Home-page: https://github.com/dimchat/core-py
|
|
6
6
|
Author: Albert Moky
|
|
@@ -49,7 +49,7 @@ from abc import ABC, abstractmethod
|
|
|
49
49
|
from enum import IntEnum
|
|
50
50
|
from typing import Optional, Dict
|
|
51
51
|
|
|
52
|
-
from dimp import
|
|
52
|
+
from dimp import *
|
|
53
53
|
|
|
54
54
|
|
|
55
55
|
class HandshakeState(IntEnum):
|
|
@@ -78,12 +78,12 @@ class HandshakeCommand(Command, ABC):
|
|
|
78
78
|
~~~~~~~~~~~~~~~~~
|
|
79
79
|
|
|
80
80
|
data format: {
|
|
81
|
-
type : 0x88,
|
|
82
|
-
sn :
|
|
81
|
+
"type" : i2s(0x88),
|
|
82
|
+
"sn" : 12345,
|
|
83
83
|
|
|
84
|
-
command : "handshake", // command name
|
|
85
|
-
title : "Hello world!", // "DIM?", "DIM!"
|
|
86
|
-
session : "{SESSION_ID}", // session key
|
|
84
|
+
"command" : "handshake", // command name
|
|
85
|
+
"title" : "Hello world!", // "DIM?", "DIM!"
|
|
86
|
+
"session" : "{SESSION_ID}", // session key
|
|
87
87
|
}
|
|
88
88
|
"""
|
|
89
89
|
HANDSHAKE = 'handshake'
|
|
@@ -175,42 +175,106 @@ class BaseHandshakeCommand(BaseCommand, HandshakeCommand):
|
|
|
175
175
|
### Extends Content
|
|
176
176
|
|
|
177
177
|
```python
|
|
178
|
-
from
|
|
178
|
+
from abc import ABC, abstractmethod
|
|
179
179
|
|
|
180
180
|
from dimp import *
|
|
181
181
|
|
|
182
182
|
|
|
183
|
-
class
|
|
183
|
+
class AppContent(Content, ABC):
|
|
184
|
+
"""
|
|
185
|
+
Content for Application 0nly
|
|
186
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
187
|
+
|
|
188
|
+
data format: {
|
|
189
|
+
"type" : i2s(0xA0),
|
|
190
|
+
"sn" : 12345,
|
|
191
|
+
|
|
192
|
+
"app" : "{APP_ID}", // application (e.g.: "chat.dim.sechat")
|
|
193
|
+
"extra" : info // action parameters
|
|
194
|
+
}
|
|
195
|
+
"""
|
|
196
|
+
|
|
197
|
+
@property
|
|
198
|
+
@abstractmethod
|
|
199
|
+
def application(self) -> str:
|
|
200
|
+
""" App ID """
|
|
201
|
+
raise NotImplemented
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
class CustomizedContent(Content, ABC):
|
|
184
205
|
"""
|
|
185
206
|
Application Customized message
|
|
186
207
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
187
208
|
|
|
188
209
|
data format: {
|
|
189
|
-
type : i2s(
|
|
190
|
-
sn :
|
|
210
|
+
"type" : i2s(0xCC),
|
|
211
|
+
"sn" : 12345,
|
|
191
212
|
|
|
192
|
-
app : "{APP_ID}", // application (e.g.: "chat.dim.sechat")
|
|
193
|
-
|
|
213
|
+
"app" : "{APP_ID}", // application (e.g.: "chat.dim.sechat")
|
|
214
|
+
"mod" : "{MODULE}", // module name (e.g.: "drift_bottle")
|
|
215
|
+
"act" : "{ACTION}", // action name (e.g.: "throw")
|
|
216
|
+
"extra" : info // action parameters
|
|
194
217
|
}
|
|
195
218
|
"""
|
|
196
219
|
|
|
197
|
-
|
|
198
|
-
|
|
220
|
+
@property
|
|
221
|
+
@abstractmethod
|
|
222
|
+
def module(self) -> str:
|
|
223
|
+
""" Module Name """
|
|
224
|
+
raise NotImplemented
|
|
225
|
+
|
|
226
|
+
@property
|
|
227
|
+
@abstractmethod
|
|
228
|
+
def action(self) -> str:
|
|
229
|
+
""" Action Name """
|
|
230
|
+
raise NotImplemented
|
|
231
|
+
|
|
232
|
+
#
|
|
233
|
+
# Factory method
|
|
234
|
+
#
|
|
235
|
+
@classmethod
|
|
236
|
+
def create(cls, app: str, mod: str, act: str):
|
|
237
|
+
return AppCustomizedContent(app=app, mod=mod, act=act)
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
```python
|
|
241
|
+
from typing import Dict
|
|
242
|
+
|
|
243
|
+
from dimp import *
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
class AppCustomizedContent(BaseContent, AppContent, CustomizedContent):
|
|
247
|
+
|
|
248
|
+
def __init__(self, content: Dict = None,
|
|
249
|
+
msg_type: str = None,
|
|
250
|
+
app: str = None, mod: str = None, act: str = None):
|
|
199
251
|
if content is None:
|
|
200
|
-
# 1. new content with type,
|
|
201
|
-
assert app is not None
|
|
252
|
+
# 1. new content with type, application, module & action
|
|
253
|
+
assert app is not None and mod is not None and act is not None, \
|
|
254
|
+
'customized content error: %s, %s, %s, %s' % (msg_type, app, mod, act)
|
|
202
255
|
if msg_type is None:
|
|
203
|
-
msg_type = ContentType.
|
|
256
|
+
msg_type = ContentType.CUSTOMIZED
|
|
204
257
|
super().__init__(None, msg_type)
|
|
205
258
|
self['app'] = app
|
|
259
|
+
self['mod'] = mod
|
|
260
|
+
self['act'] = act
|
|
206
261
|
else:
|
|
207
262
|
# 2. content info from network
|
|
208
|
-
assert msg_type is None and app is None
|
|
263
|
+
assert msg_type is None and app is None and mod is None and act is None, \
|
|
264
|
+
'params error: %s, %s, %s, %s, %s' % (content, msg_type, app, mod, act)
|
|
209
265
|
super().__init__(content)
|
|
210
266
|
|
|
211
267
|
@property # Override
|
|
212
268
|
def application(self) -> str:
|
|
213
269
|
return self.get_str(key='app', default='')
|
|
270
|
+
|
|
271
|
+
@property # Override
|
|
272
|
+
def module(self) -> str:
|
|
273
|
+
return self.get_str(key='mod', default='')
|
|
274
|
+
|
|
275
|
+
@property # Override
|
|
276
|
+
def action(self) -> str:
|
|
277
|
+
return self.get_str(key='act', default='')
|
|
214
278
|
```
|
|
215
279
|
|
|
216
280
|
### Extends ID Address
|
|
@@ -219,5 +283,5 @@ class ApplicationContent(BaseContent, AppContent):
|
|
|
219
283
|
|
|
220
284
|
----
|
|
221
285
|
|
|
222
|
-
Copyright © 2018-
|
|
286
|
+
Copyright © 2018-2026 Albert Moky
|
|
223
287
|
[](https://github.com/moky?tab=followers)
|
|
@@ -35,7 +35,7 @@ from abc import ABC, abstractmethod
|
|
|
35
35
|
from enum import IntEnum
|
|
36
36
|
from typing import Optional, Dict
|
|
37
37
|
|
|
38
|
-
from dimp import
|
|
38
|
+
from dimp import *
|
|
39
39
|
|
|
40
40
|
|
|
41
41
|
class HandshakeState(IntEnum):
|
|
@@ -64,12 +64,12 @@ class HandshakeCommand(Command, ABC):
|
|
|
64
64
|
~~~~~~~~~~~~~~~~~
|
|
65
65
|
|
|
66
66
|
data format: {
|
|
67
|
-
type : 0x88,
|
|
68
|
-
sn :
|
|
67
|
+
"type" : i2s(0x88),
|
|
68
|
+
"sn" : 12345,
|
|
69
69
|
|
|
70
|
-
command : "handshake", // command name
|
|
71
|
-
title : "Hello world!", // "DIM?", "DIM!"
|
|
72
|
-
session : "{SESSION_ID}", // session key
|
|
70
|
+
"command" : "handshake", // command name
|
|
71
|
+
"title" : "Hello world!", // "DIM?", "DIM!"
|
|
72
|
+
"session" : "{SESSION_ID}", // session key
|
|
73
73
|
}
|
|
74
74
|
"""
|
|
75
75
|
HANDSHAKE = 'handshake'
|
|
@@ -161,42 +161,106 @@ class BaseHandshakeCommand(BaseCommand, HandshakeCommand):
|
|
|
161
161
|
### Extends Content
|
|
162
162
|
|
|
163
163
|
```python
|
|
164
|
-
from
|
|
164
|
+
from abc import ABC, abstractmethod
|
|
165
165
|
|
|
166
166
|
from dimp import *
|
|
167
167
|
|
|
168
168
|
|
|
169
|
-
class
|
|
169
|
+
class AppContent(Content, ABC):
|
|
170
|
+
"""
|
|
171
|
+
Content for Application 0nly
|
|
172
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
173
|
+
|
|
174
|
+
data format: {
|
|
175
|
+
"type" : i2s(0xA0),
|
|
176
|
+
"sn" : 12345,
|
|
177
|
+
|
|
178
|
+
"app" : "{APP_ID}", // application (e.g.: "chat.dim.sechat")
|
|
179
|
+
"extra" : info // action parameters
|
|
180
|
+
}
|
|
181
|
+
"""
|
|
182
|
+
|
|
183
|
+
@property
|
|
184
|
+
@abstractmethod
|
|
185
|
+
def application(self) -> str:
|
|
186
|
+
""" App ID """
|
|
187
|
+
raise NotImplemented
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
class CustomizedContent(Content, ABC):
|
|
170
191
|
"""
|
|
171
192
|
Application Customized message
|
|
172
193
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
173
194
|
|
|
174
195
|
data format: {
|
|
175
|
-
type : i2s(
|
|
176
|
-
sn :
|
|
196
|
+
"type" : i2s(0xCC),
|
|
197
|
+
"sn" : 12345,
|
|
177
198
|
|
|
178
|
-
app : "{APP_ID}", // application (e.g.: "chat.dim.sechat")
|
|
179
|
-
|
|
199
|
+
"app" : "{APP_ID}", // application (e.g.: "chat.dim.sechat")
|
|
200
|
+
"mod" : "{MODULE}", // module name (e.g.: "drift_bottle")
|
|
201
|
+
"act" : "{ACTION}", // action name (e.g.: "throw")
|
|
202
|
+
"extra" : info // action parameters
|
|
180
203
|
}
|
|
181
204
|
"""
|
|
182
205
|
|
|
183
|
-
|
|
184
|
-
|
|
206
|
+
@property
|
|
207
|
+
@abstractmethod
|
|
208
|
+
def module(self) -> str:
|
|
209
|
+
""" Module Name """
|
|
210
|
+
raise NotImplemented
|
|
211
|
+
|
|
212
|
+
@property
|
|
213
|
+
@abstractmethod
|
|
214
|
+
def action(self) -> str:
|
|
215
|
+
""" Action Name """
|
|
216
|
+
raise NotImplemented
|
|
217
|
+
|
|
218
|
+
#
|
|
219
|
+
# Factory method
|
|
220
|
+
#
|
|
221
|
+
@classmethod
|
|
222
|
+
def create(cls, app: str, mod: str, act: str):
|
|
223
|
+
return AppCustomizedContent(app=app, mod=mod, act=act)
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
```python
|
|
227
|
+
from typing import Dict
|
|
228
|
+
|
|
229
|
+
from dimp import *
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
class AppCustomizedContent(BaseContent, AppContent, CustomizedContent):
|
|
233
|
+
|
|
234
|
+
def __init__(self, content: Dict = None,
|
|
235
|
+
msg_type: str = None,
|
|
236
|
+
app: str = None, mod: str = None, act: str = None):
|
|
185
237
|
if content is None:
|
|
186
|
-
# 1. new content with type,
|
|
187
|
-
assert app is not None
|
|
238
|
+
# 1. new content with type, application, module & action
|
|
239
|
+
assert app is not None and mod is not None and act is not None, \
|
|
240
|
+
'customized content error: %s, %s, %s, %s' % (msg_type, app, mod, act)
|
|
188
241
|
if msg_type is None:
|
|
189
|
-
msg_type = ContentType.
|
|
242
|
+
msg_type = ContentType.CUSTOMIZED
|
|
190
243
|
super().__init__(None, msg_type)
|
|
191
244
|
self['app'] = app
|
|
245
|
+
self['mod'] = mod
|
|
246
|
+
self['act'] = act
|
|
192
247
|
else:
|
|
193
248
|
# 2. content info from network
|
|
194
|
-
assert msg_type is None and app is None
|
|
249
|
+
assert msg_type is None and app is None and mod is None and act is None, \
|
|
250
|
+
'params error: %s, %s, %s, %s, %s' % (content, msg_type, app, mod, act)
|
|
195
251
|
super().__init__(content)
|
|
196
252
|
|
|
197
253
|
@property # Override
|
|
198
254
|
def application(self) -> str:
|
|
199
255
|
return self.get_str(key='app', default='')
|
|
256
|
+
|
|
257
|
+
@property # Override
|
|
258
|
+
def module(self) -> str:
|
|
259
|
+
return self.get_str(key='mod', default='')
|
|
260
|
+
|
|
261
|
+
@property # Override
|
|
262
|
+
def action(self) -> str:
|
|
263
|
+
return self.get_str(key='act', default='')
|
|
200
264
|
```
|
|
201
265
|
|
|
202
266
|
### Extends ID Address
|
|
@@ -205,5 +269,5 @@ class ApplicationContent(BaseContent, AppContent):
|
|
|
205
269
|
|
|
206
270
|
----
|
|
207
271
|
|
|
208
|
-
Copyright © 2018-
|
|
272
|
+
Copyright © 2018-2026 Albert Moky
|
|
209
273
|
[](https://github.com/moky?tab=followers)
|
|
@@ -28,18 +28,12 @@
|
|
|
28
28
|
# SOFTWARE.
|
|
29
29
|
# ==============================================================================
|
|
30
30
|
|
|
31
|
-
from
|
|
32
|
-
from mkm.format import *
|
|
33
|
-
from mkm.crypto import *
|
|
34
|
-
from mkm import *
|
|
35
|
-
from dkd import *
|
|
36
|
-
|
|
37
|
-
from .protocol.base import CommandFactory
|
|
38
|
-
from .protocol import *
|
|
31
|
+
from .format import *
|
|
39
32
|
from .crypto import *
|
|
33
|
+
from .protocol import *
|
|
40
34
|
from .mkm import *
|
|
41
35
|
from .dkd import *
|
|
42
|
-
from .
|
|
36
|
+
from .ext import *
|
|
43
37
|
|
|
44
38
|
|
|
45
39
|
name = "DIMP"
|
|
@@ -53,6 +47,7 @@ __all__ = [
|
|
|
53
47
|
'URI', 'DateTime',
|
|
54
48
|
|
|
55
49
|
'Converter', 'DataConverter', 'BaseConverter',
|
|
50
|
+
|
|
56
51
|
'Copier',
|
|
57
52
|
'Wrapper', 'Stringer', 'Mapper',
|
|
58
53
|
'ConstantString', # 'String',
|
|
@@ -73,8 +68,42 @@ __all__ = [
|
|
|
73
68
|
'json_encode', 'json_decode',
|
|
74
69
|
'utf8_encode', 'utf8_decode',
|
|
75
70
|
|
|
76
|
-
'
|
|
77
|
-
'
|
|
71
|
+
'TransportableResource',
|
|
72
|
+
'TransportableData',
|
|
73
|
+
|
|
74
|
+
'TransportableDataFactory',
|
|
75
|
+
|
|
76
|
+
'TransportableDataHelper',
|
|
77
|
+
'FormatExtensions', 'shared_format_extensions',
|
|
78
|
+
|
|
79
|
+
'Header', 'DataURI',
|
|
80
|
+
|
|
81
|
+
#
|
|
82
|
+
# TED
|
|
83
|
+
#
|
|
84
|
+
|
|
85
|
+
'EncodeAlgorithms',
|
|
86
|
+
|
|
87
|
+
'BaseString', 'BaseData',
|
|
88
|
+
|
|
89
|
+
'Base64Data', 'PlainData',
|
|
90
|
+
'EmbedData',
|
|
91
|
+
|
|
92
|
+
#
|
|
93
|
+
# PNF
|
|
94
|
+
#
|
|
95
|
+
|
|
96
|
+
'TransportableFile', 'TransportableFileFactory',
|
|
97
|
+
# 'TransportableFileHelper', 'TransportableFileExtension',
|
|
98
|
+
'TransportableFileWrapper', 'TransportableFileWrapperFactory',
|
|
99
|
+
# 'TransportableFileWrapperExtension',
|
|
100
|
+
|
|
101
|
+
'PortableNetworkFile',
|
|
102
|
+
'PortableNetworkFileWrapper',
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
# ================================================================
|
|
106
|
+
|
|
78
107
|
|
|
79
108
|
#
|
|
80
109
|
# Digest
|
|
@@ -95,102 +124,153 @@ __all__ = [
|
|
|
95
124
|
|
|
96
125
|
'SymmetricKeyFactory', 'PrivateKeyFactory', 'PublicKeyFactory',
|
|
97
126
|
|
|
98
|
-
'
|
|
99
|
-
'BaseAsymmetricKey', 'BasePublicKey', 'BasePrivateKey',
|
|
127
|
+
'SymmetricKeyHelper', 'PublicKeyHelper', 'PrivateKeyHelper',
|
|
100
128
|
|
|
101
|
-
'
|
|
102
|
-
'
|
|
129
|
+
'SymmetricKeyExtension', 'PublicKeyExtension', 'PrivateKeyExtension',
|
|
130
|
+
'CryptoExtensions', 'shared_crypto_extensions',
|
|
103
131
|
|
|
104
132
|
#
|
|
105
|
-
#
|
|
133
|
+
# Algorithms
|
|
106
134
|
#
|
|
135
|
+
|
|
107
136
|
'AsymmetricAlgorithms', 'SymmetricAlgorithms',
|
|
108
|
-
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
# ================================================================
|
|
140
|
+
|
|
109
141
|
|
|
110
142
|
#
|
|
111
|
-
#
|
|
143
|
+
# Ming-Ke-Ming
|
|
112
144
|
#
|
|
113
145
|
|
|
114
146
|
'EntityType',
|
|
115
|
-
'Address',
|
|
116
|
-
'
|
|
117
|
-
'Meta',
|
|
118
|
-
'Document', 'Visa', 'Bulletin',
|
|
119
|
-
|
|
120
|
-
'MetaType', 'DocumentType',
|
|
147
|
+
'Address', 'ID',
|
|
148
|
+
'Meta', 'TAI', 'Document',
|
|
121
149
|
|
|
122
|
-
'AddressFactory',
|
|
123
|
-
'
|
|
124
|
-
'MetaFactory',
|
|
125
|
-
'DocumentFactory',
|
|
150
|
+
'AddressFactory', 'IDFactory',
|
|
151
|
+
'MetaFactory', 'DocumentFactory',
|
|
126
152
|
|
|
127
|
-
'Identifier',
|
|
128
|
-
'ANYONE', 'EVERYONE', 'FOUNDER',
|
|
129
153
|
'ANYWHERE', 'EVERYWHERE',
|
|
130
|
-
|
|
154
|
+
'ANYONE', 'EVERYONE', 'FOUNDER',
|
|
155
|
+
'BroadcastAddress', 'Identifier',
|
|
131
156
|
|
|
132
|
-
'
|
|
133
|
-
'
|
|
157
|
+
'AddressHelper', 'IDHelper',
|
|
158
|
+
'MetaHelper', 'DocumentHelper',
|
|
159
|
+
|
|
160
|
+
'AddressExtension', 'IDExtension',
|
|
161
|
+
'MetaExtension', 'DocumentExtension',
|
|
162
|
+
'AccountExtensions', 'shared_account_extensions',
|
|
134
163
|
|
|
135
164
|
#
|
|
136
|
-
#
|
|
165
|
+
# Dao-Ke-Dao
|
|
137
166
|
#
|
|
138
167
|
|
|
139
|
-
'
|
|
140
|
-
'Content',
|
|
141
|
-
'Envelope',
|
|
168
|
+
'Content', 'Envelope',
|
|
142
169
|
'Message',
|
|
143
170
|
'InstantMessage', 'SecureMessage', 'ReliableMessage',
|
|
144
171
|
|
|
145
|
-
|
|
172
|
+
'ContentFactory', 'EnvelopeFactory',
|
|
173
|
+
'InstantMessageFactory', 'SecureMessageFactory', 'ReliableMessageFactory',
|
|
174
|
+
|
|
175
|
+
'ContentHelper', 'EnvelopeHelper',
|
|
176
|
+
'InstantMessageHelper', 'SecureMessageHelper', 'ReliableMessageHelper',
|
|
177
|
+
|
|
178
|
+
'ContentExtension',
|
|
179
|
+
'InstantMessageExtension', 'SecureMessageExtension', 'ReliableMessageExtension',
|
|
180
|
+
'MessageExtensions', 'shared_message_extensions',
|
|
181
|
+
|
|
182
|
+
#
|
|
183
|
+
# Core Protocols
|
|
184
|
+
#
|
|
185
|
+
|
|
186
|
+
'MetaType',
|
|
187
|
+
'DocumentType',
|
|
188
|
+
'Visa', 'Bulletin',
|
|
189
|
+
|
|
190
|
+
'ContentType',
|
|
191
|
+
|
|
192
|
+
'Command', 'CommandFactory',
|
|
193
|
+
|
|
194
|
+
# 'CommandHelper', 'GeneralCommandHelper',
|
|
195
|
+
# 'CommandExtension', 'CmdExtension',
|
|
196
|
+
|
|
197
|
+
#
|
|
198
|
+
# Contents
|
|
199
|
+
#
|
|
200
|
+
|
|
146
201
|
'TextContent', 'PageContent', 'NameCard',
|
|
147
|
-
'ForwardContent', 'CombineContent', 'ArrayContent',
|
|
148
|
-
'FileContent', 'ImageContent', 'AudioContent', 'VideoContent',
|
|
149
202
|
'MoneyContent', 'TransferContent',
|
|
203
|
+
'FileContent', 'ImageContent', 'AudioContent', 'VideoContent',
|
|
204
|
+
'ForwardContent', 'CombineContent', 'ArrayContent',
|
|
150
205
|
'QuoteContent',
|
|
151
|
-
'
|
|
206
|
+
# 'QuoteHelper', 'QuotePurifier', 'QuoteExtension',
|
|
207
|
+
|
|
208
|
+
#
|
|
209
|
+
# Commands
|
|
210
|
+
#
|
|
152
211
|
|
|
153
|
-
# commands
|
|
154
|
-
'Command',
|
|
155
212
|
'MetaCommand', 'DocumentCommand',
|
|
156
213
|
'ReceiptCommand',
|
|
157
214
|
|
|
158
|
-
# group history
|
|
159
215
|
'HistoryCommand', 'GroupCommand',
|
|
160
216
|
'InviteCommand', 'ExpelCommand', 'JoinCommand', 'QuitCommand', 'ResetCommand',
|
|
161
|
-
'HireCommand', 'FireCommand', 'ResignCommand',
|
|
162
217
|
|
|
163
|
-
|
|
164
|
-
|
|
218
|
+
|
|
219
|
+
# ================================================================
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
#
|
|
223
|
+
# Account Implementations
|
|
224
|
+
#
|
|
225
|
+
|
|
226
|
+
'BaseMeta',
|
|
227
|
+
'BaseDocument', 'BaseVisa', 'BaseBulletin',
|
|
228
|
+
|
|
229
|
+
#
|
|
230
|
+
# Content Implementations
|
|
231
|
+
#
|
|
232
|
+
|
|
233
|
+
'BaseContent', 'BaseCommand',
|
|
234
|
+
# 'CommandHelper', 'GeneralCommandHelper',
|
|
235
|
+
# 'CommandExtension', 'CmdExtension',
|
|
236
|
+
|
|
165
237
|
'BaseTextContent', 'WebPageContent', 'NameCardContent',
|
|
166
|
-
'SecretContent', 'CombineForwardContent', 'ListContent',
|
|
167
|
-
'BaseFileContent', 'ImageFileContent', 'AudioFileContent', 'VideoFileContent',
|
|
168
238
|
'BaseMoneyContent', 'TransferMoneyContent',
|
|
239
|
+
'BaseFileContent', 'ImageFileContent', 'AudioFileContent', 'VideoFileContent',
|
|
240
|
+
'SecretContent', 'CombineForwardContent', 'ListContent',
|
|
169
241
|
'BaseQuoteContent',
|
|
170
|
-
'
|
|
242
|
+
# 'QuoteHelper', 'QuotePurifier', 'QuoteExtension',
|
|
171
243
|
|
|
172
|
-
# extend commands
|
|
173
|
-
'BaseCommand',
|
|
174
244
|
'BaseMetaCommand', 'BaseDocumentCommand',
|
|
175
245
|
'BaseReceiptCommand',
|
|
176
|
-
|
|
177
|
-
# extend group history
|
|
178
246
|
'BaseHistoryCommand', 'BaseGroupCommand',
|
|
179
|
-
'InviteGroupCommand', 'ExpelGroupCommand',
|
|
180
|
-
'JoinGroupCommand', 'QuitGroupCommand', 'ResetGroupCommand',
|
|
181
|
-
'HireGroupCommand', 'FireGroupCommand', 'ResignGroupCommand',
|
|
247
|
+
'InviteGroupCommand', 'ExpelGroupCommand', 'JoinGroupCommand', 'QuitGroupCommand', 'ResetGroupCommand',
|
|
182
248
|
|
|
183
249
|
#
|
|
184
|
-
# Message
|
|
250
|
+
# Message Implementations
|
|
185
251
|
#
|
|
186
252
|
|
|
187
253
|
'MessageEnvelope',
|
|
188
254
|
'BaseMessage',
|
|
189
255
|
'PlainMessage', 'EncryptedMessage', 'NetworkMessage',
|
|
190
256
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
257
|
+
|
|
258
|
+
# ================================================================
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
'GeneralCryptoHelper', 'GeneralCryptoExtension',
|
|
262
|
+
'GeneralAccountHelper', 'GeneralAccountExtension',
|
|
263
|
+
|
|
264
|
+
'GeneralMessageHelper', 'GeneralMessageExtension',
|
|
265
|
+
|
|
266
|
+
'TransportableFileHelper',
|
|
267
|
+
'TransportableFileExtension',
|
|
268
|
+
'TransportableFileWrapperExtension',
|
|
269
|
+
|
|
270
|
+
'CommandHelper', 'GeneralCommandHelper',
|
|
271
|
+
'CommandExtension', 'CmdExtension',
|
|
272
|
+
|
|
273
|
+
'QuoteHelper', 'QuotePurifier',
|
|
274
|
+
'QuoteExtension',
|
|
195
275
|
|
|
196
276
|
]
|
|
@@ -28,16 +28,11 @@
|
|
|
28
28
|
# SOFTWARE.
|
|
29
29
|
# ==============================================================================
|
|
30
30
|
|
|
31
|
+
from mkm.digest import *
|
|
31
32
|
from mkm.crypto import *
|
|
32
33
|
|
|
33
34
|
from .algorithms import AsymmetricAlgorithms, SymmetricAlgorithms
|
|
34
|
-
from .algorithms import EncodeAlgorithms
|
|
35
35
|
|
|
36
|
-
from .keys import BaseKey, BaseSymmetricKey
|
|
37
|
-
from .keys import BaseAsymmetricKey, BasePublicKey, BasePrivateKey
|
|
38
|
-
|
|
39
|
-
from .ted import BaseDataWrapper
|
|
40
|
-
from .pnf import BaseFileWrapper
|
|
41
36
|
|
|
42
37
|
__all__ = [
|
|
43
38
|
|
|
@@ -60,22 +55,15 @@ __all__ = [
|
|
|
60
55
|
|
|
61
56
|
'SymmetricKeyFactory', 'PrivateKeyFactory', 'PublicKeyFactory',
|
|
62
57
|
|
|
63
|
-
#
|
|
64
|
-
# Algorithm
|
|
65
|
-
#
|
|
66
|
-
'AsymmetricAlgorithms', 'SymmetricAlgorithms',
|
|
67
|
-
'EncodeAlgorithms',
|
|
58
|
+
# 'SymmetricKeyHelper', 'PublicKeyHelper', 'PrivateKeyHelper',
|
|
68
59
|
|
|
69
|
-
#
|
|
70
|
-
#
|
|
71
|
-
#
|
|
72
|
-
'BaseKey', 'BaseSymmetricKey',
|
|
73
|
-
'BaseAsymmetricKey', 'BasePublicKey', 'BasePrivateKey',
|
|
60
|
+
# 'SymmetricKeyExtension', 'PublicKeyExtension', 'PrivateKeyExtension',
|
|
61
|
+
# 'CryptoExtensions', 'shared_crypto_extensions',
|
|
74
62
|
|
|
75
|
-
|
|
76
|
-
#
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
'
|
|
63
|
+
|
|
64
|
+
# ----------------------------------------------------------------
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
'AsymmetricAlgorithms', 'SymmetricAlgorithms',
|
|
80
68
|
|
|
81
69
|
]
|
|
@@ -1,9 +1,4 @@
|
|
|
1
1
|
# -*- coding: utf-8 -*-
|
|
2
|
-
#
|
|
3
|
-
# DIMP : Decentralized Instant Messaging Protocol
|
|
4
|
-
#
|
|
5
|
-
# Written in 2025 by Moky <albert.moky@gmail.com>
|
|
6
|
-
#
|
|
7
2
|
# ==============================================================================
|
|
8
3
|
# MIT License
|
|
9
4
|
#
|
|
@@ -45,13 +40,3 @@ class SymmetricAlgorithms:
|
|
|
45
40
|
# Symmetric key algorithm for broadcast message,
|
|
46
41
|
# which will do nothing when en/decoding message data
|
|
47
42
|
PLAIN = 'PLAIN'
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
class EncodeAlgorithms:
|
|
51
|
-
""" Algorithms for Encoding Data """
|
|
52
|
-
|
|
53
|
-
DEFAULT = 'base64'
|
|
54
|
-
|
|
55
|
-
BASE_64 = 'base64'
|
|
56
|
-
BASE_58 = 'base58'
|
|
57
|
-
HEX = 'hex'
|