From 3dc2c5c6e2315c959faf6c8486d5341d37b6a841 Mon Sep 17 00:00:00 2001 From: Nick Patrick Date: Mon, 21 Aug 2023 18:30:14 -0400 Subject: [PATCH 1/4] expose trackVerifiedToken() --- README.md | 14 +++++++------- package-lock.json | 4 ++-- package.json | 2 +- src/api/verify.ts | 39 ++++++++++++++++++++++++++------------- src/index.ts | 4 ++++ src/types.ts | 3 +++ src/version.ts | 2 +- 7 files changed, 44 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index dd440d52..4db5ee7d 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ Radar.initialize('prj_test_pk_...', { /* options */ }); Add the following script in your `html` file ```html - + ``` Then initialize the Radar SDK @@ -73,8 +73,8 @@ To create a map, first initialize the Radar SDK with your publishable key. Then ```html - - + + @@ -98,8 +98,8 @@ To create an autocomplete input, first initialize the Radar SDK with your publis ```html - - + + @@ -130,8 +130,8 @@ To power [geofencing](https://radar.com/documentation/geofencing/overview) exper ```html - - + + diff --git a/package-lock.json b/package-lock.json index 3e6ab9d1..02e95b4a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "radar-sdk-js", - "version": "4.1.3", + "version": "4.1.4", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "radar-sdk-js", - "version": "4.1.3", + "version": "4.1.4", "license": "ISC", "dependencies": { "@types/geojson": "^7946.0.10" diff --git a/package.json b/package.json index ee77a220..f48643c0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "radar-sdk-js", - "version": "4.1.3", + "version": "4.1.4", "description": "Web Javascript SDK for Radar, location infrastructure for mobile and web apps.", "homepage": "https://radar.com", "type": "module", diff --git a/src/api/verify.ts b/src/api/verify.ts index 46474618..318832a2 100644 --- a/src/api/verify.ts +++ b/src/api/verify.ts @@ -6,10 +6,10 @@ import Logger from '../logger'; import Session from '../session'; import Storage from '../storage'; -import type { RadarTrackParams, RadarTrackResponse } from '../types'; +import type { RadarTrackParams, RadarTrackResponse, RadarTrackTokenResponse } from '../types'; class VerifyAPI { - static async trackVerified(params: RadarTrackParams) { + static async trackVerified(params: RadarTrackParams, encrypted: Boolean = false) { const options = Config.get(); // user indentification fields @@ -40,6 +40,7 @@ class VerifyAPI { sdkVersion: SDK_VERSION, stopped: true, userId, + encrypted, }; const response: any = await Http.request({ @@ -49,7 +50,7 @@ class VerifyAPI { host: 'https://radar-verify.com:52516', }); - const { user, events } = response; + const { user, events, token } = response; let location; if (user.location && user.location.coordinates && user.locationAccuracy) { location = { @@ -59,17 +60,29 @@ class VerifyAPI { }; } - const trackRes = { - user, - events, - location, - } as RadarTrackResponse; - - if (options.debug) { - trackRes.response = response; + if (encrypted) { + const trackTokenRes = { + token, + } as RadarTrackTokenResponse; + + if (options.debug) { + trackTokenRes.response = response; + } + + return trackTokenRes; + } else { + const trackRes = { + user, + events, + location, + } as RadarTrackResponse; + + if (options.debug) { + trackRes.response = response; + } + + return trackRes; } - - return trackRes; } } diff --git a/src/index.ts b/src/index.ts index c59b34b7..237dcaa8 100644 --- a/src/index.ts +++ b/src/index.ts @@ -148,6 +148,10 @@ class Radar { return VerifyAPI.trackVerified(params); } + public static trackVerifiedToken(params: RadarTrackParams = {}) { + return VerifyAPI.trackVerified(params, true); + } + public static getContext(params: Location) { return ContextAPI.getContext(params); } diff --git a/src/types.ts b/src/types.ts index f1fad10c..81c08aac 100644 --- a/src/types.ts +++ b/src/types.ts @@ -206,6 +206,9 @@ export interface RadarTrackResponse extends RadarResponse { events?: RadarEvent[]; } +export interface RadarTrackTokenResponse extends RadarResponse { + token?: String; +} export interface RadarContextResponse extends RadarResponse { location?: Location; diff --git a/src/version.ts b/src/version.ts index 6fc9a302..a9cac9fd 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1 +1 @@ -export default '4.1.3'; +export default '4.1.4'; From a3018e28e39314df60f6eb2d757f1bcff09db7ee Mon Sep 17 00:00:00 2001 From: Nick Patrick Date: Tue, 22 Aug 2023 06:29:42 -0400 Subject: [PATCH 2/4] add demo page --- demo/views/layouts/main.hbs | 1 + demo/views/track-verified-token.hbs | 95 +++++++++++++++++++++++++++++ 2 files changed, 96 insertions(+) create mode 100644 demo/views/track-verified-token.hbs diff --git a/demo/views/layouts/main.hbs b/demo/views/layouts/main.hbs index 627e4e04..c9d40215 100644 --- a/demo/views/layouts/main.hbs +++ b/demo/views/layouts/main.hbs @@ -67,6 +67,7 @@