
Security News
/Research
Popular node-ipc npm Package Infected with Credential Stealer
Socket detected malicious node-ipc versions with obfuscated stealer/backdoor behavior in a developing npm supply chain attack.
@vyer-technologies/offline-first
Advanced tools
Install @wora/offline-first using yarn or npm:
yarn add @wora/offline-first
import OfflineFirst, { OfflineFirstOptions, OfflineRecordCache, Request } from "@wora/offline-first";
const persistOptionsStoreOffline = {
prefix: 'example-offline',
serialize: true,
};
function execute(offlineRecord) {
// ... fetch
}
function discard(offlineRecord) {
// ... rollback
return true;
}
function complete(offlineRecord) {
// ... commit
return true;
}
const options: OfflineFirstOptions<Payload> = {
execute: (offlineRecord: any) => execute(offlineRecord),
finish?: (success: boolean, mutations: ReadonlyArray<OfflineRecordCache<T>> ) => void,
onComplete: (options: { offlineRecord: OfflineRecordCache<T>, response: any }) => complete(options),
onDiscard: (options: { offlineRecord: OfflineRecordCache<T>, error: any }) => discard(options),
};
const offlineFirst = new OfflineFirst(options, persistOptionsStoreOffline);
// ...
offlineFirst.restore().then(isRestored => setState(isRestored))
// ...
offlineFirst.publish({
request : {
payload: { url: '/api/todo', method: 'POST', json: { todoId } }
}
})
export type OfflineFirstOptions<T> = {
manualExecution?: boolean;
execute: (offlineRecord: OfflineRecordCache<T>) => Promise<any>,
finish?: (success: boolean, mutations: ReadonlyArray<OfflineRecordCache<T>> ) => void,
onComplete?: (options: { offlineRecord: OfflineRecordCache<T>, response: any }) => boolean;
onDiscard?: (options: { offlineRecord: OfflineRecordCache<T>, error: any }) => boolean;
onPublish?: ( offlineRecord: OfflineRecordCache<T>) => OfflineRecordCache<T>,
compare?: (v1: OfflineRecordCache<T>, v2: OfflineRecordCache<T>) => number;
}
execute: this is the only mandatory parameter. In this function, communications with the server must be implemented.
finish: function that is called once the request queue has been processed.
manualExecution: if set to true, requests in the queue are no longer performed automatically as soon as you go back online. invoke manually: offlineFirst.process();
onPublish: function that is called before saving the mutation in the store
onComplete: function that is called once the request has been successfully completed. Only if the function returns the value true, the request is deleted from the queue.
onDiscard: function that is called when the request returns an error. Only if the function returns the value true, the mutation is deleted from the queue
publish(options: {
id?: string,
request: Request<T>,
serial?,
}): Promise<OfflineRecordCache<T>>
request parameter is the only mandatory one and consists of the main information useful for managing the execution of the request.
requests are executed in parallel, but with the serial parameter it is possible to specify whether you want to execute some or all of the requests sequentially.
export type Request<T> = {
payload: T,
backup?: any,
sink?: any,
}
backup and sink fields when working in contexts with optimistic responses. In order to manage any UI updates.
export type OfflineRecordCache<T> = {
id: string,
request: Request<T>,
fetchTime: number,
state?: string,
retry?: number,
error?: any,
serial?: boolean
}
fetchTime, state,retry and error are managed automatically by the library during the offline process.FAQs
Forked from @wora Offline First
The npm package @vyer-technologies/offline-first receives a total of 20 weekly downloads. As such, @vyer-technologies/offline-first popularity was classified as not popular.
We found that @vyer-technologies/offline-first demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers 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.

Security News
/Research
Socket detected malicious node-ipc versions with obfuscated stealer/backdoor behavior in a developing npm supply chain attack.

Security News
TeamPCP and BreachForums are promoting a Shai-Hulud supply chain attack contest with a $1,000 prize for the biggest package compromise.

Security News
Packagist urges PHP projects to update Composer after a GitHub token format change exposed some GitHub Actions tokens in CI logs.