# @tru_id/tru-sdk-web

> SDK for tru.ID that provides a helper method for requesting the `check_url` for PhoneCheck and SubscriberCheck

Latest version **0.0.11** (published 2022-07-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install @tru_id/tru-sdk-web
pnpm add @tru_id/tru-sdk-web
yarn add @tru_id/tru-sdk-web
bun add @tru_id/tru-sdk-web
```

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.11 |
| Published | 2022-07-22 |
| First published | 2021-02-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 21.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | tru.ID |
| Maintainers | dyakici, gregholmes, leggetter, lpedrosa, ciao_mario, mtt, myakici |
| Keywords | 2FA, MFA, Number Verify |

## Links

- npm: https://www.npmjs.com/package/@tru_id/tru-sdk-web
- Repository: https://github.com/tru-ID/tru-sdk-web
- Homepage: https://github.com/tru-ID/tru-sdk-web#readme
- Issues: https://github.com/tru-ID/tru-sdk-web/issues
- npm.io page: https://npm.io/package/@tru_id/tru-sdk-web

## Alternatives

- [random-seedable](https://npm.io/package/random-seedable.md) — 27.9K weekly downloads
- [n2words](https://npm.io/package/n2words.md) — 22.2K weekly downloads
- [@stdlib/math-base-special-factorialln](https://npm.io/package/@stdlib/math-base-special-factorialln.md) — 5.7K weekly downloads
- [@stdlib/math-base-special-abs2](https://npm.io/package/@stdlib/math-base-special-abs2.md) — 1.7K weekly downloads
- [commons-math-interpolation](https://npm.io/package/commons-math-interpolation.md) — 1.4K weekly downloads

## Recent versions

- 0.0.11 (latest) — 2022-07-22
- 0.0.4 (canary) — 2021-06-10
- 0.0.10 — 2022-03-24
- 0.0.9 — 2022-03-24
- 0.0.8 — 2022-03-18
- 0.0.7 — 2022-02-16
- 0.0.6 — 2022-01-06
- 0.0.5 — 2021-06-10
- 0.0.3 — 2021-06-07
- 0.0.2-canary.1 — 2021-06-01
- 0.0.2-canary.0 — 2021-06-01
- 0.0.1-canary.2 — 2021-02-17
- 0.0.1-canary.1 — 2021-02-02
- 0.0.1-canary.0 — 2021-02-01

## README

# tru.ID SDK for Mobile Web Applications

[![License][license-image]][license-url]

The Web SDK for tru.ID providing a helper function for requesting the `check_url` for [PhoneCheck](https://tru.id/docs/phone-check) and [SubscriberCheck](https://tru.id/docs/subscriber-check).

## Installation

### Via jsDelivr CDN

```html
<script src="https://cdn.jsdelivr.net/npm/@tru_id/tru-sdk-web/dist/tru-id-sdk.umd.js"></script>
```

### Via NPM

```sh
$ npm install @tru_id/tru-sdk-web
```

## Usage

### Via jsDelivr CDN

#### Reachability Check

```html
<script src="https://cdn.jsdelivr.net/npm/@tru_id/tru-sdk-web/dist/tru-id-sdk.umd.js"></script>
<script>
  tru.ID.getReachability(url)
</script>
```

#### PhoneCheck

When installed via a CDN a `tru.ID` global is installed.

```html
<script src="https://cdn.jsdelivr.net/npm/@tru_id/tru-sdk-web/dist/tru-id-sdk.umd.js"></script>
<script>
  tru.ID.openCheckUrl(url, config)
</script>
```

### Via NPM

#### Reachability Check

```js
import truID from '@tru_id/tru-sdk-web'

truID.getReachability(url)
```

#### PhoneCheck

When installed via NPM the imported object exposes the `openCheckUrl` function.

```js
import truID from '@tru_id/tru-sdk-web'

truID.openCheckUrl(checkUrl, config)
```

### `openCheckUrl` Config

The `openCheckUrl` function takes an optional `config` Object argument:

```js
truID.openCheckUrl(url, config)
```

The configuration options are:

```js
{
  // whether debug information will be logged to the console.
  // Defaults to `false`
  debug: boolean,

  // "image" - a zero pixel image is dynamically added to the DOM for the check_url request
  // "window" - `window.open` is called to open the check_url in a new window
  // Defaults to "image".
  checkMethod: "image" | "window",

  // If `checkMethod` was set to `window` identifies the number of
  // milliseconds after which the opened window will be closed.
  // Defaults to 3000.
  windowCloseTimeout: Number,

  // It will run the device coverage check to determine
  // if the device is on a mobile IP
  // Defaults to true
  checkDeviceCoverage: boolean,

  // Depending on what PhoneCheck API version the check is created with.
  // Defaults to "v0.2"
  version: "v0.1" | "v0.2",
}
```

## Local development

You can run `npm run dev` that will open rollup with watch mode that will re-compile the SDK after every change.

In another terminal you can run `npm run serve` to open a test web page where you can test real phone checks if you have the node server running or you can simply check a PhoneCheck `check_url`.

## Releasing

1. Bump the version if required
2. Run `npm run changelog` to auto-update the `CHANGELOG.md` and manually edit to finesse
3. Commit the changes read for release: `git commit -m 'chore(release): v{version}`
4. Tag the release `git tag v{version}`
5. Push the tags `git push --follow-tags origin main`
6. Build the project with `npm run build`
6. Publish to NPM `npm publish --access public`

## License

[MIT](LICENSE)

## Meta

Distributed under the MIT license. See ``LICENSE`` for more information.

[https://github.com/tru-ID](https://github.com/tru-ID)

[license-image]: https://img.shields.io/badge/License-MIT-blue.svg
[license-url]: LICENSE

---
_Source: https://npm.io/package/@tru_id/tru-sdk-web · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
