Skip to content

Feature/update schema #51

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

Merged
merged 17 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 66 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,31 +86,6 @@ Then manually install the following JARs:

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

## Usage

To add a HTTP proxy for the API client, use `ClientConfig`:
```java

import org.glassfish.jersey.apache.connector.ApacheConnectorProvider;
import org.glassfish.jersey.client.ClientConfig;
import org.glassfish.jersey.client.ClientProperties;
import com.fingerprint.sdk.*;
import com.fingerprint.api.FingerprintApi;

...

ApiClient defaultClient = Configuration.getDefaultApiClient();
ClientConfig clientConfig = defaultClient.getClientConfig();
clientConfig.connectorProvider(new ApacheConnectorProvider());
clientConfig.property(ClientProperties.PROXY_URI, "http://proxy_url_here");
clientConfig.property(ClientProperties.PROXY_USERNAME, "proxy_username");
clientConfig.property(ClientProperties.PROXY_PASSWORD, "proxy_password");
defaultClient.setClientConfig(clientConfig);

FingerprintApi apiInstance = new FingerprintApi(defaultClient);

```

## Getting Started

Please follow the [installation](#installation) instruction and execute the following Java code:
Expand Down Expand Up @@ -160,6 +135,16 @@ public class FingerprintApiExample {
} catch (ApiException e) {
System.err.println("Exception when calling FingerprintApi.getEvent:" + e.getMessage());
}

// Update an event with a given requestId
try {
EventUpdateRequest request = new EventUpdateRequest();
request.setLinkedId("myNewLinkedId");
api.updateEvent(FPJS_REQUEST_ID, request);
} catch (ApiException e) {
System.err.println("Exception when calling FingerprintApi.updateEvent:" + e.getMessage());
}

// Get a specific visitor's all visits
try {
// Fetch all visits with a given visitorId, with a page limit
Expand All @@ -186,6 +171,13 @@ public class FingerprintApiExample {
} catch (ApiException e) {
System.err.println("Exception when calling FingerprintApi.getVisits:" + e.getMessage());
}

// Delete visitor data with a given visitorID
try {
api.deleteVisitorData(FPJS_VISITOR_ID);
} catch (ApiException e) {
System.err.println("Exception when calling FingerprintApi.deleteVisitorData:" + e.getMessage());
}
}
}
```
Expand Down Expand Up @@ -227,6 +219,37 @@ public class SealedResults {
```
To learn more, refer to example located in [src/examples/java/com/fingerprint/example/SealedResults.java](src/examples/java/com/fingerprint/example/SealedResults.java).

## Webhook signature validation
This SDK provides utility method for verifying the HMAC signature of the incoming webhook request.
```java

@RestController
class WebhookController {

@PostMapping("/api/webhook")
@ResponseBody
public String webhookHandler(@RequestBody String webhook, @RequestHeader HttpHeaders headers) {
final String secret = System.getenv("WEBHOOK_SIGNATURE_SECRET");
if (secret == null || secret.isEmpty()) {
return new ResponseEntity<String>("Secret key is not configured", HttpStatus.INTERNAL_SERVER_ERROR);
}

final String header = headers.get("fpjs-event-signature");
if (header == null || header.size == 0) {
return new ResponseEntity<String>("Missing fpjs-event-signature header", HttpStatus.BAD_REQUEST);
}
final String signature = header[0];

final boolean isValidSignature = Webhook.isValidWebhookSignature(signature, data.getBytes(StandardCharsets.UTF_8), secret);
if (!isValidSignature) {
return new ResponseEntity<String>("Webhook signature is not valid", HttpStatus.BAD_REQUEST);
}

return new ResponseEntity<String>("Webhook received", HttpStatus.OK);
}
}
```

## Documentation for API Endpoints

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


