radar-sdk-js 4.1.6-beta.0 → 4.1.7

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/README.md CHANGED
@@ -56,7 +56,7 @@ Radar.initialize('prj_test_pk_...', { /* options */ });
56
56
 
57
57
  Add the following script in your `html` file
58
58
  ```html
59
- <script src="https://js.radar.com/v4.1.6-beta.0/radar.min.js"></script>
59
+ <script src="https://js.radar.com/v4.1.7/radar.min.js"></script>
60
60
  ```
61
61
 
62
62
  Then initialize the Radar SDK
@@ -73,8 +73,8 @@ To create a map, first initialize the Radar SDK with your publishable key. Then
73
73
  ```html
74
74
  <html>
75
75
  <head>
76
- <link href="https://js.radar.com/v4.1.6-beta.0/radar.css" rel="stylesheet">
77
- <script src="https://js.radar.com/v4.1.6-beta.0/radar.min.js"></script>
76
+ <link href="https://js.radar.com/v4.1.7/radar.css" rel="stylesheet">
77
+ <script src="https://js.radar.com/v4.1.7/radar.min.js"></script>
78
78
  </head>
79
79
 
80
80
  <body>
@@ -98,8 +98,8 @@ To create an autocomplete input, first initialize the Radar SDK with your publis
98
98
  ```html
99
99
  <html>
100
100
  <head>
101
- <link href="https://js.radar.com/v4.1.6-beta.0/radar.css" rel="stylesheet">
102
- <script src="https://js.radar.com/v4.1.6-beta.0/radar.min.js"></script>
101
+ <link href="https://js.radar.com/v4.1.7/radar.css" rel="stylesheet">
102
+ <script src="https://js.radar.com/v4.1.7/radar.min.js"></script>
103
103
  </head>
104
104
 
105
105
  <body>
