@digifi/digifi-node-js v5.1.0
DigiFi Node.js Library
The DigiFi Node library provides convenient access to the DigiFi API from applications written in server-side JavaScript.
Documentation
See the API docs.
Requirements
Node 12 or higher.
Installation
Install the package with:
npm install @digifi/digifi-node-js --save
# or
yarn add @digifi/digifi-node-js
Usage
This package provides API Clients
and API Services
to help you communicate with DigiFi platform.
First, you need to create API Client
that requires url to DigiFi platform (this url can be different if you're using dedicated platform solution) and api-key.
After API Client
was initialized - you can create API Service
and start communication with to DigiFi platform API.
const Digifi = require('@digifi/digifi-node-js');
const apiClient = new Digifi.AuthorizedApiClient('https://cloud.digifi.io/api', 'digifi-...', {
apiVersion: '2024-02-26',
});
const applicationsApi = new Digifi.ApplicationsApiService(apiClient);
const { items, total } = await applicationsApi.find({ productId: '63d...' });
console.log(items);
Usage with TypeScript
DigiFi maintains types for the latest API Version.
import { AuthorizedApiClient, CreateApplicationParams, Application, ApplicationsApiService } from '@digifi/digifi-node-js';
const apiClient = new AuthorizedApiClient('https://cloud.digifi.io/api', 'digifi-...', {
apiVersion: '2024-02-26',
});
const applicationsApi = new ApplicationsApiService(apiClient);
const createApplication = async () => {
const params: CreateApplicationParams = {
productId: '63d288ae64f7677836046de7',
...,
};
const application: Application = await applicationsApi.create(params);
console.log(application.id);
};
createApplication();
Configuration
To initialize API Service
you need to create API client before.
Here is an example how to achieve that:
new AuthorizedApiClient(baseUrl: string, apiKey: string, options: object)
- default API client with authorization. Requires baseUrl
of DigiFi Platform API endpoint as first argument, api-key as second argument and apiVersion in options
object as third argument.
import { AuthorizedApiClient } from '@digifi/digifi-node-js';
const baseUrl = 'https://cloud.digifi.io/api';
const apiKey = 'digifi-cloud-...';
const authorizedApiClient = new AuthorizedApiClient(baseUrl, apiKey, {
apiVersion: '2024-02-26',
});
Options
API client can be created with required options
parameter that has this structure:
Option | Default | Required | Description |
---|---|---|---|
apiVersion | true | Api version to use for client. | |
enableIdempotencyHeader | false | false | If true is provided it allows POST requests to be idempotent |
maxNetworkRetries | 0 | false | The amount of times a request should be retried if error occured |
logger | null | false | Logger for tracing errors and requests |
Idempotency
Idempotency Header can be enabled with the enableIdempotencyHeader
to prevent duplication in cause of retry. Librabry will automatically assign idempotency header key (generated by UUID v4
) to each POST
request.
const apiClient = new AuthorizedApiClient('https://cloud.digifi.io/api', 'digifi-cloud-...', {
apiVersion: '2024-02-26',
enableIdempotencyHeader: true, // Will assign idempotency key to each POST request using UUID
});
Network retries
Automatic network retries can be enabled with the maxNetworkRetries
config option.
This will retry requests n
times with exponential backoff if they fail due to an intermittent network problem.
const apiClient = new AuthorizedApiClient('https://cloud.digifi.io/api', 'digifi-cloud-...', {
apiVersion: '2024-02-26',
maxNetworkRetries: 2, // Retry a request twice before giving up
});
API Services
Api Service
- class that provides you an interface which will simplify communicating with DigiFi Platform API without need to use AuthorizedApiClient
directly. Each Api Service
represent entity/domain in DigiFi system.
For example, if you need to create a borrower in DigiFi Platform you can use BorrowersApi
:
const apiClient = new AuthorizedApiClient(...);
const borrowersApi = new BorrowersApiService(apiClient);
const borrowers = await borrowersApi.create({ ... });
console.log(borrower.id);
Note You can communicate with DigiFi Platform API directly by
AuthorizedApiClient
, since it provides methodmakeCall
, but it's recommended to useAPI Services
to make sure that you're using correct request structure.
Here the list of API Services
that DigiFi Node JS Library provides:
new AccountsApi(apiClient: ApiClient, reference: 'borrowers' | 'intermediaries')
- api service for borrower/intermediary (depends onreference
argument) accounts.findAccountByEmail(email: string)
- returns borrower/intermediary (depends onreference
passed to the service) account.createAccount(accountParams: object, refreshTokenExpirationTimeMinutes?: number)
- creates and returns borrower/intermediary (depends onreference
passed to the service) account.getCurrentUser(accountAccessToken: string)
- returns current borrower/intermediary (depends onreference
passed to the service) account byaccountAccessToken
.sendUpdatePhoneNumberCode(phone: string, accountAccessToken: string, accountPasswordValidationToken: string)
- send code that confirms phone update for borrower/intermediary (depends onreference
passed to the service) account.updatePhoneNumber(code: string, accountAccessToken: string)
- confirms phone update for borrower/intermediary (depends onreference
passed to the service) bycode
andaccountAccessToken
.sendAddPhoneNumberCode(phone: string, accountAccessToken: string, accountPasswordValidationToken: string)
- send code that confirms phone adding for borrower/intermediary (depends onreference
passed to the service) account.addPhoneNumber(code: string, accountAccessToken: string)
- confirms add phone to borrower/intermediary (depends onreference
passed to the service) bycode
andaccountAccessToken
.deletePhoneNumber(phone: string, accountAccessToken: string, accountPasswordValidationToken: string)
- deletes phone for borrower/intermediary (depends onreference
passed to the service) byaccountAccessToken
andaccountPasswordValidationToken
.sendUpdateEmailCode(email: string, accountAccessToken: string, accountPasswordValidationToken: string)
- sends update email code for borrower/intermediary (depends onreference
passed to the service) to account byaccountAccessToken
andaccountPasswordValidationToken
.updateEmailAddress(code: string, accountAccessToken: string)
- confirms email update for borrower/intermediary (depends onreference
passed to the service) for account byaccountAccessToken
.createPasswordValidationToken(password: string, accountAccessToken: string)
- creates password validation token for borrower/intermediary (depends onreference
passed to the service) account bypassword
andaccountAccessToken
.updatePassword(oldPassword: string, newPassword: string, accountAccessToken: string)
- updates password for borrower/intermediary (depends onreference
passed to the service) account.find(params: object)
- finds borrower/intermediary (depends onreference
passed to the service) accounts byparams
object.
new EmailVerificationApi(apiClient: ApiClient, reference: 'borrowers' | 'intermediaries')
- api service for borrower/intermediary (depends onreference
argument) accounts email verification.sendVerificationEmail(accountAccessToken: string)
- sends verification email for borrower/intermediary (depends onreference
passed to the service) account byaccountAccessToken
.verifyEmail(code: string, accountAccessToken: string)
- verifies email for borrower/intermediary (depends onreference
passed to the service) account usingcode
byaccountAccessToken
.
new InvitesApi(apiClient: ApiClient, reference: 'borrowers' | 'intermediaries')
- api service for borrower/intermediary (depends onreference
argument) invitation management.acceptInvite(password: string, phone: string, token: string, refreshTokenExpirationTimeMinutes?: number)
- accepts invite for borrower/intermediary (depends onreference
passed to the service) account.getInviteInfo(token: string)
- retrieves invitation information for borrower/intermediary (depends onreference
passed to the service) account bytoken
.
new PhoneVerificationApi(apiClient: ApiClient, reference: 'borrowers' | 'intermediaries')
- api service for borrower/intermediary (depends onreference
argument) phone verification management.sendMfaCode(phone: string, accountAccessToken: string)
- sends mfa code for borrower/intermediary (depends onreference
passed to the service) account phone byaccountAccessToken
.verifyMfaCode(code: string, accountAccessToken: string)
- verifies mfa code for borrower/intermediary (depends onreference
passed to the service) account byaccountAccessToken
.
new ResetPasswordApi(apiClient: ApiClient, reference: 'borrowers' | 'intermediaries')
- api service for borrower/intermediary (depends onreference
argument) account reset password management.sendResetPasswordLink(email: string)
- sends reset password link to borrower/intermediary (depends onreference
passed to the service) account email.resetPassword(password: string, resetPasswordToken: string)
- resets password for borrower/intermediary (depends onreference
passed to the service) account byresetPasswordToken
.getResetPasswordTokenInfo(resetPasswordToken: string)
- retrieves reset password token info for borrower/intermediary (depends onreference
passed to the service) account byresetPasswordToken
.
new SessionsApi(apiClient: ApiClient, reference: 'borrowers' | 'intermediaries')
- api service for borrower/intermediary (depends onreference
argument) account session management.createSession(email: string, password: string, refreshTokenExpirationTimeMinutes?: number)
- creates session for borrower/intermediary (depends onreference
passed to the service) account.createSessionWithPhoneVerificationCode(phoneVerificationCode: string, refreshTokenExpirationTimeMinutes?: number)
- creates session for borrower/intermediary (depends onreference
passed to the service) account byphoneVerificationCode
.sendPhoneVerificationCode(phone: string)
- sends phone verification code for borrower/intermediary (depends onreference
passed to the service) account byphone
.validateToken(accountAccessToken: string)
- validates access token for borrower/intermediary (depends onreference
passed to the service) account.logout(accountAccessToken: string)
- kills session associated with borrower/intermediary (depends onreference
passed to the service) account byaccountAccessToken
.resignAccessToken(accountRefreshToken: string)
- resign access token for borrower/intermediary (depends onreference
passed to the service) account byaccountRefreshToken
.
new UsersApi(apiClient: ApiClient)
- api service for users management.find(params: object)
- finds organization users byparams
object.
new VariablesApi(apiClient: ApiClient)
- api service for variables management.find(params: object)
- finds organization variables byparams
object.
new DecisionsApi(apiClient: ApiClient)
- api service for decisions management.find(params; object)
- finds organization decisions byparams
object.findById(id: string)
- finds organization decision byid
.delete(id: string)
- deletes organization decision byid
.
new BorrowerStandardPortalGeneralSettingsApi(apiClient: ApiClient)
- api service for borrower standard portal settings management.getGeneralSettings()
- retrieves general settings of standard borrower portal for current organization.
new BorrowerStandardPortalLegalDocumentApi(apiClient)
- api service for borrower standard portal legal documents management.getLegalDocuments()
- retrieves borrower standard portal legal documents for current organization.
new BrandingApi(apiClient: ApiClient)
- api service for organization branding management.getBranding()
- retrieves current organization branding.getLogo()
- retrieves current organization logo.getFavicon()
- retrieves current organization favicon.
new DecisionProcessingApi(apiClient: ApiClient)
- api service for processing decisions.runDecisions(params: object)
- runs one/many decisions for current organization byparams
object.
new IntegrationFileDownloadApi(apiClient: ApiClient)
- api service for integration files downloads management.downloadById(id: string)
- downloads integration result file byid
.
new IntegrationProcessingApi(apiClient: ApiClient)
- api service for processing integrations.processIntegration(params: object)
- processes integration for current organization byparams
object.
new IntegrationResultFilesApi(apiClient: ApiClient)
- api service for integration result files management.uploadMany(integrationResultId: string, files: object[])
- uploads few files for integration result.
new IntegrationResultsApi(apiClient: ApiClient)
- api service for integration results management.find(params: object)
- finds integration results for current organization byparams
object.findById(id: string)
- finds integration result byid
.delete(id: string)
- deletes integration result byid
.
new ApplicationDecisionProcessingApi(apiClient: ApiClient)
- api service for processing application decisions.makeDecision(params: object)
- processes application decision for current organization byparams
object.
new ApplicationDocumentConfigurationApi(apiClient: ApiClient)
- api service for application document configuration management.find(productId: string)
- finds application document configurations for current organization and mode (depends onapi-key
provided to api client) byproductId
.
new ApplicationDocumentsApi(apiClient: ApiClient)
- api service for application documents management.find(params: object)
- finds application documents byparams
object.findById(id)
- finds application document byid
.create(params: object)
- uploads application document byparams
object.createMany(params: object)
- uploads few application documents byparams
object.update(id: string, params: object)
- updates application document byid
andparams
object.createFolder(params: object)
- creates application document folder byparams
.delete(id: string)
- deletes application document byid
.
new ApplicationDocumentsDownloadsApi(apiClient: ApiClient)
- api service for application documents download.downloadById(id: string)
- downloads application document by id.downloadAll(applicationId: string, accessPermission?: ApplicationDocumentAccessPermission)
- downloads all application documents.
new ApplicationDocumentsPreviewApi(apiClient: ApiClient)
- api service for document preview management.createToken(documentId: string)
- creates preview token for document bydocumentId
.
new ApplicationIntegrationProcessingApi(apiClient: ApiClient)
- api service for processing application integrations.processIntegration(params: object)
- processes integration for application byparams
object.
new ApplicationNotesApi(apiClient: ApiClient)
- api service for application notes management.find(params: object)
- finds application notes byparams
object.findById(id: string)
- finds application note byid
.create(params: object)
- creates application note byparams
object.update(id: string, params: object)
- updates application note byid
andparams
object.delete(id: string)
- deletes application note byid
.
new ApplicationsApiService(apiClient: ApiClient)
- api service for applications management.search(params: object)
- search applications byparams
object.list(params: object)
- lists applications byparams
object.findById(id: string)
- finds application byid
.findByDisplayId(displayId: string)
- finds application bydisplayId
.create(params: object)
- creates application byparams
object.update(id: string, params: object)
- updates application byid
andparams
object.delete(id: string)
- deletes application byid
.updateCoBorrowers(id: string, params: object)
- updates application co-borrowers byid
andparams
object.updateIntermediary(id: string, params: object)
- updates application intermediary byid
andparams
object.getVariables(id: string, variablesToInclude?: string[])
- retrieves application variables byid
(optional argumentvariablesToInclude
includes only specified variables).runCalculations(id: string, params: object)
- re-runs applications calculations byid
and optionalparams
object (providevariablesToRun
inparams
object to re-run only specified variables).addLabels(id: string, labelsIds: string[])
- adds labels to application byid
.addTeamMembers(id: string, teamMembersIds: string[])
- adds team members to application byid
.
new ApplicationStatusesApi(apiClient: ApiClient)
- api service for application statuses management.find(productId: string)
- finds application statuses for current organization and mode (depends onapi-key
provided to api client) byproductId
.
new BorrowersApiService(apiClient: ApiClient)
- api service for borrowers management.search(params: object)
- search borrowers byparams
object.list(params: object)
- lists borrowers byparams
object.findById(id: string)
- finds borrower byid
.create(params: object)
- creates borrower byparams
object.update(id: string, params: object)
- updates borrower byid
andparams
object.delete(id: string)
- deletes borrower byid
.
new CommentsApi(apiClient: ApiClient)
- api service for comments management.find(params: object)
- finds comments byparams
object.findById(id: string)
- finds comment byid
.create(params: object)
- creates comment byparams
object.update(id: string, params: object)
- updates comment byid
andparams
object.delete(id: string)
- deletes comment byid
.
new IntermediariesApiService(apiClient: ApiClient)
- api service for intermediaries management.search(params: object)
- search intermediaries byparams
object.list(params: object)
- lists intermediaries byparams
object.findById(id: string)
- finds intermediary byid
.create(params: object)
- creates intermediary byparams
object.update(id: string, params: object)
- updates intermediary byid
andparams
object.delete(id: string)
- deletes intermediary byid
.getSuggestions(params: object)
- retrieves intermediary suggestions byparams
object.createMany(intermediaries: object[])
- creates few intermediaries.
new LayoutConfigurationApi(apiClient: ApiClient)
- api service for layout configuration management.find(params: object)
- finds layout configuration byparams
object.
new ProductCalculationsApi(apiClient: ApiClient)
- api service for product calculations management.find(productId: string)
- finds product calculations for current organization and mode (depends onapi-key
provided to api client) byproductId
.
new ProductsApi(apiClient: ApiClient)
- api service for products management.find(params: object)
- finds products for current organization and mode (depends onapi-key
provided to api client) byparams
.findById(id: string)
- finds product for current organization and mode (depends onapi-key
provided to api client) byid
.
new TasksApiService(apiClient: ApiClient)
- api service for application tasks management.search(params: object)
- search tasks byparams
object.list(params: object)
- lists tasks byparams
object.findById(id: string)
- finds task byid
.create(params: object)
- creates task byparams
object.update(id: string, params: object)
- updates task byid
andparams
object.delete(id: string)
- deletes task byid
.bulkCreate(params: object)
- creates many tasks byparams
object.
new WebhookEndpointsApi(apiClient: ApiClient)
- api service for webhooks management.find(params: object)
- finds webhook endpoints byparams
object.findById(id: string)
- finds webhook endpoints byid
.create(params: object)
- creates webhook endpoint byparams
object.update(id: string, params: object)
- updates webhook endpoints byid
andparams
object.delete(id: string)
- deletes webhook endpoint byid
.
Webhook signing
DigiFi can verify webhook events signature it sends to your endpoint, allowing you to validate that they were not sent by a third-party. You can read more about it here.
Please note that you must pass the raw request body, exactly as received from DigiFi, to the verifyWebhookSignature()
function; this will not work with a parsed (i.e., JSON) request body.
Here is an example how to use it with express:
const express = require('express');
const digifi = require('digifi-node-js');
const bodyParser = require('body-parser');
const app = express();
const endpointSecret = '...';
app.post('/webhooks', bodyParser.raw({ type: 'application/json' }), (req, res) => {
const timestamp = req.headers['x-digifi-event-timestamp'];
const signature = req.headers['x-digifi-signature'];
if (!digifi.verifyWebhookSignature(req.body, endpointSecret, timestamp, signature)) {
res.status(400).send({ message: 'Invalid signature' });
return;
}
if (!digifi.verifyWebhookTimestamp(timestamp)) {
res.status(400).send({ message: 'Invalid timestamp' });
return;
}
switch (req.body.eventType) {
case 'application.created': {
handleApplicationCreate();
}
case 'application.updated': {
handleApplicationUpdate();
}
}
res.status(200).send({});
});
app.listen(3000, () => {
console.log(`Example app listening at http://localhost:3000`)
});
Support
New features and bug fixes are released on the latest major version of the @digifi/digifi-node-js
package. If you are on an older major version, we recommend that you upgrade to the latest in order to use the new features and bug fixes including those for security vulnerabilities. Older major versions of the package will continue to be available for use, but will not be receiving any updates.
More Information
1 month ago
2 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
4 months ago
4 months ago
4 months ago
5 months ago
10 months ago
7 months ago
10 months ago
9 months ago
10 months ago
7 months ago
9 months ago
10 months ago
10 months ago
10 months ago
1 year ago
1 year ago
11 months ago
12 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
2 years ago
2 years ago