@p2pdotme/sdk 1.0.0
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.
- package/README.md +155 -0
- package/dist/fraud-engine.cjs +598 -0
- package/dist/fraud-engine.cjs.map +1 -0
- package/dist/fraud-engine.d.cts +194 -0
- package/dist/fraud-engine.d.ts +194 -0
- package/dist/fraud-engine.mjs +549 -0
- package/dist/fraud-engine.mjs.map +1 -0
- package/dist/index.cjs +75 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +49 -0
- package/dist/index.d.ts +49 -0
- package/dist/index.mjs +46 -0
- package/dist/index.mjs.map +1 -0
- package/dist/order-routing.cjs +882 -0
- package/dist/order-routing.cjs.map +1 -0
- package/dist/order-routing.d.cts +68 -0
- package/dist/order-routing.d.ts +68 -0
- package/dist/order-routing.mjs +854 -0
- package/dist/order-routing.mjs.map +1 -0
- package/dist/payload.cjs +3164 -0
- package/dist/payload.cjs.map +1 -0
- package/dist/payload.d.cts +162 -0
- package/dist/payload.d.ts +162 -0
- package/dist/payload.mjs +3120 -0
- package/dist/payload.mjs.map +1 -0
- package/dist/profile.cjs +695 -0
- package/dist/profile.cjs.map +1 -0
- package/dist/profile.d.cts +133 -0
- package/dist/profile.d.ts +133 -0
- package/dist/profile.mjs +667 -0
- package/dist/profile.mjs.map +1 -0
- package/dist/qr-parsers.cjs +366 -0
- package/dist/qr-parsers.cjs.map +1 -0
- package/dist/qr-parsers.d.cts +41 -0
- package/dist/qr-parsers.d.ts +41 -0
- package/dist/qr-parsers.mjs +338 -0
- package/dist/qr-parsers.mjs.map +1 -0
- package/dist/react.cjs +4803 -0
- package/dist/react.cjs.map +1 -0
- package/dist/react.d.cts +511 -0
- package/dist/react.d.ts +511 -0
- package/dist/react.mjs +4759 -0
- package/dist/react.mjs.map +1 -0
- package/dist/zkkyc.cjs +868 -0
- package/dist/zkkyc.cjs.map +1 -0
- package/dist/zkkyc.d.cts +230 -0
- package/dist/zkkyc.d.ts +230 -0
- package/dist/zkkyc.mjs +824 -0
- package/dist/zkkyc.mjs.map +1 -0
- package/package.json +130 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/zkkyc/index.ts","../src/contracts/reputation-manager/writes.ts","../src/validation/errors.ts","../src/validation/schemas.ts","../src/zkkyc/errors.ts","../src/zkkyc/validation.ts","../src/contracts/abis/index.ts","../src/contracts/abis/order-flow-facet.ts","../src/contracts/abis/p2p-config-facet.ts","../src/contracts/abis/reputation-manager.ts","../src/zkkyc/client.ts","../src/zkkyc/orchestrators/constants.ts","../src/zkkyc/orchestrators/reclaim.ts","../src/zkkyc/orchestrators/types.ts","../src/zkkyc/orchestrators/zk-passport.ts"],"sourcesContent":["export type { Zkkyc } from \"./client\";\nexport { createZkkyc } from \"./client\";\nexport type { ZkkycErrorCode } from \"./errors\";\nexport { ZkkycError } from \"./errors\";\nexport type { ZkkycConfig } from \"./types\";\nexport type {\n\tAnonAadharProofParams,\n\tSocialVerifyParams,\n\tZkPassportRegisterParams,\n} from \"./validation\";\n\n// ── Orchestrators ────────────────────────────────────────────────────────────\n\nexport {\n\tDEFAULT_RECLAIM_PROVIDER_IDS,\n\tRECLAIM_APP_LINKS,\n\tZK_PASSPORT_APP_LINKS,\n} from \"./orchestrators/constants\";\nexport { createReclaimFlow } from \"./orchestrators/reclaim\";\nexport type {\n\tReclaimConfig,\n\tReclaimFlowOptions,\n\tReclaimProofResult,\n\tReclaimStatus,\n\tSocialPlatform,\n\tZkPassportConfig,\n\tZkPassportFlowOptions,\n\tZkPassportProofResult,\n\tZkPassportSession,\n\tZkPassportStatus,\n} from \"./orchestrators/types\";\nexport { SOCIAL_PLATFORM_NAMES } from \"./orchestrators/types\";\nexport { createZkPassportFlow } from \"./orchestrators/zk-passport\";\n","import { Result } from \"neverthrow\";\nimport { type Address, encodeFunctionData } from \"viem\";\nimport { validate } from \"../../validation\";\nimport { ZkkycError } from \"../../zkkyc/errors\";\nimport type {\n\tAnonAadharProofParams,\n\tSocialVerifyParams,\n\tZkPassportRegisterParams,\n} from \"../../zkkyc/validation\";\nimport {\n\tZodAnonAadharProofParamsSchema,\n\tZodSocialVerifyParamsSchema,\n\tZodZkPassportRegisterParamsSchema,\n} from \"../../zkkyc/validation\";\nimport { ABIS } from \"../abis\";\n\n/** Prepares a social verification transaction. */\nexport function prepareSocialVerify(\n\treputationManagerAddress: Address,\n\tparams: SocialVerifyParams,\n): Result<{ to: Address; data: `0x${string}` }, ZkkycError> {\n\treturn validate(\n\t\tZodSocialVerifyParamsSchema,\n\t\tparams,\n\t\t(message, cause, data) =>\n\t\t\tnew ZkkycError(message, { code: \"VALIDATION_ERROR\", cause, context: { params: data } }),\n\t).andThen((validated) =>\n\t\tResult.fromThrowable(\n\t\t\t() => ({\n\t\t\t\tto: reputationManagerAddress,\n\t\t\t\tdata: encodeFunctionData({\n\t\t\t\t\tabi: ABIS.EXTERNAL.REPUTATION_MANAGER,\n\t\t\t\t\tfunctionName: \"socialVerify\",\n\t\t\t\t\targs: [\n\t\t\t\t\t\tvalidated._socialName,\n\t\t\t\t\t\tvalidated.proofs.map((proof) => ({\n\t\t\t\t\t\t\t...proof,\n\t\t\t\t\t\t\tsignedClaim: {\n\t\t\t\t\t\t\t\t...proof.signedClaim,\n\t\t\t\t\t\t\t\tclaim: {\n\t\t\t\t\t\t\t\t\t...proof.signedClaim.claim,\n\t\t\t\t\t\t\t\t\tidentifier: proof.signedClaim.claim.identifier as `0x${string}`,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tsignatures: proof.signedClaim.signatures as readonly `0x${string}`[],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t})),\n\t\t\t\t\t],\n\t\t\t\t}),\n\t\t\t}),\n\t\t\t(error) =>\n\t\t\t\tnew ZkkycError(\"Failed to encode socialVerify\", {\n\t\t\t\t\tcode: \"ENCODE_ERROR\",\n\t\t\t\t\tcause: error,\n\t\t\t\t}),\n\t\t)(),\n\t);\n}\n\n/** Prepares a submit anon Aadhaar proof transaction. */\nexport function prepareSubmitAnonAadharProof(\n\treputationManagerAddress: Address,\n\tparams: AnonAadharProofParams,\n): Result<{ to: Address; data: `0x${string}` }, ZkkycError> {\n\treturn validate(\n\t\tZodAnonAadharProofParamsSchema,\n\t\tparams,\n\t\t(message, cause, data) =>\n\t\t\tnew ZkkycError(message, { code: \"VALIDATION_ERROR\", cause, context: { params: data } }),\n\t).andThen((validated) =>\n\t\tResult.fromThrowable(\n\t\t\t() => ({\n\t\t\t\tto: reputationManagerAddress,\n\t\t\t\tdata: encodeFunctionData({\n\t\t\t\t\tabi: ABIS.EXTERNAL.REPUTATION_MANAGER,\n\t\t\t\t\tfunctionName: \"submitAnonAadharProof\",\n\t\t\t\t\targs: [\n\t\t\t\t\t\tvalidated.nullifierSeed,\n\t\t\t\t\t\tvalidated.nullifier,\n\t\t\t\t\t\tvalidated.timestamp,\n\t\t\t\t\t\tvalidated.signal,\n\t\t\t\t\t\tvalidated.revealArray,\n\t\t\t\t\t\tvalidated.packedGroth16Proof,\n\t\t\t\t\t],\n\t\t\t\t}),\n\t\t\t}),\n\t\t\t(error) =>\n\t\t\t\tnew ZkkycError(\"Failed to encode submitAnonAadharProof\", {\n\t\t\t\t\tcode: \"ENCODE_ERROR\",\n\t\t\t\t\tcause: error,\n\t\t\t\t}),\n\t\t)(),\n\t);\n}\n\n/** Prepares a zkPassport registration transaction. */\nexport function prepareZkPassportRegister(\n\treputationManagerAddress: Address,\n\tparams: ZkPassportRegisterParams,\n): Result<{ to: Address; data: `0x${string}` }, ZkkycError> {\n\treturn validate(\n\t\tZodZkPassportRegisterParamsSchema,\n\t\tparams,\n\t\t(message, cause, data) =>\n\t\t\tnew ZkkycError(message, { code: \"VALIDATION_ERROR\", cause, context: { params: data } }),\n\t).andThen((validated) =>\n\t\tResult.fromThrowable(\n\t\t\t() => {\n\t\t\t\tconst { proofVerificationData, serviceConfig, committedInputs, version } = validated.params;\n\n\t\t\t\tconst proofVerificationParams = {\n\t\t\t\t\tversion: version as `0x${string}`,\n\t\t\t\t\tproofVerificationData: {\n\t\t\t\t\t\tvkeyHash: proofVerificationData.vkeyHash as `0x${string}`,\n\t\t\t\t\t\tproof: proofVerificationData.proof as `0x${string}`,\n\t\t\t\t\t\tpublicInputs: proofVerificationData.publicInputs as `0x${string}`[],\n\t\t\t\t\t},\n\t\t\t\t\tcommittedInputs: committedInputs as `0x${string}`,\n\t\t\t\t\tserviceConfig: {\n\t\t\t\t\t\tvalidityPeriodInSeconds: BigInt(serviceConfig.validityPeriodInSeconds),\n\t\t\t\t\t\tdomain: serviceConfig.domain,\n\t\t\t\t\t\tscope: serviceConfig.scope,\n\t\t\t\t\t\tdevMode: serviceConfig.devMode,\n\t\t\t\t\t},\n\t\t\t\t};\n\n\t\t\t\treturn {\n\t\t\t\t\tto: reputationManagerAddress,\n\t\t\t\t\tdata: encodeFunctionData({\n\t\t\t\t\t\tabi: ABIS.EXTERNAL.REPUTATION_MANAGER,\n\t\t\t\t\t\tfunctionName: \"zkPassportRegister\",\n\t\t\t\t\t\targs: [proofVerificationParams, validated.isIDCard],\n\t\t\t\t\t}),\n\t\t\t\t};\n\t\t\t},\n\t\t\t(error) =>\n\t\t\t\tnew ZkkycError(\"Failed to encode zkPassportRegister\", {\n\t\t\t\t\tcode: \"ENCODE_ERROR\",\n\t\t\t\t\tcause: error,\n\t\t\t\t}),\n\t\t)(),\n\t);\n}\n","export class SdkError<TCode extends string = string> extends Error {\n\treadonly code: TCode;\n\treadonly cause?: unknown;\n\treadonly context?: Record<string, unknown>;\n\n\tconstructor(\n\t\tmessage: string,\n\t\toptions: {\n\t\t\tcode: TCode;\n\t\t\tcause?: unknown;\n\t\t\tcontext?: Record<string, unknown>;\n\t\t},\n\t) {\n\t\tsuper(message);\n\t\tthis.name = \"SdkError\";\n\t\tthis.code = options.code;\n\t\tthis.cause = options.cause;\n\t\tthis.context = options.context;\n\t}\n}\n","import { err, ok, type Result } from \"neverthrow\";\nimport { isAddress } from \"viem\";\nimport { z } from \"zod\";\n\nexport const ZodAddressSchema = z\n\t.string()\n\t.refine((s) => isAddress(s), { message: \"Invalid Ethereum address\" });\n\nexport const ZodCurrencySchema = z.enum([\n\t\"IDR\",\n\t\"INR\",\n\t\"BRL\",\n\t\"ARS\",\n\t\"MEX\",\n\t\"VEN\",\n\t\"EUR\",\n\t\"NGN\",\n\t\"USD\",\n]);\n\nexport type CurrencyType = z.infer<typeof ZodCurrencySchema>;\n\nexport function validate<S extends z.ZodType, E>(\n\tschema: S,\n\tdata: unknown,\n\ttoError: (message: string, cause: unknown, data: unknown) => E,\n): Result<z.infer<S>, E> {\n\tconst result = schema.safeParse(data);\n\tif (result.success) {\n\t\treturn ok(result.data as z.infer<S>);\n\t}\n\treturn err(toError(z.prettifyError(result.error), result.error, data));\n}\n","import { SdkError } from \"../validation\";\n\nexport type ZkkycErrorCode =\n\t| \"VALIDATION_ERROR\"\n\t| \"CONTRACT_READ_ERROR\"\n\t| \"ENCODE_ERROR\"\n\t| \"RECLAIM_INIT_FAILED\"\n\t| \"RECLAIM_SESSION_NOT_FOUND\"\n\t| \"RECLAIM_PROOF_GENERATION_FAILED\"\n\t| \"RECLAIM_PROOF_INVALID\"\n\t| \"RECLAIM_POLLING_ABORTED\"\n\t| \"ZK_PASSPORT_INIT_FAILED\"\n\t| \"ZK_PASSPORT_REJECTED\"\n\t| \"ZK_PASSPORT_VERIFICATION_FAILED\"\n\t| \"ZK_PASSPORT_ABORTED\"\n\t| \"PEER_DEPENDENCY_MISSING\";\n\nexport class ZkkycError extends SdkError<ZkkycErrorCode> {\n\tconstructor(\n\t\tmessage: string,\n\t\toptions: {\n\t\t\tcode: ZkkycErrorCode;\n\t\t\tcause?: unknown;\n\t\t\tcontext?: Record<string, unknown>;\n\t\t},\n\t) {\n\t\tsuper(message, options);\n\t\tthis.name = \"ZkkycError\";\n\t}\n}\n","import { z } from \"zod\";\nimport { ZodAddressSchema } from \"../validation\";\n\n// ── Write param schemas ──────────────────────────────────────────────────────\n\nexport const ZodAnonAadharProofParamsSchema = z.object({\n\tnullifierSeed: z.bigint(),\n\tnullifier: z.bigint(),\n\ttimestamp: z.bigint(),\n\tsignal: z.bigint(),\n\trevealArray: z.tuple([z.bigint(), z.bigint(), z.bigint(), z.bigint()]),\n\tpackedGroth16Proof: z.tuple([\n\t\tz.bigint(),\n\t\tz.bigint(),\n\t\tz.bigint(),\n\t\tz.bigint(),\n\t\tz.bigint(),\n\t\tz.bigint(),\n\t\tz.bigint(),\n\t\tz.bigint(),\n\t]),\n});\n\nexport type AnonAadharProofParams = z.infer<typeof ZodAnonAadharProofParamsSchema>;\n\nexport const ZodSocialVerifyParamsSchema = z.object({\n\t_socialName: z.string(),\n\tproofs: z.array(\n\t\tz.object({\n\t\t\tclaimInfo: z.object({\n\t\t\t\tprovider: z.string(),\n\t\t\t\tparameters: z.string(),\n\t\t\t\tcontext: z.string(),\n\t\t\t}),\n\t\t\tsignedClaim: z.object({\n\t\t\t\tclaim: z.object({\n\t\t\t\t\tidentifier: z.string(),\n\t\t\t\t\towner: ZodAddressSchema,\n\t\t\t\t\ttimestampS: z.number(),\n\t\t\t\t\tepoch: z.number(),\n\t\t\t\t}),\n\t\t\t\tsignatures: z.array(z.string()),\n\t\t\t}),\n\t\t}),\n\t),\n});\n\nexport type SocialVerifyParams = z.infer<typeof ZodSocialVerifyParamsSchema>;\n\n// Schema matching SolidityVerifierParameters from @zkpassport/sdk (structural definition)\nexport const ZodSolidityVerifierParametersSchema = z.object({\n\tversion: z.string().refine((val) => val.startsWith(\"0x\"), {\n\t\tmessage: \"Version must be a hex string\",\n\t}),\n\tproofVerificationData: z.object({\n\t\tvkeyHash: z.string().refine((val) => /^0x[a-fA-F0-9]{64}$/.test(val), {\n\t\t\tmessage: \"Invalid bytes32 hex string\",\n\t\t}),\n\t\tproof: z.string().refine((val) => val.startsWith(\"0x\"), {\n\t\t\tmessage: \"Proof must be a hex string\",\n\t\t}),\n\t\tpublicInputs: z.array(\n\t\t\tz.string().refine((val) => /^0x[a-fA-F0-9]{64}$/.test(val), {\n\t\t\t\tmessage: \"Each public input must be a valid bytes32 hex string\",\n\t\t\t}),\n\t\t),\n\t}),\n\tcommittedInputs: z.string().refine((val) => val.startsWith(\"0x\"), {\n\t\tmessage: \"Committed inputs must be a hex string\",\n\t}),\n\tserviceConfig: z.object({\n\t\tvalidityPeriodInSeconds: z.number().int().nonnegative(),\n\t\tdomain: z.string(),\n\t\tscope: z.string(),\n\t\tdevMode: z.boolean(),\n\t}),\n});\n\nexport type SolidityVerifierParameters = z.infer<typeof ZodSolidityVerifierParametersSchema>;\n\nexport const ZodZkPassportRegisterParamsSchema = z.object({\n\tparams: ZodSolidityVerifierParametersSchema,\n\tisIDCard: z.boolean(),\n});\n\nexport type ZkPassportRegisterParams = z.infer<typeof ZodZkPassportRegisterParamsSchema>;\n","import { erc20Abi } from \"viem\";\nimport { orderFlowFacetAbi } from \"./order-flow-facet\";\nimport { p2pConfigFacetAbi } from \"./p2p-config-facet\";\nimport { reputationManagerAbi } from \"./reputation-manager\";\n\nconst DIAMOND_ABI = [...orderFlowFacetAbi, ...p2pConfigFacetAbi] as const;\n\nexport const ABIS = {\n\tDIAMOND: DIAMOND_ABI,\n\tFACETS: {\n\t\tORDER_FLOW: orderFlowFacetAbi,\n\t\tCONFIG: p2pConfigFacetAbi,\n\t},\n\tEXTERNAL: {\n\t\tUSDC: erc20Abi,\n\t\tREPUTATION_MANAGER: reputationManagerAbi,\n\t},\n} as const;\n","export const orderFlowFacetAbi = [\n\t{\n\t\tinputs: [\n\t\t\t{ internalType: \"uint256\", name: \"circleId\", type: \"uint256\" },\n\t\t\t{ internalType: \"uint256\", name: \"assignUpto\", type: \"uint256\" },\n\t\t\t{ internalType: \"bytes32\", name: \"currency\", type: \"bytes32\" },\n\t\t\t{ internalType: \"address\", name: \"user\", type: \"address\" },\n\t\t\t{ internalType: \"uint256\", name: \"usdtAmount\", type: \"uint256\" },\n\t\t\t{ internalType: \"uint256\", name: \"fiatAmount\", type: \"uint256\" },\n\t\t\t{ internalType: \"int256\", name: \"orderType\", type: \"int256\" },\n\t\t\t{ internalType: \"uint256\", name: \"preferredPCConfigId\", type: \"uint256\" },\n\t\t],\n\t\tname: \"getAssignableMerchantsFromCircle\",\n\t\toutputs: [{ internalType: \"address[]\", name: \"\", type: \"address[]\" }],\n\t\tstateMutability: \"view\",\n\t\ttype: \"function\",\n\t},\n\t{\n\t\tinputs: [\n\t\t\t{ internalType: \"address\", name: \"_user\", type: \"address\" },\n\t\t\t{ internalType: \"bytes32\", name: \"_nativeCurrency\", type: \"bytes32\" },\n\t\t],\n\t\tname: \"userTxLimit\",\n\t\toutputs: [\n\t\t\t{ internalType: \"uint256\", name: \"\", type: \"uint256\" },\n\t\t\t{ internalType: \"uint256\", name: \"\", type: \"uint256\" },\n\t\t],\n\t\tstateMutability: \"view\",\n\t\ttype: \"function\",\n\t},\n] as const;\n","export const p2pConfigFacetAbi = [\n\t{\n\t\tinputs: [\n\t\t\t{\n\t\t\t\tinternalType: \"bytes32\",\n\t\t\t\tname: \"_currency\",\n\t\t\t\ttype: \"bytes32\",\n\t\t\t},\n\t\t],\n\t\tname: \"getPriceConfig\",\n\t\toutputs: [\n\t\t\t{\n\t\t\t\tcomponents: [\n\t\t\t\t\t{\n\t\t\t\t\t\tinternalType: \"uint256\",\n\t\t\t\t\t\tname: \"buyPrice\",\n\t\t\t\t\t\ttype: \"uint256\",\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tinternalType: \"uint256\",\n\t\t\t\t\t\tname: \"sellPrice\",\n\t\t\t\t\t\ttype: \"uint256\",\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tinternalType: \"int256\",\n\t\t\t\t\t\tname: \"buyPriceOffset\",\n\t\t\t\t\t\ttype: \"int256\",\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tinternalType: \"uint256\",\n\t\t\t\t\t\tname: \"baseSpread\",\n\t\t\t\t\t\ttype: \"uint256\",\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tinternalType: \"struct P2pConfigStorage.PriceConfig\",\n\t\t\t\tname: \"\",\n\t\t\t\ttype: \"tuple\",\n\t\t\t},\n\t\t],\n\t\tstateMutability: \"view\",\n\t\ttype: \"function\",\n\t},\n\t{\n\t\tinputs: [\n\t\t\t{\n\t\t\t\tinternalType: \"bytes32\",\n\t\t\t\tname: \"_nativeCurrency\",\n\t\t\t\ttype: \"bytes32\",\n\t\t\t},\n\t\t],\n\t\tname: \"getRpPerUsdtLimitRational\",\n\t\toutputs: [\n\t\t\t{\n\t\t\t\tinternalType: \"uint256\",\n\t\t\t\tname: \"numerator\",\n\t\t\t\ttype: \"uint256\",\n\t\t\t},\n\t\t\t{\n\t\t\t\tinternalType: \"uint256\",\n\t\t\t\tname: \"denominator\",\n\t\t\t\ttype: \"uint256\",\n\t\t\t},\n\t\t],\n\t\tstateMutability: \"view\",\n\t\ttype: \"function\",\n\t},\n] as const;\n","export const reputationManagerAbi = [\n\t{\n\t\tinputs: [\n\t\t\t{\n\t\t\t\tinternalType: \"string\",\n\t\t\t\tname: \"_socialName\",\n\t\t\t\ttype: \"string\",\n\t\t\t},\n\t\t\t{\n\t\t\t\tcomponents: [\n\t\t\t\t\t{\n\t\t\t\t\t\tcomponents: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tinternalType: \"string\",\n\t\t\t\t\t\t\t\tname: \"provider\",\n\t\t\t\t\t\t\t\ttype: \"string\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tinternalType: \"string\",\n\t\t\t\t\t\t\t\tname: \"parameters\",\n\t\t\t\t\t\t\t\ttype: \"string\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tinternalType: \"string\",\n\t\t\t\t\t\t\t\tname: \"context\",\n\t\t\t\t\t\t\t\ttype: \"string\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t\tinternalType: \"struct IReclaimSDK.ClaimInfo\",\n\t\t\t\t\t\tname: \"claimInfo\",\n\t\t\t\t\t\ttype: \"tuple\",\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tcomponents: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tcomponents: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tinternalType: \"bytes32\",\n\t\t\t\t\t\t\t\t\t\tname: \"identifier\",\n\t\t\t\t\t\t\t\t\t\ttype: \"bytes32\",\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tinternalType: \"address\",\n\t\t\t\t\t\t\t\t\t\tname: \"owner\",\n\t\t\t\t\t\t\t\t\t\ttype: \"address\",\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tinternalType: \"uint32\",\n\t\t\t\t\t\t\t\t\t\tname: \"timestampS\",\n\t\t\t\t\t\t\t\t\t\ttype: \"uint32\",\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tinternalType: \"uint32\",\n\t\t\t\t\t\t\t\t\t\tname: \"epoch\",\n\t\t\t\t\t\t\t\t\t\ttype: \"uint32\",\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\tinternalType: \"struct IReclaimSDK.CompleteClaimData\",\n\t\t\t\t\t\t\t\tname: \"claim\",\n\t\t\t\t\t\t\t\ttype: \"tuple\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tinternalType: \"bytes[]\",\n\t\t\t\t\t\t\t\tname: \"signatures\",\n\t\t\t\t\t\t\t\ttype: \"bytes[]\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t\tinternalType: \"struct IReclaimSDK.SignedClaim\",\n\t\t\t\t\t\tname: \"signedClaim\",\n\t\t\t\t\t\ttype: \"tuple\",\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tinternalType: \"struct IReclaimSDK.Proof[]\",\n\t\t\t\tname: \"proofs\",\n\t\t\t\ttype: \"tuple[]\",\n\t\t\t},\n\t\t],\n\t\tname: \"socialVerify\",\n\t\toutputs: [],\n\t\tstateMutability: \"nonpayable\",\n\t\ttype: \"function\",\n\t},\n\t{\n\t\tinputs: [\n\t\t\t{\n\t\t\t\tinternalType: \"uint256\",\n\t\t\t\tname: \"nullifierSeed\",\n\t\t\t\ttype: \"uint256\",\n\t\t\t},\n\t\t\t{\n\t\t\t\tinternalType: \"uint256\",\n\t\t\t\tname: \"nullifier\",\n\t\t\t\ttype: \"uint256\",\n\t\t\t},\n\t\t\t{\n\t\t\t\tinternalType: \"uint256\",\n\t\t\t\tname: \"timestamp\",\n\t\t\t\ttype: \"uint256\",\n\t\t\t},\n\t\t\t{\n\t\t\t\tinternalType: \"uint256\",\n\t\t\t\tname: \"signal\",\n\t\t\t\ttype: \"uint256\",\n\t\t\t},\n\t\t\t{\n\t\t\t\tinternalType: \"uint256[4]\",\n\t\t\t\tname: \"revealArray\",\n\t\t\t\ttype: \"uint256[4]\",\n\t\t\t},\n\t\t\t{\n\t\t\t\tinternalType: \"uint256[8]\",\n\t\t\t\tname: \"groth16Proof\",\n\t\t\t\ttype: \"uint256[8]\",\n\t\t\t},\n\t\t],\n\t\tname: \"submitAnonAadharProof\",\n\t\toutputs: [],\n\t\tstateMutability: \"nonpayable\",\n\t\ttype: \"function\",\n\t},\n\t{\n\t\tinputs: [\n\t\t\t{\n\t\t\t\tcomponents: [\n\t\t\t\t\t{\n\t\t\t\t\t\tinternalType: \"bytes32\",\n\t\t\t\t\t\tname: \"version\",\n\t\t\t\t\t\ttype: \"bytes32\",\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tcomponents: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tinternalType: \"bytes32\",\n\t\t\t\t\t\t\t\tname: \"vkeyHash\",\n\t\t\t\t\t\t\t\ttype: \"bytes32\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tinternalType: \"bytes\",\n\t\t\t\t\t\t\t\tname: \"proof\",\n\t\t\t\t\t\t\t\ttype: \"bytes\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tinternalType: \"bytes32[]\",\n\t\t\t\t\t\t\t\tname: \"publicInputs\",\n\t\t\t\t\t\t\t\ttype: \"bytes32[]\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t\tinternalType: \"struct ProofVerificationData\",\n\t\t\t\t\t\tname: \"proofVerificationData\",\n\t\t\t\t\t\ttype: \"tuple\",\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tinternalType: \"bytes\",\n\t\t\t\t\t\tname: \"committedInputs\",\n\t\t\t\t\t\ttype: \"bytes\",\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tcomponents: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tinternalType: \"uint256\",\n\t\t\t\t\t\t\t\tname: \"validityPeriodInSeconds\",\n\t\t\t\t\t\t\t\ttype: \"uint256\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tinternalType: \"string\",\n\t\t\t\t\t\t\t\tname: \"domain\",\n\t\t\t\t\t\t\t\ttype: \"string\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tinternalType: \"string\",\n\t\t\t\t\t\t\t\tname: \"scope\",\n\t\t\t\t\t\t\t\ttype: \"string\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tinternalType: \"bool\",\n\t\t\t\t\t\t\t\tname: \"devMode\",\n\t\t\t\t\t\t\t\ttype: \"bool\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t\tinternalType: \"struct ServiceConfig\",\n\t\t\t\t\t\tname: \"serviceConfig\",\n\t\t\t\t\t\ttype: \"tuple\",\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tinternalType: \"struct ProofVerificationParams\",\n\t\t\t\tname: \"params\",\n\t\t\t\ttype: \"tuple\",\n\t\t\t},\n\t\t\t{\n\t\t\t\tinternalType: \"bool\",\n\t\t\t\tname: \"isIDCard\",\n\t\t\t\ttype: \"bool\",\n\t\t\t},\n\t\t],\n\t\tname: \"zkPassportRegister\",\n\t\toutputs: [],\n\t\tstateMutability: \"nonpayable\",\n\t\ttype: \"function\",\n\t},\n] as const;\n","import type { Result } from \"neverthrow\";\nimport type { Address } from \"viem\";\nimport {\n\tprepareSocialVerify,\n\tprepareSubmitAnonAadharProof,\n\tprepareZkPassportRegister,\n} from \"../contracts/reputation-manager/writes\";\nimport type { ZkkycError } from \"./errors\";\nimport type { ZkkycConfig } from \"./types\";\nimport type {\n\tAnonAadharProofParams,\n\tSocialVerifyParams,\n\tZkPassportRegisterParams,\n} from \"./validation\";\n\nexport interface Zkkyc {\n\tprepareSocialVerify(\n\t\tparams: SocialVerifyParams,\n\t): Result<{ to: Address; data: `0x${string}` }, ZkkycError>;\n\tprepareSubmitAnonAadharProof(\n\t\tparams: AnonAadharProofParams,\n\t): Result<{ to: Address; data: `0x${string}` }, ZkkycError>;\n\tprepareZkPassportRegister(\n\t\tparams: ZkPassportRegisterParams,\n\t): Result<{ to: Address; data: `0x${string}` }, ZkkycError>;\n}\n\n/**\n * Creates a Zkkyc client that binds a reputation manager address,\n * exposing write-preparation methods for social verify, Aadhaar, and ZK Passport.\n */\nexport function createZkkyc(config: ZkkycConfig): Zkkyc {\n\tconst { reputationManagerAddress } = config;\n\treturn {\n\t\tprepareSocialVerify: (params) => prepareSocialVerify(reputationManagerAddress, params),\n\t\tprepareSubmitAnonAadharProof: (params) =>\n\t\t\tprepareSubmitAnonAadharProof(reputationManagerAddress, params),\n\t\tprepareZkPassportRegister: (params) =>\n\t\t\tprepareZkPassportRegister(reputationManagerAddress, params),\n\t};\n}\n","import type { SocialPlatform } from \"./types\";\n\n/** Default Reclaim provider IDs for each social platform. */\nexport const DEFAULT_RECLAIM_PROVIDER_IDS: Record<SocialPlatform, string> = {\n\tlinkedin: \"6a86edbe-a0fe-420b-8db2-3155220cc949\",\n\tgithub: \"033f0c06-2eb3-48c8-894c-5599c3356d1c\",\n\tx: \"aad95818-f726-4a34-be97-8d1f47631b03\",\n\tinstagram: \"7e5b59a9-56c5-490c-a169-82a443f9b507\",\n\tfacebook: \"2701510b-c835-4820-84f0-d9e74569656b\",\n};\n\n/** ZK Passport app store links. */\nexport const ZK_PASSPORT_APP_LINKS = {\n\tIOS: \"https://apps.apple.com/us/app/zkpassport/id6477371975\",\n\tANDROID: \"https://play.google.com/store/apps/details?id=app.zkpassport.zkpassport\",\n} as const;\n\n/** Reclaim Protocol app store links. */\nexport const RECLAIM_APP_LINKS = {\n\tANDROID: \"https://play.google.com/store/apps/details?id=org.reclaimprotocol.app\",\n} as const;\n","import { ResultAsync } from \"neverthrow\";\nimport { ZkkycError } from \"../errors\";\nimport type { ReclaimConfig, ReclaimFlowOptions, ReclaimProofResult } from \"./types\";\nimport { SOCIAL_PLATFORM_NAMES } from \"./types\";\n\nconst RECLAIM_SESSION_API = \"https://api.reclaimprotocol.org/api/sdk/session\";\n\n/** Runs the Reclaim social verification flow and returns proof data for on-chain submission. */\nexport function createReclaimFlow(\n\tconfig: ReclaimConfig,\n\toptions: ReclaimFlowOptions,\n): ResultAsync<ReclaimProofResult, ZkkycError> {\n\treturn ResultAsync.fromPromise(\n\t\t(async () => {\n\t\t\t// biome-ignore lint/suspicious/noExplicitAny: optional peer dependency\n\t\t\tconst mod: any = await import(\"@reclaimprotocol/js-sdk\").catch(() => {\n\t\t\t\tthrow new ZkkycError(\n\t\t\t\t\t\"Missing peer dependency: @reclaimprotocol/js-sdk. Install it with: npm install @reclaimprotocol/js-sdk\",\n\t\t\t\t\t{ code: \"PEER_DEPENDENCY_MISSING\" },\n\t\t\t\t);\n\t\t\t});\n\t\t\tconst { ReclaimProofRequest, transformForOnchain } = mod;\n\n\t\t\tconst {\n\t\t\t\tplatform,\n\t\t\t\twalletAddress,\n\t\t\t\tredirectUrl,\n\t\t\t\tsessionId: existingSessionId,\n\t\t\t\tcontextDescription,\n\t\t\t\tonStatus,\n\t\t\t\tsignal,\n\t\t\t\tpollingIntervalMs = 5000,\n\t\t\t} = options;\n\n\t\t\tconst socialName = SOCIAL_PLATFORM_NAMES[platform];\n\t\t\tconst providerId = config.providerIds[platform];\n\n\t\t\tlet sessionId: string;\n\n\t\t\tif (existingSessionId) {\n\t\t\t\tsessionId = existingSessionId;\n\t\t\t} else {\n\t\t\t\tconst reclaimProofRequest = await ReclaimProofRequest.init(\n\t\t\t\t\tconfig.appId,\n\t\t\t\t\tconfig.appSecret,\n\t\t\t\t\tproviderId,\n\t\t\t\t\t{ launchOptions: { canUseDeferredDeepLinksFlow: true } },\n\t\t\t\t);\n\n\t\t\t\tconst statusUrl = reclaimProofRequest.getStatusUrl();\n\t\t\t\tsessionId = statusUrl.split(\"/\").pop() || \"\";\n\n\t\t\t\tif (redirectUrl) {\n\t\t\t\t\tconst separator = redirectUrl.includes(\"?\") ? \"&\" : \"?\";\n\t\t\t\t\treclaimProofRequest.setRedirectUrl(\n\t\t\t\t\t\t`${redirectUrl}${separator}sessionId=${sessionId}&socialPlatform=${socialName}`,\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\treclaimProofRequest.addContext(\n\t\t\t\t\twalletAddress,\n\t\t\t\t\tcontextDescription ?? `Social verification for ${socialName}`,\n\t\t\t\t);\n\n\t\t\t\tconst requestUrl = await reclaimProofRequest.getRequestUrl();\n\n\t\t\t\tonStatus?.({ type: \"session_created\", sessionId, requestUrl });\n\n\t\t\t\tif (typeof window !== \"undefined\") {\n\t\t\t\t\treclaimProofRequest.triggerReclaimFlow();\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tonStatus?.({ type: \"polling_started\", sessionId });\n\n\t\t\twhile (true) {\n\t\t\t\tif (signal?.aborted) {\n\t\t\t\t\tthrow new ZkkycError(\"Reclaim polling aborted\", {\n\t\t\t\t\t\tcode: \"RECLAIM_POLLING_ABORTED\",\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tconst response = await fetch(`${RECLAIM_SESSION_API}/${sessionId}`);\n\t\t\t\tconst data = await response.json();\n\n\t\t\t\tif (data?.session?.proofs?.length > 0) {\n\t\t\t\t\tconst proofs = data.session.proofs;\n\t\t\t\t\tonStatus?.({ type: \"proof_received\" });\n\n\t\t\t\t\tif (platform === \"github\" && proofs.length > 0) {\n\t\t\t\t\t\tconst first = proofs[0] as { publicData?: Record<string, unknown> };\n\t\t\t\t\t\tif (first?.publicData && Object.keys(first.publicData).length === 0) {\n\t\t\t\t\t\t\tthrow new ZkkycError(\"GitHub verification eligibility criteria not met\", {\n\t\t\t\t\t\t\t\tcode: \"RECLAIM_PROOF_INVALID\",\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tconst transformedProofs = proofs.map((proof: unknown) => transformForOnchain(proof));\n\n\t\t\t\t\tonStatus?.({ type: \"proof_transformed\" });\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\t_socialName: socialName,\n\t\t\t\t\t\tproofs: transformedProofs,\n\t\t\t\t\t\tsessionId,\n\t\t\t\t\t} as ReclaimProofResult;\n\t\t\t\t}\n\n\t\t\t\tif (data?.message?.includes(\"Session not found\")) {\n\t\t\t\t\tthrow new ZkkycError(\"Reclaim session not found\", {\n\t\t\t\t\t\tcode: \"RECLAIM_SESSION_NOT_FOUND\",\n\t\t\t\t\t\tcontext: { sessionId },\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tif (data?.session?.statusV2 === \"PROOF_GENERATION_FAILED\") {\n\t\t\t\t\tthrow new ZkkycError(\"Reclaim proof generation failed\", {\n\t\t\t\t\t\tcode: \"RECLAIM_PROOF_GENERATION_FAILED\",\n\t\t\t\t\t\tcontext: { sessionId },\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tawait new Promise((resolve) => setTimeout(resolve, pollingIntervalMs));\n\t\t\t}\n\t\t})(),\n\t\t(error) => {\n\t\t\tif (error instanceof ZkkycError) return error;\n\t\t\treturn new ZkkycError(\"Reclaim verification flow failed\", {\n\t\t\t\tcode: \"RECLAIM_INIT_FAILED\",\n\t\t\t\tcause: error,\n\t\t\t});\n\t\t},\n\t);\n}\n","import type { ResultAsync } from \"neverthrow\";\nimport type { Address } from \"viem\";\nimport type { ZkkycError } from \"../errors\";\nimport type { SolidityVerifierParameters } from \"../validation\";\n\n// ── Social Platform ──────────────────────────────────────────────────────────\n\nexport type SocialPlatform = \"linkedin\" | \"github\" | \"x\" | \"instagram\" | \"facebook\";\n\n/** Maps SocialPlatform to the capitalized name the contract expects for _socialName. */\nexport const SOCIAL_PLATFORM_NAMES: Record<SocialPlatform, string> = {\n\tlinkedin: \"LinkedIn\",\n\tgithub: \"GitHub\",\n\tx: \"X\",\n\tinstagram: \"Instagram\",\n\tfacebook: \"Facebook\",\n};\n\n// ── Reclaim (Social Verification) ────────────────────────────────────────────\n\nexport interface ReclaimConfig {\n\treadonly appId: string;\n\treadonly appSecret: string;\n\treadonly providerIds: Record<SocialPlatform, string>;\n}\n\nexport interface ReclaimFlowOptions {\n\treadonly platform: SocialPlatform;\n\treadonly walletAddress: Address;\n\t/** Base URL for redirect after Reclaim flow. SDK appends ?sessionId={id}&socialPlatform={Name}. */\n\treadonly redirectUrl?: string;\n\t/** Resume polling for an existing session (redirect-back case). */\n\treadonly sessionId?: string;\n\t/** Description added to Reclaim context. */\n\treadonly contextDescription?: string;\n\t/** Called with status updates during the flow. */\n\treadonly onStatus?: (status: ReclaimStatus) => void;\n\t/** AbortSignal to cancel polling. */\n\treadonly signal?: AbortSignal;\n\t/** Polling interval in ms. Defaults to 5000. */\n\treadonly pollingIntervalMs?: number;\n}\n\nexport type ReclaimStatus =\n\t| { type: \"session_created\"; sessionId: string; requestUrl: string }\n\t| { type: \"polling_started\"; sessionId: string }\n\t| { type: \"proof_received\" }\n\t| { type: \"proof_transformed\" };\n\nexport interface ReclaimProofResult {\n\treadonly _socialName: string;\n\treadonly proofs: readonly {\n\t\tclaimInfo: { provider: string; parameters: string; context: string };\n\t\tsignedClaim: {\n\t\t\tclaim: { identifier: string; owner: string; timestampS: number; epoch: number };\n\t\t\tsignatures: string[];\n\t\t};\n\t}[];\n\treadonly sessionId: string;\n}\n\n// ── ZK Passport ──────────────────────────────────────────────────────────────\n\nexport interface ZkPassportConfig {\n\t/** Domain for ZKPassport initialization. Defaults to \"app.p2p.me\". */\n\treadonly domain?: string;\n\t/** App name shown in ZKPassport UI. Defaults to \"ZKPassport\". */\n\treadonly name?: string;\n\t/** Logo URL shown in ZKPassport UI. */\n\treadonly logo?: string;\n\t/** Purpose text shown in ZKPassport UI. Defaults to \"Prove your personhood\". */\n\treadonly purpose?: string;\n}\n\nexport interface ZkPassportFlowOptions {\n\treadonly walletAddress: Address;\n\t/** Called with status updates during the flow. */\n\treadonly onStatus?: (status: ZkPassportStatus) => void;\n}\n\nexport type ZkPassportStatus =\n\t| { type: \"request_created\"; url: string }\n\t| { type: \"request_received\" }\n\t| { type: \"generating_proof\" }\n\t| { type: \"proof_generated\" }\n\t| { type: \"result_received\" }\n\t| { type: \"rejected\" };\n\nexport interface ZkPassportProofResult {\n\treadonly params: SolidityVerifierParameters;\n\treadonly isIDCard: boolean;\n}\n\nexport interface ZkPassportSession {\n\t/** URL to display as QR code or open as deeplink. */\n\treadonly url: string;\n\t/** Resolves when the full flow completes (proof verified). */\n\treadonly result: ResultAsync<ZkPassportProofResult, ZkkycError>;\n\t/** Aborts the flow. The result promise will reject with ZK_PASSPORT_ABORTED. */\n\treadonly abort: () => void;\n}\n","import { ResultAsync } from \"neverthrow\";\nimport { ZkkycError } from \"../errors\";\nimport type {\n\tZkPassportConfig,\n\tZkPassportFlowOptions,\n\tZkPassportProofResult,\n\tZkPassportSession,\n} from \"./types\";\n\n/** Initializes a ZK Passport verification flow and returns a session. */\nexport function createZkPassportFlow(\n\tconfig: ZkPassportConfig,\n\toptions: ZkPassportFlowOptions,\n): ResultAsync<ZkPassportSession, ZkkycError> {\n\treturn ResultAsync.fromPromise(\n\t\t(async () => {\n\t\t\t// biome-ignore lint/suspicious/noExplicitAny: optional peer dependency\n\t\t\tconst mod: any = await import(\"@zkpassport/sdk\").catch(() => {\n\t\t\t\tthrow new ZkkycError(\n\t\t\t\t\t\"Missing peer dependency: @zkpassport/sdk. Install it with: npm install @zkpassport/sdk\",\n\t\t\t\t\t{ code: \"PEER_DEPENDENCY_MISSING\" },\n\t\t\t\t);\n\t\t\t});\n\t\t\tconst { ZKPassport } = mod;\n\n\t\t\tconst zkPassport = new ZKPassport(config.domain ?? \"app.p2p.me\");\n\n\t\t\tconst queryBuilder = await zkPassport.request({\n\t\t\t\tname: config.name ?? \"ZKPassport\",\n\t\t\t\tlogo: config.logo ?? \"https://app.p2p.lol/favicon.svg\",\n\t\t\t\tpurpose: config.purpose ?? \"Prove your personhood\",\n\t\t\t\tscope: \"personhood\",\n\t\t\t\tmode: \"compressed-evm\",\n\t\t\t});\n\n\t\t\tconst {\n\t\t\t\turl,\n\t\t\t\tonRequestReceived,\n\t\t\t\tonGeneratingProof,\n\t\t\t\tonProofGenerated,\n\t\t\t\tonResult,\n\t\t\t\tonReject,\n\t\t\t\tonError,\n\t\t\t} = queryBuilder\n\t\t\t\t.gte(\"age\", 18)\n\t\t\t\t.disclose(\"document_type\")\n\t\t\t\t.disclose(\"nationality\")\n\t\t\t\t.bind(\"user_address\", options.walletAddress)\n\t\t\t\t.done();\n\n\t\t\toptions.onStatus?.({ type: \"request_created\", url });\n\n\t\t\tlet aborted = false;\n\n\t\t\tconst resultPromise = new Promise<ZkPassportProofResult>((resolve, reject) => {\n\t\t\t\tlet proof: unknown = null;\n\n\t\t\t\tonRequestReceived(() => {\n\t\t\t\t\tif (aborted) return;\n\t\t\t\t\toptions.onStatus?.({ type: \"request_received\" });\n\t\t\t\t});\n\n\t\t\t\tonGeneratingProof(() => {\n\t\t\t\t\tif (aborted) return;\n\t\t\t\t\toptions.onStatus?.({ type: \"generating_proof\" });\n\t\t\t\t});\n\n\t\t\t\tonProofGenerated(async (result: unknown) => {\n\t\t\t\t\tif (aborted) return;\n\t\t\t\t\toptions.onStatus?.({ type: \"proof_generated\" });\n\t\t\t\t\tproof = result;\n\t\t\t\t});\n\n\t\t\t\tonResult(\n\t\t\t\t\tasync ({\n\t\t\t\t\t\tresult,\n\t\t\t\t\t\tuniqueIdentifier,\n\t\t\t\t\t\tverified,\n\t\t\t\t\t}: {\n\t\t\t\t\t\tresult: Record<string, { disclose?: { result?: string } }>;\n\t\t\t\t\t\tuniqueIdentifier: string | null;\n\t\t\t\t\t\tverified: boolean;\n\t\t\t\t\t}) => {\n\t\t\t\t\t\tif (aborted) return;\n\t\t\t\t\t\toptions.onStatus?.({ type: \"result_received\" });\n\n\t\t\t\t\t\tif (!verified || !proof || !uniqueIdentifier) {\n\t\t\t\t\t\t\treject(\n\t\t\t\t\t\t\t\tnew ZkkycError(\"ZK Passport verification failed\", {\n\t\t\t\t\t\t\t\t\tcode: \"ZK_PASSPORT_VERIFICATION_FAILED\",\n\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tconst verifierParams = zkPassport.getSolidityVerifierParameters({\n\t\t\t\t\t\t\t\tproof,\n\t\t\t\t\t\t\t\tscope: \"personhood\",\n\t\t\t\t\t\t\t\tdevMode: false,\n\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\tconst isIDCard = result.document_type?.disclose?.result !== \"passport\";\n\n\t\t\t\t\t\t\tresolve({ params: verifierParams, isIDCard });\n\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\treject(\n\t\t\t\t\t\t\t\tnew ZkkycError(\"Failed to extract ZK Passport verifier parameters\", {\n\t\t\t\t\t\t\t\t\tcode: \"ZK_PASSPORT_VERIFICATION_FAILED\",\n\t\t\t\t\t\t\t\t\tcause: error,\n\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t);\n\n\t\t\t\tonReject(() => {\n\t\t\t\t\toptions.onStatus?.({ type: \"rejected\" });\n\t\t\t\t\treject(\n\t\t\t\t\t\tnew ZkkycError(\"User rejected ZK Passport verification\", {\n\t\t\t\t\t\t\tcode: \"ZK_PASSPORT_REJECTED\",\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\t\t\t});\n\n\t\t\t\tonError((error: unknown) => {\n\t\t\t\t\treject(\n\t\t\t\t\t\tnew ZkkycError(typeof error === \"string\" ? error : \"ZK Passport verification error\", {\n\t\t\t\t\t\t\tcode: \"ZK_PASSPORT_VERIFICATION_FAILED\",\n\t\t\t\t\t\t\tcause: error,\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\t\t\t});\n\t\t\t});\n\n\t\t\tconst session: ZkPassportSession = {\n\t\t\t\turl,\n\t\t\t\tresult: ResultAsync.fromPromise(resultPromise, (error) => {\n\t\t\t\t\tif (error instanceof ZkkycError) return error;\n\t\t\t\t\treturn new ZkkycError(\"ZK Passport flow failed\", {\n\t\t\t\t\t\tcode: \"ZK_PASSPORT_VERIFICATION_FAILED\",\n\t\t\t\t\t\tcause: error,\n\t\t\t\t\t});\n\t\t\t\t}),\n\t\t\t\tabort: () => {\n\t\t\t\t\taborted = true;\n\t\t\t\t},\n\t\t\t};\n\n\t\t\treturn session;\n\t\t})(),\n\t\t(error) => {\n\t\t\tif (error instanceof ZkkycError) return error;\n\t\t\treturn new ZkkycError(\"Failed to initialize ZK Passport\", {\n\t\t\t\tcode: \"ZK_PASSPORT_INIT_FAILED\",\n\t\t\t\tcause: error,\n\t\t\t});\n\t\t},\n\t);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,qBAAuB;AACvB,IAAAC,eAAiD;;;ACD1C,IAAM,WAAN,cAAsD,MAAM;AAAA,EACzD;AAAA,EACA;AAAA,EACA;AAAA,EAET,YACC,SACA,SAKC;AACD,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,OAAO,QAAQ;AACpB,SAAK,QAAQ,QAAQ;AACrB,SAAK,UAAU,QAAQ;AAAA,EACxB;AACD;;;ACnBA,wBAAqC;AACrC,kBAA0B;AAC1B,iBAAkB;AAEX,IAAM,mBAAmB,aAC9B,OAAO,EACP,OAAO,CAAC,UAAM,uBAAU,CAAC,GAAG,EAAE,SAAS,2BAA2B,CAAC;AAE9D,IAAM,oBAAoB,aAAE,KAAK;AAAA,EACvC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,CAAC;AAIM,SAAS,SACf,QACA,MACA,SACwB;AACxB,QAAM,SAAS,OAAO,UAAU,IAAI;AACpC,MAAI,OAAO,SAAS;AACnB,eAAO,sBAAG,OAAO,IAAkB;AAAA,EACpC;AACA,aAAO,uBAAI,QAAQ,aAAE,cAAc,OAAO,KAAK,GAAG,OAAO,OAAO,IAAI,CAAC;AACtE;;;ACfO,IAAM,aAAN,cAAyB,SAAyB;AAAA,EACxD,YACC,SACA,SAKC;AACD,UAAM,SAAS,OAAO;AACtB,SAAK,OAAO;AAAA,EACb;AACD;;;AC7BA,IAAAC,cAAkB;AAKX,I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gBAAQ,CAAC,UAAmB;AAC3B;AAAA,YACC,IAAI,WAAW,OAAO,UAAU,WAAW,QAAQ,kCAAkC;AAAA,cACpF,MAAM;AAAA,cACN,OAAO;AAAA,YACR,CAAC;AAAA,UACF;AAAA,QACD,CAAC;AAAA,MACF,CAAC;AAED,YAAM,UAA6B;AAAA,QAClC;AAAA,QACA,QAAQ,+BAAY,YAAY,eAAe,CAAC,UAAU;AACzD,cAAI,iBAAiB,WAAY,QAAO;AACxC,iBAAO,IAAI,WAAW,2BAA2B;AAAA,YAChD,MAAM;AAAA,YACN,OAAO;AAAA,UACR,CAAC;AAAA,QACF,CAAC;AAAA,QACD,OAAO,MAAM;AACZ,oBAAU;AAAA,QACX;AAAA,MACD;AAEA,aAAO;AAAA,IACR,GAAG;AAAA,IACH,CAAC,UAAU;AACV,UAAI,iBAAiB,WAAY,QAAO;AACxC,aAAO,IAAI,WAAW,oCAAoC;AAAA,QACzD,MAAM;AAAA,QACN,OAAO;AAAA,MACR,CAAC;AAAA,IACF;AAAA,EACD;AACD;","names":["import_neverthrow","import_viem","import_zod","import_viem","import_neverthrow","import_neverthrow"]}
|
package/dist/zkkyc.d.cts
ADDED
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
import { Result, ResultAsync } from 'neverthrow';
|
|
2
|
+
import { Address } from 'viem';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
|
|
5
|
+
declare class SdkError<TCode extends string = string> extends Error {
|
|
6
|
+
readonly code: TCode;
|
|
7
|
+
readonly cause?: unknown;
|
|
8
|
+
readonly context?: Record<string, unknown>;
|
|
9
|
+
constructor(message: string, options: {
|
|
10
|
+
code: TCode;
|
|
11
|
+
cause?: unknown;
|
|
12
|
+
context?: Record<string, unknown>;
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
type ZkkycErrorCode = "VALIDATION_ERROR" | "CONTRACT_READ_ERROR" | "ENCODE_ERROR" | "RECLAIM_INIT_FAILED" | "RECLAIM_SESSION_NOT_FOUND" | "RECLAIM_PROOF_GENERATION_FAILED" | "RECLAIM_PROOF_INVALID" | "RECLAIM_POLLING_ABORTED" | "ZK_PASSPORT_INIT_FAILED" | "ZK_PASSPORT_REJECTED" | "ZK_PASSPORT_VERIFICATION_FAILED" | "ZK_PASSPORT_ABORTED" | "PEER_DEPENDENCY_MISSING";
|
|
17
|
+
declare class ZkkycError extends SdkError<ZkkycErrorCode> {
|
|
18
|
+
constructor(message: string, options: {
|
|
19
|
+
code: ZkkycErrorCode;
|
|
20
|
+
cause?: unknown;
|
|
21
|
+
context?: Record<string, unknown>;
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
interface ZkkycConfig {
|
|
26
|
+
readonly reputationManagerAddress: Address;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
declare const ZodAnonAadharProofParamsSchema: z.ZodObject<{
|
|
30
|
+
nullifierSeed: z.ZodBigInt;
|
|
31
|
+
nullifier: z.ZodBigInt;
|
|
32
|
+
timestamp: z.ZodBigInt;
|
|
33
|
+
signal: z.ZodBigInt;
|
|
34
|
+
revealArray: z.ZodTuple<[z.ZodBigInt, z.ZodBigInt, z.ZodBigInt, z.ZodBigInt], null>;
|
|
35
|
+
packedGroth16Proof: z.ZodTuple<[z.ZodBigInt, z.ZodBigInt, z.ZodBigInt, z.ZodBigInt, z.ZodBigInt, z.ZodBigInt, z.ZodBigInt, z.ZodBigInt], null>;
|
|
36
|
+
}, z.core.$strip>;
|
|
37
|
+
type AnonAadharProofParams = z.infer<typeof ZodAnonAadharProofParamsSchema>;
|
|
38
|
+
declare const ZodSocialVerifyParamsSchema: z.ZodObject<{
|
|
39
|
+
_socialName: z.ZodString;
|
|
40
|
+
proofs: z.ZodArray<z.ZodObject<{
|
|
41
|
+
claimInfo: z.ZodObject<{
|
|
42
|
+
provider: z.ZodString;
|
|
43
|
+
parameters: z.ZodString;
|
|
44
|
+
context: z.ZodString;
|
|
45
|
+
}, z.core.$strip>;
|
|
46
|
+
signedClaim: z.ZodObject<{
|
|
47
|
+
claim: z.ZodObject<{
|
|
48
|
+
identifier: z.ZodString;
|
|
49
|
+
owner: z.ZodString & z.ZodType<`0x${string}`, string, z.core.$ZodTypeInternals<`0x${string}`, string>>;
|
|
50
|
+
timestampS: z.ZodNumber;
|
|
51
|
+
epoch: z.ZodNumber;
|
|
52
|
+
}, z.core.$strip>;
|
|
53
|
+
signatures: z.ZodArray<z.ZodString>;
|
|
54
|
+
}, z.core.$strip>;
|
|
55
|
+
}, z.core.$strip>>;
|
|
56
|
+
}, z.core.$strip>;
|
|
57
|
+
type SocialVerifyParams = z.infer<typeof ZodSocialVerifyParamsSchema>;
|
|
58
|
+
declare const ZodSolidityVerifierParametersSchema: z.ZodObject<{
|
|
59
|
+
version: z.ZodString;
|
|
60
|
+
proofVerificationData: z.ZodObject<{
|
|
61
|
+
vkeyHash: z.ZodString;
|
|
62
|
+
proof: z.ZodString;
|
|
63
|
+
publicInputs: z.ZodArray<z.ZodString>;
|
|
64
|
+
}, z.core.$strip>;
|
|
65
|
+
committedInputs: z.ZodString;
|
|
66
|
+
serviceConfig: z.ZodObject<{
|
|
67
|
+
validityPeriodInSeconds: z.ZodNumber;
|
|
68
|
+
domain: z.ZodString;
|
|
69
|
+
scope: z.ZodString;
|
|
70
|
+
devMode: z.ZodBoolean;
|
|
71
|
+
}, z.core.$strip>;
|
|
72
|
+
}, z.core.$strip>;
|
|
73
|
+
type SolidityVerifierParameters = z.infer<typeof ZodSolidityVerifierParametersSchema>;
|
|
74
|
+
declare const ZodZkPassportRegisterParamsSchema: z.ZodObject<{
|
|
75
|
+
params: z.ZodObject<{
|
|
76
|
+
version: z.ZodString;
|
|
77
|
+
proofVerificationData: z.ZodObject<{
|
|
78
|
+
vkeyHash: z.ZodString;
|
|
79
|
+
proof: z.ZodString;
|
|
80
|
+
publicInputs: z.ZodArray<z.ZodString>;
|
|
81
|
+
}, z.core.$strip>;
|
|
82
|
+
committedInputs: z.ZodString;
|
|
83
|
+
serviceConfig: z.ZodObject<{
|
|
84
|
+
validityPeriodInSeconds: z.ZodNumber;
|
|
85
|
+
domain: z.ZodString;
|
|
86
|
+
scope: z.ZodString;
|
|
87
|
+
devMode: z.ZodBoolean;
|
|
88
|
+
}, z.core.$strip>;
|
|
89
|
+
}, z.core.$strip>;
|
|
90
|
+
isIDCard: z.ZodBoolean;
|
|
91
|
+
}, z.core.$strip>;
|
|
92
|
+
type ZkPassportRegisterParams = z.infer<typeof ZodZkPassportRegisterParamsSchema>;
|
|
93
|
+
|
|
94
|
+
interface Zkkyc {
|
|
95
|
+
prepareSocialVerify(params: SocialVerifyParams): Result<{
|
|
96
|
+
to: Address;
|
|
97
|
+
data: `0x${string}`;
|
|
98
|
+
}, ZkkycError>;
|
|
99
|
+
prepareSubmitAnonAadharProof(params: AnonAadharProofParams): Result<{
|
|
100
|
+
to: Address;
|
|
101
|
+
data: `0x${string}`;
|
|
102
|
+
}, ZkkycError>;
|
|
103
|
+
prepareZkPassportRegister(params: ZkPassportRegisterParams): Result<{
|
|
104
|
+
to: Address;
|
|
105
|
+
data: `0x${string}`;
|
|
106
|
+
}, ZkkycError>;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Creates a Zkkyc client that binds a reputation manager address,
|
|
110
|
+
* exposing write-preparation methods for social verify, Aadhaar, and ZK Passport.
|
|
111
|
+
*/
|
|
112
|
+
declare function createZkkyc(config: ZkkycConfig): Zkkyc;
|
|
113
|
+
|
|
114
|
+
type SocialPlatform = "linkedin" | "github" | "x" | "instagram" | "facebook";
|
|
115
|
+
/** Maps SocialPlatform to the capitalized name the contract expects for _socialName. */
|
|
116
|
+
declare const SOCIAL_PLATFORM_NAMES: Record<SocialPlatform, string>;
|
|
117
|
+
interface ReclaimConfig {
|
|
118
|
+
readonly appId: string;
|
|
119
|
+
readonly appSecret: string;
|
|
120
|
+
readonly providerIds: Record<SocialPlatform, string>;
|
|
121
|
+
}
|
|
122
|
+
interface ReclaimFlowOptions {
|
|
123
|
+
readonly platform: SocialPlatform;
|
|
124
|
+
readonly walletAddress: Address;
|
|
125
|
+
/** Base URL for redirect after Reclaim flow. SDK appends ?sessionId={id}&socialPlatform={Name}. */
|
|
126
|
+
readonly redirectUrl?: string;
|
|
127
|
+
/** Resume polling for an existing session (redirect-back case). */
|
|
128
|
+
readonly sessionId?: string;
|
|
129
|
+
/** Description added to Reclaim context. */
|
|
130
|
+
readonly contextDescription?: string;
|
|
131
|
+
/** Called with status updates during the flow. */
|
|
132
|
+
readonly onStatus?: (status: ReclaimStatus) => void;
|
|
133
|
+
/** AbortSignal to cancel polling. */
|
|
134
|
+
readonly signal?: AbortSignal;
|
|
135
|
+
/** Polling interval in ms. Defaults to 5000. */
|
|
136
|
+
readonly pollingIntervalMs?: number;
|
|
137
|
+
}
|
|
138
|
+
type ReclaimStatus = {
|
|
139
|
+
type: "session_created";
|
|
140
|
+
sessionId: string;
|
|
141
|
+
requestUrl: string;
|
|
142
|
+
} | {
|
|
143
|
+
type: "polling_started";
|
|
144
|
+
sessionId: string;
|
|
145
|
+
} | {
|
|
146
|
+
type: "proof_received";
|
|
147
|
+
} | {
|
|
148
|
+
type: "proof_transformed";
|
|
149
|
+
};
|
|
150
|
+
interface ReclaimProofResult {
|
|
151
|
+
readonly _socialName: string;
|
|
152
|
+
readonly proofs: readonly {
|
|
153
|
+
claimInfo: {
|
|
154
|
+
provider: string;
|
|
155
|
+
parameters: string;
|
|
156
|
+
context: string;
|
|
157
|
+
};
|
|
158
|
+
signedClaim: {
|
|
159
|
+
claim: {
|
|
160
|
+
identifier: string;
|
|
161
|
+
owner: string;
|
|
162
|
+
timestampS: number;
|
|
163
|
+
epoch: number;
|
|
164
|
+
};
|
|
165
|
+
signatures: string[];
|
|
166
|
+
};
|
|
167
|
+
}[];
|
|
168
|
+
readonly sessionId: string;
|
|
169
|
+
}
|
|
170
|
+
interface ZkPassportConfig {
|
|
171
|
+
/** Domain for ZKPassport initialization. Defaults to "app.p2p.me". */
|
|
172
|
+
readonly domain?: string;
|
|
173
|
+
/** App name shown in ZKPassport UI. Defaults to "ZKPassport". */
|
|
174
|
+
readonly name?: string;
|
|
175
|
+
/** Logo URL shown in ZKPassport UI. */
|
|
176
|
+
readonly logo?: string;
|
|
177
|
+
/** Purpose text shown in ZKPassport UI. Defaults to "Prove your personhood". */
|
|
178
|
+
readonly purpose?: string;
|
|
179
|
+
}
|
|
180
|
+
interface ZkPassportFlowOptions {
|
|
181
|
+
readonly walletAddress: Address;
|
|
182
|
+
/** Called with status updates during the flow. */
|
|
183
|
+
readonly onStatus?: (status: ZkPassportStatus) => void;
|
|
184
|
+
}
|
|
185
|
+
type ZkPassportStatus = {
|
|
186
|
+
type: "request_created";
|
|
187
|
+
url: string;
|
|
188
|
+
} | {
|
|
189
|
+
type: "request_received";
|
|
190
|
+
} | {
|
|
191
|
+
type: "generating_proof";
|
|
192
|
+
} | {
|
|
193
|
+
type: "proof_generated";
|
|
194
|
+
} | {
|
|
195
|
+
type: "result_received";
|
|
196
|
+
} | {
|
|
197
|
+
type: "rejected";
|
|
198
|
+
};
|
|
199
|
+
interface ZkPassportProofResult {
|
|
200
|
+
readonly params: SolidityVerifierParameters;
|
|
201
|
+
readonly isIDCard: boolean;
|
|
202
|
+
}
|
|
203
|
+
interface ZkPassportSession {
|
|
204
|
+
/** URL to display as QR code or open as deeplink. */
|
|
205
|
+
readonly url: string;
|
|
206
|
+
/** Resolves when the full flow completes (proof verified). */
|
|
207
|
+
readonly result: ResultAsync<ZkPassportProofResult, ZkkycError>;
|
|
208
|
+
/** Aborts the flow. The result promise will reject with ZK_PASSPORT_ABORTED. */
|
|
209
|
+
readonly abort: () => void;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/** Default Reclaim provider IDs for each social platform. */
|
|
213
|
+
declare const DEFAULT_RECLAIM_PROVIDER_IDS: Record<SocialPlatform, string>;
|
|
214
|
+
/** ZK Passport app store links. */
|
|
215
|
+
declare const ZK_PASSPORT_APP_LINKS: {
|
|
216
|
+
readonly IOS: "https://apps.apple.com/us/app/zkpassport/id6477371975";
|
|
217
|
+
readonly ANDROID: "https://play.google.com/store/apps/details?id=app.zkpassport.zkpassport";
|
|
218
|
+
};
|
|
219
|
+
/** Reclaim Protocol app store links. */
|
|
220
|
+
declare const RECLAIM_APP_LINKS: {
|
|
221
|
+
readonly ANDROID: "https://play.google.com/store/apps/details?id=org.reclaimprotocol.app";
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
/** Runs the Reclaim social verification flow and returns proof data for on-chain submission. */
|
|
225
|
+
declare function createReclaimFlow(config: ReclaimConfig, options: ReclaimFlowOptions): ResultAsync<ReclaimProofResult, ZkkycError>;
|
|
226
|
+
|
|
227
|
+
/** Initializes a ZK Passport verification flow and returns a session. */
|
|
228
|
+
declare function createZkPassportFlow(config: ZkPassportConfig, options: ZkPassportFlowOptions): ResultAsync<ZkPassportSession, ZkkycError>;
|
|
229
|
+
|
|
230
|
+
export { type AnonAadharProofParams, DEFAULT_RECLAIM_PROVIDER_IDS, RECLAIM_APP_LINKS, type ReclaimConfig, type ReclaimFlowOptions, type ReclaimProofResult, type ReclaimStatus, SOCIAL_PLATFORM_NAMES, type SocialPlatform, type SocialVerifyParams, ZK_PASSPORT_APP_LINKS, type ZkPassportConfig, type ZkPassportFlowOptions, type ZkPassportProofResult, type ZkPassportRegisterParams, type ZkPassportSession, type ZkPassportStatus, type Zkkyc, type ZkkycConfig, ZkkycError, type ZkkycErrorCode, createReclaimFlow, createZkPassportFlow, createZkkyc };
|
package/dist/zkkyc.d.ts
ADDED
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
import { Result, ResultAsync } from 'neverthrow';
|
|
2
|
+
import { Address } from 'viem';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
|
|
5
|
+
declare class SdkError<TCode extends string = string> extends Error {
|
|
6
|
+
readonly code: TCode;
|
|
7
|
+
readonly cause?: unknown;
|
|
8
|
+
readonly context?: Record<string, unknown>;
|
|
9
|
+
constructor(message: string, options: {
|
|
10
|
+
code: TCode;
|
|
11
|
+
cause?: unknown;
|
|
12
|
+
context?: Record<string, unknown>;
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
type ZkkycErrorCode = "VALIDATION_ERROR" | "CONTRACT_READ_ERROR" | "ENCODE_ERROR" | "RECLAIM_INIT_FAILED" | "RECLAIM_SESSION_NOT_FOUND" | "RECLAIM_PROOF_GENERATION_FAILED" | "RECLAIM_PROOF_INVALID" | "RECLAIM_POLLING_ABORTED" | "ZK_PASSPORT_INIT_FAILED" | "ZK_PASSPORT_REJECTED" | "ZK_PASSPORT_VERIFICATION_FAILED" | "ZK_PASSPORT_ABORTED" | "PEER_DEPENDENCY_MISSING";
|
|
17
|
+
declare class ZkkycError extends SdkError<ZkkycErrorCode> {
|
|
18
|
+
constructor(message: string, options: {
|
|
19
|
+
code: ZkkycErrorCode;
|
|
20
|
+
cause?: unknown;
|
|
21
|
+
context?: Record<string, unknown>;
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
interface ZkkycConfig {
|
|
26
|
+
readonly reputationManagerAddress: Address;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
declare const ZodAnonAadharProofParamsSchema: z.ZodObject<{
|
|
30
|
+
nullifierSeed: z.ZodBigInt;
|
|
31
|
+
nullifier: z.ZodBigInt;
|
|
32
|
+
timestamp: z.ZodBigInt;
|
|
33
|
+
signal: z.ZodBigInt;
|
|
34
|
+
revealArray: z.ZodTuple<[z.ZodBigInt, z.ZodBigInt, z.ZodBigInt, z.ZodBigInt], null>;
|
|
35
|
+
packedGroth16Proof: z.ZodTuple<[z.ZodBigInt, z.ZodBigInt, z.ZodBigInt, z.ZodBigInt, z.ZodBigInt, z.ZodBigInt, z.ZodBigInt, z.ZodBigInt], null>;
|
|
36
|
+
}, z.core.$strip>;
|
|
37
|
+
type AnonAadharProofParams = z.infer<typeof ZodAnonAadharProofParamsSchema>;
|
|
38
|
+
declare const ZodSocialVerifyParamsSchema: z.ZodObject<{
|
|
39
|
+
_socialName: z.ZodString;
|
|
40
|
+
proofs: z.ZodArray<z.ZodObject<{
|
|
41
|
+
claimInfo: z.ZodObject<{
|
|
42
|
+
provider: z.ZodString;
|
|
43
|
+
parameters: z.ZodString;
|
|
44
|
+
context: z.ZodString;
|
|
45
|
+
}, z.core.$strip>;
|
|
46
|
+
signedClaim: z.ZodObject<{
|
|
47
|
+
claim: z.ZodObject<{
|
|
48
|
+
identifier: z.ZodString;
|
|
49
|
+
owner: z.ZodString & z.ZodType<`0x${string}`, string, z.core.$ZodTypeInternals<`0x${string}`, string>>;
|
|
50
|
+
timestampS: z.ZodNumber;
|
|
51
|
+
epoch: z.ZodNumber;
|
|
52
|
+
}, z.core.$strip>;
|
|
53
|
+
signatures: z.ZodArray<z.ZodString>;
|
|
54
|
+
}, z.core.$strip>;
|
|
55
|
+
}, z.core.$strip>>;
|
|
56
|
+
}, z.core.$strip>;
|
|
57
|
+
type SocialVerifyParams = z.infer<typeof ZodSocialVerifyParamsSchema>;
|
|
58
|
+
declare const ZodSolidityVerifierParametersSchema: z.ZodObject<{
|
|
59
|
+
version: z.ZodString;
|
|
60
|
+
proofVerificationData: z.ZodObject<{
|
|
61
|
+
vkeyHash: z.ZodString;
|
|
62
|
+
proof: z.ZodString;
|
|
63
|
+
publicInputs: z.ZodArray<z.ZodString>;
|
|
64
|
+
}, z.core.$strip>;
|
|
65
|
+
committedInputs: z.ZodString;
|
|
66
|
+
serviceConfig: z.ZodObject<{
|
|
67
|
+
validityPeriodInSeconds: z.ZodNumber;
|
|
68
|
+
domain: z.ZodString;
|
|
69
|
+
scope: z.ZodString;
|
|
70
|
+
devMode: z.ZodBoolean;
|
|
71
|
+
}, z.core.$strip>;
|
|
72
|
+
}, z.core.$strip>;
|
|
73
|
+
type SolidityVerifierParameters = z.infer<typeof ZodSolidityVerifierParametersSchema>;
|
|
74
|
+
declare const ZodZkPassportRegisterParamsSchema: z.ZodObject<{
|
|
75
|
+
params: z.ZodObject<{
|
|
76
|
+
version: z.ZodString;
|
|
77
|
+
proofVerificationData: z.ZodObject<{
|
|
78
|
+
vkeyHash: z.ZodString;
|
|
79
|
+
proof: z.ZodString;
|
|
80
|
+
publicInputs: z.ZodArray<z.ZodString>;
|
|
81
|
+
}, z.core.$strip>;
|
|
82
|
+
committedInputs: z.ZodString;
|
|
83
|
+
serviceConfig: z.ZodObject<{
|
|
84
|
+
validityPeriodInSeconds: z.ZodNumber;
|
|
85
|
+
domain: z.ZodString;
|
|
86
|
+
scope: z.ZodString;
|
|
87
|
+
devMode: z.ZodBoolean;
|
|
88
|
+
}, z.core.$strip>;
|
|
89
|
+
}, z.core.$strip>;
|
|
90
|
+
isIDCard: z.ZodBoolean;
|
|
91
|
+
}, z.core.$strip>;
|
|
92
|
+
type ZkPassportRegisterParams = z.infer<typeof ZodZkPassportRegisterParamsSchema>;
|
|
93
|
+
|
|
94
|
+
interface Zkkyc {
|
|
95
|
+
prepareSocialVerify(params: SocialVerifyParams): Result<{
|
|
96
|
+
to: Address;
|
|
97
|
+
data: `0x${string}`;
|
|
98
|
+
}, ZkkycError>;
|
|
99
|
+
prepareSubmitAnonAadharProof(params: AnonAadharProofParams): Result<{
|
|
100
|
+
to: Address;
|
|
101
|
+
data: `0x${string}`;
|
|
102
|
+
}, ZkkycError>;
|
|
103
|
+
prepareZkPassportRegister(params: ZkPassportRegisterParams): Result<{
|
|
104
|
+
to: Address;
|
|
105
|
+
data: `0x${string}`;
|
|
106
|
+
}, ZkkycError>;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Creates a Zkkyc client that binds a reputation manager address,
|
|
110
|
+
* exposing write-preparation methods for social verify, Aadhaar, and ZK Passport.
|
|
111
|
+
*/
|
|
112
|
+
declare function createZkkyc(config: ZkkycConfig): Zkkyc;
|
|
113
|
+
|
|
114
|
+
type SocialPlatform = "linkedin" | "github" | "x" | "instagram" | "facebook";
|
|
115
|
+
/** Maps SocialPlatform to the capitalized name the contract expects for _socialName. */
|
|
116
|
+
declare const SOCIAL_PLATFORM_NAMES: Record<SocialPlatform, string>;
|
|
117
|
+
interface ReclaimConfig {
|
|
118
|
+
readonly appId: string;
|
|
119
|
+
readonly appSecret: string;
|
|
120
|
+
readonly providerIds: Record<SocialPlatform, string>;
|
|
121
|
+
}
|
|
122
|
+
interface ReclaimFlowOptions {
|
|
123
|
+
readonly platform: SocialPlatform;
|
|
124
|
+
readonly walletAddress: Address;
|
|
125
|
+
/** Base URL for redirect after Reclaim flow. SDK appends ?sessionId={id}&socialPlatform={Name}. */
|
|
126
|
+
readonly redirectUrl?: string;
|
|
127
|
+
/** Resume polling for an existing session (redirect-back case). */
|
|
128
|
+
readonly sessionId?: string;
|
|
129
|
+
/** Description added to Reclaim context. */
|
|
130
|
+
readonly contextDescription?: string;
|
|
131
|
+
/** Called with status updates during the flow. */
|
|
132
|
+
readonly onStatus?: (status: ReclaimStatus) => void;
|
|
133
|
+
/** AbortSignal to cancel polling. */
|
|
134
|
+
readonly signal?: AbortSignal;
|
|
135
|
+
/** Polling interval in ms. Defaults to 5000. */
|
|
136
|
+
readonly pollingIntervalMs?: number;
|
|
137
|
+
}
|
|
138
|
+
type ReclaimStatus = {
|
|
139
|
+
type: "session_created";
|
|
140
|
+
sessionId: string;
|
|
141
|
+
requestUrl: string;
|
|
142
|
+
} | {
|
|
143
|
+
type: "polling_started";
|
|
144
|
+
sessionId: string;
|
|
145
|
+
} | {
|
|
146
|
+
type: "proof_received";
|
|
147
|
+
} | {
|
|
148
|
+
type: "proof_transformed";
|
|
149
|
+
};
|
|
150
|
+
interface ReclaimProofResult {
|
|
151
|
+
readonly _socialName: string;
|
|
152
|
+
readonly proofs: readonly {
|
|
153
|
+
claimInfo: {
|
|
154
|
+
provider: string;
|
|
155
|
+
parameters: string;
|
|
156
|
+
context: string;
|
|
157
|
+
};
|
|
158
|
+
signedClaim: {
|
|
159
|
+
claim: {
|
|
160
|
+
identifier: string;
|
|
161
|
+
owner: string;
|
|
162
|
+
timestampS: number;
|
|
163
|
+
epoch: number;
|
|
164
|
+
};
|
|
165
|
+
signatures: string[];
|
|
166
|
+
};
|
|
167
|
+
}[];
|
|
168
|
+
readonly sessionId: string;
|
|
169
|
+
}
|
|
170
|
+
interface ZkPassportConfig {
|
|
171
|
+
/** Domain for ZKPassport initialization. Defaults to "app.p2p.me". */
|
|
172
|
+
readonly domain?: string;
|
|
173
|
+
/** App name shown in ZKPassport UI. Defaults to "ZKPassport". */
|
|
174
|
+
readonly name?: string;
|
|
175
|
+
/** Logo URL shown in ZKPassport UI. */
|
|
176
|
+
readonly logo?: string;
|
|
177
|
+
/** Purpose text shown in ZKPassport UI. Defaults to "Prove your personhood". */
|
|
178
|
+
readonly purpose?: string;
|
|
179
|
+
}
|
|
180
|
+
interface ZkPassportFlowOptions {
|
|
181
|
+
readonly walletAddress: Address;
|
|
182
|
+
/** Called with status updates during the flow. */
|
|
183
|
+
readonly onStatus?: (status: ZkPassportStatus) => void;
|
|
184
|
+
}
|
|
185
|
+
type ZkPassportStatus = {
|
|
186
|
+
type: "request_created";
|
|
187
|
+
url: string;
|
|
188
|
+
} | {
|
|
189
|
+
type: "request_received";
|
|
190
|
+
} | {
|
|
191
|
+
type: "generating_proof";
|
|
192
|
+
} | {
|
|
193
|
+
type: "proof_generated";
|
|
194
|
+
} | {
|
|
195
|
+
type: "result_received";
|
|
196
|
+
} | {
|
|
197
|
+
type: "rejected";
|
|
198
|
+
};
|
|
199
|
+
interface ZkPassportProofResult {
|
|
200
|
+
readonly params: SolidityVerifierParameters;
|
|
201
|
+
readonly isIDCard: boolean;
|
|
202
|
+
}
|
|
203
|
+
interface ZkPassportSession {
|
|
204
|
+
/** URL to display as QR code or open as deeplink. */
|
|
205
|
+
readonly url: string;
|
|
206
|
+
/** Resolves when the full flow completes (proof verified). */
|
|
207
|
+
readonly result: ResultAsync<ZkPassportProofResult, ZkkycError>;
|
|
208
|
+
/** Aborts the flow. The result promise will reject with ZK_PASSPORT_ABORTED. */
|
|
209
|
+
readonly abort: () => void;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/** Default Reclaim provider IDs for each social platform. */
|
|
213
|
+
declare const DEFAULT_RECLAIM_PROVIDER_IDS: Record<SocialPlatform, string>;
|
|
214
|
+
/** ZK Passport app store links. */
|
|
215
|
+
declare const ZK_PASSPORT_APP_LINKS: {
|
|
216
|
+
readonly IOS: "https://apps.apple.com/us/app/zkpassport/id6477371975";
|
|
217
|
+
readonly ANDROID: "https://play.google.com/store/apps/details?id=app.zkpassport.zkpassport";
|
|
218
|
+
};
|
|
219
|
+
/** Reclaim Protocol app store links. */
|
|
220
|
+
declare const RECLAIM_APP_LINKS: {
|
|
221
|
+
readonly ANDROID: "https://play.google.com/store/apps/details?id=org.reclaimprotocol.app";
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
/** Runs the Reclaim social verification flow and returns proof data for on-chain submission. */
|
|
225
|
+
declare function createReclaimFlow(config: ReclaimConfig, options: ReclaimFlowOptions): ResultAsync<ReclaimProofResult, ZkkycError>;
|
|
226
|
+
|
|
227
|
+
/** Initializes a ZK Passport verification flow and returns a session. */
|
|
228
|
+
declare function createZkPassportFlow(config: ZkPassportConfig, options: ZkPassportFlowOptions): ResultAsync<ZkPassportSession, ZkkycError>;
|
|
229
|
+
|
|
230
|
+
export { type AnonAadharProofParams, DEFAULT_RECLAIM_PROVIDER_IDS, RECLAIM_APP_LINKS, type ReclaimConfig, type ReclaimFlowOptions, type ReclaimProofResult, type ReclaimStatus, SOCIAL_PLATFORM_NAMES, type SocialPlatform, type SocialVerifyParams, ZK_PASSPORT_APP_LINKS, type ZkPassportConfig, type ZkPassportFlowOptions, type ZkPassportProofResult, type ZkPassportRegisterParams, type ZkPassportSession, type ZkPassportStatus, type Zkkyc, type ZkkycConfig, ZkkycError, type ZkkycErrorCode, createReclaimFlow, createZkPassportFlow, createZkkyc };
|