{"id":25633056,"url":"https://github.com/zkemail/zk-email-sdk-js","last_synced_at":"2025-04-14T18:16:26.061Z","repository":{"id":259188335,"uuid":"862049597","full_name":"zkemail/zk-email-sdk-js","owner":"zkemail","description":"Javascript SDK for the Blueprint Registry","archived":false,"fork":false,"pushed_at":"2025-04-14T04:08:09.000Z","size":1307,"stargazers_count":4,"open_issues_count":2,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-14T18:16:20.626Z","etag":null,"topics":["zk-email","zkemail"],"latest_commit_sha":null,"homepage":"https://docs.zk.email/zk-email-sdk/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zkemail.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-09-24T00:24:31.000Z","updated_at":"2025-04-14T04:08:13.000Z","dependencies_parsed_at":"2024-11-06T09:24:22.482Z","dependency_job_id":"3e28bacd-5159-473f-9c6f-f3e13f7bcd75","html_url":"https://github.com/zkemail/zk-email-sdk-js","commit_stats":null,"previous_names":["zkemail/zk-email-sdk-js"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zkemail%2Fzk-email-sdk-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zkemail%2Fzk-email-sdk-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zkemail%2Fzk-email-sdk-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zkemail%2Fzk-email-sdk-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zkemail","download_url":"https://codeload.github.com/zkemail/zk-email-sdk-js/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248933344,"owners_count":21185460,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["zk-email","zkemail"],"created_at":"2025-02-22T21:27:52.043Z","updated_at":"2025-04-14T18:16:26.015Z","avatar_url":"https://github.com/zkemail.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ZKEmail SDK\n\nWith the ZKEmail SDK you can create proofs about emails using blueprints. You can create blueprints with this\nSDK (documentation pending), or using our [registry](https://registry.zk.email).\n\n## Install\n\nThe SDK works for all JavaScript environments. You can find\nexamples for server-side (Node, Deno, Bun) and client-side (Vite, Next.js) usage [here](https://github.com/zkemail/sdk-ts-demo).\n\nTo install run:\n\n```bash\nnpm i @zk-email/sdk\n```\n\n## Create a blueprint\n\nGo to our [registry](https://registry.zk.email) and create a blueprint there. You can also create one with the SDK,\nwe will provide the documentation for this shortly.\n\n## Generate a proof\n\nInitialize the SDK:\n\n```ts\nimport zkeSdk from \"@zk-email/sdk\";\nconst sdk = zkSdk();\n```\n\nNext, obtain the slug of the blueprint you want to create a proof for from our [registry](https://registry.zk.email).\n\n![Copy Slug](https://raw.githubusercontent.com/zkemail/zk-email-sdk-js/main/assets/copy_slug.png)\n\nUse the slug to get the blueprint:\n\n```ts\nconst blueprint = await sdk.getBlueprint(\"Bisht13/SuccinctZKResidencyInvite@v2\");\n```\n\nYou can optionally test first if the email can be used with the blueprint.\n\nYou can check out our [Next.js example](https://github.com/zkemail/sdk-ts-demo/tree/main/nextjs) to see how\na user can locally upload an email file.\n\n```ts\nconst isValid = await blueprint.validateEmail(emailStr);\n```\n\nCreate a prover. Here you can define whether the proof should be generated remotely (faster)\nor in the browser (slower but private).\nSet `isLocal` to `true` for proving in the browser.\n\n```ts\nconst prover = blueprint.createProver({ isLocal: true });\n```\n\nNow pass the email as a `string` to the prover to generate a proof.\n\nIf your blueprint requires external inputs, pass them as a second argument.\n\n```ts\n// 2. argument, externalInputs is only required if defined in the blueprint\nconst proof = await prover.generateProof(emailStr, [\n  { name: \"email\", value: \"a@b.de\", maxLength: 50 },\n]);\n\nconsole.log(\"Proof data: \", proof.props.proofData);\nconsole.log(\"Public data: \", proof.props.publicData);\n```\n\n## Verify a proof\n\n### Locally\n\nYou can verify a proof direclty using a instance of Proof.\n`verifyProof` will be true if the proof is valid and false if it is invalid.\n\n```ts\nconst verified = await blueprint.verifyProof(proof);\nconsole.log(\"Proof is valid: \", verified);\n```\n\nIf you only have the proof data, you can verify the proof like this:\n\n```ts\nconst verified = await blueprint.verifyProofData(\n  JSON.stringify(proof.props.publicOutputs),\n  JSON.stringify(proof.props.proofData)\n);\nconsole.log(\"Proof is valid: \", verified);\n```\n\n### On chain\n\nWe currently use a contract deployed to Base Sepolia for this.\n\n```ts\nconst isVerified = await blueprint.verifyProofOnChain(proof);\n```\n\n## Fetch emails with Gmail\n\nYou can use the sdks' `Gmail` utility class to fetch users emails according to the blueprints query.\n\n**NOTE:** This will only work if you approved your domain with us.\n\n```ts\nimport zkeSdk, { Gmail } from \"@zk-email/sdk\";\n\nconst gmail = new Gmail();\nconst sdk = zkeSdk();\n\n// optional - manually start Login with Google flow and authorize before fetching emails\nawait gmail.authorize();\n\n// Will start Login with Google flow if not already autorized\n// Fetches emails using the email queries given in the blueprints\nconst emails = await gmail.fetchEmails([blueprint]);\n\n// Will return an empty array if there are no more emails matching the blueprints query\nconst moreEmails = await gmail.fetchMore();\n\n// You can validate if an email is valid according to a blueprint\nconst isValid = await blueprint.validateEmail(emails[0].decodedContents);\nconsole.log(\"isValid: \", isValid);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzkemail%2Fzk-email-sdk-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzkemail%2Fzk-email-sdk-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzkemail%2Fzk-email-sdk-js/lists"}