From 74b67569383627b0159065fdd1a58e8b45bdd1d7 Mon Sep 17 00:00:00 2001 From: FranciscaOtero Date: Wed, 29 Apr 2026 18:04:28 -0400 Subject: [PATCH] feat: expose userAgent option in Fintoc constructor Co-Authored-By: Claude Opus 4.6 (1M context) --- src/lib/core.ts | 4 ++-- src/spec/core.spec.ts | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/lib/core.ts b/src/lib/core.ts index 641322b..1c38482 100644 --- a/src/lib/core.ts +++ b/src/lib/core.ts @@ -87,10 +87,10 @@ export class Fintoc { whoami: WhoamiManager; v2: FintocV2; - constructor(apiKey: string, jwsPrivateKey?: string) { + constructor(apiKey: string, jwsPrivateKey?: string, options?: { userAgent?: string }) { this.#client = new Client({ baseUrl: `${API_BASE_URL}`, - userAgent: `fintoc-node/${version}`, + userAgent: options?.userAgent || `fintoc-node/${version}`, apiKey, jwsPrivateKey, }); diff --git a/src/spec/core.spec.ts b/src/spec/core.spec.ts index 71a8fb8..9624b20 100644 --- a/src/spec/core.spec.ts +++ b/src/spec/core.spec.ts @@ -9,3 +9,17 @@ test('"Fintoc" object creation', (t) => { t.assert(fintoc.links instanceof LinksManager); t.assert(fintoc.webhookEndpoints instanceof WebhookEndpointsManager); }); + +test('"Fintoc" object creation with custom userAgent', (t) => { + const apiKey = 'super_secret_api_key'; + const fintoc = new Fintoc(apiKey, undefined, { userAgent: 'fintoc-cli/0.1.0' }); + t.assert(fintoc.links instanceof LinksManager); + t.assert(fintoc.webhookEndpoints instanceof WebhookEndpointsManager); + t.is((fintoc.links as any)._client.userAgent, 'fintoc-cli/0.1.0'); +}); + +test('"Fintoc" object creation uses default userAgent when not provided', (t) => { + const apiKey = 'super_secret_api_key'; + const fintoc = new Fintoc(apiKey); + t.true((fintoc.links as any)._client.userAgent.startsWith('fintoc-node/')); +});