@zkproofport-app/sdk 0.1.2-beta.1
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/LICENSE +21 -0
- package/README.md +469 -0
- package/dist/ProofportSDK.d.ts +1011 -0
- package/dist/constants.d.ts +223 -0
- package/dist/deeplink.d.ts +192 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.esm.js +5225 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/index.js +2364 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +5225 -0
- package/dist/index.mjs.map +1 -0
- package/dist/qrcode.d.ts +120 -0
- package/dist/types.d.ts +434 -0
- package/dist/verifier.d.ts +224 -0
- package/package.json +75 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/constants.ts","../src/deeplink.ts","../src/qrcode.ts","../src/verifier.ts","../src/ProofportSDK.ts"],"sourcesContent":["/**\n * ZKProofport SDK Constants\n */\n\nimport type { CircuitType, SDKEnvironment } from './types';\n\n/**\n * Pre-configured relay server URLs for each environment.\n * Used by `ProofportSDK.create('production')` for zero-config initialization.\n *\n * @example\n * ```typescript\n * const sdk = ProofportSDK.create('production');\n * // Uses RELAY_URLS.production = 'https://relay.zkproofport.app'\n * ```\n */\nexport const RELAY_URLS: Record<SDKEnvironment, string> = {\n production: 'https://relay.zkproofport.app',\n staging: 'https://stg-relay.zkproofport.app',\n local: 'http://localhost:4001',\n};\n\n/**\n * Default deep link URL scheme for ZKProofport mobile app.\n * Used to construct deep link URLs that open the mobile app.\n *\n * @example\n * ```typescript\n * const deepLink = `${DEFAULT_SCHEME}://proof-request?...`;\n * // Results in: zkproofport://proof-request?...\n * ```\n */\nexport const DEFAULT_SCHEME = 'zkproofport';\n\n/**\n * Deep link URL hosts for different proof request flows.\n * Used as the host component in deep link URLs.\n *\n * @example\n * ```typescript\n * const requestUrl = `zkproofport://${DEEP_LINK_HOSTS.PROOF_REQUEST}`;\n * const responseUrl = `zkproofport://${DEEP_LINK_HOSTS.PROOF_RESPONSE}`;\n * ```\n */\nexport const DEEP_LINK_HOSTS = {\n /** Host for proof requests sent to mobile app */\n PROOF_REQUEST: 'proof-request',\n /** Host for proof responses returned from mobile app */\n PROOF_RESPONSE: 'proof-response',\n} as const;\n\n/**\n * Circuit metadata containing display names, descriptions, and public input specifications.\n * Each circuit has a defined number and layout of public inputs that must match\n * the Noir circuit definition.\n *\n * @example\n * ```typescript\n * const metadata = CIRCUIT_METADATA['coinbase_attestation'];\n * console.log(metadata.name); // \"Coinbase KYC\"\n * console.log(metadata.publicInputsCount); // 2\n * ```\n */\nexport const CIRCUIT_METADATA: Record<CircuitType, {\n name: string;\n description: string;\n publicInputsCount: number;\n publicInputNames: string[];\n}> = {\n coinbase_attestation: {\n name: 'Coinbase KYC',\n description: 'Prove Coinbase identity verification',\n publicInputsCount: 2,\n publicInputNames: ['signal_hash', 'signer_list_merkle_root'],\n },\n coinbase_country_attestation: {\n name: 'Coinbase Country',\n description: 'Prove Coinbase country verification',\n publicInputsCount: 14,\n publicInputNames: ['signal_hash', 'signer_list_merkle_root', 'country_list', 'country_list_length', 'is_included'],\n },\n};\n\n/**\n * Standard verifier contract ABI shared across all Barretenberg-generated verifiers.\n * This ABI defines the interface for calling the verify function on deployed verifier contracts.\n *\n * Uses ethers v6 human-readable ABI format.\n *\n * @example\n * ```typescript\n * import { Contract } from 'ethers';\n *\n * const verifier = new Contract(verifierAddress, VERIFIER_ABI, provider);\n * const isValid = await verifier.verify(proofBytes, publicInputs);\n * ```\n */\nexport const VERIFIER_ABI = [\n 'function verify(bytes calldata _proof, bytes32[] calldata _publicInputs) external view returns (bool)',\n];\n\n/**\n * Public RPC endpoint URLs for supported blockchain networks.\n * Used as fallback when no custom provider is supplied.\n *\n * Supported networks:\n * - 84532: Base Sepolia (testnet)\n * - 8453: Base Mainnet (production)\n *\n * @example\n * ```typescript\n * import { JsonRpcProvider } from 'ethers';\n *\n * const provider = new JsonRpcProvider(RPC_ENDPOINTS[84532]);\n * ```\n */\nexport const RPC_ENDPOINTS: Record<number, string> = {\n 84532: 'https://sepolia.base.org', // Base Sepolia\n 8453: 'https://mainnet.base.org', // Base Mainnet\n};\n\n/**\n * Default proof request expiration time in milliseconds.\n * Requests older than this are considered expired and should not be processed.\n *\n * Default: 10 minutes (600,000 ms)\n *\n * @example\n * ```typescript\n * const request: ProofRequest = {\n * // ...\n * createdAt: Date.now(),\n * expiresAt: Date.now() + DEFAULT_REQUEST_EXPIRY_MS\n * };\n * ```\n */\nexport const DEFAULT_REQUEST_EXPIRY_MS = 10 * 60 * 1000;\n\n/**\n * Maximum data size (in bytes) that can be encoded in a QR code.\n * Based on QR Code Version 40 with L (Low) error correction level.\n *\n * Requests exceeding this size should use alternative methods (HTTP, WebSocket).\n *\n * @example\n * ```typescript\n * const deepLinkUrl = generateDeepLink(request);\n * if (deepLinkUrl.length > MAX_QR_DATA_SIZE) {\n * console.warn('Request too large for QR code');\n * }\n * ```\n */\nexport const MAX_QR_DATA_SIZE = 2953; // Version 40 with L error correction\n\n/**\n * Coinbase Attestation circuit public input layout (byte offsets).\n * Defines the byte positions of each field in the flattened public inputs array.\n *\n * Public inputs are packed as bytes32 values:\n * - signal_hash: bytes 0-31\n * - merkle_root: bytes 32-63\n * - scope: bytes 64-95\n * - nullifier: bytes 96-127\n *\n * @example\n * ```typescript\n * const publicInputs = response.publicInputs;\n * const signalHash = publicInputs.slice(\n * COINBASE_ATTESTATION_PUBLIC_INPUT_LAYOUT.SIGNAL_HASH_START,\n * COINBASE_ATTESTATION_PUBLIC_INPUT_LAYOUT.SIGNAL_HASH_END + 1\n * );\n * ```\n */\nexport const COINBASE_ATTESTATION_PUBLIC_INPUT_LAYOUT = {\n SIGNAL_HASH_START: 0,\n SIGNAL_HASH_END: 31,\n MERKLE_ROOT_START: 32,\n MERKLE_ROOT_END: 63,\n SCOPE_START: 64,\n SCOPE_END: 95,\n NULLIFIER_START: 96,\n NULLIFIER_END: 127,\n} as const;\n\n/**\n * Coinbase Country Attestation circuit public input layout (byte offsets).\n * Defines the byte positions of each field in the flattened public inputs array.\n *\n * Public inputs are packed as bytes32 values:\n * - signal_hash: bytes 0-31\n * - merkle_root: bytes 32-63\n * - country_list: bytes 64-83 (20 bytes for 10 countries)\n * - country_list_length: byte 84\n * - is_included: byte 85\n * - scope: bytes 86-117\n * - nullifier: bytes 118-149\n *\n * @example\n * ```typescript\n * const publicInputs = response.publicInputs;\n * const countryList = publicInputs.slice(\n * COINBASE_COUNTRY_PUBLIC_INPUT_LAYOUT.COUNTRY_LIST_START,\n * COINBASE_COUNTRY_PUBLIC_INPUT_LAYOUT.COUNTRY_LIST_END + 1\n * );\n * ```\n */\nexport const COINBASE_COUNTRY_PUBLIC_INPUT_LAYOUT = {\n SIGNAL_HASH_START: 0,\n SIGNAL_HASH_END: 31,\n MERKLE_ROOT_START: 32,\n MERKLE_ROOT_END: 63,\n COUNTRY_LIST_START: 64,\n COUNTRY_LIST_END: 83,\n COUNTRY_LIST_LENGTH: 84,\n IS_INCLUDED: 85,\n SCOPE_START: 86,\n SCOPE_END: 117,\n NULLIFIER_START: 118,\n NULLIFIER_END: 149,\n} as const;\n\n/**\n * V1 NullifierRegistry contract ABI (DEPRECATED).\n *\n * This is the legacy nullifier registry interface.\n * Use ZKPROOFPORT_NULLIFIER_REGISTRY_ABI for new integrations.\n *\n * @deprecated Use ZKPROOFPORT_NULLIFIER_REGISTRY_ABI instead. This is the V1 NullifierRegistry ABI.\n */\nexport const NULLIFIER_REGISTRY_ABI = [\n 'function registerCircuit(bytes32 _circuitId, address _verifier, uint256 _scopeIndex, uint256 _nullifierIndex) external',\n 'function updateCircuit(bytes32 _circuitId, address _newVerifier, uint256 _scopeIndex, uint256 _nullifierIndex) external',\n 'function verifyAndRegister(bytes32 _circuitId, bytes calldata _proof, bytes32[] calldata _publicInputs) external returns (bool)',\n 'function isNullifierUsed(bytes32 _nullifier) external view returns (bool)',\n 'function getScope(bytes32 _nullifier) external view returns (bytes32)',\n 'function getCircuit(bytes32 _nullifier) external view returns (bytes32)',\n 'function verifyOnly(bytes32 _circuitId, bytes calldata _proof, bytes32[] calldata _publicInputs) external view returns (bool)',\n 'event CircuitRegistered(bytes32 indexed circuitId, address verifier)',\n 'event CircuitUpdated(bytes32 indexed circuitId, address newVerifier)',\n 'event NullifierRegistered(bytes32 indexed nullifier, bytes32 indexed scope, bytes32 indexed circuitId)',\n];\n\n/**\n * ZKProofportNullifierRegistry contract ABI (V2).\n *\n * This is the current nullifier registry interface with relayer-only registration.\n * Public view functions allow checking nullifier status and verifying proofs without registration.\n *\n * Key functions:\n * - `isNullifierRegistered`: Check if a nullifier has been used\n * - `getNullifierInfo`: Get registration details for a nullifier\n * - `verifyOnly`: Verify a proof without registering the nullifier\n *\n * Note: Registration functions (verifyAndRegister) are relayer-only and not exposed in this ABI.\n *\n * @example\n * ```typescript\n * import { Contract } from 'ethers';\n *\n * const registry = new Contract(\n * registryAddress,\n * ZKPROOFPORT_NULLIFIER_REGISTRY_ABI,\n * provider\n * );\n *\n * const isUsed = await registry.isNullifierRegistered(nullifier);\n * ```\n */\nexport const ZKPROOFPORT_NULLIFIER_REGISTRY_ABI = [\n 'function isNullifierRegistered(bytes32 _nullifier) external view returns (bool)',\n 'function getNullifierInfo(bytes32 _nullifier) external view returns (uint64 registeredAt, bytes32 scope, bytes32 circuitId)',\n 'function verifyOnly(bytes32 _circuitId, bytes calldata _proof, bytes32[] calldata _publicInputs) external view returns (bool)',\n 'event NullifierRegistered(bytes32 indexed nullifier, bytes32 indexed scope, bytes32 indexed circuitId)',\n];\n","/**\n * Deep Link utilities for ZKProofport SDK\n */\n\nimport type {\n ProofRequest,\n ProofResponse,\n CircuitInputs,\n CoinbaseKycInputs,\n CoinbaseCountryInputs,\n DeepLinkComponents,\n CircuitType,\n} from './types';\nimport { DEFAULT_SCHEME, DEEP_LINK_HOSTS } from './constants';\n\n/**\n * Generates a unique request ID for proof requests.\n *\n * Creates an ID by combining a base36-encoded timestamp with a random string,\n * prefixed with \"req-\". This ensures uniqueness across concurrent requests.\n *\n * @returns A unique string identifier in the format \"req-{timestamp}-{random}\"\n *\n * @example\n * ```typescript\n * const id = generateRequestId();\n * // \"req-lh8k3f2g-a9b7c4d2\"\n * ```\n */\nexport function generateRequestId(): string {\n const timestamp = Date.now().toString(36);\n const random = Math.random().toString(36).substring(2, 10);\n return `req-${timestamp}-${random}`;\n}\n\n/**\n * Encodes an object into a URL-safe base64url string with UTF-8 support.\n *\n * Converts the input object to JSON, then encodes it using base64url format\n * (RFC 4648 §5) which replaces '+' with '-', '/' with '_', and removes padding.\n * Works in both browser and Node.js environments.\n *\n * @param data - The object to encode (will be JSON stringified)\n * @returns Base64url-encoded string safe for URL parameters\n *\n * @example\n * ```typescript\n * const encoded = encodeData({ circuit: 'coinbase_attestation', requestId: 'req-123' });\n * // \"eyJjaXJjdWl0IjoiY29pbmJhc2VfYXR0ZXN0YXRpb24iLCJyZXF1ZXN0SWQiOiJyZXEtMTIzIn0\"\n * ```\n */\nexport function encodeData(data: object): string {\n const json = JSON.stringify(data);\n // Use base64url encoding (URL-safe) with UTF-8 support\n if (typeof btoa === 'function') {\n // Browser: UTF-8 encode first, then base64\n const utf8Encoded = encodeURIComponent(json).replace(/%([0-9A-F]{2})/g, (_, p1) =>\n String.fromCharCode(parseInt(p1, 16))\n );\n return btoa(utf8Encoded)\n .replace(/\\+/g, '-')\n .replace(/\\//g, '_')\n .replace(/=+$/, '');\n }\n // Node.js environment\n return Buffer.from(json, 'utf-8')\n .toString('base64')\n .replace(/\\+/g, '-')\n .replace(/\\//g, '_')\n .replace(/=+$/, '');\n}\n\n/**\n * Decodes a base64url-encoded string back into a typed object.\n *\n * Reverses the encoding process by converting base64url to standard base64,\n * decoding it, and parsing the resulting JSON. Handles UTF-8 correctly in\n * both browser and Node.js environments.\n *\n * @typeParam T - The expected type of the decoded object\n * @param encoded - Base64url-encoded string (from encodeData)\n * @returns Decoded and parsed object of type T\n *\n * @throws {SyntaxError} If the decoded string is not valid JSON\n *\n * @example\n * ```typescript\n * const request = decodeData<ProofRequest>(encodedString);\n * console.log(request.circuit); // \"coinbase_attestation\"\n * ```\n */\nexport function decodeData<T>(encoded: string): T {\n // Restore base64 padding\n let base64 = encoded.replace(/-/g, '+').replace(/_/g, '/');\n while (base64.length % 4) {\n base64 += '=';\n }\n\n let json: string;\n if (typeof atob === 'function') {\n // Browser: decode base64, then UTF-8 decode\n const decoded = atob(base64);\n json = decodeURIComponent(\n decoded.split('').map(c => '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2)).join('')\n );\n } else {\n json = Buffer.from(base64, 'base64').toString('utf-8');\n }\n\n return JSON.parse(json) as T;\n}\n\n/**\n * Builds a deep link URL for a proof request.\n *\n * Encodes the proof request and constructs a deep link URL that can be opened\n * by the ZKProofport mobile app. The URL format is:\n * `{scheme}://proof-request?data={encodedRequest}`\n *\n * @param request - The proof request to encode in the deep link\n * @param scheme - Custom URL scheme (defaults to \"zkproofport\")\n * @returns Complete deep link URL ready to be opened or embedded in a QR code\n *\n * @example\n * ```typescript\n * const request: ProofRequest = {\n * requestId: generateRequestId(),\n * circuit: 'coinbase_attestation',\n * inputs: { scope: 'myapp.com' },\n * createdAt: Date.now()\n * };\n * const url = buildProofRequestUrl(request);\n * // \"zkproofport://proof-request?data=eyJyZXF1ZXN0SWQi...\"\n * ```\n */\nexport function buildProofRequestUrl(\n request: ProofRequest,\n scheme: string = DEFAULT_SCHEME\n): string {\n const encodedRequest = encodeData(request);\n return `${scheme}://${DEEP_LINK_HOSTS.PROOF_REQUEST}?data=${encodedRequest}`;\n}\n\n/**\n * Builds a callback URL with proof response data as query parameters.\n *\n * Appends proof response fields to the provided callback URL. For completed proofs,\n * includes proof data, public inputs, and nullifier. For errors, includes error message.\n *\n * @internal Used by the mobile app to construct callback URLs — not intended for SDK consumers.\n *\n * @param callbackUrl - Base callback URL (from the original proof request)\n * @param response - Proof response containing status and optional proof data\n * @returns Complete callback URL with proof response as query parameters\n */\nexport function buildCallbackUrl(\n callbackUrl: string,\n response: ProofResponse\n): string {\n const url = new URL(callbackUrl);\n url.searchParams.set('requestId', response.requestId);\n url.searchParams.set('status', response.status);\n\n if (response.status === 'completed' && response.proof) {\n url.searchParams.set('proof', response.proof);\n if (response.publicInputs) {\n url.searchParams.set('publicInputs', response.publicInputs.join(','));\n }\n if (response.numPublicInputs !== undefined) {\n url.searchParams.set('numPublicInputs', response.numPublicInputs.toString());\n }\n if (response.timestamp) {\n url.searchParams.set('timestamp', response.timestamp.toString());\n }\n if (response.nullifier) {\n url.searchParams.set('nullifier', response.nullifier);\n }\n } else if (response.status === 'error' && response.error) {\n url.searchParams.set('error', response.error);\n }\n\n return url.toString();\n}\n\n/**\n * Parses a proof request from a deep link URL.\n *\n * Extracts and decodes the proof request data from a ZKProofport deep link URL.\n * Returns null if the URL is invalid or missing required parameters.\n *\n * @param url - Deep link URL (e.g., \"zkproofport://proof-request?data=...\")\n * @returns Decoded ProofRequest object, or null if parsing fails\n *\n * @example\n * ```typescript\n * const url = \"zkproofport://proof-request?data=eyJyZXF1ZXN0SWQi...\";\n * const request = parseProofRequestUrl(url);\n * if (request) {\n * console.log(request.circuit); // \"coinbase_attestation\"\n * }\n * ```\n */\nexport function parseProofRequestUrl(url: string): ProofRequest | null {\n try {\n const urlObj = new URL(url);\n const data = urlObj.searchParams.get('data');\n\n if (!data) {\n return null;\n }\n\n return decodeData<ProofRequest>(data);\n } catch (error) {\n console.error('Failed to parse proof request URL:', error);\n return null;\n }\n}\n\n/**\n * Parses a proof response from a callback URL.\n *\n * Extracts proof response data from query parameters in a callback URL.\n * Handles both successful proof completions and error responses.\n * Returns null if required parameters (requestId, status) are missing.\n *\n * @param url - Callback URL with proof response query parameters\n * @returns Decoded ProofResponse object, or null if parsing fails\n *\n * @example\n * ```typescript\n * const callbackUrl = \"https://example.com/callback?requestId=req-123&status=completed&proof=0x...\";\n * const response = parseProofResponseUrl(callbackUrl);\n * if (response && response.status === 'completed') {\n * console.log(response.proof); // \"0x...\"\n * }\n * ```\n */\nexport function parseProofResponseUrl(url: string): ProofResponse | null {\n try {\n const urlObj = new URL(url);\n const requestId = urlObj.searchParams.get('requestId');\n const status = urlObj.searchParams.get('status') as ProofResponse['status'];\n\n if (!requestId || !status) {\n return null;\n }\n\n const response: ProofResponse = {\n requestId,\n circuit: urlObj.searchParams.get('circuit') as CircuitType || 'coinbase_attestation',\n status,\n };\n\n if (status === 'completed') {\n response.proof = urlObj.searchParams.get('proof') || undefined;\n const publicInputsStr = urlObj.searchParams.get('publicInputs');\n if (publicInputsStr) {\n response.publicInputs = publicInputsStr.split(',');\n }\n const numPublicInputs = urlObj.searchParams.get('numPublicInputs');\n if (numPublicInputs) {\n response.numPublicInputs = parseInt(numPublicInputs, 10);\n }\n const timestamp = urlObj.searchParams.get('timestamp');\n if (timestamp) {\n response.timestamp = parseInt(timestamp, 10);\n }\n response.nullifier = urlObj.searchParams.get('nullifier') || undefined;\n } else if (status === 'error') {\n response.error = urlObj.searchParams.get('error') || undefined;\n }\n\n return response;\n } catch (error) {\n console.error('Failed to parse proof response URL:', error);\n return null;\n }\n}\n\n/**\n * Parses a deep link URL into its component parts.\n *\n * Breaks down a custom scheme URL into scheme, host, path, and query parameters.\n * Useful for routing and handling different types of deep links.\n *\n * @param url - Custom scheme URL to parse (e.g., \"zkproofport://proof-request?data=...\")\n * @returns Object containing scheme, host, path, and params, or null if invalid\n *\n * @example\n * ```typescript\n * const url = \"zkproofport://proof-request/verify?data=abc123\";\n * const components = parseDeepLink(url);\n * // {\n * // scheme: \"zkproofport\",\n * // host: \"proof-request\",\n * // path: \"/verify\",\n * // params: { data: \"abc123\" }\n * // }\n * ```\n */\nexport function parseDeepLink(url: string): DeepLinkComponents | null {\n try {\n // Handle custom scheme URLs\n const schemeMatch = url.match(/^([a-z][a-z0-9+.-]*):\\/\\/(.+)$/i);\n if (!schemeMatch) {\n return null;\n }\n\n const scheme = schemeMatch[1];\n const rest = schemeMatch[2];\n\n // Parse host and path\n const [hostPath, queryString] = rest.split('?');\n const [host, ...pathParts] = hostPath.split('/');\n const path = '/' + pathParts.join('/');\n\n // Parse query parameters\n const params: Record<string, string> = {};\n if (queryString) {\n const searchParams = new URLSearchParams(queryString);\n searchParams.forEach((value, key) => {\n params[key] = value;\n });\n }\n\n return { scheme, host, path, params };\n } catch (error) {\n console.error('Failed to parse deep link:', error);\n return null;\n }\n}\n\n/**\n * Checks if a URL is a valid ZKProofport deep link.\n *\n * Performs a case-insensitive check to see if the URL starts with the\n * ZKProofport scheme. Does not validate the URL structure beyond the scheme.\n *\n * @param url - URL to check\n * @param scheme - Expected URL scheme (defaults to \"zkproofport\")\n * @returns True if the URL starts with the specified scheme\n *\n * @example\n * ```typescript\n * isProofportDeepLink(\"zkproofport://proof-request?data=...\"); // true\n * isProofportDeepLink(\"https://example.com\"); // false\n * isProofportDeepLink(\"ZKPROOFPORT://proof-request\"); // true (case-insensitive)\n * ```\n */\nexport function isProofportDeepLink(\n url: string,\n scheme: string = DEFAULT_SCHEME\n): boolean {\n return url.toLowerCase().startsWith(`${scheme.toLowerCase()}://`);\n}\n\n/**\n * @internal\n * Validates a proof request for completeness and correctness.\n *\n * Performs comprehensive validation including:\n * - Required fields (requestId, circuit, callbackUrl)\n * - Circuit type validity (must be a supported circuit)\n * - Circuit-specific input validation (e.g., userAddress format, countryList structure)\n * - Expiration check (if expiresAt is provided)\n *\n * Note: userAddress is optional for both circuits - the mobile app will prompt\n * for wallet connection if not provided.\n *\n * @param request - Proof request to validate\n * @returns Validation result with `valid` flag and optional `error` message\n */\nexport function validateProofRequest(request: ProofRequest): { valid: boolean; error?: string } {\n if (!request.requestId) {\n return { valid: false, error: 'Missing requestId' };\n }\n\n if (!request.circuit) {\n return { valid: false, error: 'Missing circuit type' };\n }\n\n if (!['coinbase_attestation', 'coinbase_country_attestation'].includes(request.circuit)) {\n return { valid: false, error: `Invalid circuit type: ${request.circuit}` };\n }\n\n if (!request.callbackUrl) {\n return { valid: false, error: 'Missing callbackUrl' };\n }\n\n // Validate circuit-specific inputs\n if (request.circuit === 'coinbase_attestation') {\n // Coinbase KYC: userAddress is optional - app will connect wallet if not provided\n const inputs = request.inputs as CoinbaseKycInputs;\n if (inputs.userAddress && !/^0x[a-fA-F0-9]{40}$/.test(inputs.userAddress)) {\n return { valid: false, error: 'Invalid userAddress format' };\n }\n // If userAddress is not provided, app will prompt wallet connection - this is valid\n } else if (request.circuit === 'coinbase_country_attestation') {\n const inputs = request.inputs as CoinbaseCountryInputs;\n if (inputs.userAddress && !/^0x[a-fA-F0-9]{40}$/.test(inputs.userAddress)) {\n return { valid: false, error: 'Invalid userAddress format' };\n }\n if (!inputs.countryList || !Array.isArray(inputs.countryList) || inputs.countryList.length === 0) {\n return { valid: false, error: 'countryList is required and must be a non-empty array' };\n }\n if (!inputs.countryList.every(c => typeof c === 'string')) {\n return { valid: false, error: 'countryList must contain only strings' };\n }\n if (typeof inputs.isIncluded !== 'boolean') {\n return { valid: false, error: 'isIncluded is required and must be a boolean' };\n }\n }\n\n // Check expiry\n if (request.expiresAt && Date.now() > request.expiresAt) {\n return { valid: false, error: 'Request has expired' };\n }\n\n return { valid: true };\n}\n","/**\n * QR Code utilities for ZKProofport SDK\n */\n\nimport QRCode from 'qrcode';\nimport type { ProofRequest, QRCodeOptions } from './types';\nimport { buildProofRequestUrl } from './deeplink';\nimport { DEFAULT_SCHEME, MAX_QR_DATA_SIZE } from './constants';\n\n/**\n * Default QR code options\n */\nconst DEFAULT_QR_OPTIONS: QRCodeOptions = {\n width: 300,\n errorCorrectionLevel: 'M',\n margin: 2,\n darkColor: '#000000',\n lightColor: '#ffffff',\n};\n\n/**\n * Generates a QR code as a base64-encoded PNG data URL.\n *\n * Creates a scannable QR code image from a proof request or deep link URL.\n * The returned data URL can be used directly in HTML img src attributes.\n * Validates that the encoded data doesn't exceed the maximum QR code size.\n *\n * @param requestOrUrl - Proof request object or pre-built deep link URL\n * @param options - QR code appearance options (width, colors, error correction)\n * @param scheme - Custom URL scheme (only used if requestOrUrl is a ProofRequest)\n * @returns Promise resolving to base64 PNG data URL (e.g., \"data:image/png;base64,...\")\n *\n * @throws {Error} If the URL exceeds MAX_QR_DATA_SIZE (2953 bytes)\n *\n * @example\n * ```typescript\n * const request: ProofRequest = {\n * requestId: generateRequestId(),\n * circuit: 'coinbase_attestation',\n * inputs: { scope: 'myapp.com' },\n * createdAt: Date.now()\n * };\n *\n * const dataUrl = await generateQRCodeDataUrl(request, {\n * width: 400,\n * darkColor: '#000000',\n * lightColor: '#ffffff'\n * });\n *\n * // Use in HTML: <img src={dataUrl} alt=\"Scan to prove\" />\n * ```\n */\nexport async function generateQRCodeDataUrl(\n requestOrUrl: ProofRequest | string,\n options: QRCodeOptions = {},\n scheme: string = DEFAULT_SCHEME\n): Promise<string> {\n const url = typeof requestOrUrl === 'string'\n ? requestOrUrl\n : buildProofRequestUrl(requestOrUrl, scheme);\n\n // Check data size\n if (url.length > MAX_QR_DATA_SIZE) {\n throw new Error(\n `QR code data too large (${url.length} bytes). Maximum is ${MAX_QR_DATA_SIZE} bytes.`\n );\n }\n\n const mergedOptions = { ...DEFAULT_QR_OPTIONS, ...options };\n\n return QRCode.toDataURL(url, {\n width: mergedOptions.width,\n errorCorrectionLevel: mergedOptions.errorCorrectionLevel,\n margin: mergedOptions.margin,\n color: {\n dark: mergedOptions.darkColor,\n light: mergedOptions.lightColor,\n },\n });\n}\n\n/**\n * Generates a QR code as an SVG string.\n *\n * Creates a scalable vector graphics QR code that can be embedded directly in HTML\n * or saved to a file. SVG QR codes scale perfectly at any size and have smaller\n * file sizes than raster formats.\n *\n * @param requestOrUrl - Proof request object or pre-built deep link URL\n * @param options - QR code appearance options (width, colors, error correction)\n * @param scheme - Custom URL scheme (only used if requestOrUrl is a ProofRequest)\n * @returns Promise resolving to SVG markup string\n *\n * @throws {Error} If the URL exceeds MAX_QR_DATA_SIZE (2953 bytes)\n *\n * @example\n * ```typescript\n * const request: ProofRequest = { ... };\n * const svg = await generateQRCodeSVG(request, { width: 300 });\n *\n * // Embed directly: <div dangerouslySetInnerHTML={{ __html: svg }} />\n * // Or save to file: fs.writeFileSync('qr.svg', svg);\n * ```\n */\nexport async function generateQRCodeSVG(\n requestOrUrl: ProofRequest | string,\n options: QRCodeOptions = {},\n scheme: string = DEFAULT_SCHEME\n): Promise<string> {\n const url = typeof requestOrUrl === 'string'\n ? requestOrUrl\n : buildProofRequestUrl(requestOrUrl, scheme);\n\n if (url.length > MAX_QR_DATA_SIZE) {\n throw new Error(\n `QR code data too large (${url.length} bytes). Maximum is ${MAX_QR_DATA_SIZE} bytes.`\n );\n }\n\n const mergedOptions = { ...DEFAULT_QR_OPTIONS, ...options };\n\n return QRCode.toString(url, {\n type: 'svg',\n width: mergedOptions.width,\n errorCorrectionLevel: mergedOptions.errorCorrectionLevel,\n margin: mergedOptions.margin,\n color: {\n dark: mergedOptions.darkColor,\n light: mergedOptions.lightColor,\n },\n });\n}\n\n/**\n * Renders a QR code directly to an HTML canvas element.\n *\n * Browser-only function that draws a QR code onto an existing canvas element.\n * Useful for interactive applications or when you need direct canvas manipulation.\n * The canvas dimensions will be set automatically based on the width option.\n *\n * @param canvas - HTML canvas element to render to (must exist in DOM)\n * @param requestOrUrl - Proof request object or pre-built deep link URL\n * @param options - QR code appearance options (width, colors, error correction)\n * @param scheme - Custom URL scheme (only used if requestOrUrl is a ProofRequest)\n * @returns Promise that resolves when rendering is complete\n *\n * @throws {Error} If the URL exceeds MAX_QR_DATA_SIZE (2953 bytes)\n * @throws {Error} If canvas is not a valid HTMLCanvasElement (browser only)\n *\n * @example\n * ```typescript\n * // In a React component:\n * const canvasRef = useRef<HTMLCanvasElement>(null);\n *\n * useEffect(() => {\n * if (canvasRef.current) {\n * generateQRCodeToCanvas(canvasRef.current, request, { width: 400 });\n * }\n * }, [request]);\n *\n * return <canvas ref={canvasRef} />;\n * ```\n */\nexport async function generateQRCodeToCanvas(\n canvas: HTMLCanvasElement,\n requestOrUrl: ProofRequest | string,\n options: QRCodeOptions = {},\n scheme: string = DEFAULT_SCHEME\n): Promise<void> {\n const url = typeof requestOrUrl === 'string'\n ? requestOrUrl\n : buildProofRequestUrl(requestOrUrl, scheme);\n\n if (url.length > MAX_QR_DATA_SIZE) {\n throw new Error(\n `QR code data too large (${url.length} bytes). Maximum is ${MAX_QR_DATA_SIZE} bytes.`\n );\n }\n\n const mergedOptions = { ...DEFAULT_QR_OPTIONS, ...options };\n\n await QRCode.toCanvas(canvas, url, {\n width: mergedOptions.width,\n errorCorrectionLevel: mergedOptions.errorCorrectionLevel,\n margin: mergedOptions.margin,\n color: {\n dark: mergedOptions.darkColor,\n light: mergedOptions.lightColor,\n },\n });\n}\n\n/**\n * Estimates the byte size of a QR code's encoded data.\n *\n * Calculates the size of the deep link URL that will be encoded in the QR code,\n * and checks if it's within the maximum supported size (2953 bytes for QR version 40\n * with medium error correction). Use this before generating QR codes to avoid errors.\n *\n * @param requestOrUrl - Proof request object or pre-built deep link URL\n * @param scheme - Custom URL scheme (only used if requestOrUrl is a ProofRequest)\n * @returns Object with `size` in bytes and `withinLimit` boolean flag\n *\n * @example\n * ```typescript\n * const request: ProofRequest = { ... };\n * const { size, withinLimit } = estimateQRDataSize(request);\n *\n * if (!withinLimit) {\n * console.error(`QR code too large: ${size} bytes (max 2953)`);\n * // Consider reducing request data or splitting into multiple QR codes\n * }\n *\n * // Example output: { size: 384, withinLimit: true }\n * ```\n */\nexport function estimateQRDataSize(\n requestOrUrl: ProofRequest | string,\n scheme: string = DEFAULT_SCHEME\n): { size: number; withinLimit: boolean } {\n const url = typeof requestOrUrl === 'string'\n ? requestOrUrl\n : buildProofRequestUrl(requestOrUrl, scheme);\n return {\n size: url.length,\n withinLimit: url.length <= MAX_QR_DATA_SIZE,\n };\n}\n","/**\n * On-chain verification utilities for ZKProofport SDK\n *\n * Compatible with both ethers v5 and v6.\n */\n\nimport { ethers } from 'ethers';\nimport type { CircuitType, ParsedProof, VerifierContract } from './types';\nimport { VERIFIER_ABI, RPC_ENDPOINTS } from './constants';\n\n// ethers v5/v6 compatibility shims\nconst _ethers = ethers as any;\n\n/** @internal ethers v5/v6 compatibility shim */\nfunction hexZeroPad(value: string, length: number): string {\n // v6: ethers.zeroPadValue, v5: ethers.utils.hexZeroPad\n if (typeof _ethers.zeroPadValue === 'function') return _ethers.zeroPadValue(value, length);\n if (_ethers.utils?.hexZeroPad) return _ethers.utils.hexZeroPad(value, length);\n // manual fallback\n const hex = value.startsWith('0x') ? value.slice(2) : value;\n return '0x' + hex.padStart(length * 2, '0');\n}\n\n/** @internal ethers v5/v6 compatibility shim */\nfunction createJsonRpcProvider(url: string) {\n // v6: ethers.JsonRpcProvider, v5: ethers.providers.JsonRpcProvider\n if (typeof _ethers.JsonRpcProvider === 'function') return new _ethers.JsonRpcProvider(url);\n if (_ethers.providers?.JsonRpcProvider) return new _ethers.providers.JsonRpcProvider(url);\n throw new Error('No JsonRpcProvider found in ethers');\n}\n\n/**\n * @internal Resolve verifier from SDK config or proof response.\n * SDK config (customVerifier) takes priority over response-provided verifier.\n */\nfunction resolveVerifier(\n customVerifier?: VerifierContract,\n responseVerifier?: { verifierAddress?: string; chainId?: number }\n): VerifierContract | null {\n if (customVerifier) return customVerifier;\n if (responseVerifier?.verifierAddress) {\n return {\n address: responseVerifier.verifierAddress,\n chainId: responseVerifier.chainId ?? 0,\n abi: VERIFIER_ABI,\n };\n }\n return null;\n}\n\n/**\n * Get verifier contract instance for interacting with on-chain verifier contracts.\n *\n * @param providerOrSigner - ethers.js Provider or Signer instance (v5 or v6 compatible)\n * @param verifier - Verifier contract configuration containing address and ABI\n * @returns ethers.Contract instance connected to the verifier\n *\n * @example\n * ```typescript\n * const provider = new ethers.JsonRpcProvider(rpcUrl);\n * const contract = getVerifierContract(provider, {\n * address: '0x...',\n * chainId: 11155111,\n * abi: VERIFIER_ABI\n * });\n * ```\n */\nexport function getVerifierContract(\n providerOrSigner: any,\n verifier: VerifierContract\n): ethers.Contract {\n return new ethers.Contract(\n verifier.address,\n verifier.abi,\n providerOrSigner\n );\n}\n\n/**\n * Get default JSON-RPC provider for a chain using pre-configured RPC endpoints.\n *\n * @param chainId - The chain ID (e.g., 11155111 for Sepolia, 84532 for Base Sepolia)\n * @returns ethers.JsonRpcProvider instance for the specified chain\n * @throws Error if no RPC endpoint is configured for the chain\n *\n * @example\n * ```typescript\n * const provider = getDefaultProvider(11155111); // Sepolia\n * ```\n */\nexport function getDefaultProvider(chainId: number) {\n const rpcUrl = RPC_ENDPOINTS[chainId];\n if (!rpcUrl) {\n throw new Error(`No RPC endpoint configured for chain ${chainId}`);\n }\n return createJsonRpcProvider(rpcUrl);\n}\n\n/**\n * Verify a zero-knowledge proof on-chain by calling the verifier smart contract.\n *\n * This function resolves the verifier contract from SDK config or proof response,\n * connects to the blockchain, and calls the verify() method with the proof and public inputs.\n *\n * @param circuit - The canonical circuit identifier (e.g., \"coinbase_attestation\")\n * @param parsedProof - Parsed proof object containing proofHex and publicInputsHex\n * @param providerOrSigner - Optional ethers.js Provider or Signer instance. If not provided, uses default RPC for the chain\n * @param customVerifier - Optional custom verifier contract config (takes priority over responseVerifier)\n * @param responseVerifier - Optional verifier info from proof generation response\n * @returns Promise resolving to verification result with valid flag and optional error message\n *\n * @example\n * ```typescript\n * const parsed = parseProofForOnChain(proof, publicInputs, numPublicInputs);\n * const result = await verifyProofOnChain(\n * 'coinbase_attestation',\n * parsed,\n * provider,\n * { address: '0x...', chainId: 11155111, abi: VERIFIER_ABI }\n * );\n *\n * if (result.valid) {\n * console.log('Proof is valid!');\n * } else {\n * console.error('Verification failed:', result.error);\n * }\n * ```\n */\nexport async function verifyProofOnChain(\n circuit: CircuitType,\n parsedProof: ParsedProof,\n providerOrSigner?: any,\n customVerifier?: VerifierContract,\n responseVerifier?: { verifierAddress?: string; chainId?: number }\n): Promise<{ valid: boolean; error?: string }> {\n const verifier = resolveVerifier(customVerifier, responseVerifier);\n if (!verifier) {\n return {\n valid: false,\n error: 'No verifier address provided. Configure via SDK or ensure proof response includes verifierAddress.',\n };\n }\n\n const provider = providerOrSigner || (verifier.chainId > 0 ? getDefaultProvider(verifier.chainId) : null);\n if (!provider) {\n return {\n valid: false,\n error: 'No provider available. Provide a provider or ensure chainId is set for RPC lookup.',\n };\n }\n\n const contract = getVerifierContract(provider, verifier);\n\n try {\n const isValid = await contract.verify(\n parsedProof.proofHex,\n parsedProof.publicInputsHex\n );\n\n return { valid: isValid };\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : String(error);\n return { valid: false, error: errorMessage };\n }\n}\n\n/** @internal Ensure a hex string has the 0x prefix */\nfunction ensureHexPrefix(hex: string): string {\n return hex.startsWith('0x') ? hex : `0x${hex}`;\n}\n\n/**\n * Parse proof response into format suitable for on-chain verification.\n *\n * Converts proof and public inputs from relay response format to the format\n * expected by Solidity verifier contracts. Public inputs are zero-padded to\n * 32 bytes (bytes32) to match Solidity's bytes32[] type.\n *\n * @param proof - Proof bytes as hex string (with or without 0x prefix)\n * @param publicInputs - Array of public input values as hex strings\n * @param numPublicInputs - Number of public inputs (for validation)\n * @returns Parsed proof object ready for on-chain verification\n *\n * @example\n * ```typescript\n * const parsed = parseProofForOnChain(\n * '0x1a2b3c...',\n * ['0x01', '0x02', '0x03'],\n * 3\n * );\n *\n * // parsed.proofHex: '0x1a2b3c...'\n * // parsed.publicInputsHex: ['0x0000...01', '0x0000...02', '0x0000...03']\n * ```\n */\nexport function parseProofForOnChain(\n proof: string,\n publicInputs: string[],\n numPublicInputs: number\n): ParsedProof {\n const proofHex = ensureHexPrefix(proof);\n\n const publicInputsHex = publicInputs.map((input) => {\n return hexZeroPad(ensureHexPrefix(input), 32);\n });\n\n return {\n proofHex,\n publicInputsHex,\n numPublicInputs,\n };\n}\n\n/** @internal Require a verifier or throw with a helpful message */\nfunction requireVerifier(circuit: CircuitType, verifier?: VerifierContract): VerifierContract {\n if (!verifier) {\n throw new Error(`No verifier configured for circuit '${circuit}'. Configure via SDK verifiers option.`);\n }\n return verifier;\n}\n\n/**\n * Get verifier contract address for a circuit.\n *\n * @param circuit - The canonical circuit identifier (e.g., \"coinbase_attestation\")\n * @param customVerifier - Optional custom verifier contract config\n * @returns Verifier contract address as hex string\n * @throws Error if no verifier is configured for the circuit\n *\n * @example\n * ```typescript\n * const address = getVerifierAddress('coinbase_attestation', verifierConfig);\n * console.log(address); // '0x1234...'\n * ```\n */\nexport function getVerifierAddress(\n circuit: CircuitType,\n customVerifier?: VerifierContract\n): string {\n return requireVerifier(circuit, customVerifier).address;\n}\n\n/**\n * Get chain ID for a circuit's verifier contract.\n *\n * @param circuit - The canonical circuit identifier (e.g., \"coinbase_attestation\")\n * @param customVerifier - Optional custom verifier contract config\n * @returns Chain ID number (e.g., 11155111 for Sepolia, 84532 for Base Sepolia)\n * @throws Error if no verifier is configured for the circuit\n *\n * @example\n * ```typescript\n * const chainId = getVerifierChainId('coinbase_attestation', verifierConfig);\n * console.log(chainId); // 11155111\n * ```\n */\nexport function getVerifierChainId(\n circuit: CircuitType,\n customVerifier?: VerifierContract\n): number {\n return requireVerifier(circuit, customVerifier).chainId;\n}\n\n/**\n * Extract scope value from public inputs array.\n *\n * The scope is a bytes32 value encoded across 32 consecutive field elements\n * in the public inputs. The exact position depends on the circuit type.\n *\n * @param publicInputsHex - Array of public input hex strings (zero-padded to 32 bytes)\n * @param circuit - Optional circuit identifier to determine field positions\n * @returns Reconstructed scope as hex string with 0x prefix, or null if inputs are insufficient\n *\n * @example\n * ```typescript\n * const scope = extractScopeFromPublicInputs(publicInputsHex, 'coinbase_attestation');\n * console.log(scope); // '0x7a6b70726f6f66706f72742e636f6d...'\n * ```\n */\nexport function extractScopeFromPublicInputs(\n publicInputsHex: string[],\n circuit?: string,\n): string | null {\n let start: number, end: number;\n if (circuit === 'coinbase_country_attestation') {\n start = 86; end = 117;\n } else {\n start = 64; end = 95;\n }\n if (publicInputsHex.length <= end) return null;\n const scopeFields = publicInputsHex.slice(start, end + 1);\n return reconstructBytes32FromFields(scopeFields);\n}\n\n/**\n * Extract nullifier value from public inputs array.\n *\n * The nullifier is a bytes32 value encoded across 32 consecutive field elements\n * in the public inputs. The exact position depends on the circuit type.\n * Nullifiers are used for duplicate proof detection and must be unique per user+scope.\n *\n * @param publicInputsHex - Array of public input hex strings (zero-padded to 32 bytes)\n * @param circuit - Optional circuit identifier to determine field positions\n * @returns Reconstructed nullifier as hex string with 0x prefix, or null if inputs are insufficient\n *\n * @example\n * ```typescript\n * const nullifier = extractNullifierFromPublicInputs(publicInputsHex, 'coinbase_attestation');\n * console.log(nullifier); // '0xabcd1234...'\n *\n * // Check if nullifier is already registered\n * const isRegistered = await isNullifierRegistered(nullifier, registryAddress, provider);\n * ```\n */\nexport function extractNullifierFromPublicInputs(\n publicInputsHex: string[],\n circuit?: string,\n): string | null {\n let start: number, end: number;\n if (circuit === 'coinbase_country_attestation') {\n start = 118; end = 149;\n } else {\n start = 96; end = 127;\n }\n if (publicInputsHex.length <= end) return null;\n const nullifierFields = publicInputsHex.slice(start, end + 1);\n return reconstructBytes32FromFields(nullifierFields);\n}\n\n/** @internal Reconstruct a bytes32 value from 32 individual field elements */\nfunction reconstructBytes32FromFields(fields: string[]): string {\n if (fields.length !== 32) {\n throw new Error(`Expected 32 fields, got ${fields.length}`);\n }\n const bytes = fields.map(f => {\n const byte = BigInt(f) & 0xFFn;\n return byte.toString(16).padStart(2, '0');\n }).join('');\n return '0x' + bytes;\n}\n\n/**\n * Check if a nullifier is already registered on-chain in the ZKProofport nullifier registry.\n *\n * This function queries the on-chain nullifier registry contract to determine if a nullifier\n * has been used before. This is used to prevent duplicate proof submissions from the same user\n * for the same scope.\n *\n * @param nullifier - The nullifier hash as hex string with 0x prefix\n * @param registryAddress - ZKProofportNullifierRegistry contract address\n * @param provider - ethers.js Provider instance (v5 or v6 compatible)\n * @returns Promise resolving to true if nullifier is registered, false otherwise\n *\n * @example\n * ```typescript\n * const nullifier = extractNullifierFromPublicInputs(publicInputsHex, circuit);\n * const isRegistered = await isNullifierRegistered(\n * nullifier,\n * '0x...',\n * provider\n * );\n *\n * if (isRegistered) {\n * console.log('This nullifier has already been used');\n * }\n * ```\n */\nexport async function isNullifierRegistered(\n nullifier: string,\n registryAddress: string,\n provider: any\n): Promise<boolean> {\n const { ZKPROOFPORT_NULLIFIER_REGISTRY_ABI } = await import('./constants');\n const contract = new ethers.Contract(registryAddress, ZKPROOFPORT_NULLIFIER_REGISTRY_ABI, provider);\n try {\n return await contract.isNullifierRegistered(nullifier);\n } catch {\n return false;\n }\n}\n\n/**\n * Get detailed information about a registered nullifier from the on-chain registry.\n *\n * This function retrieves the registration timestamp, scope, and circuit ID for a nullifier\n * that has been registered on-chain. This metadata is useful for auditing and analytics.\n *\n * @param nullifier - The nullifier hash as hex string with 0x prefix\n * @param registryAddress - ZKProofportNullifierRegistry contract address\n * @param provider - ethers.js Provider instance (v5 or v6 compatible)\n * @returns Promise resolving to nullifier info object, or null if not registered\n *\n * @example\n * ```typescript\n * const info = await getNullifierInfo(nullifier, registryAddress, provider);\n *\n * if (info) {\n * console.log('Registered at:', new Date(info.registeredAt * 1000));\n * console.log('Scope:', info.scope);\n * console.log('Circuit:', info.circuitId);\n * } else {\n * console.log('Nullifier not registered');\n * }\n * ```\n */\nexport async function getNullifierInfo(\n nullifier: string,\n registryAddress: string,\n provider: any\n): Promise<{ registeredAt: number; scope: string; circuitId: string } | null> {\n const { ZKPROOFPORT_NULLIFIER_REGISTRY_ABI } = await import('./constants');\n const contract = new ethers.Contract(registryAddress, ZKPROOFPORT_NULLIFIER_REGISTRY_ABI, provider);\n try {\n const [registeredAt, scope, circuitId] = await contract.getNullifierInfo(nullifier);\n if (BigInt(registeredAt) === 0n) return null;\n return {\n registeredAt: Number(registeredAt),\n scope: scope as string,\n circuitId: circuitId as string,\n };\n } catch {\n return null;\n }\n}\n","/**\n * Proofport SDK - Main class\n */\n\nimport type {\n ProofRequest,\n ProofResponse,\n CircuitType,\n CircuitInputs,\n CoinbaseKycInputs,\n CoinbaseCountryInputs,\n ProofportConfig,\n QRCodeOptions,\n ParsedProof,\n VerifierContract,\n AuthCredentials,\n AuthToken,\n RelayProofRequest,\n RelayProofResult,\n} from './types';\nimport {\n generateRequestId,\n buildProofRequestUrl,\n buildCallbackUrl,\n parseProofRequestUrl,\n parseProofResponseUrl,\n validateProofRequest,\n isProofportDeepLink,\n} from './deeplink';\nimport {\n generateQRCodeDataUrl,\n generateQRCodeSVG,\n generateQRCodeToCanvas,\n estimateQRDataSize,\n} from './qrcode';\nimport {\n verifyProofOnChain,\n parseProofForOnChain,\n getVerifierAddress,\n getVerifierChainId,\n getDefaultProvider,\n extractNullifierFromPublicInputs,\n extractScopeFromPublicInputs,\n isNullifierRegistered,\n getNullifierInfo,\n} from './verifier';\nimport {\n DEFAULT_SCHEME,\n DEFAULT_REQUEST_EXPIRY_MS,\n CIRCUIT_METADATA,\n RELAY_URLS,\n} from './constants';\nimport type { SDKEnvironment } from './types';\n\n\n/**\n * Main SDK class for interacting with the ZKProofport mobile app.\n *\n * Provides methods for creating proof requests, generating QR codes and deep links,\n * verifying proofs on-chain, and handling proof responses from the mobile app.\n *\n * @example\n * ```typescript\n * import { ProofportSDK } from '@zkproofport-app/sdk';\n *\n * // Initialize SDK (uses production relay by default)\n * const sdk = ProofportSDK.create();\n *\n * // Authenticate\n * await sdk.login({ clientId: 'your-id', apiKey: 'your-key' });\n *\n * // Create proof request via relay\n * const relay = await sdk.createRelayRequest('coinbase_attestation', {\n * scope: 'myapp.com'\n * });\n *\n * // Generate QR code for desktop users\n * const qrDataUrl = await sdk.generateQRCode(relay.deepLink);\n *\n * // Wait for proof via WebSocket (primary) or polling (fallback)\n * const result = await sdk.waitForProof(relay.requestId);\n * if (result.status === 'completed') {\n * console.log('Proof received:', result.proof);\n * }\n * ```\n */\nexport class ProofportSDK {\n private config: Required<Omit<ProofportConfig, 'relayUrl' | 'nullifierRegistry'>>;\n private pendingRequests: Map<string, ProofRequest> = new Map();\n private authToken: AuthToken | null = null;\n private relayUrl: string;\n private nullifierRegistry?: { address: string; chainId: number };\n private socket: any = null;\n\n /**\n * Creates a new ProofportSDK instance.\n *\n * For most use cases, prefer the static factory with environment presets:\n * ```typescript\n * const sdk = ProofportSDK.create('production');\n * ```\n *\n * @param config - SDK configuration options\n * @param config.scheme - Custom deep link scheme (default: 'zkproofport')\n * @param config.relayUrl - Relay server URL (required for relay features)\n * @param config.verifiers - Custom verifier contract addresses per circuit\n *\n * @example\n * ```typescript\n * const sdk = new ProofportSDK({\n * relayUrl: 'https://relay.zkproofport.app',\n * verifiers: {\n * coinbase_attestation: {\n * verifierAddress: '0x...',\n * chainId: 1\n * }\n * }\n * });\n * ```\n */\n constructor(config: ProofportConfig = {}) {\n this.config = {\n scheme: config.scheme || DEFAULT_SCHEME,\n verifiers: config.verifiers || {},\n };\n this.relayUrl = config.relayUrl || '';\n this.nullifierRegistry = config.nullifierRegistry;\n }\n\n // ============ Request Creation ============\n\n /**\n * @internal\n * Creates a Coinbase KYC verification proof request.\n *\n * Generates a proof request for verifying Coinbase KYC status without revealing\n * the actual attestation data. The proof confirms the user has passed Coinbase KYC\n * while maintaining privacy through zero-knowledge proofs.\n *\n * @param inputs - Circuit inputs for Coinbase KYC\n * @param inputs.scope - Application-specific scope (e.g., domain name)\n * @param options - Request configuration options\n\n * @param options.message - Custom message to display to user\n * @param options.dappName - Application name shown in ZKProofport app\n * @param options.dappIcon - Application icon URL shown in ZKProofport app\n * @param options.expiresInMs - Request expiration time in milliseconds (default: 10 minutes)\n *\n * @returns ProofRequest object with unique requestId and all request details\n *\n * @throws Error if scope is not provided\n *\n * @example\n * ```typescript\n * const request = sdk.createCoinbaseKycRequest({\n * scope: 'myapp.com'\n * }, {\n * dappName: 'My DApp',\n * message: 'Verify your KYC status to access this feature'\n * });\n *\n * const deepLink = sdk.getDeepLinkUrl(request);\n * ```\n */\n private createCoinbaseKycRequest(\n inputs: CoinbaseKycInputs,\n options: {\n message?: string;\n dappName?: string;\n dappIcon?: string;\n expiresInMs?: number;\n } = {}\n ): ProofRequest {\n if (!inputs.scope) {\n throw new Error('scope is required for coinbase_attestation circuit');\n }\n\n const request: ProofRequest = {\n requestId: generateRequestId(),\n circuit: 'coinbase_attestation',\n inputs,\n message: options.message,\n dappName: options.dappName,\n dappIcon: options.dappIcon,\n createdAt: Date.now(),\n expiresAt: Date.now() + (options.expiresInMs || DEFAULT_REQUEST_EXPIRY_MS),\n };\n\n this.pendingRequests.set(request.requestId, request);\n return request;\n }\n\n /**\n * @internal\n * Creates a Coinbase Country attestation proof request.\n *\n * Generates a proof request for verifying country eligibility through Coinbase\n * attestation without revealing the actual country data. The proof confirms the\n * user's country status while maintaining privacy through zero-knowledge proofs.\n *\n * @param inputs - Circuit inputs for Coinbase Country attestation\n * @param inputs.scope - Application-specific scope (e.g., domain name)\n * @param options - Request configuration options\n\n * @param options.message - Custom message to display to user\n * @param options.dappName - Application name shown in ZKProofport app\n * @param options.dappIcon - Application icon URL shown in ZKProofport app\n * @param options.expiresInMs - Request expiration time in milliseconds (default: 10 minutes)\n *\n * @returns ProofRequest object with unique requestId and all request details\n *\n * @throws Error if scope is not provided\n *\n * @example\n * ```typescript\n * const request = sdk.createCoinbaseCountryRequest({\n * scope: 'myapp.com'\n * }, {\n * dappName: 'My DApp',\n * message: 'Verify your country eligibility'\n * });\n * ```\n */\n private createCoinbaseCountryRequest(\n inputs: CoinbaseCountryInputs,\n options: {\n message?: string;\n dappName?: string;\n dappIcon?: string;\n expiresInMs?: number;\n } = {}\n ): ProofRequest {\n if (!inputs.scope) {\n throw new Error('scope is required for coinbase_country_attestation circuit');\n }\n if (!inputs.countryList || !Array.isArray(inputs.countryList) || inputs.countryList.length === 0) {\n throw new Error('countryList is required for coinbase_country_attestation circuit');\n }\n if (typeof inputs.isIncluded !== 'boolean') {\n throw new Error('isIncluded is required for coinbase_country_attestation circuit');\n }\n\n const request: ProofRequest = {\n requestId: generateRequestId(),\n circuit: 'coinbase_country_attestation',\n inputs,\n message: options.message,\n dappName: options.dappName,\n dappIcon: options.dappIcon,\n createdAt: Date.now(),\n expiresAt: Date.now() + (options.expiresInMs || DEFAULT_REQUEST_EXPIRY_MS),\n };\n\n this.pendingRequests.set(request.requestId, request);\n return request;\n }\n\n /**\n * @internal\n * Creates a generic proof request for any supported circuit type.\n *\n * Routes to the appropriate circuit-specific request creation method based on\n * the circuit type. Use this for dynamic circuit selection or when the circuit\n * type is determined at runtime.\n *\n * @param circuit - Circuit type identifier ('coinbase_attestation' | 'coinbase_country_attestation')\n * @param inputs - Circuit-specific inputs\n * @param options - Request configuration options\n\n * @param options.message - Custom message to display to user\n * @param options.dappName - Application name shown in ZKProofport app\n * @param options.dappIcon - Application icon URL shown in ZKProofport app\n * @param options.expiresInMs - Request expiration time in milliseconds (default: 15 minutes)\n *\n * @returns ProofRequest object with unique requestId and all request details\n *\n * @throws Error if required inputs are missing for the specified circuit\n *\n * @example\n * ```typescript\n * const circuitType = userSelection; // Dynamic selection\n * const request = sdk.createProofRequest(\n * circuitType,\n * { scope: 'myapp.com' },\n * { dappName: 'My DApp' }\n * );\n * ```\n */\n private createProofRequest(\n circuit: CircuitType,\n inputs: CircuitInputs,\n options: {\n message?: string;\n dappName?: string;\n dappIcon?: string;\n expiresInMs?: number;\n } = {}\n ): ProofRequest {\n if (circuit === 'coinbase_country_attestation') {\n return this.createCoinbaseCountryRequest(inputs as CoinbaseCountryInputs, options);\n } else {\n return this.createCoinbaseKycRequest(inputs as CoinbaseKycInputs, options);\n }\n }\n\n // ============ Deep Link Generation ============\n\n /**\n * @internal\n * Generates a deep link URL for a proof request.\n *\n * Creates a zkproofport:// URL that opens the ZKProofport mobile app with the\n * specified proof request. The URL contains all request details encoded as query\n * parameters.\n *\n * @param request - ProofRequest object to encode as deep link\n *\n * @returns Deep link URL string (e.g., 'zkproofport://proof?requestId=...')\n *\n * @example\n * ```typescript\n * const request = sdk.createCoinbaseKycRequest({ scope: 'myapp.com' });\n * const url = sdk.getDeepLinkUrl(request);\n * // url: 'zkproofport://proof?requestId=abc123&circuit=coinbase_attestation&...'\n * ```\n */\n private getDeepLinkUrl(request: ProofRequest): string {\n return buildProofRequestUrl(request, this.config.scheme);\n }\n\n /**\n * @internal\n * Opens the ZKProofport mobile app with a proof request.\n *\n * Redirects the browser to the deep link URL, which opens the ZKProofport app\n * if installed. Only works in mobile browser environments. For desktop, use\n * requestProof() to display a QR code instead.\n *\n * @param request - ProofRequest object to send to the app\n *\n * @example\n * ```typescript\n * const request = sdk.createCoinbaseKycRequest({ scope: 'myapp.com' });\n * if (ProofportSDK.isMobile()) {\n * sdk.openProofRequest(request); // Opens app directly\n * }\n * ```\n */\n private openProofRequest(request: ProofRequest): void {\n const url = this.getDeepLinkUrl(request);\n window.location.href = url;\n }\n\n /**\n * @internal\n * Requests a proof with automatic platform detection.\n *\n * Detects whether the user is on mobile or desktop and automatically chooses\n * the appropriate flow:\n * - Mobile: Opens the deep link directly to launch the ZKProofport app\n * - Desktop: Generates a QR code data URL for the user to scan\n *\n * @param request - ProofRequest object to send\n * @param qrOptions - QR code generation options (size, colors, logo) for desktop\n *\n * @returns Object containing deep link URL, optional QR code data URL, and platform detection result\n *\n * @example\n * ```typescript\n * const request = sdk.createCoinbaseKycRequest({ scope: 'myapp.com' });\n * const result = await sdk.requestProof(request);\n *\n * if (result.mobile) {\n * console.log('Opening app directly');\n * } else {\n * // Display QR code for desktop users\n * document.getElementById('qr').src = result.qrDataUrl;\n * }\n * ```\n */\n private async requestProof(\n request: ProofRequest,\n qrOptions?: QRCodeOptions\n ): Promise<{ deepLink: string; qrDataUrl?: string; mobile: boolean }> {\n const deepLink = this.getDeepLinkUrl(request);\n const mobile = ProofportSDK.isMobile();\n\n if (mobile) {\n window.location.href = deepLink;\n return { deepLink, mobile: true };\n }\n\n const qrDataUrl = await this.generateQRCode(request, qrOptions);\n return { deepLink, qrDataUrl, mobile: false };\n }\n\n // ============ QR Code Generation ============\n\n /**\n * Generates a QR code as a data URL for a proof request.\n *\n * Creates a PNG image data URL that can be directly set as an img src attribute.\n * Suitable for embedding QR codes in web pages for desktop users to scan with\n * their mobile device.\n *\n * @param requestOrUrl - ProofRequest object or deep link URL string\n * @param options - QR code customization options\n * @param options.size - QR code size in pixels (default: 256)\n * @param options.margin - Quiet zone margin in modules (default: 4)\n * @param options.darkColor - Color for dark modules (default: '#000000')\n * @param options.lightColor - Color for light modules (default: '#ffffff')\n * @param options.logoUrl - Optional center logo image URL\n * @param options.logoSize - Logo size as fraction of QR code (default: 0.2)\n *\n * @returns Promise resolving to PNG data URL (e.g., 'data:image/png;base64,...')\n *\n * @example\n * ```typescript\n * const request = sdk.createCoinbaseKycRequest({ scope: 'myapp.com' });\n * const qrUrl = await sdk.generateQRCode(request, {\n * size: 400,\n * darkColor: '#1a1a1a',\n * logoUrl: 'https://myapp.com/logo.png'\n * });\n * document.getElementById('qr-image').src = qrUrl;\n * ```\n */\n async generateQRCode(\n requestOrUrl: ProofRequest | string,\n options?: QRCodeOptions\n ): Promise<string> {\n return generateQRCodeDataUrl(requestOrUrl, options, this.config.scheme);\n }\n\n /**\n * Generates a QR code as an SVG string for a proof request.\n *\n * Creates a scalable vector graphics representation of the QR code, ideal for\n * high-resolution displays or when vector format is preferred over raster images.\n *\n * @param requestOrUrl - ProofRequest object or deep link URL string\n * @param options - QR code customization options\n * @param options.size - QR code size in pixels (default: 256)\n * @param options.margin - Quiet zone margin in modules (default: 4)\n * @param options.darkColor - Color for dark modules (default: '#000000')\n * @param options.lightColor - Color for light modules (default: '#ffffff')\n *\n * @returns Promise resolving to SVG string\n *\n * @example\n * ```typescript\n * const request = sdk.createCoinbaseKycRequest({ scope: 'myapp.com' });\n * const svgString = await sdk.generateQRCodeSVG(request);\n * document.getElementById('qr-container').innerHTML = svgString;\n * ```\n */\n async generateQRCodeSVG(\n requestOrUrl: ProofRequest | string,\n options?: QRCodeOptions\n ): Promise<string> {\n return generateQRCodeSVG(requestOrUrl, options, this.config.scheme);\n }\n\n /**\n * Renders a QR code directly to an HTML canvas element.\n *\n * Draws the QR code onto the provided canvas element, useful for custom\n * rendering workflows or when you need direct canvas manipulation.\n *\n * @param canvas - HTML canvas element to render to\n * @param requestOrUrl - ProofRequest object or deep link URL string\n * @param options - QR code customization options\n * @param options.size - QR code size in pixels (default: 256)\n * @param options.margin - Quiet zone margin in modules (default: 4)\n * @param options.darkColor - Color for dark modules (default: '#000000')\n * @param options.lightColor - Color for light modules (default: '#ffffff')\n *\n * @returns Promise that resolves when rendering is complete\n *\n * @example\n * ```typescript\n * const canvas = document.getElementById('qr-canvas') as HTMLCanvasElement;\n * const request = sdk.createCoinbaseKycRequest({ scope: 'myapp.com' });\n * await sdk.renderQRCodeToCanvas(canvas, request, { size: 400 });\n * ```\n */\n async renderQRCodeToCanvas(\n canvas: HTMLCanvasElement,\n requestOrUrl: ProofRequest | string,\n options?: QRCodeOptions\n ): Promise<void> {\n return generateQRCodeToCanvas(canvas, requestOrUrl, options, this.config.scheme);\n }\n\n /**\n * Checks if a proof request fits within QR code size limits.\n *\n * Estimates the encoded data size and validates it against QR code capacity limits.\n * Useful for validating requests before generating QR codes, especially when\n * including large custom messages or metadata.\n *\n * @param requestOrUrl - ProofRequest object or deep link URL string\n *\n * @returns Object with size in bytes and whether it fits within limits\n *\n * @example\n * ```typescript\n * const request = sdk.createCoinbaseKycRequest({ scope: 'myapp.com' });\n * const check = sdk.checkQRCodeSize(request);\n * if (!check.withinLimit) {\n * console.warn(`Request too large: ${check.size} bytes`);\n * }\n * ```\n */\n checkQRCodeSize(requestOrUrl: ProofRequest | string): { size: number; withinLimit: boolean } {\n return estimateQRDataSize(requestOrUrl, this.config.scheme);\n }\n\n // ============ Response Handling ============\n\n /**\n * @internal\n * Parses a proof response from a callback URL.\n *\n * Extracts and decodes proof response data from the callback URL query parameters\n * after the user completes proof generation in the ZKProofport app. The app\n * redirects to your callback URL with the proof data encoded as query parameters.\n *\n * @param url - Callback URL containing proof response data\n *\n * @returns ProofResponse object with status, proof data, and public inputs, or null if invalid\n *\n * @example\n * ```typescript\n * // In your callback endpoint handler\n * app.get('/callback', (req, res) => {\n * const callbackUrl = req.url;\n * const response = sdk.parseResponse(callbackUrl);\n *\n * if (response?.status === 'completed') {\n * console.log('Proof received:', response.proof);\n * console.log('Public inputs:', response.publicInputs);\n * } else if (response?.status === 'rejected') {\n * console.log('User rejected the request');\n * }\n * });\n * ```\n */\n private parseResponse(url: string): ProofResponse | null {\n return parseProofResponseUrl(url);\n }\n\n /**\n * @internal\n * Checks if a URL is a ZKProofport proof response callback.\n *\n * Validates whether the given URL contains the required query parameters for a\n * proof response. Useful for filtering and routing callback requests.\n *\n * @param url - URL to check\n *\n * @returns True if the URL appears to be a ZKProofport response callback\n *\n * @example\n * ```typescript\n * app.get('/callback', (req, res) => {\n * const fullUrl = `${req.protocol}://${req.get('host')}${req.originalUrl}`;\n * if (sdk.isProofportResponse(fullUrl)) {\n * const response = sdk.parseResponse(fullUrl);\n * // Handle proof response\n * }\n * });\n * ```\n */\n private isProofportResponse(url: string): boolean {\n try {\n const urlObj = new URL(url);\n return urlObj.searchParams.has('requestId') && urlObj.searchParams.has('status');\n } catch {\n return false;\n }\n }\n\n /**\n * @internal\n * Retrieves a pending proof request by its ID.\n *\n * Looks up a previously created proof request from the SDK's internal cache.\n * Useful for validating callback responses and maintaining request state.\n *\n * @param requestId - Unique request identifier\n *\n * @returns ProofRequest object if found, undefined otherwise\n *\n * @example\n * ```typescript\n * app.get('/callback', (req, res) => {\n * const response = sdk.parseResponse(req.url);\n * const originalRequest = sdk.getPendingRequest(response.requestId);\n *\n * if (originalRequest) {\n * console.log('Original request:', originalRequest);\n * sdk.clearPendingRequest(response.requestId);\n * }\n * });\n * ```\n */\n private getPendingRequest(requestId: string): ProofRequest | undefined {\n return this.pendingRequests.get(requestId);\n }\n\n /**\n * @internal\n * Clears a pending proof request from the internal cache.\n *\n * Removes a proof request from the SDK's pending requests map. Should be called\n * after successfully processing a proof response to prevent memory leaks.\n *\n * @param requestId - Unique request identifier to remove\n *\n * @example\n * ```typescript\n * app.get('/callback', (req, res) => {\n * const response = sdk.parseResponse(req.url);\n * if (response?.status === 'completed') {\n * // Process proof...\n * sdk.clearPendingRequest(response.requestId);\n * }\n * });\n * ```\n */\n private clearPendingRequest(requestId: string): void {\n this.pendingRequests.delete(requestId);\n }\n\n // ============ Verification ============\n\n /**\n * Verifies a zero-knowledge proof on-chain using the deployed verifier contract.\n *\n * Calls the Solidity verifier contract to cryptographically verify the proof's\n * validity. This ensures the proof was generated correctly and the public inputs\n * match the claimed values.\n *\n * @param circuit - Circuit type identifier\n * @param proof - Hex-encoded proof string from the ZKProofport app\n * @param publicInputs - Array of hex-encoded public input strings\n * @param providerOrSigner - ethers v6 Provider or Signer (defaults to base mainnet public RPC)\n *\n * @returns Promise resolving to verification result with valid boolean and optional error message\n *\n * @example\n * ```typescript\n * import { ethers } from 'ethers';\n *\n * const response = sdk.parseResponse(callbackUrl);\n * if (response?.status === 'completed') {\n * const provider = new ethers.JsonRpcProvider('https://mainnet.base.org');\n * const result = await sdk.verifyOnChain(\n * response.circuit,\n * response.proof,\n * response.publicInputs,\n * provider\n * );\n *\n * if (result.valid) {\n * console.log('Proof verified on-chain!');\n * } else {\n * console.error('Verification failed:', result.error);\n * }\n * }\n * ```\n */\n async verifyOnChain(\n circuit: CircuitType,\n proof: string,\n publicInputs: string[],\n providerOrSigner?: any\n ): Promise<{ valid: boolean; error?: string }> {\n const parsedProof = parseProofForOnChain(\n proof,\n publicInputs,\n publicInputs.length\n );\n\n const customVerifier = this.config.verifiers[circuit];\n return verifyProofOnChain(circuit, parsedProof, providerOrSigner, customVerifier);\n }\n\n /**\n * Verifies a proof response on-chain using the deployed verifier contract.\n *\n * Convenience method that extracts proof data from a ProofResponse object and\n * verifies it on-chain. Automatically handles incomplete or rejected responses.\n *\n * @param response - ProofResponse object from parseResponse()\n * @param providerOrSigner - ethers v6 Provider or Signer (defaults to base mainnet public RPC)\n *\n * @returns Promise resolving to verification result with valid boolean and optional error message\n *\n * @example\n * ```typescript\n * import { ethers } from 'ethers';\n *\n * app.get('/callback', async (req, res) => {\n * const response = sdk.parseResponse(req.url);\n *\n * if (response?.status === 'completed') {\n * const provider = new ethers.JsonRpcProvider('https://mainnet.base.org');\n * const result = await sdk.verifyResponseOnChain(response, provider);\n *\n * if (result.valid) {\n * // Grant access to user\n * res.json({ success: true, verified: true });\n * } else {\n * res.status(400).json({ error: result.error });\n * }\n * } else {\n * res.status(400).json({ error: 'Proof generation failed or rejected' });\n * }\n * });\n * ```\n */\n async verifyResponseOnChain(\n response: ProofResponse,\n providerOrSigner?: any\n ): Promise<{ valid: boolean; error?: string }> {\n if (response.status !== 'completed' || !response.proof || !response.publicInputs) {\n return { valid: false, error: 'Invalid or incomplete response' };\n }\n\n const parsedProof = parseProofForOnChain(\n response.proof,\n response.publicInputs,\n response.publicInputs.length\n );\n\n const customVerifier = this.config.verifiers[response.circuit];\n const responseVerifier = {\n verifierAddress: response.verifierAddress,\n chainId: response.chainId,\n };\n return verifyProofOnChain(response.circuit, parsedProof, providerOrSigner, customVerifier, responseVerifier);\n }\n\n // ============ Utility Methods ============\n\n /**\n * Gets the deployed verifier contract address for a circuit.\n *\n * Returns the Ethereum address of the Solidity verifier contract for the\n * specified circuit. Uses custom verifier if configured, otherwise returns\n * the default deployed address.\n *\n * @param circuit - Circuit type identifier\n *\n * @returns Ethereum address of the verifier contract (0x...)\n *\n * @example\n * ```typescript\n * const address = sdk.getVerifierAddress('coinbase_attestation');\n * console.log('Verifier deployed at:', address);\n * ```\n */\n getVerifierAddress(circuit: CircuitType): string {\n const customVerifier = this.config.verifiers[circuit];\n return getVerifierAddress(circuit, customVerifier);\n }\n\n /**\n * Gets the blockchain chain ID where the verifier contract is deployed.\n *\n * Returns the EIP-155 chain ID for the network where the verifier contract\n * is deployed. Uses custom verifier if configured, otherwise returns the\n * default chain ID (Base mainnet: 8453).\n *\n * @param circuit - Circuit type identifier\n *\n * @returns Chain ID number (e.g., 8453 for Base mainnet)\n *\n * @example\n * ```typescript\n * const chainId = sdk.getVerifierChainId('coinbase_attestation');\n * console.log('Verifier on chain:', chainId); // 8453 (Base mainnet)\n * ```\n */\n getVerifierChainId(circuit: CircuitType): number {\n const customVerifier = this.config.verifiers[circuit];\n return getVerifierChainId(circuit, customVerifier);\n }\n\n /**\n * Gets metadata for a specific circuit type.\n *\n * Returns circuit metadata including display name, description, required inputs,\n * and other configuration details.\n *\n * @param circuit - Circuit type identifier\n *\n * @returns Circuit metadata object with name, description, and configuration\n *\n * @example\n * ```typescript\n * const metadata = sdk.getCircuitMetadata('coinbase_attestation');\n * console.log('Circuit name:', metadata.name);\n * console.log('Description:', metadata.description);\n * ```\n */\n getCircuitMetadata(circuit: CircuitType) {\n return CIRCUIT_METADATA[circuit];\n }\n\n /**\n * Gets all supported circuit types.\n *\n * Returns an array of all circuit type identifiers that are currently supported\n * by the SDK and ZKProofport app.\n *\n * @returns Array of supported circuit type identifiers\n *\n * @example\n * ```typescript\n * const circuits = sdk.getSupportedCircuits();\n * console.log('Supported circuits:', circuits);\n * // ['coinbase_attestation', 'coinbase_country_attestation']\n * ```\n */\n getSupportedCircuits(): CircuitType[] {\n return Object.keys(CIRCUIT_METADATA) as CircuitType[];\n }\n\n /**\n * @internal\n * Validates a proof request for completeness and correctness.\n *\n * Checks that the proof request contains all required fields and that the\n * circuit-specific inputs are valid. Useful for catching configuration errors\n * before generating QR codes or sending requests to users.\n *\n * @param request - ProofRequest object to validate\n *\n * @returns Validation result with valid boolean and optional error message\n *\n * @example\n * ```typescript\n * const request = sdk.createCoinbaseKycRequest({ scope: 'myapp.com' });\n * const validation = sdk.validateRequest(request);\n *\n * if (!validation.valid) {\n * console.error('Invalid request:', validation.error);\n * }\n * ```\n */\n private validateRequest(request: ProofRequest): { valid: boolean; error?: string } {\n return validateProofRequest(request);\n }\n\n /**\n * @internal\n * Checks if a URL is a ZKProofport deep link.\n *\n * Validates whether the given URL uses the ZKProofport deep link scheme\n * (zkproofport:// by default) and has the correct format for a proof request.\n *\n * @param url - URL string to check\n *\n * @returns True if the URL is a valid ZKProofport deep link\n *\n * @example\n * ```typescript\n * const url = 'zkproofport://proof?requestId=abc123&circuit=coinbase_attestation';\n * if (sdk.isProofportDeepLink(url)) {\n * const request = sdk.parseDeepLink(url);\n * console.log('Parsed request:', request);\n * }\n * ```\n */\n private isProofportDeepLink(url: string): boolean {\n return isProofportDeepLink(url, this.config.scheme);\n }\n\n /**\n * @internal\n * Parses a proof request from a deep link URL.\n *\n * Extracts and decodes the proof request data from a zkproofport:// deep link URL.\n * Useful for handling deep link navigation in web applications or validating\n * deep link URLs before displaying QR codes.\n *\n * @param url - ZKProofport deep link URL string\n *\n * @returns ProofRequest object with all request details, or null if invalid\n *\n * @example\n * ```typescript\n * const deepLink = 'zkproofport://proof?requestId=abc123&circuit=coinbase_attestation&...';\n * const request = sdk.parseDeepLink(deepLink);\n *\n * if (request) {\n * console.log('Request ID:', request.requestId);\n * console.log('Circuit:', request.circuit);\n * }\n * ```\n */\n private parseDeepLink(url: string): ProofRequest | null {\n return parseProofRequestUrl(url);\n }\n\n // ============ Static Factory ============\n\n /**\n * Creates a new ProofportSDK instance with environment preset or custom config.\n * Defaults to `'production'` if no argument is provided.\n *\n * **Recommended usage** — use the default production relay:\n * ```typescript\n * const sdk = ProofportSDK.create();\n * ```\n *\n * Environment presets:\n * - `'production'` — relay.zkproofport.app (default)\n * - `'staging'` — stg-relay.zkproofport.app\n * - `'local'` — localhost:4001\n *\n * @param envOrConfig - Environment name or custom SDK configuration\n *\n * @returns New ProofportSDK instance\n *\n * @example\n * ```typescript\n * // Environment preset (recommended)\n * const sdk = ProofportSDK.create(); // production (default)\n * const sdk = ProofportSDK.create('staging');\n *\n * // Custom config\n * const sdk = ProofportSDK.create({\n * relayUrl: 'https://my-custom-relay.example.com',\n * });\n * ```\n */\n static create(envOrConfig?: SDKEnvironment | ProofportConfig): ProofportSDK {\n if (typeof envOrConfig === 'undefined') {\n return new ProofportSDK({ relayUrl: RELAY_URLS.production });\n }\n if (typeof envOrConfig === 'string') {\n const relayUrl = RELAY_URLS[envOrConfig];\n if (!relayUrl) {\n throw new Error(`Unknown environment: ${envOrConfig}. Use 'production', 'staging', or 'local'.`);\n }\n return new ProofportSDK({ relayUrl });\n }\n return new ProofportSDK(envOrConfig);\n }\n\n /**\n * Detects if the code is running on a mobile device.\n *\n * Uses user agent detection to determine if the current environment is a mobile\n * browser. This helps the SDK automatically choose between direct deep link\n * navigation (mobile) and QR code display (desktop).\n *\n * @returns True if running on a mobile device (iOS, Android, etc.)\n *\n * @example\n * ```typescript\n * if (ProofportSDK.isMobile()) {\n * // Open deep link directly\n * sdk.openProofRequest(request);\n * } else {\n * // Show QR code\n * const qr = await sdk.generateQRCode(request);\n * displayQRCode(qr);\n * }\n * ```\n */\n static isMobile(): boolean {\n if (typeof navigator === 'undefined') return false;\n return /Android|iPhone|iPad|iPod|webOS|BlackBerry|IEMobile|Opera Mini/i.test(\n navigator.userAgent\n );\n }\n\n /**\n * Authenticates with ZKProofport using client credentials via the relay server.\n *\n * Exchanges a client_id and api_key pair for a short-lived JWT token\n * that can be used to authenticate relay requests.\n *\n * @param credentials - Client ID and API key\n * @param relayUrl - Relay server URL (e.g., 'https://relay.zkproofport.app')\n * @returns Promise resolving to AuthToken with JWT token and metadata\n * @throws Error if authentication fails\n *\n * @example\n * ```typescript\n * const auth = await ProofportSDK.authenticate(\n * { clientId: 'your-client-id', apiKey: 'your-api-key' },\n * 'https://relay.zkproofport.app'\n * );\n * console.log('Token:', auth.token);\n * console.log('Expires in:', auth.expiresIn, 'seconds');\n * ```\n */\n static async authenticate(\n credentials: AuthCredentials,\n relayUrl: string\n ): Promise<AuthToken> {\n if (!credentials.clientId || !credentials.apiKey) {\n throw new Error('clientId and apiKey are required');\n }\n if (!relayUrl) {\n throw new Error('relayUrl is required');\n }\n\n const response = await fetch(`${relayUrl}/api/v1/auth/token`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n client_id: credentials.clientId,\n api_key: credentials.apiKey,\n }),\n });\n\n if (!response.ok) {\n const error = await response.json().catch(() => ({ error: `HTTP ${response.status}` }));\n throw new Error(error.error || `Authentication failed: HTTP ${response.status}`);\n }\n\n const data = await response.json();\n return {\n token: data.token,\n clientId: data.client_id,\n dappId: data.dapp_id,\n tier: data.tier,\n expiresIn: data.expires_in,\n expiresAt: Date.now() + (data.expires_in * 1000),\n };\n }\n\n /**\n * Checks if an auth token is still valid (not expired).\n *\n * @param auth - AuthToken to check\n * @returns True if the token has not expired\n *\n * @example\n * ```typescript\n * if (!ProofportSDK.isTokenValid(auth)) {\n * auth = await ProofportSDK.authenticate(credentials, relayUrl);\n * }\n * ```\n */\n static isTokenValid(auth: AuthToken): boolean {\n return Date.now() < auth.expiresAt - 30000; // 30s buffer\n }\n\n // ============ Relay Integration ============\n\n /**\n * Authenticates with ZKProofport and stores the token for relay requests.\n *\n * Instance method that authenticates via the relay server and stores\n * the JWT token internally, so subsequent relay requests are automatically authenticated.\n *\n * @param credentials - Client ID and API key\n * @returns Promise resolving to AuthToken\n * @throws Error if authentication fails or relayUrl is not configured\n *\n * @example\n * ```typescript\n * const sdk = ProofportSDK.create('production');\n *\n * await sdk.login({ clientId: 'your-id', apiKey: 'your-key' });\n * // SDK is now authenticated for relay requests\n * ```\n */\n async login(credentials: AuthCredentials): Promise<AuthToken> {\n if (!this.relayUrl) {\n throw new Error('relayUrl is required for authentication. Use ProofportSDK.create(\\'production\\') or set relayUrl in config.');\n }\n this.authToken = await ProofportSDK.authenticate(credentials, this.relayUrl);\n return this.authToken;\n }\n\n /**\n * Logs out by clearing the stored authentication token.\n */\n logout(): void {\n this.authToken = null;\n }\n\n /**\n * Returns whether the SDK instance is currently authenticated with a valid token.\n */\n isAuthenticated(): boolean {\n return this.authToken !== null && ProofportSDK.isTokenValid(this.authToken);\n }\n\n /**\n * Returns the current auth token, or null if not authenticated.\n */\n getAuthToken(): AuthToken | null {\n return this.authToken;\n }\n\n /**\n * Creates a proof request through the relay server.\n *\n * This is the recommended way to create proof requests. The relay server:\n * - Issues a server-side requestId (validated by the mobile app)\n * - Tracks request status in Redis\n * - Handles credit deduction and tier enforcement\n * - Builds the deep link with relay callback URL\n *\n * @param circuit - Circuit type identifier\n * @param inputs - Circuit-specific inputs\n * @param options - Request options (message, dappName, dappIcon, nonce)\n * @returns Promise resolving to RelayProofRequest with requestId, deepLink, pollUrl\n * @throws Error if not authenticated or relay request fails\n *\n * @example\n * ```typescript\n * const sdk = ProofportSDK.create();\n * await sdk.login({ clientId: 'id', apiKey: 'key' });\n *\n * const relay = await sdk.createRelayRequest('coinbase_attestation', {\n * scope: 'myapp.com'\n * }, { dappName: 'My DApp' });\n *\n * // Generate QR code from relay deep link\n * const qr = await sdk.generateQRCode(relay.deepLink);\n *\n * // Wait for proof (WebSocket primary, polling fallback)\n * const result = await sdk.waitForProof(relay.requestId);\n * ```\n */\n async createRelayRequest(\n circuit: CircuitType,\n inputs: CircuitInputs,\n options: {\n message?: string;\n dappName?: string;\n dappIcon?: string;\n nonce?: string;\n } = {}\n ): Promise<RelayProofRequest> {\n if (!this.authToken || !ProofportSDK.isTokenValid(this.authToken)) {\n throw new Error('Not authenticated. Call login() first.');\n }\n if (!this.relayUrl) {\n throw new Error('relayUrl is required. Set it in ProofportSDK config.');\n }\n\n const body: Record<string, unknown> = {\n circuitId: circuit,\n inputs,\n };\n if (options.message) body.message = options.message;\n if (options.dappName) body.dappName = options.dappName;\n if (options.dappIcon) body.dappIcon = options.dappIcon;\n if (options.nonce) body.nonce = options.nonce;\n\n const response = await fetch(`${this.relayUrl}/api/v1/proof/request`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'Authorization': `Bearer ${this.authToken.token}`,\n },\n body: JSON.stringify(body),\n });\n\n if (!response.ok) {\n const error = await response.json().catch(() => ({ error: `HTTP ${response.status}` }));\n throw new Error(error.error || `Relay request failed: HTTP ${response.status}`);\n }\n\n return await response.json() as RelayProofRequest;\n }\n\n /**\n * Polls the relay for proof result status.\n *\n * @param requestId - The relay-issued request ID\n * @returns Promise resolving to RelayProofResult\n * @throws Error if relay URL not configured or request not found\n *\n * @example\n * ```typescript\n * const result = await sdk.pollResult(relay.requestId);\n * if (result.status === 'completed') {\n * console.log('Proof:', result.proof);\n * console.log('Public inputs:', result.publicInputs);\n * }\n * ```\n */\n async pollResult(requestId: string): Promise<RelayProofResult> {\n if (!this.relayUrl) {\n throw new Error('relayUrl is required. Set it in ProofportSDK config.');\n }\n\n const response = await fetch(`${this.relayUrl}/api/v1/proof/${requestId}`);\n\n if (!response.ok) {\n if (response.status === 404) {\n throw new Error('Request not found or expired');\n }\n const error = await response.json().catch(() => ({ error: `HTTP ${response.status}` }));\n throw new Error(error.error || `Poll failed: HTTP ${response.status}`);\n }\n\n return await response.json() as RelayProofResult;\n }\n\n /**\n * Polls the relay until proof is completed or failed, with configurable interval and timeout.\n *\n * @param requestId - The relay-issued request ID\n * @param options - Polling options\n * @param options.intervalMs - Polling interval in milliseconds (default: 2000)\n * @param options.timeoutMs - Maximum polling time in milliseconds (default: 300000 = 5 min)\n * @param options.onStatusChange - Callback when status changes\n * @returns Promise resolving to final RelayProofResult\n * @throws Error if timeout or relay error\n */\n async waitForResult(\n requestId: string,\n options: {\n intervalMs?: number;\n timeoutMs?: number;\n onStatusChange?: (result: RelayProofResult) => void;\n } = {}\n ): Promise<RelayProofResult> {\n const interval = options.intervalMs || 2000;\n const timeout = options.timeoutMs || 300000;\n const startTime = Date.now();\n let lastStatus = '';\n\n while (Date.now() - startTime < timeout) {\n const result = await this.pollResult(requestId);\n\n if (result.status !== lastStatus) {\n lastStatus = result.status;\n options.onStatusChange?.(result);\n }\n\n if (result.status === 'completed' || result.status === 'failed') {\n return result;\n }\n\n await new Promise(resolve => setTimeout(resolve, interval));\n }\n\n throw new Error(`Polling timed out after ${timeout}ms`);\n }\n\n /**\n * Subscribes to real-time proof status updates via Socket.IO.\n *\n * This is the recommended way to receive proof results. Uses WebSocket\n * connection for instant delivery instead of polling.\n *\n * Requires `socket.io-client` package: `npm install socket.io-client`\n *\n * @param requestId - The relay-issued request ID to subscribe to\n * @param callbacks - Event callbacks for status changes and results\n * @param callbacks.onStatus - Called on status updates (pending, generating)\n * @param callbacks.onResult - Called when proof is completed or failed\n * @param callbacks.onError - Called on errors\n * @returns Unsubscribe function to clean up the connection\n * @throws Error if not authenticated, relayUrl not set, or socket.io-client not installed\n *\n * @example\n * ```typescript\n * const relay = await sdk.createRelayRequest('coinbase_attestation', { scope: 'myapp.com' });\n * const qr = await sdk.generateQRCode(relay.deepLink);\n *\n * const unsubscribe = await sdk.subscribe(relay.requestId, {\n * onResult: (result) => {\n * if (result.status === 'completed') {\n * console.log('Proof received!', result.proof);\n * }\n * },\n * onError: (error) => console.error('Error:', error),\n * });\n *\n * // Later: clean up\n * unsubscribe();\n * ```\n */\n async subscribe(\n requestId: string,\n callbacks: {\n onStatus?: (data: { requestId: string; status: string; deepLink?: string }) => void;\n onResult?: (result: RelayProofResult) => void;\n onError?: (error: { error: string; code?: number; requestId?: string }) => void;\n }\n ): Promise<() => void> {\n if (!this.authToken || !ProofportSDK.isTokenValid(this.authToken)) {\n throw new Error('Not authenticated. Call login() first.');\n }\n if (!this.relayUrl) {\n throw new Error('relayUrl is required. Set it in ProofportSDK config.');\n }\n\n let ioConnect: any;\n try {\n const mod: any = await import('socket.io-client');\n ioConnect = mod.io ?? mod.connect ?? mod.default;\n } catch {\n throw new Error(\n 'socket.io-client is required for real-time updates. Install it: npm install socket.io-client'\n );\n }\n\n if (typeof ioConnect !== 'function') {\n throw new Error('Failed to load socket.io-client: io function not found');\n }\n\n // Connect to relay /proof namespace\n const socket = ioConnect(`${this.relayUrl}/proof`, {\n path: '/socket.io',\n auth: { token: this.authToken.token },\n transports: ['websocket', 'polling'],\n });\n\n this.socket = socket;\n\n // Subscribe to the request room\n socket.on('connect', () => {\n socket.emit('proof:subscribe', { requestId });\n });\n\n // Handle connection errors (e.g. rejected by relay middleware)\n socket.on('connect_error', (err: Error) => {\n console.error(`[ProofportSDK] Socket.IO connect_error for requestId=${requestId}: ${err.message}`);\n callbacks.onError?.({ error: err.message, requestId });\n });\n\n // Listen for events\n if (callbacks.onStatus) {\n socket.on('proof:status', callbacks.onStatus);\n }\n if (callbacks.onResult) {\n socket.on('proof:result', callbacks.onResult);\n }\n if (callbacks.onError) {\n socket.on('proof:error', callbacks.onError);\n }\n\n // Return unsubscribe function\n return () => {\n socket.off('proof:status');\n socket.off('proof:result');\n socket.off('proof:error');\n socket.disconnect();\n if (this.socket === socket) {\n this.socket = null;\n }\n };\n }\n\n /**\n * Waits for a proof result using Socket.IO (primary) with polling fallback.\n *\n * Tries Socket.IO first for real-time delivery. If socket.io-client is not\n * installed or connection fails, automatically falls back to HTTP polling.\n *\n * @param requestId - The relay-issued request ID\n * @param options - Configuration options\n * @param options.timeoutMs - Maximum wait time in ms (default: 300000 = 5 min)\n * @param options.onStatusChange - Callback for status updates\n * @returns Promise resolving to final RelayProofResult\n */\n async waitForProof(\n requestId: string,\n options: {\n timeoutMs?: number;\n onStatusChange?: (result: RelayProofResult | { requestId: string; status: string; deepLink?: string }) => void;\n } = {}\n ): Promise<RelayProofResult> {\n const timeout = options.timeoutMs || 300000;\n\n // Try Socket.IO first\n if (this.authToken && ProofportSDK.isTokenValid(this.authToken) && this.relayUrl) {\n try {\n return await new Promise<RelayProofResult>((resolve, reject) => {\n const timer = setTimeout(() => {\n unsubscribePromise?.then(fn => fn());\n reject(new Error(`Waiting for proof timed out after ${timeout}ms`));\n }, timeout);\n\n const unsubscribePromise = this.subscribe(requestId, {\n onStatus: (data) => {\n options.onStatusChange?.(data);\n },\n onResult: (result) => {\n clearTimeout(timer);\n unsubscribePromise?.then(fn => fn());\n resolve(result);\n },\n onError: (error) => {\n clearTimeout(timer);\n unsubscribePromise?.then(fn => fn());\n reject(new Error(error.error));\n },\n });\n });\n } catch (err: any) {\n // Re-throw timeout — that's a real failure the caller should handle\n if (err.message?.includes('timed out')) {\n throw err;\n }\n // socket.io-client missing or connection failed → fall back to polling silently\n console.warn('Socket.IO unavailable, falling back to HTTP polling:', err.message);\n }\n }\n\n // Fallback: HTTP polling\n return this.waitForResult(requestId, {\n timeoutMs: timeout,\n onStatusChange: options.onStatusChange as any,\n });\n }\n\n /**\n * Disconnects the Socket.IO connection if active.\n */\n disconnect(): void {\n if (this.socket) {\n this.socket.disconnect();\n this.socket = null;\n }\n }\n\n // ============ Nullifier Utilities ============\n\n /**\n * Extracts the nullifier from proof public inputs.\n *\n * The nullifier is a bytes32 value derived from the user's address and scope,\n * used to prevent duplicate proof submissions. Each user+scope combination\n * produces a unique nullifier.\n *\n * @param publicInputs - Array of public input hex strings from proof response\n * @param circuit - Circuit type to determine field positions\n * @returns Nullifier as hex string (0x...), or null if inputs are insufficient\n *\n * @example\n * ```typescript\n * const result = await sdk.waitForProof(relay.requestId);\n * if (result.status === 'completed') {\n * const nullifier = sdk.extractNullifier(result.publicInputs, result.circuit);\n * console.log('Nullifier:', nullifier);\n * }\n * ```\n */\n extractNullifier(publicInputs: string[], circuit: CircuitType): string | null {\n return extractNullifierFromPublicInputs(publicInputs, circuit);\n }\n\n /**\n * Extracts the scope from proof public inputs.\n *\n * The scope is an application-specific identifier (e.g., domain name) encoded\n * as bytes32 in the proof's public inputs.\n *\n * @param publicInputs - Array of public input hex strings from proof response\n * @param circuit - Circuit type to determine field positions\n * @returns Scope as hex string (0x...), or null if inputs are insufficient\n *\n * @example\n * ```typescript\n * const result = await sdk.waitForProof(relay.requestId);\n * if (result.status === 'completed') {\n * const scope = sdk.extractScope(result.publicInputs, result.circuit);\n * console.log('Scope:', scope);\n * }\n * ```\n */\n extractScope(publicInputs: string[], circuit: CircuitType): string | null {\n return extractScopeFromPublicInputs(publicInputs, circuit);\n }\n\n /**\n * Checks if a nullifier is already registered on-chain.\n *\n * Queries the ZKProofportNullifierRegistry contract to determine if the\n * nullifier has been used before. Used to prevent duplicate proof submissions.\n *\n * Requires `nullifierRegistry` in SDK config.\n *\n * @param nullifier - Nullifier hex string from extractNullifier()\n * @param provider - Optional ethers provider (defaults to public RPC for configured chain)\n * @returns True if nullifier is already registered\n * @throws Error if nullifierRegistry is not configured\n *\n * @example\n * ```typescript\n * const sdk = ProofportSDK.create({\n * relayUrl: 'https://relay.zkproofport.app',\n * nullifierRegistry: { address: '0x...', chainId: 8453 }\n * });\n *\n * const nullifier = sdk.extractNullifier(publicInputs, circuit);\n * const isDuplicate = await sdk.checkNullifier(nullifier);\n * ```\n */\n async checkNullifier(nullifier: string, provider?: any): Promise<boolean> {\n if (!this.nullifierRegistry) {\n throw new Error('nullifierRegistry is required. Set it in ProofportSDK config.');\n }\n const p = provider || getDefaultProvider(this.nullifierRegistry.chainId);\n return isNullifierRegistered(nullifier, this.nullifierRegistry.address, p);\n }\n\n /**\n * Gets detailed information about a registered nullifier from on-chain registry.\n *\n * Retrieves the registration timestamp, scope, and circuit ID for a nullifier.\n * Returns null if the nullifier is not registered.\n *\n * Requires `nullifierRegistry` in SDK config.\n *\n * @param nullifier - Nullifier hex string from extractNullifier()\n * @param provider - Optional ethers provider (defaults to public RPC for configured chain)\n * @returns Nullifier info or null if not registered\n * @throws Error if nullifierRegistry is not configured\n *\n * @example\n * ```typescript\n * const info = await sdk.getNullifierDetails(nullifier);\n * if (info) {\n * console.log('Registered at:', new Date(info.registeredAt * 1000));\n * console.log('Circuit:', info.circuitId);\n * }\n * ```\n */\n async getNullifierDetails(\n nullifier: string,\n provider?: any\n ): Promise<{ registeredAt: number; scope: string; circuitId: string } | null> {\n if (!this.nullifierRegistry) {\n throw new Error('nullifierRegistry is required. Set it in ProofportSDK config.');\n }\n const p = provider || getDefaultProvider(this.nullifierRegistry.chainId);\n return getNullifierInfo(nullifier, this.nullifierRegistry.address, p);\n }\n}\n\nexport default ProofportSDK;\n"],"names":["ethers"],"mappings":";;;;;;;AAAA;;AAEG;AAIH;;;;;;;;;AASG;AACI,MAAM,UAAU,GAAmC;AACxD,IAAA,UAAU,EAA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