0.9.2 • Published 1 year ago

@worldcoin/id v0.9.2

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Warning This README is outdated. Update coming soon.

World ID Javascript Integration

The Javascript integration is the most flexible way to integrate World ID on the frontend. The package currently supports web applications and requires only a few lines of code.

🚀 Getting started

Getting started with the Javascript package is really easy. Just follow the steps below.

  1. Install/include the package in your app (recommended) or add the code snippet from the UNPKG CDN.
npm install @worldcoin/id
# or
yarn add @worldcoin/id

To add the script directly in your HTML,

<script type="text/javascript" src="//unpkg.com/@worldcoin/id/dist/world-id.js"></script>
  1. Add a <div> in your HTML where you'd like to include World ID.
<div id="world-id-container"></div>
  1. Initialize World ID (please refer to the docs for further customization details).
worldID.init('world-id-container', {
  action_id: 'wid_staging_PN8fFL7V2N', // obtain this from developer.worldcoin.org
  signal: 'my_signal',
  enableTelemetry: true, // optional, but recommended
})
  1. On document load, enable the World ID flow. When you call .enable() you will receive a promise to which you can subscribe to receive success or failure results. On failure, we recommend you call .enable() again to let the user try again (unless the failure code is a terminal one, e.g. already_signed).

With async/await:

document.addEventListener('DOMContentLoaded', async function () {
  try {
    const result = await worldID.enable()
    console.log('World ID verified successfully:', result)
  } catch (failure) {
    console.warn('World ID verification failed:', failure)
    // Re-activate here so your end user can try again
  }
})

With promises:

document.addEventListener('DOMContentLoaded', function () {
  worldID
    .enable()
    .then((result) => {
      console.log('World ID verified successfully:', result)
    })
    .catch((failure) => {
      console.warn('World ID verification failed:', failure)
      // Re-activate here so your end user can try again
    })
})

About World ID

World ID is a protocol that lets you prove a human is doing an action only once without revealing any personal data. Stop bots, stop abuse.

World ID uses a device called the Orb which takes a picture of a person's iris to verify they are a unique and alive human. The protocol uses Zero-knowledge proofs so no traceable information is ever public.

World ID is meant for on-chain web3 apps, traditional cloud applications, and even IRL verifications.

Getting started with World ID

Regardless of how you landed here, the easiest way to get started with World ID is through the the Dev Portal.

World ID Demos

Want to see World ID in action? We have a bunch of Examples.

📄 Documentation

We have comprehensive docs for World ID at https://id.worldcoin.org/docs.

🗣 Feedback

World ID is in Beta, help us improve! Please share feedback on your experience. You can find us on Discord, look for the #world-id channel. You can also open an issue or a PR directly on this repo.

🧑‍💻 Development & testing

To develop locally and contribute to this package, you can simply follow these instructions after clonning the repo.

  • Install dependencies
    npm install
  • Run tests
    npm run test
  • Run local test project
    npm run dev
  • Open browser at http://localhost:3000
  • To build the production bundle you can simply run.
    npm run build