# verify4js

> PDF файлын Notly системээр блокчэйн дээр баталгаажсан эсэхийг шалгах сан.

Latest version **2.1.2** (published 2024-05-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install verify4js
pnpm add verify4js
yarn add verify4js
bun add verify4js
```

## Health

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

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

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.1.2 |
| Published | 2024-05-07 |
| First published | 2023-04-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 7 |
| Unpacked size | 106.7 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | suugii |

## Links

- npm: https://www.npmjs.com/package/verify4js
- Repository: https://github.com/teo-mn/verify4js
- Homepage: https://github.com/teo-mn/verify4js#readme
- Issues: https://github.com/teo-mn/verify4js/issues
- npm.io page: https://npm.io/package/verify4js

## Dependencies (7)

- [ws](https://npm.io/package/ws.md) ^8.13.0
- [utf8](https://npm.io/package/utf8.md) ^3.0.0
- [web3](https://npm.io/package/web3.md) ^4.8.0
- [crypto](https://npm.io/package/crypto.md) ^1.0.1
- [pdfjs-dist](https://npm.io/package/pdfjs-dist.md) ^3.7.107
- [crypto-browserify](https://npm.io/package/crypto-browserify.md) ^3.12.0
- [fast-text-encoding](https://npm.io/package/fast-text-encoding.md) ^1.0.6

## Recent versions

- 2.1.2 (latest) — 2024-05-07
- 2.1.1 — 2023-10-12
- 2.1.0 — 2023-10-12
- 2.0.0 — 2023-08-04
- 1.0.5 — 2023-06-28
- 1.0.4 — 2023-06-26
- 1.0.3 — 2023-06-26
- 1.0.1 — 2023-04-11
- 1.0.8-test — 2023-04-11
- 1.0.7-test — 2023-04-11
- 1.0.6-test — 2023-04-11
- 1.0.5-test — 2023-04-11
- 1.0.4-test — 2023-04-11
- 1.0.3-test — 2023-04-11
- 1.0.12-test — 2023-04-11
- … 3 more at https://npm.io/package/verify4js/versions

## README

# Verify4js
PDF файлын Notly системээр блокчэйн дээр баталгаажсан эсэхийг шалгах сан.

### Суулгах заавар

npm-ээс татаж авч суулгах эсвэл шууд эх кодыг хуулж авч ашиглаж болно. <br/>
```shell
npm install verify4js
```

### Ашиглах заавар
```js
import * as Verify from "verify4js";

Verify.verify(pdfArrayBuffer, nodeUrl)
.then(res => { // console.log(res); })
.catch(err => { console.error(err.message); })
```
#### Фронтэнд Жишээ:
```js
<input type="file" name="file" onChange={handleFileChange} />

function handleFileChange(event) {
const selectedFile = event.target.files[0];
const fileType = ["application/pdf"];

if (selectedFile) {
  if (fileType.includes(selectedFile.type)) {
    const reader = new FileReader(); 
    reader.onload = (e) => { 
      const view = new Int8Array(e.target.result); 
      Verify.verify(view)
        .then((res) => {
          console.log(res);
        })
        .catch((err) => {
          console.error("test", err.message); 
        });
      setFile(e.target.result);
    };
    reader.readAsArrayBuffer(selectedFile);
  } else {
    setFile(null);
  }
}
}
```
#### Backend жишээ:

```js
const { verify } = require('verify4js');
verify(pdfArrayBuffer)
.then(res => { // console.log(res); })
.catch(err => { console.error(err.message); })
```

### Параметрүүд

- **pdfArrayBuffer** нь pdf файлаа уншиж аваад ArrayBuffer төрөлд хөрвүүлсэн утга
- **nodeUrl** нь блокчэйний node-ий хаяг. Утга зааж өгөхгүй бол TEO-ийн public node рүү заана

### Гаралт

```js
export interface VerifyResultInterface { 
  state: 'REVOKED' | 'EXPIRED' | 'ISSUED' | 'APPROVE_PENDING' | 'INVALID',
  metadata: MetaDataInterface, 
  cert: {}, 
  issuer: {isActive?: boolean}, 
  isTestnet: boolean, 
  isUniversity?: boolean 
}
```

##### state нь
- ISSUED бол баталгаажсан файл. 
- REVOKED бол хүчингүй болгосон файл
- EXPIRED бол хугацаа нь дууссан файл,
- APPROVE_PENDING бол их сургуулийн диплом БЕГ баталгаажуулахыг хүлээж буй
- INVALID бол баталгаажаагүй файл.
##### metadata нь 
файлд нэмэлтээр бичсэн утгууд.
##### cert нь 
блокчэйн дээр бичигдсэн мэдээлэл.
##### issuer нь 
баталгаажуулагчийн мэдээлэл.
##### isTestnet нь 
тест сүлжээнд баталжуулсан бол true байна.
##### isUniversity нь 
их сургуулийн диплом үед true байна.

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