Skip to content

Conversation

joaquim-verges
Copy link
Member

@joaquim-verges joaquim-verges commented Sep 28, 2025


PR-Codex overview

This PR introduces a patch for the thirdweb package, enhancing the verifyTypedData function to handle 7702 accounts by adding a signature verification process.

Detailed summary

  • Added checks for the signature to ensure it is a valid hex format.
  • Implemented logic to recover the address from the messageHash using ox__Secp256k1.recoverAddress.
  • Compared the recovered address with the provided address, returning true if they match.
  • Included a try-catch block to handle potential errors during address recovery.

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

Summary by CodeRabbit

  • New Features
    • Enhanced typed-data verification with automatic signer recovery for improved reliability.
    • Added support for additional signature formats.
    • Improved compatibility with 7702 accounts.
  • Bug Fixes
    • Early validation now rejects invalid (non-hex) signatures.
    • More robust fallback behavior when recovery fails.
  • Chores
    • Bumped patch version of the package.

Copy link

changeset-bot bot commented Sep 28, 2025

🦋 Changeset detected

Latest commit: b411922

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
thirdweb Patch
@thirdweb-dev/nebula Patch
@thirdweb-dev/wagmi-adapter Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

vercel bot commented Sep 28, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
docs-v2 Ready Ready Preview Comment Sep 28, 2025 9:39pm
nebula Ready Ready Preview Comment Sep 28, 2025 9:39pm
thirdweb_playground Ready Ready Preview Comment Sep 28, 2025 9:39pm
thirdweb-www Ready Ready Preview Comment Sep 28, 2025 9:39pm
wallet-ui Ready Ready Preview Comment Sep 28, 2025 9:39pm

Copy link
Contributor

coderabbitai bot commented Sep 28, 2025

Walkthrough

Introduces an early hex signature validation and a Secp256k1-based recovery path in verifyTypedData, falling back to existing contract verification on failure. Expands the VerifyTypedDataParams.signature type to include ox__Signature.Signature. Adds a changeset to bump a patch version for "thirdweb" documenting 7702 account handling.

Changes

Cohort / File(s) Summary
Release / Changeset
\.changeset/cyan-windows-reply.md
Adds a patch changeset for the "thirdweb" package noting verifyTypedData handling for 7702 accounts; no code changes.
Auth verification flow
packages/thirdweb/src/auth/verify-typed-data.ts
- Early guard: return false if signature is not hex
- New Secp256k1 recovery of signer from message hash; case-insensitive address match returns true
- try/catch fallback to existing contract verification path
- Imports updated (Secp256k1); retains ox/Signature for decoding
- Type export updated: VerifyTypedDataParams.signature now accepts string | Uint8Array | ox__Signature.Signature

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant C as Caller
  participant V as verifyTypedData
  participant S as Secp256k1
  participant K as ContractVerifier

  C->>V: verifyTypedData(address, message, signature)
  alt Signature not hex
    V-->>C: false
  else Signature hex
    rect rgba(220,240,255,0.5)
    note over V,S: New: Local recovery path
    V->>S: recoverAddress(hash(message), signature)
    alt Recovery succeeds and matches (case-insensitive)
      V-->>C: true
    else Recovery fails or mismatch
      end
      note over V,K: Fallback to existing verification
      V->>K: verify via contract/signature checks
      K-->>V: result (true/false)
      V-->>C: result
    end
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description Check ⚠️ Warning The pull request description retains the commented-out template and only includes an autogenerated PR-Codex summary instead of filling in the required sections, leaving out the formatted title block, issue tag, “Notes for the reviewer,” and “How to test” sections mandated by the repository’s description template. Please remove the unused template comments and populate the description with the required sections, including the formatted title or issue tag, detailed notes for the reviewer, and clear testing instructions, to fully adhere to the repository’s description template.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The title “[SDK] Handle 7702 accounts in verifyTypedData” succinctly captures the primary change by referencing the SDK scope and the key functionality being enhanced, making it clear to reviewers what this pull request addresses. It follows the repository’s convention for prefixing with the component name and is concise and specific enough for team members scanning history to understand the main update.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch _thirdweb_Handle_7702_accounts_in_verifyTypedData

Warning

Review ran into problems

🔥 Problems

Errors were encountered while retrieving linked issues.

Errors (1)
  • TEAM-0000: Entity not found: Issue - Could not find referenced Issue.

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions bot added packages SDK Involves changes to the thirdweb SDK labels Sep 28, 2025
@joaquim-verges joaquim-verges changed the title [thirdweb] Handle 7702 accounts in verifyTypedData [SDK] Handle 7702 accounts in verifyTypedData Sep 28, 2025
Copy link
Member Author


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • merge-queue - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

Copy link
Contributor

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
thirdweb (esm) 64.69 KB (+0.95% 🔺) 1.3 s (+0.95% 🔺) 282 ms (+155.06% 🔺) 1.6 s
thirdweb (cjs) 361.52 KB (-0.04% 🔽) 7.3 s (-0.04% 🔽) 1.1 s (+7.91% 🔺) 8.4 s
thirdweb (minimal + tree-shaking) 5.73 KB (0%) 115 ms (0%) 120 ms (+1073.63% 🔺) 234 ms
thirdweb/chains (tree-shaking) 526 B (0%) 11 ms (0%) 56 ms (+1971.51% 🔺) 66 ms
thirdweb/react (minimal + tree-shaking) 19.14 KB (0%) 383 ms (0%) 105 ms (+1228.24% 🔺) 487 ms

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 2c84ac4 and b411922.

