
Research
Two Malicious Rust Crates Impersonate Popular Logger to Steal Wallet Keys
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
datahub-client
Advanced tools
Node client and utilities for interacting with https://DataHub.io and handling Data Packages.
The DataHub platform stores a lot of different datasets - which are packages of useful data alongside with the description (here is the dataset specification). The data, stored on the DataHub, has a nice structure, views and a description that help people to get insights.
You can also store and share your own datasets on the DataHub
As a programmer, you may want to automate the process of getting or storing the data. Also you may want to integrate your project and the DataHub.
The datahub-client
library is designed for this. Let's explore it together.
Important notes:
npm install datahub-client --save
const datahub = require('datahub-client')
With datahub-client
you can do things like:
Let's explore datahub-client
features more deeply below.
Documentation is not ready at the moment. Information will be here after refactoring Login module.
Datahub class contains push()
and pushFlow()
methods, that is used to upload a dataset to the DataHub.io
push a dataset (dataset is an instance of a Dataset class: https://github.com/datahq/data.js#datasets):
const {DataHub} = require('datahub-client')
const {Dataset} = require('data.js')
/* secure jwt token and userId is taken from the Login&Auth module */
const datahubConfigs = {
apiUrl: 'http://api.datahub.io/',
token: 'jwt token',
debug: false,
ownerid: 'userId',
}
const datahub = new DataHub(datahubConfigs)
const pushOptions = {findability: 'unlisted'}
const res = await datahub.push(dataset, pushOptions)
console.log(res)
Possible push options:
This is an example of correct datahub.push()
response:
{ dataset_id: 'username/finance-vix',
errors: [],
flow_id: 'username/finance-vix/40',
success: true }
If you get any errors - change the debug option: datahubConfigs = {debug: true, ...}
, to see the detailed log.
**pushFlow()
is an experimental method, its documentation is not ready yet.
datahub-client
const datahub = require('datahub-client');
const {Dataset} = require('data.js');
const dataset = await Dataset.load(datasetUrl);
const resources = await datahub.get(dataset);
Dataset.load()
takes a path to the data package and returns a dataset object: https://github.com/datahq/data.js#datasets
datahub-client.get()
method accept the dataset object and returns an array with resources from it.
Each resource in the resources is the special File object from the data.js
lib: https://github.com/datahq/data.js#files
Info module contains two methods:
infoPackage(dpObj)
Shows the meta information about the dataset.
@param {data.js/Datapackage
object}
@return: {string}
async infoResource(resource)
Shows the information about one particular resource
@param {data.js/File
object} - only tabular file objects are supported
@return: {string} - ascii table
const data = require('data.js');
const datahub = require('datahub-client');
let dataset = await data.Dataset.load('http://github.com/datasets/finance-vix')
console.log(
datahub.info.infoPackage(dataset),
await datahub.info.infoResource(dataset.resources[0])
)
Init module is used to interactively create a new datapackage or update an existing one.
init.init()
scan files/directories in the current directorydatapackage.json
file, ask user if it is correctdatapackage.json
on the disk.Example: save this code into init.js
const datahub = require('datahub-client');
datahub.init.init()
Run the snippet in the terminal:
node init.js
This process initializes a new datapackage.json file.
Once there is a datapackage.json file, you can still run `data init` to
update/extend it.
Press ^C at any time to quit.
? Enter Data Package name - Some-Package-Name
? Enter Data Package title - Some-Package-Title
? Do you want to scan following directory ".idea" - y/n? n
? Do you want to scan following directory "basic-csv" - y/n? y
? Do you want to add following file as a resource "comma.csv" - y/n? y
comma.csv is just added to resources
? Going to write to /home/user/data/datapackage.json:
{
"name": "some-name",
"title": "some-title",
"resources": [
{
"path": "basic-csv/comma.csv",
<<<<<<<<< cut >>>>>>>>
Is that OK - y/n? y
datapackage.json file is saved in /home/user/data/datapackage.json
This module contains Validator
class, which checks:
Using:
const datahub = require('datahub-client')
const validator = new datahub.Validator({identifier: path_to_descriptor})
validator.validate().then(console.log)
If the datapackage is valid - the validator will return True Otherwise it will return an object with the information:
{ TableSchemaError: There are 1 type and format mismatch errors (see error.errors') ...
_errors:
[ { TableSchemaError: The value "true" in column "boolean" is not type "date" and format "default" ... } ],
rowNumber: 2,
resource: 'comma',
path: '/home/user/work/basic-csv/comma.csv' }
This module allows you to read the tabular data from inside the data.js/File
and to transform this data into a different formats.
Cat module has several writer functions, for different formats:
Each of the writers function convert the given source file into the stream with appropriate format.
The module exports the 'writers' object, that contains all this functions together:
writers = {
ascii: dumpAscii,
csv: dumpCsv,
md: dumpMarkdown,
xlsx: dumpXlsx,
html: dumpHtml
}
Example of use:
const {writers} = require('datahub-client').cat
const data = require('data.js')
const resource = data.File.load('data.csv')
Promise.resolve().then(async ()=>{
const stream = await writers.ascii(resource)
stream.pipe(process.stdout)
// or you can save the stream into a file:
const writeStream = fs.createWriteStream('filename', {flags : 'w'})
stream.pipe(writeStream)
})
Output for writers.ascii
:
┌────────────────────────────────┬────────────────────────────────┬────────────────────────────────┐
│ number │ string │ boolean │
├────────────────────────────────┼────────────────────────────────┼────────────────────────────────┤
│ 1 │ one │ true │
├────────────────────────────────┼────────────────────────────────┼────────────────────────────────┤
│ 2 │ two │ false │
└────────────────────────────────┴────────────────────────────────┴────────────────────────────────┘
Output for writers.md
:
| number | string | boolean |
| ------ | ------ | ------- |
| 1 | one | true |
| 2 | two | false |
CSV:
number,string,boolean
1,one,true
2,two,false
HTML:
<table class="table table-striped table-bordered">
<thead>
<th>number</th>
<th>string</th>
<th>boolean</th>
</thead>
<tbody>
<tr>
<td>1</td>
<td>one</td>
....................
XLSX: excel file
You need to have Node.js version >7.6
$ npm install
We use Ava for our tests. For running tests use:
$ [sudo] npm test
To run tests in watch mode:
$ [sudo] npm run watch:test
We use XO for checking our code for JS standard/convention/style:
# When you run tests, it first runs lint:
$ npm test
# To run lint separately:
$ npm run lint # shows errors only
# Fixing erros automatically:
$ xo --fix
FAQs
APIs for interacting with DataHub
The npm package datahub-client receives a total of 45 weekly downloads. As such, datahub-client popularity was classified as not popular.
We found that datahub-client 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.
Research
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
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.