Skip to content

Commit

Permalink
add setExpectedJurisdiction()
Browse files Browse the repository at this point in the history
  • Loading branch information
nickpatrick committed Aug 12, 2024
1 parent 26e1c0a commit 1f2d176
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/api/verify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ let tokenTimeoutId: any | null = null;
let tokenCallback: ((token: RadarTrackVerifiedResponse) => void) | null = null;
let lastToken: RadarTrackVerifiedResponse | null = null;
let lastTokenNow: number = 0;
let expectedCountryCode: string | null = null;
let expectedStateCode: string | null = null;

class VerifyAPI {
static async trackVerified(params: RadarTrackParams, encrypted: Boolean = false) {
Expand Down Expand Up @@ -46,6 +48,8 @@ class VerifyAPI {
stopped: true,
userId,
encrypted,
expectedCountryCode,
expectedStateCode,
};

let userAgent = navigator.userAgent;
Expand Down Expand Up @@ -151,6 +155,11 @@ class VerifyAPI {
return this.trackVerified({});
}

static setExpectedJurisdiction(countryCode?: string, stateCode?: string) {
expectedCountryCode = countryCode;
expectedStateCode = stateCode;
}

static onTokenUpdated(callback: (token: RadarTrackVerifiedResponse) => void) {
tokenCallback = callback;
}
Expand Down
4 changes: 4 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,10 @@ class Radar {
return VerifyAPI.getVerifiedLocationToken();
}

public static setExpectedJurisdiction(countryCode?: string, stateCode?: string) {
VerifyAPI.setExpectedJurisdiction(countryCode, stateCode);
}

public static getContext(params: Location) {
return ContextAPI.getContext(params);
}
Expand Down

0 comments on commit 1f2d176

Please sign in to comment.