
Research
/Security News
Malicious npm Packages Target WhatsApp Developers with Remote Kill Switch
Two npm packages masquerading as WhatsApp developer libraries include a kill switch that deletes all files if the phone number isn’t whitelisted.
jsonpatcherproxy
Advanced tools
Lean and mean Javascript implementation of the JSON-Patch standard (RFC 6902). Update JSON documents using delta patches.
ES6 proxy powered JSON Object observer. That emits JSON patches when changes occur to your object tree.
With JSONPatcherProxy, you don't need polling or dirty checking. Any changes to the object are synchronously emitted.
JSON-Patch (RFC6902) is a standard format that allows you to update a JSON document by sending the changes rather than the whole document. JSONPatcherProxy plays well with the HTTP PATCH verb (method) and REST style programming.
Mark Nottingham has a nice blog about it.
Install the current version (and save it as a dependency):
$ npm install jsonpatcherproxy --save
dist/jsonpatcherproxy.min.js
, as in:<script src="dist/jsonpatcherproxy.js"></script>
You can use rawgit.com as a CDN.
Call require to get the instance:
var JSONPatcherProxy = require('jsonpatcherproxy');
Or in ES6 and TS:
import JSONPatcherProxy from 'jsonpatcherproxy';
var myObj = { firstName:"Joachim", lastName:"Wester", contactDetails: { phoneNumbers: [ { number:"555-123" }] } };
var jsonPatcherProxy = new JSONPatcherProxy( myObj );
var observedObject = jsonPatcherProxy.observe(true);
observedObject.firstName = "Albert";
observedObject.contactDetails.phoneNumbers[0].number = "123";
observedObject.contactDetails.phoneNumbers.push({number:"456"});
var patches = jsonPatcherProxy.generate();
// patches == [
// { op:"replace", path="/firstName", value:"Albert"},
// { op:"replace", path="/contactDetails/phoneNumbers/0/number", value:"123"},
// { op:"add", path="/contactDetails/phoneNumbers/1", value:{number:"456"}}];
var myObj = { firstName:"Joachim", lastName:"Wester", contactDetails: { phoneNumbers: [ { number:"555-123" }] } };
var jsonPatcherProxy = new JSONPatcherProxy( myObj );
var observedObject = jsonPatcherProxy.observe(true, function(patch) {
// patch == { op:"replace", path="/firstName", value:"Albert"}
});
observedObject.firstName = "Albert";
root
Object, [showDetachedWarning
Boolean = true] ): JSONPatcherProxyCreates an instance of JSONPatcherProxy
around your object of interest root
, for later observe
, unobserve
, pause
, resume
calls.
Returns JSONPatcherProxy
.
root
: The object tree you want to observe
showDetachedWarning
: Modifying a child object that is detached from the parent tree is not recommended, because the object will continue to be a Proxy. That's why JSONPatcherProxy warns when a detached proxy is accessed. You can set this to false to disable those warnings.
record
Boolean, [callback
Function]): ProxySets up a deep proxy observer on root
that listens for changes in the tree. When changes are detected, the optional callback is called with the generated single patch as the parameter.
record: if set to false
, all changes are will be pass through the callback and no history will be kept. If set to true
patches history will be kept until you call generate
, this will return several patches and deletes them from history.
Returns a Proxy
mirror of your object.
record
to true
or pass a callback.JSONPatcherProxy#generate
often if you choose to record. Because the patches will accumulate if you don't._isProxified
set to true, you can use this to tell an object and its mirror apart. Also if your root
object or any deep object inside it has _isProxified
property set to true
it won't be proxified => will not emit patches.It returns the changes of your object since the last time it's called. You have to be recording (by setting record
to true
) when calling JSONPatcherProxy#observe
.
If there are no pending changes in root
, returns an empty array (length 0).
Disables patches emitting (to both callback and patches array). However, the object will be updated if you change it.
Enables patches emitting (to both callback and patches array). Starting from the moment you call it.
De-proxifies (revokes) all the proxies that were created either in #observe call or by adding sub-objects to the tree in runtime.
Turns the proxified object into a forward-proxy object; doesn't emit any patches anymore, like a normal object.
undefined
s (JS to JSON projection)As undefined
type does not exist in JSON, it's also not a valid value of JSON Patch operation. Therefore JSONPatcherProxy
will not generate JSON Patches that sets anything to undefined
.
Whenever a value is set to undefined
in JS, JSONPatcherProxy method generate
and compare
will treat it similarly to how JavaScript method JSON.stringify
(MDN) treats them:
If
undefined
(...) is encountered during conversion it is either omitted (when it is found in an object) or censored tonull
(when it is found in an array).
See the ECMAScript spec for details.
Go to /test
In Node run:
npm test
npm install
.npm test
to make sure tests pass before touching the code.MIT
FAQs
Lean and mean Javascript implementation of the JSON-Patch standard (RFC 6902). Update JSON documents using delta patches.
The npm package jsonpatcherproxy receives a total of 2 weekly downloads. As such, jsonpatcherproxy popularity was classified as not popular.
We found that jsonpatcherproxy demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 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.
Research
/Security News
Two npm packages masquerading as WhatsApp developer libraries include a kill switch that deletes all files if the phone number isn’t whitelisted.
Research
/Security News
Socket uncovered 11 malicious Go packages using obfuscated loaders to fetch and execute second-stage payloads via C2 domains.
Security News
TC39 advances 11 JavaScript proposals, with two moving to Stage 4, bringing better math, binary APIs, and more features one step closer to the ECMAScript spec.