1 | 'use strict';
|
2 |
|
3 | var cov_2oxemx8fnf = function () {
|
4 | var path = '/Users/mxu/code/uport-connect/src/util.js',
|
5 | hash = '793506c2ca48ba4665a20e33a1e8ed19d4cbc232',
|
6 | Function = function () {}.constructor,
|
7 | global = new Function('return this')(),
|
8 | gcv = '__coverage__',
|
9 | coverageData = {
|
10 | path: '/Users/mxu/code/uport-connect/src/util.js',
|
11 | statementMap: {
|
12 | '0': {
|
13 | start: {
|
14 | line: 9,
|
15 | column: 24
|
16 | },
|
17 | end: {
|
18 | line: 13,
|
19 | column: 1
|
20 | }
|
21 | },
|
22 | '1': {
|
23 | start: {
|
24 | line: 10,
|
25 | column: 2
|
26 | },
|
27 | end: {
|
28 | line: 12,
|
29 | column: 21
|
30 | }
|
31 | },
|
32 | '2': {
|
33 | start: {
|
34 | line: 11,
|
35 | column: 4
|
36 | },
|
37 | end: {
|
38 | line: 11,
|
39 | column: 61
|
40 | }
|
41 | },
|
42 | '3': {
|
43 | start: {
|
44 | line: 12,
|
45 | column: 9
|
46 | },
|
47 | end: {
|
48 | line: 12,
|
49 | column: 21
|
50 | }
|
51 | },
|
52 | '4': {
|
53 | start: {
|
54 | line: 20,
|
55 | column: 2
|
56 | },
|
57 | end: {
|
58 | line: 20,
|
59 | column: 38
|
60 | }
|
61 | },
|
62 | '5': {
|
63 | start: {
|
64 | line: 28,
|
65 | column: 2
|
66 | },
|
67 | end: {
|
68 | line: 44,
|
69 | column: 4
|
70 | }
|
71 | },
|
72 | '6': {
|
73 | start: {
|
74 | line: 30,
|
75 | column: 20
|
76 | },
|
77 | end: {
|
78 | line: 30,
|
79 | column: 34
|
80 | }
|
81 | },
|
82 | '7': {
|
83 | start: {
|
84 | line: 31,
|
85 | column: 4
|
86 | },
|
87 | end: {
|
88 | line: 31,
|
89 | column: 43
|
90 | }
|
91 | },
|
92 | '8': {
|
93 | start: {
|
94 | line: 32,
|
95 | column: 16
|
96 | },
|
97 | end: {
|
98 | line: 32,
|
99 | column: 36
|
100 | }
|
101 | },
|
102 | '9': {
|
103 | start: {
|
104 | line: 34,
|
105 | column: 4
|
106 | },
|
107 | end: {
|
108 | line: 38,
|
109 | column: 5
|
110 | }
|
111 | },
|
112 | '10': {
|
113 | start: {
|
114 | line: 35,
|
115 | column: 6
|
116 | },
|
117 | end: {
|
118 | line: 35,
|
119 | column: 38
|
120 | }
|
121 | },
|
122 | '11': {
|
123 | start: {
|
124 | line: 35,
|
125 | column: 32
|
126 | },
|
127 | end: {
|
128 | line: 35,
|
129 | column: 38
|
130 | }
|
131 | },
|
132 | '12': {
|
133 | start: {
|
134 | line: 36,
|
135 | column: 6
|
136 | },
|
137 | end: {
|
138 | line: 37,
|
139 | column: 53
|
140 | }
|
141 | },
|
142 | '13': {
|
143 | start: {
|
144 | line: 36,
|
145 | column: 29
|
146 | },
|
147 | end: {
|
148 | line: 36,
|
149 | column: 79
|
150 | }
|
151 | },
|
152 | '14': {
|
153 | start: {
|
154 | line: 37,
|
155 | column: 11
|
156 | },
|
157 | end: {
|
158 | line: 37,
|
159 | column: 53
|
160 | }
|
161 | },
|
162 | '15': {
|
163 | start: {
|
164 | line: 40,
|
165 | column: 4
|
166 | },
|
167 | end: {
|
168 | line: 40,
|
169 | column: 62
|
170 | }
|
171 | },
|
172 | '16': {
|
173 | start: {
|
174 | line: 41,
|
175 | column: 4
|
176 | },
|
177 | end: {
|
178 | line: 41,
|
179 | column: 53
|
180 | }
|
181 | },
|
182 | '17': {
|
183 | start: {
|
184 | line: 42,
|
185 | column: 4
|
186 | },
|
187 | end: {
|
188 | line: 42,
|
189 | column: 39
|
190 | }
|
191 | },
|
192 | '18': {
|
193 | start: {
|
194 | line: 43,
|
195 | column: 4
|
196 | },
|
197 | end: {
|
198 | line: 43,
|
199 | column: 21
|
200 | }
|
201 | }
|
202 | },
|
203 | fnMap: {
|
204 | '0': {
|
205 | name: '(anonymous_0)',
|
206 | decl: {
|
207 | start: {
|
208 | line: 9,
|
209 | column: 24
|
210 | },
|
211 | end: {
|
212 | line: 9,
|
213 | column: 25
|
214 | }
|
215 | },
|
216 | loc: {
|
217 | start: {
|
218 | line: 9,
|
219 | column: 30
|
220 | },
|
221 | end: {
|
222 | line: 13,
|
223 | column: 1
|
224 | }
|
225 | },
|
226 | line: 9
|
227 | },
|
228 | '1': {
|
229 | name: 'hasWeb3',
|
230 | decl: {
|
231 | start: {
|
232 | line: 19,
|
233 | column: 16
|
234 | },
|
235 | end: {
|
236 | line: 19,
|
237 | column: 23
|
238 | }
|
239 | },
|
240 | loc: {
|
241 | start: {
|
242 | line: 19,
|
243 | column: 26
|
244 | },
|
245 | end: {
|
246 | line: 21,
|
247 | column: 1
|
248 | }
|
249 | },
|
250 | line: 19
|
251 | },
|
252 | '2': {
|
253 | name: 'ipfsAdd',
|
254 | decl: {
|
255 | start: {
|
256 | line: 27,
|
257 | column: 16
|
258 | },
|
259 | end: {
|
260 | line: 27,
|
261 | column: 23
|
262 | }
|
263 | },
|
264 | loc: {
|
265 | start: {
|
266 | line: 27,
|
267 | column: 29
|
268 | },
|
269 | end: {
|
270 | line: 45,
|
271 | column: 1
|
272 | }
|
273 | },
|
274 | line: 27
|
275 | },
|
276 | '3': {
|
277 | name: '(anonymous_3)',
|
278 | decl: {
|
279 | start: {
|
280 | line: 28,
|
281 | column: 21
|
282 | },
|
283 | end: {
|
284 | line: 28,
|
285 | column: 22
|
286 | }
|
287 | },
|
288 | loc: {
|
289 | start: {
|
290 | line: 28,
|
291 | column: 42
|
292 | },
|
293 | end: {
|
294 | line: 44,
|
295 | column: 3
|
296 | }
|
297 | },
|
298 | line: 28
|
299 | },
|
300 | '4': {
|
301 | name: '(anonymous_4)',
|
302 | decl: {
|
303 | start: {
|
304 | line: 34,
|
305 | column: 29
|
306 | },
|
307 | end: {
|
308 | line: 34,
|
309 | column: 30
|
310 | }
|
311 | },
|
312 | loc: {
|
313 | start: {
|
314 | line: 34,
|
315 | column: 35
|
316 | },
|
317 | end: {
|
318 | line: 38,
|
319 | column: 5
|
320 | }
|
321 | },
|
322 | line: 34
|
323 | }
|
324 | },
|
325 | branchMap: {
|
326 | '0': {
|
327 | loc: {
|
328 | start: {
|
329 | line: 10,
|
330 | column: 2
|
331 | },
|
332 | end: {
|
333 | line: 12,
|
334 | column: 21
|
335 | }
|
336 | },
|
337 | type: 'if',
|
338 | locations: [{
|
339 | start: {
|
340 | line: 10,
|
341 | column: 2
|
342 | },
|
343 | end: {
|
344 | line: 12,
|
345 | column: 21
|
346 | }
|
347 | }, {
|
348 | start: {
|
349 | line: 10,
|
350 | column: 2
|
351 | },
|
352 | end: {
|
353 | line: 12,
|
354 | column: 21
|
355 | }
|
356 | }],
|
357 | line: 10
|
358 | },
|
359 | '1': {
|
360 | loc: {
|
361 | start: {
|
362 | line: 35,
|
363 | column: 6
|
364 | },
|
365 | end: {
|
366 | line: 35,
|
367 | column: 38
|
368 | }
|
369 | },
|
370 | type: 'if',
|
371 | locations: [{
|
372 | start: {
|
373 | line: 35,
|
374 | column: 6
|
375 | },
|
376 | end: {
|
377 | line: 35,
|
378 | column: 38
|
379 | }
|
380 | }, {
|
381 | start: {
|
382 | line: 35,
|
383 | column: 6
|
384 | },
|
385 | end: {
|
386 | line: 35,
|
387 | column: 38
|
388 | }
|
389 | }],
|
390 | line: 35
|
391 | },
|
392 | '2': {
|
393 | loc: {
|
394 | start: {
|
395 | line: 36,
|
396 | column: 6
|
397 | },
|
398 | end: {
|
399 | line: 37,
|
400 | column: 53
|
401 | }
|
402 | },
|
403 | type: 'if',
|
404 | locations: [{
|
405 | start: {
|
406 | line: 36,
|
407 | column: 6
|
408 | },
|
409 | end: {
|
410 | line: 37,
|
411 | column: 53
|
412 | }
|
413 | }, {
|
414 | start: {
|
415 | line: 36,
|
416 | column: 6
|
417 | },
|
418 | end: {
|
419 | line: 37,
|
420 | column: 53
|
421 | }
|
422 | }],
|
423 | line: 36
|
424 | }
|
425 | },
|
426 | s: {
|
427 | '0': 0,
|
428 | '1': 0,
|
429 | '2': 0,
|
430 | '3': 0,
|
431 | '4': 0,
|
432 | '5': 0,
|
433 | '6': 0,
|
434 | '7': 0,
|
435 | '8': 0,
|
436 | '9': 0,
|
437 | '10': 0,
|
438 | '11': 0,
|
439 | '12': 0,
|
440 | '13': 0,
|
441 | '14': 0,
|
442 | '15': 0,
|
443 | '16': 0,
|
444 | '17': 0,
|
445 | '18': 0
|
446 | },
|
447 | f: {
|
448 | '0': 0,
|
449 | '1': 0,
|
450 | '2': 0,
|
451 | '3': 0,
|
452 | '4': 0
|
453 | },
|
454 | b: {
|
455 | '0': [0, 0],
|
456 | '1': [0, 0],
|
457 | '2': [0, 0]
|
458 | },
|
459 | _coverageSchema: '332fd63041d2c1bcb487cc26dd0d5f7d97098a6c'
|
460 | },
|
461 | coverage = global[gcv] || (global[gcv] = {});
|
462 |
|
463 | if (coverage[path] && coverage[path].hash === hash) {
|
464 | return coverage[path];
|
465 | }
|
466 |
|
467 | coverageData.hash = hash;
|
468 | return coverage[path] = coverageData;
|
469 | }();
|
470 |
|
471 | Object.defineProperty(exports, "__esModule", {
|
472 | value: true
|
473 | });
|
474 | exports.isMobile = undefined;
|
475 |
|
476 | var _promise = require('babel-runtime/core-js/promise');
|
477 |
|
478 | var _promise2 = _interopRequireDefault(_promise);
|
479 |
|
480 | exports.hasWeb3 = hasWeb3;
|
481 | exports.ipfsAdd = ipfsAdd;
|
482 |
|
483 | var _mobileDetect = require('mobile-detect');
|
484 |
|
485 | var _mobileDetect2 = _interopRequireDefault(_mobileDetect);
|
486 |
|
487 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
488 |
|
489 |
|
490 |
|
491 |
|
492 |
|
493 |
|
494 |
|
495 | cov_2oxemx8fnf.s[0]++;
|
496 | var isMobile = exports.isMobile = function isMobile() {
|
497 | cov_2oxemx8fnf.f[0]++;
|
498 | cov_2oxemx8fnf.s[1]++;
|
499 |
|
500 | if (typeof navigator !== 'undefined') {
|
501 | cov_2oxemx8fnf.b[0][0]++;
|
502 | cov_2oxemx8fnf.s[2]++;
|
503 |
|
504 | return !!new _mobileDetect2.default(navigator.userAgent).mobile();
|
505 | } else {
|
506 | cov_2oxemx8fnf.b[0][1]++;
|
507 | cov_2oxemx8fnf.s[3]++;
|
508 | return false;
|
509 | }
|
510 | };
|
511 |
|
512 |
|
513 |
|
514 |
|
515 |
|
516 | function hasWeb3() {
|
517 | cov_2oxemx8fnf.f[1]++;
|
518 | cov_2oxemx8fnf.s[4]++;
|
519 |
|
520 | return typeof web3 !== 'undefined';
|
521 | }
|
522 |
|
523 |
|
524 |
|
525 |
|
526 |
|
527 | function ipfsAdd(jwt) {
|
528 | cov_2oxemx8fnf.f[2]++;
|
529 | cov_2oxemx8fnf.s[5]++;
|
530 |
|
531 | return new _promise2.default(function (resolve, reject) {
|
532 | cov_2oxemx8fnf.f[3]++;
|
533 |
|
534 |
|
535 | var payload = (cov_2oxemx8fnf.s[6]++, new FormData());
|
536 | cov_2oxemx8fnf.s[7]++;
|
537 | payload.append("file", new Blob([jwt]));
|
538 | var req = (cov_2oxemx8fnf.s[8]++, new XMLHttpRequest());
|
539 |
|
540 | cov_2oxemx8fnf.s[9]++;
|
541 | req.onreadystatechange = function () {
|
542 | cov_2oxemx8fnf.f[4]++;
|
543 | cov_2oxemx8fnf.s[10]++;
|
544 |
|
545 | if (req.readyState !== 4) {
|
546 | cov_2oxemx8fnf.b[1][0]++;
|
547 | cov_2oxemx8fnf.s[11]++;
|
548 | return;
|
549 | } else {
|
550 | cov_2oxemx8fnf.b[1][1]++;
|
551 | }cov_2oxemx8fnf.s[12]++;
|
552 | if (req.status != 200) {
|
553 | cov_2oxemx8fnf.b[2][0]++;
|
554 | cov_2oxemx8fnf.s[13]++;
|
555 | reject('Error ' + req.status + ': ' + req.responseText);
|
556 | } else {
|
557 | cov_2oxemx8fnf.b[2][1]++;
|
558 | cov_2oxemx8fnf.s[14]++;
|
559 | resolve(JSON.parse(req.responseText).Hash);
|
560 | }
|
561 | };
|
562 |
|
563 | cov_2oxemx8fnf.s[15]++;
|
564 | req.open('POST', 'https://ipfs.infura.io:5001/api/v0/add');
|
565 | cov_2oxemx8fnf.s[16]++;
|
566 | req.setRequestHeader('accept', 'application/json');
|
567 | cov_2oxemx8fnf.s[17]++;
|
568 | req.enctype = 'multipart/form-data';
|
569 | cov_2oxemx8fnf.s[18]++;
|
570 | req.send(payload);
|
571 | });
|
572 | } |
\ | No newline at end of file |