
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
ampersand-optimistic-sync
Advanced tools
A sync wrapper for Backbone.sync and ampersand-sync that implements optimistic concurrency in HTTP.
A wrapper for Backbone.sync and ampersand-sync that implements optimistic concurrency over HTTP.
Not sure what optimistic concurrency is? You can read a bit more about it and implementing it in HTTP here.
For the default behavior, just extend like so:
var Model = require('ampersand-model'); // or require('backbone').Model;
var syncMixin = require('ampersand-optimistic-sync');
module.exports = Model.extend(syncMixin(Model));
Now your model will check for the ETag header on every request to the server.
If it exists, the ETag will be set on the model as _version and a sync:version (args: model, version) event will fire.
On updates, sync will now automatically include the _version value as an If-Match header.
If the update is successful, the new ETag that the server sends will be set as _version.
If the update request returns a 412 error, a sync:invalid-version (args: model, version, data)
event is fired.
The mixin takes an optional second config argument that can be used to modify behavior.
Allowed values; etag (default), last-modified
When config.type is changed to last-modified like so:
var Model = require('ampersand-model'); // or require('backbone').Model;
var syncMixin = require('ampersand-optimistic-sync');
module.exports = Model.extend(syncMixin(Model, {type: 'last-modified'}));
The model will now store Last-Modified header values as _version and send _version as an If-Unmodified-Since header.
If config.invalidHandler is a function, it will be registered as a sync:invalid-version
handler before your first update request is sent.
FAQs
A sync wrapper for Backbone.sync and ampersand-sync that implements optimistic concurrency in HTTP.
The npm package ampersand-optimistic-sync receives a total of 36 weekly downloads. As such, ampersand-optimistic-sync popularity was classified as not popular.
We found that ampersand-optimistic-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
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.