Skip to content

Conversation

@erayaydin
Copy link
Contributor

@erayaydin erayaydin commented Oct 27, 2025

This PR upgrades the Server SDK to the Server API v4. It removes Server APIv3 specific behavior and aligns the SDK with the new events format shared by Server API and Webhooks.
INTER-1491

❓ Why?

  • Server API v3 is deprecated on Oct 31, 2025 and will be sunset on Oct 31, 2026.
  • v4 standardizes responses (no data/products/result nesting), switches to Bearer auth, unifies Webhooks & Server API event formats, and deprecates /visitors in favor of /v4/events.

⚙️ What Changed?

  • Project name changed from FingerprintPro.ServerSdk to Fingerprint.ServerSdk.
  • Removed ./bin/swagger-codegen-cli.jar and updated generate.sh to download openapi-generator-cli.jar (if it doesn't exist).
  • Bearer auth implemented: Removed Configuration class and implemented Client/BearerToken.cs, Client/TokenBase.cs, Client/TokenContainer`1.cs, Client/TokenProvider`1.cs, RateLimitProvider`1.cs.
  • Adds Generic Host extensions and DI support for JsonSerializationOptions.
  • <Operation>Async and <Operation>AsyncOrDefault methods to interact with the Server API.
  • Callback and hook support for the FingerprintApiEvents.

⚠️ Breaking Changes

  • All using directives and type references must change from
    FingerprintPro.ServerSdk to Fingerprint.ServerSdk.
  • If you reference project/solution files (or Docker images by name),
    update them to the new names.
  • FingerprintApi initialization changed. Prefer Generic Host + ConfigureApi instead of ad-hoc static configuration.
  • Auth changed. Use SECRET_API_KEY via DI (see Migration Guide).
  • Code that referenced requestId must switch to eventId (e.g., GetEventAsync now expects eventId).
  • Removed .toJson() methods in models.

📦 Migration Guide (SDK Consumers)

1) Change package reference to new name

Replace FingerprintPro.ServerSdk package references to new name.

- <PackageReference Include="FingerprintPro.ServerSdk" Version="7.9.0" />
+ <PackageReference Include="Fingerprint.ServerSdk" Version="8.0.0" />

2) Update package/namespace imports

Replace namespace imports: using FingerprintPro.ServerSdk; -> using Fingerprint.ServerSdk;

- using FingerprintPro.ServerSdk;
- using FingerprintPro.ServerSdk.Api;
- using FingerprintPro.ServerSdk.Model;
+ using Fingerprint.ServerSdk;
+ using Fingerprint.ServerSdk.Api;
+ using Fingerprint.ServerSdk.Model;

3) Switch to DI setup Generic Host (Auth and Region)

Before (v7.x, implicit apiKey usage):

...
var configuration = new Configuration("SECRET_API_KEY");
configuration.Region = Region.Eu;
var api = new FingerprintApi(configuration);
var getEvent = await api.GetEventAsync(requestId);

After (v8.x, Bearer + Generic Host):

using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Fingerprint.ServerSdk.Api;
using Fingerprint.ServerSdk.Client;

...

var host = Host.CreateDefaultBuilder(args)
  .ConfigureApi((context, services, options) =>
  {
      options.Region = Region.Eu;
      var token = new BearerToken("SECRET_API_KEY");
      options.AddTokens(token);
  })
  .Build();

var api = host.Services.GetRequiredService<IFingerprintApi>();
var getEvent = await api.GetEventAsync(eventId);

4) Replace request IDs with event IDs

const string id = "";

- await api.GetEventAsync(requestId: id);
+ await api.GetEventAsync(eventId: id);

5) Typed API responses

FingerprintApi methods now return a typed response wrapper that models both success and error outcomes.
You can check the outcome with the boolean properties and then safely access the typed payload via helpers:

  • Booleans: IsOk, IsNotFound, IsBadRequest, IsForbidden, IsInternalServerError, ...
  • Accessors: .Ok(), .NotFound(), .BadRequest(), .Forbidden(), .InternalServerError(), ...
  • Try-pattern: .TryOk(out var ok), .TryNotFound(out var err), .TryBadRequest(out var err), ...
  • Raw details (if needed): .RawContent, .StatusCode
- var eventsFound = api.SearchEvents(20, paginationKey: "1740815825085", bot: "bad");
+ var searchResponse = await api.SearchEventsAsync(limit: 50, paginationKey: "1740815825085", bot: "bad");
+ var eventsFound = searchResponse.Ok();
+ // var isOk = searchResponse.IsOk;
+ // var isOk = searchResponse.TryOk(out var eventsFound);

6) Remove Tag usage in EventUpdate, use Dictionary<string, object>

- var tag = new Tag
+ var tag = new Dictionary<string, object>
{
    ["key"] = "value"
};

7) Use Tags key instead of Tag when creating EventUpdate model

var body = new EventsUpdateRequest()
{
    Suspect = false,
-   Tag = tag,
+   Tags = tag,
    LinkedId = "<linked_id>"
};

8) Use new JsonConverters instead of .toJson() method

Removed .toJson() method from the models. Use new special JsonConverters for models when converting models to JSON.

- events.toJson()
+ JsonSerializer.Serialize(events);

You can also use our JsonConverters:

var jsonSerializerOptions = new JsonSerializerOptions();
jsonSerializerOptions.Converters.Add(new EventJsonConverter());
...
// or just use your concrete Host:
// var jsonSerializerOptions = jsonSerializerHost.Services.GetService<JsonSerializerOptions>();

9) Docker image and compose changes

If you run examples/tests via Docker-Compose, rebuild with the new image/tag and use the updated docker-compose.yml file.

10) Check new models and types

Please check Migrating from Server API v3 to v4 migration guide.

Renamed solution and project artifacts:
- `fingerprint-pro-server-api-dotnet-sdk.sln` to
  `fingerprint-server-dotnet-sdk.sln`.
- `src/FingerprintPro.ServerSdk*` to `src/Fingerprint.ServerSdk*`.
- Updated `*.csproj` names.

Updated namespaces and related code references:
- `FingerprintPro.ServerSdk.*` -> `Fingerprint.ServerSdk.*`
- Adjusted README code samples to use `using Fingerprint.ServerSdk;`

Updated docker image and compose service names to
`fingerprint-server-dotnet-sdk`.

Updated `bumpConfig.mjs` path points to the new
`Fingerprint.ServerSdk.csproj`.

`.swagger-codegen-ignore` paths updated to the new directory.

Changelog title also updated to the new project name.

**BREAKING CHANGE**
- All `using` directives and type references must change from
  `FingerprintPro.ServerSdk` to `Fingerprint.ServerSdk`.
- If you reference project/solution files (or Docker images by name),
  update them to the new names.

**MIGRATION GUIDE**
- Replace namespace imports:
  - `using FingerprintPro.ServerSdk;` -> `using Fingerprint.ServerSdk;`
- Update any fully-qualified types/references (e.g., `.Model.*`) to the
  new root namespace.
- If you run examples/tests via Docker-Compose, rebuild with the new
  image/tag and use the updated `docker-compose.yml` file.
- If you reference the solution or project files directly in CI
  pipeline/script, update the paths to `Fingerprint.ServerSdk/`.

Related-Task: INTER-1491
Added `set -euo pipefail` for safer and more predictable script behavior
(early fail). Made sure required directories are created before writing
files (current example list doesn't have additional directory). Switched
to `curl -fSL` for better error handling and redirect support.

Related-Task: INTER-1491
Removes unnecessary model files for Server APIv4

Related-Task: INTER-1491
Integrates Server APIv4 with `openapi-generator`.

Related-Task: INTER-1491
@erayaydin erayaydin self-assigned this Oct 27, 2025
@erayaydin erayaydin added the enhancement New feature or request label Oct 27, 2025
@changeset-bot
Copy link

changeset-bot bot commented Oct 27, 2025

🦋 Changeset detected

Latest commit: 2148758

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
fingerprint-server-dotnet-sdk Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Ignore `/bin` directory. Add `.NET` section header to the `.gitignore`
file. Remove vendored `bin/openapi-generator-cli.jar` from VCS. Update
`generate.sh` script to download openapi-generator-cli if it's not
exists.

Related-Task: INTER-1491
Adds `DecryptionKey.md`, `Sealed.md`, and `WebhookValidation.md` files
to template and update `config.json` to generate them.

Related-Task: INTER-1491
Removed `dotnet format` from the generate process. Renamed fields in
Tests. Fixed style issues for SDK.

Related-Task: INTER-1491
Removes `docs` and `src/Fingerprint.ServerSdk` before generating SDK.

Related-Task: INTER-1491
Updated the Solution template to surround the project GUID with `{}` in
both the `Project` line and `ProjectConfigurationPlatforms` mapppings.

Related-Task: INTER-1491
Adds missing `errors/400_ip_address_invalid.json` mock file.

Related-Task: INTER-1491
Add JsonSerializer to the `Fingerprint.ServerSdk.SealedResultExample`
project.

Related-Task: INTER-1491
Update OpenAPI schema to generate `EventUpdate.tags` as
`Dictionary<string, object`> instead of `Object`.

Related-Task: INTER-1491
Add `UPDATE_REQUEST_ID` to `.env.example` for updating different request
id. Rename example project from `examples` to
`Fingerprint.ServerSdk.Examples`. Add base `ExampleException` to expose
`IApiResponse`. Convert examples to new structure (`async`). Validate
env values before triggering tasks.

Related-Task: INTER-1491
Migrate `nunit` to `xunit` for `Fingerprint.ServerSdk.FunctionalTest`
project. Use Generic Host for the functional test project. Migrate
functional tests to new Server API v4. Use `IAsyncLifetime` to async
initialization. Remove unnecessary `Usings.cs` file.

Related-Task: INTER-1491
Use correct names for bearer token.

Related-Task: INTER-1491
Changes case sensitivity for `IPBlocklist`, `VPNConfidence`, `VPNMethods`

Related-Task: INTER-1491
Use different case for `IPBlocklist`, `VPNConfidence`, and `VPNMethods`
generated models.

Related-Task: INTER-1491
Use correct case for `IPBlocklist`, `VPNConfidence`, and `VPNMethods`
models.

Related-Task: INTER-1491
Use different case for model names and file names.

Related-Task: INTER-1491
Removes case issue model files from the VCS.

Related-Task: INTER-1491
Use `en_US.UTF-8` localization for generating SDK.

Related-Task: INTER-1491
Removed unnecessary `mono_nunit_test` script.

Related-Task: INTER-1491
Fixes solution file name for Dockerfile image.

Related-Task: INTER-1491
Use only `net8.0` target framework for the `Fingerprint.ServerSdk.Test`
project.

Related-Task: INTER-1491
Add missing xml docs for `HostConfiguration.cs` file.

Related-Task: INTER-1491
Adds user agent testing to `DependencyInjectionTests` test file.

Related-Task: INTER-1491
Replace `Array.Empty<string>()` with simple `[]` in DI test setup. Use
discards for unused lambda parameters. Remove unused `System` import.
Drop `net800rLater` conditions in template file because we only target
`net80`.

Related-Task: INTER-1491
Replace `appDescription` with `packageDescription` to generate file
headers.

Related-Task: INTER-1491
Replace concrete `new` lines with target-typed `new`. Use collection
expressions. Remove unused `System.Collections.Generic`.

Related-Task: INTER-1491

# Prepare OpenAPI Generator CLI
OPENAPI_GENERATOR_FILE="./bin/openapi-generator-cli.jar"
OPENAPI_GENERATOR_URL="https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.16.0/openapi-generator-cli-7.16.0.jar"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are the pros of downloading it each time and not keeping it in git?

Copy link
Contributor Author

@erayaydin erayaydin Oct 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It significantly increases the VCS repo size (~30 MB), and since it's a binary file, the only real benefit I see to keeping it in VC is security (if Maven has an outage or the file gets tampered with) and also having a static mirror. Having large files can be problematic for developers. If we're concerned about security, we could host our own remote mirror and keep it up to date instead. I'm also okay to use a static JAR file, but I prefer a small repository size.

P.S. Developers (not CI) will download it once because it doesn't download the file if it exists


// HttpResponseMessage
Console.WriteLine(visits.Response);
public class Program
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we have a complete scenario here and not just the API configuration for the DI?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you review the README changes in commit #b2ae80e? Let me know if it's enough or if you'd like me to add or remove anything.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, looks good!

@@ -0,0 +1,6 @@
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are more of them

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I can tell from reviewing the tests, we're not using the other errors. So I kept only the ones we actually use and updated the sync.sh script accordingly.

Add csharp generic host examples for operations to `api_doc` documentation.

Related-Task: INTER-1491
Reformat model docs to use unescaped description for the model.
Implement conditional properties table to avoid empty markdown table.

Related-Task: INTER-1491
Use unescaped summary and notes for operation descriptions. This
replaces  HTML entities in generated XML docs with the real character.

Related-Task: INTER-1491
Replace `REQUEST_ID` and `UPDATE_REQUEST_ID` with `EVENT_ID` and
`UPDATE_EVENT_ID` names. Use named arguments in example project.

Related-Task: INTER-1491
Expand `README.md` example to use `TryOk` and `isOk` patterns for
`GetEventAsync` and `SearchEventsAsync` operations. Also show accessing
`RawContent`, `Headers` and `StatusCode`. Include an `UpdateEventAsync`
example with an example `EventUpdate` instance.
Upgrade `BouncyCastle.Cryptography` from `2.4.0` to `2.6.2` version. No
breaking changes for our usage, no code changes required in the SDK.
Compiles cleanly and test suite passes. Change list (upstream diff) can
be found [here](bcgit/bc-csharp@release-2.4.0...release-2.6.2)

Related-Task: INTER-1491
Bump `System.Threading.Channels` from `8.0.0` to `9.0.10` version. No
breaking changes for our usage (only `` RateLimitProvider`1.cs `` is
using). No code changes required in the SDK.

Related-Task: INTER-1491
Update `Microsoft.Extensions.Http` and `Microsoft.Extensions.Http.Polly`
packages to `9.0.10` version.

Related-Task: INTER-1491
Update `Microsoft.Extensions.Hosting` package to the `9.0.10` version.

Related-Task: INTER-1491
@erayaydin erayaydin force-pushed the migrate-api-v4-inter-1491 branch from 76a4aba to 2148758 Compare October 30, 2025 13:07
@github-actions
Copy link
Contributor

🚀 Following releases will be created using changesets from this PR:

[email protected]

Major Changes

  • Rename .NET SDK project and namespaces from FingerprintPro.ServerSdk.* to Fingerprint.ServerSdk.*.

    Breaking changes

    • Update all using directives and fully-qualified type names:
      • FingerprintPro.ServerSdk.*Fingerprint.ServerSdk.*
    • If you reference solution/project file names or CI paths, update them to the new Fingerprint.ServerSdk.* locations. (7af5781)

@erayaydin erayaydin requested a review from ilfa October 30, 2025 13:14
@erayaydin erayaydin marked this pull request as ready for review October 30, 2025 13:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants