@adapt-toolkit/sdk 0.1.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.
Files changed (278) hide show
  1. package/dist/common/index.d.ts +7 -0
  2. package/dist/common/index.d.ts.map +1 -0
  3. package/dist/common/index.js +7 -0
  4. package/dist/common/index.js.map +1 -0
  5. package/dist/common/interfaces/adapt_environment.d.ts +21 -0
  6. package/dist/common/interfaces/adapt_environment.d.ts.map +1 -0
  7. package/dist/common/interfaces/adapt_environment.js +2 -0
  8. package/dist/common/interfaces/adapt_environment.js.map +1 -0
  9. package/dist/common/interfaces/adapt_evaluation_unit.d.ts +12 -0
  10. package/dist/common/interfaces/adapt_evaluation_unit.d.ts.map +1 -0
  11. package/dist/common/interfaces/adapt_evaluation_unit.js +2 -0
  12. package/dist/common/interfaces/adapt_evaluation_unit.js.map +1 -0
  13. package/dist/common/interfaces/adapt_packet_context.d.ts +29 -0
  14. package/dist/common/interfaces/adapt_packet_context.d.ts.map +1 -0
  15. package/dist/common/interfaces/adapt_packet_context.js +2 -0
  16. package/dist/common/interfaces/adapt_packet_context.js.map +1 -0
  17. package/dist/common/interfaces/adapt_value.d.ts +23 -0
  18. package/dist/common/interfaces/adapt_value.d.ts.map +1 -0
  19. package/dist/common/interfaces/adapt_value.js +2 -0
  20. package/dist/common/interfaces/adapt_value.js.map +1 -0
  21. package/dist/common/interfaces/common.d.ts +18 -0
  22. package/dist/common/interfaces/common.d.ts.map +1 -0
  23. package/dist/common/interfaces/common.js +4 -0
  24. package/dist/common/interfaces/common.js.map +1 -0
  25. package/dist/common/memory_management/adapt_object_lifetime.d.ts +114 -0
  26. package/dist/common/memory_management/adapt_object_lifetime.d.ts.map +1 -0
  27. package/dist/common/memory_management/adapt_object_lifetime.js +159 -0
  28. package/dist/common/memory_management/adapt_object_lifetime.js.map +1 -0
  29. package/dist/index.d.ts +3 -0
  30. package/dist/index.d.ts.map +1 -0
  31. package/dist/index.js +2 -0
  32. package/dist/index.js.map +1 -0
  33. package/dist/loaders/browser.d.ts +5 -0
  34. package/dist/loaders/browser.d.ts.map +1 -0
  35. package/dist/loaders/browser.js +6 -0
  36. package/dist/loaders/browser.js.map +1 -0
  37. package/dist/loaders/node.d.ts +13 -0
  38. package/dist/loaders/node.d.ts.map +1 -0
  39. package/dist/loaders/node.js +29 -0
  40. package/dist/loaders/node.js.map +1 -0
  41. package/dist/loaders/react-native.d.ts +11 -0
  42. package/dist/loaders/react-native.d.ts.map +1 -0
  43. package/dist/loaders/react-native.js +19 -0
  44. package/dist/loaders/react-native.js.map +1 -0
  45. package/dist/loaders/shared.d.ts +17 -0
  46. package/dist/loaders/shared.d.ts.map +1 -0
  47. package/dist/loaders/shared.js +2 -0
  48. package/dist/loaders/shared.js.map +1 -0
  49. package/dist/utilities/broker/broker.d.ts +21 -0
  50. package/dist/utilities/broker/broker.d.ts.map +1 -0
  51. package/dist/utilities/broker/broker.js +267 -0
  52. package/dist/utilities/broker/broker.js.map +1 -0
  53. package/dist/utilities/broker/broker_client.d.ts +40 -0
  54. package/dist/utilities/broker/broker_client.d.ts.map +1 -0
  55. package/dist/utilities/broker/broker_client.js +111 -0
  56. package/dist/utilities/broker/broker_client.js.map +1 -0
  57. package/dist/utilities/broker/broker_configurator.d.ts +6 -0
  58. package/dist/utilities/broker/broker_configurator.d.ts.map +1 -0
  59. package/dist/utilities/broker/broker_configurator.js +8 -0
  60. package/dist/utilities/broker/broker_configurator.js.map +1 -0
  61. package/dist/utilities/broker/index.d.ts +4 -0
  62. package/dist/utilities/broker/index.d.ts.map +1 -0
  63. package/dist/utilities/broker/index.js +4 -0
  64. package/dist/utilities/broker/index.js.map +1 -0
  65. package/dist/utilities/common/adapt_waitlist.d.ts +5 -0
  66. package/dist/utilities/common/adapt_waitlist.d.ts.map +1 -0
  67. package/dist/utilities/common/adapt_waitlist.js +4 -0
  68. package/dist/utilities/common/adapt_waitlist.js.map +1 -0
  69. package/dist/utilities/common/async_queue_adapter.d.ts +40 -0
  70. package/dist/utilities/common/async_queue_adapter.d.ts.map +1 -0
  71. package/dist/utilities/common/async_queue_adapter.js +88 -0
  72. package/dist/utilities/common/async_queue_adapter.js.map +1 -0
  73. package/dist/utilities/common/command_line_configurator.d.ts +88 -0
  74. package/dist/utilities/common/command_line_configurator.d.ts.map +1 -0
  75. package/dist/utilities/common/command_line_configurator.js +217 -0
  76. package/dist/utilities/common/command_line_configurator.js.map +1 -0
  77. package/dist/utilities/common/decorators.d.ts +17 -0
  78. package/dist/utilities/common/decorators.d.ts.map +1 -0
  79. package/dist/utilities/common/decorators.js +84 -0
  80. package/dist/utilities/common/decorators.js.map +1 -0
  81. package/dist/utilities/common/errors/adapt_initialization_error.d.ts +4 -0
  82. package/dist/utilities/common/errors/adapt_initialization_error.d.ts.map +1 -0
  83. package/dist/utilities/common/errors/adapt_initialization_error.js +6 -0
  84. package/dist/utilities/common/errors/adapt_initialization_error.js.map +1 -0
  85. package/dist/utilities/common/errors/adapt_network_error.d.ts +8 -0
  86. package/dist/utilities/common/errors/adapt_network_error.d.ts.map +1 -0
  87. package/dist/utilities/common/errors/adapt_network_error.js +12 -0
  88. package/dist/utilities/common/errors/adapt_network_error.js.map +1 -0
  89. package/dist/utilities/common/errors/adapt_protocol_error.d.ts +12 -0
  90. package/dist/utilities/common/errors/adapt_protocol_error.d.ts.map +1 -0
  91. package/dist/utilities/common/errors/adapt_protocol_error.js +16 -0
  92. package/dist/utilities/common/errors/adapt_protocol_error.js.map +1 -0
  93. package/dist/utilities/common/errors/adapt_test_mode_error.d.ts +11 -0
  94. package/dist/utilities/common/errors/adapt_test_mode_error.d.ts.map +1 -0
  95. package/dist/utilities/common/errors/adapt_test_mode_error.js +22 -0
  96. package/dist/utilities/common/errors/adapt_test_mode_error.js.map +1 -0
  97. package/dist/utilities/common/http_server.d.ts +18 -0
  98. package/dist/utilities/common/http_server.d.ts.map +1 -0
  99. package/dist/utilities/common/http_server.js +41 -0
  100. package/dist/utilities/common/http_server.js.map +1 -0
  101. package/dist/utilities/common/index.d.ts +25 -0
  102. package/dist/utilities/common/index.d.ts.map +1 -0
  103. package/dist/utilities/common/index.js +36 -0
  104. package/dist/utilities/common/index.js.map +1 -0
  105. package/dist/utilities/common/logger/logger.d.ts +83 -0
  106. package/dist/utilities/common/logger/logger.d.ts.map +1 -0
  107. package/dist/utilities/common/logger/logger.js +272 -0
  108. package/dist/utilities/common/logger/logger.js.map +1 -0
  109. package/dist/utilities/common/logger/logging_level.d.ts +13 -0
  110. package/dist/utilities/common/logger/logging_level.d.ts.map +1 -0
  111. package/dist/utilities/common/logger/logging_level.js +36 -0
  112. package/dist/utilities/common/logger/logging_level.js.map +1 -0
  113. package/dist/utilities/common/logger/message.d.ts +65 -0
  114. package/dist/utilities/common/logger/message.d.ts.map +1 -0
  115. package/dist/utilities/common/logger/message.js +169 -0
  116. package/dist/utilities/common/logger/message.js.map +1 -0
  117. package/dist/utilities/common/logger/network_component.d.ts +3 -0
  118. package/dist/utilities/common/logger/network_component.d.ts.map +1 -0
  119. package/dist/utilities/common/logger/network_component.js +4 -0
  120. package/dist/utilities/common/logger/network_component.js.map +1 -0
  121. package/dist/utilities/common/totp_qr_code_generator.d.ts +12 -0
  122. package/dist/utilities/common/totp_qr_code_generator.d.ts.map +1 -0
  123. package/dist/utilities/common/totp_qr_code_generator.js +19 -0
  124. package/dist/utilities/common/totp_qr_code_generator.js.map +1 -0
  125. package/dist/utilities/common/waitlist/waitlist.d.ts +36 -0
  126. package/dist/utilities/common/waitlist/waitlist.d.ts.map +1 -0
  127. package/dist/utilities/common/waitlist/waitlist.js +116 -0
  128. package/dist/utilities/common/waitlist/waitlist.js.map +1 -0
  129. package/dist/utilities/common/web_socket_client.d.ts +50 -0
  130. package/dist/utilities/common/web_socket_client.d.ts.map +1 -0
  131. package/dist/utilities/common/web_socket_client.js +80 -0
  132. package/dist/utilities/common/web_socket_client.js.map +1 -0
  133. package/dist/utilities/common/web_socket_connection.d.ts +29 -0
  134. package/dist/utilities/common/web_socket_connection.d.ts.map +1 -0
  135. package/dist/utilities/common/web_socket_connection.js +94 -0
  136. package/dist/utilities/common/web_socket_connection.js.map +1 -0
  137. package/dist/utilities/evaluator/common.d.ts +10 -0
  138. package/dist/utilities/evaluator/common.d.ts.map +1 -0
  139. package/dist/utilities/evaluator/common.js +128 -0
  140. package/dist/utilities/evaluator/common.js.map +1 -0
  141. package/dist/utilities/evaluator/evaluator.d.ts +35 -0
  142. package/dist/utilities/evaluator/evaluator.d.ts.map +1 -0
  143. package/dist/utilities/evaluator/evaluator.js +141 -0
  144. package/dist/utilities/evaluator/evaluator.js.map +1 -0
  145. package/dist/utilities/evaluator/index.d.ts +3 -0
  146. package/dist/utilities/evaluator/index.d.ts.map +1 -0
  147. package/dist/utilities/evaluator/index.js +3 -0
  148. package/dist/utilities/evaluator/index.js.map +1 -0
  149. package/dist/utilities/executables/adapt_wrapper.d.ts +3 -0
  150. package/dist/utilities/executables/adapt_wrapper.d.ts.map +1 -0
  151. package/dist/utilities/executables/adapt_wrapper.js +25 -0
  152. package/dist/utilities/executables/adapt_wrapper.js.map +1 -0
  153. package/dist/utilities/executables/adapt_wrapper_mobile.d.ts +3 -0
  154. package/dist/utilities/executables/adapt_wrapper_mobile.d.ts.map +1 -0
  155. package/dist/utilities/executables/adapt_wrapper_mobile.js +20 -0
  156. package/dist/utilities/executables/adapt_wrapper_mobile.js.map +1 -0
  157. package/dist/utilities/executables/adapt_wrapper_script.d.ts +2 -0
  158. package/dist/utilities/executables/adapt_wrapper_script.d.ts.map +1 -0
  159. package/dist/utilities/executables/adapt_wrapper_script.js +6 -0
  160. package/dist/utilities/executables/adapt_wrapper_script.js.map +1 -0
  161. package/dist/utilities/executables/broker.d.ts +2 -0
  162. package/dist/utilities/executables/broker.d.ts.map +1 -0
  163. package/dist/utilities/executables/broker.js +23 -0
  164. package/dist/utilities/executables/broker.js.map +1 -0
  165. package/dist/utilities/executables/index.d.ts +2 -0
  166. package/dist/utilities/executables/index.d.ts.map +1 -0
  167. package/dist/utilities/executables/index.js +2 -0
  168. package/dist/utilities/executables/index.js.map +1 -0
  169. package/dist/utilities/executables/local_data_storage.d.ts +2 -0
  170. package/dist/utilities/executables/local_data_storage.d.ts.map +1 -0
  171. package/dist/utilities/executables/local_data_storage.js +20 -0
  172. package/dist/utilities/executables/local_data_storage.js.map +1 -0
  173. package/dist/utilities/executables/local_data_storage_cmd_helper.d.ts +2 -0
  174. package/dist/utilities/executables/local_data_storage_cmd_helper.d.ts.map +1 -0
  175. package/dist/utilities/executables/local_data_storage_cmd_helper.js +52 -0
  176. package/dist/utilities/executables/local_data_storage_cmd_helper.js.map +1 -0
  177. package/dist/utilities/storage/data_storage.d.ts +97 -0
  178. package/dist/utilities/storage/data_storage.d.ts.map +1 -0
  179. package/dist/utilities/storage/data_storage.js +440 -0
  180. package/dist/utilities/storage/data_storage.js.map +1 -0
  181. package/dist/utilities/storage/index.d.ts +6 -0
  182. package/dist/utilities/storage/index.d.ts.map +1 -0
  183. package/dist/utilities/storage/index.js +6 -0
  184. package/dist/utilities/storage/index.js.map +1 -0
  185. package/dist/utilities/storage/local_data_storage.d.ts +7 -0
  186. package/dist/utilities/storage/local_data_storage.d.ts.map +1 -0
  187. package/dist/utilities/storage/local_data_storage.js +18 -0
  188. package/dist/utilities/storage/local_data_storage.js.map +1 -0
  189. package/dist/utilities/storage/local_data_storage_base.d.ts +74 -0
  190. package/dist/utilities/storage/local_data_storage_base.d.ts.map +1 -0
  191. package/dist/utilities/storage/local_data_storage_base.js +163 -0
  192. package/dist/utilities/storage/local_data_storage_base.js.map +1 -0
  193. package/dist/utilities/storage/local_data_storage_configurator.d.ts +7 -0
  194. package/dist/utilities/storage/local_data_storage_configurator.d.ts.map +1 -0
  195. package/dist/utilities/storage/local_data_storage_configurator.js +13 -0
  196. package/dist/utilities/storage/local_data_storage_configurator.js.map +1 -0
  197. package/dist/utilities/storage/storage_client.d.ts +28 -0
  198. package/dist/utilities/storage/storage_client.d.ts.map +1 -0
  199. package/dist/utilities/storage/storage_client.js +79 -0
  200. package/dist/utilities/storage/storage_client.js.map +1 -0
  201. package/dist/utilities/wrappers/configurators/adapt_wrapper_configurator.d.ts +14 -0
  202. package/dist/utilities/wrappers/configurators/adapt_wrapper_configurator.d.ts.map +1 -0
  203. package/dist/utilities/wrappers/configurators/adapt_wrapper_configurator.js +57 -0
  204. package/dist/utilities/wrappers/configurators/adapt_wrapper_configurator.js.map +1 -0
  205. package/dist/utilities/wrappers/configurators/control_packet_configurator.d.ts +12 -0
  206. package/dist/utilities/wrappers/configurators/control_packet_configurator.d.ts.map +1 -0
  207. package/dist/utilities/wrappers/configurators/control_packet_configurator.js +52 -0
  208. package/dist/utilities/wrappers/configurators/control_packet_configurator.js.map +1 -0
  209. package/dist/utilities/wrappers/configurators/packet_wrapper_configurator.d.ts +32 -0
  210. package/dist/utilities/wrappers/configurators/packet_wrapper_configurator.d.ts.map +1 -0
  211. package/dist/utilities/wrappers/configurators/packet_wrapper_configurator.js +123 -0
  212. package/dist/utilities/wrappers/configurators/packet_wrapper_configurator.js.map +1 -0
  213. package/dist/utilities/wrappers/enclave/control_packet.d.ts +18 -0
  214. package/dist/utilities/wrappers/enclave/control_packet.d.ts.map +1 -0
  215. package/dist/utilities/wrappers/enclave/control_packet.js +213 -0
  216. package/dist/utilities/wrappers/enclave/control_packet.js.map +1 -0
  217. package/dist/utilities/wrappers/index.d.ts +5 -0
  218. package/dist/utilities/wrappers/index.d.ts.map +1 -0
  219. package/dist/utilities/wrappers/index.js +5 -0
  220. package/dist/utilities/wrappers/index.js.map +1 -0
  221. package/dist/utilities/wrappers/wrappers/adapt_packet_wrapper.d.ts +19 -0
  222. package/dist/utilities/wrappers/wrappers/adapt_packet_wrapper.d.ts.map +1 -0
  223. package/dist/utilities/wrappers/wrappers/adapt_packet_wrapper.js +55 -0
  224. package/dist/utilities/wrappers/wrappers/adapt_packet_wrapper.js.map +1 -0
  225. package/dist/utilities/wrappers/wrappers/adapt_wrapper.d.ts +131 -0
  226. package/dist/utilities/wrappers/wrappers/adapt_wrapper.d.ts.map +1 -0
  227. package/dist/utilities/wrappers/wrappers/adapt_wrapper.js +716 -0
  228. package/dist/utilities/wrappers/wrappers/adapt_wrapper.js.map +1 -0
  229. package/dist/utilities/wrappers/wrappers/impl/adapt_packet_wrapper_impl.d.ts +75 -0
  230. package/dist/utilities/wrappers/wrappers/impl/adapt_packet_wrapper_impl.d.ts.map +1 -0
  231. package/dist/utilities/wrappers/wrappers/impl/adapt_packet_wrapper_impl.js +550 -0
  232. package/dist/utilities/wrappers/wrappers/impl/adapt_packet_wrapper_impl.js.map +1 -0
  233. package/dist/wasm/adapt.d.ts +79 -0
  234. package/dist/wasm/adapt.d.ts.map +1 -0
  235. package/dist/wasm/adapt.js +430 -0
  236. package/dist/wasm/adapt.js.map +1 -0
  237. package/dist/wasm/backend-node.d.ts +1 -0
  238. package/dist/wasm/backend-node.d.ts.map +1 -0
  239. package/dist/wasm/backend-node.js +1 -0
  240. package/dist/wasm/backend-node.js.map +1 -0
  241. package/dist/wasm/index.d.ts +12 -0
  242. package/dist/wasm/index.d.ts.map +1 -0
  243. package/dist/wasm/index.js +15 -0
  244. package/dist/wasm/index.js.map +1 -0
  245. package/dist/wasm/mufl-bindings.d.ts +3 -0
  246. package/dist/wasm/mufl-bindings.d.ts.map +1 -0
  247. package/dist/wasm/mufl-bindings.js +3833 -0
  248. package/dist/wasm/mufl-bindings.js.map +1 -0
  249. package/dist/wasm/mufl-bindings.wasm +0 -0
  250. package/dist/wasm/wasm_types.d.ts +96 -0
  251. package/dist/wasm/wasm_types.d.ts.map +1 -0
  252. package/dist/wasm/wasm_types.js +2 -0
  253. package/dist/wasm/wasm_types.js.map +1 -0
  254. package/dist/wrapper/conversion.d.ts +9 -0
  255. package/dist/wrapper/conversion.d.ts.map +1 -0
  256. package/dist/wrapper/conversion.js +30 -0
  257. package/dist/wrapper/conversion.js.map +1 -0
  258. package/dist/wrapper/index.d.ts +11 -0
  259. package/dist/wrapper/index.d.ts.map +1 -0
  260. package/dist/wrapper/index.js +25 -0
  261. package/dist/wrapper/index.js.map +1 -0
  262. package/dist/wrapper/memory_management/adapt_builder.d.ts +36 -0
  263. package/dist/wrapper/memory_management/adapt_builder.d.ts.map +1 -0
  264. package/dist/wrapper/memory_management/adapt_builder.js +98 -0
  265. package/dist/wrapper/memory_management/adapt_builder.js.map +1 -0
  266. package/dist/wrapper/memory_management/exit_handler_registrar.d.ts +10 -0
  267. package/dist/wrapper/memory_management/exit_handler_registrar.d.ts.map +1 -0
  268. package/dist/wrapper/memory_management/exit_handler_registrar.js +38 -0
  269. package/dist/wrapper/memory_management/exit_handler_registrar.js.map +1 -0
  270. package/dist/wrapper/protocol/message_handler_interfaces.d.ts +32 -0
  271. package/dist/wrapper/protocol/message_handler_interfaces.d.ts.map +1 -0
  272. package/dist/wrapper/protocol/message_handler_interfaces.js +2 -0
  273. package/dist/wrapper/protocol/message_handler_interfaces.js.map +1 -0
  274. package/dist/wrapper/protocol/protocol.d.ts +171 -0
  275. package/dist/wrapper/protocol/protocol.d.ts.map +1 -0
  276. package/dist/wrapper/protocol/protocol.js +387 -0
  277. package/dist/wrapper/protocol/protocol.js.map +1 -0
  278. package/package.json +127 -0
