@ndustrial/contxt-sdk 5.5.7 → 5.6.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.
Files changed (230) hide show
  1. package/.nvmrc +1 -1
  2. package/eslint.config.mjs +44 -0
  3. package/esm/bus/channels.js +1883 -216
  4. package/esm/bus/channels.js.map +1 -1
  5. package/esm/bus/index.browser.js +218 -37
  6. package/esm/bus/index.browser.js.map +1 -1
  7. package/esm/bus/index.js +906 -94
  8. package/esm/bus/index.js.map +1 -1
  9. package/esm/bus/webSocketConnection.browser.js +86 -12
  10. package/esm/bus/webSocketConnection.browser.js.map +1 -1
  11. package/esm/bus/webSocketConnection.js +2464 -332
  12. package/esm/bus/webSocketConnection.js.map +1 -1
  13. package/esm/config/audiences.js +37 -1
  14. package/esm/config/audiences.js.map +1 -1
  15. package/esm/config/defaults.js +37 -1
  16. package/esm/config/defaults.js.map +1 -1
  17. package/esm/config/index.js +1622 -203
  18. package/esm/config/index.js.map +1 -1
  19. package/esm/coordinator/applications.js +1019 -172
  20. package/esm/coordinator/applications.js.map +1 -1
  21. package/esm/coordinator/consent.js +603 -76
  22. package/esm/coordinator/consent.js.map +1 -1
  23. package/esm/coordinator/edgeNodes.js +520 -40
  24. package/esm/coordinator/edgeNodes.js.map +1 -1
  25. package/esm/coordinator/index.js +811 -54
  26. package/esm/coordinator/index.js.map +1 -1
  27. package/esm/coordinator/organizations.js +533 -60
  28. package/esm/coordinator/organizations.js.map +1 -1
  29. package/esm/coordinator/permissions.js +914 -107
  30. package/esm/coordinator/permissions.js.map +1 -1
  31. package/esm/coordinator/roles.js +2146 -258
  32. package/esm/coordinator/roles.js.map +1 -1
  33. package/esm/coordinator/users.js +3427 -484
  34. package/esm/coordinator/users.js.map +1 -1
  35. package/esm/events/index.js +2301 -393
  36. package/esm/events/index.js.map +1 -1
  37. package/esm/files/index.js +2053 -410
  38. package/esm/files/index.js.map +1 -1
  39. package/esm/index.js +1002 -148
  40. package/esm/index.js.map +1 -1
  41. package/esm/iot/feedTypes.js +188 -25
  42. package/esm/iot/feedTypes.js.map +1 -1
  43. package/esm/iot/feeds.js +420 -59
  44. package/esm/iot/feeds.js.map +1 -1
  45. package/esm/iot/fieldCategories.js +1172 -195
  46. package/esm/iot/fieldCategories.js.map +1 -1
  47. package/esm/iot/fieldGroupings.js +1689 -255
  48. package/esm/iot/fieldGroupings.js.map +1 -1
  49. package/esm/iot/fields.js +254 -28
  50. package/esm/iot/fields.js.map +1 -1
  51. package/esm/iot/index.js +212 -34
  52. package/esm/iot/index.js.map +1 -1
  53. package/esm/iot/outputs.js +320 -31
  54. package/esm/iot/outputs.js.map +1 -1
  55. package/esm/nionic/index.js +1097 -97
  56. package/esm/nionic/index.js.map +1 -1
  57. package/esm/request.js +1313 -219
  58. package/esm/request.js.map +1 -1
  59. package/esm/sessionTypes/auth0WebAuth.js +3395 -409
  60. package/esm/sessionTypes/auth0WebAuth.js.map +1 -1
  61. package/esm/sessionTypes/index.js +213 -22
  62. package/esm/sessionTypes/index.js.map +1 -1
  63. package/esm/sessionTypes/machineAuth.js +1314 -144
  64. package/esm/sessionTypes/machineAuth.js.map +1 -1
  65. package/esm/sessionTypes/passwordGrantAuth.js +1060 -145
  66. package/esm/sessionTypes/passwordGrantAuth.js.map +1 -1
  67. package/esm/utils/events/formatEventUpdateToServer.js +107 -4
  68. package/esm/utils/events/formatEventUpdateToServer.js.map +1 -1
  69. package/esm/utils/events/index.js +54 -2
  70. package/esm/utils/events/index.js.map +1 -1
  71. package/esm/utils/iot/formatOutputFieldDataFromServer.js +227 -14
  72. package/esm/utils/iot/formatOutputFieldDataFromServer.js.map +1 -1
  73. package/esm/utils/iot/index.js +56 -3
  74. package/esm/utils/iot/index.js.map +1 -1
  75. package/esm/utils/iot/parseOutputFieldNextPageUrlMetadata.js +207 -7
  76. package/esm/utils/iot/parseOutputFieldNextPageUrlMetadata.js.map +1 -1
  77. package/esm/utils/objects/createCaseChangeFn.js +449 -18
  78. package/esm/utils/objects/createCaseChangeFn.js.map +1 -1
  79. package/esm/utils/objects/index.js +56 -3
  80. package/esm/utils/objects/index.js.map +1 -1
  81. package/esm/utils/objects/map.js +520 -26
  82. package/esm/utils/objects/map.js.map +1 -1
  83. package/esm/utils/objects/toCamelCase.js +39 -3
  84. package/esm/utils/objects/toCamelCase.js.map +1 -1
  85. package/esm/utils/objects/toSnakeCase.js +39 -3
  86. package/esm/utils/objects/toSnakeCase.js.map +1 -1
  87. package/esm/utils/pagination/formatPaginatedDataFromServer.js +268 -11
  88. package/esm/utils/pagination/formatPaginatedDataFromServer.js.map +1 -1
  89. package/esm/utils/pagination/index.js +54 -2
  90. package/esm/utils/pagination/index.js.map +1 -1
  91. package/esm/utils/url/index.js +47 -2
  92. package/esm/utils/url/index.js.map +1 -1
  93. package/esm/utils/url/stringifyParams.js +176 -10
  94. package/esm/utils/url/stringifyParams.js.map +1 -1
  95. package/lib/bus/channels.js +1880 -223
  96. package/lib/bus/channels.js.map +1 -1
  97. package/lib/bus/index.browser.js +215 -43
  98. package/lib/bus/index.browser.js.map +1 -1
  99. package/lib/bus/index.js +903 -106
  100. package/lib/bus/index.js.map +1 -1
  101. package/lib/bus/webSocketConnection.browser.js +83 -15
  102. package/lib/bus/webSocketConnection.browser.js.map +1 -1
  103. package/lib/bus/webSocketConnection.js +2461 -339
  104. package/lib/bus/webSocketConnection.js.map +1 -1
  105. package/lib/config/audiences.js +33 -2
  106. package/lib/config/audiences.js.map +1 -1
  107. package/lib/config/defaults.js +33 -2
  108. package/lib/config/defaults.js.map +1 -1
  109. package/lib/config/index.js +1619 -212
  110. package/lib/config/index.js.map +1 -1
  111. package/lib/coordinator/applications.js +1016 -174
  112. package/lib/coordinator/applications.js.map +1 -1
  113. package/lib/coordinator/consent.js +600 -78
  114. package/lib/coordinator/consent.js.map +1 -1
  115. package/lib/coordinator/edgeNodes.js +517 -42
  116. package/lib/coordinator/edgeNodes.js.map +1 -1
  117. package/lib/coordinator/index.js +808 -78
  118. package/lib/coordinator/index.js.map +1 -1
  119. package/lib/coordinator/organizations.js +530 -62
  120. package/lib/coordinator/organizations.js.map +1 -1
  121. package/lib/coordinator/permissions.js +911 -109
  122. package/lib/coordinator/permissions.js.map +1 -1
  123. package/lib/coordinator/roles.js +2143 -260
  124. package/lib/coordinator/roles.js.map +1 -1
  125. package/lib/coordinator/users.js +3423 -489
  126. package/lib/coordinator/users.js.map +1 -1
  127. package/lib/events/index.js +2297 -404
  128. package/lib/events/index.js.map +1 -1
  129. package/lib/files/index.js +2050 -418
  130. package/lib/files/index.js.map +1 -1
  131. package/lib/index.js +999 -183
  132. package/lib/index.js.map +1 -1
  133. package/lib/iot/feedTypes.js +185 -27
  134. package/lib/iot/feedTypes.js.map +1 -1
  135. package/lib/iot/feeds.js +417 -61
  136. package/lib/iot/feeds.js.map +1 -1
  137. package/lib/iot/fieldCategories.js +1169 -203
  138. package/lib/iot/fieldCategories.js.map +1 -1
  139. package/lib/iot/fieldGroupings.js +1686 -263
  140. package/lib/iot/fieldGroupings.js.map +1 -1
  141. package/lib/iot/fields.js +251 -30
  142. package/lib/iot/fields.js.map +1 -1
  143. package/lib/iot/index.js +209 -55
  144. package/lib/iot/index.js.map +1 -1
  145. package/lib/iot/outputs.js +317 -34
  146. package/lib/iot/outputs.js.map +1 -1
  147. package/lib/nionic/index.js +1094 -98
  148. package/lib/nionic/index.js.map +1 -1
  149. package/lib/request.js +1310 -226
  150. package/lib/request.js.map +1 -1
  151. package/lib/sessionTypes/auth0WebAuth.js +3391 -421
  152. package/lib/sessionTypes/auth0WebAuth.js.map +1 -1
  153. package/lib/sessionTypes/index.js +209 -26
  154. package/lib/sessionTypes/index.js.map +1 -1
  155. package/lib/sessionTypes/machineAuth.js +1311 -151
  156. package/lib/sessionTypes/machineAuth.js.map +1 -1
  157. package/lib/sessionTypes/passwordGrantAuth.js +1057 -156
  158. package/lib/sessionTypes/passwordGrantAuth.js.map +1 -1
  159. package/lib/utils/events/formatEventUpdateToServer.js +102 -4
  160. package/lib/utils/events/formatEventUpdateToServer.js.map +1 -1
  161. package/lib/utils/events/index.js +51 -10
  162. package/lib/utils/events/index.js.map +1 -1
  163. package/lib/utils/iot/formatOutputFieldDataFromServer.js +224 -18
  164. package/lib/utils/iot/formatOutputFieldDataFromServer.js.map +1 -1
  165. package/lib/utils/iot/index.js +53 -15
  166. package/lib/utils/iot/index.js.map +1 -1
  167. package/lib/utils/iot/parseOutputFieldNextPageUrlMetadata.js +203 -13
  168. package/lib/utils/iot/parseOutputFieldNextPageUrlMetadata.js.map +1 -1
  169. package/lib/utils/objects/createCaseChangeFn.js +446 -25
  170. package/lib/utils/objects/createCaseChangeFn.js.map +1 -1
  171. package/lib/utils/objects/index.js +53 -15
  172. package/lib/utils/objects/index.js.map +1 -1
  173. package/lib/utils/objects/map.js +517 -33
  174. package/lib/utils/objects/map.js.map +1 -1
  175. package/lib/utils/objects/toCamelCase.js +36 -11
  176. package/lib/utils/objects/toCamelCase.js.map +1 -1
  177. package/lib/utils/objects/toSnakeCase.js +36 -11
  178. package/lib/utils/objects/toSnakeCase.js.map +1 -1
  179. package/lib/utils/pagination/formatPaginatedDataFromServer.js +265 -14
  180. package/lib/utils/pagination/formatPaginatedDataFromServer.js.map +1 -1
  181. package/lib/utils/pagination/index.js +51 -10
  182. package/lib/utils/pagination/index.js.map +1 -1
  183. package/lib/utils/url/index.js +44 -7
  184. package/lib/utils/url/index.js.map +1 -1
  185. package/lib/utils/url/stringifyParams.js +172 -18
  186. package/lib/utils/url/stringifyParams.js.map +1 -1
  187. package/package.json +32 -36
  188. package/src/bus/channels.js +6 -6
  189. package/src/bus/channels.spec.js +1 -1
  190. package/src/coordinator/applications.js +7 -7
  191. package/src/coordinator/applications.spec.js +1 -1
  192. package/src/coordinator/consent.js +3 -3
  193. package/src/coordinator/edgeNodes.js +3 -3
  194. package/src/coordinator/edgeNodes.spec.js +1 -1
  195. package/src/coordinator/organizations.js +4 -4
  196. package/src/coordinator/organizations.spec.js +1 -1
  197. package/src/coordinator/permissions.js +6 -6
  198. package/src/coordinator/permissions.spec.js +1 -1
  199. package/src/coordinator/roles.js +9 -9
  200. package/src/coordinator/roles.spec.js +1 -1
  201. package/src/coordinator/users.js +13 -13
  202. package/src/coordinator/users.spec.js +294 -294
  203. package/src/events/index.js +18 -18
  204. package/src/events/index.spec.js +3 -3
  205. package/src/files/index.js +9 -9
  206. package/src/files/index.spec.js +2 -2
  207. package/src/index.js +3 -1
  208. package/src/iot/feedTypes.js +2 -2
  209. package/src/iot/feeds.js +4 -4
  210. package/src/iot/feeds.spec.js +1 -1
  211. package/src/iot/fieldCategories.js +10 -10
  212. package/src/iot/fieldCategories.spec.js +2 -2
  213. package/src/iot/fieldGroupings.js +10 -10
  214. package/src/iot/fieldGroupings.spec.js +2 -2
  215. package/src/iot/fields.js +2 -2
  216. package/src/iot/fields.spec.js +1 -1
  217. package/src/iot/outputs.js +2 -2
  218. package/src/iot/outputs.spec.js +1 -1
  219. package/src/sessionTypes/auth0WebAuth.spec.js +1 -1
  220. package/src/utils/events/index.js +2 -1
  221. package/src/utils/iot/formatOutputFieldDataFromServer.js +5 -5
  222. package/src/utils/iot/formatOutputFieldDataFromServer.spec.js +2 -2
  223. package/src/utils/iot/index.js +2 -1
  224. package/src/utils/iot/parseOutputFieldNextPageUrlMetadata.js +3 -1
  225. package/src/utils/objects/index.js +2 -1
  226. package/src/utils/pagination/formatPaginatedDataFromServer.js +3 -3
  227. package/src/utils/pagination/formatPaginatedDataFromServer.spec.js +1 -1
  228. package/src/utils/pagination/index.js +2 -1
  229. package/support/mocharc.yml +1 -1
  230. package/.eslintrc +0 -24
