JavaScript SDK Reference
Overview
The prove
function from the @plutoxyz/web-proofs library provides a vanilla JavaScript implementation for integrating Pluto’s zero-knowledge proof generation (Web Proofs) into your application. It handles device detection, platform compatibility, and various user setups automatically.
There are two primary methods for generating Web Proofs using Pluto:
iOS App
: Users can generate proofs using the Pluto Attest app available on iOS devices.-
Chrome Extension
: Users on desktop can use the Pluto Chrome extension to generate proofs (Coming soon).
The prove function intelligently determines the best method to request a proof based on the user’s device, platform, and installed applications/extensions.
Key functionality includes:
- Detecting if the user is on a mobile device or desktop
- Checking if the Pluto Chrome extension is installed
- Listening for proof results from both the iOS app and Chrome extension
- Providing fallback options if a preferred method isn’t available
Key Features
Feature | Description |
---|---|
Proof Generation Handling | Manages the proof generation process, including loading states, errors, and displaying the proof result. |
Device and Platform Detection | Automatically detects the user’s device type (mobile or desktop) and operating system (iOS or Android). |
Extension Installation Checks | Checks if the Pluto Chrome extension is installed and prompts the user accordingly. |
Preferred Device Mode | Allows developers to specify a preferred device mode for proof generation (ios or chrome_extension ), which can influence the method used. |
Import
script.js
Usage
script.js
Parameters
The URL to the manifest JSON file defining the proof configuration.
ID of the DOM element where the prover UI will be rendered.
Preferred method for generating proofs. Default is 'ios'.
The mode of the prover. Typically set to 'Origo'. Default is 'Origo'.
Determines whether the extension is enabled. Default is 'false'.
Configuration options for UI visibility and styling:
Show/hide the proof result display. Default: true
Show/hide error messages. Default: true
Show/hide loading indicators. Default: true
Size of the QR code in pixels. Default: 192
Custom CSS styles for UI elements:
Custom styles for the prove button
Custom styles for the loading spinner
Custom styles for error messages
Custom styles for the proof result display
Custom styles for the loading spinner container
Event handlers for the proving process:
Called when loading state changes
Called when an error occurs
Called when proof generation succeeds
Called before redirecting to mobile app
Returns a promise that resolves with either a proof string or an error message. Times out after 5 minutes.