@ethernity-cloud/sdk-js 1.6.1 → 1.7.0
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.
- package/README.md +44 -6
- package/cas/config.js +61 -3
- package/info.js +333 -324
- package/init.js +20 -4
- package/nodenithy/build/securelock/Dockerfile.tmpl +34 -32
- package/nodenithy/build/securelock/scripts/binary-fs-build.sh +7 -6
- package/nodenithy/build/securelock/src/securelock.js.tmpl +5 -2
- package/nodenithy/build.mjs +83 -71
- package/nodenithy/run/docker-compose-final.yml.tmpl +36 -31
- package/nodenithy/run/docker-compose.yml.tmpl +34 -45
- package/nodenithy/run/image_registry.js +396 -380
- package/nodenithy/run.js +42 -28
- package/package.json +5 -3
- package/publish.js +4 -2
- package/pynithy/build/securelock/Dockerfile.base.tpl +13 -0
- package/pynithy/build/securelock/Dockerfile.tpl +131 -0
- package/pynithy/build/securelock/scripts/binary-fs-build.sh +25 -34
- package/pynithy/build/securelock/scripts/pyfreeze.sh +32 -0
- package/pynithy/build/securelock/src/{pox.abi → abi/etnyImplementationV2.abi} +1489 -1489
- package/pynithy/build/securelock/src/abi/image_registry.abi +1 -0
- package/pynithy/build/securelock/src/ecld_state.py +906 -0
- package/pynithy/build/securelock/src/esr.abi +1 -0
- package/pynithy/build/securelock/src/esr_local.py +267 -0
- package/pynithy/build/securelock/src/esr_wallet.py +150 -0
- package/pynithy/build/securelock/src/etny_crypto.py +208 -167
- package/pynithy/build/securelock/src/etny_exec.py +385 -79
- package/pynithy/build/securelock/src/etny_exec_flask.py +535 -0
- package/pynithy/build/securelock/src/etny_exec_serv.py +353 -0
- package/pynithy/build/securelock/src/etny_session_exec.py +245 -0
- package/pynithy/build/securelock/src/get_sgx_report.so +0 -0
- package/pynithy/build/securelock/src/image_registry.abi +1 -1
- package/pynithy/build/securelock/src/key_generation.py +17 -17
- package/pynithy/build/securelock/src/local_api.py +189 -0
- package/pynithy/build/securelock/src/models.py +200 -176
- package/pynithy/build/securelock/src/securelock.py.tmpl +1037 -727
- package/pynithy/build/securelock/src/swift_stream_service.py +206 -186
- package/pynithy/build.mjs +142 -92
- package/pynithy/run/docker-compose-final.yml.tmpl +58 -51
- package/pynithy/run/docker-compose.yml.tmpl +62 -48
- package/pynithy/run/etny-securelock-test.yaml.tpl +4 -1
- package/pynithy/run/image_registry.js +396 -380
- package/pynithy/run.js +44 -28
- package/pynithy/src/serverless/Dockerfile.serverless +8 -0
- package/pynithy/src/serverless/requirements.txt +6 -0
- package/run.js +69 -28
- package/nodenithy/build/las/Dockerfile +0 -5
- package/pynithy/build/docker-compose.yml +0 -70
- package/pynithy/build/las/Dockerfile +0 -11
- package/pynithy/build/las/src/etny_entrypoint.sh +0 -6
- package/pynithy/build/las/src/las_entrypoint.sh +0 -26
- package/pynithy/build/scripts/binary-fs-build.sh +0 -28
- package/pynithy/build/securelock/Dockerfile.tmpl +0 -95
|
@@ -1,176 +1,200 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
class
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
class
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
self._ipfs_hash
|
|
86
|
-
|
|
87
|
-
@property
|
|
88
|
-
def
|
|
89
|
-
return
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
def
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
def
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
self.
|
|
115
|
-
self.
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
1
|
+
"""
|
|
2
|
+
Module: models.py
|
|
3
|
+
|
|
4
|
+
This module defines data models and factories for handling orders and metadata in a blockchain-based task processing system. It includes classes for orders, base metadata, versioned payload and input metadata (V0 and V3), and factories to create metadata objects based on version strings. Additionally, it provides a class for DO (Data Owner?) request metadata, parsing and exposing properties like image hash, public key, and node address. The models support versioning, with V3 including checksums (potentially signed) for integrity verification.
|
|
5
|
+
|
|
6
|
+
Key Features:
|
|
7
|
+
- Order model: Represents blockchain orders with attributes like owner, processor, requests, and status.
|
|
8
|
+
- Metadata base and subclasses: Abstract base for metadata with version, IPFS hash, and optional checksum; V0 is hash-only, V3 includes checksum.
|
|
9
|
+
- Factories: Dynamically create versioned metadata objects from strings (e.g., "v3:hash:checksum").
|
|
10
|
+
- DOReqMetadata: Parses request metadata into accessible properties, integrating with factories for payload/input objects.
|
|
11
|
+
- No external dependencies beyond standard Python.
|
|
12
|
+
|
|
13
|
+
Usage Context: Used in trustedzone.py to fetch and parse order/request metadata from smart contracts, enabling validation and processing in secure environments like Ethernity/Etny.
|
|
14
|
+
|
|
15
|
+
Potential Security Notes: Checksums in V3 can be signed (0x-prefixed), but validation logic is external (e.g., in trustedzone.py). Assumes metadata strings are trusted from blockchain; malformed inputs could raise ValueError.
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
class Order:
|
|
19
|
+
def __init__(self, req, order_id):
|
|
20
|
+
self.id = order_id
|
|
21
|
+
self.do_owner = req[0]
|
|
22
|
+
self.dproc = req[1]
|
|
23
|
+
self.do_req = req[2]
|
|
24
|
+
self.dp_req = req[3]
|
|
25
|
+
self.status = req[4]
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class MetadataBase:
|
|
29
|
+
def __init__(self, metadata, version):
|
|
30
|
+
self.metadata = metadata
|
|
31
|
+
self._version = version
|
|
32
|
+
|
|
33
|
+
@property
|
|
34
|
+
def version(self):
|
|
35
|
+
return self._version
|
|
36
|
+
|
|
37
|
+
@property
|
|
38
|
+
def ipfs_hash(self):
|
|
39
|
+
raise NotImplementedError("Subclass must implement this method")
|
|
40
|
+
|
|
41
|
+
def checksum(self):
|
|
42
|
+
raise NotImplementedError("Subclass must implement this method")
|
|
43
|
+
|
|
44
|
+
@property
|
|
45
|
+
def has_checksum(self):
|
|
46
|
+
"""True when this metadata carries a real checksum to validate.
|
|
47
|
+
|
|
48
|
+
Empty input carries no checksum (checksum is None), so callers can skip
|
|
49
|
+
validation without inspecting raw metadata strings themselves.
|
|
50
|
+
"""
|
|
51
|
+
return self.checksum is not None
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
class PayloadFactory:
|
|
55
|
+
@staticmethod
|
|
56
|
+
def create_payload_metadata(metadata):
|
|
57
|
+
if ':' in metadata:
|
|
58
|
+
if metadata.startswith('v3') or metadata.startswith('v4'):
|
|
59
|
+
return PayloadMetadata(metadata)
|
|
60
|
+
else:
|
|
61
|
+
raise ValueError("Invalid payload metadata type")
|
|
62
|
+
else:
|
|
63
|
+
return PayloadMetadataV0(metadata)
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
class InputFactory:
|
|
67
|
+
@staticmethod
|
|
68
|
+
def create_input_metadata(metadata):
|
|
69
|
+
if ':' in metadata:
|
|
70
|
+
if metadata.startswith('v3'):
|
|
71
|
+
return InputMetadatav3(metadata)
|
|
72
|
+
else:
|
|
73
|
+
raise ValueError("Invalid payload metadata type")
|
|
74
|
+
else:
|
|
75
|
+
return InputMetadataV0(metadata)
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
class InputMetadataV0(MetadataBase):
|
|
79
|
+
def __init__(self, metadata):
|
|
80
|
+
super().__init__(metadata, 'v0')
|
|
81
|
+
self._ipfs_hash = metadata
|
|
82
|
+
|
|
83
|
+
@property
|
|
84
|
+
def ipfs_hash(self):
|
|
85
|
+
return self._ipfs_hash
|
|
86
|
+
|
|
87
|
+
@property
|
|
88
|
+
def checksum(self):
|
|
89
|
+
return None
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
class PayloadMetadataV0(MetadataBase):
|
|
93
|
+
def __init__(self, metadata):
|
|
94
|
+
super().__init__(metadata, 'v0')
|
|
95
|
+
self._ipfs_hash = metadata
|
|
96
|
+
|
|
97
|
+
@property
|
|
98
|
+
def ipfs_hash(self):
|
|
99
|
+
return self._ipfs_hash
|
|
100
|
+
|
|
101
|
+
@property
|
|
102
|
+
def checksum(self):
|
|
103
|
+
return None
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
class PayloadMetadata(MetadataBase):
|
|
107
|
+
|
|
108
|
+
def __init__(self, metadata):
|
|
109
|
+
super().__init__(metadata, metadata.split(':')[0])
|
|
110
|
+
# An absent checksum (empty third field) is normalized to None so the
|
|
111
|
+
# rest of the code can rely on `checksum is None` / `has_checksum`
|
|
112
|
+
# instead of special-casing empty strings.
|
|
113
|
+
checksum = metadata.split(':')[2].strip()
|
|
114
|
+
self._checksum = checksum or None
|
|
115
|
+
self._ipfs_hash = metadata.split(':')[1]
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
@property
|
|
119
|
+
def ipfs_hash(self):
|
|
120
|
+
return self._ipfs_hash
|
|
121
|
+
|
|
122
|
+
@property
|
|
123
|
+
def checksum(self):
|
|
124
|
+
return self._checksum
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
class InputMetadatav3(MetadataBase):
|
|
128
|
+
|
|
129
|
+
def __init__(self, metadata):
|
|
130
|
+
super().__init__(metadata, 'v3')
|
|
131
|
+
# Empty input carries an empty checksum field; normalize it to None so
|
|
132
|
+
# `has_checksum` is False and validation is skipped (nothing to check).
|
|
133
|
+
checksum = metadata.split(':')[2].strip()
|
|
134
|
+
self._checksum = checksum or None
|
|
135
|
+
self._ipfs_hash = metadata.split(':')[1]
|
|
136
|
+
|
|
137
|
+
@property
|
|
138
|
+
def ipfs_hash(self):
|
|
139
|
+
return self._ipfs_hash
|
|
140
|
+
|
|
141
|
+
@property
|
|
142
|
+
def checksum(self):
|
|
143
|
+
return self._checksum
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
class DOReqMetadata:
|
|
147
|
+
def __init__(self, req, do_req):
|
|
148
|
+
self._do_req_id = do_req
|
|
149
|
+
self._do_owner = req[0]
|
|
150
|
+
self._metadata1 = req[1]
|
|
151
|
+
self._metadata2 = req[2]
|
|
152
|
+
self._metadata3 = req[3]
|
|
153
|
+
self._metadata4 = req[4]
|
|
154
|
+
self._payload_metadata_obj = PayloadFactory.create_payload_metadata(self.payload_metadata)
|
|
155
|
+
self._input_metadata_obj = InputFactory.create_input_metadata(self.input_metadata)
|
|
156
|
+
|
|
157
|
+
@property
|
|
158
|
+
def do_req_id(self):
|
|
159
|
+
return self._do_req_id
|
|
160
|
+
|
|
161
|
+
@property
|
|
162
|
+
def do_owner(self):
|
|
163
|
+
return self._do_owner
|
|
164
|
+
|
|
165
|
+
@property
|
|
166
|
+
def image_metadata(self):
|
|
167
|
+
return self._metadata1
|
|
168
|
+
|
|
169
|
+
@property
|
|
170
|
+
def public_key(self):
|
|
171
|
+
return self.image_metadata.split(':')[5]
|
|
172
|
+
|
|
173
|
+
@property
|
|
174
|
+
def image_hash(self):
|
|
175
|
+
return self.image_metadata.split(':')[1]
|
|
176
|
+
|
|
177
|
+
@property
|
|
178
|
+
def trustedzone_image_name(self):
|
|
179
|
+
return self.image_metadata.split(':')[2]
|
|
180
|
+
|
|
181
|
+
@property
|
|
182
|
+
def payload_metadata(self):
|
|
183
|
+
return self._metadata2
|
|
184
|
+
|
|
185
|
+
@property
|
|
186
|
+
def payload_metadata_obj(self):
|
|
187
|
+
return self._payload_metadata_obj
|
|
188
|
+
|
|
189
|
+
@property
|
|
190
|
+
def input_metadata_obj(self):
|
|
191
|
+
return self._input_metadata_obj
|
|
192
|
+
|
|
193
|
+
@property
|
|
194
|
+
def input_metadata(self):
|
|
195
|
+
return self._metadata3
|
|
196
|
+
|
|
197
|
+
@property
|
|
198
|
+
def node_address(self):
|
|
199
|
+
return self._metadata4
|
|
200
|
+
|