-
Notifications
You must be signed in to change notification settings - Fork 1
[ID-1139] add js bindings #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
decentralgabe
merged 44 commits into
main
from
gabe-id-1139-add-rust-core-js-bindings-examples
Nov 24, 2025
Merged
Changes from all commits
Commits
Show all changes
44 commits
Select commit
Hold shift + click to select a range
9b8dfea
let's see what claude can do
91c2e80
more robust
88817c6
clippy
9e54c19
remove generated mobile code
5669d37
use walletkit structure
3377b14
more like idkit-rs
72e04ba
doc updates
cc9fabe
Merge origin/main into full-implementation (accepting main as source …
6971569
rebase
be6b262
simpler
b933520
doc updates
0edef22
js wasm progress
9dbc79f
js impl
8501485
Merge remote-tracking branch 'origin/main' into language-bindings-swi…
806adcc
simpler
dbc30e4
remove deprecated cred type
fa0c7bc
more drop in
8f434a5
updates to match api
986e2e8
ci
e652b19
Potential fix for code scanning alert no. 1: Workflow does not contai…
decentralgabe 5d96902
Potential fix for code scanning alert no. 2: Workflow does not contai…
decentralgabe 4012ede
remove old tests
8906a98
formatting
b77b0c5
smoke tests
ed9803e
update
7e87e9e
update ci
8d5b192
Merge branch 'main' into language-bindings-swift-kotlin-js
decentralgabe 1475821
update wasm'
fb89e04
Merge origin/main favoring main branch changes
15f3ceb
update ci
4e43acc
Fix cargo formatting - add trailing newlines
e197ab9
Merge branch 'main' into language-bindings-swift-kotlin-js
decentralgabe 9c08f25
Merge branch 'main' into gabe-id-1139-add-rust-core-js-bindings-examples
decentralgabe 56d64f1
remove codeql
b26bbfd
update v2/v3 api
b04faee
Merge branch 'main' into gabe-id-1139-add-rust-core-js-bindings-examples
decentralgabe 5473c1a
update lint
8df303f
lints
6e0bc26
update
c8bd897
Rename
cf347e5
Merge remote-tracking branch 'origin/main' into gabe-id-1139-add-rust…
439821b
simplify styling
ab106cb
fix anbi encoding
99d16d2
pr feedback
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -116,4 +116,4 @@ jobs: | |
| gh release edit "$VERSION" \ | ||
| --repo worldcoin/idkit-swift \ | ||
| --draft=false \ | ||
| --latest | ||
| --latest | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| { | ||
| "name": "idkit-monorepo", | ||
| "version": "3.0.0", | ||
| "private": true, | ||
| "description": "World ID SDK for Relying Parties - JavaScript packages", | ||
| "scripts": { | ||
| "build": "pnpm -r build", | ||
| "dev": "pnpm -r dev", | ||
| "lint": "pnpm -r lint", | ||
| "test": "pnpm -r test" | ||
| }, | ||
| "devDependencies": { | ||
| "@changesets/cli": "^2.27", | ||
| "prettier": "^3.3", | ||
| "typescript": "^5.6", | ||
| "turbo": "^2.2" | ||
| }, | ||
| "packageManager": "pnpm@9.12.2", | ||
| "engines": { | ||
| "node": ">=18" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,164 @@ | ||
| # @worldcoin/idkit-core | ||
|
|
||
| Core bridge logic for IDKit (World ID SDK) powered by Rust/WASM. | ||
|
|
||
| ## Installation | ||
|
|
||
| ```bash | ||
| npm install @worldcoin/idkit-core | ||
| # or | ||
| pnpm add @worldcoin/idkit-core | ||
| ``` | ||
|
|
||
| ## Quick Start | ||
|
|
||
| ```typescript | ||
| import { | ||
| useWorldBridgeStore, | ||
| VerificationLevel, | ||
| } from '@worldcoin/idkit-core' | ||
|
|
||
| // 1. Get store instance | ||
| const store = useWorldBridgeStore() | ||
|
|
||
| // 2. Create client - returns immutable client object | ||
| const client = await store.createClient({ | ||
| app_id: 'app_staging_xxxxx', | ||
| action: 'my-action', | ||
| verification_level: VerificationLevel.Orb, | ||
| signal: 'user-id-123', | ||
| }) | ||
|
|
||
| // 3. Display QR code for World App | ||
| console.log('Scan this:', client.connectorURI) | ||
|
|
||
| // 4. Poll for proof (handles polling automatically) | ||
| try { | ||
| const proof = await client.pollForUpdates() | ||
| console.log('Success:', proof) | ||
| } catch (error) { | ||
| console.error('Verification failed:', error) | ||
| } | ||
| ``` | ||
|
|
||
| ## V2 API | ||
|
|
||
| ```typescript | ||
| const store = useWorldBridgeStore() | ||
|
|
||
| await store.createClient({ | ||
| app_id: 'app_staging_xxxxx', | ||
| action: 'my-action', | ||
| verification_level: VerificationLevel.Orb, | ||
| signal: 'user-id-123', | ||
| }) | ||
|
|
||
| console.log('Scan this:', store.connectorURI) | ||
|
|
||
| await store.pollForUpdates() | ||
|
|
||
| if (store.result) { | ||
| console.log('Proof received:', store.result) | ||
| } | ||
| ``` | ||
|
|
||
| ## API Reference | ||
|
|
||
| ```typescript | ||
| const client = await store.createClient(config) | ||
| ``` | ||
|
|
||
| **Properties:** | ||
| - `connectorURI: string` - QR code URL for World App | ||
| - `requestId: string` - Unique request ID | ||
|
|
||
| **Methods:** | ||
| - `pollForUpdates(options?: WaitOptions): Promise<ISuccessResult>` - Poll for proof (auto-polls) | ||
| - `pollOnce(): Promise<Status>` - Poll once for status (manual polling) | ||
|
|
||
| **WaitOptions:** | ||
| ```typescript | ||
| interface WaitOptions { | ||
| pollInterval?: number // ms between polls (default: 1000) | ||
| timeout?: number // total timeout ms (default: 300000 = 5min) | ||
| signal?: AbortSignal // for cancellation | ||
| } | ||
| ``` | ||
|
|
||
| ### Store | ||
|
|
||
| ```typescript | ||
| const store = useWorldBridgeStore() | ||
| ``` | ||
|
|
||
| **V3 Methods:** | ||
| - `createClient(config: IDKitConfig): Promise<WorldBridgeClient>` - Create new client | ||
|
|
||
| **V2 State (backward compat):** | ||
| - `verificationState: VerificationState` - Current verification state | ||
| - `connectorURI: string | null` - QR code URL for World App | ||
| - `result: ISuccessResult | null` - Proof data when verified | ||
| - `errorCode: AppErrorCodes | null` - Error code if failed | ||
|
|
||
| **V2 Methods (deprecated):** | ||
| - `pollForUpdates(): Promise<void>` - Check for proof (call repeatedly) ⚠️ Use `client.pollForUpdates()` with auto-polling instead | ||
| - `reset(): void` - Clear state and start over | ||
|
|
||
| ### Types | ||
|
|
||
| ```typescript | ||
| interface IDKitConfig { | ||
| app_id: `app_${string}` | ||
| action: string | ||
| signal?: string | ||
| verification_level?: VerificationLevel | ||
| bridge_url?: string | ||
| partner?: boolean | ||
| } | ||
|
|
||
| interface ISuccessResult { | ||
| proof: string | ||
| merkle_root: string | ||
| nullifier_hash: string | ||
| verification_level: VerificationLevel | ||
| } | ||
|
|
||
| enum VerificationLevel { | ||
| Orb = 'orb', | ||
| Face = 'face', | ||
| Device = 'device', | ||
| Document = 'document', | ||
| SecureDocument = 'secure_document', | ||
| } | ||
| ``` | ||
|
|
||
| ### Utilities | ||
|
|
||
| ```typescript | ||
| // Signal hashing (keccak256) | ||
| hashToField(input: string): HashFunctionOutput | ||
|
|
||
| // ABI encoding | ||
| solidityEncode(types: string[], values: unknown[]): AbiEncodedValue | ||
| ``` | ||
|
|
||
| ## Examples | ||
|
|
||
| See [examples/browser](./examples/browser) for a complete working example. | ||
|
|
||
| ## Building from Source | ||
|
|
||
| ```bash | ||
| # Build WASM module | ||
| npm run build:wasm | ||
|
|
||
| # Build TypeScript | ||
| npm run build:ts | ||
|
|
||
| # Or both | ||
| npm run build | ||
| ``` | ||
|
|
||
| ## License | ||
|
|
||
| MIT | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| # IDKit Browser Example | ||
|
|
||
| A simple browser example demonstrating World ID verification using IDKit 3.0. | ||
|
|
||
| ## Usage | ||
|
|
||
| #### Local Development | ||
|
|
||
| 1. Build the core package: | ||
| ```bash | ||
| cd ../../ | ||
| pnpm build | ||
| ``` | ||
|
|
||
| 2. Serve the example: | ||
| ```bash | ||
| cd examples/browser | ||
| python3 -m http.server 8000 | ||
| # or | ||
| npx serve | ||
| ``` | ||
|
|
||
| 3. Open http://localhost:8000 in your browser | ||
|
|
||
| #### Production | ||
|
|
||
| Replace the import in `index.html`: | ||
|
|
||
| ```javascript | ||
| // From: | ||
| import { initIDKit, Session, Credential } from '../../dist/index.js'; | ||
|
|
||
| // To: | ||
| import { initIDKit, Session, Credential } from '@worldcoin/idkit-core'; | ||
| ``` | ||
|
|
||
| ## Configuration | ||
|
|
||
| Update these values in `index.html`: | ||
|
|
||
| ```javascript | ||
| const APP_ID = 'app_staging_123'; // Your app ID from the Developer Portal | ||
| const ACTION = 'demo-action'; // Your action identifier from the Developer Portal | ||
| ``` | ||
|
|
||
| ## API Usage | ||
|
|
||
| ```javascript | ||
| // 1. Initialize WASM | ||
| await initIDKit(); | ||
|
|
||
| // 2. Create session | ||
| const session = await Session.create({ | ||
| app_id: 'app_xxx', | ||
| action: 'my-action', | ||
| requests: [{ | ||
| type: Credential.Orb, | ||
| signal: 'my-signal', | ||
| }], | ||
| }); | ||
|
|
||
| // 3. Get QR code URL | ||
| const url = session.connectUrl(); | ||
|
|
||
| // 4. Wait for proof | ||
| const proof = await session.waitForProof(); | ||
| console.log(proof); | ||
| ``` |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is kind of similar to the session hook. But, I like it!
https://docs.world.org/world-id/id/web-react#session-hook