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

@rturnq/solid-auth0

v0.2.1

Published

Auth0 integration for solid-js

Downloads

55

Readme

solid-auth0

Auth0 integration for solid-js which wraps @auth0/auth0-spa-js

Getting Started

Installation

> npm i @rturnq/solid-auth0

Usage

Wrap the root of you application with the provider element

import { Auth0 } from '@rturnq/solid-auth0';

() => {
  return (
    <Auth0
      domain="..." // domain from Auth0
      clientId="..." // client_id from Auth0
      audience="..." // audience from Auth0
      logoutRedirectUri={`${window.location.origin}/logout`} // Absolute URI Auth0 logout redirect
      loginRedirectUri={`${window.location.origin}/`} // Absolute URI Auth0 login
    >
      <MyApp />
    </Auth0>
  )
}

Access the auth context elsewhere in your application

import { useAuth0 } from '@rturn/solid-auth0';

() => {
  const auth = useAuth0();

  return (
    // ...
  )
}

API

useAuth0

Access the auth context provided by the <Auth0> component.

useAuth0(): Auth0

interface Auth0 {
  // Signal containing the Auth0 client provided by @auth0/auth0-spa-js. Will be undefined until it
  // finishes initializing and checking authentication status.
  auth0Client: () => Auth0Client | undefined

  // Signal indicating if the Auth0 client is being initialized.
  isInitialized: () => boolean;

  // Signal indicating if the user is authenticated
  isAuthenticated: () => boolean;

  // Signal containing the user object when authenticated or undefined when not authenticated
  user: () => any;

  // Action to login using a Auth0's universal login page then redirect to the login URI configured
  // in the provider
  loginWithRedirect: (options?: RedirectLoginOptions) => Promise<void>;

  // Action to log the user out and redirect to the logout URI configured in the provider
  logout: (options?: LogoutOptions) => Primise<void>;

  // Get an auth token using they client's `getTokenSilently` method. Note, this method can be
  // called before the client is initialized and it will wait for it to initialize.
  getToken(): Promise<string>;
}

Components

<Auth0>

Wraps your applcation with the Auth0 context

interface Props {
  // Domain as configured in Auth0
  domain: string;
  
  // Audience as configured in Auth0
  audience: string;

  // Client_Id as configured in Auth0
  clientId: string;

  // Absolute URI Auth0 will redirect to after successfully logging in
  loginRedirectUri: string;

  // Absolute URI Auth0 will redirect to after logging out
  logoutRedirectUri: string;

  // Provide a way to get the current URL. Used for checking if the current URL represents a login
  // callback. By default this is impleted using `window location.href and exposed to isolate
  // browser API dependencies.
  getUrl?: () => string;

  // Callback called when Auth0 redirects the user back to your application. Auth0 includes a query
  // string containing `state` and `code`. Normally you want to redirect to a route without the
  // query string. By default this this is implemented with `window.history.replace` and is exposed
  // to isolate browser API dependencies and give you and integration point to your router.
  onLogin?: (appState: any, loginRedirectUri: string) => void;
  
  // Children
  children: JSX.Children;
}