# Credentials-service
Service implements credentials functionality. It used in `epom-ng2-api-service` in `ServerStrategy`.

## Getting Started

This module depends on `storage-service` and `ts-md5`

### Prerequisites

| Name | Description |
| ---- | ----------- |
| `storage-service` | need to get `userInfo` property from localStorage (userInfo.email, userInfo.password) |
| `ts-md5` | need for hash creating |



Install `ts-md5` via npm:

```sh
$ npm install --save ts-md5
```


### Installing

You need to provide it into your app.module
```typescript
    import {CredentialsService} from 'epom-ng2-credentials-service';
    ...
    providers: [
        CredentialsService,
        ...
    ];
```
That's all, this service works inside the  `ServerStrategy` of `epom-ng2-api-service` and provided by default.

## Service public methods
| Method Declaration                                                      | Description |
| ----------------------------------------------------------------------- | ----------- |
| .**replaceUrl**(endpointUrl: string): string  | replace timestamp, username, hash in string |
| .**extendParams**(requestParameters: paramsType): paramsType  | extend object using  {timestamp, username, hash} |
| .**create**(credentials: credentialsType): paramsType  | create object with params {timestamp, username, hash} |
| **stringToMd5**(inputString: string): string | generate md5 hash of string |

