# @bloomprotocol/share-kit

> Easily allow your users to share their verified personal information directly with your application.

Latest version **7.6.1** (published 2020-01-28) · Apache-2.0 license · 0 weekly downloads

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

## Install

```sh
npm install @bloomprotocol/share-kit
pnpm add @bloomprotocol/share-kit
yarn add @bloomprotocol/share-kit
bun add @bloomprotocol/share-kit
```

## Health

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

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 7.6.1 |
| Published | 2020-01-28 |
| First published | 2018-10-04 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 9 |
| Unpacked size | 379.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 18 |
| Author | Bloom Team |
| Maintainers | djvs, eddiebloom, izkp, jacehensley |

## Links

- npm: https://www.npmjs.com/package/@bloomprotocol/share-kit
- Repository: https://github.com/hellobloom/share-kit
- Homepage: https://github.com/hellobloom/share-kit#readme
- Issues: https://github.com/hellobloom/share-kit/issues
- npm.io page: https://npm.io/package/@bloomprotocol/share-kit

## Dependencies (9)

- [url](https://npm.io/package/url.md) ^0.11.0
- [tslib](https://npm.io/package/tslib.md) ^1.10.0
- [bowser](https://npm.io/package/bowser.md) ^2.4.0
- [extend](https://npm.io/package/extend.md) ^3.0.2
- [common-tags](https://npm.io/package/common-tags.md) ^1.8.0
- [@types/extend](https://npm.io/package/@types/extend.md) ^3.0.1
- [@bloomprotocol/qr](https://npm.io/package/@bloomprotocol/qr.md) ^2.0.1
- [@types/common-tags](https://npm.io/package/@types/common-tags.md) ^1.8.0
- [@bloomprotocol/attestations-common](https://npm.io/package/@bloomprotocol/attestations-common.md) ^1.0.1

## Recent versions

- 7.6.1 (latest) — 2020-01-28
- 7.6.0-beta.2 (beta) — 2020-01-10
- 7.6.0 — 2020-01-10
- 7.6.0-beta.1 — 2020-01-09
- 7.6.0-beta.0 — 2020-01-09
- 7.5.2 — 2019-11-14
- 7.5.1 — 2019-11-13
- 7.5.0 — 2019-11-06
- 7.3.0 — 2019-10-21
- 7.2.2 — 2019-10-10
- 7.2.2-beta.0 — 2019-09-29
- 7.2.1 — 2019-07-25
- 7.2.0 — 2019-07-25
- 7.1.0 — 2019-07-19
- 7.0.0 — 2019-06-20
- … 28 more at https://npm.io/package/@bloomprotocol/share-kit/versions

## README

![Share Kit](https://github.com/hellobloom/attestations-es/raw/master/assets/share-kit/logo.png)

# Share Kit

Easily allow your users to share their verified personal information directly with your application.

- [Share Kit](#share-kit)
  - [Installation](#installation)
  - [Implementations](#implementations)
  - [Usage](#usage)
    - [RequestData](#requestdata)
    - [TAttestationTypeNames](#tattestationtypenames)
      - [TAttestationTypeNames Subtypes](#tattestationtypenames-subtypes)
      - [Appending to URL](#appending-to-url)
    - [QROptions](#qroptions)
    - [ButtonOptions](#buttonoptions)
      - [ButtonType](#buttontype)
- [Using Share Kit for BloomID Sign-In](#using-share-kit-for-bloomid-sign-in)

## Installation

```
npm install --save @bloomprotocol/share-kit
```

## Implementations

| Name                                                                                                               | Description                                         | Status             |
| ------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------- | ------------------ |
| [share-kit](https://github.com/hellobloom/attestations-ts/tree/master/packages//share-kit)                         | Plain DOM implementation                            | :white_check_mark: |
| [share-kit-react](https://github.com/hellobloom/attestations-ts/tree/master/packages//share-kit-react)             | React wrapper for renderRequestElement              | :white_check_mark: |
| [share-kit-reactnative](https://github.com/hellobloom/attestations-ts/tree/master/packages//share-kit-reactnative) | React Native implementation for renderRequestButton | :white_check_mark: |
| [share-kit-vue](https://github.com/hellobloom/share-kit-vue)                                                       | Vue wrapper for renderRequestElement                | :white_check_mark: |
| [bloom_share_kit](https://github.com/hellobloom/share-kit-flutter)                                                 | Flutter implementation of renderRequestButton       | :white_check_mark: |

## Usage

`renderRequestElement` will render a QR code or button based on the client's platform. By default it will render a button when the client is mobile or tablet and on iOS.

```typescript
import {renderRequestElement, RequestData, QROptions} from '@bloomprotocol/share-kit'

const requestData: RequestData = {...}
const qrOptions: Partial<QROptions> = {
  size: 200,
}
const callbackUrl = 'https://mysite.com/bloom-callback'
const container = document.createElement('div')

const {update, remove} = renderRequestElement({container, requestData, qrOptions, callbackUrl})

// Update the element
update({requestData: newRequestData, qrOptions: newQROptions, callbackUrl: newCallbackUrl})

// Remove the element
remove()
```

<h2 id="request-types">Types</h3>

### RequestDataAuthentication

Data to be rendered into the RequestQRCode for authentication requests.

| Name                   | Description                                                                                     | Type     |
| ---------------------- | ----------------------------------------------------------------------------------------------- | -------- |
| action                 | Action type                                                                                     | `Action` |
| token                  | Unique string to identify this data request                                                     | `string` |
| url                    | The API endpoint to POST the `ResponseData` to.<br/> See [below](#appending-to-URL) for details | `string` |
| org_logo_url           | A url of the logo to display to the user when requesting data                                   | `string` |
| org_name               | The name of the organization requesting data                                                    | `string` |
| org_usage_policy_url   | The url of the usage policy for the organization requesting data                                | `string` |
| org_privacy_policy_url | The url of the privacy policy for the organization requesting data                              | `string` |

### RequestDataAttestation

Data to be rendered into the RequestQRCode for attestation sharing requests.

| Name                   | Description                                                                                     | Type                                              |
| ---------------------- | ----------------------------------------------------------------------------------------------- | ------------------------------------------------- |
| action                 | Action type                                                                                     | `Action`                                          |
| token                  | Unique string to identify this data request                                                     | `string`                                          |
| url                    | The API endpoint to POST the `ResponseData` to.<br/> See [below](#appending-to-URL) for details | `string`                                          |
| org_logo_url           | A url of the logo to display to the user when requesting data                                   | `string`                                          |
| org_name               | The name of the organization requesting data                                                    | `string`                                          |
| types                  | The type of attestions required and the amount needed                                           | [`TAttestationTypeNames`](#TAttestationTypeNames) |
| org_usage_policy_url   | The url of the usage policy for the organization requesting data                                | `string`                                          |
| org_privacy_policy_url | The url of the privacy policy for the organization requesting data                              | `string`                                          |

### TAttestationTypeNames

| Type              | Description                       | Source     | Platforms |
| ----------------- | --------------------------------- | ---------- | --------- |
| 'phone'           | SMS verification                  | Twilio     | iOS, Web  |
| 'email'           | Email verification                | Mailgun    | iOS, Web  |
| 'facebook'        | Facebook verification             | Facebook   | iOS, Web  |
| 'google'          | Google verification               | Google     | iOS, Web  |
| 'linkedin'        | LinkedIn verification             | LinkedIn   | iOS, Web  |
| 'twitter'         | Twitter verification              | Twitter    | iOS, Web  |
| 'id-document'     | Identity document verification    | Acuant     | Web       |
| 'sanction-screen' | Sanction person screening         | BlockScore | iOS, Web  |
| 'pep-screen'      | Politically exposed person screen | KYC2020    | iOS, Web  |
| 'income'          | Income verification               | Quovo      | Web       |
| 'assets'          | Assets verification               | Quovo      | Web       |

#### TAttestationTypeNames Subtypes

| Type           | Description                                                                                       | Platforms |
| -------------- | ------------------------------------------------------------------------------------------------- | --------- |
| 'full-name'    | Subtype of 'facebook', 'linkedin', 'sanction-screen', 'pep-screen', and 'id-document' attestation | iOS, Web  |
| 'birth-date'   | Subtype of 'sanction-screen', 'pep-screen', and 'id-document' attestations                        | iOS, Web  |
| 'gender'       | Subtype of 'id-document' attestation                                                              | Web       |
| 'supplemental' | Subtype of 'income' and 'assets' attestations                                                     | Web       |

For more information, see the [full list of attestation types](https://github.com/hellobloom/attestations-lib/blob/8192e222f66c9c9ec8a57f6e0e135f21acf4677b/src/AttestationTypes.ts#L8) that are implemented / planned to be implemented.

#### Appending to URL

The user can share by tapping a button or scanning a QR code, sometimes you'll need to know the difference so the query param `share-kit-from` is appended to your url.

The param will either be `share-kit-from=qr` OR `share-kit-from=button`.

```
// Input
'https://receive-kit.bloom.co/api/receive'

// Output
'https://receive-kit.bloom.co/api/receive?share-kit-from=qr'
```

Works if your url already has a query param too!

```
// Input
'https://receive-kit.bloom.co/api/receive?my-param=',

// Output
'https://receive-kit.bloom.co/api/receive?my-param=&share-kit-from=qr',
```

<h3 id="request-example">Example</h3>

# Attestation data request:

```ts
{
  action: Action.attestation,
  token: '0x8f31e48a585fd12ba58e70e03292cac712cbae39bc7eb980ec189aa88e24d043',
  url: 'https://receive-kit.bloom.co/api/receive',
  org_logo_url: 'https://bloom.co/images/notif/bloom-logo.png',
  org_name: 'Bloom',
  org_usage_policy_url: 'https://bloom.co/legal/terms',
  org_privacy_policy_url: 'https://bloom.co/legal/privacy',
  types: ['full-name', 'phone', 'email'],
}
```

# Authentication/login request:

```ts
{
  action: Action.authentication,
  token: '0xabcdee48a585fd12ba58e70e03292cac7fbac958b591baf9cbe9ac157cbadefa',
  url: 'https://receive-kit.bloom.co/api/receive',
  org_logo_url: 'https://bloom.co/images/notif/bloom-logo.png',
  org_name: 'Bloom',
  org_usage_policy_url: 'https://bloom.co/legal/terms',
  org_privacy_policy_url: 'https://bloom.co/legal/privacy',
  types: [],
}
```

![Sample QR](https://github.com/hellobloom/attestations-es/raw/master/assets/share-kit/sampleQR.png)

![Sample Button](https://github.com/hellobloom/attestations-es/raw/master/assets/share-kit/sampleButton.png)

### QROptions

_NOTE:_ Does not apply to the rendered button

Display options for the rendered QR code.

| Name      | Description                                                                                            | Type      | Default    |
| --------- | ------------------------------------------------------------------------------------------------------ | --------- | ---------- |
| size      | The height and width of the QR code.                                                                   | `number`  | `128`      |
| bgColor   | The background color of the QR code.                                                                   | `string`  | `#fff`     |
| fgColor   | The foreground color of the QR code.                                                                   | `string`  | `#6067f1`  |
| logoImage | The `<img />` src to displayed over the QR code.                                                       | `string`  | Bloom logo |
| hideLogo  | Whether the `logoImage` should be rendered.                                                            | `boolean` | `false`    |
| padding   | Percentage of the `size` of the QR code that will be padding. This will be the same color as `bgColor` | `number`  | `0`        |

### ButtonOptions

_NOTE:_ This is only used with the rendered button and not the QR code.

Rendering options for the rendered button.

| Name              | Description                                                        | Type                 | Required | Default   |
| ----------------- | ------------------------------------------------------------------ | -------------------- | -------- | --------- |
| buttonCallbackUrl | The url the user will be sent back to after they share their data. | `string`             | Y        | N/A       |
| size              | The size of the button                                             | `'sm' | 'md' | 'lg'` | N        | 'lg'      |
| type              | The type of button, based on the given `size`                      | See below            | N        | See below |

#### ButtonType

The type of button to rendered based on it's size

| Size | Type                                                        | Required | Default  |
| ---- | ----------------------------------------------------------- | -------- | -------- |
| sm   | `'square' \| 'rounded-square' \| 'circle' \| 'squircle'`    | Y        | N/A      |
| md   | `'log-in' \| 'sign-up' \| 'connect' \| 'bloom' \| 'verify'` | N        | 'verify' |
| lg   | `'log-in' \| 'sign-up' \| 'connect' \| 'bloom' \| 'verify'` | N        | 'verify' |

Example:

- Small:

  - Square

    ![small sqaure](https://github.com/hellobloom/attestations-es/raw/master/assets/share-kit/buttons/small/square.png)

  - Rounded Square

    ![small rounded-sqaure](https://github.com/hellobloom/attestations-es/raw/master/assets/share-kit/buttons/small/rounded-square.png)

  - Circle

    ![small circle](https://github.com/hellobloom/attestations-es/raw/master/assets/share-kit/buttons/small/circle.png)

  - Squircle

    ![small squircle](https://github.com/hellobloom/attestations-es/raw/master/assets/share-kit/buttons/small/squircle.png)

- Small Inverted:

  - Small buttons can have thier foreground and background colors swaped with the `invert` flag

    ![small inverted buttons](https://github.com/hellobloom/attestations-es/raw/master/assets/share-kit/buttons/small/inverted.png)

* Medium:

  - Log In

    ![medium log-in](https://github.com/hellobloom/attestations-es/raw/master/assets/share-kit/buttons/medium/log-in.png)

  - Sign Up

    ![medium sign-up](https://github.com/hellobloom/attestations-es/raw/master/assets/share-kit/buttons/medium/sign-up.png)

  - Connect

    ![medium connect](https://github.com/hellobloom/attestations-es/raw/master/assets/share-kit/buttons/medium/connect.png)

  - Bloom

    ![medium bloom](https://github.com/hellobloom/attestations-es/raw/master/assets/share-kit/buttons/medium/bloom.png)

  - Verify

    ![medium verify](https://github.com/hellobloom/attestations-es/raw/master/assets/share-kit/buttons/medium/verify.png)

* Large:

  - Log In

    ![large log-in](https://github.com/hellobloom/attestations-es/raw/master/assets/share-kit/buttons/large/log-in.png)

  - Sign Up

    ![large sign-up](https://github.com/hellobloom/attestations-es/raw/master/assets/share-kit/buttons/large/sign-up.png)

  - Connect

    ![large connect](https://github.com/hellobloom/attestations-es/raw/master/assets/share-kit/buttons/large/connect.png)

  - Bloom

    ![large bloom](https://github.com/hellobloom/attestations-es/raw/master/assets/share-kit/buttons/large/bloom.png)

  - Verify

    ![large verify](https://github.com/hellobloom/attestations-es/raw/master/assets/share-kit/buttons/large/verify.png)

# Using Share Kit for BloomID Sign-In

In conjuction with this libary you will use [Verify Kit](https://github.com/hellobloom/verify-kit) to verify shared data on your server.

Complete examples are available at [Bloom Starter](https://github.com/hellobloom/bloom-starter).

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