Expand All @@ -251,19 +275,25 @@ Class | Method | HTTP request | Description
- [DataCenter](docs/DataCenter.md)
- [DeprecatedIPLocation](docs/DeprecatedIPLocation.md)
- [DeprecatedIPLocationCity](docs/DeprecatedIPLocationCity.md)
- [DeveloperToolsResult](docs/DeveloperToolsResult.md)
- [EmulatorResult](docs/EmulatorResult.md)
- [Error](docs/Error.md)
- [ErrorCommon403Response](docs/ErrorCommon403Response.md)
- [ErrorCommon429Response](docs/ErrorCommon429Response.md)
- [ErrorCommon429ResponseError](docs/ErrorCommon429ResponseError.md)
- [ErrorEvent404Response](docs/ErrorEvent404Response.md)
- [ErrorEvent404ResponseError](docs/ErrorEvent404ResponseError.md)
- [ErrorUpdateEvent400Response](docs/ErrorUpdateEvent400Response.md)
- [ErrorUpdateEvent400ResponseError](docs/ErrorUpdateEvent400ResponseError.md)
- [ErrorUpdateEvent409Response](docs/ErrorUpdateEvent409Response.md)
- [ErrorUpdateEvent409ResponseError](docs/ErrorUpdateEvent409ResponseError.md)
- [ErrorVisitor400Response](docs/ErrorVisitor400Response.md)
- [ErrorVisitor400ResponseError](docs/ErrorVisitor400ResponseError.md)
- [ErrorVisitor404Response](docs/ErrorVisitor404Response.md)
- [ErrorVisitor404ResponseError](docs/ErrorVisitor404ResponseError.md)
- [ErrorVisits403](docs/ErrorVisits403.md)
- [ErrorVisitsDelete400Response](docs/ErrorVisitsDelete400Response.md)
- [ErrorVisitsDelete400ResponseError](docs/ErrorVisitsDelete400ResponseError.md)
- [ErrorVisitsDelete404Response](docs/ErrorVisitsDelete404Response.md)
- [ErrorVisitsDelete404ResponseError](docs/ErrorVisitsDelete404ResponseError.md)
- [EventResponse](docs/EventResponse.md)
- [EventUpdateRequest](docs/EventUpdateRequest.md)
- [FactoryResetResult](docs/FactoryResetResult.md)
- [FridaResult](docs/FridaResult.md)
- [HighActivityResult](docs/HighActivityResult.md)
Expand All @@ -287,11 +317,13 @@ Class | Method | HTTP request | Description
- [ProductsResponseIdentificationData](docs/ProductsResponseIdentificationData.md)
- [ProxyResult](docs/ProxyResult.md)
- [RawDeviceAttributesResultValue](docs/RawDeviceAttributesResultValue.md)
- [RemoteControlResult](docs/RemoteControlResult.md)
- [Response](docs/Response.md)
- [ResponseVisits](docs/ResponseVisits.md)
- [RootAppsResult](docs/RootAppsResult.md)
- [SeenAt](docs/SeenAt.md)
- [SignalResponseClonedApp](docs/SignalResponseClonedApp.md)
- [SignalResponseDeveloperTools](docs/SignalResponseDeveloperTools.md)
- [SignalResponseEmulator](docs/SignalResponseEmulator.md)
- [SignalResponseFactoryReset](docs/SignalResponseFactoryReset.md)
- [SignalResponseFrida](docs/SignalResponseFrida.md)
Expand All @@ -304,17 +336,22 @@ Class | Method | HTTP request | Description
- [SignalResponsePrivacySettings](docs/SignalResponsePrivacySettings.md)
- [SignalResponseProxy](docs/SignalResponseProxy.md)
- [SignalResponseRawDeviceAttributes](docs/SignalResponseRawDeviceAttributes.md)
- [SignalResponseRemoteControl](docs/SignalResponseRemoteControl.md)
- [SignalResponseRootApps](docs/SignalResponseRootApps.md)
- [SignalResponseSuspectScore](docs/SignalResponseSuspectScore.md)
- [SignalResponseTampering](docs/SignalResponseTampering.md)
- [SignalResponseTor](docs/SignalResponseTor.md)
- [SignalResponseVelocity](docs/SignalResponseVelocity.md)
- [SignalResponseVirtualMachine](docs/SignalResponseVirtualMachine.md)
- [SignalResponseVpn](docs/SignalResponseVpn.md)
- [Subdivision](docs/Subdivision.md)
- [SuspectScoreResult](docs/SuspectScoreResult.md)
- [TamperingResult](docs/TamperingResult.md)
- [TooManyRequestsResponse](docs/TooManyRequestsResponse.md)
- [TorResult](docs/TorResult.md)
- [VelocityIntervalResult](docs/VelocityIntervalResult.md)
- [VelocityIntervals](docs/VelocityIntervals.md)
- [VelocityResult](docs/VelocityResult.md)
- [VirtualMachineResult](docs/VirtualMachineResult.md)
- [Visit](docs/Visit.md)
- [VpnResult](docs/VpnResult.md)
Expand Down
13 changes: 13 additions & 0 deletions docs/DeveloperToolsResult.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@


# DeveloperToolsResult


## Properties

| Name | Type | Description | Notes |
|------------ | ------------- | ------------- | -------------|
|**result** | **Boolean** | `true` if the browser is Chrome with DevTools open or Firefox with Developer Tools open, `false` otherwise. | |



13 changes: 13 additions & 0 deletions docs/ErrorUpdateEvent400Response.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@


# ErrorUpdateEvent400Response


## Properties

| Name | Type | Description | Notes |
|------------ | ------------- | ------------- | -------------|
|**error** | [**ErrorUpdateEvent400ResponseError**](ErrorUpdateEvent400ResponseError.md) | | [optional] |



22 changes: 22 additions & 0 deletions docs/ErrorUpdateEvent400ResponseError.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@


