Skip to content

Commit 37efeb0

Browse files
author
Sergey Shelomentsev
authored
Merge pull request #51 from fingerprintjs/feature/update-schema
Feature/update schema
2 parents 5c1d3ac + 80d101e commit 37efeb0

File tree

68 files changed

+3911
-180
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+3911
-180
lines changed

README.md

Lines changed: 66 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -86,31 +86,6 @@ Then manually install the following JARs:
8686

8787
- `target/fingerprint-pro-server-api-sdk-5.1.1.jar`
8888

89-
## Usage
90-
91-
To add a HTTP proxy for the API client, use `ClientConfig`:
92-
```java
93-
94-
import org.glassfish.jersey.apache.connector.ApacheConnectorProvider;
95-
import org.glassfish.jersey.client.ClientConfig;
96-
import org.glassfish.jersey.client.ClientProperties;
97-
import com.fingerprint.sdk.*;
98-
import com.fingerprint.api.FingerprintApi;
99-
100-
...
101-
102-
ApiClient defaultClient = Configuration.getDefaultApiClient();
103-
ClientConfig clientConfig = defaultClient.getClientConfig();
104-
clientConfig.connectorProvider(new ApacheConnectorProvider());
105-
clientConfig.property(ClientProperties.PROXY_URI, "http://proxy_url_here");
106-
clientConfig.property(ClientProperties.PROXY_USERNAME, "proxy_username");
107-
clientConfig.property(ClientProperties.PROXY_PASSWORD, "proxy_password");
108-
defaultClient.setClientConfig(clientConfig);
109-
110-
FingerprintApi apiInstance = new FingerprintApi(defaultClient);
111-
112-
```
113-
11489
## Getting Started
11590

11691
Please follow the [installation](#installation) instruction and execute the following Java code:
@@ -160,6 +135,16 @@ public class FingerprintApiExample {
160135
} catch (ApiException e) {
161136
System.err.println("Exception when calling FingerprintApi.getEvent:" + e.getMessage());
162137
}
138+
139+
// Update an event with a given requestId
140+
try {
141+
EventUpdateRequest request = new EventUpdateRequest();
142+
request.setLinkedId("myNewLinkedId");
143+
api.updateEvent(FPJS_REQUEST_ID, request);
144+
} catch (ApiException e) {
145+
System.err.println("Exception when calling FingerprintApi.updateEvent:" + e.getMessage());
146+
}
147+
163148
// Get a specific visitor's all visits
164149
try {
165150
// Fetch all visits with a given visitorId, with a page limit
@@ -186,6 +171,13 @@ public class FingerprintApiExample {
186171
} catch (ApiException e) {
187172
System.err.println("Exception when calling FingerprintApi.getVisits:" + e.getMessage());
188173
}
174+
175+
// Delete visitor data with a given visitorID
176+
try {
177+
api.deleteVisitorData(FPJS_VISITOR_ID);
178+
} catch (ApiException e) {
179+
System.err.println("Exception when calling FingerprintApi.deleteVisitorData:" + e.getMessage());
180+
}
189181
}
190182
}
191183
```
@@ -227,6 +219,37 @@ public class SealedResults {
227219
```
228220
To learn more, refer to example located in [src/examples/java/com/fingerprint/example/SealedResults.java](src/examples/java/com/fingerprint/example/SealedResults.java).
229221

222+
## Webhook signature validation
223+
This SDK provides utility method for verifying the HMAC signature of the incoming webhook request.
224+
```java
225+
226+
@RestController
227+
class WebhookController {
228+
229+
@PostMapping("/api/webhook")
230+
@ResponseBody
231+
public String webhookHandler(@RequestBody String webhook, @RequestHeader HttpHeaders headers) {
232+
final String secret = System.getenv("WEBHOOK_SIGNATURE_SECRET");
233+
if (secret == null || secret.isEmpty()) {
234+
return new ResponseEntity<String>("Secret key is not configured", HttpStatus.INTERNAL_SERVER_ERROR);
235+
}
236+
237+
final String header = headers.get("fpjs-event-signature");
238+
if (header == null || header.size == 0) {
239+
return new ResponseEntity<String>("Missing fpjs-event-signature header", HttpStatus.BAD_REQUEST);
240+
}
241+
final String signature = header[0];
242+
243+
final boolean isValidSignature = Webhook.isValidWebhookSignature(signature, data.getBytes(StandardCharsets.UTF_8), secret);
244+
if (!isValidSignature) {
245+
return new ResponseEntity<String>("Webhook signature is not valid", HttpStatus.BAD_REQUEST);
246+
}
247+
248+
return new ResponseEntity<String>("Webhook received", HttpStatus.OK);
249+
}
250+
}
251+
```
252+
230253
## Documentation for API Endpoints
231254

