# gtn-signin-widget

> ---

Latest version **1.0.9** (published 2021-10-21) · 0 weekly downloads

## Install

```sh
npm install gtn-signin-widget
pnpm add gtn-signin-widget
yarn add gtn-signin-widget
bun add gtn-signin-widget
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.9 |
| Published | 2021-10-21 |
| First published | 2021-04-13 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 205.4 KB |
| Known vulnerabilities | 0 (+23 in 1 direct dependencies) |
| Install scripts | no |
| Author | Arsenii Temnik |
| Maintainers | isch, svchk, wokeisha42 |

## Links

- npm: https://www.npmjs.com/package/gtn-signin-widget
- Repository: https://github.com/get-net/gtn-signin-widget
- Homepage: https://github.com/get-net/gtn-signin-widget#readme
- Issues: https://github.com/get-net/gtn-signin-widget/issues
- npm.io page: https://npm.io/package/gtn-signin-widget

## Dependencies (2)

- [axios](https://npm.io/package/axios.md) ^0.21.1
- [sirv-cli](https://npm.io/package/sirv-cli.md) ^1.0.0

## Recent versions

- 1.0.9 (latest) — 2021-10-21
- 0.0.8 — 2021-04-16
- 0.0.7 — 2021-04-14
- 0.0.6 — 2021-04-14
- 0.0.5 — 2021-04-14
- 0.0.4 — 2021-04-13
- 0.0.3 — 2021-04-13
- 0.0.2 — 2021-04-13
- 0.0.1 — 2021-04-13

## README

---

# Get-Net SignIn Widget
This library gives you a customizable login widget, that can be used to authenticate users on your web application

## Get started
To use this library you need to do the following steps:
1. Visit our [kyc service](https://id.gtn.ee/)
2. Create your own application
![alt Applications list](img/applications.png)
![alt create application](img/add_app.png)
3. Provide redirect uri, its the base url of your app, where widget is gona be used
4. After app is created you can click on edit icon add see a client ID, it will be needed later
![alt create application](img/client.png)


## Installation
Using npm:

```bash
    npm install gtn-signin-widget
```
Import the module
```js
    // ES module
    import { SignInGTN } from 'gtn-signin-widget'
    const widget = new SignInGTN({
        // config
    })
```

Using unpkg
```html
    <script src="https://unpkg.com/gtn-signin-widget@latest/public/build/bundle.js"></script>
```
Instance of SignInGTN avaliable globally
```js
    const widget = new SignInGTN({
        // config
    })
```

## Usage
You must provide configuration object and callbacks to SignInGTN instance:

```js
    let widgetConfig = {
        client_uid: "your client id",
        appearance: {
            logo: {
                src: "https://www.get-net.ru/img/logo.png",
                width: "400px"
            },
            signInFormText: "Get-Net Sign in",
            signUpFormText: "Get-Net Sign Up",
            width: "500px" //total widget width
        },
        lang: "en", //or ru
        features: {
            registration: true, //registration feature is optional
            rememberMe : true   //remember me feature is optional
        }
    }

    const successCallback = function() {
        //your success logic goes here
    }
    const errorCallback = function(error) {
        //your error logic goes here
    }
    const widget = new SignInGTN(widgetConfig, successCallback, errorCallback)
```

To render widget use renderEl function of created instance:
```js
    const widget = new SignInGTN(widgetConfig, scal, ercal)

    widget.renderEl("app") //optional id
```
Widget will be rendered inside the html element with id="app"

### Get Token
```js
    const token = widget.getToken()
```

### Get UserInfo
```js
    const userInfo = widget.getUserInfo()
```

### Logout
```js
    widget.logout()
```
### Check User unfo
```js
    const token_valid = await widget.checkTokenValid()
```

You can acces widget globally trough window object
```js
    let widget = window.$gtn_widget
```
## Styling
Apply default style for widget:
using npm:
```js
    import 'gtn-signin-widget/public/build/bundle.css'
```
using unpkg:
```html
    <link rel="stylesheet" href="https://unpkg.com/gtn-signin-widget@latest/public/build/bundle.css"
```
### Override default styles
All ui elements of widget are inherited from gtn-widget-wrapper class

input elements have widget-input class 

For more detail information watch repository

---
_Source: https://npm.io/package/gtn-signin-widget · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
