@tak-ps/node-cot 4.6.0 → 5.0.1

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/test/cot.test.ts DELETED
@@ -1,246 +0,0 @@
1
- import test from 'tape';
2
- import CoT from '../index.js';
3
-
4
- test('Decode COT message', (t) => {
5
- const packet = '<event version="2.0" uid="ANDROID-deadbeef" type="a-f-G-U-C" how="m-g" time="2021-02-27T20:32:24.771Z" start="2021-02-27T20:32:24.771Z" stale="2021-02-27T20:38:39.771Z"><point lat="1.234567" lon="-3.141592" hae="-25.7" ce="9.9" le="9999999.0"/><detail><takv os="29" version="4.0.0.0 (deadbeef).1234567890-CIV" device="Some Android Device" platform="ATAK-CIV"/><contact xmppUsername="xmpp@host.com" endpoint="*:-1:stcp" callsign="JENNY"/><uid Droid="JENNY"/><precisionlocation altsrc="GPS" geopointsrc="GPS"/><__group role="Team Member" name="Cyan"/><status battery="78"/><track course="80.24833892285461" speed="0.0"/></detail></event>';
6
-
7
- t.deepEquals((new CoT(packet)).raw, {
8
- 'event': {
9
- '_attributes': {
10
- 'version': '2.0',
11
- 'uid': 'ANDROID-deadbeef',
12
- 'type': 'a-f-G-U-C',
13
- 'how': 'm-g',
14
- 'time': '2021-02-27T20:32:24.771Z',
15
- 'start': '2021-02-27T20:32:24.771Z',
16
- 'stale': '2021-02-27T20:38:39.771Z'
17
- },
18
- 'point': {
19
- '_attributes': {
20
- 'lat': '1.234567',
21
- 'lon': '-3.141592',
22
- 'hae': '-25.7',
23
- 'ce': '9.9',
24
- 'le': '9999999.0'
25
- }
26
- },
27
- 'detail': {
28
- 'takv': {
29
- '_attributes': {
30
- 'os': '29',
31
- 'version': '4.0.0.0 (deadbeef).1234567890-CIV',
32
- 'device': 'Some Android Device',
33
- 'platform': 'ATAK-CIV'
34
- }
35
- },
36
- 'contact': {
37
- '_attributes': {
38
- 'xmppUsername': 'xmpp@host.com',
39
- 'endpoint': '*:-1:stcp',
40
- 'callsign': 'JENNY'
41
- }
42
- },
43
- 'uid': { '_attributes': { 'Droid': 'JENNY' } },
44
- 'precisionlocation': { '_attributes': { 'altsrc': 'GPS', 'geopointsrc': 'GPS' } },
45
- '__group': { '_attributes': { 'role': 'Team Member', 'name': 'Cyan' } },
46
- 'status': { '_attributes': { 'battery': '78' } },
47
- 'track': { '_attributes': { 'course': '80.24833892285461', 'speed': '0.0' } }
48
- }
49
- }
50
- });
51
-
52
- t.end();
53
- });
54
-
55
- test('Decode COT message', (t) => {
56
- const packet = '<event version="2.0" uid="TEST-deadbeef" type="a" how="m-g" time="2021-03-12T15:49:07.138Z" start="2021-03-12T15:49:07.138Z" stale="2021-03-12T15:49:07.138Z"><point lat="0.000000" lon="0.000000" hae="0.0" ce="9999999.0" le="9999999.0"/><detail><takv os="Android" version="10" device="Some Device" platform="python unittest"/><status battery="83"/><uid Droid="JENNY"/><contact callsign="JENNY" endpoint="*:-1:stcp" phone="800-867-5309"/><__group role="Team Member" name="Cyan"/><track course="90.1" speed="10.3"/></detail></event>';
57
-
58
- t.deepEquals((new CoT(packet)).raw, {
59
- 'event': {
60
- '_attributes': {
61
- 'version': '2.0',
62
- 'uid': 'TEST-deadbeef',
63
- 'type': 'a',
64
- 'how': 'm-g',
65
- 'time': '2021-03-12T15:49:07.138Z',
66
- 'start': '2021-03-12T15:49:07.138Z',
67
- 'stale': '2021-03-12T15:49:07.138Z'
68
- },
69
- 'point': {
70
- '_attributes': {
71
- 'lat': '0.000000',
72
- 'lon': '0.000000',
73
- 'hae': '0.0',
74
- 'ce': '9999999.0',
75
- 'le': '9999999.0'
76
- }
77
- },
78
- 'detail': {
79
- 'takv': {
80
- '_attributes': {
81
- 'os': 'Android',
82
- 'version': '10',
83
- 'device': 'Some Device',
84
- 'platform': 'python unittest'
85
- }
86
- },
87
- 'status': {
88
- '_attributes': {
89
- 'battery': '83'
90
- }
91
- },
92
- 'uid': {
93
- '_attributes': {
94
- 'Droid': 'JENNY'
95
- }
96
- },
97
- 'contact': {
98
- '_attributes': {
99
- 'callsign': 'JENNY',
100
- 'endpoint': '*:-1:stcp',
101
- 'phone': '800-867-5309'
102
- }
103
- },
104
- '__group': {
105
- '_attributes': {
106
- 'role': 'Team Member',
107
- 'name': 'Cyan'
108
- }
109
- },
110
- 'track': {
111
- '_attributes': {
112
- 'course': '90.1',
113
- 'speed': '10.3'
114
- }
115
- }
116
- }
117
- }
118
- });
119
-
120
- t.end();
121
- });
122
-
123
- test('Encode COT message', (t) => {
124
- const packet = {
125
- 'event': {
126
- '_attributes': {
127
- 'version': '2.0',
128
- 'uid': 'ANDROID-deadbeef',
129
- 'type': 'a-f-G-U-C',
130
- 'how': 'm-g',
131
- 'time': '2021-02-27T20:32:24.771Z',
132
- 'start': '2021-02-27T20:32:24.771Z',
133
- 'stale': '2021-02-27T20:38:39.771Z'
134
- },
135
- 'point': {
136
- '_attributes': {
137
- 'lat': '1.234567',
138
- 'lon': '-3.141592',
139
- 'hae': '-25.7',
140
- 'ce': '9.9',
141
- 'le': '9999999'
142
- }
143
- },
144
- 'detail': {
145
- 'takv': {
146
- '_attributes': {
147
- 'os': '29',
148
- 'version': '4.0.0.0 (deadbeef).1234567890-CIV',
149
- 'device': 'Some Android Device',
150
- 'platform': 'ATAK-CIV'
151
- }
152
- },
153
- 'contact': {
154
- '_attributes': {
155
- 'xmppUsername': 'xmpp@host.com',
156
- 'endpoint': '*:-1:stcp',
157
- 'callsign': 'JENNY'
158
- }
159
- },
160
- 'uid': { '_attributes': { 'Droid': 'JENNY' } },
161
- 'precisionlocation': { '_attributes': { 'altsrc': 'GPS', 'geopointsrc': 'GPS' } },
162
- '__group': { '_attributes': { 'role': 'Team Member', 'name': 'Cyan' } },
163
- 'status': { '_attributes': { 'battery': '78' } },
164
- 'track': { '_attributes': { 'course': '80.24833892285461', 'speed': '0.0' } }
165
- }
166
- }
167
- };
168
-
169
- t.deepEquals(
170
- (new CoT(packet)).to_xml(),
171
- '<event version="2.0" uid="ANDROID-deadbeef" type="a-f-G-U-C" how="m-g" time="2021-02-27T20:32:24.771Z" start="2021-02-27T20:32:24.771Z" stale="2021-02-27T20:38:39.771Z"><point lat="1.234567" lon="-3.141592" hae="-25.7" ce="9.9" le="9999999"/><detail><takv os="29" version="4.0.0.0 (deadbeef).1234567890-CIV" device="Some Android Device" platform="ATAK-CIV"/><contact xmppUsername="xmpp@host.com" endpoint="*:-1:stcp" callsign="JENNY"/><uid Droid="JENNY"/><precisionlocation altsrc="GPS" geopointsrc="GPS"/><__group role="Team Member" name="Cyan"/><status battery="78"/><track course="80.24833892285461" speed="0.0"/></detail></event>'
172
- );
173
-
174
- t.end();
175
- });
176
-
177
- test('Parse GeoChat message', (t) => {
178
- const geochat = '<event version="2.0" uid="GeoChat.ANDROID-deadbeef.JOKER MAN.563040b9-2ac9-4af3-9e01-4cb2b05d98ea" type="b-t-f" how="h-g-i-g-o" time="2021-02-23T22:28:22.191Z" start="2021-02-23T22:28:22.191Z" stale="2021-02-24T22:28:22.191Z">\n' +
179
- ' <point lat="1.234567" lon="-3.141592" hae="-25.8" ce="9.9" le="9999999.0"/>\n' +
180
- ' <detail>\n' +
181
- ' <__chat parent="RootContactGroup" groupOwner="false" chatroom="JOKER MAN" id="ANDROID-cafebabe" senderCallsign="JENNY">\n' +
182
- ' <chatgrp uid0="ANDROID-deadbeef" uid1="ANDROID-cafebabe" id="ANDROID-cafebabe"/>\n' +
183
- ' </__chat>\n' +
184
- ' <link uid="ANDROID-deadbeef" type="a-f-G-U-C" relation="p-p"/>\n' +
185
- ' <remarks source="BAO.F.ATAK.ANDROID-deadbeef" to="ANDROID-cafebabe" time="2021-02-23T22:28:22.191Z">test</remarks>\n' +
186
- ' <__serverdestination destinations="123.45.67.89:4242:tcp:ANDROID-deadbeef"/>\n' +
187
- ' <marti>\n' +
188
- ' <dest callsign="JOKER MAN"/>\n' +
189
- ' </marti>\n' +
190
- ' </detail>\n' +
191
- '</event>';
192
-
193
- t.deepEquals((new CoT(geochat)).raw, {
194
- 'event': {
195
- '_attributes': {
196
- 'version': '2.0',
197
- 'uid': 'GeoChat.ANDROID-deadbeef.JOKER MAN.563040b9-2ac9-4af3-9e01-4cb2b05d98ea',
198
- 'type': 'b-t-f',
199
- 'how': 'h-g-i-g-o',
200
- 'time': '2021-02-23T22:28:22.191Z',
201
- 'start': '2021-02-23T22:28:22.191Z',
202
- 'stale': '2021-02-24T22:28:22.191Z'
203
- },
204
- 'point': {
205
- '_attributes': {
206
- 'lat': '1.234567',
207
- 'lon': '-3.141592',
208
- 'hae': '-25.8',
209
- 'ce': '9.9',
210
- 'le': '9999999.0'
211
- }
212
- },
213
- 'detail': {
214
- '__chat': {
215
- '_attributes': {
216
- 'parent': 'RootContactGroup',
217
- 'groupOwner': 'false',
218
- 'chatroom': 'JOKER MAN',
219
- 'id': 'ANDROID-cafebabe',
220
- 'senderCallsign': 'JENNY'
221
- },
222
- 'chatgrp': {
223
- '_attributes': {
224
- 'uid0': 'ANDROID-deadbeef',
225
- 'uid1': 'ANDROID-cafebabe',
226
- 'id': 'ANDROID-cafebabe'
227
- }
228
- }
229
- },
230
- 'link': { '_attributes': { 'uid': 'ANDROID-deadbeef', 'type': 'a-f-G-U-C', 'relation': 'p-p' } },
231
- 'remarks': {
232
- '_attributes': {
233
- 'source': 'BAO.F.ATAK.ANDROID-deadbeef',
234
- 'to': 'ANDROID-cafebabe',
235
- 'time': '2021-02-23T22:28:22.191Z'
236
- },
237
- '_text': 'test'
238
- },
239
- '__serverdestination': { '_attributes': { 'destinations': '123.45.67.89:4242:tcp:ANDROID-deadbeef' } },
240
- 'marti': { 'dest': { '_attributes': { 'callsign': 'JOKER MAN' } } }
241
- }
242
- }
243
- });
244
-
245
- t.end();
246
- });