# ngma-core-libraries

> [Changelog here](https://github.com/fonzy85vr/ngma-core-libraries/blob/develop/projects/ngma-core-libraries/CHANGELOG.md)

Latest version **0.3.0** (published 2019-09-06) · 0 weekly downloads

## Install

```sh
npm install ngma-core-libraries
pnpm add ngma-core-libraries
yarn add ngma-core-libraries
bun add ngma-core-libraries
```

## Health

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

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.0 |
| Published | 2019-09-06 |
| First published | 2018-12-17 |
| Weekly downloads | 0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 240.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | fonzy85vr |

## Links

- npm: https://www.npmjs.com/package/ngma-core-libraries
- npm.io page: https://npm.io/package/ngma-core-libraries

## Dependencies (1)

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

## Recent versions

- 0.3.0 (latest) — 2019-09-06
- 0.2.1 — 2018-12-24
- 0.2.0 — 2018-12-20
- 0.1.5 — 2018-12-17

## README

# NgmaCoreLibraries

## Changelog
[Changelog here](https://github.com/fonzy85vr/ngma-core-libraries/blob/develop/projects/ngma-core-libraries/CHANGELOG.md)

## Description
This package containt all the base functionalities of an Angular Application.
- Authentication (by google, local server, ...)

## Usage

### Authentication Module

for usage this module, in your module file set this code:
```javascript
const _url = `${environment.urlAPIs}`;

export function getAuthServiceConfigs() {
  const config = new AuthServiceConfig([{
      id: GoogleProvider.PROVIDER_ID,
      provider: new GoogleProvider('306411211066-aft61tohv2uml1rirdmmutb7e2nhleq6.apps.googleusercontent.com')
  }, {
    id: LocalProvider.PROVIDER_ID,
    provider: new LocalProvider(`${_url}\auth`)
}]);

  return config;
}

@NgModule({
  imports: [
    HttpClientModule,
    AuthModule.Init(getAuthServiceConfigs())
  ],
  exports: [],
  declarations: [],
  providers: [],
})
export class SharedModule { }
```

In your server api you must have an entry point called **login** that accept the parameters **username** and **password**.

In your Service

```javascript
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { AuthorizationService, GoogleProvider, LocalProvider } from 'ngma-core-libraries';

@Injectable()
export class AuthService {

    constructor(private _authService: AuthorizationService, private _http: HttpClient) {}

    googleLogin() {
        return this._authService.Login(GoogleProvider.PROVIDER_ID, { offline: true }).then(
            (userData) => {
               console.log(userData); // userData contains or GoogleAuthToken or Google User informations
            }
        );
    }

    login(username, password) {
        return this._authService.Login(LocalProvider.PROVIDER_ID, { username, password }, this._http).then(
            (userData) => {
               return userData; // userData contains your api result
            }
        );
    }

    authToken(token) {
        return this._authService.AuthorizeToken(LocalProvider.PROVIDER_ID, { token }, this._http).then(
            (userData) => {
               return userData; // userData contains your api result
            }
        );
    }
}

```

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