# ula-process-eth-barcode

> An ULA plugin for processing barcodes for the eth namespace

Latest version **0.2.2** (published 2020-03-24) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install ula-process-eth-barcode
pnpm add ula-process-eth-barcode
yarn add ula-process-eth-barcode
bun add ula-process-eth-barcode
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.2 |
| Published | 2020-03-24 |
| First published | 2019-09-16 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=8.15.0 |
| Dependencies | 1 |
| Unpacked size | 35.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | dlamers, jnieuwenhuijzen, rabomarnix |
| Keywords | plugin, ethereum, did, barcode, universal, ledger, agent, module, identity, blockchain |

## Links

- npm: https://www.npmjs.com/package/ula-process-eth-barcode
- Repository: https://github.com/rabobank-blockchain/ula-process-eth-barcode
- Homepage: https://github.com/rabobank-blockchain/ula-process-eth-barcode#readme
- Issues: https://github.com/rabobank-blockchain/ula-process-eth-barcode/issues
- npm.io page: https://npm.io/package/ula-process-eth-barcode

## Dependencies (1)

- [universal-ledger-agent](https://npm.io/package/universal-ledger-agent.md) ^0.1.3

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 0.2.2 (latest) — 2020-03-24
- 0.2.0 — 2019-12-27
- 0.1.0 — 2019-09-16

## README

# ula-process-eth-barcode

[![Build Status](https://travis-ci.org/rabobank-blockchain/ula-process-eth-barcode.svg?branch=master)](https://travis-ci.org/rabobank-blockchain/ula-process-eth-barcode)
[![Test Coverage](https://api.codeclimate.com/v1/badges/773aa5e63b2d2b70b99c/test_coverage)](https://codeclimate.com/github/rabobank-blockchain/ula-process-eth-barcode/test_coverage)
[![Maintainability](https://api.codeclimate.com/v1/badges/773aa5e63b2d2b70b99c/maintainability)](https://codeclimate.com/github/rabobank-blockchain/ula-process-eth-barcode/maintainability)
[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)

A Holder [ULA](https://github.com/rabobank-blockchain/universal-ledger-agent) plugin for processing [W3C Verifiable Credential](https://www.w3.org/TR/verifiable-claims-data-model/) QR codes, using
the [credential exchange flow](https://github.com/rabobank-blockchain/vp-toolkit/blob/master/doc/vc-flow.png) described in [vp-toolkit](https://github.com/rabobank-blockchain/vp-toolkit).
This small plugin calls the endpoint as provided in the QR code and expects a ChallengeRequest object response from the endpoint.
Then the ChallengeRequest object is parsed and sent to the next plugin by broadcasting a ULA message.

**We strongly recommend to add the [ula-vp-controller](https://github.com/rabobank-blockchain/ula-vp-controller) plugin so the rest of the flow is executed.**

## Installation

In an existing project (with `package.json`), install `ula-process-eth-barcode`

```bash
npm install ula-process-eth-barcode --save
```

## Usage

```typescript
import { ProcessEthBarcode, BrowserHttpService } from 'ula-process-eth-barcode'
import { EventHandler, UlaResponse } from 'universal-ledger-agent'

// Prepare the ProcessEthBarcode plugin
const httpService = new BrowserHttpService()
const processEthBarcode = new ProcessEthBarcode(httpService)
// Instantiate the Universal Ledger Agent with this plugin
const ulaEventHandler = new EventHandler([processEthBarcode])
// Note that you will need to add more plugins to complete the flow

// Then, somewhere in your code, call your own QR code scanner component:
const qrCodeContents: object = await yourQRCodeScanner.scan()
// Make sure that qrCodeContents object at least contains a 'type' field!

// And let the ULA handle the rest of the process:
ulaEventHandler.processMsg(qrCodeContents, (response: UlaResponse) => {
  // Handle callback
})
```

The `UlaResponse` callback with the `statusCode` and `body` fields can be in many shapes or forms.
This plugin does not use the callback itself, instead, it passes it to the next plugin.


### QR code content

In order to trigger this plugin, the ULA message must be in the following format:
```typescript
const msg = {
  type: 'ethereum-qr',
  url: '{endpoint}'
}
```
The endpoint must return a signed, stringified [ChallengeRequest](https://github.com/rabobank-blockchain/vp-toolkit-models/blob/master/src/model/challenge-request.ts) when doing a `GET` request.

### Handling the ChallengeRequest

This plugin does **not** handle the ChallengeRequest. Instead, this plugin will send a new ULA message with this payload:
```typescript
const msg = {
  type: 'process-challengerequest',
  msg: challengeRequestJson
}
```
This message can be handled by the [ula-vp-controller](https://github.com/rabobank-blockchain/ula-vp-controller) plugin.
If you want to handle the ChallengeRequest yourself, create a plugin which listens to the `process-challengerequest` type.

## Running tests

Besides unit testing with Mocha, the effectivity of all tests are also measured with the Stryker mutation testing framework.

```bash
npm run test
npm run stryker
```

We aim to achieve a coverage of 100%. Stryker and/or mocha test scores below 80% will fail the build.

## Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

## License and disclaimer

[apache-2.0](https://choosealicense.com/licenses/apache-2.0/) with a [notice](NOTICE).

We discourage the use of this work in production environments as it is in active development and not mature enough.

---
_Source: https://npm.io/package/ula-process-eth-barcode · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
