npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

weauthjs

v1.1.155

Published

WeYouMe Protocol Javascript SDK Library

Downloads

52

Readme

Getting Started

For general information about weauthjs and setting up your app please see this post from @noisy: How to configure weauthjs and use it with your application

Include the weauthjs SDK in your HTML page

You can download a minified version of weauthjs here: https://WeYouMe.github.io/weauthjs-angular/weauthjs.min.js and include it in your HTML page:

<script src="/scripts/weauthjs.min.js"></script>

SDK Methods

Init SDK

Call the Initialize() method when your app first loads to initialize the SDK:

var weauthjs = require('weauthjs');

var api = weauthjs.Initialize({
  app: 'weapp',
  callbackURL: 'http://localhost:8000/demo/',
  accessToken: 'access_token',
  scope: ['vote', 'comment']
});

Parameters:

  • app: This is the name of the app that was registered in the weauthjs dashboard
  • callbackURL: This is the URL that users will be redirected to after interacting with weauthjs. It must be listed in the "Redirect URI(s)" list in the app settings EXACTLY the same as it is specified here
  • accessToken: If weauthjs have an oauth2 access token for this user already weauthjs can specify it here, otherwise weauthjs can leave it and set it later using weauthjs.setAccessToken(accessToken).
  • scope: This is a list of operations the app will be able to access on the user's account. For a complete list of scopes see: https://github.com/WeYouMe/weauth/wiki/OAuth-2#scopes

Get Login URL

The following method returns a URL that weauthjs can redirect the user to so that they may log in to WeYouMe app through weauthjs:

var link = api.getLoginURL(state);
console.log(link)
// => https://auth.WeYouMe.io/oauth2/authorize?client_id=[app]&redirect_uri=[callbackURL]&scope=vote,comment&state=[state]

Parameters:

  • state: Data that will be passed to the callbackURL for your app after the user has logged in.

After logging in, weauthjs will redirect the user to the "redirect_uri" specified in the login url above and add the following query string parameters for your app to use:

  • access_token: This is the oauth2 access token that is required to make any WeYouMe API calls on behalf of the current user. Once weauthjs have this weauthjs need to tell the weauthjs SDK to use it by either specifying it as a parameter to the init() method call or by calling weauthjs.setAccessToken([accessToken]).
  • expires_in: The number of seconds until the access token expires.
  • username: The username of the current user.

Get user profile

Once a user is logged in to your app weauthjs can call the following method to get the details of their account:

api.me(function (err, res) {
  console.log(err, res)
});

If it is successful, the result will be a JSON object with the following properties:

account:{id: 338059, name: "yabapmatt", owner: {}, active: {}, posting: {}, ...}
name:"yabapmatt"
scope:["vote"]
user:"yabapmatt"
user_metadata:{}
_id:"yabapmatt"

Vote

The vote() method will cast a vote on the specified post or comment from the current user:

api.vote(voter, author, permlink, weight, function (err, res) {
  console.log(err, res)
});

Parameters:

  • voter: The protocol username of the current user.
  • author: The protocol username of the author of the post or comment.
  • permlink: The link to the post or comment on which to vote. This is the portion of the URL after the last "/". For example the "permlink" for this post: https://alpha.WeYouMe.io/steem/@ned/announcing-smart-media-tokens-smts would be "announcing-smart-media-tokens-smts".
  • weight: The weight of the vote. 10000 equale a 100% vote.
  • callback: A function that is called once the vote is submitted and included in a block. If successful the "res" variable will be a JSON object containing the details of the block and the vote operation.

Comment

The comment() method will post a comment on an existing post or comment from the current user:

api.comment(parentAuthor, parentPermlink, author, permlink, title, body, json, function (err, res) {
  console.log(err, res)
});

Generate hot signing link

The sign() method creates a URL to which your app can redirect the user to perform a signed transaction on the blockchain such as a transfer or delegation:

var link = api.sign('transfer', {
  to: 'fabien',
  amount: '1.000 TME',
  memo: 'Hello World!',
}, 'http://localhost:8000/demo/transfer-complete');

console.log(link);
// => https://auth.WeYouMe.io/sign/transfer?to=fabien&amount=1.000%20TME&memo=Hello%20World!&redirect_uri=http%3A%2F%2Flocalhost%3A8000%2Fdemo%2Ftransfer-complete

Logout

The revokeToken() method will log the current user out of your application by revoking the access token provided to your app for that user:

api.revokeToken(function (err, res) {
  console.log(err, res)
});

Reblog

api.reblog(account, author, permlink, function (err, res) {
  console.log(err, res)
});

Follow

api.follow(follower, following, function (err, res) {
  console.log(err, res)
});

Unfollow

api.unfollow(unfollower, unfollowing, function (err, res) {
  console.log(err, res)
});

Ignore

api.ignore(follower, following, function (err, res) {
  console.log(err, res)
});

Claim Reward Balance

api.claimRewardBalance(account, TMErewardin, TSDreward, SCOREreward, function (err, res) {
  console.log(err, res)
});

Update User Metadata

api.updateUserMetadata(metadata, function (err, res) {
  console.log(err, res)
});

Changelog

1.0.1

  • Fixed response error checking.

1.0.0

  • Migrated to instance based architecture. You have to create new instance using Initialize function now. See documentation above.

contributing

building

[user@linux ~]$ npm i
[user@linux ~]$ npm run build

publish if weauthjs want to

[user@linux ~]$ npm publish