API Reference

Components

ZkEmailSDKProvider

The ZkEmailSDKProvider is a wrapper component that provides the ZK Email SDK context to its children. It manages the core functionalities of the SDK, including input generation, proof creation, and interaction with the ZK Email SDK registry.

Props

Prop
Type
Description

children

ReactNode

Child components to be wrapped

clientId

string

Google OAuth client ID

zkEmailSDKRegistryUrl

string

URL for the ZK Email SDK registry

Usage

import { ZkEmailSDKProvider } from "@zk-email/zk-email-sdk";

function App() {
  return (
    <ZkEmailSDKProvider 
      clientId={import.meta.env.VITE_GOOGLE_OAUTH_CLIENT_ID}
      zkEmailSDKRegistryUrl='https://registry-dev.zkregex.com'
    >
      {/* Your app components */}
    </ZkEmailSDKProvider>
  );
}

export default App;

GoogleAuthProvider

The GoogleAuthProvider is a wrapper component that manages Google authentication state and provides authentication-related functions to its child components. It's an essential part of the ZK Email SDK that simplifies the process of integrating Google authentication into your application.

Props

Prop
Type
Description

children

ReactNode

Child components that will have access to the authentication context

Hooks

useZkEmailSDK

The useZkEmailSDK hook provides access to ZK Email SDK functionalities, allowing components to interact with the core features of the SDK.

Returns

Property
Type
Description

zkEmailSDKRegistryUrl

string

URL of the ZK Email SDK registry

inputWorkers

Record<string, Worker>

Object containing input workers

createInputWorker

(name: string) => void

Creates an input worker

deleteInputWorker

(name: string) => void

Deletes an input worker

generateInputFromEmail

(name: string, email: string, externalInputs: Record<string, string>) => Promise

Generates input from an email

loadProofsFromStorage

(name: string) => void

Loads proofs from local storage

proofStatus

Record<string, ProofStatus>

Object containing proof statuses

generateProofRemotely

(name: string, input: any) => Promise

Generates a proof remotely

deleteProofFromStorage

(id: string) => void

Deletes a proof from storage

useGoogleAuth

The useGoogleAuth hook provides access to Google authentication functionalities, allowing components to check authentication status and perform login/logout operations.

Returns

Property
Type
Description

googleAuthToken

any | null

Google authentication token

isGoogleAuthed

boolean

Whether the user is authenticated with Google

loggedInGmail

string | null

Email of the logged-in user

scopesApproved

boolean

Whether all required scopes are approved

googleLogIn

() => void

Initiates Google login

googleLogOut

() => void

Logs out from Google

The googleAuthToken is automatically stored in local storage for persistence across page reloads.

Utility Functions

fetchEmailList, fetchEmailsRaw, fetchProfile

These functions fetch email data and user profile information using the provided Google authentication token.

Usage

Last updated