@worldcoin/idkit 2.4.2 → 4.0.0-dev.fe98789

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 CHANGED
@@ -1,68 +1,51 @@
1
- # IDKit JS Widget
1
+ # @worldcoin/idkit
2
2
 
3
- This folder (`/idkit`) contains the main code for the widget. For instructions on **how to use the widget**, please refer to the repository's main [README](/README.md).
3
+ React SDK for World ID built on top of `@worldcoin/idkit-core`.
4
4
 
5
- ## ℹ️ About the Codebase
5
+ ## Highlights
6
6
 
7
- - The widget is made to work mainly with vanilla JS code (no framework required). The starting point can be found in `src/vanilla.tsx`.
8
- - The React wrapper is found on `src/components/IDKitWidget/index.ts`.
7
+ - Headless hooks for custom UI
8
+ - Built-in controlled widgets with shadow DOM isolation
9
+ - Separate request and session APIs
9
10
 
10
- ## 🧑‍💻 Development & Testing
11
+ ## Installation
11
12
 
12
- To develop locally and contribute to this package, you can simply follow these instructions after cloning the repo.
13
+ ```bash
14
+ npm install @worldcoin/idkit
15
+ ```
13
16
 
14
- - Install dependencies
15
- ```bash
16
- # be sure to run this in the root folder of the repo
17
- yarn install
18
- ```
19
- - Run tests
20
- ```bash
21
- # runs in the /idkit folder
22
- cd idkit/
23
- yarn test
24
- ```
25
- - Run local test project
26
- ```bash
27
- # runs in the /idkit folder
28
- yarn dev
29
- ```
30
- - Open browser at `http://localhost:3000`
31
- - To build the production bundle you can simply run.
32
- ```bash
33
- # runs in the /idkit folder
34
- yarn build
35
- ```
17
+ ## Basic usage
36
18
 
37
- ## Usage
38
-
39
- ### Set Language Explicitly
40
19
  ```tsx
41
- <IDKitWidget
42
- app_id="your_app_id"
43
- action="your_action"
44
- onSuccess={handleSuccess}
45
- language="es" // Spanish
46
- >
47
- {({ open }) => <button onClick={open}>Verify with World ID</button>}
48
- </IDKitWidget>
49
- ```
50
-
51
- ### Automatic Language Detection (Default)
52
- ```tsx
53
- <IDKitWidget
54
- app_id="your_app_id"
55
- action="your_action"
56
- onSuccess={handleSuccess}
57
- // No language prop needed - will auto-detect
58
- >
59
- {({ open }) => <button onClick={open}>Verify with World ID</button>}
60
- </IDKitWidget>
61
- ```
62
-
63
- ## Supported Languages
20
+ import { useIDKitRequest, orbLegacy } from "@worldcoin/idkit";
21
+
22
+ function Example() {
23
+ const flow = useIDKitRequest({
24
+ app_id: "app_xxxxx",
25
+ action: "my-action",
26
+ rp_context,
27
+ allow_legacy_proofs: false,
28
+ preset: orbLegacy({ signal: "user-123" }),
29
+ });
30
+ const isBusy =
31
+ flow.isAwaitingUserConnection || flow.isAwaitingUserConfirmation;
32
+
33
+ return (
34
+ <button onClick={flow.open} disabled={isBusy}>
35
+ Verify
36
+ </button>
37
+ );
38
+ }
39
+ ```
64
40
 
65
- Currently supported languages:
66
- - `en` - English (default)
67
- - `es` - Spanish
68
- - `th` - Thai
41
+ ```tsx
42
+ import type { IDKitRequestHookConfig } from "@worldcoin/idkit";
43
+
44
+ const config: IDKitRequestHookConfig = {
45
+ app_id: "app_xxxxx",
46
+ action: "my-action",
47
+ rp_context,
48
+ allow_legacy_proofs: false,
49
+ preset: { type: "OrbLegacy" },
50
+ };
51
+ ```