@worldcoin/idkit 2.2.0 → 2.2.2
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/build/config-BRFx4nLT.d.cts +45 -0
- package/build/index.cjs +2371 -0
- package/build/index.d.cts +56 -0
- package/build/index.js +165 -150
- package/build/internal.cjs +269 -0
- package/build/internal.d.cts +53 -0
- package/package.json +17 -6
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { C as Config, W as WidgetProps } from './config-BRFx4nLT.cjs';
|
|
2
|
+
import * as react from 'react';
|
|
3
|
+
export { solidityEncode } from '@worldcoin/idkit-core/hashing';
|
|
4
|
+
export { IVerifyResponse, verifyCloudProof } from '@worldcoin/idkit-core/backend';
|
|
5
|
+
import { IDKitConfig, VerificationState, ISuccessResult, AppErrorCodes } from '@worldcoin/idkit-core';
|
|
6
|
+
export { IErrorState, ISuccessResult, VerificationLevel, VerificationState } from '@worldcoin/idkit-core';
|
|
7
|
+
|
|
8
|
+
type HookConfig = Partial<Pick<Config, 'handleVerify' | 'onSuccess'>>;
|
|
9
|
+
declare const useIDKit: ({ handleVerify, onSuccess }?: HookConfig) => {
|
|
10
|
+
open: boolean;
|
|
11
|
+
setOpen: (open: boolean) => void;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
declare const _default: react.NamedExoticComponent<WidgetProps>;
|
|
15
|
+
|
|
16
|
+
type UseSessionConfig = IDKitConfig;
|
|
17
|
+
type UseSessionResult = {
|
|
18
|
+
/** The current verification state */
|
|
19
|
+
status: VerificationState;
|
|
20
|
+
/** The QR code URI that users can scan to verify */
|
|
21
|
+
sessionURI: string | null;
|
|
22
|
+
/** The verification result if successful */
|
|
23
|
+
result: ISuccessResult | null;
|
|
24
|
+
/** Error code if verification failed */
|
|
25
|
+
errorCode: AppErrorCodes | null;
|
|
26
|
+
/** Function to reset the session and start over */
|
|
27
|
+
reset: () => void;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* A beginner-friendly React hook for World ID verification sessions.
|
|
31
|
+
*
|
|
32
|
+
* This hook automatically:
|
|
33
|
+
* - Creates a verification session
|
|
34
|
+
* - Generates a QR code URI for scanning
|
|
35
|
+
* - Polls for verification updates
|
|
36
|
+
* - Stops polling when verification completes or fails
|
|
37
|
+
*
|
|
38
|
+
* @param config - The World ID configuration object
|
|
39
|
+
* @returns Session state and controls
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```tsx
|
|
43
|
+
* const { status, sessionURI, result, errorCode } = useSession({
|
|
44
|
+
* app_id: 'app_staging_12345',
|
|
45
|
+
* action: 'login',
|
|
46
|
+
* signal: 'user_123'
|
|
47
|
+
* })
|
|
48
|
+
*
|
|
49
|
+
* if (status === VerificationState.WaitingForConnection) {
|
|
50
|
+
* return <QRCodeSVG value={sessionURI} />
|
|
51
|
+
* }
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
declare function useSession(config: UseSessionConfig): UseSessionResult;
|
|
55
|
+
|
|
56
|
+
export { Config, _default as IDKitWidget, type UseSessionConfig, type UseSessionResult, WidgetProps, useIDKit, useSession };
|