UNPKG

@visionfi/server-sdk

Version:

Server-side SDK for VisionFI API access using Google Service Account authentication

47 lines (46 loc) 1.91 kB
/** * VisionFI Server SDK Client * The use cases for this SDK include backend services, server applications, and automated workflows that need to interact with the VisionFI platform. * The VisionFI Server SDK provides a client to interact with the VisionFI API using service-to-service authentication. * The SDK supports authentication via: * - Google Application Default Credentials (ADC) * - Service account JSON file * - Service account impersonation (for internal developers with IAM permissions) * It uses ID tokens for secure communication with the VisionFI API. * It includes clients for managing packages, authentication, and administrative tasks. * It handles token management, request signing, and error handling. * Copyright (c) 2024-2025 VisionFI. All Rights Reserved. */ import { GoogleAuth } from 'google-auth-library'; import { PackageClient } from './clients/package/PackageClient.js'; import { AdminClient } from './clients/admin/AdminClient.js'; import { AuthClient } from './clients/auth/AuthClient.js'; export interface VisionFIServerConfig { apiUrl?: string; audience?: string; authClient?: GoogleAuth; apiKey?: string; /** Service account email to impersonate (requires IAM permissions) */ impersonateServiceAccount?: string; /** Lifetime of impersonated credentials in seconds (default: 3600, max: 43200) */ impersonationLifetime?: number; } export declare class VisionFI { private apiClient; private auth; private impersonatedClient?; private config; private initPromise; readonly packages: PackageClient; readonly admin: AdminClient; readonly authentication: AuthClient; constructor(config?: VisionFIServerConfig); /** * Initialize impersonation if configured */ private initializeImpersonation; /** * Test connection to the API */ testConnection(): Promise<boolean>; }