# @blinkmobile/bm-identity

> Helper functions for Blink Mobiles single identity

Latest version **5.0.0** (published 2019-03-05) · ISC license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install @blinkmobile/bm-identity
pnpm add @blinkmobile/bm-identity
yarn add @blinkmobile/bm-identity
bun add @blinkmobile/bm-identity
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 5.0.0 |
| Published | 2019-03-05 |
| First published | 2016-09-01 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=10 |
| Dependencies | 7 |
| Unpacked size | 52.4 KB |
| Known vulnerabilities | 0 (+6 in 3 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | BlinkMobile |
| Maintainers | aaronroworth, blinkmobile-admin, kizaonline, mymattcarroll, simon_marklar |

## Links

- npm: https://www.npmjs.com/package/@blinkmobile/bm-identity
- Repository: https://github.com/blinkmobile/bm-identity.js
- Homepage: https://github.com/blinkmobile/bm-identity.js#readme
- Issues: https://github.com/blinkmobile/bm-identity.js/issues
- npm.io page: https://npm.io/package/@blinkmobile/bm-identity

## Dependencies (7)

- [opn](https://npm.io/package/opn.md) 5.4.0
- [aws-sdk](https://npm.io/package/aws-sdk.md) 2.412.0
- [request](https://npm.io/package/request.md) 2.88.0
- [inquirer](https://npm.io/package/inquirer.md) 6.2.2
- [base64url](https://npm.io/package/base64url.md) 3.0.1
- [jsonwebtoken](https://npm.io/package/jsonwebtoken.md) 8.5.0
- [@blinkmobile/blinkmrc](https://npm.io/package/@blinkmobile/blinkmrc.md) 2.0.0

## Recent versions

- 5.0.0 (latest) — 2019-03-05
- 5.1.0-beta.1 (beta) — 2020-03-02
- 4.0.2 — 2018-07-20
- 4.0.1 — 2018-02-02
- 4.0.0 — 2018-02-01
- 3.3.0 — 2018-01-24
- 3.2.0 — 2018-01-10
- 3.1.0 — 2017-10-19
- 3.0.0 — 2017-09-21
- 2.3.5 — 2017-05-29
- 2.3.4 — 2017-03-28
- 2.3.3 — 2017-03-01
- 2.3.2 — 2017-02-28
- 2.3.1 — 2017-01-16
- 2.3.0 — 2016-12-01
- … 5 more at https://npm.io/package/@blinkmobile/bm-identity/versions

## README

# bm-identity.js [![npm](https://img.shields.io/npm/v/@blinkmobile/bm-identity.svg?maxAge=2592000)](https://www.npmjs.com/package/@blinkmobile/bm-identity) [![AppVeyor Status](https://img.shields.io/appveyor/ci/blinkmobile/bm-identity-js/master.svg)](https://ci.appveyor.com/project/blinkmobile/bm-identity-js) [![Travis CI Status](https://travis-ci.org/blinkmobile/bm-identity.js.svg?branch=master)](https://travis-ci.org/blinkmobile/bm-identity.js) [![Greenkeeper badge](https://badges.greenkeeper.io/blinkmobile/bm-identity.js.svg)](https://greenkeeper.io/)

Provides easy management of authenication for our CLI via a single identity.

## Getting Started

```sh
npm install @blinkmobile/bm-identity --save
```

```js
const BlinkMobileIdentity = require('@blinkmobile/bm-identity');
const blinkMobileIdentity = new BlinkMobileIdentity();
```

## Usage

### Login

If no LoginOptions are passed, a browser based login process will start. This is how users can login using a social account e.g. Google.

```js
login (options: LoginOptions) => Promise{String}
```

```js
interface LoginOptions {
  username? : String|Boolean, // Can also pass true, and username will be prompted for
  password? : String, // Will be prompted for password if username is truthy
  storeJwt? : Boolean, // Set to true to store jwt on local file system, defaults to false
  refreshToken? : Boolean, // Set to true will request a refresh token as well as an access token
}
```

```js
blinkMobileIdentity.login()
  .then(jwt => {
    // Use jwt access token.
  });
```

#### `storeJwt` Option

-   If set to `true`, will use [@blinkmobile/blinkmrc User Config](https://www.npmjs.com/package/@blinkmobile/blinkmrc) to store on local file system for later use.

### Logout

```js
logout () => Promise
```

```js
blinkMobileIdentity.logout();
```

### Get Access Token

To create an `AccessToken` using BlinkM Deployment Keys or retrieve the `AccessToken` stored after a successful login:

#### Using Deployment Keys

If the following environment variables are set:

-   `BLINKM_ACCESS_KEY`
-   `BLINKM_SECRET_KEY`

These will be used to create an `AccessToken`

```js
getAccessToken () => Promise{string}
```

```js
blinkMobileIdentity.getAccessToken()
  .then(jwt => {
    // Use access token
  });
```

### Get Access Token Payload

Helper function to get the payload for a JWT

```js
getPayload () => Promise{Object}
```

```js
blinkMobileIdentity.getPayload()
  .then(payload => {
    // Use payload
  });
```

---
_Source: https://npm.io/package/@blinkmobile/bm-identity · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
