
Research
/Security News
Coruna Respawned: Compromised art-template npm Package Leads to iOS Browser Exploit Kit
Compromised npm package art-template delivered a Coruna-like iOS Safari exploit framework through a watering-hole attack.
offline-data-sync
Advanced tools
A robust, TypeScript-based library for managing offline-first data synchronization in web applications. This library provides seamless data persistence and synchronization capabilities, ensuring your application works flawlessly regardless of network connectivity.
Offline-First Architecture
Advanced Conflict Resolution
Robust Error Handling
Flexible Configuration
Node.js >= 14.0.0
npm >= 6.0.0
npm install offline-data-sync
import { SyncManager } from "offline-data-sync";
// Create a custom API adapter
class TodoApiAdapter implements ApiAdapter {
constructor(private baseUrl: string) {
this.apiUrl = baseUrl.replace(/\/$/, "");
}
async create(record: SyncRecord): Promise<Response> {
return fetch(`${this.apiUrl}/${record.id}`, {
method: "POST",
headers: {
"Content-Type": "application/json",
"If-Match": record.version?.toString() || "*",
},
body: JSON.stringify(record.data),
});
}
// Implement other methods...
}
// Initialize SyncManager
const syncManager = new SyncManager({
storeName: "todos",
apiAdapter: new TodoApiAdapter("http://localhost:3001/api/todos"),
conflictResolution: "server-wins",
batchSize: 50,
});
// Create a todo
await syncManager.create({
title: "New Todo",
completed: false,
});
// Update a todo
await syncManager.update("todo-id", {
title: "Updated Todo",
completed: true,
});
// Delete a todo
await syncManager.delete("todo-id");
// Get processed records (with UI-ready format)
const records = await syncManager.getProcessedRecords();
// Monitor sync status
syncManager.onSyncStatusChange((status) => {
console.log("Sync status:", status);
});
interface SyncConfig {
storeName: string;
primaryKey?: string;
syncEndpoint?: string;
apiAdapter?: ApiAdapter;
conflictResolution?:
| "client-wins"
| "server-wins"
| "manual"
| "last-write-wins"
| "merge";
batchSize?: number;
maxRetries?: number;
retryDelay?: number;
mergeStrategy?: (clientData: any, serverData: any) => any;
}
interface ApiAdapter {
create(record: SyncRecord): Promise<Response>;
update(record: SyncRecord): Promise<Response>;
delete(record: SyncRecord): Promise<Response>;
handleResponse(response: Response): Promise<Record<string, unknown> | null>;
}
const syncManager = new SyncManager({
conflictResolution: "server-wins",
});
const syncManager = new SyncManager({
conflictResolution: "client-wins",
});
const syncManager = new SyncManager({
conflictResolution: "manual",
});
// Later, when conflict occurs:
await syncManager.resolveConflict(
"record-id",
"accept-server", // or "accept-client" or "custom"
customData // optional, for custom resolution
);
# Install dependencies
npm install
# Build library
npm run build
# Run example app
cd example/ods-sample-app
npm install
npm run dev
# Run test server
cd example/test-server
npm install
npm run dev
class SyncManager {
async create(data: any): Promise<void>;
async update(id: string, data: any): Promise<void>;
async delete(id: string): Promise<void>;
async get(id: string): Promise<SyncRecord>;
async getAll(): Promise<SyncRecord[]>;
async getProcessedRecords(): Promise<any[]>;
async resolveConflict(
id: string,
resolution: string,
customData?: any
): Promise<void>;
onSyncStatusChange(callback: (status: SyncStatus) => void): () => void;
}
FAQs
Offline-first data synchronization library with conflict resolution
We found that offline-data-sync demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

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.

Research
/Security News
Compromised npm package art-template delivered a Coruna-like iOS Safari exploit framework through a watering-hole attack.

Company News
As AI accelerates how code is written and shipped, Socket is scaling to protect the software supply chain from the growing wave of attacks targeting open source dependencies.

Company News
Socket is scaling to defend open source against supply chain attacks as AI accelerates software development.