Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
harcon-radiation
Advanced tools
Harcon-Radiation - An extension to the harcon library to automatically expose selected entities through REST and/or Websocket.
!Note: Please be aware, that from version 1.3.0, harcon-radiation requires Node 4.0.0 or above...
================ harcon-radiation is a small, yet handy tool extending the harcon library to provide a REST-, and Websocket-based interface to it.
Every time you publish or revoke an object-based entity, the harcon-radiation reacts to the changes and maintain the interfaces transparently.
$ npm install harcon-radiation
var harcon = new Harcon( { ... } );
var radiation = new Radiation( harcon );
var rest = require('connect-rest');
var connect = require('connect');
...
var app = connect();
...
app.use( radiation.rester( rest, options ) ); // Activates the REST services
...
server = http.createServer(app);
io = radiation.io( io.listen( server ) ); // Activates the Websocket services
...
harcon.addicts( {
name: 'julie',
context: 'book',
rest: true,
websocket: true,
log: function( data, callback ){
callback( null, 'Done.' );
}
} );
The example shows how you can attach the radiation to a connect/express instance and link to your harcon instance. You can activate the REST and Websocket interfaces only or both as you wish. Any object-based entities published to harcon possessing attributes 'rest' and 'websocket' will be exposed through those interfaces automatically.
The default behavior is to publish all services. However, one can define rules to make exceptions. By setting the option hideInnerServices, harcon-radiation will hide inner services and won't publish them
var radiation = new Radiation( harcon, { hideInnerServices: true } );
harcon-radiation ignores a service in 2 cases:
var radiation = new Radiation( harcon, { hideInnerServices: true, innerServicesPrefix: '_' } );
var radiation = new Radiation( harcon, { hideInnerServices: true, innerServicesFn: function(name){
return name.startsWith('inner') || name.startsWith('sys');
} } );
REST interface means a POST service using the same addressing logic as was implemented in harcon. An division-aware URI composed by name or context and a service function's name
post -> 'http://localhost:8080/Inflicter/book/log'
with body
{ params: [ 'Hello!'] }
will do perfectly.
Using Websockets is also straightforward:
var socket = ioclient( 'http://localhost:8080/Inflicter' );
socket.emit('ignite', { division: 'Inflicter', event: 'book.log', params: [ 'Helloka!' ] } );
The lib will open the namespace 'Inflicter' listening incoming packets. By sending an 'ignite' message passing the communication you want to deliver will do fine.
harcon-radiation supports JSON-RPC 2.0 if you create the instace as follows:
var radiation = new Radiation( harcon, { jsonrpcPath: '/JSONRPC' } );
This will accept POST request on the given path in regard with the JSON-RPC 2.0 standard. Setting the 'jsonrpcPath' attribute will also open a Websocket namespace listening incoming JSON-RPC 2.0 packets.
Note: be aware the limitations of JSON-RPC. It does not support orchestration like divisions or contexts, therefore addressing should be limited to entityname.service.
You can send out / broadcast messages to connected listeners if your business entity calls the method 'shifted', which is a built-in service of harcon letting entities to inform the system about state changes. harcon-radiation uses this mechanism to send out those messages to the websocket listeners.
this.shifted( { mood: 'happy' } );
That will send the message 'mood' to the connected clients with the data 'happy'. All properties of the object sent will be turned into separate messages to be broadcasted. And the payload of the messages will be set by the value of the given property.
Note: Considering the nature of the JSON-RPC 2.0, this level of service is available only for the 'normal' websockets clients.
harcon-radiation is using connect-rest inside and allows you to use the security features of that REST lib. Your components might possess a protector function which should retrieve protector function used by the connect-rest when it is called. The service parameter can be used to differentiate the different security aspects your services cover.
harcon.addicts( {
name: 'julie',
rest: true,
security: {
protector: function(service){
return function( req, res, pathname, path, callback ){
callback();
}
}
}
} );
About the protector functions, please find the description here.
(The MIT License)
Copyright (c) 2016 Imre Fazekas
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
See https://github.com/imrefazekas/harcon-radiation/issues.
FAQs
REST and Websocket plugin for harcon
The npm package harcon-radiation receives a total of 14 weekly downloads. As such, harcon-radiation popularity was classified as not popular.
We found that harcon-radiation 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
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.