@visionfi/server-sdk
v1.4.0
Published
Server-side SDK for VisionFI API access using Google Service Account authentication
Maintainers
Readme
@visionfi/server
Server-side SDK for VisionFI API access using Google Service Account authentication.
Installation
npm install @visionfi/serverQuick Start
import { VisionFi } from '@visionfi/server';
// Initialize with service account
const client = new VisionFi({
serviceAccountPath: './service-account.json'
});
// Or use Application Default Credentials
const client = new VisionFi();
// Verify authentication
const auth = await client.verifyAuth();
// Create a package
const pkg = await client.createPackage({
productType: 'consumer_loan_vehicle',
description: 'Vehicle loan application'
});
// Analyze a document
const job = await client.analyzeDocument(fileBuffer, {
fileName: 'document.pdf',
analysisType: 'auto_loan_abstract'
});
// Get results
const results = await client.getResults(job.uuid);Authentication
This package supports three authentication methods:
- Service Account File: Provide path to JSON key file
- Service Account JSON: Pass JSON object directly
- Application Default Credentials: Automatic in GCP environments
Features
- Document analysis and processing
- Package management
- Package sharing with role-based permissions
- DocuSign integration
- Workflow management
- Processing history and results
- Per-request custom headers for B2B2C scenarios
Package Sharing
The SDK supports sharing packages with other users with role-based permissions.
Share a Package
// Share with specific users
await client.packages.sharing.addShares('package-uuid', [
{ target: '[email protected]', role: 'editor' },
{ target: '[email protected]', role: 'viewer' }
]);
// Share with all users in your organization
await client.packages.sharing.addShares('package-uuid', [
{ target: 'AllUsers', role: 'viewer' }
]);Update Share Role
await client.packages.sharing.updateRole('package-uuid', '[email protected]', 'viewer');Remove a Share
await client.packages.sharing.remove('package-uuid', '[email protected]');Get Sharing Info (Owner Only)
const info = await client.packages.sharing.getInfo('package-uuid');
// { packageId, owner, shares: [{ target, role }] }List Packages Shared With Me
const shared = await client.packages.listShared();
// { packages: [{ packageId, owner, myRole, sharedVia, ... }], total }List All Accessible Packages
// List only owned packages (default)
const owned = await client.packages.list();
// List only shared packages
const shared = await client.packages.list({ include: 'shared' });
// List all accessible packages (owned + shared)
const all = await client.packages.list({ include: 'all' });Per-Request Custom Headers
All SDK methods support an optional requestOptions parameter that allows you to pass custom headers on a per-request basis. This is useful for B2B2C scenarios where you need to identify the end-user making the request.
Example: Passing End-User Identity
import { VisionFi } from '@visionfi/server';
const client = new VisionFi();
// Pass end-user identity via VF-On-Behalf-Of header
const packages = await client.packages.list(
{ productTypes: 'consumer_loan_vehicle' },
{ headers: { 'VF-On-Behalf-Of': '[email protected]' } }
);
// Works with all SDK methods
const pkg = await client.packages.get(
'package-uuid',
{ headers: { 'VF-On-Behalf-Of': '[email protected]' } }
);
// Create package on behalf of user
const newPkg = await client.packages.create(
{ productType: 'consumer_loan_vehicle' },
{ headers: { 'VF-On-Behalf-Of': '[email protected]' } }
);
// Execute processing on behalf of user
const result = await client.packages.processing.execute(
'package-uuid',
{ workflow: 'auto_loan_abstract' },
{ headers: { 'VF-On-Behalf-Of': '[email protected]' } }
);Protected Headers
For security, the following headers cannot be overridden per-request and will be stripped:
authorization- Managed by SDK authenticationhost- Managed by axiosx-api-key- Managed by SDK configuration
License
Copyright (c) 2024-2025 VisionFI. All Rights Reserved.
See LICENSE file for details.