# ErrorUpdateEvent400ResponseError


## Properties

| Name | Type | Description | Notes |
|------------ | ------------- | ------------- | -------------|
|**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 | |
|**message** | **String** | Details about the underlying issue with the input payload | |


## Enum: CodeEnum

| Name | Value |
|---- | ----- |
| REQUEST_CANNOT_BE_PARSED | &quot;RequestCannotBeParsed&quot; |
| FAILED | &quot;Failed&quot; |



13 changes: 13 additions & 0 deletions docs/ErrorUpdateEvent409Response.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@


# ErrorUpdateEvent409Response


## Properties

| Name | Type | Description | Notes |
|------------ | ------------- | ------------- | -------------|
|**error** | [**ErrorUpdateEvent409ResponseError**](ErrorUpdateEvent409ResponseError.md) | | [optional] |



21 changes: 21 additions & 0 deletions docs/ErrorUpdateEvent409ResponseError.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@


# ErrorUpdateEvent409ResponseError


## Properties

| Name | Type | Description | Notes |
|------------ | ------------- | ------------- | -------------|
|**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. | |
|**message** | **String** | | |


## Enum: CodeEnum

| Name | Value |
|---- | ----- |
| STATE_NOT_READY | &quot;StateNotReady&quot; |



13 changes: 13 additions & 0 deletions docs/ErrorVisitor400Response.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@


# ErrorVisitor400Response


## Properties

| Name | Type | Description | Notes |
|------------ | ------------- | ------------- | -------------|
|**error** | [**ErrorVisitor400ResponseError**](ErrorVisitor400ResponseError.md) | | [optional] |



21 changes: 21 additions & 0 deletions docs/ErrorVisitor400ResponseError.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@


# ErrorVisitor400ResponseError


## Properties

| Name | Type | Description | Notes |
|------------ | ------------- | ------------- | -------------|
|**code** | [**CodeEnum**](#CodeEnum) | Error code: * `RequestCannotBeParsed` - The visitor ID parameter is missing or in the wrong format. | |
|**message** | **String** | | |


## Enum: CodeEnum

| Name | Value |
|---- | ----- |
| REQUEST_CANNOT_BE_PARSED | &quot;RequestCannotBeParsed&quot; |



13 changes: 13 additions & 0 deletions docs/ErrorVisitor404Response.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@


# ErrorVisitor404Response


## Properties

| Name | Type | Description | Notes |
|------------ | ------------- | ------------- | -------------|
|**error** | [**ErrorVisitor404ResponseError**](ErrorVisitor404ResponseError.md) | | [optional] |



21 changes: 21 additions & 0 deletions docs/ErrorVisitor404ResponseError.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@


# ErrorVisitor404ResponseError


## Properties

| Name | Type | Description | Notes |
|------------ | ------------- | ------------- | -------------|
|**code** | [**CodeEnum**](#CodeEnum) | Error code: * `VisitorNotFound` - The specified visitor ID was not found. It never existed or it may have already been deleted. | |
|**message** | **String** | | |


## Enum: CodeEnum

| Name | Value |
|---- | ----- |
| VISITOR_NOT_FOUND | &quot;VisitorNotFound&quot; |



15 changes: 15 additions & 0 deletions docs/EventUpdateRequest.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@


# EventUpdateRequest


## Properties

| Name | Type | Description | Notes |
|------------ | ------------- | ------------- | -------------|
|**linkedId** | **String** | LinkedID value to assign to the existing event | [optional] |
|**tag** | **Object** | Full `tag` value to be set to the existing event. Replaces any existing `tag` payload completely. | [optional] |
|**suspect** | **Boolean** | Suspect flag indicating observed suspicious or fraudulent event | [optional] |



4 changes: 2 additions & 2 deletions docs/FactoryResetResult.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

| Name | Type | Description | Notes |
|------------ | ------------- | ------------- | -------------|
|**time** | **OffsetDateTime** | Time in UTC when the most recent factory reset of the Android or iOS device was done. If there is no sign of factory reset or the client is not a mobile device, the field will contain the epoch time (1 January 1970) in UTC. | |
|**timestamp** | **Long** | Same value as it's in the `time` field but represented in timestamp format. | |
|**time** | **OffsetDateTime** | Indicates the time (in UTC) of the most recent factory reset that happened on the **mobile device**. When a factory reset cannot be detected on the mobile device or when the request is initiated from a browser, this field will correspond to the *epoch* time (i.e 1 Jan 1970 UTC). See [Factory Reset Detection](https://dev.fingerprint.com/docs/smart-signals-overview#factory-reset-detection) to learn more about this Smart Signal. | |
|**timestamp** | **Long** | This field is just another representation of the value in the `time` field. The time of the most recent factory reset that happened on the **mobile device** is expressed as Unix epoch time. | |



Loading
Loading