@@ -1,24 +1,1160 @@
1
- 'use strict';
1
+ "use strict";
2
2
 
3
+ require("core-js/modules/es.array.filter.js");
4
+ require("core-js/modules/es.object.get-own-property-descriptors.js");
5
+ require("core-js/modules/esnext.iterator.constructor.js");
6
+ require("core-js/modules/esnext.iterator.filter.js");
7
+ require("core-js/modules/esnext.iterator.for-each.js");
3
8
  Object.defineProperty(exports, "__esModule", {
4
9
  value: true
5
10
  });
6
- exports.TYPE = undefined;
7
-
8
- var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
9
-
10
- var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
11
-
12
- var _axios = require('axios');
13
-
14
- var _axios2 = _interopRequireDefault(_axios);
15
-
16
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
-
18
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
19
-
20
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
21
-
11
+ exports.default = exports.TYPE = void 0;
12
+ require("core-js/modules/es.promise.js");
13
+ var _axios = _interopRequireDefault(require("axios"));
14
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
15
+ function cov_1wzdsw0kpo() {
16
+ var path = "/home/runner/work/contxt-sdk-js/contxt-sdk-js/src/sessionTypes/machineAuth.js";
17
+ var hash = "5f9f61811e14fa3deec2529b55782b794416b677";
18
+ var global = new Function("return this")();
19
+ var gcv = "__coverage__";
20
+ var coverageData = {
21
+ path: "/home/runner/work/contxt-sdk-js/contxt-sdk-js/src/sessionTypes/machineAuth.js",
22
+ statementMap: {
23
+ "0": {
24
+ start: {
25
+ line: 36,
26
+ column: 4
27
+ },
28
+ end: {
29
+ line: 36,
30
+ column: 20
31
+ }
32
+ },
33
+ "1": {
34
+ start: {
35
+ line: 37,
36
+ column: 4
37
+ },
38
+ end: {
39
+ line: 37,
40
+ column: 27
41
+ }
42
+ },
43
+ "2": {
44
+ start: {
45
+ line: 38,
46
+ column: 4
47
+ },
48
+ end: {
49
+ line: 38,
50
+ column: 29
51
+ }
52
+ },
53
+ "3": {
54
+ start: {
55
+ line: 40,
56
+ column: 4
57
+ },
58
+ end: {
59
+ line: 42,
60
+ column: 5
61
+ }
62
+ },
63
+ "4": {
64
+ start: {
65
+ line: 41,
66
+ column: 6
67
+ },
68
+ end: {
69
+ line: 41,
70
+ column: 73
71
+ }
72
+ },
73
+ "5": {
74
+ start: {
75
+ line: 44,
76
+ column: 4
77
+ },
78
+ end: {
79
+ line: 46,
80
+ column: 5
81
+ }
82
+ },
83
+ "6": {
84
+ start: {
85
+ line: 45,
86
+ column: 6
87
+ },
88
+ end: {
89
+ line: 45,
90
+ column: 77
91
+ }
92
+ },
93
+ "7": {
94
+ start: {
95
+ line: 57,
96
+ column: 20
97
+ },
98
+ end: {
99
+ line: 57,
100
+ column: 74
101
+ }
102
+ },
103
+ "8": {
104
+ start: {
105
+ line: 59,
106
+ column: 4
107
+ },
108
+ end: {
109
+ line: 61,
110
+ column: 7
111
+ }
112
+ },
113
+ "9": {
114
+ start: {
115
+ line: 60,
116
+ column: 6
117
+ },
118
+ end: {
119
+ line: 60,
120
+ column: 45
121
+ }
122
+ },
123
+ "10": {
124
+ start: {
125
+ line: 74,
126
+ column: 4
127
+ },
128
+ end: {
129
+ line: 76,
130
+ column: 5
131
+ }
132
+ },
133
+ "11": {
134
+ start: {
135
+ line: 75,
136
+ column: 6
137
+ },
138
+ end: {
139
+ line: 75,
140
+ column: 71
141
+ }
142
+ },
143
+ "12": {
144
+ start: {
145
+ line: 78,
146
+ column: 4
147
+ },
148
+ end: {
149
+ line: 80,
150
+ column: 6
151
+ }
152
+ },
153
+ "13": {
154
+ start: {
155
+ line: 79,
156
+ column: 23
157
+ },
158
+ end: {
159
+ line: 79,
160
+ column: 43
161
+ }
162
+ },
163
+ "14": {
164
+ start: {
165
+ line: 91,
166
+ column: 4
167
+ },
168
+ end: {
169
+ line: 93,
170
+ column: 5
171
+ }
172
+ },
173
+ "15": {
174
+ start: {
175
+ line: 92,
176
+ column: 6
177
+ },
178
+ end: {
179
+ line: 92,
180
+ column: 19
181
+ }
182
+ },
183
+ "16": {
184
+ start: {
185
+ line: 95,
186
+ column: 36
187
+ },
188
+ end: {
189
+ line: 95,
190
+ column: 67
191
+ }
192
+ },
193
+ "17": {
194
+ start: {
195
+ line: 97,
196
+ column: 6
197
+ },
198
+ end: {
199
+ line: 97,
200
+ column: 55
201
+ }
202
+ },
203
+ "18": {
204
+ start: {
205
+ line: 98,
206
+ column: 30
207
+ },
208
+ end: {
209
+ line: 98,
210
+ column: 64
211
+ }
212
+ },
213
+ "19": {
214
+ start: {
215
+ line: 100,
216
+ column: 4
217
+ },
218
+ end: {
219
+ line: 100,
220
+ column: 58
221
+ }
222
+ },
223
+ "20": {
224
+ start: {
225
+ line: 114,
226
+ column: 21
227
+ },
228
+ end: {
229
+ line: 114,
230
+ column: 61
231
+ }
232
+ },
233
+ "21": {
234
+ start: {
235
+ line: 116,
236
+ column: 4
237
+ },
238
+ end: {
239
+ line: 118,
240
+ column: 5
241
+ }
242
+ },
243
+ "22": {
244
+ start: {
245
+ line: 117,
246
+ column: 6
247
+ },
248
+ end: {
249
+ line: 117,
250
+ column: 66
251
+ }
252
+ },
253
+ "23": {
254
+ start: {
255
+ line: 120,
256
+ column: 4
257
+ },
258
+ end: {
259
+ line: 149,
260
+ column: 5
261
+ }
262
+ },
263
+ "24": {
264
+ start: {
265
+ line: 121,
266
+ column: 6
267
+ },
268
+ end: {
269
+ line: 148,
270
+ column: 11
271
+ }
272
+ },
273
+ "25": {
274
+ start: {
275
+ line: 129,
276
+ column: 10
277
+ },
278
+ end: {
279
+ line: 132,
280
+ column: 12
281
+ }
282
+ },
283
+ "26": {
284
+ start: {
285
+ line: 135,
286
+ column: 10
287
+ },
288
+ end: {
289
+ line: 135,
290
+ column: 55
291
+ }
292
+ },
293
+ "27": {
294
+ start: {
295
+ line: 136,
296
+ column: 10
297
+ },
298
+ end: {
299
+ line: 136,
300
+ column: 51
301
+ }
302
+ },
303
+ "28": {
304
+ start: {
305
+ line: 138,
306
+ column: 10
307
+ },
308
+ end: {
309
+ line: 138,
310
+ column: 29
311
+ }
312
+ },
313
+ "29": {
314
+ start: {
315
+ line: 141,
316
+ column: 10
317
+ },
318
+ end: {
319
+ line: 145,
320
+ column: 11
321
+ }
322
+ },
323
+ "30": {
324
+ start: {
325
+ line: 142,
326
+ column: 12
327
+ },
328
+ end: {
329
+ line: 144,
330
+ column: 14
331
+ }
332
+ },
333
+ "31": {
334
+ start: {
335
+ line: 147,
336
+ column: 10
337
+ },
338
+ end: {
339
+ line: 147,
340
+ column: 20
341
+ }
342
+ },
343
+ "32": {
344
+ start: {
345
+ line: 151,
346
+ column: 4
347
+ },
348
+ end: {
349
+ line: 151,
350
+ column: 45
351
+ }
352
+ },
353
+ "33": {
354
+ start: {
355
+ line: 165,
356
+ column: 4
357
+ },
358
+ end: {
359
+ line: 168,
360
+ column: 6
361
+ }
362
+ },
363
+ "34": {
364
+ start: {
365
+ line: 172,
366
+ column: 20
367
+ },
368
+ end: {
369
+ line: 172,
370
+ column: 33
371
+ }
372
+ }
373
+ },
374
+ fnMap: {
375
+ "0": {
376
+ name: "(anonymous_0)",
377
+ decl: {
378
+ start: {
379
+ line: 35,
380
+ column: 2
381
+ },
382
+ end: {
383
+ line: 35,
384
+ column: 3
385
+ }
386
+ },
387
+ loc: {
388
+ start: {
389
+ line: 35,
390
+ column: 19
391
+ },
392
+ end: {
393
+ line: 47,
394
+ column: 3
395
+ }
396
+ },
397
+ line: 35
398
+ },
399
+ "1": {
400
+ name: "(anonymous_1)",
401
+ decl: {
402
+ start: {
403
+ line: 56,
404
+ column: 2
405
+ },
406
+ end: {
407
+ line: 56,
408
+ column: 3
409
+ }
410
+ },
411
+ loc: {
412
+ start: {
413
+ line: 56,
414
+ column: 37
415
+ },
416
+ end: {
417
+ line: 62,
418
+ column: 3
419
+ }
420
+ },
421
+ line: 56
422
+ },
423
+ "2": {
424
+ name: "(anonymous_2)",
425
+ decl: {
426
+ start: {
427
+ line: 59,
428
+ column: 24
429
+ },
430
+ end: {
431
+ line: 59,
432
+ column: 25
433
+ }
434
+ },
435
+ loc: {
436
+ start: {
437
+ line: 59,
438
+ column: 30
439
+ },
440
+ end: {
441
+ line: 61,
442
+ column: 5
443
+ }
444
+ },
445
+ line: 59
446
+ },
447
+ "3": {
448
+ name: "(anonymous_3)",
449
+ decl: {
450
+ start: {
451
+ line: 73,
452
+ column: 2
453
+ },
454
+ end: {
455
+ line: 73,
456
+ column: 3
457
+ }
458
+ },
459
+ loc: {
460
+ start: {
461
+ line: 73,
462
+ column: 35
463
+ },
464
+ end: {
465
+ line: 81,
466
+ column: 3
467
+ }
468
+ },
469
+ line: 73
470
+ },
471
+ "4": {
472
+ name: "(anonymous_4)",
473
+ decl: {
474
+ start: {
475
+ line: 79,
476
+ column: 6
477
+ },
478
+ end: {
479
+ line: 79,
480
+ column: 7
481
+ }
482
+ },
483
+ loc: {
484
+ start: {
485
+ line: 79,
486
+ column: 23
487
+ },
488
+ end: {
489
+ line: 79,
490
+ column: 43
491
+ }
492
+ },
493
+ line: 79
494
+ },
495
+ "5": {
496
+ name: "(anonymous_5)",
497
+ decl: {
498
+ start: {
499
+ line: 90,
500
+ column: 2
501
+ },
502
+ end: {
503
+ line: 90,
504
+ column: 3
505
+ }
506
+ },
507
+ loc: {
508
+ start: {
509
+ line: 90,
510
+ column: 32
511
+ },
512
+ end: {
513
+ line: 101,
514
+ column: 3
515
+ }
516
+ },
517
+ line: 90
518
+ },
519
+ "6": {
520
+ name: "(anonymous_6)",
521
+ decl: {
522
+ start: {
523
+ line: 113,
524
+ column: 2
525
+ },
526
+ end: {
527
+ line: 113,
528
+ column: 3
529
+ }
530
+ },
531
+ loc: {
532
+ start: {
533
+ line: 113,
534
+ column: 35
535
+ },
536
+ end: {
537
+ line: 152,
538
+ column: 3
539
+ }
540
+ },
541
+ line: 113
542
+ },
543
+ "7": {
544
+ name: "(anonymous_7)",
545
+ decl: {
546
+ start: {
547
+ line: 128,
548
+ column: 14
549
+ },
550
+ end: {
551
+ line: 128,
552
+ column: 15
553
+ }
554
+ },
555
+ loc: {
556
+ start: {
557
+ line: 128,
558
+ column: 28
559
+ },
560
+ end: {
561
+ line: 133,
562
+ column: 9
563
+ }
564
+ },
565
+ line: 128
566
+ },
567
+ "8": {
568
+ name: "(anonymous_8)",
569
+ decl: {
570
+ start: {
571
+ line: 134,
572
+ column: 14
573
+ },
574
+ end: {
575
+ line: 134,
576
+ column: 15
577
+ }
578
+ },
579
+ loc: {
580
+ start: {
581
+ line: 134,
582
+ column: 31
583
+ },
584
+ end: {
585
+ line: 139,
586
+ column: 9
587
+ }
588
+ },
589
+ line: 134
590
+ },
591
+ "9": {
592
+ name: "(anonymous_9)",
593
+ decl: {
594
+ start: {
595
+ line: 140,
596
+ column: 15
597
+ },
598
+ end: {
599
+ line: 140,
600
+ column: 16
601
+ }
602
+ },
603
+ loc: {
604
+ start: {
605
+ line: 140,
606
+ column: 24
607
+ },
608
+ end: {
609
+ line: 148,
610
+ column: 9
611
+ }
612
+ },
613
+ line: 140
614
+ },
615
+ "10": {
616
+ name: "(anonymous_10)",
617
+ decl: {
618
+ start: {
619
+ line: 164,
620
+ column: 2
621
+ },
622
+ end: {
623
+ line: 164,
624
+ column: 3
625
+ }
626
+ },
627
+ loc: {
628
+ start: {
629
+ line: 164,
630
+ column: 42
631
+ },
632
+ end: {
633
+ line: 169,
634
+ column: 3
635
+ }
636
+ },
637
+ line: 164
638
+ }
639
+ },
640
+ branchMap: {
641
+ "0": {
642
+ loc: {
643
+ start: {
644
+ line: 40,
645
+ column: 4
646
+ },
647
+ end: {
648
+ line: 42,
649
+ column: 5
650
+ }
651
+ },
652
+ type: "if",
653
+ locations: [{
654
+ start: {
655
+ line: 40,
656
+ column: 4
657
+ },
658
+ end: {
659
+ line: 42,
660
+ column: 5
661
+ }
662
+ }, {
663
+ start: {
664
+ line: undefined,
665
+ column: undefined
666
+ },
667
+ end: {
668
+ line: undefined,
669
+ column: undefined
670
+ }
671
+ }],
672
+ line: 40
673
+ },
674
+ "1": {
675
+ loc: {
676
+ start: {
677
+ line: 44,
678
+ column: 4
679
+ },
680
+ end: {
681
+ line: 46,
682
+ column: 5
683
+ }
684
+ },
685
+ type: "if",
686
+ locations: [{
687
+ start: {
688
+ line: 44,
689
+ column: 4
690
+ },
691
+ end: {
692
+ line: 46,
693
+ column: 5
694
+ }
695
+ }, {
696
+ start: {
697
+ line: undefined,
698
+ column: undefined
699
+ },
700
+ end: {
701
+ line: undefined,
702
+ column: undefined
703
+ }
704
+ }],
705
+ line: 44
706
+ },
707
+ "2": {
708
+ loc: {
709
+ start: {
710
+ line: 57,
711
+ column: 20
712
+ },
713
+ end: {
714
+ line: 57,
715
+ column: 74
716
+ }
717
+ },
718
+ type: "binary-expr",
719
+ locations: [{
720
+ start: {
721
+ line: 57,
722
+ column: 20
723
+ },
724
+ end: {
725
+ line: 57,
726
+ column: 53
727
+ }
728
+ }, {
729
+ start: {
730
+ line: 57,
731
+ column: 57
732
+ },
733
+ end: {
734
+ line: 57,
735
+ column: 74
736
+ }
737
+ }],
738
+ line: 57
739
+ },
740
+ "3": {
741
+ loc: {
742
+ start: {
743
+ line: 74,
744
+ column: 4
745
+ },
746
+ end: {
747
+ line: 76,
748
+ column: 5
749
+ }
750
+ },
751
+ type: "if",
752
+ locations: [{
753
+ start: {
754
+ line: 74,
755
+ column: 4
756
+ },
757
+ end: {
758
+ line: 76,
759
+ column: 5
760
+ }
761
+ }, {
762
+ start: {
763
+ line: undefined,
764
+ column: undefined
765
+ },
766
+ end: {
767
+ line: undefined,
768
+ column: undefined
769
+ }
770
+ }],
771
+ line: 74
772
+ },
773
+ "4": {
774
+ loc: {
775
+ start: {
776
+ line: 91,
777
+ column: 4
778
+ },
779
+ end: {
780
+ line: 93,
781
+ column: 5
782
+ }
783
+ },
784
+ type: "if",
785
+ locations: [{
786
+ start: {
787
+ line: 91,
788
+ column: 4
789
+ },
790
+ end: {
791
+ line: 93,
792
+ column: 5
793
+ }
794
+ }, {
795
+ start: {
796
+ line: undefined,
797
+ column: undefined
798
+ },
799
+ end: {
800
+ line: undefined,
801
+ column: undefined
802
+ }
803
+ }],
804
+ line: 91
805
+ },
806
+ "5": {
807
+ loc: {
808
+ start: {
809
+ line: 91,
810
+ column: 10
811
+ },
812
+ end: {
813
+ line: 91,
814
+ column: 62
815
+ }
816
+ },
817
+ type: "binary-expr",
818
+ locations: [{
819
+ start: {
820
+ line: 91,
821
+ column: 10
822
+ },
823
+ end: {
824
+ line: 91,
825
+ column: 27
826
+ }
827
+ }, {
828
+ start: {
829
+ line: 91,
830
+ column: 31
831
+ },
832
+ end: {
833
+ line: 91,
834
+ column: 62
835
+ }
836
+ }],
837
+ line: 91
838
+ },
839
+ "6": {
840
+ loc: {
841
+ start: {
842
+ line: 97,
843
+ column: 6
844
+ },
845
+ end: {
846
+ line: 97,
847
+ column: 55
848
+ }
849
+ },
850
+ type: "binary-expr",
851
+ locations: [{
852
+ start: {
853
+ line: 97,
854
+ column: 6
855
+ },
856
+ end: {
857
+ line: 97,
858
+ column: 50
859
+ }
860
+ }, {
861
+ start: {
862
+ line: 97,
863
+ column: 54
864
+ },
865
+ end: {
866
+ line: 97,
867
+ column: 55
868
+ }
869
+ }],
870
+ line: 97
871
+ },
872
+ "7": {
873
+ loc: {
874
+ start: {
875
+ line: 100,
876
+ column: 14
877
+ },
878
+ end: {
879
+ line: 100,
880
+ column: 56
881
+ }
882
+ },
883
+ type: "binary-expr",
884
+ locations: [{
885
+ start: {
886
+ line: 100,
887
+ column: 14
888
+ },
889
+ end: {
890
+ line: 100,
891
+ column: 22
892
+ }
893
+ }, {
894
+ start: {
895
+ line: 100,
896
+ column: 26
897
+ },
898
+ end: {
899
+ line: 100,
900
+ column: 56
901
+ }
902
+ }],
903
+ line: 100
904
+ },
905
+ "8": {
906
+ loc: {
907
+ start: {
908
+ line: 116,
909
+ column: 4
910
+ },
911
+ end: {
912
+ line: 118,
913
+ column: 5
914
+ }
915
+ },
916
+ type: "if",
917
+ locations: [{
918
+ start: {
919
+ line: 116,
920
+ column: 4
921
+ },
922
+ end: {
923
+ line: 118,
924
+ column: 5
925
+ }
926
+ }, {
927
+ start: {
928
+ line: undefined,
929
+ column: undefined
930
+ },
931
+ end: {
932
+ line: undefined,
933
+ column: undefined
934
+ }
935
+ }],
936
+ line: 116
937
+ },
938
+ "9": {
939
+ loc: {
940
+ start: {
941
+ line: 116,
942
+ column: 10
943
+ },
944
+ end: {
945
+ line: 116,
946
+ column: 39
947
+ }
948
+ },
949
+ type: "binary-expr",
950
+ locations: [{
951
+ start: {
952
+ line: 116,
953
+ column: 10
954
+ },
955
+ end: {
956
+ line: 116,
957
+ column: 18
958
+ }
959
+ }, {
960
+ start: {
961
+ line: 116,
962
+ column: 22
963
+ },
964
+ end: {
965
+ line: 116,
966
+ column: 39
967
+ }
968
+ }],
969
+ line: 116
970
+ },
971
+ "10": {
972
+ loc: {
973
+ start: {
974
+ line: 120,
975
+ column: 4
976
+ },
977
+ end: {
978
+ line: 149,
979
+ column: 5
980
+ }
981
+ },
982
+ type: "if",
983
+ locations: [{
984
+ start: {
985
+ line: 120,
986
+ column: 4
987
+ },
988
+ end: {
989
+ line: 149,
990
+ column: 5
991
+ }
992
+ }, {
993
+ start: {
994
+ line: undefined,
995
+ column: undefined
996
+ },
997
+ end: {
998
+ line: undefined,
999
+ column: undefined
1000
+ }
1001
+ }],
1002
+ line: 120
1003
+ },
1004
+ "11": {
1005
+ loc: {
1006
+ start: {
1007
+ line: 141,
1008
+ column: 10
1009
+ },
1010
+ end: {
1011
+ line: 145,
1012
+ column: 11
1013
+ }
1014
+ },
1015
+ type: "if",
1016
+ locations: [{
1017
+ start: {
1018
+ line: 141,
1019
+ column: 10
1020
+ },
1021
+ end: {
1022
+ line: 145,
1023
+ column: 11
1024
+ }
1025
+ }, {
1026
+ start: {
1027
+ line: undefined,
1028
+ column: undefined
1029
+ },
1030
+ end: {
1031
+ line: undefined,
1032
+ column: undefined
1033
+ }
1034
+ }],
1035
+ line: 141
1036
+ },
1037
+ "12": {
1038
+ loc: {
1039
+ start: {
1040
+ line: 141,
1041
+ column: 16
1042
+ },
1043
+ end: {
1044
+ line: 141,
1045
+ column: 51
1046
+ }
1047
+ },
1048
+ type: "binary-expr",
1049
+ locations: [{
1050
+ start: {
1051
+ line: 141,
1052
+ column: 16
1053
+ },
1054
+ end: {
1055
+ line: 141,
1056
+ column: 28
1057
+ }
1058
+ }, {
1059
+ start: {
1060
+ line: 141,
1061
+ column: 32
1062
+ },
1063
+ end: {
1064
+ line: 141,
1065
+ column: 51
1066
+ }
1067
+ }],
1068
+ line: 141
1069
+ }
1070
+ },
1071
+ s: {
1072
+ "0": 0,
1073
+ "1": 0,
1074
+ "2": 0,
1075
+ "3": 0,
1076
+ "4": 0,
1077
+ "5": 0,
1078
+ "6": 0,
1079
+ "7": 0,
1080
+ "8": 0,
1081
+ "9": 0,
1082
+ "10": 0,
1083
+ "11": 0,
1084
+ "12": 0,
1085
+ "13": 0,
1086
+ "14": 0,
1087
+ "15": 0,
1088
+ "16": 0,
1089
+ "17": 0,
1090
+ "18": 0,
1091
+ "19": 0,
1092
+ "20": 0,
1093
+ "21": 0,
1094
+ "22": 0,
1095
+ "23": 0,
1096
+ "24": 0,
1097
+ "25": 0,
1098
+ "26": 0,
1099
+ "27": 0,
1100
+ "28": 0,
1101
+ "29": 0,
1102
+ "30": 0,
1103
+ "31": 0,
1104
+ "32": 0,
1105
+ "33": 0,
1106
+ "34": 0
1107
+ },
1108
+ f: {
1109
+ "0": 0,
1110
+ "1": 0,
1111
+ "2": 0,
1112
+ "3": 0,
1113
+ "4": 0,
1114
+ "5": 0,
1115
+ "6": 0,
1116
+ "7": 0,
1117
+ "8": 0,
1118
+ "9": 0,
1119
+ "10": 0
1120
+ },
1121
+ b: {
1122
+ "0": [0, 0],
1123
+ "1": [0, 0],
1124
+ "2": [0, 0],
1125
+ "3": [0, 0],
1126
+ "4": [0, 0],
1127
+ "5": [0, 0],
1128
+ "6": [0, 0],
1129
+ "7": [0, 0],
1130
+ "8": [0, 0],
1131
+ "9": [0, 0],
1132
+ "10": [0, 0],
1133
+ "11": [0, 0],
1134
+ "12": [0, 0]
1135
+ },
1136
+ _coverageSchema: "1a1c01bbd47fc00a2c39e90264f33305004495a9",
1137
+ hash: "5f9f61811e14fa3deec2529b55782b794416b677"
1138
+ };
1139
+ var coverage = global[gcv] || (global[gcv] = {});
1140
+ if (!coverage[path] || coverage[path].hash !== hash) {
1141
+ coverage[path] = coverageData;
1142
+ }
1143
+ var actualCoverage = coverage[path];
1144
+ {
1145
+ // @ts-ignore
1146
+ cov_1wzdsw0kpo = function () {
1147
+ return actualCoverage;
1148
+ };
1149
+ }
1150
+ return actualCoverage;
1151
+ }
1152
+ cov_1wzdsw0kpo();
1153
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
1154
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
1155
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
1156
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
1157
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
22
1158
  /**
23
1159
  * @typedef {Object} MachineAuthSessionInfo
24
1160
  * @property {string} apiToken
@@ -47,23 +1183,33 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
47
1183
  * sessionType: 'machineAuth'
48
1184
  * });
49
1185
  */
