radar-sdk-js 4.4.9 → 4.4.10-beta.0

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.4.9/radar.min.js"></script>
59
+ <script src="https://js.radar.com/v4.4.10-beta.0/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.4.9/radar.css" rel="stylesheet">
77
- <script src="https://js.radar.com/v4.4.9/radar.min.js"></script>
76
+ <link href="https://js.radar.com/v4.4.10-beta.0/radar.css" rel="stylesheet">
77
+ <script src="https://js.radar.com/v4.4.10-beta.0/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.4.9/radar.css" rel="stylesheet">
102
- <script src="https://js.radar.com/v4.4.9/radar.min.js"></script>
101
+ <link href="https://js.radar.com/v4.4.10-beta.0/radar.css" rel="stylesheet">
102
+ <script src="https://js.radar.com/v4.4.10-beta.0/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.4.9/radar.css" rel="stylesheet">
134
- <script src="https://js.radar.com/v4.4.9/radar.min.js"></script>
133
+ <link href="https://js.radar.com/v4.4.10-beta.0/radar.css" rel="stylesheet">
134
+ <script src="https://js.radar.com/v4.4.10-beta.0/radar.min.js"></script>
135
135
  </head>
136
136
 
137
137
  <body>
@@ -1,5 +1,6 @@
1
1
  import type { RadarStartTrackingVerifiedParams, RadarTrackVerifiedParams, RadarTrackVerifiedResponse } from '../types';
2
2
  declare class VerifyAPI {
3
+ static checkIpChanges(): Promise<boolean>;
3
4
  static trackVerified(params: RadarTrackVerifiedParams, encrypted?: Boolean): Promise<RadarTrackVerifiedResponse>;
4
5
  static startTrackingVerified(params: RadarStartTrackingVerifiedParams): Promise<void>;
5
6
  static stopTrackingVerified(): void;
package/dist/radar.js CHANGED
@@ -405,7 +405,7 @@ class Navigator {
405
405
  }
406
406
  }
407
407
 
408
- var SDK_VERSION = '4.4.9';
408
+ var SDK_VERSION = '4.4.10-beta.0';
409
409
 
410
410
  const inFlightRequests = new Map();
411
411
  class Http {
@@ -1247,27 +1247,8 @@ class TrackAPI {
1247
1247
  'X-Radar-Desktop-Device-Type': 'Web',
1248
1248
  },
1249
1249
  });
