npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@finsys/borrower-client

v2.0.0

Published

Client library for the FinSys Borrower API — authentication, file uploads, and two-step loan application submission

Downloads

549

Readme

@finsys/borrower-client

Client library for the FinSys Borrower API — handles authentication, file uploads, and two-step loan application submission.

Install

npm install @finsys/borrower-client @finsys/core

@finsys/core is a peer dependency that provides shared form configuration types.

Quick Start

import {
  BorrowerApiClient,
  BorrowerEnvironment,
  buildSubmissionPayloads,
} from '@finsys/borrower-client'

// 1. Create a client
const client = new BorrowerApiClient({
  environment: BorrowerEnvironment.STAGING,
  credentials: {
    clientId: 'your-client-id',
    clientSecret: 'your-client-secret',
    gatewayKey: 'optional-gateway-key', // Azure APIM subscription key
  },
})

// 2. Test the connection
const { success, message } = await client.testConnection()

// 3. Upload a file
const result = await client.uploadFile(fileBuffer, 'document.pdf')
console.log(result.url) // blob storage URL

// 4. Build submission payloads from form data
const formData = {
  totalFinancing: 329000,
  fullName: 'John Doe',
  email: '[email protected]',
  bank_statement_t1: [{ url: result.url, name: 'document.pdf' }],
}

const { createPayload, finalizePayload } = buildSubmissionPayloads(
  formData,
  formConfig.fields // Record<string, FieldData> from @finsys/core
)

// 5. Two-step submission
const created = await client.submitApplication({
  ...createPayload,
  status: 'CREATING_APPLICATION',
})

await client.updateApplication(created.ihsId, {
  ...finalizePayload,
  status: 'APPLICATION_FINALIZED',
})

API

BorrowerApiClient

constructor(config: BorrowerClientConfig)

Creates a client instance. Environment determines the base URL:

| Environment | Base URL | |-------------|----------| | staging | https://api.finhero.asia/stage/buyerfuel/v1 | | production | https://api.finhero.asia/buyerfuel/v1 |

Use endpointOverrides to override individual endpoint URLs when needed.

login(): Promise<string>

Authenticates and returns a bearer token. Tokens are cached and auto-refreshed.

uploadFile(fileBuffer: Buffer, fileName: string): Promise<UploadResult>

Uploads a file and returns the blob storage URL.

submitApplication(payload): Promise<SubmissionResult>

Creates a new loan application (POST). Returns ihsId on success.

updateApplication(ihsId: string, payload): Promise<UpdateResult>

Updates an existing application (PATCH). Used to finalize with document URLs.

testConnection(): Promise<ConnectionTestResult>

Tests connectivity by attempting to authenticate.

invalidateToken(): void

Clears the cached auth token, forcing re-authentication on the next call.

buildSubmissionPayloads(formData, fields, now?)

Transforms form data into the two payloads needed for the two-step submission flow.

Parameters:

  • formData — Form values (Record<string, unknown>). File fields should contain UploadedFileRef[] or plain URL strings.
  • fields — Form config fields (Record<string, FieldData> from @finsys/core). File fields are identified by type: 'file'.
  • now — Optional Date for bank statement year computation (defaults to current date).

Returns: { createPayload, finalizePayload }

  • createPayload — Metadata only (no file references). Used for the initial POST.
  • finalizePayload — Updatable metadata + transformed document references. Used for the PATCH.

Field name conventions:

File fields are mapped to the API format based on their names:

| Field pattern | API field | Format | |---------------|-----------|--------| | bank_statement_tN | bankStatements | [{ path, month: N, year }] | | financials* | financialStatements | [{ path, year: ordinal }] | | ssm | form9 | "url" |

Contact/consent fields (email, fullName, mobilePhoneNo, formOfDisclosure) are automatically excluded from the finalize payload, as the API rejects these on update.

Types

interface UploadedFileRef {
  url: string
  name: string
}

interface UploadResult {
  success: boolean
  url?: string
  data?: unknown
  message?: string
}

interface SubmissionResult {
  success: boolean
  applicationId?: string
  ihsId?: string
  message?: string
  errors?: Record<string, string[]>
  data?: unknown
}

interface UpdateResult {
  success: boolean
  message?: string
  data?: unknown
}

interface ConnectionTestResult {
  success: boolean
  message: string
}

interface SubmissionPayloads {
  createPayload: Record<string, unknown>
  finalizePayload: Record<string, unknown>
}

License

Apache-2.0