50
- var MachineAuth = function () {
1186
+ class MachineAuth {
51
1187
  /**
52
1188
  * @param {Object} sdk An instance of the SDK so the module can communicate with other modules
53
1189
  */
54
- function MachineAuth(sdk) {
55
- _classCallCheck(this, MachineAuth);
56
-
1190
+ constructor(sdk) {
1191
+ cov_1wzdsw0kpo().f[0]++;
1192
+ cov_1wzdsw0kpo().s[0]++;
57
1193
  this._sdk = sdk;
1194
+ cov_1wzdsw0kpo().s[1]++;
58
1195
  this._sessionInfo = {};
1196
+ cov_1wzdsw0kpo().s[2]++;
59
1197
  this._tokenPromises = {};
60
-
1198
+ cov_1wzdsw0kpo().s[3]++;
61
1199
  if (!this._sdk.config.auth.clientId) {
1200
+ cov_1wzdsw0kpo().b[0][0]++;
1201
+ cov_1wzdsw0kpo().s[4]++;
62
1202
  throw new Error('clientId is required for the MachineAuth config');
1203
+ } else {
1204
+ cov_1wzdsw0kpo().b[0][1]++;
63
1205
  }
64
-
1206
+ cov_1wzdsw0kpo().s[5]++;
65
1207
  if (!this._sdk.config.auth.clientSecret) {
1208
+ cov_1wzdsw0kpo().b[1][0]++;
1209
+ cov_1wzdsw0kpo().s[6]++;
66
1210
  throw new Error('clientSecret is required for the MachineAuth config');
1211
+ } else {
1212
+ cov_1wzdsw0kpo().b[1][1]++;
67
1213
  }
68
1214
  }
69
1215
 
@@ -74,140 +1220,154 @@ var MachineAuth = function () {
74
1220
  *
75
1221
  * @returns {Promise}
76
1222
  */
1223
+ clearCurrentApiToken(audienceName) {
1224
+ cov_1wzdsw0kpo().f[1]++;
1225
+ const promise = (cov_1wzdsw0kpo().s[7]++, (cov_1wzdsw0kpo().b[2][0]++, this._tokenPromises[audienceName]) || (cov_1wzdsw0kpo().b[2][1]++, Promise.resolve()));
1226
+ cov_1wzdsw0kpo().s[8]++;
1227
+ return promise.then(() => {
1228
+ cov_1wzdsw0kpo().f[2]++;
1229
+ cov_1wzdsw0kpo().s[9]++;
1230
+ delete this._sessionInfo[audienceName];
1231
+ });
1232
+ }
77
1233
 
78
-
79
- _createClass(MachineAuth, [{
80
- key: 'clearCurrentApiToken',
81
- value: function clearCurrentApiToken(audienceName) {
82
- var _this = this;
83
-
84
- var promise = this._tokenPromises[audienceName] || Promise.resolve();
85
-
86
- return promise.then(function () {
87
- delete _this._sessionInfo[audienceName];
88
- });
89
- }
90
-
91
- /**
92
- * Gets the current API token (used to communicate with other Contxt APIs). Will get and store a
93
- * token or use a previously acquired and stored token.
94
- *
95
- * @param {string} audienceName The audience you wish to get an API for
96
- *
97
- * @returns {Promise}
98
- * @fulfills {string} apiToken
99
- */
100
-
101
- }, {
102
- key: 'getCurrentApiToken',
103
- value: function getCurrentApiToken(audienceName) {
104
- if (this.isAuthenticated(audienceName)) {
105
- return Promise.resolve(this._sessionInfo[audienceName].apiToken);
106
- }
107
-
108
- return this._getNewSessionInfo(audienceName).then(function (sessionInfo) {
109
- return sessionInfo.apiToken;
110
- });
1234
+ /**
1235
+ * Gets the current API token (used to communicate with other Contxt APIs). Will get and store a
1236
+ * token or use a previously acquired and stored token.
1237
+ *
1238
+ * @param {string} audienceName The audience you wish to get an API for
1239
+ *
1240
+ * @returns {Promise}
1241
+ * @fulfills {string} apiToken
1242
+ */
1243
+ getCurrentApiToken(audienceName) {
1244
+ cov_1wzdsw0kpo().f[3]++;
1245
+ cov_1wzdsw0kpo().s[10]++;
1246
+ if (this.isAuthenticated(audienceName)) {
1247
+ cov_1wzdsw0kpo().b[3][0]++;
1248
+ cov_1wzdsw0kpo().s[11]++;
1249
+ return Promise.resolve(this._sessionInfo[audienceName].apiToken);
1250
+ } else {
1251
+ cov_1wzdsw0kpo().b[3][1]++;
111
1252
  }
1253
+ cov_1wzdsw0kpo().s[12]++;
1254
+ return this._getNewSessionInfo(audienceName).then(sessionInfo => {
1255
+ cov_1wzdsw0kpo().f[4]++;
1256
+ cov_1wzdsw0kpo().s[13]++;
1257
+ return sessionInfo.apiToken;
1258
+ });
1259
+ }
112
1260
 
113
- /**
114
- * Tells caller if the app is authenticated with a particular service.
115
- *
116
- * @param audienceName
117
- *
118
- * @returns {boolean}
119
- */
120
-
121
- }, {
122
- key: 'isAuthenticated',
123
- value: function isAuthenticated(audienceName) {
124
- if (!(this._sessionInfo && this._sessionInfo[audienceName])) {
125
- return false;
126
- }
127
-
128
- var _sessionInfo$audience = this._sessionInfo[audienceName],
129
- apiToken = _sessionInfo$audience.apiToken,
130
- expiresAt = _sessionInfo$audience.expiresAt;
131
-
132
- var tokenExpiresAtBufferMs = this._sdk.config.auth.tokenExpiresAtBufferMs || 0;
133
- var bufferedExpiresAt = expiresAt - tokenExpiresAtBufferMs;
134
-
135
- return !!(apiToken && bufferedExpiresAt > Date.now());
1261
+ /**
1262
+ * Tells caller if the app is authenticated with a particular service.
1263
+ *
1264
+ * @param audienceName
1265
+ *
1266
+ * @returns {boolean}
1267
+ */
1268
+ isAuthenticated(audienceName) {
1269
+ cov_1wzdsw0kpo().f[5]++;
1270
+ cov_1wzdsw0kpo().s[14]++;
1271
+ if (!((cov_1wzdsw0kpo().b[5][0]++, this._sessionInfo) && (cov_1wzdsw0kpo().b[5][1]++, this._sessionInfo[audienceName]))) {
1272
+ cov_1wzdsw0kpo().b[4][0]++;
1273
+ cov_1wzdsw0kpo().s[15]++;
1274
+ return false;
1275
+ } else {
1276
+ cov_1wzdsw0kpo().b[4][1]++;
136
1277
  }
1278
+ const _ref = (cov_1wzdsw0kpo().s[16]++, this._sessionInfo[audienceName]),
1279
+ apiToken = _ref.apiToken,
1280
+ expiresAt = _ref.expiresAt;
1281
+ const tokenExpiresAtBufferMs = (cov_1wzdsw0kpo().s[17]++, (cov_1wzdsw0kpo().b[6][0]++, this._sdk.config.auth.tokenExpiresAtBufferMs) || (cov_1wzdsw0kpo().b[6][1]++, 0));
1282
+ const bufferedExpiresAt = (cov_1wzdsw0kpo().s[18]++, expiresAt - tokenExpiresAtBufferMs);
1283
+ cov_1wzdsw0kpo().s[19]++;
1284
+ return !!((cov_1wzdsw0kpo().b[7][0]++, apiToken) && (cov_1wzdsw0kpo().b[7][1]++, bufferedExpiresAt > Date.now()));
1285
+ }
137
1286
 
138
- /**
139
- * Requests an access token from Contxt Auth for the correct audience
140
- *
141
- * @param audienceName
142
- *
143
- * @returns {Promise}
144
- * @fulfill {MachineAuthSessionInfo}
145
- *
146
- * @private
147
- */
148
-
149
- }, {
150
- key: '_getNewSessionInfo',
151
- value: function _getNewSessionInfo(audienceName) {
152
- var _this2 = this;
153
-
154
- var audience = this._sdk.config.audiences[audienceName];
155
-
156
- if (!(audience && audience.clientId)) {
157
- return Promise.reject(new Error('No valid audience found'));
158
- }
159
-
160
- if (!this._tokenPromises[audienceName]) {
161
- this._tokenPromises[audienceName] = _axios2.default.post(this._sdk.config.audiences.contxtAuth.host + '/v1/oauth/token', {
162
- audience: audience.clientId,
163
- client_id: this._sdk.config.auth.clientId,
164
- client_secret: this._sdk.config.auth.clientSecret,
165
- grant_type: 'client_credentials'
166
- }).then(function (_ref) {
167
- var data = _ref.data;
168
-
169
- return {
170
- apiToken: data.access_token,
171
- expiresAt: Date.now() + data.expires_in * 1000
172
- };
173
- }).then(function (sessionInfo) {
174
- _this2._saveSession(audienceName, sessionInfo);
175
- _this2._tokenPromises[audienceName] = null;
176
-
177
- return sessionInfo;
178
- }).catch(function (err) {
179
- if (!(err.response && err.response.status)) {
180
- throw new Error('There was a problem getting a token from the ContxtAuth server. Please check your configuration settings.');
181
- }
182
-
183
- throw err;
184
- });
185
- }
186
-
187
- return this._tokenPromises[audienceName];
1287
+ /**
1288
+ * Requests an access token from Contxt Auth for the correct audience
1289
+ *
1290
+ * @param audienceName
1291
+ *
1292
+ * @returns {Promise}
1293
+ * @fulfill {MachineAuthSessionInfo}
1294
+ *
1295
+ * @private
1296
+ */
1297
+ _getNewSessionInfo(audienceName) {
1298
+ cov_1wzdsw0kpo().f[6]++;
1299
+ const audience = (cov_1wzdsw0kpo().s[20]++, this._sdk.config.audiences[audienceName]);
1300
+ cov_1wzdsw0kpo().s[21]++;
1301
+ if (!((cov_1wzdsw0kpo().b[9][0]++, audience) && (cov_1wzdsw0kpo().b[9][1]++, audience.clientId))) {
1302
+ cov_1wzdsw0kpo().b[8][0]++;
1303
+ cov_1wzdsw0kpo().s[22]++;
1304
+ return Promise.reject(new Error('No valid audience found'));
1305
+ } else {
1306
+ cov_1wzdsw0kpo().b[8][1]++;
188
1307
  }
189
-
190
- /**
191
- * Saves a session in the auth instance for future use
192
- *
193
- * @param {string} audienceName
194
- * @param {Object} sessionInfo
195
- * @param {string} sessionInfo.apiToken
196
- * @param {number} sessionInfo.expiresAt
197
- *
198
- * @private
199
- */
200
-
201
- }, {
202
- key: '_saveSession',
203
- value: function _saveSession(audienceName, sessionInfo) {
204
- this._sessionInfo = _extends({}, this._sessionInfo, _defineProperty({}, audienceName, sessionInfo));
1308
+ cov_1wzdsw0kpo().s[23]++;
1309
+ if (!this._tokenPromises[audienceName]) {
1310
+ cov_1wzdsw0kpo().b[10][0]++;
1311
+ cov_1wzdsw0kpo().s[24]++;
1312
+ this._tokenPromises[audienceName] = _axios.default.post(`${this._sdk.config.audiences.contxtAuth.host}/v1/oauth/token`, {
1313
+ audience: audience.clientId,
1314
+ client_id: this._sdk.config.auth.clientId,
1315
+ client_secret: this._sdk.config.auth.clientSecret,
1316
+ grant_type: 'client_credentials'
1317
+ }).then(_ref2 => {
1318
+ let data = _ref2.data;
1319
+ cov_1wzdsw0kpo().f[7]++;
1320
+ cov_1wzdsw0kpo().s[25]++;
1321
+ return {
1322
+ apiToken: data.access_token,
1323
+ expiresAt: Date.now() + data.expires_in * 1000
1324
+ };
1325
+ }).then(sessionInfo => {
1326
+ cov_1wzdsw0kpo().f[8]++;
1327
+ cov_1wzdsw0kpo().s[26]++;
1328
+ this._saveSession(audienceName, sessionInfo);
1329
+ cov_1wzdsw0kpo().s[27]++;
1330
+ this._tokenPromises[audienceName] = null;
1331
+ cov_1wzdsw0kpo().s[28]++;
1332
+ return sessionInfo;
1333
+ }).catch(err => {
1334
+ cov_1wzdsw0kpo().f[9]++;
1335
+ cov_1wzdsw0kpo().s[29]++;
1336
+ if (!((cov_1wzdsw0kpo().b[12][0]++, err.response) && (cov_1wzdsw0kpo().b[12][1]++, err.response.status))) {
1337
+ cov_1wzdsw0kpo().b[11][0]++;
1338
+ cov_1wzdsw0kpo().s[30]++;
1339
+ throw new Error('There was a problem getting a token from the ContxtAuth server. Please check your configuration settings.');
1340
+ } else {
1341
+ cov_1wzdsw0kpo().b[11][1]++;
1342
+ }
1343
+ cov_1wzdsw0kpo().s[31]++;
1344
+ throw err;
1345
+ });
1346
+ } else {
1347
+ cov_1wzdsw0kpo().b[10][1]++;
205
1348
  }
206
- }]);
207
-
208
- return MachineAuth;
209
- }();
1349
+ cov_1wzdsw0kpo().s[32]++;
1350
+ return this._tokenPromises[audienceName];
1351
+ }
210
1352
 
211
- var TYPE = exports.TYPE = 'machineAuth';
212
- exports.default = MachineAuth;
1353
+ /**
1354
+ * Saves a session in the auth instance for future use
1355
+ *
1356
+ * @param {string} audienceName
1357
+ * @param {Object} sessionInfo
1358
+ * @param {string} sessionInfo.apiToken
1359
+ * @param {number} sessionInfo.expiresAt
1360
+ *
1361
+ * @private
1362
+ */
1363
+ _saveSession(audienceName, sessionInfo) {
1364
+ cov_1wzdsw0kpo().f[10]++;
1365
+ cov_1wzdsw0kpo().s[33]++;
1366
+ this._sessionInfo = _objectSpread(_objectSpread({}, this._sessionInfo), {}, {
1367
+ [audienceName]: sessionInfo
1368
+ });
1369
+ }
1370
+ }
1371
+ const TYPE = exports.TYPE = (cov_1wzdsw0kpo().s[34]++, 'machineAuth');
1372
+ var _default = exports.default = MachineAuth;
213
1373
  //# sourceMappingURL=machineAuth.js.map