Skip to content

Commit

Permalink
feat: add idvc verifier (#2)
Browse files Browse the repository at this point in the history
* feat: ci/cd (#3)

* feat: ci/cd (#4)

* fix: failing snapshot tests

* chore: renaming tests, ensure they all pass

* feat: commit lock

* feat: add relevant idvc verifiers

* chore: fix lint errors

* feat: regenerate fixtures

* feat: update readme

* feat: add additional verify branch for tt specific docs in did-signed-doc-status

* feat: add additional error document for invalid idvc verification

* feat: remove useless docs | add additional tests for missing idvc

* feat: update readme

* feat: update dependencies to point to alpha tt-oa
  • Loading branch information
cavacado authored Nov 14, 2023
1 parent fd3077e commit 2257484
Show file tree
Hide file tree
Showing 59 changed files with 20,635 additions and 19,800 deletions.
53 changes: 24 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
[![CircleCI](https://circleci.com/gh/Open-Attestation/oa-verify.svg?style=svg)](https://circleci.com/gh/Open-Attestation/oa-verify)
![Release](https://github.com/TradeTrust/oa-verify/actions/workflows/release.yml/badge.svg)

# Open Attestation (Verify)

The [Open Attestation (Verify)](https://github.com/Open-Attestation/oa-verify) repository is the codebase for the npm module that allows you to verify [wrapped document](https://www.openattestation.com/docs/developer-section/libraries/remote-files/open-attestation#wrapping-documents) programmatically. This is useful if you are building your own API or web components. Some common use cases where you will need this module:
The [Open Attestation (Verify)](https://github.com/TradeTrust/oa-verify) repository is the codebase for the npm module that allows you to verify a wrapped document programmatically. This is useful if you are building your own API or web components. Some common use cases where you will need this module:

- [Verifying a document](#verifying-a-document)
- [Building custom verifier](#custom-verification)
- [Building custom validation](#custom-validation)

This module does not provide the following functionality:

- Programmatic wrapping of OA documents (refer to [Open Attestation](https://www.openattestation.com/docs/developer-section/libraries/remote-files/open-attestation#wrapping-documents))
- Encryption or decryption of OA documents (refer to [Open Attestation (Encryption)](https://www.openattestation.com/docs/developer-section/libraries/remote-files/open-attestation-encryption))
- Programmatic wrapping of OA documents
- Encryption or decryption of OA documents
- Programmatic issuance/revocation of document on the Ethereum blockchain

## Installation

```bash
npm i @govtechsg/oa-verify
npm i @tradetrust/oa-verify
```

---
Expand All @@ -32,7 +32,7 @@ A verification happens on a wrapped document, and it consists of answering to so
- Is the issuance state of the document valid ?
- Is the document issuer identity valid ? (see [identity proof](https://www.openattestation.com/docs/docs-section/how-does-it-work/issuance-identity))

A wrapped document (shown below) created using [Open Attestation](https://www.openattestation.com/docs/developer-section/libraries/remote-files/open-attestation) would be required.
A wrapped document (shown below) created using Open Attestation would be required.

> **NOTE:** The document shown below is valid and has been issued on the goerli network
Expand Down Expand Up @@ -83,7 +83,7 @@ To perform verification check on the document:

```ts
// index.ts
import { isValid, verify } from "@govtechsg/oa-verify";
import { isValid, verify } from "@tradetrust/oa-verify";
import * as document from "./document.json";

const fragments = await verify(document as any);
Expand All @@ -105,7 +105,7 @@ You can build your own verify method or your own verifiers:

```ts
// creating your own verify using default exported verifiers
import { verificationBuilder, openAttestationVerifiers } from "@govtechsg/oa-verify";
import { verificationBuilder, openAttestationVerifiers } from "@tradetrust/oa-verify";

const verify1 = verificationBuilder(openAttestationVerifiers, { network: "goerli" }); // this verify is equivalent to the one exported by the library
// this verify is equivalent to the one exported by the library
Expand All @@ -116,7 +116,7 @@ const verify2 = verificationBuilder([openAttestationVerifiers[0], openAttestatio

```ts
// creating your own verify using custom verifier
import { verificationBuilder, openAttestationVerifiers, Verifier } from "@govtechsg/oa-verify";
import { verificationBuilder, openAttestationVerifiers, Verifier } from "@tradetrust/oa-verify";
const customVerifier: Verifier<any> = {
skip: () => {
// return a SkippedVerificationFragment if the verifier should be skipped or throw an error if it should always run
Expand Down Expand Up @@ -150,7 +150,7 @@ The function also allows a list of types to check for as a second parameter.

```ts
// index.ts
import { isValid, openAttestationVerifiers, verificationBuilder } from "@govtechsg/oa-verify";
import { isValid, openAttestationVerifiers, verificationBuilder } from "@tradetrust/oa-verify";
import * as document from "./document.json";

const verify = verificationBuilder(openAttestationVerifiers, {
Expand All @@ -176,7 +176,7 @@ The `verify` function provides an option to listen to individual verification me

```ts
// index.ts
import { isValid, openAttestationVerifiers, verificationBuilder } from "@govtechsg/oa-verify";
import { isValid, openAttestationVerifiers, verificationBuilder } from "@tradetrust/oa-verify";
import * as document from "./document.json";

const verify = verificationBuilder(openAttestationVerifiers, {
Expand Down Expand Up @@ -217,8 +217,8 @@ This is where `skip` and `test` methods come into play. We will use the `test` m

```ts
// index.ts
import { verificationBuilder, openAttestationVerifiers, Verifier, isValid } from "@govtechsg/oa-verify";
import { getData } from "@govtechsg/open-attestation";
import { verificationBuilder, openAttestationVerifiers, Verifier, isValid } from "@tradetrust/oa-verify";
import { getData } from "@tradetrust/open-attestation";
import * as document from "./document.json";

const customVerifier: Verifier<any> = {
Expand Down Expand Up @@ -246,8 +246,8 @@ Once we have decided `when` the verification method run, it's time to write the

```ts
// index.ts
import { verificationBuilder, openAttestationVerifiers, Verifier, isValid } from "@govtechsg/oa-verify";
import { getData } from "@govtechsg/open-attestation";
import { verificationBuilder, openAttestationVerifiers, Verifier, isValid } from "@tradetrust/oa-verify";
import { getData } from "@tradetrust/open-attestation";
import * as document from "./document.json";

const customVerifier: Verifier<any> = {
Expand Down Expand Up @@ -290,8 +290,8 @@ Extending from what have been mentioned in [Custom Verification](#custom-verific

```ts
// index.ts
import { verificationBuilder, openAttestationVerifiers, Verifier, isValid } from "@govtechsg/oa-verify";
import { getData } from "@govtechsg/open-attestation";
import { verificationBuilder, openAttestationVerifiers, Verifier, isValid } from "@tradetrust/oa-verify";
import { getData } from "@tradetrust/open-attestation";
import document from "./document.json";

// our custom verifier will be valid only if the document version is not https://schema.openattestation.com/2.0/schema.json
Expand Down Expand Up @@ -403,7 +403,7 @@ const verify = verificationBuilder(openAttestationVerifiers, { network: "goerli"
`oa-verify` exposes a method, called `createResolver` that allows you to easily create custom resolvers, to resolve DIDs:

```ts
import { createResolver, verificationBuilder, openAttestationVerifiers } from "@govtechsg/oa-verify";
import { createResolver, verificationBuilder, openAttestationVerifiers } from "@tradetrust/oa-verify";

const resolver = createResolver({
networks: [{ name: "my-network", rpcUrl: "https://my-private-chain/besu", registry: "0xaE5a9b9..." }],
Expand Down Expand Up @@ -435,7 +435,7 @@ It requires a set of options:
The most basic way to use:

```ts
import { utils } from "@govtechsg/oa-verify";
import { utils } from "@tradetrust/oa-verify";
const provider = utils.generateProvider();
// This will generate an infura provider using the default values.
```
Expand All @@ -450,15 +450,15 @@ PROVIDER_ENDPOINT_URL = "http://jsonrpc.com";
PROVIDER_API_KEY = "ajdh1j23";

// provider file
import { utils } from "@govtechsg/oa-verify";
import { utils } from "@tradetrust/oa-verify";
const provider = utils.generateProvider();
// This will use the environment variables declared in the files automatically.
```

Alternate way 2 (passing values in as parameters):

```ts
import { utils } from "@govtechsg/oa-verify";
import { utils } from "@tradetrust/oa-verify";
const providerOptions = {
network: "goerli",
providerType: "infura",
Expand Down Expand Up @@ -491,7 +491,7 @@ Let's see how to use it
### Example

```ts
import { utils } from "@govtechsg/oa-verify";
import { utils } from "@tradetrust/oa-verify";
const fragments = verify(documentValidWithCertificateStore, { network: "goerli" });
// return the correct fragment, correctly typed
const fragment = utils.getOpenAttestationEthereumTokenRegistryStatusFragment(fragments);
Expand Down Expand Up @@ -537,6 +537,7 @@ Note that in the example above, using `utils.isValidFragment` might be unnecessa
| OpenAttestationDidIdentityProof | ISSUER_IDENTITY | Verify identity of DID (similar to OpenAttestationDidSignedDocumentStatus) | No |
| OpenAttestationDnsDidIdentityProof | ISSUER_IDENTITY | Verify identify of DID certificate using DNS-TXT | Yes |
| OpenAttestationDnsTxtIdentityProof | ISSUER_IDENTITY | Verify identify of document store certificate using DNS-TXT | Yes |
| TradeTrustIDVCIdentityProof | ISSUER_IDENTITY | Verify identify of document store certificate using IDVC | Yes |

---

Expand All @@ -548,17 +549,11 @@ To run tests
npm run test
```

To generate test documents (for v3), you may use the script at `scripts/generate.v3.ts` and run the command

```
npm run generate:v3
```

## License

[GPL-3.0](https://www.gnu.org/licenses/gpl-3.0.html)

## Additional information

- For Verification SDK implementation follow our [Verifier ADR](https://github.com/Open-Attestation/adr/blob/master/verifier.md).
- Found a bug ? Having a question ? Want to share an idea ? Reach us out on the [Github repository](https://github.com/Open-Attestation/oa-verify).`
- Found a bug ? Having a question ? Want to share an idea ? Reach us out on the [Github repository](https://github.com/TradeTrust/oa-verify).`
Loading

0 comments on commit 2257484

Please sign in to comment.