📒 Files selected for processing (2)
  • .changeset/cyan-windows-reply.md (1 hunks)
  • packages/thirdweb/src/auth/verify-typed-data.ts (2 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{ts,tsx}: Write idiomatic TypeScript with explicit function declarations and return types
Limit each file to one stateless, single-responsibility function for clarity
Re-use shared types from @/types or local types.ts barrels
Prefer type aliases over interface except for nominal shapes
Avoid any and unknown unless unavoidable; narrow generics when possible
Choose composition over inheritance; leverage utility types (Partial, Pick, etc.)
Comment only ambiguous logic; avoid restating TypeScript in prose

**/*.{ts,tsx}: Use explicit function declarations and explicit return types in TypeScript
Limit each file to one stateless, single‑responsibility function
Re‑use shared types from @/types where applicable
Prefer type aliases over interface except for nominal shapes
Avoid any and unknown unless unavoidable; narrow generics when possible
Prefer composition over inheritance; use utility types (Partial, Pick, etc.)
Lazy‑import optional features and avoid top‑level side‑effects to reduce bundle size

Files:

  • packages/thirdweb/src/auth/verify-typed-data.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (CLAUDE.md)

Load heavy dependencies inside async paths to keep initial bundle lean (lazy loading)

Files:

  • packages/thirdweb/src/auth/verify-typed-data.ts
packages/thirdweb/**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

packages/thirdweb/**/*.{ts,tsx}: Every public symbol must have comprehensive TSDoc with at least one compiling @example and a custom tag (@beta, @internal, @experimental, etc.)
Comment only ambiguous logic; avoid restating TypeScript in prose
Lazy‑load heavy dependencies inside async paths (e.g., const { jsPDF } = await import("jspdf"))

Files:

  • packages/thirdweb/src/auth/verify-typed-data.ts
.changeset/*.md

📄 CodeRabbit inference engine (AGENTS.md)

.changeset/*.md: Each change in packages/* must include a changeset for the appropriate package
Version bump rules: patch for non‑API changes; minor for new/modified public API

Files:

  • .changeset/cyan-windows-reply.md
🧠 Learnings (1)
📚 Learning: 2025-08-29T15:37:38.513Z
Learnt from: CR
PR: thirdweb-dev/js#0
File: AGENTS.md:0-0
Timestamp: 2025-08-29T15:37:38.513Z
Learning: Applies to .changeset/*.md : Version bump rules: patch for non‑API changes; minor for new/modified public API

Applied to files:

  • .changeset/cyan-windows-reply.md
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Unit Tests
  • GitHub Check: Size

Comment on lines +106 to +118
if (!isHex(signature)) {
return false;
}

try {
const recoveredAddress = ox__Secp256k1.recoverAddress({
payload: messageHash,
signature: ox__Signature.fromHex(signature),
});

if (recoveredAddress.toLowerCase() === address.toLowerCase()) {
return true;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Do not short-circuit non-hex signatures

signature is still documented and typed as string | Uint8Array | ox__Signature.Signature, but the new isHex guard returns false for the latter two cases, so previously valid Uint8Array / structured signatures now always fail verification. We need to either convert non-string signatures to hex before the guard or bypass the early return and fall back to verifyHash just like before.

One option:

- if (!isHex(signature)) {
-   return false;
- }
-
- const recoveredAddress = ox__Secp256k1.recoverAddress({
-   payload: messageHash,
-   signature: ox__Signature.fromHex(signature),
- });
+ const signatureHex =
+   typeof signature === "string"
+     ? signature
+     : ox__Signature.toHex(signature);
+
+ if (!isHex(signatureHex)) {
+   return false;
+ }
+
+ const recoveredAddress = ox__Secp256k1.recoverAddress({
+   payload: messageHash,
+   signature: ox__Signature.fromHex(signatureHex),
+ });

(Or, if toHex isn’t available, short-circuit to the legacy verifyHash path when typeof signature !== "string".) Without this, we regress valid callers.

Committable suggestion skipped: line range outside the PR's diff.

Copy link

codecov bot commented Sep 28, 2025

Codecov Report

❌ Patch coverage is 81.25000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 56.29%. Comparing base (2c84ac4) to head (b411922).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
packages/thirdweb/src/auth/verify-typed-data.ts 81.25% 3 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #8141   +/-   ##
=======================================
  Coverage   56.28%   56.29%           
=======================================
  Files         906      906           
  Lines       59192    59208   +16     
  Branches     4174     4179    +5     
=======================================
+ Hits        33316    33329   +13     
- Misses      25771    25774    +3     
  Partials      105      105           
Flag Coverage Δ
packages 56.29% <81.25%> (+<0.01%) ⬆️
Files with missing lines Coverage Δ
packages/thirdweb/src/auth/verify-typed-data.ts 93.33% <81.25%> (-6.67%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@joaquim-verges joaquim-verges merged commit 85bde21 into main Sep 28, 2025
26 of 27 checks passed
@joaquim-verges joaquim-verges deleted the _thirdweb_Handle_7702_accounts_in_verifyTypedData branch September 28, 2025 21:32
@joaquim-verges joaquim-verges mentioned this pull request Sep 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

packages SDK Involves changes to the thirdweb SDK

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant