@worldcoin/idkit 0.0.1 → 0.0.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.
@@ -0,0 +1,37 @@
1
+ /// <reference types="node" />
2
+ import type { BytesLike } from '@ethersproject/bytes';
3
+ import type { StringOrAdvanced } from '../types/config';
4
+ export interface HashFunctionOutput {
5
+ hash: BigInt;
6
+ digest: string;
7
+ }
8
+ /**
9
+ * Hashes an input using the `keccak256` hashing function used across the World ID protocol, to be used as
10
+ * a ZKP input. The function will try to determine the best hashing mechanism, if the string already looks like hex-encoded
11
+ * bytes (e.g. `0x0000000000000000000000000000000000000000`), it will be hashed directly.
12
+ * @param input Any string, hex-like string, bytes represented as a hex string.
13
+ * @returns
14
+ */
15
+ export declare function worldIDHash(input: Buffer | BytesLike | StringOrAdvanced): HashFunctionOutput;
16
+ /**
17
+ * Using `worldIDHash` is recommended! Use this if you're certain you want to hash a string.
18
+ * Converts an input to bytes and then hashes it with the World ID protocol hashing function.
19
+ * @param input - String to hash
20
+ * @returns hash
21
+ */
22
+ export declare function hashString(input: string): HashFunctionOutput;
23
+ /**
24
+ * Using `worldIDHash` is recommended! Use this if you're certain you want to hash raw bytes.
25
+ * Hashes raw bytes input using the `keccak256` hashing function used across the World ID protocol, to be used as
26
+ * a ZKP input. Example use cases include when you're hashing an address to be verified in a smart contract.
27
+ * @param input - Bytes represented as a hex string.
28
+ * @returns
29
+ */
30
+ export declare function hashEncodedBytes(input: BytesLike): HashFunctionOutput;
31
+ /**
32
+ * Partial implementation of `keccak256` hash from @ethersproject/solidity; only supports hashing a single BytesLike value
33
+ * @param value value to hash
34
+ * @returns
35
+ */
36
+ export declare function keccak256(value: BytesLike): string;
37
+ export declare const validateABILikeEncoding: (value: string) => boolean;
@@ -0,0 +1,5 @@
1
+ import type WalletConnect from '@walletconnect/client';
2
+ /**
3
+ * Build data for QR Code
4
+ */
5
+ export declare function buildQRData(connector: WalletConnect, returnUrl?: string): string;
@@ -0,0 +1,4 @@
1
+ export declare const getTelemetryId: () => string;
2
+ export declare const initTelemetry: (enableTelemetry?: boolean) => void;
3
+ export declare const telemetryModalOpened: () => void;
4
+ export declare const telemetryPhoneTyped: () => void;
@@ -1 +1,2 @@
1
- export declare const classNames: (...classes: Array<boolean | string | undefined>) => string;
1
+ export declare const classNames: (...classes: unknown[]) => string;
2
+ export declare const randomNumber: (min: number, max: number) => number;
@@ -1,6 +1,6 @@
1
1
  import type { PhoneSignalProof } from '../types';
2
2
  export declare function requestCode(phone_number: string, action_id: string, ph_distinct_id: string): Promise<void>;
3
- interface VerifyCodeSuccess extends Pick<PhoneSignalProof, 'timestamp' | 'signature'> {
3
+ interface VerifyCodeSuccess extends Pick<PhoneSignalProof, 'signature' | 'timestamp'> {
4
4
  success: true;
5
5
  nullifier_hash: string;
6
6
  }
@@ -0,0 +1,14 @@
1
+ import type { OrbResponse } from '../types/orb';
2
+ import type { StringOrAdvanced } from '../types/config';
3
+ import { ErrorCodes, VerificationState } from '../types/orb';
4
+ type UseOrbSignalResponse = {
5
+ result: OrbResponse | null;
6
+ errorCode: ErrorCodes | null;
7
+ verificationState: VerificationState;
8
+ qrData: {
9
+ default: string;
10
+ mobile: string;
11
+ } | null;
12
+ };
13
+ declare const useOrbSignal: (action_id: StringOrAdvanced, signal: StringOrAdvanced) => UseOrbSignalResponse;
14
+ export default useOrbSignal;
@@ -1,29 +1,30 @@
1
1
  import { IDKITStage } from '../types';
2
- import type { Config } from '../types/config';
3
2
  import type { CallbackFn, ErrorState, ISuccessResult } from '../types';
3
+ import type { Config, ConfigSource, StringOrAdvanced } from '../types/config';
4
4
  export type IDKitStore = {
5
5
  code: string;
6
6
  open: boolean;
7
- actionId: string;
8
7
  stage: IDKITStage;
9
8
  autoClose: boolean;
10
9
  phoneNumber: string;
11
- copy: Config['copy'];
12
10
  processing: boolean;
11
+ copy: Config['copy'];
12
+ signal: StringOrAdvanced;
13
+ actionId: StringOrAdvanced;
14
+ stringifiedActionId: string;
13
15
  errorState: ErrorState | null;
14
- successCallbacks: Array<CallbackFn>;
16
+ successCallbacks: Record<ConfigSource, CallbackFn | undefined> | Record<string, never>;
15
17
  retryFlow: () => void;
16
18
  setCode: (code: string) => void;
17
19
  setOpen: (open: boolean) => void;
18
20
  setStage: (stage: IDKITStage) => void;
19
- setOptions: (options: Config) => void;
20
21
  onOpenChange: (open: boolean) => void;
21
- setActionId: (actionId: string) => void;
22
22
  onSuccess: (result: ISuccessResult) => void;
23
23
  setProcessing: (processing: boolean) => void;
24
- addSuccessCallback: (cb: CallbackFn) => void;
25
24
  setPhoneNumber: (phoneNumber: string) => void;
26
25
  setErrorState: (errorState: ErrorState | null) => void;
26
+ setOptions: (options: Config, source: ConfigSource) => void;
27
+ addSuccessCallback: (cb: CallbackFn, source: ConfigSource) => void;
27
28
  };
28
29
  declare const useIDKitStore: import("zustand").UseBoundStore<import("zustand").StoreApi<IDKitStore>>;
29
30
  export default useIDKitStore;