@worldcoin/idkit-core 2.1.0 → 4.0.1-dev.eebacb1
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 +186 -0
- package/dist/idkit_wasm_bg.wasm +0 -0
- package/dist/index.cjs +1986 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +437 -0
- package/dist/index.d.ts +437 -0
- package/dist/index.js +1972 -0
- package/dist/index.js.map +1 -0
- package/package.json +35 -62
- package/wasm/idkit_wasm.d.ts +456 -0
- package/wasm/idkit_wasm.js +1877 -0
- package/wasm/idkit_wasm_bg.wasm +0 -0
- package/wasm/idkit_wasm_bg.wasm.d.ts +54 -0
- package/LICENSE +0 -7
- package/build/chunk-HZ2SQA5V.js +0 -50
- package/build/config-fuwC_Hia.d.cts +0 -41
- package/build/config-fuwC_Hia.d.ts +0 -41
- package/build/index.cjs +0 -424
- package/build/index.d.cts +0 -37
- package/build/index.d.ts +0 -37
- package/build/index.js +0 -358
- package/build/lib/backend.cjs +0 -71
- package/build/lib/backend.d.cts +0 -12
- package/build/lib/backend.d.ts +0 -12
- package/build/lib/backend.js +0 -31
- package/build/lib/hashing.cjs +0 -78
- package/build/lib/hashing.d.cts +0 -21
- package/build/lib/hashing.d.ts +0 -21
- package/build/lib/hashing.js +0 -14
- package/build/result-BZ4QXOc2.d.cts +0 -35
- package/build/result-CqgtArQe.d.ts +0 -35
package/README.md
ADDED
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
# @worldcoin/idkit-core
|
|
2
|
+
|
|
3
|
+
Core bridge logic for IDKit (World ID SDK) powered by Rust/WASM.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @worldcoin/idkit-core
|
|
9
|
+
# or
|
|
10
|
+
pnpm add @worldcoin/idkit-core
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Quick Start
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import { useWorldBridgeStore } from "@worldcoin/idkit-core";
|
|
17
|
+
|
|
18
|
+
// 1. Get store instance
|
|
19
|
+
const store = useWorldBridgeStore();
|
|
20
|
+
|
|
21
|
+
// 2. Create client with explicit requests
|
|
22
|
+
const client = await store.createClient({
|
|
23
|
+
app_id: "app_staging_xxxxx",
|
|
24
|
+
action: "my-action",
|
|
25
|
+
requests: [{ credential_type: "orb", signal: "user-id-123" }],
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
// 3. Display QR code for World App
|
|
29
|
+
console.log("Scan this:", client.connectorURI);
|
|
30
|
+
|
|
31
|
+
// 4. Poll for proof (handles polling automatically)
|
|
32
|
+
try {
|
|
33
|
+
const proof = await client.pollForUpdates();
|
|
34
|
+
console.log("Success:", proof);
|
|
35
|
+
} catch (error) {
|
|
36
|
+
console.error("Verification failed:", error);
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Multiple Credential Types
|
|
41
|
+
|
|
42
|
+
You can request verification with multiple credential types. The user can satisfy the request with any of them:
|
|
43
|
+
|
|
44
|
+
```typescript
|
|
45
|
+
const client = await store.createClient({
|
|
46
|
+
app_id: "app_staging_xxxxx",
|
|
47
|
+
action: "my-action",
|
|
48
|
+
requests: [
|
|
49
|
+
{ credential_type: "orb", signal: "user-id-123" },
|
|
50
|
+
{ credential_type: "device", signal: "user-id-123" },
|
|
51
|
+
],
|
|
52
|
+
});
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Credential Types
|
|
56
|
+
|
|
57
|
+
- `orb` - Verified via Orb biometric scan (highest trust)
|
|
58
|
+
- `face` - Verified via Face ID
|
|
59
|
+
- `device` - Verified via device binding
|
|
60
|
+
- `document` - Verified via document scan
|
|
61
|
+
- `secure_document` - Verified via secure document scan
|
|
62
|
+
|
|
63
|
+
## API Reference
|
|
64
|
+
|
|
65
|
+
### Creating a Client
|
|
66
|
+
|
|
67
|
+
```typescript
|
|
68
|
+
const client = await store.createClient(config);
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
**Config:**
|
|
72
|
+
|
|
73
|
+
```typescript
|
|
74
|
+
interface IDKitConfig {
|
|
75
|
+
app_id: `app_${string}`; // Your World ID app ID
|
|
76
|
+
action: string; // Action identifier
|
|
77
|
+
requests: RequestConfig[]; // Required: credential type requests
|
|
78
|
+
bridge_url?: string; // Custom bridge URL (optional)
|
|
79
|
+
partner?: boolean; // Partner mode (optional)
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
interface RequestConfig {
|
|
83
|
+
credential_type: CredentialType;
|
|
84
|
+
signal?: string | AbiEncodedValue; // Optional signal for this request
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
type CredentialType =
|
|
88
|
+
| "orb"
|
|
89
|
+
| "face"
|
|
90
|
+
| "device"
|
|
91
|
+
| "document"
|
|
92
|
+
| "secure_document";
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
**Client Properties:**
|
|
96
|
+
|
|
97
|
+
- `connectorURI: string` - QR code URL for World App
|
|
98
|
+
- `requestId: string` - Unique request ID
|
|
99
|
+
|
|
100
|
+
**Client Methods:**
|
|
101
|
+
|
|
102
|
+
- `pollForUpdates(options?: WaitOptions): Promise<ISuccessResult>` - Poll for proof (auto-polls)
|
|
103
|
+
- `pollOnce(): Promise<Status>` - Poll once for status (manual polling)
|
|
104
|
+
|
|
105
|
+
**WaitOptions:**
|
|
106
|
+
|
|
107
|
+
```typescript
|
|
108
|
+
interface WaitOptions {
|
|
109
|
+
pollInterval?: number; // ms between polls (default: 1000)
|
|
110
|
+
timeout?: number; // total timeout ms (default: 300000 = 5min)
|
|
111
|
+
signal?: AbortSignal; // for cancellation
|
|
112
|
+
}
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### Store
|
|
116
|
+
|
|
117
|
+
```typescript
|
|
118
|
+
const store = useWorldBridgeStore();
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
**Methods:**
|
|
122
|
+
|
|
123
|
+
- `createClient(config: IDKitConfig): Promise<WorldBridgeClient>` - Create new client
|
|
124
|
+
- `reset(): void` - Clear state and start over
|
|
125
|
+
|
|
126
|
+
**State (for reactive frameworks):**
|
|
127
|
+
|
|
128
|
+
- `verificationState: VerificationState` - Current verification state
|
|
129
|
+
- `connectorURI: string | null` - QR code URL for World App
|
|
130
|
+
- `result: ISuccessResult | null` - Proof data when verified
|
|
131
|
+
- `errorCode: AppErrorCodes | null` - Error code if failed
|
|
132
|
+
|
|
133
|
+
### Result Types
|
|
134
|
+
|
|
135
|
+
```typescript
|
|
136
|
+
interface ISuccessResult {
|
|
137
|
+
proof: string;
|
|
138
|
+
merkle_root: string;
|
|
139
|
+
nullifier_hash: string;
|
|
140
|
+
verification_level: CredentialType; // The credential type used
|
|
141
|
+
}
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
## React Integration
|
|
145
|
+
|
|
146
|
+
```tsx
|
|
147
|
+
import { useWorldBridgeStore, IDKitWidget } from "@worldcoin/idkit-core";
|
|
148
|
+
|
|
149
|
+
function MyComponent() {
|
|
150
|
+
const handleSuccess = (result) => {
|
|
151
|
+
console.log("Verified:", result);
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
return (
|
|
155
|
+
<IDKitWidget
|
|
156
|
+
app_id="app_staging_xxxxx"
|
|
157
|
+
action="my-action"
|
|
158
|
+
requests={[{ credential_type: "orb", signal: "user-123" }]}
|
|
159
|
+
onSuccess={handleSuccess}
|
|
160
|
+
>
|
|
161
|
+
{({ open }) => <button onClick={open}>Verify with World ID</button>}
|
|
162
|
+
</IDKitWidget>
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
## Examples
|
|
168
|
+
|
|
169
|
+
See [examples/browser](../../examples/browser) for a complete working example.
|
|
170
|
+
|
|
171
|
+
## Building from Source
|
|
172
|
+
|
|
173
|
+
```bash
|
|
174
|
+
# Build WASM module
|
|
175
|
+
npm run build:wasm
|
|
176
|
+
|
|
177
|
+
# Build TypeScript
|
|
178
|
+
npm run build:ts
|
|
179
|
+
|
|
180
|
+
# Or both
|
|
181
|
+
npm run build
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
## License
|
|
185
|
+
|
|
186
|
+
MIT
|
|
Binary file
|