@@ -0,0 +1,65 @@
1
+ import { NetworkComponent } from "./network_component.js";
2
+ import { LoggingLevel } from "./logging_level.js";
3
+ import { AdaptPacketContext, AdaptValue } from '@adapt-toolkit/sdk/backend';
4
+ import { Protocol } from '../../../wrapper/index.js';
5
+ export declare class LazyMessage {
6
+ get_msg: () => any;
7
+ constructor(get_msg: () => any);
8
+ }
9
+ export declare class Message {
10
+ level: LoggingLevel.Level;
11
+ args: any[];
12
+ timestamp: number;
13
+ indent: string;
14
+ constructor(level: LoggingLevel.Level, ...args: any[]);
15
+ protected set_indent(indent?: string): void;
16
+ to_string(): string;
17
+ }
18
+ export declare class FunctionCallMessage extends Message {
19
+ static s_stack_depth: number;
20
+ m_stack_depth: number;
21
+ constructor(...args: any[]);
22
+ }
23
+ export declare class FunctionCallMessageStart extends FunctionCallMessage {
24
+ private function_name;
25
+ constructor(function_name: string, args: any[]);
26
+ to_string(): string;
27
+ }
28
+ export declare class FunctionCallMessageEnd extends FunctionCallMessage {
29
+ private result;
30
+ private timediff;
31
+ constructor(result: any, timediff: number);
32
+ to_string(): string;
33
+ }
34
+ export declare class DebugMessage extends Message {
35
+ constructor(...args: any[]);
36
+ }
37
+ export declare class InfoMessage extends Message {
38
+ constructor(...args: any[]);
39
+ }
40
+ export declare class WarningMessage extends Message {
41
+ constructor(...args: any[]);
42
+ }
43
+ export declare class ErrorMessage extends Message {
44
+ constructor(...args: any[]);
45
+ }
46
+ declare class DebugMessagesMessage extends Message {
47
+ from: NetworkComponent;
48
+ to: NetworkComponent;
49
+ message: AdaptValue;
50
+ message_type_id: Protocol.MessageName;
51
+ is_incoming: boolean;
52
+ constructor(from: NetworkComponent, to: NetworkComponent, message: AdaptValue, message_type_id: Protocol.MessageName, is_incoming: boolean);
53
+ protected header(): string;
54
+ to_string(): string;
55
+ }
56
+ export declare class IncomingDebugMessage extends DebugMessagesMessage {
57
+ to_packet?: AdaptPacketContext | undefined;
58
+ constructor(from: NetworkComponent, to: NetworkComponent, message: AdaptValue, message_type_id: Protocol.MessageName, to_packet?: AdaptPacketContext | undefined);
59
+ decrypt_message(): IncomingDebugMessage | undefined;
60
+ }
61
+ export declare class OutgoingDebugMessage extends DebugMessagesMessage {
62
+ constructor(from: NetworkComponent, to: NetworkComponent, message: AdaptValue, message_type_id: Protocol.MessageName);
63
+ }
64
+ export {};
65
+ //# sourceMappingURL=message.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"message.d.ts","sourceRoot":"","sources":["../../../../src/utilities/common/logger/message.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAsB,MAAM,wBAAwB,CAAC;AAC9E,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,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AO;IACnB,IAAI,EAAE,gBAAgB;IAAS,EAAE,EAAE,gBAAgB;IAAS,OAAO,EAAE,UAAU;IAAS,eAAe,EAAE,QAAQ,CAAC,WAAW;IAAS,WAAW,EAAE,OAAO;gBAA1J,IAAI,EAAE,gBAAgB,EAAS,EAAE,EAAE,gBAAgB,EAAS,OAAO,EAAE,UAAU,EAAS,eAAe,EAAE,QAAQ,CAAC,WAAW,EAAS,WAAW,EAAE,OAAO;IAI7K,SAAS,CAAC,MAAM;IAMP,SAAS,IAAI,MAAM;CAK/B;AAED,qBAAa,oBAAqB,SAAQ,oBAAoB;IAEmE,SAAS,CAAC,EAAE,kBAAkB;gBAA/I,IAAI,EAAE,gBAAgB,EAAE,EAAE,EAAE,gBAAgB,EAAE,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,QAAQ,CAAC,WAAW,EAAS,SAAS,CAAC,EAAE,kBAAkB,YAAA;IAK3J,eAAe;CA6BlB;AAED,qBAAa,oBAAqB,SAAQ,oBAAoB;gBAC9C,IAAI,EAAE,gBAAgB,EAAE,EAAE,EAAE,gBAAgB,EAAE,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,QAAQ,CAAC,WAAW;CAIvH"}
@@ -0,0 +1,169 @@
1
+ import { translateComponent } from "./network_component.js";
2
+ import { LoggingLevel } from "./logging_level.js";
3
+ import { AdaptValue } from '@adapt-toolkit/sdk/backend';
4
+ import { AdaptObjectBuilder, Protocol } from '../../../wrapper/index.js';
5
+ export class LazyMessage {
6
+ get_msg;
7
+ constructor(get_msg) {
8
+ this.get_msg = get_msg;
9
+ }
10
+ }
11
+ export class Message {
12
+ level;
13
+ args;
14
+ timestamp;
15
+ indent = "";
16
+ constructor(level, ...args) {
17
+ this.level = level;
18
+ this.args = args;
19
+ this.timestamp = Date.now();
20
+ this.set_indent();
21
+ }
22
+ set_indent(indent = "| ".repeat(FunctionCallMessage.s_stack_depth)) {
23
+ this.indent = indent;
24
+ }
25
+ to_string() {
26
+ return `${LoggingLevel.Level[this.level]}: ${this.args.map(arg => {
27
+ if (arg instanceof LazyMessage)
28
+ arg = arg.get_msg();
29
+ if (arg instanceof AdaptValue)
30
+ return `AdaptValue(${arg.Visualize()})`;
31
+ return String(arg);
32
+ }).join(' ')}`;
33
+ }
34
+ }
35
+ export class FunctionCallMessage extends Message {
36
+ static s_stack_depth = 0;
37
+ m_stack_depth = 0;
38
+ constructor(...args) {
39
+ super(LoggingLevel.Level.FUNCTION_CALLS, ...args);
40
+ }
41
+ }
42
+ export class FunctionCallMessageStart extends FunctionCallMessage {
43
+ function_name;
44
+ constructor(function_name, args) {
45
+ super(args);
46
+ this.function_name = function_name;
47
+ this.m_stack_depth = FunctionCallMessage.s_stack_depth++;
48
+ }
49
+ to_string() {
50
+ const args_str = this.args.map(arg => {
51
+ let arg_str;
52
+ if (arg instanceof LazyMessage)
53
+ arg = arg.get_msg();
54
+ if (arg instanceof AdaptValue) {
55
+ let vis = arg.Visualize();
56
+ if (vis.length > 25)
57
+ vis = vis.substring(0, 25) + `...${vis.length - 25} more characters`;
58
+ arg_str = `AdaptValue(${vis})`;
59
+ }
60
+ else {
61
+ arg_str = String(arg);
62
+ }
63
+ return arg_str;
64
+ }).join(', ');
65
+ return `${this.function_name} (${args_str})`;
66
+ }
67
+ }
68
+ export class FunctionCallMessageEnd extends FunctionCallMessage {
69
+ result;
70
+ timediff;
71
+ constructor(result, timediff) {
72
+ super();
73
+ this.result = result;
74
+ this.timediff = timediff;
75
+ this.m_stack_depth = --FunctionCallMessage.s_stack_depth;
76
+ this.set_indent();
77
+ }
78
+ to_string() {
79
+ return `=> ${this.result instanceof LazyMessage ? this.result.get_msg() : this.result} (${this.timediff})`;
80
+ }
81
+ }
82
+ export class DebugMessage extends Message {
83
+ constructor(...args) {
84
+ super(LoggingLevel.Level.DEBUG, ...args);
85
+ }
86
+ }
87
+ export class InfoMessage extends Message {
88
+ constructor(...args) {
89
+ super(LoggingLevel.Level.INFO, ...args);
90
+ }
91
+ }
92
+ export class WarningMessage extends Message {
93
+ constructor(...args) {
94
+ super(LoggingLevel.Level.WARNING, ...args);
95
+ }
96
+ }
97
+ export class ErrorMessage extends Message {
98
+ constructor(...args) {
99
+ super(LoggingLevel.Level.ERROR, ...args);
100
+ }
101
+ }
102
+ class DebugMessagesMessage extends Message {
103
+ from;
104
+ to;
105
+ message;
106
+ message_type_id;
107
+ is_incoming;
108
+ constructor(from, to, message, message_type_id, is_incoming) {
109
+ super(LoggingLevel.Level.DEBUG_MESSAGES);
110
+ this.from = from;
111
+ this.to = to;
112
+ this.message = message;
113
+ this.message_type_id = message_type_id;
114
+ this.is_incoming = is_incoming;
115
+ }
116
+ header() {
117
+ return this.is_incoming ?
118
+ `#### ${translateComponent(this.to)} <-- ${translateComponent(this.from)} #### ${this.message_type_id} ####\n` :
119
+ `#### ${translateComponent(this.from)} --> ${translateComponent(this.to)} #### ${this.message_type_id} ####\n`;
120
+ }
121
+ to_string() {
122
+ const header = this.header();
123
+ const footer = '\n' + '#'.repeat(header.length) + '\n';
124
+ return header + this.message.Visualize() + footer;
125
+ }
126
+ }
127
+ export class IncomingDebugMessage extends DebugMessagesMessage {
128
+ to_packet;
129
+ constructor(from, to, message, message_type_id, to_packet) {
130
+ super(from, to, message, message_type_id, true);
131
+ this.to_packet = to_packet;
132
+ }
133
+ // may throw an Error
134
+ decrypt_message() {
135
+ if (!this.to_packet) {
136
+ console.log("Failed to decrypt message: packet is undefined");
137
+ return;
138
+ }
139
+ const builder = new AdaptObjectBuilder();
140
+ try {
141
+ const type_id = Protocol.GetTypeId(this.message);
142
+ if (type_id !== Protocol.MessageName.b2w_exec_transaction)
143
+ return this;
144
+ const body = builder.Attach(Protocol.GetBody(this.message));
145
+ const envlp = body.Reduce(Protocol.FieldName.envlp);
146
+ const ip_document = envlp.Reduce(Protocol.FieldName.ip_document);
147
+ const trn_body = envlp.Reduce(Protocol.FieldName.body);
148
+ const decoded = Protocol.DescribeTransaction(this.to_packet, trn_body);
149
+ const to = builder.Attach(Protocol.GetTo(this.message));
150
+ const from = builder.Attach(Protocol.GetFrom(this.message));
151
+ const message_hash = builder.Attach(Protocol.GetMessageHash(this.message));
152
+ const new_msg = Protocol.CreateProtocolMessage(this.message_type_id, {
153
+ to: to, from: from, message_hash: message_hash, body: Protocol.GetProtocolContainer().CreateDictionary().Mutate(Protocol.FieldName.envlp, builder.Attach(Protocol.CreateTransactionEnvelope(decoded, to, from, ip_document)))
154
+ });
155
+ const result = new IncomingDebugMessage(this.from, this.to, new_msg, this.message_type_id, this.to_packet);
156
+ result.timestamp = this.timestamp;
157
+ return result;
158
+ }
159
+ finally {
160
+ builder.Destroy();
161
+ }
162
+ }
163
+ }
164
+ export class OutgoingDebugMessage extends DebugMessagesMessage {
165
+ constructor(from, to, message, message_type_id) {
166
+ super(from, to, message, message_type_id, false);
167
+ }
168
+ }
169
+ //# sourceMappingURL=message.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"message.js","sourceRoot":"","sources":["../../../../src/utilities/common/logger/message.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC9E,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAsB,UAAU,EAAE,MAAM,UAAU,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAEzE,MAAM,OAAO,WAAW;IAED;IAAnB,YAAmB,OAAkB;QAAlB,YAAO,GAAP,OAAO,CAAW;IAAG,CAAC;CAC5C;AAED,MAAM,OAAO,OAAO;IAIG;IAHnB,IAAI,CAAO;IACX,SAAS,CAAQ;IACjB,MAAM,GAAW,EAAE,CAAA;IACnB,YAAmB,KAAyB,EAAE,GAAG,IAAW;QAAzC,UAAK,GAAL,KAAK,CAAoB;QACxC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;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eAAqC;QAChH,KAAK,CAAC,IAAI,EAAE,EAAE,EAAE,OAAO,EAAE,eAAe,EAAE,KAAK,CAAC,CAAC;IACrD,CAAC;CAEJ"}
@@ -0,0 +1,3 @@
1
+ export type NetworkComponent = 'adapt_wrapper' | 'data_storage' | 'broker' | 'broker_client' | 'storage_client' | 'packet_wrapper';
2
+ export declare function translateComponent(comp: NetworkComponent): NetworkComponent;
3
+ //# sourceMappingURL=network_component.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"network_component.d.ts","sourceRoot":"","sources":["../../../../src/utilities/common/logger/network_component.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,gBAAgB,GAAG,eAAe,GAAG,cAAc,GAAG,QAAQ,GAAG,eAAe,GAAG,gBAAgB,GAAG,gBAAgB,CAAA;AAElI,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,gBAAgB,oBAExD"}
@@ -0,0 +1,4 @@
1
+ export function translateComponent(comp) {
2
+ return comp; // disable components translation for now
3
+ }
4
+ //# sourceMappingURL=network_component.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"network_component.js","sourceRoot":"","sources":["../../../../src/utilities/common/logger/network_component.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,kBAAkB,CAAC,IAAsB;IACrD,OAAO,IAAI,CAAC,CAAC,yCAAyC;AAC1D,CAAC"}
@@ -0,0 +1,12 @@
1
+ interface TOTPConfig {
2
+ secret: Uint8Array;
3
+ issuer: string;
4
+ accountName: string;
5
+ algorithm?: string;
6
+ digits?: number;
7
+ period?: number;
8
+ }
9
+ export declare const generateTOTPURI: (config: TOTPConfig) => string;
10
+ export declare const generateTOTPQRCode: (config: TOTPConfig) => Promise<string>;
11
+ export {};
12
+ //# sourceMappingURL=totp_qr_code_generator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"totp_qr_code_generator.d.ts","sourceRoot":"","sources":["../../../src/utilities/common/totp_qr_code_generator.ts"],"names":[],"mappings":"AAGA,UAAU,UAAU;IAClB,MAAM,EAAE,UAAU,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,eAAO,MAAM,eAAe,GAAI,QAAQ,UAAU,KAAG,MAMpD,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAAU,QAAQ,UAAU,KAAG,OAAO,CAAC,MAAM,CAO3E,CAAC"}
@@ -0,0 +1,19 @@
1
+ import * as QRCode from 'qrcode';
2
+ import base32 from 'hi-base32';
3
+ export const generateTOTPURI = (config) => {
4
+ const { secret, issuer, accountName, algorithm = 'SHA1', digits = 6, period = 30 } = config;
5
+ if (algorithm != 'SHA1' && algorithm != 'SHA256' && algorithm != "SHA512")
6
+ throw new Error("Invalid hashing algorithm name. Expected one of: [SHA1, SHA256, SHA512], but obtained: " + algorithm);
7
+ const encodedSecret = base32.encode(secret).replace(/=/g, '');
8
+ return `otpauth://totp/${encodeURIComponent(issuer)}:${encodeURIComponent(accountName)}?secret=${encodedSecret}&issuer=${encodeURIComponent(issuer)}&algorithm=${algorithm}&digits=${digits}&period=${period}`;
9
+ };
10
+ export const generateTOTPQRCode = async (config) => {
11
+ const uri = generateTOTPURI(config);
12
+ try {
13
+ return await QRCode.toDataURL(uri);
14
+ }
15
+ catch (error) {
16
+ throw new Error('Failed to generate QR Code');
17
+ }
18
+ };
19
+ //# sourceMappingURL=totp_qr_code_generator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"totp_qr_code_generator.js","sourceRoot":"","sources":["../../../src/utilities/common/totp_qr_code_generator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,MAAM,MAAM,WAAW,CAAA;AAW9B,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,MAAkB,EAAU,EAAE;IAC5D,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,SAAS,GAAG,MAAM,EAAE,MAAM,GAAG,CAAC,EAAE,MAAM,GAAG,EAAE,EAAE,GAAG,MAAM,CAAC;IAC5F,IAAI,SAAS,IAAI,MAAM,IAAI,SAAS,IAAI,QAAQ,IAAI,SAAS,IAAI,QAAQ;QACvE,MAAM,IAAI,KAAK,CAAC,yFAAyF,GAAG,SAAS,CAAC,CAAC;IACzH,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IAC9D,OAAO,kBAAkB,kBAAkB,CAAC,MAAM,CAAC,IAAI,kBAAkB,CAAC,WAAW,CAAC,WAAW,aAAa,WAAW,kBAAkB,CAAC,MAAM,CAAC,cAAc,SAAS,WAAW,MAAM,WAAW,MAAM,EAAE,CAAC;AACjN,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAAG,KAAK,EAAE,MAAkB,EAAmB,EAAE;IAC9E,MAAM,GAAG,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;IACpC,IAAI,CAAC;QACH,OAAO,MAAM,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;IACrC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;IAChD,CAAC;AACH,CAAC,CAAC"}
@@ -0,0 +1,36 @@
1
+ export declare enum CallbackOption {
2
+ AFTER_ALL = 0,// callback should be executed after all dependencies are satisfied
3
+ AFTER_ONE = 1
4
+ }
5
+ /**
6
+ * Js callback wrapper with generic parameter. Stores option of the callback execution: either AFTER_ONE(callback is being executed after one dependency is satisfied), or AFTER_ALL(callback is being called after all dependencies are satisfied)
7
+ */
8
+ export declare class Callback<T> {
9
+ private _cb;
10
+ readonly option: CallbackOption;
11
+ constructor(_cb: (message: T) => void, option?: CallbackOption);
12
+ call(arg: T): void;
13
+ get get(): (message: T) => void;
14
+ }
15
+ /**
16
+ * Manages dependency on one exact key.
17
+ * When the dependency with given key is satisfied, callbacks with option AFTER_ONE are being executed.
18
+ */
19
+ export declare class MessageDependency<Key, T> {
20
+ readonly key: Key;
21
+ private readonly _callbacks;
22
+ constructor(key: Key, cb?: Callback<T>[] | Callback<T>);
23
+ /**
24
+ *
25
+ * @param arg argument to the callback
26
+ * @returns list of callbacks, that should be executed after all dependencies are satisfied
27
+ */
28
+ satisfy(arg: T): (() => void)[];
29
+ }
30
+ export declare class Waitlist<Key, T> {
31
+ private readonly _waitlist;
32
+ constructor();
33
+ add(dependencies: MessageDependency<Key, T>[] | MessageDependency<Key, T>, cb?: () => void): void;
34
+ satisfy(key: Key, arg: T): void;
35
+ }
36
+ //# sourceMappingURL=waitlist.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"waitlist.d.ts","sourceRoot":"","sources":["../../../../src/utilities/common/waitlist/waitlist.ts"],"names":[],"mappings":"AAEA,oBAAY,cAAc;IACtB,SAAS,IAAA,CAAE,mEAAmE;IAC9E,SAAS,IAAA;CACZ;AAED;;GAEG;AACH,qBAAa,QAAQ,CAAC,CAAC;IACN,OAAO,CAAC,GAAG;IAAwB,QAAQ,CAAC,MAAM,EAAE,cAAc;gBAA1D,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,IAAI,EAAW,MAAM,GAAE,cAAyC;IAEnG,IAAI,CAAC,GAAG,EAAE,CAAC;IAIlB,IAAW,GAAG,cANsB,CAAC,KAAK,IAAI,CAQ7C;CACJ;AAED;;;GAGG;AACH,qBAAa,iBAAiB,CAAC,GAAG,EAAE,CAAC;IAErB,QAAQ,CAAC,GAAG,EAAE,GAAG;IAD7B,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAoB;gBAC1B,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,GAAG,QAAQ,CAAC,CAAC,CAAC;IAK/D;;;;OAIG;IACH,OAAO,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,MAAM,IAAI,CAAC,EAAE;CAWlC;AAqCD,qBAAa,QAAQ,CAAC,GAAG,EAAE,CAAC;IAExB,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAyD;;IAInF,GAAG,CAAC,YAAY,EAAE,iBAAiB,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,GAAG,iBAAiB,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,MAAM,IAAI;IAgB1F,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;CAU3B"}
@@ -0,0 +1,116 @@
1
+ import { logging } from '../logger/logger.js';
2
+ export var CallbackOption;
3
+ (function (CallbackOption) {
4
+ CallbackOption[CallbackOption["AFTER_ALL"] = 0] = "AFTER_ALL";
5
+ CallbackOption[CallbackOption["AFTER_ONE"] = 1] = "AFTER_ONE"; // callback should be executed after this dependency is satisfied
6
+ })(CallbackOption || (CallbackOption = {}));
7
+ /**
8
+ * Js callback wrapper with generic parameter. Stores option of the callback execution: either AFTER_ONE(callback is being executed after one dependency is satisfied), or AFTER_ALL(callback is being called after all dependencies are satisfied)
9
+ */
10
+ export class Callback {
11
+ _cb;
12
+ option;
13
+ constructor(_cb, option = CallbackOption.AFTER_ONE) {
14
+ this._cb = _cb;
15
+ this.option = option;
16
+ }
17
+ call(arg) {
18
+ this._cb(arg);
19
+ }
20
+ get get() {
21
+ return this._cb;
22
+ }
23
+ }
24
+ /**
25
+ * Manages dependency on one exact key.
26
+ * When the dependency with given key is satisfied, callbacks with option AFTER_ONE are being executed.
27
+ */
28
+ export class MessageDependency {
29
+ key;
30
+ _callbacks = [];
31
+ constructor(key, cb) {
32
+ this.key = key;
33
+ if (cb)
34
+ this._callbacks = this._callbacks.concat(cb);
35
+ }
36
+ /**
37
+ *
38
+ * @param arg argument to the callback
39
+ * @returns list of callbacks, that should be executed after all dependencies are satisfied
40
+ */
41
+ satisfy(arg) {
42
+ let result = [];
43
+ this._callbacks.forEach(cb => {
44
+ if (cb.option === CallbackOption.AFTER_ONE)
45
+ cb.call(arg);
46
+ else {
47
+ result.push(cb.get.bind(undefined, arg));
48
+ }
49
+ });
50
+ return result;
51
+ }
52
+ }
53
+ /**
54
+ * Enables support to multiple dependencies of the element.
55
+ * Stores all the dependencies in the map by the key of the dependency.
56
+ * When all the dependencies are satisfied, it executes callbacks with provided option AFTER_ALL.
57
+ */
58
+ class DependenciesHandler {
59
+ callbacks = [];
60
+ dependencies;
61
+ /**
62
+ *
63
+ * @param cb callback to call after all dependencies are satisfied(called without arguments)
64
+ * @param dependencies dependencies of the message with own callbacks
65
+ */
66
+ constructor(dependencies, cb) {
67
+ if (cb)
68
+ this.callbacks = [cb];
69
+ this.dependencies = new Map(dependencies.map(dep => { return [dep.key, dep]; }));
70
+ }
71
+ satisfy(key, arg) {
72
+ const dep = this.dependencies.get(key);
73
+ if (dep === undefined)
74
+ return;
75
+ this.callbacks = this.callbacks.concat(dep.satisfy(arg));
76
+ this.dependencies.delete(key);
77
+ if (this.satisfied)
78
+ this.callbacks.forEach(cb => cb());
79
+ }
80
+ get satisfied() {
81
+ return this.dependencies.size === 0;
82
+ }
83
+ }
84
+ export class Waitlist {
85
+ // map dependency --> all the messages dependent on this dependency(these messages could be dependent on other dependencies as well)
86
+ _waitlist = new Map();
87
+ constructor() { }
88
+ add(dependencies, cb) {
89
+ dependencies = [].concat(dependencies);
90
+ logging.debug("Adding dependency to waitlist:", dependencies.map(el => { return el.key; }), "with callback:", cb ? cb.toString() : 'undefined');
91
+ const dep_handler = new DependenciesHandler(dependencies, cb);
92
+ dependencies.forEach(dep => {
93
+ const key = dep.key;
94
+ let dependent_elements;
95
+ if ((dependent_elements = this._waitlist.get(key)) !== undefined) { // if there were already elements dependent on this key
96
+ dependent_elements.add(dep_handler);
97
+ }
98
+ else {
99
+ this._waitlist.set(key, new Set([dep_handler]));
100
+ }
101
+ });
102
+ }
103
+ satisfy(key, arg) {
104
+ let dependent_elememts = this._waitlist.get(key);
105
+ if (dependent_elememts === undefined)
106
+ return;
107
+ dependent_elememts.forEach(el => {
108
+ el.satisfy(key, arg);
109
+ if (el.satisfied) {
110
+ dependent_elememts?.delete(el);
111
+ }
112
+ });
113
+ }
114
+ }
115
+ // consider the order of execution messages
116
+ //# sourceMappingURL=waitlist.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"waitlist.js","sourceRoot":"","sources":["../../../../src/utilities/common/waitlist/waitlist.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,MAAM,CAAN,IAAY,cAGX;AAHD,WAAY,cAAc;IACtB,6DAAS,CAAA;IACT,6DAAS,CAAA,CAAC,iEAAiE;AAC/E,CAAC,EAHW,cAAc,KAAd,cAAc,QAGzB;AAED;;GAEG;AACH,MAAM,OAAO,QAAQ;IACI;IAAoC;IAAzD,YAAqB,GAAyB,EAAW,SAAyB,cAAc,CAAC,SAAS;QAArF,QAAG,GAAH,GAAG,CAAsB;QAAW,WAAM,GAAN,MAAM,CAA2C;IAAG,CAAC;IAEvG,IAAI,CAAC,GAAM;QACd,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAClB,CAAC;IAED,IAAW,GAAG;QACV,OAAO,IAAI,CAAC,GAAG,CAAC;IACpB,CAAC;CACJ;AAED;;;GAGG;AACH,MAAM,OAAO,iBAAiB;IAEL;IADJ,UAAU,GAAkB,EAAE,CAAA;IAC/C,YAAqB,GAAQ,EAAE,EAAgC;QAA1C,QAAG,GAAH,GAAG,CAAK;QACzB,IAAI,EAAE;YACF,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IACrD,CAAC;IAED;;;;OAIG;IACH,OAAO,CAAC,GAAM;QACV,IAAI,MAAM,GAAmB,EAAE,CAAA;QAC/B,IAAI,CAA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AC7C,kBAAkB,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE;YAC5B,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;YACrB,IAAI,EAAE,CAAC,SAAS,EAAE,CAAC;gBACf,kBAAkB,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC;YACnC,CAAC;QACL,CAAC,CAAC,CAAA;IACN,CAAC;CACJ;AAGD,2CAA2C"}
@@ -0,0 +1,50 @@
1
+ import { AsyncQueueAdapter } from './async_queue_adapter.js';
2
+ import WebSocket from 'isomorphic-ws';
3
+ import { WebSocketConnection, AdaptProtocolWSConnection } from './web_socket_connection.js';
4
+ import { AdaptValue } from '@adapt-toolkit/sdk/backend';
5
+ import * as async from 'async';
6
+ declare class GenericWebSocketClient<EventType, T extends WebSocketConnection, OnMessageType> {
7
+ protected server_address: string;
8
+ protected ws: T;
9
+ wsconnection: {
10
+ new (socket: WebSocket): T;
11
+ };
12
+ private _queue;
13
+ constructor(server_address: string, wsconnection: {
14
+ new (socket: WebSocket): T;
15
+ });
16
+ get queue(): AsyncQueueAdapter<EventType, number, (task: EventType) => void>;
17
+ /**
18
+ * Async queue worker. Override this method in child class to create custom behavior of the worker
19
+ *
20
+ * @param e Event
21
+ * @param cb callback to call after event processing done
22
+ */
23
+ worker(e: EventType, cb: async.ErrorCallback): void;
24
+ ws_start(): void;
25
+ /**
26
+ * Override this method in child class to create 'open' event listener.
27
+ */
28
+ on_open(): void;
29
+ /**
30
+ * Override this method in child class to create 'close' event listener.
31
+ */
32
+ on_close(code: number, reason: Buffer): void;
33
+ /**
34
+ * Override this method in child class to create 'error' event listener.
35
+ */
36
+ on_error(e: Error): void;
37
+ /**
38
+ * Override this method in child class to create 'message' event listener.
39
+ * @param data Data received from socket
40
+ */
41
+ on_message(data: OnMessageType): void;
42
+ }
43
+ export declare class WebSocketClient<EventType> extends GenericWebSocketClient<EventType, WebSocketConnection, any> {
44
+ constructor(server_address: string);
45
+ }
46
+ export declare class AdaptProtocolWebSocketClient<EventType> extends GenericWebSocketClient<EventType, AdaptProtocolWSConnection, AdaptValue> {
47
+ constructor(server_address: string);
48
+ }
49
+ export {};
50
+ //# sourceMappingURL=web_socket_client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"web_socket_client.d.ts","sourceRoot":"","sources":["../../../src/utilities/common/web_socket_client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,iBAAiB,EAAC,MAAM,0BAA0B,CAAA;AAC1D,OAAO,SAAS,MAAM,eAAe,CAAA;AACrC,OAAO,EAAC,mBAAmB,EAAE,yBAAyB,EAAC,MAAM,4BAA4B,CAAA;AACzF,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAO9B,cAAM,sBAAsB,CAAC,SAAS,EAAE,CAAC,SAAS,mBAAmB,EAAE,aAAa;IAChF,SAAS,CAAC,cAAc,EAAE,MAAM,CAAC;IACjC,SAAS,CAAC,EAAE,EAAE,CAAC,CAAC;IAChB,YAAY,EAAE;QAAE,KAAI,MAAM,EAAE,SAAS,GAAG,CAAC,CAAA;KAAC,CAAA;IAG1C,OAAO,CAAC,MAAM,CAA+B;gBAEhC,cAAc,EAAE,MAAM,EAAE,YAAY,EAAE;QAAE,KAAI,MAAM,EAAE,SAAS,GAAG,CAAC,CAAA;KAAC;IAQ/E,IAAI,KAAK,oEAER;IAED;;;;;OAKG;IACH,MAAM,CAAC,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE,KAAK,CAAC,aAAa;IAK5C,QAAQ;IAWR;;OAEG;IACH,OAAO;IAIP;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAKrC;;OAEG;IACH,QAAQ,CAAC,CAAC,EAAE,KAAK;IAIjB;;;OAGG;IACH,UAAU,CAAC,IAAI,EAAE,aAAa;CAIjC;AAED,qBAAa,eAAe,CAAC,SAAS,CAAE,SAAQ,sBAAsB,CAAC,SAAS,EAAE,mBAAmB,EAAE,GAAG,CAAC;gBAC3F,cAAc,EAAE,MAAM;CAGrC;AAED,qBAAa,4BAA4B,CAAC,SAAS,CAAE,SAAQ,sBAAsB,CAAC,SAAS,EAAE,yBAAyB,EAAE,UAAU,CAAC;gBACrH,cAAc,EAAE,MAAM;CAGrC"}
@@ -0,0 +1,80 @@
1
+ import { AsyncQueueAdapter } from './async_queue_adapter.js';
2
+ import WebSocket from 'isomorphic-ws';
3
+ import { WebSocketConnection, AdaptProtocolWSConnection } from './web_socket_connection.js';
4
+ import { logging } from './logger/logger.js';
5
+ /*
6
+ This class is generic client for web socket connection. It connects to server via web socket, and create async queue to process messages from and to server
7
+
8
+ */
9
+ class GenericWebSocketClient {
10
+ server_address;
11
+ ws;
12
+ wsconnection;
13
+ _queue;
14
+ constructor(server_address, wsconnection) {
15
+ this._queue = new AsyncQueueAdapter(this.worker.bind(this));
16
+ this.server_address = server_address;
17
+ this.wsconnection = wsconnection;
18
+ this.ws = new wsconnection(new WebSocket(this.server_address));
19
+ this.queue.pause();
20
+ }
21
+ get queue() {
22
+ return this._queue;
23
+ }
24
+ /**
25
+ * Async queue worker. Override this method in child class to create custom behavior of the worker
26
+ *
27
+ * @param e Event
28
+ * @param cb callback to call after event processing done
29
+ */
30
+ worker(e, cb) {
31
+ cb();
32
+ }
33
+ ws_start() {
34
+ logging.debug("Attempting to establish web socket connection with: ", this.server_address);
35
+ if (this.ws.closed)
36
+ this.ws = new this.wsconnection(new WebSocket(this.server_address));
37
+ this.ws.on('open', this.on_open.bind(this));
38
+ this.ws.on('close', this.on_close.bind(this));
39
+ this.ws.on('error', this.on_error.bind(this));
40
+ this.ws.on('message', this.on_message.bind(this));
41
+ this.queue.resume();
42
+ }
43
+ /**
44
+ * Override this method in child class to create 'open' event listener.
45
+ */
46
+ on_open() {
47
+ logging.warning("You forgot to override the on_open method? We have obtained the message in the parent class and don't know what to do with it.");
48
+ }
49
+ /**
50
+ * Override this method in child class to create 'close' event listener.
51
+ */
52
+ on_close(code, reason) {
53
+ this.queue.pause();
54
+ setTimeout(() => this.ws_start(), 1000);
55
+ }
56
+ /**
57
+ * Override this method in child class to create 'error' event listener.
58
+ */
59
+ on_error(e) {
60
+ logging.warning("You forgot to override the on_error method? We have obtained the message in the parent class and don't know what to do with it.");
61
+ }
62
+ /**
63
+ * Override this method in child class to create 'message' event listener.
64
+ * @param data Data received from socket
65
+ */
66
+ on_message(data) {
67
+ logging.warning("You forgot to override the on_mesasge method? We have obtained the message in the parent class and don't know what to do with it.");
68
+ }
69
+ }
70
+ export class WebSocketClient extends GenericWebSocketClient {
71
+ constructor(server_address) {
72
+ super(server_address, WebSocketConnection);
73
+ }
74
+ }
75
+ export class AdaptProtocolWebSocketClient extends GenericWebSocketClient {
76
+ constructor(server_address) {
77
+ super(server_address, AdaptProtocolWSConnection);
78
+ }
79
+ }
80
+ //# sourceMappingURL=web_socket_client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"web_socket_client.js","sourceRoot":"","sources":["../../../src/utilities/common/web_socket_client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,iBAAiB,EAAC,MAAM,0BAA0B,CAAA;AAC1D,OAAO,SAAS,MAAM,eAAe,CAAA;AACrC,OAAO,EAAC,mBAAmB,EAAE,yBAAyB,EAAC,MAAM,4BAA4B,CAAA;AAGzF,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAE7C;;;EAGE;AACF,MAAM,sBAAsB;IACd,cAAc,CAAS;IACvB,EAAE,CAAI;IAChB,YAAY,CAA8B;IAGlC,MAAM,CAA+B;IAE7C,YAAa,cAAsB,EAAE,YAA0C;QAC3E,IAAI,CAAC,MAAM,GAAG,IAAI,iBAAiB,CAAY,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QACvE,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QACrC,IAAI,CAAC,YAAY,GAAG,YAAY,C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I,CAAC,KAAK,CAAC,KAAK,EAAE,CAAA;QAClB,UAAU,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,IAAI,CAAC,CAAA;IAC3C,CAAC;IAED;;OAEG;IACH,QAAQ,CAAC,CAAQ;QACb,OAAO,CAAC,OAAO,CAAC,iIAAiI,CAAC,CAAA;IACtJ,CAAC;IAED;;;OAGG;IACH,UAAU,CAAC,IAAmB;QAC1B,OAAO,CAAC,OAAO,CAAC,mIAAmI,CAAC,CAAA;IACxJ,CAAC;CAEJ;AAED,MAAM,OAAO,eAA2B,SAAQ,sBAA2D;IACvG,YAAY,cAAsB;QAC9B,KAAK,CAAC,cAAc,EAAE,mBAAmB,CAAC,CAAA;IAC9C,CAAC;CACJ;AAED,MAAM,OAAO,4BAAwC,SAAQ,sBAAwE;IACjI,YAAY,cAAsB;QAC9B,KAAK,CAAC,cAAc,EAAE,yBAAyB,CAAC,CAAC;IACrD,CAAC;CACJ"}
@@ -0,0 +1,29 @@
1
+ import WebSocket from 'isomorphic-ws';
2
+ import { AdaptValue } from '@adapt-toolkit/sdk/backend';
3
+ declare class GenericWebSocketConnection<OnMessageType> {
4
+ protected socket: WebSocket;
5
+ constructor(socket: WebSocket);
6
+ send(data: any): void;
7
+ close(): void;
8
+ get closed(): boolean;
9
+ protected on_message(cb: (data: any) => void): void;
10
+ protected on_close(cb: (code: number, reason: string) => void): void;
11
+ protected on_error(cb: (error: Error) => void): void;
12
+ protected on_open(cb: () => void): void;
13
+ private event_to_function_map;
14
+ on(event: 'message', cb: (data: OnMessageType) => void): void;
15
+ on(event: 'close', cb: (code: number, reason: Buffer) => void): void;
16
+ on(event: 'error', cb: (error: Error) => void): void;
17
+ on(event: 'open', cb: () => void): void;
18
+ on<A extends OnMessageType | Error | undefined | number, B extends (A extends undefined ? undefined : (A extends number ? Buffer : undefined))>(event: 'message' | 'close' | 'error' | 'open', cb: (a?: A, b?: B) => void): void;
19
+ }
20
+ export declare class WebSocketConnection extends GenericWebSocketConnection<any> {
21
+ }
22
+ export declare class AdaptProtocolWSConnection extends GenericWebSocketConnection<AdaptValue> {
23
+ constructor(socket: WebSocket);
24
+ send(data: AdaptValue): void;
25
+ private parse_and_validate;
26
+ on_message(cb: (data: AdaptValue) => void): void;
27
+ }
28
+ export {};
29
+ //# sourceMappingURL=web_socket_connection.d.ts.map