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 🙏

© 2025 – Pkg Stats / Ryan Hefner

simple-lastfm-desktop

v1.0.1

Published

A simple-lastfm extension for the destop authentication process

Readme

simple-lastfm-desktop

Desktop Hooks for lastfm integrations

You are here because you are building an app(probably with Electron) which integrates to lastfm, but using the desktop integration flow with any of the existing npm libraries kind of sucks.

So here's extensions to simple-lastfm to support desktop authentication methods, as well as a conveinience method to handle the whole process.

account configuration

Make sure when you create your last.fm account you set your domain to localhost, so your application can open a port and the web browser can deliver the token to your app. The .ready() wrapup function uses http://localhost:8082/lastfm_return, so you should use that. If you are manually using .getDesktopSessionKey() and .getToken() you can use whatever you want (like something more complicated requiring a server).

desktop authentication methods

  • api.getToken(<callback(result)>) calls with an object containing .status and .token or .error and requires .api_key and .api_secret are set
  • api.getDesktopSessionKey(<callback(result)>, <authenticate(finishFunction)>) calls with an object containing .status and .token or .error and requires .token, .api_key and .api_secret are set.

To authenticate you need to open a server which can recieve the notification, then forward the user to the last.fm authentication endpoint( http://www.last.fm/api/auth/?api_key=<api key>&token=<token> ), after authenticating the app they will redirect to the URL you set when you obtain the key. If you want a host free setup, then use localhost and the website can notify your local webserver (this is automated in .ready() below).

.ready() ... the short, short version

.ready(<readyFunction>, <authenticationCompleteFunction>)

So, this requires a sql compatible database. I'm going to show how to use it with Mangrove, but you could also use anything that supports sql (just pass an object with a .query(<sql>, <callback>) signature). This will direct the user through last.fm's authentication flow in their default browser and return them to the application when complete (some browsers will not allow me to close the resulting window!). I'm using the fs sync functions just for brevity and the process requires port 8082 be available. When using this in your own project copy lastfm.html into your own app (this is the page served to users when they return from last.fm).

var db = new Mangrove(fs.readFileSync('services.json'))

api.ready(db, function(){
    //api is now ready to be used
}, function(){
	//switch back to the app window after auth in the browser
    window.show();
});

Then, when the application is closing:

fs.writeFileSync('services.json', db.toJSON())

That was as simple as I could make it, and really... that's not too bad.

Enjoy,

-Abbey Hawk Sparrow