# `niche-schibsted-account`

This package is a wrapper around `@schibsted/account-sdk-browser` that makes it easier to use for Niche team.

## What are additional things it does in coparison to SDK?

- override logout function to allow passing `redirectUrl` (`window.location.href` by default) to it.
- assigns instance if SDK to `window.Identity` - it is used like that by core comments.
- sends events for initialization and user change
- runs simplified login logic
- runs auto-login logic

## Local development

First install dependencies
clone repository, open terminal and run.

```bash
npm ci
```

Next start transpiling the source code:

```bash
npm run dev
```

### Linking

Note: order of command execution is important.

In order to make your project available as package locally:

```bash
npm link
```

And in project you need:

```bash
npm link @schibsted/niche-schibsted-account
```

Since library has `react` as peer dependency you need to make sure to pass `react` manually to the library if you want to use linked version. The easiest way to do so is to declare `react` as a webpack alias, e.g.

```js
config.resolve.alias.react = path.resolve('./node_modules/react');
```

If the project you use this package in, does not have webpack, you can try https://benjaminwfox.com/blog/tech/why-isnt-npm-link-working#if-you-use-react.

And now you are all good. Your project will now use the local version of niche-schibsted-account instead of the one in node_modules.
