Skip to content

Commit

Permalink
fix(clerk-js): Handle gracefully Coinbase Wallet initial configuration (
Browse files Browse the repository at this point in the history
  • Loading branch information
chanioxaris authored Sep 25, 2024
1 parent c906385 commit d7cea3f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/gold-vans-swim.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@clerk/clerk-js": patch
---

Handle gracefully Coinbase Wallet initial configuration
19 changes: 18 additions & 1 deletion packages/clerk-js/src/core/resources/SignUp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,24 @@ export class SignUp extends BaseResource implements SignUpResource {
clerkVerifyWeb3WalletCalledBeforeCreate('SignUp');
}

const signature = await generateSignature({ identifier, nonce, provider });
let signature: string;
try {
signature = await generateSignature({ identifier, nonce, provider });
} catch (err) {
// There is a chance that as a first time visitor when you try to setup and use the
// Coinbase Wallet from scratch in order to authenticate, the initial generate
// signature request to be rejected. For this reason we retry the request once more
// in order for the flow to be able to be completed successfully.
//
// error code 4001 means the user rejected the request
// Reference: https://docs.cdp.coinbase.com/wallet-sdk/docs/errors
if (provider === 'coinbase_wallet' && err.code === 4001) {
signature = await generateSignature({ identifier, nonce, provider });
} else {
throw err;
}
}

return this.attemptWeb3WalletVerification({ signature, strategy });
};

Expand Down

0 comments on commit d7cea3f

Please sign in to comment.