
Research
Malicious fezbox npm Package Steals Browser Passwords from Cookies via Innovative QR Code Steganographic Technique
A malicious package uses a QR code as steganography in an innovative technique.
A simple record table for react with editable fields and a REST API interface
A simple React table to edit tabular data either with a REST API or through variables and functions:
Another simple example:
import EditTable from './edittable.jsx';
var data = [
{ id: '1', name: 'Test1', email: 'test1@test.com', description: 'Bla 1' },
{ id: '2', name: 'Test2', email: 'test2@test.com', description: 'Bla 2' },
{ id: '3', name: 'Test3', email: 'test3@test.com', description: 'Bla 3' }
];
class DataExample extends React.Component {
render () {
var fields = { name: 'Name *', email: 'Email *', description: 'Description' };
return <EditTable name="users" url="/api/users" fields={fields} data={data} />;
}
}
There are many fields that can be used by default and new ones can be created easily. This is the most important configurable part of your app. They will manipulate and display your data for better integration. Full list of properties for reference:
var fields = {
first: { // any name here
header: 'first', // For the table header
name: 'first', // The field (and data key) name
placeholder: 'first', // The text to show as placeholder
type: 'text', // For validation and manipulation
required: false, // Self-explanatory. Parses the 'header *' if omitted
readonly: false, // Only display it, but cannot edit it
validate: (val, cb, self) => cb(true) // Validates the data as it's edited
display: (val, cb, self) => cb(val), // Transformation for displaying data
}
};
Read the full fields documentation to know how to use them properly:
The data retrieved should have a particular format: an array of elements, where each element is an object with keys as the field name and value as the value for that instance. Each element is required to have a unique id (the format of it doesn't matter):
var data = [
{ id: '1', name: 'Test1', email: 'test1@test.com', description: 'Bla 1' },
{ id: '2', name: 'Test2', email: 'test2@test.com', description: 'Bla 2' },
{ id: '3', name: 'Test3', email: 'test3@test.com', description: 'Bla 3' },
{ id: '4', name: 'Test4', email: 'test4@test.com', description: 'Bla 4' }
];
This format is the one expected in case you pass down the data as a property or in case you retrieve it through the API.
By default it is a simple REST API:
var api {
get: function(callback){
this.ajax(this.url, 'GET', {}, callback);
},
post: function(data, callback){
this.ajax(this.url, 'POST', data, callback);
},
put: function(id, data, callback){
this.ajax(this.url + '/' + id, 'PUT', data, callback);
},
delete: function(id, callback){
this.ajax(this.url + '/' + id, 'DELETE', {}, callback);
}
};
Edit Table is really flexible, and while it was initially thought for a simple REST API now it's configurable deeply. Let's start with the default and easy case though:
For a simple REST API you can pass only the url:
import EditTable from './edittable.jsx';
class SimpleApi extends React.Component {
render () {
var fields = { name: 'Name *', email: 'Email *', description: 'Description' };
return <EditTable url="/api/users" fields={fields} />;
}
}
To make it token-based, you can do it just passing the token (code simplified):
var token = cookies('token'); // Using http://github.com/franciscop/cookies.js
<EditTable url="/api/users" token={token} fields={fields} />;
And to use your own authentication method, you would overwrite the method auth
within the API:
var auth = function(data, callback){
data = data || {};
if (cookies('token')) { // Using http://github.com/franciscop/cookies.js
data.authtoken = cookies('token');
}
callback(data);
}
<EditTable url="/api/users" auth={auth} fields={fields} />;
We also support not using a REST API. For instance, let's store the data within a variable (no persistence):
import EditTable from './edittable.jsx';
class UserList extends React.Component {
constructor(){
super();
this.state = { data: [
{ id: '1', name: 'Test1', email: 'test1@test.com', description: 'Bla 1' },
{ id: '2', name: 'Test2', email: 'test2@test.com', description: 'Bla 2' },
{ id: '3', name: 'Test3', email: 'test3@test.com', description: 'Bla 3' },
{ id: '4', name: 'Test4', email: 'test4@test.com', description: 'Bla 4' }
]};
}
update(data){
this.setState({ data: data });
}
render () {
var fields = { name: 'Name *', email: 'Email *', description: 'Description' };
var data = this.state.data;
var update = this.update.bind(this);
return <EditTable fields={fields} data={data} update={update} />;
}
}
To make your own persistence model, just overwrite the API. This is the footprint of them:
var api = {
get: function(callback){ /* write your own */ },
post: function(data, callback){ /* write your own */ },
put: function(id, data, callback){ /* write your own */ },
delete: function(id, callback){ /* write your own */ }
};
<EditTable fields={fields} api={api} />;
FAQs
A simple record table for react with editable fields and a REST API interface
We found that edittable 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
A malicious package uses a QR code as steganography in an innovative technique.
Research
/Security News
Socket identified 80 fake candidates targeting engineering roles, including suspected North Korean operators, exposing the new reality of hiring as a security function.
Application Security
/Research
/Security News
Socket detected multiple compromised CrowdStrike npm packages, continuing the "Shai-Hulud" supply chain attack that has now impacted nearly 500 packages.