
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.
microformat-node
Advanced tools
NOTE: Major breaking changes to the interface between v0.3.x and v1.x.x to bring library inline with microformat-shiv and Mozilla code base. Collecting HTML from URLs now needs to be done by a external module.
A node.js microformats parser. It is the same codebase as microformat-shiv project, but used the ultra-fast HTML DOM cheerio.
Using bower:
$ npm install microformat-shiv
The get
method parses microformats data from either a html
string or a cheerio
object.
Simple parse of HTML string.
var Microformats = require('microformat-node'),
options = {};
options.html = '<a class="h-card" href="http://glennjones.net">Glenn</a>';
Microformats.get(options, function(err, data){
// do something with data
});
Simple parse of a Cheerio parsed page
var Microformats = require('microformat-node'),
Cheerio = require('cheerio'),
options = {};
options.node = Cheerio.load('<a class="h-card" href="http://glennjones.net">Glenn</a>');
Microformats.get(options, function(err, data){
// do something with data
});
html
- (String) the html to be parsenode
- (Cheerio DOM object) the element to be parsefilter
- (Array) microformats types returned - i.e. ['h-card']
- always adds rels
textFormat
- (String) text style whitespacetrimmed
or normalised
default is whitespacetrimmed
dateFormat
- (String) the ISO date profile auto
, w3c
rfc3339
or html5
default is auto
add
- (Array) adds microformat version 1 definitionsI would recommended always setting textFormat
option to normalised
. This is not part of the microformat parsing rules, but in most cases provides more usable output.
These options are part of ongoing specification development. They maybe removed or renamed in future.
overlappingVersions
- (Boolean) block overlapping properties from different microformat versions default is true
impliedPropertiesByVersion
(Boolean) Set implied properties by microformat version default is false
parseLatLonGeo
(Boolean) Parse geo date writen as latlon i.e. 30.267991;-97.739568
default is false
JSON output. This is an example of a parsed h-card
microformat.
{
"items": [{
"type": ["h-card"],
"properties": {
"url": ["http://blog.lizardwrangler.com/"],
"name": ["Mitchell Baker"],
"org": ["Mozilla Foundation"],
"note": ["Mitchell is responsible for setting the direction Mozilla ..."],
"category": ["Strategy", "Leadership"]
}
}],
"rels": {},
"rel-urls": {}
}
The count
method returns the number of each microformat type found. It does not do a full parse so it is much quicker
than get and can be used for tasks such as adding notifications to the UI. The method can take a options
object as a parameter.
var Microformats = require('microformat-node'),
options = {};
options.html = '<a class="h-card" href="http://glennjones.net">Glenn</a>';
Microformats.count(options, function(err, data){
// do something with data
});
Output
{
'h-event': 1,
'h-card': 2,
'rels': 6
}
The isMicroformat
method returns weather a node has a valid microformats class. It currently does not work consider
rel=*
a microformats. The method can take a options
object as a second parameter.
var Microformats = require('microformat-node'),
options = {};
options.html = '<a class="h-card" href="http://glennjones.net">Glenn</a>';
Microformats.isMicroformat(options, function(err, isValid){
// do something with isValid
});
The hasMicroformats
method returns weather a document or node has any valid microformats class. It currently does
not take rel=* microformats into account. The method can take a options
object as a second parameter.
var Microformats = require('microformat-node'),
options = {};
options.html = '<div><a class="h-card" href="http://glennjones.net">Glenn</a></div>';
Microformats.hasMicroformats(options, function(err, isValid){
// do something with isValid
});
There are promise based version of the four public methods, each is appended with the text Async
. So the names for promise methods are getAsync
, countAsync
, isMicroformatAsync
and hasMicroformatsAsync
.
var Microformats = require('microformat-node'),
options = {};
options.html = '<a class="h-card" href="http://glennjones.net">Glenn</a>';
Microformats.getAsync(options)
.then(function (data) {
// do something with data
})
.catch(function(err){
// do something with err
})
The library has two properties to help identify now up todate it is:
version
(String) interanl version numberlivingStandard
(String ISO Date) the current https://github.com/microformats/tests used.The library has built-in version 1 microformats definitions, but you can add new definitions using options.add
if you wish. Below is an example of a definitions object. Examples of existing definitions found in the directory lib/maps
. You not need to add new definitions object if your using the microformats version 2.
{
root: 'hpayment',
name: 'h-payment',
properties: {
'amount': {},
'currency': {}
}
}
MIT © Copyright Glenn Jones
FAQs
A microformat parser for node.js
The npm package microformat-node receives a total of 1,044 weekly downloads. As such, microformat-node popularity was classified as popular.
We found that microformat-node 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
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.