radar-sdk-js 5.0.0 → 5.1.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
@@ -46,10 +46,8 @@ Then import and initialize:
46
46
  ```js
47
47
  import Radar from 'radar-sdk-js';
48
48
 
49
- // initialize with your test or live publishable key
50
- Radar.initialize('prj_test_pk_...', {
51
- /* options */
52
- });
49
+ // initialize with your publishable key
50
+ Radar.initialize({ publishableKey: 'prj_test_pk_...' });
53
51
  ```
54
52
 
55
53
  ### With a script tag
@@ -57,12 +55,10 @@ Radar.initialize('prj_test_pk_...', {
57
55
  Add the following to your HTML:
58
56
 
59
57
  ```html
60
- <script src="https://js.radar.com/v5.0.0/radar.min.js"></script>
58
+ <script src="https://js.radar.com/v5.1.0/radar.min.js"></script>
61
59
 
62
60
  <script>
63
- Radar.initialize('prj_test_pk_...', {
64
- /* options */
65
- });
61
+ Radar.initialize({ publishableKey: 'prj_test_pk_...' });
66
62
  </script>
67
63
  ```
68
64
 
@@ -84,7 +80,7 @@ import { createMapsPlugin } from '@radarlabs/plugin-maps';
84
80
  import '@radarlabs/plugin-maps/dist/radar-maps.css';
85
81
 
86
82
  Radar.registerPlugin(createMapsPlugin());
87
- Radar.initialize('prj_test_pk_...');
83
+ Radar.initialize({ publishableKey: 'prj_test_pk_...' });
88
84
 
89
85
  const map = Radar.ui.map({
90
86
  container: 'map',
@@ -103,7 +99,7 @@ import { createAutocompletePlugin } from '@radarlabs/plugin-autocomplete';
103
99
  import '@radarlabs/plugin-autocomplete/dist/radar-autocomplete.css';
104
100
 
105
101
  Radar.registerPlugin(createAutocompletePlugin());
106
- Radar.initialize('prj_test_pk_...');
102
+ Radar.initialize({ publishableKey: 'prj_test_pk_...' });
107
103
 
108
104
  Radar.ui.autocomplete({
109
105
  container: 'autocomplete',
@@ -124,7 +120,7 @@ import Radar from 'radar-sdk-js';
124
120
  import { createFraudPlugin } from '@radarlabs/plugin-fraud';
125
121
 
126
122
  Radar.registerPlugin(createFraudPlugin());
127
- Radar.initialize('prj_live_pk_...');
123
+ Radar.initialize({ publishableKey: 'prj_live_pk_...' });
128
124
 
129
125
  const { token, user, events } = await Radar.fraud.trackVerified();
130
126
  ```
@@ -136,11 +132,11 @@ the core SDK first, then any plugins you need:
136
132
 
137
133
  ```html
138
134
  <link href="https://js.radar.com/maps/v1.0.0/radar-maps.css" rel="stylesheet" />
139
- <link href="https://js.radar.com/autocomplete/v1.0.0/radar-autocomplete.css" rel="stylesheet" />
135
+ <link href="https://js.radar.com/autocomplete/v1.1.0/radar-autocomplete.css" rel="stylesheet" />
140
136
 
141
- <script src="https://js.radar.com/v5.0.0/radar.min.js"></script>
137
+ <script src="https://js.radar.com/v5.1.0/radar.min.js"></script>
142
138
  <script src="https://js.radar.com/maps/v1.0.0/radar-maps.min.js"></script>
143
- <script src="https://js.radar.com/autocomplete/v1.0.0/radar-autocomplete.min.js"></script>
139
+ <script src="https://js.radar.com/autocomplete/v1.1.0/radar-autocomplete.min.js"></script>
144
140
  <script src="https://js.radar.com/fraud/v1.0.0/radar-fraud.min.js"></script>
145
141
  ```
146
142
 
@@ -155,7 +151,7 @@ by ID or element reference.
155
151
  <html>
156
152
  <head>
157
153
  <link href="https://js.radar.com/maps/v1.0.0/radar-maps.css" rel="stylesheet" />
158
- <script src="https://js.radar.com/v5.0.0/radar.min.js"></script>
154
+ <script src="https://js.radar.com/v5.1.0/radar.min.js"></script>
159
155
  <script src="https://js.radar.com/maps/v1.0.0/radar-maps.min.js"></script>
160
156
  </head>
161
157
 
@@ -163,7 +159,7 @@ by ID or element reference.
163
159
  <div id="map" style="width: 100%; height: 500px;" />
164
160
 
165
161
  <script>
166
- Radar.initialize('<RADAR_PUBLISHABLE_KEY>');
162
+ Radar.initialize({ publishableKey: '<RADAR_PUBLISHABLE_KEY>' });
167
163
 
168
164
  const map = Radar.ui.map({
169
165
  container: 'map', // OR document.getElementById('map')
@@ -181,16 +177,16 @@ by ID or element reference.
181
177
  ```html
182
178
  <html>
183
179
  <head>
184
- <link href="https://js.radar.com/autocomplete/v1.0.0/radar-autocomplete.css" rel="stylesheet" />
185
- <script src="https://js.radar.com/v5.0.0/radar.min.js"></script>
186
- <script src="https://js.radar.com/autocomplete/v1.0.0/radar-autocomplete.min.js"></script>
180
+ <link href="https://js.radar.com/autocomplete/v1.1.0/radar-autocomplete.css" rel="stylesheet" />
181
+ <script src="https://js.radar.com/v5.1.0/radar.min.js"></script>
182
+ <script src="https://js.radar.com/autocomplete/v1.1.0/radar-autocomplete.min.js"></script>
187
183
  </head>
188
184
 
189
185
  <body>
190
186
  <div id="autocomplete" />
191
187
 
192
188
  <script>
193
- Radar.initialize('<RADAR_PUBLISHABLE_KEY>');
189
+ Radar.initialize({ publishableKey: '<RADAR_PUBLISHABLE_KEY>' });
194
190
 
195
191
  // create autocomplete widget
196
192
  Radar.ui.autocomplete({
@@ -215,12 +211,12 @@ are needed for geofencing.
215
211
  ```html
216
212
  <html>
217
213
  <head>
218
- <script src="https://js.radar.com/v5.0.0/radar.min.js"></script>
214
+ <script src="https://js.radar.com/v5.1.0/radar.min.js"></script>
219
215
  </head>
220
216
 
221
217
  <body>
222
218
  <script>
223
- Radar.initialize('<RADAR_PUBLISHABLE_KEY>');
219
+ Radar.initialize({ publishableKey: '<RADAR_PUBLISHABLE_KEY>' });
224
220
 
225
221
  Radar.trackOnce({ userId: 'example-user-id' }).then(({ location, user, events }) => {
226
222
  // do something with user location or events
@@ -254,7 +250,7 @@ import { createFraudPlugin } from '@radarlabs/plugin-fraud';
254
250
  Radar.registerPlugin(createMapsPlugin());
255
251
  Radar.registerPlugin(createAutocompletePlugin());
256
252
  Radar.registerPlugin(createFraudPlugin());
257
- Radar.initialize('prj_test_pk_...');
253
+ Radar.initialize({ publishableKey: 'prj_test_pk_...' });
258
254
  ```
259
255
 
260
256
  If you're building a custom plugin, import the plugin types from the
package/dist/api.d.ts CHANGED
@@ -1,13 +1,13 @@
1
1
  import * as errors from './errors';
2
2
  import type { RadarError } from './errors';
3
3
  import type { RadarPlugin } from './plugin';
4
- import type { Location, NavigatorPosition, RadarAutocompleteParams, RadarAutocompleteResponse, RadarContextResponse, RadarConversionParams, RadarConversionResponse, RadarDistanceParams, RadarForwardGeocodeParams, RadarGeocodeResponse, RadarIPGeocodeResponse, RadarMatrixParams, RadarMatrixResponse, RadarMetadata, RadarOptions, RadarReverseGeocodeParams, RadarRouteResponse, RadarSearchGeofencesParams, RadarSearchGeofencesResponse, RadarSearchPlacesParams, RadarSearchPlacesResponse, RadarTrackParams, RadarTrackResponse, RadarTripOptions, RadarTripResponse, RadarValidateAddressParams, RadarValidateAddressResponse } from './types';
4
+ import type { Location, NavigatorPosition, RadarAutocompleteParams, RadarAutocompleteResponse, RadarContextResponse, RadarConversionParams, RadarConversionResponse, RadarDistanceParams, RadarForwardGeocodeParams, RadarGeocodeResponse, RadarIPGeocodeResponse, RadarMatrixParams, RadarMatrixResponse, RadarMetadata, RadarInitOptions, RadarOptions, RadarReverseGeocodeParams, RadarRouteResponse, RadarSearchGeofencesParams, RadarSearchGeofencesResponse, RadarSearchPlacesParams, RadarSearchPlacesResponse, RadarTrackParams, RadarTrackResponse, RadarTripOptions, RadarTripResponse, RadarValidateAddressParams, RadarValidateAddressResponse } from './types';
5
5
  /**
6
6
  * main entry point for the Radar SDK. all methods are static — do not instantiate.
7
7
  *
8
8
  * @example
9
9
  * ```ts
10
- * Radar.initialize('prj_test_pk_...');
10
+ * Radar.initialize({ publishableKey: 'prj_test_pk_...' });
11
11
  * const { user, events } = await Radar.trackOnce();
12
12
  * ```
13
13
  */
@@ -20,7 +20,13 @@ declare class Radar {
20
20
  static registerPlugin(...plugins: RadarPlugin[]): void;
21
21
  private static _getPluginContext;
22
22
  /**
23
- * initialize the SDK with a publishable key. must be called before any other method.
23
+ * initialize the SDK with an authToken or publishable key via options object.
24
+ * @param options - SDK configuration with `authToken` or `publishableKey`
25
+ * @throws {RadarPublishableKeyError} if credentials are missing or invalid
26
+ */
27
+ static initialize(options: RadarInitOptions): void;
28
+ /**
29
+ * initialize the SDK with a publishable key string.
24
30
  * @param publishableKey - your Radar publishable key (starts with `prj_test_pk_` or `prj_live_pk_`)
25
31
  * @param options - optional SDK configuration
26
32
  * @throws {RadarPublishableKeyError} if the key is missing or is a secret key
package/dist/config.d.ts CHANGED
@@ -24,5 +24,9 @@ declare class Config {
24
24
  static onError(callback: (error: RadarError) => void): void;
25
25
  /** dispatch an error to the registered callback */
26
26
  static sendError(error: any): void;
27
+ /** build standard Radar request headers (Authorization, Device-Type, SDK-Version).
28
+ * Callers must ensure credentials are set before calling (e.g. via Radar.initialize).
29
+ * */
30
+ static getDefaultHeaders(): Record<string, string>;
27
31
  }
28
32
  export default Config;
package/dist/http.d.ts CHANGED
@@ -43,7 +43,7 @@ declare class Http {
43
43
  * send an HTTP request to the Radar API
44
44
  * @param options - request configuration
45
45
  * @returns parsed response body, typed as `T`
46
- * @throws {RadarPublishableKeyError} if publishable key is not set
46
+ * @throws {RadarPublishableKeyError} if neither publishable key nor authToken is set
47
47
  * @throws {RadarBadRequestError} on 400 responses
48
48
  * @throws {RadarUnauthorizedError} on 401 responses
49
49
  * @throws {RadarNetworkError} on network failures
package/dist/radar.js CHANGED
@@ -1,3 +1,5 @@
1
+ var SDK_VERSION = '5.1.0';
2
+
1
3
  /** global SDK configuration singleton */
2
4
  class Config {
3
5
  /** store SDK options (called by Radar.initialize) */
@@ -23,6 +25,26 @@ class Config {
23
25
  Config.errorCallback(error);
24
26
  }
25
27
  }
28
+ /** build standard Radar request headers (Authorization, Device-Type, SDK-Version).
29
+ * Callers must ensure credentials are set before calling (e.g. via Radar.initialize).
30
+ * */
31
+ static getDefaultHeaders() {
32
+ const { publishableKey, authToken, getRequestHeaders: getHeaders } = Config.get();
33
+ const headers = {
34
+ 'X-Radar-Device-Type': 'Web',
35
+ 'X-Radar-SDK-Version': SDK_VERSION,
36
+ };
37
+ if (authToken) {
38
+ headers.Authorization = `Bearer ${authToken}`;
39
+ }
40
+ else if (publishableKey) {
41
+ headers.Authorization = publishableKey;
42
+ }
43
+ if (typeof getHeaders === 'function') {
44
+ Object.assign(headers, getHeaders());
45
+ }
46
+ return headers;
47
+ }
26
48
  }
27
49
  /** registered error callback, if any */
28
50
  Config.errorCallback = null;
@@ -180,17 +202,11 @@ const LOG_LEVELS = {
180
202
  // get the numeric level for logLevel option
181
203
  const getLevel = () => {
182
204
  // disable logging in tests
183
- if (window && window.RADAR_TEST_ENV) {
205
+ if (typeof window !== 'undefined' && window.RADAR_TEST_ENV) {
184
206
  return LOG_LEVELS.none;
185
207
  }
186
- const { logLevel, debug } = Config.get();
187
- if (debug) {
188
- return LOG_LEVELS.debug;
189
- }
190
- if (logLevel) {
191
- return LOG_LEVELS[logLevel];
192
- }
193
- return LOG_LEVELS.error; // default to error-level logging if not set
208
+ const { logLevel } = Config.get();
209
+ return logLevel ? LOG_LEVELS[logLevel] : LOG_LEVELS.error;
194
210
  };
195
211
  /** leveled console logger controlled by SDK config */
196
212
  class Logger {
@@ -451,8 +467,6 @@ class Navigator {
451
467
  }
452
468
  }
453
469
 
454
- var SDK_VERSION = '5.0.0';
455
-
456
470
  const inFlightRequests = new Map();
457
471
  /** fetch-based HTTP client for Radar API requests */
458
472
  class Http {
@@ -466,9 +480,9 @@ class Http {
466
480
  }
467
481
  static async request({ method, path, data, host, version, headers = {}, responseType, requestId, }) {
468
482
  const options = Config.get();
469
- const publishableKey = options.publishableKey;
470
- if (!publishableKey) {
471
- throw new RadarPublishableKeyError('publishableKey not set.');
483
+ const { publishableKey, authToken } = options;
484
+ if (!publishableKey && !authToken) {
485
+ throw new RadarPublishableKeyError('publishableKey or authToken not set.');
472
486
  }
473
487
  const urlHost = host || options.host;
474
488
  const urlVersion = version || options.version;
@@ -494,17 +508,11 @@ class Http {
494
508
  if (requestId) {
495
509
  inFlightRequests.set(requestId, abortController);
496
510
  }
497
- const defaultHeaders = {
498
- Authorization: publishableKey,
511
+ const allHeaders = {
499
512
  'Content-Type': 'application/json',
500
- 'X-Radar-Device-Type': 'Web',
501
- 'X-Radar-SDK-Version': SDK_VERSION,
513
+ ...Config.getDefaultHeaders(),
514
+ ...headers,
502
515
  };
503
- let configHeaders = {};
504
- if (typeof options.getRequestHeaders === 'function') {
505
- configHeaders = options.getRequestHeaders();
506
- }
507
- const allHeaders = { ...defaultHeaders, ...configHeaders, ...headers };
508
516
  let response;
509
517
  try {
510
518
  response = await fetch(url, {
@@ -1351,12 +1359,20 @@ class TrackAPI {
1351
1359
 
1352
1360
  const isSecretKey = (key) => key.includes('_sk_');
1353
1361
  const isLiveKey = (key) => key.includes('_live_');
1362
+ const isJWTShape = (value) => {
1363
+ // NOTE(jasonl): keep this check lightweight since we're doing real validation server-side
1364
+ if (!value.startsWith('eyJ')) {
1365
+ return false;
1366
+ }
1367
+ const parts = value.split('.');
1368
+ return parts.length === 3 && parts.every((s) => s.length > 0);
1369
+ };
1354
1370
  /**
1355
1371
  * main entry point for the Radar SDK. all methods are static — do not instantiate.
1356
1372
  *
1357
1373
  * @example
1358
1374
  * ```ts
1359
- * Radar.initialize('prj_test_pk_...');
1375
+ * Radar.initialize({ publishableKey: 'prj_test_pk_...' });
1360
1376
  * const { user, events } = await Radar.trackOnce();
1361
1377
  * ```
1362
1378
  */
@@ -1400,34 +1416,38 @@ class Radar {
1400
1416
  },
1401
1417
  };
1402
1418
  }
1403
- /**
1404
- * initialize the SDK with a publishable key. must be called before any other method.
1405
- * @param publishableKey - your Radar publishable key (starts with `prj_test_pk_` or `prj_live_pk_`)
1406
- * @param options - optional SDK configuration
1407
- * @throws {RadarPublishableKeyError} if the key is missing or is a secret key
1408
- */
1409
- static initialize(publishableKey, options = {}) {
1410
- if (!publishableKey) {
1411
- throw new RadarPublishableKeyError('Publishable key required in initialization.');
1412
- }
1413
- if (isSecretKey(publishableKey)) {
1414
- throw new RadarPublishableKeyError('Secret keys are not allowed. Please use your Radar publishable key.');
1415
- }
1416
- // store settings in global config
1417
- const live = isLiveKey(publishableKey);
1418
- const logLevel = live ? 'error' : 'info';
1419
- const debug = !live;
1420
- const radarOptions = Object.assign(Config.defaultOptions, {
1421
- publishableKey,
1422
- live,
1423
- logLevel,
1424
- debug,
1425
- }, options);
1426
- Config.setup(radarOptions);
1427
- Logger.info(`initialized with ${live ? 'live' : 'test'} publishableKey.`);
1428
- if (options.debug) {
1429
- Logger.debug('using options', options);
1419
+ static initialize(publishableKeyOrOptions, extraOptions = {}) {
1420
+ // NOTE(jasonl): shim the string signature into the options object to handle both cases
1421
+ const options = typeof publishableKeyOrOptions === 'string'
1422
+ ? { publishableKey: publishableKeyOrOptions, ...extraOptions }
1423
+ : { ...publishableKeyOrOptions };
1424
+ if (options.publishableKey && options.authToken) {
1425
+ throw new RadarPublishableKeyError('Token and publishableKey are mutually exclusive.');
1426
+ }
1427
+ let credentialLabel;
1428
+ if (options.publishableKey) {
1429
+ if (isSecretKey(options.publishableKey)) {
1430
+ throw new RadarPublishableKeyError('Secret keys are not allowed. Please use your Radar publishable key.');
1431
+ }
1432
+ options.live = isLiveKey(options.publishableKey);
1433
+ credentialLabel = 'publishableKey';
1434
+ }
1435
+ else if (options.authToken) {
1436
+ if (!isJWTShape(options.authToken)) {
1437
+ throw new RadarPublishableKeyError('Invalid authToken format. Expected a JWT.');
1438
+ }
1439
+ credentialLabel = 'authToken';
1430
1440
  }
1441
+ else {
1442
+ throw new RadarPublishableKeyError('Publishable key or authToken required in initialization.');
1443
+ }
1444
+ // NOTE(jasonl): for backwards compat with the old `live` option - if `debug` isn't explicitly set, we'll set it to the inverse of `live`
1445
+ options.debug = options.debug ?? (options.live !== undefined ? !options.live : false);
1446
+ options.logLevel = options.logLevel ?? (options.debug ? 'debug' : 'error');
1447
+ const radarOptions = Object.assign({}, Config.defaultOptions, options);
1448
+ Config.setup(radarOptions);
1449
+ Logger.info(`initialized with ${credentialLabel}.`);
1450
+ Logger.debug('using options', options);
1431
1451
  // NOTE(jasonl): this allows us to run jest tests
1432
1452
  // without having to mock the ConfigAPI.getConfig call
1433
1453
  if (!window?.RADAR_TEST_ENV) {
package/dist/radar.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"radar.js","sources":["../src/config.ts","../src/errors.ts","../src/logger.ts","../src/storage.ts","../src/navigator.ts","../src/version.ts","../src/http.ts","../src/api/addresses.ts","../src/device.ts","../src/session.ts","../src/api/config.ts","../src/api/context.ts","../src/api/conversions.ts","../src/api/geocoding.ts","../src/api/routing.ts","../src/api/search.ts","../src/api/trips.ts","../src/api/track.ts","../src/api.ts"],"sourcesContent":["import type { RadarError } from './errors';\nimport type { RadarOptions } from './types';\n\n/** global SDK configuration singleton */\nclass Config {\n /** current SDK options */\n static options: RadarOptions;\n /** registered error callback, if any */\n static errorCallback: ((error: RadarError) => void) | null = null;\n\n /** default option values applied during initialization */\n static defaultOptions = {\n live: false,\n logLevel: 'error',\n host: 'https://api.radar.io',\n version: 'v1',\n debug: false,\n };\n\n /** store SDK options (called by Radar.initialize) */\n public static setup(options: RadarOptions = {}) {\n Config.options = options;\n }\n\n /** get the current SDK options */\n public static get(): RadarOptions {\n return Config.options || {};\n }\n\n /** clear all SDK options and error callback */\n public static clear() {\n Config.options = {};\n Config.errorCallback = null;\n }\n\n /** register a callback invoked on SDK errors */\n public static onError(callback: (error: RadarError) => void) {\n Config.errorCallback = callback;\n }\n\n /** dispatch an error to the registered callback */\n public static sendError(error: any) {\n if (Config.errorCallback && error) {\n Config.errorCallback(error);\n }\n }\n}\n\nexport default Config;\n","import type { RadarResponse } from './http';\n\n/** base error class for all Radar SDK errors */\nexport abstract class RadarError extends Error {\n /** legacy status code string (e.g. `'ERROR_PUBLISHABLE_KEY'`) */\n public abstract readonly status: string;\n public abstract readonly name: string;\n\n constructor(message: string) {\n super(message);\n }\n}\n\n/** thrown when a publishable key is missing or invalid (e.g. secret key used) */\nexport class RadarPublishableKeyError extends RadarError {\n public override readonly name = 'RadarPublishableKeyError';\n public override readonly status = 'ERROR_PUBLISHABLE_KEY';\n\n constructor(message: string) {\n super(message);\n }\n}\n\n/** thrown when the device location cannot be determined */\nexport class RadarLocationError extends RadarError {\n public override readonly name = 'RadarLocationError';\n public override readonly status = 'ERROR_LOCATION';\n\n constructor(message: string) {\n super(message);\n }\n}\n\n/** thrown when location permissions are denied by the browser */\nexport class RadarPermissionsError extends RadarError {\n public override readonly name = 'RadarPermissionsError';\n public override readonly status = 'ERROR_PERMISSIONS';\n\n constructor(message: string) {\n super(message);\n }\n}\n\n/** thrown on HTTP 400 Bad Request responses */\nexport class RadarBadRequestError extends RadarError {\n public override readonly name = 'RadarBadRequestError';\n public override readonly status = 'ERROR_BAD_REQUEST';\n public readonly code = 400;\n public readonly response?: RadarResponse;\n\n constructor(response?: RadarResponse) {\n super(response?.meta?.message || 'Bad request.');\n\n this.response = response;\n }\n}\n\n/** thrown on HTTP 401 Unauthorized responses */\nexport class RadarUnauthorizedError extends RadarError {\n public override readonly name = 'RadarUnauthorizedError';\n public override readonly status = 'ERROR_UNAUTHORIZED';\n public readonly code = 401;\n public readonly response?: RadarResponse;\n\n constructor(response?: RadarResponse) {\n super(response?.meta?.message || 'Unauthorized.');\n\n this.response = response;\n }\n}\n\n/** thrown on HTTP 402 Payment Required responses */\nexport class RadarPaymentRequiredError extends RadarError {\n public override readonly name = 'RadarPaymentRequiredError';\n public override readonly status = 'ERROR_PAYMENT_REQUIRED';\n public readonly code = 402;\n public readonly response?: RadarResponse;\n\n constructor(response?: RadarResponse) {\n super(response?.meta?.message || 'Payment required.');\n\n this.response = response;\n }\n}\n\n/** thrown on HTTP 403 Forbidden responses */\nexport class RadarForbiddenError extends RadarError {\n public override readonly name = 'RadarForbiddenError';\n public override readonly status = 'ERROR_FORBIDDEN';\n public readonly code = 403;\n public readonly response?: RadarResponse;\n\n constructor(response?: RadarResponse) {\n super(response?.meta?.message || 'Forbidden.');\n\n this.response = response;\n }\n}\n\n/** thrown on HTTP 404 Not Found responses */\nexport class RadarNotFoundError extends RadarError {\n public override readonly name = 'RadarNotFoundError';\n public override readonly status = 'ERROR_NOT_FOUND';\n public readonly code = 404;\n public readonly response?: RadarResponse;\n\n constructor(response?: RadarResponse) {\n super(response?.meta?.message || 'Not found.');\n\n this.response = response;\n }\n}\n\n/** thrown on HTTP 429 Rate Limit responses */\nexport class RadarRateLimitError extends RadarError {\n public override readonly name = 'RadarRateLimitError';\n public override readonly status = 'ERROR_RATE_LIMIT';\n public readonly code = 429;\n public readonly response?: RadarResponse;\n /** rate limit type from the API response (e.g. `'hourly'`) */\n public readonly type?: string;\n\n constructor(response?: RadarResponse) {\n super(response?.meta?.message || 'Rate limit exceeded.');\n\n this.response = response;\n this.type = response?.meta?.type;\n }\n}\n\n/** thrown on HTTP 5xx server errors */\nexport class RadarServerError extends RadarError {\n public override readonly name = 'RadarServerError';\n public override readonly status = 'ERROR_SERVER';\n public readonly response?: RadarResponse;\n\n constructor(response?: RadarResponse) {\n super(response?.meta?.message || 'Internal server error.');\n\n this.response = response;\n }\n}\n\n/** thrown when a request times out or the network is unavailable */\nexport class RadarNetworkError extends RadarError {\n public override readonly name = 'RadarNetworkError';\n public override readonly status = 'ERROR_NETWORK';\n\n constructor() {\n super('Request timed out.');\n }\n}\n\n/** thrown for unexpected/unclassified errors */\nexport class RadarUnknownError extends RadarError {\n public override readonly name = 'RadarUnknownError';\n public override readonly status = 'ERROR_UNKNOWN';\n public readonly response?: RadarResponse;\n\n constructor(response?: RadarResponse) {\n super(response?.meta?.message || 'Something went wrong.');\n\n this.response = response;\n }\n}\n","import Config from './config';\n\nconst LOG_LEVELS = {\n none: 0,\n error: 1,\n warn: 2,\n info: 3,\n debug: 4,\n};\n\n// get the numeric level for logLevel option\nconst getLevel = (): number => {\n // disable logging in tests\n if (window && window.RADAR_TEST_ENV) {\n return LOG_LEVELS.none;\n }\n\n const { logLevel, debug } = Config.get();\n if (debug) {\n return LOG_LEVELS.debug;\n }\n if (logLevel) {\n return LOG_LEVELS[logLevel];\n }\n return LOG_LEVELS.error; // default to error-level logging if not set\n};\n\n/** leveled console logger controlled by SDK config */\nclass Logger {\n /** log a debug-level message (only when debug mode is enabled) */\n public static debug(message: string, options?: any) {\n if (getLevel() === LOG_LEVELS.debug) {\n console.log(`Radar SDK (debug): ${message.trim()}`, options);\n }\n }\n\n /** log an info-level message */\n public static info(message: string) {\n if (getLevel() >= LOG_LEVELS.info) {\n console.log(`Radar SDK: ${message.trim()}`);\n }\n }\n\n /** log a warning-level message */\n public static warn(message: string) {\n if (getLevel() >= LOG_LEVELS.warn) {\n console.warn(`Radar SDK: ${message.trim()}`);\n }\n }\n\n /** log an error-level message */\n public static error(message: string) {\n if (getLevel() >= LOG_LEVELS.error) {\n console.error(`Radar SDK: ${message.trim()}`);\n }\n }\n}\n\nexport default Logger;\n","import Logger from './logger';\n\n/** typed localStorage wrapper with `radar-*` namespaced keys */\nclass Storage {\n /** localStorage key for user ID */\n public static get USER_ID() {\n return 'radar-userId';\n }\n /** localStorage key for device ID */\n public static get DEVICE_ID() {\n return 'radar-deviceId';\n }\n /** localStorage key for install ID */\n public static get INSTALL_ID() {\n return 'radar-installId';\n }\n /** localStorage key for session ID */\n public static get SESSION_ID() {\n return 'radar-sessionId';\n }\n /** localStorage key for user description */\n public static get DESCRIPTION() {\n return 'radar-description';\n }\n /** localStorage key for user metadata */\n public static get METADATA() {\n return 'radar-metadata';\n }\n /** localStorage key for cached location */\n public static get CACHED_LOCATION() {\n return 'radar-cached-location';\n }\n /** localStorage key for trip options */\n public static get TRIP_OPTIONS() {\n return 'radar-trip-options';\n }\n\n /** localStorage key for product identifier */\n public static get PRODUCT() {\n return 'radar-product';\n }\n\n /** @internal get the underlying localStorage instance */\n private static getStorage() {\n const storage = window?.localStorage;\n if (!storage) {\n Logger.warn('localStorage not available.');\n }\n return storage;\n }\n\n /**\n * store a string value in localStorage\n * @param key - the storage key\n * @param value - the string value to store\n */\n public static setItem(key: string, value: string) {\n const storage = this.getStorage();\n if (!storage) {\n return;\n }\n if (value === undefined || value === null) {\n return;\n }\n storage.setItem(key, value);\n }\n\n /**\n * retrieve a string value from localStorage\n * @param key - the storage key\n * @returns the stored value, or null if not found\n */\n public static getItem(key: string) {\n const storage = this.getStorage();\n if (!storage) {\n return null;\n }\n const value = storage.getItem(key);\n if (value !== undefined && value !== null) {\n return value;\n }\n return null;\n }\n\n /**\n * retrieve and parse a JSON value from localStorage\n * @param key - the storage key\n * @returns the parsed object, or null if not found or parse fails\n */\n public static getJSON(key: string) {\n const item = this.getItem(key);\n if (!item) {\n return null;\n }\n\n try {\n return JSON.parse(item);\n } catch {\n Logger.warn(`could not getJSON from storage for key: ${key}`);\n return null;\n }\n }\n\n /**\n * remove an item from localStorage\n * @param key - the storage key to remove\n */\n public static removeItem(key: string) {\n const storage = this.getStorage();\n if (!storage) {\n return null;\n }\n storage.removeItem(key);\n }\n\n /** clear all localStorage entries */\n public static clear() {\n const storage = this.getStorage();\n if (!storage) {\n return null;\n }\n storage.clear();\n }\n}\n\nexport default Storage;\n","import Config from './config';\nimport { RadarLocationError, RadarPermissionsError } from './errors';\nimport Logger from './logger';\nimport Storage from './storage';\n\nimport type { LocationAuthorization, NavigatorPosition } from './types';\n\ninterface PositionOptionOverrides {\n desiredAccuracy?: string;\n}\n\nconst DEFAULT_POSITION_OPTIONS: PositionOptions = {\n maximumAge: 0,\n timeout: 1000 * 10, // 10 seconds\n enableHighAccuracy: true,\n};\n\n// set \"enableHighAccuracy\" for navigator only when desiredAccuracy is \"high\"\nconst useHighAccuracy = (desiredAccuracy?: string) => Boolean(desiredAccuracy === 'high');\n\n/** browser geolocation wrapper with caching and permission checks */\nclass Navigator {\n /**\n * get the device's current position via the browser geolocation API\n * @param overrides - optional accuracy overrides\n * @returns device coordinates with accuracy\n * @throws {RadarLocationError} if geolocation is unavailable or times out\n * @throws {RadarPermissionsError} if location permissions are denied\n */\n public static async getCurrentPosition(overrides: PositionOptionOverrides = {}): Promise<NavigatorPosition> {\n return new Promise((resolve, reject) => {\n const options = Config.get();\n\n if (!navigator || !navigator.geolocation) {\n return reject(new RadarLocationError('navigator.geolocation is not available.'));\n }\n\n // use cached location if available and options are set\n if (options.cacheLocationMinutes) {\n try {\n const rawCachedLocation = Storage.getItem(Storage.CACHED_LOCATION);\n if (rawCachedLocation) {\n const cachedLocation = JSON.parse(rawCachedLocation);\n const { latitude, longitude, accuracy, expiresAt } = cachedLocation || {};\n if (Date.now() < parseInt(expiresAt)) {\n if (latitude && longitude && accuracy) {\n return resolve({ latitude, longitude, accuracy });\n }\n }\n }\n } catch {\n Logger.warn('could not load cached location.');\n }\n }\n\n // set options from config\n const positionOptions = Object.assign({}, DEFAULT_POSITION_OPTIONS);\n if (options.locationMaximumAge !== undefined) {\n positionOptions.maximumAge = options.locationMaximumAge;\n }\n if (options.locationTimeout !== undefined) {\n positionOptions.timeout = options.locationTimeout;\n }\n if (options.desiredAccuracy !== undefined) {\n positionOptions.enableHighAccuracy = useHighAccuracy(options.desiredAccuracy);\n }\n\n // set options from overrides\n if (overrides.desiredAccuracy !== undefined) {\n positionOptions.enableHighAccuracy = useHighAccuracy(overrides.desiredAccuracy);\n }\n\n Logger.info(`Using geolocation options: ${JSON.stringify(positionOptions)}`);\n\n // get current location from browser\n navigator.geolocation.getCurrentPosition(\n (position) => {\n if (!position || !position.coords) {\n return reject(new RadarLocationError('device location return empty coordinates.'));\n }\n\n const { latitude, longitude, accuracy } = position.coords;\n\n // cache location if option is set\n if (options.cacheLocationMinutes) {\n const cacheLocationMinutes = Number.parseFloat(options.cacheLocationMinutes as any);\n const updatedAt = Date.now();\n const expiresAt = updatedAt + cacheLocationMinutes * 60 * 1000; // convert to ms\n\n const lastLocation = { latitude, longitude, accuracy, updatedAt, expiresAt };\n Storage.setItem(Storage.CACHED_LOCATION, JSON.stringify(lastLocation));\n }\n\n return resolve({ latitude, longitude, accuracy });\n },\n (err: GeolocationPositionError) => {\n // location call failed or user did not grant permission\n if (err && err.code === 1) {\n // https://developer.mozilla.org/en-US/docs/Web/API/GeolocationPositionError\n // code 1 means location permissions denied\n // codes 2 and 3 mean location unavailable or timeout\n return reject(new RadarPermissionsError('Location permissions denied.'));\n }\n return reject(new RadarLocationError('Could not determine location.'));\n },\n positionOptions,\n );\n });\n }\n\n /**\n * query the current geolocation permission status\n * @returns the current location authorization state\n */\n public static async getPermissionStatus(): Promise<LocationAuthorization> {\n return new Promise((resolve) => {\n let locationAuthorization: LocationAuthorization = 'NOT_DETERMINED';\n\n if (!navigator || !navigator.permissions) {\n return resolve(locationAuthorization);\n }\n\n void navigator.permissions.query({ name: 'geolocation' }).then((permissionsStatus) => {\n switch (permissionsStatus.state) {\n case 'granted':\n locationAuthorization = 'GRANTED_FOREGROUND';\n break;\n case 'denied':\n locationAuthorization = 'DENIED';\n break;\n case 'prompt':\n locationAuthorization = 'NOT_DETERMINED';\n break;\n default:\n break;\n }\n\n return resolve(locationAuthorization);\n });\n });\n }\n\n /** check whether the browser reports being online */\n public static online(): boolean {\n return navigator && navigator.onLine;\n }\n}\n\nexport default Navigator;\n","export default '5.0.0';\n","import Config from './config';\nimport {\n RadarBadRequestError,\n RadarForbiddenError,\n RadarLocationError,\n RadarNetworkError,\n RadarNotFoundError,\n RadarPaymentRequiredError,\n RadarPermissionsError,\n RadarPublishableKeyError,\n RadarRateLimitError,\n RadarServerError,\n RadarUnauthorizedError,\n RadarUnknownError,\n} from './errors';\nimport Logger from './logger';\nimport Navigator from './navigator';\nimport SDK_VERSION from './version';\n\n/** HTTP methods supported by the SDK */\ntype HttpMethod = 'GET' | 'PUT' | 'PATCH' | 'POST' | 'DELETE';\n\n/** Shape of the `meta` field present in all Radar API responses */\ninterface RadarApiMeta {\n error?: string;\n message?: string;\n type?: string;\n}\n\n/** Base shape all Radar API JSON responses share */\ninterface RadarApiResponse {\n meta?: RadarApiMeta;\n [key: string]: unknown;\n}\n\n/** Blob response shape returned when responseType is 'blob' */\ninterface RadarBlobResponse {\n meta?: undefined;\n code: number;\n data: Blob;\n}\n\nexport type RadarResponse = RadarApiResponse | RadarBlobResponse;\n\n/** Request configuration for Http.request */\ninterface HttpRequestOptions {\n method: HttpMethod;\n path: string;\n data?: Record<string, any>;\n host?: string;\n version?: string;\n headers?: Record<string, string>;\n responseType?: 'blob' | 'json';\n requestId?: string;\n}\n\nconst inFlightRequests = new Map<string, AbortController>();\n\n/** fetch-based HTTP client for Radar API requests */\nclass Http {\n /** map of host patterns to custom error factories for intercepting network errors */\n static errorInterceptors: Map<string, (online: boolean) => Error> = new Map();\n\n /**\n * register a custom error factory for network errors matching a host pattern\n * @param hostPattern - substring matched against the request host\n * @param handler - factory that receives online status and returns an error\n */\n static registerErrorInterceptor(hostPattern: string, handler: (online: boolean) => Error) {\n Http.errorInterceptors.set(hostPattern, handler);\n }\n\n /**\n * send an HTTP request to the Radar API\n * @param options - request configuration\n * @returns parsed response body, typed as `T`\n * @throws {RadarPublishableKeyError} if publishable key is not set\n * @throws {RadarBadRequestError} on 400 responses\n * @throws {RadarUnauthorizedError} on 401 responses\n * @throws {RadarNetworkError} on network failures\n */\n static async request(options: HttpRequestOptions & { responseType: 'blob' }): Promise<RadarBlobResponse>;\n static async request<T extends Record<string, any> = RadarApiResponse>(\n options: HttpRequestOptions,\n ): Promise<T & { meta?: RadarApiMeta }>;\n static async request<T extends Record<string, any> = RadarApiResponse>({\n method,\n path,\n data,\n host,\n version,\n headers = {},\n responseType,\n requestId,\n }: HttpRequestOptions): Promise<(T & { meta?: RadarApiMeta }) | RadarBlobResponse> {\n const options = Config.get();\n\n const publishableKey = options.publishableKey;\n if (!publishableKey) {\n throw new RadarPublishableKeyError('publishableKey not set.');\n }\n\n const urlHost = host || options.host;\n const urlVersion = version || options.version;\n let url = `${urlHost}/${urlVersion}/${path}`;\n\n // filter out undefined values from request data\n const filtered = Object.fromEntries(Object.entries(data ?? {}).filter(([, v]) => v !== undefined));\n\n let body: string | undefined;\n\n if (method === 'GET') {\n const params = new URLSearchParams(Object.entries(filtered).map(([k, v]) => [k, String(v)]));\n const qs = params.toString();\n if (qs) {\n url = `${url}?${qs}`;\n }\n } else {\n body = JSON.stringify(filtered);\n }\n\n // abort in-flight requests with matching requestIds\n if (requestId) {\n inFlightRequests.get(requestId)?.abort();\n }\n\n const abortController = new AbortController();\n\n if (requestId) {\n inFlightRequests.set(requestId, abortController);\n }\n\n const defaultHeaders: Record<string, string> = {\n Authorization: publishableKey,\n 'Content-Type': 'application/json',\n 'X-Radar-Device-Type': 'Web',\n 'X-Radar-SDK-Version': SDK_VERSION,\n };\n\n let configHeaders: Record<string, string> = {};\n if (typeof options.getRequestHeaders === 'function') {\n configHeaders = options.getRequestHeaders();\n }\n\n const allHeaders: Record<string, string> = { ...defaultHeaders, ...configHeaders, ...headers };\n\n let response: Response;\n try {\n response = await fetch(url, {\n method,\n headers: allHeaders,\n body,\n signal: abortController.signal,\n });\n } catch {\n // Delete abort controller instance for this request ID if it hasn't yet been replaced with a different one\n if (requestId && inFlightRequests.get(requestId) === abortController) {\n inFlightRequests.delete(requestId);\n }\n\n if (host) {\n for (const [pattern, handler] of Http.errorInterceptors) {\n if (host.includes(pattern)) {\n throw handler(!!Navigator.online());\n }\n }\n }\n throw new RadarNetworkError();\n }\n\n if (requestId && inFlightRequests.get(requestId) === abortController) {\n inFlightRequests.delete(requestId);\n }\n\n let parsed: RadarResponse | undefined;\n try {\n if (responseType === 'blob') {\n parsed = { code: response.status, data: await response.blob() };\n } else {\n parsed = (await response.json()) as RadarApiResponse;\n }\n } catch (err) {\n if (parsed) {\n throw new RadarServerError(parsed);\n } else {\n if (options.debug) {\n Logger.debug(`API call failed: ${url}`);\n Logger.debug(String(err));\n }\n\n throw new RadarUnknownError(parsed);\n }\n }\n\n if (parsed && typeof parsed === 'object' && 'meta' in parsed) {\n const error = parsed.meta?.error;\n if (error === 'ERROR_PERMISSIONS') {\n throw new RadarPermissionsError('Location permissions not granted.');\n } else if (error === 'ERROR_LOCATION') {\n throw new RadarLocationError('Could not determine location.');\n } else if (error === 'ERROR_NETWORK') {\n throw new RadarNetworkError();\n }\n }\n\n if (response.ok) {\n return parsed as T;\n }\n\n if (options.debug) {\n Logger.debug(`API call failed: ${url}`);\n Logger.debug(JSON.stringify(parsed));\n }\n\n if (response.status === 400) {\n throw new RadarBadRequestError(parsed);\n } else if (response.status === 401) {\n throw new RadarUnauthorizedError(parsed);\n } else if (response.status === 402) {\n throw new RadarPaymentRequiredError(parsed);\n } else if (response.status === 403) {\n throw new RadarForbiddenError(parsed);\n } else if (response.status === 404) {\n throw new RadarNotFoundError(parsed);\n } else if (response.status === 429) {\n throw new RadarRateLimitError(parsed);\n } else if (response.status >= 500 && response.status < 600) {\n throw new RadarServerError(parsed);\n } else {\n throw new RadarUnknownError(parsed);\n }\n }\n}\n\nexport default Http;\n","import Config from '../config';\nimport Http from '../http';\n\nimport type { RadarValidateAddressParams, RadarValidateAddressResponse } from '../types';\n\n/** @internal address validation API — use {@link Radar.validateAddress} instead */\nclass AddressesAPI {\n /**\n * validate a structured address\n * @param params - address fields to validate\n * @returns validated address and verification result\n */\n static async validateAddress(params: RadarValidateAddressParams): Promise<RadarValidateAddressResponse> {\n const options = Config.get();\n\n const response = await Http.request<Omit<RadarValidateAddressResponse, 'response'>>({\n method: 'GET',\n path: 'addresses/validate',\n data: params,\n });\n const { address, result } = response;\n\n const validateAddressRes: RadarValidateAddressResponse = {\n address,\n result,\n };\n\n if (options.debug) {\n validateAddressRes.response = response;\n }\n\n return validateAddressRes;\n }\n}\n\nexport default AddressesAPI;\n","import Storage from './storage';\n\nconst generateUUID = (): string => {\n if (typeof crypto !== 'undefined' && crypto.randomUUID) {\n return crypto.randomUUID();\n }\n\n // fallback for older browsers\n const bytes = new Uint8Array(16);\n crypto.getRandomValues(bytes);\n bytes[6] = (bytes[6]! & 0x0f) | 0x40; // version 4\n bytes[8] = (bytes[8]! & 0x3f) | 0x80; // variant 10\n\n const hex = Array.from(bytes, (b) => b.toString(16).padStart(2, '0')).join('');\n return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;\n};\n\n/** device and install ID manager backed by localStorage */\nclass Device {\n /**\n * get or generate a persistent device ID\n * @returns the device UUID (persisted in localStorage)\n */\n static getDeviceId(): string {\n // use existing deviceId if present\n const deviceId = Storage.getItem(Storage.DEVICE_ID);\n if (deviceId) {\n return deviceId;\n }\n\n // generate new deviceId\n const uuid = generateUUID();\n Storage.setItem(Storage.DEVICE_ID, uuid);\n return uuid;\n }\n\n /**\n * get or generate a persistent install ID\n * @returns the install UUID (persisted in localStorage)\n */\n static getInstallId(): string {\n // use existing installId if present\n const deviceId = Storage.getItem(Storage.INSTALL_ID);\n if (deviceId) {\n return deviceId;\n }\n\n // generate new installId\n const uuid = generateUUID();\n Storage.setItem(Storage.INSTALL_ID, uuid);\n return uuid;\n }\n}\n\nexport default Device;\n","import Storage from './storage';\n\nconst SESSION_TIMEOUT_SECS = 300; // 5 mins\n\nconst isValid = (sessionId: string): boolean => {\n const now = Math.trunc(Date.now() / 1000);\n const session = Number.parseInt(sessionId);\n const diff = Math.abs(now - session);\n return diff < SESSION_TIMEOUT_SECS;\n};\n\n/** session ID manager with a 5-minute timeout */\nclass Session {\n /**\n * get the current session ID, creating a new one if expired\n * @returns unix timestamp string used as session ID\n */\n static getSessionId() {\n const sessionId = Storage.getItem(Storage.SESSION_ID);\n\n // reuse session if still within 5 min threshold\n if (sessionId && isValid(sessionId)) {\n return sessionId;\n }\n\n // create new session if does not already exist or expired\n const newSessionId = Math.trunc(Date.now() / 1000).toString(); // unix ts in seconds\n Storage.setItem(Storage.SESSION_ID, newSessionId);\n return newSessionId;\n }\n}\n\nexport default Session;\n","import Device from '../device';\nimport Http from '../http';\nimport Logger from '../logger';\nimport Navigator from '../navigator';\nimport Session from '../session';\n\nimport type { LocationAuthorization, RadarConfigResponse, RadarTrackParams } from '../types';\n\n/** options for customizing the config request (e.g. host, headers) */\ninterface ConfigRequestOptions {\n /** override the API host */\n host?: string;\n /** additional headers to include in the request */\n headers?: Record<string, string>;\n}\n\n/** @internal SDK configuration API for fetching remote config */\nclass ConfigAPI {\n /**\n * fetch remote SDK configuration from the Radar API. Generic so plugins can extend the response shape.\n *\n * @param params - optional tracking params for device/session identification\n * @param options - optional request overrides (host, headers)\n */\n public static async getConfig<T extends RadarConfigResponse = RadarConfigResponse>(\n params: RadarTrackParams = {},\n options: ConfigRequestOptions = {},\n ): Promise<T> {\n const deviceId = params.deviceId || Device.getDeviceId();\n const installId = params.installId || Device.getInstallId();\n const sessionId = Session.getSessionId();\n\n // location authorization\n let locationAuthorization: LocationAuthorization | undefined;\n try {\n locationAuthorization = await Navigator.getPermissionStatus();\n } catch (err: any) {\n Logger.warn(`Location authorization error: ${err.message}`);\n }\n\n const data = {\n deviceId,\n installId,\n sessionId,\n locationAuthorization,\n };\n\n return Http.request<T>({\n method: 'GET',\n path: 'config',\n data,\n host: options.host,\n headers: options.headers,\n });\n }\n}\n\nexport default ConfigAPI;\n","import Config from '../config';\nimport Http from '../http';\nimport Navigator from '../navigator';\n\nimport type { RadarContextResponse, Location } from '../types';\n\n/** @internal context API — use {@link Radar.getContext} instead */\nclass ContextAPI {\n /**\n * get context (geofences, place, region) for a location\n * @param location - coordinates to get context for\n * @returns geofences, place, country, state, DMA, and postal code\n */\n public static async getContext(location: Location): Promise<RadarContextResponse> {\n const options = Config.get();\n\n // get device location if coordinates not provided\n if (!location.latitude || !location.longitude) {\n location = await Navigator.getCurrentPosition();\n }\n\n const { latitude, longitude, accuracy } = location;\n\n const response = await Http.request<Omit<RadarContextResponse, 'response' | 'location'>>({\n method: 'GET',\n path: 'context',\n data: {\n coordinates: `${latitude},${longitude}`,\n accuracy,\n },\n });\n\n const { geofences, place, country, state, dma, postalCode } = response;\n\n const contextRes: RadarContextResponse = {\n location,\n geofences,\n place,\n country,\n state,\n dma,\n postalCode,\n };\n\n if (options.debug) {\n contextRes.response = response;\n }\n\n return contextRes;\n }\n}\n\nexport default ContextAPI;\n","import Config from '../config';\nimport Device from '../device';\nimport Http from '../http';\nimport Storage from '../storage';\n\nimport type { RadarConversionParams, RadarConversionResponse } from '../types';\n\n/** @internal conversions API — use {@link Radar.logConversion} instead */\nclass ConversionsAPI {\n /**\n * log a conversion event\n * @param params - conversion name, user info, and optional metadata/revenue\n * @returns the created event\n */\n static async logConversion(params: RadarConversionParams): Promise<RadarConversionResponse> {\n const options = Config.get();\n\n const name = params.name;\n const userId = params.userId || Storage.getItem(Storage.USER_ID);\n const deviceId = params.deviceId || Device.getDeviceId();\n const installId = params.installId || Device.getInstallId();\n const metadata = params.metadata || {};\n const createdAt = params.createdAt;\n\n if (params.revenue) {\n metadata.revenue = params.revenue;\n }\n\n const createdAtValue =\n typeof createdAt === 'string'\n ? createdAt\n : createdAt instanceof Date\n ? createdAt.toISOString()\n : new Date().toISOString();\n\n const data = {\n name,\n userId,\n deviceId,\n installId,\n metadata,\n createdAt: createdAtValue,\n };\n\n const response = await Http.request<Omit<RadarConversionResponse, 'response'>>({\n method: 'POST',\n path: 'events',\n data,\n });\n\n const conversionRes: RadarConversionResponse = {\n event: response.event,\n };\n\n if (options.debug) {\n conversionRes.response = response;\n }\n\n return conversionRes;\n }\n}\n\nexport default ConversionsAPI;\n","import Config from '../config';\nimport Http from '../http';\nimport Navigator from '../navigator';\n\nimport type {\n RadarForwardGeocodeParams,\n RadarReverseGeocodeParams,\n RadarGeocodeResponse,\n RadarIPGeocodeResponse,\n} from '../types';\n\n/** @internal geocoding API — use Radar.forwardGeocode / reverseGeocode / ipGeocode instead */\nclass Geocoding {\n /**\n * geocode an address or place name to coordinates\n * @param params - query string, optional layers and country filter\n * @returns matching addresses\n */\n static async forwardGeocode(params: RadarForwardGeocodeParams): Promise<RadarGeocodeResponse> {\n const options = Config.get();\n\n const { query, layers, country, lang } = params;\n\n const response = await Http.request<Omit<RadarGeocodeResponse, 'response'>>({\n method: 'GET',\n path: 'geocode/forward',\n data: {\n query,\n layers,\n country,\n lang,\n },\n });\n\n const forwardGeocodeRes: RadarGeocodeResponse = {\n addresses: response.addresses,\n };\n\n if (options.debug) {\n forwardGeocodeRes.response = response;\n }\n\n return forwardGeocodeRes;\n }\n\n /**\n * reverse geocode coordinates to addresses\n * @param params - latitude/longitude, optional layers filter\n * @returns matching addresses\n */\n static async reverseGeocode(params: RadarReverseGeocodeParams): Promise<RadarGeocodeResponse> {\n const options = Config.get();\n\n const { layers } = params;\n let { latitude, longitude } = params;\n\n if (!latitude || !longitude) {\n const location = await Navigator.getCurrentPosition();\n latitude = location.latitude;\n longitude = location.longitude;\n }\n\n const response = await Http.request<Omit<RadarGeocodeResponse, 'response'>>({\n method: 'GET',\n path: 'geocode/reverse',\n data: {\n coordinates: `${latitude},${longitude}`,\n layers,\n },\n });\n\n const reverseGeocodeRes: RadarGeocodeResponse = {\n addresses: response.addresses,\n };\n\n if (options.debug) {\n reverseGeocodeRes.response = response;\n }\n\n return reverseGeocodeRes;\n }\n\n /**\n * geocode the device's IP address to a rough location\n * @returns IP address, approximate address, and proxy info\n */\n static async ipGeocode(): Promise<RadarIPGeocodeResponse> {\n const options = Config.get();\n\n const response = await Http.request<Omit<RadarIPGeocodeResponse, 'response'>>({\n method: 'GET',\n path: 'geocode/ip',\n });\n\n const ipGeocodeRes: RadarIPGeocodeResponse = {\n ip: response.ip,\n address: response.address,\n proxy: response.proxy,\n };\n\n if (options.debug) {\n ipGeocodeRes.response = response;\n }\n\n return ipGeocodeRes;\n }\n}\n\nexport default Geocoding;\n","import Config from '../config';\nimport Http from '../http';\nimport Navigator from '../navigator';\n\nimport type { RadarDistanceParams, RadarRouteResponse, RadarMatrixParams, RadarMatrixResponse } from '../types';\n\n/** @internal routing API — use Radar.distance / matrix instead */\nclass RoutingAPI {\n /**\n * calculate travel distance and duration between two points\n * @param params - origin, destination, modes, and units\n * @returns routes with distance and duration per mode\n */\n static async distance(params: RadarDistanceParams): Promise<RadarRouteResponse> {\n const options = Config.get();\n\n const { units, geometry, geometryPoints } = params;\n let { origin, destination, modes, avoid } = params;\n\n // use browser location if \"near\" not provided\n if (!origin) {\n const { latitude, longitude } = await Navigator.getCurrentPosition();\n origin = `${latitude},${longitude}`;\n } else if (typeof origin !== 'string') {\n // origin is \"Location\" object\n const { latitude, longitude } = origin;\n origin = `${latitude},${longitude}`;\n }\n\n if (typeof destination !== 'string') {\n const { latitude, longitude } = destination;\n destination = `${latitude},${longitude}`;\n }\n\n if (Array.isArray(modes)) {\n modes = modes.join(',');\n }\n\n if (Array.isArray(avoid)) {\n avoid = avoid.join(',');\n }\n\n const response = await Http.request<Omit<RadarRouteResponse, 'response'>>({\n method: 'GET',\n path: 'route/distance',\n data: {\n origin,\n destination,\n modes,\n units,\n geometry,\n geometryPoints,\n avoid,\n },\n });\n\n const distanceRes: RadarRouteResponse = {\n routes: response.routes,\n };\n\n if (options.debug) {\n distanceRes.response = response;\n }\n\n return distanceRes;\n }\n\n /**\n * calculate a distance matrix between multiple origins and destinations\n * @param params - origins, destinations, mode, and units\n * @returns matrix of distances and durations\n */\n static async matrix(params: RadarMatrixParams): Promise<RadarMatrixResponse> {\n const options = Config.get();\n\n const { mode, units } = params;\n let { origins, destinations, avoid } = params;\n\n // use browser location if \"near\" not provided\n if (!origins) {\n const { latitude, longitude } = await Navigator.getCurrentPosition();\n const originStrings = [];\n for (let i = 0; i < destinations.length; i++) {\n originStrings.push(`${latitude},${longitude}`);\n }\n origins = originStrings.join('|');\n } else if (Array.isArray(origins)) {\n // origin is a list of \"Location\" objects\n origins = origins.map((location) => `${location.latitude},${location.longitude}`).join('|');\n }\n\n // convert array to pipe-delimited string\n if (Array.isArray(destinations)) {\n destinations = destinations.map((location) => `${location.latitude},${location.longitude}`).join('|');\n }\n\n if (Array.isArray(avoid)) {\n avoid = avoid.join(',');\n }\n\n const response = await Http.request<Omit<RadarMatrixResponse, 'response'>>({\n method: 'GET',\n path: 'route/matrix',\n data: {\n origins,\n destinations,\n mode,\n units,\n avoid,\n },\n });\n\n const matrixRes: RadarMatrixResponse = {\n origins: response.origins,\n destinations: response.destinations,\n matrix: response.matrix,\n };\n\n if (options.debug) {\n matrixRes.response = response;\n }\n\n return matrixRes;\n }\n}\n\nexport default RoutingAPI;\n","import Config from '../config';\nimport Http from '../http';\nimport Navigator from '../navigator';\n\nimport type {\n RadarAutocompleteParams,\n RadarAutocompleteResponse,\n RadarSearchPlacesParams,\n RadarSearchPlacesResponse,\n RadarSearchGeofencesParams,\n RadarSearchGeofencesResponse,\n} from '../types';\n\n/** @internal search API — use Radar.autocomplete / searchGeofences / searchPlaces instead */\nclass SearchAPI {\n /**\n * autocomplete partial addresses and place names\n * @param params - query and search configuration\n * @param requestId - optional ID for deduplicating in-flight requests\n * @returns matching addresses\n */\n static async autocomplete(params: RadarAutocompleteParams, requestId?: string): Promise<RadarAutocompleteResponse> {\n const options = Config.get();\n\n const { query, limit, layers, countryCode, expandUnits, mailable, lang, postalCode } = params;\n let { near } = params;\n\n // near can be provided as a string or Location object\n // if \"near\" is not provided, request will fallback to IP based location\n if (near && typeof near !== 'string') {\n if (near.latitude && near.longitude) {\n near = `${near.latitude},${near.longitude}`;\n }\n }\n\n const response = await Http.request<Omit<RadarAutocompleteResponse, 'response'>>({\n method: 'GET',\n path: 'search/autocomplete',\n data: {\n query,\n near,\n limit,\n layers,\n countryCode,\n expandUnits,\n mailable,\n lang,\n postalCode,\n },\n requestId,\n });\n\n const autocompleteRes: RadarAutocompleteResponse = {\n addresses: response.addresses,\n };\n\n if (options.debug) {\n autocompleteRes.response = response;\n }\n\n return autocompleteRes;\n }\n\n /**\n * search for geofences near a location\n * @param params - location, radius, tags, and filters\n * @returns matching geofences\n */\n static async searchGeofences(params: RadarSearchGeofencesParams): Promise<RadarSearchGeofencesResponse> {\n const options = Config.get();\n\n const { radius, metadata, limit, includeGeometry } = params;\n let { near, tags } = params;\n\n // use browser location if \"near\" not provided\n if (!near) {\n const { latitude, longitude } = await Navigator.getCurrentPosition();\n near = `${latitude},${longitude}`;\n } else if (typeof near !== 'string') {\n // near is \"Location\" object\n const { latitude, longitude } = near;\n near = `${latitude},${longitude}`;\n }\n\n // convert arrays to comma-strings\n if (Array.isArray(tags)) {\n tags = tags.join(',');\n }\n\n const response = await Http.request<Omit<RadarSearchGeofencesResponse, 'response'>>({\n method: 'GET',\n path: 'search/geofences',\n data: {\n near,\n radius,\n tags,\n metadata,\n limit,\n includeGeometry,\n },\n });\n\n const geofencesSearchRes: RadarSearchGeofencesResponse = {\n geofences: response.geofences,\n };\n\n if (options.debug) {\n geofencesSearchRes.response = response;\n }\n\n return geofencesSearchRes;\n }\n\n /**\n * search for places near a location\n * @param params - location, radius, chains, categories, and groups\n * @returns matching places\n */\n static async searchPlaces(params: RadarSearchPlacesParams): Promise<RadarSearchPlacesResponse> {\n const options = Config.get();\n\n const { radius, limit } = params;\n let { near, chains, categories, groups } = params;\n\n // use browser location if \"near\" not provided\n if (!near) {\n const { latitude, longitude } = await Navigator.getCurrentPosition();\n near = `${latitude},${longitude}`;\n } else if (typeof near !== 'string') {\n // near is \"Location\" object\n const { latitude, longitude } = near;\n near = `${latitude},${longitude}`;\n }\n\n // convert arrays to comma-strings\n if (Array.isArray(chains)) {\n chains = chains.join(',');\n }\n if (Array.isArray(categories)) {\n categories = categories.join(',');\n }\n if (Array.isArray(groups)) {\n groups = groups.join(',');\n }\n\n const response = await Http.request<Omit<RadarSearchPlacesResponse, 'response'>>({\n method: 'GET',\n path: 'search/places',\n data: {\n near,\n radius,\n chains,\n categories,\n groups,\n limit,\n },\n });\n\n const placeSearchRes: RadarSearchPlacesResponse = {\n places: response.places,\n };\n\n if (options.debug) {\n placeSearchRes.response = response;\n }\n\n return placeSearchRes;\n }\n}\n\nexport default SearchAPI;\n","import Config from '../config';\nimport Http from '../http';\nimport Logger from '../logger';\nimport Storage from '../storage';\n\nimport type { RadarTripOptions, RadarTripStatus, RadarTripResponse } from '../types';\n\n// https://stackoverflow.com/a/44198641\nconst isValidDate = (date: any): Date | undefined =>\n date && Object.prototype.toString.call(date) === '[object Date]' && !isNaN(date);\n\n/** @internal trips API — use Radar.startTrip / updateTrip / completeTrip / cancelTrip instead */\nclass TripsAPI {\n /** save trip options to localStorage, pass `undefined` to clear */\n static setTripOptions(tripOptions?: RadarTripOptions) {\n if (!tripOptions) {\n TripsAPI.clearTripOptions();\n return;\n }\n const tripOptionsString = JSON.stringify(tripOptions);\n Logger.debug(`Saving trip options: ${tripOptionsString}`);\n Storage.setItem(Storage.TRIP_OPTIONS, tripOptionsString);\n }\n\n /** get saved trip options from localStorage */\n static getTripOptions(): RadarTripOptions {\n let tripOptions = Storage.getItem(Storage.TRIP_OPTIONS);\n if (tripOptions) {\n tripOptions = JSON.parse(tripOptions);\n }\n return tripOptions as RadarTripOptions;\n }\n\n /** remove saved trip options from localStorage */\n static clearTripOptions() {\n Storage.removeItem(Storage.TRIP_OPTIONS);\n }\n\n /**\n * start a new trip\n * @param tripOptions - trip configuration and destination\n * @returns the created trip and any triggered events\n */\n static async startTrip(tripOptions: RadarTripOptions): Promise<RadarTripResponse> {\n const options = Config.get();\n tripOptions = tripOptions || TripsAPI.getTripOptions();\n\n if (!tripOptions) {\n Logger.warn('tripOptions not set when calling \"startTrip\"');\n }\n\n const userId = tripOptions.userId || Storage.getItem(Storage.USER_ID);\n if (userId && userId !== Storage.getItem(Storage.USER_ID)) {\n // set as userId for tracking if provided\n Storage.setItem(Storage.USER_ID, userId);\n }\n\n const {\n externalId,\n destinationGeofenceTag,\n destinationGeofenceExternalId,\n mode,\n metadata,\n approachingThreshold,\n scheduledArrivalAt,\n } = tripOptions;\n\n if (scheduledArrivalAt && !isValidDate(scheduledArrivalAt)) {\n Logger.warn('Invalid date format for scheduledArrivalAt');\n }\n\n const data = {\n userId,\n externalId,\n destinationGeofenceTag,\n destinationGeofenceExternalId,\n mode,\n metadata,\n approachingThreshold,\n scheduledArrivalAt: isValidDate(scheduledArrivalAt) ? scheduledArrivalAt!.toJSON() : undefined,\n };\n\n const response = await Http.request<Omit<RadarTripResponse, 'response'>>({\n method: 'POST',\n path: 'trips',\n data,\n });\n\n // save trip options\n TripsAPI.setTripOptions(tripOptions);\n\n const tripRes: RadarTripResponse = {\n trip: response.trip,\n events: response.events,\n };\n\n if (options.debug) {\n tripRes.response = response;\n }\n\n return tripRes;\n }\n\n /**\n * update an in-progress trip\n * @param tripOptions - updated trip configuration\n * @param status - optional trip status override\n * @returns the updated trip and any triggered events\n */\n static async updateTrip(tripOptions: RadarTripOptions, status?: RadarTripStatus): Promise<RadarTripResponse> {\n const options = Config.get();\n tripOptions = tripOptions || TripsAPI.getTripOptions();\n\n if (!tripOptions) {\n Logger.warn('tripOptions not set when calling \"startTrip\"');\n }\n\n const {\n externalId,\n destinationGeofenceTag,\n destinationGeofenceExternalId,\n mode,\n metadata,\n approachingThreshold,\n scheduledArrivalAt,\n } = tripOptions;\n\n if (scheduledArrivalAt && !isValidDate(scheduledArrivalAt)) {\n Logger.warn('Invalid date format for scheduledArrivalAt');\n }\n\n const data = {\n status,\n externalId,\n destinationGeofenceTag,\n destinationGeofenceExternalId,\n mode,\n metadata,\n approachingThreshold,\n scheduledArrivalAt: isValidDate(scheduledArrivalAt) ? scheduledArrivalAt!.toJSON() : undefined,\n };\n\n const response = await Http.request<Omit<RadarTripResponse, 'response'>>({\n method: 'PATCH',\n path: `trips/${externalId}/update`,\n data,\n });\n\n const tripRes: RadarTripResponse = {\n trip: response.trip,\n events: response.events,\n };\n\n if (options.debug) {\n tripRes.response = response;\n }\n\n return tripRes;\n }\n\n /** complete the current trip and clear local trip options */\n static async completeTrip(): Promise<RadarTripResponse> {\n const tripOptions = TripsAPI.getTripOptions();\n const tripResponse = await TripsAPI.updateTrip(tripOptions, 'completed');\n\n // clear local trip options\n TripsAPI.clearTripOptions();\n\n return tripResponse;\n }\n\n /** cancel the current trip and clear local trip options */\n static async cancelTrip(): Promise<RadarTripResponse> {\n const tripOptions = TripsAPI.getTripOptions();\n const tripResponse = await TripsAPI.updateTrip(tripOptions, 'canceled');\n\n // clear local trip options\n TripsAPI.clearTripOptions();\n\n return tripResponse;\n }\n}\n\nexport default TripsAPI;\n","import Config from '../config';\nimport Device from '../device';\nimport Http from '../http';\nimport Logger from '../logger';\nimport Navigator from '../navigator';\nimport Session from '../session';\nimport Storage from '../storage';\nimport SDK_VERSION from '../version';\nimport TripsAPI from './trips';\n\nimport type { RadarTrackParams, RadarTrackResponse } from '../types';\n\n/** @internal tracking API — use {@link Radar.trackOnce} instead */\nclass TrackAPI {\n /**\n * track the user's current location once\n * @param params - tracking parameters (location, user info, trip options)\n * @returns tracked user, events, and location\n */\n static async trackOnce(params: RadarTrackParams) {\n const options = Config.get();\n\n const { desiredAccuracy } = params;\n let { latitude, longitude, accuracy } = params;\n\n // if latitude & longitude are not provided,\n // try and retrieve device location (will prompt for location permissions)\n if (!latitude || !longitude) {\n const deviceLocation = await Navigator.getCurrentPosition({ desiredAccuracy });\n latitude = deviceLocation.latitude;\n longitude = deviceLocation.longitude;\n accuracy = deviceLocation.accuracy;\n }\n\n // location authorization\n const locationAuthorization = await Navigator.getPermissionStatus();\n\n // user indentification fields\n const userId = params.userId || Storage.getItem(Storage.USER_ID);\n const deviceId = params.deviceId || Device.getDeviceId();\n const installId = params.installId || Device.getInstallId();\n const sessionId = Session.getSessionId();\n const deviceType = params.deviceType || 'Web';\n const description = params.description || Storage.getItem(Storage.DESCRIPTION);\n\n // save userId for trip tracking\n if (!userId) {\n Logger.warn('userId not provided for trackOnce.');\n } else {\n Storage.setItem(Storage.USER_ID, userId);\n }\n\n // other info\n const metadata = params.metadata || Storage.getJSON(Storage.METADATA);\n\n // trips\n const tripOptions = params.tripOptions || TripsAPI.getTripOptions();\n if (tripOptions) {\n tripOptions.version = '2';\n }\n\n const body = {\n ...params,\n locationAuthorization,\n accuracy,\n description,\n deviceId,\n deviceType,\n foreground: true,\n installId,\n sessionId,\n latitude,\n longitude,\n metadata,\n sdkVersion: SDK_VERSION,\n stopped: true,\n userId,\n tripOptions,\n };\n\n const response = await Http.request<Omit<RadarTrackResponse, 'response' | 'location'>>({\n method: 'POST',\n path: 'track',\n data: body,\n });\n\n const { user, events } = response;\n const location = { latitude, longitude, accuracy };\n\n const trackRes: RadarTrackResponse = {\n user,\n events,\n location,\n };\n\n if (options.debug) {\n trackRes.response = response;\n }\n\n return trackRes;\n }\n}\n\nexport default TrackAPI;\n","import AddressesAPI from './api/addresses';\nimport ConfigAPI from './api/config';\nimport ContextAPI from './api/context';\nimport ConversionsAPI from './api/conversions';\nimport GeocodingAPI from './api/geocoding';\nimport RoutingAPI from './api/routing';\nimport SearchAPI from './api/search';\nimport TrackAPI from './api/track';\nimport TripsAPI from './api/trips';\nimport Config from './config';\nimport Device from './device';\nimport * as errors from './errors';\nimport { RadarPublishableKeyError } from './errors';\nimport Http from './http';\nimport Logger from './logger';\nimport Navigator from './navigator';\nimport Session from './session';\nimport Storage from './storage';\nimport SDK_VERSION from './version';\n\nimport type { RadarError } from './errors';\nimport type { RadarPlugin, RadarPluginContext, RadarStatic } from './plugin';\nimport type {\n Location,\n NavigatorPosition,\n RadarAutocompleteParams,\n RadarAutocompleteResponse,\n RadarContextResponse,\n RadarConversionParams,\n RadarConversionResponse,\n RadarDistanceParams,\n RadarForwardGeocodeParams,\n RadarGeocodeResponse,\n RadarIPGeocodeResponse,\n RadarMatrixParams,\n RadarMatrixResponse,\n RadarMetadata,\n RadarOptions,\n RadarReverseGeocodeParams,\n RadarRouteResponse,\n RadarSearchGeofencesParams,\n RadarSearchGeofencesResponse,\n RadarSearchPlacesParams,\n RadarSearchPlacesResponse,\n RadarTrackParams,\n RadarTrackResponse,\n RadarTripOptions,\n RadarTripResponse,\n RadarValidateAddressParams,\n RadarValidateAddressResponse,\n} from './types';\n\nconst isSecretKey = (key: string): boolean => key.includes('_sk_');\nconst isLiveKey = (key: string): boolean => key.includes('_live_');\n\n/**\n * main entry point for the Radar SDK. all methods are static — do not instantiate.\n *\n * @example\n * ```ts\n * Radar.initialize('prj_test_pk_...');\n * const { user, events } = await Radar.trackOnce();\n * ```\n */\nclass Radar {\n private static _plugins: Map<string, RadarPlugin> = new Map();\n\n public static errors = errors;\n\n /** current SDK version string */\n public static get VERSION() {\n return SDK_VERSION;\n }\n\n /** register one or more plugins (e.g. maps, autocomplete, fraud) */\n public static registerPlugin(...plugins: RadarPlugin[]) {\n const ctx = Radar._getPluginContext();\n for (const plugin of plugins) {\n if (Radar._plugins.has(plugin.name)) {\n Logger.warn(`plugin \"${plugin.name}\" already registered.`);\n continue;\n }\n\n plugin.install(ctx);\n Radar._plugins.set(plugin.name, plugin);\n }\n }\n\n private static _getPluginContext(): RadarPluginContext {\n return {\n Radar: Radar as RadarStatic,\n Config,\n Http,\n Storage,\n Device,\n Session,\n Logger,\n Navigator,\n apis: {\n Addresses: AddressesAPI,\n Config: ConfigAPI,\n Context: ContextAPI,\n Conversions: ConversionsAPI,\n Geocoding: GeocodingAPI,\n Routing: RoutingAPI,\n Search: SearchAPI,\n Track: TrackAPI,\n Trips: TripsAPI,\n },\n };\n }\n\n /**\n * initialize the SDK with a publishable key. must be called before any other method.\n * @param publishableKey - your Radar publishable key (starts with `prj_test_pk_` or `prj_live_pk_`)\n * @param options - optional SDK configuration\n * @throws {RadarPublishableKeyError} if the key is missing or is a secret key\n */\n public static initialize(publishableKey: string, options: RadarOptions = {}) {\n if (!publishableKey) {\n throw new RadarPublishableKeyError('Publishable key required in initialization.');\n }\n\n if (isSecretKey(publishableKey)) {\n throw new RadarPublishableKeyError('Secret keys are not allowed. Please use your Radar publishable key.');\n }\n\n // store settings in global config\n const live = isLiveKey(publishableKey);\n const logLevel = live ? 'error' : 'info';\n const debug = !live;\n const radarOptions = Object.assign(\n Config.defaultOptions,\n {\n publishableKey,\n live,\n logLevel,\n debug,\n },\n options,\n );\n Config.setup(radarOptions);\n\n Logger.info(`initialized with ${live ? 'live' : 'test'} publishableKey.`);\n if (options.debug) {\n Logger.debug('using options', options);\n }\n\n // NOTE(jasonl): this allows us to run jest tests\n // without having to mock the ConfigAPI.getConfig call\n if (!window?.RADAR_TEST_ENV) {\n ConfigAPI.getConfig().catch((err) => {\n Logger.warn(`Error calling /config: ${err.message}`);\n });\n }\n }\n\n /** clear all SDK state and configuration */\n public static clear() {\n Config.clear();\n }\n\n ///////////////////////\n // Geofencing Platform\n ///////////////////////\n\n /** set the user ID for tracking. pass `undefined` to clear. */\n public static setUserId(userId?: string) {\n if (!userId) {\n Storage.removeItem(Storage.USER_ID);\n return;\n }\n Storage.setItem(Storage.USER_ID, String(userId).trim());\n }\n\n /** set a description for the current user. pass `undefined` to clear. */\n public static setDescription(description?: string) {\n if (!description) {\n Storage.removeItem(Storage.DESCRIPTION);\n return;\n }\n Storage.setItem(Storage.DESCRIPTION, String(description).trim());\n }\n\n /** set custom metadata for the current user. pass `undefined` to clear. */\n public static setMetadata(metadata?: RadarMetadata) {\n if (!metadata) {\n Storage.removeItem(Storage.METADATA);\n return;\n }\n Storage.setItem(Storage.METADATA, JSON.stringify(metadata));\n }\n\n /** get the device's current location using the browser geolocation API */\n public static getLocation(): Promise<NavigatorPosition> {\n return Navigator.getCurrentPosition();\n }\n\n /** track the user's current location once, returning location context and events */\n public static trackOnce(params: RadarTrackParams = {}): Promise<RadarTrackResponse> {\n try {\n return TrackAPI.trackOnce(params);\n } finally {\n // call with updated permissions\n ConfigAPI.getConfig(params).catch((err) => {\n Logger.warn(`Error calling /config: ${err.message}`);\n });\n }\n }\n\n /** get context (geofences, place, regions) for a location without tracking */\n public static getContext(params: Location): Promise<RadarContextResponse> {\n return ContextAPI.getContext(params);\n }\n\n /** save trip options for tracking. pass `undefined` to clear */\n public static setTripOptions(tripOptions?: RadarTripOptions) {\n TripsAPI.setTripOptions(tripOptions);\n }\n\n /** clear saved trip options */\n public static clearTripOptions() {\n TripsAPI.clearTripOptions();\n }\n\n /** get the currently saved trip options */\n public static getTripOptions(): RadarTripOptions {\n return TripsAPI.getTripOptions();\n }\n\n /** start a new trip with the given options */\n public static startTrip(tripOptions: RadarTripOptions): Promise<RadarTripResponse> {\n return TripsAPI.startTrip(tripOptions);\n }\n\n /** update an in-progress trip */\n public static updateTrip(tripOptions: RadarTripOptions): Promise<RadarTripResponse> {\n return TripsAPI.updateTrip(tripOptions);\n }\n\n /** complete the current trip and clear local trip options */\n public static completeTrip(): Promise<RadarTripResponse> {\n return TripsAPI.completeTrip();\n }\n\n /** cancel the current trip and clear local trip options */\n public static cancelTrip(): Promise<RadarTripResponse> {\n return TripsAPI.cancelTrip();\n }\n\n /** log a conversion event */\n public static logConversion(params: RadarConversionParams): Promise<RadarConversionResponse> {\n return ConversionsAPI.logConversion(params);\n }\n\n /** set the product identifier for tracking requests. pass `undefined` to clear */\n public static setProduct(product?: string) {\n if (!product) {\n Storage.removeItem(Storage.PRODUCT);\n return;\n }\n Storage.setItem(Storage.PRODUCT, String(product).trim());\n }\n\n ///////////////////////\n // Listeners\n ///////////////////////\n\n /** register a global error callback invoked on SDK errors */\n public static onError(callback: (error: RadarError) => void) {\n Config.onError(callback);\n }\n\n /////////////////\n // Maps Platform\n /////////////////\n\n /** geocode an address or place name to coordinates */\n public static forwardGeocode(params: RadarForwardGeocodeParams): Promise<RadarGeocodeResponse> {\n return GeocodingAPI.forwardGeocode(params);\n }\n\n /** reverse geocode coordinates to addresses */\n public static reverseGeocode(params: RadarReverseGeocodeParams): Promise<RadarGeocodeResponse> {\n return GeocodingAPI.reverseGeocode(params);\n }\n\n /** geocode the device's IP address to a rough location */\n public static ipGeocode(): Promise<RadarIPGeocodeResponse> {\n return GeocodingAPI.ipGeocode();\n }\n\n /** autocomplete partial addresses and place names */\n public static autocomplete(params: RadarAutocompleteParams, requestId?: string): Promise<RadarAutocompleteResponse> {\n return SearchAPI.autocomplete(params, requestId);\n }\n\n /** search for geofences near a location */\n public static searchGeofences(params: RadarSearchGeofencesParams): Promise<RadarSearchGeofencesResponse> {\n return SearchAPI.searchGeofences(params);\n }\n\n /** search for places (POIs) near a location */\n public static searchPlaces(params: RadarSearchPlacesParams): Promise<RadarSearchPlacesResponse> {\n return SearchAPI.searchPlaces(params);\n }\n\n /** validate a structured address */\n public static validateAddress(params: RadarValidateAddressParams): Promise<RadarValidateAddressResponse> {\n return AddressesAPI.validateAddress(params);\n }\n\n /** calculate travel distance and duration between two points */\n public static distance(params: RadarDistanceParams): Promise<RadarRouteResponse> {\n return RoutingAPI.distance(params);\n }\n\n /** calculate a distance matrix between multiple origins and destinations */\n public static matrix(params: RadarMatrixParams): Promise<RadarMatrixResponse> {\n return RoutingAPI.matrix(params);\n }\n}\n\nexport default Radar;\n"],"names":["GeocodingAPI"],"mappings":"AAGA;AACA,MAAM,MAAM,CAAA;;AAgBH,IAAA,OAAO,KAAK,CAAC,OAAA,GAAwB,EAAE,EAAA;AAC5C,QAAA,MAAM,CAAC,OAAO,GAAG,OAAO;IAC1B;;AAGO,IAAA,OAAO,GAAG,GAAA;AACf,QAAA,OAAO,MAAM,CAAC,OAAO,IAAI,EAAE;IAC7B;;AAGO,IAAA,OAAO,KAAK,GAAA;AACjB,QAAA,MAAM,CAAC,OAAO,GAAG,EAAE;AACnB,QAAA,MAAM,CAAC,aAAa,GAAG,IAAI;IAC7B;;IAGO,OAAO,OAAO,CAAC,QAAqC,EAAA;AACzD,QAAA,MAAM,CAAC,aAAa,GAAG,QAAQ;IACjC;;IAGO,OAAO,SAAS,CAAC,KAAU,EAAA;AAChC,QAAA,IAAI,MAAM,CAAC,aAAa,IAAI,KAAK,EAAE;AACjC,YAAA,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC;QAC7B;IACF;;AAtCA;AACO,MAAA,CAAA,aAAa,GAAyC,IAAI;AAEjE;AACO,MAAA,CAAA,cAAc,GAAG;AACtB,IAAA,IAAI,EAAE,KAAK;AACX,IAAA,QAAQ,EAAE,OAAO;AACjB,IAAA,IAAI,EAAE,sBAAsB;AAC5B,IAAA,OAAO,EAAE,IAAI;AACb,IAAA,KAAK,EAAE,KAAK;CACb;;ACfH;AACM,MAAgB,UAAW,SAAQ,KAAK,CAAA;AAK5C,IAAA,WAAA,CAAY,OAAe,EAAA;QACzB,KAAK,CAAC,OAA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AAA,OAAO,YAAY,CAAC,eAAe,CAAC,MAAM,CAAC;IAC7C;;IAGO,OAAO,QAAQ,CAAC,MAA2B,EAAA;AAChD,QAAA,OAAO,UAAU,CAAC,QAAQ,CAAC,MAAM,CAAC;IACpC;;IAGO,OAAO,MAAM,CAAC,MAAyB,EAAA;AAC5C,QAAA,OAAO,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC;IAClC;;AA/Pe,KAAA,CAAA,QAAQ,GAA6B,IAAI,GAAG,EAAE;AAE/C,KAAA,CAAA,MAAM,GAAG,MAAM;;;;"}
1
+ {"version":3,"file":"radar.js","sources":["../src/version.ts","../src/config.ts","../src/errors.ts","../src/logger.ts","../src/storage.ts","../src/navigator.ts","../src/http.ts","../src/api/addresses.ts","../src/device.ts","../src/session.ts","../src/api/config.ts","../src/api/context.ts","../src/api/conversions.ts","../src/api/geocoding.ts","../src/api/routing.ts","../src/api/search.ts","../src/api/trips.ts","../src/api/track.ts","../src/api.ts"],"sourcesContent":["export default '5.1.0';\n","import SDK_VERSION from './version';\n\nimport type { RadarError } from './errors';\nimport type { RadarOptions } from './types';\n\n/** global SDK configuration singleton */\nclass Config {\n /** current SDK options */\n static options: RadarOptions;\n /** registered error callback, if any */\n static errorCallback: ((error: RadarError) => void) | null = null;\n\n /** default option values applied during initialization */\n static defaultOptions = {\n live: false,\n logLevel: 'error',\n host: 'https://api.radar.io',\n version: 'v1',\n debug: false,\n };\n\n /** store SDK options (called by Radar.initialize) */\n public static setup(options: RadarOptions = {}) {\n Config.options = options;\n }\n\n /** get the current SDK options */\n public static get(): RadarOptions {\n return Config.options || {};\n }\n\n /** clear all SDK options and error callback */\n public static clear() {\n Config.options = {};\n Config.errorCallback = null;\n }\n\n /** register a callback invoked on SDK errors */\n public static onError(callback: (error: RadarError) => void) {\n Config.errorCallback = callback;\n }\n\n /** dispatch an error to the registered callback */\n public static sendError(error: any) {\n if (Config.errorCallback && error) {\n Config.errorCallback(error);\n }\n }\n\n /** build standard Radar request headers (Authorization, Device-Type, SDK-Version).\n * Callers must ensure credentials are set before calling (e.g. via Radar.initialize).\n * */\n static getDefaultHeaders(): Record<string, string> {\n const { publishableKey, authToken, getRequestHeaders: getHeaders } = Config.get();\n const headers: Record<string, string> = {\n 'X-Radar-Device-Type': 'Web',\n 'X-Radar-SDK-Version': SDK_VERSION,\n };\n if (authToken) {\n headers.Authorization = `Bearer ${authToken}`;\n } else if (publishableKey) {\n headers.Authorization = publishableKey;\n }\n if (typeof getHeaders === 'function') {\n Object.assign(headers, getHeaders());\n }\n return headers;\n }\n}\n\nexport default Config;\n","import type { RadarResponse } from './http';\n\n/** base error class for all Radar SDK errors */\nexport abstract class RadarError extends Error {\n /** legacy status code string (e.g. `'ERROR_PUBLISHABLE_KEY'`) */\n public abstract readonly status: string;\n public abstract readonly name: string;\n\n constructor(message: string) {\n super(message);\n }\n}\n\n/** thrown when a publishable key is missing or invalid (e.g. secret key used) */\nexport class RadarPublishableKeyError extends RadarError {\n public override readonly name = 'RadarPublishableKeyError';\n public override readonly status = 'ERROR_PUBLISHABLE_KEY';\n\n constructor(message: string) {\n super(message);\n }\n}\n\n/** thrown when the device location cannot be determined */\nexport class RadarLocationError extends RadarError {\n public override readonly name = 'RadarLocationError';\n public override readonly status = 'ERROR_LOCATION';\n\n constructor(message: string) {\n super(message);\n }\n}\n\n/** thrown when location permissions are denied by the browser */\nexport class RadarPermissionsError extends RadarError {\n public override readonly name = 'RadarPermissionsError';\n public override readonly status = 'ERROR_PERMISSIONS';\n\n constructor(message: string) {\n super(message);\n }\n}\n\n/** thrown on HTTP 400 Bad Request responses */\nexport class RadarBadRequestError extends RadarError {\n public override readonly name = 'RadarBadRequestError';\n public override readonly status = 'ERROR_BAD_REQUEST';\n public readonly code = 400;\n public readonly response?: RadarResponse;\n\n constructor(response?: RadarResponse) {\n super(response?.meta?.message || 'Bad request.');\n\n this.response = response;\n }\n}\n\n/** thrown on HTTP 401 Unauthorized responses */\nexport class RadarUnauthorizedError extends RadarError {\n public override readonly name = 'RadarUnauthorizedError';\n public override readonly status = 'ERROR_UNAUTHORIZED';\n public readonly code = 401;\n public readonly response?: RadarResponse;\n\n constructor(response?: RadarResponse) {\n super(response?.meta?.message || 'Unauthorized.');\n\n this.response = response;\n }\n}\n\n/** thrown on HTTP 402 Payment Required responses */\nexport class RadarPaymentRequiredError extends RadarError {\n public override readonly name = 'RadarPaymentRequiredError';\n public override readonly status = 'ERROR_PAYMENT_REQUIRED';\n public readonly code = 402;\n public readonly response?: RadarResponse;\n\n constructor(response?: RadarResponse) {\n super(response?.meta?.message || 'Payment required.');\n\n this.response = response;\n }\n}\n\n/** thrown on HTTP 403 Forbidden responses */\nexport class RadarForbiddenError extends RadarError {\n public override readonly name = 'RadarForbiddenError';\n public override readonly status = 'ERROR_FORBIDDEN';\n public readonly code = 403;\n public readonly response?: RadarResponse;\n\n constructor(response?: RadarResponse) {\n super(response?.meta?.message || 'Forbidden.');\n\n this.response = response;\n }\n}\n\n/** thrown on HTTP 404 Not Found responses */\nexport class RadarNotFoundError extends RadarError {\n public override readonly name = 'RadarNotFoundError';\n public override readonly status = 'ERROR_NOT_FOUND';\n public readonly code = 404;\n public readonly response?: RadarResponse;\n\n constructor(response?: RadarResponse) {\n super(response?.meta?.message || 'Not found.');\n\n this.response = response;\n }\n}\n\n/** thrown on HTTP 429 Rate Limit responses */\nexport class RadarRateLimitError extends RadarError {\n public override readonly name = 'RadarRateLimitError';\n public override readonly status = 'ERROR_RATE_LIMIT';\n public readonly code = 429;\n public readonly response?: RadarResponse;\n /** rate limit type from the API response (e.g. `'hourly'`) */\n public readonly type?: string;\n\n constructor(response?: RadarResponse) {\n super(response?.meta?.message || 'Rate limit exceeded.');\n\n this.response = response;\n this.type = response?.meta?.type;\n }\n}\n\n/** thrown on HTTP 5xx server errors */\nexport class RadarServerError extends RadarError {\n public override readonly name = 'RadarServerError';\n public override readonly status = 'ERROR_SERVER';\n public readonly response?: RadarResponse;\n\n constructor(response?: RadarResponse) {\n super(response?.meta?.message || 'Internal server error.');\n\n this.response = response;\n }\n}\n\n/** thrown when a request times out or the network is unavailable */\nexport class RadarNetworkError extends RadarError {\n public override readonly name = 'RadarNetworkError';\n public override readonly status = 'ERROR_NETWORK';\n\n constructor() {\n super('Request timed out.');\n }\n}\n\n/** thrown for unexpected/unclassified errors */\nexport class RadarUnknownError extends RadarError {\n public override readonly name = 'RadarUnknownError';\n public override readonly status = 'ERROR_UNKNOWN';\n public readonly response?: RadarResponse;\n\n constructor(response?: RadarResponse) {\n super(response?.meta?.message || 'Something went wrong.');\n\n this.response = response;\n }\n}\n","import Config from './config';\n\nconst LOG_LEVELS = {\n none: 0,\n error: 1,\n warn: 2,\n info: 3,\n debug: 4,\n};\n\n// get the numeric level for logLevel option\nconst getLevel = (): number => {\n // disable logging in tests\n if (typeof window !== 'undefined' && window.RADAR_TEST_ENV) {\n return LOG_LEVELS.none;\n }\n\n const { logLevel } = Config.get();\n return logLevel ? LOG_LEVELS[logLevel] : LOG_LEVELS.error;\n};\n\n/** leveled console logger controlled by SDK config */\nclass Logger {\n /** log a debug-level message (only when debug mode is enabled) */\n public static debug(message: string, options?: any) {\n if (getLevel() === LOG_LEVELS.debug) {\n console.log(`Radar SDK (debug): ${message.trim()}`, options);\n }\n }\n\n /** log an info-level message */\n public static info(message: string) {\n if (getLevel() >= LOG_LEVELS.info) {\n console.log(`Radar SDK: ${message.trim()}`);\n }\n }\n\n /** log a warning-level message */\n public static warn(message: string) {\n if (getLevel() >= LOG_LEVELS.warn) {\n console.warn(`Radar SDK: ${message.trim()}`);\n }\n }\n\n /** log an error-level message */\n public static error(message: string) {\n if (getLevel() >= LOG_LEVELS.error) {\n console.error(`Radar SDK: ${message.trim()}`);\n }\n }\n}\n\nexport default Logger;\n","import Logger from './logger';\n\n/** typed localStorage wrapper with `radar-*` namespaced keys */\nclass Storage {\n /** localStorage key for user ID */\n public static get USER_ID() {\n return 'radar-userId';\n }\n /** localStorage key for device ID */\n public static get DEVICE_ID() {\n return 'radar-deviceId';\n }\n /** localStorage key for install ID */\n public static get INSTALL_ID() {\n return 'radar-installId';\n }\n /** localStorage key for session ID */\n public static get SESSION_ID() {\n return 'radar-sessionId';\n }\n /** localStorage key for user description */\n public static get DESCRIPTION() {\n return 'radar-description';\n }\n /** localStorage key for user metadata */\n public static get METADATA() {\n return 'radar-metadata';\n }\n /** localStorage key for cached location */\n public static get CACHED_LOCATION() {\n return 'radar-cached-location';\n }\n /** localStorage key for trip options */\n public static get TRIP_OPTIONS() {\n return 'radar-trip-options';\n }\n\n /** localStorage key for product identifier */\n public static get PRODUCT() {\n return 'radar-product';\n }\n\n /** @internal get the underlying localStorage instance */\n private static getStorage() {\n const storage = window?.localStorage;\n if (!storage) {\n Logger.warn('localStorage not available.');\n }\n return storage;\n }\n\n /**\n * store a string value in localStorage\n * @param key - the storage key\n * @param value - the string value to store\n */\n public static setItem(key: string, value: string) {\n const storage = this.getStorage();\n if (!storage) {\n return;\n }\n if (value === undefined || value === null) {\n return;\n }\n storage.setItem(key, value);\n }\n\n /**\n * retrieve a string value from localStorage\n * @param key - the storage key\n * @returns the stored value, or null if not found\n */\n public static getItem(key: string) {\n const storage = this.getStorage();\n if (!storage) {\n return null;\n }\n const value = storage.getItem(key);\n if (value !== undefined && value !== null) {\n return value;\n }\n return null;\n }\n\n /**\n * retrieve and parse a JSON value from localStorage\n * @param key - the storage key\n * @returns the parsed object, or null if not found or parse fails\n */\n public static getJSON(key: string) {\n const item = this.getItem(key);\n if (!item) {\n return null;\n }\n\n try {\n return JSON.parse(item);\n } catch {\n Logger.warn(`could not getJSON from storage for key: ${key}`);\n return null;\n }\n }\n\n /**\n * remove an item from localStorage\n * @param key - the storage key to remove\n */\n public static removeItem(key: string) {\n const storage = this.getStorage();\n if (!storage) {\n return null;\n }\n storage.removeItem(key);\n }\n\n /** clear all localStorage entries */\n public static clear() {\n const storage = this.getStorage();\n if (!storage) {\n return null;\n }\n storage.clear();\n }\n}\n\nexport default Storage;\n","import Config from './config';\nimport { RadarLocationError, RadarPermissionsError } from './errors';\nimport Logger from './logger';\nimport Storage from './storage';\n\nimport type { LocationAuthorization, NavigatorPosition } from './types';\n\ninterface PositionOptionOverrides {\n desiredAccuracy?: string;\n}\n\nconst DEFAULT_POSITION_OPTIONS: PositionOptions = {\n maximumAge: 0,\n timeout: 1000 * 10, // 10 seconds\n enableHighAccuracy: true,\n};\n\n// set \"enableHighAccuracy\" for navigator only when desiredAccuracy is \"high\"\nconst useHighAccuracy = (desiredAccuracy?: string) => Boolean(desiredAccuracy === 'high');\n\n/** browser geolocation wrapper with caching and permission checks */\nclass Navigator {\n /**\n * get the device's current position via the browser geolocation API\n * @param overrides - optional accuracy overrides\n * @returns device coordinates with accuracy\n * @throws {RadarLocationError} if geolocation is unavailable or times out\n * @throws {RadarPermissionsError} if location permissions are denied\n */\n public static async getCurrentPosition(overrides: PositionOptionOverrides = {}): Promise<NavigatorPosition> {\n return new Promise((resolve, reject) => {\n const options = Config.get();\n\n if (!navigator || !navigator.geolocation) {\n return reject(new RadarLocationError('navigator.geolocation is not available.'));\n }\n\n // use cached location if available and options are set\n if (options.cacheLocationMinutes) {\n try {\n const rawCachedLocation = Storage.getItem(Storage.CACHED_LOCATION);\n if (rawCachedLocation) {\n const cachedLocation = JSON.parse(rawCachedLocation);\n const { latitude, longitude, accuracy, expiresAt } = cachedLocation || {};\n if (Date.now() < parseInt(expiresAt)) {\n if (latitude && longitude && accuracy) {\n return resolve({ latitude, longitude, accuracy });\n }\n }\n }\n } catch {\n Logger.warn('could not load cached location.');\n }\n }\n\n // set options from config\n const positionOptions = Object.assign({}, DEFAULT_POSITION_OPTIONS);\n if (options.locationMaximumAge !== undefined) {\n positionOptions.maximumAge = options.locationMaximumAge;\n }\n if (options.locationTimeout !== undefined) {\n positionOptions.timeout = options.locationTimeout;\n }\n if (options.desiredAccuracy !== undefined) {\n positionOptions.enableHighAccuracy = useHighAccuracy(options.desiredAccuracy);\n }\n\n // set options from overrides\n if (overrides.desiredAccuracy !== undefined) {\n positionOptions.enableHighAccuracy = useHighAccuracy(overrides.desiredAccuracy);\n }\n\n Logger.info(`Using geolocation options: ${JSON.stringify(positionOptions)}`);\n\n // get current location from browser\n navigator.geolocation.getCurrentPosition(\n (position) => {\n if (!position || !position.coords) {\n return reject(new RadarLocationError('device location return empty coordinates.'));\n }\n\n const { latitude, longitude, accuracy } = position.coords;\n\n // cache location if option is set\n if (options.cacheLocationMinutes) {\n const cacheLocationMinutes = Number.parseFloat(options.cacheLocationMinutes as any);\n const updatedAt = Date.now();\n const expiresAt = updatedAt + cacheLocationMinutes * 60 * 1000; // convert to ms\n\n const lastLocation = { latitude, longitude, accuracy, updatedAt, expiresAt };\n Storage.setItem(Storage.CACHED_LOCATION, JSON.stringify(lastLocation));\n }\n\n return resolve({ latitude, longitude, accuracy });\n },\n (err: GeolocationPositionError) => {\n // location call failed or user did not grant permission\n if (err && err.code === 1) {\n // https://developer.mozilla.org/en-US/docs/Web/API/GeolocationPositionError\n // code 1 means location permissions denied\n // codes 2 and 3 mean location unavailable or timeout\n return reject(new RadarPermissionsError('Location permissions denied.'));\n }\n return reject(new RadarLocationError('Could not determine location.'));\n },\n positionOptions,\n );\n });\n }\n\n /**\n * query the current geolocation permission status\n * @returns the current location authorization state\n */\n public static async getPermissionStatus(): Promise<LocationAuthorization> {\n return new Promise((resolve) => {\n let locationAuthorization: LocationAuthorization = 'NOT_DETERMINED';\n\n if (!navigator || !navigator.permissions) {\n return resolve(locationAuthorization);\n }\n\n void navigator.permissions.query({ name: 'geolocation' }).then((permissionsStatus) => {\n switch (permissionsStatus.state) {\n case 'granted':\n locationAuthorization = 'GRANTED_FOREGROUND';\n break;\n case 'denied':\n locationAuthorization = 'DENIED';\n break;\n case 'prompt':\n locationAuthorization = 'NOT_DETERMINED';\n break;\n default:\n break;\n }\n\n return resolve(locationAuthorization);\n });\n });\n }\n\n /** check whether the browser reports being online */\n public static online(): boolean {\n return navigator && navigator.onLine;\n }\n}\n\nexport default Navigator;\n","import Config from './config';\nimport {\n RadarBadRequestError,\n RadarForbiddenError,\n RadarLocationError,\n RadarNetworkError,\n RadarNotFoundError,\n RadarPaymentRequiredError,\n RadarPermissionsError,\n RadarPublishableKeyError,\n RadarRateLimitError,\n RadarServerError,\n RadarUnauthorizedError,\n RadarUnknownError,\n} from './errors';\nimport Logger from './logger';\nimport Navigator from './navigator';\n\n/** HTTP methods supported by the SDK */\ntype HttpMethod = 'GET' | 'PUT' | 'PATCH' | 'POST' | 'DELETE';\n\n/** Shape of the `meta` field present in all Radar API responses */\ninterface RadarApiMeta {\n error?: string;\n message?: string;\n type?: string;\n}\n\n/** Base shape all Radar API JSON responses share */\ninterface RadarApiResponse {\n meta?: RadarApiMeta;\n [key: string]: unknown;\n}\n\n/** Blob response shape returned when responseType is 'blob' */\ninterface RadarBlobResponse {\n meta?: undefined;\n code: number;\n data: Blob;\n}\n\nexport type RadarResponse = RadarApiResponse | RadarBlobResponse;\n\n/** Request configuration for Http.request */\ninterface HttpRequestOptions {\n method: HttpMethod;\n path: string;\n data?: Record<string, any>;\n host?: string;\n version?: string;\n headers?: Record<string, string>;\n responseType?: 'blob' | 'json';\n requestId?: string;\n}\n\nconst inFlightRequests = new Map<string, AbortController>();\n\n/** fetch-based HTTP client for Radar API requests */\nclass Http {\n /** map of host patterns to custom error factories for intercepting network errors */\n static errorInterceptors: Map<string, (online: boolean) => Error> = new Map();\n\n /**\n * register a custom error factory for network errors matching a host pattern\n * @param hostPattern - substring matched against the request host\n * @param handler - factory that receives online status and returns an error\n */\n static registerErrorInterceptor(hostPattern: string, handler: (online: boolean) => Error) {\n Http.errorInterceptors.set(hostPattern, handler);\n }\n\n /**\n * send an HTTP request to the Radar API\n * @param options - request configuration\n * @returns parsed response body, typed as `T`\n * @throws {RadarPublishableKeyError} if neither publishable key nor authToken is set\n * @throws {RadarBadRequestError} on 400 responses\n * @throws {RadarUnauthorizedError} on 401 responses\n * @throws {RadarNetworkError} on network failures\n */\n static async request(options: HttpRequestOptions & { responseType: 'blob' }): Promise<RadarBlobResponse>;\n static async request<T extends Record<string, any> = RadarApiResponse>(\n options: HttpRequestOptions,\n ): Promise<T & { meta?: RadarApiMeta }>;\n static async request<T extends Record<string, any> = RadarApiResponse>({\n method,\n path,\n data,\n host,\n version,\n headers = {},\n responseType,\n requestId,\n }: HttpRequestOptions): Promise<(T & { meta?: RadarApiMeta }) | RadarBlobResponse> {\n const options = Config.get();\n\n const { publishableKey, authToken } = options;\n if (!publishableKey && !authToken) {\n throw new RadarPublishableKeyError('publishableKey or authToken not set.');\n }\n\n const urlHost = host || options.host;\n const urlVersion = version || options.version;\n let url = `${urlHost}/${urlVersion}/${path}`;\n\n // filter out undefined values from request data\n const filtered = Object.fromEntries(Object.entries(data ?? {}).filter(([, v]) => v !== undefined));\n\n let body: string | undefined;\n\n if (method === 'GET') {\n const params = new URLSearchParams(Object.entries(filtered).map(([k, v]) => [k, String(v)]));\n const qs = params.toString();\n if (qs) {\n url = `${url}?${qs}`;\n }\n } else {\n body = JSON.stringify(filtered);\n }\n\n // abort in-flight requests with matching requestIds\n if (requestId) {\n inFlightRequests.get(requestId)?.abort();\n }\n\n const abortController = new AbortController();\n\n if (requestId) {\n inFlightRequests.set(requestId, abortController);\n }\n\n const allHeaders: Record<string, string> = {\n 'Content-Type': 'application/json',\n ...Config.getDefaultHeaders(),\n ...headers,\n };\n\n let response: Response;\n try {\n response = await fetch(url, {\n method,\n headers: allHeaders,\n body,\n signal: abortController.signal,\n });\n } catch {\n // Delete abort controller instance for this request ID if it hasn't yet been replaced with a different one\n if (requestId && inFlightRequests.get(requestId) === abortController) {\n inFlightRequests.delete(requestId);\n }\n\n if (host) {\n for (const [pattern, handler] of Http.errorInterceptors) {\n if (host.includes(pattern)) {\n throw handler(!!Navigator.online());\n }\n }\n }\n throw new RadarNetworkError();\n }\n\n if (requestId && inFlightRequests.get(requestId) === abortController) {\n inFlightRequests.delete(requestId);\n }\n\n let parsed: RadarResponse | undefined;\n try {\n if (responseType === 'blob') {\n parsed = { code: response.status, data: await response.blob() };\n } else {\n parsed = (await response.json()) as RadarApiResponse;\n }\n } catch (err) {\n if (parsed) {\n throw new RadarServerError(parsed);\n } else {\n if (options.debug) {\n Logger.debug(`API call failed: ${url}`);\n Logger.debug(String(err));\n }\n throw new RadarUnknownError(parsed);\n }\n }\n\n if (parsed && typeof parsed === 'object' && 'meta' in parsed) {\n const error = parsed.meta?.error;\n if (error === 'ERROR_PERMISSIONS') {\n throw new RadarPermissionsError('Location permissions not granted.');\n } else if (error === 'ERROR_LOCATION') {\n throw new RadarLocationError('Could not determine location.');\n } else if (error === 'ERROR_NETWORK') {\n throw new RadarNetworkError();\n }\n }\n\n if (response.ok) {\n return parsed as T;\n }\n if (options.debug) {\n Logger.debug(`API call failed: ${url}`);\n Logger.debug(JSON.stringify(parsed));\n }\n\n if (response.status === 400) {\n throw new RadarBadRequestError(parsed);\n } else if (response.status === 401) {\n throw new RadarUnauthorizedError(parsed);\n } else if (response.status === 402) {\n throw new RadarPaymentRequiredError(parsed);\n } else if (response.status === 403) {\n throw new RadarForbiddenError(parsed);\n } else if (response.status === 404) {\n throw new RadarNotFoundError(parsed);\n } else if (response.status === 429) {\n throw new RadarRateLimitError(parsed);\n } else if (response.status >= 500 && response.status < 600) {\n throw new RadarServerError(parsed);\n } else {\n throw new RadarUnknownError(parsed);\n }\n }\n}\n\nexport default Http;\n","import Config from '../config';\nimport Http from '../http';\n\nimport type { RadarValidateAddressParams, RadarValidateAddressResponse } from '../types';\n\n/** @internal address validation API — use {@link Radar.validateAddress} instead */\nclass AddressesAPI {\n /**\n * validate a structured address\n * @param params - address fields to validate\n * @returns validated address and verification result\n */\n static async validateAddress(params: RadarValidateAddressParams): Promise<RadarValidateAddressResponse> {\n const options = Config.get();\n\n const response = await Http.request<Omit<RadarValidateAddressResponse, 'response'>>({\n method: 'GET',\n path: 'addresses/validate',\n data: params,\n });\n const { address, result } = response;\n\n const validateAddressRes: RadarValidateAddressResponse = {\n address,\n result,\n };\n\n if (options.debug) {\n validateAddressRes.response = response;\n }\n\n return validateAddressRes;\n }\n}\n\nexport default AddressesAPI;\n","import Storage from './storage';\n\nconst generateUUID = (): string => {\n if (typeof crypto !== 'undefined' && crypto.randomUUID) {\n return crypto.randomUUID();\n }\n\n // fallback for older browsers\n const bytes = new Uint8Array(16);\n crypto.getRandomValues(bytes);\n bytes[6] = (bytes[6]! & 0x0f) | 0x40; // version 4\n bytes[8] = (bytes[8]! & 0x3f) | 0x80; // variant 10\n\n const hex = Array.from(bytes, (b) => b.toString(16).padStart(2, '0')).join('');\n return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;\n};\n\n/** device and install ID manager backed by localStorage */\nclass Device {\n /**\n * get or generate a persistent device ID\n * @returns the device UUID (persisted in localStorage)\n */\n static getDeviceId(): string {\n // use existing deviceId if present\n const deviceId = Storage.getItem(Storage.DEVICE_ID);\n if (deviceId) {\n return deviceId;\n }\n\n // generate new deviceId\n const uuid = generateUUID();\n Storage.setItem(Storage.DEVICE_ID, uuid);\n return uuid;\n }\n\n /**\n * get or generate a persistent install ID\n * @returns the install UUID (persisted in localStorage)\n */\n static getInstallId(): string {\n // use existing installId if present\n const deviceId = Storage.getItem(Storage.INSTALL_ID);\n if (deviceId) {\n return deviceId;\n }\n\n // generate new installId\n const uuid = generateUUID();\n Storage.setItem(Storage.INSTALL_ID, uuid);\n return uuid;\n }\n}\n\nexport default Device;\n","import Storage from './storage';\n\nconst SESSION_TIMEOUT_SECS = 300; // 5 mins\n\nconst isValid = (sessionId: string): boolean => {\n const now = Math.trunc(Date.now() / 1000);\n const session = Number.parseInt(sessionId);\n const diff = Math.abs(now - session);\n return diff < SESSION_TIMEOUT_SECS;\n};\n\n/** session ID manager with a 5-minute timeout */\nclass Session {\n /**\n * get the current session ID, creating a new one if expired\n * @returns unix timestamp string used as session ID\n */\n static getSessionId() {\n const sessionId = Storage.getItem(Storage.SESSION_ID);\n\n // reuse session if still within 5 min threshold\n if (sessionId && isValid(sessionId)) {\n return sessionId;\n }\n\n // create new session if does not already exist or expired\n const newSessionId = Math.trunc(Date.now() / 1000).toString(); // unix ts in seconds\n Storage.setItem(Storage.SESSION_ID, newSessionId);\n return newSessionId;\n }\n}\n\nexport default Session;\n","import Device from '../device';\nimport Http from '../http';\nimport Logger from '../logger';\nimport Navigator from '../navigator';\nimport Session from '../session';\n\nimport type { LocationAuthorization, RadarConfigResponse, RadarTrackParams } from '../types';\n\n/** options for customizing the config request (e.g. host, headers) */\ninterface ConfigRequestOptions {\n /** override the API host */\n host?: string;\n /** additional headers to include in the request */\n headers?: Record<string, string>;\n}\n\n/** @internal SDK configuration API for fetching remote config */\nclass ConfigAPI {\n /**\n * fetch remote SDK configuration from the Radar API. Generic so plugins can extend the response shape.\n *\n * @param params - optional tracking params for device/session identification\n * @param options - optional request overrides (host, headers)\n */\n public static async getConfig<T extends RadarConfigResponse = RadarConfigResponse>(\n params: RadarTrackParams = {},\n options: ConfigRequestOptions = {},\n ): Promise<T> {\n const deviceId = params.deviceId || Device.getDeviceId();\n const installId = params.installId || Device.getInstallId();\n const sessionId = Session.getSessionId();\n\n // location authorization\n let locationAuthorization: LocationAuthorization | undefined;\n try {\n locationAuthorization = await Navigator.getPermissionStatus();\n } catch (err: any) {\n Logger.warn(`Location authorization error: ${err.message}`);\n }\n\n const data = {\n deviceId,\n installId,\n sessionId,\n locationAuthorization,\n };\n\n return Http.request<T>({\n method: 'GET',\n path: 'config',\n data,\n host: options.host,\n headers: options.headers,\n });\n }\n}\n\nexport default ConfigAPI;\n","import Config from '../config';\nimport Http from '../http';\nimport Navigator from '../navigator';\n\nimport type { RadarContextResponse, Location } from '../types';\n\n/** @internal context API — use {@link Radar.getContext} instead */\nclass ContextAPI {\n /**\n * get context (geofences, place, region) for a location\n * @param location - coordinates to get context for\n * @returns geofences, place, country, state, DMA, and postal code\n */\n public static async getContext(location: Location): Promise<RadarContextResponse> {\n const options = Config.get();\n\n // get device location if coordinates not provided\n if (!location.latitude || !location.longitude) {\n location = await Navigator.getCurrentPosition();\n }\n\n const { latitude, longitude, accuracy } = location;\n\n const response = await Http.request<Omit<RadarContextResponse, 'response' | 'location'>>({\n method: 'GET',\n path: 'context',\n data: {\n coordinates: `${latitude},${longitude}`,\n accuracy,\n },\n });\n\n const { geofences, place, country, state, dma, postalCode } = response;\n\n const contextRes: RadarContextResponse = {\n location,\n geofences,\n place,\n country,\n state,\n dma,\n postalCode,\n };\n\n if (options.debug) {\n contextRes.response = response;\n }\n\n return contextRes;\n }\n}\n\nexport default ContextAPI;\n","import Config from '../config';\nimport Device from '../device';\nimport Http from '../http';\nimport Storage from '../storage';\n\nimport type { RadarConversionParams, RadarConversionResponse } from '../types';\n\n/** @internal conversions API — use {@link Radar.logConversion} instead */\nclass ConversionsAPI {\n /**\n * log a conversion event\n * @param params - conversion name, user info, and optional metadata/revenue\n * @returns the created event\n */\n static async logConversion(params: RadarConversionParams): Promise<RadarConversionResponse> {\n const options = Config.get();\n\n const name = params.name;\n const userId = params.userId || Storage.getItem(Storage.USER_ID);\n const deviceId = params.deviceId || Device.getDeviceId();\n const installId = params.installId || Device.getInstallId();\n const metadata = params.metadata || {};\n const createdAt = params.createdAt;\n\n if (params.revenue) {\n metadata.revenue = params.revenue;\n }\n\n const createdAtValue =\n typeof createdAt === 'string'\n ? createdAt\n : createdAt instanceof Date\n ? createdAt.toISOString()\n : new Date().toISOString();\n\n const data = {\n name,\n userId,\n deviceId,\n installId,\n metadata,\n createdAt: createdAtValue,\n };\n\n const response = await Http.request<Omit<RadarConversionResponse, 'response'>>({\n method: 'POST',\n path: 'events',\n data,\n });\n\n const conversionRes: RadarConversionResponse = {\n event: response.event,\n };\n\n if (options.debug) {\n conversionRes.response = response;\n }\n\n return conversionRes;\n }\n}\n\nexport default ConversionsAPI;\n","import Config from '../config';\nimport Http from '../http';\nimport Navigator from '../navigator';\n\nimport type {\n RadarForwardGeocodeParams,\n RadarReverseGeocodeParams,\n RadarGeocodeResponse,\n RadarIPGeocodeResponse,\n} from '../types';\n\n/** @internal geocoding API — use Radar.forwardGeocode / reverseGeocode / ipGeocode instead */\nclass Geocoding {\n /**\n * geocode an address or place name to coordinates\n * @param params - query string, optional layers and country filter\n * @returns matching addresses\n */\n static async forwardGeocode(params: RadarForwardGeocodeParams): Promise<RadarGeocodeResponse> {\n const options = Config.get();\n\n const { query, layers, country, lang } = params;\n\n const response = await Http.request<Omit<RadarGeocodeResponse, 'response'>>({\n method: 'GET',\n path: 'geocode/forward',\n data: {\n query,\n layers,\n country,\n lang,\n },\n });\n\n const forwardGeocodeRes: RadarGeocodeResponse = {\n addresses: response.addresses,\n };\n\n if (options.debug) {\n forwardGeocodeRes.response = response;\n }\n\n return forwardGeocodeRes;\n }\n\n /**\n * reverse geocode coordinates to addresses\n * @param params - latitude/longitude, optional layers filter\n * @returns matching addresses\n */\n static async reverseGeocode(params: RadarReverseGeocodeParams): Promise<RadarGeocodeResponse> {\n const options = Config.get();\n\n const { layers } = params;\n let { latitude, longitude } = params;\n\n if (!latitude || !longitude) {\n const location = await Navigator.getCurrentPosition();\n latitude = location.latitude;\n longitude = location.longitude;\n }\n\n const response = await Http.request<Omit<RadarGeocodeResponse, 'response'>>({\n method: 'GET',\n path: 'geocode/reverse',\n data: {\n coordinates: `${latitude},${longitude}`,\n layers,\n },\n });\n\n const reverseGeocodeRes: RadarGeocodeResponse = {\n addresses: response.addresses,\n };\n\n if (options.debug) {\n reverseGeocodeRes.response = response;\n }\n\n return reverseGeocodeRes;\n }\n\n /**\n * geocode the device's IP address to a rough location\n * @returns IP address, approximate address, and proxy info\n */\n static async ipGeocode(): Promise<RadarIPGeocodeResponse> {\n const options = Config.get();\n\n const response = await Http.request<Omit<RadarIPGeocodeResponse, 'response'>>({\n method: 'GET',\n path: 'geocode/ip',\n });\n\n const ipGeocodeRes: RadarIPGeocodeResponse = {\n ip: response.ip,\n address: response.address,\n proxy: response.proxy,\n };\n\n if (options.debug) {\n ipGeocodeRes.response = response;\n }\n\n return ipGeocodeRes;\n }\n}\n\nexport default Geocoding;\n","import Config from '../config';\nimport Http from '../http';\nimport Navigator from '../navigator';\n\nimport type { RadarDistanceParams, RadarRouteResponse, RadarMatrixParams, RadarMatrixResponse } from '../types';\n\n/** @internal routing API — use Radar.distance / matrix instead */\nclass RoutingAPI {\n /**\n * calculate travel distance and duration between two points\n * @param params - origin, destination, modes, and units\n * @returns routes with distance and duration per mode\n */\n static async distance(params: RadarDistanceParams): Promise<RadarRouteResponse> {\n const options = Config.get();\n\n const { units, geometry, geometryPoints } = params;\n let { origin, destination, modes, avoid } = params;\n\n // use browser location if \"near\" not provided\n if (!origin) {\n const { latitude, longitude } = await Navigator.getCurrentPosition();\n origin = `${latitude},${longitude}`;\n } else if (typeof origin !== 'string') {\n // origin is \"Location\" object\n const { latitude, longitude } = origin;\n origin = `${latitude},${longitude}`;\n }\n\n if (typeof destination !== 'string') {\n const { latitude, longitude } = destination;\n destination = `${latitude},${longitude}`;\n }\n\n if (Array.isArray(modes)) {\n modes = modes.join(',');\n }\n\n if (Array.isArray(avoid)) {\n avoid = avoid.join(',');\n }\n\n const response = await Http.request<Omit<RadarRouteResponse, 'response'>>({\n method: 'GET',\n path: 'route/distance',\n data: {\n origin,\n destination,\n modes,\n units,\n geometry,\n geometryPoints,\n avoid,\n },\n });\n\n const distanceRes: RadarRouteResponse = {\n routes: response.routes,\n };\n\n if (options.debug) {\n distanceRes.response = response;\n }\n\n return distanceRes;\n }\n\n /**\n * calculate a distance matrix between multiple origins and destinations\n * @param params - origins, destinations, mode, and units\n * @returns matrix of distances and durations\n */\n static async matrix(params: RadarMatrixParams): Promise<RadarMatrixResponse> {\n const options = Config.get();\n\n const { mode, units } = params;\n let { origins, destinations, avoid } = params;\n\n // use browser location if \"near\" not provided\n if (!origins) {\n const { latitude, longitude } = await Navigator.getCurrentPosition();\n const originStrings = [];\n for (let i = 0; i < destinations.length; i++) {\n originStrings.push(`${latitude},${longitude}`);\n }\n origins = originStrings.join('|');\n } else if (Array.isArray(origins)) {\n // origin is a list of \"Location\" objects\n origins = origins.map((location) => `${location.latitude},${location.longitude}`).join('|');\n }\n\n // convert array to pipe-delimited string\n if (Array.isArray(destinations)) {\n destinations = destinations.map((location) => `${location.latitude},${location.longitude}`).join('|');\n }\n\n if (Array.isArray(avoid)) {\n avoid = avoid.join(',');\n }\n\n const response = await Http.request<Omit<RadarMatrixResponse, 'response'>>({\n method: 'GET',\n path: 'route/matrix',\n data: {\n origins,\n destinations,\n mode,\n units,\n avoid,\n },\n });\n\n const matrixRes: RadarMatrixResponse = {\n origins: response.origins,\n destinations: response.destinations,\n matrix: response.matrix,\n };\n\n if (options.debug) {\n matrixRes.response = response;\n }\n\n return matrixRes;\n }\n}\n\nexport default RoutingAPI;\n","import Config from '../config';\nimport Http from '../http';\nimport Navigator from '../navigator';\n\nimport type {\n RadarAutocompleteParams,\n RadarAutocompleteResponse,\n RadarSearchPlacesParams,\n RadarSearchPlacesResponse,\n RadarSearchGeofencesParams,\n RadarSearchGeofencesResponse,\n} from '../types';\n\n/** @internal search API — use Radar.autocomplete / searchGeofences / searchPlaces instead */\nclass SearchAPI {\n /**\n * autocomplete partial addresses and place names\n * @param params - query and search configuration\n * @param requestId - optional ID for deduplicating in-flight requests\n * @returns matching addresses\n */\n static async autocomplete(params: RadarAutocompleteParams, requestId?: string): Promise<RadarAutocompleteResponse> {\n const options = Config.get();\n\n const { query, limit, layers, countryCode, expandUnits, mailable, lang, postalCode } = params;\n let { near } = params;\n\n // near can be provided as a string or Location object\n // if \"near\" is not provided, request will fallback to IP based location\n if (near && typeof near !== 'string') {\n if (near.latitude && near.longitude) {\n near = `${near.latitude},${near.longitude}`;\n }\n }\n\n const response = await Http.request<Omit<RadarAutocompleteResponse, 'response'>>({\n method: 'GET',\n path: 'search/autocomplete',\n data: {\n query,\n near,\n limit,\n layers,\n countryCode,\n expandUnits,\n mailable,\n lang,\n postalCode,\n },\n requestId,\n });\n\n const autocompleteRes: RadarAutocompleteResponse = {\n addresses: response.addresses,\n };\n\n if (options.debug) {\n autocompleteRes.response = response;\n }\n\n return autocompleteRes;\n }\n\n /**\n * search for geofences near a location\n * @param params - location, radius, tags, and filters\n * @returns matching geofences\n */\n static async searchGeofences(params: RadarSearchGeofencesParams): Promise<RadarSearchGeofencesResponse> {\n const options = Config.get();\n\n const { radius, metadata, limit, includeGeometry } = params;\n let { near, tags } = params;\n\n // use browser location if \"near\" not provided\n if (!near) {\n const { latitude, longitude } = await Navigator.getCurrentPosition();\n near = `${latitude},${longitude}`;\n } else if (typeof near !== 'string') {\n // near is \"Location\" object\n const { latitude, longitude } = near;\n near = `${latitude},${longitude}`;\n }\n\n // convert arrays to comma-strings\n if (Array.isArray(tags)) {\n tags = tags.join(',');\n }\n\n const response = await Http.request<Omit<RadarSearchGeofencesResponse, 'response'>>({\n method: 'GET',\n path: 'search/geofences',\n data: {\n near,\n radius,\n tags,\n metadata,\n limit,\n includeGeometry,\n },\n });\n\n const geofencesSearchRes: RadarSearchGeofencesResponse = {\n geofences: response.geofences,\n };\n\n if (options.debug) {\n geofencesSearchRes.response = response;\n }\n\n return geofencesSearchRes;\n }\n\n /**\n * search for places near a location\n * @param params - location, radius, chains, categories, and groups\n * @returns matching places\n */\n static async searchPlaces(params: RadarSearchPlacesParams): Promise<RadarSearchPlacesResponse> {\n const options = Config.get();\n\n const { radius, limit } = params;\n let { near, chains, categories, groups } = params;\n\n // use browser location if \"near\" not provided\n if (!near) {\n const { latitude, longitude } = await Navigator.getCurrentPosition();\n near = `${latitude},${longitude}`;\n } else if (typeof near !== 'string') {\n // near is \"Location\" object\n const { latitude, longitude } = near;\n near = `${latitude},${longitude}`;\n }\n\n // convert arrays to comma-strings\n if (Array.isArray(chains)) {\n chains = chains.join(',');\n }\n if (Array.isArray(categories)) {\n categories = categories.join(',');\n }\n if (Array.isArray(groups)) {\n groups = groups.join(',');\n }\n\n const response = await Http.request<Omit<RadarSearchPlacesResponse, 'response'>>({\n method: 'GET',\n path: 'search/places',\n data: {\n near,\n radius,\n chains,\n categories,\n groups,\n limit,\n },\n });\n\n const placeSearchRes: RadarSearchPlacesResponse = {\n places: response.places,\n };\n\n if (options.debug) {\n placeSearchRes.response = response;\n }\n\n return placeSearchRes;\n }\n}\n\nexport default SearchAPI;\n","import Config from '../config';\nimport Http from '../http';\nimport Logger from '../logger';\nimport Storage from '../storage';\n\nimport type { RadarTripOptions, RadarTripStatus, RadarTripResponse } from '../types';\n\n// https://stackoverflow.com/a/44198641\nconst isValidDate = (date: any): Date | undefined =>\n date && Object.prototype.toString.call(date) === '[object Date]' && !isNaN(date);\n\n/** @internal trips API — use Radar.startTrip / updateTrip / completeTrip / cancelTrip instead */\nclass TripsAPI {\n /** save trip options to localStorage, pass `undefined` to clear */\n static setTripOptions(tripOptions?: RadarTripOptions) {\n if (!tripOptions) {\n TripsAPI.clearTripOptions();\n return;\n }\n const tripOptionsString = JSON.stringify(tripOptions);\n Logger.debug(`Saving trip options: ${tripOptionsString}`);\n Storage.setItem(Storage.TRIP_OPTIONS, tripOptionsString);\n }\n\n /** get saved trip options from localStorage */\n static getTripOptions(): RadarTripOptions {\n let tripOptions = Storage.getItem(Storage.TRIP_OPTIONS);\n if (tripOptions) {\n tripOptions = JSON.parse(tripOptions);\n }\n return tripOptions as RadarTripOptions;\n }\n\n /** remove saved trip options from localStorage */\n static clearTripOptions() {\n Storage.removeItem(Storage.TRIP_OPTIONS);\n }\n\n /**\n * start a new trip\n * @param tripOptions - trip configuration and destination\n * @returns the created trip and any triggered events\n */\n static async startTrip(tripOptions: RadarTripOptions): Promise<RadarTripResponse> {\n const options = Config.get();\n tripOptions = tripOptions || TripsAPI.getTripOptions();\n\n if (!tripOptions) {\n Logger.warn('tripOptions not set when calling \"startTrip\"');\n }\n\n const userId = tripOptions.userId || Storage.getItem(Storage.USER_ID);\n if (userId && userId !== Storage.getItem(Storage.USER_ID)) {\n // set as userId for tracking if provided\n Storage.setItem(Storage.USER_ID, userId);\n }\n\n const {\n externalId,\n destinationGeofenceTag,\n destinationGeofenceExternalId,\n mode,\n metadata,\n approachingThreshold,\n scheduledArrivalAt,\n } = tripOptions;\n\n if (scheduledArrivalAt && !isValidDate(scheduledArrivalAt)) {\n Logger.warn('Invalid date format for scheduledArrivalAt');\n }\n\n const data = {\n userId,\n externalId,\n destinationGeofenceTag,\n destinationGeofenceExternalId,\n mode,\n metadata,\n approachingThreshold,\n scheduledArrivalAt: isValidDate(scheduledArrivalAt) ? scheduledArrivalAt!.toJSON() : undefined,\n };\n\n const response = await Http.request<Omit<RadarTripResponse, 'response'>>({\n method: 'POST',\n path: 'trips',\n data,\n });\n\n // save trip options\n TripsAPI.setTripOptions(tripOptions);\n\n const tripRes: RadarTripResponse = {\n trip: response.trip,\n events: response.events,\n };\n\n if (options.debug) {\n tripRes.response = response;\n }\n\n return tripRes;\n }\n\n /**\n * update an in-progress trip\n * @param tripOptions - updated trip configuration\n * @param status - optional trip status override\n * @returns the updated trip and any triggered events\n */\n static async updateTrip(tripOptions: RadarTripOptions, status?: RadarTripStatus): Promise<RadarTripResponse> {\n const options = Config.get();\n tripOptions = tripOptions || TripsAPI.getTripOptions();\n\n if (!tripOptions) {\n Logger.warn('tripOptions not set when calling \"startTrip\"');\n }\n\n const {\n externalId,\n destinationGeofenceTag,\n destinationGeofenceExternalId,\n mode,\n metadata,\n approachingThreshold,\n scheduledArrivalAt,\n } = tripOptions;\n\n if (scheduledArrivalAt && !isValidDate(scheduledArrivalAt)) {\n Logger.warn('Invalid date format for scheduledArrivalAt');\n }\n\n const data = {\n status,\n externalId,\n destinationGeofenceTag,\n destinationGeofenceExternalId,\n mode,\n metadata,\n approachingThreshold,\n scheduledArrivalAt: isValidDate(scheduledArrivalAt) ? scheduledArrivalAt!.toJSON() : undefined,\n };\n\n const response = await Http.request<Omit<RadarTripResponse, 'response'>>({\n method: 'PATCH',\n path: `trips/${externalId}/update`,\n data,\n });\n\n const tripRes: RadarTripResponse = {\n trip: response.trip,\n events: response.events,\n };\n\n if (options.debug) {\n tripRes.response = response;\n }\n\n return tripRes;\n }\n\n /** complete the current trip and clear local trip options */\n static async completeTrip(): Promise<RadarTripResponse> {\n const tripOptions = TripsAPI.getTripOptions();\n const tripResponse = await TripsAPI.updateTrip(tripOptions, 'completed');\n\n // clear local trip options\n TripsAPI.clearTripOptions();\n\n return tripResponse;\n }\n\n /** cancel the current trip and clear local trip options */\n static async cancelTrip(): Promise<RadarTripResponse> {\n const tripOptions = TripsAPI.getTripOptions();\n const tripResponse = await TripsAPI.updateTrip(tripOptions, 'canceled');\n\n // clear local trip options\n TripsAPI.clearTripOptions();\n\n return tripResponse;\n }\n}\n\nexport default TripsAPI;\n","import Config from '../config';\nimport Device from '../device';\nimport Http from '../http';\nimport Logger from '../logger';\nimport Navigator from '../navigator';\nimport Session from '../session';\nimport Storage from '../storage';\nimport SDK_VERSION from '../version';\nimport TripsAPI from './trips';\n\nimport type { RadarTrackParams, RadarTrackResponse } from '../types';\n\n/** @internal tracking API — use {@link Radar.trackOnce} instead */\nclass TrackAPI {\n /**\n * track the user's current location once\n * @param params - tracking parameters (location, user info, trip options)\n * @returns tracked user, events, and location\n */\n static async trackOnce(params: RadarTrackParams) {\n const options = Config.get();\n\n const { desiredAccuracy } = params;\n let { latitude, longitude, accuracy } = params;\n\n // if latitude & longitude are not provided,\n // try and retrieve device location (will prompt for location permissions)\n if (!latitude || !longitude) {\n const deviceLocation = await Navigator.getCurrentPosition({ desiredAccuracy });\n latitude = deviceLocation.latitude;\n longitude = deviceLocation.longitude;\n accuracy = deviceLocation.accuracy;\n }\n\n // location authorization\n const locationAuthorization = await Navigator.getPermissionStatus();\n\n // user indentification fields\n const userId = params.userId || Storage.getItem(Storage.USER_ID);\n const deviceId = params.deviceId || Device.getDeviceId();\n const installId = params.installId || Device.getInstallId();\n const sessionId = Session.getSessionId();\n const deviceType = params.deviceType || 'Web';\n const description = params.description || Storage.getItem(Storage.DESCRIPTION);\n\n // save userId for trip tracking\n if (!userId) {\n Logger.warn('userId not provided for trackOnce.');\n } else {\n Storage.setItem(Storage.USER_ID, userId);\n }\n\n // other info\n const metadata = params.metadata || Storage.getJSON(Storage.METADATA);\n\n // trips\n const tripOptions = params.tripOptions || TripsAPI.getTripOptions();\n if (tripOptions) {\n tripOptions.version = '2';\n }\n\n const body = {\n ...params,\n locationAuthorization,\n accuracy,\n description,\n deviceId,\n deviceType,\n foreground: true,\n installId,\n sessionId,\n latitude,\n longitude,\n metadata,\n sdkVersion: SDK_VERSION,\n stopped: true,\n userId,\n tripOptions,\n };\n\n const response = await Http.request<Omit<RadarTrackResponse, 'response' | 'location'>>({\n method: 'POST',\n path: 'track',\n data: body,\n });\n\n const { user, events } = response;\n const location = { latitude, longitude, accuracy };\n\n const trackRes: RadarTrackResponse = {\n user,\n events,\n location,\n };\n\n if (options.debug) {\n trackRes.response = response;\n }\n\n return trackRes;\n }\n}\n\nexport default TrackAPI;\n","import AddressesAPI from './api/addresses';\nimport ConfigAPI from './api/config';\nimport ContextAPI from './api/context';\nimport ConversionsAPI from './api/conversions';\nimport GeocodingAPI from './api/geocoding';\nimport RoutingAPI from './api/routing';\nimport SearchAPI from './api/search';\nimport TrackAPI from './api/track';\nimport TripsAPI from './api/trips';\nimport Config from './config';\nimport Device from './device';\nimport * as errors from './errors';\nimport { RadarPublishableKeyError } from './errors';\nimport Http from './http';\nimport Logger from './logger';\nimport Navigator from './navigator';\nimport Session from './session';\nimport Storage from './storage';\nimport SDK_VERSION from './version';\n\nimport type { RadarError } from './errors';\nimport type { RadarPlugin, RadarPluginContext, RadarStatic } from './plugin';\nimport type {\n Location,\n NavigatorPosition,\n RadarAutocompleteParams,\n RadarAutocompleteResponse,\n RadarContextResponse,\n RadarConversionParams,\n RadarConversionResponse,\n RadarDistanceParams,\n RadarForwardGeocodeParams,\n RadarGeocodeResponse,\n RadarIPGeocodeResponse,\n RadarMatrixParams,\n RadarMatrixResponse,\n RadarMetadata,\n RadarInitOptions,\n RadarOptions,\n RadarReverseGeocodeParams,\n RadarRouteResponse,\n RadarSearchGeofencesParams,\n RadarSearchGeofencesResponse,\n RadarSearchPlacesParams,\n RadarSearchPlacesResponse,\n RadarTrackParams,\n RadarTrackResponse,\n RadarTripOptions,\n RadarTripResponse,\n RadarValidateAddressParams,\n RadarValidateAddressResponse,\n} from './types';\n\nconst isSecretKey = (key: string): boolean => key.includes('_sk_');\nconst isLiveKey = (key: string): boolean => key.includes('_live_');\nconst isJWTShape = (value: string): boolean => {\n // NOTE(jasonl): keep this check lightweight since we're doing real validation server-side\n if (!value.startsWith('eyJ')) {\n return false;\n }\n const parts = value.split('.');\n return parts.length === 3 && parts.every((s) => s.length > 0);\n};\n\n/**\n * main entry point for the Radar SDK. all methods are static — do not instantiate.\n *\n * @example\n * ```ts\n * Radar.initialize({ publishableKey: 'prj_test_pk_...' });\n * const { user, events } = await Radar.trackOnce();\n * ```\n */\nclass Radar {\n private static _plugins: Map<string, RadarPlugin> = new Map();\n\n public static errors = errors;\n\n /** current SDK version string */\n public static get VERSION() {\n return SDK_VERSION;\n }\n\n /** register one or more plugins (e.g. maps, autocomplete, fraud) */\n public static registerPlugin(...plugins: RadarPlugin[]) {\n const ctx = Radar._getPluginContext();\n for (const plugin of plugins) {\n if (Radar._plugins.has(plugin.name)) {\n Logger.warn(`plugin \"${plugin.name}\" already registered.`);\n continue;\n }\n\n plugin.install(ctx);\n Radar._plugins.set(plugin.name, plugin);\n }\n }\n\n private static _getPluginContext(): RadarPluginContext {\n return {\n Radar: Radar as RadarStatic,\n Config,\n Http,\n Storage,\n Device,\n Session,\n Logger,\n Navigator,\n apis: {\n Addresses: AddressesAPI,\n Config: ConfigAPI,\n Context: ContextAPI,\n Conversions: ConversionsAPI,\n Geocoding: GeocodingAPI,\n Routing: RoutingAPI,\n Search: SearchAPI,\n Track: TrackAPI,\n Trips: TripsAPI,\n },\n };\n }\n /**\n * initialize the SDK with an authToken or publishable key via options object.\n * @param options - SDK configuration with `authToken` or `publishableKey`\n * @throws {RadarPublishableKeyError} if credentials are missing or invalid\n */\n public static initialize(options: RadarInitOptions): void;\n /**\n * initialize the SDK with a publishable key string.\n * @param publishableKey - your Radar publishable key (starts with `prj_test_pk_` or `prj_live_pk_`)\n * @param options - optional SDK configuration\n * @throws {RadarPublishableKeyError} if the key is missing or is a secret key\n */\n public static initialize(publishableKey: string, options?: RadarOptions): void;\n public static initialize(publishableKeyOrOptions: string | RadarInitOptions, extraOptions: RadarOptions = {}) {\n // NOTE(jasonl): shim the string signature into the options object to handle both cases\n const options: RadarOptions =\n typeof publishableKeyOrOptions === 'string'\n ? { publishableKey: publishableKeyOrOptions, ...extraOptions }\n : { ...publishableKeyOrOptions };\n\n if (options.publishableKey && options.authToken) {\n throw new RadarPublishableKeyError('Token and publishableKey are mutually exclusive.');\n }\n\n let credentialLabel: 'publishableKey' | 'authToken';\n\n if (options.publishableKey) {\n if (isSecretKey(options.publishableKey)) {\n throw new RadarPublishableKeyError('Secret keys are not allowed. Please use your Radar publishable key.');\n }\n options.live = isLiveKey(options.publishableKey);\n credentialLabel = 'publishableKey';\n } else if (options.authToken) {\n if (!isJWTShape(options.authToken)) {\n throw new RadarPublishableKeyError('Invalid authToken format. Expected a JWT.');\n }\n credentialLabel = 'authToken';\n } else {\n throw new RadarPublishableKeyError('Publishable key or authToken required in initialization.');\n }\n\n // NOTE(jasonl): for backwards compat with the old `live` option - if `debug` isn't explicitly set, we'll set it to the inverse of `live`\n options.debug = options.debug ?? (options.live !== undefined ? !options.live : false);\n options.logLevel = options.logLevel ?? (options.debug ? 'debug' : 'error');\n const radarOptions = Object.assign({}, Config.defaultOptions, options);\n Config.setup(radarOptions);\n\n Logger.info(`initialized with ${credentialLabel}.`);\n Logger.debug('using options', options);\n\n // NOTE(jasonl): this allows us to run jest tests\n // without having to mock the ConfigAPI.getConfig call\n if (!window?.RADAR_TEST_ENV) {\n ConfigAPI.getConfig().catch((err) => {\n Logger.warn(`Error calling /config: ${err.message}`);\n });\n }\n }\n\n /** clear all SDK state and configuration */\n public static clear() {\n Config.clear();\n }\n\n ///////////////////////\n // Geofencing Platform\n ///////////////////////\n\n /** set the user ID for tracking. pass `undefined` to clear. */\n public static setUserId(userId?: string) {\n if (!userId) {\n Storage.removeItem(Storage.USER_ID);\n return;\n }\n Storage.setItem(Storage.USER_ID, String(userId).trim());\n }\n\n /** set a description for the current user. pass `undefined` to clear. */\n public static setDescription(description?: string) {\n if (!description) {\n Storage.removeItem(Storage.DESCRIPTION);\n return;\n }\n Storage.setItem(Storage.DESCRIPTION, String(description).trim());\n }\n\n /** set custom metadata for the current user. pass `undefined` to clear. */\n public static setMetadata(metadata?: RadarMetadata) {\n if (!metadata) {\n Storage.removeItem(Storage.METADATA);\n return;\n }\n Storage.setItem(Storage.METADATA, JSON.stringify(metadata));\n }\n\n /** get the device's current location using the browser geolocation API */\n public static getLocation(): Promise<NavigatorPosition> {\n return Navigator.getCurrentPosition();\n }\n\n /** track the user's current location once, returning location context and events */\n public static trackOnce(params: RadarTrackParams = {}): Promise<RadarTrackResponse> {\n try {\n return TrackAPI.trackOnce(params);\n } finally {\n // call with updated permissions\n ConfigAPI.getConfig(params).catch((err) => {\n Logger.warn(`Error calling /config: ${err.message}`);\n });\n }\n }\n\n /** get context (geofences, place, regions) for a location without tracking */\n public static getContext(params: Location): Promise<RadarContextResponse> {\n return ContextAPI.getContext(params);\n }\n\n /** save trip options for tracking. pass `undefined` to clear */\n public static setTripOptions(tripOptions?: RadarTripOptions) {\n TripsAPI.setTripOptions(tripOptions);\n }\n\n /** clear saved trip options */\n public static clearTripOptions() {\n TripsAPI.clearTripOptions();\n }\n\n /** get the currently saved trip options */\n public static getTripOptions(): RadarTripOptions {\n return TripsAPI.getTripOptions();\n }\n\n /** start a new trip with the given options */\n public static startTrip(tripOptions: RadarTripOptions): Promise<RadarTripResponse> {\n return TripsAPI.startTrip(tripOptions);\n }\n\n /** update an in-progress trip */\n public static updateTrip(tripOptions: RadarTripOptions): Promise<RadarTripResponse> {\n return TripsAPI.updateTrip(tripOptions);\n }\n\n /** complete the current trip and clear local trip options */\n public static completeTrip(): Promise<RadarTripResponse> {\n return TripsAPI.completeTrip();\n }\n\n /** cancel the current trip and clear local trip options */\n public static cancelTrip(): Promise<RadarTripResponse> {\n return TripsAPI.cancelTrip();\n }\n\n /** log a conversion event */\n public static logConversion(params: RadarConversionParams): Promise<RadarConversionResponse> {\n return ConversionsAPI.logConversion(params);\n }\n\n /** set the product identifier for tracking requests. pass `undefined` to clear */\n public static setProduct(product?: string) {\n if (!product) {\n Storage.removeItem(Storage.PRODUCT);\n return;\n }\n Storage.setItem(Storage.PRODUCT, String(product).trim());\n }\n\n ///////////////////////\n // Listeners\n ///////////////////////\n\n /** register a global error callback invoked on SDK errors */\n public static onError(callback: (error: RadarError) => void) {\n Config.onError(callback);\n }\n\n /////////////////\n // Maps Platform\n /////////////////\n\n /** geocode an address or place name to coordinates */\n public static forwardGeocode(params: RadarForwardGeocodeParams): Promise<RadarGeocodeResponse> {\n return GeocodingAPI.forwardGeocode(params);\n }\n\n /** reverse geocode coordinates to addresses */\n public static reverseGeocode(params: RadarReverseGeocodeParams): Promise<RadarGeocodeResponse> {\n return GeocodingAPI.reverseGeocode(params);\n }\n\n /** geocode the device's IP address to a rough location */\n public static ipGeocode(): Promise<RadarIPGeocodeResponse> {\n return GeocodingAPI.ipGeocode();\n }\n\n /** autocomplete partial addresses and place names */\n public static autocomplete(params: RadarAutocompleteParams, requestId?: string): Promise<RadarAutocompleteResponse> {\n return SearchAPI.autocomplete(params, requestId);\n }\n\n /** search for geofences near a location */\n public static searchGeofences(params: RadarSearchGeofencesParams): Promise<RadarSearchGeofencesResponse> {\n return SearchAPI.searchGeofences(params);\n }\n\n /** search for places (POIs) near a location */\n public static searchPlaces(params: RadarSearchPlacesParams): Promise<RadarSearchPlacesResponse> {\n return SearchAPI.searchPlaces(params);\n }\n\n /** validate a structured address */\n public static validateAddress(params: RadarValidateAddressParams): Promise<RadarValidateAddressResponse> {\n return AddressesAPI.validateAddress(params);\n }\n\n /** calculate travel distance and duration between two points */\n public static distance(params: RadarDistanceParams): Promise<RadarRouteResponse> {\n return RoutingAPI.distance(params);\n }\n\n /** calculate a distance matrix between multiple origins and destinations */\n public static matrix(params: RadarMatrixParams): Promise<RadarMatrixResponse> {\n return RoutingAPI.matrix(params);\n }\n}\n\nexport default Radar;\n"],"names":["GeocodingAPI"],"mappings":"AAAA,kBAAe,OAAO;;ACKtB;AACA,MAAM,MAAM,CAAA;;AAgBH,IAAA,OAAO,KAAK,CAAC,OAAA,GAAwB,EAAE,EAAA;AAC5C,QAAA,MAAM,CAAC,OAAO,GAAG,OAAO;IAC1B;;AAGO,IAAA,OAAO,GAAG,GAAA;AACf,QAAA,OAAO,MAAM,CAAC,OAAO,IAAI,EAAE;IAC7B;;AAGO,IAAA,OAAO,KAAK,GAAA;AACjB,QAAA,MAAM,CAAC,OAAO,GAAG,EAAE;AACnB,QAAA,MAAM,CAAC,aAAa,GAAG,IAAI;IAC7B;;IAGO,OAAO,OAAO,CAAC,QAAqC,EAAA;AACzD,QAAA,MAAM,CAAC,aAAa,GAAG,QAAQ;IACjC;;IAGO,OAAO,SAAS,CAAC,KAAU,EAAA;AAChC,QAAA,IAAI,MAAM,CAAC,aAAa,IAAI,KAAK,EAAE;AACjC,YAAA,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC;QAC7B;IACF;AAEA;;AAEK;AACL,IAAA,OAAO,iBAAiB,GAAA;AACtB,QAAA,MAAM,EAAE,cAAc,EAAE,SAAS,EAAE,iBAAiB,EAAE,UAAU,EAAE,GAAG,MAAM,CAAC,GAAG,EAAE;AACjF,QAAA,MAAM,OAAO,GAA2B;AACtC,YAAA,qBAAqB,EAAE,KAAK;AAC5B,YAAA,qBAAqB,EAAE,WAAW;SACnC;QACD,IAAI,SAAS,EAAE;AACb,YAAA,OAAO,CAAC,aAAa,GAAG,CAAA,OAAA,EAAU,SAAS,EAAE;QAC/C;aAAO,IAAI,cAAc,EAAE;AAC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AAM,CAAC,MAAyB,EAAA;AAC5C,QAAA,OAAO,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC;IAClC;;AA5Qe,KAAA,CAAA,QAAQ,GAA6B,IAAI,GAAG,EAAE;AAE/C,KAAA,CAAA,MAAM,GAAG,MAAM;;;;"}
package/dist/types.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /** log verbosity level for the SDK */
2
- export type LogLevel = 'none' | 'info' | 'warn' | 'error';
2
+ export type LogLevel = 'none' | 'error' | 'warn' | 'info' | 'debug';
3
3
  /** a geographic coordinate with optional accuracy and timestamp */
4
4
  export interface Location {
5
5
  latitude: number;
@@ -18,11 +18,9 @@ export interface NavigatorPosition {
18
18
  }
19
19
  /** browser location permission state */
20
20
  export type LocationAuthorization = 'DENIED' | 'NOT_DETERMINED' | 'GRANTED_FOREGROUND';
21
- /** configuration options passed to {@link Radar.initialize} */
22
- export interface RadarOptions {
23
- /** Radar publishable key (set automatically by `initialize`) */
24
- publishableKey?: string;
25
- /** whether the key is a live key (set automatically) */
21
+ /** shared SDK configuration fields (excluding auth credentials) */
22
+ export interface RadarBaseOptions {
23
+ /** @deprecated use `debug` instead. inferred automatically from publishableKey. */
26
24
  live?: boolean;
27
25
  /** SDK log verbosity */
28
26
  logLevel?: LogLevel;
@@ -43,6 +41,28 @@ export interface RadarOptions {
43
41
  /** enable debug logging */
44
42
  debug?: boolean;
45
43
  }
44
+ /** options for initializing with a JWT auth token */
45
+ export interface RadarAuthTokenInitOptions extends RadarBaseOptions {
46
+ /** JWT auth token */
47
+ authToken: string;
48
+ live?: never;
49
+ publishableKey?: never;
50
+ }
51
+ /** options for initializing with a publishable key via the options object */
52
+ export interface RadarPublishableKeyInitOptions extends RadarBaseOptions {
53
+ /** Radar publishable key */
54
+ publishableKey: string;
55
+ authToken?: never;
56
+ }
57
+ /** configuration options passed to {@link Radar.initialize} */
58
+ export type RadarInitOptions = RadarAuthTokenInitOptions | RadarPublishableKeyInitOptions;
59
+ /** internal SDK configuration (all fields optional — stored by Config after initialization) */
60
+ export interface RadarOptions extends RadarBaseOptions {
61
+ /** Radar publishable key (set automatically by `initialize`) */
62
+ publishableKey?: string;
63
+ /** JWT auth Token (mutually exclusive with publishableKey) */
64
+ authToken?: string;
65
+ }
46
66
  /** response from GET /v1/config */
47
67
  export interface RadarConfigResponse {
48
68
  meta: {
package/dist/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- declare const _default: "5.0.0";
1
+ declare const _default: "5.1.0";
2
2
  export default _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "radar-sdk-js",
3
- "version": "5.0.0",
3
+ "version": "5.1.0",
4
4
  "description": "Web Javascript SDK for Radar, location infrastructure for mobile and web apps.",
5
5
  "homepage": "https://radar.com",
6
6
  "license": "ISC",
package/src/api.ts CHANGED
@@ -35,6 +35,7 @@ import type {
35
35
  RadarMatrixParams,
36
36
  RadarMatrixResponse,
37
37
  RadarMetadata,
38
+ RadarInitOptions,
38
39
  RadarOptions,
39
40
  RadarReverseGeocodeParams,
40
41
  RadarRouteResponse,
@@ -52,13 +53,21 @@ import type {
52
53
 
53
54
  const isSecretKey = (key: string): boolean => key.includes('_sk_');
54
55
  const isLiveKey = (key: string): boolean => key.includes('_live_');
56
+ const isJWTShape = (value: string): boolean => {
57
+ // NOTE(jasonl): keep this check lightweight since we're doing real validation server-side
58
+ if (!value.startsWith('eyJ')) {
59
+ return false;
60
+ }
61
+ const parts = value.split('.');
62
+ return parts.length === 3 && parts.every((s) => s.length > 0);
63
+ };
55
64
 
56
65
  /**
57
66
  * main entry point for the Radar SDK. all methods are static — do not instantiate.
58
67
  *
59
68
  * @example
60
69
  * ```ts
61
- * Radar.initialize('prj_test_pk_...');
70
+ * Radar.initialize({ publishableKey: 'prj_test_pk_...' });
62
71
  * const { user, events } = await Radar.trackOnce();
63
72
  * ```
64
73
  */
@@ -109,42 +118,55 @@ class Radar {
109
118
  },
110
119
  };
111
120
  }
112
-
113
121
  /**
114
- * initialize the SDK with a publishable key. must be called before any other method.
122
+ * initialize the SDK with an authToken or publishable key via options object.
123
+ * @param options - SDK configuration with `authToken` or `publishableKey`
124
+ * @throws {RadarPublishableKeyError} if credentials are missing or invalid
125
+ */
126
+ public static initialize(options: RadarInitOptions): void;
127
+ /**
128
+ * initialize the SDK with a publishable key string.
115
129
  * @param publishableKey - your Radar publishable key (starts with `prj_test_pk_` or `prj_live_pk_`)
116
130
  * @param options - optional SDK configuration
117
131
  * @throws {RadarPublishableKeyError} if the key is missing or is a secret key
118
132
  */
119
- public static initialize(publishableKey: string, options: RadarOptions = {}) {
120
- if (!publishableKey) {
121
- throw new RadarPublishableKeyError('Publishable key required in initialization.');
133
+ public static initialize(publishableKey: string, options?: RadarOptions): void;
134
+ public static initialize(publishableKeyOrOptions: string | RadarInitOptions, extraOptions: RadarOptions = {}) {
135
+ // NOTE(jasonl): shim the string signature into the options object to handle both cases
136
+ const options: RadarOptions =
137
+ typeof publishableKeyOrOptions === 'string'
138
+ ? { publishableKey: publishableKeyOrOptions, ...extraOptions }
139
+ : { ...publishableKeyOrOptions };
140
+
141
+ if (options.publishableKey && options.authToken) {
142
+ throw new RadarPublishableKeyError('Token and publishableKey are mutually exclusive.');
122
143
  }
123
144
 
124
- if (isSecretKey(publishableKey)) {
125
- throw new RadarPublishableKeyError('Secret keys are not allowed. Please use your Radar publishable key.');
145
+ let credentialLabel: 'publishableKey' | 'authToken';
146
+
147
+ if (options.publishableKey) {
148
+ if (isSecretKey(options.publishableKey)) {
149
+ throw new RadarPublishableKeyError('Secret keys are not allowed. Please use your Radar publishable key.');
150
+ }
151
+ options.live = isLiveKey(options.publishableKey);
152
+ credentialLabel = 'publishableKey';
153
+ } else if (options.authToken) {
154
+ if (!isJWTShape(options.authToken)) {
155
+ throw new RadarPublishableKeyError('Invalid authToken format. Expected a JWT.');
156
+ }
157
+ credentialLabel = 'authToken';
158
+ } else {
159
+ throw new RadarPublishableKeyError('Publishable key or authToken required in initialization.');
126
160
  }
127
161
 
128
- // store settings in global config
129
- const live = isLiveKey(publishableKey);
130
- const logLevel = live ? 'error' : 'info';
131
- const debug = !live;
132
- const radarOptions = Object.assign(
133
- Config.defaultOptions,
134
- {
135
- publishableKey,
136
- live,
137
- logLevel,
138
- debug,
139
- },
140
- options,
141
- );
162
+ // NOTE(jasonl): for backwards compat with the old `live` option - if `debug` isn't explicitly set, we'll set it to the inverse of `live`
163
+ options.debug = options.debug ?? (options.live !== undefined ? !options.live : false);
164
+ options.logLevel = options.logLevel ?? (options.debug ? 'debug' : 'error');
165
+ const radarOptions = Object.assign({}, Config.defaultOptions, options);
142
166
  Config.setup(radarOptions);
143
167
 
144
- Logger.info(`initialized with ${live ? 'live' : 'test'} publishableKey.`);
145
- if (options.debug) {
146
- Logger.debug('using options', options);
147
- }
168
+ Logger.info(`initialized with ${credentialLabel}.`);
169
+ Logger.debug('using options', options);
148
170
 
149
171
  // NOTE(jasonl): this allows us to run jest tests
150
172
  // without having to mock the ConfigAPI.getConfig call
package/src/config.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import SDK_VERSION from './version';
2
+
1
3
  import type { RadarError } from './errors';
2
4
  import type { RadarOptions } from './types';
3
5
 
@@ -44,6 +46,26 @@ class Config {
44
46
  Config.errorCallback(error);
45
47
  }
46
48
  }
49
+
50
+ /** build standard Radar request headers (Authorization, Device-Type, SDK-Version).
51
+ * Callers must ensure credentials are set before calling (e.g. via Radar.initialize).
52
+ * */
53
+ static getDefaultHeaders(): Record<string, string> {
54
+ const { publishableKey, authToken, getRequestHeaders: getHeaders } = Config.get();
55
+ const headers: Record<string, string> = {
56
+ 'X-Radar-Device-Type': 'Web',
57
+ 'X-Radar-SDK-Version': SDK_VERSION,
58
+ };
59
+ if (authToken) {
60
+ headers.Authorization = `Bearer ${authToken}`;
61
+ } else if (publishableKey) {
62
+ headers.Authorization = publishableKey;
63
+ }
64
+ if (typeof getHeaders === 'function') {
65
+ Object.assign(headers, getHeaders());
66
+ }
67
+ return headers;
68
+ }
47
69
  }
48
70
 
49
71
  export default Config;
package/src/http.ts CHANGED
@@ -15,7 +15,6 @@ import {
15
15
  } from './errors';
16
16
  import Logger from './logger';
17
17
  import Navigator from './navigator';
18
- import SDK_VERSION from './version';
19
18
 
20
19
  /** HTTP methods supported by the SDK */
21
20
  type HttpMethod = 'GET' | 'PUT' | 'PATCH' | 'POST' | 'DELETE';
@@ -74,7 +73,7 @@ class Http {
74
73
  * send an HTTP request to the Radar API
75
74
  * @param options - request configuration
76
75
  * @returns parsed response body, typed as `T`
77
- * @throws {RadarPublishableKeyError} if publishable key is not set
76
+ * @throws {RadarPublishableKeyError} if neither publishable key nor authToken is set
78
77
  * @throws {RadarBadRequestError} on 400 responses
79
78
  * @throws {RadarUnauthorizedError} on 401 responses
80
79
  * @throws {RadarNetworkError} on network failures
@@ -95,9 +94,9 @@ class Http {
95
94
  }: HttpRequestOptions): Promise<(T & { meta?: RadarApiMeta }) | RadarBlobResponse> {
96
95
  const options = Config.get();
97
96
 
98
- const publishableKey = options.publishableKey;
99
- if (!publishableKey) {
100
- throw new RadarPublishableKeyError('publishableKey not set.');
97
+ const { publishableKey, authToken } = options;
98
+ if (!publishableKey && !authToken) {
99
+ throw new RadarPublishableKeyError('publishableKey or authToken not set.');
101
100
  }
102
101
 
103
102
  const urlHost = host || options.host;
@@ -130,20 +129,12 @@ class Http {
130
129
  inFlightRequests.set(requestId, abortController);
131
130
  }
132
131
 
133
- const defaultHeaders: Record<string, string> = {
134
- Authorization: publishableKey,
132
+ const allHeaders: Record<string, string> = {
135
133
  'Content-Type': 'application/json',
136
- 'X-Radar-Device-Type': 'Web',
137
- 'X-Radar-SDK-Version': SDK_VERSION,
134
+ ...Config.getDefaultHeaders(),
135
+ ...headers,
138
136
  };
139
137
 
140
- let configHeaders: Record<string, string> = {};
141
- if (typeof options.getRequestHeaders === 'function') {
142
- configHeaders = options.getRequestHeaders();
143
- }
144
-
145
- const allHeaders: Record<string, string> = { ...defaultHeaders, ...configHeaders, ...headers };
146
-
147
138
  let response: Response;
148
139
  try {
149
140
  response = await fetch(url, {
@@ -187,7 +178,6 @@ class Http {
187
178
  Logger.debug(`API call failed: ${url}`);
188
179
  Logger.debug(String(err));
189
180
  }
190
-
191
181
  throw new RadarUnknownError(parsed);
192
182
  }
193
183
  }
@@ -206,7 +196,6 @@ class Http {
206
196
  if (response.ok) {
207
197
  return parsed as T;
208
198
  }
209
-
210
199
  if (options.debug) {
211
200
  Logger.debug(`API call failed: ${url}`);
212
201
  Logger.debug(JSON.stringify(parsed));
package/src/logger.ts CHANGED
@@ -11,18 +11,12 @@ const LOG_LEVELS = {
11
11
  // get the numeric level for logLevel option
12
12
  const getLevel = (): number => {
13
13
  // disable logging in tests
14
- if (window && window.RADAR_TEST_ENV) {
14
+ if (typeof window !== 'undefined' && window.RADAR_TEST_ENV) {
15
15
  return LOG_LEVELS.none;
16
16
  }
17
17
 
18
- const { logLevel, debug } = Config.get();
19
- if (debug) {
20
- return LOG_LEVELS.debug;
21
- }
22
- if (logLevel) {
23
- return LOG_LEVELS[logLevel];
24
- }
25
- return LOG_LEVELS.error; // default to error-level logging if not set
18
+ const { logLevel } = Config.get();
19
+ return logLevel ? LOG_LEVELS[logLevel] : LOG_LEVELS.error;
26
20
  };
27
21
 
28
22
  /** leveled console logger controlled by SDK config */
package/src/types.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /** log verbosity level for the SDK */
2
- export type LogLevel = 'none' | 'info' | 'warn' | 'error';
2
+ export type LogLevel = 'none' | 'error' | 'warn' | 'info' | 'debug';
3
3
 
4
4
  /** a geographic coordinate with optional accuracy and timestamp */
5
5
  export interface Location {
@@ -22,11 +22,9 @@ export interface NavigatorPosition {
22
22
  /** browser location permission state */
23
23
  export type LocationAuthorization = 'DENIED' | 'NOT_DETERMINED' | 'GRANTED_FOREGROUND';
24
24
 
25
- /** configuration options passed to {@link Radar.initialize} */
26
- export interface RadarOptions {
27
- /** Radar publishable key (set automatically by `initialize`) */
28
- publishableKey?: string;
29
- /** whether the key is a live key (set automatically) */
25
+ /** shared SDK configuration fields (excluding auth credentials) */
26
+ export interface RadarBaseOptions {
27
+ /** @deprecated use `debug` instead. inferred automatically from publishableKey. */
30
28
  live?: boolean;
31
29
  /** SDK log verbosity */
32
30
  logLevel?: LogLevel;
@@ -48,6 +46,32 @@ export interface RadarOptions {
48
46
  debug?: boolean;
49
47
  }
50
48
 
49
+ /** options for initializing with a JWT auth token */
50
+ export interface RadarAuthTokenInitOptions extends RadarBaseOptions {
51
+ /** JWT auth token */
52
+ authToken: string;
53
+ live?: never;
54
+ publishableKey?: never;
55
+ }
56
+
57
+ /** options for initializing with a publishable key via the options object */
58
+ export interface RadarPublishableKeyInitOptions extends RadarBaseOptions {
59
+ /** Radar publishable key */
60
+ publishableKey: string;
61
+ authToken?: never;
62
+ }
63
+
64
+ /** configuration options passed to {@link Radar.initialize} */
65
+ export type RadarInitOptions = RadarAuthTokenInitOptions | RadarPublishableKeyInitOptions;
66
+
67
+ /** internal SDK configuration (all fields optional — stored by Config after initialization) */
68
+ export interface RadarOptions extends RadarBaseOptions {
69
+ /** Radar publishable key (set automatically by `initialize`) */
70
+ publishableKey?: string;
71
+ /** JWT auth Token (mutually exclusive with publishableKey) */
72
+ authToken?: string;
73
+ }
74
+
51
75
  /** response from GET /v1/config */
52
76
  export interface RadarConfigResponse {
53
77
  meta: {
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export default '5.0.0';
1
+ export default '5.1.0';