@@ -130,8 +130,8 @@ To power [geofencing](https://radar.com/documentation/geofencing/overview) exper
130
130
  ```html
131
131
  <html>
132
132
  <head>
133
- <link href="https://js.radar.com/v4.1.6-beta.0/radar.css" rel="stylesheet">
134
- <script src="https://js.radar.com/v4.1.6-beta.0/radar.min.js"></script>
133
+ <link href="https://js.radar.com/v4.1.7/radar.css" rel="stylesheet">
134
+ <script src="https://js.radar.com/v4.1.7/radar.min.js"></script>
135
135
  </head>
136
136
 
137
137
  <body>
@@ -1,5 +1,5 @@
1
- import type { RadarTrackParams, RadarTrackResponse, RadarTrackTokenResponse } from '../types';
1
+ import type { RadarTrackParams, RadarTrackResponse } from '../types';
2
2
  declare class TrackAPI {
3
- static trackOnce(params: RadarTrackParams, verified?: boolean, encrypted?: boolean, host?: string | undefined): Promise<RadarTrackTokenResponse | RadarTrackResponse>;
3
+ static trackOnce(params: RadarTrackParams): Promise<RadarTrackResponse>;
4
4
  }
5
5
  export default TrackAPI;
@@ -1,5 +1,5 @@
1
1
  import type { RadarTrackParams, RadarTrackResponse, RadarTrackTokenResponse } from '../types';
2
2
  declare class VerifyAPI {
3
- static trackVerified(params: RadarTrackParams, encrypted?: Boolean, host?: string): Promise<RadarTrackTokenResponse | RadarTrackResponse>;
3
+ static trackVerified(params: RadarTrackParams, encrypted?: Boolean): Promise<RadarTrackTokenResponse | RadarTrackResponse>;
4
4
  }
5
5
  export default VerifyAPI;
package/dist/config.d.ts CHANGED
@@ -5,7 +5,6 @@ declare class Config {
5
5
  live: boolean;
6
6
  logLevel: string;
7
7
  host: string;
8
- verifiedHost: string;
9
8
  version: string;
10
9
  debug: boolean;
11
10
  };
package/dist/device.d.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  declare class Device {
2
- static getPlatform(): string;
3
2
  static getDeviceId(): string;
4
3
  static getInstallId(): string;
5
4
  }
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /// <reference types="mapbox__point-geometry" />
2
2
  import MapUI from './ui/map';
3
3
  import AutocompleteUI from './ui/autocomplete';
4
- import type { Location, RadarAutocompleteParams, RadarConversionParams, RadarDistanceParams, RadarForwardGeocodeParams, RadarMatrixParams, RadarMetadata, RadarOptions, RadarReverseGeocodeParams, RadarSearchGeofencesParams, RadarSearchPlacesParams, RadarTrackParams, RadarTrackResponse, RadarTrackTokenResponse, RadarTripOptions, RadarValidateAddressParams } from './types';
4
+ import type { Location, RadarAutocompleteParams, RadarConversionParams, RadarDistanceParams, RadarForwardGeocodeParams, RadarMatrixParams, RadarMetadata, RadarOptions, RadarReverseGeocodeParams, RadarSearchGeofencesParams, RadarSearchPlacesParams, RadarTrackParams, RadarTripOptions, RadarValidateAddressParams } from './types';
5
5
  import 'maplibre-gl/dist/maplibre-gl.css';
6
6
  import '../styles/radar.css';
7
7
  declare class Radar {
@@ -61,9 +61,9 @@ declare class Radar {
61
61
  static setDescription(description?: string): void;
62
62
  static setMetadata(metadata?: RadarMetadata): void;
63
63
  static getLocation(): Promise<import("./types").NavigatorPosition>;
64
- static trackOnce(params?: RadarTrackParams): Promise<RadarTrackResponse>;
65
- static trackVerified(params?: RadarTrackParams): Promise<RadarTrackResponse>;
66
- static trackVerifiedToken(params?: RadarTrackParams): Promise<RadarTrackTokenResponse>;
64
+ static trackOnce(params?: RadarTrackParams): Promise<import("./types").RadarTrackResponse>;
65
+ static trackVerified(params?: RadarTrackParams): Promise<import("./types").RadarTrackResponse | import("./types").RadarTrackTokenResponse>;
66
+ static trackVerifiedToken(params?: RadarTrackParams): Promise<import("./types").RadarTrackResponse | import("./types").RadarTrackTokenResponse>;
67
67
  static getContext(params: Location): Promise<import("./types").RadarContextResponse>;
68
68
  static setTripOptions(tripOptions?: RadarTripOptions): void;
69
69
  static clearTripOptions(): void;
package/dist/radar.js CHANGED
@@ -17,7 +17,6 @@ var Config = /** @class */ (function () {
17
17
  live: false,
18
18
  logLevel: 'error',
19
19
  host: 'https://api.radar.io',
20
- verifiedHost: 'https://api-verified.radar.io',
21
20
  version: 'v1',
22
21
  debug: false,
23
22
  };
@@ -190,61 +189,6 @@ var Storage = /** @class */ (function () {
190
189
  return Storage;
191
190
  }());
192
191
 
193
- var generateUUID = function () {
194
- var uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (char) {
195
- var r = Math.random() * 16 | 0;
196
- var v = (char == 'x') ? r : (r & 0x3 | 0x8);
197
- return v.toString(16);
198
- });
199
- return uuid;
200
- };
201
- var Device = /** @class */ (function () {
202
- function Device() {
203
- }
204
- Device.getPlatform = function () {
205
- var userAgent = navigator.userAgent;
206
- if (userAgent) {
207
- userAgent = userAgent.toLowerCase();
208
- if (userAgent.includes('macintosh')) {
209
- return 'DESKTOP_MAC';
210
- }
211
- else if (userAgent.includes('windows')) {
212
- return 'DESKTOP_WINDOWS';
213
- }
214
- else if (userAgent.includes('iphone') || userAgent.includes('ipad') || userAgent.includes('ipod')) {
215
- return 'MOBILE_IOS';
216
- }
217
- else if (userAgent.includes('android')) {
218
- return 'MOBILE_ANDROID';
219
- }
220
- }
221
- return 'OTHER';
222
- };
223
- Device.getDeviceId = function () {
224
- // use existing deviceId if present
225
- var deviceId = Storage.getItem(Storage.DEVICE_ID);
226
- if (deviceId) {
227
- return deviceId;
228
- }
229
- // generate new deviceId
230
- var uuid = generateUUID();
231
- Storage.setItem(Storage.DEVICE_ID, uuid);
232
- return uuid;
233
- };
234
- Device.getInstallId = function () {
235
- // use existing installId if present
236
- var deviceId = Storage.getItem(Storage.INSTALL_ID);
237
- if (deviceId) {
238
- return deviceId;
239
- }
240
- // generate new installId
241
- var uuid = generateUUID();
242
- Storage.setItem(Storage.INSTALL_ID, uuid);
243
- return uuid;
244
- };
245
- return Device;
246
- }());
247
-
248
192
  /******************************************************************************
249
193
  Copyright (c) Microsoft Corporation.
250
194
 
@@ -621,7 +565,7 @@ var Navigator = /** @class */ (function () {
621
565
  return Navigator;
622
566
  }());
623
567
 
624
- var SDK_VERSION = '4.1.6-beta.0';
568
+ var SDK_VERSION = '4.1.7';
625
569
 
626
570
  var Http = /** @class */ (function () {
627
571
  function Http() {
@@ -714,7 +658,7 @@ var Http = /** @class */ (function () {
714
658
  }
715
659
  };
716
660
  xhr.onerror = function () {
717
- if (host && (host === 'https://radar-verify.com:52516' || host === 'http://localhost:52516')) {
661
+ if (host && host === 'https://radar-verify.com:52516') {
718
662
  reject(new RadarDesktopAppError());
719
663
  }
720
664
  else {
@@ -765,6 +709,42 @@ var AddressesAPI = /** @class */ (function () {
765
709
  return AddressesAPI;
766
710
  }());
767
711
 
712
+ var generateUUID = function () {
713
+ var uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (char) {
714
+ var r = Math.random() * 16 | 0;
715
+ var v = (char == 'x') ? r : (r & 0x3 | 0x8);
716
+ return v.toString(16);
717
+ });
718
+ return uuid;
719
+ };
720
+ var Device = /** @class */ (function () {
721
+ function Device() {
722
+ }
723
+ Device.getDeviceId = function () {
724
+ // use existing deviceId if present
725
+ var deviceId = Storage.getItem(Storage.DEVICE_ID);
726
+ if (deviceId) {
727
+ return deviceId;
728
+ }
729
+ // generate new deviceId
730
+ var uuid = generateUUID();
731
+ Storage.setItem(Storage.DEVICE_ID, uuid);
732
+ return uuid;
733
+ };
734
+ Device.getInstallId = function () {
735
+ // use existing installId if present
736
+ var deviceId = Storage.getItem(Storage.INSTALL_ID);
737
+ if (deviceId) {
738
+ return deviceId;
739
+ }
740
+ // generate new installId
741
+ var uuid = generateUUID();
742
+ Storage.setItem(Storage.INSTALL_ID, uuid);
743
+ return uuid;
744
+ };
745
+ return Device;
746
+ }());
747
+
768
748
  var SESSION_TIMEOUT_SECS = 300; // 5 mins
769
749
  var isValid = function (sessionId) {
770
750
  var now = Math.trunc(Date.now() / 1000);
@@ -1473,12 +1453,9 @@ var TripsAPI = /** @class */ (function () {
1473
1453
  var TrackAPI = /** @class */ (function () {
1474
1454
  function TrackAPI() {
1475
1455
  }
1476
- TrackAPI.trackOnce = function (params, verified, encrypted, host) {
1477
- if (verified === void 0) { verified = false; }
1478
- if (encrypted === void 0) { encrypted = false; }
1479
- if (host === void 0) { host = undefined; }
1456
+ TrackAPI.trackOnce = function (params) {
1480
1457
  return __awaiter(this, void 0, void 0, function () {
1481
- var options, latitude, longitude, accuracy, desiredAccuracy, deviceLocation, locationAuthorization, err_1, userId, deviceId, installId, sessionId, deviceType, description, metadata, tripOptions, body, response, user, events, token, location, trackTokenRes, trackRes;
1458
+ var options, latitude, longitude, accuracy, desiredAccuracy, deviceLocation, locationAuthorization, err_1, userId, deviceId, installId, sessionId, deviceType, description, metadata, tripOptions, body, response, user, events, location, trackRes;
1482
1459
  return __generator(this, function (_a) {
1483
1460
  switch (_a.label) {
1484
1461
  case 0:
@@ -1521,26 +1498,16 @@ var TrackAPI = /** @class */ (function () {
1521
1498
  if (tripOptions) {
1522
1499
  tripOptions.version = '2';
1523
1500
  }
1524
- body = __assign(__assign({}, params), { locationAuthorization: locationAuthorization, accuracy: accuracy, description: description, deviceId: deviceId, deviceType: deviceType, foreground: true, installId: installId, sessionId: sessionId, latitude: latitude, longitude: longitude, metadata: metadata, sdkVersion: SDK_VERSION, stopped: true, userId: userId, tripOptions: tripOptions, verified: verified, encrypted: encrypted });
1501
+ body = __assign(__assign({}, params), { locationAuthorization: locationAuthorization, accuracy: accuracy, description: description, deviceId: deviceId, deviceType: deviceType, foreground: true, installId: installId, sessionId: sessionId, latitude: latitude, longitude: longitude, metadata: metadata, sdkVersion: SDK_VERSION, stopped: true, userId: userId, tripOptions: tripOptions });
1525
1502
  return [4 /*yield*/, Http.request({
1526
1503
  method: 'POST',
1527
1504
  path: 'track',
1528
1505
  data: body,
1529
- host: host,
1530
1506
  })];
1531
1507
  case 6:
1532
1508
  response = _a.sent();
1533
- user = response.user, events = response.events, token = response.token;
1509
+ user = response.user, events = response.events;
1534
1510
  location = { latitude: latitude, longitude: longitude, accuracy: accuracy };
1535
- if (encrypted) {
1536
- trackTokenRes = {
1537
- token: token,
1538
- };
1539
- if (options.debug) {
1540
- trackTokenRes.response = response;
1541
- }
1542
- return [2 /*return*/, trackTokenRes];
1543
- }
1544
1511
  trackRes = {
1545
1512
  user: user,
1546
1513
  events: events,
@@ -1560,9 +1527,8 @@ var TrackAPI = /** @class */ (function () {
1560
1527
  var VerifyAPI = /** @class */ (function () {
1561
1528
  function VerifyAPI() {
1562
1529
  }
1563
- VerifyAPI.trackVerified = function (params, encrypted, host) {
1530
+ VerifyAPI.trackVerified = function (params, encrypted) {
1564
1531
  if (encrypted === void 0) { encrypted = false; }
1565
- if (host === void 0) { host = 'http://localhost:52516'; }
1566
1532
  return __awaiter(this, void 0, void 0, function () {
1567
1533
  var options, userId, deviceId, installId, sessionId, description, metadata, body, response, user, events, token, location, trackTokenRes, trackRes;
1568
1534
  return __generator(this, function (_a) {
@@ -1587,7 +1553,7 @@ var VerifyAPI = /** @class */ (function () {
1587
1553
  method: 'GET',
1588
1554
  path: 'verify',
1589
1555
  data: body,
1590
- host: host,
1556
+ host: 'https://radar-verify.com:52516',
1591
1557
  })];
1592
1558
  case 1:
1593
1559
  response = _a.sent();
@@ -1938,16 +1904,17 @@ var AutocompleteUI = /** @class */ (function () {
1938
1904
  };
1939
1905
  AutocompleteUI.prototype.fetchResults = function (query) {
1940
1906
  return __awaiter(this, void 0, void 0, function () {
1941
- var _a, limit, layers, countryCode, onRequest, params, addresses;
1907
+ var _a, limit, layers, countryCode, expandUnits, onRequest, params, addresses;
1942
1908
  return __generator(this, function (_b) {
1943
1909
  switch (_b.label) {
1944
1910
  case 0:
1945
- _a = this.config, limit = _a.limit, layers = _a.layers, countryCode = _a.countryCode, onRequest = _a.onRequest;
1911
+ _a = this.config, limit = _a.limit, layers = _a.layers, countryCode = _a.countryCode, expandUnits = _a.expandUnits, onRequest = _a.onRequest;
1946
1912
  params = {
1947
1913
  query: query,
1948
1914
  limit: limit,
1949
1915
  layers: layers,
1950
1916
  countryCode: countryCode,
1917
+ expandUnits: expandUnits,
1951
1918
  };
1952
1919
  if (this.near) {
1953
1920
  params.near = this.near;
@@ -2243,39 +2210,11 @@ var Radar = /** @class */ (function () {
2243
2210
  };
2244
2211
  Radar.trackVerified = function (params) {
2245
2212
  if (params === void 0) { params = {}; }
2246
- var platform = Device.getPlatform();
2247
- if (platform === 'DESKTOP_MAC') { // use Mac app
2248
- return VerifyAPI.trackVerified(params, false, 'https://radar-verify.com:52516');
2249
- }
2250
- else if (platform === 'DESKTOP_WINDOWS') { // use Windows app
2251
- return VerifyAPI.trackVerified(params, false, 'http://localhost:52516');
2252
- }
2253
- else { // bypass desktop app
2254
- try {
2255
- return TrackAPI.trackOnce(params, true, false, 'https://api-verified.radar.io');
2256
- }
2257
- finally {
2258
- ConfigAPI.getConfig(params); // call with updated permissions
2259
- }
2260
- }
2213
+ return VerifyAPI.trackVerified(params);
2261
2214
  };
2262
2215
  Radar.trackVerifiedToken = function (params) {
2263
2216
  if (params === void 0) { params = {}; }
2264
- var platform = Device.getPlatform();
2265
- if (platform === 'DESKTOP_MAC') { // use Mac app
2266
- return VerifyAPI.trackVerified(params, true, 'https://radar-verify.com:52516');
2267
- }
2268
- else if (platform === 'DESKTOP_WINDOWS') { // use Windows app
2269
- return VerifyAPI.trackVerified(params, true, 'http://localhost:52516');
2270
- }
2271
- else { // bypass desktop app
2272
- try {
2273
- return TrackAPI.trackOnce(params, true, true, 'https://api-verified.radar.io');
2274
- }
2275
- finally {
2276
- ConfigAPI.getConfig(params); // call with updated permissions
2277
- }
2278
- }
2217
+ return VerifyAPI.trackVerified(params, true);
2279
2218
  };
2280
2219
  Radar.getContext = function (params) {
2281
2220
  return ContextAPI.getContext(params);
package/dist/radar.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"radar.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/dist/types.d.ts CHANGED
@@ -245,7 +245,7 @@ export interface RadarAutocompleteParams {
245
245
  expandUnits?: boolean;
246
246
  }
247
247
  export interface RadarAutocompleteResponse extends RadarResponse {
248
- addresses: RadarAutocompleteAddress;
248
+ addresses: RadarAutocompleteAddress[];
249
249
  }
250
250
  export interface RadarSearchPlacesParams {
251
251
  near?: Location | string;
@@ -352,6 +352,7 @@ export interface RadarAutocompleteUIOptions {
352
352
  limit?: number;
353
353
  layers?: RadarGeocodeLayer[];
354
354
  countryCode?: string;
355
+ expandUnits?: boolean;
355
356
  placeholder?: string;
356
357
  onSelection?: (selection: any) => void;
357
358
  onRequest?: (params: RadarAutocompleteParams) => void;
@@ -15,7 +15,7 @@ declare class AutocompleteUI {
15
15
  constructor(options?: Partial<RadarAutocompleteUIOptions>);
16
16
  handleInput(): void;
17
17
  debounce(fn: Function, delay: number): (...args: any[]) => Promise<unknown>;
18
- fetchResults(query: string): Promise<import("../types").RadarAutocompleteAddress>;
18
+ fetchResults(query: string): Promise<import("../types").RadarAutocompleteAddress[]>;
19
19
  displayResults(results: any[]): void;
20
20
  open(): void;
21
21
  close(e?: FocusEvent): void;
package/dist/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- declare const _default: "4.1.6-beta.0";
1
+ declare const _default: "4.1.7";
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.6-beta.0",
3
+ "version": "4.1.7",
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/track.ts CHANGED
@@ -9,10 +9,10 @@ import Storage from '../storage';
9
9
 
10
10
  import TripsAPI from './trips';
11
11
 
12
- import type { RadarTrackParams, RadarTrackResponse, RadarTrackTokenResponse } from '../types';
12
+ import type { RadarTrackParams, RadarTrackResponse } from '../types';
13
13
 
14
14
  class TrackAPI {
15
- static async trackOnce(params: RadarTrackParams, verified: boolean = false, encrypted: boolean = false, host: string | undefined = undefined) {
15
+ static async trackOnce(params: RadarTrackParams) {
16
16
  const options = Config.get();
17
17
 
18
18
  let { latitude, longitude, accuracy, desiredAccuracy } = params;
@@ -75,32 +75,17 @@ class TrackAPI {
75
75
  stopped: true,
76
76
  userId,
77
77
  tripOptions,
78
- verified,
79
- encrypted,
80
78
  };
81
79
 
82
80
  const response: any = await Http.request({
83
81
  method: 'POST',
84
82
  path: 'track',
85
83
  data: body,
86
- host,
87
84
  });
88
85
 
89
- const { user, events, token } = response;
86
+ const { user, events } = response;
90
87
  const location = { latitude, longitude, accuracy };
91
88
 
92
- if (encrypted) {
93
- const trackTokenRes = {
94
- token,
95
- } as RadarTrackTokenResponse;
96
-
97
- if (options.debug) {
98
- trackTokenRes.response = response;
99
- }
100
-
101
- return trackTokenRes;
102
- }
103
-
104
89
  const trackRes = {
105
90
  user,
106
91
  events,
package/src/api/verify.ts CHANGED
@@ -9,7 +9,7 @@ import Storage from '../storage';
9
9
  import type { RadarTrackParams, RadarTrackResponse, RadarTrackTokenResponse } from '../types';
10
10
 
11
11
  class VerifyAPI {
12
- static async trackVerified(params: RadarTrackParams, encrypted: Boolean = false, host: string = 'http://localhost:52516') {
12
+ static async trackVerified(params: RadarTrackParams, encrypted: Boolean = false) {
13
13
  const options = Config.get();
14
14
 
15
15
  // user indentification fields
@@ -47,7 +47,7 @@ class VerifyAPI {
47
47
  method: 'GET',
48
48
  path: 'verify',
49
49
  data: body,
50
- host,
50
+ host: 'https://radar-verify.com:52516',
51
51
  });
52
52
 
53
53
  const { user, events, token } = response;
package/src/config.ts CHANGED
@@ -7,7 +7,6 @@ class Config {
7
7
  live: false,
8
8
  logLevel: 'error',
9
9
  host: 'https://api.radar.io',
10
- verifiedHost: 'https://api-verified.radar.io',
11
10
  version: 'v1',
12
11
  debug: false,
13
12
  };
package/src/device.ts CHANGED
@@ -1,4 +1,3 @@
1
- import Config from './config';
2
1
  import Storage from './storage';
3
2
 
4
3
  const generateUUID = (): string => {
@@ -12,23 +11,6 @@ const generateUUID = (): string => {
12
11
  };
13
12
 
14
13
  class Device {
15
- static getPlatform(): string {
16
- let userAgent = navigator.userAgent;
17
- if (userAgent) {
18
- userAgent = userAgent.toLowerCase();
19
- if (userAgent.includes('macintosh')) {
20
- return 'DESKTOP_MAC';
21
- } else if (userAgent.includes('windows')) {
22
- return 'DESKTOP_WINDOWS';
23
- } else if (userAgent.includes('iphone') || userAgent.includes('ipad') || userAgent.includes('ipod')) {
24
- return 'MOBILE_IOS';
25
- } else if (userAgent.includes('android')) {
26
- return 'MOBILE_ANDROID';
27
- }
28
- }
29
- return 'OTHER';
30
- }
31
-
32
14
  static getDeviceId(): string {
33
15
  // use existing deviceId if present
34
16
  const deviceId = Storage.getItem(Storage.DEVICE_ID);
package/src/http.ts CHANGED
@@ -132,7 +132,7 @@ class Http {
132
132
  }
133
133
 
134
134
  xhr.onerror = function() {
135
- if (host && (host === 'https://radar-verify.com:52516' || host === 'http://localhost:52516')) {
135
+ if (host && host === 'https://radar-verify.com:52516') {
136
136
  reject(new RadarDesktopAppError());
137
137
  } else {
138
138
  reject(new RadarServerError());
package/src/index.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import Config from './config';
2
- import Device from './device';
3
2
  import Logger from './logger';
4
3
  import Storage from './storage';
5
4
  import Navigator from './navigator';
@@ -34,8 +33,6 @@ import type {
34
33
  RadarSearchGeofencesParams,
35
34
  RadarSearchPlacesParams,
36
35
  RadarTrackParams,
37
- RadarTrackResponse,
38
- RadarTrackTokenResponse,
39
36
  RadarTripOptions,
40
37
  RadarValidateAddressParams,
41
38
  } from './types';
@@ -139,7 +136,7 @@ class Radar {
139
136
  return Navigator.getCurrentPosition();
140
137
  }
141
138
 
142
- public static trackOnce(params: RadarTrackParams = {}): Promise<RadarTrackResponse> {
139
+ public static trackOnce(params: RadarTrackParams = {}) {
143
140
  try {
144
141
  return TrackAPI.trackOnce(params);
145
142
  } finally {
@@ -147,34 +144,12 @@ class Radar {
147
144
  }
148
145
  }
149
146
 
150
- public static trackVerified(params: RadarTrackParams = {}): Promise<RadarTrackResponse> {
151
- const platform = Device.getPlatform();
152
- if (platform === 'DESKTOP_MAC') { // use Mac app
153
- return VerifyAPI.trackVerified(params, false, 'https://radar-verify.com:52516');
154
- } else if (platform === 'DESKTOP_WINDOWS') { // use Windows app
155
- return VerifyAPI.trackVerified(params, false, 'http://localhost:52516');
156
- } else { // bypass desktop app
157
- try {
158
- return TrackAPI.trackOnce(params, true, false, 'https://api-verified.radar.io');
159
- } finally {
160
- ConfigAPI.getConfig(params); // call with updated permissions
161
- }
162
- }
147
+ public static trackVerified(params: RadarTrackParams = {}) {
148
+ return VerifyAPI.trackVerified(params);
163
149
  }
164
150
 
165
- public static trackVerifiedToken(params: RadarTrackParams = {}): Promise<RadarTrackTokenResponse> {
166
- const platform = Device.getPlatform();
167
- if (platform === 'DESKTOP_MAC') { // use Mac app
168
- return VerifyAPI.trackVerified(params, true, 'https://radar-verify.com:52516');
169
- } else if (platform === 'DESKTOP_WINDOWS') { // use Windows app
170
- return VerifyAPI.trackVerified(params, true, 'http://localhost:52516');
171
- } else { // bypass desktop app
172
- try {
173
- return TrackAPI.trackOnce(params, true, true, 'https://api-verified.radar.io');
174
- } finally {
175
- ConfigAPI.getConfig(params); // call with updated permissions
176
- }
177
- }
151
+ public static trackVerifiedToken(params: RadarTrackParams = {}) {
152
+ return VerifyAPI.trackVerified(params, true);
178
153
  }
179
154
 
180
155
  public static getContext(params: Location) {
package/src/types.ts CHANGED
@@ -340,7 +340,7 @@ export interface RadarAutocompleteParams {
340
340
  }
341
341
 
342
342
  export interface RadarAutocompleteResponse extends RadarResponse {
343
- addresses: RadarAutocompleteAddress;
343
+ addresses: RadarAutocompleteAddress[];
344
344
  }
345
345
 
346
346
  export interface RadarSearchPlacesParams {
@@ -467,6 +467,7 @@ export interface RadarAutocompleteUIOptions {
467
467
  limit?: number, // Maximum number of autocomplete results
468
468
  layers?: RadarGeocodeLayer[];
469
469
  countryCode?: string;
470
+ expandUnits?: boolean;
470
471
  placeholder?: string, // Placeholder text for the input field
471
472
  onSelection?: (selection: any) => void,
472
473
  onRequest?: (params: RadarAutocompleteParams) => void,
@@ -226,13 +226,14 @@ class AutocompleteUI {
226
226
  }
227
227
 
228
228
  public async fetchResults(query: string) {
229
- const { limit, layers, countryCode, onRequest } = this.config;
229
+ const { limit, layers, countryCode, expandUnits, onRequest } = this.config;
230
230
 
231
231
  const params: RadarAutocompleteParams = {
232
232
  query,
233
233
  limit,
234
234
  layers,
235
235
  countryCode,
236
+ expandUnits,
236
237
  }
237
238
 
238
239
  if (this.near) {
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export default '4.1.6-beta.0';
1
+ export default '4.1.7';