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

@ui-toolkit/auth

v1.2.0

Published

Auth module for Vue apps

Downloads

5

Readme

Installation

npm i @ui-toolkit/auth
import Auth from '@ui-toolkit/auth';
import router from '@/router';

const auth = new Auth({
  router, // vue-router. This needs to be after it's initialized.
  authority: 'https://youridserver.com',
  clientId: 'my-app',
  scope: 'profile offline_access', // offline_access is required
  siteDomain: 'yourwebsite.com',
});

Vue.use(auth);

export default auth;

This module is an oidc-client implementation allowing a no-setup use of oidc in a vue app. There's a fair bit of configuration available to allow for custom use case, but 5 config options are required.

API

The auth module can be used throughout the app. It exposes the following API through the exported module as well as globally in vue components via this.$auth.

auth.loggedIn

Returns a boolean indicating whether the user is logged in.

auth.user

Returns the user object.

auth.userExpired

Returns a boolean indicating whether the user is expired.

auth.logIn()

Starts the login flow.

auth.logOut()

Logs the user out.

auth.refresh()

Forces a refresh of the user session if the ID session is still valid. (new token is grabbed)

auth.map()

Utility function for mapping the above properties to computed properties & vuex getters. Takes an array of keys and returns an object that can be spread into computed.

computed: { ...this.$auth.map(['loggedIn', 'user']), },

Config

router

Type: VueRouter

The reference to your initialized vue router.

authority

Type: string

The id server url.

clientId

Type: string

The clientId for oidc.

scope

Type: string

The oidc scope string. offline_access must always be included. The remaining scopes are typically custom per application and per id server client id config.

siteDomain

Type: string

The full root domain of the site.

appContextPath

Type: string

If the app has a root path as context, such as mysite.com/app/, the appContextPath would be /app. Do not end it with a slash.

beforeAuthCheck

Type: Function (to: Route) => void

Any custom logic you want to run before checking auth.

getHints

Type: Function (to: Route) => { localeHint: string; loginHint: string }

The function to get localeHint and loginHint.

customLightValidation

Type: Function (auth: Auth) => boolean;

Custom logic for light validation to be called every 5 seconds.

customFullValidation

Type: Function (auth: Auth) => boolean;

Custom logic for light validation to be called every route change & every 10 minutes. It should return a boolean indicating the user is validated. If the function returns false, the app will log out on route change.

customPostLogin

Type: Function (auth: Auth, returnUrl: string | null, returnIsExternal: boolean) => boolean

Custom logic called after logging in. It should return a boolean indicating whether to proceed. True will continue, false will cause a logout.

customPostLogout

Type: Function (reason?: string) => void

Custom logic called after logging out.

customPostUserLoaded

Type: Function (auth: Auth) => void

Custom logic called after the user has loaded.

customMapProfile

Type: Function (auth: Auth) => void

Custom logic called during the 'process login callback'. Receives the entire auth object, allowing custom mapping through access to the user.

extendedUserDefaults

Type: Object

An object that becomes reactive data on the user object.

customCallbackView

Type: VueComponent

customLoggedOutView

Type: VueComponent

customLayout

Type: VueComponent

extraQueryParams

Type: Function () => { [key: string]: string }

Function that returns key value pairs to be added as query string params during the signInRedirect.