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

wikibase-token

v3.0.5

Published

A promises-based lib abstracting authentification for write requests on a Wikibase API

Downloads

15

Readme

wikibase-token

A promises-based lib abstracting authentification for write requests on a Wikibase API.

See Wikidata API for API reference.

This package was primarily published as wikidata-token but has now being generalized to support any Wikibase instance: wikidata.org among others.

NPM

License Node JavaScript Style Guide

Summary

How To

install

npm install wikibase-token

use

with username / password

var config = {
  // Required
  instance: 'https://mywikibase.instance', // For Wikidata, that would be 'https://www.wikidata.org'
  username: 'myUsername',
  password: 'pa55word',
  // Optional
  verbose: true, // Default: false
  userAgent: `your-module/${pkg.version} (https://git.repo/username/your-module)` // Default: to 'wikibase-token/${pkg.version} (${pkg.repository.url})`
}
var wbToken = require('wikibase-token')
var getToken = wbToken(config)

getToken is then a function, which when called returns an ES6 promise that shoud resolve to something looking like:

{
  token: 'eb974a8adc9abacf7c9f3f94763ad92e51d76e57+\\',
  cookie: 'a very long cookie with your session data'
}

Your request header should then look like:

'cookie': cookie
'content-type': 'application/x-www-form-urlencoded'

and the token should then be passed in the body of your request as form data (thus the x-www-form-urlencoded header) and NOT ~~JSON~~ (this one got me crazy and made me realize that there was a time JSON wasn't obvious..! poor elders of the Internet), in addition with the other field expected by the API action you're using: contrary to what the API documentation seem to indicate, for POST action, parameters are passed in the body and not in the url (out of action and format)

with OAuth

same as with username / password but your config object will look like:

var config = {
  // Required
  instance: 'https://mywikibase.instance', // For Wikidata, that would be 'https://www.wikidata.org'
  oauth: {
    // Obtained at registration
    // https://www.mediawiki.org/wiki/OAuth/For_Developers#Registration
    consumer_key: 'your-consumer-token',
    consumer_secret: 'your-secret-token',
    // Obtained when the user authorized your service
    // see https://www.mediawiki.org/wiki/OAuth/For_Developers#Authorization
    token: 'a-user-token',
    token_secret: 'a-secret-token'
  },
  // Then the optional parameters are the same
}

Example

Development

To run the tests, make sure to create a config/local.js overriding config/default.js with the username and password of a Wikibase instance

Donate

We are developing and maintaining tools to work with Wikidata from NodeJS, the browser, or simply the command line, with quality and ease of use at heart. Any donation will be interpreted as a "please keep going, your work is very much needed and awesome. PS: love". Donate

See Also

You may also like

inventaire banner

Do you know inventaire.io? It's a web app to share books with your friends, built on top of Wikidata! And its libre software too.

License

MIT