232255
All URIs are relative to *https://api.fpjs.io*
@@ -236,6 +259,7 @@ Class | Method | HTTP request | Description
236259
*FingerprintApi* | [**deleteVisitorData**](docs/FingerprintApi.md#deleteVisitorData) | **DELETE** /visitors/{visitor_id} | Delete data by visitor ID
237260
*FingerprintApi* | [**getEvent**](docs/FingerprintApi.md#getEvent) | **GET** /events/{request_id} | Get event by request ID
238261
*FingerprintApi* | [**getVisits**](docs/FingerprintApi.md#getVisits) | **GET** /visitors/{visitor_id} | Get visits by visitor ID
262+
*FingerprintApi* | [**updateEvent**](docs/FingerprintApi.md#updateEvent) | **PUT** /events/{request_id} | Update an event with a given request ID
239263
*FingerprintApi* | [**webhookTrace**](docs/FingerprintApi.md#webhookTrace) | **TRACE** /webhook |
240264

241265

@@ -251,19 +275,25 @@ Class | Method | HTTP request | Description
251275
- [DataCenter](docs/DataCenter.md)
252276
- [DeprecatedIPLocation](docs/DeprecatedIPLocation.md)
253277
- [DeprecatedIPLocationCity](docs/DeprecatedIPLocationCity.md)
278+
- [DeveloperToolsResult](docs/DeveloperToolsResult.md)
254279
- [EmulatorResult](docs/EmulatorResult.md)
255280
- [Error](docs/Error.md)
256281
- [ErrorCommon403Response](docs/ErrorCommon403Response.md)
257282
- [ErrorCommon429Response](docs/ErrorCommon429Response.md)
258283
- [ErrorCommon429ResponseError](docs/ErrorCommon429ResponseError.md)
259284
- [ErrorEvent404Response](docs/ErrorEvent404Response.md)
260285
- [ErrorEvent404ResponseError](docs/ErrorEvent404ResponseError.md)
286+
- [ErrorUpdateEvent400Response](docs/ErrorUpdateEvent400Response.md)
287+
- [ErrorUpdateEvent400ResponseError](docs/ErrorUpdateEvent400ResponseError.md)
288+
- [ErrorUpdateEvent409Response](docs/ErrorUpdateEvent409Response.md)
289+
- [ErrorUpdateEvent409ResponseError](docs/ErrorUpdateEvent409ResponseError.md)
290+
- [ErrorVisitor400Response](docs/ErrorVisitor400Response.md)
291+
- [ErrorVisitor400ResponseError](docs/ErrorVisitor400ResponseError.md)
292+
- [ErrorVisitor404Response](docs/ErrorVisitor404Response.md)
293+
- [ErrorVisitor404ResponseError](docs/ErrorVisitor404ResponseError.md)
261294
- [ErrorVisits403](docs/ErrorVisits403.md)
262-
- [ErrorVisitsDelete400Response](docs/ErrorVisitsDelete400Response.md)
263-
- [ErrorVisitsDelete400ResponseError](docs/ErrorVisitsDelete400ResponseError.md)
264-
- [ErrorVisitsDelete404Response](docs/ErrorVisitsDelete404Response.md)
265-
- [ErrorVisitsDelete404ResponseError](docs/ErrorVisitsDelete404ResponseError.md)
266295
- [EventResponse](docs/EventResponse.md)
296+
- [EventUpdateRequest](docs/EventUpdateRequest.md)
267297
- [FactoryResetResult](docs/FactoryResetResult.md)
268298
- [FridaResult](docs/FridaResult.md)
269299
- [HighActivityResult](docs/HighActivityResult.md)
@@ -287,11 +317,13 @@ Class | Method | HTTP request | Description
287317
- [ProductsResponseIdentificationData](docs/ProductsResponseIdentificationData.md)
288318
- [ProxyResult](docs/ProxyResult.md)
289319
- [RawDeviceAttributesResultValue](docs/RawDeviceAttributesResultValue.md)
320+
- [RemoteControlResult](docs/RemoteControlResult.md)
290321
- [Response](docs/Response.md)
291322
- [ResponseVisits](docs/ResponseVisits.md)
292323
- [RootAppsResult](docs/RootAppsResult.md)
293324
- [SeenAt](docs/SeenAt.md)
294325
- [SignalResponseClonedApp](docs/SignalResponseClonedApp.md)
326+
- [SignalResponseDeveloperTools](docs/SignalResponseDeveloperTools.md)
295327
- [SignalResponseEmulator](docs/SignalResponseEmulator.md)
296328
- [SignalResponseFactoryReset](docs/SignalResponseFactoryReset.md)
297329
- [SignalResponseFrida](docs/SignalResponseFrida.md)
@@ -304,17 +336,22 @@ Class | Method | HTTP request | Description
304336
- [SignalResponsePrivacySettings](docs/SignalResponsePrivacySettings.md)
305337
- [SignalResponseProxy](docs/SignalResponseProxy.md)
306338
- [SignalResponseRawDeviceAttributes](docs/SignalResponseRawDeviceAttributes.md)
339+
- [SignalResponseRemoteControl](docs/SignalResponseRemoteControl.md)
307340
- [SignalResponseRootApps](docs/SignalResponseRootApps.md)
308341
- [SignalResponseSuspectScore](docs/SignalResponseSuspectScore.md)
309342
- [SignalResponseTampering](docs/SignalResponseTampering.md)
310343
- [SignalResponseTor](docs/SignalResponseTor.md)
344+
- [SignalResponseVelocity](docs/SignalResponseVelocity.md)
311345
- [SignalResponseVirtualMachine](docs/SignalResponseVirtualMachine.md)
312346
- [SignalResponseVpn](docs/SignalResponseVpn.md)
313347
- [Subdivision](docs/Subdivision.md)
314348
- [SuspectScoreResult](docs/SuspectScoreResult.md)
315349
- [TamperingResult](docs/TamperingResult.md)
316350
- [TooManyRequestsResponse](docs/TooManyRequestsResponse.md)
317351
- [TorResult](docs/TorResult.md)
352+
- [VelocityIntervalResult](docs/VelocityIntervalResult.md)
353+
- [VelocityIntervals](docs/VelocityIntervals.md)
354+
- [VelocityResult](docs/VelocityResult.md)
318355
- [VirtualMachineResult](docs/VirtualMachineResult.md)
319356
- [Visit](docs/Visit.md)
320357
- [VpnResult](docs/VpnResult.md)

docs/DeveloperToolsResult.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
3+
# DeveloperToolsResult
4+
5+
6+
## Properties
7+
8+
| Name | Type | Description | Notes |
9+
|------------ | ------------- | ------------- | -------------|
10+
|**result** | **Boolean** | `true` if the browser is Chrome with DevTools open or Firefox with Developer Tools open, `false` otherwise. | |
11+
12+
13+

docs/ErrorUpdateEvent400Response.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
3+
# ErrorUpdateEvent400Response
4+
5+
6+
## Properties
7+
8+
| Name | Type | Description | Notes |
9+
|------------ | ------------- | ------------- | -------------|
10+
|**error** | [**ErrorUpdateEvent400ResponseError**](ErrorUpdateEvent400ResponseError.md) | | [optional] |
11+
12+
13+
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
3+
# ErrorUpdateEvent400ResponseError
4+
5+
6+
## Properties
7+
8+
| Name | Type | Description | Notes |
9+
|------------ | ------------- | ------------- | -------------|
10+
|**code** | [**CodeEnum**](#CodeEnum) | Error code: * `RequestCannotBeParsed` - the JSON content of the request contains some errors that prevented us from parsing it (wrong type/surpassed limits) * `Failed` - the event is more than 10 days old and cannot be updated | |
11+
|**message** | **String** | Details about the underlying issue with the input payload | |
12+
13+
14+
## Enum: CodeEnum
15+
16+
| Name | Value |
17+
|---- | ----- |
18+
| REQUEST_CANNOT_BE_PARSED | &quot;RequestCannotBeParsed&quot; |
19+
| FAILED | &quot;Failed&quot; |
20+
21+
22+

docs/ErrorUpdateEvent409Response.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
3+
# ErrorUpdateEvent409Response
4+
5+
6+
## Properties
7+
8+
| Name | Type | Description | Notes |
9+
|------------ | ------------- | ------------- | -------------|
10+
|**error** | [**ErrorUpdateEvent409ResponseError**](ErrorUpdateEvent409ResponseError.md) | | [optional] |
11+
12+
13+
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
2+
3+
# ErrorUpdateEvent409ResponseError
4+
5+
6+
## Properties
7+
8+
| Name | Type | Description | Notes |
9+
|------------ | ------------- | ------------- | -------------|
10+
|**code** | [**CodeEnum**](#CodeEnum) | Error code: * `StateNotReady` - The event specified with request id is not ready for updates yet. Try again. This error happens in rare cases when update API is called immediately after receiving the request id on the client. In case you need to send information right away, we recommend using the JS agent API instead. | |
11+
|**message** | **String** | | |
12+
13+
14+
## Enum: CodeEnum
15+
16+
| Name | Value |
17+
|---- | ----- |
18+
| STATE_NOT_READY | &quot;StateNotReady&quot; |
19+
20+
21+

docs/ErrorVisitor400Response.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
3+
# ErrorVisitor400Response
4+
5+
6+
## Properties
7+
8+
| Name | Type | Description | Notes |
9+
|------------ | ------------- | ------------- | -------------|
10+
|**error** | [**ErrorVisitor400ResponseError**](ErrorVisitor400ResponseError.md) | | [optional] |
11+
12+
13+

docs/ErrorVisitor400ResponseError.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
2+
3+
# ErrorVisitor400ResponseError
4+
5+
6+
## Properties
7+
8+
| Name | Type | Description | Notes |
9+
|------------ | ------------- | ------------- | -------------|
10+
|**code** | [**CodeEnum**](#CodeEnum) | Error code: * `RequestCannotBeParsed` - The visitor ID parameter is missing or in the wrong format. | |
11+
|**message** | **String** | | |
12+
13+
14+
## Enum: CodeEnum
15+
16+
| Name | Value |
17+
|---- | ----- |
18+
| REQUEST_CANNOT_BE_PARSED | &quot;RequestCannotBeParsed&quot; |
19+
20+
21+

docs/ErrorVisitor404Response.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
3+
# ErrorVisitor404Response
4+
5+
6+
## Properties
7+
8+
| Name | Type | Description | Notes |
9+
|------------ | ------------- | ------------- | -------------|
10+
|**error** | [**ErrorVisitor404ResponseError**](ErrorVisitor404ResponseError.md) | | [optional] |
11+
12+
13+

docs/ErrorVisitor404ResponseError.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
2+
3+
# ErrorVisitor404ResponseError
4+
5+
6+
## Properties
7+
8+
| Name | Type | Description | Notes |
9+
|------------ | ------------- | ------------- | -------------|
10+
|**code** | [**CodeEnum**](#CodeEnum) | Error code: * `VisitorNotFound` - The specified visitor ID was not found. It never existed or it may have already been deleted. | |
11+
|**message** | **String** | | |
12+
13+
14+
## Enum: CodeEnum
15+
16+
| Name | Value |
17+
|---- | ----- |
18+
| VISITOR_NOT_FOUND | &quot;VisitorNotFound&quot; |
19+
20+
21+

0 commit comments

Comments
 (0)