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

@nanoauth/myanimelist

v0.2.3

Published

NanoAuth library for retrieving a MyAnimeList token

Downloads

131

Readme

@nanoauth/myanimelist — Handle MyAnimeList OAuth2 flow

Provides a set of basic utilities for managing OAuth2 flows in a popup.

You can absolutely use this directly, but if there's a @nanoauth/ package specific to the site you want to access, I recommend using that instead. The stuff in this package is pretty low-level.

Usage

Install NanoAuth as a dependency

npm install @nanoauth/base

Set up your redirect target. This should be an HTML file which just calls handleRedirect(), and it must be served from the same origin as your application.

async getAuthorization(url: URL | string): Promise<Record<string, unknown>>

Opens a popup for an OAuth2 flow and resolves with the resulting data. If the OAuth2 Provider redirects with an error or the popup fails to open, this will reject.

handleRedirect(): void

Only used for the redirect target. Extracts the URL params for both Authorization Code (?query) and Implicit Grant (#fragment) redirect responses, and sends them to the originating page with postMessage.

generateRandom64(bytes: number): string

Utility for PKCE support. Uses browser crypto to securely generate a base64-encoded string of random bytes.

Errors

PopupFailed extends Error

Failed to open a popup. This usually happens due to a popup blocker. Check that you are calling getAuthorization within one second of user interaction (ie, clicking a button)

StateMismatch extends Error

The state parameter received back from the OAuth2 provider wasn't the expected one.

OAuth2Error extends Error

Base class for generic OAuth2 errors.

InvalidRequest extends OAuth2Error

The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed.

UnauthorizedClient extends OAuth2Error

The client is not authorized to request an authorization code using this method.

AccessDenied extends OAuth2Error

The resource owner or authorization server denied the request.

UnsupportedResponseType extends OAuth2Error

The authorization server does not support obtaining an authorization code using this method.

InvalidScope extends OAuth2Error

The requested scope is invalid, unknown, or malformed.

ServerError extends OAuth2Error

The authorization server encountered an unexpected condition that prevented it from fulfilling the request.

TemporarilyUnavailable extends OAuth2Error

The authorization server is currently unable to handle the request due to a temporary overloading or maintenance of the server.