@@ -11,29 +11,34 @@ startAuthentication() was not called correctly
1111TypeError: base64URLString.replace is not a function
1212```
1313
14- ** Root Cause:**
15- The ` startAuthentication ` function from ` @simplewebauthn/browser ` expects base64url ** strings** , but we were passing arrays/bytes.
14+ ** Root Cause:** The ` startAuthentication ` function from
15+ ` @simplewebauthn/browser ` expects base64url ** strings** , but we were passing
16+ arrays/bytes.
1617
1718** Fix Applied:**
1819
1920``` javascript
2021// Before (WRONG):
2122const authOptions = {
22- challenge: Array .from (challenge), // ❌ Array
23- allowCredentials: [{
24- id: base64UrlToBytes (passkeyData .credentialId ), // ❌ Bytes
25- type: ' public-key' ,
26- }],
23+ challenge: Array .from (challenge), // ❌ Array
24+ allowCredentials: [
25+ {
26+ id: base64UrlToBytes (passkeyData .credentialId ), // ❌ Bytes
27+ type: " public-key" ,
28+ },
29+ ],
2730};
2831
2932// After (CORRECT):
30- const challengeBase64 = bytesToBase64Url (challenge); // Convert to base64url string
33+ const challengeBase64 = bytesToBase64Url (challenge); // Convert to base64url string
3134const authOptions = {
32- challenge: challengeBase64, // ✅ String
33- allowCredentials: [{
34- id: passkeyData .credentialId , // ✅ String (already base64url)
35- type: ' public-key' ,
36- }],
35+ challenge: challengeBase64, // ✅ String
36+ allowCredentials: [
37+ {
38+ id: passkeyData .credentialId , // ✅ String (already base64url)
39+ type: " public-key" ,
40+ },
41+ ],
3742};
3843```
3944
@@ -50,24 +55,23 @@ AbiFunctionNotFoundError: Function not found on ABI.
5055Make sure you are using the correct ABI and that the function exists on it.
5156```
5257
53- ** Root Cause:**
54- Using ` encodeFunctionData ` with ` parseAbiParameters ` is incorrect.
55- ` encodeFunctionData ` expects a full function ABI with a function name,
56- while ` parseAbiParameters ` only provides parameter types.
58+ ** Root Cause:** Using ` encodeFunctionData ` with ` parseAbiParameters ` is
59+ incorrect. ` encodeFunctionData ` expects a full function ABI with a function
60+ name, while ` parseAbiParameters ` only provides parameter types.
5761
5862** Fix Applied:**
5963
6064``` javascript
6165// Before (WRONG):
6266return encodeFunctionData ({
63- abi: parseAbiParameters (' bytes, string, uint256, uint256, bytes' ),
67+ abi: parseAbiParameters (" bytes, string, uint256, uint256, bytes" ),
6468 values: [authenticatorData, clientDataJSON, r, s, credentialId],
6569});
6670
6771// After (CORRECT):
6872return encodeAbiParameters (
69- parseAbiParameters (' bytes, string, uint256, uint256, bytes' ),
70- [authenticatorData, clientDataJSON, r, s, credentialId]
73+ parseAbiParameters (" bytes, string, uint256, uint256, bytes" ),
74+ [authenticatorData, clientDataJSON, r, s, credentialId],
7175);
7276```
7377
@@ -87,7 +91,8 @@ Changes made:
8791
88921 . Convert challenge to base64url string before passing to ` startAuthentication `
89932 . Use original base64url credential ID string (not bytes)
90- 3 . Replace ` encodeFunctionData ` with ` encodeAbiParameters ` for signature encoding
94+ 3 . Replace ` encodeFunctionData ` with ` encodeAbiParameters ` for signature
95+ encoding
9196
9297``` javascript
9398async function signWithPasskey (hash ) {
@@ -97,12 +102,14 @@ async function signWithPasskey(hash) {
97102 const challengeBase64 = bytesToBase64Url (challenge);
98103
99104 const authOptions = {
100- challenge: challengeBase64, // ✅ String format
101- allowCredentials: [{
102- id: passkeyData .credentialId , // ✅ String format
103- type: ' public-key' ,
104- }],
105- userVerification: ' preferred' ,
105+ challenge: challengeBase64, // ✅ String format
106+ allowCredentials: [
107+ {
108+ id: passkeyData .credentialId , // ✅ String format
109+ type: " public-key" ,
110+ },
111+ ],
112+ userVerification: " preferred" ,
106113 timeout: 60000 ,
107114 };
108115
@@ -112,8 +119,8 @@ async function signWithPasskey(hash) {
112119
113120 // ✅ FIX 2: Use encodeAbiParameters instead of encodeFunctionData
114121 return encodeAbiParameters (
115- parseAbiParameters (' bytes, string, uint256, uint256, bytes' ),
116- [authenticatorDataHex, clientDataJSONString, r, s, credentialIdHex]
122+ parseAbiParameters (" bytes, string, uint256, uint256, bytes" ),
123+ [authenticatorDataHex, clientDataJSONString, r, s, credentialIdHex],
117124 );
118125}
119126```
@@ -160,11 +167,13 @@ return keccak256(packed);
160167### When to Use Each Encoding Function
161168
1621691 . ** ` encodeFunctionData ` **
170+
163171 - Use for: Encoding function calls with function name
164172 - Requires: Full function ABI with ` name ` , ` inputs ` , ` outputs `
165173 - Example: ` execute(address to, uint256 value, bytes data) `
166174
1671752 . ** ` encodeAbiParameters ` **
176+
168177 - Use for: Encoding raw parameters without function name
169178 - Requires: Only parameter types via ` parseAbiParameters `
170179 - Example: Encoding struct data, signature data, or raw parameters
@@ -241,14 +250,15 @@ Do not convert these to arrays or bytes - keep them as base64url strings!
241250
242251### Why These Errors Occurred
243252
244- 1 . ** API Expectations Mismatch** : The ` @simplewebauthn/browser ` library has specific format requirements
245- that weren't immediately obvious from the documentation.
253+ 1 . ** API Expectations Mismatch** : The ` @simplewebauthn/browser ` library has
254+ specific format requirements that weren't immediately obvious from the
255+ documentation.
246256
247- 2 . ** Function Naming Confusion** : ` encodeFunctionData ` and ` encodeAbiParameters ` sound similar
248- but have different purposes and requirements.
257+ 2 . ** Function Naming Confusion** : ` encodeFunctionData ` and ` encodeAbiParameters `
258+ sound similar but have different purposes and requirements.
249259
2502603 . ** Type Conversion** : JavaScript's flexibility with types (strings, arrays,
251- Uint8Arrays) can lead to passing the wrong type without compile-time errors.
261+ Uint8Arrays) can lead to passing the wrong type without compile-time errors.
252262
253263### Prevention
254264
@@ -270,12 +280,12 @@ Bundler error: EntryPoint 0x0000000071727De22E5E9d8BAf0edAc6f37da032 not support
270280supported EntryPoints: 0x4337084D9E255Ff0702461CF8895CE9E3b5Ff108
271281```
272282
273- ** Root Cause:**
274- The ZKsync SSO bundler uses a custom EntryPoint contract at ` 0x4337084D9E255Ff0702461CF8895CE9E3b5Ff108 ` instead of the
275- standard ERC-4337 v0.7 EntryPoint.
283+ ** Root Cause:** The ZKsync SSO bundler uses a custom EntryPoint contract at
284+ ` 0x4337084D9E255Ff0702461CF8895CE9E3b5Ff108 ` instead of the standard ERC-4337
285+ v0.7 EntryPoint.
276286
277- ** Fix Applied:**
278- Updated the EntryPoint address to match the bundler's supported address:
287+ ** Fix Applied:** Updated the EntryPoint address to match the bundler's supported
288+ address:
279289
280290``` javascript
281291// Before:
0 commit comments