UNPKG

@worldcoin/idkit

Version:

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

69 lines (64 loc) 3.59 kB
import * as react from 'react'; import * as zustand_traditional from 'zustand/traditional'; import * as zustand_vanilla from 'zustand/vanilla'; import { I as IDKITStage, c as ConfigSource, d as CallbackFn, C as Config } from './config-SH5TbLYj.cjs'; export { S as SupportedLanguage, a as getCurrentLanguage, g as getLocalizationConfig, b as getSupportedLanguages, s as setLocalizationConfig } from './config-SH5TbLYj.cjs'; import { IDKitConfig, ISuccessResult, IErrorState } from '@worldcoin/idkit-core'; /** * ## Adding Translations * To add a new language: * 1. Create a new translation file in `src/lang/translations/[lang].ts` * 2. Implement all translation strings in the new file * 3. Add the language to the `translations` index * 4. Update the `SupportedLanguage` type in `src/lang/types.ts` */ /** * Translation function with type-safe parameter support * * Examples: * - __('Hello world') // No parameters needed * - __('Invalid IDKitStage :stage.', { stage: 'init' }) // Parameter required */ type HasPlaceholder<T extends string> = T extends `${string}:${string}` ? true : false; type GetPlaceholderName<T extends string> = T extends `:${infer Name}${infer Rest}` ? Name extends `${infer Word}${' ' | ',' | ':' | '!' | '?' | '.'}${string}` ? Word : Name : never; type GetAllPlaceholders<T extends string> = T extends `${infer Before}:${infer After}` ? GetAllPlaceholders<After> | GetPlaceholderName<`:${After}`> : never; type TranslationParams<T extends string> = GetAllPlaceholders<T> extends never ? never : { [K in GetAllPlaceholders<T>]: string; }; declare function __<T extends string>(str: T, ...args: HasPlaceholder<T> extends true ? [params: TranslationParams<T>] : []): string; type Props = { data: string; size?: number; }; declare const _default: react.MemoExoticComponent<({ data, size }: Props) => JSX.Element>; declare const SELF_HOSTED_APP_ID = "self_hosted"; type IDKitStore = { app_id: IDKitConfig['app_id'] | typeof SELF_HOSTED_APP_ID | ''; action: IDKitConfig['action']; signal: IDKitConfig['signal']; bridge_url?: IDKitConfig['bridge_url']; action_description?: IDKitConfig['action_description']; verification_level: NonNullable<IDKitConfig['verification_level']>; partner?: IDKitConfig['partner']; open: boolean; stage: IDKITStage; autoClose: boolean; processing: boolean; result: ISuccessResult | null; errorState: IErrorState | null; errorCallbacks: Record<ConfigSource, CallbackFn<IErrorState> | undefined> | Record<string, never>; verifyCallbacks: Record<ConfigSource, CallbackFn<ISuccessResult> | undefined> | Record<string, never>; successCallbacks: Record<ConfigSource, CallbackFn<ISuccessResult> | undefined> | Record<string, never>; retryFlow: () => void; setStage: (stage: IDKITStage) => void; onOpenChange: (open: boolean) => void; setProcessing: (processing: boolean) => void; handleVerify: (result: ISuccessResult) => void; setErrorState: (state: IErrorState | null) => void; setOptions: (options: Config, source: ConfigSource) => void; addErrorCallback: (cb: CallbackFn<IErrorState>, source: ConfigSource) => void; addSuccessCallback: (cb: CallbackFn<ISuccessResult>, source: ConfigSource) => void; addVerificationCallback: (cb: CallbackFn<ISuccessResult>, source: ConfigSource) => void; }; declare const useIDKitStore: zustand_traditional.UseBoundStoreWithEqualityFn<zustand_vanilla.StoreApi<IDKitStore>>; export { ConfigSource, _default as QRCode, __, useIDKitStore };