npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@openpassport/qrcode

v0.0.14

Published

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

Downloads

1,071

Readme

Installation

yarn add @openpassport/sdk

Generate a QR code

Create an AppType type object:

import { AppType } from '@openpassport/sdk';
const appName = '🤠 Cowboy App';
const scope = 'cowboyApp';
const userID = 'user1234';
const sessionID = uuidv4();

const cowboyApp: AppType = {
  name: appName,
  scope,
  userId: userID,
  sessionId: sessionID,
  circuit: 'prove',
  arguments: {
    disclosureOptions: { older_than: '18', nationality: 'France' },
  },
};

| Parameter | Optional | Description | | ----------- | -------- | ------------------------------------------------------------- | | scope | M | The scope of your application, is unique for each application | | name | M | Name of the application | | userId | M | User ID | | sessionId | M | Session ID | | circuit | M | Circuit to use, only prove is available for now | | arguments | O | Optional disclosure options, based on passport attributes |

Display the QR code

Use the appType object defined above to generate a QR code. The generated QR code is an HTML element that you can display in your app.

import { QRCodeGenerator } from '@openpassport/sdk';

// [...]  define cowboyApp as described above

const qrCode: HTMLElement = await QRCodeGenerator.generateQRCode(cowboyApp);

Verify the proof

1 Step flow

To use the OpenPassportVerifier, import and initialize it as follows:

import { OpenPassportVerifier } from '@openpassport/sdk';
const verifier = new OpenPassportVerifier({
  scope: 'cowboyApp',
  requirements: [
    ['older_than', '18'],
    ['nationality', 'France'],
  ],
});

Parameters for OpenPassportVerifier

| Parameter | Optional | Description | | --------------- | -------- | --------------------------------------------------------------------------------- | | scope | M | The scope of your application, is unique for each application. | | attestationId | O | The ID of the attestation, defaults to PASSPORT_ATTESTATION_ID. | | requirements | O | An array of requirements, each an array with an attribute and its expected value. | | rpcUrl | O | The RPC URL to connect to the blockchain, defaults to DEFAULT_RPC_URL. | | dev_mode | O | Allow users with generated passport to pass the verification. |

Verify the proof

The function fired from the OpenPassport app will send an OpenPassportVerifierInputs object.

const result: OpenPassportVerifierReport = await verifier.verify(openPassportVerifierInputs);

From the result object, you can inspect the validity of any submitted attribute. To check the overall validity of the proof, you can inspect the valid attribute.

require(result.valid);

Nullifier and user identifier are accessible from the result object.

const nullifier: number = result.nullifier;
const user_identifier: number = result.user_identifier;

2 Steps flow

🚧 Work in progress 🚧

Development

Install the dependencies

yarn install-sdk

Tests

To run the tests, you need to download the circuits and the zkey files from the AWS s3 bucket. This script will also compile the circuits to generate the wasm files. Make sure that the circuits in the circuits folder are up to date with the AWS zkey files.

yarn download-circuits

Then run the tests with the following command:

yarn test