-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support new expiresAt/expiresIn/token/passed fields with trackOnce({ fraud: true }) and trackVerified() #159
Changes from 15 commits
34fa1eb
59b890d
a562e6e
d7e0fb2
7c5af93
88a48de
518d9f9
eab72d6
b04ab32
7759979
0b2387b
fab26fb
1e37c3d
669cec0
65779eb
081dcf4
7a3979a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ import TripsAPI from './trips'; | |
import { signJWT } from '../util/jwt'; | ||
import { ping } from '../util/net'; | ||
|
||
import type { RadarTrackParams, RadarTrackResponse } from '../types'; | ||
import type { RadarTrackParams, RadarTrackResponse, RadarTrackVerifiedResponse } from '../types'; | ||
|
||
class TrackAPI { | ||
static async trackOnce(params: RadarTrackParams) { | ||
|
@@ -160,15 +160,41 @@ class TrackAPI { | |
sclVal, | ||
cslVal, | ||
}; | ||
|
||
let { user, events, token, expiresAt } = response; | ||
const location = { latitude, longitude, accuracy }; | ||
let passed; | ||
let expiresIn; | ||
if (expiresAt) { | ||
expiresAt = new Date(expiresAt); | ||
passed = user?.fraud?.passed && user?.country?.passed && user?.state?.passed; | ||
expiresIn = (expiresAt.getTime() - Date.now()) / 1000; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should the name be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't really include units in the field name anywhere else in our APIs, so prefer to keep it |
||
} | ||
|
||
const trackRes = { | ||
user, | ||
events, | ||
location, | ||
token, | ||
expiresAt, | ||
expiresIn, | ||
passed, | ||
} as RadarTrackVerifiedResponse; | ||
|
||
if (options.debug) { | ||
trackRes.response = response; | ||
} | ||
|
||
return trackRes; | ||
} | ||
} else { | ||
response = await Http.request({ | ||
method: 'POST', | ||
path: 'track', | ||
data: body, | ||
}); | ||
} | ||
|
||
response = await Http.request({ | ||
method: 'POST', | ||
path: 'track', | ||
data: body, | ||
}); | ||
|
||
const { user, events } = response; | ||
const location = { latitude, longitude, accuracy }; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,19 +23,19 @@ export class RadarLocationError extends RadarError { | |
} | ||
} | ||
|
||
export class RadarLocationPermissionsError extends RadarError { | ||
export class RadarPermissionsError extends RadarError { | ||
constructor(message: string) { | ||
super(message); | ||
this.name = 'RadarLocationPermissionsError'; | ||
this.name = 'RadarPermissionsError'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To match mobile SDKs |
||
this.status = 'ERROR_PERMISSIONS'; | ||
} | ||
} | ||
|
||
export class RadarDesktopAppError extends RadarError { | ||
export class RadarVerifyAppError extends RadarError { | ||
constructor() { | ||
super('Desktop app not running.'); | ||
this.name = 'RadarDesktopAppError'; | ||
this.status = 'ERROR_DESKTOP_APP'; | ||
super('Radar Verify app not running.'); | ||
this.name = 'RadarVerifyAppError'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To account for Radar Verify desktop AND mobile apps |
||
this.status = 'ERROR_VERIFY_APP'; | ||
} | ||
} | ||
|
||
|
@@ -131,11 +131,11 @@ export class RadarServerError extends RadarError { | |
} | ||
} | ||
|
||
export class RadarTimeoutError extends RadarError { | ||
export class RadarNetworkError extends RadarError { | ||
constructor() { | ||
super('Request timed out.'); | ||
this.name = 'RadarTimeoutError'; | ||
this.status = 'ERROR_TIMED_OUT'; | ||
this.name = 'RadarNetworkError'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To match mobile SDKs |
||
this.status = 'ERROR_NETWORK'; | ||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we shipping these changes as
4.2
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing
trackVerifiedToken()
and renaming the error codes are breaking changes, so should prob be4.2.x
instead of4.1.x