Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

@lockbridge/integration-sdk

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lockbridge/integration-sdk

JavaScript SDK for Lockbridge Integration API - Upload files directly to cloud storage

latest
Source
npmnpm
Version
1.1.6
Version published
Weekly downloads
11
-93.25%
Maintainers
1
Weekly downloads
 
Created
Source

ViteBridge Integration SDK

JavaScript SDK for uploading files directly to cloud storage (S3, Google Drive, Dropbox) through the ViteBridge Integration API.

Installation

npm install @lockbridge/integration-sdk

Quick Start

HTML/CSS/JavaScript

<!DOCTYPE html>
<html>
<head>
    <title>File Upload</title>
</head>
<body>
    <input type="file" id="fileInput" multiple>
    <button id="uploadBtn">Upload</button>
    <div id="progress"></div>

    <script type="module">
        import { ViteBridgeClient } from '@lockbridge/integration-sdk';

        const client = new ViteBridgeClient({
            apiUrl: 'https://your-api.com/api/integration',
            token: 'your-integration-token'
        });

        const fileInput = document.getElementById('fileInput');
        const uploadBtn = document.getElementById('uploadBtn');
        const progress = document.getElementById('progress');

        uploadBtn.addEventListener('click', async () => {
            const files = Array.from(fileInput.files);

            for (const file of files) {
                try {
                    const result = await client.uploadFile(file, {
                        onProgress: (prog) => {
                            progress.textContent = `${file.name}: ${prog.percentage}%`;
                        }
                    });
                    console.log('Success:', result);
                } catch (error) {
                    console.error('Error:', error);
                }
            }
        });
    </script>
</body>
</html>

React with Hooks

import React, { useState } from 'react';
import { ViteBridgeProvider, useViteBridge } from '@lockbridge/integration-sdk/react';

function UploadComponent() {
    const { uploadFile, isUploading, progress } = useViteBridge();
    const [selectedFile, setSelectedFile] = useState(null);

    const handleFileSelect = (e) => {
        setSelectedFile(e.target.files[0]);
    };

    const handleUpload = async () => {
        if (!selectedFile) return;

        try {
            const result = await uploadFile(selectedFile, {
                onProgress: (prog) => console.log(`Progress: ${prog.percentage}%`)
            });
            console.log('Upload successful:', result);
        } catch (error) {
            console.error('Upload failed:', error);
        }
    };

    return (
        <div>
            <input type="file" onChange={handleFileSelect} />
            <button onClick={handleUpload} disabled={!selectedFile || isUploading}>
                {isUploading ? 'Uploading...' : 'Upload'}
            </button>

            {Object.entries(progress).map(([id, prog]) => (
                <div key={id}>{prog.percentage}%</div>
            ))}
        </div>
    );
}

function App() {
    return (
        <ViteBridgeProvider config={{
            apiUrl: 'https://your-api.com/api/integration',
            token: 'your-integration-token'
        }}>
            <UploadComponent />
        </ViteBridgeProvider>
    );
}

export default App;

React with Components

import React from 'react';
import { ViteBridgeProvider, FileUploader } from '@lockbridge/integration-sdk/react';

function App() {
    return (
        <ViteBridgeProvider config={{
            apiUrl: 'https://your-api.com/api/integration',
            token: 'your-integration-token'
        }}>
            <FileUploader
                multiple={true}
                onUploadComplete={(results) => console.log('Done:', results)}
                onUploadError={(errors) => console.error('Error:', errors)}
            />
        </ViteBridgeProvider>
    );
}

export default App;

API Reference

ViteBridgeClient

const client = new ViteBridgeClient({
    apiUrl: 'string',    // Required: Your API URL
    token: 'string',     // Required: Integration token
    debug: boolean,      // Optional: Enable logging
    timeout: number      // Optional: Request timeout in ms
});

// Upload single file
await client.uploadFile(file, options);

// Upload multiple files
await client.uploadFiles(files, options);

// Resume upload
await client.resumeUpload({ uploadId, file });

React Hook

const {
    uploadFile,      // Function to upload single file
    uploadFiles,     // Function to upload multiple files
    isUploading,     // Boolean: upload in progress
    progress,        // Object: upload progress by file
    errors,          // Object: errors by file
    clearErrors      // Function to clear errors
} = useViteBridge();

Upload Options

{
    onProgress: (progress) => void,  // Progress callback
    onComplete: (result) => void,    // Success callback
    onError: (error) => void         // Error callback
}

Configuration

Set your API credentials:

const config = {
    apiUrl: process.env.VITE_BRIDGE_API_URL,
    token: process.env.VITE_BRIDGE_TOKEN
};

Error Handling

try {
    await client.uploadFile(file);
} catch (error) {
    console.log(error.code);      // Error code
    console.log(error.message);   // Error message
    console.log(error.retryable); // Can retry?
}

License

MIT

Keywords

file-upload

FAQs

Package last updated on 18 Sep 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts