openshell-shared 0.1.2__py3-none-any.whl
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.
- api/__init__.py +1 -0
- api/manager/__init__.py +1 -0
- api/manager/v1/__init__.py +78 -0
- api/manager/v1/authentication.py +278 -0
- api/manager/v1/client.py +111 -0
- api/manager/v1/domains.py +64 -0
- api/manager/v1/entities.py +97 -0
- api/manager/v1/exceptions.py +98 -0
- api/manager/v1/identity.py +44 -0
- api/manager/v1/models.py +342 -0
- api/manager/v1/passports.py +131 -0
- api/manager/v1/sessions.py +83 -0
- api/manager/v1/transport.py +253 -0
- api/manager/v1/tunnels.py +120 -0
- cryptography/__init__.py +0 -0
- cryptography/certificate.py +390 -0
- cryptography/encoding.py +0 -0
- cryptography/identity.py +124 -0
- cryptography/keys.py +463 -0
- cryptography/signatures.py +63 -0
- cryptography/utils.py +0 -0
- domain/__init__.py +0 -0
- domain/domain.py +80 -0
- domain/membership.py +21 -0
- domain/permissions.py +14 -0
- domain/policies.py +2 -0
- identity/__init__.py +0 -0
- identity/identification.py +64 -0
- identity/store.py +150 -0
- modules/__init__.py +0 -0
- modules/shell/__init__.py +0 -0
- modules/shell/client.py +361 -0
- modules/shell/models.py +61 -0
- modules/shell/protocol.py +249 -0
- modules/shell/server.py +511 -0
- modules/shell/session.py +339 -0
- modules/utils.py +212 -0
- openshell_shared-0.1.2.dist-info/METADATA +59 -0
- openshell_shared-0.1.2.dist-info/RECORD +62 -0
- openshell_shared-0.1.2.dist-info/WHEEL +5 -0
- openshell_shared-0.1.2.dist-info/top_level.txt +7 -0
- protocols/__init__.py +0 -0
- protocols/negotiation/challenge.py +127 -0
- protocols/negotiation/models.py +28 -0
- standards/__init__.py +0 -0
- standards/certificates/__init__.py +0 -0
- standards/certificates/status.py +12 -0
- standards/certificates/types.py +11 -0
- standards/entities/__init__.py +0 -0
- standards/entities/types.py +14 -0
- standards/events/__init__.py +0 -0
- standards/events/schemas/__init__.py +0 -0
- standards/events/schemas/entity_registered.py +13 -0
- standards/events/types.py +18 -0
- standards/passports/__init__.py +0 -0
- standards/passports/types.py +5 -0
- standards/permissions/__init__.py +0 -0
- standards/permissions/types.py +14 -0
- standards/roles/__init__.py +0 -0
- standards/roles/types.py +8 -0
- standards/transports/__init__.py +0 -0
- standards/transports/types.py +24 -0
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
# shell/protocol.py
|
|
2
|
+
|
|
3
|
+
# =====================================================
|
|
4
|
+
# LIBRARY IMPORTS
|
|
5
|
+
# =====================================================
|
|
6
|
+
|
|
7
|
+
import time
|
|
8
|
+
|
|
9
|
+
from uuid6 import uuid7
|
|
10
|
+
|
|
11
|
+
from .models import (
|
|
12
|
+
ProtocolType,
|
|
13
|
+
ProtocolStandard
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
# =====================================================
|
|
18
|
+
# PACKAGE BASE
|
|
19
|
+
# =====================================================
|
|
20
|
+
|
|
21
|
+
class PackageBase:
|
|
22
|
+
|
|
23
|
+
def __init__(
|
|
24
|
+
self,
|
|
25
|
+
auth_token: str,
|
|
26
|
+
tunnel_token: str,
|
|
27
|
+
session_token: str
|
|
28
|
+
):
|
|
29
|
+
|
|
30
|
+
self.auth_token = auth_token
|
|
31
|
+
self.tunnel_token = tunnel_token
|
|
32
|
+
self.session_token = session_token
|
|
33
|
+
|
|
34
|
+
def header(self) -> dict:
|
|
35
|
+
|
|
36
|
+
return {
|
|
37
|
+
"auth_token":
|
|
38
|
+
self.auth_token,
|
|
39
|
+
|
|
40
|
+
"tunnel_token":
|
|
41
|
+
self.tunnel_token,
|
|
42
|
+
|
|
43
|
+
"session_token":
|
|
44
|
+
self.session_token,
|
|
45
|
+
|
|
46
|
+
"packet_type":
|
|
47
|
+
"DATA"
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
# =====================================================
|
|
52
|
+
# SHELL PROTOCOL
|
|
53
|
+
# =====================================================
|
|
54
|
+
|
|
55
|
+
class ShellProtocol(
|
|
56
|
+
PackageBase
|
|
57
|
+
):
|
|
58
|
+
|
|
59
|
+
PROTOCOL = (
|
|
60
|
+
ProtocolStandard.SHELL
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
PROTOCOL_VERSION = 2
|
|
64
|
+
|
|
65
|
+
# ================================================
|
|
66
|
+
# INTERNAL
|
|
67
|
+
# ================================================
|
|
68
|
+
|
|
69
|
+
def _payload(
|
|
70
|
+
self,
|
|
71
|
+
protocol_type: str,
|
|
72
|
+
event: str,
|
|
73
|
+
**kwargs
|
|
74
|
+
):
|
|
75
|
+
|
|
76
|
+
payload = {
|
|
77
|
+
"protocol":
|
|
78
|
+
self.PROTOCOL.value,
|
|
79
|
+
|
|
80
|
+
"protocol_type":
|
|
81
|
+
protocol_type,
|
|
82
|
+
|
|
83
|
+
"protocol_version":
|
|
84
|
+
self.PROTOCOL_VERSION,
|
|
85
|
+
|
|
86
|
+
"event":
|
|
87
|
+
event,
|
|
88
|
+
|
|
89
|
+
"timestamp":
|
|
90
|
+
time.time()
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
payload.update(kwargs)
|
|
94
|
+
|
|
95
|
+
return payload
|
|
96
|
+
|
|
97
|
+
# ================================================
|
|
98
|
+
# CLIENT EVENTS
|
|
99
|
+
# ================================================
|
|
100
|
+
|
|
101
|
+
def open(self):
|
|
102
|
+
|
|
103
|
+
packet = self.header()
|
|
104
|
+
|
|
105
|
+
packet["payload"] = (
|
|
106
|
+
self._payload(
|
|
107
|
+
protocol_type=
|
|
108
|
+
ProtocolType.CLIENT.value,
|
|
109
|
+
|
|
110
|
+
event="OPEN",
|
|
111
|
+
|
|
112
|
+
request_id=
|
|
113
|
+
str(uuid7())
|
|
114
|
+
)
|
|
115
|
+
)
|
|
116
|
+
|
|
117
|
+
return packet
|
|
118
|
+
|
|
119
|
+
def input(
|
|
120
|
+
self,
|
|
121
|
+
data: str
|
|
122
|
+
):
|
|
123
|
+
|
|
124
|
+
packet = self.header()
|
|
125
|
+
|
|
126
|
+
packet["payload"] = (
|
|
127
|
+
self._payload(
|
|
128
|
+
protocol_type=
|
|
129
|
+
ProtocolType.CLIENT.value,
|
|
130
|
+
|
|
131
|
+
event="INPUT",
|
|
132
|
+
|
|
133
|
+
data=data
|
|
134
|
+
)
|
|
135
|
+
)
|
|
136
|
+
|
|
137
|
+
return packet
|
|
138
|
+
|
|
139
|
+
def resize(
|
|
140
|
+
self,
|
|
141
|
+
rows: int,
|
|
142
|
+
cols: int
|
|
143
|
+
):
|
|
144
|
+
|
|
145
|
+
packet = self.header()
|
|
146
|
+
|
|
147
|
+
packet["payload"] = (
|
|
148
|
+
self._payload(
|
|
149
|
+
protocol_type=
|
|
150
|
+
ProtocolType.CLIENT.value,
|
|
151
|
+
|
|
152
|
+
event="RESIZE",
|
|
153
|
+
|
|
154
|
+
rows=rows,
|
|
155
|
+
cols=cols
|
|
156
|
+
)
|
|
157
|
+
)
|
|
158
|
+
|
|
159
|
+
return packet
|
|
160
|
+
|
|
161
|
+
def signal(
|
|
162
|
+
self,
|
|
163
|
+
signal_name: str
|
|
164
|
+
):
|
|
165
|
+
|
|
166
|
+
packet = self.header()
|
|
167
|
+
|
|
168
|
+
packet["payload"] = (
|
|
169
|
+
self._payload(
|
|
170
|
+
protocol_type=
|
|
171
|
+
ProtocolType.CLIENT.value,
|
|
172
|
+
|
|
173
|
+
event="SIGNAL",
|
|
174
|
+
|
|
175
|
+
signal=signal_name
|
|
176
|
+
)
|
|
177
|
+
)
|
|
178
|
+
|
|
179
|
+
return packet
|
|
180
|
+
|
|
181
|
+
def close(self):
|
|
182
|
+
|
|
183
|
+
packet = self.header()
|
|
184
|
+
|
|
185
|
+
packet["payload"] = (
|
|
186
|
+
self._payload(
|
|
187
|
+
protocol_type=
|
|
188
|
+
ProtocolType.CLIENT.value,
|
|
189
|
+
|
|
190
|
+
event="CLOSE"
|
|
191
|
+
)
|
|
192
|
+
)
|
|
193
|
+
|
|
194
|
+
return packet
|
|
195
|
+
|
|
196
|
+
# ================================================
|
|
197
|
+
# SERVER EVENTS
|
|
198
|
+
# ================================================
|
|
199
|
+
|
|
200
|
+
def output(
|
|
201
|
+
self,
|
|
202
|
+
session_token: str,
|
|
203
|
+
data: str
|
|
204
|
+
):
|
|
205
|
+
|
|
206
|
+
packet = self.header()
|
|
207
|
+
|
|
208
|
+
packet["session_token"] = (
|
|
209
|
+
session_token
|
|
210
|
+
)
|
|
211
|
+
|
|
212
|
+
packet["payload"] = (
|
|
213
|
+
self._payload(
|
|
214
|
+
protocol_type=
|
|
215
|
+
ProtocolType.SERVER.value,
|
|
216
|
+
|
|
217
|
+
event="OUTPUT",
|
|
218
|
+
|
|
219
|
+
data=data
|
|
220
|
+
)
|
|
221
|
+
)
|
|
222
|
+
|
|
223
|
+
return packet
|
|
224
|
+
|
|
225
|
+
def exit(
|
|
226
|
+
self,
|
|
227
|
+
session_token: str,
|
|
228
|
+
return_code: int
|
|
229
|
+
):
|
|
230
|
+
|
|
231
|
+
packet = self.header()
|
|
232
|
+
|
|
233
|
+
packet["session_token"] = (
|
|
234
|
+
session_token
|
|
235
|
+
)
|
|
236
|
+
|
|
237
|
+
packet["payload"] = (
|
|
238
|
+
self._payload(
|
|
239
|
+
protocol_type=
|
|
240
|
+
ProtocolType.SERVER.value,
|
|
241
|
+
|
|
242
|
+
event="EXIT",
|
|
243
|
+
|
|
244
|
+
return_code=
|
|
245
|
+
return_code
|
|
246
|
+
)
|
|
247
|
+
)
|
|
248
|
+
|
|
249
|
+
return packet
|