Skip to content

Commit

Permalink
clean and fix sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
remicolin committed Aug 27, 2024
1 parent ce0427a commit af4fe04
Show file tree
Hide file tree
Showing 29 changed files with 200 additions and 4,021 deletions.
2 changes: 0 additions & 2 deletions sdk/OpenPassportQRCode.ts

This file was deleted.

79 changes: 0 additions & 79 deletions sdk/OpenPassportRegister.ts

This file was deleted.

48 changes: 0 additions & 48 deletions sdk/OpenPassportWeb3Verifier.ts

This file was deleted.

77 changes: 24 additions & 53 deletions sdk/README.md
Original file line number Diff line number Diff line change
@@ -1,38 +1,25 @@
# SDK

## Installation
# Installation

```bash
yarn add @openpassport/sdk
```

## Development

```bash
yarn install-sdk
```
## Tests

```bash
yarn test
```

## How to use
# How to use

### Web2 applications
## 1 Step flow

To use the `OpenPassportWeb2Verifier` in Web2 applications, import and initialize it as follows:
To use the `OpenPassport1StepVerifier`, import and initialize it as follows:


```typescript
import { OpenPassportWeb2Verifier } from '@openpassport/sdk';
const verifier = new OpenPassportWeb2Verifier({
import { OpenPassport1StepVerifier } from '@openpassport/sdk';
const verifier = new OpenPassport1StepVerifier({
scope: "yourScope",
requirements: [["older_than", "18"], ["nationality", "France"]]
});
```

#### parameters for `OpenPassportWeb2Verifier`
### parameters for `OpenPassport1StepVerifier`

| Parameter | Optional | Description |
|---------------|----------|-------------|
Expand All @@ -48,43 +35,27 @@ The function fired from the OpenPassport app will send a `OpenPassportWeb2Inputs

const result = await verifier.verify(openPassportWeb2Inputs); // OpenPassportWeb2Inputs : OpenPassportWeb2Inputs
```
## 2 Steps flow
### 🚧 Work in progress 🚧

### Web3 application
For Web3 applications, use the `OpenPassportWeb3Verifier` as follows:
# Development

```typescript
import { OpenPassportWeb3Verifier } from '@openpassport/sdk';
const verifier = new OpenPassportWeb3Verifier({
scope: "yourScope",
rpcUrl: "https://custom.rpc.url"
});
```bash
yarn install-sdk
```
#### Parameters for `OpenPassportWeb3Verifier`

| Parameter | Optional | Description |
|---------------|----------|-------------|
| `scope` | No | The scope of the verification. |
| `attestationId` | Yes | The ID of the attestation, defaults to `PASSPORT_ATTESTATION_ID`. |
| `requirements` | Yes | An array of requirements, each an array with an attribute and its expected value. |
| `rpcUrl` | Yes | The RPC URL to connect to the blockchain, defaults to `DEFAULT_RPC_URL`. |

#### Verify the user owns a sbt which satisfies the requirements:
## Tests
To run the tests, you need to download the circuits and the zkey files from the AWS s3 bucket.

```typescript
const result = await verifier.verify(address, tokenId);
```bash
yarn download-circuits
```

### Handle the report

Each verification will returns a OpenPassportVerifierReport object which contains all the informations about the verification of each requirement.

If a requirement is not satisfied, the corresponding field will be set to `true`.
The `valid` field will be `false` if there is at least one requirement that is not satisfied.

`nullifier` and `user_identifier` are also accessible as report fields.
Finally compile the circuits with the following command:
```bash
yarn compile-circuits
```
Then run the tests with the following command:
```bash
yarn test
```

```typescript
const report = await verifier.verify(publicSignals, proof);
const nullifier = report.nullifier;
const userIdentifier = report.user_identifier;
```
Loading

0 comments on commit af4fe04

Please sign in to comment.