radar-sdk-js 4.1.7 → 4.1.8

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/dist/radar.js CHANGED
@@ -273,7 +273,7 @@ var RadarError = /** @class */ (function (_super) {
273
273
  __extends(RadarError, _super);
274
274
  function RadarError(message) {
275
275
  var _this = _super.call(this, message) || this;
276
- _this.status = ''; // to be overridden (support for leagcy status)
276
+ _this.status = ''; // to be overridden (support for legacy status)
277
277
  return _this;
278
278
  }
279
279
  return RadarError;
@@ -565,7 +565,7 @@ var Navigator = /** @class */ (function () {
565
565
  return Navigator;
566
566
  }());
567
567
 
568
- var SDK_VERSION = '4.1.7';
568
+ var SDK_VERSION = '4.1.8';
569
569
 
570
570
  var Http = /** @class */ (function () {
571
571
  function Http() {
@@ -618,6 +618,7 @@ var Http = /** @class */ (function () {
618
618
  });
619
619
  }
620
620
  xhr.onload = function () {
621
+ var _a;
621
622
  var response;
622
623
  try {
623
624
  response = JSON.parse(xhr.response);
@@ -625,6 +626,16 @@ var Http = /** @class */ (function () {
625
626
  catch (e) {
626
627
  return reject(new RadarServerError(response));
627
628
  }
629
+ var error = (_a = response === null || response === void 0 ? void 0 : response.meta) === null || _a === void 0 ? void 0 : _a.error;
630
+ if (error === 'ERROR_PERMISSIONS') {
631
+ return reject(new RadarLocationPermissionsError('Location permissions not granted.'));
632
+ }
633
+ else if (error === 'ERROR_LOCATION') {
634
+ return reject(new RadarLocationError('Could not determine location.'));
635
+ }
636
+ else if (error === 'ERROR_NETWORK') {
637
+ return reject(new RadarTimeoutError());
638
+ }
628
639
  if (xhr.status == 200) {
629
640
  return resolve(response);
630
641
  }
@@ -1530,7 +1541,7 @@ var VerifyAPI = /** @class */ (function () {
1530
1541
  VerifyAPI.trackVerified = function (params, encrypted) {
1531
1542
  if (encrypted === void 0) { encrypted = false; }
1532
1543
  return __awaiter(this, void 0, void 0, function () {
1533
- var options, userId, deviceId, installId, sessionId, description, metadata, body, response, user, events, token, location, trackTokenRes, trackRes;
1544
+ var options, userId, deviceId, installId, sessionId, description, metadata, body, userAgent, windows, response, user, events, token, location, trackTokenRes, trackRes;
1534
1545
  return __generator(this, function (_a) {
1535
1546
  switch (_a.label) {
1536
1547
  case 0:
@@ -1549,11 +1560,13 @@ var VerifyAPI = /** @class */ (function () {
1549
1560
  }
1550
1561
  metadata = params.metadata || Storage.getJSON(Storage.METADATA);
1551
1562
  body = __assign(__assign({}, params), { description: description, deviceId: deviceId, foreground: true, installId: installId, sessionId: sessionId, metadata: metadata, sdkVersion: SDK_VERSION, stopped: true, userId: userId, encrypted: encrypted });
1563
+ userAgent = navigator.userAgent;
1564
+ windows = userAgent && userAgent.toLowerCase().includes('windows');
1552
1565
  return [4 /*yield*/, Http.request({
1553
1566
  method: 'GET',
1554
1567
  path: 'verify',
1555
1568
  data: body,
1556
- host: 'https://radar-verify.com:52516',
1569
+ host: windows ? 'http://localhost:52516' : 'https://radar-verify.com:52516',
1557
1570
  })];
1558
1571
  case 1:
1559
1572
  response = _a.sent();
package/dist/radar.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"radar.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/dist/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- declare const _default: "4.1.7";
1
+ declare const _default: "4.1.8";
2
2
  export default _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "radar-sdk-js",
3
- "version": "4.1.7",
3
+ "version": "4.1.8",
4
4
  "description": "Web Javascript SDK for Radar, location infrastructure for mobile and web apps.",
5
5
  "homepage": "https://radar.com",
6
6
  "type": "module",
package/src/api/verify.ts CHANGED
@@ -43,11 +43,14 @@ class VerifyAPI {
43
43
  encrypted,
44
44
  };
45
45
 
46
+ let userAgent = navigator.userAgent;
47
+ const windows = userAgent && userAgent.toLowerCase().includes('windows');
48
+
46
49
  const response: any = await Http.request({
47
50
  method: 'GET',
48
51
  path: 'verify',
49
52
  data: body,
50
- host: 'https://radar-verify.com:52516',
53
+ host: windows ? 'http://localhost:52516' : 'https://radar-verify.com:52516',
51
54
  });
52
55
 
53
56
  const { user, events, token } = response;
package/src/errors.ts CHANGED
@@ -3,7 +3,7 @@ class RadarError extends Error {
3
3
 
4
4
  constructor(message: string) {
5
5
  super(message);
6
- this.status = ''; // to be overridden (support for leagcy status)
6
+ this.status = ''; // to be overridden (support for legacy status)
7
7
  }
8
8
  }
9
9
 
package/src/http.ts CHANGED
@@ -6,6 +6,8 @@ import {
6
6
  RadarBadRequestError,
7
7
  RadarDesktopAppError,
8
8
  RadarForbiddenError,
9
+ RadarLocationError,
10
+ RadarLocationPermissionsError,
9
11
  RadarNotFoundError,
10
12
  RadarPaymentRequiredError,
11
13
  RadarPublishableKeyError,
@@ -96,6 +98,15 @@ class Http {
96
98
  return reject(new RadarServerError(response));
97
99
  }
98
100
 
101
+ const error = response?.meta?.error;
102
+ if (error === 'ERROR_PERMISSIONS') {
103
+ return reject(new RadarLocationPermissionsError('Location permissions not granted.'));
104
+ } else if (error === 'ERROR_LOCATION') {
105
+ return reject(new RadarLocationError('Could not determine location.'));
106
+ } else if (error === 'ERROR_NETWORK') {
107
+ return reject(new RadarTimeoutError());
108
+ }
109
+
99
110
  if (xhr.status == 200) {
100
111
  return resolve(response);
101
112
  }
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export default '4.1.7';
1
+ export default '4.1.8';