Skip to content
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
4 changes: 2 additions & 2 deletions src/lib/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});
Expand Down
14 changes: 14 additions & 0 deletions src/spec/core.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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/'));
});
Loading