5.1.0 • Published 6 months ago

@esek/auth-client v5.1.0

Weekly downloads
-
License
ISC
Repository
github
Last release
6 months ago

@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:

VariableRequiredDefaultDescription
authUrltrue | The URL of the E-Sek SSO OAuth2.0 provider.
clientIdfalse | The client ID of the application.
clientSecretfalse | The client secret of the application.
redirectUrifalse | 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:

VariableRequiredDefaultDescription
authUrltrue | The URL of the E-Sek SSO OAuth2.0 provider.
clientIdfalse | The client ID of the application.
clientSecretfalse | The client secret of the application.
basePathfalse/authThe base url that all authentication is handled via (ex. /{BASE_PATH}/login etc.)
isDevtrue | 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;
5.1.0

6 months ago

5.0.3

1 year ago

5.0.2

1 year ago

5.0.1

1 year ago

5.0.0

1 year ago

2.2.2-alpha.1

2 years ago

2.2.2-alpha.0

2 years ago

3.0.0-alpha.2.0

2 years ago

3.0.0-alpha.0

2 years ago

2.2.2

2 years ago

4.0.0-alpha.0

2 years ago

4.1.1-alpha.0

2 years ago

3.0.0

2 years ago

2.2.3-beta.1

2 years ago

4.1.0-alpha.0

2 years ago

2.2.1

2 years ago

2.2.0

2 years ago

2.1.5

2 years ago

2.1.4

2 years ago

2.1.3

2 years ago

2.1.2

2 years ago

2.1.1

2 years ago

2.1.0

2 years ago

2.0.0

2 years ago

1.0.14

2 years ago

1.0.13

2 years ago

1.0.12

2 years ago

1.0.11

2 years ago

1.0.10

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago