Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
A lightweight and modular social sharing library:
Install Sharon using npm:
npm install sharon --save
Load the whole library:
var sharon = require('sharon');
Or cherry-pick networks for smaller Webpack, Browserify or Rollup bundles:
var facebook = require('sharon/facebook');
var twitter = require('sharon/twitter');
<script src="dist/sharon.js"></script>
For the sharon.js
file check the dist
directory of the installed module or directly download it:
Each social network has its own endpoint under the Sharon API:
Social network | Endpoint | Share count support | Share parameters |
---|---|---|---|
Buffer | sharon.buffer | Yes | Reference |
sharon.facebook | Yes | ||
Google+ | sharon.plus | Yes | Reference |
sharon.linkedin | Yes | Reference | |
sharon.pinterest | Yes | Reference | |
Tumblr | sharon.tumblr | Yes | Reference |
sharon.twitter | Reference | ||
sharon.xing | Reference |
This table also shows which of the networks support retrieving share counts and links to the share parameters references.
url
<String> The URL to share. Defaults to the current location.parameters
<Object> Share parameters. Default to an object with the title property equal to the current page title.Opens a share popup.
sharon.twitter();
With a custom title:
sharon.twitter({title: 'Check it out'});
Share example.com:
sharon.twitter('http://example.com');
Share example.com with a custom title:
sharon.twitter('http://example.com', {title: 'Check it out'});
url
<String> The URL to share. Defaults to the current location.parameters
<Object> Share parameters. Default to an object with the title property equal to the current page title.Returns a share popup URL.
var link = sharon.twitter.href();
With a custom title:
var link = sharon.twitter.href({title: 'Check it out'});
For example.com:
var link = sharon.twitter.href('http://example.com');
For example.com with a custom title:
var link = sharon.twitter.href('http://example.com', {title: 'Check it out'});
url
<String> The URL of which to retrive the share count. Defaults to the current location.callback
<Function(err, count)> A callback function that receives the count.Retrieves the share count of a URL.
sharon.facebook.count(function (err, count) {
if (err) throw err;
console.log(count);
});
For example.com:
sharon.facebook.count('http://example.com', function (err, count) {
if (err) throw err;
console.log(count);
});
When using sharon.network
or sharon.network.href
functions you can specify the share parameters by passing an object as the last argument. They are added to the query parameters of the share popup URL and are specifying additional features:
sharon.twitter({
title: 'One last quarter as defending champs!',
hashtags: ['SuperBowl', 'DenverBroncos']
});
This produces a popup with a predefined title and hashtags:
The set of the features is different for the most of the social networks. To find them out check their documentation, links to which are provided in the Supported social networks table.
There is an inconsistency between different networks: for instance, Twitter expects the text
parameter to contain a link title, while Pinterest expects the description
one. Sharon normalizes this behavior: when you pass a title
parameter it's automatically translated into a one that corresponds to a chosen network.
<button type="button" onclick="sharon.twitter()">Tweet</button>
<a ng-click="share($event)" ng-href="{{href}}">Share on Facebook {{count}}</a>
$scope.href = sharon.facebook.href();
$scope.share = function (event) {
event.preventDefault();
sharon.facebook();
};
sharon.facebook.count(function (err, count) {
if (err) throw err;
$scope.$apply(function () {
$scope.count = count;
});
});
class LinkedInShareButton extends React.Component {
constructor(props) {
super(props);
this.state = {href: sharon.linkedin.href()};
sharon.linkedin.count((err, count) => {
if (err) throw err;
this.setState({count});
});
}
share(event) {
event.preventDefault();
sharon.linkedin();
}
render() {
return <a onClick={this.share} href={this.state.href}>Share on LinkedIn {this.state.count}</a>;
}
}
1.0.0
Initial release.
FAQs
A lightweight and modular social sharing library
The npm package sharon receives a total of 9 weekly downloads. As such, sharon popularity was classified as not popular.
We found that sharon 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.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.