1250
- let sclVal = -1;
1251
- let cslVal = -1;
1252
- /*
1253
- try {
1254
- const [sclRes, csl] = await Promise.all([
1255
- Http.request({
1256
- host: `https://${pingHost}`,
1257
- method: 'GET',
1258
- path: 'ping',
1259
- }),
1260
- ping(`wss://${pingHost}`),
1261
- ]);
1262
- const { scl }: any = sclRes;
1263
- sclVal = scl;
1264
- cslVal = csl;
1265
- } catch (err) {
1266
- // do nothing, send scl = -1 and csl = -1
1267
- }
1268
- */
1269
1250
  const payload = {
1270
- payload: JSON.stringify(Object.assign(Object.assign({}, body), { scl: sclVal, csl: cslVal, lang,
1251
+ payload: JSON.stringify(Object.assign(Object.assign({}, body), { lang,
1271
1252
  langs })),
1272
1253
  };
1273
1254
  const reqToken = yield signJWT(payload, dk);
@@ -1282,15 +1263,6 @@ class TrackAPI {
1282
1263
  'X-Radar-Body-Is-Token': 'true',
1283
1264
  },
1284
1265
  });
1285
- if (options.debug && response && response.user) {
1286
- if (!response.user.metadata) {
1287
- response.user.metadata = {};
1288
- }
1289
- response.user.metadata['radar:debug'] = {
1290
- sclVal,
1291
- cslVal,
1292
- };
1293
- }
1294
1266
  let { user, events, token, expiresAt, expiresIn, passed, failureReasons, _id } = response;
1295
1267
  const location = { latitude, longitude, accuracy };
1296
1268
  if (expiresAt) {
@@ -1338,8 +1310,25 @@ let lastToken = null;
1338
1310
  let lastTokenNow = 0;
1339
1311
  let expectedCountryCode = null;
1340
1312
  let expectedStateCode = null;
1313
+ let lastIp = null;
1341
1314
  class VerifyAPI {
1315
+ static checkIpChanges() {
1316
+ return __awaiter(this, void 0, void 0, function* () {
1317
+ const { ip } = yield Http.request({
1318
+ method: 'GET',
1319
+ path: 'ping',
1320
+ });
1321
+ const ipChanged = ip !== lastIp;
1322
+ if (ipChanged) {
1323
+ Logger.info(`IP changed from ${lastIp} to ${ip}`);
1324
+ lastToken = null;
1325
+ }
1326
+ lastIp = ip;
1327
+ return ipChanged;
1328
+ });
1329
+ }
1342
1330
  static trackVerified(params, encrypted = false) {
1331
+ var _a, _b;
1343
1332
  return __awaiter(this, void 0, void 0, function* () {
1344
1333
  const options = Config.get();
1345
1334
  const { skipVerifyApp } = params;
@@ -1410,6 +1399,10 @@ class VerifyAPI {
1410
1399
  trackRes.response = response;
1411
1400
  }
1412
1401
  }
1402
+ if (params.ipChanges && ((_a = trackRes === null || trackRes === void 0 ? void 0 : trackRes.user) === null || _a === void 0 ? void 0 : _a.ip)) {
1403
+ lastIp = (_b = trackRes === null || trackRes === void 0 ? void 0 : trackRes.user) === null || _b === void 0 ? void 0 : _b.ip;
1404
+ Logger.info(`Setting ip to ${lastIp}`);
1405
+ }
1413
1406
  lastToken = trackRes;
1414
1407
  lastTokenNow = performance.now();
1415
1408
  if (tokenCallback) {
@@ -1420,6 +1413,11 @@ class VerifyAPI {
1420
1413
  }
1421
1414
  static startTrackingVerified(params) {
1422
1415
  return __awaiter(this, void 0, void 0, function* () {
1416
+ let { interval } = params;
1417
+ if (!interval) {
1418
+ interval = 60;
1419
+ Logger.info(`interval not provided, using 60 seconds`);
1420
+ }
1423
1421
  const doTrackVerified = () => __awaiter(this, void 0, void 0, function* () {
1424
1422
  let trackRes;
1425
1423
  try {
@@ -1428,7 +1426,6 @@ class VerifyAPI {
1428
1426
  catch (err) {
1429
1427
  Logger.error(`trackVerified error: ${err.message}`);
1430
1428
  }
1431
- const { interval } = params;
1432
1429
  let expiresIn = 0;
1433
1430
  let minInterval = interval;
1434
1431
  if (trackRes) {
@@ -1460,6 +1457,9 @@ class VerifyAPI {
1460
1457
  static getVerifiedLocationToken(params) {
1461
1458
  return __awaiter(this, void 0, void 0, function* () {
1462
1459
  const lastTokenElapsed = (performance.now() - lastTokenNow) / 1000;
1460
+ if (params.ipChanges) {
1461
+ yield this.checkIpChanges();
1462
+ }
1463
1463
  if (lastToken && lastToken.passed) {
1464
1464
  if (lastTokenElapsed < (lastToken.expiresIn || 0)) {
1465
1465
  return lastToken;
@@ -1924,7 +1924,6 @@ class RadarLogoControl {
1924
1924
  this.link.id = 'radar-map-logo';
1925
1925
  this.link.href = 'https://radar.com?ref=powered_by_radar';
1926
1926
  this.link.target = '_blank';
1927
- this.link.style.pointerEvents = "auto";
1928
1927
  this.link.appendChild(img);
1929
1928
  return this.link;
1930
1929
  }
@@ -2033,7 +2032,7 @@ class RadarMap extends maplibregl.Map {
2033
2032
  // configure map options
2034
2033
  const style = getStyle(config, radarMapOptions);
2035
2034
  const mapOptions = Object.assign({}, defaultRadarMapOptions, defaultMaplibreOptions, radarMapOptions, { style });
2036
- Logger.debug('map initailized with options', mapOptions);
2035
+ Logger.debug('map initialized with options', mapOptions);
2037
2036
  mapOptions.transformRequest = (url, resourceType) => {
2038
2037
  // this handles when a style is switched
2039
2038
  if (resourceType === 'Style' && isRadarStyle(url)) {
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
@@ -59,10 +59,12 @@ export interface RadarTrackVerifiedParams {
59
59
  description?: string;
60
60
  metadata?: RadarMetadata;
61
61
  skipVerifyApp?: boolean;
62
+ ipChanges?: boolean;
62
63
  }
63
64
  export interface RadarStartTrackingVerifiedParams {
64
65
  interval: number;
65
66
  skipVerifyApp?: boolean;
67
+ ipChanges?: boolean;
66
68
  }
67
69
  export declare enum RadarEventConfidence {
68
70
  none = 0,
@@ -147,6 +149,7 @@ export interface RadarUser {
147
149
  dma?: RadarRegion;
148
150
  postalCode?: RadarRegion;
149
151
  fraud?: RadarFraud;
152
+ ip?: string;
150
153
  }
151
154
  export interface RadarTrackResponse extends RadarResponse {
152
155
  location?: Location;
package/dist/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- declare const _default: "4.4.9";
1
+ declare const _default: "4.4.10-beta.0";
2
2
  export default _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "radar-sdk-js",
3
- "version": "4.4.9",
3
+ "version": "4.4.10-beta.0",
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
@@ -89,7 +89,6 @@ class TrackAPI {
89
89
  let response: any;
90
90
  if (fraud) {
91
91
  const host = 'https://api-verified.radar.io';
92
- const pingHost = 'ping.radar-verify.com';
93
92
 
94
93
  const lang = navigator.language;
95
94
  const langs = navigator.languages;
@@ -109,31 +108,9 @@ class TrackAPI {
109
108
  },
110
109
  });
111
110
 
112
- let sclVal = -1;
113
- let cslVal = -1;
114
- /*
115
- try {
116
- const [sclRes, csl] = await Promise.all([
117
- Http.request({
118
- host: `https://${pingHost}`,
119
- method: 'GET',
120
- path: 'ping',
121
- }),
122
- ping(`wss://${pingHost}`),
123
- ]);
124
- const { scl }: any = sclRes;
125
- sclVal = scl;
126
- cslVal = csl;
127
- } catch (err) {
128
- // do nothing, send scl = -1 and csl = -1
129
- }
130
- */
131
-
132
111
  const payload = {
133
112
  payload: JSON.stringify({
134
113
  ...body,
135
- scl: sclVal,
136
- csl: cslVal,
137
114
  lang,
138
115
  langs,
139
116
  }),
@@ -153,17 +130,6 @@ class TrackAPI {
153
130
  },
154
131
  });
155
132
 
156
- if (options.debug && response && response.user) {
157
- if (!response.user.metadata) {
158
- response.user.metadata = {};
159
- }
160
-
161
- response.user.metadata['radar:debug'] = {
162
- sclVal,
163
- cslVal,
164
- };
165
- }
166
-
167
133
  let { user, events, token, expiresAt, expiresIn, passed, failureReasons, _id } = response;
168
134
  const location = { latitude, longitude, accuracy };
169
135
  if (expiresAt) {
package/src/api/verify.ts CHANGED
@@ -15,8 +15,27 @@ let lastToken: RadarTrackVerifiedResponse | null = null;
15
15
  let lastTokenNow: number = 0;
16
16
  let expectedCountryCode: string | null = null;
17
17
  let expectedStateCode: string | null = null;
18
+ let lastIp: string | null = null;
18
19
 
19
20
  class VerifyAPI {
21
+ static async checkIpChanges() {
22
+ const { ip }: any = await Http.request({
23
+ method: 'GET',
24
+ path: 'ping',
25
+ });
26
+
27
+ const ipChanged = ip !== lastIp;
28
+ if (ipChanged) {
29
+ Logger.info(`IP changed from ${lastIp} to ${ip}`);
30
+
31
+ lastToken = null;
32
+ }
33
+
34
+ lastIp = ip;
35
+
36
+ return ipChanged;
37
+ }
38
+
20
39
  static async trackVerified(params: RadarTrackVerifiedParams, encrypted: Boolean = false) {
21
40
  const options = Config.get();
22
41
 
@@ -104,6 +123,11 @@ class VerifyAPI {
104
123
  }
105
124
  }
106
125
 
126
+ if (params.ipChanges && trackRes?.user?.ip) {
127
+ lastIp = trackRes?.user?.ip;
128
+ Logger.info(`Setting ip to ${lastIp}`);
129
+ }
130
+
107
131
  lastToken = trackRes;
108
132
  lastTokenNow = performance.now();
109
133
 
@@ -115,6 +139,12 @@ class VerifyAPI {
115
139
  }
116
140
 
117
141
  static async startTrackingVerified(params: RadarStartTrackingVerifiedParams) {
142
+ let { interval } = params;
143
+ if (!interval) {
144
+ interval = 60;
145
+ Logger.info(`interval not provided, using 60 seconds`);
146
+ }
147
+
118
148
  const doTrackVerified = async () => {
119
149
  let trackRes;
120
150
  try {
@@ -122,8 +152,6 @@ class VerifyAPI {
122
152
  } catch (err: any) {
123
153
  Logger.error(`trackVerified error: ${err.message}`);
124
154
  }
125
-
126
- const { interval } = params;
127
155
 
128
156
  let expiresIn = 0;
129
157
  let minInterval = interval;
@@ -164,6 +192,10 @@ class VerifyAPI {
164
192
  static async getVerifiedLocationToken(params: RadarTrackVerifiedParams) {
165
193
  const lastTokenElapsed = (performance.now() - lastTokenNow) / 1000;
166
194
 
195
+ if (params.ipChanges) {
196
+ await this.checkIpChanges();
197
+ }
198
+
167
199
  if (lastToken && lastToken.passed) {
168
200
  if (lastTokenElapsed < (lastToken.expiresIn || 0)) {
169
201
  return lastToken;
package/src/types.ts CHANGED
@@ -81,11 +81,13 @@ export interface RadarTrackVerifiedParams {
81
81
  description?: string;
82
82
  metadata?: RadarMetadata;
83
83
  skipVerifyApp?: boolean;
84
+ ipChanges?: boolean;
84
85
  }
85
86
 
86
87
  export interface RadarStartTrackingVerifiedParams {
87
88
  interval: number;
88
89
  skipVerifyApp?: boolean;
90
+ ipChanges?: boolean;
89
91
  }
90
92
 
91
93
  export enum RadarEventConfidence {
@@ -217,6 +219,7 @@ export interface RadarUser {
217
219
  dma?: RadarRegion;
218
220
  postalCode?: RadarRegion;
219
221
  fraud?: RadarFraud;
222
+ ip?: string;
220
223
  }
221
224
 
222
225
  export interface RadarTrackResponse extends RadarResponse {
@@ -12,7 +12,6 @@ class RadarLogoControl {
12
12
  this.link.id = 'radar-map-logo';
13
13
  this.link.href = 'https://radar.com?ref=powered_by_radar';
14
14
  this.link.target = '_blank';
15
- this.link.style.pointerEvents = "auto";
16
15
  this.link.appendChild(img);
17
16
 
18
17
  return this.link;
@@ -96,7 +96,7 @@ class RadarMap extends maplibregl.Map {
96
96
  radarMapOptions,
97
97
  { style },
98
98
  );
99
- Logger.debug('map initailized with options', mapOptions);
99
+ Logger.debug('map initialized with options', mapOptions);
100
100
 
101
101
  (mapOptions as maplibregl.MapOptions).transformRequest = (url, resourceType) => {
102
102
  // this handles when a style is switched
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export default '4.4.9';
1
+ export default '4.4.10-beta.0';