Skip to main content

JS SDK Overview

Based on the Iden3 core protocol libraries, the Polygon ID JS SDK is used for interacting with REST APIs and developing browser-based applications.

The Polygon ID JS SDK allows developers to create applications like mobile or web wallets, browser extensions, and issuer nodes. Using this SDK, developers can start creating and issuing verifiable credentials, and generating zero knowledge proofs based on our Iden3 protocol. Individuals and organizations can use this SDK for their existing applications.

note

With JS SDK, you can build custom applications/modules by providing your own implementation of our core interfaces. The functionalities that we provide in these tutorials can be extended as per your requirements. For example, JS SDK does not provide a codebase for database storage but you can implement that by extending the SDK's functionalities.

Why JS SDK?

The Polygon ID JS SDK has been developed to provide the following functionalities for a user's browser-based wallet:

  • Create and manage Identity wallet
  • Issue and manage credentials
  • Generate zero-knowledge proofs after credential issuance
  • Publish the updated state of the Issuer once a credential is added to the claims Merkle tree
  • Handle authorization requests

Components of JS SDK

The following components form the inherent part of the JS SDK. In the upcoming tutorials, we shall read more about the implementation of these components in JS SDK. To know what each of these components stands for, go through their links:

Prerequisites

  • Node.js must be installed on your system. Version 16.14 or above is required for Polygon ID JS SDK.
note

While installing Node.js, make sure that you select all the checkboxes related to the dependencies.

  • A browser where you can install and manage your browser wallet.

Dependencies

You can install project dependencies using either one of the following ways:

  • Using npm:
npm install @0xpolygonid/js-sdk
  • For browser-based applications, you can use the following script tag, adding import to your index.html file after npm run build:
<script src="./dist/umd/index.js"></script>
<script>
const {
LocalStoragePrivateKeyStore,
IdentityStorage,
MerkleTreeLocalStorage,
CredentialStorage,
W3CCredential,
BrowserDataSource,
BjjProvider,
KmsKeyType,
IdentityWallet,
CredentialWallet,
KMS,
core,
CredentialStatusType,
} = PolygonIdSdk;
</script>

Core Libraries

JS SDK is a fully-functional wrapper on top of our Iden3 core libraries. The following set of core Iden3 libraries has been used to implement Polygon ID JS SDK:

  • Iden3 JS Crypto: Implementation of the Elliptic Curve for Baby Jubjub Key, Poseidon hash and other cryptographic elements.
  • JS Iden3 Core: JavaScript implementation of the Iden3 core functionalities including Identity creation.
  • JS JSON-LD Merklization: A library that merkelizes JSON-LD documents in JavaScript. Merklization is a process that creates a Merkle tree of a JSON-LD document so that it can be verified for its data integrity and authenticity. It is a library that lets you work with Verifiable Credentials. A JSON-LD is a schema document that represents data fields related to a Verifiable Credential in a pre-determined format.
  • JS JWZ: JavaScript implementation of JSON Web Zero Knowledge and lets you create JWZ tokens.
  • JS Merkle Tree JavaScript implementation for creating a Sparse Merkle Tree (SMT). It carries code implementation for the browser, local storage, and memory.
info

Follow the links below to learn more about W3C standards for DID (Decentralised Identifier) and Verifiable Credentials:

What Can Be Built Upon JS SDK?

On the Polygon ID JS SDK, you can build the following functionalities:

  • An Issuer on a Merkle Tree
  • A Verifier that can verify zero-knowledge proofs generated by a user's identity wallet
  • An Identity Wallet based on the Iden3 core protocol
  • The JS SDK also provides a revocation feature for credentials and proof generation