UNPKG

@worldcoin/idkit

Version:

The identity SDK. Privacy-preserving identity and proof of personhood with World ID.

57 lines (52 loc) 2.07 kB
import { C as Config, W as WidgetProps } from './config-BRFx4nLT.cjs'; import * as react from 'react'; export { solidityEncode } from '@worldcoin/idkit-core/hashing'; export { IVerifyResponse, verifyCloudProof } from '@worldcoin/idkit-core/backend'; import { IDKitConfig, VerificationState, ISuccessResult, AppErrorCodes } from '@worldcoin/idkit-core'; export { IErrorState, ISuccessResult, VerificationLevel, VerificationState } from '@worldcoin/idkit-core'; type HookConfig = Partial<Pick<Config, 'handleVerify' | 'onSuccess'>>; declare const useIDKit: ({ handleVerify, onSuccess }?: HookConfig) => { open: boolean; setOpen: (open: boolean) => void; }; declare const _default: react.NamedExoticComponent<WidgetProps>; type UseSessionConfig = IDKitConfig; type UseSessionResult = { /** The current verification state */ status: VerificationState; /** The QR code URI that users can scan to verify */ sessionURI: string | null; /** The verification result if successful */ result: ISuccessResult | null; /** Error code if verification failed */ errorCode: AppErrorCodes | null; /** Function to reset the session and start over */ reset: () => void; }; /** * A beginner-friendly React hook for World ID verification sessions. * * This hook automatically: * - Creates a verification session * - Generates a QR code URI for scanning * - Polls for verification updates * - Stops polling when verification completes or fails * * @param config - The World ID configuration object * @returns Session state and controls * * @example * ```tsx * const { status, sessionURI, result, errorCode } = useSession({ * app_id: 'app_staging_12345', * action: 'login', * signal: 'user_123' * }) * * if (status === VerificationState.WaitingForConnection) { * return <QRCodeSVG value={sessionURI} /> * } * ``` */ declare function useSession(config: UseSessionConfig): UseSessionResult; export { Config, _default as IDKitWidget, type UseSessionConfig, type UseSessionResult, WidgetProps, useIDKit, useSession };