{"version":3,"sources":["../src/react.tsx"],"sourcesContent":["/**\n * @file React integration for the 1auth SDK.\n *\n * Exports the {@link PayButton} component — a ready-to-use payment button that\n * handles authentication, session recovery, and intent submission without\n * requiring the consuming app to manage auth state directly.\n *\n * @module @rhinestone/1auth/react\n */\n\nimport * as React from \"react\";\nimport { OneAuthClient } from \"./client\";\nimport { tokenFetchError } from \"./sponsorship-fetch\";\nimport { toOneAuthError } from \"./errors\";\nimport type {\n  SendIntentOptions,\n  SendIntentResult,\n  CloseOnStatus,\n  SponsorshipCallbackConfig,\n  SponsorshipUrlConfig,\n} from \"./types\";\n\n// Fingerprint icon SVG\nconst FingerprintIcon = ({ className }: { className?: string }) => (\n  <svg\n    className={className}\n    width=\"20\"\n    height=\"20\"\n    viewBox=\"0 0 24 24\"\n    fill=\"none\"\n    stroke=\"currentColor\"\n    strokeWidth=\"2\"\n    strokeLinecap=\"round\"\n    strokeLinejoin=\"round\"\n  >\n    <path d=\"M12 10a2 2 0 0 0-2 2c0 1.02-.1 2.51-.26 4\" />\n    <path d=\"M14 13.12c0 2.38 0 6.38-1 8.88\" />\n    <path d=\"M17.29 21.02c.12-.6.43-2.3.5-3.02\" />\n    <path d=\"M2 12a10 10 0 0 1 18-6\" />\n    <path d=\"M2 16h.01\" />\n    <path d=\"M21.8 16c.2-2 .131-5.354 0-6\" />\n    <path d=\"M5 19.5C5.5 18 6 15 6 12a6 6 0 0 1 .34-2\" />\n    <path d=\"M8.65 22c.21-.66.45-1.32.57-2\" />\n    <path d=\"M9 6.8a6 6 0 0 1 9 5.2v2\" />\n  </svg>\n);\n\n// Default styles\nconst defaultStyles: React.CSSProperties = {\n  display: \"inline-flex\",\n  alignItems: \"center\",\n  justifyContent: \"center\",\n  gap: \"8px\",\n  padding: \"16px 32px\",\n  fontSize: \"16px\",\n  fontWeight: 500,\n  color: \"#ffffff\",\n  backgroundColor: \"#18181b\",\n  border: \"none\",\n  borderRadius: \"9999px\",\n  cursor: \"pointer\",\n  transition: \"background-color 0.2s\",\n  width: \"100%\",\n};\n\nconst defaultDisabledStyles: React.CSSProperties = {\n  opacity: 0.5,\n  cursor: \"not-allowed\",\n};\n\nconst defaultHoverStyles: React.CSSProperties = {\n  backgroundColor: \"#27272a\",\n};\n\nconst defaultSuccessStyles: React.CSSProperties = {\n  backgroundColor: \"#16a34a\",\n  cursor: \"default\",\n};\n\n// Checkmark icon SVG\nconst CheckIcon = ({ className }: { className?: string }) => (\n  <svg\n    className={className}\n    width=\"20\"\n    height=\"20\"\n    viewBox=\"0 0 24 24\"\n    fill=\"none\"\n    stroke=\"currentColor\"\n    strokeWidth=\"2.5\"\n    strokeLinecap=\"round\"\n    strokeLinejoin=\"round\"\n  >\n    <path d=\"M20 6L9 17l-5-5\" />\n  </svg>\n);\n\nexport interface PayButtonProps {\n  /** The OneAuthClient instance */\n  client: OneAuthClient;\n  /**\n   * Intent parameters (calls, targetChain, etc.). `accountAddress` is omitted\n   * because PayButton resolves it internally (cached session or auth modal) and\n   * overwrites it on the sendIntent call — callers pass only calls + target\n   * chain, keeping the drop-in payment API intact.\n   */\n  intent: Omit<SendIntentOptions, \"closeOn\" | \"accountAddress\">;\n  /** Called when payment succeeds */\n  onSuccess?: (result: SendIntentResult) => void;\n  /** Called when payment fails */\n  onError?: (error: Error) => void;\n  /** When to close the dialog and return success. Defaults to \"preconfirmed\" */\n  closeOn?: CloseOnStatus;\n  /** Button text - defaults to \"Pay with 1auth\" */\n  children?: React.ReactNode;\n  /** Custom class name */\n  className?: string;\n  /** Custom inline styles (merged with defaults) */\n  style?: React.CSSProperties;\n  /** Disabled state */\n  disabled?: boolean;\n  /** Hide the fingerprint icon */\n  hideIcon?: boolean;\n}\n\n/**\n * A pre-built payment button that integrates 1auth passkey authentication\n * and intent submission into a single interactive element.\n *\n * The button manages its own loading and success states. On first click it\n * recovers the last authenticated user from `localStorage`; if none is found\n * it opens the auth modal before submitting the intent. On subsequent clicks\n * the stored session is reused so the user only needs to re-authenticate when\n * their session has been invalidated server-side.\n *\n * @param props - See {@link PayButtonProps} for the full set of options.\n *\n * @example\n * ```tsx\n * import { PayButton } from \"@rhinestone/1auth/react\";\n * import { client } from \"./auth\"; // your OneAuthClient instance\n *\n * <PayButton\n *   client={client}\n *   intent={{\n *     targetChain: 8453, // Base\n *     calls: [{ to: \"0xRecipient\", data: \"0x\", value: \"1000000\" }],\n *   }}\n *   onSuccess={(result) => console.log(\"tx:\", result.transactionHash)}\n *   onError={(err) => console.error(err)}\n * >\n *   Pay $5 USDC\n * </PayButton>\n * ```\n */\nexport function PayButton({\n  client,\n  intent,\n  onSuccess,\n  onError,\n  closeOn = \"preconfirmed\",\n  children = \"Pay with 1auth\",\n  className,\n  style,\n  disabled,\n  hideIcon,\n}: PayButtonProps) {\n  const [isProcessing, setIsProcessing] = React.useState(false);\n  const [isSuccess, setIsSuccess] = React.useState(false);\n  const [isHovered, setIsHovered] = React.useState(false);\n\n  const handleClick = async () => {\n    if (disabled || isProcessing || isSuccess) return;\n\n    setIsProcessing(true);\n\n    try {\n      await executePayment();\n    } catch (err) {\n      if (err instanceof Error && !err.message.includes(\"rejected\")) {\n        onError?.(err);\n      }\n    } finally {\n      setIsProcessing(false);\n    }\n  };\n\n  /**\n   * Core payment execution with built-in session recovery and re-auth retry.\n   *\n   * Flow:\n   * 1. On first call (`forceReauth = false`), attempt to load a cached user\n   *    from `localStorage` under the key `\"1auth-user\"`. If the JSON is\n   *    malformed the cache entry is removed so the next call starts clean.\n   * 2. If no cached user exists (or `forceReauth` is `true`), open the auth\n   *    modal. On success, persist `{ address }` to `localStorage`\n   *    so subsequent clicks skip authentication.\n   * 3. Submit the intent. If the server responds with \"User not found\" — which\n   *    happens when a cached account address no longer exists on the server —\n   *    clear `localStorage` and call `executePayment(true)` to force a fresh\n   *    authentication before retrying once.\n   *\n   * @param forceReauth - When `true`, skip the localStorage lookup and go\n   *   straight to the auth modal. Used internally on \"User not found\" errors\n   *   to recover from a stale cache without requiring a second user gesture.\n   */\n  const executePayment = async (forceReauth = false) => {\n    // Try to get existing account address from localStorage\n    let accountAddress: string | null = null;\n    if (!forceReauth) {\n      const savedUser = localStorage.getItem(\"1auth-user\");\n      if (savedUser) {\n        try {\n          const parsed = JSON.parse(savedUser);\n          accountAddress = parsed.address || null;\n        } catch {\n          localStorage.removeItem(\"1auth-user\");\n        }\n      }\n    }\n\n    // If no account address (or forced reauth), authenticate first\n    if (!accountAddress) {\n      const authResult = await client.authWithModal();\n      if (authResult.success && authResult.user) {\n        accountAddress = authResult.user.address || null;\n        const stored: Record<string, string> = {};\n        if (accountAddress) stored.address = accountAddress;\n        if (authResult.signerType) stored.signerType = authResult.signerType;\n        localStorage.setItem(\"1auth-user\", JSON.stringify(stored));\n      } else {\n        // Auth cancelled or failed\n        return;\n      }\n    }\n\n    // Send the intent\n    let result: SendIntentResult;\n    try {\n      result = await client.sendIntent({\n        ...intent,\n        // Guaranteed non-null: the `if (!accountAddress) { ...return }` guard\n        // above either resolved an address or bailed out before reaching here.\n        accountAddress,\n        closeOn,\n      });\n    } catch (err) {\n      // If user not found, clear localStorage and force re-authentication\n      if (err instanceof Error && err.message.includes(\"User not found\")) {\n        localStorage.removeItem(\"1auth-user\");\n        return executePayment(true);\n      }\n      throw err;\n    }\n\n    if (result.success) {\n      setIsSuccess(true);\n      onSuccess?.(result);\n    } else {\n      // If user not found error in result, clear localStorage and retry\n      if (result.error?.message?.includes(\"User not found\")) {\n        localStorage.removeItem(\"1auth-user\");\n        return executePayment(true);\n      }\n      onError?.(toOneAuthError(result.error, \"Payment failed\", \"INTENT_FAILED\"));\n    }\n  };\n\n  const combinedStyles: React.CSSProperties = {\n    ...defaultStyles,\n    ...(isSuccess ? defaultSuccessStyles : {}),\n    ...(isHovered && !disabled && !isProcessing && !isSuccess ? defaultHoverStyles : {}),\n    ...(disabled || isProcessing ? defaultDisabledStyles : {}),\n    ...style,\n  };\n\n  return (\n    <button\n      type=\"button\"\n      className={className}\n      style={combinedStyles}\n      onClick={handleClick}\n      disabled={disabled || isProcessing || isSuccess}\n      onMouseEnter={() => setIsHovered(true)}\n      onMouseLeave={() => setIsHovered(false)}\n    >\n      {isSuccess ? (\n        <>\n          <CheckIcon className=\"pay-button-icon\" />\n          Paid\n        </>\n      ) : isProcessing ? (\n        \"Processing...\"\n      ) : (\n        <>\n          {!hideIcon && <FingerprintIcon className=\"pay-button-icon\" />}\n          {children}\n        </>\n      )}\n    </button>\n  );\n}\n\n/**\n * Margin (ms) before a JWT's `exp` at which the cached access token is\n * treated as stale. Covers clock skew between the minting app server and\n * the orchestrator's verifier plus in-flight time of the prepare call —\n * a token that verifies fine locally can still be rejected downstream if\n * it expires mid-request.\n */\nconst ACCESS_TOKEN_EXPIRY_MARGIN_MS = 60_000;\n\n/**\n * Check whether a cached JWT access token is still safely usable.\n *\n * Decodes the payload WITHOUT verifying the signature — the client only\n * needs the `exp` claim to know when to re-mint; verification happens\n * server-side. Returns `false` (unusable) when the token is expired or\n * within {@link ACCESS_TOKEN_EXPIRY_MARGIN_MS} of expiry. Tokens that\n * can't be decoded or carry no numeric `exp` are treated as unusable so\n * a malformed cache entry never gets served indefinitely.\n */\nexport function isAccessTokenFresh(token: string): boolean {\n  try {\n    const payload = token.split(\".\")[1];\n    if (!payload) return false;\n    // base64url → base64 before atob; JWTs use the url-safe alphabet.\n    const json = atob(payload.replace(/-/g, \"+\").replace(/_/g, \"/\"));\n    const claims = JSON.parse(json) as { exp?: unknown };\n    if (typeof claims.exp !== \"number\") return false;\n    return Date.now() < claims.exp * 1000 - ACCESS_TOKEN_EXPIRY_MARGIN_MS;\n  } catch {\n    return false;\n  }\n}\n\n/**\n * Build a {@link SponsorshipCallbackConfig} from token endpoint URLs with an\n * expiry-aware access-token cache held in a closure.\n *\n * Exported as the non-React core of {@link useSponsorship} so the caching\n * behaviour is unit-testable (and usable outside React). The access token is\n * cached and re-used only while its `exp` claim is comfortably in the\n * future — a long-lived tab must re-mint rather than serve a token the\n * orchestrator will reject with a 401 (`\"exp\" claim timestamp check\n * failed`), which previously surfaced to users as \"Failed to get quote from\n * orchestrator\". The extension token is always fetched fresh per intent\n * because it binds to a specific `intentOp`.\n *\n * Both fetches use `credentials: \"include\"` so the app's own session cookies\n * authenticate the user — no separate auth channel needed.\n */\nexport function createCachedSponsorship(\n  config: SponsorshipUrlConfig,\n): SponsorshipCallbackConfig {\n  const { accessTokenUrl, extensionTokenUrl } = config;\n  let cachedToken: string | null = null;\n\n  const fetchAccessToken = async (): Promise<string> => {\n    const res = await fetch(accessTokenUrl, {\n      method: \"GET\",\n      credentials: \"include\",\n    });\n    if (!res.ok) {\n      // Folds the server's JSON error reason into the message so\n      // misconfigurations aren't reduced to an opaque HTTP status.\n      throw await tokenFetchError(\"sponsorship access token\", res);\n    }\n    const body = (await res.json()) as { token?: string };\n    if (!body.token) throw new Error(\"Missing `token` in access-token response\");\n    cachedToken = body.token;\n    return body.token;\n  };\n\n  return {\n    accessToken: async () =>\n      cachedToken && isAccessTokenFresh(cachedToken)\n        ? cachedToken\n        : await fetchAccessToken(),\n    getExtensionToken: async (intentOp: string) => {\n      const res = await fetch(extensionTokenUrl, {\n        method: \"POST\",\n        credentials: \"include\",\n        headers: { \"Content-Type\": \"application/json\" },\n        body: JSON.stringify({ intentOp }),\n      });\n      if (res.status === 401) {\n        // Access token likely expired — drop cached copy so the next\n        // accessToken() call re-mints, then surface the error for the\n        // integrator to retry.\n        cachedToken = null;\n      }\n      if (!res.ok) {\n        throw await tokenFetchError(\"sponsorship extension token\", res);\n      }\n      const body = (await res.json()) as { token?: string };\n      if (!body.token) throw new Error(\"Missing `token` in extension-token response\");\n      return body.token;\n    },\n  };\n}\n\n/**\n * React hook wrapper around {@link createCachedSponsorship}. The returned\n * config is stable across renders (memoized by URL), so passing it to\n * `new OneAuthClient({ sponsorship })` or `client.setSponsorship(...)` does\n * not thrash the client. Re-creating on URL change naturally resets the\n * cached token so we never serve a token minted against the previous\n * endpoint.\n */\nexport function useSponsorship(\n  config: SponsorshipUrlConfig,\n): SponsorshipCallbackConfig {\n  const { accessTokenUrl, extensionTokenUrl } = config;\n\n  return React.useMemo<SponsorshipCallbackConfig>(\n    () => createCachedSponsorship({ accessTokenUrl, extensionTokenUrl }),\n    [accessTokenUrl, extensionTokenUrl],\n  );\n}\n\n// Export the constructor from the same entrypoint that creates PayButton\n// errors. Separate tsup entry bundles do not share JavaScript class identity,\n// so consumers must use this export for reliable `instanceof` checks.\nexport { OneAuthError } from \"./errors\";\n\n// Re-export types for convenience\nexport type { SendIntentOptions, SendIntentResult, CloseOnStatus } from \"./types\";\n"],"mappings":";;;;;;;;;AAUA,YAAY,WAAW;AAcrB,SAsQM,UA3PJ,KAXF;AADF,IAAM,kBAAkB,CAAC,EAAE,UAAU,MACnC;AAAA,EAAC;AAAA;AAAA,IACC;AAAA,IACA,OAAM;AAAA,IACN,QAAO;AAAA,IACP,SAAQ;AAAA,IACR,MAAK;AAAA,IACL,QAAO;AAAA,IACP,aAAY;AAAA,IACZ,eAAc;AAAA,IACd,gBAAe;AAAA,IAEf;AAAA,0BAAC,UAAK,GAAE,6CAA4C;AAAA,MACpD,oBAAC,UAAK,GAAE,kCAAiC;AAAA,MACzC,oBAAC,UAAK,GAAE,qCAAoC;AAAA,MAC5C,oBAAC,UAAK,GAAE,0BAAyB;AAAA,MACjC,oBAAC,UAAK,GAAE,aAAY;AAAA,MACpB,oBAAC,UAAK,GAAE,gCAA+B;AAAA,MACvC,oBAAC,UAAK,GAAE,4CAA2C;AAAA,MACnD,oBAAC,UAAK,GAAE,iCAAgC;AAAA,MACxC,oBAAC,UAAK,GAAE,4BAA2B;AAAA;AAAA;AACrC;AAIF,IAAM,gBAAqC;AAAA,EACzC,SAAS;AAAA,EACT,YAAY;AAAA,EACZ,gBAAgB;AAAA,EAChB,KAAK;AAAA,EACL,SAAS;AAAA,EACT,UAAU;AAAA,EACV,YAAY;AAAA,EACZ,OAAO;AAAA,EACP,iBAAiB;AAAA,EACjB,QAAQ;AAAA,EACR,cAAc;AAAA,EACd,QAAQ;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