# @ekycsolutions/ml-js-sdk

> A module for ML web sdk

Latest version **0.0.10-alpha.13** (published 2023-09-12) · ISC license · 0 weekly downloads

## Install

```sh
npm install @ekycsolutions/ml-js-sdk
pnpm add @ekycsolutions/ml-js-sdk
yarn add @ekycsolutions/ml-js-sdk
bun add @ekycsolutions/ml-js-sdk
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; large bundle; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.10-alpha.13 |
| Published | 2023-09-12 |
| First published | 2023-06-09 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 9 |
| Unpacked size | 23.1 MB |
| Known vulnerabilities | 0 (+28 in 3 direct dependencies) |
| Install scripts | no |
| Maintainers | shadowlegend |

## Links

- npm: https://www.npmjs.com/package/@ekycsolutions/ml-js-sdk
- npm.io page: https://npm.io/package/@ekycsolutions/ml-js-sdk

## Dependencies (9)

- [rxjs](https://npm.io/package/rxjs.md) ^7.8.1
- [axios](https://npm.io/package/axios.md) ^0.21.4
- [howler](https://npm.io/package/howler.md) ^2.2.3
- [nanoid](https://npm.io/package/nanoid.md) ^4.0.2
- [opencv.js](https://npm.io/package/opencv.js.md) ^1.2.1
- [face-api.js](https://npm.io/package/face-api.js.md) ^0.22.2
- [@babel/runtime](https://npm.io/package/@babel/runtime.md) ^7.22.3
- [@tensorflow/tfjs](https://npm.io/package/@tensorflow/tfjs.md) 1.7.0
- [@mediapipe/face_mesh](https://npm.io/package/@mediapipe/face_mesh.md) ^0.4.1633559619

## Recent versions

- 0.0.10-alpha.13 (latest) — 2023-09-12
- 0.0.10-alpha.12 — 2023-09-04
- 0.0.10-alpha.11 — 2023-08-24
- 0.0.10-alpha.10 — 2023-08-24
- 0.0.10-alpha.9 — 2023-08-24
- 0.0.10-alpha.8 — 2023-08-24
- 0.0.10-alpha.7 — 2023-08-24
- 0.0.10-alpha.6 — 2023-08-24
- 0.0.10-alpha.5 — 2023-08-24
- 0.0.10-alpha.4 — 2023-08-24
- 0.0.10-alpha.3 — 2023-08-22
- 0.0.10-alpha.2 — 2023-08-22
- 0.0.10-alpha.1 — 2023-08-22
- 0.0.10-alpha.0 — 2023-08-02
- 0.0.10-alpha — 2023-08-02
- … 1 more at https://npm.io/package/@ekycsolutions/ml-js-sdk/versions

## README

# Ekyc SDK

A web sdk.

## 1. Module

```js
filename: "ekyc-web-sdk.js",
library: "EkycWebSdk",
```

## 2. How-to-use
For further detail, please find `example.***.html` files.

```html
<!-- html -->
<script src="ekyc-web-sdk.js"></script>
<!-- -- or -- -->
<script src="https://package.registry.gitlab.com/ekyc/ekyc-web-sdk.js"></script>

<script>
  const detector = new EkycWebSdk.FaceDetection();
  detector.build();
  const result = await detector.send(imageData);
</script>
```

```js
// ES2015
import { faceDetection, cardDetection } from "ekyc-web-sdk";
import EkycWebSdk from "ekyc-web-sdk";
// -- or --
// js module
const faceDetection = require("ekyc-web-sdk");
```



## 3. How-to-manually-test-module

I create an index.html file in the dist folder. Modifying it to your like. Later on, I will set up the test which make it easier for automation the coding process.

## quick start

### with svelte
1. create a project `pnpm create vite`, select `svelte` then `typescript`
2. install the sdk `pnpm add @ekycsolutions/ml-js-sdk`
  1. if you want to use it locally, clone the repo
  2. install and configure `verdaccio`
    - run `verdaccio` to let it generate config dir and file for the first time if you havent and then close it
    - edit the `config.yaml` file which located in `/home/[user]/.config/verdaccio/` if on linux
    - update the follow block to allow publish to local registry without authentication
      ```
      packages:
      '@*/*':
        # scoped packages
        access: $all
        publish: $anonymous
        unpublish: $anonymous
        proxy: npmjs

      '**':
        # allow all users (including non-authenticated users) to read and
        # publish all packages
        #
        # you can specify usernames/groupnames (depending on your auth plugin)
        # and three keywords: "$all", "$anonymous", "$authenticated"
        access: $all

        # allow all known users to publish/publish packages
        # (anyone can register by default, remember?)
        publish: $anonymous
        unpublish: $anonymous
      ```
    - then run `verdaccio` again in another terminal
    - then run `npm install`
    - then run `npm run build`
    - then run `npm publish --registry http://localhost:4873`
    - then install the dep with `pnpm add @ekycsolutions/ml-js-sdk --registry http://localhost:4873`
3. update `src/App.svelte` to include a container div for kyc
  ```svelte
  <script lang='ts'>
  import { onMount } from 'svelte';
  import {
    Kyc,
    DocumentScannerDefaultOverlay,
    LivenessDetectionDefaultOverlay,
  } from '@ekycsolutions/ml-js-sdk';

  onMount(() => {
    const kyc = new Kyc({
      containerId: 'kyc',
      isEnableDebug: true,

      videoWidth: 640 * 1.5,
      videoHeight: 480 * 1.5,

      // true to use manual kyc flow
      // false to use express ekyc flow
      isLivenessDetectFaceSideOnly: false,

      // true to use liveness config from node server
      isUseLivenessChecksFromServer: false,

      // liveness config from local
      // if `isUseLivenessChecksFromServer` is true
      // will override this
      livenessChecks: ['left', 'right', 'blinking'],

      // document scanner overlay, by default we provide one
      // but you could also bring your own ui
      DocumentScannerOverlayClass: DocumentScannerDefaultOverlay,

      // liveness detection overlay, by default we provide one
      // but you could also bring your own ui
      LivenessDetectionOverlayClass: LivenessDetectionDefaultOverlay,
      documentScannerOverlayOpts: {
        lang: 'en',
        wrapperId: 'wrapper',
        overlayId: 'overlay',
      },
      livenessDetectionOverlayOpts: {
        lang: 'en',
        wrapperId: 'wrapper',
        overlayId: 'overlay',
      },

      // access to all events within each flow
      onChange: (e) => {
        console.log('==== manual kyc on changed ====');
        console.log(e);
      },

      // after all kyc flow completed
      // there is callback that contains all data
      // and another callback within to call ekyc api
      // the types of the argument
      // {
      //  event: Kyc.CallbackEvent;
      //  data: {
      //    livenessChecks: { checks: string; canvasImageData: Canvas.ImageData; }[];
      //    faceImagesData: { frontSize: Canvas.ImageData; leftSide: Canvas.ImageData; rightSide: Canvas.ImageData; };
      //    documentScanned: { [DocumentSide.Main = 0]: Canvas.ImageData; [DocumentSide.Secondary = 1]: Canvas.ImageData };
      //    runKyc: Function();
      //   };
      // }
      onKYCCompleted: (e) => {
        console.log('KYC Done');
      },
    });

    kyc.init();
  });
  </script>

  <main>
    <div id="kyc" />
  </main>
  ```
4. run `pnpm dev` to test the ekyc with our default overlay as demo

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