# ngx-line-liff

> Authentication module for Angular. Supports authentication with LINE-LIFF. Can be extended to other providers also.

Latest version **1.0.0** (published 2021-09-16) · 0 weekly downloads

## Install

```sh
npm install ngx-line-liff
pnpm add ngx-line-liff
yarn add ngx-line-liff
bun add ngx-line-liff
```

## Health

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

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2021-09-16 |
| First published | 2021-09-16 |
| Weekly downloads | 0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 180.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | aofxta |

## Links

- npm: https://www.npmjs.com/package/ngx-line-liff
- npm.io page: https://npm.io/package/ngx-line-liff

## Dependencies (1)

- [tslib](https://npm.io/package/tslib.md) ^2.3.0

## Recent versions

- 1.0.0 (latest) — 2021-09-16
- 0.5.0 — 2021-09-16
- 0.0.1 — 2021-09-16

## README

# Angular LINE LIFF

> Demo: [Line OA](https://lin.ee/un7ovFi) for demo.

Authentication module for Angular. Supports authentication with LINE-LIFF. Can be extended to other providers also.

### Comatibility Matrix

| Library Version | Angular Version | @line/liff |
| - | - | - |
| 1.0.0 | 12.2.0 | 2.14.0 |
| 0.5.0 | 12 | 2.13.0 |

## Getting started

### Install via npm

```sh
npm i ngx-line-liff
npm i @line/liff
```

### Import the module

In your `AppModule`, import the `NgxLineLiffModule`

```javascript
...
import {
  NgxLineLiffModule,
  LineLiffLoginProvider,
  LineLiffServiceConfig
} from 'ngx-line-liff';

const ngxLiffConfig = <LineLiffServiceConfig>{
  autoLogin: false,
  providers: [
    {
      id: LineLiffLoginProvider.PROVIDER_ID,
      provider: new LineLiffLoginProvider('channel_id', { liffId: 'liff_id' })
    }
  ],
  onError: (err: any) => console.log(err)
}

@NgModule({
  declarations: [ ... ],
  imports: [
    ...
    NgxLineLiffModule
  ],
  providers: [
    {
      provide: 'LineLiffServiceConfig',
      useValue: ngxLiffConfig as LineLiffServiceConfig
    }
  ],
  bootstrap: [...]
})
export class AppModule { }
```

### Sign in and out users

```javascript
...
import { NgxLineLiffService } from 'ngx-line-liff';

@Component({
  selector: 'app-demo',
  templateUrl: './demo.component.html',
  styleUrls: ['./demo.component.css']
})
export class DemoComponent implements OnInit {

  constructor(private auth: NgxLineLiffService) { }

  statusLogined(): void {
    this.ngxLineLiff.getLoginStatus();
  }
  authLogin(): void {
    //-- this.ngxLineLiff.signIn();
    this.ngxLineLiff.signIn({ redirectUri: window.location.href });
  }
  authLogout(): void {
    this.ngxLineLiff.signOut();
  }
}
```

### Subscribe to the authentication state

You receive a `LineProfile` object when the user logs in and a `null` when the user logs out. `LineProfile` object contains basic user information such as name, photo URL, etc.

```javascript
...
import { NgxLineLiffService, LineProfile } from 'ngx-line-liff';

@Component({
  selector: 'app-demo',
  templateUrl: './demo.component.html',
  styleUrls: ['./demo.component.css']
})
export class DemoComponent implements OnInit {

  user: LineProfile;
  loggedIn: boolean;

  constructor(private auth: NgxLineLiffService) { }

  ngOnInit() {
    this.auth.authState.subscribe(user => {
      this.user = user;
      this.loggedIn = (user != null);
    });
  }
}
```

### Display the user information

```html
<img src="{{ user.pictureUrl }}">
<div>
  <h4>{{ user.displayName }}</h4>
  <p>{{ user.statusMessage }}</p>
</div>
```

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