@verifiedonchain-protocol/sdk 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,152 @@
1
+ # VerifiedOnchain SDK (`vo-sdk`)
2
+
3
+ A lightweight, framework-agnostic React SDK for integrating the **Proof of Humanity** face verification, social connections, and wallet abstractions into your dApp.
4
+
5
+ This SDK captures biometric telemetry, performs local sequential liveness detection (blinking, head movement, emotions), and generates a zero-knowledge SimHash of the user's face. It then securely relays this hash to the VerifiedOnchain backend for Arcium MPC comparison and Solana gas-abstracted submission.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ npm install vo-sdk
11
+ ```
12
+
13
+ *(Note: If you are using React 18, you might need to install peer dependencies like `framer-motion` for animations, `@solana/wallet-adapter-react` for Solana support, and `wagmi` + `viem` for EVM support if you haven't already).*
14
+
15
+ ## Quick Start & Setup
16
+
17
+ The SDK requires two things to function correctly:
18
+ 1. **Tailwind CSS**: The UI components are built with Tailwind.
19
+ 2. **Machine Learning Models**: The SDK runs facial verification entirely on the client side (in-browser) for privacy. You must host the underlying AI models in your `public` directory.
20
+
21
+ ### 1. Hosting the ML Models
22
+
23
+ Download the standard Human.js models (or copy them from the SDK's `node_modules/vo-sdk/models` if available) and place them in your web root under `/models`. The required models typically include `blazeface.json`, `faceres.json`, etc.
24
+
25
+ ### 2. Basic Usage
26
+
27
+ The easiest way to integrate the SDK is using the `VerifiedOnchainFlow` component, which provides a complete turn-key UI for wallet connection, social linking, and biometric scanning.
28
+
29
+ ```tsx
30
+ import { VerifiedOnchainFlow } from 'vo-sdk';
31
+ import 'vo-sdk/dist/index.css'; // Optional if you are compiling Tailwind yourself
32
+
33
+ export default function VerificationPage() {
34
+ const handleSuccess = (data) => {
35
+ console.log("User successfully verified!", data);
36
+ // data.walletAddress
37
+ // data.chain
38
+ // data.humanityCode (The on-chain unique identifier!)
39
+ };
40
+
41
+ return (
42
+ <div className="flex justify-center items-center h-screen bg-black">
43
+ <VerifiedOnchainFlow
44
+ appId="YOUR_APP_ID" // Required for production!
45
+ requiredWallets={['phantom', 'metamask']}
46
+ requiredSocials={['x', 'farcaster']}
47
+ requireBiometrics={true}
48
+ onIdentityVerified={handleSuccess}
49
+ environment="mainnet"
50
+ relayerUrl="https://api.verifiedonchain.com"
51
+ />
52
+ </div>
53
+ );
54
+ }
55
+ ```
56
+
57
+ ## Component API Reference
58
+
59
+ VerifiedOnchain SDK provides two ways to build your integration:
60
+ 1. **The Turn-Key Flow**: A complete, pre-built multi-step wizard (`VerifiedOnchainFlow`).
61
+ 2. **The Headless / Modular Approach**: Highly customizable, individual components you can compose however you want.
62
+
63
+ ### 1. The Turn-Key Approach
64
+ The `VerifiedOnchainFlow` component is the easiest way to get started. It automatically handles the step-by-step UI for wallet connection, social linking, and biometric scanning.
65
+
66
+ **Props:**
67
+ * `appId`: Your registered Application ID (e.g. `'YOUR_APP_ID'`).
68
+ * `requiredWallets`: Array of wallet types to display (e.g. `['phantom', 'backpack', 'metamask', 'rainbow']`).
69
+ * `requiredSocials`: Array of required social platforms (e.g. `['farcaster', 'lens', 'x']`).
70
+ * `requireBiometrics`: Boolean (default: `true`). If false, skips the facial scan.
71
+ * `onIdentityVerified`: Callback function triggered when the flow successfully completes and the relayer returns the `humanityCode`.
72
+ * `environment`: `'mainnet'` or `'testnet'`.
73
+ * `relayerUrl`: The base URL of your relayer backend.
74
+
75
+ ### 2. The Headless / Modular Approach (Custom Flows)
76
+ If you need complete control over the user experience, styling, or the order of operations, you can use our individual headless components. You handle the state routing, and we handle the heavy lifting of Web3 connections, OAuth, and zero-knowledge biometrics.
77
+
78
+ #### `<WalletSelection />`
79
+ A plug-and-play UI for wallet connections across both EVM and Solana ecosystems.
80
+
81
+ ```tsx
82
+ import { WalletSelection } from 'vo-sdk';
83
+
84
+ <WalletSelection
85
+ requiredWallets={['phantom', 'metamask', 'backpack']}
86
+ onWalletConnected={(address, chain) => {
87
+ console.log(`Connected to ${chain}: ${address}`);
88
+ }}
89
+ />
90
+ ```
91
+
92
+ #### `<SocialConnection />`
93
+ Handles OAuth flows and API integrations for social verification.
94
+
95
+ ```tsx
96
+ import { SocialConnection } from 'vo-sdk';
97
+
98
+ <SocialConnection
99
+ requiredSocials={['x', 'farcaster']}
100
+ onSocialConnected={(platform, profileData) => {
101
+ console.log(`Connected to ${platform}:`, profileData);
102
+ }}
103
+ />
104
+ ```
105
+
106
+ #### `<ProofOfHumanity />` and `<FaceZK />`
107
+ The core biometric scanners. `ProofOfHumanity` provides a structured UI wrapper around the raw `FaceZK` scanner.
108
+
109
+ ```tsx
110
+ import { ProofOfHumanity } from 'vo-sdk';
111
+
112
+ <ProofOfHumanity
113
+ onNextStep={() => console.log("User clicked continue")}
114
+ onVerificationComplete={(hexHash, liveness) => {
115
+ // You now have the secure SimHash and liveness score!
116
+ submitToBackend(hexHash, liveness);
117
+ }}
118
+ />
119
+ ```
120
+
121
+ ## Backend Submission (Relayer Client)
122
+
123
+ If you are using the **Headless / Modular Approach**, you are responsible for submitting the biometric payload to the backend using the `VerifiedRelayerClient`.
124
+
125
+ ```tsx
126
+ import { VerifiedRelayerClient } from 'vo-sdk';
127
+
128
+ // Initialize the client
129
+ const client = new VerifiedRelayerClient({
130
+ baseUrl: 'https://api.verifiedonchain.com/v1',
131
+ network: 'mainnet',
132
+ appId: 'YOUR_APP_ID' // Required for production usage!
133
+ });
134
+
135
+ // Submit the verification payload
136
+ const response = await client.submitVerification({
137
+ simhashFull: '...', // the hex hash from ProofOfHumanity
138
+ livenessCombined: 0.99, // the liveness score from ProofOfHumanity
139
+ walletAddress: '0x...', // the connected wallet from WalletSelection
140
+ chain: 'evm' // 'evm' or 'solana'
141
+ });
142
+
143
+ console.log("Humanity Code:", response.data.humanityCode);
144
+ ```
145
+
146
+ ### Security & Authentication
147
+
148
+ The VerifiedOnchain backend enforces strict authentication for relayed requests:
149
+ 1. **AppID (`appId`)**: You must provide your officially registered `appId` when initializing the `VerifiedRelayerClient`.
150
+ 2. **Domain Origin Constraints**: Verification requests will only be accepted from your pre-authorized domain origins (e.g., `https://your-dapp-domain.com`). Local development (`localhost` / `127.0.0.1`) is permitted for testing.
151
+
152
+ If your domain is not authorized, the API will reject the request with a `403 FORBIDDEN` error.