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

@esek/auth-client

v5.1.0

Published

Authorzation helpers for client side

Downloads

109

Readme

@esek/auth-client

An SDK to authenticate against the E-Sek SSO OAuth2.0 login provider.

Also includes wrappers to handle OAuth for different types of clients (web). At the moment of writing, the only client that has a wrapper is SvelteKit.

EOAuth2.0Client - Generic SDK

The EAuth2.0Client is a generic SDK that streamlines the requests required to authenticate against the E-Sek SSO OAuth2.0 provider. This can be used as a standalone library, but it's also used under the hood in the SvelteKit (and should be used in additional) wrapper.

Options

When initailizing the EOAuth2.0Client, you can pass in the following options:

| Variable | Required | Default | Description | | -------------- | -------- | ------- | ------------------------------------------------------------------------------------------------------------------------ | | authUrl | true | | The URL of the E-Sek SSO OAuth2.0 provider. | | `clientId` | `false` | | The client ID of the application. | | clientSecret | false | | The client secret of the application. | | `redirectUri` | `false` | | The (default) redirect URI of the application. Note that all these non-required options can be overritten at any request |

EOAuth2Handler - SvelteKit wrapper

In order to use the E-Sek OAuth2.0 wrapper in SvelteKit, you need to:

  1. Create a hooks.{js|ts} file in the root (or somewhere else if you point it correctly according to the docs)
  2. Create a new EOAuth2Handler somewhere in your project and make it exportable:
// hooks.ts
export const appAuth = new EOAuthHandler({
  ...options,
});

The options provided to the constructor are as follows:

| Variable | Required | Default | Description | | -------------- | -------- | ------- | ----------------------------------------------------------------------------------- | | authUrl | true | | The URL of the E-Sek SSO OAuth2.0 provider. | | `clientId` | `false` | | The client ID of the application. | | clientSecret | false | | The client secret of the application. | | `basePath` | `false` | `/auth` | The base url that all authentication is handled via (ex. `/{BASE_PATH}/login` etc.) | | `isDev` | `true` | | Tells the wrapper whether to set the cookie domain or not |

  1. Use the created appAuth in your hooks file
export const handle = appAuth.handle;
export const getSession = appAuth.getSession;
  1. Create a /{BASE_PATH}/[...auth].ts route under /routes in your SvelteKit-application. This needs to be created otherwise the SvelteKit router will throw a 404 before hitting the session.

  2. Export the GET and POST endpoints from our [...auth].ts file:

// [...auth].ts
import { appAuth } from 'xxx';

export const { GET, POST } = appAuth;